Page 1 of 1
Quantity in packing slip
Posted: Thu Oct 02, 2008 2:24 pm
by William_firefold
Sorry for all the posts today, but I have one more for the day.
We want a item count label on our packing slip(admin/print/packslips.aspx) and I have been unable to make one from the orderShipment field that the packing slips use.
Could I get some code that will count the items in each order and put the number into a label?
Re: Quantity in packing slip
Posted: Thu Oct 02, 2008 2:46 pm
by William_firefold
May have solved my own problem but if you can(or want to) write better code, Ill use it.
I just cloned the getproducts method and added my counter variable:
Code: Select all
protected OrderItemCollection GetProducts2(object dataItem)
{
itemCount=0;
OrderShipment shipment = (OrderShipment)dataItem;
Order order = shipment.Order;
OrderItemCollection products = new OrderItemCollection();
foreach (OrderItem item in order.Items)
{
if ((item.OrderItemType == OrderItemType.Product) && (item.OrderShipmentId == shipment.OrderShipmentId))
{
products.Add(item);
itemCount+=item.Quantity;
}
}
products.Sort(new OrderItemComparer());
return products;
}
Then I can use the method like so without worrying about what its counting and when.
Code: Select all
<asp:Label ID="qtylabel" runat="server" Text="Total QTY Shipped:"></asp:Label>
<asp:Label ID="Qty" DataSource='<%#GetProducts2(Container.DataItem)%>' runat="server" Text='<%#(itemCount)%>'></asp:Label>