Example #1
0
        public WIPWHTotal(Session session, ProdRouteListTransfer rTransfer)
            : base(session)
        {
            _Warehouse = rTransfer.ProdOrder.Warehouse;
            OnChanged("Warehouse");

            _PhysicalQty = 0;
            OnChanged("PhysicalQty");

            _AvailQty = 0;
            OnChanged("AvailQty");

            _Item = rTransfer.ProdOrder.Item;
            OnChanged("Item");
        }
Example #2
0
        public WIPWHTotal(Session session, PurchOrderReceive poReceive)
            : base(session)
        {
            _Warehouse = poReceive.PurchOrderLine.Warehouse;
            OnChanged("Warehouse");

            _PhysicalQty = 0;
            OnChanged("PhysicalQty");

            _AvailQty = 0;
            OnChanged("AvailQty");

            _Item = poReceive.PurchOrderLine.Item;
            OnChanged("Item");
        }
Example #3
0
        public WIPWHTotal(Session session, WHTotal whTotal)
            : base(session)
        {
            _Warehouse = whTotal.Warehouse;
            OnChanged("Warehouse");

            _PhysicalQty = whTotal.PhysicalQty;
            OnChanged("PhysicalQty");

            _AvailQty = whTotal.AvailQty;
            OnChanged("AvailQty");

            _Item = whTotal.Item;
            OnChanged("Item");
        }
Example #4
0
        public static WHTotal Find(Item item, WareHouse warehouse, Session session)
        {
            if (item == null || warehouse == null)
                return null;

            XPCollection<WHTotal> whTotals = new XPCollection<WHTotal>(session);
            whTotals.Criteria = CriteriaOperator.Parse(string.Format("Item.Oid == '{0}' AND Warehouse.Oid == '{1}'", item.Oid, warehouse.Oid));

            if (whTotals.Count > 0)
            {
                return whTotals[0];
            }
            else
            {
                return null;
            }
        }
Example #5
0
 public void PostMoveOrder(Session s, WareHouse fromWareHouse)
 {
     if (this.NeedQty <= 0 || this.NeedDate == null || this.BomItem == null)
     {
         this._Result = ResultStatus.Error;
     }
     else
         if (this.selected && this.Result != ResultStatus.OK)
         {
             try
             {
                 MoveOrder moveOrder = new MoveOrder(Session);
                 moveOrder.FromWarehouse = fromWareHouse;
                 moveOrder.Item = this.BomItem;
                 moveOrder.Qty = this.NeedQty;
                 moveOrder.ToWarehouse = this.Warehouse;
                 moveOrder.WorkOrder = this.WorkOrder;
                 moveOrder.Remark = this.WorkOrder.WorkOrderNo;
                 moveOrder.Save();
                 this._Result = ResultStatus.OK;
             }
             catch
             {
                 this._Result = ResultStatus.Error;
             }
         }
 }
Example #6
0
        public BindingList<woPurchOrder> CalcWoPurchOrder(Session _session)
        {
            XPClassInfo woClass;
            CriteriaOperator criteria;
            SortingCollection sortProps;

            _fromWareHouse = StoreWH;
            session = _session;
            UnitOfWork uow = (UnitOfWork)session;
            woClass = uow.GetClassInfo(typeof(WorkOrder));

            if (this.WorkOrder == null)
                criteria = CriteriaOperator.Parse("WorkOrderNo >= '0'");
            else
                criteria = CriteriaOperator.Parse("WorkOrderNo >= '" + this.WorkOrder.WorkOrderNo + "'");

            sortProps = new SortingCollection(null);
            sortProps.Add(new SortProperty("WorkOrderNo", SortingDirection.Ascending));

            ICollection workOrders = uow.GetObjects(woClass, criteria, sortProps, int.MaxValue, false, true);
            BindingList<woPurchOrder> woPurchOrders = new BindingList<woPurchOrder>();
            Dictionary<string, float> dictWHQty = new Dictionary<string, float>();

            foreach (WorkOrder wo in workOrders)
            {
                if (wo.WorkOrderNo.StartsWith("WoHistory") == false)
                {
                    if (wo.NeedQty - wo.ExtraQty > 0 )
                        this.CalcWoPurchOrderLine(woPurchOrders, dictWHQty, wo, wo.Item, wo.NeedQty - wo.ExtraQty, wo.Item.Source, 1, 1, 0, 0);
                }
            }

            return woPurchOrders;
        }
Example #7
0
        private void CalcWHQty(Item item , WareHouse warehouse, ref float Qty)
        {
            float whQty = 0;

            if (_dictWH.ContainsKey(item.ItemNo))
            {
                whQty = _dictWH[item.ItemNo];
            }
            else
            {
                WHTotal whTotal = this.Session.FindObject<WHTotal>(CriteriaOperator.Parse(string.Format("Item = '{0}' AND Warehouse = '{1}'", item.Oid , warehouse.Oid )));
                if (whTotal != null)
                    whQty = whTotal.AvailQty;

                _dictWH.Add(item.ItemNo, whQty);
            }

            if (balQty > whQty)
            {
                balQty = balQty - whQty;
                Qty = whQty;
                whQty = 0;
            }
            else
            {
                whQty = whQty - balQty;
                Qty = balQty;
                balQty = 0;
            }

            _dictWH[item.ItemNo] = whQty;
        }
Example #8
0
 public void SetDefaultWH(WareHouse warehouse)
 {
     defaultWH = warehouse;
 }
Example #9
0
        protected override void OnSaving()
        {
            if (base.IsNewRecord())
            {
                OrderTypeScrapSetting scrapSetting = OrderTypeScrapSetting.Find(OrderTypeScrapSetting.OrderSettingType.ProdOrder,
                    this.bomItem.ItemType, ProdOrder.OrderType, Session);

                if (scrapSetting != null)
                {
                    if (scrapSetting.ApplyConstantScrap)
                        this.ConstantScrap = scrapSetting.ConstantScrap;

                    if (scrapSetting.ApplyLineType)
                        this.LineType = scrapSetting.LineType;

                    if (scrapSetting.ApplyVariableScrap)
                        this.VariableScrap = scrapSetting.VariableScrap;

                    if (scrapSetting.ApplyBomQty)
                        this.Qty = scrapSetting.BomQty;

                }

                this.Warehouse = ProdOrder.Warehouse;

            }
            base.OnSaving();
        }
Example #10
0
        private WareHouse GetWarehouse(string warehouseName)
        {
            if (dictWarehouse == null)
            {
                dictWarehouse = new Dictionary<string, WareHouse>();
                XPCollection<WareHouse> whs = new XPCollection<WareHouse>(session);

                foreach (WareHouse wh in whs)
                {
                    dictWarehouse.Add(wh.WarehouseName.ToUpper(), wh);
                }
            }

            if (dictWarehouse.ContainsKey(warehouseName.ToUpper()))
            {
                return dictWarehouse[warehouseName.ToUpper()];
            }
            else
            {
                WareHouse wh = new WareHouse(session);
                wh.WarehouseName = warehouseName;
                wh.Factor = 100;
                wh.Save();

                dictWarehouse.Add(warehouseName.ToUpper(), wh);

                return wh;
            }
        }
        public static BindingList<SalesLineWithWarehouse> GetSalesLineWithWarehouseIList(Session session, Customer customer, DateTime endDate, Boolean includeSSTK, ShipmentSetting.SortType sortBy, WareHouse wareHouse)
        {
            XPCollection<SalesOrderLine> salesOrderLines = SalesOrderLine.GetOpenSalesOrderLine(session, null, includeSSTK, customer, endDate, sortBy, wareHouse);
            float WHQty = 0;
            string dictKey = "";

            Dictionary<string, float> dictWHQty = new Dictionary<string, float>();
            Dictionary<string, float> dictReadyQty = new Dictionary<string, float>();
            XPCollection<Shipment> shipments = new XPCollection<Shipment>(session);
            shipments.Criteria = CriteriaOperator.Parse(string.Format("Status == '{0}'", Shipment.PackStatus.Waiting)); // ACTIVE

            foreach (Shipment shipment in shipments)
            {
                dictKey = shipment.Item.ItemNo + "_" + shipment.SalesOrderLine.WareHouse.WarehouseName;

                if (dictReadyQty.ContainsKey(dictKey))
                {
                    dictReadyQty[dictKey] = dictReadyQty[dictKey] + shipment.Qty;
                }
                else
                {
                    dictReadyQty.Add(dictKey, shipment.Qty);
                }
            }

            BindingList<SalesLineWithWarehouse> salesLineWithWHs = new BindingList<SalesLineWithWarehouse>();

            foreach (SalesOrderLine sLine in salesOrderLines)
            {
                if (sLine.WareHouse != null)
                {
                    dictKey = sLine.Item.ItemNo + "_" + sLine.WareHouse.WarehouseName;

                    if (dictWHQty.ContainsKey(dictKey))
                    {
                        WHQty = dictWHQty[dictKey];
                    }
                    else
                    {
                        WHTotal whTotal = WHTotal.Find(sLine.Item, sLine.WareHouse, session);

                        if (sLine.Item.ItemNo == "00WA2592A01")
                            System.Diagnostics.Debug.Print("AA");

                        if (whTotal != null)
                        {
                            WHQty = whTotal.AvailQty;

                            if (dictReadyQty.ContainsKey(dictKey))
                            {
                                WHQty = WHQty - dictReadyQty[dictKey];

                                if (WHQty < 0)
                                    WHQty = 0;
                            }
                        }
                        else
                        {
                            WHQty = 0;
                        }
                    }

                    if (WHQty > 0 && sLine.LackQty > 0)
                    {
                        SalesLineWithWarehouse salesLineWithWH = new SalesLineWithWarehouse();
                        salesLineWithWH.SalesOrderLine = sLine;
                        if (sLine.LackQty > WHQty)
                        {
                            salesLineWithWH.AvailQty = WHQty;
                            WHQty = 0;
                        }
                        else
                        {
                            salesLineWithWH.AvailQty = sLine.LackQty;
                            WHQty = WHQty - sLine.LackQty;
                        }

                        if (dictWHQty.ContainsKey(dictKey))
                        {
                            dictWHQty[dictKey] = WHQty;
                        }
                        else
                        {
                            dictWHQty.Add(dictKey, WHQty);
                        }
                        salesLineWithWHs.Add(salesLineWithWH);
                    }
                }
            }

            return salesLineWithWHs;
        }
 public static BindingList<SalesLineWithWarehouse> GetSalesLineWithWarehouseIList(Session session, Customer customer, Boolean includeSSTK, ShipmentSetting.SortType sortBy, WareHouse wareHouse)
 {
     return GetSalesLineWithWarehouseIList(session, customer, DateTime.Now.AddYears(10), includeSSTK, sortBy, wareHouse);
 }
Example #13
0
        public static XPCollection<SalesOrderLine> GetOpenSalesOrderLine(Session session, Item item, DateTime endDate, WareHouse warehouse)
        {
            ShipmentSetting setting = ShipmentSetting.GetInstance(session);

            return SalesOrderLine.GetOpenSalesOrderLine(session, item, setting.IncludeSSTK, null, endDate, setting.SortBy, warehouse);
        }
Example #14
0
        public static XPCollection<SalesOrderLine> GetOpenSalesOrderLine(Session session, Item item, bool includeSSTK, Customer customer,
        DateTime endDate, ShipmentSetting.SortType sortBy, WareHouse wareHouse)
        {
            XPCollection<SalesOrderLine> salesOrderLines = new XPCollection<SalesOrderLine>(session);
            StringBuilder sbCriteria = new StringBuilder();

            //sbCriteria.Append(string.Format("(NeedDate <= #{0}# OR Priority >= 0) AND OrderStatus == 1 ", endDate));

            sbCriteria.Append(string.Format("(NeedDate <= #{0}# OR Priority >= 0) ", endDate));
            sbCriteria.Append(string.Format(" AND OrderStatus = '{0}' ", SalesOrderStatus.Active));

            if (customer != null)
                sbCriteria.Append(string.Format(" AND SalesOrder.Customer.Oid == '{0}'", customer.Oid));

            if (!includeSSTK)
                sbCriteria.Append(" AND SalesOrder.OrderType == 0 ");

            if (item != null)
                sbCriteria.Append(string.Format(" AND Item.Oid == '{0}'", item.Oid));

            if (wareHouse != null)
                sbCriteria.Append(string.Format(" AND WareHouse.Oid == '{0}'", wareHouse.Oid));

            salesOrderLines.Criteria = CriteriaOperator.Parse(sbCriteria.ToString());

            SortingCollection sCollection = new SortingCollection();

            if (sortBy == ShipmentSetting.SortType.PriorityDate)
            {
                sCollection.Add(new SortProperty("Priority", DevExpress.Xpo.DB.SortingDirection.Descending));
                sCollection.Add(new SortProperty("NeedDate", DevExpress.Xpo.DB.SortingDirection.Ascending));
            }
            else
            {
                sCollection.Add(new SortProperty("NeedDate", DevExpress.Xpo.DB.SortingDirection.Ascending));
                sCollection.Add(new SortProperty("Priority", DevExpress.Xpo.DB.SortingDirection.Descending));
            }

            salesOrderLines.Sorting = sCollection;
            return salesOrderLines;
        }
Example #15
0
        public void SetProdBom(ProdBom prodBom)
        {
            _ProdBom = prodBom;

            if (_ProdOrder != _ProdBom.ProdOrder)
            {
                _ProdOrder = _ProdBom.ProdOrder;
                OnChanged("ProdOrder");
            }

            if (_Item != _ProdBom.bomItem)
            {
                _Item = _ProdBom.bomItem;
                OnChanged("Item");
            }

            Warehouse = prodBom.Warehouse;
            this.Qty = prodBom.RemainReturnQty;
        }
Example #16
0
        private WIPWHTotal GetWHTotal(string itemNo, WareHouse wareHouse)
        {
            string key = itemNo;

            if (dictWHTotal.ContainsKey(key))
            {
                XPCollection<WIPWHTotal> wipWHTotals = dictWHTotal[key];

                foreach (WIPWHTotal wipWHTotal in wipWHTotals)
                {
                    if (wipWHTotal.Warehouse == wareHouse)
                    {
                        return wipWHTotal;
                    }
                }
            }

            return null;
        }