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

📄 st_pwdmodify.aspx.cs

📁 学生管理系统。C#开发。偏重与数据库的应用。
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class ST_pwdmodify : System.Web.UI.Page
{
    	
		protected void Page_Load(object sender,EventArgs e)
		{	
			
		}
    protected void st_btn_ok_Click(object sender, EventArgs e)
    {//获得数据库连接字符串
        string st_connstr = ConfigurationManager.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();
		}
    
    protected void st_btn_upst_date_Click(object sender, EventArgs e)
    {

        string st_connstr = ConfigurationManager.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 = "无此用户或者密码不对";
        }
    }
}

⌨️ 快捷键说明

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