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 SystemManage_user_open : System.Web.UI.Page
{
	private readonly static string sqlcmd1 = "select username from System_Users where id=";

    protected void Page_Load(object sender, EventArgs e)
    {
		if (Convert.ToString(Session["username"]) == "")
		{
			Response.Write("<script language=javascript>alert('请登录');location='../login.aspx'</script>");
		}
		if(!IsPostBack)
		{
			using(SqlConnection sqlconn=new SqlConnection(Tools.strConn))
			{
				SqlCommand cmd = new SqlCommand((sqlcmd1 + Request["id"]), sqlconn);
				sqlconn.Open();
				this.username.Text = Convert.ToString(cmd.ExecuteScalar());
			}
		}
    }

	protected void Button1_Click(object sender, EventArgs e)
	{
		if (Tools.validate(Request["userpwd"].ToString()))
		{
			Response.Write("<script>alert('密码中不能含有非法字符');history.back()</script>");
			Response.End();
		}
		using(SqlConnection sqlconn=new SqlConnection(Tools.strConn))
		{
			SqlCommand cmd = new SqlCommand("update System_Users set userpwd= '" + Request["userpwd"] + "',AddTime = '" + DateTime.Now + "' where id = '" + Request["id"] + "'", sqlconn);
			sqlconn.Open();
			cmd.ExecuteNonQuery();
			Response.Write("<script>alert('密码修改成功');opener.location='SystemUserManage.aspx';window.close()</script>");
		}
	}
}
