Exemplo n.º 1
0
        void EditForm_Saving(object sender, SavingEventArgs e)
        {
            ObservableCollection <FBEntity> details = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_PERSONBUDGETAPPLYDETAIL).Name);

            List <string> msgs = new List <string>();

            details.ToList().ForEach(item =>
            {
                T_FB_PERSONBUDGETAPPLYDETAIL detail = item.Entity as T_FB_PERSONBUDGETAPPLYDETAIL;
                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);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 刷新数据
        /// </summary>
        private void RefreshBudgetData()
        {
            ObservableCollection <FBEntity> detailList = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_DEPTBUDGETAPPLYDETAIL).Name);
            decimal?newTotal = 0;

            detailList.ToList().ForEach(item =>
            {
                ObservableCollection <FBEntity> obPersonDetail = item.GetRelationFBEntities(typeof(T_FB_PERSONBUDGETAPPLYDETAIL).Name);
                var totalPerson = obPersonDetail.Sum(itemPersonDetail =>
                {
                    // 在个人预算中将会部门预算记录,所以需要判断是否统计的对象是个人预算
                    T_FB_PERSONBUDGETAPPLYDETAIL pDetail = itemPersonDetail.Entity as T_FB_PERSONBUDGETAPPLYDETAIL;
                    if (pDetail != null)
                    {
                        return(pDetail.BUDGETMONEY);
                    }
                    else
                    {
                        return(0);
                    }
                });
                var itemDept = item.Entity as T_FB_DEPTBUDGETAPPLYDETAIL;
                itemDept.PERSONBUDGETMONEY = totalPerson;
                itemDept.BUDGETMONEY       = itemDept.TOTALBUDGETMONEY.Subtract(itemDept.PERSONBUDGETMONEY).Value;
                newTotal += itemDept.TOTALBUDGETMONEY;
            });

            this.OrderEntity.SetObjValue("Entity.BUDGETMONEY", newTotal);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 添加时操作
        /// </summary>
        /// <param name="e"></param>
        private void DoForAdd(QueryFBEntitiesCompletedEventArgs e)
        {
            // 清除预算明细
            this.OrderEntity.GetRelationFBEntities(typeof(T_FB_DEPTBUDGETAPPLYDETAIL).Name).Clear();
            this.OrderEntity.GetRelationFBEntities(typeof(T_FB_PERSONBUDGETAPPLYDETAIL).Name).Clear();
            // 添加预算明细
            e.Result.ToList().ForEach(item =>
            {
                item.FBEntityState = FBEntityState.Added;
                T_FB_DEPTBUDGETAPPLYDETAIL deptDetail = item.Entity as T_FB_DEPTBUDGETAPPLYDETAIL;
                deptDetail.T_FB_DEPTBUDGETAPPLYMASTER = this.OrderEntity.Entity as T_FB_DEPTBUDGETAPPLYMASTER;

                #region beyond
                item.GetRelationFBEntities(typeof(T_FB_PERSONBUDGETAPPLYDETAIL).Name).ToList().ForEach(fbpersondetail =>
                {
                    T_FB_PERSONBUDGETAPPLYDETAIL persondetail = fbpersondetail.Entity as T_FB_PERSONBUDGETAPPLYDETAIL;
                    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_DEPTBUDGETAPPLYDETAIL = deptDetail;

                    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_DEPTBUDGETAPPLYDETAIL>(e.Result);

            this.OrderEntity.FBEntity.SetObjValue("Entity.BUDGETMONEY", 0);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取T_FB_PERSONBUDGETAPPLYDETAIL信息
        /// </summary>
        /// <param name="strPersonBudgetApplyDetailId">主键索引</param>
        /// <returns></returns>
        public T_FB_PERSONBUDGETAPPLYDETAIL GetPersonBudgetApplyDetailByID(string strPersonBudgetApplyDetailId)
        {
            if (string.IsNullOrEmpty(strPersonBudgetApplyDetailId))
            {
                return(null);
            }

            PersonBudgetApplyDetailDAL dalPersonBudgetApplyDetail = new PersonBudgetApplyDetailDAL();
            StringBuilder strFilter = new StringBuilder();
            List <string> objArgs   = new List <string>();

            if (!string.IsNullOrEmpty(strPersonBudgetApplyDetailId))
            {
                strFilter.Append(" PERSONBUDGETAPPLYDETAILID == @0");
                objArgs.Add(strPersonBudgetApplyDetailId);
            }

            T_FB_PERSONBUDGETAPPLYDETAIL entRd = dalPersonBudgetApplyDetail.GetPersonBudgetApplyDetailRdByMultSearch(strFilter.ToString(), objArgs.ToArray());

            return(entRd);
        }
Exemplo n.º 5
0
 public static T_FB_PERSONBUDGETAPPLYDETAIL CreateT_FB_PERSONBUDGETAPPLYDETAIL(string pERSONBUDGETAPPLYDETAILID, string cREATEUSERID, global::System.DateTime cREATEDATE, string uPDATEUSERID, global::System.DateTime uPDATEDATE, string oWNERID)
 {
     T_FB_PERSONBUDGETAPPLYDETAIL t_FB_PERSONBUDGETAPPLYDETAIL = new T_FB_PERSONBUDGETAPPLYDETAIL();
     t_FB_PERSONBUDGETAPPLYDETAIL.PERSONBUDGETAPPLYDETAILID = pERSONBUDGETAPPLYDETAILID;
     t_FB_PERSONBUDGETAPPLYDETAIL.CREATEUSERID = cREATEUSERID;
     t_FB_PERSONBUDGETAPPLYDETAIL.CREATEDATE = cREATEDATE;
     t_FB_PERSONBUDGETAPPLYDETAIL.UPDATEUSERID = uPDATEUSERID;
     t_FB_PERSONBUDGETAPPLYDETAIL.UPDATEDATE = uPDATEDATE;
     t_FB_PERSONBUDGETAPPLYDETAIL.OWNERID = oWNERID;
     return t_FB_PERSONBUDGETAPPLYDETAIL;
 }
Exemplo n.º 6
0
 public void AddToT_FB_PERSONBUDGETAPPLYDETAIL(T_FB_PERSONBUDGETAPPLYDETAIL t_FB_PERSONBUDGETAPPLYDETAIL)
 {
     base.AddObject("T_FB_PERSONBUDGETAPPLYDETAIL", t_FB_PERSONBUDGETAPPLYDETAIL);
 }
Exemplo n.º 7
0
        private void SetPropertyChanged()
        {
            // 因后台保存是二层结构,所有需要把 A->B->C这种结构变成 A->B, A->C结构
            ObservableCollection <FBEntity> detailPersonList = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_PERSONBUDGETAPPLYDETAIL).Name);
            ObservableCollection <FBEntity> detailList       = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_DEPTBUDGETAPPLYDETAIL).Name);

            detailList.ToList().ForEach(item =>
            {
                #region 部门变化
                // 部门预算明细变化事件
                item.Entity.PropertyChanged += (senderDept, eDept) =>
                {
                    T_FB_DEPTBUDGETAPPLYDETAIL DeptDetail = senderDept as T_FB_DEPTBUDGETAPPLYDETAIL;

                    #region
                    // 部门预算明细的总预算变化时,统计所有明细的预算
                    if (eDept.PropertyName == "TOTALBUDGETMONEY")
                    {
                        decimal?newTotal = detailList.Sum(itemDept =>
                        {
                            return((decimal?)itemDept.GetObjValue("Entity.TOTALBUDGETMONEY"));
                        });

                        this.OrderEntity.SetObjValue("Entity.BUDGETMONEY", 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_PERSONBUDGETAPPLYDETAIL).Name);
                obPersonDetail.ToList().ForEach(itemPerson =>
                {
                    T_FB_PERSONBUDGETAPPLYDETAIL persondetail = itemPerson.Entity as T_FB_PERSONBUDGETAPPLYDETAIL;

                    itemPerson.Entity.PropertyChanged += (senderPerson, ePerson) =>
                    {
                        if (ePerson.PropertyName == "BUDGETMONEY")
                        {
                            var totalPerson = obPersonDetail.Sum(itemPersonDetail =>
                            {
                                // 在个人预算中将会部门预算记录,所以需要判断是否统计的对象是个人预算
                                T_FB_PERSONBUDGETAPPLYDETAIL pDetail = itemPersonDetail.Entity as T_FB_PERSONBUDGETAPPLYDETAIL;
                                if (pDetail != null)
                                {
                                    return(pDetail.BUDGETMONEY);
                                }
                                else
                                {
                                    return(0);
                                }
                            });
                            var itemDept = item.Entity as T_FB_DEPTBUDGETAPPLYDETAIL;
                            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_DEPTBUDGETAPPLYDETAIL;
                    var sumFBEntity            = sumEntity.ToFBEntity();
                    sumFBEntity.ReadOnly       = true;
                    sumEntity.LIMITBUDGETMONEY = curItemEntity.BEGINNINGBUDGETBALANCE.Subtract(obPersonDetail.Sum(itemFB =>
                    {
                        var tee = (itemFB.Entity as T_FB_PERSONBUDGETAPPLYDETAIL);
                        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);
        }