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); }
//自定义汇总 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; }
/// <summary> /// 创建新的 T_FB_COMPANYBUDGETSUMDETAIL 对象。 /// </summary> /// <param name="cOMPANYBUDGETSUMDETAILID">COMPANYBUDGETSUMDETAILID 属性的初始值。</param> /// <param name="cREATEUSERID">CREATEUSERID 属性的初始值。</param> /// <param name="cREATEDATE">CREATEDATE 属性的初始值。</param> /// <param name="uPDATEUSERID">UPDATEUSERID 属性的初始值。</param> /// <param name="uPDATEDATE">UPDATEDATE 属性的初始值。</param> public static T_FB_COMPANYBUDGETSUMDETAIL CreateT_FB_COMPANYBUDGETSUMDETAIL(global::System.String cOMPANYBUDGETSUMDETAILID, global::System.String cREATEUSERID, global::System.DateTime cREATEDATE, global::System.String uPDATEUSERID, global::System.DateTime uPDATEDATE) { T_FB_COMPANYBUDGETSUMDETAIL t_FB_COMPANYBUDGETSUMDETAIL = new T_FB_COMPANYBUDGETSUMDETAIL(); t_FB_COMPANYBUDGETSUMDETAIL.COMPANYBUDGETSUMDETAILID = cOMPANYBUDGETSUMDETAILID; t_FB_COMPANYBUDGETSUMDETAIL.CREATEUSERID = cREATEUSERID; t_FB_COMPANYBUDGETSUMDETAIL.CREATEDATE = cREATEDATE; t_FB_COMPANYBUDGETSUMDETAIL.UPDATEUSERID = uPDATEUSERID; t_FB_COMPANYBUDGETSUMDETAIL.UPDATEDATE = uPDATEDATE; return t_FB_COMPANYBUDGETSUMDETAIL; }
public FBEntity GetCompanyBudgetSumSet(T_FB_COMPANYBUDGETSUMDETAIL entity, T_FB_SUMSETTINGSMASTER masterset) { FBEntity result = null; decimal? budgetYear = entity.T_FB_COMPANYBUDGETAPPLYMASTER.BUDGETYEAR; QueryExpression qe = QueryExpression.Equal(FieldName_BudgetYear, budgetYear.Value.ToString()); QueryExpression qeStates = QueryExpression.Equal(FieldName.CheckStates, ((int)CheckStates.UnSubmit).ToString()); QueryExpression qeCompany = QueryExpression.Equal(FieldName.OwnerCompanyID, masterset.OWNERCOMPANYID); // QueryExpression qeSumsettings = QueryExpression.Equal("SUMSETTINGSMASTERID", masterset.SUMSETTINGSMASTERID).And("PARENTID", entity.T_FB_COMPANYBUDGETSUMMASTER.PARENTID); qe.RelatedExpression = qeStates; qeStates.RelatedExpression = qeCompany; // qeCompany.RelatedExpression = qeSumsettings; T_FB_COMPANYBUDGETSUMMASTER sumMaster = this.InnerGetEntities<T_FB_COMPANYBUDGETSUMMASTER>(qe).FirstOrDefault(); if (sumMaster == null) { sumMaster = new T_FB_COMPANYBUDGETSUMMASTER(); sumMaster.COMPANYBUDGETSUMMASTERID = Guid.NewGuid().ToString(); sumMaster.COMPANYBUDGETSUMMASTERCODE = "自动生成"; sumMaster.CREATEUSERID = SYSTEM_USER_ID; sumMaster.CREATEUSERNAME = "******"; sumMaster.CREATEDATE = System.DateTime.Now; sumMaster.UPDATEUSERID = SYSTEM_USER_ID; sumMaster.UPDATEDATE = System.DateTime.Now; sumMaster.CREATECOMPANYID = SYSTEM_USER_ID; sumMaster.CREATECOMPANYNAME = "系统生成"; sumMaster.CREATEDEPARTMENTID = SYSTEM_USER_ID; sumMaster.CREATEDEPARTMENTNAME = "系统生成"; sumMaster.CREATEPOSTID = SYSTEM_USER_ID; sumMaster.CREATEPOSTNAME = "系统生成"; sumMaster.BUDGETYEAR = budgetYear; sumMaster.OWNERCOMPANYID = masterset.OWNERCOMPANYID; sumMaster.OWNERCOMPANYNAME = masterset.OWNERCOMPANYNAME; sumMaster.OWNERDEPARTMENTID = masterset.OWNERDEPARTMENTID; sumMaster.OWNERDEPARTMENTNAME = masterset.OWNERDEPARTMENTNAME; sumMaster.OWNERPOSTID = masterset.OWNERPOSTID; sumMaster.OWNERPOSTNAME = masterset.OWNERPOSTNAME; sumMaster.OWNERID = masterset.OWNERID; ; sumMaster.OWNERNAME = masterset.OWNERNAME; sumMaster.SUMSETTINGSMASTERID = masterset.SUMSETTINGSMASTERID; sumMaster.SUMLEVEL = 1; //0:代表当前汇总单不走自定义汇总流程;1:代表当前汇总单走自定义汇总流程 sumMaster.CHECKSTATES = (int)CheckStates.UnSubmit; sumMaster.EDITSTATES = (int)EditStates.Actived; result = sumMaster.ToFBEntity(); result.FBEntityState = FBEntityState.Added; } else { result = sumMaster.ToFBEntity(); result.FBEntityState = FBEntityState.Modified; } return result; }
/// <summary> /// 用于向 T_FB_COMPANYBUDGETSUMDETAIL EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToT_FB_COMPANYBUDGETSUMDETAIL(T_FB_COMPANYBUDGETSUMDETAIL t_FB_COMPANYBUDGETSUMDETAIL) { base.AddObject("T_FB_COMPANYBUDGETSUMDETAIL", t_FB_COMPANYBUDGETSUMDETAIL); }