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

📄 adminchangpwd.aspx.cs

📁 会议室管理系统,本系统是我大学毕业时候的毕业设计,一次通过的!
💻 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 adminchangpwd : System.Web.UI.Page
{
    SqlConnection cn;
    SqlDataReader dr;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            this.Labadminname.Text = Convert.ToString(Session["username"]);
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            try
            {
                int id = Convert.ToInt32(Session ["id"]);
                cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["cn"]);
                cn.Open();
                SqlCommand cmd1 = new SqlCommand("select * from userinfo where username='" + this.Labadminname.Text.ToString().Trim() + "' and pwd='" + this.txtpwd.Text.ToString().Trim() + "'", cn);
                dr = cmd1.ExecuteReader();
                if (dr.Read())
                {
                    Session["id"] = dr["id"];
                    Session["username"] = dr["username"].ToString().Trim();
                    Session["pwd"] = dr["pwd"].ToString();
                    dr.Close();

                    SqlCommand cmd = new SqlCommand("update userinfo set pwd='" + this.txtnewpwd.Text.ToString().Trim() + "' where id='"+id+"' and username='"+this.Labadminname .Text .Trim ()+"'", cn);
                    cmd.ExecuteNonQuery();
                    this.Labmessage.Text = "修改用户密码成功";
                }
                else
                {
                    this.Labmessage.Text = "旧密码输入错误!";
                }
            }
            catch
            {
                this.Labmessage.Text = "服务器忙,请一会在试!";
            }
            finally
            {
                cn.Close();
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        this.txtnewpwd.Text = "";
        this.txtnewpwdagina.Text = "";
        this.txtpwd.Text = "";
        this.txtpwd.Focus();
        this.Labmessage.Text = "";

    }
}

⌨️ 快捷键说明

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