温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:三层新闻发布管理系统源码
当前文件:
TreeLayerNews/news2005/Web/UserCenter.aspx.cs,打开代码结构图
TreeLayerNews/news2005/Web/UserCenter.aspx.cs,打开代码结构图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 Web_Usercenter : System.Web.UI.Page 13
{ 14
BLL.admin Ba = new BLL.admin(); 15
Model.admin Ma = new Model.admin(); 16
17
protected void Page_Load(object sender, EventArgs e) 18
{ 19
if (!Page.IsPostBack) 20
{ 21
if (Session["username"] == null) 22
{ 23
Response.Write("<script language=javascript>alert('数据库操作出错!')</script>"); 24
} 25
else 26
{ 27
this.UserName.Text = Session["username"].ToString(); 28
this.TodayTime.Text = System.DateTime.Now.ToShortDateString().ToString(); 29
ViewState["name"] = Session["username"].ToString(); 30
DataBindUserInfo(); 31
this.TextBox2.Focus(); 32
this.Title = "用户信息中心!"; 33
} 34
} 35
} 36
37
/// <summary> 38
/// 数据初始化 39
/// </summary> 40
public void DataBindUserInfo() 41
{ 42
Ma.username = ViewState["name"].ToString(); 43
DataSet ds = Ba.QueryUserInfoByName(Ma); 44
this.email.Text = ds.Tables[0].Rows[0][3].ToString(); 45
this.TextBox3.Text = ds.Tables[0].Rows[0][3].ToString(); 46
this.aleave.Text = ds.Tables[0].Rows[0][4].ToString(); 47
this.TextBox1.Text = ds.Tables[0].Rows[0][1].ToString(); 48
} 49
protected void LinkButton1_Click(object sender, EventArgs e) 50
{ 51
if (tb.Visible) 52
{ 53
tb.Visible = false; 54
} 55
else 56
{ 57
tb.Visible = true; 58
} 59
} 60
protected void UpdateOK_Click(object sender, EventArgs e) 61
{ 62
Ma.username = this.TextBox1.Text.Trim(); 63
Ma.password = FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBox2.Text.Trim(),"MD5"); 64
Ma.useremail = this.TextBox3.Text.Trim(); 65
if (Ba.UpdateUserInfoByName(Ma)) 66
{ 67
tb.Visible = false; 68
Response.Write("<script language=javascript>alert('用户信息修改成功!')</script>"); 69
} 70
} 71
} 72




BLL.admin Ba 
}
}