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_SendMessage 的摘要说明。
	/// </summary>
	public class cu_SendMessage : BaseControl
	{
		protected SK.MemberWeb.Controls.ControlHolder ControlHolder4;
		protected System.Web.UI.WebControls.TextBox TextBox1;
		MemberSystem member = new MemberSystem();
		protected SK.MemberWeb.Controls.ControlHolder ControlHolder5;
		protected SK.MemberWeb.Controls.ControlHolder ControlHolder7;
		protected System.Web.UI.WebControls.Button btnSend;
		protected System.Web.UI.WebControls.TextBox txtBody;
		protected System.Web.UI.WebControls.TextBox txtSubject;
		protected System.Web.UI.WebControls.TextBox txtReceiver;
		protected SK.MemberWeb.Controls.ControlHolder ControlHolder6;
		protected SK.MemberWeb.Controls.ControlHolder ControlHolder2;
		protected SK.MemberWeb.Controls.ControlHolder ControlHolder3;
		MessageSystem msg = new MessageSystem();

		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			txtBody.Attributes["onkeydown"] = "textCounter(document.getElementById('"+txtBody.ClientID+"'),document.getElementById('remtxtBody'),1000);";
			txtBody.Attributes["onkeyup"] = "textCounter(document.getElementById('"+txtBody.ClientID+"'),document.getElementById('remtxtBody'),1000);";
			btnSend.Attributes["onclick"] = "return SendMessage_CheckInput();";
			if(!IsPostBack)
			{
				ViewState["MemberName"] = Request.QueryString["name"];
				if(!(ViewState["MemberName"]==null||ViewState["MemberName"].ToString()==""))
				{
					txtReceiver.Text = ViewState["MemberName"].ToString();
				}
			}
		}

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

		}
		#endregion

		private void btnSend_Click(object sender, System.EventArgs e)
		{
			DataRow dr = member.Info_Name(txtReceiver.Text);
			if(dr==null)
			{
				this.DisplayAlert("该用户名不存在!");
			}
			else
			{
				msg.Add(txtSubject.Text,txtBody.Text,this.CurrentMemberID,dr["MemberID"]);
				Response.Redirect("MemberMsg.aspx?msg="+Server.UrlEncode("消息成功发送"));
			}
		}
	}
}