Example #1
0
        public void CreateCompanyBudgetSumDetail(T_FB_COMPANYBUDGETAPPLYMASTER entity)
        {
            if (UpdateOldDetail(entity))
            {
                return;
            }
            T_FB_COMPANYBUDGETSUMDETAIL detail = new T_FB_COMPANYBUDGETSUMDETAIL();

            detail.COMPANYBUDGETSUMDETAILID = Guid.NewGuid().ToString();
            detail.CREATEUSERID = SYSTEM_USER_ID;
            detail.CREATEDATE = System.DateTime.Now;
            detail.UPDATEUSERID = SYSTEM_USER_ID;
            detail.UPDATEDATE = System.DateTime.Now;
            detail.T_FB_COMPANYBUDGETAPPLYMASTER = entity;
            FBEntity fbDetail = detail.ToFBEntity();
            fbDetail.FBEntityState = FBEntityState.Added;

            FBEntity fbSumMaster = new FBEntity();
            fbSumMaster = GetCompanyBudgetSum(entity);           
            detail.T_FB_COMPANYBUDGETSUMMASTER = fbSumMaster.Entity as T_FB_COMPANYBUDGETSUMMASTER;
            fbSumMaster.AddFBEntities<T_FB_COMPANYBUDGETSUMDETAIL>(new List<FBEntity> { fbDetail });
            this.InnerSave(fbSumMaster);
        }
Example #2
0
        //自定义汇总
        public bool CreateCompanyBudgetSumSetMaster(FBEntity fbMaster)
        {
            bool bRes = false;
            T_FB_COMPANYBUDGETSUMMASTER Master = fbMaster.Entity as T_FB_COMPANYBUDGETSUMMASTER;
            foreach (var entity in Master.T_FB_COMPANYBUDGETSUMDETAIL)
            {
                T_FB_COMPANYBUDGETSUMDETAIL detail = new T_FB_COMPANYBUDGETSUMDETAIL();

                detail.COMPANYBUDGETSUMDETAILID = Guid.NewGuid().ToString();
                detail.CREATEUSERID = SYSTEM_USER_ID;
                detail.CREATEDATE = System.DateTime.Now;
                detail.UPDATEUSERID = SYSTEM_USER_ID;
                detail.UPDATEDATE = System.DateTime.Now;
                detail.T_FB_COMPANYBUDGETAPPLYMASTER = entity.T_FB_COMPANYBUDGETAPPLYMASTER;
                FBEntity fbDetail = detail.ToFBEntity();
                fbDetail.FBEntityState = FBEntityState.Added;

                List<FBEntity> fbSumMasterlist = new List<FBEntity>();

                //查找汇总节点设置 有则新增汇总记录
                FBEntity fbSumMaster = new FBEntity();
                QueryExpression qeDetail = QueryExpression.Equal(FieldName.OwnerCompanyID, entity.T_FB_COMPANYBUDGETAPPLYMASTER.OWNERCOMPANYID).And(FieldName.EditStates, "1");
                qeDetail.QueryType = "T_FB_SUMSETTINGSDETAIL";
                T_FB_SUMSETTINGSDETAIL detailset = GetEntities<T_FB_SUMSETTINGSDETAIL>(qeDetail).FirstOrDefault();
                T_FB_SUMSETTINGSMASTER masterset = null;
                if (detailset != null)
                {
                    QueryExpression qeMaster = QueryExpression.Equal("SUMSETTINGSMASTERID", detailset.T_FB_SUMSETTINGSMASTERReference.EntityKey.EntityKeyValues[0].Value.ToString()).And(FieldName.EditStates, "1");
                    qeMaster.QueryType = "T_FB_SUMSETTINGSMASTER";
                    masterset = GetEntities<T_FB_SUMSETTINGSMASTER>(qeMaster).FirstOrDefault();
                    if (masterset != null)
                    {
                        fbSumMaster = GetCompanyBudgetSumSet(entity, masterset);
                        detail.T_FB_COMPANYBUDGETSUMMASTER = fbSumMaster.Entity as T_FB_COMPANYBUDGETSUMMASTER;
                        fbSumMaster.AddFBEntities<T_FB_COMPANYBUDGETSUMDETAIL>(new List<FBEntity> { fbDetail });
                        fbSumMasterlist.Add(fbSumMaster);
                        Master.PARENTID = detail.T_FB_COMPANYBUDGETSUMMASTER.COMPANYBUDGETSUMMASTERID;
                        Master.SUMSETTINGSMASTERID = masterset.SUMSETTINGSMASTERID;
                        Master.SUMLEVEL = 1; //0:代表当前汇总单不走自定义汇总流程;1:代表当前汇总单走自定义汇总流程
                        fbMaster.Entity = Master;
                        fbMaster.FBEntityState = FBEntityState.Modified;
                        fbSumMasterlist.Add(fbMaster);
                        this.FBEntityBLLSaveListNoTrans(fbSumMasterlist);
                       // this.InnerSave(fbSumMaster);
                    }
                }
            }

            bRes = true;
            return bRes;
          
        }