editpwd.aspx.cs

来自「用vs2005写的一个生产任务管理系统。数据的统计和综合查询是主要功能」· CS 代码 · 共 53 行

CS
53
字号
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 EditPwd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        strSession strJudge = new strSession();
        strJudge.Judge();
    }
    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("Default2.aspx");
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        SqlConnection str = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["conn"].ToString());
        str.Open();
        try
        {
            string strUserName = Session["username"].ToString();
            string strOldPwd = "";
            SqlCommand cmdEdit = new SqlCommand("select password from users where username='" + strUserName + "'", str);
            strOldPwd = cmdEdit.ExecuteScalar().ToString();
            if (strOldPwd != this.txtOldPwd.Text.Trim())
            {
                Response.Write("<script>alert('密码不正确!');</script>");
            }
            else
            {
                SqlCommand cmd = new SqlCommand("update users set password='" + this.txtNewPwd.Text + "' where username = '" + strUserName + "'", str);
                cmd.ExecuteNonQuery();
                Response.Write("<script>alert('密码修改成功!');</script>");
            }
        }
        catch
        { }
        finally
        {
            str.Close();
        }
    }
}

⌨️ 快捷键说明

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