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

📄 pwd.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.Xml;
public partial class manger_pwd : System.Web.UI.Page
{
    private XmlDocument xmld;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["admin"].ToString() != "true")
            {
                //Response.Write("<script>parent.window.location.href='login.aspx';</script>");
                Response.Write("<script>parent.window.location.href='../';</script>");
                Response.End();
            }
        }
        catch
        {
            Response.Write("<script>parent.window.location.href='../';</script>");
            Response.End();
        }
        try
        {
            xmld = new XmlDocument();
            xmld.Load(Server.MapPath(@"../App_Data/admin.config"));
        }
        catch//(Exception exp)
        {
            Response.Write("数据打开失败,请与管理员联系");
            Response.End();
        }
        Label3.Text = Session["name"].ToString();

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
         if ((TextBox2.Text == TextBox3.Text) && TextBox3.Text != "" && TextBox1.Text != "")
        {
            int i = -1;
            XmlNodeList xnl = xmld.SelectSingleNode("admin").ChildNodes;
        
            foreach (XmlNode xn in xnl)
            {
             
                XmlElement xe = (XmlElement)xn;
                if (xe.GetAttribute("name") == Session["name"].ToString())
                {
                    if (xe.GetAttribute("pass") == FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text, "MD5"))
                    {
                        xe.SetAttribute("pass", FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox2.Text, "MD5"));
                        i = 1;
                        break;
                    }
                    else
                    {
                        Response.Write("<script>alert('原始密码错误');</script>");
                        break;
                    }

                }
            }
            if (i == 1)
            {
                xmld.Save(Server.MapPath(@"../App_Data/admin.config"));
                Response.Write("<script>alert('修改成功');</script>");
                TextBox1.Text = "";
                TextBox2.Text = "";
                TextBox3.Text = "";
                //Response.Write("xxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
            }

        }
        else
            Response.Write("<script>alert('数据输入不完整');</script>");

    }

    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -