protected void Page_Load(object sender, EventArgs e) { type = Request["type"].Trim2(); if (type == "" && pro_type2 != "") { type2name= new ProductTypeBll().GetByPrimaryKey(pro_type2.ToInt()).Entity.Name; } }
/// <summary> /// 加载菜单类别 /// </summary> /// <returns></returns> public string loadCategory() { ProductTypeBll protypebll = new ProductTypeBll(); StringBuilder sb = new StringBuilder(); var typelist = protypebll.GetAll("*", " [type]=1", null, " [order] desc").Entity; string categorytemp = "<li {0}><h2><a href=\"#\">{1}</a></h2>{2}</li>";//0 是否当前类 1一级类名称 2 二级类名称 class=\"sel\" string childtemp = "<a href=\"prodlist.aspx?pro_type2={0}\" class=\"bdradius6\">{1}</a>"; string childstr = ""; if (typelist.Count > 0) { int index = 0; for (int i = 0; i < typelist.Count; i++) { var childlist = protypebll.GetAll("*", " [typeint]=" + typelist[i].Id, null, " [order] desc").Entity; if (childlist.Count > 0) { childstr = ""; childstr += "<p>"; for (int j = 0; j < childlist.Count; j++) { childstr += string.Format(childtemp, childlist[j].Id, childlist[j].Name); } childstr += "</p>"; } //当前显示类 string parenttypeid = ""; if (pro_type2.NoEmpty()) { parenttypeid = protypebll.GetByPrimaryKey(pro_type2.ToInt()).Entity == null ? "" : protypebll.GetByPrimaryKey(pro_type2.ToInt()).Entity.TypeInt.ToString(); } if (currenttype1 == typelist[i].Id.ToString() || parenttypeid == typelist[i].Id.ToString()) sb.Append(string.Format(categorytemp, "class=\"sel\" onClick=\"flcontLiShowsSub(" + index + ")\"", typelist[i].Name, childstr)); else sb.Append(string.Format(categorytemp, "onClick=\"flcontLiShowsSub(" + index + ")\"", typelist[i].Name, childstr)); index++; } } return sb.ToString(); ; }
private string getQuery(string type,string type2) { string sql = ""; if (type.NoEmpty()) { //一级类 var childlist = new ProductTypeBll().GetAll("*", " [typeint]=" + type, null, "[order]").Entity; string type_ids = ""; if (childlist.Count > 0) { for (int i = 0; i < childlist.Count; i++) { type_ids += childlist[i].Id.ToString() + ","; } type_ids = type_ids.Trim(','); sql = " ProductTypeId in (" + type_ids + ")"; } } if (type2.NoEmpty()) { //二级类 sql = " ProductTypeId =" + type2; } return sql; }