| As you can see by the time stamp of this topic reply, this has taken some doing - but I got it. This report template is based on the sample Detailed Service Workorder with Grand Total report that was initially edited by masonworks and has now been further customized to include a total of Net NC charge amount derived from NC Hours multipled the Service Rate Charge; the Net NC Hours; and at the report footer, a total of NC Hours and total of NC charge amount derived from NC Hours multipled the Service Rate Charge. This report could be useful if you provide no charge labor to your clients - showing on the report you provide them the amount of no charge hours and the potential currency amount of no charge that you did not charge them. This provides value in the eyes of your clients - if you are not going to charge them for something, let them know they received that. And the report includes scripts so that if there isn't any NC Hours, it doesn't show any labels for these fields. As you may not want to provide a report to your client that says 0 NC Hours. To do this requires scripts to be applied as well as the fields.
Download and import the report template, open it in custom report designer, and follow along by selecting the properties where indicated so that you can see how done. Select the ReportHeaderBand1, select the Properties tab, expand the Scripts property, and open the the OnBeforePrint script property.
In the existing script have added the variables where the running totals of NC Hours and NC Amount will be kept decimal NetNC = 0; decimal NetNCAmount = 0; Also added into this script setting the default heights for the two panels that we want to show only if the NC Hours is more than 0. These initially set the default height of these panels to 0 (shrunk). int pnlNetNCAmountDefault=0; int pnlTotalNCAmountDefault=0;
pnlNetNCAmountDefault=pnlNetNCAmount.Height; pnlTotalNCAmountDefault=pnlTotalNCAmount.Height; In the Detail1 band for the DetailReportItemLabor band have placed the panel pnlNetNCAmount with the field xrLabel12 that is just text, and the field xrLabel15 that is derived from the NC Hours multipled the Service Rate Charge for that labor item.
You can see the script for xrLabel15 by selecting it, select Properties tab, expand the Scripts property, open the OnBeforePrint script property: private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { //this gets the value of the NC Hours object, coverts it to decimal and holds it in the NCQty variable decimal NCQty = Convert.ToDecimal(DetailReportItemLabor.GetCurrentColumnValue("LT_WorkorderItemLabor_Label_NoChargeQuantity")); //this gets the value of the Service Rate Charge, converts it to decimal and holds it in the NCRate variable decimal NCRate = Convert.ToDecimal(DetailReportItemLabor.GetCurrentColumnValue("LT_WorkorderItemLabor_Label_LaborRateCharge")); //this multiplies the NCQty by the NCRate to produce the NCAmount variable decimal NCAmount = NCQty * NCRate; //this format the NCAmount variable first to currency and than to a string to place as text into the xrLabel15 field xrLabel15.Text = string.Format("{0:c2}", NCAmount); //this states that if the NoCharge Qty is 0, to set the field xrLabel15 to not be visible xrLabel15.Visible=(0!=decimal.Parse(DetailReportItemLabor.GetCurrentColumnValue("LT_WorkorderItemLabor_Label_NoChargeQuantity").ToString())); //this maintains a running total of NCAmount into the NetNCAmount we will use at the end of the report NetNCAmount += Convert.ToDecimal(NCAmount); } Select the Detail1 band of the DetailReportItemLabor, select Properties, expand Scripts and view the OnBeforePrint script property where have added the additional code so that this panel doesn't show and also shrinks up if NC is 0
if(DetailReportItemLabor.GetCurrentColumnValue("LT_WorkorderItemLabor_Label_NoChargeQuantity").ToString()=="0") pnlNetNCAmount.Height=1; else pnlNetNCAmount.Height=pnlNetNCAmountDefault; Detail1.Height=pnlNetNCAmount.Bottom; In the GroupFooter2 band of DetailReportItemLabor, you had blown away some of the cells of the table, but the scripts were still obtaining data for different information - which would have greatly affected the displayed data. For example, in your original customized report you had attached, the field xrTableCell70 had a OnSummaryCalculated field to keep a running total of Net Labor when it was for displaying NC hours, and field xrTableCell71 has an OnSummaryCalculated field to keep a running total of Net Tax A but it was for displaying Net Labor, and the field xrTableCell72 was now keeping a running total of Net Tax B but it was for keeping a running total of Net Tax A - and the running total for Net Tax B was blown away.
Make sure that if you edit an existing detailed report template, that you do check for existing scripts to make sure results are not affected. In the GroupFooter2 band, select the xrTableCell63 field and check out the OnBeforePrint script. Do the same for the xrTableCell70 field. You will also note that the xrTableCell70 field has two scripts - one to occur before printing to determine if this field should be visible or not, and the other OnSummaryCalculated to keep a running total for the Total at the bottom of the report. Now move to the ReportFooter band and view the OnBeforePrint script. This script checks to see if the NC amount is 0 or not - if it is 0 than the panel that holds these additional fields won't show.
The fields xrLabel10 and xrLabel16 have OnBeforePrint scripts that run to display the running total of the amounts that have been accumulating in the workorder for total NC hours and total NC amount. I believe I got everything that may have been accidiently removed from the original Sample Detailed report Template such as the deleting of the Net Tax B that would have affected the totals at the bottom of the report.
<EDITED FEB 2007 - removed existing report template as not compatible with AyaNova 3.3.3.0 or higher> - Joyce
- AyaNova Sales & Technical Support
- http://www.ayanova.com
|