using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using SK.MemberBLL;

namespace SK.MemberWeb.admin
{
	/// <summary>
	/// LeaveWordList 的摘要说明。
	/// </summary>
	public class LeaveWordList : BasePage
	{
		protected Wuqi.Webdiyer.AspNetPager pager;
		protected System.Web.UI.WebControls.TextBox txtKeyword;
		protected System.Web.UI.WebControls.Button btnSearch;
		protected System.Web.UI.WebControls.Repeater lstWord;
		LeaveWordSystem word = new LeaveWordSystem();
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if(!IsPostBack)
			{
				BindData();
			}
		}

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

		}
		#endregion
		protected void Delete_Load(object sender, System.EventArgs e)
		{
			((LinkButton)sender).Attributes["onclick"]="return confirm('您确定要删除这条留言吗？');";
		}
		private void BindData()
		{

			pager.RecordCount = word.List_Count(txtKeyword.Text);
			lstWord.DataSource = word.List(pager.PageSize,pager.CurrentPageIndex,txtKeyword.Text);
			lstWord.DataBind();
		}

		private void btnSearch_Click(object sender, System.EventArgs e)
		{
			pager.CurrentPageIndex = 1;
			BindData();
		}

		private void pager_PageChanged(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
		{
			pager.CurrentPageIndex = e.NewPageIndex;
			BindData();
		}

		private void lstWord_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
		{
			if(e.CommandName=="Delete")
			{
				word.Delete(e.CommandArgument);
			}
			BindData();
		}
	}
}
