Use Crystal\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 Deferred_View Activate_oOrderEntryViewAUXINSA for ; Object oOrderEntryViewAUXINSA is a dbView Set Border_Style to Border_Thick Set Maximize_Icon to True Set Label to "Order Entry" Set Location to 2 3 Set Size to 193 387 Set piMinSize to 193 387 Set Color to 13303807 Object Vendor_DD is a Vendor_DataDictionary End_Object // Vendor_DD Object Invt_DD is a Invt_DataDictionary Set DDO_Server to Vendor_DD Function Prueba Returns Integer Handle hoDD Boolean bhasrecord String sAux Get field_current_value of Self Field invt.Item_ID to sAux If (saux contains "A") Begin Send info_box "No permito pedidos con 'A' en codigo" "Error" Function_Return -1 End Function_Return 0 End_Function Set Field_Exit_msg Field invt.Item_ID to get_prueba 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 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 377 Set Location to 2 3 Set peAnchors to anTopLeftRight Set Color to 13303807 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 // We want to disable the print button if there is no // current record. The DD notifies all DEOs of any record // change. We can augment any DEO's refresh message to see // if a current record exists and set the enabled_state of // print button accordingly. Procedure Refresh Integer iMode Boolean bHasRecord Handle hoDD Forward Send Refresh iMode // if record exists, enable the print button. Get server to hoDD Get HasRecord of hoDD to bHasRecord Set Enabled_State of oPrintBtn to bHasRecord End_Procedure // Refresh 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 201 Set peAnchors to anTopRight Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right // If order record exists, disallow entry in customer window. Procedure Refresh Integer iMode Handle hoSrvr Boolean bCrnt Get Server to hoSrvr // get the data_set Get HasRecord of hoSrvr to bCrnt // has record in data_set // Set displayonly to true if iCrnt is non-zero Set Enabled_State to (not(bCrnt)) Forward Send Refresh iMode // do normal refrsh // don't leave us sitting on a displayonly window If (bCrnt and Focus(Self)=Self) Send Next End_Procedure // Refresh 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 299 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 180 Set Location to 18 63 Set peAnchors to anTopLeftRight Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right Set Prompt_Button_Mode to pb_PromptOff // We want this to be a displayonly field Set Enabled_State to False End_Object // oCustomer_Name Object oCustomer_Address is a dbForm Entry_Item Customer.Address Set Label to "Street Address:" Set Size to 13 180 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 84 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 155 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 183 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 299 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 299 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 Set Entry_State to False 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 183 Set peAnchors to anTopRight Set Form_Border to 0 Set Label_Col_Offset to 2 Set Label_Justification_Mode to jMode_Right Set Entry_State to False Procedure Switch // the normal switch behavior is to attempt to keep // keep looking for additional objects to switch to if. If // we can't switch to the dtl table, we want to stop! So just // do a simple activate. Send Activate of oOrderDtl_Grid End_Procedure // Switch End_Object // oOrderHea_Ship_Via End_Object // oDbContainer3d1 Object oOrderDtl_Grid is a dbGrid Set Size to 63 377 Set Location to 90 3 Begin_Row Entry_Item Invt.Item_id Entry_Item Invt.Description Entry_Item Invt.Unit_Price Entry_Item OrderDtl.Price Entry_Item OrderDtl.Qty_Ordered Entry_Item OrderDtl.Extended_Price End_Row Set Main_File to OrderDtl.File_Number Set Server to OrderDtl_DD Set Form_Width 0 to 55 Set Header_Label 0 to "Item ID" Set Form_Width 1 to 119 Set Header_Label 1 to "Description" Set Form_Width 2 to 55 Set Header_Label 2 to "Unit Price" Set Form_Width 3 to 43 Set Header_Label 3 to "Price" Set Form_Width 4 to 43 Set Header_Label 4 to "Quantity" Set Form_Width 5 to 55 Set Header_Label 5 to "Total" Set Column_Button 4 to Form_Button_Spin // make qty column spinner Set Column_Minimum_Position 4 to 0 // with range of 0 to 999 Set Column_Maximum_Position 4 to 999 // Change: Table entry checking. // Set child_table_state to true which will // cause table to save when exiting and // attempt to save header when entering. Set Child_Table_State to True // Saves when exit object Set Ordering to 1 Set peAnchors to anAll Set peResizeColumn to rcAll Set Wrap_State to True Set pbEmbeddedPrompts to True // Called when entering the table. Check with the header if it // has a valid saved record. If not, disallow entry. Function Child_Entering Returns Integer Integer iRetVal // Check with header to see if it is saved. Delegate Get Save_Header to iRetVal Function_Return iRetVal // if non-zero do not enter End_Function // Child_Entering // Change: Assign insert-row key append a row // Create new behavior to support append a row // Optimize the table refresh Set Allow_Insert_Add_State to False On_Key kAdd_Mode Send Append_a_Row // Hot Key for KAdd_Mode = Shift+F10 // Add new record to the end of the table. Procedure Append_a_Row // Q: how would a keyboard do this? Send End_Of_Data // A: Go to end of table and Send Down // down 1 line to empty line End_Procedure // Append_a_Row // The way this table is set up, items can never be added out // of order. New items are always added to the end of the table. // By setting Auto_Regenerate_State to false we are telling the // table to never bother reordering after adding records. This is // a minor optimization. Set Auto_Regenerate_State to False // table is always in order. 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 307 Set peAnchors to anBottomRight Set Label_Col_Offset to 3 Set Label_Justification_Mode to jMode_Right End_Object // oOrderHea_Order_Total Object oPrintBtn is a Button Set Label to "Print Order" Set Location to 156 3 Set peAnchors to anBottomLeft 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 ; Get Confirm "Save this NEW order header?" to iNoSave Function_Return iNoSave End_Function // Define alternate confirmation Messages Set Verify_Save_MSG to GET_Confirm_save_order Set Verify_Delete_MSG to GET_Confirm_delete_order // Change: Table entry checking - attempt to save header record // before entering a table (this is called by table. Return // a non-zero if the save failed (i.e., don't enter table) Function Save_Header Returns Integer Boolean bHasRec bChanged Handle hoSrvr Get Server to hoSrvr // The Header DDO. Get HasRecord of hoSrvr to bHasRec // Do we have a record? Get Should_Save to bChanged // Are there any current changes? // If there is no record and no changes we have an error. If ( not(bHasRec) and not(bChanged) ) Begin // no rec Error DfErr_Operator 'You must First Create & Save Main Order Header' Function_Return 1 End // Attempt to Save the current Record // request_save_no_clear does a save without clearing. Send Request_Save_No_Clear // The save succeeded if there are now no changes, and we // have a saved record. Should_save tells us if we've got changes. // We must check the data-sets hasRecord property to see if // we have a record. If it is not, we had no save. Get Should_Save to bChanged // is a save still needed Get HasRecord of hoSrvr to bHasRec // current record of the DD // if no record or changes still exist, return an error code of 1 If ( not(bHasRec) or (bChanged)) ; Function_Return 1 End_Function // Save_Header // 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 Cd_End_Object