/// <summary> /// 【反审核】生成库存异动日志 /// </summary> /// <param name="paramStockOutBill">出库单</param> /// <param name="paramStockOutBillDetail">出库单明细</param> /// <param name="paramInventory">库存</param> /// <returns></returns> private MDLPIS_InventoryTransLog GenerateInventoryTransLogOfUnApprove(MDLPIS_StockOutBill paramStockOutBill, StockOutBillManagerDetailUIModel paramStockOutBillDetail, MDLPIS_Inventory paramInventory) { MDLPIS_InventoryTransLog newInventoryTransLog = new MDLPIS_InventoryTransLog { ITL_Org_ID = string.IsNullOrEmpty(paramStockOutBill.SOB_Org_ID) ? LoginInfoDAX.OrgID : paramStockOutBill.SOB_Org_ID, ITL_WH_ID = paramInventory.INV_WH_ID, ITL_WHB_ID = paramStockOutBillDetail.SOBD_WHB_ID, //业务单号为[出库单]的单号 ITL_BusinessNo = paramStockOutBill.SOB_No, ITL_Barcode = paramInventory.INV_Barcode, ITL_BatchNo = paramInventory.INV_BatchNo, ITL_Name = paramStockOutBillDetail.SOBD_Name, ITL_Specification = paramStockOutBillDetail.SOBD_Specification, ITL_UnitCostPrice = paramInventory.INV_PurchaseUnitPrice, ITL_UnitSalePrice = paramStockOutBillDetail.SOBD_UnitSalePrice, //出库 反审核,实际为入库,数量为正 ITL_Qty = paramStockOutBillDetail.SOBD_Qty, ITL_AfterTransQty = paramInventory.INV_Qty, ITL_IsValid = true, ITL_CreatedBy = LoginInfoDAX.UserName, ITL_UpdatedBy = LoginInfoDAX.UserName }; //异动类型 switch (paramStockOutBill.SOB_SourceTypeName) { case StockOutBillSourceTypeEnum.Name.THCK: //退货出库 newInventoryTransLog.ITL_TransType = InventoryTransTypeEnum.Name.THCK; break; case StockOutBillSourceTypeEnum.Name.XSCK: //销售出库 newInventoryTransLog.ITL_TransType = InventoryTransTypeEnum.Name.XSCK; break; } return(newInventoryTransLog); }
/// <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); }
/// <summary> /// 【审核-退货】生成销售退货入库的库存异动日志 /// </summary> /// <param name="paramStockInBill">入库单</param> /// <param name="paramReturnStockInDetail">退货入库明细</param> /// <param name="paramInventory">库存</param> /// <param name="paramSalesReturnOrderManager">销售退货</param> /// <returns></returns> private MDLPIS_InventoryTransLog GenerateStockInInventoryTransLog(MDLPIS_StockInBill paramStockInBill, ReturnStockInDetailUIModel paramReturnStockInDetail, MDLPIS_Inventory paramInventory, SalesReturnOrderManagerUIModel paramSalesReturnOrderManager) { MDLPIS_InventoryTransLog newInventoryTransLog = new MDLPIS_InventoryTransLog { ITL_Org_ID = string.IsNullOrEmpty(paramStockInBill.SIB_Org_ID) ? LoginInfoDAX.OrgID : paramStockInBill.SIB_Org_ID, ITL_WH_ID = paramInventory.INV_WH_ID, ITL_WHB_ID = paramReturnStockInDetail.SID_WHB_ID, //业务单号为[入库单]的单号 ITL_BusinessNo = paramStockInBill.SIB_No, ITL_Barcode = paramInventory.INV_Barcode, ITL_BatchNo = paramInventory.INV_BatchNo, ITL_Name = paramReturnStockInDetail.SID_Name, ITL_Specification = paramReturnStockInDetail.SID_Specification, ITL_UnitCostPrice = paramInventory.INV_PurchaseUnitPrice, ITL_UnitSalePrice = null, //入库,数量为正 ITL_Qty = paramReturnStockInDetail.SID_Qty, ITL_AfterTransQty = paramInventory.INV_Qty, ITL_IsValid = true, ITL_CreatedBy = LoginInfoDAX.UserName, ITL_UpdatedBy = LoginInfoDAX.UserName, //异动类型为{销售退货} ITL_TransType = InventoryTransTypeEnum.Name.XSTH, ITL_Source = paramSalesReturnOrderManager.AROrgName, ITL_Destination = paramReturnStockInDetail.WH_Name, }; return(newInventoryTransLog); }
/// <summary> /// 反审核 /// </summary> /// <param name="paramHead">UIModel</param> /// <param name="paramDetailList">出库单明细列表</param> /// <returns></returns> public bool UnApproveDetailDS(StockOutBillManagerUIModel paramHead, SkyCarBindingList <StockOutBillManagerDetailUIModel, MDLPIS_StockOutBillDetail> paramDetailList) { var funcName = "UnApproveDetailDS"; 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.UNAPPROVE }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } #endregion #region 准备数据 #region 变量定义 //待更新的[出库单] var updateStockOutBill = paramHead.ToTBModelForSaveAndDelete <MDLPIS_StockOutBill>(); //待删除的[应收单] MDLFM_AccountReceivableBill deleteAccountReceivableBill = new MDLFM_AccountReceivableBill(); //待删除的[应收单明细]列表 List <MDLFM_AccountReceivableBillDetail> deleteAccountReceivableBillDetailList = new List <MDLFM_AccountReceivableBillDetail>(); //待新增的[库存异动日志]列表 List <MDLPIS_InventoryTransLog> newInventoryTransLogList = new List <MDLPIS_InventoryTransLog>(); //待更新的[库存]列表 List <MDLPIS_Inventory> updateInventoryList = new List <MDLPIS_Inventory>(); #endregion #region 更新[出库单] //将出库单[审核状态]更新为[待审核],[单据状态]更新为[已生成] updateStockOutBill.SOB_VersionNo++; updateStockOutBill.SOB_ApprovalStatusCode = ApprovalStatusEnum.Code.DSH; updateStockOutBill.SOB_ApprovalStatusName = ApprovalStatusEnum.Name.DSH; updateStockOutBill.SOB_UpdatedBy = LoginInfoDAX.UserName; updateStockOutBill.SOB_UpdatedTime = BLLCom.GetCurStdDatetime(); //updateStockOutBill.SOB_StatusCode = StockOutBillStatusEnum.Code.YSC; //updateStockOutBill.SOB_StatusName = StockOutBillStatusEnum.Name.YSC; #endregion #region 获取待删除的[应收单] _bll.QueryForObject <MDLFM_AccountReceivableBill, MDLFM_AccountReceivableBill>(new MDLFM_AccountReceivableBill { WHERE_ARB_SrcBillNo = updateStockOutBill.SOB_No, WHERE_ARB_IsValid = true }, deleteAccountReceivableBill); deleteAccountReceivableBill.WHERE_ARB_ID = deleteAccountReceivableBill.ARB_ID; #endregion #region 获取待删除的[应收单明细]列表 if (!string.IsNullOrEmpty(deleteAccountReceivableBill.ARB_ID)) { _bll.QueryForList <MDLFM_AccountReceivableBillDetail, MDLFM_AccountReceivableBillDetail>(new MDLFM_AccountReceivableBillDetail { WHERE_ARBD_ARB_ID = deleteAccountReceivableBill.ARB_ID, WHERE_ARBD_SrcBillNo = updateStockOutBill.SOB_No, WHERE_ARBD_IsValid = true }, deleteAccountReceivableBillDetailList); } foreach (var loopAccountReceivableBillDetail in deleteAccountReceivableBillDetailList) { if (string.IsNullOrEmpty(loopAccountReceivableBillDetail.ARBD_ID)) { continue; } loopAccountReceivableBillDetail.WHERE_ARBD_ID = loopAccountReceivableBillDetail.ARBD_ID; } #endregion #region 获取待更新的[库存]列表,生成[库存异动日志] foreach (var loopDetail in paramDetailList) { //待更新的[库存] MDLPIS_Inventory updateInventory = new MDLPIS_Inventory(); _bll.QueryForObject <MDLPIS_Inventory, MDLPIS_Inventory>(new MDLPIS_Inventory { WHERE_INV_Org_ID = updateStockOutBill.SOB_Org_ID, WHERE_INV_WH_ID = loopDetail.SOBD_WH_ID, WHERE_INV_WHB_ID = loopDetail.SOBD_WHB_ID, WHERE_INV_Barcode = loopDetail.SOBD_Barcode, WHERE_INV_BatchNo = loopDetail.SOBD_BatchNo, WHERE_INV_IsValid = true }, updateInventory); if (!string.IsNullOrEmpty(updateInventory.INV_ID) && !string.IsNullOrEmpty(updateInventory.INV_Barcode) && !string.IsNullOrEmpty(updateInventory.INV_BatchNo)) { //[反审核]时,恢复[审核]时出库的配件数量 updateInventory.INV_Qty += loopDetail.SOBD_Qty; updateInventory.INV_UpdatedBy = LoginInfoDAX.UserName; updateInventory.INV_UpdatedTime = BLLCom.GetCurStdDatetime(); updateInventory.WHERE_INV_ID = updateInventory.INV_ID; updateInventory.WHERE_INV_VersionNo = updateInventory.INV_VersionNo; } updateInventoryList.Add(updateInventory); //生成[库存异动日志] newInventoryTransLogList.Add(GenerateInventoryTransLogOfUnApprove(updateStockOutBill, loopDetail, updateInventory)); } #endregion #endregion #region 带事务的保存和删除 try { DBManager.BeginTransaction(DBCONFIG.Coeus); #region 更新[出库单] bool updateStockOutBillResult = _bll.Save(updateStockOutBill); if (!updateStockOutBillResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.SAVE + SystemTableEnums.Name.PIS_StockOutBill }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } #endregion #region 除[应收单] if (!string.IsNullOrEmpty(deleteAccountReceivableBill.ARB_ID)) { var deleteAccountReceivableBillResult = _bll.Delete <MDLFM_AccountReceivableBill>(deleteAccountReceivableBill); if (!deleteAccountReceivableBillResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.DELETE + SystemTableEnums.Name.FM_AccountReceivableBill }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } } #endregion #region 除[应收单明细] if (deleteAccountReceivableBillDetailList.Count > 0) { var deleteAccountReceivableBillDetailResult = _bll.DeleteByList <MDLFM_AccountReceivableBillDetail, MDLFM_AccountReceivableBillDetail>(deleteAccountReceivableBillDetailList); if (!deleteAccountReceivableBillDetailResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.DELETE + SystemTableEnums.Name.FM_AccountReceivableBillDetail }); 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.UNAPPROVE, ex.Message }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ex.Message, "", null); return(false); } #endregion //将最新数据回写给DetailDS CopyModel(updateStockOutBill, paramHead); return(true); }
/// <summary> /// 审核 /// </summary> /// <param name="paramHead">销售订单</param> /// <param name="paramDetailList">销售订单明细列表</param> /// <param name="paramStockOutDetailList">出库明细列表</param> /// <param name="paramReturnStockInDetailList">退货入库明细列表</param> /// <param name="paramIsHasInventory">是否启用进销存模块</param> /// <returns></returns> public bool ApproveDetailDS(SalesReturnOrderManagerUIModel paramHead, SkyCarBindingList <SalesOrderDetailUIModel, MDLSD_SalesOrderDetail> paramDetailList, List <SalesStockOutDetailUIModel> paramStockOutDetailList, List <ReturnStockInDetailUIModel> paramReturnStockInDetailList, bool paramIsHasInventory) { var funcName = "ApproveDetailDS"; LogHelper.WriteBussLogStart(BussID, LoginInfoDAX.UserName, funcName, "", "", null); #region 验证 if (paramHead == null || string.IsNullOrEmpty(paramHead.SO_ID) || string.IsNullOrEmpty(paramHead.SO_No)) { //没有获取到销售订单,审核失败 ResultMsg = MsgHelp.GetMsg(MsgCode.W_0024, new object[] { SystemTableEnums.Name.SD_SalesOrder, SystemActionEnum.Name.APPROVE }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } #endregion #region 准备数据 #region 变量定义 //待更新的[销售订单] MDLSD_SalesOrder updateSalesOrder = paramHead.ToTBModelForSaveAndDelete <MDLSD_SalesOrder>(); //待新增的退货时的[应收单] MDLFM_AccountReceivableBill newRejectAccountReceivableBill = new MDLFM_AccountReceivableBill(); //待新增的退货时的[应收单明细]列表 List <MDLFM_AccountReceivableBillDetail> newRejectReceivableBillDetailList = new List <MDLFM_AccountReceivableBillDetail>(); //待新增的退货入库[入库单] MDLPIS_StockInBill newReturnStockInBill = new MDLPIS_StockInBill(); //待新增的退货入库[入库单明细]列表 List <MDLPIS_StockInDetail> newReturnStockInDetailList = new List <MDLPIS_StockInDetail>(); //待更新的[库存]列表 List <MDLPIS_Inventory> updateStockInInventoryList = new List <MDLPIS_Inventory>(); //待新增的[库存异动日志]列表 List <MDLPIS_InventoryTransLog> newStockInInventoryTransLogList = new List <MDLPIS_InventoryTransLog>(); #endregion #region 更新销售订单 //更新[销售订单]审核状态为[已审核],单据状态根据[来源类型]决定 updateSalesOrder.SO_VersionNo++; updateSalesOrder.SO_ApprovalStatusCode = ApprovalStatusEnum.Code.YSH; updateSalesOrder.SO_ApprovalStatusName = ApprovalStatusEnum.Name.YSH; updateSalesOrder.SO_UpdatedBy = LoginInfoDAX.UserName; updateSalesOrder.SO_UpdatedTime = BLLCom.GetCurStdDatetime(); #endregion #region [销售订单].[来源类型]为{手工创建退货}、{在线销售退货}、{主动销售退货}的场合 //销售退货的场合,更新[销售订单].[单据状态]为[交易成功] updateSalesOrder.SO_StatusCode = SalesOrderStatusEnum.Code.JYCG; updateSalesOrder.SO_StatusName = SalesOrderStatusEnum.Name.JYCG; #region 创建退货入库的[入库单] //新增[来源类型]为[销售退货],[业务状态]为{已完成},[审核状态]为{已审核}的[入库单] newReturnStockInBill.SIB_ID = Guid.NewGuid().ToString(); newReturnStockInBill.SIB_No = BLLCom.GetCoeusDocumentNo(DocumentTypeEnums.Code.SIB); newReturnStockInBill.SIB_SourceTypeCode = StockInBillSourceTypeEnum.Code.SSTH; newReturnStockInBill.SIB_SourceTypeName = StockInBillSourceTypeEnum.Name.SSTH; newReturnStockInBill.SIB_SourceNo = updateSalesOrder.SO_No; newReturnStockInBill.SIB_Org_ID = updateSalesOrder.SO_Org_ID; newReturnStockInBill.SIB_StatusName = StockInBillStatusEnum.Name.YWC; newReturnStockInBill.SIB_StatusCode = StockInBillStatusEnum.Code.YWC; newReturnStockInBill.SIB_ApprovalStatusCode = ApprovalStatusEnum.Code.YSH; newReturnStockInBill.SIB_ApprovalStatusName = ApprovalStatusEnum.Name.YSH; newReturnStockInBill.SIB_IsValid = true; newReturnStockInBill.SIB_CreatedBy = LoginInfoDAX.UserName; newReturnStockInBill.SIB_CreatedTime = BLLCom.GetCurStdDatetime(); newReturnStockInBill.SIB_UpdatedBy = LoginInfoDAX.UserName; newReturnStockInBill.SIB_UpdatedTime = BLLCom.GetCurStdDatetime(); #endregion #region 创建负向的[应收单] //新增[来源类型]为[销售应收],[单据方向]为[负向],金额为负,[业务状态]为{执行中},[审核状态]为{已审核}的[应收单] newRejectAccountReceivableBill.ARB_ID = Guid.NewGuid().ToString(); newRejectAccountReceivableBill.ARB_No = BLLCom.GetCoeusDocumentNo(DocumentTypeEnums.Code.ARB); newRejectAccountReceivableBill.ARB_BillDirectCode = BillDirectionEnum.Code.MINUS; newRejectAccountReceivableBill.ARB_BillDirectName = BillDirectionEnum.Name.MINUS; newRejectAccountReceivableBill.ARB_SourceTypeCode = AccountReceivableBillSourceTypeEnum.Code.XSYS; newRejectAccountReceivableBill.ARB_SourceTypeName = AccountReceivableBillSourceTypeEnum.Name.XSYS; newRejectAccountReceivableBill.ARB_SrcBillNo = updateSalesOrder.SO_No; newRejectAccountReceivableBill.ARB_Org_ID = LoginInfoDAX.OrgID; newRejectAccountReceivableBill.ARB_Org_Name = LoginInfoDAX.OrgShortName; if (paramHead.SO_CustomerTypeName == CustomerTypeEnum.Name.PTNQXSH) { newRejectAccountReceivableBill.ARB_PayObjectTypeName = AmountTransObjectTypeEnum.Name.PLATFORMAUTOFACTORY; newRejectAccountReceivableBill.ARB_PayObjectTypeCode = AmountTransObjectTypeEnum.Code.PLATFORMAUTOFACTORY; } else if (paramHead.SO_CustomerTypeName == CustomerTypeEnum.Name.YBQXSH) { newRejectAccountReceivableBill.ARB_PayObjectTypeName = AmountTransObjectTypeEnum.Name.GENERALAUTOFACTORY; newRejectAccountReceivableBill.ARB_PayObjectTypeCode = AmountTransObjectTypeEnum.Code.GENERALAUTOFACTORY; } else { newRejectAccountReceivableBill.ARB_PayObjectTypeName = AmountTransObjectTypeEnum.Name.REGULARCUSTOMER; newRejectAccountReceivableBill.ARB_PayObjectTypeCode = AmountTransObjectTypeEnum.Code.REGULARCUSTOMER; } newRejectAccountReceivableBill.ARB_PayObjectName = paramHead.SO_CustomerName; newRejectAccountReceivableBill.ARB_PayObjectID = paramHead.SO_CustomerID; newRejectAccountReceivableBill.ARB_BusinessStatusCode = AccountReceivableBillStatusEnum.Code.ZXZ; newRejectAccountReceivableBill.ARB_BusinessStatusName = AccountReceivableBillStatusEnum.Name.ZXZ; newRejectAccountReceivableBill.ARB_ApprovalStatusCode = ApprovalStatusEnum.Code.YSH; newRejectAccountReceivableBill.ARB_ApprovalStatusName = ApprovalStatusEnum.Name.YSH; newRejectAccountReceivableBill.ARB_IsValid = true; newRejectAccountReceivableBill.ARB_CreatedBy = LoginInfoDAX.UserName; newRejectAccountReceivableBill.ARB_CreatedTime = BLLCom.GetCurStdDatetime(); newRejectAccountReceivableBill.ARB_UpdatedBy = LoginInfoDAX.UserName; newRejectAccountReceivableBill.ARB_UpdatedTime = BLLCom.GetCurStdDatetime(); #endregion //退货产生的应收单.[应收金额] decimal returnReceivableAmount = 0; foreach (var loopSalesOrderReturnDetail in paramDetailList) { #region 退货的[销售订单明细] //[销售订单明细]审核状态 和 单据状态与单头一致 loopSalesOrderReturnDetail.WHERE_SOD_ID = loopSalesOrderReturnDetail.SOD_ID; loopSalesOrderReturnDetail.WHERE_SOD_VersionNo = loopSalesOrderReturnDetail.SOD_VersionNo; loopSalesOrderReturnDetail.SOD_VersionNo++; loopSalesOrderReturnDetail.SOD_ApprovalStatusCode = updateSalesOrder.SO_ApprovalStatusCode; loopSalesOrderReturnDetail.SOD_ApprovalStatusName = updateSalesOrder.SO_ApprovalStatusName; loopSalesOrderReturnDetail.SOD_StatusCode = updateSalesOrder.SO_StatusCode; loopSalesOrderReturnDetail.SOD_StatusName = updateSalesOrder.SO_StatusName; loopSalesOrderReturnDetail.SOD_UpdatedBy = LoginInfoDAX.UserName; loopSalesOrderReturnDetail.SOD_UpdatedTime = BLLCom.GetCurStdDatetime(); #endregion #region 退货的[应收单明细] //新增[来源类型]为[销售应收],[是否负向明细]为[true],金额为负的[应收单明细] MDLFM_AccountReceivableBillDetail newAccountReceivableBillDetail = new MDLFM_AccountReceivableBillDetail { ARBD_ID = Guid.NewGuid().ToString(), ARBD_ARB_ID = newRejectAccountReceivableBill.ARB_ID, ARBD_IsMinusDetail = true, ARBD_SrcBillNo = updateSalesOrder.SO_No, ARBD_SrcBillDetailID = loopSalesOrderReturnDetail.SOD_ID, ARBD_Org_ID = newRejectAccountReceivableBill.ARB_Org_ID, ARBD_Org_Name = newRejectAccountReceivableBill.ARB_Org_Name, //应收金额 = 销售数量(退货数量) * 单价 ARBD_AccountReceivableAmount = -Math.Round((loopSalesOrderReturnDetail.SOD_Qty ?? 0) * (loopSalesOrderReturnDetail.SOD_UnitPrice ?? 0), 2), ARBD_ReceivedAmount = 0, ARBD_UnReceiveAmount = -Math.Round((loopSalesOrderReturnDetail.SOD_Qty ?? 0) * (loopSalesOrderReturnDetail.SOD_UnitPrice ?? 0), 2), ARBD_BusinessStatusCode = newRejectAccountReceivableBill.ARB_BusinessStatusCode, ARBD_BusinessStatusName = newRejectAccountReceivableBill.ARB_BusinessStatusName, ARBD_ApprovalStatusCode = newRejectAccountReceivableBill.ARB_ApprovalStatusCode, ARBD_ApprovalStatusName = newRejectAccountReceivableBill.ARB_ApprovalStatusName, ARBD_IsValid = true, ARBD_CreatedBy = LoginInfoDAX.UserName, ARBD_CreatedTime = BLLCom.GetCurStdDatetime(), ARBD_UpdatedBy = LoginInfoDAX.UserName, ARBD_UpdatedTime = BLLCom.GetCurStdDatetime() }; returnReceivableAmount += (newAccountReceivableBillDetail.ARBD_AccountReceivableAmount ?? 0); newRejectReceivableBillDetailList.Add(newAccountReceivableBillDetail); #endregion } //[应收单].[应收金额] newRejectAccountReceivableBill.ARB_AccountReceivableAmount = returnReceivableAmount; newRejectAccountReceivableBill.ARB_ReceivedAmount = 0; newRejectAccountReceivableBill.ARB_UnReceiveAmount = returnReceivableAmount; //[销售单].[总金额] updateSalesOrder.SO_TotalAmount = returnReceivableAmount; foreach (var loopReturnStockInDetail in paramReturnStockInDetailList) { #region 退货入库的[入库单明细] MDLPIS_StockInDetail newStockInDetail = new MDLPIS_StockInDetail(); _bll.CopyModel(loopReturnStockInDetail, newStockInDetail); newStockInDetail.SID_ID = Guid.NewGuid().ToString(); newStockInDetail.SID_SIB_ID = newReturnStockInBill.SIB_ID; newStockInDetail.SID_SIB_No = newReturnStockInBill.SIB_No; newStockInDetail.SID_IsValid = true; newStockInDetail.SID_CreatedBy = LoginInfoDAX.UserName; newStockInDetail.SID_CreatedTime = BLLCom.GetCurStdDatetime(); newStockInDetail.SID_UpdatedBy = LoginInfoDAX.UserName; newStockInDetail.SID_UpdatedTime = BLLCom.GetCurStdDatetime(); var curInDetailOfSalesDetail = paramDetailList.FirstOrDefault(x => x.SOD_Barcode == newStockInDetail.SID_Barcode); if (curInDetailOfSalesDetail != null) { //[入库单明细].[来源单据明细ID] 为 [销售退货单明细].[ID] newStockInDetail.SID_SourceDetailID = curInDetailOfSalesDetail.SOD_ID; } newReturnStockInDetailList.Add(newStockInDetail); #endregion if (paramIsHasInventory) { #region 进销存 并且 审核销售退货订单的场合,创建相关单据为已审核的场合,更新[库存],创建[库存异动日志] //在[入库单明细]列表中第一次出现的配件[库存]信息 MDLPIS_Inventory inventoryExists = null; foreach (var loopInventory in updateStockInInventoryList) { if (loopInventory.INV_Barcode == loopReturnStockInDetail.SID_Barcode && loopInventory.INV_BatchNo == loopReturnStockInDetail.SID_BatchNo) { inventoryExists = loopInventory; break; } } if (inventoryExists != null) { //[入库单明细]列表中已遍历过该配件,累加数量 inventoryExists.INV_Qty += loopReturnStockInDetail.SID_Qty; inventoryExists.INV_UpdatedBy = LoginInfoDAX.UserName; inventoryExists.INV_UpdatedTime = BLLCom.GetCurStdDatetime(); //生成[库存异动日志] newStockInInventoryTransLogList.Add(GenerateStockInInventoryTransLog(newReturnStockInBill, loopReturnStockInDetail, inventoryExists, paramHead)); } else { //[入库单明细]列表中第一次出现该配件 //查询该配件是否在[库存]中存在 MDLPIS_Inventory resultInventory = new MDLPIS_Inventory(); _bll.QueryForObject <MDLPIS_Inventory, MDLPIS_Inventory>(new MDLPIS_Inventory { WHERE_INV_Org_ID = newReturnStockInBill.SIB_Org_ID, WHERE_INV_Barcode = loopReturnStockInDetail.SID_Barcode, WHERE_INV_BatchNo = loopReturnStockInDetail.SID_BatchNo, WHERE_INV_WH_ID = loopReturnStockInDetail.SID_WH_ID, WHERE_INV_IsValid = true }, resultInventory); //[库存]中不存在该配件 if (string.IsNullOrEmpty(resultInventory.INV_ID)) { //新增一个该配件的库存信息 MDLPIS_Inventory inventoryToInsert = new MDLPIS_Inventory { INV_Org_ID = newReturnStockInBill.SIB_Org_ID, INV_SUPP_ID = loopReturnStockInDetail.SID_SUPP_ID, INV_WH_ID = loopReturnStockInDetail.SID_WH_ID, INV_WHB_ID = loopReturnStockInDetail.SID_WHB_ID, INV_ThirdNo = loopReturnStockInDetail.SID_ThirdNo, INV_OEMNo = loopReturnStockInDetail.SID_OEMNo, INV_Barcode = loopReturnStockInDetail.SID_Barcode, INV_BatchNo = loopReturnStockInDetail.SID_BatchNo, INV_Name = loopReturnStockInDetail.SID_Name, INV_Specification = loopReturnStockInDetail.SID_Specification, INV_Qty = loopReturnStockInDetail.SID_Qty, INV_PurchaseUnitPrice = loopReturnStockInDetail.SID_UnitCostPrice, INV_IsValid = true, INV_CreatedBy = LoginInfoDAX.UserName, INV_CreatedTime = BLLCom.GetCurStdDatetime(), INV_UpdatedBy = LoginInfoDAX.UserName, INV_UpdatedTime = BLLCom.GetCurStdDatetime() }; updateStockInInventoryList.Add(inventoryToInsert); //生成[库存异动日志] newStockInInventoryTransLogList.Add(GenerateStockInInventoryTransLog(newReturnStockInBill, loopReturnStockInDetail, inventoryToInsert, paramHead)); } //[库存]中存在该配件 else { //更新[库存]中该配件的数量 resultInventory.INV_Qty += loopReturnStockInDetail.SID_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; updateStockInInventoryList.Add(resultInventory); //生成[库存异动日志] newStockInInventoryTransLogList.Add(GenerateStockInInventoryTransLog(newReturnStockInBill, loopReturnStockInDetail, resultInventory, paramHead)); } } #endregion } } #endregion #endregion #region 带事务的新增和更新 try { DBManager.BeginTransaction(DBCONFIG.Coeus); #region 更新[销售订单] bool saveSalesOrder = _bll.Save(updateSalesOrder); if (!saveSalesOrder) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { MsgParam.UPDATE + SystemTableEnums.Name.SD_SalesOrder }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } #endregion #region 保存[销售订单明细] bool saveSalesOrderDetailResult = _bll.UnitySave(paramDetailList); if (!saveSalesOrderDetailResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.SAVE + SystemTableEnums.Name.SD_SalesOrderDetail }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } #endregion #region 新增[应收单] if (!string.IsNullOrEmpty(newRejectAccountReceivableBill.ARB_ID)) { //销售退货时产生的负向的[销售应收] bool insertAccountReceivableBillResult = _bll.Insert(newRejectAccountReceivableBill); if (!insertAccountReceivableBillResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.NEW + SystemTableEnums.Name.FM_AccountReceivableBill }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } } #endregion #region 新增[应收单明细] //销售退货时产生的负向的[销售应收] if (newRejectReceivableBillDetailList.Count > 0) { bool insertAccountReceivableBillDetailResult = _bll.InsertByList <MDLFM_AccountReceivableBillDetail, MDLFM_AccountReceivableBillDetail>(newRejectReceivableBillDetailList); if (!insertAccountReceivableBillDetailResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.NEW + SystemTableEnums.Name.FM_AccountReceivableBillDetail }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } } #endregion #region 保存[库存] foreach (var loopInventory in updateStockInInventoryList) { 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 (newStockInInventoryTransLogList.Count > 0) { bool insertInventoryTransLogResult = _bll.InsertByList <MDLPIS_InventoryTransLog, MDLPIS_InventoryTransLog>(newStockInInventoryTransLogList); 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 #region 销售退货入库时生成[入库单] if (!string.IsNullOrEmpty(newReturnStockInBill.SIB_ID)) { bool insertStockInBillResult = _bll.Insert(newReturnStockInBill); if (!insertStockInBillResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.NEW + SystemTableEnums.Name.PIS_StockInBill }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } } #endregion #region 销售退货入库时生成[入库单明细] if (newReturnStockInDetailList.Count > 0) { bool insertStockInDetailResult = _bll.InsertByList <MDLPIS_StockInDetail, MDLPIS_StockInDetail>(newReturnStockInDetailList); if (!insertStockInDetailResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.NEW + SystemTableEnums.Name.PIS_StockInDetail }); 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 _bll.CopyModel(updateSalesOrder, paramHead); return(true); }