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

📄 modifypass.aspx.cs

📁 三层班级留言本源码 用VS2005写的,对于其中没有太多的技术含量, 但是还是蛮有参考价值的. 后台数据库的读写采用三层架构,没有专业的后台管理程序,所有操作都是同一个页面上进行. 如果
💻 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.IO;
using UserInfoLib;

public partial class ModifyPass : System.Web.UI.Page
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if ((Session["User"] != null) && (Session["Root"] != null) && (Session["Root"].ToString()) != "0")
            {
                this.LabelName.Text = Session["User"].ToString();
                UserInfo user = new UserInfo();
                user.UserName = Session["User"].ToString();
                DataSet table  = user.SeleUpdate();
                this.TextBoxPassword.Text = table.Tables[0].Rows[0]["UserPassword"].ToString();
                this.TextBox1.Text = table.Tables[0].Rows[0]["UserImage"].ToString();
                this.ViewState["table"] = table;
                this.ButtonClose.Attributes.Add("onclick", "window.close();");
            }
            else
            {
                this.Response.Write("<script>alert('您还没有登陆!');</script>");
                this.Response.Redirect("index.aspx");
                //this.Page.RegisterStartupScript("closewindow", "<script>window.close()</script>");
            }
        }
    }
    protected void ButtonExit_Click(object sender, EventArgs e)
    {       
        this.TextBoxPassword.Text = "";
    }
    protected void ButtonModify_Click(object sender, EventArgs e)
    {        
        UserInfo user = new UserInfo();
        user.UserName = this.LabelName.Text;
        user.UserPassword = this.TextBoxPassword.Text;
        user.UserImage = this.TextBox1.Text;
        if (FileUpload1.FileName == null || FileUpload1.FileName == "")
        {
            DataSet table = (DataSet)ViewState["table"];
            user.UserLable = table.Tables[0].Rows[0]["UserLable"].ToString();
        }
        else
        {  
            
            this.FileUpload1.PostedFile.SaveAs(this.Server.MapPath("UPimage") + "\\" + Path.GetFileName(FileUpload1.PostedFile.FileName));
            user.UserLable = "~\\UPimage\\" + this.FileUpload1.FileName;
        }
        user.Update();
        this.TextBoxPassword.Text = "";
        this.Response.Write("<script>alert('修改成功');</script>");
        this.Response.Write("<script>window.setTimeout('window.close()',0)</script>");
    }
}

⌨️ 快捷键说明

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