public void ListaMenu() { MenuItem menu = new MenuItem(); BEMenu eMenu = new BEMenu(); BERolMenu eRolMenu = new BERolMenu(); DataTable dt = new DataTable(); eRolUsuario.Cod_Personal = Session["IDPERSONAL"].ToString(); try { eRolMenu.Id_Rol = Convert.ToInt32(Session["RolElegido"].ToString()); eMenu.Id_Padre = 0; dt = objMenu.ConsultarMenu(eMenu, eRolMenu); if (dt.Rows.Count > 0) { Session["NewRol"] = Convert.ToInt32(Session["RolElegido"].ToString()); CargaMenu(dt); } } catch (Exception ex) { NetAjax.JsMensajeAlert(this.Page, ex.Message); } }
public DataTable ConsultarMenu(BEMenu eMenu, BERolMenu eRolMenu) { DataTable dt = new DataTable(); MySqlConnection conn = new MySqlConnection("Server=127.0.0.1; Database=MECANICSWEB; Uid=Administrador; Pwd=admin"); MySqlCommand command = new MySqlCommand("`mecanicsweb`.`ConsultarMenu`", conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(ObjSqlParameter("N_IDRol", eRolMenu.Id_Rol, ParameterDirection.Input, System.Data.DbType.Int32)); command.Parameters.Add(ObjSqlParameter("N_IDPadre", eMenu.Id_Padre, ParameterDirection.Input, System.Data.DbType.Int32)); conn.Open(); IDataReader dr = command.ExecuteReader(); dt.Load(dr); conn.Close(); return dt; }
public void CargaMenu(DataTable dt) { for (int i = 0; i < dt.Rows.Count; i++) { MenuItem menuItem = new MenuItem(); menuItem.Value = dt.Rows[i]["ID"].ToString(); menuItem.Text = dt.Rows[i]["Nombre"].ToString(); menuItem.NavigateUrl = dt.Rows[i]["Pagina"].ToString(); menuItem.Selectable = false; DataTable dt2 = new DataTable(); BEMenu eMenu = new BEMenu(); BERolMenu eRolMenu = new BERolMenu(); eRolMenu.Id_Rol = Convert.ToInt32(Session["NewRol"]); eMenu.Id_Padre = Convert.ToInt32(dt.Rows[i].ItemArray[0].ToString()); dt2 = objMenu.ConsultarMenu(eMenu, eRolMenu); NavigationMenu.Items.Add(menuItem); AddMenuItem(menuItem, dt2); } }
public DataTable ConsultarMenu(BEMenu objEMEnu, BERolMenu eRolMenu) { return objMenu.ConsultarMenu(objEMEnu, eRolMenu); }