Asp.net源码专业站
首页->新知实践->JaneLee简单购物车源码>>mycart.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:JaneLee简单购物车源码
当前文件:文件类型 JaneLeeShopCart/mycart.aspx.cs[2K,2009-6-12 11:45:29]打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11//该源码下载自www.51aspx.com(51aspx.com) 12 13public partial class mycart : System.Web.UI.Page 14{ 15 protected void Page_Load(object sender, EventArgs e) 16 { 17 if (!IsPostBack) 18 { 19 GridView1.DataSource = Session["shoppingcart"]; 20 GridView1.DataBind(); 21 } 22 } 23 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 24 { 25 DataTable Cart = new DataTable(); 26 if (e.CommandName == "buy") 27 { 28 if (Session["ShoppingCart2"] == null) 29 { 30 Cart.Columns.Add("商品编号", typeof(int)); //建立数据表结构 31 Cart.Columns.Add("商品名称", typeof(string)); 32 Cart.Columns.Add("单位数量", typeof(string)); 33 Cart.Columns.Add("单价", typeof(double)); 34 Cart.Columns.Add("订购数量", typeof(int)); 35 //Cart.Columns.Add("折扣", typeof(double)); 36 Cart.Columns.Add("合计", typeof(double)); 37 Session["ShoppingCart2"] = Cart; 38 } 39 Cart = (DataTable)Session["ShoppingCart2"]; 40 if (TextBox1.Text == "") // 输入客户标志 41 { 42 Validate(); // 调用校验控件进行校验 43 } 44 else 45 { 46 Session["khbz"] = TextBox1.Text; 47 int index = Convert.ToInt32(e.CommandArgument); 48 GridViewRow row = GridView1.Rows[index]; 49 TextBox tt = (TextBox)row.Cells[1].FindControl("TextBox2"); 50 string dgl = tt.Text; 51 int dg = int.Parse(dgl); 52 if (dg <= 1) 53 dg = 1; 54 string bhText = row.Cells[2].Text; 55 string mcText = row.Cells[3].Text; 56 string dwText = row.Cells[4].Text; 57 string djText = row.Cells[5].Text; 58 int bh = int.Parse(bhText); 59 double dj = double.Parse(djText); 60 DataRow rr = Cart.NewRow(); 61 rr["商品编号"]=bh; 62 rr["商品名称"] = mcText; 63 rr["单位数量"] = dwText; 64 rr["单价"] = dj; 65 rr["订购数量"] = dg; 66 //int zk = 1; 67 //rr["折扣"] = zk; 68 double hj = dj * dg; 69 rr["合计"] = hj; 70 Cart.Rows.Add(rr); 71 Session["ShoppingCart2"] = Cart; 72 } 73 } 74 } 75} 76 77 78 79
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:JaneLee简单购物车源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146