Exemplo n.º 1
0
        //delete user product
        public ActionResult deleteCart(int?id)
        {
            MemberShop memsp = db.MemberShops.Find(id);

            db.MemberShops.Remove(memsp);
            Product proaa = db.Products.Find(memsp.productId);

            proaa.productStore += (int)memsp.shopNumber;

            db.SaveChanges();
            return(RedirectToAction("cart"));
        }
Exemplo n.º 2
0
        //use to chang shop number and chage product store
        public ActionResult changeProductNumber(int?id, int?shopNumber)
        {
            Session["errorShop"] = "";
            MemberShop memsp   = db.MemberShops.Find(id);
            Product    product = db.Products.Find(memsp.productId);

            product.productStore -= ((int)shopNumber - (int)memsp.shopNumber);
            if (product.productStore >= 0)
            {
                memsp.shopNumber = shopNumber;
                memsp.totalMoney = shopNumber * product.productPrice;

                db.SaveChanges();
                return(RedirectToAction("cart"));
            }
            Session["errorShop"] = "庫存不足";
            return(RedirectToAction("cart"));
        }
Exemplo n.º 3
0
        public ActionResult productDetail(int productId, int shopNumber, int productStore, int id, int totalMoney)
        {
            if (shopNumber != 0 && shopNumber <= productStore)
            {
                Product product_Strore = db.Products.Find(id);
                product_Strore.productStore -= shopNumber;
                MemberShop memShop = new MemberShop();
                memShop.memberId     = (int)Session["memberId"];
                memShop.productId    = productId;
                memShop.payState     = "未結帳";
                memShop.shopNumber   = shopNumber;
                memShop.shopDate     = DateTime.Now.ToString("yyyy/MM/dd");
                memShop.memberShopID = DateTime.Now.ToString("yyyyMMdd") + String.Format("{0:00}", Session["memberId"]);
                memShop.totalMoney   = totalMoney * shopNumber;
                db.MemberShops.Add(memShop);
                db.SaveChanges();;
                return(RedirectToAction("convertProduct"));
            }
            Session["errorShop"] = "不能為0或大於庫存量";
            ;
            Product pro = db.Products.Find(id);

            return(View(pro));
        }