private void AgregarButton_Click(object sender, EventArgs e) { bool paso = false; if (DetallesDataGridView.DataSource != null) { this.Detalle = (List <RolesDetalle>)DetallesDataGridView.DataSource; } if (PermisosComboBox.Text == string.Empty) { MessageBox.Show("Debes de seleccionar un permiso para continuar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.Detalle.Add( new RolesDetalle( id: 0, rolId: (int)IdNumericUpDown.Value, permisoId: Convert.ToInt32(PermisosComboBox.Text), esasignado: AsignadoCheckBox.Checked ) ); CargarGrid(); PermisosComboBox.Focus(); AsignadoCheckBox.Checked = paso; }
private bool Validar() { bool paso = true; ErrorProvider.Clear(); if (DescripcionTextBox.Text == string.Empty) { ErrorProvider.SetError(DescripcionTextBox, "El campo Rol no puede estar vacío"); DescripcionTextBox.Focus(); paso = false; } if (RolesBLL.ExisteDescripcion(DescripcionTextBox.Text, (int)IdNumericUpDown.Value)) { ErrorProvider.SetError(DescripcionTextBox, "Este Rol ya existe"); DescripcionTextBox.Focus(); paso = false; } if (PermisosComboBox.Text == string.Empty) { ErrorProvider.SetError(PermisosComboBox, "Debe seleccionar un Id"); PermisosComboBox.Focus(); paso = false; } if (this.Detalle.Count == 0) { ErrorProvider.SetError(DetallesDataGridView, "Debe agregar un Permiso"); PermisosComboBox.Focus(); paso = false; } return(paso); }
private void AgregarButton_Click(object sender, EventArgs e) { if (DetallesDataGridView.DataSource != null) { this.Detalle = (List <RolesDetalle>)DetallesDataGridView.DataSource; } this.Detalle.Add( new RolesDetalle( id: 0, rolId: (int)IdNumericUpDown.Value, permisoId: Convert.ToInt32(PermisosComboBox.Text), esasignado: AsignadoCheckBox.Checked ) ); CargarGrid(); PermisosComboBox.Focus(); //PermisosComboBox.Text = " "; AsignadoCheckBox.Checked = false; }