//AB/ Project Customer Selection Report //AB/ Object prj is a Report_Project //AB/ Set ProjectName to "Customer Selection Report" //AB/ Set ProjectFileName to "CustSelReport.RV" //AB/ Set GenerateFileName to "NONAME" // Project Object Structure // oCustomerSelection_Report is a dbReportView // Customer_From_DD is a Customer_DataDictionary // Customer_To_DD is a Customer_DataDictionary // Vendor_DD is a DataDictionary // Invt_DD is a DataDictionary // Customer_DD is a DataDictionary // Salesp_DD is a DataDictionary // Orderhea_DD is a DataDictionary // Orderdtl_DD is a DataDictionary // oCustomer_From is a dbForm // oCustomer_To is a dbForm // oComment_tb is a Textbox // oOk_bn is a Button // oCancel_bn is a Button // oReport is a ReportView // Cust_Order_Listing is a WinReport // Order_listing is a WinReport // Order_Dtl is a WinReport // Register all objects Register_Object Cust_Order_Listing Register_Object Customer_DD Register_Object Customer_From_DD Register_Object Customer_To_DD Register_Object Invt_DD Register_Object Order_Dtl Register_Object Order_listing Register_Object Orderdtl_DD Register_Object Orderhea_DD Register_Object oCancel_bn Register_Object oComment_tb Register_Object oCustomer_From Register_Object oCustomer_To Register_Object oCustomerSelection_Report Register_Object oOk_bn Register_Object oReport Register_Object Salesp_DD Register_Object Vendor_DD //AB/ Report View //AB-IgnoreStart Use dbRptVw.Pkg Use VENDOR.DD Use INVT.DD Use CUSTOMER.DD Use SALESP.DD Use ORDERHEA.DD Use ORDERDTL.DD //AB-IgnoreEnd DEFERRED_VIEW Activate_oCustomerSelection_Report FOR ; ; Object oCustomerSelection_Report is a dbReportView //AB-StoreTopStart Property String psCustomerFrom Public "" Property String psCustomerTo Public "" // This is an example with WinPrint, but you can use crystalreport just as easy // with this approach. Property Integer WinQL_ReportID Public 0 // We use three different instances of the same datadictionary class. // Note that this is not supported behaviour of Data Access for now. It is nothing // to worry about eeiter, because we do not allow any saves to happen. // (The dbReportView is dumbed down to not accept a request_save or a request_delete) Object Customer_From_DD is a Customer_DataDictionary Set Read_Only_State To True End_Object // Customer_From_DD Object Customer_To_DD is a Customer_DataDictionary Set Read_Only_State To True End_Object // Customer_To_DD //AB-StoreTopEnd Set Label to "Customer selection report" Set Size to 92 198 Set Location to 4 5 //AB-DDOStart Object Vendor_DD is a Vendor_DataDictionary End_Object // Vendor_DD Object Invt_DD is a Invt_DataDictionary Set DDO_Server to (Vendor_DD(self)) End_Object // Invt_DD Object Customer_DD is a Customer_DataDictionary //AB-StoreStart Begin_Constraints Local String sCustomerFrom Local String sCustomerTo Get psCustomerFrom to sCustomerFrom Get psCustomerTo to sCustomerTo If sCustomerFrom NE "" ; Constrain CUSTOMER.NAME GE sCustomerFrom If sCustomerTo NE "" ; Constrain CUSTOMER.NAME LE sCustomerTo End_Constraints //AB-StoreEnd 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(self)) Set DDO_Server to (Salesp_DD(self)) Set Constrain_File to Customer.File_Number End_Object // Orderhea_DD Object Orderdtl_DD is a Orderdtl_DataDictionary Set DDO_Server to (Orderhea_DD(self)) Set DDO_Server to (Invt_DD(self)) Set Constrain_File to Orderhea.File_Number End_Object // Orderdtl_DD Set Main_DD to (Customer_DD(self)) Set Server to (Customer_DD(self)) //AB-DDOEnd Object oCustomer_From is a dbForm //AB-StoreTopStart Set Server to (Customer_From_DD(Self)) //AB-StoreTopEnd Entry_Item Customer.Name Set Label to "From customer:" Set Size to 13 120 Set Location to 18 66 //AB-StoreStart // Clear the entire screen, not just this field Procedure Request_Clear Delegate Send Request_Clear End_Procedure // Request_Clear //AB-StoreEnd End_Object // oCustomer_From Object oCustomer_To is a dbForm //AB-StoreTopStart Set Server to (Customer_To_DD(Self)) //AB-StoreTopEnd Entry_Item Customer.Name Set Label to "To customer:" Set Size to 13 120 Set Location to 34 66 //AB-StoreStart // An alternative way to set up the properties needed for the constraint. // I guess that the current method is much easier/cleaner. See procedure // initialize_constraints. // Procedure Exiting Integer hWhereTo returns Integer // Local Integer iRetVal // Local String sValue // Forward Get MSG_Exiting hWhereTo To iRetVal // If Not iRetVal Begin // Get Value Item 0 To sValue // Set psCustomerTo To sValue // End // Procedure_Return iRetVal // End_Procedure // Exiting // Clear the entire screen, not just this field Procedure Request_Clear Delegate Send Request_Clear End_Procedure // Request_Clear //AB-StoreEnd End_Object // oCustomer_To Object oComment_tb is a Textbox Set Label to "Print a selection to the screen" Set Location to 1 7 Set Size to 10 99 Set FontWeight to 600 End_Object // oComment_tb Object oOk_bn is a Button Set Label to "OK" Set Default_State to TRUE Set Location to 56 73 //AB-StoreStart Set Status_Help to "Print the selected report" Procedure OnClick Send StartReport End_Procedure // OnClick //AB-StoreEnd End_Object // oOk_bn Object oCancel_bn is a Button Set Label to "Cancel" Set Location to 56 136 //AB-StoreStart Set Status_Help to "Cancel the report" Procedure OnClick Delegate Send Request_cancel End_Procedure // Onclick //AB-StoreEnd End_Object // oCancel_bn //AB-StoreStart Object oReport is a ReportView Object Cust_Order_Listing is a WinReport Set Report_Title to "Printing Customer Orders" Set Server to (Customer_DD(Self)) Report_Breaks CUSTOMER.CUSTOMER_NUMBER Procedure_Section Page_Top DFFont "Arial" //Using font Arial DFFontSize 10 //Set fontsize to 10 //The last used font and size will //be used if you dont change it //Before we where using images. Now we use DFBeginHeader and //DFEndHeader to define an image. DFBeginHeader DFPageTop //A Header of type DFPageTop DFHeaderPos HDR_LEFT //Set all items in the header to //left justify DFHeaderFrame HDR_MARGINS // Set frame to MarginToMargin // Writeln in header to position 6 using bold. In this case 6 cm // Default for metrics is cm but you can change it to inch DFWritelnPos "Orders Listing" 6 (FONT_BOLD) DFFontSize 12 DFWritePos "Page:" 11.5 (FONT_ITALIC) //This is how to do page counting in WinPrint // #pagecount# MUST be in small letters DFWritelnPos "#pagecount#" 13 (FONT_ITALIC) DFEndHeader End_Procedure Procedure_Section SubHeader1 DFFont "Arial" DFFontSize 9 DFBeginHeader DFSubHeader 1 //A header of type DFSubHeader. //1=SubHeader 1 DFHeaderWrap HDR_NOWRAP //Donīt wrap/reprint on page break DFHeaderPos HDR_LEFT DFHeaderFrame HDR_MARGINS DFHeaderLineCheck 8 //Check that the header + 8 lines //fits on the page. Using last //font and size DFWritePos Customer.Customer_Number 0.5 (FONT_ITALIC+FONT_BOLD) DFWritelnPos Customer.Name 2 (FONT_ITALIC+FONT_BOLD) DFEndHeader End_Procedure // // report Class: Order_Listing // Print customer orders. This can be used as a main outer report // (Order_listing--> Order_Dtl) or it can be used as an inner report // (Cust_order_Listing-->Order_Listing-->Order_Dtl). // Object Order_listing is a WinReport //Report_Main_File OrderHea Set Server to (OrderHea_DD(Self)) Report_Index by OrderHea.Customer_Number // // Report: Order_Dtl // Inner report for check Order Detail. // Object Order_Dtl is a WinReport //Report_Main_File OrderDtl Set Server to (OrderDtl_DD(Self)) Report_Index BY OrderDtl.Order_Number Report_Breaks OrderHea.Order_Number Procedure_Section SubHeader1 Send Update_Status (Customer.Name - ":" * String(Orderhea.Order_Number)) DFFont "Arial" DFFontSize 9 DFBeginHeader DFSubHeader 5 //This is a very special thing in //nested reports. If you look in the //source you will se that itīs two //SubHeaders 1. If they are nested //they canīt have the same number. //use an unused number !!! DFHeaderWrap HDR_NOWRAP DFHeaderPos HDR_LEFT DFHeaderFrame HDR_MARGINS DFHeaderLineCheck 5 //Check that the header + 5 lines //fits on the page. Using last //font and size DFWritePos "Order Number" 0.5 (FONT_ITALIC) DFWritePos OrderHea.Order_Number 3.5 (FONT_ITALIC) DFWritePos "Customer#" 6 (FONT_ITALIC) DFWritelnPos CUSTOMER.CUSTOMER_NUMBER 9 (FONT_ITALIC) DFWritePos "Bill To" 0.5 (FONT_ITALIC) DFWritePos Customer.Name 2.5 (FONT_ITALIC) DFWritePos "Date" 8.5 (FONT_ITALIC) DFWritePos "Via" 10.5 (FONT_ITALIC) DFWritelnPos "Slsmn" 13.5 (FONT_ITALIC) DFWritePos Customer.Address 2.5 (FONT_ITALIC) DFWritePos OrderHea.Order_date 8.5 (FONT_ITALIC) DFWritePos Orderhea.Ship_Via 10.5 (FONT_ITALIC) DFWritelnPos Orderhea.Salesperson_ID 13.5 (FONT_ITALIC) DFWritePos Customer.City 2.5 (FONT_ITALIC) DFWritePos Customer.State 5.5 (FONT_ITALIC) DFWritelnPos Customer.Zip 6.5 (FONT_ITALIC) DFWriteln "" DFWritePos "Part Id" 0.5 (FONT_BOLD) DFWritePos "Description" 3.5 (FONT_BOLD) DFWritePos "Price" 9 (FONT_BOLD) DFWritePos "Qty" 11 (FONT_BOLD) DFWritelnPos "Amount" 13 (FONT_BOLD) DFEndHeader End_Procedure Procedure_Section Body DFFont "Times New Roman" DFFontSize 9 DFWritePos Orderdtl.Item_ID 0.5 (FONT_ITALIC) DFWritePos Invt.Description 3.5 (FONT_ITALIC) DFWritePos (Orderdtl.Price / Orderdtl.Qty_Ordered) 10 (FONT_ITALIC) 2 DFWritePos Orderdtl.Qty_Ordered 11 (FONT_ITALIC) DFWritelnPos Orderdtl.Price 14.5 (FONT_ITALIC) 2 End_Procedure Procedure_Section SubTotal1 DFFont "Arial" DFFontSize 9 DFWriteln "" DFBeginHeader DFSubTotal 5 //Muste use this in nested reports and //Se SubHeader in same report. DFHeaderWrap HDR_NOWRAP DFHeaderPos HDR_LEFT DFHeaderFrame HDR_NOFRAME //Donīt print any frame DFWritelnPos Orderhea.Order_Total 14.5 (FONT_ITALIC+FONT_BOLD+FONT_UNDER) 2 DFEndHeader DFWriteln "" Send Add_SubTotal 1 Orderhea.Order_Total Send Add_SubTotal 2 Orderhea.Order_Total End_Procedure End_Object // Order_Dtl__1 End_Object // Order_listing__1 Procedure_Section SubTotal1 Local integer iBreak DFFont "Arial" DFFontSize 9 DFBeginHeader DFSubTotal 1 //A header of type DFSubTotal. DFHeaderWrap HDR_NOWRAP DFHeaderPos HDR_LEFT DFHeaderFrame HDR_MARGINS DFWritePos CUSTOMER.CUSTOMER_NUMBER 0.5 (FONT_ITALIC+FONT_BOLD) DFWritePos Customer.Name 2 (FONT_ITALIC+FONT_BOLD) //Print total at pos 14.4 italic+bold USING 2 decimals //If you send a param 0-?? it will be treated as a numeric //value printed with ?? digits to the right of the number //All numeric values will be right justify. DFWritelnPos (SubTotal(Self,2)) 14.5 (FONT_ITALIC+FONT_BOLD) 2 DFEndHeader DFWriteln "" End_Procedure Procedure_Section Total DFFont "Arial" DFFontSize 9 DFWriteln "" DFBeginHeader DFTotal DFHeaderPos HDR_LEFT DFHeaderFrame HDR_MARGINS DFWritelnPos (SubTotal(Self,1)) 14.5 (FONT_ITALIC+FONT_BOLD) 2 DFEndHeader End_Procedure Procedure_Section Page_Bottom Local Date dDate Sysdate dDate DFFont "Arial" DFFontSize 10 DFBeginHeader DFPageBottom DFHeaderPos HDR_CENTER DFHeaderFrame HDR_MARGINS //If you use DFWrite and DFWriteln (not Pos or Col) the //text will be centert. DFWrite "WinRpt10 Sample: Printed on: " (FONT_ITALIC) DFWriteln (RptToday(Self)) (FONT_ITALIC) DFEndHeader End_Procedure Procedure Run_Order_Report Report_Index by Customer.Name Send Run_report End_Procedure // Run_Order_Report End_Object // Cust_order_listing // Run the report // set indicators to tell the report object what we are doing and // then tell the report object to perform its magic. // Procedure StartReport Set OutPut_Device_Mode to PRINT_TO_WINDOW Send Run_Order_Report to (Cust_Order_Listing(Self)) End_Procedure End_Object // oReport // By Getting the field_current_value of the DDO's we are sure that we have the // selections currently on the screen. It is totally independent of navigation // of the user. Just the way it should be. Procedure Initialize_Constraints Local String sCustomerFrom Local String sCustomerTo Get Field_Current_Value Of Customer_From_DD Field CUSTOMER.NAME To sCustomerFrom Get Field_Current_Value Of Customer_To_DD Field CUSTOMER.NAME To sCustomerTo Set psCustomerFrom To sCustomerFrom Set psCustomerTo To sCustomerTo Send Rebuild_Constraints To Customer_DD End_Procedure // Initialize_Constraints Procedure Request_Clear Set psCustomerFrom To "" Set psCustomerTo To "" Send Request_Clear to (Customer_From_DD(Self)) Send Request_Clear to (Customer_To_DD(Self)) forward send Request_Clear End_Procedure // Request_Clear Procedure StartReport Send Initialize_Constraints Send StartReport to (oReport(Self)) Send Request_Clear End_Procedure // StartReport //AB-StoreEnd CD_End_Object // oCustomerSelection_Report //AB/ End_Object // prj