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 System.Data.SqlClient;

namespace norke
{
	/// <summary>
	/// Default 的摘要说明。
	/// </summary>
	public partial class Default : System.Web.UI.Page
	{
    
		protected void Page_Load(object sender, System.EventArgs e)
		{
            if( !IsPostBack )
            {
                getHotDataList();//热卖产品
                getNewDataList();
                getTJDataList();//精品推荐
                getAnnounce();//获取公告信息
                qqDataList();
                zsDataList();
            }
		}
        private void getHotDataList()//推荐产品
        {
            DBConn myDB = new DBConn();
            string sql = "select top 6 PID,PPicture,substring(pname,0,8)+'...' as pname from Products where PCommend=1 order by PID desc";
            HDataList.DataSource = myDB.getDataReader(sql);
            HDataList.DataBind();
            myDB.Close();
        }
        private void getNewDataList()//最新上架
        {
            DBConn myDB = new DBConn();
            string sql = "select top 9 * from Products order by PID desc";
            NDataList.DataSource = myDB.getDataReader(sql);
            NDataList.DataBind();
            myDB.Close();
        }
        private void getAnnounce()//获取公告信息
        {
            string mySql="select * from append where id='3'";
            
            DBConn myDB = new DBConn();
            SqlDataReader mydr  = myDB.getDataReader( mySql );
            if( mydr.Read() )
            {
                lblAnnounce.Text = CleanString.htmlOutputText( mydr["text"].ToString() );
            }
            mydr.Close();
            myDB.Close();        
        }  
        private void qqDataList()//求购
        {
            DBConn mydb = new DBConn();
            string sql = "select top 16 qid,qname from qqproduct";
            DataList1.DataSource = mydb.getDataReader(sql);
            DataList1.DataBind();
            mydb.Close();
        }

        private void zsDataList()//创业
        {
            DBConn mydb = new DBConn();
            string sql = "select top 8 id,zname,zimg from zhaoshang order by id desc";
            DataList2.DataSource = mydb.getDataReader(sql);
            DataList2.DataBind();
            mydb.Close();
        }
        private void getTJDataList()//单位
        {
            DBConn myDB = new DBConn();
            string sql = "select top 10 hyname,gsname from Muser order by id desc";
            JRepeater.DataSource = myDB.getDataReader( sql );
            JRepeater.DataBind();
            myDB.Close();  
        }

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

        }
		#endregion
       
	}
}
