public ResultModel Complete(UserModel user, int customId) { ResultModel result = new ResultModel(); try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { result = this.customsclearanceDAL.Get(user, customId); if (result.ResultStatus != 0) return result; Model.CustomsClearance customsClearance = result.ReturnValue as CustomsClearance; if (customsClearance == null) { result.Message = "该数据不存在,不能完成"; return result; } result = customsclearanceDAL.Complete(user, customsClearance); if (result.ResultStatus != 0) return result; //获取所有已生效的明细 DAL.CustomsDetailDAL customsDetailDAL = new CustomsDetailDAL(); result = customsDetailDAL.Load(user, customId, StatusEnum.已生效); if (result.ResultStatus != 0) return result; List<Model.CustomsDetail> details = result.ReturnValue as List<Model.CustomsDetail>; if (details == null || !details.Any()) { result.ResultStatus = -1; result.Message = "获取失败"; return result; } DAL.StockLogDAL stockLogDAL = new StockLogDAL(); DAL.StockDAL stockDAL = new StockDAL(); foreach (Model.CustomsDetail detail in details) { //明细完成 result = customsDetailDAL.Complete(user, detail); if (result.ResultStatus != 0) return result; //获取报关流水 result = stockLogDAL.Get(user, detail.StockLogId); if (result.ResultStatus != 0) return result; Model.StockLog stockLog = result.ReturnValue as Model.StockLog; if (stockLog == null || stockLog.StockLogId <= 0) { result.ResultStatus = -1; result.Message = "报关流水获取失败"; return result; } //完成报关流水 result = stockLogDAL.Complete(user, stockLog); if (result.ResultStatus != 0) return result; //获取库存 result = stockDAL.Get(user, detail.StockId); if (result.ResultStatus != 0) return result; Model.Stock stock = result.ReturnValue as Model.Stock; if (stock == null || stock.StockId <= 0) { result.ResultStatus = -1; result.Message = "库存获取失败"; return result; } stock.StockStatus = (int)stock.PreStatus == 0 ? StockStatusEnum.在库正常 : stock.PreStatus; stock.CustomsType = NFMT.Data.DetailProvider.Details(Data.StyleEnum.CustomType)["InsideCustom"].StyleDetailId;//关内 result = stockDAL.Update(user, stock); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.Message = ex.Message; } finally { if (result.ResultStatus != 0) log.ErrorFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue); else if (log.IsInfoEnabled) log.InfoFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue); } return result; }
public ResultModel CompleteCancel(UserModel user, int customId) { ResultModel result = new ResultModel(); try { using (System.Transactions.TransactionScope scope = new TransactionScope()) { result = this.customsclearanceDAL.Get(user, customId); if (result.ResultStatus != 0) return result; Model.CustomsClearance customsClearance = result.ReturnValue as CustomsClearance; if (customsClearance == null) { result.Message = "该数据不存在,不能完成"; result.ResultStatus = -1; return result; } result = customsclearanceDAL.CompleteCancel(user, customsClearance); if (result.ResultStatus != 0) return result; //获取所有已生效的明细 DAL.CustomsDetailDAL customsDetailDAL = new CustomsDetailDAL(); result = customsDetailDAL.Load(user, customId, StatusEnum.已完成); if (result.ResultStatus != 0) return result; List<Model.CustomsDetail> details = result.ReturnValue as List<Model.CustomsDetail>; if (details == null || !details.Any()) { result.ResultStatus = -1; result.Message = "获取失败"; return result; } DAL.StockLogDAL stockLogDAL = new StockLogDAL(); DAL.StockDAL stockDAL = new StockDAL(); foreach (Model.CustomsDetail detail in details) { //明细完成 result = customsDetailDAL.CompleteCancel(user, detail); if (result.ResultStatus != 0) return result; //获取报关流水 result = stockLogDAL.Get(user, detail.StockLogId); if (result.ResultStatus != 0) return result; Model.StockLog stockLog = result.ReturnValue as Model.StockLog; if (stockLog == null || stockLog.StockLogId <= 0) { result.ResultStatus = -1; result.Message = "报关流水获取失败"; return result; } //完成报关流水 result = stockLogDAL.CompleteCancel(user, stockLog); if (result.ResultStatus != 0) return result; //获取库存 result = stockDAL.Get(user, detail.StockId); if (result.ResultStatus != 0) return result; Model.Stock stock = result.ReturnValue as Model.Stock; if (stock == null || stock.StockId <= 0) { result.ResultStatus = -1; result.Message = "库存获取失败"; return result; } stock.StockStatus = StockStatusEnum.预报关库存; stock.CustomsType = NFMT.Data.DetailProvider.Details(Data.StyleEnum.CustomType)["OutsideCustom"].StyleDetailId;//关外 result = stockDAL.Update(user, stock); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; return result; } return result; }
public ResultModel Audit(UserModel user, NFMT.WorkFlow.Model.DataSource dataSource, bool isPass) { ResultModel result = new ResultModel(); try { DAL.StockDAL stockDAL = new StockDAL(); NFMT.WareHouse.DAL.StockLogDAL stockLogDAL = new StockLogDAL(); NFMT.WareHouse.DAL.StockReceiptDetailDAL stockReceiptDetailDAL = new StockReceiptDetailDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { result = this.stockreceiptDAL.Get(NFMT.Common.DefaultValue.SysUser, dataSource.RowId); if (result.ResultStatus != 0) return result; Model.StockReceipt stockReceipt = result.ReturnValue as Model.StockReceipt; if (stockReceipt == null || stockReceipt.ReceiptId <= 0) { result.ResultStatus = -1; result.Message = "库存回执不存在"; return result; } //审核,修改数据状态 result = this.stockreceiptDAL.Audit(user, stockReceipt, isPass); if (result.ResultStatus != 0) return result; //审核通过 if (isPass) { //获取回执明细 result = stockReceiptDetailDAL.Load(user, stockReceipt.ReceiptId); if (result.ResultStatus != 0) return result; List<Model.StockReceiptDetail> stockReceiptDetails = result.ReturnValue as List<Model.StockReceiptDetail>; if (stockReceiptDetails == null || stockReceiptDetails.Count == 0) { result.ResultStatus = -1; result.Message = "获取回执明细失败"; return result; } foreach (Model.StockReceiptDetail detail in stockReceiptDetails) { //获取库存流水 result = stockLogDAL.Get(NFMT.Common.DefaultValue.SysUser, detail.StockLogId); if (result.ResultStatus != 0) return result; Model.StockLog stockLog = result.ReturnValue as Model.StockLog; if (stockLog == null || stockLog.StockLogId <= 0) { result.ResultStatus = -1; result.Message = "获取库存流水失败"; return result; } //更新库存流水回执重量 stockLog.GapAmount += detail.QtyMiss; result = stockLogDAL.Update(user, stockLog); if (result.ResultStatus != 0) return result; //获取库存 result = stockDAL.Get(user, detail.StockId); if (result.ResultStatus != 0) return result; Model.Stock stock = result.ReturnValue as Model.Stock; if (stock == null || stock.StockId <= 0) { result.ResultStatus = -1; result.Message = "库存不存在"; return result; } //更新库存净重 if (stockReceipt.ReceiptType == (int)ReceiptTypeEnum.入库回执) { stock.ReceiptInGap += detail.QtyMiss; //stock.NetAmount += detail.QtyMiss; } else stock.ReceiptOutGap += detail.QtyMiss; stock.CurNetAmount = detail.ReceiptAmount; result = stockDAL.Update(user, stock); if (result.ResultStatus != 0) return result; } } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; return result; } return result; }
public ResultModel CompleteCancel(UserModel user, int receiptId) { ResultModel result = new ResultModel(); try { DAL.StockDAL stockDAL = new StockDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { result = this.stockreceiptDAL.Get(user, receiptId); if (result.ResultStatus != 0) return result; StockReceipt stockReceipt = result.ReturnValue as StockReceipt; if (stockReceipt == null || stockReceipt.ReceiptId <= 0) { result.ResultStatus = -1; result.Message = "该数据不存在,不能作废"; return result; } result = this.stockreceiptDAL.CompleteCancel(user, stockReceipt); if (result.ResultStatus != 0) return result; StockReceiptDetailDAL detailDAL = new StockReceiptDetailDAL(); result = detailDAL.Load(user, stockReceipt.ReceiptId, StatusEnum.已完成); if (result.ResultStatus != 0) return result; List<Model.StockReceiptDetail> details = result.ReturnValue as List<Model.StockReceiptDetail>; if (details == null) { result.ResultStatus = -1; result.Message = "获取回执明细失败"; return result; } foreach (Model.StockReceiptDetail detail in details) { result = detailDAL.CompleteCancel(user, detail); if (result.ResultStatus != 0) return result; //获取库存 result = stockDAL.Get(user, detail.StockId); if (result.ResultStatus != 0) return result; Model.Stock stock = result.ReturnValue as Model.Stock; if (stock == null || stock.StockId <= 0) { result.ResultStatus = -1; result.Message = "库存不存在"; return result; } //更新库存净重 if (stockReceipt.ReceiptType == (int)ReceiptTypeEnum.入库回执) { stock.ReceiptInGap -= detail.QtyMiss; stock.NetAmount -= detail.QtyMiss; } else stock.ReceiptOutGap -= detail.QtyMiss; stock.CurNetAmount -= detail.QtyMiss; result = stockDAL.Update(user, stock); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } finally { if (result.ResultStatus != 0) log.ErrorFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue); else if (log.IsInfoEnabled) log.InfoFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue); } return result; }
public ResultModel StockReceiptUpdate(UserModel user, int detailId, int stockId, int stockLogId, decimal receiptAmount) { ResultModel result = new ResultModel(); try { DAL.StockDAL stockDAL = new StockDAL(); DAL.StockLogDAL stockLogDAL = new StockLogDAL(); DAL.StockReceiptDetailDAL stockReceiptDetailDAL = new StockReceiptDetailDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { result = stockReceiptDetailDAL.Get(user, detailId); if (result.ResultStatus != 0) return result; Model.StockReceiptDetail stockReceiptDetail = result.ReturnValue as Model.StockReceiptDetail; if (stockReceiptDetail == null || stockReceiptDetail.DetailId <= 0) { result.ResultStatus = -1; result.Message = "获取库存回执错误"; return result; } stockReceiptDetail.ReceiptAmount = receiptAmount; stockReceiptDetail.QtyMiss = receiptAmount - stockReceiptDetail.PreNetAmount; stockReceiptDetail.QtyRate = (receiptAmount / stockReceiptDetail.PreNetAmount - 1) / 100; //修改库存回执明细 result = stockReceiptDetailDAL.Update(user, stockReceiptDetail); if (result.ResultStatus != 0) return result; //获取库存回执 result = stockreceiptDAL.Get(user, stockReceiptDetail.ReceiptId); if (result.ResultStatus != 0) return result; Model.StockReceipt stockReceipt = result.ReturnValue as Model.StockReceipt; if (stockReceipt == null || stockReceipt.ReceiptId <= 0) { result.ResultStatus = -1; result.Message = "获取库存回执出错"; return result; } result = stockLogDAL.Get(user, stockLogId); if (result.ResultStatus != 0) return result; Model.StockLog stockLog = result.ReturnValue as Model.StockLog; if (stockLog == null || stockLog.StockLogId <= 0) { result.ResultStatus = -1; result.Message = "获取库存流水出错"; return result; } stockLog.GapAmount = receiptAmount - stockReceiptDetail.PreNetAmount; //更新库存流水 result = stockLogDAL.Update(user, stockLog); if (result.ResultStatus != 0) return result; //获取库存 result = stockDAL.Get(user, stockId); if (result.ResultStatus != 0) return result; Model.Stock stock = result.ReturnValue as Model.Stock; if (stock == null || stock.StockId <= 0) { result.ResultStatus = -1; result.Message = "获取库存出错"; return result; } if (stockReceipt.ReceiptType == (int)NFMT.WareHouse.ReceiptTypeEnum.入库回执) { stock.ReceiptInGap = receiptAmount - stockReceiptDetail.PreNetAmount; } else if (stockReceipt.ReceiptType == (int)NFMT.WareHouse.ReceiptTypeEnum.出库回执) { stock.ReceiptOutGap = receiptAmount - stockReceiptDetail.PreNetAmount; } stock.CurNetAmount = receiptAmount; //更新库存 result = stockDAL.Update(user, stock); if (result.ResultStatus != 0) return result; //若此库存已开业务票,则修改业务票中的净重 result = stockreceiptDAL.UpdateBussinessInvDetail(user, stockLogId, receiptAmount); if (result.ResultStatus != 0) return result; scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } finally { if (result.ResultStatus != 0) log.ErrorFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue); else if (log.IsInfoEnabled) log.InfoFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue); } return result; }
public ResultModel CompleteCancel(UserModel user, int stockOutId) { ResultModel result = new ResultModel(); try { DAL.StockLogDAL stockLogDAL = new StockLogDAL(); DAL.StockDAL stockDAL = new StockDAL(); DAL.StockNameDAL stockNameDAL = new StockNameDAL(); DAL.StockOutDAL stockOutDAL = new StockOutDAL(); DAL.StockOutDetailDAL stockOutDetailDAL = new StockOutDetailDAL(); DAL.StockOutApplyDAL outApplyDAL = new StockOutApplyDAL(); Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证出库 result = stockoutDAL.Get(user, stockOutId); if (result.ResultStatus != 0) return result; StockOut stockOut = result.ReturnValue as StockOut; if (stockOut == null || stockOut.StockOutId <= 0) { result.ResultStatus = -1; result.Message = "该数据不存在,不能进行执行完成操作"; return result; } //撤销出库 result = this.stockoutDAL.CompleteCancel(user, stockOut); if (result.ResultStatus != 0) return result; //验证出库申请 result = outApplyDAL.Get(user, stockOut.StockOutApplyId); if (result.ResultStatus != 0) return result; Model.StockOutApply outApply = result.ReturnValue as Model.StockOutApply; if (outApply == null || outApply.StockOutApplyId <= 0) { result.ResultStatus = -1; result.Message = "出库申请不存在"; return result; } //验证主申请 result = applyDAL.Get(user, outApply.ApplyId); if (result.ResultStatus != 0) return result; Operate.Model.Apply apply = result.ReturnValue as Operate.Model.Apply; if (apply == null || apply.ApplyId <= 0) { result.ResultStatus = -1; result.Message = "主申请不存在"; return result; } //判断主申请状态是否为已生效, if (apply.ApplyStatus != StatusEnum.已生效) { result.ResultStatus = -1; result.Message = "申请状态只有在已生效下才能进行执行完成撤销"; return result; } //获取已完成出库明细 result = stockOutDetailDAL.Load(user, stockOut.StockOutId, Common.StatusEnum.已完成); if (result.ResultStatus != 0) return result; List<Model.StockOutDetail> details = result.ReturnValue as List<Model.StockOutDetail>; if (details == null) { result.ResultStatus = -1; result.Message = "获取出库明细错误"; return result; } //将所有已完成出库明细更新至已生效 foreach (Model.StockOutDetail detail in details) { result = stockOutDetailDAL.CompleteCancel(user, detail); if (result.ResultStatus != 0) return result; //获取出库流水 result = stockLogDAL.Get(user, detail.StockLogId); if (result.ResultStatus != 0) return result; Model.StockLog stockLog = result.ReturnValue as Model.StockLog; if (stockLog == null || stockLog.StockLogId <= 0) { result.ResultStatus = -1; result.Message = "获取出库流水失败"; return result; } //更新出库流水状态为已生效 result = stockLogDAL.CompleteCancel(user, stockLog); if (result.ResultStatus != 0) return result; //获取库存 result = stockDAL.Get(user,stockLog.StockId); if(result.ResultStatus!=0) return result; Model.Stock stock = result.ReturnValue as Model.Stock; if (stock == null || stock.StockId <= 0) { result.ResultStatus = -1; result.Message = "获取库存错误"; return result; } //库存重量添加 stock.CurGrossAmount += detail.GrossAmount; stock.CurNetAmount += detail.NetAmount; stock.Bundles += detail.Bundles; //明细关联库存状态更新至前一状态 if (stock.StockStatus == StockStatusEnum.已售库存) stock.StockStatus = StockStatusEnum.预售库存; result = stockDAL.Update(user, stock); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }
public ResultModel Complete(UserModel user, int stockOutId) { ResultModel result = new ResultModel(); try { StockDAL stockDAL = new StockDAL(); StockLogDAL stockLogDAL = new StockLogDAL(); StockNameDAL stockNameDAL = new StockNameDAL(); StockOutDetailDAL stockOutDetailDAL = new StockOutDetailDAL(); StockOutApplyDAL applyDAL = new StockOutApplyDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证出库 result = stockoutDAL.Get(user, stockOutId); if (result.ResultStatus != 0) return result; StockOut resultObj = result.ReturnValue as StockOut; if (resultObj == null || resultObj.StockOutId <= 0) { result.ResultStatus = -1; result.Message = "该数据不存在,不能进行执行完成操作"; return result; } //执行完成 result = stockoutDAL.Complete(user, resultObj); if (result.ResultStatus != 0) return result; //加载明细 result = stockOutDetailDAL.Load(user, resultObj.StockOutId); if (result.ResultStatus != 0) return result; List<Model.StockOutDetail> details = result.ReturnValue as List<Model.StockOutDetail>; if (details == null) { result.ResultStatus = -1; result.Message = "获取出库明细失败"; return result; } //加载对应出库申请 result = applyDAL.Get(user, resultObj.StockOutApplyId); if (result.ResultStatus != 0) return result; StockOutApply apply = result.ReturnValue as StockOutApply; if (apply == null || apply.StockOutApplyId <= 0) { result.ResultStatus = -1; result.Message = "对应出库申请加载失败"; return result; } //明细执行完成 foreach(Model.StockOutDetail detail in details) { //出库明细完成 result = stockOutDetailDAL.Complete(user,detail); if (result.ResultStatus != 0) return result; //获取出库流水 result = stockLogDAL.Get(user, detail.StockLogId); if (result.ResultStatus != 0) return result; Model.StockLog stockLog = result.ReturnValue as Model.StockLog; if (stockLog == null || stockLog.StockLogId <= 0) { result.ResultStatus = -1; result.Message = "出库流水获取失败"; return result; } //完成出库流水 result = stockLogDAL.Complete(user, stockLog); if (result.ResultStatus != 0) return result; //获取库存 result = stockDAL.Get(user, stockLog.StockId); if (result.ResultStatus != 0) return result; Model.Stock stock = result.ReturnValue as Model.Stock; if (stock == null || stock.StockId <= 0) { result.ResultStatus = -1; result.Message = "库存获取失败"; return result; } //库存重量捆数减少 stock.CurGrossAmount -= detail.GrossAmount; stock.CurNetAmount -= detail.NetAmount; stock.Bundles -= detail.Bundles; //库存状态修改 if (stock.StockStatus == StockStatusEnum.预售库存) stock.StockStatus = StockStatusEnum.已售库存; result = stockDAL.Update(user, stock); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }