Пример #1
0
 private void BtnBorrar_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvHab.SelectedRows.Count > 0)
         {
             habitacion.IdHabitacion = Convert.ToInt32(dgvHab.CurrentRow.Cells[0].Value);
             if (habitacion.Delete(habitacion) == true)
             {
                 FrmCorrecto.confirmacionForm("ELIMINADO");
                 RefreshDgv();
             }
             else
             {
                 MessageBox.Show("Error al eliminar los datos.");
             }
         }
         else
         {
             MessageBox.Show("Seleccione una fila.");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error al borrar las habitación. (Error: " + ex + ")");
     }
 }
 private void BtnBorrar_Click(object sender, EventArgs e)
 {
     try
     {
         habitacion.IdHabitacion = Convert.ToInt32(dgvHab.CurrentRow.Cells[0].Value);
         if (habitacion.Delete(habitacion) == true)
         {
             MessageBox.Show("La habitación ha sido eliminada.");
             Clear();
         }
         else
         {
             MessageBox.Show("Error al editar los datos.)");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error al borrar las habitación. (Error: " + ex + ")");
     }
 }
        public bool Delete(int id)
        {
            Habitacion h = this.FindById(id);

            return(h != null && h.Delete());
        }