Example Invoice Data: Override a Field Value
Example 1: Reformat Invoice Due Date
The following code overrides the invoice due date contained in the XML document to a format that differs from the original value. The code reads the existing value from the XML document node, formats the value and writes back the new value to the same node.
XmlNode invoiceDueDate =
originalDocument.SelectSingleNode("/InvoiceData/InvoiceDueDate");
if (invoiceDueDate != null && DateTime.TryParse(invoiceDueDate.InnerText,
out val)) invoiceDueDate.InnerText = val.ToString("dd-MMM-yyyy");
Example 2: Change Invoice Name
The following example changes the invoice name. In the example, the "InvoiceName" tag was obtained from the XSD structure that was used to create the InvoiceDefault.rpt file. This code does not change the invoice in the database. The name is only changed in the generated XML object that is used to render the invoice report that displays and is subsequently printed.
XmlNodeList list = originalDocument.GetElementsByTagName("InvoiceName");
foreach(XmlNode node in list)
{
node.InnerText =" NEW NAME ";
}