📄 password.aspx.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.Data.SqlClient;
public partial class Password : System.Web.UI.Page
{
clsMdf mdf;
string name;
int i;
int j;
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["news_manageConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
name= Session["UserName"].ToString();
mdf = new clsMdf();
}
//取出用户ID
public void query()
{
string str = "select UserId from t_News_User where userName='"+name +"'";
SqlCommand com = new SqlCommand(str, conn);
conn.Open();
i=Convert.ToInt32(com.ExecuteScalar());
conn.Close();
}
//判断用户是否存在
public void check()
{
string str = "select count(*) from t_News_User where userName='" + name + "' and USERPASSWORD = '"+this.TextBox1.Text+"'";
SqlCommand com = new SqlCommand(str, conn);
conn.Open();
j= Convert.ToInt32(com.ExecuteScalar());
conn.Close();
if (j > 0)
{
this.mdi();
}
else
{
Response.Write("<script language=javascript> window.alert('你输入的密码不正确,请重新输入!')</script>");
this.TextBox1.Text = "";
}
}
//保存按钮
protected void btnSave_Click(object sender, EventArgs e)
{
query();
check();
}
//修改用户
public void mdi()
{
string pwd = this.txtInput.Text;
bool b = false;
b = mdf.modify(name, pwd, i);
if (b)
{
Response.Write("<script language=javascript> window.alert('恭喜你,修改成功!')</script>");
}
else
{
Response.Write("<script language=javascript> window.alert('抱歉,你修改失败!')</script>");
}
}
//取消
protected void Button1_Click(object sender, EventArgs e)
{
this.txtInput.Text = "";
this.txtOk.Text = "";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -