⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 st_pwdmodify.aspx.cs

📁 本人上传的是学生管理系统,希望能给广大编程爱好都以帮助
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;


namespace STGROUP
{
	/// <summary>
	/// ST_pwdmodify 的摘要说明。
	/// </summary>
	public class ST_pwdmodify : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox st_tbx_id;
		protected System.Web.UI.WebControls.TextBox st_tbx_beforepwd;
		protected System.Web.UI.WebControls.Button st_btn_upst_date;
		protected System.Web.UI.WebControls.Panel st_pn_user;
		protected System.Web.UI.WebControls.TextBox st_tbx_newpwd;
		protected System.Web.UI.WebControls.TextBox st_tbx_pwdok;
		protected System.Web.UI.WebControls.CompareValidator st_cv_pwd;
		protected System.Web.UI.WebControls.Button st_btn_ok;
		protected System.Web.UI.WebControls.Label st_lbl_note;
		protected System.Web.UI.WebControls.Panel st_pnl_update;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.st_btn_upst_date.Click += new System.EventHandler(this.st_btn_upst_date_Click);
			this.st_btn_ok.Click += new System.EventHandler(this.st_btn_ok_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void st_btn_upst_date_Click(object sender, System.EventArgs e)
		{
			string st_connstr= ConfigurationSettings.AppSettings["st_dbconn"];
			SqlConnection st_conn=new SqlConnection(st_connstr);	
			st_conn.Open();
			string st_sqlstr="select * from ST_users where ST_User_id='"+st_tbx_id.Text+"'and ST_User_password='"+st_tbx_beforepwd.Text+"'";
			SqlCommand st_comm=new SqlCommand(st_sqlstr,st_conn);
			SqlDataReader st_dreader=st_comm.ExecuteReader();
			if(st_dreader.Read())
			{	
				//使修改密码面板显示
				st_pnl_update.Visible=true;
				//使修改面板隐藏
				st_pn_user.Visible=false;
				st_lbl_note.Text="";
			}
			else
			{
				st_lbl_note.Text="无此用户或者密码不对";
			}
		}

		private void st_btn_ok_Click(object sender, System.EventArgs e)
		{
			//获得数据库连接字符串
			string st_connstr= ConfigurationSettings.AppSettings["st_dbconn"];
			//建立连接
			SqlConnection st_conn=new SqlConnection(st_connstr);
			 //打开连接	
			st_conn.Open();
			//更新语句字符串
			string st_sqlstr="update ST_users set ST_User_password='"+st_tbx_newpwd.Text+"' where ST_User_id='"+st_tbx_id.Text+"'";
			//建立命令语句
			SqlCommand st_comm=new SqlCommand(st_sqlstr,st_conn);
			try
			{
				//执行sql语句
				st_comm.ExecuteNonQuery();
				st_lbl_note.Text="修改成功!";
			}
			catch(SqlException)
			{
				st_lbl_note.Text="修改有误!";
				st_pn_user.Visible=true;
			}
			//关闭连接
			st_conn.Close();
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -