예제 #1
0
        public void addProd()
        {
            string       ts        = "加入购物车失败";
            ShoppingCart shopcCart = new ShoppingCart();

            shopcCart.ProCode    = Request["codes"];
            shopcCart.Qty        = Convert.ToInt32(Request["num"]);
            shopcCart.CusId      = Convert.ToInt32(Session["cusId"]);
            shopcCart.CreateTime = DateTime.Now;
            shopcCart.checks     = 0;
            var shca = ShopCartService.GetEntities(n => n.CusId == shopcCart.CusId && n.ProCode == shopcCart.ProCode);

            if (shca.Count() > 0)
            {
                if (shca.First().Qty + shopcCart.Qty >= 5)
                {
                    ts = "购物车内该物品数量已达到上限";
                    return;
                }
                shopcCart.Qty += shca.First().Qty;
                if (ShopCartService.Add(shopcCart))
                {
                    ts = "加入购物车成功";
                }
            }
            else if (ShopCartService.Add(shopcCart))
            {
                ts = "加入购物车成功";
            }
            Response.ContentType = "text/plain";
            Response.Write(ts);
            Response.End();
        }
예제 #2
0
        /// <summary>
        /// 插入购物车
        /// </summary>
        /// <returns></returns>
        public ActionResult InsertShopCart()
        {
            string id    = Request["id"];
            string price = Request["price"];
            string cid   = Session["cid"].ToString();
            int    num   = Convert.ToInt32(Request["num"]);
            Guid   g     = System.Guid.NewGuid();
            //把传过来的商品信息和用户信息添加到数据库
            ShoppongCart shoppongCart = new ShoppongCart
            {
                Id         = g,
                Cid        = cid,
                Pcode      = id,
                num        = num,
                Price      = Convert.ToDecimal(price),
                Totale     = Convert.ToDecimal(price) * num,
                IsCheck    = 0,
                CreateTime = DateTime.Now
            };

            if (ShopCartService.Add(shoppongCart))
            {
                return(Content("完成添加"));
            }
            else
            {
                return(Content("未完成添加"));
            }
        }
예제 #3
0
        }                                                    //商品信息表
        public ActionResult Index()
        {
            //查看购物车
            var ShopCartResult = ShopCartService.GetEntities(x => true);

            ViewBag.ShopCart    = ShopCartResult.ToList();
            ViewBag.ProductInfo = ProductService;
            return(View());
        }
예제 #4
0
        public ActionResult UpdateShopCart1(string pcode)
        {
            string cid   = Session["cid"].ToString();
            var    shop1 = ShopCartService.GetEntity(x => x.Cid == cid && x.Pcode == pcode);

            shop1.IsCheck = 0;
            bool a = ShopCartService.Modify(shop1);

            return(View());
        }
예제 #5
0
        public ActionResult DeleteFrist()
        {
            //删除单条购物车
            ShopCart sc = new ShopCart()
            {
                ScartId = int.Parse(Request["CartId"]),
            };

            ShopCartService.Remove(sc);
            return(RedirectToAction("Index"));
        }
예제 #6
0
        // GET: Order
        public ActionResult Index(int num = 0)
        {
            orderViewModel.ProNum = num;
            var pro = ShopCartService.GetEntities(n => n.checks == 1);

            orderViewModel.ShoppingCarts = ShopCartService.GetEntities(n => n.checks == 1);
            orderViewModel.Addrresses    = AddrressService.GetEntity(n => n.State == 1);
            foreach (var ppp in pro)
            {
                orderViewModel.price += ppp.Qty * ppp.Product.SellPrice;
            }
            return(View(orderViewModel));
        }
예제 #7
0
        }                                                    //收藏
        // GET: ShopCart
        public ActionResult ShopCart()
        {
            //获取购物车信息
            string cid          = Session["cid"].ToString();
            var    shoppongCart = ShopCartService.GetEntities(x => x.Cid == cid);

            ViewBag.shopCart = shoppongCart.ToList();
            //把商品的信息传入前台供查询
            // var pro = proService.GetEntity(x => x.Code == "E00100010001");
            //  ViewBag.pro1 = pro.Name;
            ViewBag.pro = proService;
            //把规格的信息传入前台
            ViewBag.Speci = specificationService;
            return(View());
        }
예제 #8
0
        // GET: Order
        public ActionResult Index()
        {
            string[] id = Request["id"].Split(',');//
            foreach (var item in id)
            {
                var shopOrder = ShopCartService.GetEntities(x => x.Cid == item);
            }
            ViewBag.id              = id;
            ViewBag.pro             = proService;
            ViewBag.shopcartService = ShopCartService;
            OAuthUserInfo userInfo = Session["userInfo"] as OAuthUserInfo;                               //获取用户的信息
            string        cid      = userInfo.openid;                                                    //获取用户的openid
            var           address  = addressService.GetEntity(x => x.IsDefault == true && x.cid == cid); //查找出关于用户的默认收货底座

            ViewBag.name    = address.name;                                                              //把收货人传到前台
            ViewBag.address = address.address1;                                                          //把收货地址传到前台
            ViewBag.tel     = address.tel;
            return(View());
        }
예제 #9
0
        public void addorder()
        {
            var          ts        = 0;
            var          Num       = Convert.ToInt32(Request["proNum"]);
            var          Code      = Request["proCode"].ToString();
            ShoppingCart shopcCart = new ShoppingCart();

            shopcCart.ProCode    = Code;
            shopcCart.Qty        = Num;
            shopcCart.CusId      = Convert.ToInt32(Session["cusId"]);
            shopcCart.CreateTime = DateTime.Now;
            shopcCart.checks     = 1;
            if (Num > ProductService.GetEntity(n => n.Code == Code).Stock.QTY)
            {
                ts = 2000;
            }
            var shca = ShopCartService.GetEntities(n => n.CusId == shopcCart.CusId && n.ProCode == shopcCart.ProCode);

            if (shca.Count() > 0)
            {
                if (ShopCartService.Add(shopcCart))
                {
                    ts = shca.First().Qty;
                }
                else
                {
                    ts = 2000;
                }
            }
            else if (ShopCartService.Add(shopcCart))
            {
                ts = 0;
            }
            else
            {
                ts = 2000;
            }
            Response.ContentType = "text/plain";
            Response.Write(ts);
            Response.End();
        }
예제 #10
0
        public void addOrder()
        {
            var aa = "200";

            var pink = 0;
            var memo = Request["Memo"];

            if (memo == "")
            {
                memo = null;
            }
            var pro = ShopCartService.GetEntities(n => n.checks == 1);

            orderViewModel.Addrresses = AddrressService.GetEntity(n => n.State == 1);
            foreach (var ppp in pro)
            {
                orderViewModel.price += ppp.Qty * ppp.Product.SellPrice;
            }
            int cusid = Convert.ToInt32(Session["cusId"]);

            foreach (var od in pro)
            {
                if (od.Product.IsPinkage)
                {
                    pink = 10;
                    break;
                }
            }
            var code = cusid + DateTime.Now.Year.ToString().Substring(2, 2) + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + pro.First().ProCode.Substring(12, 2);
            var sql  = $"exec addOrder '{code}',{cusid},'{"待付款"}',{orderViewModel.price},{pink},'{memo}'";
            var nums = pro.Count() * 2 + 1;

            if (OrddeService.QueryBySql(sql) == nums)
            {
                aa = code;
            }
            Response.ContentType = "text/plain";
            Response.Write(aa);
            Response.End();
        }