private void frmShipmentFromWH_FormClosing(object sender, FormClosingEventArgs e)
        {
            //sSetting.Save();
            sSetting = null;

            fromWH = null;
        }
Beispiel #2
0
        public static ShipmentSetting GetInstance(Session session)
        {
            ShipmentSetting setting = session.FindObject<ShipmentSetting>(null);

            if (setting == null)
            {
                session.BeginTransaction();
                setting = new ShipmentSetting(session);
                setting.Name = "ShipmentSetting";
                setting.NoOfDay = 7;
                setting.IncludeSSTK = false;
                setting.SortBy = SortType.PriorityDate;
                setting.Save();
                session.CommitTransaction();
            }

            return setting;
        }
        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);
 }
        private void frmShipmentFromWH_Load(object sender, EventArgs e)
        {
            session = new Session();
            XPCollection<Customer> customers = new XPCollection<Customer>(session);
            cboCustomer.Properties.DataSource = customers;

            if (customers.Count > 0)
                cboCustomer.EditValue = customers[0].Oid;

            XPCollection<WareHouse> warehouses = new XPCollection<WareHouse>(session);
            lueWarehouse.Properties.DataSource = warehouses;

            if (warehouses.Count > 0)
                lueWarehouse.EditValue = warehouses[0].Oid;

            cboSortBy.Properties.Items.Add("先交期, 后优先");
            cboSortBy.Properties.Items.Add("先优先, 后交期");

            sSetting = ShipmentSetting.GetInstance(session);
            fromWH = new Shipment_FromWH();
            dateLastNeedDate.DateTime = DateTime.Today.AddDays(sSetting.NoOfDay);

            if (sSetting.SortBy == ShipmentSetting.SortType.DatePriority)
                cboSortBy.SelectedIndex = 0;
            else
                cboSortBy.SelectedIndex = 1;

            chkSSTK.Checked = sSetting.IncludeSSTK;
        }
Beispiel #6
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;
        }