예제 #1
0
        private static void In(SpareEntities db, TB_BILL bill, TS_STOCK_DETAIL detailIn)
        {
            CheckStockDetailLoc(db, detailIn.LocCode);

            if (detailIn.UpdateQty <= 0)
            {
                throw new WmsException(ResultCode.StockNotEnough, GetDetailInfo(detailIn), "入库数量错误");
            }
            var stockDetail = Get(db, detailIn.LocCode, detailIn.PartCode, detailIn.Batch) ?? detailIn.Clone();

            stockDetail.Qty       += detailIn.UpdateQty;
            stockDetail.UpdateQty  = detailIn.UpdateQty;
            stockDetail.UpdateTime = DateTime.Now;
            db.TS_STOCK_DETAIL.AddOrUpdate(stockDetail);
            SetProduceDate(db, stockDetail);

            TransactionLogController.Add(db, bill, detailIn); //添加库存事务日志
        }
예제 #2
0
        public static void Out(SpareEntities db, TB_BILL bill, TS_STOCK_DETAIL detailOut)
        {
            CheckStockDetailLoc(db, detailOut.LocCode);

            var loc = StoreLocationController.Get(db, detailOut.LocCode);

//            if (detailOut.UpdateQty >= 0)
//            {
//                throw new WmsException(ResultCode.StockNotEnough,
//                   GetDetailInfo(detailOut), "出库数量错误,无法移出");
//            }
            if (detailOut.Qty + detailOut.UpdateQty < 0)
            {
                throw new WmsException(ResultCode.StockNotEnough,
                                       GetDetailInfo(detailOut), "出库库存明细不足,无法移出");
            }
            var stockDetail = Get(db, detailOut.LocCode, detailOut.PartCode, detailOut.Batch);

            if (stockDetail == null) //库存明细不存在,报错
            {
                if (bill.BillType == (int)BillType.InventoryPlan)
                {
                    return;
                }
                throw new WmsException(ResultCode.DataNotFound,
                                       GetDetailInfo(detailOut), "出库库存明细不存在");
            }
            else //库存明细存在,更新数量(出库时更新数量为负值)
            {
                stockDetail.Qty       += detailOut.UpdateQty;
                stockDetail.UpdateQty  = detailOut.UpdateQty;
                stockDetail.UpdateTime = DateTime.Now;
            }
            db.TS_STOCK_DETAIL.AddOrUpdate(stockDetail);
            TransactionLogController.Add(db, bill, detailOut); //添加库存事务日志
        }