📄 updateregister.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace Service
{
/// <summary>
/// Summary description for UpdateRegister.
/// </summary>
public partial class UpdateRegister : System.Web.UI.Page
{
public String sOperation = "";
public String sLinkName = "";
protected void Page_Load(object sender, System.EventArgs e)
{
if(Session["UserID"] == null)
{
Response.Redirect("~/Default.aspx");
}
else
{
String sUserRoleName = UserDB.GetUserLoginRole(Int32.Parse(Session["UserID"].ToString()));
if(sUserRoleName.IndexOf("Valid") == -1 && sUserRoleName.IndexOf("Normal") == -1)
{
Response.Redirect("~/Default.aspx");
}
}
UserName.Text = Session["UserName"].ToString();
if(Request.Params["LinkID"] != null)
{
GetLinkName(Request.Params["LinkID"].ToString());
}
}
private void GetLinkName(String sLinkID)
{
String[] aName = new String[2];
aName = GlobalVarables.GetLinkName(sLinkID);
if(GlobalVarables.aLinkName.Count > 0)
{
sOperation = aName[0].ToString();
sLinkName = aName[1].ToString();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
protected void AddUserBtn_Click(object sender, System.EventArgs e)
{
UserDB user = new UserDB();
String userId = "";
if(NewPassword.Text == PasswordStr.Text)
{
SqlDataReader recu = user.GetUserLogin(UserName.Text.Trim(),UserDB.Encrypt(OldPassword.Text.Trim()));
if(recu.Read())
{
userId = recu["ID"].ToString();
}
else
{
Response.Write("<script>alert(\"旧密码输入错误,请重新输入你的密码!\")</script>");
}
recu.Close();
if((userId != null)&&(userId != ""))
{
try
{
user.UpdateUserPassword(Int32.Parse(userId),UserDB.Encrypt(NewPassword.Text.Trim()),
CleanString.InputText(RealName.Text.Trim(),32),Telephone.Text,
CleanString.InputText(Address.Text,200));
Response.Write("<script>alert(\"更改用户信息成功,请妥善保管好你的密码!\")</script>");
}
catch(Exception ex)
{
string sRawURL = Request.RawUrl;
if(sRawURL.IndexOf("?") > -1)
{
sRawURL = sRawURL.Substring(0,sRawURL.IndexOf("?"));
}
Response.Redirect("~/ManageSystem/ErrorPage.aspx?ErrorUrl=" + sRawURL + "&ErrorMessage=" + ex.Message.Replace("\n"," "));
}
}
}
else
{
Response.Write("<script>alert(\"两次输入的密码不相同,请重新输入!\")</script>");
}
}
protected void CancelBtn_Click(object sender, System.EventArgs e)
{
Response.Write("<script>window.close();</script>");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -