温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Asp.net简单会议事务系统
当前文件:
SimpleMeeting/adminchangpwd.aspx.cs[2K,2009-6-12 11:54:08],打开代码结构图
SimpleMeeting/adminchangpwd.aspx.cs[2K,2009-6-12 11:54:08],打开代码结构图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
using System.Data.SqlClient; 12
13
public partial class adminchangpwd : System.Web.UI.Page 14
{ 15
SqlConnection cn; 16
SqlDataReader dr; 17
protected void Page_Load(object sender, EventArgs e) 18
{ 19
if (!Page.IsPostBack) 20
{ 21
this.Labadminname.Text = Convert.ToString(Session["username"]); 22
} 23
} 24
protected void Button2_Click(object sender, EventArgs e) 25
{ 26
if (Page.IsValid) 27
{ 28
try 29
{ 30
int id = Convert.ToInt32(Session ["id"]); 31
cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["cn"]); 32
cn.Open(); 33
SqlCommand cmd1 = new SqlCommand("select * from userinfo where username='" + this.Labadminname.Text.ToString().Trim() + "' and pwd='" + this.txtpwd.Text.ToString().Trim() + "'", cn); 34
dr = cmd1.ExecuteReader(); 35
if (dr.Read()) 36
{ 37
Session["id"] = dr["id"]; 38
Session["username"] = dr["username"].ToString().Trim(); 39
Session["pwd"] = dr["pwd"].ToString(); 40
dr.Close(); 41
42
SqlCommand cmd = new SqlCommand("update userinfo set pwd='" + this.txtnewpwd.Text.ToString().Trim() + "' where id='"+id+"' and username='"+this.Labadminname .Text .Trim ()+"'", cn); 43
cmd.ExecuteNonQuery(); 44
this.Labmessage.Text = "修改用户密码成功"; 45
} 46
else 47
{ 48
this.Labmessage.Text = "旧密码输入错误!"; 49
} 50
} 51
catch 52
{ 53
this.Labmessage.Text = "服务器忙,请一会在试!"; 54
} 55
finally 56
{ 57
cn.Close(); 58
} 59
} 60
} 61
protected void Button1_Click(object sender, EventArgs e) 62
{ 63
this.txtnewpwd.Text = ""; 64
this.txtnewpwdagina.Text = ""; 65
this.txtpwd.Text = ""; 66
this.txtpwd.Focus(); 67
this.Labmessage.Text = ""; 68
69
} 70
} 71





SqlConnection cn;

}
}