/// <summary> /// 获取产品Quantity /// </summary> /// <returns></returns> protected int GetProductCount() { UserInfo user = Session["user"] as UserInfo; if (user != null) { return(CartTempService.GetProductCount(user.id)); } return(0); }
/// <summary> /// 获取购物车产品Quantity /// </summary> /// <returns></returns> protected string GetCarTotal() { StringBuilder sb = new StringBuilder(); UserInfo user = Session["user"] as UserInfo; if (user != null) { int count = CartTempService.GetProductCount(user.id); if (count > 0) { sb.Append("<span class=\"num totleNum\" id=\"carttotal\">" + count + "</span>"); } else { sb.Append("<span class=\"num hideNum\" id=\"carttotal\"></span>"); } } else { List <CartTemp> list = Session["nologinCart"] as List <CartTemp>; if (list != null) { int count = list.Count; if (count > 0) { int total = 0; foreach (CartTemp ct in list) { total += ct.productCount; } sb.Append("<span class=\"num totleNum\" id=\"carttotal\">" + total + "</span>"); } else { sb.Append("<span class=\"num\" id=\"carttotal\"></span>"); } } else { sb.Append("<span class=\"\" id=\"carttotal\"></span>"); } } return(sb.ToString()); }