温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:淘淘网电子商务网站源码(毕业设计)
当前文件:
TaoTaoBiz/Customer/MyInformation.aspx.cs,打开代码结构图
TaoTaoBiz/Customer/MyInformation.aspx.cs,打开代码结构图1using System; 2
using System.Collections; 3
using System.ComponentModel; 4
using System.Data; 5
using System.Drawing; 6
using System.Web; 7
using System.Web.SessionState; 8
using System.Web.UI; 9
using System.Web.UI.WebControls; 10
using System.Web.UI.HtmlControls; 11
using web.Code; 12
13
namespace web.Customer 14
{ 15
/// <summary> 16
/// MyInformation 的摘要说明。 17
/// </summary> 18
public partial class MyInformation : System.Web.UI.Page 19
{ 20
21
static string Name = null; 22
23
protected void Page_Load(object sender, System.EventArgs e) 24
{ 25
// 在此处放置用户代码以初始化页面 26
if( !Page.IsPostBack ) 27
{ 28
if( Session["LoginName"] == null ) 29
{ 30
if( Request.Params["CustomerId"] != null ) 31
{ 32
int id = Convert.ToInt32( Request.Params["CustomerId"].ToString() ); 33
CustomerDAO customerDAO = new CustomerDAO(); 34
DataGrid1.DataSource = customerDAO.getMyInformation( id ); 35
DataGrid1.DataBind(); 36
} 37
else 38
{ 39
Response.Redirect("../Login.aspx?Return=" + Request.Url.ToString()); 40
} 41
} 42
else 43
{ 44
Name = Session["LoginName"].ToString(); 45
BindData(); 46
} 47
} 48
} 49
50
Web 窗体设计器生成的代码 72
73
private void BindData() 74
{ 75
CustomerDAO customerDAO = new CustomerDAO(); 76
DataGrid1.DataSource = customerDAO.getMyInformation( Name ); 77
DataGrid1.DataBind(); 78
} 79
80
private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) 81
{ 82
DataGrid1.EditItemIndex=(int)e.Item.ItemIndex; 83
BindData(); 84
} 85
86
public string getSex( string virtualSex ) 87
{ 88
string Sex = null; 89
switch( virtualSex ) 90
{ 91
case "0": 92
Sex = "男"; 93
break; 94
case "1": 95
Sex = "女"; 96
break; 97
} 98
return Sex; 99
} 100
101
private void DataGrid1_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) 102
{ 103
DataGrid1.EditItemIndex = -1; 104
BindData(); 105
} 106
107
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) 108
{ 109
string realName = ((TextBox)(e.Item.FindControl("TextBox2"))).Text; 110
string address = ((TextBox)(e.Item.FindControl("TextBox3"))).Text; 111
string sex = ((RadioButtonList)(e.Item.FindControl("RadioButtonList1"))).SelectedValue; 112
string phone = ((TextBox)(e.Item.FindControl("TextBox4"))).Text; 113
string email = ((TextBox)(e.Item.FindControl("TextBox5"))).Text; 114
string qq = ((TextBox)(e.Item.FindControl("TextBox6"))).Text; 115
CustomerVO customerVO = new CustomerVO(); 116
customerVO.RealName = realName; 117
customerVO.Address = address; 118
customerVO.Sex = sex; 119
customerVO.Phone = phone; 120
customerVO.Email = email; 121
customerVO.QQ = qq; 122
CustomerDAO customerDAO = new CustomerDAO(); 123
customerVO.CustomerId = customerDAO.getUserId( Name ); 124
if( customerDAO.updateMyInformation( customerVO ) != 0 ) 125
{ 126
Response.Write("<script>alert('修改成功!')</script>"); 127
DataGrid1.EditItemIndex=-1; 128
BindData(); 129
} 130
} 131
132
} 133
} 134





}