protected override void AfterSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { var taskWork = this.GetEntityByID <S_W_TaskWork>(dic.GetValue("ID")); var sum = taskWork.S_W_TaskWork_RoleRate.Sum(a => a.Rate).ToString().TrimEnd('0').TrimEnd('.') + "%"; var d = taskWork.S_W_TaskWork_RoleRate.FirstOrDefault(a => a.Role == "Designer"); var c = taskWork.S_W_TaskWork_RoleRate.FirstOrDefault(a => a.Role == "Collactor"); var au = taskWork.S_W_TaskWork_RoleRate.FirstOrDefault(a => a.Role == "Auditor"); var ap = taskWork.S_W_TaskWork_RoleRate.FirstOrDefault(a => a.Role == "Approver"); var m = taskWork.S_W_TaskWork_RoleRate.FirstOrDefault(a => a.Role == "Mapper"); var designStr = d == null ? "" : "设(" + d.Rate.ToString().TrimEnd('0').TrimEnd('.') + "%);"; var collactStr = c == null ? "" : "校(" + c.Rate.ToString().TrimEnd('0').TrimEnd('.') + "%);"; var auditStr = au == null ? "" : "审(" + au.Rate.ToString().TrimEnd('0').TrimEnd('.') + "%);"; var approveStr = ap == null ? "" : "定(" + ap.Rate.ToString().TrimEnd('0').TrimEnd('.') + "%);"; var mapperStr = m == null ? "" : "制(" + m.Rate.ToString().TrimEnd('0').TrimEnd('.') + "%);"; var sumString = sum + " :" + (designStr == "设(%);" ? "" : designStr) + (collactStr == "校(%);" ? "" : collactStr) + (auditStr == "审(%);" ? "" : auditStr) + (approveStr == "定(%);" ? "" : approveStr) + (mapperStr == "制(%);" ? "" : mapperStr); taskWork.WorkloadDistribute = sumString; taskWork.Save(); taskWork.RoleRate = JsonHelper.ToJson(taskWork.S_W_TaskWork_RoleRate.OrderBy(a => a.SortIndex)); this.BusinessEntities.SaveChanges(); }
protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { var contractID = dic.GetValue("ID"); dic.SetValue("Code", dic.GetValue("SerialNumber")); //添加过补充协议的合同状态不能改成登记 var hasSupp = this.BusinessEntities.Set <S_SP_SupplierContract_Supplementary>().Any(a => a.MainContract == contractID); if (hasSupp && string.IsNullOrEmpty(dic.GetValue("SignDate"))) { throw new Formula.Exceptions.BusinessException("添加过补充协议的分包合同必须有签约日期"); } var entity = this.GetEntityByID(contractID); if (entity == null) { entity = new S_SP_SupplierContract(); } this.UpdateEntity(entity, dic); entity.Save(); var sumSettle = this.BusinessEntities.Set <S_SP_SupplierContract_Supplementary>().Where(a => a.MainContract == entity.ID).ToList().Sum(a => a.ContractValue); entity.ContractValue = entity.ThisContractValue + sumSettle; }
protected override void AfterSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { var entity = this.GetEntityByID <S_C_ManageContract_Supplementary>(dic.GetValue("ID")); SyncContract(entity); if (entity.SignDate.HasValue) { var date = Convert.ToDateTime(entity.SignDate); entity.BelongQuarter = MarketHelper.GetQuarter(date); entity.BelongYear = date.Year; entity.BelongMonth = date.Month; } Action action = () => { this.BusinessEntities.SaveChanges(); #region 修改补充协议需要同步业财的合同信息 if (entity.S_C_ManageContract != null) { var contractInfoDic = FormulaHelper.ModelToDic <S_C_ManageContract>(entity.S_C_ManageContract); Expenses.Logic.CBSInfoFO.SynCBSInfo(contractInfoDic, Expenses.Logic.SetCBSOpportunity.Contract); } #endregion }; this.ExecuteAction(action); }
protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { //base.BeforeSave(dic, formInfo, isNew); //补充协议为负值时,1.不能大于剩余可开票金额 var currentValue = Convert.ToDecimal(dic.GetValue("SupplementaryRMBAmount")); var contractID = dic.GetValue("ContractInfoID"); if (currentValue < 0) { var id = dic.GetValue("ID"); var detailIstStr = dic.GetValue("ReceiptObj"); if (!string.IsNullOrEmpty(detailIstStr)) { var detailIst = JsonHelper.ToList(detailIstStr); if (detailIst.Count > 1) { throw new Formula.Exceptions.BusinessException("协议金额为负数时,不能增加收款项"); } } ValidateDelete(contractID, currentValue); } //补充协议关联的合同必须有签约日期 var contract = this.GetEntityByID <S_C_ManageContract>(contractID); if (contract.SignDate == null) { throw new Formula.Exceptions.BusinessException("未签约的合同不能添加补充协议"); } }
protected override void AfterSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { var contract = this.GetEntityByID(dic["ID"]); if (contract == null) { contract = this.BusinessEntities.Set <S_C_ManageContract>().Create(); } this.UpdateEntity(contract, dic); contract.Save(); contract.SynchContractProperties(); var receiptObjList = contract.S_C_ManageContract_ReceiptObj.ToList(); var dicList = new List <Dictionary <string, object> >(); if (!string.IsNullOrEmpty(dic.GetValue("ReceiptObj"))) { dicList = JsonHelper.ToList(dic.GetValue("ReceiptObj")); } foreach (var receiptObj in contract.S_C_ManageContract_ReceiptObj.ToList()) { var dicItem = dicList.FirstOrDefault(a => a.GetValue("ID") == receiptObj.ID); if (dicItem != null) { UpdateEntity(receiptObj, dicItem); } receiptObj.SummaryReceiptValue(); receiptObj.ResetPlan(); receiptObj.SyncSupplementary(); } this.BusinessEntities.SaveChanges(); #region 自动同步核算项目 Expenses.Logic.CBSInfoFO.SynCBSInfo(FormulaHelper.ModelToDic <S_C_ManageContract>(contract), Expenses.Logic.SetCBSOpportunity.Contract); #endregion }
protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { var entity = this.GetEntityByID(dic["ID"]) ?? new T_SP_PaymentApply(); this.UpdateEntity(entity, dic); entity.Validate(); base.BeforeSave(dic, formInfo, isNew); }
protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { if (isNew) { if (String.IsNullOrEmpty(dic.GetValue("SubContractTaskID"))) { throw new Formula.Exceptions.BusinessValidationException("必须选择一个委外任务才能进行变更,请确认您是否关联了委外任务,因为委外任务ID为空值"); } var lastVersionData = this.GetDataDicByID("S_EP_SubContractTask", dic.GetValue("SubContractTaskID"), Config.ConnEnum.Market, true); dic.SetValue("LastVersionData", JsonHelper.ToJson(lastVersionData)); } }
protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { var user = dic.GetValue("UserID"); var year = Convert.ToInt32(dic.GetValue("Year")); var id = dic.GetValue("ID"); var exsit = this.BusinessEntities.Set <S_W_AttendanceAnnualLeave>().FirstOrDefault(a => a.UserID == user && a.Year == year && a.ID != id); if (exsit != null) { throw new Formula.Exceptions.BusinessException("【" + exsit.UserIDName + "】已经存在【" + year + "】年的年假数据"); } base.BeforeSave(dic, formInfo, isNew); }
protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { if (string.IsNullOrEmpty(dic.GetValue("PaymentDate"))) { throw new Formula.Exceptions.BusinessValidationException("请填写付款日期"); } CostFO.ValidatePeriodIsClosed(Convert.ToDateTime(dic.GetValue("PaymentDate"))); Expenses.Logic.BusinessFacade.DataInterfaceFo.ValidateDataSyn("S_SP_Payment", dic.GetValue("ID")); var entity = this.GetEntityByID(dic["ID"]) ?? new S_SP_Payment(); this.UpdateEntity(entity, dic); entity.Validate(); paymentid = dic["ID"]; }
protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { CostFO.ValidatePeriodIsClosed(new DateTime(Convert.ToInt32(dic["BelongYear"]), Convert.ToInt32(dic["BelongMonth"]), 1), "不能增加人工成本数据"); var costUnitID = dic.GetValue("CostUnitID"); var costUnitDic = this.GetDataDicByID("S_EP_CostUnit", costUnitID); if (costUnitDic == null) { throw new BusinessException("成本单元为空"); } var cbsNodeDic = this.GetDataDicByID("S_EP_CBSNode", costUnitDic.GetValue("CBSNodeID")); if (cbsNodeDic == null) { throw new BusinessException("未找到成本单元的cbsNode节点"); } var subjectDt = this.SQLDB.ExecuteDataTable(String.Format(@"select * from S_EP_CBSNode with(nolock) where FullID like '{0}%' order by FullID", cbsNodeDic.GetValue("FullID"))); var subjectNode = subjectDt.AsEnumerable().FirstOrDefault(c => c["SubjectType"] != null && c["SubjectType"] != DBNull.Value && c["SubjectType"].ToString() == SubjectType.HRCost.ToString()); if (subjectNode == null) { throw new BusinessException("未找到SubjectType为【" + SubjectType.HRCost.ToString() + "】的节点"); } dic["Name"] = subjectNode["Name"].ToString(); dic["Code"] = subjectNode["Code"].ToString(); dic["CBSNodeFullID"] = subjectNode["FullID"].ToString(); dic["CBSFullCode"] = subjectNode["FullCode"].ToString(); dic["CBSNodeID"] = subjectNode["ID"].ToString(); dic["SubjectCode"] = subjectNode["SubjectCode"].ToString(); dic["BelongDept"] = subjectNode["ChargerDept"].ToString(); dic["BelongDeptName"] = subjectNode["ChargerDeptName"].ToString(); dic["BelongUser"] = subjectNode["ChargerUser"].ToString(); dic["BelongUserName"] = subjectNode["ChargerUserName"].ToString(); dic["CostType"] = SubjectType.HRCost.ToString(); if (!String.IsNullOrEmpty(dic["BelongMonth"].ToString())) { var nBelongMonth = Convert.ToInt32(dic["BelongMonth"].ToString()); dic["BelongQuarter"] = ((nBelongMonth - 1) / 3 + 1).ToString(); } }
protected override void BeforeSaveSubTable(Dictionary <string, string> dic, string subTableName, List <Dictionary <string, string> > detailList, Base.Logic.Domain.S_UI_Form formInfo) { if (SysParams.Params.GetValue("SubContractConfirmMethod") == "PaymentConfirm" && subTableName == "CostInfo")//委外付款确认 { var costValue = 0m; var contractValue = 0m; foreach (var item in detailList) { costValue = 0m; decimal.TryParse(item.GetValue("CostValue"), out costValue); if (costValue <= 0) { throw new Formula.Exceptions.BusinessValidationException("【付款金额】必须大于0!"); } contractValue = 0m; decimal.TryParse(item.GetValue("ContractValue"), out contractValue); if (costValue > contractValue) { throw new Formula.Exceptions.BusinessValidationException("【付款金额】不能超过【合同金额】"); } } } if (subTableName == "InvoiceRelation") { var sumRelation = 0M; var paymentValue = String.IsNullOrEmpty(dic.GetValue("PaymentValue")) ? 0m : Convert.ToDecimal(dic.GetValue("PaymentValue")); foreach (var item in detailList) { var relationValue = String.IsNullOrEmpty(item.GetValue("RelationValue")) ? 0m : Convert.ToDecimal(item.GetValue("RelationValue")); sumRelation += relationValue; var remainRelationValue = String.IsNullOrEmpty(item.GetValue("RemainInvoiceValue")) ? 0m : Convert.ToDecimal(item.GetValue("RemainInvoiceValue")); if (relationValue > remainRelationValue) { throw new Formula.Exceptions.BusinessValidationException("本次对应金额【" + relationValue + "】不能大于可对应金额【" + remainRelationValue + "】"); } } if (sumRelation > paymentValue) { throw new Formula.Exceptions.BusinessValidationException("对应的发票金额总和不能大于本次付款金额"); } } else if (subTableName == "AcceptanceBill") { var sumRelation = 0M; var ids = new List <string>(); var paymentValue = String.IsNullOrEmpty(dic.GetValue("PaymentValue")) ? 0m : Convert.ToDecimal(dic.GetValue("PaymentValue")); foreach (var item in detailList) { var relationValue = String.IsNullOrEmpty(item.GetValue("Amount")) ? 0m : Convert.ToDecimal(item.GetValue("Amount")); sumRelation += relationValue; ids.Add(item.GetValue("AcceptanceBillID")); } if (sumRelation > paymentValue) { throw new Formula.Exceptions.BusinessValidationException("承兑汇票金额总和不能大于本次付款的金额"); } //修改承兑汇票支付状态 var mentity = FormulaHelper.GetEntities <MarketEntities>(); mentity.Set <S_C_AcceptanceBill>().Where(a => ids.Contains(a.ID)).Update(a => { a.State = "AlreadyPaid"; }); } else if (subTableName == "CostInfo") { var paymentValue = String.IsNullOrEmpty(dic.GetValue("PaymentValue")) ? 0m : Convert.ToDecimal(dic.GetValue("PaymentValue")); var sumRelation = 0M; foreach (var item in detailList) { var relationValue = String.IsNullOrEmpty(item.GetValue("CostValue")) ? 0m : Convert.ToDecimal(item.GetValue("CostValue")); sumRelation += relationValue; } if (sumRelation > paymentValue) { throw new Formula.Exceptions.BusinessValidationException("成本明细总额不能大于实付总金额"); } } }
protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { //model.SynchPostTemplate(); base.BeforeSave(dic, formInfo, isNew); }
//单个物资到货,自动补到货单,一货一单 protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { base.BeforeSave(dic, formInfo, isNew); if (!isNew) { return; } S_P_Arrival arrival = new S_P_Arrival(); arrival.ID = FormulaHelper.CreateGuid(); S_P_ContractInfo_Content content = EPCEntites.Set <S_P_ContractInfo_Content>().Find(dic.GetValue("BomInfo")); if (content == null) { throw new Formula.Exceptions.BusinessValidationException("未找到物资信息"); } decimal quantity = 0; decimal.TryParse(dic.GetValue("Quantity"), out quantity); if (quantity < 0) { throw new Formula.Exceptions.BusinessValidationException("到货数量不能为" + quantity); } //可能多发不判断 //decimal quantity = 0; //decimal.TryParse(dic.GetValue("Quantity"), out quantity); //decimal hasArrivalQuantity = EPCEntites.Set<S_P_Arrival_DetailInfo>().Where(a => a.BomInfo == content.ID).ToList().Sum(a => a.Quantity ?? 0); //decimal sumRest = content.ContractQuantity ?? 0 - hasArrivalQuantity; //if (quantity > sumRest) //{ // throw new Formula.Exceptions.BusinessValidationException("到货数量超出了剩余数量" + sumRest); //} arrival.CreateDate = DateTime.Now; arrival.ModifyDate = DateTime.Now; arrival.CreateUserID = CurrentUserInfo.UserID; arrival.CreateUser = CurrentUserInfo.UserName; arrival.ModifyUserID = CurrentUserInfo.UserID; arrival.ModifyUser = CurrentUserInfo.UserName; arrival.OrgID = CurrentUserInfo.UserOrgID; arrival.CompanyID = CurrentUserInfo.UserCompanyID; arrival.FlowPhase = "Start"; arrival.StepName = ""; arrival.EngineeringInfoName = content.S_P_ContractInfo.EngineeringInfoName; //dic.GetValue("EngineeringInfoName"); arrival.EngineeringInfoCode = content.S_P_ContractInfo.EngineeringInfoCode; // dic.GetValue("EngineeringInfoCode"); arrival.ContractInfo = content.S_P_ContractInfo.ID; // dic.GetValue("ContractInfo"); arrival.ContractInfoName = content.S_P_ContractInfo.Name; // dic.GetValue("ContractInfoName"); arrival.ContractCode = content.S_P_ContractInfo.SerialNumber; // dic.GetValue("ContractInfoNum"); arrival.ArrivalDate = Convert.ToDateTime(dic.GetValue("ArrivalDate")); arrival.CheckUser = CurrentUserInfo.UserID; arrival.CheckUserName = CurrentUserInfo.UserName; var form = baseEntities.Set <S_UI_Form>().Where(c => c.Code == "Arrival").OrderByDescending(c => c.ID).FirstOrDefault(); //获取最新一个版本即可 if (form == null) { throw new Formula.Exceptions.BusinessValidationException("表单编号为Arrival不存在!"); } string SerialNumberSettings = form.SerialNumberSettings; var serialNumberDic = JsonHelper.ToObject(SerialNumberSettings); SerialNumberParam param = new SerialNumberParam(); string tmpl = serialNumberDic["Tmpl"].ToString(); string resetRule = serialNumberDic["ResetRule"].ToString(); arrival.SerialNumber = SerialNumberHelper.GetSerialNumberString(tmpl, param, resetRule, true); arrival.SendFormID = ""; //没有发货单可关联 arrival.SendFormIDName = ""; //同上 arrival.CheckDate = DateTime.Now; arrival.CheckResult = ""; //无 arrival.Register = CurrentUserInfo.UserID; arrival.RegisterName = CurrentUserInfo.UserName; arrival.RegisterDate = DateTime.Now; arrival.Remark = "来自手机端扫描入库"; arrival.EngineeringInfoID = content.S_P_ContractInfo.EngineeringInfoID;// dic.GetValue("EngineeringInfoID"); EPCEntites.Set <S_P_Arrival>().Add(arrival); EPCEntites.SaveChanges(); dic.SetValue("PBomID", content.PBomID); dic.SetValue("Code", content.Code); dic.SetValue("Sepcification", content.Model); dic.SetValue("Unit", content.Unit); //dic.SetValue("BomInfo", content.ID); dic.SetValue("BomInfoName", content.Name); dic.SetValue("Name", content.Name); dic.SetValue("S_P_ArrivalID", arrival.ID); }
protected override void BeforeSaveSubTable(Dictionary <string, string> dic, string subTableName, List <Dictionary <string, string> > detailList, Base.Logic.Domain.S_UI_Form formInfo) { }
protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { var list = new List <Dictionary <string, object> >(); var id = dic.GetValue("ID"); var normalValue = 0m; if (!string.IsNullOrEmpty(dic.GetValue("NormalValue"))) { normalValue = Convert.ToDecimal(dic.GetValue("NormalValue")); } var extraValue = 0m; if (!string.IsNullOrEmpty(dic.GetValue("AdditionalValue"))) { extraValue = Convert.ToDecimal(dic.GetValue("AdditionalValue")); } if ((normalValue == 0 && extraValue == 0)) { throw new Formula.Exceptions.BusinessException("每日工时不能为0"); } var user = FormulaHelper.GetUserInfoByID(dic.GetValue("UserID")); var employee = this.ComprehensiveDbContext.Set <S_HR_Employee>().FirstOrDefault(d => d.UserID == user.UserID); var fo = FormulaHelper.CreateFO <WorkHourFO>(); //根据日期段判断 var startDate = dic.GetValue("WorkHourDateStart").Replace("T", " "); var endDate = dic.GetValue("WorkHourDateEnd").Replace("T", " "); var projectID = dic.GetValue("ProjectID"); var WorkTimeMajor = dic.GetValue("WorkTimeMajor"); var SubProjectCode = dic.GetValue("SubProjectCode"); var MajorCode = dic.GetValue("MajorCode"); var WorkContent = dic.GetValue("WorkContent"); var dateList = getWorkHourDate(startDate, endDate); //已存在工时数据 var userID = dic.GetValue("UserID"); var existList = this.ComprehensiveDbContext.Set <S_W_UserWorkHour>().Where(a => a.UserID == userID && dateList.Contains(a.WorkHourDate)).ToList(); foreach (var item in dateList) { var existNormalValue = existList.Where(a => a.WorkHourDate == item && a.SupplementID != id).Sum(a => a.NormalValue); var existExtraValue = existList.Where(a => a.WorkHourDate == item && a.SupplementID != id).Sum(a => a.AdditionalValue); if (!existNormalValue.HasValue) { existNormalValue = 0; } if (!existExtraValue.HasValue) { existExtraValue = 0; } //自动补全正班工日,加班工日不补全 if ((normalValue + existNormalValue) > NormalHoursMax) { normalValue = NormalHoursMax - existNormalValue.Value; } //throw new Formula.Exceptions.BusinessException("【" + item.ToShortDateString() + "】正常工时不能大于" + NormalHoursMax.ToString()); if ((extraValue + existExtraValue) > maxExtraHour) { throw new Formula.Exceptions.BusinessException("【" + item.ToShortDateString() + "】加班工时不能大于" + maxExtraHour.ToString()); } if ((normalValue == 0 && extraValue == 0)) { continue; } var userWorkHour = existList.FirstOrDefault(d => d.SupplementID == id && d.UserID == user.UserID && d.WorkHourDate == item); if (userWorkHour == null || ComprehensiveDbContext.Entry <S_W_UserWorkHour>(userWorkHour).State == System.Data.EntityState.Deleted) { userWorkHour = ComprehensiveDbContext.Set <S_W_UserWorkHour>().Create(); userWorkHour.ID = FormulaHelper.CreateGuid(); userWorkHour.UserID = user.UserID; userWorkHour.UserName = user.UserName; userWorkHour.UserDeptID = user.UserOrgID; userWorkHour.UserDeptName = user.UserOrgName; userWorkHour.WorkHourDate = item; userWorkHour.UserCode = user.Code; if (employee != null) { userWorkHour.EmployeeID = employee.ID; } userWorkHour.State = "Create"; userWorkHour.IsConfirm = "0"; userWorkHour.IsStep1 = "0"; userWorkHour.IsStep2 = "0"; userWorkHour.CreateUser = CurrentUserInfo.UserName; userWorkHour.CreateUserID = CurrentUserInfo.UserID; userWorkHour.SupplementID = id; userWorkHour.BelongMonth = item.Month; userWorkHour.BelongYear = item.Year; userWorkHour.BelongQuarter = ((item.Month - 1) / 3) + 1; ComprehensiveDbContext.Set <S_W_UserWorkHour>().Add(userWorkHour); } if (userWorkHour.State != "Create") { continue; } userWorkHour.ProjectChargerUser = dic.GetValue("ProjectChargerUser"); userWorkHour.ProjectChargerUserName = dic.GetValue("ProjectChargerUserName"); userWorkHour.ProjectCode = dic.GetValue("ProjectCode"); userWorkHour.ProjectDept = dic.GetValue("ProjectDept"); userWorkHour.ProjectDeptName = dic.GetValue("ProjectDeptName"); userWorkHour.ProjectID = projectID; userWorkHour.ProjectName = dic.GetValue("ProjectName"); userWorkHour.WorkTimeMajor = dic.GetValue("WorkTimeMajor"); userWorkHour.SubProjectCode = dic.GetValue("SubProjectCode"); userWorkHour.SubProjectName = dic.GetValue("SubProjectName"); userWorkHour.TaskWorkCode = dic.GetValue("TaskWorkCode"); userWorkHour.TaskWorkName = dic.GetValue("TaskWorkName"); userWorkHour.WorkContent = dic.GetValue("WorkContent"); userWorkHour.MajorCode = dic.GetValue("MajorCode"); userWorkHour.MajorName = dic.GetValue("MajorName"); userWorkHour.WorkHourType = dic.GetValue("WorkHourType"); userWorkHour.NormalValue = normalValue; userWorkHour.AdditionalValue = extraValue; userWorkHour.WorkHourValue = normalValue + extraValue; userWorkHour.WorkHourDay = fo.ConvertHourToDay(userWorkHour.WorkHourValue, workHourType, NormalHoursMax); } }
protected override void BeforeSaveSubTable(Dictionary <string, string> dic, string subTableName, List <Dictionary <string, string> > detailList, Base.Logic.Domain.S_UI_Form formInfo) { decimal sumWorkload = 0; foreach (var detail in detailList) { sumWorkload += string.IsNullOrEmpty(detail.GetValue("Workload")) ? 0m : Convert.ToDecimal(detail.GetValue("Workload")); } var workload = string.IsNullOrEmpty(dic.GetValue("Workload")) ? 0m : Convert.ToDecimal(dic.GetValue("Workload")); if (workload > sumWorkload) { throw new Formula.Exceptions.BusinessException("卷册的工时没有分配完。"); } else if (workload < sumWorkload) { throw new Formula.Exceptions.BusinessException("分配的工时总数超过卷册的工时,请重新分配。"); } }
protected override void BeforeSaveDetail(Dictionary <string, string> dic, string subTableName, Dictionary <string, string> detail, List <Dictionary <string, string> > detailList, Base.Logic.Domain.S_UI_Form formInfo) { //校验设备数量不能超过可采购数量 if (subTableName == "Content") { var conid = dic.GetValue("ContractID"); var bomid = detail.GetValue("PBomID"); var number = detail.GetValue("Number"); var bom = this.GetEntityByID <S_P_Bom>(bomid); if (bom == null) { return; } if (dic.GetValue("ValidateBomQuantity") == true.ToString().ToLower()) { var qty = 0m; var remain = 0m; var sum = this.EPCEntites.Set <S_P_ContractInfo_Content>().Where(a => a.S_P_ContractInfoID != conid && a.PBomID == bomid).Select(a => a.ContractQuantity).Sum(); if (!sum.HasValue) { sum = 0; } if (bom.Quantity.HasValue) { qty = bom.Quantity.Value; } remain = qty - sum.Value; var value = String.IsNullOrEmpty(detail.GetValue("ContractQuantity")) ? 0m : Convert.ToDecimal(detail.GetValue("ContractQuantity")); if (value > remain) { throw new Formula.Exceptions.BusinessValidationException("设备【" + bom.Name + "】的数量不能超过可采购数量【" + remain + "】"); } } //来自招标比选则不能超过招标比选的量 if (dic.GetValue("ContractType") == "Contract") { var device = EPCEntites.Set <S_P_Invitation_Device>().Find(detail.GetValue("ApplyDetailID")); if (device == null) { throw new Formula.Exceptions.BusinessValidationException("未找到【" + bom.Name + "】的招标比价信息"); } var thisQuantity = 0.0m; if (!String.IsNullOrEmpty(detail.GetValue("ContractQuantity"))) { thisQuantity = Convert.ToDecimal(detail.GetValue("ContractQuantity")); } var applyDetailID = detail.GetValue("ApplyDetailID"); var detailID = detail.GetValue("OrlID"); var contractQuantity = EPCEntites.Set <S_P_ContractInfo_Content>().Where(a => a.ID != detailID && a.ApplyDetailID == applyDetailID).Sum(a => a.ContractQuantity); var restQuantiy = device.InvitationQuantity - contractQuantity; if (restQuantiy < thisQuantity) { throw new Formula.Exceptions.BusinessValidationException("设备【" + bom.Name + "】的数量不能超过招标可签订数量【" + restQuantiy + "】"); } } //不能小于已到货数量 var quantity = 0.0m; if (!String.IsNullOrEmpty(detail.GetValue("ContractQuantity"))) { quantity = Convert.ToDecimal(detail.GetValue("ContractQuantity")); } var arrivalQuantity = 0.0m; if (!String.IsNullOrEmpty(detail.GetValue("ArrivalQuantity"))) { arrivalQuantity = Convert.ToDecimal(detail.GetValue("ArrivalQuantity")); } if (quantity < arrivalQuantity) { throw new Formula.Exceptions.BusinessValidationException("设备【" + detail.GetValue("Name") + "】的数量不能小于到货数量【" + arrivalQuantity + "】"); } } else if (subTableName == "PaymentObj") { var paymentID = detail.GetValue("ID"); var PlanPaymentValue = 0.0m; var SumPaymentValue = 0.0m; // EPCEntites.Set<S_P_Payment_PaymentObjRelation>().Where(a => a.PaymentObjID == paymentID).ToList().Sum(a => a.RelationValue ?? 0); var SumInvoiceValue = 0.0m; //EPCEntites.Set<S_P_Invoice_PaymentObjRelation>().Where(a => a.S_P_PaymentObjID == paymentID).ToList().Sum(a => a.RelationValue ?? 0); decimal.TryParse(detail.GetValue("PlanPaymentValue"), out PlanPaymentValue); decimal.TryParse(detail.GetValue("SumPaymentValue"), out SumPaymentValue); decimal.TryParse(detail.GetValue("SumInvoiceValue"), out SumInvoiceValue); var tmp = Math.Max(SumPaymentValue, SumInvoiceValue); if ((SumPaymentValue > SumInvoiceValue) && PlanPaymentValue < SumPaymentValue) { throw new Formula.Exceptions.BusinessValidationException("付款项【" + detail.GetValue("Name") + "】的金额不能小于已付款金额【" + SumPaymentValue + "元】"); } if ((SumPaymentValue < SumInvoiceValue) && PlanPaymentValue < SumInvoiceValue) { throw new Formula.Exceptions.BusinessValidationException("付款项【" + detail.GetValue("Name") + "】的金额不能小于已开票金额【" + SumInvoiceValue + "元】"); } } }
protected override void BeforeSaveSubTable(Dictionary <string, string> dic, string subTableName, List <Dictionary <string, string> > detailList, Base.Logic.Domain.S_UI_Form formInfo) { if (SysParams.Params.GetValue("SubContractConfirmMethod") == "PaymentConfirm" && subTableName == "CostInfo")//委外付款确认 { var costValue = 0m; var contractValue = 0m; foreach (var item in detailList) { costValue = 0m; decimal.TryParse(item.GetValue("CostValue"), out costValue); if (costValue <= 0) { throw new Formula.Exceptions.BusinessValidationException("【付款金额】必须大于0!"); } contractValue = 0m; decimal.TryParse(item.GetValue("ContractValue"), out contractValue); if (costValue > contractValue) { throw new Formula.Exceptions.BusinessValidationException("【付款金额】不能超过【合同金额】"); } } } if (subTableName == "InvoiceRelation") { var sumRelation = 0M; var ApplyValue = String.IsNullOrEmpty(dic.GetValue("ApplyValue")) ? 0m : Convert.ToDecimal(dic.GetValue("ApplyValue")); foreach (var item in detailList) { var relationValue = String.IsNullOrEmpty(item.GetValue("RelationValue")) ? 0m : Convert.ToDecimal(item.GetValue("RelationValue")); sumRelation += relationValue; var remainRelationValue = String.IsNullOrEmpty(item.GetValue("RemainInvoiceValue")) ? 0m : Convert.ToDecimal(item.GetValue("RemainInvoiceValue")); if (relationValue > remainRelationValue) { throw new Formula.Exceptions.BusinessValidationException("本次对应金额【" + relationValue + "】不能大于可对应金额【" + remainRelationValue + "】"); } } if (sumRelation > ApplyValue) { throw new Formula.Exceptions.BusinessValidationException("对应的发票金额总和不能大于本次付款金额"); } } else if (subTableName == "AcceptanceBill") { var applyValue = String.IsNullOrEmpty(dic.GetValue("ApplyValue")) ? 0m : Convert.ToDecimal(dic.GetValue("ApplyValue")); var billValue = String.IsNullOrEmpty(dic.GetValue("BillValue")) ? 0m : Convert.ToDecimal(dic.GetValue("BillValue")); if (billValue > applyValue) { throw new Formula.Exceptions.BusinessValidationException("承兑汇票金额总和不能大于本次申请付款的金额"); } foreach (var detail in detailList) { string billID = detail.GetValue("AcceptanceBillID"); string spID = dic.GetValue("ID"); if (BusinessEntities.Set <T_SP_PaymentApply_AcceptanceBill>().Any(a => billID == a.AcceptanceBillID && a.T_SP_PaymentApplyID != spID)) { throw new Formula.Exceptions.BusinessValidationException("汇票号【" + detail.GetValue("SerialNumber") + "】已经被流程被其他支付申请流程占用"); } } } }
protected override void BeforeSaveSubTable(Dictionary <string, string> dic, string subTableName, List <Dictionary <string, string> > detailList, Base.Logic.Domain.S_UI_Form formInfo) { var contractValue = String.IsNullOrEmpty(dic.GetValue("ContractAmount")) ? 0m : Convert.ToDecimal(dic.GetValue("ContractAmount")); //合同金额不能小于设备总价 if (subTableName == "Content") { var sumValue = 0m; foreach (var item in detailList) { sumValue += String.IsNullOrEmpty(item.GetValue("TotalPrice")) ? 0m : Convert.ToDecimal(item.GetValue("TotalPrice")); } if (sumValue > contractValue) { throw new Formula.Exceptions.BusinessValidationException("设备材料金额总计不能大于合同金额"); } var applyDetailIDList = detailList.Select(c => c.GetValue("ApplyDetailID")).Distinct().ToList(); #region 判定采购申请的数量,因为同样的设备会在采购设备明细中出现2次,且价格不同(类似第二件半价),所以采购申请的数量需要统一校验,不能单个校验 //零星采购申请单独判断 if (dic.GetValue("OrderType") == "零星采购申请") { foreach (var applyDetailID in applyDetailIDList) { var applyDetail = EPCEntites.Set <S_P_ProcurementSmartApply_PBom>().FirstOrDefault(c => c.ID == applyDetailID); if (applyDetail == null) { continue;//历史数据不包含采购申请,不报错。 } var obj = this.EPCSQLDB.ExecuteScalar(String.Format("select Sum(ContractQuantity) from S_P_ContractInfo_Content where ApplyDetailID='{0}' and S_P_ContractInfoID!='{1}'", applyDetailID, dic.GetValue("ContractID"))); var otherContractQuantity = 0.0d; if (obj != null && obj != DBNull.Value) { otherContractQuantity = Convert.ToDouble(obj); } var quantity = 0.0d; var list = detailList.Where(c => c.GetValue("ApplyDetailID") == applyDetailID).ToList(); foreach (var applyDetailInfo in list) { var contractQuantity = 0.0d; if (!String.IsNullOrEmpty(applyDetailInfo.GetValue("ContractQuantity"))) { contractQuantity = Convert.ToDouble(applyDetailInfo.GetValue("ContractQuantity")); } quantity += contractQuantity; } if (applyDetail.Quantity < (otherContractQuantity + quantity)) { throw new Exception("设备材料【" + applyDetail.Name + "】合计不能大于零星采购申请数量【" + applyDetail.Quantity + "】"); } } } else { foreach (var applyDetailID in applyDetailIDList) { var applyDetail = EPCEntites.Set <S_P_ProcurementApply_PBom>().FirstOrDefault(c => c.ID == applyDetailID); if (applyDetail == null) { continue;//历史数据不包含采购申请,不报错。 } var obj = this.EPCSQLDB.ExecuteScalar(String.Format("select Sum(ContractQuantity) from S_P_ContractInfo_Content where ApplyDetailID='{0}' and S_P_ContractInfoID!='{1}'", applyDetailID, dic.GetValue("ContractID"))); var otherContractQuantity = 0m; if (obj != null && obj != DBNull.Value) { otherContractQuantity = Convert.ToDecimal(obj); } var quantity = 0m; var list = detailList.Where(c => c.GetValue("ApplyDetailID") == applyDetailID).ToList(); foreach (var applyDetailInfo in list) { var contractQuantity = 0m; if (!String.IsNullOrEmpty(applyDetailInfo.GetValue("ContractQuantity"))) { contractQuantity = Convert.ToDecimal(applyDetailInfo.GetValue("ContractQuantity")); } quantity += contractQuantity; } if (applyDetail.Quantity < (otherContractQuantity + quantity)) { throw new Exception("设备材料【" + applyDetail.Name + "】合计不能大于采购申请数量【" + applyDetail.Quantity + "】"); } } } #endregion } else if (subTableName == "PaymentObj") { var sumValue = 0m; foreach (var item in detailList) { sumValue += String.IsNullOrEmpty(item.GetValue("PlanPaymentValue")) ? 0m : Convert.ToDecimal(item.GetValue("PlanPaymentValue")); } if (sumValue > contractValue) { throw new Formula.Exceptions.BusinessValidationException("付款项金额总计不能大于合同金额"); } } }
protected override void BeforeSaveSubTable(Dictionary <string, string> dic, string subTableName, List <Dictionary <string, string> > detailList, Base.Logic.Domain.S_UI_Form formInfo) { if (subTableName == "ReceiptObj") { var sumReceiptObjValue = 0m; foreach (var item in detailList) { sumReceiptObjValue += String.IsNullOrEmpty(item.GetValue("ReceiptValue")) ? 0m : Convert.ToDecimal(item.GetValue("ReceiptValue")); } var contractRMBValue = String.IsNullOrEmpty(dic.GetValue("ContractRMBAmount")) ? 0m : Convert.ToDecimal(dic.GetValue("ContractRMBAmount")); if (sumReceiptObjValue > contractRMBValue) { throw new Formula.Exceptions.BusinessException("收款项金额总计不能大于合同结算金额"); } } else if (subTableName == "ContractSplit") { var sumValue = 0m; foreach (var item in detailList) { sumValue += String.IsNullOrEmpty(item.GetValue("SplitValue")) ? 0m : Convert.ToDecimal(item.GetValue("SplitValue")); } var contractRMBValue = String.IsNullOrEmpty(dic.GetValue("ContractRMBAmount")) ? 0m : Convert.ToDecimal(dic.GetValue("ContractRMBAmount")); if (sumValue > contractRMBValue) { throw new Formula.Exceptions.BusinessException("合同分解金额总计不能大于结算人民币金额"); } } else if (subTableName == "ProjectRelation") { var sumValue = 0m; foreach (var item in detailList) { sumValue += String.IsNullOrEmpty(item.GetValue("ProjectValue")) ? 0m : Convert.ToDecimal(item.GetValue("ProjectValue")); } var contractRMBValue = String.IsNullOrEmpty(dic.GetValue("ContractRMBAmount")) ? 0m : Convert.ToDecimal(dic.GetValue("ContractRMBAmount")); if (sumValue > contractRMBValue) { throw new Formula.Exceptions.BusinessException("关联项目金额总计不能大于结算人民币金额"); } } else if (subTableName == "DeptRelation") { var sumValue = 0m; foreach (var item in detailList) { sumValue += String.IsNullOrEmpty(item.GetValue("DeptValue")) ? 0m : Convert.ToDecimal(item.GetValue("DeptValue")); } var contractRMBValue = String.IsNullOrEmpty(dic.GetValue("ThisContractRMBAmount")) ? 0m : Convert.ToDecimal(dic.GetValue("ThisContractRMBAmount")); if (sumValue != contractRMBValue) { throw new Formula.Exceptions.BusinessException("部门分解总额总计必须等于折合人民币金额"); } } }