public static List <EquipmentGroupObject> GetAllGroup() { try { string query = "Select ID,GroupName from tblEquipmentGroup order by GroupName"; List <EquipmentGroupObject> obj = new List <EquipmentGroupObject>(); DataTable dt = new DataTable(); dt = DBModel.CustomSelectQuery(query); if (dt != null) { if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { EquipmentGroupObject temp = new EquipmentGroupObject(); temp.ID = Convert.ToInt32(dr["ID"].ToString()); temp.GroupName = dr["GroupName"].ToString(); obj.Add(temp); } } } return(obj); } catch { return(null); } }
public static List <EquipmentGroupObject> GetEnrolledGroup() { int groupCount = 0; try { bool isHost = SettingModels.isHostEnabled(); string query = ""; string IP = HttpHandler.GetIPAddress(); string[] computer_name = Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]).HostName.Split(new Char[] { '.' }); string HostName = computer_name[0].ToString().ToUpper(); if (isHost == true) { query = "Select a.GroupID,b.GroupName from tblGroupEnrollment a left join tblEquipmentGroup b on a.GroupID=b.ID where a.UserID='" + HttpContext.Current.Session["Username"].ToString() + "' and (a.HostID='" + HostName + "' or a.HostID='" + IP + "') and b.isEnabled=1"; } else { query = "Select a.GroupID,b.GroupName from tblGroupEnrollment a left join tblEquipmentGroup b on a.GroupID=b.ID where a.UserID='" + HttpContext.Current.Session["Username"].ToString() + "' and b.isEnabled=1"; } DataTable dt = new DataTable(); dt = DBModel.CustomSelectQuery(query); if (dt != null) { if (dt.Rows.Count > 0) { List <EquipmentGroupObject> obj = new List <EquipmentGroupObject>(); foreach (DataRow dr in dt.Rows) { EquipmentGroupObject temp = new EquipmentGroupObject(); temp.ID = Convert.ToInt32(dr["GroupID"].ToString()); temp.GroupName = dr["GroupName"].ToString(); var check = hasChildGroup(temp.ID.ToString()); if (check == true) { obj.Add(temp); } } groupCount = dt.Rows.Count; CreateGroupCountSessionCookie(groupCount); return(obj); } else { groupCount = 0; CreateGroupCountSessionCookie(groupCount); return(null); } } else { groupCount = 0; CreateGroupCountSessionCookie(groupCount); return(null); } } catch { //handle error groupCount = 0; CreateGroupCountSessionCookie(groupCount); return(null); } }