/// <summary> /// 删除实体 /// </summary> /// <param name="param">删除条件实体</param> /// <returns></returns> public WCFAddUpdateResult DelInfo(ORD_PurchaseReturnParam param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); int affect = 0; try { #region 判断 if (param.PRGuid == null) { throw new WarnException("请指定要删除的退货单ID!"); } #endregion WhereClip whereClip = GetWhereClip(param); ORD_PurchaseReturnResult info = new ORD_PurchaseReturnResult(); info.IsDeleted = true; affect = this.Update <ORD_PurchaseReturnResult>(info, whereClip); #region 设置返回值 ret.Key = affect; #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }
object Form_GetEditEntity() { ORD_PurchaseReturnResult info = new ORD_PurchaseReturnResult(); info.PRGuid = PRGuid; info = this.ConvertControlToEntity <ORD_PurchaseReturnResult>(this.stcpBase.Controls, info, null); this.SetDataIsChanged <ORD_PurchaseReturnResult>(info); return(info); }
public ORD_PurchaseReturnResult GetInfo(ORD_PurchaseReturnParam param) { ORD_PurchaseReturnResult ret = new ORD_PurchaseReturnResult(); ExeResult rst = new ExeResult(); rst = this.Execute("ZNLCRM.BLL.PPM.ORD_PurchaseReturnBLL", "GetInfo", param); ret = rst == null ? new ORD_PurchaseReturnResult() : rst.Result as ORD_PurchaseReturnResult; return(ret); }
public WCFAddUpdateResult AddOrUpdate(ORD_PurchaseReturnResult param) { WCFAddUpdateResult ret = new WCFAddUpdateResult(); ExeResult rst = new ExeResult(); rst = this.Execute("ZNLCRM.BLL.PPM.ORD_PurchaseReturnBLL", "AddOrUpdate", param); ret = (rst == null ? new WCFAddUpdateResult() : rst.Result as WCFAddUpdateResult); return(ret); }
private void txtSourceBillNo_ButtonCustomClick(object sender, EventArgs e) { if (!string.IsNullOrEmpty(cboBillType.SelectedValue.ToStringHasNull())) { DialogResult rst = DialogResult.Cancel; switch (cboBillType.SelectedValue.ToStringHasNull()) { case "SO_OUT": frmSelectSalesOrder frmSelectSalesOrder = new frmSelectSalesOrder(false); frmSelectSalesOrder.BringToFront(); frmSelectSalesOrder.StartPosition = FormStartPosition.CenterScreen; rst = frmSelectSalesOrder.ShowDialog(); if (rst == DialogResult.OK) { List <ORD_SalesOrderResult> rstList = frmSelectSalesOrder.GetSelectList <ORD_SalesOrderResult>(); if (rstList != null && rstList.Count > 0) { ORD_SalesOrderResult orderResult = rstList[0]; InitSourceData("SO_OUT", orderResult); } } break; case "POR_OUT": frmSelectPurchaseReturn frmSelectPurchaseReturn = new frmSelectPurchaseReturn(false); frmSelectPurchaseReturn.BringToFront(); frmSelectPurchaseReturn.StartPosition = FormStartPosition.CenterScreen; rst = frmSelectPurchaseReturn.ShowDialog(); if (rst == DialogResult.OK) { List <ORD_PurchaseReturnResult> rstList = frmSelectPurchaseReturn.GetSelectList <ORD_PurchaseReturnResult>(); if (rstList != null && rstList.Count > 0) { ORD_PurchaseReturnResult orderResult = rstList[0]; InitSourceData("POR_OUT", orderResult); } } break; case "ZX_OUT": break; } } else { MessageBox.Show("请选择出库类型!"); } }
private void tsbSave_Click(object sender, EventArgs e) { ORD_PurchaseReturnResult info = Form_GetEditEntity() as ORD_PurchaseReturnResult; if (!this.DataIsChanged) { this.ShowNoChangedMsg(); return; } bsPurchaseReturnLine.EndEdit(); tempList.Clear(); foreach (ORD_PurchaseReturnLineResult rst in addOrModifyList) { if (rst.HasChanged()) { tempList.Add(rst); } } //tempList.AddRange(addOrModifyList); tempList.AddRange(delList); info.ReturnLineList = tempList; WCFAddUpdateResult result = this.AsyncExecute <WCFAddUpdateResult, ORD_PurchaseReturnResult>(info, returnLogic.AddOrUpdate, (a) => { if (a.KeyGuid.ToGuid() != Guid.Empty) { PRGuid = a.KeyGuid.ToGuid(); CRM_CompanyResult companyResult = companyLogic.GetCustInfo(new CRM_CompanyParam() { CompanyID = txtSupplierID.Text.ToInt32() }); if (companyResult != null) { companyResult.LastBusinessDate = txtReturnDate.Text.ToDateTime(); companyLogic.AddOrUpdateSup(companyResult); } if (SaveAttach != null) { SaveAttach("ORD_PurchaseReturn", PRGuid.ToGuid(), a.BillNo); } InitData(); delList.Clear(); } }); }
public bool UpdateStatus(ORD_PurchaseReturnParam param) { bool flag = true; try { ORD_PurchaseReturnResult orderResult = this.GetInfo(param); if (orderResult != null) { if (orderResult.ReturnLineList != null && orderResult.ReturnLineList.Count > 0) { List <ORD_PurchaseReturnLineResult> lineList = orderResult.ReturnLineList; if (lineList != null && lineList.Count > 0) { int?qty = lineList.Where(a => a.Qty != null).Select(a => a.Qty).Sum(); int?stkOutQty = lineList.Where(a => a.StkOutQty != null).Select(a => a.StkOutQty).Sum(); if (stkOutQty == 0) { orderResult.StkOutStatus = "待出库"; } else if (stkOutQty >= qty) { orderResult.StkOutStatus = "全部出库"; } else { orderResult.StkOutStatus = "部分出库"; } this.AddOrUpdate(orderResult); } } } } catch (WarnException exp) { flag = false; throw exp; } catch (System.Exception exp) { flag = false; LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(flag); }
private void InitData() { if (PRGuid != null) { ORD_PurchaseReturnResult info = returnLogic.GetInfo(new ORD_PurchaseReturnParam { PRGuid = PRGuid }); this.ConvertEntityToControl <ORD_PurchaseReturnResult>(this.stcpBase.Controls, info, null); if (info != null) { txtOperDeptName.Text = info.OperDeptName; decimal totalAmount = Math.Round(info.Amount.ToDecimal(), 3, MidpointRounding.AwayFromZero); txtAmount.Text = totalAmount.ToStringHasNull(); if (info.ReturnLineList != null) { addOrModifyList = info.ReturnLineList; } } } else { txtReturnDate.Text = DateTime.Now.Date.ToStringHasNull(); txtOperDeptID.Text = MySession.DeptID.ToStringHasNull(); txtOperDeptName.Text = MySession.DeptName; txtOperEmpID.Text = MySession.UserID.ToStringHasNull(); txtOperEmpName.Text = MySession.UserName.ToStringHasNull(); SYS_DictItemLineLogic.SetCombolSelectedIndex(this.cboOperOrgID, MySession.OrgID, true); } bsPurchaseReturnLine.DataSource = addOrModifyList; dgvPurchaseReturnLine.DataSource = bsPurchaseReturnLine; //CheckAuditButton("ORD_SalesOrder", SRGuid, this.tsbSubmit, null, this.tsbAudit, this.tsbUnDo); if (PRGuid == null && SourceBillGuid != null) { ORD_PurchaseOrderResult orderResult = orderLogic.GetInfo(new ORD_PurchaseOrderParam() { POGuid = SourceBillGuid }); if (orderResult != null) { InitSourceData(orderResult); } } }
private void tsbDel_Click(object sender, EventArgs e) { ORD_PurchaseReturnParam param = new ORD_PurchaseReturnParam(); param.PRGuid = _PRGuid; ORD_PurchaseReturnResult rst = returnLogic.GetInfo(param); if (rst != null) { if (MessageBox.Show("请确认是否要删除采购退货单:【" + rst.BillNo + "】", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { WCFAddUpdateResult result = this.AsyncExecute <WCFAddUpdateResult, ORD_PurchaseReturnParam>(param, returnLogic.DelInfo, a => { BindDataGridView(pgPurchaseReturn.PageIndex); }); } } else { this.ShowMessage("请选择需要删除的采购退货单!"); } }
void InitSourceData(string billType, Guid?sourceBillGuid) { switch (billType) { case "SO_OUT": ORD_SalesOrderResult orderResult = orderLogic.GetInfo(new ORD_SalesOrderParam() { SOGuid = sourceBillGuid }); InitSourceData(billType, orderResult); break; case "POR_OUT": ORD_PurchaseReturnResult returnResult = returnLogic.GetInfo(new ORD_PurchaseReturnParam() { PRGuid = sourceBillGuid }); InitSourceData(billType, returnResult); break; } }
/// <summary> /// 获取一条信息记录 /// </summary> /// <param name="param"></param> /// <returns></returns> public ORD_PurchaseReturnResult GetInfo(ORD_PurchaseReturnParam param) { this.CheckSession(); ORD_PurchaseReturnResult rst = new ORD_PurchaseReturnResult(); #region 判断 if (param.PRGuid == null) { throw new WarnException("请指定采购退货单GUID!"); } #endregion #region 获取实体 rst = this.Select <ORD_PurchaseReturnResult>(GetWhereClip(param)); if (rst != null) { string[] statusArr = new string[] { rst.StkOutStatus }; rst.AllStatus = string.Join(",", statusArr); ORD_PurchaseReturnLineBLL lineBLL = new ORD_PurchaseReturnLineBLL(); lineBLL.SessionInfo = this.SessionInfo; rst.ReturnLineList = lineBLL.GetList(new ORD_PurchaseReturnLineParam() { PRGuid = rst.PRGuid }); //this.SelectList<ORD_SalesOrderLineResult>(ORD_SalesOrderLine._.SOGuid == rst.SOGuid); HR_DepartmentBLL deptBLL = new HR_DepartmentBLL(); deptBLL.SessionInfo = this.SessionInfo; HR_DepartmentResult deptResult = deptBLL.GetInfo(new HR_DepartmentParam() { DeptID = rst.OperDeptID }); rst.OperDeptName = deptResult.DeptName; } #endregion return(rst); }
public void InitSourceData(string billType, object obj) { if (obj != null) { if (cboBillType.SelectedValue.ToStringHasNull() == "") { SYS_DictItemLineLogic.SetCombolSelectedIndex(cboBillType, billType, true); } if (obj is ORD_SalesOrderResult) { ORD_SalesOrderResult salesOrderResult = obj as ORD_SalesOrderResult; if (salesOrderResult != null) { txtSourceBillGuid.Text = salesOrderResult.SOGuid.ToStringHasNull(); txtSourceBillNo.Text = salesOrderResult.BillNo; cboTaxRate.SelectedValue = salesOrderResult.TaxRate == null ? 0 : salesOrderResult.TaxRate; cboCurrency.SelectedValue = salesOrderResult.Currency; List <STK_StockReserveResult> reserveList = reserveLogic.GetList(new STK_StockReserveParam() { SourceBillGuid = salesOrderResult.SOGuid, IsUsedOver = false }); List <ORD_SalesOrderLineResult> lineList = null; if (salesOrderResult.OrderLineList != null)//从其他窗体点击出库进入,只传递guid,通过guid获取的对象中含有明细 { lineList = salesOrderResult.OrderLineList.Where(a => a.StkOutOccQty.ToInt32() < a.Qty).ToList(); } else//在出库窗体打开选择窗体得到的对象是没有包含明细的,需要去单独获取明细 { lineList = orderLineLogic.GetList(new ORD_SalesOrderLineParam() { SOGuid = salesOrderResult.SOGuid }).Where(a => a.StkOutOccQty.ToInt32() < a.Qty).ToList(); } foreach (STK_StockReserveResult reserveResult in reserveList) { STK_OutLineResult stkOutLineResult = new STK_OutLineResult(); ORD_SalesOrderLineResult lineResult = lineList.FirstOrDefault(a => a.SOLineGuid == reserveResult.SourceBillLineGuid); if (lineResult != null) { stkOutLineResult.UnitPrice = lineResult.UnitPrice; } SetStkLineObjectValue(stkOutLineResult, reserveResult); bsStkOutLine.Add(stkOutLineResult); } } } else if (obj is ORD_PurchaseReturnResult) { ORD_PurchaseReturnResult purReturnResult = obj as ORD_PurchaseReturnResult; if (purReturnResult != null) { txtSourceBillGuid.Text = purReturnResult.POGuid.ToStringHasNull(); txtSourceBillNo.Text = purReturnResult.BillNo; decimal?taxRate = 0; cboTaxRate.SelectedValue = taxRate; cboCurrency.SelectedValue = purReturnResult.Currency; List <STK_StockReserveResult> reserveList = reserveLogic.GetList(new STK_StockReserveParam() { SourceBillGuid = purReturnResult.PRGuid, IsUsedOver = false }); List <ORD_PurchaseReturnLineResult> lineList = null; if (purReturnResult.ReturnLineList != null) { lineList = purReturnResult.ReturnLineList.Where(a => a.StkOutOccQty.ToInt32() < a.Qty).ToList(); } else { lineList = returnLineLogic.GetList(new ORD_PurchaseReturnLineParam() { PRGuid = purReturnResult.PRGuid }).Where(a => a.StkOutOccQty.ToInt32() < a.Qty).ToList(); } foreach (STK_StockReserveResult reserveResult in reserveList) { STK_OutLineResult stkOutLineResult = new STK_OutLineResult(); ORD_PurchaseReturnLineResult lineResult = lineList.FirstOrDefault(a => a.PRLineGuid == reserveResult.SourceBillLineGuid); if (lineResult != null) { stkOutLineResult.UnitPrice = lineResult.UnitPrice; } SetStkLineObjectValue(stkOutLineResult, reserveResult); bsStkOutLine.Add(stkOutLineResult); } } } CalcExchangeRate(); } }
/// <summary> /// 添加和新增修改 /// </summary> /// <param name="param">新增或修改的实体</param> /// <returns></returns> public WCFAddUpdateResult AddOrUpdate(ORD_PurchaseReturnResult param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); try { int affect = 0; #region 判断 if (string.IsNullOrEmpty(param.SupplierName.Trim())) { throw new WarnException("请选择客户!"); } if (string.IsNullOrEmpty(param.POBillNo)) { throw new WarnException("请选择采购单号!"); } if (string.IsNullOrEmpty(param.OperEmpName)) { throw new WarnException("请选择归属人!"); } if (string.IsNullOrEmpty(param.Currency)) { throw new WarnException("请选择币种!"); } if (param.ReturnLineList == null) { throw new WarnException("请导入退货明细!"); } string msg = string.Empty; foreach (ORD_PurchaseReturnLineResult rst in param.ReturnLineList) { if (rst.StkInLineGuid.ToGuid() == Guid.Empty) { msg = "请选择关联的入库明细!"; break; } if (rst.Qty <= 0) { msg = "请填写采购退货明细的数量!"; break; } } if (!string.IsNullOrEmpty(msg)) { throw new WarnException(msg); } #endregion List <ORD_PurchaseReturnLineResult> orderLineList = param.ReturnLineList; #region 系统默认值 if (param.PRGuid != null) { WhereClip where = ORD_PurchaseReturn._.PRGuid == param.PRGuid; param.UpdatedEmpID = this.SessionInfo.UserID; param.UpdatedEmpName = this.SessionInfo.UserName; param.UpdatedTime = DateTime.Now; affect = this.Update <ORD_PurchaseReturnResult>(param, where); } else { param.PRGuid = Guid.NewGuid(); Sys_CodeRulerBLL codeRulerBll = new Sys_CodeRulerBLL(); codeRulerBll.SessionInfo = this.SessionInfo; param.BillNo = param.BillNo = codeRulerBll.GetBillNo(new Entity.UserModel.Sys.SYS_CredentialCodeRuleParam() { BillDate = DateTime.Today, TableName = "ORD_PurchaseReturn" }); param.GCompanyID = this.SessionInfo.CompanyID; param.StkOutOccStatus = "待占有"; param.StkOutStatus = "待入库"; param.Status = "New"; param.ApproveStatus = "待提交"; param.IsDeleted = false; param.CreatedEmpID = this.SessionInfo.UserID; param.CreatedEmpName = this.SessionInfo.UserName; param.CreatedTime = DateTime.Now; affect = this.Insert <ORD_PurchaseReturnResult>(param); param = this.Select <ORD_PurchaseReturnResult>(new List <Field>() { ORD_PurchaseReturn._.All }, ORD_PurchaseReturn._.PRGuid == param.PRGuid); } foreach (ORD_PurchaseReturnLineResult rst in orderLineList) { if (rst.PRLineGuid.ToGuid() == Guid.Empty) { rst.PRLineGuid = Guid.NewGuid(); rst.PRGuid = param.PRGuid; rst.GCompanyID = this.SessionInfo.CompanyID; rst.CreatedEmpID = this.SessionInfo.UserID; rst.CreatedEmpName = this.SessionInfo.UserName; rst.CreatedTime = DateTime.Now; rst.IsDeleted = false; } else { rst.UpdatedEmpID = this.SessionInfo.UserID; rst.UpdatedEmpName = this.SessionInfo.UserName; rst.UpdatedTime = DateTime.Now; } } this.BatchInsertOrUpdate <ORD_PurchaseReturnLineResult>(orderLineList); this.BatchExecute(); #region 设置返回值 ret.Key = param.PRID.ToInt32(); ret.KeyGuid = param.PRGuid; ret.CreatedTime = param.CreatedTime; ret.CreatedEmpID = param.CreatedEmpID; ret.CreatedEmpName = param.CreatedEmpName; ret.UpdatedEmpID = param.UpdatedEmpID; ret.UpdatedEmpName = param.UpdatedEmpName; ret.UpdatedTime = param.UpdatedTime; #endregion #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }
public bool SubmitPurchaseReturnBill(ORD_PurchaseReturnParam param) { this.CheckSession(); bool submitFlag = true; try { ORD_PurchaseReturnResult returnResult = this.GetInfo(param); if (returnResult != null) { #region 判断是否可以提交 bool isAllowSubmit = true; if (returnResult.ApproveStatus == "待审核") { isAllowSubmit = false; throw new WarnException("采购退货单当前状态为:【已提交,待审核】,禁止重复提交!"); } else if (returnResult.ApproveStatus == "审核完成") { isAllowSubmit = false; throw new WarnException("采购退货单当前状态为:【审核完成】,撤单后才可以再次提交!"); } if (isAllowSubmit) { returnResult.Status = "Approve"; returnResult.ApproveStatus = "待审核"; WCFAddUpdateResult ret = this.AddOrUpdate(returnResult); if (ret.KeyGuid.ToGuid() == Guid.Empty) { submitFlag = false; } else { #region 定义相关变量 ORD_PurchaseOrderBLL purOrderBLL = new ORD_PurchaseOrderBLL(); purOrderBLL.SessionInfo = this.SessionInfo; ORD_PurchaseOrderLineBLL purOrderLineBLL = new ORD_PurchaseOrderLineBLL(); purOrderLineBLL.SessionInfo = this.SessionInfo; STK_InBLL inBLL = new STK_InBLL(); inBLL.SessionInfo = this.SessionInfo; STK_InLineBLL inLineBLL = new STK_InLineBLL(); inLineBLL.SessionInfo = this.SessionInfo; ORD_PurchaseReturnLineBLL returnLineBLL = new ORD_PurchaseReturnLineBLL(); returnLineBLL.SessionInfo = this.SessionInfo; STK_StockReserveBLL reserveBLL = new STK_StockReserveBLL(); reserveBLL.SessionInfo = this.SessionInfo; Guid?[] POLineGuids = null; Guid?[] StkInLineGuids = null; Guid?[] PRGuids = null; Guid?[] effPRGuids = null; Guid?[] POGuids = null; List <STK_InLineResult> linkInLineList = new List <STK_InLineResult>(); List <ORD_PurchaseOrderLineResult> linkPurchaseOrderLineList = new List <ORD_PurchaseOrderLineResult>(); List <ORD_PurchaseReturnResult> linkReturnList = new List <ORD_PurchaseReturnResult>(); List <ORD_PurchaseReturnLineResult> linkReturnLineList = new List <ORD_PurchaseReturnLineResult>(); List <ORD_PurchaseReturnLineResult> effReturnLineList = new List <ORD_PurchaseReturnLineResult>(); #endregion List <ORD_PurchaseReturnLineResult> purReturnLineList = returnLineBLL.GetList(new ORD_PurchaseReturnLineParam() { PRGuid = returnResult.PRGuid }); #region 预留库存 foreach (ORD_PurchaseReturnLineResult returnLineResult in purReturnLineList) { //创建预留明细 STK_StockReserveResult reserveResult = new STK_StockReserveResult(); reserveResult.SourceBillGuid = returnResult.PRGuid; //采购退货单guid reserveResult.SourceBillNo = returnResult.BillNo; //退货单编号 reserveResult.SourceBillLineGuid = returnLineResult.PRLineGuid; //退货明细guid reserveResult.SourceBillType = "采购退货出库"; reserveResult.ReserveType = 4; //退货预留 reserveResult.OperType = false; //系统预留 reserveResult.StkInLineGuid = returnLineResult.StkInLineGuid; // 入库明细guid reserveResult.ItemCode = returnLineResult.ItemCode; reserveResult.OperFlag = true; //增加 reserveBLL.OperateReserve(reserveResult); } #endregion #region 更新入库明细的退货数量 //获取退货明细关联的入库明细ID集合 StkInLineGuids = purReturnLineList.Select(a => a.StkInLineGuid).Distinct().ToArray(); if (StkInLineGuids != null && StkInLineGuids.Length > 0) { //退货明细关联的入库明细 linkInLineList = inLineBLL.GetList(new STK_InLineParam() { StkInLineGuids = StkInLineGuids }); //关联的入库明细所关联的退货明细 linkReturnLineList = returnLineBLL.GetList(new ORD_PurchaseReturnLineParam() { StkInLineGuids = StkInLineGuids }); PRGuids = linkReturnLineList.Select(a => a.PRGuid).Distinct().ToArray(); if (PRGuids != null && PRGuids.Length > 0) { //关联的入库明细所关联的退货明细对应的退货主单 linkReturnList = this.GetList(new ORD_PurchaseReturnParam() { PRGuids = PRGuids, StatusArr = new string[] { "Complete", "Approve" } }); if (linkReturnList != null && linkReturnList.Count > 0) { effPRGuids = linkReturnList.Select(a => (Guid?)a.PRGuid).Distinct().ToArray(); effReturnLineList = linkReturnLineList.Where(a => effPRGuids.Contains(a.PRGuid)).ToList(); foreach (STK_InLineResult inLineResult in linkInLineList) { int?qty = effReturnLineList.Where(a => a.StkInLineGuid == inLineResult.StkInLineGuid).Sum(a => a.Qty.ToInt32()); inLineResult.ReturnOccQty = qty; } } } //更新退货明细关联的入库明细的退货占有数量 inLineBLL.UpdateOrInsertList(linkInLineList); } #endregion #region 更新采购明细的采购占有数量和采购主单的退货占有状态 //获取关联采购明细ID集合 POLineGuids = purReturnLineList.Select(a => a.POLineGuid).Distinct().ToArray(); linkPurchaseOrderLineList = purOrderLineBLL.GetList(new ORD_PurchaseOrderLineParam() { POLineGuids = POLineGuids, IsCancel = false }); //获取关联的采购明细所关联的退货明细 linkReturnLineList = returnLineBLL.GetList(new ORD_PurchaseReturnLineParam() { POLineGuids = POLineGuids }); PRGuids = linkReturnLineList.Select(a => a.PRGuid).Distinct().ToArray(); if (PRGuids != null && PRGuids.Length > 0) { //采购明细所关联的退货明细对应的退货主单 linkReturnList = this.GetList(new ORD_PurchaseReturnParam() { PRGuids = PRGuids, StatusArr = new string[] { "Complete", "Approve" } }); if (linkReturnList != null && linkReturnList.Count > 0) { effPRGuids = linkReturnList.Select(a => (Guid?)a.PRGuid).Distinct().ToArray(); effReturnLineList = linkReturnLineList.Where(a => effPRGuids.Contains(a.PRGuid)).ToList(); foreach (ORD_PurchaseOrderLineResult purLineResult in linkPurchaseOrderLineList) { int?qty = effReturnLineList.Where(a => a.POLineGuid == purLineResult.POLineGuid).Sum(a => a.Qty.ToInt32()); purLineResult.ReturnOccQty = qty; } } } purOrderLineBLL.UpdateOrInsertList(linkPurchaseOrderLineList); POGuids = linkPurchaseOrderLineList.Select(a => a.SOGuid).Distinct().ToArray(); foreach (Guid poguid in POGuids) { purOrderBLL.UpdateStatus(new ORD_PurchaseOrderParam() { POGuid = poguid }); } #endregion } } #endregion } else { throw new WarnException("要提交的采购退货单在系统中不存在!"); } } catch (WarnException exp) { throw exp; } catch (Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(submitFlag); }
public bool AuditPurchaseReturnBill(ORD_PurchaseReturnParam param) { bool auditFlag = true; try { ORD_PurchaseReturnResult returnResult = this.GetInfo(param); if (returnResult != null) { bool isAllowAudit = true; if (returnResult.ApproveStatus == "待提交") { isAllowAudit = false; throw new WarnException("采购退货单当前状态为:【待提交】,请先提交!"); } else if (returnResult.ApproveStatus == "审核完成") { isAllowAudit = false; throw new WarnException("采购退货单当前状态为:【审核完成】,禁止重复审核!"); } if (isAllowAudit) { returnResult.Status = "Complete"; returnResult.ApproveStatus = "审核完成"; WCFAddUpdateResult ret = this.AddOrUpdate(returnResult); if (ret.KeyGuid.ToGuid() == Guid.Empty) { auditFlag = false; } else { #region 定义相关变量 ORD_PurchaseOrderBLL purOrderBLL = new ORD_PurchaseOrderBLL(); purOrderBLL.SessionInfo = this.SessionInfo; ORD_PurchaseOrderLineBLL purOrderLineBLL = new ORD_PurchaseOrderLineBLL(); purOrderLineBLL.SessionInfo = this.SessionInfo; STK_InBLL inBLL = new STK_InBLL(); inBLL.SessionInfo = this.SessionInfo; STK_InLineBLL inLineBLL = new STK_InLineBLL(); inLineBLL.SessionInfo = this.SessionInfo; ORD_PurchaseReturnLineBLL returnLineBLL = new ORD_PurchaseReturnLineBLL(); returnLineBLL.SessionInfo = this.SessionInfo; Guid?[] POLineGuids = null; Guid?[] StkInLineGuids = null; Guid?[] PRGuids = null; Guid?[] effPRGuids = null; Guid?[] POGuids = null; List <STK_InLineResult> linkInLineList = new List <STK_InLineResult>(); List <ORD_PurchaseOrderLineResult> linkPurchaseOrderLineList = new List <ORD_PurchaseOrderLineResult>(); List <ORD_PurchaseReturnResult> linkReturnList = new List <ORD_PurchaseReturnResult>(); List <ORD_PurchaseReturnLineResult> linkReturnLineList = new List <ORD_PurchaseReturnLineResult>(); List <ORD_PurchaseReturnLineResult> effReturnLineList = new List <ORD_PurchaseReturnLineResult>(); #endregion List <ORD_PurchaseReturnLineResult> purReturnLineList = returnLineBLL.GetList(new ORD_PurchaseReturnLineParam() { PRGuid = returnResult.PRGuid }); #region 更新采购明细的退货数量和采购主单的退货状态 //获取关联的采购明细ID集合 POLineGuids = purReturnLineList.Select(a => a.POLineGuid).Distinct().ToArray(); linkPurchaseOrderLineList = purOrderLineBLL.GetList(new ORD_PurchaseOrderLineParam() { POLineGuids = POLineGuids }); //获取关联的采购明细所关联的退货明细 linkReturnLineList = returnLineBLL.GetList(new ORD_PurchaseReturnLineParam() { POLineGuids = POLineGuids }); PRGuids = linkReturnLineList.Select(a => a.PRGuid).Distinct().ToArray(); if (PRGuids != null && PRGuids.Length > 0) { //采购明细所关联的退货明细对应的退货主单 linkReturnList = this.GetList(new ORD_PurchaseReturnParam() { PRGuids = PRGuids, Status = "Complete" }); if (linkReturnList != null && linkReturnList.Count > 0) { effPRGuids = linkReturnList.Select(a => (Guid?)a.PRGuid).Distinct().ToArray(); effReturnLineList = linkReturnLineList.Where(a => effPRGuids.Contains(a.PRGuid)).ToList(); foreach (ORD_PurchaseOrderLineResult purLineResult in linkPurchaseOrderLineList) { int?qty = effReturnLineList.Where(a => a.POLineGuid == purLineResult.SOLineGuid).Sum(a => a.Qty.ToInt32()); purLineResult.ReturnQty = qty; } } } purOrderLineBLL.UpdateOrInsertList(linkPurchaseOrderLineList); POGuids = linkPurchaseOrderLineList.Select(a => a.SOGuid).Distinct().ToArray(); foreach (Guid poguid in POGuids) { purOrderBLL.UpdateStatus(new ORD_PurchaseOrderParam() { POGuid = poguid }); } #endregion } } } else { throw new WarnException("要审核的采购退货单在系统中不存在!"); } } catch (WarnException exp) { throw exp; } catch (Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(auditFlag); }