public void LV_List_OnItemDataBound(object sender, ListViewItemEventArgs e) { Orders boundOrder = (Orders)((ListViewDataItem)(e.Item)).DataItem; PFlow flow = new PFlow(); flowQueue.Enqueue(flow); flow.FlowCode = boundOrder.Flow.Code; flow.PartyFrom = boundOrder.Flow.PartyFrom; foreach (ItemFlow itemFlow in boundOrder.ItemFlows) { IList<string> orderedPOList = new List<string>(); PItem item = new PItem(); item.Code = itemFlow.Item; Item i = TheItemMgr.LoadItem(item.Code); item.Desc = i.Desc1; item.Spec = i.Spec; var demand = itemFlow.OrderTracers.Where(o => o.TracerType == LeanEngine.Utility.Enumerators.TracerType.Demand).ToList(); if (demand.Count != null && demand.Count > 0) { item.SaveStock = demand[0].Qty; } var onhandInv = itemFlow.OrderTracers.Where(o => o.TracerType == LeanEngine.Utility.Enumerators.TracerType.OnhandInv).ToList(); if (onhandInv.Count != null && onhandInv.Count > 0) { item.Inventory = onhandInv[0].Qty; } var orderIss = itemFlow.OrderTracers.Where(o => o.TracerType == LeanEngine.Utility.Enumerators.TracerType.OrderIss).ToList(); if (orderIss != null && orderIss.Count > 0) { foreach (OrderTracer ot in orderIss) { string hql = @"select od from OrderDetail od inner join od.OrderHead oh where od.Item.Code = ? and oh.OrderNo = ? '"; IList<OrderDetail> orderDetailList = this.TheCriteriaMgr.FindAllWithHql<OrderDetail>(hql, new object[] { ot.Item, ot.Code }); if (orderDetailList != null && orderDetailList.Count > 0) { OrderDetail orderDetail = orderDetailList[0]; OrderHead orderHead = orderDetail.OrderHead; POrder pOrder = new POrder(); pOrder.OrderNo = orderHead.OrderNo; pOrder.CustomerCode = orderHead.PartyTo.Code; pOrder.CustomerName = orderHead.PartyTo.Name; pOrder.NeedPrepayment = orderHead.PartyTo.BoolField1.HasValue ? orderHead.PartyTo.BoolField1.Value : false; pOrder.HasPrepayed = orderHead.BoolField1; pOrder.RequiredQty = orderDetail.OrderedQty; pOrder.ShippedQty = orderDetail.ShippedQty.HasValue ? orderDetail.ShippedQty.Value : 0; pOrder.DeliverDate = orderHead.WindowTime; hql = @"select oh.OrderNo, ot.Qty from OrderTracer as ot, OrderLocationTransaction as olt inner join olt.OrderDetail as od inner join od.OrderHead as oh where olt.Id = ot.RefOrderLocTransId and ot.OrderDetail.Id = ?"; IList<object[]> qtyList = this.TheCriteriaMgr.FindAllWithHql<object[]>(hql, new object[] { orderDetail.Id }); if (qtyList != null && qtyList.Count > 0) { foreach (object[] obj in qtyList) { orderedPOList.Add((string)obj[0]); pOrder.OrderedQty += (decimal)obj[1]; } } else { pOrder.OrderedQty = 0; } if (pOrder.RequiredQty > pOrder.ShippedQty && pOrder.RequiredQty > pOrder.OrderedQty) { item.AddOrder(pOrder); } } } } var orderRct = itemFlow.OrderTracers.Where(o => o.TracerType == LeanEngine.Utility.Enumerators.TracerType.OrderRct).ToList(); if (orderRct != null && orderRct.Count > 0) { foreach (OrderTracer ot in orderRct) { if (!orderedPOList.Contains(ot.Code)) { item.OrderedQty += ot.Qty; } } } if ((item.OrderList != null && item.OrderList.Count > 0) || (item.SaveStock > (item.Inventory + item.OrderedQty))) { flow.AddItem(item); } } }