⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 changepwd.aspx.cs

📁 具有仓库管理信息系统的基本功能。。入库
💻 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 + -