c#购物车
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
dt.Columns.Add("Name");
dt.Columns.Add("Quantity");
dt.Columns.Add("UnitPrice");
DataRow r = dt.NewRow();
DataTable dt = (DataTable)Session["car"];
foreach (DataRow dr in dt.Rows)
{
a += Convert.ToDouble(dr["Quantity"]) * Convert.ToDouble(dr["UnitPrice"]);
/// </summary>
private void AccountPrice()
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
DataTable dt = (DataTable)Session["car"];
if (r["Id"].ToSr["Quantity"] = Convert.ToInt32(r["Quantity"]) + 1;
Session["car"] = dt;
tabload.Visible = true;
tabloading.Visible = false;
}
//绑定gridview
GridView1.DataSource = (DataTable)Session["car"];
GridView1.DataBind();
AccountPrice();
}
/// <summary>
/// 统计每种商品的金额
Session["car"] = dt;
Response.Redirect("Cart.aspx");
}
else
{
DataTable dt = (DataTable)Session["car"];
}
lbcountmoney.Text = a.ToString();
}
//删除购物车事件
protected void lbtnDelall_Click(object sender, EventArgs e)
{
Session["car"] = null;
dt.Rows.Add(dr);
Session["car"] = dt;
Response.Redirect("Cart.aspx");
}
}
//显示购物车
public void Bind()
{
foreach (DataRow r in dt.Rows)
{
string var = ((HiddenField)DataList1.Items[index].FindControl("hfflowerid")).Value;
Label lbPrice = ((Label)GridView1.Rows[i].FindControl("lbSumPrice"));
lbPrice.Text = (Convert.ToDouble(dt.Rows[i]["UnitPrice"]) * Convert.ToDouble(dt.Rows[i]["Quantity"])).ToString();
Response.Write("<script>alert('删除成功')</script>");
//GridView1.DataSource = (DataTable)Session["car"];
//GridView1.DataBind();
r["Id"] = ((HiddenField)DataList1.Items[index].FindControl("hfflowerid")).Value;
r["Name"] = ((Label)DataList1.Items[index].FindControl("lbname")).Text;
r["Quantity"] = 1;
r["UnitPrice"] = ((Label)DataList1.Items[index].FindControl("lbvipprice")).Text;
dt.Rows.Add(r);
}
TotalPrice();//统计购物车商品的总金额
}
/// <summary>
/// //统计购物车商品的总金额
/// </summary>
private void TotalPrice()
{
double a = 0;
添加购物车事件
public void AddCar()
{
if (Session["car"] == null)
{
DataTable dt = new DataTable();
dt.Columns.Add("Id");
Response.Redirect("Cart.aspx");
}
}
DataRow dr = dt.NewRow();
dr["Id"] = ((HiddenField)DataList1.Items[index].FindControl("hfflowerid")).Value;
dr["Name"] = ((Label)DataList1.Items[index].FindControl("lbname")).Text;
dr["Quantity"] = 1;
dr["UnitPrice"] = ((Label)DataList1.Items[index].FindControl("lbvipprice")).Text;
dt.Columns.Add("Quantity");
dt.Columns.Add("UnitPrice");
DataRow r = dt.NewRow();
DataTable dt = (DataTable)Session["car"];
foreach (DataRow dr in dt.Rows)
{
a += Convert.ToDouble(dr["Quantity"]) * Convert.ToDouble(dr["UnitPrice"]);
/// </summary>
private void AccountPrice()
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
DataTable dt = (DataTable)Session["car"];
if (r["Id"].ToSr["Quantity"] = Convert.ToInt32(r["Quantity"]) + 1;
Session["car"] = dt;
tabload.Visible = true;
tabloading.Visible = false;
}
//绑定gridview
GridView1.DataSource = (DataTable)Session["car"];
GridView1.DataBind();
AccountPrice();
}
/// <summary>
/// 统计每种商品的金额
Session["car"] = dt;
Response.Redirect("Cart.aspx");
}
else
{
DataTable dt = (DataTable)Session["car"];
}
lbcountmoney.Text = a.ToString();
}
//删除购物车事件
protected void lbtnDelall_Click(object sender, EventArgs e)
{
Session["car"] = null;
dt.Rows.Add(dr);
Session["car"] = dt;
Response.Redirect("Cart.aspx");
}
}
//显示购物车
public void Bind()
{
foreach (DataRow r in dt.Rows)
{
string var = ((HiddenField)DataList1.Items[index].FindControl("hfflowerid")).Value;
Label lbPrice = ((Label)GridView1.Rows[i].FindControl("lbSumPrice"));
lbPrice.Text = (Convert.ToDouble(dt.Rows[i]["UnitPrice"]) * Convert.ToDouble(dt.Rows[i]["Quantity"])).ToString();
Response.Write("<script>alert('删除成功')</script>");
//GridView1.DataSource = (DataTable)Session["car"];
//GridView1.DataBind();
r["Id"] = ((HiddenField)DataList1.Items[index].FindControl("hfflowerid")).Value;
r["Name"] = ((Label)DataList1.Items[index].FindControl("lbname")).Text;
r["Quantity"] = 1;
r["UnitPrice"] = ((Label)DataList1.Items[index].FindControl("lbvipprice")).Text;
dt.Rows.Add(r);
}
TotalPrice();//统计购物车商品的总金额
}
/// <summary>
/// //统计购物车商品的总金额
/// </summary>
private void TotalPrice()
{
double a = 0;
添加购物车事件
public void AddCar()
{
if (Session["car"] == null)
{
DataTable dt = new DataTable();
dt.Columns.Add("Id");
Response.Redirect("Cart.aspx");
}
}
DataRow dr = dt.NewRow();
dr["Id"] = ((HiddenField)DataList1.Items[index].FindControl("hfflowerid")).Value;
dr["Name"] = ((Label)DataList1.Items[index].FindControl("lbname")).Text;
dr["Quantity"] = 1;
dr["UnitPrice"] = ((Label)DataList1.Items[index].FindControl("lbvipprice")).Text;