public Model.RolModel getRol(long idUsuario) { Model.RolModel rol = new Model.RolModel(); try { using (var entity=new GestorDocumentEntities()) { APP_ROL res; res = (from r in entity.APP_ROL join ur in entity.APP_USUARIO_ROL on r.IdRol equals ur.IdRol join u in entity.APP_USUARIO on ur.IdUsuario equals u.IdUsuario where u.IdUsuario == idUsuario select r).FirstOrDefault(); if (res != null) { rol.IdRol = res.IdRol; rol.RolName = res.RolName; } } } catch (Exception) { } return rol; }
public IEnumerable<Model.RolModel> GetDestinatarios() { ObservableCollection<Model.RolModel> filtroDestinatarios = new ObservableCollection<Model.RolModel>(); using (var entity = new GestorDocumentEntities()) { try { (from r in entity.APP_ROL where r.IdRol != 10 select r).OrderBy(o => o.RolName).ToList().ForEach(row => { Model.RolModel r = new Model.RolModel() { IdRol = row.IdRol, RolName = row.RolName, IsActive = false }; filtroDestinatarios.Add(r); }); } catch (Exception) { filtroDestinatarios = null; } return filtroDestinatarios; } }
public NuevoRol(Model.RolModel _rol) { InitializeComponent(); controller = new Controller.RolController(); rol = _rol; cbEstados.Enabled = false; }
public List<Model.RolModel> buscarTodosLosRoles() { List<Model.RolModel> roles = new List<Model.RolModel>(); Model.RolModel rol = null; SqlConnection myConnection = null; try { myConnection = new SqlConnection(stringConexion); myConnection.Open(); SqlCommand command = null; var query = "SELECT rol_id, rol_nombre, rol_habilitado " + "FROM MONDONGO.ROLES "; command = new SqlCommand(query, myConnection); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { var rolId = (int)(double)reader.GetDecimal(0); var rolNombre = reader.GetString(1); Model.Estado rolHabilitado = (Model.Estado)reader.GetInt32(2); rol = new Model.RolModel(rolId,rolNombre,rolHabilitado); roles.Add(rol); } } } catch (Exception ex) { MessageBox.Show("ERROR" + ex.Message); } finally { myConnection.Close(); } return roles; }
private void dgvRoles_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { rolSeleccionado = (Model.RolModel)dgvRoles.CurrentRow.DataBoundItem; if (rolSeleccionado._rolHabilitado != Model.Estado.BORRADO) { btnEditarRol.Enabled = true; btnFuncionalidades.Enabled = true; } else { btnEditarRol.Enabled = false; btnFuncionalidades.Enabled = false; } }