Exemplo n.º 1
0
        public ActionResult Editar(int id)
        {
            using (hotelesEntidad db = new hotelesEntidad())
            {
                try
                {
                    string[]       lista  = Listado.getListado();
                    List <Listado> clases = new List <Listado>();

                    for (int i = 0; i < lista.Length; i++)
                    {
                        Listado item = new Listado();
                        item.id     = i;
                        item.nombre = lista[i];
                        clases.Add(item);
                    }
                    ViewData["listaClases"] = clases;
                    habitacion h = db.habitacion.Find(id);
                    return(View(h));
                }
                catch (Exception e)
                {
                    TempData["Mensaje"] = new Mensajes()
                    {
                        Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al editar esta habitación."
                    };
                    return(RedirectToAction("Inicio"));
                }
            }
        }
Exemplo n.º 2
0
        public ActionResult Agregar(int id)
        {
            try
            {
                string[]       lista  = Listado.getListado();
                List <Listado> clases = new List <Listado>();

                for (int i = 0; i < lista.Length; i++)
                {
                    Listado item = new Listado();
                    item.id     = i;
                    item.nombre = lista[i];
                    clases.Add(item);
                }
                ViewData["listaClases"] = clases;
                habitacion hab = new habitacion();
                hab.hotel_id = id;
                return(View(hab));
            }
            catch (Exception e)
            {
                TempData["Mensaje"] = new Mensajes()
                {
                    Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al agregar la habitación."
                };
                return(RedirectToAction("Ver", "Hotel", id));;
            }
        }
Exemplo n.º 3
0
 public ActionResult Eliminar(int id)
 {
     using (hotelesEntidad db = new hotelesEntidad())
     {
         if (!ModelState.IsValid)
         {
             return(View());
         }
         try
         {
             habitacion h = db.habitacion.Find(id);
             db.habitacion.Remove(h);
             db.SaveChanges();
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-success", Titulo = "Perfecto!", Mensaje = "La categoria fue eliminada."
             };
             return(RedirectToAction("Ver", "Hotel", new { id = h.hotel_id }));
         }
         catch (Exception e)
         {
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al agregar la categoria."
             };
             return(RedirectToAction("Inicio", "Hotel"));
         }
     }
 }
        public async Task <IActionResult> Edit(int id, [Bind("Id,piso,nHabitacion,tipo,detalles,disponible")] habitacion habitacion)
        {
            var registros_afectados =
                await _context.Database.ExecuteSqlCommandAsync(
                    "UPDATE habitacions SET piso = 2, nHabitacion = 201 Where Id = @id",
                    new SqlParameter("@Id", id));

            if (id != habitacion.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(habitacion);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!habitacionExists(habitacion.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(habitacion));
        }
Exemplo n.º 5
0
 public ActionResult Editar(habitacion h)
 {
     using (hotelesEntidad db = new hotelesEntidad())
     {
         if (!ModelState.IsValid)
         {
             return(View());
         }
         try
         {
             habitacion hab = db.habitacion.Find(h.id);
             hab.codigo = h.codigo.ToUpper();
             hab.precio = h.precio;
             hab.clase  = h.clase;
             db.SaveChanges();
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-success", Titulo = "Perfecto!", Mensaje = "La habitación fue actualizada."
             };
             return(RedirectToAction("Ver", "Hotel", new { id = h.hotel_id }));
         }
         catch (Exception e)
         {
             TempData["Mensaje"] = new Mensajes()
             {
                 Clase = "alert-danger", Titulo = "Error!", Mensaje = "Error al editar la habitación."
             };
             return(RedirectToAction("Ver", "Hotel", new { id = h.hotel_id }));
         }
     }
 }
Exemplo n.º 6
0
        public ActionResult DeleteConfirmed(int id)//METODO Q ES LLAMADO CUANDO SE CONFIRMA LA ELIMINACION
        {
            habitacion habitacion = db.habitacion.Find(id);

            db.habitacion.Remove(habitacion);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Index(_HabitacionArray habitacion)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();

            //numero = db.numerohabitaciones;
            int tam = int.Parse(habitacion.tam);

            for (int i = 0; i < tam; i++)
            {
                habitacion hab = new habitacion();

                hab.numero         = habitacion.h[i].numero;
                hab.tipo           = habitacion.h[i].tipo;
                hab.disponibilidad = true;
                hab.precio         = habitacion.h[i].precio;
                try
                {
                    db.habitacions.InsertOnSubmit(hab);
                    db.SubmitChanges();
                }
                catch (Exception)
                {
                    //this.ValidateRequest = false;
                    ModelState.AddModelError("", "El número de la habitacion ya existe");
                    var q = from tip in db.tip_habs
                            select new SelectListItem {
                        Selected = false, Text = tip.tipo, Value = tip.id.ToString()
                    };
                    var ha = from habi in db.habitacions
                             select new SelectListItem {
                        Selected = false, Text = habi.numero.ToString(), Value = habi.numero.ToString()
                    };
                    SelectListItem[] listaOpciones = new SelectListItem[10];
                    for (int j = 0; j < 10; j++)
                    {
                        listaOpciones[j] = new SelectListItem()
                        {
                            Text = (j + 1).ToString(), Value = (j + 1).ToString(), Selected = false
                        }
                    }
                    ;

                    //SelectListItem []listaOpciones=new SelectListItem            ViewBag.t = tipos;
                    ViewBag.x   = (from k in db.habitacions select k).Take(10).ToList();
                    ViewBag.t   = q.ToArray();
                    ViewBag.t2  = listaOpciones;
                    ViewBag.hab = ha.ToArray();
                    return(View(habitacion));
                }
                ViewBag.x = (from k in db.habitacions select k).Take(10).ToList();
            }

            //return n(new Object());
            return(RedirectToAction("Index", "Habitacion"));
        }
        public async Task <IActionResult> Create([Bind("Id,piso,nHabitacion,tipo,detalles,disponible")] habitacion habitacion)
        {
            if (ModelState.IsValid)
            {
                _context.Add(habitacion);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(habitacion));
        }
Exemplo n.º 9
0
 public ActionResult Edit([Bind(Include = "id,hab_codigo,hab_descripcion,hab_fotop,hab_precio,tih_id")] habitacion habitacion)
 {//CUANDO YA SE CONFIRMÓ LA EDICION DEL REGISTRO
     if (ModelState.IsValid)
     {
         db.Entry(habitacion).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.tih_id = new SelectList(db.tipo_habitacion, "id", "tih_codigo", habitacion.tih_id);
     return(View(habitacion));
 }
        public JsonResult DeleteHab(int id)
        {
            //string _num= new string numero;
            //Guid _idRol = new Guid(idRol);
            //Guid _idUser = new Guid(idUser);
            DataClasses1DataContext db = new DataClasses1DataContext();
            habitacion num             = db.habitacions.Where(a => a.numero == id).First();

            db.habitacions.DeleteOnSubmit(num);
            db.SubmitChanges();
            return(Json(new { success = true }));
        }
Exemplo n.º 11
0
        public ActionResult Create([Bind(Include = "id,hab_codigo,hab_descripcion,hab_fotop,hab_precio,tih_id")] habitacion habitacion)
        {//CUANDO SE CONFIRMA EL NUEVO REGISTRO
            if (ModelState.IsValid)
            {
                db.habitacion.Add(habitacion);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.tih_id = new SelectList(db.tipo_habitacion, "id", "tih_codigo", habitacion.tih_id);
            return(View(habitacion));
        }
Exemplo n.º 12
0
 public void Delete(String id)
 {
     try
     {
         habitacion objH = db.habitacion.Find(id);
         db.habitacion.Remove(objH);
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 13
0
        public ActionResult Delete(int?id) //METODO QUE BUSCA UN REGISTRO Y MUESTRA EN LA VISTA BORRAR
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            habitacion habitacion = db.habitacion.Find(id);

            if (habitacion == null)
            {
                return(HttpNotFound());
            }
            return(View(habitacion));
        }
Exemplo n.º 14
0
 public void Estado(String id, String estado)
 {
     try
     {
         habitacion objH = db.habitacion.Find(id);
         objH.estado_habi     = estado;
         db.Entry(objH).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 15
0
        // GET: habitacions/Details/5
        public ActionResult Details(int?id) //METODO PARA ACCEDER AL DETALLE DEL REGISTRO(HABTIACION)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            habitacion habitacion = db.habitacion.Find(id);

            if (habitacion == null)
            {
                return(HttpNotFound());
            }
            return(View(habitacion));
        }
Exemplo n.º 16
0
        // GET: habitacions/Edit/5
        public ActionResult Edit(int?id) //METODO QUE BUSCA UN ID Y MUESTRA EN EL FORMULARIO EDITAR
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            habitacion habitacion = db.habitacion.Find(id);

            if (habitacion == null)
            {
                return(HttpNotFound());
            }
            ViewBag.tih_id = new SelectList(db.tipo_habitacion, "id", "tih_codigo", habitacion.tih_id);
            return(View(habitacion));
        }
Exemplo n.º 17
0
        static public bool Registrar(habitacion habitacion)
        {
            bool exito = true;

            try
            {
                using (var data = new ViajaMasEntities())
                {
                    data.habitacion.Add(habitacion);
                    data.SaveChanges();
                }
            }
            catch
            {
                exito = false;
            }

            return(exito);
        }
Exemplo n.º 18
0
        public ActionResult codigoExistente(string codigo, int id)
        {
            habitacion hab = null;

            using (hotelesEntidad db = new hotelesEntidad())
            {
                try {
                    hab = (from c in db.habitacion where c.codigo == codigo select c).First();
                }catch (Exception e) { }
            }
            if (hab.codigo == codigo && id != hab.id)
            {
                return(Content("false"));
            }
            else
            {
                return(Content("true"));
            }
        }
Exemplo n.º 19
0
 public void Update(Habitacion h)
 {
     try
     {
         habitacion objH = new habitacion()
         {
             num_habi    = h.num_habi,
             desc_habi   = h.desc_habi,
             precio_habi = h.precio_habi,
             cat_id      = h.cat_id,
             id_piso     = h.id_piso,
             img_habi    = h.img_habi,
             estado_habi = h.estado_habi,
         };
         db.Entry(objH).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 20
0
        public Habitacion Find(String id)
        {
            Habitacion h = new Habitacion();

            try
            {
                habitacion objH = db.habitacion.Find(id);
                h.num_habi    = objH.num_habi;
                h.desc_habi   = objH.desc_habi;
                h.precio_habi = objH.precio_habi;
                h.cat_id      = objH.cat_id;
                h.id_piso     = objH.id_piso;
                h.img_habi    = objH.img_habi;
                h.estado_habi = objH.estado_habi;
            }

            catch (Exception e)
            {
                throw e;
            }
            return(h);
        }
Exemplo n.º 21
0
        public ActionResult RegistroHabitacion(Habitaciones newhabitacion)
        {
            if (ModelState.IsValid)
            {
                DataClasses1DataContext db = new DataClasses1DataContext();
                this.ViewBag.hab = db.tipos.Select(a => new SelectListItem()
                {
                    Selected = false, Value = a.id.ToString(), Text = a.nombre + " Precio: " + Convert.ToInt16(a.precio)
                }).ToList();


                habitacion hab = new habitacion();
                //tipo ti = new tipo();
                hab.estado = "libre";
                hab.numero = newhabitacion.numero.ToString();
                hab.idTip  = Convert.ToInt32(newhabitacion.idTipo);
                db.habitacions.InsertOnSubmit(hab);
                db.SubmitChanges();
            }
            //  return Redirect("../RegistroHabitacion");
            return(View());
        }
Exemplo n.º 22
0
        public JsonResult Grabar(int id_habitacion, int id_hotel, int capacidad, float precio, string tipo_Habitacion, string estado)
        {
            habitacion habi  = new habitacion();
            bool       exito = true;

            habi.id_hotel        = id_hotel;
            habi.capacidad       = capacidad;
            habi.precio          = precio;
            habi.tipo_Habitacion = tipo_Habitacion;
            habi.estado          = estado;

            if (id_habitacion == -1)
            {
                exito = BLHabitacion.Registrar(habi);
            }
            else
            {
                habi.id_habitacion = id_habitacion;
                //exito = BLEmpresa.Actualizar(empre);
            }

            return(Json(new { success = exito }));
        }
Exemplo n.º 23
0
        public Habitacion Insert(Habitacion h)
        {
            try
            {
                habitacion objH = new habitacion();
                objH.num_habi    = h.num_habi;
                objH.desc_habi   = h.desc_habi;
                objH.precio_habi = h.precio_habi;
                objH.cat_id      = h.cat_id;
                objH.id_piso     = h.id_piso;
                objH.img_habi    = h.img_habi;
                objH.estado_habi = h.estado_habi;

                objH.categoria_habitacion = db.categoria_habitacion.Find(objH.cat_id);
                objH.piso = db.piso.Find(objH.id_piso);
                db.habitacion.Add(objH);
                db.SaveChanges();
                return(h);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 24
0
 public static bool Registrar(habitacion habitacion)
 {
     return(DAHabitacion.Registrar(habitacion));
 }