📄 mimaxiugai.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace free.bbs
{
/// <summary>
/// Summary description for mimaxiugai.
/// </summary>
public partial class mimaxiugai : System.Web.UI.Page
{
SqlConnection conn;
SqlDataReader r;
string name;
protected void Page_Load(object sender, System.EventArgs e)
{
try
{
name=Request.Cookies["free_huiyuan"].Value.ToString();
}
catch
{
Response.Redirect("error.aspx");
}
conn=new SqlConnection(Session["str_connection"].ToString());
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
protected void Button1_Click(object sender, System.EventArgs e)
{
conn.Open();
SqlCommand command=new SqlCommand("select mima from huiyuan where yonghuming='"+name+"'",conn);
r=command.ExecuteReader();
try
{
r.Read();
if(yuanmima.Text.Trim()==r["mima"].ToString().Trim())
{
r.Close();
if(xinmima1.Text.Trim()=="")
{
Response.Write("<script>alert('新密码不能为空!')</script>");
}
else if(xinmima1.Text.Trim()==xinmima2.Text.Trim()&&xinmima2.Text.Trim()!="" &&Page.IsValid)
{
command=new SqlCommand("update huiyuan set mima=@mima where yonghuming='"+name+"'",conn);
command.Parameters.Add(new SqlParameter("@mima",SqlDbType.Char,15));
command.Parameters["@mima"].Value=xinmima1.Text.Trim();
command.ExecuteNonQuery();
Response.Write("<script>alert('密码修改成功!')</script>");
conn.Close();
}
else
{
Response.Write("<script>alert('新密码不一致!!')</script>");
}
}
else
{
Response.Write("<script>alert('旧密码不正确!')</script>");
}
}
catch
{
Response.Write("<script>alert('错误,你的输入有误!')</script>");
}
conn.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -