Beispiel #1
0
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         PurchaseItemRecord record = dataGridView1.Rows[e.RowIndex].Tag as PurchaseItemRecord;
         if (dataGridView1.Columns[e.ColumnIndex].Name == "colSheetNo")
         {
             PurchaseOrder sheet = (new PurchaseOrderBLL(AppSettings.Current.ConnStr)).GetByID(record.SheetNo).QueryObject;
             if (sheet != null)
             {
                 FrmPurchaseOrderDetail frm = new FrmPurchaseOrderDetail();
                 frm.IsAdding     = false;
                 frm.UpdatingItem = sheet;
                 frm.IsForView    = true;
                 frm.ShowDialog();
             }
         }
         else if (dataGridView1.Columns[e.ColumnIndex].Name == "colReceived")
         {
             ProductInventoryItemSearchCondition con = new ProductInventoryItemSearchCondition();
             con.PurchaseItem = record.ID;
             FrmProductInventoryItemView frm = new FrmProductInventoryItemView();
             frm.SearchCondition = con;
             frm.ShowDialog();
         }
     }
 }
Beispiel #2
0
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0 && dataGridView1.Columns[e.ColumnIndex].Name == "colInventory")
     {
         OrderItemRecord item = dataGridView1.Rows[e.RowIndex].Tag as OrderItemRecord;
         ProductInventoryItemSearchCondition con = new ProductInventoryItemSearchCondition();
         con.OrderItem = item.ID;
         con.UnShipped = true;
         FrmProductInventoryItemView frm = new FrmProductInventoryItemView();
         frm.SearchCondition = con;
         frm.ShowDialog();
     }
     if (e.RowIndex >= 0 && dataGridView1.Columns[e.ColumnIndex].Name == "colShipped")
     {
         OrderItemRecord item = dataGridView1.Rows[e.RowIndex].Tag as OrderItemRecord;
         ProductInventoryItemSearchCondition con = new ProductInventoryItemSearchCondition();
         con.OrderItem = item.ID;
         con.UnShipped = false;
         FrmProductInventoryItemView frm = new FrmProductInventoryItemView();
         frm.SearchCondition = con;
         frm.ShowDialog();
     }
     if (e.RowIndex >= 0 && dataGridView1.Columns[e.ColumnIndex].Name == "colValidInventory")
     {
         OrderItemRecord item = dataGridView1.Rows[e.RowIndex].Tag as OrderItemRecord;
         ProductInventoryItemSearchCondition con = new ProductInventoryItemSearchCondition();
         con.Products = new List <string>();
         con.Products.Add(item.ProductID);
         con.UnShipped  = true;
         con.UnReserved = true;
         FrmProductInventoryItemView frm = new FrmProductInventoryItemView();
         frm.SearchCondition = con;
         frm.ShowDialog();
     }
 }
        /// <summary>
        /// 将库存分配给某个订单项,分配给某个订单项的库存不能再用于其它订单的出货,只能用于该订单项出货
        /// </summary>
        /// <param name="pi"></param>
        /// <param name="orderItem"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public CommandResult Reserve(string warehouseID, string productID, Guid orderItem, string orderID, decimal count)
        {
            IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(RepoUri);
            ProductInventoryItemSearchCondition con = new ProductInventoryItemSearchCondition();

            con.Products = new List <string>();
            con.Products.Add(productID);
            con.WareHouseID = warehouseID;
            con.UnShipped   = true; //未发货的库存项
            con.UnReserved  = true; //未分配给某个特定的订单
            List <ProductInventoryItem> items = ProviderFactory.Create <IProvider <ProductInventoryItem, Guid> >(RepoUri).GetItems(con).QueryObjects;

            if (items.Sum(item => item.Count) < count)
            {
                return(new CommandResult(ResultCode.Fail, string.Format("库存不足,预分配失败!", productID)));
            }

            if (UserSettings.Current.InventoryOutType == InventoryOutType.FIFO) //根据产品的出货方式排序
            {
                items = (from item in items orderby item.AddDate ascending select item).ToList();
            }
            else
            {
                items = (from item in items orderby item.AddDate descending select item).ToList();
            }
            foreach (ProductInventoryItem pii in items)
            {
                if (count > 0)
                {
                    ProductInventoryItem pii1 = pii.Clone();
                    if (pii.Count > count) //对于部分出货的情况,一条库存记录拆成两条,其中一条表示出货的,另一条表示未出货部分,即要保证DelvieryItem不为空的都是未出货的,为空的都是已经出货的
                    {
                        pii.OrderItem = orderItem;
                        pii.OrderID   = orderID;
                        pii.Count     = count;
                        ProviderFactory.Create <IProvider <ProductInventoryItem, Guid> >(RepoUri).Update(pii, pii1, unitWork);

                        pii1.ID     = Guid.NewGuid();
                        pii1.Count -= count;
                        ProviderFactory.Create <IProvider <ProductInventoryItem, Guid> >(RepoUri).Insert(pii1, unitWork);
                        count = 0;
                    }
                    else
                    {
                        pii.OrderItem = orderItem;
                        pii.OrderID   = orderID;
                        ProviderFactory.Create <IProvider <ProductInventoryItem, Guid> >(RepoUri).Update(pii, pii1, unitWork);
                        count -= pii.Count;
                    }
                }
            }
            return(unitWork.Commit());
        }
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         if (dataGridView1.Columns[e.ColumnIndex].Name == "colValid")
         {
             ProductInventory item = dataGridView1.Rows[e.RowIndex].Tag as ProductInventory;
             ProductInventoryItemSearchCondition con = new ProductInventoryItemSearchCondition();
             con.Products = new List <string>();
             con.Products.Add(item.ProductID);
             con.WareHouseID = item.WareHouseID;
             con.UnReserved  = true;
             con.UnShipped   = true;
             View.FrmProductInventoryItemView frm = new View.FrmProductInventoryItemView();
             frm.SearchCondition = con;
             frm.ShowDialog();
         }
         else if (dataGridView1.Columns[e.ColumnIndex].Name == "colReserved")
         {
             ProductInventory item = dataGridView1.Rows[e.RowIndex].Tag as ProductInventory;
             ProductInventoryItemSearchCondition con = new ProductInventoryItemSearchCondition();
             con.Products = new List <string>();
             con.Products.Add(item.ProductID);
             con.WareHouseID = item.WareHouseID;
             con.UnReserved  = false;
             con.UnShipped   = true;
             View.FrmProductInventoryItemView frm = new View.FrmProductInventoryItemView();
             frm.SearchCondition = con;
             frm.ShowDialog();
         }
         else if (dataGridView1.Columns[e.ColumnIndex].Name == "colAmount")
         {
             ProductInventory item = dataGridView1.Rows[e.RowIndex].Tag as ProductInventory;
             ProductInventoryItemSearchCondition con = new ProductInventoryItemSearchCondition();
             con.Products = new List <string>();
             con.Products.Add(item.ProductID);
             con.WareHouseID = item.WareHouseID;
             con.UnShipped   = true;
             View.FrmProductInventoryItemView frm = new View.FrmProductInventoryItemView();
             frm.SearchCondition = con;
             frm.ShowDialog();
         }
     }
 }
        protected override void DoNullify(Order info, IUnitWork unitWork, DateTime dt, string opt)
        {
            //首先取消订单的备货项
            ProductInventoryItemSearchCondition con = new ProductInventoryItemSearchCondition();

            con.OrderID   = info.ID;
            con.UnShipped = true;
            List <ProductInventoryItem> items = ProviderFactory.Create <IProvider <ProductInventoryItem, Guid> >(RepoUri).GetItems(con).QueryObjects;

            if (items != null && items.Count > 0)
            {
                foreach (ProductInventoryItem item in items)
                {
                    ProductInventoryItem clone = item.Clone();
                    item.OrderID   = null;
                    item.OrderItem = null;
                    ProviderFactory.Create <IProvider <ProductInventoryItem, Guid> >(RepoUri).Update(item, clone, unitWork);
                }
            }
            base.DoNullify(info, unitWork, dt, opt);
        }
Beispiel #6
0
        private void InventoryOut(StackOutSheet sheet, InventoryOutType inventoryOutType, IUnitWork unitWork)
        {
            List <string> pids = sheet.Items.Select(it => it.ProductID).ToList();
            ProductInventoryItemSearchCondition con = new ProductInventoryItemSearchCondition();

            con.Products    = pids;
            con.WareHouseID = sheet.WareHouseID;
            con.UnShipped   = true;
            List <ProductInventoryItem> inventoryItems = ProviderFactory.Create <IProvider <ProductInventoryItem, Guid> >(RepoUri).GetItems(con).QueryObjects;

            if (inventoryItems == null || inventoryItems.Count == 0)
            {
                throw new Exception("没有找到相关的库存项");
            }
            List <ProductInventoryItem> clones = new List <ProductInventoryItem>();

            inventoryItems.ForEach(it => clones.Add(it.Clone()));                        //备分所有的项的克隆
            List <ProductInventoryItem> addingItems = new List <ProductInventoryItem>(); //要于保存将要增加的项

            ////减少库存
            foreach (StackOutItem si in sheet.Items)
            {
                Product p = ProviderFactory.Create <IProvider <Product, string> >(RepoUri).GetByID(si.ProductID).QueryObject;
                if (p != null && p.IsService != null && p.IsService.Value)
                {
                    continue;                                                        //如果是产品是服务的话就不用再从库存中扣除了
                }
                Assign(si, inventoryOutType, inventoryItems, addingItems);
            }
            foreach (ProductInventoryItem item in inventoryItems)
            {
                ProductInventoryItem clone = clones.Single(it => it.ID == item.ID);
                ProviderFactory.Create <IProvider <ProductInventoryItem, Guid> >(RepoUri).Update(item, clone, unitWork);
            }
            foreach (ProductInventoryItem item in addingItems)
            {
                ProviderFactory.Create <IProvider <ProductInventoryItem, Guid> >(RepoUri).Insert(item, unitWork);
            }
        }
Beispiel #7
0
        protected override List <ProductInventoryItem> GetingItems(DataContext dc, SearchCondition search)
        {
            IQueryable <ProductInventoryItem> ret = dc.GetTable <ProductInventoryItem>();

            if (search is ProductInventoryItemSearchCondition)
            {
                ProductInventoryItemSearchCondition con = search as ProductInventoryItemSearchCondition;
                if (con.Products != null && con.Products.Count > 0)
                {
                    ret = ret.Where(item => con.Products.Contains(item.ProductID));
                }
                if (!string.IsNullOrEmpty(con.WareHouseID))
                {
                    ret = ret.Where(item => item.WareHouseID == con.WareHouseID);
                }
                if (con.OrderItem != null)
                {
                    ret = ret.Where(item => item.OrderItem == con.OrderItem);
                }
                if (!string.IsNullOrEmpty(con.OrderID))
                {
                    ret = ret.Where(item => item.OrderID == con.OrderID);
                }
                if (con.PurchaseItem != null)
                {
                    ret = ret.Where(item => item.PurchaseItem == con.PurchaseItem);
                }
                if (!string.IsNullOrEmpty(con.PurchaseID))
                {
                    ret = ret.Where(item => item.PurchaseID == con.PurchaseID);
                }
                if (con.InventoryItem != null)
                {
                    ret = ret.Where(item => item.InventoryItem == con.InventoryItem);
                }
                if (!string.IsNullOrEmpty(con.InventorySheetNo))
                {
                    ret = ret.Where(item => item.InventorySheet == con.InventorySheetNo);
                }
                if (con.DeliveryItem != null)
                {
                    ret = ret.Where(item => item.DeliveryItem == con.DeliveryItem);
                }
                if (!string.IsNullOrEmpty(con.DeliverySheetNo))
                {
                    ret = ret.Where(item => item.DeliverySheet == con.DeliverySheetNo);
                }
                if (con.UnShipped != null)
                {
                    if (con.UnShipped.Value)
                    {
                        ret = ret.Where(item => item.DeliveryItem == null);
                    }
                    else
                    {
                        ret = ret.Where(item => item.DeliveryItem != null);
                    }
                }
                if (con.UnReserved != null)
                {
                    if (con.UnReserved.Value)
                    {
                        ret = ret.Where(item => item.OrderItem == null);
                    }
                    else
                    {
                        ret = ret.Where(item => item.OrderItem != null);
                    }
                }
            }
            return(ret.ToList());
        }