/// <summary> /// 审核 /// </summary> /// <param name="paramHead"></param> /// <param name="paramDetailList"></param> /// <returns></returns> public bool ApprovePayBill(PayBillManagerUIModel paramHead, SkyCarBindingList <PayBillManagerDetailUIModel, MDLFM_PayBillDetail> paramDetailList) { var funcName = "ApproveDetailDS"; LogHelper.WriteBussLogStart(BussID, LoginInfoDAX.UserName, funcName, "", "", null); if (paramHead == null) { //没有获取到付款单,审核失败 ResultMsg = MsgHelp.GetMsg(MsgCode.W_0024, new object[] { SystemTableEnums.Name.FM_PayBill, SystemActionEnum.Name.APPROVE }); return(false); } var payBillManagerDetailList = paramDetailList.Where(x => x.PBD_SourceTypeName == PayBillDetailSourceTypeEnum.Name.SGFK); if (payBillManagerDetailList.Count() != paramDetailList.Count() || payBillManagerDetailList.Count() == 0) { //收款单不为手工付款,不能审核 ResultMsg = MsgHelp.GetMsg(MsgCode.E_0017, new object[] { SystemTableEnums.Name.FM_PayBill + MsgParam.NO + MsgParam.BE + PayBillDetailSourceTypeEnum.Name.SGFK, SystemActionEnum.Name.APPROVE }); return(false); } #region 定义变量 //待更新[付款单] MDLFM_PayBill updatePayBill = paramHead.ToTBModelForSaveAndDelete <MDLFM_PayBill>(); //待更新[付款单明细] List <MDLFM_PayBillDetail> updatePayBillDetaillList = new List <MDLFM_PayBillDetail>(); //待新增对应的[应付单] List <MDLFM_AccountPayableBill> addAccountPayableBillList = new List <MDLFM_AccountPayableBill>(); //待新增对应的[应付单明细] List <MDLFM_AccountPayableBillDetail> addAccountPayableBillDetailList = new List <MDLFM_AccountPayableBillDetail>(); //待更新的[钱包] MDLEWM_Wallet updateWallet = new MDLEWM_Wallet(); //待新增的[钱包异动] MDLEWM_WalletTrans addWalletTrans = new MDLEWM_WalletTrans(); #endregion #region 准备数据 if (paramDetailList[0].PBD_SourceTypeName == PayBillDetailSourceTypeEnum.Name.SGFK) { #region 新增[应付单]和[应付单明细] foreach (var loopDetail in paramDetailList) { #region 新增[应付单] MDLFM_AccountPayableBill accountPayableBill = new MDLFM_AccountPayableBill { APB_ID = System.Guid.NewGuid().ToString(), APB_No = BLLCom.GetCoeusDocumentNo(DocumentTypeEnums.Code.APB), APB_BillDirectCode = BillDirectionEnum.Code.PLUS, APB_BillDirectName = BillDirectionEnum.Name.PLUS, APB_SourceTypeCode = AccountPayableBillSourceTypeEnum.Code.SGCJ, APB_SourceTypeName = AccountPayableBillSourceTypeEnum.Name.SGCJ, APB_ReceiveObjectTypeCode = paramHead.PB_RecObjectTypeCode, APB_ReceiveObjectTypeName = paramHead.PB_RecObjectTypeName, APB_ReceiveObjectID = paramHead.PB_RecObjectID, APB_ReceiveObjectName = paramHead.PB_RecObjectName, APB_Org_ID = LoginInfoDAX.OrgID, APB_Org_Name = LoginInfoDAX.OrgShortName, APB_AccountPayableAmount = loopDetail.PBD_PayAmount, APB_PaidAmount = loopDetail.PBD_PayAmount, APB_UnpaidAmount = 0, APB_BusinessStatusName = AccountPayableBillStatusEnum.Name.YWC, APB_BusinessStatusCode = AccountPayableBillStatusEnum.Code.YWC, APB_ApprovalStatusName = ApprovalStatusEnum.Name.YSH, APB_ApprovalStatusCode = ApprovalStatusEnum.Code.YSH, APB_IsValid = true, APB_CreatedBy = LoginInfoDAX.UserName, APB_CreatedTime = BLLCom.GetCurStdDatetime(), APB_UpdatedBy = LoginInfoDAX.UserName, APB_UpdatedTime = BLLCom.GetCurStdDatetime(), }; addAccountPayableBillList.Add(accountPayableBill); //回写付款单的来源的单号 loopDetail.PBD_SrcBillNo = accountPayableBill.APB_No; #endregion #region 新增[应付单明细] MDLFM_AccountPayableBillDetail accountPayableBillDetail = new MDLFM_AccountPayableBillDetail { APBD_ID = Guid.NewGuid().ToString(), APBD_APB_ID = accountPayableBill.APB_ID, APBD_IsMinusDetail = false, APBD_Org_ID = accountPayableBill.APB_Org_ID, APBD_Org_Name = accountPayableBill.APB_Org_Name, APBD_AccountPayableAmount = loopDetail.PBD_PayAmount, APBD_PaidAmount = loopDetail.PBD_PayAmount, APBD_UnpaidAmount = 0, APBD_BusinessStatusName = accountPayableBill.APB_BusinessStatusName, APBD_BusinessStatusCode = accountPayableBill.APB_BusinessStatusCode, APBD_ApprovalStatusName = accountPayableBill.APB_ApprovalStatusName, APBD_ApprovalStatusCode = accountPayableBill.APB_ApprovalStatusCode, APBD_IsValid = true, APBD_CreatedBy = LoginInfoDAX.UserName, APBD_CreatedTime = BLLCom.GetCurStdDatetime(), APBD_UpdatedBy = LoginInfoDAX.UserName, APBD_UpdatedTime = BLLCom.GetCurStdDatetime(), }; addAccountPayableBillDetailList.Add(accountPayableBillDetail); #endregion } #endregion } #region 更新[付款单]数据 updatePayBill.PB_ApprovalStatusName = ApprovalStatusEnum.Name.YSH; updatePayBill.PB_ApprovalStatusCode = ApprovalStatusEnum.Code.YSH; updatePayBill.PB_BusinessStatusName = PayBillStatusEnum.Name.YWC; updatePayBill.PB_BusinessStatusCode = PayBillStatusEnum.Code.YWC; updatePayBill.PB_UpdatedBy = LoginInfoDAX.UserName; updatePayBill.PB_UpdatedTime = BLLCom.GetCurStdDatetime(); #endregion #region 更新[付款单明细]数据 _bll.CopyModelList <PayBillManagerDetailUIModel, MDLFM_PayBillDetail>(paramDetailList, updatePayBillDetaillList); foreach (var loopPayBillDetaill in updatePayBillDetaillList) { loopPayBillDetaill.WHERE_PBD_ID = loopPayBillDetaill.PBD_ID; loopPayBillDetaill.WHERE_PBD_VersionNo = loopPayBillDetaill.PBD_VersionNo; loopPayBillDetaill.PBD_VersionNo++; } #endregion #region 更新[钱包余额]和新增[钱包异动] if (paramHead.PB_PayTypeName == TradeTypeEnum.Name.WALLET) { #region 更新[钱包] updateWallet.WHERE_Wal_ID = paramHead.Wal_ID; updateWallet.WHERE_Wal_VersionNo = paramHead.Wal_VersionNo; updateWallet.Wal_AvailableBalance = paramHead.Wal_AvailableBalance + paramHead.PB_RealPayableTotalAmount; paramHead.Wal_AvailableBalance = updateWallet.Wal_AvailableBalance ?? 0; #endregion #region 新增[钱包异动] addWalletTrans.WalT_ID = System.Guid.NewGuid().ToString(); addWalletTrans.WalT_Org_ID = LoginInfoDAX.OrgID; addWalletTrans.WalT_Org_Name = LoginInfoDAX.OrgShortName; addWalletTrans.WalT_Wal_ID = paramHead.Wal_ID; addWalletTrans.WalT_Wal_No = paramHead.Wal_No; addWalletTrans.WalT_Time = BLLCom.GetCurStdDatetime(); addWalletTrans.WalT_TypeCode = WalTransTypeEnum.Code.TK; addWalletTrans.WalT_TypeName = WalTransTypeEnum.Name.TK; addWalletTrans.WalT_Amount = paramHead.PB_RealPayableTotalAmount; addWalletTrans.WalT_BillNo = paramHead.PB_No; addWalletTrans.WalT_IsValid = true; addWalletTrans.WalT_CreatedBy = LoginInfoDAX.UserName; addWalletTrans.WalT_CreatedTime = BLLCom.GetCurStdDatetime(); addWalletTrans.WalT_UpdatedBy = LoginInfoDAX.UserName; addWalletTrans.WalT_UpdatedTime = BLLCom.GetCurStdDatetime(); #endregion } #endregion #endregion #region 带事务的保存 try { DBManager.BeginTransaction(DBCONFIG.Coeus); #region 更新[付款单] bool updatePayBillResult = _bll.Save(updatePayBill); if (!updatePayBillResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.APPROVE + SystemTableEnums.Name.FM_PayBill }); return(false); } #endregion #region 更新[付款单明细] foreach (var loopPayBillDetaill in updatePayBillDetaillList) { bool updateDetailResult = _bll.Update(loopPayBillDetaill); if (!updateDetailResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.APPROVE + SystemTableEnums.Name.FM_PayBillDetail }); return(false); } } #endregion #region 新增[应付单] bool addAccountPayableBillResult = _bll.InsertByList <MDLFM_AccountPayableBill, MDLFM_AccountPayableBill>(addAccountPayableBillList); if (!addAccountPayableBillResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { MsgParam.ADD + SystemTableEnums.Name.FM_AccountPayableBill }); return(false); } #endregion #region 新增[应付单明细] bool addAccountPayableBillDetailResult = _bll.InsertByList <MDLFM_AccountPayableBillDetail, MDLFM_AccountPayableBillDetail>(addAccountPayableBillDetailList); if (!addAccountPayableBillDetailResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { MsgParam.ADD + SystemTableEnums.Name.FM_AccountPayableBillDetail }); return(false); } #endregion #region 更新[钱包余额]和新增[钱包异动] if (paramHead.PB_PayTypeName == TradeTypeEnum.Name.WALLET) { #region 更新[钱包余额] bool updateWalletResult = _bll.Save(updateWallet); if (!updateWalletResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { MsgParam.UPDATE + SystemTableEnums.Name.EWM_Wallet }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } #endregion #region 新增[钱包异动] bool addWalletTransResult = _bll.Insert <MDLEWM_WalletTrans>(addWalletTrans); if (!addWalletTransResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { MsgParam.ADD + SystemTableEnums.Name.EWM_WalletTrans }); return(false); } #endregion } #endregion DBManager.CommitTransaction(DBCONFIG.Coeus); } catch (Exception ex) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0018, new object[] { SystemActionEnum.Name.APPROVE, ex.Message }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, MethodBase.GetCurrentMethod().ToString(), ex.Message, "", null); return(false); } #endregion //将最新数据回写给DetailDS CopyModel(updatePayBill, paramHead); return(true); }
/// <summary> /// 审核 /// </summary> /// <param name="paramHead">UIModel</param> /// <param name="paramDetailList">出库单明细列表</param> /// <returns></returns> public bool ApproveDetailDS(PurchaseReturnManagerUIModel paramHead, SkyCarBindingList <StockOutBillManagerDetailUIModel, MDLPIS_StockOutBillDetail> paramDetailList) { var funcName = "ApproveDetailDS"; LogHelper.WriteBussLogStart(BussID, LoginInfoDAX.UserName, funcName, "", "", null); #region 验证 if (paramHead == null || string.IsNullOrEmpty(paramHead.SOB_ID) || string.IsNullOrEmpty(paramHead.SOB_No)) { //没有获取到出库单,审核失败 ResultMsg = MsgHelp.GetMsg(MsgCode.W_0024, new object[] { SystemTableEnums.Name.PIS_StockOutBill, SystemActionEnum.Name.APPROVE }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } #endregion #region 准备数据 #region 变量定义 //待更新的出库单 MDLPIS_StockOutBill updateStockOutBill = paramHead.ToTBModelForSaveAndDelete <MDLPIS_StockOutBill>(); //待新增的[应付单] MDLFM_AccountPayableBill newAccountPayableBill = new MDLFM_AccountPayableBill(); //待新增的[应付单明细]列表 List <MDLFM_AccountPayableBillDetail> newAccountPayableBillDetailList = new List <MDLFM_AccountPayableBillDetail>(); //待更新的[库存]列表 List <MDLPIS_Inventory> updateInventoryList = new List <MDLPIS_Inventory>(); //待新增的[库存异动日志]列表 List <MDLPIS_InventoryTransLog> newInventoryTransLogList = new List <MDLPIS_InventoryTransLog>(); #endregion //计算出库金额 decimal totalStockOutAmount = CalculateStockOutAmount(updateStockOutBill, paramDetailList); #region 创建[应付单]的场合 if (updateStockOutBill.SOB_SourceTypeName == StockOutBillSourceTypeEnum.Name.THCK) { //应付单 newAccountPayableBill.APB_ID = Guid.NewGuid().ToString(); newAccountPayableBill.APB_No = BLLCom.GetCoeusDocumentNo(DocumentTypeEnums.Code.APB); newAccountPayableBill.APB_BillDirectCode = BillDirectionEnum.Code.MINUS; newAccountPayableBill.APB_BillDirectName = BillDirectionEnum.Name.MINUS; newAccountPayableBill.APB_SourceTypeCode = AccountPayableBillSourceTypeEnum.Code.CKYF; newAccountPayableBill.APB_SourceTypeName = AccountPayableBillSourceTypeEnum.Name.CKYF; newAccountPayableBill.APB_SourceBillNo = updateStockOutBill.SOB_No; newAccountPayableBill.APB_Org_ID = LoginInfoDAX.OrgID; newAccountPayableBill.APB_Org_Name = LoginInfoDAX.OrgShortName; newAccountPayableBill.APB_ReceiveObjectTypeCode = AmountTransObjectTypeEnum.Code.AUTOPARTSSUPPLIER; newAccountPayableBill.APB_ReceiveObjectTypeName = AmountTransObjectTypeEnum.Name.AUTOPARTSSUPPLIER; newAccountPayableBill.APB_ReceiveObjectID = paramHead.SOB_SUPP_ID; newAccountPayableBill.APB_ReceiveObjectName = paramHead.SOB_SUPP_Name; newAccountPayableBill.APB_AccountPayableAmount = -totalStockOutAmount; newAccountPayableBill.APB_PaidAmount = 0; newAccountPayableBill.APB_UnpaidAmount = -totalStockOutAmount; newAccountPayableBill.APB_BusinessStatusCode = AccountPayableBillStatusEnum.Code.ZXZ; newAccountPayableBill.APB_BusinessStatusName = AccountPayableBillStatusEnum.Name.ZXZ; newAccountPayableBill.APB_ApprovalStatusCode = ApprovalStatusEnum.Code.YSH; newAccountPayableBill.APB_ApprovalStatusName = ApprovalStatusEnum.Name.YSH; newAccountPayableBill.APB_IsValid = true; newAccountPayableBill.APB_CreatedBy = LoginInfoDAX.UserName; newAccountPayableBill.APB_CreatedTime = BLLCom.GetCurStdDatetime(); newAccountPayableBill.APB_UpdatedBy = LoginInfoDAX.UserName; newAccountPayableBill.APB_UpdatedTime = BLLCom.GetCurStdDatetime(); } #endregion #region 更新[出库单] //将出库单审核状态更新为[已审核],单据状态更新为[已完成] updateStockOutBill.SOB_VersionNo++; updateStockOutBill.SOB_ApprovalStatusCode = ApprovalStatusEnum.Code.YSH; updateStockOutBill.SOB_ApprovalStatusName = ApprovalStatusEnum.Name.YSH; updateStockOutBill.SOB_UpdatedBy = LoginInfoDAX.UserName; updateStockOutBill.SOB_UpdatedTime = BLLCom.GetCurStdDatetime(); //updateStockOutBill.SOB_StatusCode = StockOutBillStatusEnum.Code.YWC; //updateStockOutBill.SOB_StatusName = StockOutBillStatusEnum.Name.YWC; #endregion #region 遍历[出库单明细]列表,创建[应付单明细]和[应收单明细],创建或更新[库存],创建[库存异动日志] foreach (var loopStockOutBillDetail in paramDetailList) { if (string.IsNullOrEmpty(loopStockOutBillDetail.SOBD_Barcode) || string.IsNullOrEmpty(loopStockOutBillDetail.SOBD_BatchNo)) { continue; } if (updateStockOutBill.SOB_SourceTypeName == StockOutBillSourceTypeEnum.Name.THCK) { //出库明细 loopStockOutBillDetail.WHERE_SOBD_ID = loopStockOutBillDetail.SOBD_ID; loopStockOutBillDetail.WHERE_SOBD_VersionNo = loopStockOutBillDetail.SOBD_VersionNo; #region 应付单明细 MDLFM_AccountPayableBillDetail newAccountPayableBillDetail = new MDLFM_AccountPayableBillDetail { APBD_ID = Guid.NewGuid().ToString(), APBD_APB_ID = newAccountPayableBill.APB_ID, APBD_IsMinusDetail = false, APBD_SourceBillNo = updateStockOutBill.SOB_No, APBD_SourceBillDetailID = loopStockOutBillDetail.SOBD_ID, APBD_Org_ID = newAccountPayableBill.APB_Org_ID, APBD_Org_Name = newAccountPayableBill.APB_Org_Name, APBD_AccountPayableAmount = -loopStockOutBillDetail.SOBD_Amount, APBD_PaidAmount = 0, APBD_UnpaidAmount = -loopStockOutBillDetail.SOBD_Amount, APBD_BusinessStatusCode = newAccountPayableBill.APB_BusinessStatusCode, APBD_BusinessStatusName = newAccountPayableBill.APB_BusinessStatusName, APBD_ApprovalStatusCode = newAccountPayableBill.APB_ApprovalStatusCode, APBD_ApprovalStatusName = newAccountPayableBill.APB_ApprovalStatusName, APBD_IsValid = true, APBD_CreatedBy = LoginInfoDAX.UserName, APBD_CreatedTime = BLLCom.GetCurStdDatetime(), APBD_UpdatedBy = LoginInfoDAX.UserName, APBD_UpdatedTime = BLLCom.GetCurStdDatetime() }; newAccountPayableBillDetailList.Add(newAccountPayableBillDetail); #endregion #region 库存和库存异动日志 //在[出库单明细]列表中第一次出现的配件[库存]信息 MDLPIS_Inventory inventoryExists = null; foreach (var loopInventory in updateInventoryList) { if (loopInventory.INV_Barcode == loopStockOutBillDetail.SOBD_Barcode && loopInventory.INV_BatchNo == loopStockOutBillDetail.SOBD_BatchNo) { inventoryExists = loopInventory; break; } } if (inventoryExists != null) { if (inventoryExists.INV_Qty < loopStockOutBillDetail.SOBD_Qty) { //配件:loopStockOutBillDetail.SOBD_Name(条形码:loopStockOutBillDetail.SOBD_Barcode)的库存不足,审核失败 ResultMsg = MsgHelp.GetMsg(MsgCode.E_0030, new object[] { loopStockOutBillDetail.SOBD_Name, loopStockOutBillDetail.SOBD_Barcode, MsgParam.SHORTAGE, SystemActionEnum.Name.APPROVE }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } //[出库单明细]列表中已遍历过该配件,累减数量 inventoryExists.INV_Qty -= loopStockOutBillDetail.SOBD_Qty; //生成[库存异动日志] newInventoryTransLogList.Add(GenerateInventoryTransLogOfApprove(updateStockOutBill, loopStockOutBillDetail, inventoryExists)); } else { //[出库单明细]列表中第一次出现该配件 //查询该配件是否在[库存]中存在 MDLPIS_Inventory resultInventory = new MDLPIS_Inventory(); _bll.QueryForObject <MDLPIS_Inventory, MDLPIS_Inventory>(new MDLPIS_Inventory { WHERE_INV_Org_ID = updateStockOutBill.SOB_Org_ID, WHERE_INV_Barcode = loopStockOutBillDetail.SOBD_Barcode, WHERE_INV_BatchNo = loopStockOutBillDetail.SOBD_BatchNo, WHERE_INV_WH_ID = loopStockOutBillDetail.SOBD_WH_ID, WHERE_INV_IsValid = true }, resultInventory); //[库存]中不存在该配件 if (string.IsNullOrEmpty(resultInventory.INV_ID)) { //配件:loopStockOutBillDetail.SOBD_Name(条形码:loopStockOutBillDetail.SOBD_Barcode)的库存不存在,审核失败 ResultMsg = MsgHelp.GetMsg(MsgCode.E_0030, new object[] { loopStockOutBillDetail.SOBD_Name, loopStockOutBillDetail.SOBD_Barcode, MsgParam.NOTEXIST, SystemActionEnum.Name.APPROVE }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } if (resultInventory.INV_Qty < loopStockOutBillDetail.SOBD_Qty) { //配件:loopStockOutBillDetail.SOBD_Name(条形码:loopStockOutBillDetail.SOBD_Barcode)的库存不足,审核失败 ResultMsg = MsgHelp.GetMsg(MsgCode.E_0030, new object[] { loopStockOutBillDetail.SOBD_Name, loopStockOutBillDetail.SOBD_Barcode, MsgParam.SHORTAGE, SystemActionEnum.Name.APPROVE }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } //[库存]中存在该配件 //更新[库存]中该配件的数量 resultInventory.INV_Qty -= loopStockOutBillDetail.SOBD_Qty; resultInventory.INV_UpdatedBy = LoginInfoDAX.UserName; resultInventory.INV_UpdatedTime = BLLCom.GetCurStdDatetime(); resultInventory.WHERE_INV_ID = resultInventory.INV_ID; resultInventory.WHERE_INV_VersionNo = resultInventory.INV_VersionNo; updateInventoryList.Add(resultInventory); //生成[库存异动日志] newInventoryTransLogList.Add(GenerateInventoryTransLogOfApprove(updateStockOutBill, loopStockOutBillDetail, resultInventory)); } #endregion } } #endregion #endregion #region 带事务的新增和保存 try { DBManager.BeginTransaction(DBCONFIG.Coeus); #region 新增[应付单] if (!string.IsNullOrEmpty(newAccountPayableBill.APB_ID)) { bool insertAccountPayableBillResult = _bll.Insert(newAccountPayableBill); if (!insertAccountPayableBillResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.NEW + SystemTableEnums.Name.FM_AccountPayableBill }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } } #endregion #region 新增[应付单明细] if (newAccountPayableBillDetailList.Count > 0) { bool insertAccountPayableBillDetailResult = _bll.InsertByList <MDLFM_AccountPayableBillDetail, MDLFM_AccountPayableBillDetail>(newAccountPayableBillDetailList); if (!insertAccountPayableBillDetailResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.NEW + SystemTableEnums.Name.FM_AccountPayableBillDetail }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } } #endregion #region 保存[出库单] bool updateStockOutBillResult = _bll.Save(updateStockOutBill); if (!updateStockOutBillResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { MsgParam.UPDATE + SystemTableEnums.Name.PIS_StockOutBill }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } #endregion #region 保存[出库单明细] var updateDetailList = new List <MDLPIS_StockOutBillDetail>(); //将当前DetailGridDS转换为指定类型的TBModelList paramDetailList.ToTBModelListForUpdateAndDelete <MDLPIS_StockOutBillDetail>(updateDetailList); foreach (var loopStockoutBillDetail in updateDetailList) { bool saveStockOutBillDetailResult = _bll.Save(loopStockoutBillDetail); if (!saveStockOutBillDetailResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.SAVE + SystemTableEnums.Name.PIS_StockOutBillDetail }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } } #endregion #region 更新[库存] foreach (var loopInventory in updateInventoryList) { bool saveInventoryResult = _bll.Save(loopInventory); if (!saveInventoryResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.SAVE + SystemTableEnums.Name.PIS_Inventory }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } } #endregion #region 新增[库存异动日志] if (newInventoryTransLogList.Count > 0) { bool insertInventoryTransLogResult = _bll.InsertByList <MDLPIS_InventoryTransLog, MDLPIS_InventoryTransLog>(newInventoryTransLogList); if (!insertInventoryTransLogResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.NEW + SystemTableEnums.Name.PIS_InventoryTransLog }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } } #endregion DBManager.CommitTransaction(DBCONFIG.Coeus); } catch (Exception ex) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0018, new object[] { SystemActionEnum.Name.APPROVE, ex.Message }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } #endregion //将最新数据回写给DetailDS CopyModel(updateStockOutBill, paramHead); //更新明细版本号 foreach (var loopInsertDetail in paramDetailList.InsertList) { //新增时版本号为1 loopInsertDetail.SOBD_VersionNo = 1; } foreach (var loopUpdateDetail in paramDetailList.UpdateList) { //更新时版本号加1 loopUpdateDetail.SOBD_VersionNo = loopUpdateDetail.SOBD_VersionNo + 1; } return(true); }