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 CascadeMenu : System.Web.UI.UserControl
{
string strClassOne;
string strClassTwo;
string strMerchandises;
protected void Page_Load(object sender, EventArgs e)
{
#region 获取大类别的sql语句
if (Session["Lang"] != null)
{
if (Session["Lang"].ToString() == "zh-cn")
{
strClassOne = " select * from ( select Id, ParentId ,name_cn AS Name ,Visiable from v3_m_category where ParentId =0 ) as class where Visiable=1 or visiable =3";
}
else
{
strClassOne = "select * from ( select Id, ParentId ,name_en AS Name ,Visiable from v3_m_category where ParentId =0 ) as class where Visiable=1 or visiable =3";
}
}
else
{
strClassOne = " select * from ( select Id, ParentId ,name_cn AS Name ,Visiable from v3_m_category where ParentId =0 ) as class where Visiable=1 or visiable =3";
}
#endregion
DataTable dtClassOne = DBH.DBHelper.GetDataSet(strClassOne); // 获取大类别,并绑定数据
RptClassOneName.DataSource = dtClassOne;
RptClassOneName.DataBind();
}
///
/// 更具大类别绑定小类别名称
///
///
///
protected void RptClassOneName_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
//判断里层repeater处于外层repeater的哪个位置
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater repTwo = e.Item.FindControl("RptClassTwoName") as Repeater;//找到里层的Repeater对象。
DataRowView rowTwo = (DataRowView)e.Item.DataItem; //找到外层需要关联的数据项,求值。
string strPid = rowTwo["ID"].ToString();
#region 查询二级菜单的sql语句双语
if (Session["Lang"] != null)
{
if (Session["Lang"].ToString() == "zh-cn")
{
strClassTwo = "select * from (select Id, ParentId ,name_cn AS Name ,Visiable from v3_m_category where ParentId =" + strPid + " )as class where visiable=1 or visiable =3";
}
else
{
strClassTwo = "select * from (select Id, ParentId ,name_en AS Name ,Visiable from v3_m_category where ParentId =" + strPid + " ) as class where visiable=1 or visiable =3";
}
}
else
{
strClassTwo = "select * from (select Id, ParentId ,name_cn AS Name ,Visiable from v3_m_category where ParentId =" + strPid + " )as class where visiable=1 or visiable =3";
}
#endregion
DataTable dtClassTwo = DBH.DBHelper.GetDataSet(strClassTwo);
repTwo.DataSource = dtClassTwo;
repTwo.DataBind();
}
}
///
/// 更具小类别加载具体的商品名称
///
///
///
protected void RptClassTwoName_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater repMerchandises = e.Item.FindControl("RptMerchandises") as Repeater;
DataRowView rowMerchandises = (DataRowView)e.Item.DataItem;
string strCid = rowMerchandises["ID"].ToString();
#region 双语查询sql语句
if (Session["Lang"] != null)
{
if (Session["Lang"].ToString() == "zh-cn")
{
strMerchandises = @"select shangpin.pid as ID,shangpin.market_price_rmb as jiage1,lei.visiable,
shangpin.vip_price_rmb as jiage2,shangpin.trade_name_cn as Name,pic.[FileName] as [FileName]
from v3_merchandises as shangpin
left join v3_m_category as lei on lei.ID=shangpin.cID
left join v3_Pic_path as pic on pic.pID=shangpin.PID
where pic.show=1 and shangpin.cid=" + strCid + " and (lei.visiable =1 or lei.visiable =3)";
}
else
{
strMerchandises = @"select shangpin.pid as ID,shangpin.market_price_rmb as jiage1, shangpin.vip_price_rmb as jiage2,shangpin.trade_name_en as Name,pic.[FileName] as [FileName] from v3_merchandises as shangpin
left join v3_m_category as lei on lei.ID=shangpin.cID left join v3_Pic_path as pic on pic.pID=shangpin.PID where pic.show=1 and shangpin.cid=" + strCid + " and ( lei.visiable =1 or lei.visiable =3)";
}
}
else
{
strMerchandises = @"select shangpin.pid as ID,shangpin.market_price_rmb as jiage1,lei.visiable,
shangpin.vip_price_rmb as jiage2,shangpin.trade_name_cn as Name,pic.[FileName] as [FileName]
from v3_merchandises as shangpin
left join v3_m_category as lei on lei.ID=shangpin.cID
left join v3_Pic_path as pic on pic.pID=shangpin.PID
where pic.show=1 and shangpin.cid=" + strCid + " and (lei.visiable =1 or lei.visiable =3)";
}
#endregion
DataTable dtMerchandises = DBH.DBHelper.GetDataSet(strMerchandises);
repMerchandises.DataSource = dtMerchandises;
repMerchandises.DataBind();
}
}
}