/// <summary> /// 创建【拣料单】 /// </summary> /// <param name="db"></param> /// <param name="billPickFact">拣料单</param> /// <param name="details">拣料明细</param> /// <returns></returns> public static void AddMaterialOut(SpareEntities db, TB_BILL billPickFact, List <TB_OUT> details) { { //校验单据状态是否为新建 if (billPickFact.State != (int)BillState.New) { throw new WmsException(ResultCode.DataStateError, billPickFact.BillNum, "状态错误,不应为:" + billPickFact.State); } if (string.IsNullOrEmpty(billPickFact.BillNum)) { SetBillNum(billPickFact); //设置单据编号 details.ForEach(p => p.BillNum = billPickFact.BillNum); //设置明细编号 NotifyController.AddNotify(db, billPickFact.OperName, NotifyType.MaterialOut, billPickFact.BillNum, ""); } else { var dbOutList = db.TB_OUT.Where(p => p.BillNum == billPickFact.BillNum).ToList(); foreach (var det in dbOutList) { if (details.FirstOrDefault(p => p.UID == det.UID) == null) { SpareOutController.RemaveDetail(db, det); } } NotifyController.AddNotify(db, billPickFact.OperName, NotifyType.MaterialOutUpdate, billPickFact.BillNum, ""); } BillController.AddOrUpdate(db, billPickFact); //添加【原料拣料单】单据 SpareOutController.AddOrUpdateList(db, details); //更新【实际拣料单】明细 EntitiesFactory.SaveDb(db); } }
public static void UpdateState(SpareEntities db, TB_BILL bill, BillState state) { bill.State = (int)state;//更新【单据】状态为:完成 OperateType operType; switch (state) { case BillState.New: case BillState.Handling: bill.StartTime = DateTime.Now.ToString(SysConfig.LongTimeString); operType = OperateType.Update; break; case BillState.Finished: bill.FinishTime = DateTime.Now.ToString(SysConfig.LongTimeString); operType = OperateType.Finish; break; case BillState.Cancelled: bill.FinishTime = DateTime.Now.ToString(SysConfig.LongTimeString); operType = OperateType.Cancel; break; default: bill.StartTime = DateTime.Now.ToString(SysConfig.LongTimeString); operType = OperateType.Update; break; } AddOrUpdate(db, bill); BillLogController.Add(db, bill, bill.OperName, operType); //创建【单据日志】 }
/// <summary> /// 添加【其它出库单】 /// </summary> /// <param name="db"></param> /// <param name="bill">其它出库单</param> /// <param name="details">其它出库明细</param> /// <returns></returns> public static void AddOtherOut(SpareEntities db, TB_BILL bill, List <TB_OTHER_OUT> details) { { SetBillNum(bill); //设置单据编号 details.ForEach(p => p.BillNum = bill.BillNum); //设置明细编号 BillController.AddOrUpdate(db, bill); //添加单据 foreach (var detail in details) { OtherOutController.AddOrUpdate(db, detail); //添加明细 } var subBillType = (SubBillType)bill.SubBillType; switch (subBillType) { //出库 case SubBillType.OtherOut: //其它出库 // case SubBillType.ReturnToSupplier: //原料退货 case SubBillType.InventoryLoss: //盘亏 case SubBillType.ScrapDestroy: //报废销毁 var detailsOut = details.Select(detail => detail.ToStockDetailOut(bill)).ToList(); StockDetailController.ListOut(db, bill, detailsOut); //更新【库存主表】【库存明细】出库 break; default: throw new WmsException(ResultCode.Exception, bill.BillNum, "单据二级类型错误"); } NotifyController.AddNotify(db, bill.OperName, NotifyType.OtherOutApprove, bill.BillNum, ""); } }
public TB_BILL GetSourceBill(string sourceBillNum) { TB_BILL bill = new TB_BILL(); bill = BillController.GetSourceBill(rdb, sourceBillNum); return(bill); }
/// <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); //根据盘点结果调整库存 }
public static void AdjustStockByInventory(SpareEntities db, TB_BILL bill, List <TB_INVENTORY_DETAIL> details) { var stockMoveList = new List <TB_STOCK_MOVE>(); foreach (TB_INVENTORY_DETAIL detail in details) { StoreLocationController.UnLock(db, detail.CheckLocCode);//解锁库位 var diffqty = detail.BookQty - detail.CheckQty; if (diffqty == 0) { continue; } var stockMove = detail.ToStockMove(); if (diffqty < 0) { stockMove.FromLocCode = "OTHER"; stockMove.ToLocCode = stockMove.ToLocCode; stockMove.Qty = (decimal) - diffqty; } else { stockMove.FromLocCode = stockMove.ToLocCode; stockMove.ToLocCode = "OTHER"; stockMove.Qty = (decimal)diffqty; } stockMoveList.Add(stockMove); } StockDetailController.ListMove(db, bill, stockMoveList);//盘点差异执行移库 }
public static void UpdateState(SpareEntities db, TB_BILL bill, BillState state) { bill.State = (int)state;//更新【单据】状态为:完成 OperateType operType; switch (state) { case BillState.New: case BillState.Handling: operType = OperateType.Update; break; case BillState.Finished: operType = OperateType.Finish; break; case BillState.Cancelled: operType = OperateType.Cancel; break; default: operType = OperateType.Update; break; } BillLogController.Add(db, bill, bill.OperName, operType); //创建【单据日志】 }
private void btnSubmit_Click(object sender, RoutedEventArgs e) { try { TB_BILL bill = new TB_BILL(); bill.PROJECTID = mProj.Id; bill.BILLNUMBER = txtBillNumber.Text; bill.CREATEDATE = this.dtpBeginDate.DateTime; bill.STATUS = 1; decimal money = 0; decimal.TryParse(txtMoney.Text, out money); if (money > 0) { bill.MONEY = money; } else { MessageHelper.ShowMessage("发票金额格式错误!"); return; } mBill = bill; this.Close(); } catch (Exception ex) { MessageHelper.ShowMessage(ex.Message); } }
public ActionResult CreateBill(TB_BILL bill) { var message = ""; try { bill.BILL_DATE = DateTime.Now; bill.STATUS = 0; entities.TB_BILL.Add(bill); if (entities.SaveChanges() > 0) { TB_GAME_ACCOUNT account = entities.TB_GAME_ACCOUNT.Find(bill.GAME_ACCOUNT_ID); account.CURRENT_STATUS = 2; // cập nhật lại trạng thái 2(đã bán) TB_USER user = entities.TB_USER.Find(bill.USER_ACCOUNT_ID); user.TB_MONEY.TOTAL_MONEY = user.TB_MONEY.TOTAL_MONEY - bill.SUCCESS_PRICE; // cập nhật lại số dư if (entities.SaveChanges() > 0) { message = "success"; } } return(Json(message, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { message = ex.GetBaseException().ToString(); } return(Json(message, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 【盘点单】调整库存 /// </summary> /// <param name="db"></param> /// <param name="bill"></param> /// <param name="details"></param> /// <returns></returns> public static void AdjustStockByInventoryLoc(SpareEntities db, TB_BILL bill) { var details = db.TB_INVENTORY_DETAIL.Where(p => p.BillNum == bill.BillNum).ToList(); InventoryController.AdjustStockByInventory(db, bill, details); BillController.UpdateState(db, bill, BillState.Finished); NotifyController.AddNotify(db, bill.OperName, NotifyType.InventoryPlanApprove, bill.BillNum, ""); }
/// <summary> /// 添加移库单,原料入库,成品入库,原料发货,成品出库,其它移库等等都当做移库处理,以SubBillType进行区分 /// </summary> /// <param name="db"></param> /// <param name="bill"></param> /// <param name="details"></param> /// <returns></returns> public static void AddStockMove(SpareEntities db, TB_BILL bill, List <TB_STOCK_MOVE> details) { SetBillNum(bill); //设置单据编号 details.ForEach(p => p.BillNum = bill.BillNum); //设置明细编号 BillController.AddOrUpdate(db, bill); //添加【移库单】单据 StockMoveController.AddList(db, details); //添加【移库单】明细 StockDetailController.ListMove(db, bill, details); //更新【库存主表】【库存明细】 NotifyController.AddNotify(db, bill.OperName, NotifyType.StockMoveApprove, bill.BillNum, ""); }
/// <summary> /// 【盘点单】更新盘点明细表 /// </summary> /// <param name="db"></param> /// <param name="bill"></param> /// <param name="details"></param> /// <returns></returns> public static void AddOrUpdateInventoryDetail(SpareEntities db, TB_BILL bill, List <TB_INVENTORY_DETAIL> details) { foreach (var detail in details) { InventoryController.AddOrUpdate(db, detail); } BillController.UpdateState(db, bill, BillState.Handling); NotifyController.AddNotify(db, bill.OperName, NotifyType.InventoryPlanUpdate, bill.BillNum, ""); }
/// <summary> /// 【盘点计划】取消 /// </summary> /// <param name="db"></param> /// <param name="bill"></param> /// <returns></returns> public static void CancelInventoryBill(SpareEntities db, TB_BILL bill) { //校验【盘点计划】状态是否为新建或已开始 if (bill.State != (int)BillState.New && bill.State != (int)BillState.Handling) { throw new WmsException(ResultCode.DataStateError, bill.BillNum, "状态错误,不应为:" + bill.State); } InventoryController.Cancel(db, bill); }
private void btnSearch_Click(object sender, RoutedEventArgs e) { this.dgProfile.ItemsSource = null; Decimal TotalMoney = 0; //合同金额总计 Decimal TotalCost = 0; //成本金额总计 Decimal TotalProfile = 0; //净利润金额合计 //项目查询 string year1 = this.cmbYear.Text; string month1 = this.cmbMonth.Text; string year2 = this.cmbYear2.Text; string month2 = this.cmbMonth2.Text; string start = year1 + "-" + month1 + "-1 00:00:00"; string end = year2 + "-" + month2 + "-1 23:59:59"; DateTime startDate = DateTime.Parse(start); DateTime endDate = DateTime.Parse(end).AddMonths(1).AddDays(-1); List <TB_PROJECT> list = Comments.Comment.QueryProject(0, "", "", startDate, endDate); if (list.Count > 0) { List <tmpProfile> ls = new List <tmpProfile>(); for (int i = 0; i < list.Count; i++) { tmpProfile tmp = new tmpProfile(); tmp.INDEX = i + 1; tmp.projName = list[i].OBJECTNAME; tmp.projDate = list[i].BEGINDATE.ToShortDateString(); tmp.projAddress = list[i].ADDRESS; tmp.LEADER = list[i].TEAMLEDER; tmp.SALER = list[i].CREATEUSER; tmp.MONEY = list[i].MONEY; TotalMoney += tmp.MONEY; tmp.COST = ExpenseBusiness.getTotalExpense(list[i].Id); TotalCost += tmp.COST; profileporcess pp = new profileporcess(); projProfileClass ppc = pp.getProfile(list[i]); if (ppc != null) { tmp.JLR = ppc.xmjlr; //净利润 tmp.JLV = ppc.mlv; //净利率 } TB_BILL bill = getBillInfo(list[i].Id); if (bill != null) { tmp.BILLDATE = bill.CREATEDATE.ToShortDateString(); } if (list[i].BILLDATE != null && list[i].BILLSTATUS == "已结算") { tmp.COMPLETEDATE = list[i].BILLDATE.Year.ToString() + "年" + list[i].BILLDATE.Month.ToString() + "月"; } ls.Add(tmp); } this.dgProfile.ItemsSource = ls; this.lab1.Content = "合计发票金额:" + TotalMoney.ToString(); this.lab2.Content = "合计成本金额:" + TotalCost.ToString(); this.lab3.Content = "合计净利润金额:" + TotalProfile.ToString(); } }
public static void ListOut(SpareEntities db, TB_BILL bill, List <TS_STOCK_DETAIL> details) { foreach (var detail in details) { Out(db, bill, detail); // //创建ERP接口 // ErpInterfaceController.CreateSH(db, detail.PartCode, detail.Qty, string.Empty, detail.LocCode, bill.BillNum, (BillType)(bill.BillType), bill.BillTime); } }
/// <summary> /// 取消【叫料单】 /// </summary> /// <param name="db"></param> /// <param name="bill"></param> /// <returns></returns> public static void CancelMaterialAsk(SpareEntities db, TB_BILL bill) { { //校验【叫料单】状态是否为新建 if (bill.State != (int)BillState.New) { throw new WmsException(ResultCode.DataStateError, bill.BillNum, "状态错误,不应为:" + bill.State); } BillController.UpdateState(db, bill, BillState.Cancelled); //更新【叫料单】状态为:取消 } }
private static void SetBillNum(TB_BILL bill) { if (!string.IsNullOrEmpty(bill.BillNum)) { return; } bill.BillNum = BillTypeController.GetBillNum((BillType)bill.BillType); bill.State = (int)BillState.New; bill.BillTime = DateTime.Now; // bill.StartTime = DateTime.Now; // bill.FinishTime = DateTime.Now; }
public static void Add(SpareEntities db, TB_BILL bill, string operName, OperateType operateType) { var log = new TL_BILL() { OperName = operName, LogTime = DateTime.Now, BillNum = bill.BillNum, BillType = bill.BillType, LogType = operateType.ToString(), }; db.TL_BILL.Add(log); }
private void grid_GridCellActivated(object sender, GridCellActivatedEventArgs e) { // MessageBox.Show(e.GridCell.GridRow.DataItem.ToString()); SpareEntities db = EntitiesFactory.CreateSpareInstance(); _bill = db.TB_BILL.SingleOrDefault(p => p.UID == grid.MasterUid); if (_bill == null) { return; } var billNum = _bill.BillNum; var count = SetDetailDataSource(billNum); grid.IsDetailVisible = count > 0; }
/// <summary> /// 确认【拣料单】 /// </summary> /// <param name="db"></param> /// <param name="bill"></param> /// <param name="details"></param> /// <returns></returns> public static void FinishMaterialOut(SpareEntities db, TB_BILL bill, List <TB_OUT> details) { //校验单据状态是否为执行中 if (bill.State != (int)BillState.New) { throw new WmsException(ResultCode.DataStateError, bill.BillNum, "状态错误,不应为:" + bill.State); } foreach (var detail in details) { var detailOut = detail.ToStockDetailOut(); StockDetailController.Out(db, bill, detailOut); } BillController.UpdateState(db, bill, BillState.Finished); //更新【拣料单】状态为:完成 NotifyController.AddNotify(db, bill.OperName, NotifyType.MaterialOutApprove, bill.BillNum, ""); }
private static void ReadRCPFile(List <string> dataList, string filename, SpareEntities db) { Console.WriteLine(@"接收采购订单收货数据开始"); var partList = new List <TA_PART>(); var billList = new List <TB_BILL>(); var MIList = new List <TB_IN>(); for (int i = 0; i < dataList.Count; i++) { string strErr = "采购订单收货文件 " + filename + " 第 " + i + " 行 \t"; string data = dataList[i]; var cols = data.Split(';'); if (cols.Length != 11) { Console.WriteLine(strErr + @" 格式错误" + Environment.NewLine + "\t\t\t\t" + data); continue; } //添加TB_BILL表数据 var bill = new TB_BILL(); var BillNum = ""; var SourceBillNum = cols[0]; if (billList.FirstOrDefault(p => p.SourceBillNum == SourceBillNum) == null) { bill.BillNum = BillNum; bill.BillTime = DateTime.Now; bill.BillType = (int)BillType.MaterialIn; bill.OperName = GlobalVar.OperName; bill.SourceBillNum = SourceBillNum; billList.Add(bill); } //添加TB_IN表记录 var MI = new TB_IN() { BillNum = BillNum, PoBillNum = SourceBillNum, PoLineNum = Convert.ToInt32(cols[1]), PartCode = cols[3], Batch = GetBatch(), ToLocCode = _defaultLoc, Qty = Convert.ToInt32(cols[4]), UnitPrice = Convert.ToDecimal(cols[5]), ProduceDate = DateTime.Now }; MIList.Add(MI); } BillHandler.AddMaterialIn(db, billList, MIList); Console.WriteLine(@"接收采购订单收货数据完成"); }
/// <summary> /// 执行【领用申请单】,生成【领用单】 /// </summary> /// <param name="db"></param> /// <param name="billAsk">申请单</param> /// <param name="details">申请明细</param> /// <returns></returns> public static string HandleMaterialAsk(SpareEntities db, TB_BILL billAsk, List <TB_ASK> details) { try { //校验【领用单】状态是否为批准 if (billAsk.State != (int)BillState.Approve) { return("申请单状态错误,不应为:" + billAsk.State); } var partPickList = new List <TB_OUT>(); foreach (var detail in details) { var pList = SpareOutController.GetList(db, detail); if (pList.Count == 0 || pList.Sum(p => p.OutQty) < detail.Qty) { return("库存不足,生成领用单失败!"); } partPickList.AddRange(pList); } var billPick = new TB_BILL { BillNum = "", SourceBillNum = billAsk.BillNum, BillType = (int)BillType.MaterialDeliver, SubBillType = (int)billAsk.SubBillType, BillTime = DateTime.Now, OperName = billAsk.OperName, SplyId = billAsk.SplyId, State = (int)BillState.New, Remark = "", }; SetBillNum(billPick); partPickList.ForEach(p => p.BillNum = billPick.BillNum); BillController.AddOrUpdate(db, billPick); SpareOutController.AddList(db, partPickList); BillController.UpdateState(db, billAsk, BillState.Handling); //更新【叫料单】状态为:执行中 NotifyController.AddNotify(db, billPick.OperName, NotifyType.MaterialOut, billAsk.BillNum, ""); return("OK"); } catch (Exception ex) { BillController.UpdateState(db, billAsk, BillState.Failed); billAsk.Remark = ex.ToString(); return(ex.ToString()); } }
public static void AddMaterialReturn(SpareEntities db, TB_BILL bill, List <TB_RETURN> details) { BillController.AddOrUpdate(db, bill); //添加单据 foreach (var detail in details) { var dbReturns = SpareReturnController.GetList(db, bill.BillNum).ToList(); foreach (var sparereturn in dbReturns) { if (details.FirstOrDefault(p => p.UID == sparereturn.UID) == null) { SpareReturnController.RemaveDetail(db, sparereturn); } } SpareReturnController.AddOrUpdate(db, detail);//添加或修改【领用归还单】明细 } NotifyController.AddNotify(db, bill.OperName, NotifyType.SpareReturnUpdate, bill.BillNum, ""); }
/// <summary> /// 添加【其它出入库单】 /// </summary> /// <param name="db"></param> /// <param name="bill">其它出入库单</param> /// <param name="details">其它出入库明细</param> /// <returns></returns> public static void AddOtherIn(SpareEntities db, TB_BILL bill, List <TB_OTHER_IN> details) { { SetBillNum(bill); //设置单据编号 details.ForEach(p => p.BillNum = bill.BillNum); //设置明细编号 BillController.AddOrUpdate(db, bill); //添加单据 foreach (var detail in details) { OtherInController.AddOrUpdate(db, detail); //添加明细 } var subBillType = (SubBillType)bill.SubBillType; switch (subBillType) { //出库 case SubBillType.OtherOut: //其它出库 // case SubBillType.ReturnToSupplier: //原料退货 case SubBillType.InventoryLoss: //盘亏 case SubBillType.ScrapDestroy: //报废销毁 // var detailsOut = details.Select(detail => detail.ToStockDetailOut(bill)).ToList(); // StockDetailController.ListOut(db, bill, detailsOut); //更新【库存主表】【库存明细】出库 // break; //入库 case SubBillType.OtherIn: //其它入库 // case SubBillType.ProductReturn: //成品退货 case SubBillType.InventoryProfit: //盘盈 var detailsIn = details.Select(detail => detail.ToStockDetailIn(bill)).ToList(); StockDetailController.ListIn(db, bill, detailsIn); //更新【库存主表】【库存明细】入库 break; case SubBillType.ProductUndecide: //隔离 case SubBillType.ProductScrap: //报废 // var detailsMove = details.Select(p => p.ToStockMove()).ToList(); // StockDetailController.ListMove(db, bill, detailsMove); //更新【库存主表】【库存明细】 break; default: throw new WmsException(ResultCode.Exception, bill.BillNum, "单据二级类型错误"); } NotifyController.AddNotify(db, bill.OperName, NotifyType.OtherInApprove, bill.BillNum, ""); } }
/// <summary> /// 根据【领用出库单】,生成【领用还回单】 /// </summary> /// <param name="db"></param> /// <param name="billAsk">申请单</param> /// <param name="details">申请明细</param> /// <returns></returns> public static string HandleMaterialReturn(SpareEntities db, TB_BILL billOut, List <TB_OUT> details) { try { //校验【领用单】状态是否为批准 if (billOut.State != (int)BillState.Finished) { return("申请单状态错误,不应为:" + billOut.State); } if (billOut.SubBillType != (int)SubBillType.SpareLoan) { return("非借出单,不能进行还回操作!"); } var partPickList = new List <TB_RETURN>(); foreach (var detail in details) { var pList = SpareReturnController.OutToReturnList(detail); partPickList.Add(pList); } var billPick = new TB_BILL { BillNum = "", SourceBillNum = billOut.BillNum, BillType = (int)BillType.SpareReturn, SubBillType = (int)SubBillType.SpareReturn, BillTime = DateTime.Now, OperName = billOut.OperName, SplyId = billOut.SplyId, State = (int)BillState.New, Remark = "", }; SetBillNum(billPick); partPickList.ForEach(p => p.BillNum = billPick.BillNum); BillController.AddOrUpdate(db, billPick); SpareReturnController.AddList(db, partPickList); NotifyController.AddNotify(db, billPick.OperName, NotifyType.SpareReturn, billPick.BillNum, ""); return("OK"); } catch (Exception ex) { BillController.UpdateState(db, billOut, BillState.Failed); billOut.Remark = ex.ToString(); return(ex.ToString()); } }
public static void _report_Initialize(GridppReport report, TB_BILL bill, string detailTableName, string indexColumnName) { Console.WriteLine(report.Parameters.Count); report.ParameterByName("BillNum").AsString = bill.BillNum; report.ParameterByName("SourceBillNum").AsString = bill.SourceBillNum; report.ParameterByName("BillType").AsString = bill.BillType.ToString(); report.ParameterByName("SubBillType").AsString = bill.SubBillType.ToString(); report.ParameterByName("BillTime").AsString = bill.BillTime.ToString(GlobalVar.LongTimeString); report.ParameterByName("StartTime").AsString = bill.StartTime; report.ParameterByName("FinishTime").AsString = bill.FinishTime; report.ParameterByName("SplyId").AsString = bill.SplyId; report.ParameterByName("OperName").AsString = bill.OperName; report.ParameterByName("State").AsString = bill.State.ToString(); report.ParameterByName("Remark").AsString = bill.Remark; report.ConnectionString = EntitiesFactory.WmsConnectionString; report.DetailGrid.Recordset.ConnectionString = EntitiesFactory.WmsConnectionString; report.DetailGrid.Recordset.QuerySQL = $"select * from {detailTableName} where {indexColumnName} = '{bill.BillNum}'"; }
private TB_BILL getBillInfo(int projId) { TB_BILL rtn = null; try { TB_BILL[] arr = TB_BILLDAO.FindAll(new EqExpression("PROJECTID", projId), new EqExpression("STATUS", 1)); if (arr.Length > 0) { rtn = arr[0]; } } catch (Exception ex) { throw ex; } return(rtn); }
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); //添加库存事务日志 }
/// <summary> /// 添加【叫料单】 /// </summary> /// <param name="db"></param> /// <param name="bill">叫料单</param> /// <param name="details">叫料明细</param> /// <returns></returns> public static void AddMaterialAsk(SpareEntities db, TB_BILL bill, List <TB_ASK> details) { if (bill.BillNum == null) { SetBillNum(bill); //设置单据编号 details.ForEach(p => p.BillNum = bill.BillNum); //设置明细编号 NotifyController.AddNotify(db, bill.OperName, NotifyType.MaterialAskUpdate, bill.BillNum, ""); //添加【叫料提醒单】 } else { NotifyController.AddNotify(db, bill.OperName, NotifyType.MaterialAsk, bill.BillNum, ""); //添加【叫料提醒单】 } BillController.AddOrUpdate(db, bill); //添加【生产叫料单】单据 foreach (var detail in details) { SpareAskController.AddOrUpdate(db, detail);//添加或修改【生产叫料单】明细 } }
/// <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); //添加盘点单据 } }