/// <summary> /// 一级类和二级类的 查询条件 /// </summary> /// <param name="type1"></param> /// <param name="type2"></param> /// <returns></returns> private string getQuery(string type1, string type2) { string sql = ""; if (type1.NoEmpty()) { //一级类 var childlist = new ProductTypeBll().GetAll("*", " [typeint]=" + type1, 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); }
/// <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());; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["typeId"] != null && Request.QueryString["typeId"] != "") { int proTypeId = Convert.ToInt32(Request.QueryString["typeId"]); List <Model.ProductType> list = ProductTypeBll.GetProductType(proTypeId); if (list.Count > 0) { lblType.Text = list[0].TypeName; hftypeId.Value = proTypeId.ToString(); hlnkPro.NavigateUrl = "Product.aspx?typeId=" + hftypeId.Value; txtTimer.Value = DateTime.Now.ToString("yyyy-MM-dd"); } } else if (Request.QueryString["id"] != null && Request.QueryString["id"] != "") { int proId = Convert.ToInt32(Request.QueryString["id"]); hfId.Value = proId.ToString(); List <Model.Product> list = ProductBll.GetProductbyId(proId); if (list.Count > 0) { txtTitle.Text = list[0].Title; txtTimer.Value = list[0].CreateTime; txtImg.Text = list[0].ImgUrl; txtBigImg.Text = list[0].BigImgUrl; fck_intro.Value = list[0].Intro; fck_detail.Value = list[0].Details; chkIndex.Checked = Convert.ToBoolean(list[0].IndexShow); chkShow.Checked = Convert.ToBoolean(list[0].IsShow); List <ProductType> list_proType = ProductTypeBll.GetProductType(list[0].ProTypeId); if (list_proType.Count > 0) { lblType.Text = list_proType[0].TypeName; } else { lblType.Text = ""; } hlnkPro.NavigateUrl = "Product.aspx?typeId=" + list[0].ProTypeId; } } } }