private void CargarModulos() { try { BLL.Tables.TBL_MENUS _menu = new BLL.Tables.TBL_MENUS(); _menu.WhereParameter.Add(DAL.Tables.TBL_MENUS.ColumnEnum.Id_MenuPadre, DAL.SqlEnums.OperandEnum.Equal, 0); _menu.OrderByParameter.Add(DAL.Tables.TBL_MENUS.ColumnEnum.DescripcionMenu, DAL.SqlEnums.DirEnum.ASC); _menu.ItemList(); Entities.Tables.TBL_MENUS _itemSeleccion = new Entities.Tables.TBL_MENUS(); //Limpia el combo this.comboModulos.SuspendLayout(); this.comboModulos.DataSource = null; this.comboModulos.Items.Clear(); //Carga el item de Seleccion.- _itemSeleccion.DESCRIPCIONMENU = "<Seleccione un Módulo>"; _itemSeleccion.ID_MENU = 0; _menu.Result.Insert(0, _itemSeleccion); //Carga el combo this.comboModulos.ValueMember = "Id_Menu"; this.comboModulos.DisplayMember = "DescripcionMenu"; this.comboModulos.DataSource = _menu.Result; this.comboModulos.ResumeLayout(); this.comboModulos.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cmdGrabarUsuario_Click(object sender, EventArgs e) { if (VerificaIngreso()) { try { BLL.Tables.TBL_MENUS _menu = new BLL.Tables.TBL_MENUS(); Entities.Tables.TBL_MENUS _itemMenu = new Entities.Tables.TBL_MENUS(); BLL.Procedures.ULTIMA_POSICION_MENU _ultimaPoc = new BLL.Procedures.ULTIMA_POSICION_MENU(); int _pos = 0; //TRAIGO LA ULTIMA POSICION DEL MENU. PARA SABER EN QUE LUGAR CREO ESTE NUEVO MENU _ultimaPoc.Items((int)this.comboMenuPadre.SelectedValue); _pos = _ultimaPoc.Result[0].ultimomenu + 1; // ES LA PROXIMA POSICIÓN //AGGREGO EL NUEVO MENU _itemMenu.DESCRIPCIONMENU = this.textDescrip.Text.ToString(); _itemMenu.FORMULARIOASOCIADO = true; _itemMenu.HABILITADOMENU = true; _itemMenu.ID_MENUPADRE = (int)this.comboMenuPadre.SelectedValue; _itemMenu.POSICIONMENU = _pos; _itemMenu.URLMENU = this.comboModulos.Text.ToString() + "." + this.textNombre.Text.ToString(); // LA URLMENU ES LA CONCATENACION DEL MODULO CON EL NOMBRE DEL FORMULARIO _menu.AddItem(_itemMenu); MessageBox.Show("Menú agregado correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); this.NuevoIngreso(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }