📄 adminchangpwd.aspx.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 + -