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_LeaveWord 的摘要说明。
	/// </summary>
	public class cu_LeaveWord : BaseControl
	{
		protected System.Web.UI.WebControls.Button btnSubmit;
		protected System.Web.UI.WebControls.TextBox txtTrueName;
		protected System.Web.UI.WebControls.RadioButtonList rblSex;
		protected System.Web.UI.WebControls.TextBox txtEmail;
		protected System.Web.UI.WebControls.TextBox txtTel;
		protected System.Web.UI.WebControls.TextBox txtBody;
		protected System.Web.UI.WebControls.TextBox txtVerifyCode;
		protected SK.MemberWeb.Controls.ControlHolder ControlHolder3;
		LeaveWordSystem word = new LeaveWordSystem();
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			btnSubmit.Attributes["onclick"] = "return cu_LeaveWord_CheckInput();";
		}

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

		}
		#endregion

		private void btnSubmit_Click(object sender, System.EventArgs e)
		{
			if(Session["verifycode"]==null)
			{
				this.AlertAndRedir("超时，验证码丢失，将刷新本页","/LeaveWord.aspx");
				return;
			}
			if(txtVerifyCode.Text.ToUpper()!=Session["verifycode"].ToString().ToUpper())
			{
				this.DisplayAlert("验证码错误");
				return;
			}
			word.Add(txtTrueName.Text,rblSex.SelectedValue,txtTel.Text,txtEmail.Text,txtBody.Text);
			Response.Redirect("Msg.aspx?msg="+Server.UrlEncode("留言已成功提交"));
		}

	}
}
