public ActionResult ProEditPost(int?id, DetalleCot mod) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } try { if (ModelState.IsValid) { var cant = mod.Cantidad; var fichaVeh = mod.FichaVehiculo; var valor = mod.Valor; var comen = mod.Comentario; DetalleCot detalleCot = DB.DetalleCot.Find(id); detalleCot.Cantidad = cant; detalleCot.FichaVehiculo = fichaVeh; detalleCot.Valor = valor; detalleCot.Comentario = comen; DB.SaveChanges(); return(RedirectToAction("ProductoFac", new { cotId = detalleCot.CotizacionId })); } } catch (RetryLimitExceededException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } return(View(mod)); }
public ActionResult DeleteProConfirmed(DetalleCot det) { try { var MId = det.DetalleCotId; DetalleCot detallecot = DB.DetalleCot.Find(MId); DB.DetalleCot.Remove(detallecot); DB.SaveChanges(); Decimal monto = DB.DetalleCot .Where(d => d.CotizacionId == MId) .Sum(m => m.Cantidad * m.Valor); Decimal itbis = monto * 0.18m; Cotizacion cotm = DB.Cotizacion.Find(MId); cotm.TotalFactura = monto; cotm.Itbis = itbis; DB.SaveChanges(); return(RedirectToAction("ProductoFac", new { cotId = detallecot.CotizacionId })); } catch (RetryLimitExceededException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. return(RedirectToAction("ProDelete", new { id = det.DetalleCotId, saveChangesError = true })); } }
// GET: Cliente/Edit/5 //[Authorize(Roles = "Admin, Usuario")] public ActionResult ProEdit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var detalleCot = new DetalleCot(); detalleCot = DB.DetalleCot.Find(id); if (detalleCot == null) { return(HttpNotFound()); } return(View(detalleCot)); }
public ActionResult ProductoFac(DetalleCotViewModel cot, int productoId) { try { if (ModelState.IsValid) { var cotId = cot.Cotizacion.CotizacionId; var prodId = productoId; var cant = cot.Cantidad; var ficVeh = cot.FichaVehiculo; var valor = cot.Valor; var comen = cot.Comentario; DetalleCot file = new DetalleCot(); file.CotizacionId = cotId; file.ProductoId = prodId; file.Cantidad = cant; file.FichaVehiculo = ficVeh; file.Valor = valor; file.Comentario = comen; DB.DetalleCot.Add(file); DB.SaveChanges(); Decimal monto = DB.DetalleCot .Where(d => d.CotizacionId == cotId) .Sum(m => m.Cantidad * m.Valor); Decimal itbis = monto * 0.18m; Cotizacion cotm = DB.Cotizacion.Find(cotId); cotm.TotalFactura = monto; cotm.Itbis = itbis; DB.SaveChanges(); TempData["Status"] = "Upload successful"; return(RedirectToAction("ProductoFac", new { cotId = file.CotizacionId })); } } catch (RetryLimitExceededException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(cot)); }