//加载购物车中所有的信息 private void LoadAllCartInfo(List<Model.Cart> listCart) { if (Session["userInfo"] != null) { Model.Users user = Session["userInfo"] as Model.Users; //BLL.CartBll cartBll = new BLL.CartBll(); listCart.AddRange(cartBll.GetModelList2("UserId = " + user.Id)); } else { HttpCookie cookie = Request.Cookies["ShoppingCart"]; if (cookie != null) { BLL.BooksBll bookBll = new BooksBll(); foreach (string item in cookie.Values) { string itemValue = cookie.Values[item]; string[] cartInfo = itemValue.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); listCart.Add(new Model.Cart() { Book = bookBll.GetModel(Convert.ToInt32(cartInfo[0])), Count = Convert.ToInt32(cartInfo[1]) }); } } } }