public ActionResult Editar(int id) { ViewBag.lista = LlenarCombo(); VentaCLS oVentaCLS = new VentaCLS(); using (BuhoDBEntities db = new BuhoDBEntities()) { Ventas oVenta = db.Ventas.Where(p => p.ID_Venta.Equals(id)).First(); oVentaCLS.idVenta = id; oVentaCLS.idCliente = (int)oVenta.ID_Cliente; oVentaCLS.fecha = (DateTime)oVenta.Fecha; } return(View(oVentaCLS)); }
public ActionResult Editar(VentaCLS oVentaCLS) { if (!ModelState.IsValid) { ViewBag.lista = LlenarCombo(); return(View(oVentaCLS)); } using (BuhoDBEntities db = new BuhoDBEntities()) { Ventas oVenta = db.Ventas.Find(oVentaCLS.idVenta); oVenta.ID_Cliente = oVentaCLS.idCliente; oVenta.Fecha = oVentaCLS.fecha; db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Agregar(VentaCLS oVentaCLS) { if (!ModelState.IsValid) { ViewBag.lista = LlenarCombo(); return(View(oVentaCLS)); } else { using (BuhoDBEntities db = new BuhoDBEntities()) { Ventas oVenta = new Ventas(); oVenta.ID_Cliente = oVentaCLS.idCliente; oVenta.ID_Impuesto = 1; oVenta.Fecha = oVentaCLS.fecha; db.Ventas.Add(oVenta); db.SaveChanges(); } } return(RedirectToAction("Index")); }