温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:某大学学生管理系统(毕业设计)源码
当前文件:
StudentsInfo/ST_pwdmodify.aspx.cs,打开代码结构图
StudentsInfo/ST_pwdmodify.aspx.cs,打开代码结构图1using System; 2
using System.Collections; 3
using System.ComponentModel; 4
using System.Data; 5
using System.Data.SqlClient; 6
using System.Drawing; 7
using System.Web; 8
using System.Web.SessionState; 9
using System.Web.UI; 10
using System.Web.UI.WebControls; 11
using System.Web.UI.HtmlControls; 12
using System.Configuration; 13
14
15
namespace STGROUP 16
{ 17
/// <summary> 18
/// ST_pwdmodify 的摘要说明。 19
/// </summary> 20
public class ST_pwdmodify : System.Web.UI.Page 21
{ 22
protected System.Web.UI.WebControls.TextBox st_tbx_id; 23
protected System.Web.UI.WebControls.TextBox st_tbx_beforepwd; 24
protected System.Web.UI.WebControls.Button st_btn_upst_date; 25
protected System.Web.UI.WebControls.Panel st_pn_user; 26
protected System.Web.UI.WebControls.TextBox st_tbx_newpwd; 27
protected System.Web.UI.WebControls.TextBox st_tbx_pwdok; 28
protected System.Web.UI.WebControls.CompareValidator st_cv_pwd; 29
protected System.Web.UI.WebControls.Button st_btn_ok; 30
protected System.Web.UI.WebControls.Label st_lbl_note; 31
protected System.Web.UI.WebControls.Panel st_pnl_update; 32
33
private void Page_Load(object sender, System.EventArgs e) 34
{ 35
// 在此处放置用户代码以初始化页面 36
} 37
38
Web Form Designer generated code 60
61
private void st_btn_upst_date_Click(object sender, System.EventArgs e) 62
{ 63
string st_connstr= ConfigurationSettings.AppSettings["st_dbconn"]; 64
SqlConnection st_conn=new SqlConnection(st_connstr); 65
st_conn.Open(); 66
string st_sqlstr="select * from ST_users where ST_User_id='"+st_tbx_id.Text+"'and ST_User_password='"+st_tbx_beforepwd.Text+"'"; 67
SqlCommand st_comm=new SqlCommand(st_sqlstr,st_conn); 68
SqlDataReader st_dreader=st_comm.ExecuteReader(); 69
if(st_dreader.Read()) 70
{ 71
//使修改密码面板显示 72
st_pnl_update.Visible=true; 73
//使修改面板隐藏 74
st_pn_user.Visible=false; 75
st_lbl_note.Text=""; 76
} 77
else 78
{ 79
st_lbl_note.Text="无此用户或者密码不对"; 80
} 81
} 82
83
private void st_btn_ok_Click(object sender, System.EventArgs e) 84
{ 85
//获得数据库连接字符串 86
string st_connstr= ConfigurationSettings.AppSettings["st_dbconn"]; 87
//建立连接 88
SqlConnection st_conn=new SqlConnection(st_connstr); 89
//打开连接 90
st_conn.Open(); 91
//更新语句字符串 92
string st_sqlstr="update ST_users set ST_User_password='"+st_tbx_newpwd.Text+"' where ST_User_id='"+st_tbx_id.Text+"'"; 93
//建立命令语句 94
SqlCommand st_comm=new SqlCommand(st_sqlstr,st_conn); 95
try 96
{ 97
//执行sql语句 98
st_comm.ExecuteNonQuery(); 99
st_lbl_note.Text="修改成功!"; 100
} 101
catch(SqlException) 102
{ 103
st_lbl_note.Text="修改有误!"; 104
st_pn_user.Visible=true; 105
} 106
//关闭连接 107
st_conn.Close(); 108
} 109
110
} 111
} 112
113





}