private void cmbRoles_SelectedIndexChanged(object sender, EventArgs e) { lstFuncionalidades.Items.Clear(); FuncionalidadService service = new FuncionalidadService(); Rol rol = (Rol)cmbRoles.SelectedItem; if (rol.Id != 0) { rol.Funcionalidades = service.GetByRolId(rol.Id); List <Funcionalidad> funcionalidades = service.GetAll(); foreach (Funcionalidad f in funcionalidades) { bool esta = false; foreach (Funcionalidad rf in rol.Funcionalidades) { if (f.Id == rf.Id) { esta = true; } } lstFuncionalidades.Items.Add(f, esta); } ((ListBox)lstFuncionalidades).ValueMember = "Id"; ((ListBox)lstFuncionalidades).DisplayMember = "Nombre"; txtNombreRol.Text = rol.Nombre; chbActivo.Checked = rol.Activo; } }
private void frmAltaRol_Load(object sender, EventArgs e) { FuncionalidadService service = new FuncionalidadService(); ((ListBox)lstFuncionalidades).DataSource = service.GetAll(); ((ListBox)lstFuncionalidades).ValueMember = "Id"; ((ListBox)lstFuncionalidades).DisplayMember = "Nombre"; }