namespace baoge
{
	using System;
	using System.Data;
	using System.Drawing;
	using System.Web;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;
	using System.Data.OleDb;

	/// <summary>
	///		header 的摘要说明。
	/// </summary>
	public class header : System.Web.UI.UserControl
	{


		public string WebName,WebUrl,WebLogo,WebEmail,CAddress,CTel,CQQ,Webcopyright;
		protected System.Web.UI.WebControls.DataList DataList2;
		protected System.Web.UI.WebControls.DataList DataList3;
		protected System.Web.UI.WebControls.DataList DataList4;
		protected System.Web.UI.WebControls.DataList DataList5;
		protected System.Web.UI.WebControls.DataList DataList6;
		protected System.Web.UI.WebControls.DataList DataList7;
		protected System.Web.UI.WebControls.DataList DataList8;
		protected System.Web.UI.WebControls.DataList DataList9;
		protected System.Web.UI.WebControls.DataList DataList1;


		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面

			if(!IsPostBack)
			{
				SystemBaseDataBind();
				Naviget();
                Naviget1();
				Naviget2();
                Naviget3();
				Naviget4();
			}

		}


		private void SystemBaseDataBind()
		{
			//取得数据库路径
			string dbPath=System.Configuration.ConfigurationSettings.AppSettings["dbPath"];
			//定义连接字符串
			string ACconnStr="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath(dbPath);
			//创建数据库对像
			OleDbConnection ACconn=new OleDbConnection(ACconnStr);
			//数据库操作
			try
			{
				ACconn.Open();
				//取得所需操作的记录ID

				//定义SQL语句
				string ACsql="select ID,WebName,WebUrl,WebLogo,WebEmail,CAddress,CTel,CQQ,Webcopyright from Config where ID=1";
				//创建Command对像
				OleDbCommand ACcomm=new OleDbCommand(ACsql,ACconn);
				//通过执行Command实例化DataReader类
				OleDbDataReader ACdr=ACcomm.ExecuteReader();
				if(ACdr.Read())
				{
					WebName=ACdr["WebName"].ToString();
					WebUrl=ACdr["WebUrl"].ToString();
					WebLogo=ACdr["WebLogo"].ToString();
					WebEmail=ACdr["WebEmail"].ToString();
					CAddress=ACdr["CAddress"].ToString();
					CTel=ACdr["CTel"].ToString();
					CQQ=ACdr["CQQ"].ToString();
					Webcopyright=ACdr["Webcopyright"].ToString();

					ACdr.Close();

				}
				else
				{
					Response.Write("对不起，请先填加网站信息");
				}
			
			}
			catch(Exception ex)
			{
				Response.Write(ex.ToString());
			}
			finally
			{
				ACconn.Close();

			}
		}




	
//		public string Naviget()
//		{
//			//取得数据库路径
//			string dbPath=System.Configuration.ConfigurationSettings.AppSettings["dbPath"];
//			//定义连接字符串
//			string ACconnStr="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath(dbPath);
//			//创建数据库对像
//			OleDbConnection ACconn=new OleDbConnection(ACconnStr);
//
//            ACconn.Open();
//			
//
//			string Naviget=null;//新闻主体
//			//定义SQL语句
//			string ACsql="select * from Channel where ispic=false and issoft=false and isphoto=false";
//
//			//创建Command对像
//			OleDbCommand ACcomm=new OleDbCommand(ACsql,ACconn);
//			
//			//通过执行Command实例化DataReader类
//			OleDbDataReader ACdr=ACcomm.ExecuteReader();
//		
//			
//			while(ACdr.Read ())//循环读取
//			{
////				if((int)ACdr["ChannelID"]!=31)
////				{
//					Naviget+=" "+" "+"|"+" "+" ";
//					Naviget+="<a class=Na href='ListChannel.aspx?id="+ACdr["ChannelID"]+"' target=_blank>"+ACdr["ChannelName"]+"</a>";
////				}
//			}
//			ACdr.Close();//切记一定要关闭阅读器
//			ACconn.Close();
//			return Naviget;
//			
//
//		}

		private void Naviget()
		{
			//取得数据库路径
			string dbPath=System.Configuration.ConfigurationSettings.AppSettings["dbPath"];
			//定义连接字符串
			string ACconnStr="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath(dbPath);
			//创建数据库对像
			OleDbConnection con=new OleDbConnection(ACconnStr);

			OleDbDataAdapter sda=new OleDbDataAdapter();
			sda.SelectCommand=new OleDbCommand("select * from Channel where ispic=false and issoft=false and isphoto=false",con);
			DataSet ds=new DataSet();
			sda.Fill(ds,"Channel");
			this.DataList1.DataSource=ds.Tables["Channel"];
			this.DataList1.DataBind();

			sda.Dispose();
			con.Close();
//			OleDbCommand cmd=new OleDbCommand("select * from Channel where ispic=false and issoft=false and isphoto=false",con);
            
//			string Naviget=null;//新闻主体
//			//定义SQL语句
//			string ACsql="select * from Channel where ispic=false and issoft=false and isphoto=false";
//
//			//创建Command对像
//			OleDbCommand ACcomm=new OleDbCommand(ACsql,ACconn);
//			
//			//通过执行Command实例化DataReader类
//			OleDbDataReader ACdr=ACcomm.ExecuteReader();
//		
//			
//			while(ACdr.Read ())//循环读取
//			{
//				//				if((int)ACdr["ChannelID"]!=31)
//				//				{
//				Naviget+=" "+" "+"|"+" "+" ";
//				Naviget+="<a class=Na href='ListChannel.aspx?id="+ACdr["ChannelID"]+"' target=_blank>"+ACdr["ChannelName"]+"</a>";
//				//				}
//			}
//			ACdr.Close();//切记一定要关闭阅读器
//			ACconn.Close();
//			return Naviget;
			

		}

		private void Naviget1()
		{


			//取得数据库路径
			string dbPath=System.Configuration.ConfigurationSettings.AppSettings["dbPath"];
			//定义连接字符串
			string ACconnStr="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath(dbPath);
			//创建数据库对像
			OleDbConnection con=new OleDbConnection(ACconnStr);

			OleDbDataAdapter sda=new OleDbDataAdapter();
			sda.SelectCommand=new OleDbCommand("select * from Channel where ispic=true and issoft=false and isphoto=false",con);
			DataSet ds=new DataSet();
			sda.Fill(ds,"Channel");
			this.DataList6.DataSource=ds.Tables["Channel"];
			this.DataList6.DataBind();

            sda.Dispose();
			con.Close();

//			//取得数据库路径
//			string dbPath=System.Configuration.ConfigurationSettings.AppSettings["dbPath"];
//			//定义连接字符串
//			string ACconnStr="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath(dbPath);
//			//创建数据库对像
//			OleDbConnection ACconn=new OleDbConnection(ACconnStr);
//
//			ACconn.Open();
//			
//
//			string Naviget1=null;//新闻主体
//			//定义SQL语句
//			string ACsql="select * from Channel where ispic=true and issoft=false and isphoto=false";
//
//			//创建Command对像
//			OleDbCommand ACcomm=new OleDbCommand(ACsql,ACconn);
//			
//			//通过执行Command实例化DataReader类
//			OleDbDataReader ACdr=ACcomm.ExecuteReader();
//		
//			
//			while(ACdr.Read ())//循环读取
//			{
////				if((int)ACdr["ChannelID"]==31)
////				{
//					Naviget1+=" "+" "+"|"+" "+" ";
//					Naviget1+="<a class=Na href='listChanelPic.aspx?id="+ACdr["ChannelID"]+"' target=_blank>"+ACdr["ChannelName"]+"</a>";
////				}
//			}
//			ACdr.Close();//切记一定要关闭阅读器
//			ACconn.Close();
//			return Naviget1;
			

		}

		private void Naviget2()
		{


			//取得数据库路径
			string dbPath=System.Configuration.ConfigurationSettings.AppSettings["dbPath"];
			//定义连接字符串
			string ACconnStr="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath(dbPath);
			//创建数据库对像
			OleDbConnection con=new OleDbConnection(ACconnStr);

			OleDbDataAdapter sda=new OleDbDataAdapter();
			sda.SelectCommand=new OleDbCommand("select * from Channel where ispic=false and issoft=true and isphoto=false",con);
			DataSet ds=new DataSet();
			sda.Fill(ds,"Channel");
			this.DataList7.DataSource=ds.Tables["Channel"];
			this.DataList7.DataBind();

			sda.Dispose();
			con.Close();
//			//取得数据库路径
//			string dbPath=System.Configuration.ConfigurationSettings.AppSettings["dbPath"];
//			//定义连接字符串
//			string ACconnStr="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath(dbPath);
//			//创建数据库对像
//			OleDbConnection ACconn=new OleDbConnection(ACconnStr);
//
//			ACconn.Open();
//			
//
//			string Naviget2=null;//新闻主体
//			//定义SQL语句
//			string ACsql="select * from Channel where ispic=false and issoft=true and isphoto=false";
//
//			//创建Command对像
//			OleDbCommand ACcomm=new OleDbCommand(ACsql,ACconn);
//			
//			//通过执行Command实例化DataReader类
//			OleDbDataReader ACdr=ACcomm.ExecuteReader();
//		
//			
//			while(ACdr.Read ())//循环读取
//			{
//				//				if((int)ACdr["ChannelID"]==31)
//				//				{
//				Naviget2+=" "+" "+"|"+" "+" ";
//				Naviget2+="<a class=Na href='listChanelSoft.aspx?id="+ACdr["ChannelID"]+"' target=_blank>"+ACdr["ChannelName"]+"</a>";
//				//				}
//			}
//			ACdr.Close();//切记一定要关闭阅读器
//			ACconn.Close();
//			return Naviget2;
			

		}

		private void Naviget3()
		{


			//取得数据库路径
			string dbPath=System.Configuration.ConfigurationSettings.AppSettings["dbPath"];
			//定义连接字符串
			string ACconnStr="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath(dbPath);
			//创建数据库对像
			OleDbConnection con=new OleDbConnection(ACconnStr);

			OleDbDataAdapter sda=new OleDbDataAdapter();
			sda.SelectCommand=new OleDbCommand("select * from Channel where ispic=false and issoft=false and isphoto=true",con);
			DataSet ds=new DataSet();
			sda.Fill(ds,"Channel");
			this.DataList8.DataSource=ds.Tables["Channel"];
			this.DataList8.DataBind();

			sda.Dispose();
			con.Close();
//			//取得数据库路径
//			string dbPath=System.Configuration.ConfigurationSettings.AppSettings["dbPath"];
//			//定义连接字符串
//			string ACconnStr="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath(dbPath);
//			//创建数据库对像
//			OleDbConnection ACconn=new OleDbConnection(ACconnStr);
//
//			ACconn.Open();
//			
//
//			string Naviget3=null;//新闻主体
//			//定义SQL语句
//			string ACsql="select * from Channel where ispic=false and issoft=false and isphoto=true";
//
//			//创建Command对像
//			OleDbCommand ACcomm=new OleDbCommand(ACsql,ACconn);
//			
//			//通过执行Command实例化DataReader类
//			OleDbDataReader ACdr=ACcomm.ExecuteReader();
//		
//			
//			while(ACdr.Read ())//循环读取
//			{
//				//				if((int)ACdr["ChannelID"]==31)
//				//				{
//				Naviget3+=" "+" "+"|"+" "+" ";
//				Naviget3+="<a class=Na href='listChanelPhoto.aspx?id="+ACdr["ChannelID"]+"' target=_blank>"+ACdr["ChannelName"]+"</a>";
//				//				}
//			}
//			ACdr.Close();//切记一定要关闭阅读器
//			ACconn.Close();
//			return Naviget3;
			

		}

		private void Naviget4()
		{



			//取得数据库路径
			string dbPath=System.Configuration.ConfigurationSettings.AppSettings["dbPath"];
			//定义连接字符串
			string ACconnStr="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath(dbPath);
			//创建数据库对像
			OleDbConnection con=new OleDbConnection(ACconnStr);

			OleDbDataAdapter sda=new OleDbDataAdapter();
			sda.SelectCommand=new OleDbCommand("select * from Channel where ispic=false and issoft=false and isphoto=false and ismovie=true",con);
			DataSet ds=new DataSet();
			sda.Fill(ds,"Channel");
			this.DataList9.DataSource=ds.Tables["Channel"];
			this.DataList9.DataBind();
			
			sda.Dispose();
			con.Close();
//			//取得数据库路径
//			string dbPath=System.Configuration.ConfigurationSettings.AppSettings["dbPath"];
//			//定义连接字符串
//			string ACconnStr="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath(dbPath);
//			//创建数据库对像
//			OleDbConnection ACconn=new OleDbConnection(ACconnStr);
//
//			ACconn.Open();
//			
//
//			string Naviget4=null;//新闻主体
//			//定义SQL语句
//			string ACsql="select * from Channel where ispic=false and issoft=false and isphoto=false and ismovie=true";
//
//			//创建Command对像
//			OleDbCommand ACcomm=new OleDbCommand(ACsql,ACconn);
//			
//			//通过执行Command实例化DataReader类
//			OleDbDataReader ACdr=ACcomm.ExecuteReader();
//		
//			
//			while(ACdr.Read ())//循环读取
//			{
//				//				if((int)ACdr["ChannelID"]==31)
//				//				{
//				Naviget4+=" "+" "+"|"+" "+" ";
//				Naviget4+="<a class=Na href='listChanelMovie.aspx?id="+ACdr["ChannelID"]+"' target=_blank>"+ACdr["ChannelName"]+"</a>";
//				//				}
//			}
//			ACdr.Close();//切记一定要关闭阅读器
//			ACconn.Close();
//			return Naviget4;
			

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

		}
		#endregion
	}
}


