Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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"));
        }
Exemplo n.º 3
0
 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"));
 }