/// <summary> /// 刷新数据 /// </summary> private void RefreshBudgetData() { ObservableCollection <FBEntity> detailList = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_DEPTBUDGETADDDETAIL).Name); decimal?newTotal = 0; detailList.ToList().ForEach(item => { ObservableCollection <FBEntity> obPersonDetail = item.GetRelationFBEntities(typeof(T_FB_PERSONBUDGETADDDETAIL).Name); var totalPerson = obPersonDetail.Sum(itemPersonDetail => { // 在个人预算中将会部门预算记录,所以需要判断是否统计的对象是个人预算 T_FB_PERSONBUDGETADDDETAIL pDetail = itemPersonDetail.Entity as T_FB_PERSONBUDGETADDDETAIL; if (pDetail != null) { return(pDetail.BUDGETMONEY); } else { return(0); } }); var itemDept = item.Entity as T_FB_DEPTBUDGETADDDETAIL; itemDept.PERSONBUDGETMONEY = totalPerson; itemDept.BUDGETMONEY = itemDept.TOTALBUDGETMONEY.Subtract(itemDept.PERSONBUDGETMONEY).Value; newTotal += itemDept.TOTALBUDGETMONEY; }); this.OrderEntity.SetObjValue("Entity.BUDGETCHARGE", newTotal); }
/// <summary> /// 添加时操作 /// </summary> /// <param name="e"></param> private void DoForAdd(QueryFBEntitiesCompletedEventArgs e) { //beyond // 清除预算明细 this.OrderEntity.GetRelationFBEntities(typeof(T_FB_DEPTBUDGETADDDETAIL).Name).Clear(); this.OrderEntity.GetRelationFBEntities(typeof(T_FB_PERSONBUDGETADDDETAIL).Name).Clear(); // 添加预算明细 e.Result.ToList().ForEach(item => { T_FB_DEPTBUDGETADDDETAIL deptDetail = item.Entity as T_FB_DEPTBUDGETADDDETAIL; deptDetail.T_FB_DEPTBUDGETADDMASTER = this.OrderEntity.Entity as T_FB_DEPTBUDGETADDMASTER; item.FBEntityState = FBEntityState.Added; #region beyond item.GetRelationFBEntities(typeof(T_FB_PERSONBUDGETADDDETAIL).Name).ToList().ForEach(fbpersondetail => { T_FB_PERSONBUDGETADDDETAIL persondetail = fbpersondetail.Entity as T_FB_PERSONBUDGETADDDETAIL; persondetail.CREATEUSERID = this.OrderEntity.LoginUser.Value.ToString(); persondetail.CREATEUSERNAME = this.OrderEntity.LoginUser.Text; persondetail.UPDATEUSERID = this.OrderEntity.LoginUser.Value.ToString(); persondetail.UPDATEUSERNAME = this.OrderEntity.LoginUser.Text; persondetail.T_FB_DEPTBUDGETADDDETAIL = item.Entity as T_FB_DEPTBUDGETADDDETAIL; fbpersondetail.FBEntityState = FBEntityState.Added; }); #endregion deptDetail.T_FB_SUBJECT.T_FB_BUDGETACCOUNT.Clear(); deptDetail.T_FB_SUBJECT.T_FB_BUDGETCHECK.Clear(); }); this.OrderEntity.FBEntity.AddFBEntities <T_FB_DEPTBUDGETADDDETAIL>(e.Result); this.OrderEntity.FBEntity.SetObjValue("Entity.BUDGETCHARGE", 0); }
void EditForm_Saving(object sender, SavingEventArgs e) { ObservableCollection <FBEntity> details = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_PERSONBUDGETADDDETAIL).Name); if (details.Count == 0) { e.Action = Actions.Cancel; CommonFunction.ShowErrorMessage(ErrorMessage.NoDetailInfo); return; } List <string> msgs = new List <string>(); details.ToList().ForEach(item => { T_FB_PERSONBUDGETADDDETAIL detail = item.Entity as T_FB_PERSONBUDGETADDDETAIL; if (detail.BUDGETMONEY < 0) { string errorMessage = string.Format(ErrorMessage.BudgetMoneyZero, detail.T_FB_SUBJECT.SUBJECTNAME); msgs.Add(errorMessage); } if (detail.USABLEMONEY.LessThan(detail.BUDGETMONEY)) { msgs.Add(string.Format(ErrorMessage.BudgetMoneyBigger, detail.T_FB_SUBJECT.SUBJECTNAME)); } }); if (msgs.Count > 0) { e.Action = Actions.Cancel; CommonFunction.ShowErrorMessage(msgs); } }
void persondetail_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "BUDGETMONEY") { T_FB_PERSONBUDGETADDDETAIL persondetail = sender as T_FB_PERSONBUDGETADDDETAIL; decimal? budgetMoney = persondetail.BUDGETMONEY; string Key = persondetail.T_FB_SUBJECT.SUBJECTID + "-" + persondetail.OWNERID; FBEntity fbDeptDetail = dictPersonDetail[Key]; decimal? PERSONBUDGETMONEY = (decimal?)(fbDeptDetail.Entity.GetObjValue("PERSONBUDGETMONEY")); decimal? oldbudgetMoney = dictPersonBUDGETMONEY[Key]; dictPersonBUDGETMONEY[Key] = budgetMoney; fbDeptDetail.Entity.SetObjValue("PERSONBUDGETMONEY", budgetMoney - oldbudgetMoney + PERSONBUDGETMONEY); //object personMoney = sender.GetObjValue("PERSONBUDGETMONEY"); //Nullable<decimal> a = (decimal?)budgetMoney; //Nullable<decimal> b = (decimal?)personMoney; //sender.SetObjValue("TOTALBUDGETMONEY", a.Add(b)); } }
/// <summary> /// 获取T_FB_PERSONBUDGETADDDETAIL信息 /// </summary> /// <param name="strPersonBudgetAddDetailId">主键索引</param> /// <returns></returns> public T_FB_PERSONBUDGETADDDETAIL GetPersonBudgetAddDetailByID(string strPersonBudgetAddDetailId) { if (string.IsNullOrEmpty(strPersonBudgetAddDetailId)) { return(null); } PersonBudgetAddDetailDAL dalPersonBudgetAddDetail = new PersonBudgetAddDetailDAL(); StringBuilder strFilter = new StringBuilder(); List <string> objArgs = new List <string>(); if (!string.IsNullOrEmpty(strPersonBudgetAddDetailId)) { strFilter.Append(" PERSONBUDGETADDDETAILID == @0"); objArgs.Add(strPersonBudgetAddDetailId); } T_FB_PERSONBUDGETADDDETAIL entRd = dalPersonBudgetAddDetail.GetPersonBudgetAddDetailRdByMultSearch(strFilter.ToString(), objArgs.ToArray()); return(entRd); }
public static T_FB_PERSONBUDGETADDDETAIL CreateT_FB_PERSONBUDGETADDDETAIL(string pERSONBUDGETADDDETAILID, string cREATEUSERID, global::System.DateTime cREATEDATE, string uPDATEUSERID, global::System.DateTime uPDATEDATE, string oWNERID) { T_FB_PERSONBUDGETADDDETAIL t_FB_PERSONBUDGETADDDETAIL = new T_FB_PERSONBUDGETADDDETAIL(); t_FB_PERSONBUDGETADDDETAIL.PERSONBUDGETADDDETAILID = pERSONBUDGETADDDETAILID; t_FB_PERSONBUDGETADDDETAIL.CREATEUSERID = cREATEUSERID; t_FB_PERSONBUDGETADDDETAIL.CREATEDATE = cREATEDATE; t_FB_PERSONBUDGETADDDETAIL.UPDATEUSERID = uPDATEUSERID; t_FB_PERSONBUDGETADDDETAIL.UPDATEDATE = uPDATEDATE; t_FB_PERSONBUDGETADDDETAIL.OWNERID = oWNERID; return t_FB_PERSONBUDGETADDDETAIL; }
public void AddToT_FB_PERSONBUDGETADDDETAIL(T_FB_PERSONBUDGETADDDETAIL t_FB_PERSONBUDGETADDDETAIL) { base.AddObject("T_FB_PERSONBUDGETADDDETAIL", t_FB_PERSONBUDGETADDDETAIL); }
private void SetPropertyChanged() { // 因后台保存是二层结构,所有需要把 A->B->C这种结构变成 A->B, A->C结构 ObservableCollection <FBEntity> detailPersonList = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_PERSONBUDGETADDDETAIL).Name); ObservableCollection <FBEntity> detailList = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_DEPTBUDGETADDDETAIL).Name); detailList.ToList().ForEach(item => { #region 部门变化 // 部门预算明细变化事件 item.Entity.PropertyChanged += (senderDept, eDept) => { T_FB_DEPTBUDGETADDDETAIL DeptDetail = senderDept as T_FB_DEPTBUDGETADDDETAIL; #region // 部门预算明细的总预算变化时,统计所有明细的预算 if (eDept.PropertyName == "TOTALBUDGETMONEY") { decimal?newTotal = detailList.Sum(itemDept => { return((decimal?)itemDept.GetObjValue("Entity.TOTALBUDGETMONEY")); }); this.OrderEntity.SetObjValue("Entity.BUDGETCHARGE", newTotal); } // 改:先填写预算总额,后填个人预算,而部门的公共预算=预算总额 - 个人预算 2011-12-28 // 个人预算或部门预算变化时,统计个人预算明细 + 部门预算 if (eDept.PropertyName == "TOTALBUDGETMONEY" || eDept.PropertyName == "PERSONBUDGETMONEY") { DeptDetail.BUDGETMONEY = DeptDetail.TOTALBUDGETMONEY.Subtract(DeptDetail.PERSONBUDGETMONEY).Value; } #endregion }; #endregion #region 个人预算明细变化 // 个人预算明细变化 ObservableCollection <FBEntity> obPersonDetail = item.GetRelationFBEntities(typeof(T_FB_PERSONBUDGETADDDETAIL).Name); obPersonDetail.ToList().ForEach(itemPerson => { T_FB_PERSONBUDGETADDDETAIL persondetail = itemPerson.Entity as T_FB_PERSONBUDGETADDDETAIL; itemPerson.Entity.PropertyChanged += (senderPerson, ePerson) => { if (ePerson.PropertyName == "BUDGETMONEY") { var totalPerson = obPersonDetail.Sum(itemPersonDetail => { // 在个人预算中将会部门预算记录,所以需要判断是否统计的对象是个人预算 T_FB_PERSONBUDGETADDDETAIL pDetail = itemPersonDetail.Entity as T_FB_PERSONBUDGETADDDETAIL; if (pDetail != null) { return(pDetail.BUDGETMONEY); } else { return(0); } }); var itemDept = item.Entity as T_FB_DEPTBUDGETADDDETAIL; itemDept.PERSONBUDGETMONEY = totalPerson; } }; detailPersonList.Add(itemPerson); }); // 因为在个人预算中需要体现部门公共费用栏,则加入部门公共费用(T记录到个人预算集合中 if (obPersonDetail.Count > 0) { var sumEntity = new V_DepartmentSum(item.Entity); var curItemEntity = item.Entity as T_FB_DEPTBUDGETADDDETAIL; var sumFBEntity = sumEntity.ToFBEntity(); sumFBEntity.ReadOnly = true; sumEntity.LIMITBUDGETMONEY = curItemEntity.AUDITBUDGETMONEY.Subtract(obPersonDetail.Sum(itemFB => { var tee = (itemFB.Entity as T_FB_PERSONBUDGETADDDETAIL); if (tee.LIMITBUDGETMONEY == null) { return(0); } else { return(tee.LIMITBUDGETMONEY); } })); sumFBEntity.FBEntityState = FBEntityState.Unchanged; obPersonDetail.Insert(0, sumFBEntity); } else { item.HideDetails = true; } #endregion }); this.EditForm.BindingData(); this.CloseProcess(false); }
/// <summary> /// 可为负数的保存校验 /// </summary> /// <returns>returns</returns> private List <string> CheckSaveB() { List <string> msgs = new List <string>(); ObservableCollection <FBEntity> details = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_DEPTBUDGETADDDETAIL).Name); if (details.Count == 0) { msgs.Add(ErrorMessage.NoDetailInfo); return(msgs); } var detailList = details.Select(item => item.Entity as T_FB_DEPTBUDGETADDDETAIL).ToList(); var existBiggerThanZero = detailList.Count(item => item.TOTALBUDGETMONEY > 0) > 0; var existLessThanZero = detailList.Count(item => item.TOTALBUDGETMONEY < 0) > 0; if (existBiggerThanZero && existLessThanZero) { msgs.Add("预算明细只能全为负数,或全为正数,请确认!"); return(msgs); } // 都大于0的 if (!existLessThanZero) { return(CheckSaveA()); } details.ToList().ForEach(item => { T_FB_DEPTBUDGETADDDETAIL detail = item.Entity as T_FB_DEPTBUDGETADDDETAIL; // 判断个人预算是否出现负数的情况 var personDetailList = item.GetEntityList <T_FB_PERSONBUDGETADDDETAIL>(itemT => { var result = itemT as T_FB_PERSONBUDGETADDDETAIL; if (result == null) { V_DepartmentSum vd = itemT as V_DepartmentSum; result = new T_FB_PERSONBUDGETADDDETAIL() { LIMITBUDGETMONEY = vd.LIMITBUDGETMONEY, BUDGETMONEY = vd.BUDGETMONEY, OWNERNAME = vd.OWNERNAME, OWNERPOSTNAME = vd.OWNERPOSTNAME }; } return(result); }); // 表示没做过任何操作 if (detail.TOTALBUDGETMONEY.Equal(0) && detail.BUDGETMONEY.Equal(0)) { return; } if (detail.TOTALBUDGETMONEY > 0) { string errorMessage = string.Format(ErrorMessage.MoneyBiggerThanZero, detail.T_FB_SUBJECT.SUBJECTNAME, FieldDisplayName.BudgetMoney); msgs.Add(errorMessage); } //不能大于当前可用结余AUDITBUDGETMONEY if (detail.AUDITBUDGETMONEY.Add(detail.TOTALBUDGETMONEY) < 0) { msgs.Add(string.Format(ErrorMessage.MoneyBigger, "扣减的预算金额", "可用结余", detail.T_FB_SUBJECT.SUBJECTNAME)); } personDetailList.ForEach(itemP => { if (itemP.LIMITBUDGETMONEY.Add(itemP.BUDGETMONEY) < 0) { msgs.Add(string.Format("科目:{0} 扣减的预算金额不能大于可用结余!", detail.T_FB_SUBJECT.SUBJECTNAME + "(" + itemP.OWNERNAME + ")")); } else if (itemP.BUDGETMONEY > 0) { msgs.Add(string.Format("科目:{0} 扣减的预算金额不能大于零!", detail.T_FB_SUBJECT.SUBJECTNAME + "(" + itemP.OWNERNAME + ")")); } }); }); T_FB_DEPTBUDGETADDMASTER entMaster = this.OrderEntity.FBEntity.Entity as T_FB_DEPTBUDGETADDMASTER; if (entMaster.BUDGETCHARGE >= 0) { msgs.Add("费用总预算必须小于0!"); } return(msgs); }
/// <summary> /// 可为负数的保存校验 /// </summary> /// <returns>returns</returns> private List<string> CheckSaveB() { List<string> msgs = new List<string>(); ObservableCollection<FBEntity> details = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_DEPTBUDGETADDDETAIL).Name); if (details.Count == 0) { msgs.Add(ErrorMessage.NoDetailInfo); return msgs; } var detailList = details.Select(item => item.Entity as T_FB_DEPTBUDGETADDDETAIL).ToList(); var existBiggerThanZero = detailList.Count(item => item.TOTALBUDGETMONEY > 0) > 0; var existLessThanZero = detailList.Count(item => item.TOTALBUDGETMONEY < 0) > 0; if (existBiggerThanZero && existLessThanZero) { msgs.Add("预算明细只能全为负数,或全为正数,请确认!"); return msgs; } // 都大于0的 if (!existLessThanZero) { return CheckSaveA(); } details.ToList().ForEach(item => { T_FB_DEPTBUDGETADDDETAIL detail = item.Entity as T_FB_DEPTBUDGETADDDETAIL; // 判断个人预算是否出现负数的情况 var personDetailList = item.GetEntityList<T_FB_PERSONBUDGETADDDETAIL>(itemT => { var result = itemT as T_FB_PERSONBUDGETADDDETAIL; if (result == null) { V_DepartmentSum vd = itemT as V_DepartmentSum; result = new T_FB_PERSONBUDGETADDDETAIL() { LIMITBUDGETMONEY = vd.LIMITBUDGETMONEY, BUDGETMONEY = vd.BUDGETMONEY, OWNERNAME = vd.OWNERNAME, OWNERPOSTNAME = vd.OWNERPOSTNAME }; } return result; }); // 表示没做过任何操作 if (detail.TOTALBUDGETMONEY.Equal(0) && detail.BUDGETMONEY.Equal(0)) { return; } if (detail.TOTALBUDGETMONEY > 0) { string errorMessage = string.Format(ErrorMessage.MoneyBiggerThanZero, detail.T_FB_SUBJECT.SUBJECTNAME, FieldDisplayName.BudgetMoney); msgs.Add(errorMessage); } //不能大于当前可用结余AUDITBUDGETMONEY if (detail.AUDITBUDGETMONEY.Add(detail.TOTALBUDGETMONEY) < 0) { msgs.Add(string.Format(ErrorMessage.MoneyBigger,"扣减的预算金额", "可用结余", detail.T_FB_SUBJECT.SUBJECTNAME)); } personDetailList.ForEach(itemP => { if (itemP.LIMITBUDGETMONEY.Add(itemP.BUDGETMONEY) < 0) { msgs.Add(string.Format("科目:{0} 扣减的预算金额不能大于可用结余!",detail.T_FB_SUBJECT.SUBJECTNAME + "(" + itemP.OWNERNAME + ")")); } else if (itemP.BUDGETMONEY > 0) { msgs.Add(string.Format("科目:{0} 扣减的预算金额不能大于零!", detail.T_FB_SUBJECT.SUBJECTNAME + "(" + itemP.OWNERNAME + ")")); } }); }); T_FB_DEPTBUDGETADDMASTER entMaster = this.OrderEntity.FBEntity.Entity as T_FB_DEPTBUDGETADDMASTER; if (entMaster.BUDGETCHARGE >= 0) { msgs.Add("费用总预算必须小于0!"); } return msgs; }