温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:JaneLee简单购物车源码
当前文件:
JaneLeeShopCart/account.aspx.cs[3K,2009-6-12 11:45:29],打开代码结构图
JaneLeeShopCart/account.aspx.cs[3K,2009-6-12 11:45:29],打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
12
public partial class account : System.Web.UI.Page 13
{ 14
protected void Page_Load(object sender, EventArgs e) 15
{ 16
if (!IsPostBack) 17
{ 18
if(Session["khbz"]!=null) 19
TextBox1.Text=Session["khbz"].ToString(); 20
GridView1.DataSource = Session["shoppingcart2"]; 21
GridView1.DataBind(); 22
} 23
} 24
protected void Button1_Click(object sender, EventArgs e) 25
{ 26
double sum = 0.0; 27
for (int i = 0; i < GridView1.Rows.Count; i++) 28
{ 29
CheckBox cc = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox1"); 30
if (cc.Checked) 31
{ 32
sum = sum + (double.Parse(GridView1.Rows[i].Cells[6].Text)); 33
} 34
} 35
TextBox2.Text = sum.ToString(); 36
} 37
protected void Button2_Click(object sender, EventArgs e) 38
{ 39
for (int i = 0; i < GridView1.Rows.Count; i++) 40
{ 41
CheckBox cc = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox1"); 42
if (cc.Checked) 43
{ 44
SqlDataSource1.InsertParameters.Clear(); 45
if (Session["khbz"] != null) 46
//Response.Write(Session["khbz"]); 47
SqlDataSource1.InsertParameters.Add("Param1", Session["khbz"].ToString()); 48
SqlDataSource1.InsertParameters.Add("Param2", GridView1.Rows[i].Cells[1].Text); 49
SqlDataSource1.InsertParameters.Add("Param3", GridView1.Rows[i].Cells[2].Text); 50
SqlDataSource1.InsertParameters.Add("Param4", GridView1.Rows[i].Cells[3].Text); 51
SqlDataSource1.InsertParameters.Add("Param5", GridView1.Rows[i].Cells[4].Text); 52
SqlDataSource1.InsertParameters.Add("Param6", GridView1.Rows[i].Cells[5].Text); 53
SqlDataSource1.InsertParameters.Add("Param7", DateTime.Today.ToShortDateString()); 54
//if (Session["khbz"] != null) 55
// SqlDataSource1.InsertParameters[0].DefaultValue = Session["khbz"].ToString(); 56
//SqlDataSource1.InsertParameters[1].DefaultValue = GridView1.Rows[i].Cells[1].Text; 57
//SqlDataSource1.InsertParameters[2].DefaultValue = GridView1.Rows[i].Cells[2].Text; 58
//SqlDataSource1.InsertParameters[3].DefaultValue = GridView1.Rows[i].Cells[3].Text; 59
//SqlDataSource1.InsertParameters[4].DefaultValue = GridView1.Rows[i].Cells[4].Text; 60
//SqlDataSource1.InsertParameters[5].DefaultValue = GridView1.Rows[i].Cells[5].Text; 61
//SqlDataSource1.InsertParameters[6].DefaultValue = DateTime.Now.ToString(); 62
Session["ccsj"] = DateTime.Today.ToShortDateString(); 63
SqlDataSource1.Insert(); 64
65
} 66
} 67
Session["shoppingcart"] = ""; 68
Session["shoppingcart2"] = ""; 69
Response.Redirect("ordering.aspx"); 70
} 71
} 72






}
}