editpassword.aspx.cs

来自「程序学生信息管理系统(SQL2000+ASP.NET+c#+)」· CS 代码 · 共 86 行

CS
86
字号
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;
using SMS;

public partial class Default2 : System.Web.UI.Page
{
    OPDataBase op = new OPDataBase();
   
    protected void Page_Load(object sender, EventArgs e)
    {
       TextBox4 .Text = Session["UserID"]+":你好!";
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        //SqlConnection conn = new SqlConnection( op .getConnection ());
        //conn.Open();
        string test = TextBox3.Text.Trim();
        string sql = "select Password from Users where  UserID='" +Session ["UserID"] + "'and Password='"+test +"'";
        SqlDataReader dr;

        dr = op.getDataReader(sql);
        if (dr.Read())

        {

            Panel1.Visible = true;
            Label2.Text = "";

        }
        else
        {
         
          
            TextBox3 .Text ="";
            Panel1.Visible = false;
           
        }

        TextBox1.Focus();


    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (TextBox1.Text == TextBox2.Text&&TextBox1.Text !=""||TextBox2 .Text !="")
        {
            string sql = " Update Users set Password='" + TextBox2.Text.Trim() + "'";
           SqlConnection conn = op.sqlConnection();
           conn.Open();
           SqlCommand cmd = new SqlCommand(sql ,conn );
           try
           {
               cmd.ExecuteNonQuery();
               Label2.Text = "*修改成功!*";
               Panel1.Visible = false; 
             
           }
           catch
           {
               Label2.Text = "*修改失败!*";
           }
         
        
        
        }
    }

    protected void Button4_Click(object sender, EventArgs e)
    {
        TextBox3.Text = "";
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("EditStudent.aspx");
    }
}

⌨️ 快捷键说明

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