/// <summary> /// 生成选中项的值和描述 /// </summary> void GenerateSelectedValueAndText() { SelectedGridList = new List <MDLSD_LogisticsBill>(); foreach (var loopSourceItem in ListGridDS) { if (!loopSourceItem.IsChecked) { continue; } MDLSD_LogisticsBill argsSalesOrder = new MDLSD_LogisticsBill { LB_ID = loopSourceItem.LB_ID, LB_No = loopSourceItem.LB_No, LB_Org_ID = loopSourceItem.LB_Org_ID, LB_Org_Name = loopSourceItem.LB_Org_Name, LB_SourceTypeCode = loopSourceItem.LB_SourceTypeCode, LB_SourceTypeName = loopSourceItem.LB_SourceTypeName, LB_SourceNo = loopSourceItem.LB_SourceNo, LB_SourceCode = loopSourceItem.LB_SourceCode, LB_SourceName = loopSourceItem.LB_SourceName, LB_DeliveryByID = loopSourceItem.LB_DeliveryByID, LB_DeliveryBy = loopSourceItem.LB_DeliveryBy, LB_PhoneNo = loopSourceItem.LB_PhoneNo, LB_AcceptTime = loopSourceItem.LB_AcceptTime, LB_AcceptPicPath1 = loopSourceItem.LB_AcceptPicPath1, LB_AcceptPicPath2 = loopSourceItem.LB_AcceptPicPath2, LB_Receiver = loopSourceItem.LB_Receiver, LB_ReceiverAddress = loopSourceItem.LB_ReceiverAddress, LB_ReceiverPostcode = loopSourceItem.LB_ReceiverPostcode, LB_ReceiverPhoneNo = loopSourceItem.LB_ReceiverPhoneNo, LB_ReceivedBy = loopSourceItem.LB_ReceivedBy, LB_ReceivedTime = loopSourceItem.LB_ReceivedTime, LB_ReceivedPicPath1 = loopSourceItem.LB_ReceivedPicPath1, LB_ReceivedPicPath2 = loopSourceItem.LB_ReceivedPicPath2, LB_Fee = loopSourceItem.LB_Fee, LB_PayStautsCode = loopSourceItem.LB_PayStautsCode, LB_PayStautsName = loopSourceItem.LB_PayStautsName, LB_StatusCode = loopSourceItem.LB_StatusCode, LB_StatusName = loopSourceItem.LB_StatusName, LB_Remark = loopSourceItem.LB_Remark, LB_IsValid = loopSourceItem.LB_IsValid, LB_CreatedBy = loopSourceItem.LB_CreatedBy, LB_CreatedTime = loopSourceItem.LB_CreatedTime, LB_UpdatedBy = loopSourceItem.LB_UpdatedBy, LB_UpdatedTime = loopSourceItem.LB_UpdatedTime, LB_VersionNo = loopSourceItem.LB_VersionNo, }; SelectedGridList.Add(argsSalesOrder); } }
/// <summary> /// 审核 /// </summary> /// <param name="paramHead">物流单</param> /// <param name="paramDetailList">物流单明细列表</param> /// <returns></returns> public bool ApproveDetailDS(LogisticsBillManagerUIModel paramHead, SkyCarBindingList <LogisticsBillDetailManagerUIModel, MDLSD_LogisticsBillDetail> paramDetailList, Dictionary <string, string> paramPictureNameAndPath) { var funcName = "ApproveDetailDS"; LogHelper.WriteBussLogStart(BussID, LoginInfoDAX.UserName, funcName, "", "", null); if (paramHead == null || string.IsNullOrEmpty(paramHead.LB_ID) || string.IsNullOrEmpty(paramHead.LB_No)) { //没有获取到物流单,审核失败 ResultMsg = MsgHelp.GetMsg(MsgCode.W_0024, new object[] { SystemTableEnums.Name.SD_LogisticsBill, SystemActionEnum.Name.APPROVE }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } #region 准备数据 #region 变量定义 //待更新的当前[物流单] MDLSD_LogisticsBill updateCurLogisticsBill = new MDLSD_LogisticsBill(); updateCurLogisticsBill = paramHead.ToTBModelForSaveAndDelete <MDLSD_LogisticsBill>(); //待更新的当前[物流单明细]列表 List <MDLSD_LogisticsBillDetail> updateCurLogisticsBillDetailList = new List <MDLSD_LogisticsBillDetail>(); CopyModelList(paramDetailList, updateCurLogisticsBillDetailList); //待新增的当前[物流单异动日志] MDLSD_LogisticsBillTrans newLogisticsBillTrans = new MDLSD_LogisticsBillTrans(); //待更新的当前物流单对应的[销售订单] MDLSD_SalesOrder updateCurSalesOrder = new MDLSD_SalesOrder(); //待更新的当前物流单对应的[销售订单明细]列表 List <MDLSD_SalesOrderDetail> updateCurSalesOrderDetailList = new List <MDLSD_SalesOrderDetail>(); //待更新的[调拨单] MDLPIS_TransferBill transferBill = new MDLPIS_TransferBill(); #endregion #region 更新[物流单] //更新[物流单].[单据状态]为{配送中},[审核状态]为{已审核} updateCurLogisticsBill.LB_StatusCode = LogisticsBillStatusEnum.Code.PSZ; updateCurLogisticsBill.LB_StatusName = LogisticsBillStatusEnum.Name.PSZ; updateCurLogisticsBill.LB_ApprovalStatusCode = ApprovalStatusEnum.Code.YSH; updateCurLogisticsBill.LB_ApprovalStatusName = ApprovalStatusEnum.Name.YSH; updateCurLogisticsBill.LB_UpdatedBy = LoginInfoDAX.UserName; updateCurLogisticsBill.LB_UpdatedTime = BLLCom.GetCurStdDatetime(); #endregion #region 新增[物流单异动日志] //新增状态为 当前物流单状态 的[物流单异动日志] newLogisticsBillTrans.LBT_ID = Guid.NewGuid().ToString(); newLogisticsBillTrans.LBT_Org_ID = updateCurLogisticsBill.LB_Org_ID; newLogisticsBillTrans.LBT_Org_Name = updateCurLogisticsBill.LB_Org_Name; newLogisticsBillTrans.LBT_LB_ID = updateCurLogisticsBill.LB_ID ?? updateCurLogisticsBill.WHERE_LB_ID; newLogisticsBillTrans.LBT_LB_NO = updateCurLogisticsBill.LB_No; newLogisticsBillTrans.LBT_Time = BLLCom.GetCurStdDatetime(); newLogisticsBillTrans.LBT_Status = updateCurLogisticsBill.LB_StatusName; newLogisticsBillTrans.LBT_IsValid = true; newLogisticsBillTrans.LBT_CreatedBy = LoginInfoDAX.UserName; newLogisticsBillTrans.LBT_CreatedTime = BLLCom.GetCurStdDatetime(); newLogisticsBillTrans.LBT_UpdatedBy = LoginInfoDAX.UserName; newLogisticsBillTrans.LBT_UpdatedTime = BLLCom.GetCurStdDatetime(); #endregion if (paramHead.LB_SourceTypeName == DeliveryBillSourceTypeEnum.Name.ZZDB) { #region 更新[调拨单] _bll.QueryForObject <MDLPIS_TransferBill, MDLPIS_TransferBill>(new MDLPIS_TransferBill() { WHERE_TB_No = paramHead.LB_SourceNo }, transferBill); if (!string.IsNullOrEmpty(transferBill.TB_ID)) { transferBill.TB_StatusName = TransfeStatusEnum.Name.YWC; transferBill.TB_StatusCode = TransfeStatusEnum.Code.YWC; transferBill.WHERE_TB_ID = transferBill.TB_ID; transferBill.WHERE_TB_VersionNo = transferBill.TB_VersionNo; transferBill.TB_VersionNo = +1; } #endregion } else { #region 更新[销售订单] //查询物流单对应的销售订单 _bll.QueryForObject <MDLSD_SalesOrder, MDLSD_SalesOrder>(new MDLSD_SalesOrder { WHERE_SO_No = updateCurLogisticsBill.LB_SourceNo, WHERE_SO_IsValid = true }, updateCurSalesOrder); if (!string.IsNullOrEmpty(updateCurSalesOrder.SO_ID)) { //更新[销售订单].[单据状态]为{已发货} updateCurSalesOrder.SO_StatusCode = SalesOrderStatusEnum.Code.YFH; updateCurSalesOrder.SO_StatusName = SalesOrderStatusEnum.Name.YFH; updateCurSalesOrder.SO_UpdatedBy = LoginInfoDAX.UserName; updateCurSalesOrder.SO_UpdatedTime = BLLCom.GetCurStdDatetime(); updateCurSalesOrder.WHERE_SO_ID = updateCurSalesOrder.SO_ID; updateCurSalesOrder.WHERE_SO_VersionNo = updateCurSalesOrder.SO_VersionNo; } #endregion #region 获取对应的[销售订单明细]列表 _bll.QueryForList <MDLSD_SalesOrderDetail, MDLSD_SalesOrderDetail>(new MDLSD_SalesOrderDetail { WHERE_SOD_SO_ID = updateCurSalesOrder.SO_ID, WHERE_SOD_IsValid = true }, updateCurSalesOrderDetailList); #endregion } #region 图片 foreach (var loopPicture in paramPictureNameAndPath) { if (string.IsNullOrEmpty(loopPicture.Key) || string.IsNullOrEmpty(loopPicture.Value)) { continue; } #region 将图片保存到本地以及上传文件服务器 string fileNetUrl = string.Empty; bool savePictureResult = BLLCom.SaveFileByFileName(loopPicture.Value, loopPicture.Key, ref fileNetUrl); if (!savePictureResult) { ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.SAVE + MsgParam.IMAGE }); LogHelper.WriteBussLogEndNG(BussID, LoginInfoDAX.UserName, funcName, ResultMsg, "", null); return(false); } #endregion //截取上传图片返回值中的文件名称 int fileNameStartIndex = fileNetUrl.IndexOf("FileName=", StringComparison.Ordinal) + 1; int fileNameEndIndex = fileNameStartIndex + "FileName=".Length; int length = fileNetUrl.Length; //文件名称 string tempFileName = fileNetUrl.Substring(fileNameEndIndex - 1, length - (fileNameEndIndex - 1)); //给各个图片赋值 if (loopPicture.Key == updateCurLogisticsBill.LB_AcceptPicPath1) { updateCurLogisticsBill.LB_AcceptPicPath1 = tempFileName; } else if (loopPicture.Key == updateCurLogisticsBill.LB_AcceptPicPath2) { updateCurLogisticsBill.LB_AcceptPicPath2 = tempFileName; } else if (loopPicture.Key == updateCurLogisticsBill.LB_ReceivedPicPath1) { updateCurLogisticsBill.LB_ReceivedPicPath1 = tempFileName; } else if (loopPicture.Key == updateCurLogisticsBill.LB_ReceivedPicPath2) { updateCurLogisticsBill.LB_ReceivedPicPath2 = tempFileName; } } #endregion #endregion #region 带事务的保存 try { DBManager.BeginTransaction(DBCONFIG.Coeus); #region 更新[物流单] bool updateLogisticsBillResult = _bll.Save(updateCurLogisticsBill); if (!updateLogisticsBillResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); foreach (var loopPicture in paramPictureNameAndPath) { if (string.IsNullOrEmpty(loopPicture.Key) || string.IsNullOrEmpty(loopPicture.Value)) { continue; } //保存失败,删除本地以及文件服务器上的图片 var outMsg = string.Empty; BLLCom.DeleteFileByFileName(loopPicture.Key, ref outMsg); } ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { MsgParam.UPDATE + SystemTableEnums.Name.SD_LogisticsBill }); return(false); } #endregion #region 更新[物流单明细] foreach (var loopLogisticsBillDetail in updateCurLogisticsBillDetailList) { //更新[物流单明细].[物流状态]为{配送中} loopLogisticsBillDetail.LBD_StatusCode = LogisticsBillDetailStatusEnum.Code.PSZ; loopLogisticsBillDetail.LBD_StatusName = LogisticsBillDetailStatusEnum.Name.PSZ; loopLogisticsBillDetail.LBD_UpdatedBy = LoginInfoDAX.UserName; loopLogisticsBillDetail.LBD_UpdatedTime = BLLCom.GetCurStdDatetime(); if (paramHead.LB_SourceTypeName == DeliveryBillSourceTypeEnum.Name.ZZDB) { loopLogisticsBillDetail.LBD_SignQty = loopLogisticsBillDetail.LBD_DeliveryQty; } loopLogisticsBillDetail.WHERE_LBD_ID = loopLogisticsBillDetail.LBD_ID; loopLogisticsBillDetail.WHERE_LBD_VersionNo = loopLogisticsBillDetail.LBD_VersionNo; bool updateLogisticsBillDetailResult = _bll.Save(loopLogisticsBillDetail); if (!updateLogisticsBillDetailResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); foreach (var loopPicture in paramPictureNameAndPath) { if (string.IsNullOrEmpty(loopPicture.Key) || string.IsNullOrEmpty(loopPicture.Value)) { continue; } //保存失败,删除本地以及文件服务器上的图片 var outMsg = string.Empty; BLLCom.DeleteFileByFileName(loopPicture.Key, ref outMsg); } ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { MsgParam.UPDATE + SystemTableEnums.Name.SD_LogisticsBillDetail }); return(false); } } #endregion #region 新增[物流单日志] bool addLogisticsBillTransResult = _bll.Insert(newLogisticsBillTrans); if (!addLogisticsBillTransResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); foreach (var loopPicture in paramPictureNameAndPath) { if (string.IsNullOrEmpty(loopPicture.Key) || string.IsNullOrEmpty(loopPicture.Value)) { continue; } //保存失败,删除本地以及文件服务器上的图片 var outMsg = string.Empty; BLLCom.DeleteFileByFileName(loopPicture.Key, ref outMsg); } ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { SystemActionEnum.Name.NEW + SystemTableEnums.Name.SD_LogisticsBillTrans }); return(false); } #endregion if (paramHead.LB_SourceTypeName == DeliveryBillSourceTypeEnum.Name.ZZDB) { #region 更新[调拨单]数据 if (!string.IsNullOrEmpty(transferBill.TB_ID)) { bool updateTransferBillResult = _bll.Update(transferBill); if (!updateTransferBillResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); foreach (var loopPicture in paramPictureNameAndPath) { if (string.IsNullOrEmpty(loopPicture.Key) || string.IsNullOrEmpty(loopPicture.Value)) { continue; } //保存失败,删除本地以及文件服务器上的图片 var outMsg = string.Empty; BLLCom.DeleteFileByFileName(loopPicture.Key, ref outMsg); } ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { MsgParam.UPDATE + SystemTableEnums.Name.PIS_TransferBill }); return(false); } } #endregion } else { #region 更新[销售订单]数据 if (!string.IsNullOrEmpty(updateCurSalesOrder.SO_ID)) { bool updateSalesOrderResult = _bll.Update(updateCurSalesOrder); if (!updateSalesOrderResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); foreach (var loopPicture in paramPictureNameAndPath) { if (string.IsNullOrEmpty(loopPicture.Key) || string.IsNullOrEmpty(loopPicture.Value)) { continue; } //保存失败,删除本地以及文件服务器上的图片 var outMsg = string.Empty; BLLCom.DeleteFileByFileName(loopPicture.Key, ref outMsg); } ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { MsgParam.UPDATE + SystemTableEnums.Name.SD_SalesOrder }); return(false); } } #endregion #region 更新[销售订单明细]数据 if (updateCurSalesOrderDetailList.Count > 0) { foreach (var loopSalesOrderDetail in updateCurSalesOrderDetailList) { //更新[销售订单明细].[单据状态]与单头一致 loopSalesOrderDetail.SOD_StatusName = updateCurSalesOrder.SO_StatusName; loopSalesOrderDetail.SOD_StatusCode = updateCurSalesOrder.SO_StatusCode; loopSalesOrderDetail.SOD_ApprovalStatusName = updateCurSalesOrder.SO_ApprovalStatusName; loopSalesOrderDetail.SOD_ApprovalStatusCode = updateCurSalesOrder.SO_ApprovalStatusCode; loopSalesOrderDetail.SOD_UpdatedBy = LoginInfoDAX.UserName; loopSalesOrderDetail.SOD_UpdatedTime = BLLCom.GetCurStdDatetime(); loopSalesOrderDetail.WHERE_SOD_ID = loopSalesOrderDetail.SOD_ID; loopSalesOrderDetail.WHERE_SOD_VersionNo = loopSalesOrderDetail.SOD_VersionNo; bool updateLogisticsBillDetailResult = _bll.Update(loopSalesOrderDetail); if (!updateLogisticsBillDetailResult) { DBManager.RollBackTransaction(DBCONFIG.Coeus); foreach (var loopPicture in paramPictureNameAndPath) { if (string.IsNullOrEmpty(loopPicture.Key) || string.IsNullOrEmpty(loopPicture.Value)) { continue; } //保存失败,删除本地以及文件服务器上的图片 var outMsg = string.Empty; BLLCom.DeleteFileByFileName(loopPicture.Key, ref outMsg); } ResultMsg = MsgHelp.GetMsg(MsgCode.E_0010, new object[] { MsgParam.UPDATE + SystemTableEnums.Name.SD_SalesOrderDetail }); return(false); } } } #endregion } DBManager.CommitTransaction(DBCONFIG.Coeus); } catch (Exception ex) { DBManager.RollBackTransaction(DBCONFIG.Coeus); foreach (var loopPicture in paramPictureNameAndPath) { if (string.IsNullOrEmpty(loopPicture.Key) || string.IsNullOrEmpty(loopPicture.Value)) { continue; } //保存失败,删除本地以及文件服务器上的图片 var outMsg = string.Empty; BLLCom.DeleteFileByFileName(loopPicture.Key, ref outMsg); } 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(updateCurLogisticsBill, paramHead); //更新明细版本号 if (paramDetailList != null) { foreach (var loopUpdateDetail in paramDetailList) { if (loopUpdateDetail.LBD_VersionNo == null) { //新增时版本号为1 loopUpdateDetail.LBD_VersionNo = 1; if (paramHead.LB_SourceTypeName == DeliveryBillSourceTypeEnum.Name.ZZDB) { loopUpdateDetail.LBD_SignQty = loopUpdateDetail.LBD_DeliveryQty; } } else { //更新时版本号加1 loopUpdateDetail.LBD_VersionNo = loopUpdateDetail.LBD_VersionNo + 1; if (paramHead.LB_SourceTypeName == DeliveryBillSourceTypeEnum.Name.ZZDB) { loopUpdateDetail.LBD_SignQty = loopUpdateDetail.LBD_DeliveryQty; } } } } foreach (var loopPicture in paramPictureNameAndPath) { if (string.IsNullOrEmpty(loopPicture.Key) || string.IsNullOrEmpty(loopPicture.Value)) { continue; } //保存成功,删除临时保存的图片 if (File.Exists(loopPicture.Value)) { File.Delete(loopPicture.Value); } } return(true); }