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;

namespace flash
{
	/// <summary>
	/// Search 的摘要说明。
	/// </summary>
	public partial class Search : System.Web.UI.Page
	{
		protected string status = "";
		protected string key;


		protected void Page_Load(object sender, System.EventArgs e)
		{
			key = Request.QueryString["key"];
			if (key != null)
				key = HttpUtility.HtmlEncode(key);

			string pc = Request.QueryString["pc"];
			if (pc == null)
				pc = "1";

			int PageCurrent = int.Parse(pc);

			string sql = null;

			sql = string.Format("select top 20 id,title from flash where isrecomment=1 order by newid() desc");
			recomment.DataSource = DAL.DataProvider.ExecuteSql(sql);
			recomment.DataBind();

			int count = -1;
			flash.DataSource = DAL.DataProvider.GetList(out count, true, "flash", 30, PageCurrent-1, "id,title,picture", "id", string.Format("title like '%{0}%'", key.Replace("'", "''")), "desc");
			flash.DataBind();
			pager1.UrlFormat = "/Search.aspx?key=" + HttpUtility.UrlEncode(key, System.Text.Encoding.GetEncoding("GB2312")).ToUpper() + "&pc={0}";
			pager1.RecordCount = count;

			if (count == 0)
				this.status = "<p>没有找到，请尝试其他搜索词</p>";

		}

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