?? changepwd.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 鏈接頁面_ChangePwd : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void mainpage_Click(object sender, EventArgs e)
{
Response.Redirect("../Mainbody/BorrowReturn.aspx");
}
protected void personinfo_Click(object sender, EventArgs e)
{
Response.Redirect("../Link/Myinfo.aspx");
}
protected void borrowbook_Click(object sender, EventArgs e)
{
Response.Redirect("../Link/Borrow.aspx");
}
protected void returnbook_Click(object sender, EventArgs e)
{
Response.Redirect("../Link/Return.aspx");
}
protected void history_Click(object sender, EventArgs e)
{
Response.Redirect("../Link/BorrowHistory.aspx");
}
protected void changepwd_Click(object sender, EventArgs e)
{
Response.Redirect("../Link/ChangePwd.aspx");
}
protected void logout_Click(object sender, EventArgs e)
{
Session.Contents.Remove("studentname");
Session.Contents.Remove("studentnum");
Response.Redirect("../Login/Login.aspx");
}
protected void surebutton_Click(object sender, EventArgs e)
{
string stunum = Session["studentnumber"].ToString();
string connstr = "Server=localhost;Database=Materialsystem;User ID=sa";
SqlConnection stuinfoconn = new SqlConnection(connstr);
string startstr = startpwdtextbox.Text.ToString().Trim();
string newstr = newpwdtextbox.Text.ToString().Trim();
string surestr = surepwdtextbox.Text.ToString().Trim();
try
{
if (stuinfoconn.State == ConnectionState.Closed)
{
stuinfoconn.Open();
string teststr = "SELECT * FROM Cardinfo WHERE (SELECT Cardpwd FROM Cardinfo WHERE Snum='" + stunum + "')='"+startstr+"'";
SqlCommand testcomm = new SqlCommand(teststr, stuinfoconn);
SqlDataReader test = testcomm.ExecuteReader(CommandBehavior.CloseConnection);
if (!test.Read())
{
Response.Write("<script>alert('密碼錯誤!');</script>");
}
else
{
try
{
if (newstr == surestr)
{
string cardnumstr = "UPDATE Cardinfo SET Cardpwd='" + newstr + "' WHERE Snum='" + stunum + "'";
if (stuinfoconn.State == ConnectionState.Closed)
{
stuinfoconn.Open();
}
SqlCommand mycomm = new SqlCommand(cardnumstr, stuinfoconn);
mycomm.ExecuteNonQuery();
Response.Write("<script>alert('密碼修改成功!');</script>");
}
else
{
Response.Write("<script>alert('你兩次輸入的密碼不一致,修改密碼失敗!');</script>");
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (stuinfoconn.State == ConnectionState.Open)
{
stuinfoconn.Close();
}
}
}
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (stuinfoconn.State == ConnectionState.Open)
{
stuinfoconn.Close();
}
}
}
protected void cancelbutton_Click(object sender, EventArgs e)
{
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -