namespace SK.MemberWeb.Templates.Default
{
	using System;
	using System.Data;
	using System.Drawing;
	using System.Web;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;
	using SK.MemberBLL;

	/// <summary>
	///		cu_ChangePwd 的摘要说明。
	/// </summary>
	public class cu_ChangePwd : BaseControl
	{
		protected SK.MemberWeb.Controls.ControlHolder ControlHolder4;
		protected SK.MemberWeb.Controls.ControlHolder ControlHolder6;
		protected SK.MemberWeb.Controls.ControlHolder ControlHolder5;
		protected System.Web.UI.WebControls.Button btnSave;
		protected System.Web.UI.WebControls.TextBox renewPassword;
		protected System.Web.UI.WebControls.TextBox newPassword;
		protected System.Web.UI.WebControls.TextBox Password;
		protected SK.MemberWeb.Controls.ControlHolder ControlHolder2;
		MemberSystem member = new MemberSystem();

		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			btnSave.Attributes["onclick"]="return CheckInput();";
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		///		设计器支持所需的方法 - 不要使用代码编辑器
		///		修改此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
		public string MemberName
		{
			get{return this.CurrentMemberName.ToString();}
		}

		private void btnSave_Click(object sender, System.EventArgs e)
		{
			BasePape des = new BasePape();
			des.EncryptKey = "sorkednc";
			des.InputString = Password.Text;
			des.DesEncrypt();
			string EncryptString = des.OutString;

			if(member.Login(this.CurrentMemberName,EncryptString)!=DBNull.Value)
			{
				des.EncryptKey = "sorkednc";
				des.InputString = newPassword.Text;
				des.DesEncrypt();
				EncryptString = des.OutString;

				member.UpdatePassword(this.CurrentMemberID,EncryptString);
				this.AlertAndRedir("密码修改成功!","ChangePwd.aspx");
			}
			else
			{
				this.AlertAndRedir("密码错误!","ChangePwd.aspx");
			}
		}
	}
}
