Use Windows.pkg Use DFClient.pkg Use cGraphicDataDictionary.dd Use dfTable.pkg Use cComWebBrowser.pkg Use dfLine.pkg Use DfCentry.pkg Use dfTable.pkg Use Flexml.pkg Use for_all.pkg Open VENDOR Open INVT Open Customer Deferred_View Activate_oSalesGraphic for ; Object oSalesGraphic is a dbView Object oGraphic_DD is a cGraphicDataDictionary Procedure OnConstrain Constrain Graphic.Value ne 0 End_Procedure End_Object Set Main_DD to oGraphic_DD Set Server to oGraphic_DD Set Border_Style to Border_Normal Set Size to 331 672 Set Location to 2 2 Set Label to "Chart" Object oFileSel is a RadioGroup Set Size to 50 124 Set Location to 278 10 Set Label to "Select Data file" Object oRadio1 is a Radio Set Label to "Vendor" Set Size to 10 38 Set Location to 12 6 Set Status_Help to "Vendor Data File" End_Object // oRadio1 Object oRadio2 is a Radio Set Label to "Customer" Set Size to 10 42 Set Location to 24 6 Set Status_Help to "Customer Data File" End_Object // oRadio2 Object oRadio3 is a Radio Set Label to "Item" Set Size to 10 37 Set Location to 13 67 Set Status_Help to "Item Data File" End_Object // oRadio3 Function IsDF Returns Boolean Integer iRadio Get Current_radio to iRadio Function_Return iRadio End_Function // IsToPrinter End_Object // oFileSel Object oSalesPur is a RadioGroup Set Size to 50 72 Set Location to 278 137 Set Label to "Select Data Group" Object oRadio1 is a Radio Set Label to "Sales" Set Size to 10 61 Set Location to 12 6 Set Status_Help to "Total Sales" End_Object // oRadio1 Object oRadio2 is a Radio Set Label to "Purchase" Set Size to 10 42 Set Location to 24 6 Set Status_Help to "Total Purchase" End_Object // oRadio2 Function IsPS Returns Boolean Integer iRadio Get Current_radio to iRadio Function_Return (iRadio=1) End_Function // End_Object // oSalesPur Object oGraphType is a RadioGroup Set Size to 50 72 Set Location to 278 212 Set Label to "Select Chart Type" Object oRadio1 is a Radio Set Label to "Pie" Set Size to 10 61 Set Location to 12 7 Set Status_Help to "Pie Chart" End_Object // oRadio1 Object oRadio2 is a Radio Set Label to "Line" Set Size to 10 42 Set Location to 24 7 Set Status_Help to "Line Chart" End_Object // oRadio2 Object oRadio3 is a Radio Set Label to "Bar" Set Size to 10 42 Set Location to 36 7 Set Status_Help to "Bar Chart" End_Object // oRadio2 Function IsPLB Returns Boolean Integer iRadio Get Current_radio to iRadio Function_Return iRadio End_Function // End_Object // oGraphType Object oGraphMode is a RadioGroup Set Size to 50 72 Set Location to 278 289 Set Label to "Select Chart Mode" Object oRadio1 is a Radio Set Label to "2D" Set Size to 10 61 Set Location to 12 7 Set Status_Help to "2 Dimention" End_Object // oRadio1 Object oRadio2 is a Radio Set Label to "3D" Set Size to 10 42 Set Location to 24 7 Set Status_Help to "3 Dimention" End_Object // oRadio2 Function Is23D Returns Boolean Integer iRadio Get Current_radio to iRadio Function_Return iRadio End_Function // End_Object // oGraphMode Object oF20 is a Group Set Size to 50 72 Set Location to 278 365 Set Label to "Limit Records" Object oF20R is a CheckBox Set Size to 10 50 Set Location to 20 10 Set Label to "Top 20" //Fires whenever the value of the control is changed //Procedure OnChange // Boolean bChecked // // Get Checked_State To bChecked //End_Procedure End_Object End_Object Object oDisplayG is a dbGrid Set Size to 264 202 Set Location to 12 7 Set Ordering to 1 Begin_Row Entry_Item Graphic.No Entry_Item Graphic.Description Entry_Item Graphic.Value End_Row Set Main_File to Graphic.File_number Set Form_Width 0 to 30 Set Header_Label 0 to "Code" Set Form_Width 1 to 115 Set Header_Label 1 to "Description" Set Form_Width 2 to 43 Set Header_Label 2 to "Value" End_Object Object oComWebBrowser1 is a cComWebBrowser Set Size to 264 455 Set Location to 12 211 Procedure OnCreate Forward Send OnCreate // ToDo: Set the ActiveX properties here... End_Procedure // OnCreate End_Object Object oDrawPie is a Button Set Size to 14 60 Set Label to "Draw Chart" Set Location to 282 605 Set peAnchors to anTopRight // Display the sample help HTML file Procedure OnClick Send PrepareData Send Beginning_of_Data of oDisplayG //refresh grid End_Procedure // OnClick End_Object Procedure PrepareData Integer IFileNo ISalesPurch GType GMode Recs String Gpara d23 Boolean top20 //0-Vendor 1-Customer 2-invt Get IsDF of oFileSel to IFileNo //0- sales 1- purchase Get IsPS of oSalesPur to ISalesPurch //0-pie 1-line 2-bar GType Get IsPLB of oGraphType to GType //0- 2d 1- 3d Get Is23D of oGraphMode to GMode //top20 Get Checked_State of oF20R to top20 //Pie2D Pie3d Line2D column2d column3d If GType eq 0 Move "Pie" to Gpara If GType eq 1 Move "Line" to Gpara If GType eq 2 Move "Column" to Gpara If GMode eq 0 Move "2D" to d23 Else Move "3D" to d23 If Gpara eq "Line" Begin Move (Gpara+"2D") to Gpara End Else Begin Move (Gpara+d23) to Gpara End ZeroFile Graphic If IFileNo eq 0 Begin //vendor If ISalesPurch eq 0 Begin //sales Move 0 to Recs For_All VENDOR down Index.3 Constrain VENDOR.TotalSales ne 0 do Add 1 to Recs If top20 Begin If (Recs > 20) Move False to Continue End Clear Graphic Move VENDOR.ID to Graphic.No Move (Trim(VENDOR.NAME)) to Graphic.Description Move VENDOR.TotalSales to Graphic.Value SaveRecord Graphic End_For_All End Else Begin //purchase Move 0 to Recs For_All VENDOR down Index.4 Constrain VENDOR.TotalPurch ne 0 do Add 1 to Recs If top20 Begin If (Recs > 20) Move False to Continue End Clear Graphic Move VENDOR.ID to Graphic.No Move (Trim(VENDOR.Name)) to Graphic.Description Move VENDOR.TotalPurch to Graphic.Value SaveRecord Graphic End_For_All End End If IFileNo eq 1 Begin //Customer If ISalesPurch eq 0 Begin //sales Move 0 to Recs For_All Customer down Index.4 Constrain Customer.Purchases ne 0 do Add 1 to Recs If top20 Begin If (Recs > 20) Move False to Continue End Clear Graphic Move Customer.Customer_Number to Graphic.No Move (Trim(Customer.Name)) to Graphic.Description Move Customer.Purchases to Graphic.Value SaveRecord Graphic End_For_All End Else Begin Send UserError "Not Available" "Customer Purchace" Function_Return 1 End End If IFileNo eq 2 Begin //invt If ISalesPurch eq 0 Begin //sales Move 0 to Recs For_All Invt down Index.4 Constrain invt.TotalSales ne 0 do Add 1 to Recs If top20 Begin If (Recs > 20) Move False to Continue End Clear Graphic Move INVT.Item_ID to Graphic.No Move (Trim(INVT.DESCRIPTION)) to Graphic.Description Move INVT.TotalSales to Graphic.Value SaveRecord Graphic End_For_All End Else Begin //purchase Send UserError "Not Available" "Item Purchace" Function_Return 1 End End Send GenGraphData (Gpara+".xml") //generate xml file Send Navigate (Gpara+".html") // and navigate to it. End_Procedure Object oBPrint is a Button Set Size to 14 60 Set Location to 298 605 Set Label to "Print" // fires when the button is clicked Procedure OnClick Send MyPrintView End_Procedure End_Object Procedure Navigate String SFileType String sURL String sHome String sDataPath Get psHome of (phoWorkspace(ghoApplication)) to sHome Move (sHome+"Graphics\Gallery\"+SFileType) to sURL Send ComNavigate of oComWebBrowser1 sURL 0 0 0 0 End_Procedure Procedure GenGraphData String SFileType Integer bTest iRegistro Handle hoRoot hoXML String sDataPath sPath String sQuery sValue1 sValue2 sValue3 Handle hoTable hoOtro String sTitle sSubTitle sAxisX sAxisY Integer IFileNo ISalesPurch String sDataFile sType //0-Vendor 1-Customer 2-invt 3-accdep Get IsDF of oFileSel to IFileNo If IFileNo eq 0 Move "Vendor" to sDataFile If IFileNo eq 1 Move "Customer" to sDataFile If IFileNo eq 2 Move "Items" to sDataFile //0- sales 1- purchase Get IsPS of oSalesPur to ISalesPurch If ISalesPurch eq 0 Move "sales" to stype Else Move "Purchase" to sType Move (sDataFile*stype*"Chart") to sTitle Move "Amount" to sSubTitle Get psHome of (phoWorkspace(ghoApplication)) to sPath Move (sPath+"Graphics\Gallery\Data\"+SFileType) to sPath Move (sDataFile*"No.") to sAxisX Move "Sales Year" to sAxisY EraseFile sPath Get Create U_cXMLDOMDocument to hoXML Set psDocumentName of hoXML to sPath Get LoadXMLDocument of hoXML to bTest // get documentElement. If it exists we are editing an xml file. If // it does not exist, its a new file, create the doc element node Get DocumentElement of hoXML to hoRoot If not hoRoot Begin Get CreateDocumentElement of hoXML "Graph" to hoRoot Send AddAttribute of hoRoot "Caption" sTitle Send AddAttribute of hoRoot "Subcaption" sSubTitle Send AddAttribute of hoRoot "xAxisName" sAxisX Send AddAttribute of hoRoot "yAxisName" sAxisY Send AddAttribute of hoRoot "DecimalPrecision" "0" End Open Graphic Clear Graphic Find ge Graphic by Index.1 For_All Graphic by Index.1 //Constrain Graphic.VINDOR_CODE lt 21 // first 20 customer Constrain Graphic.Value ne 0 do Move Graphic.No to sValue1 //axis X Move Graphic.Value to sValue2 //axis Y Move Graphic.Description to sValue3 Move ("set[@name='" + sValue1 + "']") to sQuery Get FindNode of hoRoot sQuery to hoTable // see such a node exists // If a node is returned, it exists. Ask what to do. If hoTable Begin Get RemoveNode of hoRoot hoTable to hoTable Send destroy of hoTable // continue on writing the table End Get AddElement of hoRoot "set" sValue1 to hoOtro Send AddAttribute of hoOtro "Name" sValue1 Send AddAttribute of hoOtro "Value" sValue2 Send AddAttribute of hoOtro "hoverText" sValue3 End_For_All Send Destroy of hoRoot // root node no longer needed // Save the XML file Get SaveXMLDocument of hoXML to bTest Send Destroy of hoXML // XML document no longer needed End_Procedure On_Key Key_Ctrl+Key_P Send MyPrintView Procedure MyPrintView Integer hoSelf Move Self to hoSelf Send Print_Screen to hoSelf End_Procedure // MyPrintView Cd_End_Object