using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using BookShopOnline.Bll;
using BookShopOnline.Model;

public partial class AddToShoppingCart : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int bookID = 0;
        if (!int.TryParse(PageHelper.GetUrlParmValue(UrlParmName.BookID), out bookID))
            return;

        InsertShoppingCart(bookID);
    }

    #region 加入购物车
    private void InsertShoppingCart(int bookID)
    {

        string cartGuid = WebTool.GetCartGuid();

        ShoppingCart shoppingCart = new ShoppingCart();
        shoppingCart.BookID =bookID;
        shoppingCart.CartGuid = cartGuid;
        shoppingCart.Quatity = 1;

        ShoppingCartBll shoppingCartBll = new ShoppingCartBll();
        shoppingCartBll.InsertShoppingCart(shoppingCart);

        Response.Redirect("~/ShowShoppingCart.aspx");
    }
    #endregion
}
