📄 updatepassword.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 ChangePassword : System.Web.UI.Page
{
private string sqlcon = ConfigurationManager.AppSettings["SQLCONNECTION"].ToString();
protected void Page_Load(object sender, EventArgs e)
{
// Session["EmployeeID"] = "333333512";
/* if (!IsPostBack)
{
tbx_oldPW.Text = "";
tbx_newPW.Text = "";
tbx_ConfirmnewPW.Text = "";
lbl_WrongoPW.Visible = false;
}*/
}
protected bool isContainNumber(string s)
{
int i;
char c;
for (i = 0; i < s.Length; i++)
{
c = s[i];
if (c <= 57 && c >= 48) return true;
}
return false;
}
protected bool str_Judge(string s)
{
if (s.Length <= 8 || s.Length >= 12)
return false;
else if (isContainNumber( s) == false)
return false;
else if (s == s.ToLower())
return false;
else if (s == s.ToUpper())
return false;
else return true;
}
/*
protected void isValid(object sourse, ServerValidateEventArgs args)
{
args.IsValid = false;
string = Convert.ToString(args.Value);
if (str_Judge(PassrowdAgian) == true)
args.IsValid = true;
}
*/
protected void clk_ChangePW(object sender, EventArgs e)
{
string str_toCheck = tbx_newPW.Text;
string oldPW;
lbl_ComplexError.Text = "";
lbl_WrongoPW.Visible = false;
SqlConnection conn = new SqlConnection(sqlcon);
conn.Open();
string cmd_GetPW = "select Password from tblEmployee where EmployeeID = '" + Session["EmployeeID"].ToString() + "'";
SqlCommand GetPW = new SqlCommand( cmd_GetPW, conn);
SqlDataReader dr_getPW = GetPW.ExecuteReader();
// while( dr_getPW.Read())//获取旧密码
// {
dr_getPW.Read();
oldPW = dr_getPW["Password"].ToString();
// }
conn.Close();
if( tbx_oldPW.Text != oldPW)//判断旧密码是否正确
{
lbl_WrongoPW.Visible = true;
tbx_oldPW.Text = "";
tbx_newPW.Text = "";
tbx_ConfirmnewPW.Text = "";
conn.Close();
}
else if ( str_Judge(str_toCheck) == false)
{
lbl_ComplexError.Text = "请输入复杂密码";
tbx_oldPW.Text = "";
tbx_newPW.Text = "";
tbx_ConfirmnewPW.Text = "";
conn.Close();
}
else
{
lbl_ComplexError.Text = "";
string cmd_ChangePW = "update tblEmployee set Password = '" + tbx_newPW.Text + "' where EmployeeID = '" + Session["EmployeeID"].ToString() + "'";
SqlCommand ChangePW = new SqlCommand(cmd_ChangePW, conn);
conn.Open();
ChangePW.ExecuteNonQuery();
conn.Close();
tbx_oldPW.Text = "";
tbx_newPW.Text = "";
tbx_ConfirmnewPW.Text = "";
lbl_WrongoPW.Visible = false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -