public ActionResult EditProcesar(Anticipos anticipo) { var anticip = db.Anticipos.Where(a => a.IdAnticipo == anticipo.IdAnticipo).Include(a => a.Viaje).Include(a => a.ConceptosAdicionales).SingleOrDefault(); anticip.Observaciones = anticipo.Observaciones; anticip.FechaMod = DateTime.Now; anticip.UsuarioMod = GetUserId(User); db.Entry(anticip).State = EntityState.Modified; db.SaveChanges(); ViewBag.Porcentaje = new List <SelectListItem>() { new SelectListItem() { Text = "25%", Value = "25" }, new SelectListItem() { Text = "50%", Value = "50" }, new SelectListItem() { Text = "75%", Value = "75" }, new SelectListItem() { Text = "100%", Value = "100" } }; return(View("AprobarDenegar", anticip)); }
public ActionResult DeleteConfirmed(int id) { Anticipos anticipos = db.Anticipos.Find(id); anticipos.FechaMod = DateTime.Now; anticipos.UsuarioMod = GetUserId(User); anticipos.Eliminado = true; db.Entry(anticipos).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Gestionar", "viajes", new { id = anticipos.IdViaje })); }
public ActionResult Create([Bind(Include = "IdAnticipo,Porcentaje,TotalAnticipar,TotalAdicionales,TotalAsignado,TasaCambioApp,IdEstado,IdViaje,UsuarioCrea,UsuarioMod,FechaCrea,FechaMod,Eliminado")] Anticipos anticipos) { if (ModelState.IsValid) { db.Anticipos.Add(anticipos); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IdViaje = new SelectList(db.Viajes, "IdViaje", "Viaje", anticipos.IdViaje); return(View(anticipos)); }
private void conceptosDeAnticiposToolStripMenuItem_Click(object sender, EventArgs e) { if (Application.OpenForms["Anticipos"] != null) { Application.OpenForms["Anticipos"].Activate(); } else { Anticipos frm = new Anticipos(); frm.MdiParent = this; frm.Show(); } }
// GET: Anticipos/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Anticipos anticipos = db.Anticipos.Find(id); if (anticipos == null) { return(HttpNotFound()); } return(View(anticipos)); }
// GET: Anticipos/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Anticipos anticipos = db.Anticipos.Find(id); if (anticipos == null) { return(HttpNotFound()); } ViewBag.IdViaje = new SelectList(db.Viajes, "IdViaje", "Viaje", anticipos.IdViaje); return(View(anticipos)); }
public ActionResult Edit(Anticipos anticipos) { if (ModelState.IsValid) { var anticipo = db.Anticipos.Find(anticipos.IdAnticipo); anticipo.Porcentaje = anticipos.Porcentaje; anticipo.UsuarioMod = GetUserId(User); anticipo.FechaMod = DateTime.Now; anticipo.TotalAnticipar = anticipo.TotalViaje * (anticipo.Porcentaje / 100.00); db.Entry(anticipo).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { idViaje = anticipo.IdViaje })); } ViewBag.IdViaje = new SelectList(db.Viajes, "IdViaje", "Viaje", anticipos.IdViaje); return(View(anticipos)); }
// GET: Anticipos public ActionResult Index(int?idViaje) { if (idViaje == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var idusuario = GetUserId(User); ViewBag.usuario = db.Users.Where(u => u.Id == idusuario).SingleOrDefault(); var anticipos = db.Anticipos.Where(a => a.IdViaje == idViaje && a.Eliminado != true).Include(a => a.Viaje.Usuario.Pais.Moneda).Include(a => a.ConceptosAdicionales); ViewBag.Porcentaje = new List <SelectListItem>() { new SelectListItem() { Text = "25%", Value = "25" }, new SelectListItem() { Text = "50%", Value = "50" }, new SelectListItem() { Text = "75%", Value = "75" }, new SelectListItem() { Text = "100%", Value = "100" } }; if (anticipos.ToList().Count() > 0) { return(View(anticipos.FirstOrDefault())); } var liquidacion = db.LiquidacionesViaje.Where(a => a.IdViaje == idViaje && a.Eliminado != true); if (liquidacion.ToList().Count() > 0) { Session["MyAlert"] = "<script type='text/javascript'>alertify.error('No se puede crear un anticipo porque ya hay una liquidación pendiente.');</script>"; return(RedirectToAction("Gestionar", "Viajes", new { id = idViaje })); } else { Anticipos anticipo = new Anticipos(); anticipo.Eliminado = false; anticipo.FechaCrea = DateTime.Now; anticipo.UsuarioCrea = GetUserId(User); anticipo.IdViaje = (int)idViaje; anticipo.IdEstado = Estado.Creado; var anticiposCorrelativo = db.Anticipos.Where(ac => ac.Viaje.Usuario.Id == anticipo.UsuarioCrea).ToList().AsReadOnly(); var corre = "00000" + (anticiposCorrelativo.Count() + 1); anticipo.NoSolicitud = corre.Substring(corre.Length - 5, 5); var use = db.Users.Where(u => u.Id == anticipo.UsuarioCrea).Include(u => u.Departamento).SingleOrDefault(); anticipo.UsuarioAutoriza = use.Departamento.IdPersonaACargo; var viaje = db.Viajes.Find(idViaje); anticipo.Porcentaje = 100; anticipo.TasaCambioApp = 0; anticipo.TotalAdicionales = 0; anticipo.TotalAsignado = totalAsignado(viaje.IdPaisOrigen, viaje.IdPaisDestino, use.Cargo, viaje.ClasificacionViaje) * viaje.Duracion; anticipo.TotalViaje = anticipo.TotalAsignado; anticipo.TotalAnticipar = anticipo.TotalViaje * (anticipo.Porcentaje / 100.00); db.Entry(anticipo).State = EntityState.Added; db.SaveChanges(); anticipos = db.Anticipos.Where(a => a.IdViaje == idViaje && a.Eliminado != true).Include(a => a.Viaje.Usuario.Pais.Moneda).Include(a => a.ConceptosAdicionales); Session["MyAlert"] = "<script type='text/javascript'>alertify.success('Se ha creado la solicitud exitosamente.');</script>"; return(View(anticipos.FirstOrDefault())); } }