Exemple #1
0
        public void filtro_general_inicial()
        {
            UFiltro consulta = new UFiltro();

            consulta.nombrehotel = null;
            new DAOhotel().hotelesregistrados(consulta);
        }
Exemple #2
0
        public UFiltro filtro_general(string preciomin, string preciomax, string maxpersonas, string DateAntesDe, string DateDespuesDe, string Calificacion, string Zona, string Municipio, string Tipo)
        {
            UFiltro busqueda = new UFiltro();

            busqueda = this.verificar_vacios(preciomin, preciomax, maxpersonas, DateAntesDe, DateDespuesDe, Calificacion, Zona, Municipio, Tipo);

            return(busqueda);
        }
Exemple #3
0
    protected void IB_Busquedageneral_Click(object sender, ImageClickEventArgs e)
    {
        UFiltro busqueda = new UFiltro();

        busqueda.nombrehotel = TB_Busquedageneral.Text;
        busqueda.nombrehotel = new LFiltro().filtro_general_nombre(busqueda);

        Session["hotelseleccionado"] = busqueda;
        DL_Listaprincipalhoteles.DataBind();
    }
Exemple #4
0
    protected void B_Filtrar_Click(object sender, EventArgs e)
    {
        LFiltro filtro   = new LFiltro();
        UFiltro busqueda = new UFiltro();

        busqueda = filtro.filtro_general(TB_PrecioMin.Text, TB_PrecioMax.Text, TB_Maxpersonas.Text, TB_DateAntesDe.Text, TB_DateDespuesDe.Text, DDL_Calificacion.Text, DDL_Zona.Text, DDL_Municipio.Text, DDL_Tipo.Text);

        //L_MensajeFalloFechas.Text = msj;
        Session["hotelseleccionado"] = busqueda;
        DL_Listaprincipalhoteles.DataBind();
    }
Exemple #5
0
 public string filtro_general_nombre(UFiltro busqueda)
 {
     if (busqueda.nombrehotel == null || busqueda.nombrehotel == String.Empty)
     {
         return(null);
         //busqueda.nombrehotel = null;
     }
     else
     {
         return((busqueda.nombrehotel).ToUpper());
         //busqueda.nombrehotel = (TB_Busquedageneral.Text).ToUpper();
     }
 }
Exemple #6
0
        public UFiltro verificar_vacios(string preciomin, string preciomax, string maxpersonas, string DateAntesDe, string DateDespuesDe, string Calificacion, string Zona, string Municipio, string Tipo)
        {
            UFiltro filtro = new UFiltro();

            if (preciomin == "")
            {
                filtro.preciomin = null;
            }
            else if (preciomin != "")
            {
                filtro.preciomin = int.Parse(preciomin);
            }
            if (preciomax == "")
            {
                filtro.preciomax = null;
            }
            else if (preciomax != "")
            {
                filtro.preciomax = int.Parse(preciomax);
            }
            if (maxpersonas == "")
            {
                filtro.numpersonas = null;
            }
            else if (maxpersonas != "")
            {
                filtro.numpersonas = int.Parse(maxpersonas);
            }
            if (DateAntesDe == "")
            {
                filtro.fecha_antesde = null;
            }
            else if (DateAntesDe != "")
            {
                if (DateTime.Parse(DateAntesDe) < DateTime.Parse(DateDespuesDe))
                {
                    filtro.mensaje = "La fecha Antes de, debe ser mayor de   " + DateTime.Parse(DateDespuesDe).ToString("dd-MM-yyyy");
                }
                else
                {
                    filtro.mensaje       = " ";
                    filtro.fecha_antesde = DateTime.Parse(DateAntesDe);
                }
            }
            if (DateDespuesDe == "")
            {
                filtro.fecha_despuesde = null;
            }
            else if (DateDespuesDe != "")
            {
                if (DateTime.Parse(DateDespuesDe) < DateTime.Now)
                {
                    filtro.mensaje = "La fecha especificada debe ser después de     " + DateTime.Now.ToString("dd-MM-yyyy");
                }
                else
                {
                    filtro.mensaje         = " ";
                    filtro.fecha_despuesde = DateTime.Parse(DateDespuesDe);
                }
            }

            if (Zona.Equals("--Seleccione--"))
            {
                filtro.zona = null;
            }
            else if (Zona != "--Seleccione--")
            {
                filtro.zona = Zona;
            }
            if (Municipio.Equals("--Seleccione--"))
            {
                filtro.municipio = null;
            }
            else if (Municipio != "--Seleccione--")
            {
                filtro.municipio = Municipio;
            }
            if (Calificacion.Equals("--Seleccionar--"))
            {
                filtro.calificacion = null;
            }
            else if (Calificacion != "--Seleccione--")
            {
                filtro.calificacion = Calificacion;
            }
            if (Tipo.Equals("--Seleccionar--"))
            {
                filtro.tipo = null;
            }
            else if (Tipo != "--Seleccione--")
            {
                filtro.tipo = Tipo;
            }

            return(filtro);
        }
Exemple #7
0
 public List <UHabitacion> habitacionesHotel(UHotel idE, UFiltro consulta)
 {
     return(new DAOHabitacion().habitacionesHotel(idE, consulta));
 }
Exemple #8
0
 //tablas
 public List <UHotel> hotelesPrincipal(UFiltro consulta)
 {
     return(new DAOhotel().hotelesregistrados(consulta));
 }
Exemple #9
0
        //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);
                    }
                }
            }
        }
Exemple #10
0
        //lista de hoteles por usuario
        //(hoteles que se muestran en index)
        public List <UHotel> hotelesregistrados(UFiltro consulta)
        {
            int num = 0;

            if (consulta != null && consulta.numpersonas != null)
            {
                num = int.Parse((consulta.numpersonas).ToString());
            }

            if (consulta != null && (consulta.fecha_antesde != null && consulta.fecha_despuesde != null))
            {
                using (var db = new Mapeo())
                {
                    List <UHotel> elementos = (from h in db.hotel
                                               join hm in db.hotelmunicipio on h.Idmunicipio equals hm.Idmunicipio
                                               join hz in db.hotelzona on h.Idzona equals hz.Idzona
                                               //join rh in db.reserva on h.Idhotel equals rh.Idhotel

                                               select new
                    {
                        h,
                        hm,
                        hz,
                        //rh,
                    }).OrderBy(h => h.h.Nombre).ToList().Select(m => new UHotel
                    {
                        NumHabitDisponibles = ((db.habitacion.Where(x => x.Idhotel == m.h.Idhotel).Count()) - (db.reserva.Where(x => (x.Idhotel == m.h.Idhotel) &&
                                                                                                                                ((consulta.fecha_despuesde >= x.Fecha_llegada && consulta.fecha_despuesde <= x.Fecha_salida) || (consulta.fecha_antesde >= x.Fecha_salida && consulta.fecha_antesde <= x.Fecha_salida))).Count()) < 0 ? 0
                                                                        : (db.habitacion.Where(x => x.Idhotel == m.h.Idhotel).Count()) - (db.reserva.Where(x => (x.Idhotel == m.h.Idhotel) &&
                                                                                                                                                           ((consulta.fecha_despuesde >= x.Fecha_llegada && consulta.fecha_despuesde <= x.Fecha_salida) || (consulta.fecha_antesde >= x.Fecha_salida && consulta.fecha_antesde <= x.Fecha_salida))).Count())),

                        Promediocalificacion = m.h.Promediocalificacion,
                        Idhotel            = m.h.Idhotel,
                        Nombre             = m.h.Nombre,
                        Precionoche        = m.h.Precionoche,
                        PrecioNocheDoble   = m.h.PrecioNocheDoble,
                        PrecioNochePremium = m.h.PrecioNochePremium,
                        Imagen             = m.h.Imagen,
                        Municipio          = m.hm.Nombre,
                        Zona = m.hz.Nombre,
                        //Fecha_antesde = m.rh.Fecha_salida,
                        //Fecha_despuesde = m.rh.Fecha_llegada,
                    }).Where(x => x.NumHabitDisponibles > 0).ToList();
                    return(elementos);
                }
            }
            else
            {
                using (var db = new Mapeo())
                {
                    List <UHotel> elementos = (from h in db.hotel
                                               join hm in db.hotelmunicipio on h.Idmunicipio equals hm.Idmunicipio
                                               join hz in db.hotelzona on h.Idzona equals hz.Idzona

                                               //join rh in db.reserva on h.Idhotel equals rh.Idhotel
                                               //join hhab in db.habitacion on h.Idhotel equals hhab.Idhotel

                                               select new
                    {
                        h,
                        hm,
                        hz,
                    }).OrderBy(h => h.h.Nombre).ToList().Select(m => new UHotel
                    {
                        NumHabitDisponibles  = db.habitacion.Where(x => x.Idhotel == m.h.Idhotel).Count(),
                        Promediocalificacion = m.h.Promediocalificacion,
                        Idhotel            = m.h.Idhotel,
                        Nombre             = m.h.Nombre,
                        Precionoche        = m.h.Precionoche,
                        PrecioNocheDoble   = m.h.PrecioNocheDoble,
                        PrecioNochePremium = m.h.PrecioNochePremium,
                        Imagen             = m.h.Imagen,
                        Municipio          = m.hm.Nombre,
                        Zona           = m.hz.Nombre,
                        NumMaxPersonas = db.habitacion.Where(x => x.Numpersonas == num && x.Idhotel == m.h.Idhotel).Count() == 0 ? 0 : 1,
                    }).Where(x => num > 0 ? x.NumMaxPersonas > 0 : x.NumMaxPersonas == 0).ToList();
                    if (consulta == null)
                    {
                        return(elementos);
                    }

                    if (consulta.calificacion != null)
                    {
                        if (consulta.calificacion.Equals("--Seleccionar--"))
                        {
                            elementos = elementos.Where(x => (x.Promediocalificacion <= 5) || (x.Promediocalificacion == null)).ToList();//&& (x.Promediocalificacion == null)
                        }
                        else
                        {
                            elementos = elementos.Where(x => x.Promediocalificacion == (int.Parse(consulta.calificacion))).ToList();
                        }
                    }

                    if (consulta.nombrehotel != null)
                    {
                        elementos = elementos.Where(x => x.Nombre.ToUpper().Equals(consulta.nombrehotel)).ToList();
                    }
                    if (consulta.preciomin != null && consulta.preciomax != null)
                    {
                        if (consulta.tipo != null)
                        {
                            if (consulta.tipo.Equals("Basica"))
                            {
                                elementos = elementos.Where(x => (x.Precionoche <= consulta.preciomax && x.Precionoche >= consulta.preciomin)).ToList();
                            }
                            if (consulta.tipo.Equals("Doble"))
                            {
                                elementos = elementos.Where(x => (x.PrecioNocheDoble <= consulta.preciomax && x.PrecioNocheDoble >= consulta.preciomin)).ToList();
                            }
                            if (consulta.tipo.Equals("Premium"))
                            {
                                elementos = elementos.Where(x => (x.PrecioNochePremium <= consulta.preciomax && x.PrecioNochePremium >= consulta.preciomin)).ToList();
                            }
                        }
                        else if (consulta.tipo == null)
                        {
                            elementos = elementos.Where(x => x.Precionoche != null && x.Precionoche != null).ToList();
                        }
                    }
                    else
                    {
                        if (consulta.preciomax != null && consulta.preciomin == null)
                        {
                            elementos = elementos.Where(x => x.Precionoche <= consulta.preciomax).ToList();
                        }
                        if (consulta.preciomin != null && consulta.preciomax == null)
                        {
                            elementos = elementos.Where(x => x.Precionoche >= consulta.preciomin).ToList();
                        }
                    }
                    if (consulta.zona != null && consulta.municipio != null)
                    {
                        elementos = elementos.Where(x => (x.Municipio.Equals(consulta.municipio)) && (x.Zona.Equals(consulta.zona))).ToList();
                    }
                    else
                    {
                        if (consulta.municipio != null && consulta.zona == null)
                        {
                            elementos = elementos.Where(x => x.Municipio.Equals(consulta.municipio)).ToList();
                        }
                        else
                        if (consulta.zona != null && consulta.municipio == null)
                        {
                            elementos = elementos.Where(x => x.Zona.Equals(consulta.zona)).ToList();
                        }
                    }

                    return(elementos);
                }
            }
        }