Exemplo n.º 1
0
    /// <summary>
    /// 结算生成订单
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCheckOut_Click(object sender, EventArgs e)
    {
        ShoppingManager manager = new ShoppingManager(Session["Cart"], Session["CurrentUser"]);

        if (manager.ShoppingItems.Count == 0)
        {
            Page.RegisterClientScriptBlock("", "<script>alert('您的购物车为空,请先将图书放入购物车!');document.location='BookList.aspx';</script>");
            return;
        }
        if (manager.User == null)
        {
            Page.RegisterClientScriptBlock("", "<script>alert('登陆超时,请重新登陆!');document.location='Login.aspx';</script>");
            return;
        }
        manager.MakeOrder();
        Session.Remove("Cart");
        Page.RegisterClientScriptBlock("", "<script>alert('结算成功,请等待审批订单!');document.location='BookList.aspx';</script>");
    }
        /// <summary>
        /// 提交订单
        /// </summary>
        /// <returns></returns>
        public ActionResult Submit()
        {
            ShoppingManager manager = new ShoppingManager(Session["Cart"], Session["CurrentUser"]);

            if (manager.ShoppingItems.Count == 0)
            {
                return(Content("<script>alert('您的购物车为空,请先将图书放入购物车!!');document.location='" + Url.Action("Index", "Home") + "';</script>"));
            }
            if (manager.User == null)
            {
                return(Content("<script>alert('登录超时,请重新登录!');document.location='" + Url.Action("Login", "Account") + "';</script>"));
            }



            manager.MakeOrder();
            Session.Remove("Cart");
            return(Content("<script>alert('结算成功,请等待审批订单!!');document.location='" + Url.Action("Index", "Home") + "';</script>"));
        }