Example #1
0
        private void btnCrear_Click(object sender, EventArgs e)
        {
            string error = ValidateForm();

            if (string.IsNullOrEmpty(error))
            {
                try
                {
                    HotelInhabilitacion hotelInhabilitado = new HotelInhabilitacion();
                    hotelInhabilitado.FechaCreacion = Session.Fecha;
                    hotelInhabilitado.FechaInicio   = dateDesde.Value;
                    hotelInhabilitado.FechaFin      = dateHasta.Value;
                    hotelInhabilitado.Descripcion   = txtDescripcion.Text;
                    hotelInhabilitado.HotelId       = this.hotelId;

                    ReservaService reservaService = new ReservaService();
                    if (reservaService.GetCountActiveReservaBetweenDatesByHotelId(hotelInhabilitado.HotelId, hotelInhabilitado.FechaInicio, hotelInhabilitado.FechaFin) == 0)
                    {
                        HotelService hotelService = new HotelService();
                        hotelService.InsertHotelInhabilitado(hotelInhabilitado);
                        MessageBox.Show("El hotel se ha inhabilitado.");
                    }
                    else
                    {
                        MessageBox.Show("El hotel no puede ser inhabilitado ya que posee reservas en esas fechas");
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("OcurriĆ³ un error, no se ha podido inhabilitar el hotel.");
                }
            }
            else
            {
                MessageBox.Show(error);
            }
        }