//insert registro public void insertHotel(UHotel hotelE) { using (var db = new Mapeo()) { db.hotel.Add(hotelE); db.SaveChanges(); } }
protected void DL_Listaprincipalhoteles_ItemCommand(object source, DataListCommandEventArgs e) { UHotel hotelinfo = new UHotel(); hotelinfo.Idhotel = int.Parse(e.CommandArgument.ToString()); Session["visitarhotel"] = hotelinfo; Session.Remove("calificarhotel"); Response.Redirect("PanelHotel.aspx"); }
//eliminar hotel public void deleteHotel(UHotel id) { using (var db = new Mapeo()) { UHotel mihotel = db.hotel.Where(x => x.Idhotel == id.Idhotel).First(); List <UHabitacion> mihabitacion = db.habitacion.Where(x => x.Idhotel == id.Idhotel).ToList(); db.habitacion.RemoveRange(mihabitacion); db.hotel.Remove(mihotel); db.SaveChanges(); } }
//actualizar calificacion public void actualizarcalificacion(UHotel hotelE) { using (var db = new Mapeo()) { UHotel datoanterior = db.hotel.Where(x => x.Idhotel == hotelE.Idhotel).First(); datoanterior.Promediocalificacion = hotelE.Promediocalificacion; var entry = db.Entry(datoanterior); entry.State = EntityState.Modified; db.SaveChanges(); } }
//Agregar habitación en el hotel public void actualizarhabiatacion(UHabitacion idE) { using (var db = new Mapeo()) { UHotel datoanterior = db.hotel.Where(x => x.Idhotel == idE.Idhotel).First(); var idanterior = datoanterior.Numhabitacion; datoanterior.Numhabitacion = idanterior + 1; var entry = db.Entry(datoanterior); entry.State = EntityState.Modified; db.SaveChanges(); } }
//Confirmar reserva public UHotel confirmarReserva(UHotel infoHotel, UReserva infoReserva) { UHotel hotel = new UHotel(); hotel = new DAOhotel().infohotel(infoHotel); var fechasreservadas = new DAOReserva().fechasdisponibles(infoReserva); int cantReservas = new DAOReserva().verificarreserva(infoReserva); string fechaLlegada = (infoReserva.Fecha_llegada).ToString(); string fechaSalida = (infoReserva.Fecha_salida).ToString(); if (fechasreservadas == 1) { //cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('No hay disponibilidad entre estas fechas');</script>"); hotel.Mensaje2 = "No hay disponibilidad entre estas fechas"; hotel.Mensaje = null; } else if (fechasreservadas == 0) { if (cantReservas == 0) { if (infoReserva.Idusuario != 0) { new DAOReserva().insertReserva(infoReserva); hotel.Mensaje = "La reserva ha sido exitosa"; hotel.Mensaje2 = null; //cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('La reserva ha sido exitosa');</script>"); new Mail().mailconfirmarreserva(infoReserva); //correo de confirmacion } else { new DAOReserva().insertReserva(infoReserva); new Mail().mailconfirmarreserva(infoReserva); hotel.Mensaje = "La reserva ha sido exitosa"; hotel.Mensaje2 = "ESTA RESERVA SE ENCUENTRA OCUPADA"; //cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('La reserva ha sido exitosa');</script>"); } } else { hotel.Mensaje2 = "ESTA RESERVA SE ENCUENTRA OCUPADA";//, REVISE SU CORREO PARA MÁS DETALLES hotel.Mensaje = null; //cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('ESTA RESERVA SE ENCUENTRA OCUPADA');</script>"); } } return(hotel); }
public UHotel info_hotel(UHotel session) { UHotel hotel = new UHotel(); if (session != null) { hotel.Idhotel = session.Idhotel; hotel = new DAOhotel().infohotel(hotel); return(hotel); } else { hotel.Url = "index.aspx"; return(hotel); } }
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."; } }
//disponibbilidad de personas public List <UHabitacion> disponibilidadDePeronas(UHotel datosE) { using (var db = new Mapeo()) { List <UHabitacion> limiteDePersonas = (from hhab in db.habitacion where hhab.Idhotel == datosE.Idhotel select new { hhab }).ToList().Select(m => new UHabitacion { Id = m.hhab.Numpersonas, }).ToList(); return(limiteDePersonas); } }
public UHabitacion agregarHabitacion(int idtipo, UHabitacion habitacion) { UHabitacion mensaje = new UHabitacion(); if (habitacion.Tipo != "--Seleccionar--") { UHotel infohotel = new UHotel(); infohotel.Idhotel = habitacion.Idhotel; infohotel = new DAOhotel().infohotel(infohotel); if (idtipo == 1)//basica { habitacion.Precio = infohotel.Precionoche; } if (idtipo == 2)//doble { habitacion.Precio = infohotel.PrecioNocheDoble; } if (idtipo == 3)//premium { habitacion.Precio = infohotel.PrecioNochePremium; } int cantHabitaciones = new DAOHabitacion().cantidadHabitaciones(habitacion); if (cantHabitaciones == 150) { mensaje.Mensaje = " Limite de habitaciones alcanzado"; } else { new DAOHabitacion().insertHabitacion(habitacion); new DAOhotel().actualizarhabiatacion(habitacion); mensaje.Mensaje = " Habitacion añadida con exito"; mensaje.Tb_NumPersonas = ""; mensaje.Tb_NumBanio = ""; mensaje.Tb_NumeroDeCamas = ""; } } else { mensaje.Mensaje = "Seleccione una opción"; } return(mensaje); }
public UMisReservas accionCalificarComentar(int idreserva, string accion) { UMisReservas mensaje = new UMisReservas(); if (accion == "calificarreserva") { UReserva inforeserva = new UReserva(); inforeserva.Id = idreserva; inforeserva = new DAOReserva().inforeserva(inforeserva); UHotel hotelinfo = new UHotel(); hotelinfo.Idhotel = int.Parse((inforeserva.Idhotel).ToString()); mensaje.Infohotel = hotelinfo; //Session["visitarhotel"] = hotelinfo; mensaje.URL1 = "ComentariosHotel.aspx"; } else if (accion == "cancelarreserva") { UReserva inforeserva = new UReserva(); inforeserva.Id = idreserva; inforeserva = new DAOReserva().inforeserva(inforeserva); if (inforeserva.Fecha_salida <= DateTime.Now) { mensaje.Mensaje = "No es posible eliminar una reserva ya realizada"; //this.RegisterStartupScript("mensaje", "<script type='text/javascript'>alert('No es posible eliminar una reserva ya realizada');</script>"); } else if (inforeserva.Fecha_llegada > DateTime.Now) { new DAOReserva().deleteReserva(inforeserva); mensaje.Mensaje = "Reserva eliminada con exito"; //this.RegisterStartupScript("mensaje", "<script type='text/javascript'>alert('Reserva eliminada con exito');</script>"); } else if ((inforeserva.Fecha_llegada <= DateTime.Now) && (inforeserva.Fecha_salida >= DateTime.Now)) { mensaje.Mensaje = "No es posible realizar la eliminación"; //this.RegisterStartupScript("mensaje", "<script type='text/javascript'>alert('No es posible realizar la eliminación');</script>"); } } return(mensaje); }
protected void B_ConfirmarReserva_Click(object sender, EventArgs e) { ClientScriptManager cm = this.ClientScript;//script UHotel hotel = new UHotel(); hotel.Idhotel = ((UHotel)Session["visitarhotel"]).Idhotel; //hotel = new DAOhotel().infohotel(hotel); UReserva reserva = new UReserva(); try { reserva.Idusuario = ((URegistro)Session["usuario"]).Id; }catch { reserva.Idusuario = 0; } reserva.Apellido = TB_Apellido.Text; reserva.Nombre = TB_Nombre.Text; reserva.Numpersona = int.Parse(L_NumeroDePersonas.Text); reserva.Correo = TB_Correo.Text; reserva.Idhotel = ((UHotel)Session["visitarhotel"]).Idhotel; reserva.Fecha_llegada = C_FechaLlegada.SelectedDate; reserva.Fecha_salida = C_FechaSalida.SelectedDate; DateTime fechaMaxima = reserva.Fecha_llegada.AddDays(30); reserva.Mediopago = CHBL_Mediodepago.Text; reserva.Id_habitacion = ((UHabitacion)Session["idhabitacion"]).Id; reserva.Limite_comentario = reserva.Fecha_salida.AddDays(3); reserva.PrecioNoche = int.Parse(L_PrecioNoche.Text); hotel = new LReserva().confirmarReserva(hotel, reserva); if (hotel.Mensaje != null) { this.RegisterStartupScript("mensaje", "<script type='text/javascript'>alert('" + hotel.Mensaje + "');window.location=\"Perfil.aspx\"</script>"); } else { L_MensajeestadoSession.Text = hotel.Mensaje2; } }
//Tablas-Acciones public void eliminarHotelTabla(UHotel id) { new DAOhotel().deleteHotel(id); }
public List <UComentarios> obtenerComentarios(UHotel id) { return(new DAOComentarios().obtenerComentarios(id)); }
public List <UHabitacion> habitacionesHotel(UHotel idE, UFiltro consulta) { return(new DAOHabitacion().habitacionesHotel(idE, consulta)); }
//habitaciones por hotel public List <UHabitacion> habitacionesHotel(UHotel idE, UFiltro consulta) { try { if (consulta.numpersonas == null) { using (var db = new Mapeo()) { List <UHabitacion> habitaciones = (from hhab in db.habitacion select new { hhab }).ToList().Select(m => new UHabitacion { Tipo = m.hhab.Tipo, Id = m.hhab.Id, Numbanio = m.hhab.Numbanio, Numcamas = m.hhab.Numcamas, Numpersonas = m.hhab.Numpersonas, Idhotel = m.hhab.Idhotel, Precio = m.hhab.Precio, }).Where(x => x.Idhotel == idE.Idhotel).ToList(); return(habitaciones); } } else { using (var db = new Mapeo()) { List <UHabitacion> habitaciones = (from hhab in db.habitacion select new { hhab }).ToList().Select(m => new UHabitacion { Tipo = m.hhab.Tipo, Id = m.hhab.Id, Numbanio = m.hhab.Numbanio, Numcamas = m.hhab.Numcamas, Numpersonas = m.hhab.Numpersonas, Idhotel = m.hhab.Idhotel, Precio = m.hhab.Precio, }).Where(x => (x.Idhotel == idE.Idhotel) && (x.Numpersonas == consulta.numpersonas)).ToList(); return(habitaciones); } } } catch { if (consulta == null) { using (var db = new Mapeo()) { List <UHabitacion> habitaciones = (from hhab in db.habitacion select new { hhab }).ToList().Select(m => new UHabitacion { Tipo = m.hhab.Tipo, Id = m.hhab.Id, Numbanio = m.hhab.Numbanio, Numcamas = m.hhab.Numcamas, Numpersonas = m.hhab.Numpersonas, Idhotel = m.hhab.Idhotel, Precio = m.hhab.Precio, }).Where(x => x.Idhotel == idE.Idhotel).ToList(); return(habitaciones); } } else { using (var db = new Mapeo()) { List <UHabitacion> habitaciones = (from hhab in db.habitacion select new { hhab }).ToList().Select(m => new UHabitacion { Tipo = m.hhab.Tipo, Id = m.hhab.Id, Numbanio = m.hhab.Numbanio, Numcamas = m.hhab.Numcamas, Numpersonas = m.hhab.Numpersonas, Idhotel = m.hhab.Idhotel, Precio = m.hhab.Precio, }).Where(x => (x.Idhotel == idE.Idhotel) && (x.Numpersonas == consulta.numpersonas)).ToList(); return(habitaciones); } } } }
public UComentario_CalificacionDatos comentar(URegistro session, UComentarios comentario, UHotel hotelSession) { UComentario_CalificacionDatos datos = new UComentario_CalificacionDatos(); if (session != null) { UComentarios comenta = new UComentarios(); comenta.Id_hotel = hotelSession.Idhotel; comenta.Id_usuario = session.Id; comenta.Comentario = comentario.Comentario; comenta.Fecha_comentario = DateTime.Now; Boolean consulta = new DAOComentarios().consulta(comenta); if (consulta == true) { new DAOComentarios().insertComentario(comenta); datos.ComentarioTb = ""; datos.Mensaje = "Comentario Agregado."; } else { datos.Mensaje = "No puede comentar"; } } else { datos.Mensaje = "Para comentar, inicie sesion."; datos.ComentarioTb = ""; } return(datos); }
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); }
public UComentario_CalificacionDatos calificar(URegistro sessionUsuario, UHotel hotelSession, UReserva inforeserva, RadioButton[] arrayRadioButton) { UComentario_CalificacionDatos mensaje = new UComentario_CalificacionDatos(); DateTime fechaparacalificar; if (inforeserva != null) { inforeserva = new DAOReserva().inforeserva(inforeserva); try { fechaparacalificar = inforeserva.Fecha_salida; if (DateTime.Now >= fechaparacalificar.AddDays(1)) { if (inforeserva.Calificacion == null) { if (arrayRadioButton[0].Checked) { inforeserva.Calificacion = 0; } else if (arrayRadioButton[1].Checked) { inforeserva.Calificacion = 1; } else if (arrayRadioButton[2].Checked) { inforeserva.Calificacion = 2; } else if (arrayRadioButton[3].Checked) { inforeserva.Calificacion = 3; } else if (arrayRadioButton[4].Checked) { inforeserva.Calificacion = 4; } else if (arrayRadioButton[5].Checked) { inforeserva.Calificacion = 5; } if (inforeserva.Calificacion != null) { new DAOReserva().actualizarcalificacion(inforeserva); mensaje.Mensaje = "Calificacion realizada con exito"; new DAOReserva().cantidaddereservasconcalificacion(inforeserva); var promediocalificacion = new DAOReserva().cantidaddereservasconcalificacion(inforeserva); UHotel hotel = new UHotel(); hotel.Idhotel = int.Parse((inforeserva.Idhotel).ToString()); hotel.Promediocalificacion = promediocalificacion; new DAOhotel().actualizarcalificacion(hotel); } else { mensaje.Mensaje = "Seleccione una opcion a calificar"; } } else if (inforeserva.Calificacion != null) { mensaje.Mensaje = "Este servicio ha sido calificado antes"; } } else { mensaje.Mensaje = "No es posible realizar aun esta calificación"; } } catch { mensaje.Mensaje = "No es posible realizar aun esta calificación "; } } else if (inforeserva == null) { mensaje.Mensaje = "Todas sus reservas han sido calificadas"; } return(mensaje); }
//select info hotel panel hotel public UHotel infohotel(UHotel hotelE) { return(new Mapeo().hotel.Where(x => x.Idhotel == hotelE.Idhotel).FirstOrDefault()); }
//select zona public UHotelZona zona(UHotel hotelE) { return(new Mapeo().hotelzona.Where(x => x.Idzona.Equals(hotelE.Idzona)).FirstOrDefault()); }
//select municipio public UHotelMunicipio municipio(UHotel hotelE) { return(new Mapeo().hotelmunicipio.Where(x => x.Idmunicipio.Equals(hotelE.Idmunicipio)).FirstOrDefault()); }
public UHotel insertHotel(FileUpload imagenPrincipal, FileUpload imagenSecundaria, FileUpload imagenSecundaria2, string direccion1, string direccion2, string direccion3, string dir1, string dir2, string dir3, UHotel datosHotel) { UHotel hotel = new UHotel(); hotel.Nombre = datosHotel.Nombre; hotel.Municipio = datosHotel.Municipio; hotel.Idmunicipio = datosHotel.Idmunicipio; hotel.Numhabitacion = datosHotel.Numhabitacion; hotel.Precionoche = datosHotel.Precionoche; hotel.PrecioNocheDoble = datosHotel.PrecioNocheDoble; hotel.PrecioNochePremium = datosHotel.PrecioNochePremium; hotel.Descripcion = datosHotel.Descripcion; hotel.Condicion = datosHotel.Condicion; hotel.Checkin = datosHotel.Checkin; hotel.Checkout = datosHotel.Checkout; hotel.Usuarioencargado = datosHotel.Usuarioencargado; hotel.Idusuario = datosHotel.Idusuario; hotel.Idzona = datosHotel.Idzona; hotel.Condicionesbioseguridad = datosHotel.Condicionesbioseguridad; hotel.Direccion = datosHotel.Direccion; if (imagenPrincipal.HasFile) { string ext = System.IO.Path.GetExtension(imagenPrincipal.FileName);//obtiene la extencion del archivo ext = ext.ToLower(); int tam = imagenPrincipal.PostedFile.ContentLength; if ((ext == ".jpg" || ext == ".png" || ext == ".jpeg") && (tam < 1048576)) { imagenPrincipal.SaveAs(dir1); //hotel.Mensaje = "*Imagen Aceptada"; hotel.Mensaje = null; hotel.Imagen = direccion1; if (imagenSecundaria.HasFile) //secundaria1 { string exts = System.IO.Path.GetExtension(imagenSecundaria.FileName); //obtiene la extencion del archivo exts = exts.ToLower(); int tams = imagenSecundaria.PostedFile.ContentLength; if ((exts == ".jpg" || exts == ".png" || exts == ".jpeg") && (tams < 1048576)) { imagenSecundaria.SaveAs(dir2); hotel.Mensaje2 = "*Imagen Aceptada"; hotel.Imagen_secundaria = direccion2; } else { hotel.Mensaje2 = "*Imagen no esta en formato correcto o es muy pesada."; } } else { hotel.Mensaje2 = ""; hotel.Imagen_secundaria = null; } if (imagenSecundaria2.HasFile) //secundaria2 { string extt = System.IO.Path.GetExtension(imagenSecundaria2.FileName); //obtiene la extencion del archivo extt = extt.ToLower(); int tamt = imagenSecundaria2.PostedFile.ContentLength; if ((extt == ".jpg" || extt == ".png" || extt == ".jpeg") && (tamt < 1048576)) { imagenSecundaria2.SaveAs(dir3); hotel.Mensaje3 = "*Imagen Aceptada"; hotel.Imagen_secundaria2 = direccion3; } else { hotel.Mensaje3 = "*Imagen no esta en formato correcto o es muy pesada."; } } else { hotel.Mensaje3 = ""; hotel.Imagen_secundaria2 = null; } new DAOhotel().insertHotel(hotel); } else { hotel.Mensaje = "*Imagen no esta en formato correcto o es muy pesada."; } } else { hotel.Mensaje = "*Seleccione una imagen"; } return(hotel); }
protected void B_CargarHotel_Click(object sender, EventArgs e) { string direccionImagen; string nombre; string direccionImagenA1; string nombre1; string direccionImagenA2; string nombre2; string dirImagen; string dirImagenA1; string dirImagenA2; UHotel hotel = new UHotel(); hotel.Nombre = TB_NombreHotel.Text; hotel.Idmunicipio = int.Parse(DDL_Municipio.Text); hotel.Idzona = int.Parse(DDL_Zona.Text); hotel.Checkin = TB_Checkin.Text; hotel.Checkout = TB_Checkout.Text; hotel.Descripcion = TB_Descripcion.Text; hotel.Condicion = TB_Condiciones.Text; hotel.Usuarioencargado = ((URegistro)Session["usuario"]).Usuario; hotel.Idusuario = ((URegistro)Session["usuario"]).Id; hotel.Condicionesbioseguridad = TB_descripcioncovid19.Text; hotel.Direccion = TB_Direccion.Text; hotel.PrecioNocheDoble = int.Parse(TB_PrecioNocheDoble.Text); hotel.PrecioNochePremium = int.Parse(TB_PrecioNochePremium.Text); hotel.Precionoche = int.Parse(TB_PrecioNoche.Text); //hotel.Imagen = null; hotel.Imagen_secundaria = null; hotel.Imagen_secundaria2 = null; nombre = ((URegistro)Session["usuario"]).Usuario + FU_ImgPrincipal.FileName; nombre1 = ((URegistro)Session["usuario"]).Usuario + FU_ImgAdicional.FileName; nombre2 = ((URegistro)Session["usuario"]).Usuario + FU_ImgAdicional0.FileName; direccionImagen = "/Vew/hoteles/imgprincipal/" + nombre; direccionImagenA1 = "/Vew/hoteles/imgadicional/" + nombre1; direccionImagenA2 = "/Vew/hoteles/imgadicional/" + nombre2; dirImagen = Server.MapPath(direccionImagen); dirImagenA1 = Server.MapPath(direccionImagenA1); dirImagenA2 = Server.MapPath(direccionImagenA2); hotel = new LAgregarServicioHotel().insertHotel(FU_ImgPrincipal, FU_ImgAdicional, FU_ImgAdicional0, direccionImagen, direccionImagenA1, direccionImagenA2, dirImagen, dirImagenA1, dirImagenA2, hotel); if (hotel.Mensaje != null) { L_CargarimagenAgregarHotel.Text = hotel.Mensaje; L_CargarimagenAgregarHotel0.Text = hotel.Mensaje2; L_CargarimagenAgregarHotel1.Text = hotel.Mensaje3; } else { this.RegisterStartupScript("mensaje", "<script type='text/javascript'>alert('Hotel agregado correctamente');window.location=\"Perfil.aspx\"</script>"); } /* * ClientScriptManager cm = this.ClientScript; * Hotel serviciohotel = new Hotel(); * * serviciohotel.Nombre = TB_NombreHotel.Text; * serviciohotel.Precionoche = int.Parse(TB_PrecioNoche.Text); * serviciohotel.Idmunicipio = int.Parse(DDL_Municipio.Text); * serviciohotel.Idzona = int.Parse(DDL_Zona.Text); * serviciohotel.Checkin = TB_Checkin.Text; * serviciohotel.Checkout = TB_Checkout.Text; * serviciohotel.Descripcion = TB_Descripcion.Text; * serviciohotel.Condicion = TB_Condiciones.Text; * serviciohotel.Usuarioencargado = ((Registro)Session["usuario"]).Usuario; * serviciohotel.Condicionesbioseguridad = TB_descripcioncovid19.Text; * serviciohotel.Direccion = TB_Direccion.Text; * serviciohotel.PrecioNocheDoble = int.Parse(TB_PrecioNocheDoble.Text); * serviciohotel.PrecioNochePremium = int.Parse(TB_PrecioNochePremium.Text); * * * //verifica si hay archivos seleccionados * if (FU_ImgPrincipal.HasFile) * { * string direccion; * string ext = System.IO.Path.GetExtension(FU_ImgPrincipal.FileName);//obtiene la extencion del archivo * ext = ext.ToLower();//minusculas * * int tam = FU_ImgPrincipal.PostedFile.ContentLength;//obtiene tamano archivo * * if ((ext == ".jpg" || ext == ".png") && (tam < 1048576))//menor a 1MB en bytes * { * direccion = "~/Vew/hoteles/imgprincipal/" + ((Registro)Session["usuario"]).Usuario + FU_ImgPrincipal.FileName; * FU_ImgPrincipal.SaveAs(Server.MapPath(direccion));//mapea y guarda el archivo en la direccion * L_CargarimagenAgregarHotel.Text = "*Imagen aceptada"; * //actualiza foto de perfil * * serviciohotel.Imagen = direccion; * } * else * { * L_CargarimagenAgregarHotel.Text = "*Imagen no esta en formato correcto o es muy pesada"; * } * } * else * { * L_CargarimagenAgregarHotel.Text = "*Selecciona una imagen"; * } * * * //verifica si hay archivos seleccionados * if (FU_ImgAdicional.HasFile) * { * string direccion; * string ext = System.IO.Path.GetExtension(FU_ImgAdicional.FileName);//obtiene la extencion del archivo * ext = ext.ToLower();//minusculas * * int tam = FU_ImgAdicional.PostedFile.ContentLength;//obtiene tamano archivo * * if ((ext == ".jpg" || ext == ".png") && (tam < 1048576))//menor a 1MB en bytes * { * direccion = "~/Vew/hoteles/imgadicional/" + ((Registro)Session["usuario"]).Usuario + FU_ImgAdicional.FileName; * FU_ImgAdicional.SaveAs(Server.MapPath(direccion));//mapea y guarda el archivo en la direccion * L_CargarimagenAgregarHotel0.Text = "*Imagen aceptada"; * //actualiza foto de perfil * * serviciohotel.Imagen_secundaria = direccion; * } * else * { * L_CargarimagenAgregarHotel.Text = "*Imagen no esta en formato correcto o es muy pesada"; * } * } * else * { * serviciohotel.Imagen_secundaria = null; * } * * * //verifica si hay archivos seleccionados * if (FU_ImgAdicional0.HasFile) * { * string direccion; * string ext = System.IO.Path.GetExtension(FU_ImgAdicional0.FileName);//obtiene la extencion del archivo * ext = ext.ToLower();//minusculas * * int tam = FU_ImgAdicional0.PostedFile.ContentLength;//obtiene tamano archivo * * if ((ext == ".jpg" || ext == ".png") && (tam < 1048576))//menor a 1MB en bytes * { * direccion = "~/Vew/hoteles/imgadicional/" + ((Registro)Session["usuario"]).Usuario + FU_ImgAdicional0.FileName; * FU_ImgAdicional0.SaveAs(Server.MapPath(direccion));//mapea y guarda el archivo en la direccion * L_CargarimagenAgregarHotel1.Text = "*Imagen aceptada"; * //actualiza foto de perfil * * serviciohotel.Imagen_secundaria2 = direccion; * } * else * { * L_CargarimagenAgregarHotel1.Text = "*Imagen no esta en formato correcto o es muy pesada"; * } * } * else * { * serviciohotel.Imagen_secundaria2 = null; * } * * new DAOhotel().insertHotel(serviciohotel); * * this.RegisterStartupScript("mensaje", "<script type='text/javascript'>alert('Hotel agregado correctamente');window.location=\"Perfil.aspx\"</script>"); * * return; */ }