public BaseController() { if (System.Web.HttpContext.Current.Session["UIConvert"] == null) { Common.ListMenuUlTag.Clear(); Common.ListMenuSelectTag.Clear(); Common.ListMenuBasic.Clear(); var menuDb = new MenuDb(); var list = menuDb.GetAll(); var listAfterConvert = Common.GetTree(list, 0); Common.GetMenuUlTag(listAfterConvert); //Common.GetMenuSelectTag(listAfterConvert); System.Web.HttpContext.Current.Session["UIConvert"] = Common.ListMenuUlTag.ToString(); System.Web.HttpContext.Current.Session["UIMenu"] = Common.ListMenuSelectTag.ToString(); } }
/// <summary> /// Get all item from database /// </summary> /// <returns></returns> public List <MenuDb> GetAll() { var list = new List <MenuDb>(); //--Start Get/List--// var _conn = new SqlConnection(ConfigurationManager.ConnectionStrings["InfoWebAppDbStr"].ConnectionString); if (_conn.State == ConnectionState.Closed) { _conn.Open(); } //Create command store procedure var command = new SqlCommand("Get_tblMenu"); command.Connection = _conn; command.CommandType = CommandType.StoredProcedure; try { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { var item = new MenuDb(); item.Id = reader.GetInt32(0); item.Name = reader.GetString(1); item.Description = reader.GetString(2); item.ParentId = reader.GetInt32(3); list.Add(item); } reader.Close(); } } finally { command.Connection.Close(); command.Connection.Dispose(); } //--End Get/List--// return(list); }