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")); } } }
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));; } }
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)); }
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 })); } } }
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)); }
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 })); }
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)); }
public void Delete(String id) { try { habitacion objH = db.habitacion.Find(id); db.habitacion.Remove(objH); db.SaveChanges(); } catch (Exception e) { throw e; } }
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)); }
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; } }
// 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)); }
// 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)); }
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); }
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")); } }
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; } }
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); }
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()); }
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 })); }
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; } }
public static bool Registrar(habitacion habitacion) { return(DAHabitacion.Registrar(habitacion)); }