Hi again Ian
I’ve attached a copy of your report template with the following:
In reportHeaderBand1 OnBeforePrint to set the totals we will be using in this report: " "
decimal NetTotal = 0;
decimal CarriageTotal = 0;
double dVATTotal = 0;
decimal POTotal = 0;
In Detail1 band’s OnBefore Print have the following: " "
private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
//obtain what the Net is for this record
decimal NetPrice = Convert.ToDecimal(Convert.ToDouble(DetailReport1.GetCurrentColumnValue(“LT_UI_Label_NetValue”)));
//Add that Net to the running NetTotal
NetTotal += (NetPrice);
}
In the xrLabel30 VAT data field OnBeforePrint: " "
private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
//obtain the amount for shipping (in the event the custom field doesn’t have anything, have to parse it out)
decimal d = 0;
decimal.TryParse(DetailReport.GetCurrentColumnValue(“LT_PurchaseOrder_Label_Custom0”).ToString(), out d);
CarriageTotal = d;
//Add this amount to the running total for the PO
POTotal += CarriageTotal;
//add the shipping to NetTotal
decimal nt = (CarriageTotal + NetTotal);
//declare the VAT %
decimal vtp = Convert.ToDecimal(0.15);
//obtain the VAT total and show it in the field and add it to the running POTotal
dVATTotal = decimal.Multiply(nt, vtp);
xrLabel30.Text = string.Format("{0:n2}", dVATTotal);
POTotal += Convert.ToDecimal(dVATTotal);
}
In the Total for the PO field’s OnBeforePrint " "
private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
//display the final running total for the PO
xrLabel32.Text = string.Format("{0:c}", (POTotal + NetTotal));
}
And then finally to zero out for the next report in the event you are printing multiple PO’s, the AfterPrint script: " "
private void OnAfterPrint(object sender, System.EventArgs e)
{
NetTotal = 0;
CarriageTotal = 0;
dVATTotal = 0;
POTotal = 0;
}
I’ve attached a copy of the custom report template showing this for your benefit, as well as for others that may want to do something similar. Have a good weekend.