Report Script: Create a Packing List in report script: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 43: | Line 43: | ||
return; |
return; |
||
//Get total smallest UOM Qty of same ItemCode and UOMRate |
|||
decimal smallestQty = GetSmallestQty(GetCurrentColumnValue(" |
decimal smallestQty = GetSmallestQty(GetCurrentColumnValue("ItemCode"), GetCurrentColumnValue("UOMRate")); |
||
decimal uomRate; |
decimal uomRate; |
||
Line 64: | Line 65: | ||
</syntaxhighlight> |
</syntaxhighlight> |
||
<syntaxhighlight lang="csharp"> |
<syntaxhighlight lang="csharp"> |
||
//ItemCode and UOMRate are the grouping in this report |
|||
private decimal GetSmallestQty(object |
private decimal GetSmallestQty(object oItemCode, object oUomRate) |
||
{ |
{ |
||
if (oItemCode == null) |
|||
return BCE.Data.Convert.ToDecimal(oQty) * BCE.Data.Convert.ToDecimal(oRate); |
|||
return 0; |
|||
return (Report.DataSource as DataSet).Tables["Master"].AsEnumerable() |
|||
.Where(r => |
|||
r.Field<string>("ItemCode") == oItemCode.ToString() && |
|||
r.Field<decimal>("UOMRate") == BCE.Data.Convert.ToDecimal(oUomRate) |
|||
) |
|||
.GroupBy(r => new { |
|||
ItemCode = r.Field<string>("ItemCode"), |
|||
UOMRate = r.Field<decimal>("UOMRate") |
|||
}) |
|||
.Select(g => g.Sum(r => r.Field<decimal>("Qty") * r.Field<decimal>("Rate"))) |
|||
.FirstOrDefault(); |
|||
} |
} |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
Line 82: | Line 97: | ||
{ |
{ |
||
//Format the display text of qty and uom |
//Format the display text of qty and uom |
||
if (qty == 0) |
|||
return result; |
|||
string formatQtyUom = string.Format("{0} {1}", qty, uom); |
string formatQtyUom = string.Format("{0} {1}", qty, uom); |
||
return string.IsNullOrEmpty(result) ? formatQtyUom |
return string.IsNullOrEmpty(result) ? formatQtyUom |
||
: string.Format("{0} |
: string.Format("{0}, {1}", result, formatQtyUom); |
||
} |
} |
||
</syntaxhighlight> |
</syntaxhighlight> |