protected void btnAltaAlojamiento_Click(object sender, EventArgs e)
        {
            string      tipo     = drpTipo.SelectedItem.Text;
            string      ciudad   = txtCiudad.Text;
            string      barrio   = txtBarrio.Text;
            string      dirL1    = txtDirL1.Text;
            string      dirL2    = txtDirL2.Text;
            DateTime    fechaIni = calFechaIni.SelectedDate;
            DateTime    fechaFin = calFechaFin.SelectedDate;
            decimal     precio   = Convert.ToDecimal(txtPrecio.Text);
            RangoPrecio unR      = new RangoPrecio {
                Id = 1, Fecha_inicio = fechaIni, Fecha_fin = fechaFin, Variacion_precio = precio
            };
            Alojamiento unA = new Alojamiento
            {
                Id        = 0,
                Tipo      = tipo,
                Ubicacion = new Ubicacion {
                    Id = 1, Barrio = barrio, Ciudad = ciudad, DireccionLinea1 = dirL1, DireccionLinea2 = dirL2
                },
                Precios_temporada = new List <RangoPrecio>()
            };

            unA.Precios_temporada.Add(unR);
            if (unA.Add())
            {
                lblMensaje.Text = "EXITO";
            }
            else
            {
                lblMensaje.Text = "ERROR";
            }
            //IRepositorioAlojamientos unRepo = FabricaReposBienvenidosUY.CrearRepositorioAlojamiento();
        }
        public List <RangoPrecio> FindAll()
        {
            string             cadenaFindAll = "SELECT id ,fecha_ini, fecha_fin, variacion_precio FROM RangoPrecio";
            List <RangoPrecio> listaRangos   = new List <RangoPrecio>();

            using (SqlConnection cn = BdSQL.Conectar())
            {
                using (SqlCommand cmd = new SqlCommand(cadenaFindAll, cn))
                {
                    cn.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader != null)
                    {
                        while (reader.Read())
                        {
                            RangoPrecio unRP = new RangoPrecio();
                            unRP.Load(reader);
                            if (unRP.Validar())
                            {
                                listaRangos.Add(unRP);
                            }
                        }
                    }
                }
            }
            return(listaRangos);
        }
Exemplo n.º 3
0
        public ActionResult Delete(string Id)
        {
            var RangoPrecio = new RangoPrecio();

            RangoPrecio.DeleteRangoPrecio(int.Parse(Id));

            return(RedirectToAction("Index"));
        }
        public Alojamiento FindById(int id)
        {
            string cadenaFind = "SELECT Alojamiento.*, Ubicacion.ciudad, Ubicacion.barrio, Ubicacion.dirLinea1, Ubicacion.dirLinea2 FROM Alojamiento, Ubicacion WHERE Alojamiento.idUbicacion = Ubicacion.id AND Alojamiento.id = @id";

            SqlConnection      cn = BdSQL.Conectar();
            List <RangoPrecio> precios_temporada = new List <RangoPrecio>();
            Alojamiento        unA = null;

            try
            {
                SqlCommand cmd = new SqlCommand(cadenaFind, cn);
                cmd.Parameters.AddWithValue("@id", id);
                cn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                //traigo alojamiento
                if (reader != null && reader.Read())
                {
                    unA = new Alojamiento();
                    unA.Load(reader);
                    unA.Id        = id;
                    unA.Ubicacion = new Ubicacion
                    {
                        Id              = Convert.ToInt32(reader["idUbicacion"].ToString()),
                        Ciudad          = reader["ciudad"].ToString(),
                        Barrio          = reader["barrio"].ToString(),
                        DireccionLinea1 = reader["dirLinea1"].ToString(),
                        DireccionLinea2 = reader["dirLinea2"].ToString()
                    };
                }
                reader.Close();
                //Cargo los elementos de la lista de rango precios
                cmd.CommandText = "SELECT * FROM RangoPrecio WHERE id_alojamiento = @id";
                reader          = cmd.ExecuteReader();
                while (reader.Read())
                {
                    RangoPrecio unR = new RangoPrecio();
                    unA.loadRangoPrecio(unR, reader);
                    precios_temporada.Add(unR);
                }
                unA.Precios_temporada = precios_temporada;
                reader.Close();
                return(unA);
            }
            catch (Exception ex)
            {
                //mostrar exception
                BdSQL.LoguearError(ex.Message + "No se pudo cargar el Alojamiento");
                unA.Precios_temporada = null;
                return(unA = null);
            }
            finally
            {
                cn.Close();
                cn.Dispose();
            }
        }
Exemplo n.º 5
0
        public ActionResult Edit(string Id)
        {
            var Restaurante = new Restaurante();
            var model       = new RestauranteViewModel();

            var TipoRestaurante = new TipoRestaurante().SelectTipoRestaurantes();
            var RangoPrecio     = new RangoPrecio().SelectRangoPrecios();
            var Ciudad          = new Ciudad().SelectCiudades();

            List <SelectListItem> TipoRestaurantes = new List <SelectListItem>();

            foreach (var item in TipoRestaurante)
            {
                TipoRestaurantes.Add(new SelectListItem {
                    Text = item.Nombre, Value = item.Id.ToString()
                });
            }

            List <SelectListItem> RangoPrecios = new List <SelectListItem>();

            foreach (var item in RangoPrecio)
            {
                RangoPrecios.Add(new SelectListItem {
                    Text = item.Nombre, Value = item.Id.ToString()
                });
            }

            List <SelectListItem> Ciudades = new List <SelectListItem>();

            foreach (var item in Ciudad)
            {
                Ciudades.Add(new SelectListItem {
                    Text = item.Nombre, Value = item.Id.ToString()
                });
            }

            ViewBag.TipoRestaurantes = TipoRestaurantes;
            ViewBag.RangoPrecios     = RangoPrecios;
            ViewBag.Ciudades         = Ciudades;

            Restaurante = Restaurante.SelectRestaurante(int.Parse(Id));

            model.Id                = Restaurante.Id;
            model.Nombre            = Restaurante.Nombre;
            model.IdTipoRestaurante = Restaurante.IdTipoRestaurante;
            model.Valoracion        = Restaurante.Valoracion;
            model.IdRangoPrecio     = Restaurante.IdRangoPrecio;
            model.Direccion         = Restaurante.Direccion;
            model.IdCiudad          = Restaurante.IdCiudad;
            model.Telefono          = Restaurante.Telefono;
            model.LatitudGps        = Restaurante.LatitudGps;
            model.LongitudGps       = Restaurante.LongitudGps;

            return(View(model));
        }
Exemplo n.º 6
0
        public ActionResult Edit(RangoPrecioViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var RangoPrecio = new RangoPrecio();

            RangoPrecio.UpdateRangoPrecio(model.Id, model.Nombre, model.PrecioMayor, model.PrecioMenor, model.PrecioMedio);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 7
0
        protected void btnBuscarRP_Click(object sender, EventArgs e)
        {
            IRepositorioRangoPrecios repoRango = FabricaReposBienvenidosUY.CrearRepositorioRangoPrecio();
            int         id = Convert.ToInt32(txtRP.Text);
            RangoPrecio rp = repoRango.FindById(id);

            if (rp != null)
            {
                this.lblRangoPrecio.Text = rp.ToString();
            }
            else
            {
                this.lblRangoPrecio.Text = "No hay organizaciones para mostrar.";
            }
        }
Exemplo n.º 8
0
        public ActionResult Edit(string Id)
        {
            var RangoPrecio = new RangoPrecio();
            var model       = new RangoPrecioViewModel();

            RangoPrecio = RangoPrecio.SelectRangoPrecio(int.Parse(Id));

            model.Id          = RangoPrecio.Id;
            model.Nombre      = RangoPrecio.Nombre;
            model.PrecioMayor = RangoPrecio.PrecioMayor;
            model.PrecioMedio = RangoPrecio.PrecioMedio;
            model.PrecioMenor = RangoPrecio.PrecioMenor;

            return(View(model));
        }
Exemplo n.º 9
0
        public ActionResult New(RestauranteViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var TipoRestaurante = new TipoRestaurante().SelectTipoRestaurantes();
                var RangoPrecio     = new RangoPrecio().SelectRangoPrecios();
                var Ciudad          = new Ciudad().SelectCiudades();

                List <SelectListItem> TipoRestaurantes = new List <SelectListItem>();
                foreach (var item in TipoRestaurante)
                {
                    TipoRestaurantes.Add(new SelectListItem {
                        Text = item.Nombre, Value = item.Id.ToString()
                    });
                }

                List <SelectListItem> RangoPrecios = new List <SelectListItem>();
                foreach (var item in RangoPrecio)
                {
                    RangoPrecios.Add(new SelectListItem {
                        Text = item.Nombre, Value = item.Id.ToString()
                    });
                }

                List <SelectListItem> Ciudades = new List <SelectListItem>();
                foreach (var item in Ciudad)
                {
                    Ciudades.Add(new SelectListItem {
                        Text = item.Nombre, Value = item.Id.ToString()
                    });
                }

                ViewBag.TipoRestaurantes = TipoRestaurantes;
                ViewBag.RangoPrecios     = RangoPrecios;
                ViewBag.Ciudades         = Ciudades;

                return(View(model));
            }

            var Restaurante = new Restaurante();

            Restaurante.InsertRestaurante(model.Nombre, model.IdTipoRestaurante, model.IdRangoPrecio, model.Direccion, model.IdCiudad, model.Telefono, model.LatitudGps, model.LongitudGps);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 10
0
        public ActionResult New()
        {
            var TipoRestaurante = new TipoRestaurante().SelectTipoRestaurantes();
            var RangoPrecio     = new RangoPrecio().SelectRangoPrecios();
            var Ciudad          = new Ciudad().SelectCiudades();

            List <SelectListItem> TipoRestaurantes = new List <SelectListItem>();

            foreach (var item in TipoRestaurante)
            {
                TipoRestaurantes.Add(new SelectListItem {
                    Text = item.Nombre, Value = item.Id.ToString()
                });
            }

            List <SelectListItem> RangoPrecios = new List <SelectListItem>();

            foreach (var item in RangoPrecio)
            {
                RangoPrecios.Add(new SelectListItem {
                    Text = item.Nombre, Value = item.Id.ToString()
                });
            }

            List <SelectListItem> Ciudades = new List <SelectListItem>();

            foreach (var item in Ciudad)
            {
                Ciudades.Add(new SelectListItem {
                    Text = item.Nombre, Value = item.Id.ToString()
                });
            }

            ViewBag.TipoRestaurantes = TipoRestaurantes;
            ViewBag.RangoPrecios     = RangoPrecios;
            ViewBag.Ciudades         = Ciudades;

            return(View());
        }
        public RangoPrecio FindById(int id)
        {
            string      cadenaFind = "SELECT fecha_ini, fecha_fin, variacion_precio FROM RangoPrecio WHERE id = @id";
            RangoPrecio unRP       = null;

            using (SqlConnection cn = BdSQL.Conectar())
            {
                using (SqlCommand cmd = new SqlCommand(cadenaFind, cn))
                {
                    cmd.Parameters.AddWithValue("@id", id);
                    cn.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader != null && reader.Read())
                    {
                        unRP = new RangoPrecio();
                        unRP.Load(reader);
                        unRP.Id = id;
                    }
                }
            }
            return(unRP);
        }
        public Habitacion FindById(int id)
        {
            string             cadenaFind        = "SELECT id,banio_privado,camas,cupo_max,precio_base FROM Habitacion WHERE id=@id";
            Habitacion         h                 = null;
            Alojamiento        a                 = null;
            Servicio           s                 = null;
            List <Servicio>    listaServicios    = new List <Servicio>();
            List <RangoPrecio> precios_temporada = new List <RangoPrecio>();

            using (SqlConnection cn = BdSQL.Conectar())
            {
                using (SqlCommand cmd = new SqlCommand(cadenaFind, cn))
                {
                    cmd.Parameters.AddWithValue("@id", id);
                    cn.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader != null && reader.Read())
                    {
                        // cargo la habitacion
                        h = new Habitacion();
                        h.Load(reader);
                        reader.Close();

                        //cargo los  servicios
                        //cmd.CommandText = "SELECT id_servicio FROM ServiciosHabitacion WHERE id_habitacion=@id";

                        cmd.CommandText = "SELECT Servicio.* FROM ServiciosHabitacion, Servicio WHERE ServiciosHabitacion.id_habitacion = @id AND Servicio.id = ServiciosHabitacion.id_servicio";
                        reader          = cmd.ExecuteReader();
                        if (reader != null)
                        {
                            while (reader.Read())
                            {
                                s = new Servicio();
                                s.Load(reader);
                                listaServicios.Add(s);
                            }
                        }
                        h.Servicios = listaServicios;
                        reader.Close();

                        //cargo el id del alojamiento para esa habitacion
                        cmd.CommandText = "SELECT Habitacion.id_alojamiento FROM Habitacion WHERE Habitacion.id=@id";
                        reader          = cmd.ExecuteReader();
                        int idAlo = 0;
                        if (reader != null && reader.Read())
                        {
                            idAlo = Convert.ToInt32(reader["id_alojamiento"].ToString());
                        }
                        reader.Close();

                        //cargo todos los datos simples del alojamiento sin el rango precio
                        cmd.CommandText = "SELECT Alojamiento.*, Ubicacion.ciudad, Ubicacion.id as idubi, Ubicacion.barrio, Ubicacion.dirLinea1, Ubicacion.dirLinea2 FROM Alojamiento, Ubicacion WHERE Alojamiento.idUbicacion = Ubicacion.id AND Alojamiento.id = @id";
                        cmd.Parameters.Clear();
                        cmd.Parameters.AddWithValue("@id", idAlo);
                        reader = cmd.ExecuteReader();
                        if (reader != null && reader.Read())
                        {
                            a = new Alojamiento();
                            a.Load(reader);
                            a.Id        = idAlo;
                            a.Ubicacion = new Ubicacion
                            {
                                Id              = Convert.ToInt32(reader["idubi"].ToString()),
                                Ciudad          = reader["ciudad"].ToString(),
                                Barrio          = reader["barrio"].ToString(),
                                DireccionLinea1 = reader["dirLinea1"].ToString(),
                                DireccionLinea2 = reader["dirLinea2"].ToString()
                            };
                        }
                        reader.Close();
                        //Cargo los elementos de la lista de rango precios al alojamiento
                        cmd.CommandText = "SELECT * FROM RangoPrecio WHERE id_alojamiento = @id";
                        reader          = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            RangoPrecio unR = new RangoPrecio();
                            a.loadRangoPrecio(unR, reader);
                            precios_temporada.Add(unR);
                        }
                        a.Precios_temporada = precios_temporada;
                        h.Alojamiento       = a;
                        reader.Close();
                    }
                }
            }
            return(h);
        }
 public bool Update(RangoPrecio obj)
 {
     return(obj != null && obj.Update());
 }
        public bool Delete(int id)
        {
            RangoPrecio rp = this.FindById(id);

            return(rp != null && rp.Delete());
        }
 public bool Add(RangoPrecio obj)
 {
     return(obj != null && obj.Add());
 }
Exemplo n.º 16
0
        public void Delete(string Id)
        {
            var RangoPrecio = new RangoPrecio();

            RangoPrecio.DeleteRangoPrecio(int.Parse(Id));
        }