private void btnEliminar_Click(object sender, EventArgs e) { byte id = (byte)UFormulario.ObtenerIdGrid(dgvCargos); if (id > 0) { if (MessageBox.Show("Deseas eliminar el registro", "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes ) { if (CargoBL.Eliminar(new Cargo { Id = id }) > 0) { MessageBox.Show("Registro eliminado"); MostrarCargos(); } } } else { MessageBox.Show("Debe seleccionar un registro"); } }
private void btnEliminar_Click(object sender, EventArgs e) { try { byte id = (byte)UFormulario.ObtenerIdGrid(dgvEstados); if (id > 0) { if (MessageBox.Show("Desea eliminar el registro", "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { if (EstadoBL.Eliminar(new Estado { Id = id }) > 0) { MessageBox.Show("Registro eliminado"); MostrarEstados(); } } } else { MessageBox.Show("Debe seleccionar un registro"); } } catch (Exception ex) { MessageBox.Show("Error al eliminar un registro: " + ex.Message); } }
private void btnModificar_Click(object sender, EventArgs e) { byte id = (byte)UFormulario.ObtenerIdGrid(dgvCargos); if (id > 0) { FrmCargo frmCargo = new FrmCargo(); frmCargo.StartPosition = FormStartPosition.CenterScreen; frmCargo._idCargo = id; frmCargo.ShowDialog(); MostrarCargos(); } else { MessageBox.Show("Debes seleccionar un Estado"); } }