protected override void AfterGetData(Dictionary <string, object> dic, bool isNew, string upperVersionID) { base.AfterGetData(dic, isNew, upperVersionID); string ContractID = dic.GetValue("ContractID"); if (isNew) { ContractID = GetQueryString("ContractID"); } var lastVersionID = dic.GetValue("LastVersionID"); if (string.IsNullOrEmpty(lastVersionID)) { var contract = EPCEntites.Set <S_P_ContractInfo>().Find(ContractID); dic.SetValue("LastVersionData", JsonHelper.ToJson(contract)); } else { string LastVersionID = dic.GetValue("LastVersionID"); var change = EPCEntites.Set <S_P_FbContractChange>().Find(LastVersionID); if (change != null) { S_P_ContractInfo contract = new S_P_ContractInfo(); FormulaHelper.UpdateEntity(contract, change.ToDic());//只带合同信息,去掉审批字段数据 dic.SetValue("LastVersionData", JsonHelper.ToJson(contract)); } } }
protected override void OnFlowEnd(T_P_ContractReview entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing) { base.OnFlowEnd(entity, taskExec, routing); S_P_ContractInfo contract = EPCEntites.Set <S_P_ContractInfo>().Find(entity.ContractInfo); if (contract == null) { throw new BusinessException("已无法找到id为【" + entity.ContractInfo + "】的采购合同信息"); } contract.ContractState = "Review"; //foreach (var content in contract.S_P_ContractInfo_Content) //{ // var tContent = entity.T_P_ContractReview_Content.FirstOrDefault(a => a.PBomID == content.PBomID); // if(tContent != null) // { // content.SFZJ = tContent.SFZJ; // } //} EPCEntites.SaveChanges(); }
public void PriceValidate(List <Dictionary <string, object> > list, string versionID) { string contractInfoID = this.GetQueryString("ContractInfoID"); //合同金额 S_P_ContractInfo contractInfo = entities.Set <S_P_ContractInfo>().Find(contractInfoID); if (contractInfo == null) { throw new Formula.Exceptions.BusinessValidationException("id为" + contractInfoID + "的合同已不存在"); } decimal priceTotal = 0; List <string> ids = new List <string>(); foreach (var item in list) { ids.Add(item.GetValue("ID")); string dataStateFromUICtrl = item.GetValue("_state").ToLower(); decimal tmp = 0; decimal.TryParse(item.GetValue("Price"), out tmp); if (dataStateFromUICtrl == "removed") { tmp = -tmp; } priceTotal += tmp; } //找出不在list(变更项)的数据 decimal dbPriceTotal = entities.Set <S_C_BOQ_Version_Detail>().Where(a => !ids.Contains(a.ID) && a.VersionID == versionID).ToList().Sum(a => a.Price ?? 0); if ((priceTotal + dbPriceTotal) > (contractInfo.ContractAmount ?? 0)) { throw new Formula.Exceptions.BusinessValidationException("清单总价已经超出了合同额" + contractInfo.ContractAmount + "元"); } }
protected override void AfterGetData(Dictionary <string, object> dic, bool isNew, string upperVersionID) { string tmplCode = Request["TmplCode"]; var formInfo = baseEntities.Set <S_UI_Form>().SingleOrDefault(c => c.Code == tmplCode); if (formInfo == null) { throw new Exception("没有找到编号为【" + tmplCode + "】的表单定义"); } var items = JsonHelper.ToList(formInfo.Items).Where(c => c.GetValue("ItemType") == "SubTable").ToList(); string ContractID = dic.GetValue("ContractID"); if (isNew) { ContractID = GetQueryString("ContractID"); foreach (var item in items) { var tableName = formInfo.TableName + "_" + item.GetValue("Code"); var contractTableName = "S_P_ContractInfo" + "_" + item.GetValue("Code"); string sql = "SELECT count(0) as TableCount FROM sysobjects WHERE name='{0}'"; var obj = Convert.ToInt32(this.EPCSQLDB.ExecuteScalar(String.Format(sql, contractTableName))); if (obj > 0) { sql = "Select * from {0} where S_P_ContractInfoID='{1}'"; var subTable = this.EPCSQLDB.ExecuteDataTable(String.Format(sql, contractTableName, ContractID)); var subTableData = new List <Dictionary <string, object> >(); foreach (DataRow subItem in subTable.Rows) { var TmpDic = Formula.FormulaHelper.DataRowToDic(subItem); //if (item.GetValue("Code") == "PaymentObj") //{ // string paymentID = subItem["ID"].ToString(); // bool CantChange = false; // if (EPCEntites.Set<S_P_Payment_PaymentObjRelation>().Any(a => a.PaymentObjID == paymentID) // || EPCEntites.Set<S_P_Invoice_PaymentObjRelation>().Any(a => a.S_P_PaymentObjID == paymentID)) // { // CantChange = true; // } // TmpDic.SetValue("CantChange", CantChange); //} TmpDic.SetValue("ID", ""); TmpDic.SetValue("OrlID", subItem["ID"]); subTableData.Add(TmpDic); } var json = JsonHelper.ToJson(subTableData); dic.SetValue(item.GetValue("Code"), json);//子表json赋值 } } } var lastVersionID = dic.GetValue("LastVersionID"); if (string.IsNullOrEmpty(lastVersionID)) { var contract = EPCEntites.Set <S_P_ContractInfo>().Find(ContractID); dic.SetValue("LastVersionData", JsonHelper.ToJson(contract)); var cbsInfo = contract.S_P_ContractInfo_CBSInfo; var cbsDics = FormulaHelper.CollectionToListDic(cbsInfo); foreach (var cbsDic in cbsDics) { cbsDic.SetValue("OrlID", cbsDic.GetValue("ID")); } var content = contract.S_P_ContractInfo_Content; var contentDics = FormulaHelper.CollectionToListDic(content); foreach (var contentDic in contentDics) { contentDic.SetValue("OrlID", contentDic.GetValue("ID")); } var payment = contract.S_P_ContractInfo_PaymentObj; var paymentDics = FormulaHelper.CollectionToListDic(payment); foreach (var paymentDic in paymentDics) { paymentDic.SetValue("OrlID", paymentDic.GetValue("ID")); } dic.SetValue("LastCBSInfo", JsonHelper.ToJson(cbsDics)); dic.SetValue("LastContent", JsonHelper.ToJson(contentDics)); dic.SetValue("LastPaymentObj", JsonHelper.ToJson(paymentDics)); } else { S_P_ProcurementContractChange change = EPCEntites.Set <S_P_ProcurementContractChange>().Find(lastVersionID); if (change != null) { S_P_ContractInfo contract = new S_P_ContractInfo(); FormulaHelper.UpdateEntity(contract, change.ToDic());//只带合同信息,去掉审批字段数据 dic.SetValue("LastVersionData", JsonHelper.ToJson(contract)); dic.SetValue("LastCBSInfo", JsonHelper.ToJson(change.S_P_ProcurementContractChange_CBSInfo)); dic.SetValue("LastContent", JsonHelper.ToJson(change.S_P_ProcurementContractChange_Content)); dic.SetValue("LastPaymentObj", JsonHelper.ToJson(change.S_P_ProcurementContractChange_PaymentObj)); } } }
protected override void OnFlowEnd(Logic.Domain.S_P_ContractInfo_Fb_BOQPayCheck entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing) { base.OnFlowEnd(entity, taskExec, routing); S_P_ContractInfo contract = EPCEntites.Set <S_P_ContractInfo>().Find(entity.ContractInfoID); if (contract == null) { throw new Formula.Exceptions.BusinessValidationException("ID为" + entity.ContractInfoID + "的合同已不存在"); } var detailSummary = EPCEntites.Set <S_P_ContractInfo_Fb_BOQPayCheck_Detail>() .SingleOrDefault(a => a.S_P_ContractInfo_Fb_BOQPayCheckID == entity.ID && a.PayCheckDetailType == (int)PayCheckDetailTemplateType.Summary); if (detailSummary == null) { throw new Formula.Exceptions.BusinessValidationException("找不到工程价款项"); } //合同付款项 S_P_ContractInfo_PaymentObj paymentObj = new S_P_ContractInfo_PaymentObj(); paymentObj.ContractFullID = entity.ContractInfoID; paymentObj.ID = FormulaHelper.CreateGuid(); paymentObj.Name = "预付"; paymentObj.PayType = "预付"; paymentObj.PlanPaymentValue = detailSummary.ConfirmPrice; paymentObj.S_P_ContractInfoID = entity.ContractInfoID; paymentObj.Scale = 100; EPCEntites.Set <S_P_ContractInfo_PaymentObj>().Add(paymentObj); //付款数据 var payment = EPCEntites.Set <S_P_Payment>().Find(entity.ID); if (payment == null) { payment = new S_P_Payment(); payment.ID = entity.ID; payment.State = PaymentState.Normal.ToString(); EPCEntites.Set <S_P_Payment>().Add(payment); } payment.OrgID = entity.OrgID; payment.CompanyID = entity.CompanyID; payment.ContractInfo = entity.ContractInfoID; payment.ContractInfoName = entity.ContractInfoName; payment.SupplierInfo = contract.PartyB; payment.SupplierInfoName = contract.PartyBName; payment.EngineeringInfoID = contract.EngineeringInfoID; payment.CreateDate = DateTime.Now; payment.CreateUser = CurrentUserInfo.UserName; payment.CreateUserID = CurrentUserInfo.UserID; payment.OrgID = CurrentUserInfo.UserOrgID; payment.PaymentValue = detailSummary.ConfirmPrice; payment.PaymentValueDX = ConvertToChinese(detailSummary.ConfirmPrice ?? 0); payment.PaymentRMBAmount = detailSummary.ConfirmPrice; payment.Register = entity.CreateUserID; payment.RegisterName = entity.CreateUser; payment.PaymentDate = DateTime.Now; payment.S_P_ContractInfo = contract; contract.S_P_Payment.Add(payment); //付款数据关联合同付款项 var detail = new S_P_Payment_PaymentObjRelation(); detail.S_P_ContractInfo_PaymentObj = paymentObj; detail.ID = FormulaHelper.CreateGuid(); detail.PaymentObjID = paymentObj.ID; detail.S_P_PaymentID = payment.ID; detail.RelationValue = paymentObj.PlanPaymentValue; EPCEntites.Set <S_P_Payment_PaymentObjRelation>().Add(detail); contract.SumPaymentValue = (contract.SumPaymentValue ?? 0) + detailSummary.ConfirmPrice; payment.ToCost(S_T_DefineParams.Params.GetValue("BOQPayAutoSettle").ToLower() == "true"); EPCEntites.SaveChanges(); }