欢迎来到天天文库
浏览记录
ID:62981409
大小:959.00 KB
页数:17页
时间:2021-07-23
《最新cookies购物车类.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、精品资料cookies购物车类........................................精品资料cookies购物车类........................................精品资料cookies购物车类........................................精品资料publicstaticDataTableGetShoppingCart(){ DataTabledt=newDataTable();if(HttpContext.Current.Request.Cookies["S
2、hoppingCart"]!=null&&HttpContext.Current.Request.Cookies["ShoppingCart"].Value.Trim()!=""){HttpCookieoCookie=(HttpCookie)HttpContext.Current.Request.Cookies["ShoppingCart"];oCookie.Expires=DateTime.Now.AddYears(3);stringShoppingCartStr=oCookie.Value.ToString();//HttpContext.Curr
3、ent.Response.Write(ShoppingCartStr);........................................精品资料string[]arrCookie=ShoppingCartStr.Split(newchar[]{','});//查看cookie中是否有该产品stringnewCookie="";for(inti=0;i4、':'));}newCookie=newCookie.Substring(1);dt=Product.GetProductByProductIds(newCookie,-1);dt.Columns.Add("Quantity");dt.Columns.Add("Box");foreach(DataRowrowindt.Rows){........................................精品资料for(inti=0;i5、ookie[i].IndexOf(':'))==row["ProductId"].ToString()){row["Quantity"]=arrCookie[i].Substring(arrCookie[i].IndexOf(":")+1);row["Quantity"]=row["Quantity"].ToString().Remove(row["Quantity"].ToString().IndexOf(":"));stringBox=arrCookie[i].Substring(arrCookie[i].LastIndexOf(":")+1);i6、f(Box=="1")row["Box"]=true;else........................................精品资料row["Box"]=false;}}}}else{dt=Database.GetDataTable("selecttop0*fromView_ProductList");dt.Columns.Add("Quantity");}returndt;}}//如果没有该产品if(!bExists)........................................精品资料{oCookie.Value7、=oCookie.Value+","+ProductID.ToString()+":"+Quantity.ToString()+":"+Box.ToString();}else{oCookie.Value=newCookie.Substring(1);}HttpContext.Current.Response.Cookies.Add(oCookie);HttpContext.Current.Response.Write("ShoppingCart:"+HttpContext.Current.Request.Cookies["ShoppingCart"]8、.Value);}}.....................................
4、':'));}newCookie=newCookie.Substring(1);dt=Product.GetProductByProductIds(newCookie,-1);dt.Columns.Add("Quantity");dt.Columns.Add("Box");foreach(DataRowrowindt.Rows){........................................精品资料for(inti=0;i5、ookie[i].IndexOf(':'))==row["ProductId"].ToString()){row["Quantity"]=arrCookie[i].Substring(arrCookie[i].IndexOf(":")+1);row["Quantity"]=row["Quantity"].ToString().Remove(row["Quantity"].ToString().IndexOf(":"));stringBox=arrCookie[i].Substring(arrCookie[i].LastIndexOf(":")+1);i6、f(Box=="1")row["Box"]=true;else........................................精品资料row["Box"]=false;}}}}else{dt=Database.GetDataTable("selecttop0*fromView_ProductList");dt.Columns.Add("Quantity");}returndt;}}//如果没有该产品if(!bExists)........................................精品资料{oCookie.Value7、=oCookie.Value+","+ProductID.ToString()+":"+Quantity.ToString()+":"+Box.ToString();}else{oCookie.Value=newCookie.Substring(1);}HttpContext.Current.Response.Cookies.Add(oCookie);HttpContext.Current.Response.Write("ShoppingCart:"+HttpContext.Current.Request.Cookies["ShoppingCart"]8、.Value);}}.....................................
5、ookie[i].IndexOf(':'))==row["ProductId"].ToString()){row["Quantity"]=arrCookie[i].Substring(arrCookie[i].IndexOf(":")+1);row["Quantity"]=row["Quantity"].ToString().Remove(row["Quantity"].ToString().IndexOf(":"));stringBox=arrCookie[i].Substring(arrCookie[i].LastIndexOf(":")+1);i
6、f(Box=="1")row["Box"]=true;else........................................精品资料row["Box"]=false;}}}}else{dt=Database.GetDataTable("selecttop0*fromView_ProductList");dt.Columns.Add("Quantity");}returndt;}}//如果没有该产品if(!bExists)........................................精品资料{oCookie.Value
7、=oCookie.Value+","+ProductID.ToString()+":"+Quantity.ToString()+":"+Box.ToString();}else{oCookie.Value=newCookie.Substring(1);}HttpContext.Current.Response.Cookies.Add(oCookie);HttpContext.Current.Response.Write("ShoppingCart:"+HttpContext.Current.Request.Cookies["ShoppingCart"]
8、.Value);}}.....................................
此文档下载收益归作者所有