// GET: hojaRutas/Edit/5 public ActionResult Edit(int?id) { if (Session["Login"] == null) { return(RedirectToAction("Login", "Home")); } else { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } hojaRuta hojaRuta = db.hojaRuta.Find(id); if (hojaRuta == null) { return(HttpNotFound()); } TempData["id"] = id; ViewBag.patente = new SelectList(db.vehiculo, "patente", "patente", hojaRuta.patente); ViewBag.patente = new SelectList(db.vehiculo, "patente", "descripcion", hojaRuta.patente); return(RedirectToAction("Index", "costosHojaRutas")); } }
// GET: hojaRutas/Details/5 public ActionResult AddDatos(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } hojaRuta hojaRuta = db.hojaRuta.Find(id); if (hojaRuta == null) { return(HttpNotFound()); } TempData["id"] = id; return(RedirectToAction("Create", "colaboradorHojaRutas")); }
public ActionResult Finalizar() { if (Session["Login"] == null) { return(RedirectToAction("Login", "Home")); } else { int id = Convert.ToInt32(TempData["id"]); TempData["id"] = id; hojaRuta hojaRuta = db.hojaRuta.Find(id); hojaRuta.estado = false; hojaRuta.fechaModificacion = DateTime.Now; db.SaveChanges(); TempData["Alerta"] = "Hoja de Ruta Cerrada"; return(RedirectToAction("Index", "hojaRutas")); } }
public JsonResult GuardarColaboradorHojaRutaInDatabase(HojaRutaViewModel model) { var result = false; try { if (model.idHojaRuta > 0) { hojaRuta hoja = db.hojaRuta.SingleOrDefault(s => s.idHojaRuta == model.idHojaRuta); hoja.patente = model.patente; hoja.fechaModificacion = DateTime.Now; db.SaveChanges(); result = true; } else { fechaTramo fecha = new fechaTramo(); fecha.fechaIngreso = 20181128; fecha.dia = 28; fecha.mes = 11; fecha.anio = 2018; fecha.semestre = "2"; fecha.trimestre = "3"; fecha.cuatrimestre = "3"; hojaRuta hoja = new hojaRuta(); hoja.fechaCreacion = DateTime.Now; hoja.fechaIngreso = fecha.fechaIngreso; hoja.patente = model.patente; hoja.estado = "1"; db.hojaRuta.Add(hoja); db.SaveChanges(); result = true; } } catch (Exception ex) { throw ex; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult AddChofer(int?id) { if (Session["Login"] == null) { return(RedirectToAction("Login", "Home")); } else { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } hojaRuta hojaRuta = db.hojaRuta.Find(id); if (hojaRuta == null) { return(HttpNotFound()); } TempData["id"] = id; TempData["cargo"] = "Chofer"; return(RedirectToAction("Index", "colaboradorHojaRutas")); } }
public ActionResult Edit([Bind(Include = "idHojaRuta,patente,fechaCreacion,fechaModificacion,estado")] hojaRuta hojaRuta) { int ids = Convert.ToInt32(TempData["id"]); TempData["id"] = ids; if (Session["Login"] == null) { return(RedirectToAction("Login", "Home")); } else { if (ModelState.IsValid) { db.Entry(hojaRuta).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.patente = new SelectList(db.vehiculo, "patente", "descripcion", hojaRuta.patente); ViewBag.patente = new SelectList(db.vehiculo, "patente", "descripcion", hojaRuta.patente); return(View(hojaRuta)); } }
public ActionResult Create([Bind(Include = "patente")] hojaRuta hojaRuta) { if (Session["Login"] == null) { return(RedirectToAction("Login", "Home")); } else { if (ModelState.IsValid) { hojaRuta.fechaCreacion = DateTime.Now; hojaRuta.estado = true; hojaRuta.usuarioID = Convert.ToInt32(Session["usuarioID"]); db.hojaRuta.Add(hojaRuta); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.patente = new SelectList(db.vehiculo, "patente", "descripcion", hojaRuta.patente); ViewBag.patente = new SelectList(db.vehiculo, "patente", "descripcion", hojaRuta.patente); return(View(hojaRuta)); } }