/// <summary> /// 刷新数据 /// </summary> private void RefreshBudgetData() { ObservableCollection <FBEntity> detailList = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_DEPTTRANSFERDETAIL).Name); decimal?newTotal = 0; detailList.ToList().ForEach(item => { ObservableCollection <FBEntity> obPersonDetail = item.GetRelationFBEntities(typeof(T_FB_PERSONTRANSFERDETAIL).Name); var totalPerson = obPersonDetail.Sum(itemPersonDetail => { // 在个人预算中将会部门预算记录,所以需要判断是否统计的对象是个人预算 T_FB_PERSONTRANSFERDETAIL pDetail = itemPersonDetail.Entity as T_FB_PERSONTRANSFERDETAIL; if (pDetail != null) { return(pDetail.BUDGETMONEY == null ? 0 : pDetail.BUDGETMONEY.Value); } else { return(0); } }); var itemDept = item.Entity as T_FB_DEPTTRANSFERDETAIL; itemDept.TRANSFERMONEY = totalPerson; newTotal += itemDept.TRANSFERMONEY; }); this.OrderEntity.SetObjValue("Entity.TRANSFERMONEY", newTotal); }
/// <summary> /// 添加时操作 /// </summary> /// <param name="e"></param> private void DoForAdd(QueryFBEntitiesCompletedEventArgs e) { SetPropertyChanged(); // 清除预算明细 this.OrderEntity.GetRelationFBEntities(typeof(T_FB_DEPTTRANSFERDETAIL).Name).Clear(); this.OrderEntity.GetRelationFBEntities(typeof(T_FB_PERSONTRANSFERDETAIL).Name).Clear(); // 添加预算明细 // 添加预算明细 e.Result.ToList().ForEach(item => { T_FB_DEPTTRANSFERDETAIL deptDetail = item.Entity as T_FB_DEPTTRANSFERDETAIL; deptDetail.T_FB_DEPTTRANSFERMASTER = this.OrderEntity.Entity as T_FB_DEPTTRANSFERMASTER; item.FBEntityState = FBEntityState.Added; #region 个人明细 item.GetRelationFBEntities(typeof(T_FB_PERSONTRANSFERDETAIL).Name).ToList().ForEach(fbpersondetail => { T_FB_PERSONTRANSFERDETAIL persondetail = fbpersondetail.Entity as T_FB_PERSONTRANSFERDETAIL; 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_DEPTTRANSFERDETAIL = item.Entity as T_FB_DEPTTRANSFERDETAIL; 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_DEPTTRANSFERDETAIL>(e.Result); this.OrderEntity.FBEntity.SetObjValue("Entity.TRANSFERMONEY", 0); }
private void SetPropertyChanged() { CollectionClear((this.OrderEntity.Entity as T_FB_DEPTTRANSFERMASTER).T_FB_DEPTTRANSFERDETAIL); // 因后台保存是二层结构,所有需要把 A->B->C这种结构变成 A->B, A->C结构 ObservableCollection <FBEntity> detailPersonList = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_PERSONTRANSFERDETAIL).Name); ObservableCollection <FBEntity> detailList = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_DEPTTRANSFERDETAIL).Name); detailList.ToList().ForEach(item => { T_FB_DEPTTRANSFERDETAIL detailDept = (item.Entity as T_FB_DEPTTRANSFERDETAIL); CollectionClear(detailDept.T_FB_PERSONTRANSFERDETAIL); CollectionClear(detailDept.T_FB_SUBJECT.T_FB_DEPTTRANSFERDETAIL); if (item.FBEntityState == FBEntityState.Added) { (item.Entity as T_FB_DEPTTRANSFERDETAIL).T_FB_DEPTTRANSFERMASTER = this.OrderEntity.Entity as T_FB_DEPTTRANSFERMASTER; } #region 部门变化 // 部门预算明细变化事件 item.Entity.PropertyChanged += (senderDept, eDept) => { T_FB_DEPTTRANSFERDETAIL DeptDetail = senderDept as T_FB_DEPTTRANSFERDETAIL; #region // 部门预算明细的总预算变化时,统计所有明细的预算 if (eDept.PropertyName == "TRANSFERMONEY") { decimal?newTotal = detailList.Sum(itemDept => { return((decimal?)itemDept.GetObjValue("Entity.TRANSFERMONEY")); }); this.OrderEntity.SetObjValue("Entity.TRANSFERMONEY", newTotal); } #endregion }; #endregion #region 个人预算明细变化 // 个人预算明细变化 ObservableCollection <FBEntity> obPersonDetail = item.GetRelationFBEntities(typeof(T_FB_PERSONTRANSFERDETAIL).Name); obPersonDetail.ToList().ForEach(itemPerson => { T_FB_PERSONTRANSFERDETAIL persondetail = itemPerson.Entity as T_FB_PERSONTRANSFERDETAIL; CollectionClear(persondetail.T_FB_SUBJECT.T_FB_PERSONTRANSFERDETAIL); itemPerson.Entity.PropertyChanged += (senderPerson, ePerson) => { if (ePerson.PropertyName == "BUDGETMONEY") { var totalPerson = obPersonDetail.Sum(itemPersonDetail => { // 在个人预算中将会部门预算记录,所以需要判断是否统计的对象是个人预算 T_FB_PERSONTRANSFERDETAIL pDetail = itemPersonDetail.Entity as T_FB_PERSONTRANSFERDETAIL; if (pDetail != null) { return(pDetail.BUDGETMONEY); } else { return(0); } }); var itemDept = item.Entity as T_FB_DEPTTRANSFERDETAIL; itemDept.TRANSFERMONEY = totalPerson.Value; } }; detailPersonList.Add(itemPerson); }); // 因为在个人预算中需要体现部门公共费用栏,则加入部门公共费用(T记录到个人预算集合中 item.HideDetails = obPersonDetail.Count == 0; #endregion }); this.EditForm.BindingData(); this.CloseProcess(false); }
void EditForm_Saving(object sender, SavingEventArgs e) { List <string> msgs = new List <string>(); if (object.Equals(this.OrderEntity.GetObjValue(EntityFieldName.OwnerID), null)) { msgs.Add("找不到相应的部门负责人!"); } else { // 调出金额不可大于可用金额 ObservableCollection <FBEntity> details = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_DEPTTRANSFERDETAIL).Name); ObservableCollection <FBEntity> personDetails = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_PERSONTRANSFERDETAIL).Name); if (details.Count == 0) { msgs.Add(ErrorMessage.NoDetailInfo); } var validDetails = details.FindAll(item => (item.Entity as T_FB_DEPTTRANSFERDETAIL).TRANSFERMONEY != 0); var validPersonDetails = personDetails.FindAll(item => (item.Entity as T_FB_PERSONTRANSFERDETAIL).BUDGETMONEY != 0); personDetails.ToList().ForEach(item => { T_FB_PERSONTRANSFERDETAIL personDetail = item.Entity as T_FB_PERSONTRANSFERDETAIL; if (personDetail.BUDGETMONEY < 0) { if (personDetail.LIMITBUDGETMONEY + personDetail.BUDGETMONEY < 0) { string errorMessage = string.Format(ErrorMessage.Err_ComCheck2, personDetail.T_FB_SUBJECT.SUBJECTNAME); msgs.Add(errorMessage); } } }); if (validDetails.Count == 0) { msgs.Add(ErrorMessage.NoDetailInfo); } details.ToList().ForEach(item => { T_FB_DEPTTRANSFERDETAIL detail = item.Entity as T_FB_DEPTTRANSFERDETAIL; //if (detail.TRANSFERMONEY < 0) //{ // string errorMessage = string.Format(ErrorMessage.TransMoneyZero, detail.T_FB_SUBJECT.SUBJECTNAME); // msgs.Add(errorMessage); //} if (detail.TRANSFERMONEY < 0) { if (detail.USABLEMONEY + detail.TRANSFERMONEY < 0) { string errorMessage = string.Format(ErrorMessage.Err_ComCheck2, detail.T_FB_SUBJECT.SUBJECTNAME); msgs.Add(errorMessage); } } if (detail.USABLEMONEY.LessThan(detail.TRANSFERMONEY)) { if (detail.TRANSFERMONEY > 0) { msgs.Add(string.Format(ErrorMessage.TransMoneyBigger, detail.T_FB_SUBJECT.SUBJECTNAME)); } } }); } if (msgs.Count > 0) { CommonFunction.ShowErrorMessage(msgs); e.Action = Actions.Cancel; } }
public static T_FB_PERSONTRANSFERDETAIL CreateT_FB_PERSONTRANSFERDETAIL(string pERSONTRANSFERDETAILID, string cREATEUSERID, global::System.DateTime cREATEDATE, string uPDATEUSERID, global::System.DateTime uPDATEDATE, string oWNERID) { T_FB_PERSONTRANSFERDETAIL t_FB_PERSONTRANSFERDETAIL = new T_FB_PERSONTRANSFERDETAIL(); t_FB_PERSONTRANSFERDETAIL.PERSONTRANSFERDETAILID = pERSONTRANSFERDETAILID; t_FB_PERSONTRANSFERDETAIL.CREATEUSERID = cREATEUSERID; t_FB_PERSONTRANSFERDETAIL.CREATEDATE = cREATEDATE; t_FB_PERSONTRANSFERDETAIL.UPDATEUSERID = uPDATEUSERID; t_FB_PERSONTRANSFERDETAIL.UPDATEDATE = uPDATEDATE; t_FB_PERSONTRANSFERDETAIL.OWNERID = oWNERID; return t_FB_PERSONTRANSFERDETAIL; }
public void AddToT_FB_PERSONTRANSFERDETAIL(T_FB_PERSONTRANSFERDETAIL t_FB_PERSONTRANSFERDETAIL) { base.AddObject("T_FB_PERSONTRANSFERDETAIL", t_FB_PERSONTRANSFERDETAIL); }