用来实现购物车的,看不懂,能不能帮我解释解释~~~~~
public void cookies()
{
string cooki = Request.Cookies["Fbus"] == null ? "" : Request.Cookies["Fbus"].Value.Substring(1, Request.Cookies["Fbus"].Value.Length - 1);
string str;
if (cooki == "")
{
str = "select * from goods where id=-1";
}
else
{ str = "select * from goods where id in(" + cooki + ")"; }
rpcookie.DataSource = Sqlbase.ExecuteTable(CommandType.Text, str, null);
rpcookie.DataBind();
}
protected void lbdel_Command(object sender, CommandEventArgs e)
{
string ids = e.CommandArgument.ToString();
string str = Request.Cookies["Fbus"] == null ? "" : Request.Cookies["Fbus"].Value;
if (!str.Contains(ids))
{
}
else
{
if (str.Substring(1).Contains(","))
{
str = str.Replace("," + ids, "");
Response.Cookies.Add(new HttpCookie("Fbus", str));
Response.Cookies["Fbus"].Expires = DateTime.Now.AddDays(1);
}
else
{
HttpCookie cookie = Request.Cookies["Fbus"];
if (cookie != null)
{
cookie.Expires = DateTime.Now.AddDays(-1);
cookie.Values.Clear();
System.Web.HttpContext.Current.Response.Cookies.Set(cookie);
}
}
}
Response.Redirect("order.aspx");
}
public void cookies()
{
string cooki = Request.Cookies["Fbus"] == null ? "" : Request.Cookies["Fbus"].Value.Substring(1, Request.Cookies["Fbus"].Value.Length - 1);
string str;
if (cooki == "")
{
str = "select * from goods where id=-1";
}
else
{ str = "select * from goods where id in(" + cooki + ")"; }
rpcookie.DataSource = Sqlbase.ExecuteTable(CommandType.Text, str, null);
rpcookie.DataBind();
}
protected void lbdel_Command(object sender, CommandEventArgs e)
{
string ids = e.CommandArgument.ToString();
string str = Request.Cookies["Fbus"] == null ? "" : Request.Cookies["Fbus"].Value;
if (!str.Contains(ids))
{
}
else
{
if (str.Substring(1).Contains(","))
{
str = str.Replace("," + ids, "");
Response.Cookies.Add(new HttpCookie("Fbus", str));
Response.Cookies["Fbus"].Expires = DateTime.Now.AddDays(1);
}
else
{
HttpCookie cookie = Request.Cookies["Fbus"];
if (cookie != null)
{
cookie.Expires = DateTime.Now.AddDays(-1);
cookie.Values.Clear();
System.Web.HttpContext.Current.Response.Cookies.Set(cookie);
}
}
}
Response.Redirect("order.aspx");
}