protected void btnCart_Click(object sender, EventArgs e) { if (Session["uid"] == null) { Response.Redirect("/login.aspx"); } int userid = (int)Session["uid"]; CartModel cart = new CartModel(); cart.user.id = userid; BookOrderModel bookOrder = new BookOrderModel(); bookOrder.quantity = int.Parse(txtNum.Text); bookOrder.price = BookOnThisPage.price; bookOrder.book = BookOnThisPage; if (CartBLL.AddBookToCart(cart, bookOrder) > 0) { Modal.Show(this, "已添加到购物车"); } }