private void BtnEditar_Click(object sender, EventArgs e) { Rol rolSeleccionado = new Rol(); if (DgRoles.SelectedRows.Count > 0) { BindingSource bs = DgRoles.DataSource as BindingSource; if (bs != null) { rolSeleccionado = (Rol)bs.List[bs.Position]; } } var altaRol = new AltaRol(); altaRol.Text = Resources.EdicionRol; altaRol.Rol = rolSeleccionado; var result = altaRol.ShowDialog(); if (result.Equals(DialogResult.OK)) { BindingList <Rol> dataSource = new BindingList <Rol>(RolesServices.GetAllData()); BindingSource bs = new BindingSource { DataSource = dataSource }; DgRoles.DataSource = bs; } }
private void BtnAgregar_Click(object sender, EventArgs e) { var altaRol = new AltaRol(); altaRol.Rol = Usuario.RolActivo != null ? Usuario.RolActivo : new Rol(); var result = altaRol.ShowDialog(); if (result.Equals(DialogResult.OK)) { BindingList <Rol> dataSource = new BindingList <Rol>(RolesServices.GetAllData()); BindingSource bs = new BindingSource { DataSource = dataSource }; DgRoles.DataSource = bs; } }