public ActionResult DeleteConfirmed(int id) { tb_ventas tb_ventas = db.tb_ventas.Find(id); db.tb_ventas.Remove(tb_ventas); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "id_ventas,venta_total")] tb_ventas tb_ventas) { if (ModelState.IsValid) { db.Entry(tb_ventas).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tb_ventas)); }
public ActionResult Create([Bind(Include = "id_ventas,venta_total")] tb_ventas tb_ventas) { if (ModelState.IsValid) { db.tb_ventas.Add(tb_ventas); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tb_ventas)); }
// GET: ventas/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tb_ventas tb_ventas = db.tb_ventas.Find(id); if (tb_ventas == null) { return(HttpNotFound()); } return(View(tb_ventas)); }
public ActionResult ventaProductos([Bind(Include = "id_productos,producto_nombre,producto_precio,producto_cantidad,producto_descripcion,id_proveedor")] tb_productos tb_productos, int cantidadProducto, int precioVenta) { if (ModelState.IsValid) { tb_ventas ventas = new tb_ventas(); ventas.id_ventas++; ventas.venta_total = precioVenta; db.tb_ventas.Add(ventas); tb_productos.producto_cantidad = tb_productos.producto_cantidad - cantidadProducto; db.Entry(tb_productos).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.id_proveedor = new SelectList(db.tb_proveedores, "id_proveedor", "nombre_proveedor", tb_productos.id_proveedor); return(View(tb_productos)); }