/// <summary> /// 通过ProjectID GetOrgID /// </summary> /// <param name="iProjectID"></param> /// <returns></returns> public static int GetOrgIDByProjectID(int iProjectID) { using (LedDb db = new LedDb()) { ProjectInfo aProject = db.ProjectInfo.Where(p => p.Id == iProjectID).FirstOrDefault(); if (aProject != null) { return(aProject.OrgId.Value); } else { return(0); } } }
/// <summary> /// 通过ProjectName GetOrgID /// </summary> /// <param name="devID"></param> /// <returns></returns> public static int GetOrgIDByProjectName(string strName) { using (LedDb db = new LedDb()) { ProjectInfo aProject = db.ProjectInfo.Where(p => p.ProjectName == strName).FirstOrDefault(); if (aProject != null) { return(aProject.OrgId.Value); } else { return(0); } } }
/// <summary> /// 加载Org /// </summary> /// <returns></returns> public static List <TreeSelectorEntity> LoadOrg() { StringBuilder strSql = new StringBuilder(); strSql.Append(@"select 'org_'+cast(o.ID as varchar) as [id], o.Name as [text], CAST((select COUNT(*) from GroupInfo b where b.OrgID=o.ID and b.IsDel!=1)+(select COUNT(*) from ProjectInfo bg where bg.OrgID=o.ID and bg.IsDel!=1) as varchar) as [state], iconCls='icon-org' from OrgInfo o where o.IsDel!=1"); using (LedDb db = new LedDb()) { List <TreeSelectorEntity> list = db.Database.SqlQuery <TreeSelectorEntity>(strSql.ToString()).ToList(); return(list); } }
/// <summary> /// 加载GasCardWithCommInfo /// </summary> /// <returns></returns> public static List <TreeSelectorEntity> LoadGasCardWithCommInfo(string strProjectID) { StringBuilder strSql = new StringBuilder(); strSql.AppendFormat(@"select 'gas_'+cast(o.ID as varchar) as [id], o.Name as [text], '0' as [state], iconCls='icon-gas' from GasCardWithCommInfo o where o.ProjectId='{0}' and o.IsDel!=1", strProjectID); using (LedDb db = new LedDb()) { List <TreeSelectorEntity> list = db.Database.SqlQuery <TreeSelectorEntity>(strSql.ToString()).ToList(); return(list); } }
/// <summary> /// 加载Project /// </summary> /// <returns></returns> public static List <TreeSelectorEntity> LoadProject(string strGroupID) { StringBuilder strSql = new StringBuilder(); strSql.AppendFormat(@"select 'project_'+cast(o.ID as varchar) as [id], o.ProjectName as [text], CAST((select COUNT(*) from GasCardWithCommInfo b where b.IsDel!=1) as varchar) as [state], iconCls='icon-project' from ProjectInfo o where o.GroupId='{0}' and o.IsDel!=1", strGroupID); using (LedDb db = new LedDb()) { List <TreeSelectorEntity> list = db.Database.SqlQuery <TreeSelectorEntity>(strSql.ToString()).ToList(); return(list); } }
/// <summary> /// Get所有GasCardWithCommInfoList /// </summary> /// <param name="strOrgID"></param> /// <returns></returns> public static List <ModelForGasCardWithCommInfo> GetAllGasCardWithCommInfoList() { StringBuilder strSql = new StringBuilder(); strSql.AppendFormat(@"select gm.*, o.Id OrgId, o.Name OrgName, g.Id GroupId, g.GroupName, p.Id ProjectId, p.ProjectName from GasCardWithCommInfo gm left join OrgInfo o on gm.OrgId=o.Id left join GroupInfo g on g.Id=gm.GroupId left join ProjectInfo p on p.Id=gm.ProjectId where gm.IsDel!=1"); using (LedDb db = new LedDb()) { List <ModelForGasCardWithCommInfo> list = db.Database.SqlQuery <ModelForGasCardWithCommInfo>(strSql.ToString()).ToList(); return(list); } }