Beispiel #1
0
        /// <summary>
        ///     添加临时盘点
        /// </summary>
        /// <param name="db"></param>
        /// <param name="locBill">盘点库位</param>
        /// <param name="details">盘点明细</param>
        /// <returns></returns>
        public static void AddTempInventory(SpareEntities db, TB_INVENTORY_LOC locBill,
                                            List <TB_INVENTORY_DETAIL> details)
        {
            var bill = new TB_BILL
            {
                BillType   = (int)BillType.InventoryPlan,
                OperName   = locBill.OperName,
                StartTime  = locBill.CheckBeginTime,
                FinishTime = locBill.CheckEndTime,
                State      = (int)BillState.Finished
            };

            locBill.State = (int)InventoryState.Checked;
            var locList = new List <TB_INVENTORY_LOC> {
                locBill
            };

            SetBillNum(bill);                                              //设置单据编号
            locList.ForEach(p => p.BillNum = bill.BillNum);                //设置明细编号

            InventoryController.AddOrUpdate(db, bill);                     //添加盘点计划
            InventoryController.AddLocList(db, locList);                   //添加盘点库位
            InventoryController.AddDetailList(db, details);                //添加盘点明细

            InventoryController.AdjustStockByInventory(db, bill, details); //根据盘点结果调整库存
        }
Beispiel #2
0
        /// <summary>
        ///     添加【盘点计划】
        /// </summary>
        /// <param name="db"></param>
        /// <param name="bill">盘点计划</param>
        /// <param name="locList">盘点库位明细</param>
        /// <returns></returns>
        public static void AddInventoryLoc(SpareEntities db, TB_BILL bill, List <TB_INVENTORY_LOC> locList)
        {
            {
                //新单据,增加盘点的三张表
                if (string.IsNullOrEmpty(bill.BillNum))
                {
                    SetBillNum(bill);                               //设置单据编号
                    locList.ForEach(p => p.BillNum = bill.BillNum); //设置明细编号
                    InventoryController.AddLocList(db, locList);    //添加盘点库位列表
                    foreach (var locBill in locList)
                    {
                        var stockDetailList     = StockDetailController.GetTListByLocCode(db, locBill.LocCode);
                        var inventoryDetailList = (stockDetailList.Select(p => p.ToInventoryDetail(locBill))).ToList();
                        InventoryController.AddDetailList(db, inventoryDetailList);                            //添加盘点明细
                    }
                    NotifyController.AddNotify(db, bill.OperName, NotifyType.InventoryPlan, bill.BillNum, ""); //添加【叫料提醒单】
                }
                else
                {
                    //修改单据,对第二、三张表的增加或删除
                    foreach (var locBill in locList)
                    {
                        if (db.TB_INVENTORY_LOC.FirstOrDefault(p => p.BillNum == bill.BillNum && p.LocCode == locBill.LocCode) == null)
                        {
                            InventoryController.AddLocList(db, locList); //添加盘点库位列表
                            var stockDetailList     = StockDetailController.GetTListByLocCode(db, locBill.LocCode);
                            var inventoryDetailList = (stockDetailList.Select(p => p.ToInventoryDetail(locBill))).ToList();
                            InventoryController.AddDetailList(db, inventoryDetailList); //添加盘点明细
                        }
                    }

                    var DBLocList = db.TB_INVENTORY_LOC.Where(p => p.BillNum == bill.BillNum).ToList();
                    foreach (var loc in DBLocList)
                    {
                        if (locList.SingleOrDefault(p => p.LocCode == loc.LocCode) == null)
                        {
                            InventoryController.DeleteInventory(db, loc);
                        }
                    }
                    NotifyController.AddNotify(db, bill.OperName, NotifyType.InventoryPlanUpdate, bill.BillNum, ""); //添加【叫料提醒单】
                }
                InventoryController.AddOrUpdate(db, bill);                                                           //添加盘点单据
            }
        }