//BtnOk_Click... private void BtnOk_Click_Extend(object sender, EventArgs e) { //调用模版提供的默认实现.--默认实现可能会调用相应的Action. decimal sumMoveMoney = 0;//累计挪出金额 foreach (PrePaymentLineRecord record in this.Model.PrePaymentLine.SelectRecords) { decimal canMoveMoney = record.CanMoveMoney ?? decimal.Zero; decimal thisMoveMoney = record.ThisMoveMoney ?? decimal.Zero; if (thisMoveMoney <= 0) { throw new Exception("预付款通知单行:本次挪出金额必须0!"); } if (thisMoveMoney > canMoveMoney) { throw new Exception("预付款通知单行:本次挪出金额不允许大于可挪出金额!"); } sumMoveMoney = sumMoveMoney + thisMoveMoney; } if (this.Model.PurchaseOrderView.SelectRecords.Count == 0) { throw new Exception("没有选择需要挪入的采购订单!"); } List <UFIDA.U9.Cust.GS.FI.PrePaymentBP.PrePaymentHeadDTOData> headList = new List <PrePaymentBP.PrePaymentHeadDTOData>(); UFIDA.U9.Cust.GS.FI.PrePaymentBP.PrePaymentHeadDTOData head = new PrePaymentBP.PrePaymentHeadDTOData(); head.ID = this.Model.PrePaymentLine.FocusedRecord.PrePayment_ID; head.PrePaymentLineDTOs = new List <PrePaymentBP.PrePaymentLineDTOData>(); //先将挪出的行加入到DTO中 PrePaymentBP.PrePaymentLineDTOData moveLine = new PrePaymentBP.PrePaymentLineDTOData(); moveLine.ID = this.Model.PrePaymentLine.FocusedRecord.ID; moveLine.ThisMoveMoney = this.Model.PrePaymentLine.FocusedRecord.ThisMoveMoney ?? decimal.Zero; head.PrePaymentLineDTOs.Add(moveLine); decimal sumIntoMoney = 0; foreach (PurchaseOrderViewRecord poRecord in this.Model.PurchaseOrderView.SelectRecords) { decimal intoMoney = poRecord.ThisMoveMoney ?? decimal.Zero; if (intoMoney <= 0) { throw new Exception("本次挪入金额必须大于0!"); } sumIntoMoney = sumIntoMoney + intoMoney; //将挪入的行加入到DTO PrePaymentBP.PrePaymentLineDTOData intoLine = new PrePaymentBP.PrePaymentLineDTOData(); intoLine.PurchaseOrder = poRecord.PODocID.Value; intoLine.PrePayMoney = poRecord.ThisMoveMoney.Value; intoLine.SrcMoveDocID = this.Model.PrePaymentLine.FocusedRecord.PrePayment_ID; intoLine.SrcMoveDocNo = this.Model.PrePaymentLine.FocusedRecord.PrePayment_DocNo; intoLine.SrcMoveLineID = this.Model.PrePaymentLine.FocusedRecord.ID; intoLine.SrcMoveLineNum = this.Model.PrePaymentLine.FocusedRecord.LineNum.Value; head.PrePaymentLineDTOs.Add(intoLine); } if (sumMoveMoney != sumIntoMoney) { throw new Exception("本次挪出金额不等于本次挪入金额之和!"); } headList.Add(head); UFIDA.U9.Cust.GS.FI.PrePaymentBP.Proxy.PrePaymentMoveBPProxy bp = new PrePaymentBP.Proxy.PrePaymentMoveBPProxy(); bp.PrePaymentHeadDTOs = headList; bp.Do(); BtnOk_Click_DefaultImpl(sender, e); }
//BtnOk_Click... private void BtnOk_Click_Extend(object sender, EventArgs e) { //调用模版提供的默认实现.--默认实现可能会调用相应的Action. if (this.Model.DocumentTypeView.FocusedRecord.DocType <= 0L) { throw new Exception("红冲类型不能为空!"); } if (this.Model.PrePaymentLine.SelectRecords.Count <= 0) { throw new Exception("没有选择要红冲的预付款通知单行!"); } List <UFIDA.U9.Cust.GS.FI.PrePaymentBP.PrePaymentHeadDTOData> headList = new List <PrePaymentBP.PrePaymentHeadDTOData>(); UFIDA.U9.Cust.GS.FI.PrePaymentBP.PrePaymentHeadDTOData head = new PrePaymentBP.PrePaymentHeadDTOData(); head.DocumentType = this.Model.DocumentTypeView.FocusedRecord.DocType; head.SrcPrePayDocID = long.Parse(this.Model.PrePaymentLine.SelectRecords[0]["PrePayment_ID"].ToString()); head.PrePaymentLineDTOs = new List <PrePaymentBP.PrePaymentLineDTOData>(); foreach (PrePaymentLineRecord record in this.Model.PrePaymentLine.SelectRecords) { decimal canRedMoney = record.CanRedMoney ?? decimal.Zero; decimal thisRedMoney = record.ThisRedMoney ?? decimal.Zero; if (thisRedMoney <= 0) { throw new Exception("第" + record.LineNum.ToString() + "行:本次红冲金额必须大于0!"); } if (thisRedMoney > canRedMoney) { throw new Exception("第" + record.LineNum.ToString() + "行:本次红冲金额不能大于可红冲金额!"); } UFIDA.U9.Cust.GS.FI.PrePaymentBP.PrePaymentLineDTOData line = new PrePaymentBP.PrePaymentLineDTOData(); line.SrcPrePayLineID = record.ID; line.ThisRedMoney = thisRedMoney; head.PrePaymentLineDTOs.Add(line); } headList.Add(head); UFIDA.U9.Cust.GS.FI.PrePaymentBP.Proxy.RedFlushPrePaymentBPProxy bp = new PrePaymentBP.Proxy.RedFlushPrePaymentBPProxy(); bp.PrePaymentHeadDTOs = headList; List <UFIDA.U9.Cust.GS.FI.PubBP.CommonDTOData> resultList = bp.Do(); if (resultList != null && resultList.Count > 0) { foreach (UFIDA.U9.Cust.GS.FI.PubBP.CommonDTOData result in resultList) { UFIDA.U9.Cust.GS.FI.PrePaymentBP.Proxy.ApprovedPrePaymentBPProxy subBP = new PrePaymentBP.Proxy.ApprovedPrePaymentBPProxy(); subBP.EntityKey = result.ID; subBP.Type = 0; subBP.Do(); UFIDA.U9.Cust.GS.FI.PrePaymentBP.Proxy.ApprovedPrePaymentBPProxy appBP = new PrePaymentBP.Proxy.ApprovedPrePaymentBPProxy(); appBP.EntityKey = result.ID; appBP.Type = 1; appBP.Do(); } } BtnOk_Click_DefaultImpl(sender, e); }
/// <summary> /// 批量拉单 /// </summary> private void BatchCreatePrePayment() { int selectCount = this.Model.PurchaseOrderView.SelectRecords.Count; if (selectCount == 0) { throw new Exception("未选中数据!"); } DataTable table = new DataTable(); table.Columns.Add("Supplier", typeof(long)); table.Columns.Add("Currency", typeof(long)); table.Columns.Add("POOrg", typeof(long)); table.Columns.Add("Dept", typeof(long)); table.Columns.Add("Buyer", typeof(long)); #region 对选中的数据按照供应商、币种、采购组织、来源组织、采购部门、业务员进行分组 foreach (PurchaseOrderViewRecord record in this.Model.PurchaseOrderView.SelectRecords) { decimal preMoney = record.ThisPreMoney ?? decimal.Zero; decimal canMoney = record.CanPreMoney ?? decimal.Zero; if (preMoney <= 0) { throw new Exception("本次预付金额必须大于0!"); } if (preMoney > canMoney) { throw new Exception("本次预付金额不能大于可预付金额!"); } StringBuilder strWhere = new StringBuilder(300); strWhere.Append("Supplier='" + record.Supplier.ToString() + "'"); strWhere.Append(" and Currency='" + record.Currency.ToString() + "'"); strWhere.Append(" and POOrg='" + record.POOrg.ToString() + "'"); strWhere.Append(" and Dept='" + record.Dept.ToString() + "'"); strWhere.Append(" and Buyer='" + record.Buyer.ToString() + "'"); DataRow[] drs = table.Select(strWhere.ToString()); if (drs != null && drs.Length == 0) { DataRow dr = table.NewRow(); dr["Supplier"] = record.Supplier; dr["Currency"] = record.Currency; dr["POOrg"] = record.POOrg; dr["Dept"] = record.Dept; dr["Buyer"] = record.Buyer; table.Rows.Add(dr); } } #endregion #region 把分单后的数据赋值给创建预付款通知单的BP List <UFIDA.U9.Cust.GS.FI.PrePaymentBP.PrePaymentHeadDTOData> headList = new List <PrePaymentBP.PrePaymentHeadDTOData>(); foreach (DataRow dr in table.Rows) { UFIDA.U9.Cust.GS.FI.PrePaymentBP.PrePaymentHeadDTOData head = new PrePaymentBP.PrePaymentHeadDTOData(); if (this.NameValues["DocumentType"] != null) { head.DocumentType = long.Parse(this.NameValues["DocumentType"].ToString()); } head.Currency = long.Parse(dr["Currency"].ToString()); head.Supplier = long.Parse(dr["Supplier"].ToString()); head.POOrg = long.Parse(dr["POOrg"].ToString()); head.Dept = long.Parse(dr["Dept"].ToString()); head.Buyer = long.Parse(dr["Buyer"].ToString()); LocateExpressionCollection expList = new LocateExpressionCollection(); LocateExpression exp1 = new LocateExpression("Supplier", ExpressionOperator.Equal, long.Parse(dr["Supplier"].ToString())); LocateExpression exp2 = new LocateExpression("Currency", ExpressionOperator.Equal, long.Parse(dr["Currency"].ToString())); LocateExpression exp3 = new LocateExpression("POOrg", ExpressionOperator.Equal, long.Parse(dr["POOrg"].ToString())); LocateExpression exp4 = new LocateExpression("Dept", ExpressionOperator.Equal, long.Parse(dr["Dept"].ToString())); LocateExpression exp5 = new LocateExpression("Buyer", ExpressionOperator.Equal, long.Parse(dr["Buyer"].ToString())); expList.Add(exp1); expList.Add(exp2); expList.Add(exp3); expList.Add(exp4); expList.Add(exp5); ILocateExpression _ILocateExpression = expList; IUIRecordCollection records = this.Model.PurchaseOrderView.SelectRecords.FindAll(expList); head.PrePaymentLineDTOs = new List <PrePaymentBP.PrePaymentLineDTOData>(); foreach (IUIRecord record in records) { PurchaseOrderViewRecord poRecord = record as PurchaseOrderViewRecord; PrePaymentBP.PrePaymentLineDTOData line = new PrePaymentBP.PrePaymentLineDTOData(); line.PurchaseOrder = poRecord.PODocID.Value; line.PrePayMoney = poRecord.ThisPreMoney.Value; head.PrePaymentLineDTOs.Add(line); } headList.Add(head); } UFIDA.U9.Cust.GS.FI.PrePaymentBP.Proxy.BatchCreatePrePaymentBPProxy bp = new PrePaymentBP.Proxy.BatchCreatePrePaymentBPProxy(); bp.PrePaymentHeadDTOs = headList; List <UFIDA.U9.Cust.GS.FI.PubBP.CommonDTOData> resultList = bp.Do(); this.CurrentState["CommonDTODataList"] = resultList; #endregion if (this.Model.QueryConditionView.FocusedRecord.IsShow.Value) { NameValueCollection param = new NameValueCollection(); param.Add("PDPageStatus", "Browse");//这行代码是控制弹开画面为浏览状态 string FormID = "9b3eb33f-d188-4d0d-8856-aff8c6c23f1e"; this.ShowModalDialog(FormID, "批量预付结果", "810", "375", null, param, false, false); } }