예제 #1
0
        private void buscarDisponibilidad_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboHoteles.SelectedItem == null)
                {
                    throw new System.ArgumentException("No se seleccionó hotel");
                }
                if (fechaDesdeCalendar.SelectionEnd >= fechaHastaCalendar.SelectionEnd)
                {
                    throw new System.ArgumentException("La fecha hasta debe ser mayor a la de inicio");
                }

                int               idHotel    = (int)comboHoteles.SelectedValue;
                DateTime          fechaDesde = fechaDesdeCalendar.SelectionEnd;
                DateTime          fechaHasta = fechaHastaCalendar.SelectionEnd;
                List <Habitacion> habitacionesDisponibles = hotelCtrl.obtenerHabitacionesDisponibles(idHotel, fechaDesde, fechaHasta, (int)tipoHabBox.SelectedValue);
                if (habitacionesDisponibles.Count > 0)
                {
                    //abrir ventana de habitaciones disponibles
                    RegimenYHabitaciones regHabForm = new RegimenYHabitaciones(habitacionesDisponibles, fechaDesde, fechaHasta);
                    if (regHabForm.ShowDialog(this) == DialogResult.OK)
                    {
                        codigoReserva = regHabForm.id_reserva;
                        MessageBox.Show("Se generó correctamente la reserva./n El número de reserva es " + codigoReserva.ToString());
                    }
                    else
                    {
                        MessageBox.Show("Operacion cancelada");
                    }
                }
                else
                {
                    MessageBox.Show("La opcion seleccionada no tiene disponibilidad");
                }
            } catch (Exception exc) {
                MessageBox.Show(exc.Message);
            }
        }
 private void cargarHabitacionesDisponibles()
 {
     dataGridHabDispon.DataSource = hotelCtrl.obtenerHabitacionesDisponibles(reservaPrevia.id_hotel, fechaInicioBox.Value, fechaFinBox.Value, 0);
 }