protected void Page_Load(object sender, EventArgs e) { UHotel hotel = new UHotel(); UHabitacion habitacion = new UHabitacion(); try { hotel.Idhotel = ((UHotel)Session["visitarhotel"]).Idhotel; habitacion = (UHabitacion)Session["idhabitacion"]; } catch { Response.Redirect("index.aspx"); } URegistro registro = new URegistro(); registro = (URegistro)Session["usuario"]; UDatosUsuario datos = new UDatosUsuario(); LReserva reserva = new LReserva(); datos = reserva.pageload_ingreso_reserva(hotel, habitacion, registro); TB_Nombre.Enabled = datos.Aviso; TB_Correo.Enabled = datos.Aviso; TB_Apellido.Enabled = datos.Aviso; TB_CCorreo.Enabled = datos.Aviso; B_ConfirmarReserva.Enabled = datos.Aviso; L_NombreHotel.Text = datos.Hotel.Nombre; L_PrecioNoche.Text = datos.Hotel.Precionoche.ToString(); L_NumeroDePersonas.Text = datos.Habitacion.Numpersonas.ToString(); L_Habitaciondisponible.Text = "Seleccione una fecha"; if (Session["usuario"] != null) { L_Nombreusuario.Text = datos.Registro.Nombre; L_MensajeestadoSession.Text = "Si la reserva no se hará a su nombre ingrese los datos de la persona que será responsable de la reserva"; TB_Apellido.Text = datos.Registro.Apellido; TB_Nombre.Text = datos.Registro.Nombre; } else { L_Nombreusuario.Text = "Cliente"; L_MensajeestadoSession.Text = "Al parecer no te haz registrado o iniciado sesión, no hay problema igualmente puedes reservar, solo dejanos saber algunos datos."; } }
//buscar Disponibilidad de fecha public UDatosUsuario buscarDisponibilidad(UReserva reserva, DateTime fechaMaxima) { UDatosUsuario mensaje = new UDatosUsuario(); if (reserva.Fecha_llegada < DateTime.Now) { mensaje.Mensaje = "Seleccione fechas de llegada despues de " + DateTime.Now.Date; //deshabilitarbotones(); mensaje.Aviso = false; } else { if (reserva.Fecha_salida > fechaMaxima) { mensaje.Mensaje = "Su estadia en el hotel no puede superar los 30 dias."; //cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Su estadia en el hotel no puede superar los 30 dias.');</script>"); //deshabilitarbotones(); mensaje.Aviso = false; } else { if (reserva.Fecha_llegada == null || reserva.Fecha_salida == null) { mensaje.Mensaje = "Seleccione las fechas correctamente"; //deshabilitarbotones(); mensaje.Aviso = false; } else if (reserva.Fecha_llegada != null || reserva.Fecha_salida != null) { if (reserva.Fecha_llegada > reserva.Fecha_salida) { mensaje.Mensaje = "Seleccione una fecha de salida posterior a\n" + reserva.Fecha_llegada; } else if (reserva.Fecha_llegada <= reserva.Fecha_salida) { var hdisponibles = new DAOReserva().habitacionesdisponibles(reserva);//numero de habitaciones en ese hotel para ese numero maximo de personas var fechasreservadas = new DAOReserva().fechasdisponibles(reserva); //var disponibilidad = hdisponibles - fechasreservadas; if (hdisponibles >= 1) { if (fechasreservadas >= 1) { mensaje.Mensaje = "No hay disponibilidad para las fechas selccionadas"; //deshabilitarbotones(); mensaje.Aviso = false; } else if (fechasreservadas == 0) { mensaje.Mensaje = "habitación disponible para las fechas selccionadas"; //habilitarbotones(); mensaje.Aviso = true; } } else { mensaje.Mensaje = "No hay habitaciones disponibles para ese numero de personas"; //deshabilitarbotones(); mensaje.Aviso = false; } } } } } return(mensaje); }
public UDatosUsuario pageload_ingreso_reserva(UHotel hotel_id, UHabitacion infoHabitacion, URegistro infousuario) { //deshabilitarbotones(); UDatosUsuario datosUsuario = new UDatosUsuario(); datosUsuario.Hotel = new UHotel(); datosUsuario.Habitacion = new UHabitacion(); datosUsuario.Registro = new URegistro(); datosUsuario.Aviso = false; try { datosUsuario.Hotel.Idhotel = hotel_id.Idhotel; datosUsuario.Hotel = new DAOhotel().infohotel(datosUsuario.Hotel); datosUsuario.Hotel.Nombre = datosUsuario.Hotel.Nombre.ToUpper(); //L_NombreHotel.Text if (infoHabitacion.Tipo.Equals("Básica")) { datosUsuario.Hotel.Precionoche = datosUsuario.Hotel.Precionoche; //L_PrecioNoche.Text = hotel.Precionoche.ToString(); } else if (infoHabitacion.Tipo.Equals("Doble")) { datosUsuario.Hotel.Precionoche = datosUsuario.Hotel.PrecioNocheDoble; //L_PrecioNoche.Text = hotel.PrecioNocheDoble.ToString(); } else if (infoHabitacion.Tipo.Equals("Premium")) { datosUsuario.Hotel.Precionoche = datosUsuario.Hotel.PrecioNochePremium; //L_PrecioNoche.Text = hotel.PrecioNochePremium.ToString(); } datosUsuario.Habitacion.Numpersonas = infoHabitacion.Numpersonas; if (infousuario != null) { datosUsuario.Registro.Nombre = infousuario.Nombre; datosUsuario.Registro.Apellido = infousuario.Apellido; datosUsuario.Registro.Contrasena = infousuario.Correo; //TB_Correo.Text = ((Registro)Session["usuario"]).Correo; } else { datosUsuario.Registro.Apellido = ""; //TB_Apellido.Text = ""; datosUsuario.Registro.Nombre = ""; //TB_Nombre.Text = ""; datosUsuario.Registro.Contrasena = ""; //TB_Correo.Text = ""; datosUsuario.Mensaje = "Al parecer no te haz registrado o iniciado sesión, no hay problema igualmente puedes reservar, solo dejanos saber algunos datos."; ///////////////////L_Nombreusuario.Text = "Cliente"; ////////////////////L_MensajeestadoSession.Text = "Al parecer no te haz registrado o iniciado sesión, no hay problema igualmente puedes reservar, solo dejanos saber algunos datos."; } } catch (Exception ex) { datosUsuario.Url = "index.aspx"; //Response.Redirect("index.aspx"); } return(datosUsuario); }