Пример #1
0
 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);
     }
 }