Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            tbCarrito tbCarrito = db.tbCarrito.Find(id);

            db.tbCarrito.Remove(tbCarrito);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
 public ActionResult Edit([Bind(Include = "car_Id,clte_Id,prod_Id,car_FechaOrden,car_Cantidad")] tbCarrito tbCarrito)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbCarrito).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.clte_Id = new SelectList(db.tbCliente, "clte_Id", "clte_Identidad", tbCarrito.clte_Id);
     ViewBag.prod_Id = new SelectList(db.tbProducto, "prod_Id", "prod_Codigo", tbCarrito.prod_Id);
     return(View(tbCarrito));
 }
Пример #3
0
        public JsonResult FacturaCarrito(int id)
        {
            V_Usuarios           oUsuario           = (V_Usuarios)Session["User"];
            string               ErrorInsert        = "";
            IEnumerable <object> listFacturaCarrito = null;
            var consulta = (from fact in db.tbCarrito
                            where fact.clte_Id == oUsuario.clte_Id && fact.tbProducto.prod_Precio > 0
                            select new
            {
                prodprecio = fact.tbProducto.prod_Precio,
                cantidadProd = fact.car_Cantidad,
                prodId = fact.prod_Id
            }).ToList();
            tbCarrito carr = db.tbCarrito.Where(x => x.clte_Id == oUsuario.clte_Id).FirstOrDefault();


            foreach (var item in consulta)
            {
                try
                {
                    listFacturaCarrito = db.UDP_Vent_tbFacturaDetalle_Insert(5,
                                                                             item.prodId,
                                                                             item.cantidadProd,
                                                                             item.prodprecio,
                                                                             Convert.ToDecimal(item.cantidadProd * 0.15),
                                                                             0,
                                                                             3,
                                                                             DateTime.Now);

                    foreach (UDP_Vent_tbFacturaDetalle_Insert_Result res in listFacturaCarrito)
                    {
                        ErrorInsert = res.MensajeError;
                    }


                    if (ErrorInsert == "-1")
                    {
                        ModelState.AddModelError("", "No se pudo ingresar el registro, contacte al administrador.");
                        return(Json("error", JsonRequestBehavior.AllowGet));
                    }
                    if (carr != null)
                    {
                        db.tbCarrito.Remove(carr);
                        db.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                    ex.Message.ToString();
                }
            }
            return(Json("bien", JsonRequestBehavior.AllowGet));
        }
Пример #4
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbCarrito tbCarrito = db.tbCarrito.Find(id);

            if (tbCarrito == null)
            {
                return(HttpNotFound());
            }
            return(View(tbCarrito));
        }
Пример #5
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            tbCarrito tbCarrito = db.tbCarrito.Find(id);

            if (tbCarrito == null)
            {
                return(RedirectToAction("Index"));
            }
            ViewBag.clte_Id = new SelectList(db.tbCliente, "clte_Id", "clte_Identidad", tbCarrito.clte_Id);
            ViewBag.prod_Id = new SelectList(db.tbProducto, "prod_Id", "prod_Codigo", tbCarrito.prod_Id);
            return(View(tbCarrito));
        }
Пример #6
0
        public ActionResult Create([Bind(Include = "car_Id,clte_Id,prod_Id,car_FechaOrden,car_Cantidad")] tbCarrito tbCarrito, int?id)
        {
            V_Usuarios oUsuario = (V_Usuarios)Session["User"];

            tbCarrito.clte_Id        = oUsuario.clte_Id;
            tbCarrito.car_FechaOrden = DateTime.Now;
            tbCarrito.prod_Id        = id;
            tbCarrito.car_Cantidad   = 1;
            if (ModelState.IsValid)
            {
                db.tbCarrito.Add(tbCarrito);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(tbCarrito));
        }