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 DAL;

namespace flash
{
	/// <summary>
	/// flash 的摘要说明。
	/// </summary>
	public partial class flash1 : PageBase
	{
		public int FlashID;
		public string title;
		public string content;

		public string img;


		protected void Page_Load(object sender, System.EventArgs e)
		{
			int id = int.Parse(Request.QueryString["id"]);

			string sql = string.Format("select top 1 * from flash where id={0}", id);
			DataTable dt = DAL.DataProvider.ExecuteSql(sql);
			if (dt != null && dt.Rows.Count>0)
			{
				this.FlashID = id;
				this.title = dt.Rows[0]["title"].ToString();
				this.content = dt.Rows[0]["content"].ToString();

				DataTable dtClass = DataProvider.ExecuteSql("select top 1 * from class where id=" + dt.Rows[0]["class"].ToString());
				Literal1.Text = dtClass.Rows[0]["classname"].ToString();

				ClassName.Text = dtClass.Rows[0]["classname"].ToString();
				HyperLink1.Text = dtClass.Rows[0]["classname"].ToString() + "类";
				HyperLink1.NavigateUrl = "/" + dt.Rows[0]["class"].ToString() + "_1.aspx";

				string[] pic = dt.Rows[0]["picture"].ToString().Split(',');
				for (int i = 0; i < pic.Length; i++)
				{
					img += "<a href=\"/play_" + id + ".aspx\" target=\"_blank\"><img src=\"" + Global.GetPicture(pic[i]) + "\" alt=\"" + title + "\" width=\"100\" height=\"75\" border=\"0\" /></a>&nbsp;";
				}

				this.CacheFile = string.Format("/CacheFile/{0}.html", id);

				sql = string.Format("select top 20 id,title from flash where class={0} and isrecomment=1 order by id desc", dt.Rows[0]["class"].ToString());
				recomment.DataSource = DAL.DataProvider.ExecuteSql(sql);
				recomment.DataBind();

				sql = string.Format("select top 9 id,title from flash order by newid()");
				randomFlash.DataSource = DAL.DataProvider.ExecuteSql(sql);
				randomFlash.DataBind();

				sql = string.Format("select top 9 id,title from flash where class={0} and isrecomment=1", dt.Rows[0]["class"].ToString());
				Repeater1.DataSource = DAL.DataProvider.ExecuteSql(sql);
				Repeater1.DataBind();

			}
		}

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