278 lines
15 KiB
C#
278 lines
15 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace Mtxfw.shop
|
|
{
|
|
public partial class shop_search : System.Web.UI.Page
|
|
{
|
|
public Mtxfw.DAL.P_Category daoCategory = new Mtxfw.DAL.P_Category();
|
|
public Mtxfw.DAL.P_Product daoProduct = new Mtxfw.DAL.P_Product();
|
|
public Mtxfw.DAL.Ads daoAds = new Mtxfw.DAL.Ads();
|
|
public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config();
|
|
public String TitName = "", strNextPage = "", strcategories = "", rurl = "", strposition = "", strstype="";
|
|
public string strprovince = "", strprovincename = "", strUrl = "/search.html?page={0}";
|
|
protected string AdsName01, AdsName02;
|
|
protected string indexTP01, indexTP02;
|
|
protected string indexTPLink01, indexTPLink02;
|
|
protected int MemberIFStores = 0;
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
if (Session["MemberId"] != null && Session["MemberIFStores"] != null)
|
|
{
|
|
MemberIFStores = int.Parse(Session["MemberIFStores"].ToString());
|
|
}
|
|
System.Data.DataSet Ds_Ads = daoAds.GetCacheList("top 50", "utype=N'首页广告' Order By AdsSort asc", "shop_Ads");
|
|
System.Data.DataTable Dt_Ads = Ds_Ads != null && Ds_Ads.Tables[0] != null ? Ds_Ads.Tables[0] : null;
|
|
int i = 1;
|
|
foreach (System.Data.DataRow Dr in Dt_Ads.Rows)
|
|
{
|
|
if (i == Dt_Ads.Rows.Count)
|
|
{
|
|
indexTP01 = Dr["AdsPic"].ToString();
|
|
indexTPLink01 = Dr["AdsUrl"].ToString();
|
|
AdsName01 = Dr["AdsName"].ToString();
|
|
}
|
|
|
|
i += 1;
|
|
}
|
|
if (!IsPostBack)
|
|
{
|
|
try
|
|
{
|
|
MyPager.UrlRewritePattern = strUrl;
|
|
Data_Bind();
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
}
|
|
protected void Data_Bind()
|
|
{
|
|
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
|
|
|
String ClsID = Mtxfw.Utility.Tools.SafeSQL(Request.QueryString["ClassID"]);
|
|
String Price = Mtxfw.Utility.Tools.SafeSQL(Request.QueryString["Price"]);
|
|
String key = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(Request.QueryString["keyword"]));
|
|
String PageSize = Mtxfw.Utility.Tools.SafeSQL(Request.QueryString["PageSize"]);
|
|
String iPage = Mtxfw.Utility.Tools.SafeSQL(Request.QueryString["Page"]);
|
|
String stype = Mtxfw.Utility.Tools.SafeSQL(Request.QueryString["stype"]);
|
|
String Order = Mtxfw.Utility.Tools.SafeSQL(Request.QueryString["Order"]);
|
|
string strOrder = "P_ID desc";
|
|
Page.Title = "搜索商品-" + strprovincename + "-" + config.webName;
|
|
strposition = "所有商品";
|
|
if (!String.IsNullOrEmpty(stype) && stype != "-1")
|
|
{
|
|
strUrl = "/search-" + stype + ".html?page={0}";
|
|
MyPager.UrlRewritePattern = strUrl;
|
|
if (stype == "0")
|
|
{
|
|
sb.Append(" and P_qgproduct = 1");
|
|
Page.Title = "限时抢购-" + config.webName;
|
|
Page.MetaDescription = "限时抢购-" + config.webName + "-" + config.webDescription;
|
|
Page.MetaKeywords = "限时抢购," + config.webKeywords;
|
|
strposition = "限时抢购";
|
|
}
|
|
if (stype == "1")
|
|
{
|
|
sb.Append(" and P_ppproduct = 1");
|
|
Page.Title = "品牌精选- " + config.webName;
|
|
Page.MetaDescription = "品牌精选-" + config.webName + "-" + config.webDescription;
|
|
Page.MetaKeywords = "品牌精选," + config.webKeywords;
|
|
strposition = "品牌精选";
|
|
strstype = stype;
|
|
}
|
|
if (stype == "2")
|
|
{
|
|
sb.Append(" and P_COMMENDF = 1");
|
|
Page.Title = "热销推荐-" + strprovincename + "-" + config.webName;
|
|
Page.MetaDescription = "热销推荐-" + strprovincename + "-" + config.webName + "-" + config.webDescription;
|
|
Page.MetaKeywords = "热销推荐," + config.webKeywords;
|
|
strposition = "热销推荐";
|
|
}
|
|
if (stype == "3")
|
|
{
|
|
Page.Title = "新品上市-" + config.webName;
|
|
Page.MetaDescription = "新品上市-" + config.webName + "-" + config.webDescription;
|
|
Page.MetaKeywords = "新品上市," + config.webKeywords;
|
|
strposition = "新品上市";
|
|
}
|
|
if (stype == "4")
|
|
{
|
|
strOrder = "P_Orders Desc";
|
|
Page.Title = "热销商品-" + config.webName;
|
|
Page.MetaDescription = "热销商品-" + config.webName + "-" + config.webDescription;
|
|
Page.MetaKeywords = "热销商品," + config.webKeywords;
|
|
strposition = "热销商品";
|
|
}
|
|
}
|
|
int strPID = 0;
|
|
if (!String.IsNullOrEmpty(ClsID) && ClsID != "-1")
|
|
{
|
|
ClsID = Mtxfw.Utility.Tools.SafeSQL(ClsID);
|
|
strUrl = "/search-class-" + ClsID + ".html?page={0}";
|
|
MyPager.UrlRewritePattern = strUrl;
|
|
System.Data.DataSet Ds = daoCategory.GetList("(select b.C_NAME From P_Category b where b.C_ID=a.C_PARENTID) as PNAME,(select b.C_ProductCount From P_Category b where b.C_ID=a.C_PARENTID) as PProductCount,(select count(b.C_ID) From P_Category b where b.C_PARENTID=a.C_ID) as IsChild,", "C_ID=" + ClsID);
|
|
if (Ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
string C_PARENTID = Ds.Tables[0].Rows[0]["C_PARENTID"].ToString();
|
|
string C_NAME = Ds.Tables[0].Rows[0]["C_NAME"].ToString();
|
|
string PNAME = Ds.Tables[0].Rows[0]["PNAME"].ToString();
|
|
string PNAME2 = PNAME;
|
|
string C_ID = Ds.Tables[0].Rows[0]["C_ID"].ToString();
|
|
string C_ProductCount = Ds.Tables[0].Rows[0]["C_ProductCount"].ToString();
|
|
string PProductCount = Ds.Tables[0].Rows[0]["PProductCount"].ToString();
|
|
string IsChild = Ds.Tables[0].Rows[0]["IsChild"].ToString();
|
|
string C_Layer = Ds.Tables[0].Rows[0]["C_Layer"].ToString();
|
|
if (C_Layer == "3")
|
|
{
|
|
|
|
strPID = int.Parse(C_PARENTID);
|
|
System.Data.DataSet Dss = daoCategory.GetList("(select b.C_NAME From P_Category b where b.C_ID=a.C_PARENTID) as PNAME,", "C_ID=" + C_PARENTID);
|
|
if (Dss.Tables[0].Rows.Count > 0)
|
|
{
|
|
string C_PARENTID2 = Dss.Tables[0].Rows[0]["C_PARENTID"].ToString();
|
|
string CPNAME2 = Dss.Tables[0].Rows[0]["PNAME"].ToString();
|
|
strposition = "<a href=\"/search-class-" + C_PARENTID2 + ".html\">" + CPNAME2 + "</a> > <a href=\"/search-class-" + C_PARENTID + ".html\">" + PNAME + "</a> > " + C_NAME + "";
|
|
Page.Title = C_NAME + "-" + PNAME2 + "-" + config.webName;
|
|
Page.MetaDescription = C_NAME + "-" + PNAME2 + "-" + config.webName + "-" + config.webDescription;
|
|
Page.MetaKeywords = C_NAME + "," + PNAME2 + "," + config.webKeywords.Replace("广西", strprovincename);
|
|
}
|
|
|
|
PNAME = "<a href=\"/search-class-" + C_PARENTID + ".html\" class='mainmenuactive' >" + PNAME + "<span></span></a>\n";//(" + PProductCount + ")
|
|
|
|
}
|
|
else if (C_Layer == "2")
|
|
{
|
|
strPID = int.Parse(C_PARENTID);
|
|
Page.Title = C_NAME + "-" + PNAME2 + "-" + config.webName;
|
|
Page.MetaDescription = C_NAME + "-" + PNAME2 + "-" + config.webName + "-" + config.webDescription;
|
|
Page.MetaKeywords = C_NAME + "," + PNAME2 + "," + config.webKeywords.Replace("广西", strprovincename);
|
|
strposition = "<a href=\"/shop_search.aspx?ClassID=" + C_PARENTID + "\">" + PNAME + "</a> > " + C_NAME + "";
|
|
PNAME = "<a href=\"/search-class-" + C_PARENTID + ".html\" class='mainmenuactive' >" + PNAME + "<span></span></a>\n";//(" + PProductCount + ")
|
|
}
|
|
else
|
|
{
|
|
strPID = int.Parse(ClsID);
|
|
Page.Title = C_NAME + "-" + config.webName;
|
|
Page.MetaDescription = C_NAME + "-" + config.webName + "-" + config.webDescription;
|
|
Page.MetaKeywords = C_NAME + "," + config.webKeywords;
|
|
strposition = "" + C_NAME + "";
|
|
string strurl = "";
|
|
if (strPID == 152)
|
|
{
|
|
strurl = "/view-2540.html";
|
|
}
|
|
else
|
|
{
|
|
strurl = "/search-class-" + strPID + ".html";
|
|
}
|
|
PNAME = "<a href=\"" + strurl + "\" class='mainmenuactive' >" + C_NAME + "<span></span></a>\n";//(" + C_ProductCount + ")
|
|
}
|
|
strcategories += "<div id=\"categoriescon\"><div id=\"categoriescontitle\">分类筛选</div>\n";
|
|
strcategories += "<div id=\"categorieslist\"><UL><LI class=\"categorieslistlast\">" + PNAME + "\n";
|
|
System.Data.DataSet Ds2 = daoCategory.GetList("C_PARENTID=" + strPID + " And IfShow=0");
|
|
if (Ds2.Tables[0].Rows.Count > 0)
|
|
{
|
|
for (int i = 0; i < Ds2.Tables[0].Rows.Count; i++)
|
|
{
|
|
C_NAME = Ds2.Tables[0].Rows[i]["C_NAME"].ToString();
|
|
C_ID = Ds2.Tables[0].Rows[i]["C_ID"].ToString();
|
|
C_ProductCount = Ds2.Tables[0].Rows[i]["C_ProductCount"].ToString();
|
|
string strurl = "";
|
|
if (C_ID == "162")
|
|
{
|
|
strurl = "/view-2523.html";
|
|
}
|
|
else if (C_ID == "163")
|
|
{
|
|
strurl = "/view-2522.html";
|
|
}
|
|
else
|
|
{
|
|
strurl = "/search-class-" + C_ID + ".html";
|
|
}
|
|
strcategories += "<UL><LI><span class=\"selectedlist\"><a href=\"" + strurl + "\" >" + C_NAME + "<span></span></a></span></LI></UL>\n";//(" + C_ProductCount + ")
|
|
}
|
|
}
|
|
Ds2.Clear();
|
|
strcategories += "</li></ul>\n";
|
|
strcategories += "</div></div>";
|
|
//Page.MetaDescription = C_NAME + "-" + config.webName + "-" + config.webDescription;
|
|
//Page.MetaKeywords = C_NAME + "-" + config.webKeywords.Replace("广西", strprovincename);
|
|
}
|
|
Ds.Clear();
|
|
|
|
sb.Append(" and (P_CATEGORY=" + Mtxfw.Utility.Tools.SafeSQL(ClsID) + " Or P_CATEGORYs like '%," + Mtxfw.Utility.Tools.SafeSQL(ClsID) + ",%') And P_ppproduct=0");
|
|
}
|
|
if (!String.IsNullOrEmpty(key))
|
|
{
|
|
key = Mtxfw.Utility.Tools.SafeSQL(key);
|
|
strUrl = "/search.html?keyword=" + key + "&page={0}";
|
|
MyPager.UrlRewritePattern = strUrl;
|
|
sb.Append(" and (P_NAME like '%" + key + "%')");
|
|
}
|
|
if (!String.IsNullOrEmpty(Price) && Price != "-1")
|
|
{
|
|
strUrl += "&Price=" + Price + "";
|
|
MyPager.UrlRewritePattern = strUrl;
|
|
string[] APrice = Price.Split(',');
|
|
if(APrice[0]!="")
|
|
{
|
|
sb.Append(" and P_VIP_P>=" + Mtxfw.Utility.Tools.SafeSQL(APrice[0]));
|
|
}
|
|
if (APrice[01] != "")
|
|
{
|
|
sb.Append(" and P_VIP_P<=" + Mtxfw.Utility.Tools.SafeSQL(APrice[1]));
|
|
}
|
|
}
|
|
|
|
|
|
if (!String.IsNullOrEmpty(Order))
|
|
{
|
|
strUrl += "&Order=" + Order + "";
|
|
MyPager.UrlRewritePattern = strUrl;
|
|
if (Order=="0")
|
|
{
|
|
strOrder = "P_Orders desc";
|
|
}
|
|
if (Order == "1")
|
|
{
|
|
strOrder = "P_VIP_P desc";
|
|
}
|
|
if (Order == "2")
|
|
{
|
|
strOrder = "P_PJOrders desc";
|
|
}
|
|
if (Order == "2")
|
|
{
|
|
strOrder = "P_ADDATE desc";
|
|
}
|
|
}
|
|
|
|
MyPager.PageSize = 32;
|
|
if (!String.IsNullOrEmpty(PageSize) && PageSize != "")
|
|
{
|
|
strUrl += "&PageSize=" + PageSize + "";
|
|
MyPager.UrlRewritePattern = strUrl;
|
|
PageSize = int.Parse(PageSize).ToString();
|
|
MyPager.PageSize = int.Parse(PageSize);
|
|
}
|
|
if (!String.IsNullOrEmpty(iPage) && iPage != "-1")
|
|
{
|
|
MyPager.CurrentPageIndex = int.Parse(iPage);
|
|
}
|
|
MyPager.RecordCount = daoProduct.GetCount("utype='0' and P_State='已处理'" + sb.ToString());
|
|
Mtxfw.Utility.Tools.ToBind(Repeater_shop, daoProduct.GetPager(MyPager, "", "utype='0' and P_State='已处理'" + sb.ToString() + " Order by " + strOrder));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
} |