コード例 #1
0
    protected void imgBuyProduct_Click(object sender, ImageClickEventArgs e)
    {
        if (subTool.CheckUserLogin("-1"))
        {
            int        userID = WebUnitily.CheckInt(mycookie.getCookiesValue("shop8517User", "userID"));
            L_CartInfo cInfo  = new L_CartInfo();
            cInfo.UserID    = userID;
            cInfo.CartID    = userID.ToString() + DateTime.Now.ToString("yyyyMMddmm");
            cInfo.ProductID = WebUnitily.CheckInt(ViewState["PID"]);
            cInfo.BugNum    = WebUnitily.CheckInt(txtBuyNum.Text);
            cInfo.bugTime   = DateTime.Now;

            if (cInfo.ProductID == 0)
            {
                Response.Write("你需要加入购物车的商品不存在,请您检查!!");
                Response.End();
            }
            if (cInfo.BugNum == 0)
            {
                Response.Write("请检查你要购买的商品数!");
                Response.End();
            }

            int exresult = cartinfo.addCart(cInfo);
            switch (exresult)
            {
            case 20:
                Response.Write("<script>alert('商品添加购物车成功');</script>");
                Server.Transfer("../orderinfo/UserCard.aspx");
                break;

            case 10:
                Response.Write("<script>alert('商品添加收藏夹成功');</script>");
                Server.Transfer("../orderinfo/UserCard.aspx");
                break;

            default:
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", WebUnitily.AlertUrl("加入购物车失败,请您检查"));
                break;
            }
        }
    }
コード例 #2
0
ファイル: AddCart.aspx.cs プロジェクト: kent10636/E-Commerce
    private void userAddCart()
    {
        L_CartInfo cInfo = new L_CartInfo();

        cInfo.UserID    = userID;
        cInfo.CartID    = userID.ToString() + DateTime.Now.ToString("yyyyMMddmm");
        cInfo.ProductID = WebUnitily.CheckInt(Request.Form["PId"]);
        cInfo.BugNum    = WebUnitily.CheckInt(Request.Form["BuyNum"]);
        cInfo.bugTime   = DateTime.Now;

        if (cInfo.ProductID == 0)
        {
            Response.Write("-1");
            Response.End();
        }
        if (cInfo.BugNum == 0)
        {
            Response.Write("-1");
            Response.End();
        }

        int extResult = cartinfo.addCart(cInfo);

        switch (extResult)
        {
        case 20:
            Response.Write("产品已经在购物车中");
            Response.End();
            break;

        case 10:
            Response.Write("产品加入购物车成功");
            Response.End();
            break;

        default:
            Response.Write("加入购物车失败");
            Response.End();
            break;
        }
    }