Exemplo n.º 1
0
        private void CreateWoIssueByDetail(woPoTotal wpTotal, Session session)
        {
            XPCollection<SalesOrderLine> soLines = new XPCollection<SalesOrderLine>(session);
            soLines.Criteria = CriteriaOperator.Parse(string.Format("Item.Oid == '{0}' AND OrderStatus = '{1}' ", wpTotal.Item.Oid, SalesOrderLine.SalesOrderStatus.Active));

            SortingCollection sCollection = new SortingCollection();
            sCollection.Add(new SortProperty("PoDate", DevExpress.Xpo.DB.SortingDirection.Descending));
            sCollection.Add(new SortProperty("LineNo", DevExpress.Xpo.DB.SortingDirection.Descending));

            soLines.Sorting = sCollection;

            float remainQty = wpTotal.Wo_Po * -1;
            woIssue woIssue;

            foreach (SalesOrderLine soLine in soLines)
            {
                woIssue = new woIssue();
                woIssue.Item = soLine.Item;
                woIssue.WoNeedDate = soLine.NeedDate;

                if (soLine.NeedQty > remainQty)
                {
                    woIssue.WoNeedQty = remainQty;
                    remainQty = 0;
                }
                else
                {
                    woIssue.WoNeedQty = soLine.NeedQty;
                    remainQty = remainQty - soLine.NeedQty;
                }
                woIssue.SalesOrderLine = soLine;
                _woIssues.Add(woIssue);

                if (remainQty == 0)
                    return;
            }

            woIssue = new woIssue();
            woIssue.Item = wpTotal.Item;
            woIssue.WoNeedDate = DateTime.Today.AddDays(woIssue.Item.LeadTime);
            woIssue.WoNeedQty = remainQty;

            _woIssues.Add(woIssue);
        }
Exemplo n.º 2
0
        private BindingList<woPoTotal> CalcWoPoTotal(Session session)
        {
            Dictionary<Item, woPoTotal> dictWoPo = new Dictionary<Item, woPoTotal>();
            woPoTotal woPo;

            XPCollection<SalesOrderLine> soLines = new XPCollection<SalesOrderLine>(session);

            var soList = from s in soLines
                         where (s.SalesOrder.OrderType == SalesOrder.SalesOrderType.Normal && s.OrderStatus == SalesOrderLine.SalesOrderStatus.Active && s.IgnorePlanningReport == false )
                         group s by s.Item
                         into ss
                         select new
                         { Item = ss.Key, Total = ss.Sum(s => s.NeedQty), Shipped = ss.Sum(s => s.ShipQty) };

            foreach (var sLine in soList)
            {
                woPo = new woPoTotal();  //new woPoTotal(session);
                woPo.Item = sLine.Item;
                woPo.poTotal = sLine.Total;
                woPo.poShipped = sLine.Shipped;
                dictWoPo.Add(woPo.Item, woPo);
            }

            var sstkList = from s in soLines
                           where s.SalesOrder.OrderType == SalesOrder.SalesOrderType.SSTK && s.OrderStatus == SalesOrderLine.SalesOrderStatus.Active && s.IgnorePlanningReport == false
                           group s by s.Item
                           into ss
                           select new
                           { Item = ss.Key, Total = ss.Sum(s => s.NeedQty) };

            foreach (var sLine in sstkList)
            {
                if (dictWoPo.ContainsKey(sLine.Item))
                {
                    woPo = dictWoPo[sLine.Item];
                    woPo.sstkQty = sLine.Total;
                }
                else
                {
                    woPo = new woPoTotal();  // new woPoTotal(session);
                    woPo.Item = sLine.Item;
                    woPo.sstkQty = sLine.Total;
                    dictWoPo.Add(woPo.Item, woPo);
                }
            }

            XPCollection<WorkOrder> wos = new XPCollection<WorkOrder>(session);

            var woList = from s in wos
                         group s by s.Item
                         into ss
                         select new
                         { Item = ss.Key, Total = ss.Sum(s => s.NeedQty) };

            foreach (var woLine in woList)
            {
                if (dictWoPo.ContainsKey(woLine.Item))
                {
                    woPo = dictWoPo[woLine.Item];
                    woPo.woTotal = woLine.Total;
                }
                else
                {
                    woPo = new woPoTotal();  // new woPoTotal(session);
                    woPo.Item = woLine.Item;
                    woPo.woTotal = woLine.Total;
                    dictWoPo.Add(woPo.Item, woPo);
                }
            }

            BindingList<woPoTotal> woPoTotals = new BindingList<woPoTotal>();
            _woIssues = new BindingList<woIssue>();

            foreach (KeyValuePair<Item, woPoTotal> woPoTotal in dictWoPo)
            {
                woPoTotals.Add(woPoTotal.Value);

                woPoTotal wpTotal = (woPoTotal)woPoTotal.Value;

                if (wpTotal.Wo_Po < 0)
                {
                    if (PostByPO)
                    {
                        this.CreateWoIssueByDetail(wpTotal, session);
                    }
                    else
                    {
                        this.CreateWoIssue(wpTotal);
                    }
                }
            }

            foreach (woPoTotal woPoTotal in woPoTotals)
            {
                WHTotal whTotal = WHTotal.Find(woPoTotal.Item, Warehouse, session);

                if (whTotal != null)
                    woPoTotal.WarehouseQty = whTotal.AvailQty;

            }

            return woPoTotals;
        }
Exemplo n.º 3
0
        private void CreateWoIssue(woPoTotal wpTotal)
        {
            woIssue woIssue = new woIssue();
            woIssue.Item = wpTotal.Item;
            woIssue.WoNeedDate = DateTime.Today.AddDays(woIssue.Item.LeadTime);
            woIssue.WoNeedQty = wpTotal.Wo_Po * -1;

            _woIssues.Add(woIssue);
        }
Exemplo n.º 4
0
        private BindingList<PurchOrderReturn> CalcPurchOrderReturn(Session session)
        {
            Dictionary<Item, woPoTotal> dictWoPo = new Dictionary<Item, woPoTotal>();
            woPoTotal woPo;

            BindingList<PurchOrderReturn> poReturns = new BindingList<PurchOrderReturn>();
            XPCollection<SalesOrderLine> soLines = new XPCollection<SalesOrderLine>(session);

            var soList = from s in soLines
                         where (s.SalesOrder.OrderType == SalesOrder.SalesOrderType.Normal && s.OrderStatus == SalesOrderLine.SalesOrderStatus.Active && s.IgnorePlanningReport == false)
                         group s by s.Item
                         into ss
                         select new
                         { Item = ss.Key, Total = ss.Sum(s => s.NeedQty), Shipped = ss.Sum(s => s.ShipQty) };

            foreach (var sLine in soList)
            {
                //woPo = new woPoTotal(session);
                woPo = new woPoTotal();
                woPo.Item = sLine.Item;
                woPo.poTotal = sLine.Total;
                woPo.poShipped = sLine.Shipped;
                dictWoPo.Add(woPo.Item, woPo);
            }

            return poReturns;
        }