📄 userpassword.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 WebPage_UserPassword : System.Web.UI.Page
{
string UserName = "", uid = "";
protected void Page_Load(object sender, EventArgs e)
{
HttpCookie Cookie = CheckLogin();
if (Cookie != null)
{
uid = Cookie["User_ID"].ToString();
UserName = Cookie["UserName"].ToString();
}
txt_UserName.Text = UserName;
}
#region CheckLogin()//个人用户是否登录<返回一个HttpCookie>
/// <summary>
/// 是否登录
/// </summary>
/// <returns></returns>
private HttpCookie CheckLogin()
{
HttpCookie Cookie = Request.Cookies["Message"];
HttpCookie retCookie = null;
if (Cookie == null || Cookie.ToString() == "")
{
return retCookie;
}
else
{
retCookie = Request.Cookies["Message"];
return retCookie;
}
}
#endregion
#region 保存密码的修改
/// <summary>
/// 保存密码的修改
/// </summary>
private void SavePassword()
{
try
{
DataSet ds = new DataSet();
DAL.boBusiness bo = new DAL.boBusiness();
DAL.MakeConnection Conn = new DAL.MakeConnection();
DAL.clsDBConnkey ConnKey = new DAL.clsDBConnkey();
ConnKey = bo.loadkey();//得到config数据库连接
string strSql = "";
string strUserName = this.txt_UserName.Text;
string strPassword = this.txt_OldPassword.Text;
if (strUserName != "" && strPassword != "")
{
strPassword = DataSecurity.DataEncrypt(strPassword);
strSql = "select * from SystemUser where UserAccounts=@UserAccounts and UserPassword=@UserPassword";
SqlCommand sql_Command = new SqlCommand();
sql_Command.CommandText = strSql;
sql_Command.Parameters.Add(new SqlParameter("@UserAccounts", SqlDbType.NVarChar));
sql_Command.Parameters["@UserAccounts"].Value = strUserName;
sql_Command.Parameters.Add(new SqlParameter("@UserPassword", SqlDbType.NVarChar));
sql_Command.Parameters["@UserPassword"].Value = strPassword;
ds = (DataSet)Conn.MakeConnectionSqlCommand(sql_Command, ConnKey, DAL.executeMethod.execute_DataSet, DAL.
EnumDBType.Sql); //VritualPath需要Index.aspx传过来!
if (ds.Tables[0].Rows.Count > 0)
{
strPassword = DataSecurity.DataEncrypt(txt_NewPassword.Text);
strSql = "Update SystemUser set UserPassword=@UserPassword where User_ID=" + uid;
SqlCommand sql_Command2 = new SqlCommand();
sql_Command2.CommandText = strSql;
sql_Command2.Parameters.Add(new SqlParameter("@UserPassword", SqlDbType.NVarChar));
sql_Command2.Parameters["@UserPassword"].Value = strPassword;
Conn.MakeConnectionSqlCommand(sql_Command2, ConnKey, DAL.executeMethod.execute_NoneQuery, DAL.
EnumDBType.Sql); //VritualPath需要Index.aspx传过来!
string strMsg = "<script language='javascript'>window.setTimeout(\"alert('密码修改成功,请下次登陆时使用新密码!')\",100);</script>";
Response.Write(strMsg);
}
}
}
catch(System.Exception ex)
{
throw ex;
}
}
#endregion
protected void btnEnter_Click(object sender, EventArgs e)
{
SavePassword();
}
protected void btnCancel_Click(object sender, EventArgs e)
{
this.txt_NewPassword.Text = "";
this.txt_OldPassword.Text = "";
this.txt_EnterNewPassword.Text = "";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -