Esempio n. 1
0
        public ActionResult Create([Bind(Include = "IdCategoria,Categoria1")] Categoria categoria)
        {
            if (ModelState.IsValid)
            {
                db.Categoria.Add(categoria);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(categoria));
        }
        public RedirectToRouteResult Create([Bind(Include = "IdCliente,Rut,Nombres,ApPaterno,ApMaterno,Telefono,User,Pass,fechaNacimiento")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                db.Cliente.Add(cliente);
                db.SaveChanges();
                return(RedirectToAction("Index", "Login"));
            }

            return(RedirectToAction("Create"));
        }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "IdProducto,IdBoleta,IdCategoria,Foto,NombreProd,Marca,Stock,Precio,Descripcion,Eliminado")] Producto producto)
        {
            if (ModelState.IsValid)
            {
                db.Producto.Add(producto);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(producto));
        }
        public ActionResult agregar(Producto imgModel)
        {
            string fileName  = Path.GetFileNameWithoutExtension(imgModel.ImgFile.FileName);
            string extension = Path.GetExtension(imgModel.ImgFile.FileName);

            fileName      = fileName + DateTime.Now.ToString("yymmssfff") + extension;
            imgModel.Foto = "~/Imagenes/" + fileName;

            fileName = Path.Combine(Server.MapPath("~/Imagenes/"), fileName);
            imgModel.ImgFile.SaveAs(fileName);
            {
                db.Producto.Add(imgModel);
                db.SaveChanges();
            }
            ModelState.Clear();
            return(RedirectToAction("Index"));;
        }
Esempio n. 5
0
        //public JsonResult anularCompra(int id)
        //{
        //    Boleta bol = new Boleta();

        //    bol = db.Boleta.Where(i => i.IdBoleta == id).First();

        //    WebClient wc = new WebClient();
        //    NameValueCollection nvc = new NameValueCollection();
        //    nvc.Add("apikey", apik);
        //    nvc.Add("descripcion", "Anular Compra Barcode");
        //    nvc.Add("idPedido", "10");
        //    nvc.Add("idCuenta", bol.cuentaPago.ToString());
        //    nvc.Add("monto", bol.Total.ToString());

        //    byte[] result = wc.UploadValues(urlbase + "Anular", nvc);
        //    string JsonResult = Encoding.UTF8.GetString(result);
        //    RespuestaAnulacion ra = JsonConvert.DeserializeObject<RespuestaAnulacion>(JsonResult);
        //    return Json(ra, JsonRequestBehavior.AllowGet);
        //}

        public ActionResult anularCompra(int id)
        {
            Boleta bol = new Boleta();

            bol = db.Boleta.Where(i => i.IdBoleta == id).First();

            WebClient           wc  = new WebClient();
            NameValueCollection nvc = new NameValueCollection();

            nvc.Add("apikey", apik);
            nvc.Add("descripcion", "Anular Compra Barcode");
            nvc.Add("idPedido", "10");
            nvc.Add("idCuenta", bol.cuentaPago.ToString());
            nvc.Add("monto", bol.Total.ToString());

            byte[]             result     = wc.UploadValues(urlbase + "Anular", nvc);
            string             JsonResult = Encoding.UTF8.GetString(result);
            RespuestaAnulacion ra         = JsonConvert.DeserializeObject <RespuestaAnulacion>(JsonResult);

            //return Json(ra, JsonRequestBehavior.AllowGet);

            ViewBag.respuesta = ra.mensaje.ToString();

            List <Detalle> det = new List <Detalle>();

            foreach (Detalle d in db.Detalle.Where(b => b.idDetalle == id).ToList())
            {
                Producto pro = db.Producto.Where(i => i.IdProducto == d.IdProducto).FirstOrDefault();
                pro.Stock = (pro.Stock + d.Cantidad);
                db.SaveChanges();
            }

            bol.estado = 0;
            db.SaveChanges();

            ViewBag.venta = id;

            return(View(ViewBag));
        }
Esempio n. 6
0
        public ActionResult PagoOk()
        {
            carro = Session["carro"] as List <Carrito>;


            Cliente cli = new Cliente();

            cli = Session["Usuario"] as Cliente;



            int total    = 0;
            int idBoleta = 0;

            //Boleta bol = new Boleta();

            foreach (var x in carro)
            {
                total += (x.PrecioUnitario * x.Cantidad);
            }



            using (barCodePruebaEntities Context = new barCodePruebaEntities())
            {
                //Context.Proveedores.Add(entity);
                //Context.SaveChanges();

                Boleta bol = new Boleta();

                bol.IdCliente  = cli.IdCliente;
                bol.Total      = total;
                bol.Fecha      = DateTime.Now.ToString("dd-MM-yyyy");
                bol.estado     = 1;
                bol.cuentaPago = int.Parse(Session["NCuenta"].ToString());
                Context.Boleta.Add(bol);
                Context.SaveChanges();
                idBoleta = bol.IdBoleta;
            }



            foreach (var x in carro)
            {
                Producto pro = new Producto();
                pro       = db.Producto.Where(i => i.IdProducto == x.IdProducto).FirstOrDefault();
                pro.Stock = pro.Stock - x.Cantidad;
                db.SaveChanges();

                Detalle det = new Detalle();
                det.idDetalle  = idBoleta;
                det.Cantidad   = x.Cantidad;
                det.Total      = (x.PrecioUnitario * x.Cantidad);
                det.IdProducto = x.IdProducto;
                db.Detalle.Add(det);
                db.SaveChanges();
            }


            Session["carro"]   = null;
            Session["NCuenta"] = null;


            return(View());
        }