public ActionResult DeleteConfirmed(int id) { ProductoLote productoLote = db.ProductoLote.Find(id); db.ProductoLote.Remove(productoLote); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ProductoLoteId,ProductoId,Cantidad,Costo,Fecha")] ProductoLote productoLote) { if (ModelState.IsValid) { db.Entry(productoLote).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductoId = new SelectList(db.Productos, "ProductoId", "Producto", productoLote.ProductoId); return(View(productoLote)); }
// GET: ProductoLotes/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductoLote productoLote = db.ProductoLote.Find(id); if (productoLote == null) { return(HttpNotFound()); } return(View(productoLote)); }
// GET: ProductoLotes/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductoLote productoLote = db.ProductoLote.Find(id); if (productoLote == null) { return(HttpNotFound()); } ViewBag.ProductoId = new SelectList(db.Productos, "ProductoId", "Producto", productoLote.ProductoId); return(View(productoLote)); }
public ActionResult GuardarMovimiento([Bind(Include = "MovimientoId,Fecha,ProductoLoteId,cantidad,Total")] Movimientos movimientos) { string mensaje = ""; if (ModelState.IsValid) { try { ProductoLote ProductoLotes = db.ProductoLote.Find(movimientos.ProductoLoteId); movimientos.Fecha = DateTime.Now; db.Movimientos.Add(movimientos); //db.SaveChanges(); ProductoLotes.Cantidad = ProductoLotes.Cantidad - movimientos.cantidad; db.Entry(ProductoLotes).State = EntityState.Modified; db.SaveChanges(); mensaje = "guardado"; return(Json(mensaje, JsonRequestBehavior.AllowGet));; } catch (DbEntityValidationException dbEx) { string[] ErrorMessages = new string[dbEx.EntityValidationErrors.Count() + 1]; var x = 0; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); ErrorMessages[x] = string.Format("Property: {0} Error: {1}$", validationError.PropertyName, validationError.ErrorMessage); x++; } } string errores = ""; foreach (var error in ErrorMessages) { errores += error; } TempData["ErrorMessages"] = errores; return(RedirectToAction("DBSaveError", "Messages")); } } return(Json(mensaje, JsonRequestBehavior.AllowGet)); }
public ActionResult Cancelar(int id) { Movimientos movimiento = db.Movimientos.Where(m => m.MovimientoId == id).First(); if (movimiento != null) { ProductoLote productoLote = db.ProductoLote.Find(movimiento.ProductoLoteId); db.Movimientos.Remove(movimiento); productoLote.Cantidad = productoLote.Cantidad + movimiento.cantidad; db.Entry(productoLote).State = EntityState.Modified; db.SaveChanges(); ViewBag.ProductoId = new SelectList(db.Productos, "ProductoId", "Producto"); return(View("~/Views/Movimientos/ListaMovimientos.cshtml", db.Movimientos.ToList())); } var movimientos = db.Movimientos.Include(m => m.ProductoLote); ViewBag.ProductoId = new SelectList(db.Productos, "ProductoId", "Producto"); return(View("~/Views/Movimientos/ListaMovimientos.cshtml", movimientos.ToList())); }