Example #1
0
        /// <summary>        
        ///   保存科目设置流水
        /// </summary>
        /// <param name="fbEntityList"></param>
        /// <returns></returns>
        public bool SaveListT_FB_WFSUBJECTSETTING(List<FBEntity> fbEntityList, string strfig)
        {
            List<FBEntity> inActivedlist = fbEntityList.CreateList(item =>
            {
                T_FB_WFSUBJECTSETTING fbEntity = new T_FB_WFSUBJECTSETTING();

                if (strfig == "1")
                {
                    T_FB_SUBJECTCOMPANY SubjectEntity = item.Entity as T_FB_SUBJECTCOMPANY;

                    fbEntity.WFSUBJECTSETTINGID = Guid.NewGuid().ToString();
                    fbEntity.SUBJECTID = SubjectEntity.T_FB_SUBJECTReference.EntityKey.EntityKeyValues[0].Value.ToString();
                    fbEntity.ACTIVED = SubjectEntity.ACTIVED;
                    fbEntity.ISMONTHADJUST = SubjectEntity.ISMONTHADJUST;
                    fbEntity.ISMONTHLIMIT = SubjectEntity.ISMONTHLIMIT;
                    fbEntity.ISPERSON = SubjectEntity.ISPERSON;
                    fbEntity.ISYEARBUDGET = SubjectEntity.ISYEARBUDGET;
                    fbEntity.CONTROLTYPE = SubjectEntity.CONTROLTYPE;
                    fbEntity.OWNERCOMPANYID = SubjectEntity.OWNERCOMPANYID;
                    fbEntity.OWNERCOMPANYNAME = SubjectEntity.OWNERCOMPANYNAME;
                    fbEntity.OWNERDEPARTMENTID = SubjectEntity.OWNERDEPARTMENTID;
                    fbEntity.OWNERDEPARTMENTNAME = SubjectEntity.OWNERDEPARTMENTNAME;
                    fbEntity.OWNERPOSTID = SubjectEntity.OWNERPOSTID;
                    fbEntity.OWNERPOSTNAME = SubjectEntity.OWNERPOSTNAME;
                    fbEntity.CREATEUSERID = SubjectEntity.CREATEUSERID;
                    fbEntity.UPDATEUSERID = SubjectEntity.UPDATEUSERID;
                    fbEntity.UPDATEDATE = DateTime.Now;
                    fbEntity.CREATEDATE = DateTime.Now;
                    fbEntity.ORDERTYPE = strfig;//1 公司 2部门 3岗位
                }
                else if (strfig == "2")
                {
                    T_FB_SUBJECTDEPTMENT SubjectEntity = item.Entity as T_FB_SUBJECTDEPTMENT;
                    if (SubjectEntity == null)
                    {
                        T_FB_SUBJECTPOST SubjectEntity1 = item.Entity as T_FB_SUBJECTPOST;

                        fbEntity.WFSUBJECTSETTINGID = Guid.NewGuid().ToString();
                        fbEntity.SUBJECTID = SubjectEntity1.T_FB_SUBJECTReference.EntityKey.EntityKeyValues[0].Value.ToString();
                        fbEntity.ACTIVED = SubjectEntity1.ACTIVED;
                        fbEntity.LIMITBUDGEMONEY = SubjectEntity1.LIMITBUDGEMONEY;
                        fbEntity.OWNERCOMPANYID = SubjectEntity1.OWNERCOMPANYID;
                        fbEntity.OWNERCOMPANYNAME = SubjectEntity1.OWNERCOMPANYNAME;
                        fbEntity.OWNERDEPARTMENTID = SubjectEntity1.OWNERDEPARTMENTID;
                        fbEntity.OWNERDEPARTMENTNAME = SubjectEntity1.OWNERDEPARTMENTNAME;
                        fbEntity.OWNERPOSTID = SubjectEntity1.OWNERPOSTID;
                        fbEntity.OWNERPOSTNAME = SubjectEntity1.OWNERPOSTNAME;
                        fbEntity.CREATEUSERID = SubjectEntity1.CREATEUSERID;
                        fbEntity.UPDATEUSERID = SubjectEntity1.UPDATEUSERID;
                        fbEntity.UPDATEDATE = DateTime.Now;
                        fbEntity.CREATEDATE = DateTime.Now;
                        fbEntity.ORDERTYPE = "3";//1 公司 2部门 3岗位
                    }
                    else
                    {
                        fbEntity.WFSUBJECTSETTINGID = Guid.NewGuid().ToString();
                        fbEntity.SUBJECTID = SubjectEntity.T_FB_SUBJECTReference.EntityKey.EntityKeyValues[0].Value.ToString();
                        fbEntity.ACTIVED = SubjectEntity.ACTIVED;
                        fbEntity.LIMITBUDGEMONEY = SubjectEntity.LIMITBUDGEMONEY;
                        fbEntity.OWNERCOMPANYID = SubjectEntity.OWNERCOMPANYID;
                        fbEntity.OWNERCOMPANYNAME = SubjectEntity.OWNERCOMPANYNAME;
                        fbEntity.OWNERDEPARTMENTID = SubjectEntity.OWNERDEPARTMENTID;
                        fbEntity.OWNERDEPARTMENTNAME = SubjectEntity.OWNERDEPARTMENTNAME;
                        fbEntity.OWNERPOSTID = SubjectEntity.OWNERPOSTID;
                        fbEntity.OWNERPOSTNAME = SubjectEntity.OWNERPOSTNAME;
                        fbEntity.CREATEUSERID = SubjectEntity.CREATEUSERID;
                        fbEntity.UPDATEUSERID = SubjectEntity.UPDATEUSERID;
                        fbEntity.UPDATEDATE = DateTime.Now;
                        fbEntity.CREATEDATE = DateTime.Now;
                        fbEntity.ORDERTYPE = strfig;//1 公司 2部门 3岗位
                    }
                }
                else if (strfig == "3")
                {
                    T_FB_SUBJECTPOST SubjectEntity = item.Entity as T_FB_SUBJECTPOST;

                    fbEntity.WFSUBJECTSETTINGID = Guid.NewGuid().ToString();
                    fbEntity.SUBJECTID = SubjectEntity.T_FB_SUBJECTReference.EntityKey.EntityKeyValues[0].Value.ToString();
                    fbEntity.ACTIVED = SubjectEntity.ACTIVED;
                    fbEntity.LIMITBUDGEMONEY = SubjectEntity.LIMITBUDGEMONEY;
                    fbEntity.OWNERCOMPANYID = SubjectEntity.OWNERCOMPANYID;
                    fbEntity.OWNERCOMPANYNAME = SubjectEntity.OWNERCOMPANYNAME;
                    fbEntity.OWNERDEPARTMENTID = SubjectEntity.OWNERDEPARTMENTID;
                    fbEntity.OWNERDEPARTMENTNAME = SubjectEntity.OWNERDEPARTMENTNAME;
                    fbEntity.OWNERPOSTID = SubjectEntity.OWNERPOSTID;
                    fbEntity.OWNERPOSTNAME = SubjectEntity.OWNERPOSTNAME;
                    fbEntity.CREATEUSERID = SubjectEntity.CREATEUSERID;
                    fbEntity.UPDATEUSERID = SubjectEntity.UPDATEUSERID;
                    fbEntity.UPDATEDATE = DateTime.Now;
                    fbEntity.CREATEDATE = DateTime.Now;
                    fbEntity.ORDERTYPE = strfig;//1 公司 2部门 3岗位
                }
                FBEntity a = new FBEntity();
                a.Entity = fbEntity;
                a.FBEntityState = FBEntityState.Added;
                a.EntityKey = null;
                return a;
            });
            return FBEntityBLLSaveList(inActivedlist);
        }
Example #2
0
        /// <summary>
        /// 保存公司科目维护
        ///   级联的去除不可用的部门科目和岗位科目
        /// </summary>
        /// <param name="fbEntityList"></param>
        /// <returns></returns>
        public bool SaveListT_FB_SUBJECTCOMPANY(List<FBEntity> fbEntityList)
        {
            QueryExpression qeSCom = new QueryExpression();
            QueryExpression qeTop = qeSCom;
            string StrCompanyID = "";//公司ID
            bool IsExistPlus = false;
            // 找出没有设置年度预算而后又允许年度预算的
            List<T_FB_SUBJECTCOMPANY> inActivedlist = fbEntityList.CreateList(item =>
            {
                T_FB_SUBJECTCOMPANY entity = item.Entity as T_FB_SUBJECTCOMPANY;
                if (string.IsNullOrEmpty(StrCompanyID))
                {
                    StrCompanyID = entity.OWNERCOMPANYID;
                    QueryExpression qe = QueryExpression.Equal("SUBJECTCOMPANYID", entity.SUBJECTCOMPANYID);
                    var baData = this.InnerGetEntities<T_FB_SUBJECTCOMPANY>(qe);
                    if (baData.Count() > 0)
                    {
                        T_FB_SUBJECTCOMPANY OldSub = new T_FB_SUBJECTCOMPANY();
                        OldSub = baData.FirstOrDefault();
                        if (OldSub.ISYEARBUDGET == 0)
                        {
                            if (entity.ISYEARBUDGET == 1)
                            {
                                QueryExpression qeAccount = QueryExpression.Equal("OWNERCOMPANYID", entity.OWNERCOMPANYID);
                                QueryExpression qeAccount1 = QueryExpression.Equal("T_FB_SUBJECT.SUBJECTID", entity.T_FB_SUBJECT != null ? entity.T_FB_SUBJECT.SUBJECTID : entity.T_FB_SUBJECTReference.EntityKey.EntityKeyValues[0].Value.ToString());
                                QueryExpression qeAccount2 = QueryExpression.Equal("ACCOUNTOBJECTTYPE", "1");
                                QueryExpression qeAccount3 = new QueryExpression();
                                qeAccount3.PropertyName = "USABLEMONEY";
                                qeAccount3.PropertyValue = "0";
                                qeAccount3.Operation = QueryExpression.Operations.LessThanOrEqual;
                                qeAccount3.Operation = QueryExpression.Operations.LessThan;//是否有问题
                                qeAccount.RelatedType = QueryExpression.RelationType.And;
                                qeAccount1.RelatedType = QueryExpression.RelationType.And;
                                qeAccount2.RelatedType = QueryExpression.RelationType.And;
                                qeAccount3.RelatedType = QueryExpression.RelationType.And;

                                qeAccount.RelatedExpression = qeAccount1;
                                qeAccount2.RelatedExpression = qeAccount1;
                                qeAccount3.RelatedExpression = qeAccount2;
                                qeAccount3.QueryType = typeof(T_FB_BUDGETACCOUNT).Name;


                                //var baDataAccount = this.InnerGetEntities<T_FB_BUDGETACCOUNT>(qeAccount);
                                //if(baDataAccount.Count() >0)
                                //{
                                //    //IsExistPlus= true;
                                //}
                            }
                        }
                    }
                }
                //return entity.ACTIVED != 1 ? entity : null;

                return entity;
            });
            if (IsExistPlus)
            {
                return IsExistPlus;
            }

            //var baData = this.InnerGetEntities<T_FB_SUBJECTCOMPANY>(qeDept);
            // 查出公司科目相关的部门科目及岗位科目
            inActivedlist.ForEach(item =>
            {
                qeTop.RelatedExpression = QueryExpression.Equal("T_FB_SUBJECTCOMPANY.SUBJECTCOMPANYID", item.SUBJECTCOMPANYID);
                qeTop.RelatedType = QueryExpression.RelationType.Or;
                qeTop = qeTop.RelatedExpression;
            });
            // 将部门科目及岗位科目置为不可用
            if (qeSCom.RelatedExpression != null)
            {
                qeSCom = qeSCom.RelatedExpression;
                qeSCom.Include = new string[] { "T_FB_SUBJECTPOST" };
                List<T_FB_SUBJECTDEPTMENT> inActiveDataList = GetEntities<T_FB_SUBJECTDEPTMENT>(qeSCom.RelatedExpression);
                inActiveDataList.ForEach(item =>
                {
                    item.ACTIVED = 0;
                    item.T_FB_SUBJECTPOST.ToList().ForEach(itemPost =>
                    {
                        itemPost.ACTIVED = 0;
                    });
                });
            }

            if (fbEntityList.Count > 0)
            {
                //记录公司部门科目设置修改流水
                SaveListT_FB_WFSUBJECTSETTING(fbEntityList, "1");
            }
            return FBEntityBLLSaveList(fbEntityList);
        }