use Order\CheckForCrystal.dg Use dfClient.pkg Use DataDict.pkg Use dfEntry.pkg Use dfSpnEnt.pkg Use dfCEntry.pkg Use dfTable.pkg Use Windows.pkg Use cCrystal.pkg Use Vendor.DD Use Invt.DD Use Customer.DD Use SalesP.DD Use OrderHea.DD Use OrderDtl.DD Use cDbCJGrid.pkg Use cCJGridColumnRowIndicator.pkg Use cSigCjChartControl.pkg Use Order\Vendor.vw Struct tdVendorInfo Integer iId String sName Integer iCount End_Struct Activate_View Activate_oChartOrderEntryView for oChartOrderEntryView Object oChartOrderEntryView is a dbView Set Border_Style to Border_Thick Set Maximize_Icon to True Set Label to "Order Entry (Chart)" Set Location to 2 3 Set Size to 174 629 Set piMinSize to 174 629 Set pbAutoActivate to True Object Vendor_DD is a Vendor_DataDictionary End_Object // Vendor_DD Object Invt_DD is a Invt_DataDictionary Set DDO_Server to Vendor_DD End_Object // Invt_DD Object Customer_DD is a Customer_DataDictionary End_Object // Customer_DD Object SalesP_DD is a Salesp_DataDictionary End_Object // SalesP_DD Object OrderHea_DD is a OrderHea_DataDictionary Set DDO_Server to Customer_DD Set DDO_Server to SalesP_DD // this lets you save a new OrderHea from within OrderDtl. Set Allow_Foreign_New_Save_State to True End_Object // OrderHea_DD Object OrderDtl_DD is a OrderDtl_DataDictionary Set DDO_Server to OrderHea_DD Set DDO_Server to Invt_DD Set Constrain_File to OrderHea.File_Number End_Object // OrderDtl_DD Set Main_DD to OrderHea_DD Set Server to OrderHea_DD Object oDbContainer3d1 is a dbContainer3d Set Size to 85 410 Set Location to 2 3 Set peAnchors to anTopLeft Object oOrderHea_Order_Number is a dbForm Entry_Item OrderHea.Order_Number Set Label to "Order Number:" Set Size to 13 42 Set Location to 4 63 Set peAnchors to anTopLeft Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right End_Object // oOrderHea_Order_Number Object oOrderHea_Customer_Number is a dbForm Entry_Item Customer.Customer_Number Set Label to "Customer Number:" Set Size to 13 42 Set Location to 4 234 Set peAnchors to anTopRight Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right End_Object // oOrderHea_Customer_Number Object oOrderHea_Order_Date is a dbSpinForm Entry_Item OrderHea.Order_Date Set Label to "Order Date:" Set Size to 13 67 Set Location to 4 332 Set peAnchors to anTopRight Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right End_Object // oOrderHea_Order_Date Object oCustomer_Name is a dbForm Entry_Item Customer.Name Set Label to "Customer Name:" Set Size to 13 213 Set Location to 18 63 Set peAnchors to anTopLeftRight Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right End_Object // oCustomer_Name Object oCustomer_Address is a dbForm Entry_Item Customer.Address Set Label to "Street Address:" Set Size to 13 213 Set Location to 34 63 Set peAnchors to anTopLeftRight Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right End_Object // oCustomer_Address Object oCustomer_City is a dbForm Entry_Item Customer.City Set Label to "City/State/Zip:" Set Size to 13 117 Set Location to 49 63 Set peAnchors to anTopLeftRight Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right End_Object // oCustomer_City Object oCustomer_State is a dbForm Entry_Item Customer.State Set Size to 13 20 Set Location to 49 188 Set peAnchors to anTopRight End_Object // oCustomer_State Object oCustomer_Zip is a dbForm Entry_Item Customer.Zip Set Size to 13 60 Set Location to 49 216 Set peAnchors to anTopRight End_Object // oCustomer_Zip Object oOrderHea_Ordered_By is a dbForm Entry_Item OrderHea.Ordered_By Set Label to "Ordered By:" Set Size to 13 67 Set Location to 34 332 Set peAnchors to anTopRight Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right End_Object // oOrderHea_Ordered_By Object oOrderHea_Salesperson_ID is a dbForm Entry_Item Salesp.Id Set Label to "Salesperson ID:" Set Size to 13 40 Set Location to 49 332 Set peAnchors to anTopRight Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right End_Object // oOrderHea_Salesperson_ID Object oOrderHea_Terms is a dbComboForm Entry_Item OrderHea.Terms Set Label to "Terms:" Set Size to 13 85 Set Location to 64 63 Set peAnchors to anTopLeft Set Form_Border to 0 Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right End_Object // oOrderHea_Terms Object oOrderHea_Ship_Via is a dbComboForm Entry_Item OrderHea.Ship_Via Set Label to "Ship Via:" Set Size to 13 103 Set Location to 64 216 Set peAnchors to anTopRight Set Form_Border to 0 Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right End_Object // oOrderHea_Ship_Via End_Object // oDbContainer3d1 Object oOrderDtl_Grid is a cDbCJGrid Set Server to OrderDtl_DD Set Ordering to 1 Set Size to 63 410 Set Location to 90 3 Set peAnchors to anTopBottomLeft Set pbAllowInsertRow to False Set pbRestoreLayout to False Set psLayoutSection to "OrderView_oOrderDtl_Grid2" Set piLayoutBuild to 6 Set pbHeaderPrompts to True Set peHorizontalGridStyle to xtpGridNoLines On_Key Key_F11 Send Request_InsertRow Object oMark is a cCJGridColumnRowIndicator Set piWidth to 21 End_Object Object oInvt_Item_ID is a cDbCJGridColumn Entry_Item Invt.Item_ID Set piWidth to 98 Set psCaption to "Item ID" Set psImage to "ActionPrompt.ico" End_Object Object oInvt_Description is a cDbCJGridColumn Entry_Item Invt.Description Set piWidth to 230 Set psCaption to "Description" End_Object Object oInvt_Unit_Price is a cDbCJGridColumn Entry_Item Invt.Unit_Price Set piWidth to 57 Set psCaption to "Unit Price" End_Object Object oOrderDtl_Qty_Ordered is a cDbCJGridColumn Entry_Item OrderDtl.Qty_Ordered Set piWidth to 54 Set psCaption to "Quantity" End_Object Object oOrderDtl_Price is a cDbCJGridColumn Entry_Item OrderDtl.Price Set piWidth to 67 Set psCaption to "Price" End_Object Object oOrderDtl_Extended_Price is a cDbCJGridColumn Entry_Item OrderDtl.Extended_Price Set piWidth to 88 Set psCaption to "Total" End_Object End_Object // oOrderDtl_Grid Object oOrderHea_Order_Total is a dbForm Entry_Item OrderHea.Order_Total Set Label to "Order Total:" Set Size to 13 60 Set Location to 156 340 Set peAnchors to anBottom Set Label_Col_Offset to 3 Set Label_Justification_Mode to jMode_Right Procedure OnChange Send ReLoadAllSeriesPoints of (oVendorChart(oChartOrderEntryView(Self))) End_Procedure End_Object // oOrderHea_Order_Total Object oPrintBtn is a Button Set Label to "Print Order" Set Location to 156 3 Set peAnchors to anBottomLeft Set psToolTip to "Print preview of current order" Procedure OnClick Delegate Send PrintCurrentOrder // defined in view object End_Procedure // OnClick End_Object // oPrintBtn Object oOrder_Report is a cCrystal Set psReportName to "Orders.rpt" Property Integer piOrderNumber 0 // Procedure : OnInitializeReport // Purpose : This is a hook message sent by the Open_report procedure. You may use this // procedure to set selection values, print options, etc. This procedure is // intended for augmentation; it has no action by default. Procedure OnInitializeReport Handle hoReport Integer iOrder String sSelection Handle hoTerms hoShipVia Variant[][2] vTerms Variant[][2] vShipVia Forward Send OnInitializeReport hoReport Get CreateCDO of hoReport "Terms.ttx" to hoTerms If (hoTerms) Begin Get TableData of Terms_table to vTerms Send AppendCDOData of hoReport hoTerms vTerms End Get CreateCDO of hoReport "ShipVia.ttx" to hoShipVia If (hoShipVia) Begin Get TableData of Ship_Table to vShipVia Send AppendCDOData of hoReport hoShipVia vShipVia End Get piOrderNumber to iOrder // Set the selection formula to print the one order. Move ("{OrderHea.Order_Number} = " + String(iOrder)) to sSelection Set ComRecordSelectionFormula of hoReport to sSelection End_Procedure // OnInitializeReport // pass order to print Procedure PrintOrder Integer iNum Boolean bCrystalOK Set piOrderNumber to iNum // check for Crystal Get CheckCrystalEnvironment of oCheckForCrystal to bCrystalOK If (bCrystalOK) Begin Send RunReport End Else Begin Send DisplayDialog of oCheckForCrystal End End_Procedure End_Object // oOrder_Report // Change: Create custom confirmation messages for save and delete // We must create the new functions and assign verify messages // to them. Function Confirm_Delete_Order Returns Integer Integer iRetVal Get Confirm "Delete Entire Order?" to iRetVal Function_Return iRetVal End_Function // Only confirm on the saving of new records Function Confirm_Save_Order Returns Integer Integer iNoSave iSrvr Boolean bOld Get Server to iSrvr Get HasRecord of iSrvr to bOld If not bOld Begin Get Confirm "Save this NEW order header?" to iNoSave End Function_Return iNoSave End_Function // Define alternate confirmation Messages Set Verify_Save_MSG to (RefFunc(Confirm_Save_Order)) Set Verify_Delete_MSG to (RefFunc(Confirm_Delete_Order)) Set Auto_Clear_DEO_State to False // don't clear Header on save Object oVendorChart is a cSigCJChart Set Size to 167 212 Set Location to 3 415 Set peAnchors to anAll Set pbLegendVisible to False Set psTitleText to "Order total by Vendor" Set pnTitleFontSize to 11 Set psPalette to "Photodesign" // a Palette of colors a series can choose from. Object oVendorDiagram is a cSigCjDiagram Object oVendorSeries is a cSigCjSeries Set peSeriesStyle to xtpPieSeriesStyle Set pbColorEach to True // when true a different color will be chosen for each seperate series point. Set piHolePercent to 25 // the percentage size of the pie which will appear as a hole in the middle. Set pbLabelFormatUseThousandSeparator to True Set peLabelFormatCategory to xtpChartCurrency Procedure OnAddChartData Integer iSize iLoop tdVendorInfo[] taVendorInfo Get RelevantVendors to taVendorInfo Move (SizeOfArray(taVendorInfo)) to iSize For iLoop from 0 to (iSize-1) Send AddPoint taVendorInfo[iLoop].sName taVendorInfo[iLoop].iId taVendorInfo[iLoop].iCount Loop End_Procedure End_Object End_Object Procedure OnPointDblClick Short llButton Short llShift Integer iSeriesIndex Integer iPointIndex Handle hoPoint Integer iVendorId Handle hoDD Get ComArgumentValueString of hoPoint to iVendorId // retrieve the X-Axis value of the selected point object Send Activate_oVendorView Move (Vendor_DD(oVendorView(Self))) to hoDD Send Clear of hoDD Move iVendorId to Vendor.ID Send Request_Find of hoDD Eq Vendor.File_Number 1 End_Procedure End_Object // Custom comparison function: // Returns (GT) if struct value in first parameter > struct value in second parameter. // Returns (LT) if struct value in first parameter < struct value in second parameter. // Otherwise returns (EQ). Function CompareVendor tdVendorInfo tVendorInfo tdVendorInfo tComparison Returns Integer If (tVendorInfo.iId > tComparison.iId) ; Function_Return (GT) If (tVendorInfo.iId < tComparison.iId) ; Function_Return (LT) Function_Return (EQ) End_Function Function RelevantVendors Returns tdVendorInfo[] Integer iId iIndex iSize iAmount iOrder tdVendorInfo[] taVendorInfo tdVendorInfo tSearchVendor Get Field_Current_Value of (Server(Self)) Field OrderHea.Order_Number to iOrder Clear OrderDtl Move iOrder to OrderDtl.Order_Number Find Gt OrderDtl by Index.1 While ((Found) and (OrderDtl.Order_Number=iOrder)) Relate OrderDtl Move Vendor.ID to iId Move iId to tSearchVendor.iId Move (SearchArray(tSearchVendor,taVendorInfo,Self,(RefFunc(CompareVendor)))) to iIndex If (iIndex<>-1) Begin Move OrderDtl.Extended_Price to iAmount Move (taVendorInfo[iIndex].iCount+iAmount) to taVendorInfo[iIndex].iCount End Else Begin Move (SizeOfArray(taVendorInfo)) to iSize Move iId to taVendorInfo[iSize].iId Move (Trim(Vendor.Name)) to taVendorInfo[iSize].sName Move OrderDtl.Extended_Price to taVendorInfo[iSize].iCount End Find Gt OrderDtl by Index.1 Loop Send Refind_Records of OrderDtl_DD Function_Return taVendorInfo End_Function // print the current order. This message will be sent // by the print button Procedure PrintCurrentOrder Integer hDD iNum Get Server to hDD // this will be the OrderHea DD If (HasRecord(hDD)) Begin // only do this if record exists Get Field_Current_Value of hDD Field OrderHea.Order_Number to iNum Send PrintOrder of oOrder_Report iNum End End_Procedure // refresh is sent to containers. We will use that to control the print button and only // enable it when an order exists Procedure Refresh Integer eMode Boolean bRec Handle hoServer Get Server to hoServer Get HasRecord of hoServer to bRec Set Enabled_State of oPrintBtn to bRec End_Procedure End_Object