using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class index : System.Web.UI.Page
{
public string UserName;
public string Title, Keywords, Description, ShouQianQQ, ShouHouQQ, CaiWuQQ, TouSuQQ;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Users"] != null)
{
UserName = DBHelper.ExecuteScalar("select UserName from Users where ID='" + Session["Users"] + "'").ToString();
Panel1.Visible = false;
Panel2.Visible = true;
}
else if (Session["SHUsers"] != null)
{
UserName = DBHelper.ExecuteScalar("select UserName from Users where ID='" + Session["SHUsers"] + "'").ToString();
Panel1.Visible = false;
Panel2.Visible = true;
}
else
{
Panel1.Visible = true;
Panel2.Visible = false;
}
if (!IsPostBack)
{
lblcopyright.Text =System.Web.HttpUtility.HtmlDecode(DBHelper.ExecuteScalar("select Copyright from wj_Copyright ").ToString());
WebSiteInfo();
bindType();
bindTop5Type();
bindbanner();
bindNewTuiJian();
bindGongGao();
bindKuaiXun();
BindType();
}
var dt = DBHelper.GetDataTable("select * from KeFuQQ");
ShouQianQQ = dt.Rows[0]["QQNum"].ToString();
ShouHouQQ = dt.Rows[1]["QQNum"].ToString();
CaiWuQQ = dt.Rows[2]["QQNum"].ToString();
TouSuQQ = dt.Rows[3]["QQNum"].ToString();
}
private void BindType()
{
var dt = DBHelper.GetDataTable("select * from NewsType order by ID asc");
rptType.DataSource = dt;
rptType.DataBind();
}
protected void rptType_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string preid = ((DataRowView)e.Item.DataItem).Row["ID"].ToString(); //获得对应ID
Repeater rptNews = (Repeater)e.Item.FindControl("rptNews"); //找到要绑定数据的Repeater
if (rptNews != null)
{
string sqlstr = "select top 5 * from News where NID='" + preid + "' order by ID asc";
rptNews.DataSource = DBHelper.GetDataTable(sqlstr);
rptNews.DataBind();
}
}
}
private void bindGongGao()
{
var dt = DBHelper.GetDataTable("select top 5 * from News where NID=5");
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dt.DefaultView;
if (dt.Rows.Count > 0)
{
this.rptGongGao.DataSource = pds;
this.rptGongGao.DataBind();
}
}
private void bindKuaiXun()
{
var dt = DBHelper.GetDataTable("select top 5 * from News where NID=6");
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dt.DefaultView;
if (dt.Rows.Count > 0)
{
this.rptKuaiXun.DataSource = pds;
this.rptKuaiXun.DataBind();
}
}
public void WebSiteInfo()
{
var dt = Class1.ExecSel("select WS_Title,WS_keywords,WS_description from Site_Config");
this.Title = Convert.ToString(dt.Rows[0]["WS_Title"]);
this.Keywords = Convert.ToString(dt.Rows[0]["WS_keywords"]);
this.Description = Convert.ToString(dt.Rows[0]["WS_description"]);
}
/// <summary>
/// 绑定新品推荐
/// </summary>
private void bindNewTuiJian()
{
var dt = DBHelper.GetDataTable("select top 9 * from SHAd where ShowAd=1 order by id desc");
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dt.DefaultView;
if (dt.Rows.Count > 0)
{
this.rptNewTuiJian.DataSource = pds;
this.rptNewTuiJian.DataBind();
}
}
/// <summary>
/// 绑定banner图
/// </summary>
private void bindbanner()
{
var dt = DBHelper.GetDataTable("select * from banner order by sort asc");
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dt.DefaultView;
if (dt.Rows.Count > 0)
{
this.Repeater8.DataSource = pds;
this.Repeater8.DataBind();
}
}
private void bindType()
{
string sql = "select * from ShangPinType where twoid=0 and threeid=0 order by sort asc";
var dt = DBHelper.GetDataTable(sql);
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dt.DefaultView;
if (dt.Rows.Count > 0)
{
this.Repeater1.DataSource = pds;
this.Repeater1.DataBind();
}
}
private void bindTop5Type()
{
string sql = "select top 5 * from ShangPinType where twoid=0 and threeid=0 order by sort asc";
var dt = DBHelper.GetDataTable(sql);
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dt.DefaultView;
if (dt.Rows.Count > 0)
{
this.Repeater4.DataSource = pds;
this.Repeater4.DataBind();
}
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string preid = ((DataRowView)e.Item.DataItem).Row["oneid"].ToString(); //获得对应ID
Repeater Repeater2 = (Repeater)e.Item.FindControl("Repeater2"); //找到要绑定数据的Repeater
if (Repeater2 != null)
{
Session["repeater1ID"] = preid;
string sqlstr = "select * from ShangPinType where oneid='" + preid + "' and twoid<>0 and threeid=0 order by sort asc";
Repeater2.DataSource = DBHelper.GetDataTable(sqlstr);
Repeater2.DataBind();
}
}
}
protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string preid = ((DataRowView)e.Item.DataItem).Row["twoid"].ToString(); //获得对应ID
Repeater Repeater3 = (Repeater)e.Item.FindControl("Repeater3"); //找到要绑定数据的Repeater
if (Repeater3 != null)
{
string sqlstr = "select * from ShangPinType where oneid='" + Session["repeater1ID"] + "' and twoid='" + preid + "' and threeid<>0 order by sort asc";
Repeater3.DataSource = DBHelper.GetDataTable(sqlstr);
Repeater3.DataBind();
}
}
}
protected void Repeater4_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string preid = ((DataRowView)e.Item.DataItem).Row["oneid"].ToString(); //获得对应ID
Repeater Repeater5 = (Repeater)e.Item.FindControl("Repeater5");
Repeater Repeater6 = (Repeater)e.Item.FindControl("Repeater6"); //找到要绑定数据的Repeater
string sqlstr = "select * from ShangPinType where oneid='" + preid + "' and twoid<>0 and threeid=0 order by sort asc";
if (Repeater5 != null)
{
Repeater5.DataSource = DBHelper.GetDataTable(sqlstr);
Repeater5.DataBind();
}
if (Repeater6 != null)
{
Repeater6.DataSource = DBHelper.GetDataTable(sqlstr);
Repeater6.DataBind();
}
//sqlstr = "select top 8 ID,ImgUrl,SHName,SellPrice,RenQiNum from SHAd where Type1='" + preid + "' and ShowAd=1 order by ID desc";
sqlstr = "select top 8 S.ID,S.ImgUrl,S.Adtitle,S.SellPrice,S.RenQiNum from SHAd S left join Collections C on S.ID=C.SHAdID left join SHinfo SH on SH.SHUserID=S.SHUserID where S.Type1='" + preid + "' and S.ShowAd=1 group by S.ID,S.ImgUrl,S.Adtitle,S.SellPrice,S.RenQiNum order by S.ID desc";
Repeater Repeater7 = (Repeater)e.Item.FindControl("Repeater7");
if (Repeater7!=null)
{
Repeater7.DataSource = DBHelper.GetDataTable(sqlstr);
Repeater7.DataBind();
}
}
}
protected void lbtnExit_Click(object sender, EventArgs e)
{
if (Session["Users"] != null)
{
Session.Remove("Users");
Response.Redirect("/index.aspx");
}
if (Session["SHUsers"] != null)
{
Session.Remove("SHUsers");
Response.Redirect("/index.aspx");
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
Response.Redirect("Serch_Result.aspx?KeyWord=" + txtKeyWord.Text);
}
}
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class index : System.Web.UI.Page
{
public string UserName;
public string Title, Keywords, Description, ShouQianQQ, ShouHouQQ, CaiWuQQ, TouSuQQ;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Users"] != null)
{
UserName = DBHelper.ExecuteScalar("select UserName from Users where ID='" + Session["Users"] + "'").ToString();
Panel1.Visible = false;
Panel2.Visible = true;
}
else if (Session["SHUsers"] != null)
{
UserName = DBHelper.ExecuteScalar("select UserName from Users where ID='" + Session["SHUsers"] + "'").ToString();
Panel1.Visible = false;
Panel2.Visible = true;
}
else
{
Panel1.Visible = true;
Panel2.Visible = false;
}
if (!IsPostBack)
{
lblcopyright.Text =System.Web.HttpUtility.HtmlDecode(DBHelper.ExecuteScalar("select Copyright from wj_Copyright ").ToString());
WebSiteInfo();
bindType();
bindTop5Type();
bindbanner();
bindNewTuiJian();
bindGongGao();
bindKuaiXun();
BindType();
}
var dt = DBHelper.GetDataTable("select * from KeFuQQ");
ShouQianQQ = dt.Rows[0]["QQNum"].ToString();
ShouHouQQ = dt.Rows[1]["QQNum"].ToString();
CaiWuQQ = dt.Rows[2]["QQNum"].ToString();
TouSuQQ = dt.Rows[3]["QQNum"].ToString();
}
private void BindType()
{
var dt = DBHelper.GetDataTable("select * from NewsType order by ID asc");
rptType.DataSource = dt;
rptType.DataBind();
}
protected void rptType_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string preid = ((DataRowView)e.Item.DataItem).Row["ID"].ToString(); //获得对应ID
Repeater rptNews = (Repeater)e.Item.FindControl("rptNews"); //找到要绑定数据的Repeater
if (rptNews != null)
{
string sqlstr = "select top 5 * from News where NID='" + preid + "' order by ID asc";
rptNews.DataSource = DBHelper.GetDataTable(sqlstr);
rptNews.DataBind();
}
}
}
private void bindGongGao()
{
var dt = DBHelper.GetDataTable("select top 5 * from News where NID=5");
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dt.DefaultView;
if (dt.Rows.Count > 0)
{
this.rptGongGao.DataSource = pds;
this.rptGongGao.DataBind();
}
}
private void bindKuaiXun()
{
var dt = DBHelper.GetDataTable("select top 5 * from News where NID=6");
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dt.DefaultView;
if (dt.Rows.Count > 0)
{
this.rptKuaiXun.DataSource = pds;
this.rptKuaiXun.DataBind();
}
}
public void WebSiteInfo()
{
var dt = Class1.ExecSel("select WS_Title,WS_keywords,WS_description from Site_Config");
this.Title = Convert.ToString(dt.Rows[0]["WS_Title"]);
this.Keywords = Convert.ToString(dt.Rows[0]["WS_keywords"]);
this.Description = Convert.ToString(dt.Rows[0]["WS_description"]);
}
/// <summary>
/// 绑定新品推荐
/// </summary>
private void bindNewTuiJian()
{
var dt = DBHelper.GetDataTable("select top 9 * from SHAd where ShowAd=1 order by id desc");
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dt.DefaultView;
if (dt.Rows.Count > 0)
{
this.rptNewTuiJian.DataSource = pds;
this.rptNewTuiJian.DataBind();
}
}
/// <summary>
/// 绑定banner图
/// </summary>
private void bindbanner()
{
var dt = DBHelper.GetDataTable("select * from banner order by sort asc");
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dt.DefaultView;
if (dt.Rows.Count > 0)
{
this.Repeater8.DataSource = pds;
this.Repeater8.DataBind();
}
}
private void bindType()
{
string sql = "select * from ShangPinType where twoid=0 and threeid=0 order by sort asc";
var dt = DBHelper.GetDataTable(sql);
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dt.DefaultView;
if (dt.Rows.Count > 0)
{
this.Repeater1.DataSource = pds;
this.Repeater1.DataBind();
}
}
private void bindTop5Type()
{
string sql = "select top 5 * from ShangPinType where twoid=0 and threeid=0 order by sort asc";
var dt = DBHelper.GetDataTable(sql);
PagedDataSource pds = new PagedDataSource();
pds.DataSource = dt.DefaultView;
if (dt.Rows.Count > 0)
{
this.Repeater4.DataSource = pds;
this.Repeater4.DataBind();
}
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string preid = ((DataRowView)e.Item.DataItem).Row["oneid"].ToString(); //获得对应ID
Repeater Repeater2 = (Repeater)e.Item.FindControl("Repeater2"); //找到要绑定数据的Repeater
if (Repeater2 != null)
{
Session["repeater1ID"] = preid;
string sqlstr = "select * from ShangPinType where oneid='" + preid + "' and twoid<>0 and threeid=0 order by sort asc";
Repeater2.DataSource = DBHelper.GetDataTable(sqlstr);
Repeater2.DataBind();
}
}
}
protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string preid = ((DataRowView)e.Item.DataItem).Row["twoid"].ToString(); //获得对应ID
Repeater Repeater3 = (Repeater)e.Item.FindControl("Repeater3"); //找到要绑定数据的Repeater
if (Repeater3 != null)
{
string sqlstr = "select * from ShangPinType where oneid='" + Session["repeater1ID"] + "' and twoid='" + preid + "' and threeid<>0 order by sort asc";
Repeater3.DataSource = DBHelper.GetDataTable(sqlstr);
Repeater3.DataBind();
}
}
}
protected void Repeater4_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string preid = ((DataRowView)e.Item.DataItem).Row["oneid"].ToString(); //获得对应ID
Repeater Repeater5 = (Repeater)e.Item.FindControl("Repeater5");
Repeater Repeater6 = (Repeater)e.Item.FindControl("Repeater6"); //找到要绑定数据的Repeater
string sqlstr = "select * from ShangPinType where oneid='" + preid + "' and twoid<>0 and threeid=0 order by sort asc";
if (Repeater5 != null)
{
Repeater5.DataSource = DBHelper.GetDataTable(sqlstr);
Repeater5.DataBind();
}
if (Repeater6 != null)
{
Repeater6.DataSource = DBHelper.GetDataTable(sqlstr);
Repeater6.DataBind();
}
//sqlstr = "select top 8 ID,ImgUrl,SHName,SellPrice,RenQiNum from SHAd where Type1='" + preid + "' and ShowAd=1 order by ID desc";
sqlstr = "select top 8 S.ID,S.ImgUrl,S.Adtitle,S.SellPrice,S.RenQiNum from SHAd S left join Collections C on S.ID=C.SHAdID left join SHinfo SH on SH.SHUserID=S.SHUserID where S.Type1='" + preid + "' and S.ShowAd=1 group by S.ID,S.ImgUrl,S.Adtitle,S.SellPrice,S.RenQiNum order by S.ID desc";
Repeater Repeater7 = (Repeater)e.Item.FindControl("Repeater7");
if (Repeater7!=null)
{
Repeater7.DataSource = DBHelper.GetDataTable(sqlstr);
Repeater7.DataBind();
}
}
}
protected void lbtnExit_Click(object sender, EventArgs e)
{
if (Session["Users"] != null)
{
Session.Remove("Users");
Response.Redirect("/index.aspx");
}
if (Session["SHUsers"] != null)
{
Session.Remove("SHUsers");
Response.Redirect("/index.aspx");
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
Response.Redirect("Serch_Result.aspx?KeyWord=" + txtKeyWord.Text);
}
}