You are currently reviewing an older revision of this page.
Total quantities of parts in a project may not always be whole numbers. As designed, the project may contain 3.435 lengths of DIN rail, or 1.2 boxes of fuses. While accurate, the totals may not be ideal for how items are actually purchased.
This article describes how to use scripts to round quantities up to the nearest whole number on quantified bill of materials reports. As an example the BOM_Qty - Letter template is modified.
double totalQuantity = 0; private void Quantity_SummaryReset(object sender, EventArgs e) { // Reset the result each time a group is printed. totalQuantity = 0; } private void Quantity_SummaryRowChanged(object sender, EventArgs e) { // Calculate a summary. totalQuantity += Convert.ToDouble(GetCurrentColumnValue("QUANTITY")); } private void Quantity_SummaryGetResult(object sender, SummaryGetResultEventArgs e) { // Round the result, so that a pack will be taken into account // even if it contains only one unit. e.Result = Math.Ceiling(totalQuantity); e.Handled = true; }
Before Print scripts for report templates
DevExpress: How to: Calculate a Custom Summary