/// <summary> /// 获得wid的用户分类信息 /// </summary> /// <returns></returns> public IList <Model.wx_book_category> getCategory() { Tag tag = this.Document.CurrentRenderingTag; ///classlayer表示取类别深度,如果为-1,则取所有分类的深度,如果为1,则取第一层目录,如果为2,则去第2层目录 var classlayer = tag.Attributes["classlayer"]; var parentidObj = tag.Attributes["parentid"]; int parentid = -1; if (parentidObj != null && MyCommFun.isNumber(parentidObj.Value.GetValue())) { parentid = MyCommFun.Obj2Int(parentidObj.Value.GetValue()); } int class_layer = -1; if (classlayer != null && MyCommFun.isNumber(classlayer.Value.GetValue())) { class_layer = MyCommFun.Obj2Int(classlayer.Value.GetValue()); } DAL.wx_book_category cateBll = new DAL.wx_book_category(); IList <Model.wx_book_category> categorylist = cateBll.GetCategoryListByWid(wid, -1, parentid, class_layer); if (categorylist != null && categorylist.Count > 0) { Model.wx_book_category cat = new Model.wx_book_category(); for (int i = 0; i < categorylist.Count; i++) { cat = categorylist[i]; if (cat.link_url == null || cat.link_url.Trim() == "") { //如果link_url为空,则直接调用本系统的信息 cat.link_url = MyCommFun.urlAddOpenid("/book/list.aspx?wid=" + wid + "&cid=" + cat.id, openid); cat.category_url = MyCommFun.urlAddOpenid("/book/category.aspx?wid=" + wid + "&cid=" + cat.id, openid); } else { cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid); } } } return(categorylist); }
public void ProductClassPage() { int category_id = MyCommFun.RequestInt("cid"); //--=====begin: 将这个列表(文章类别)的基本信息展示出来 ====-- DAL.wx_book_category cateBll = new DAL.wx_book_category(); Model.wx_book_category category = cateBll.GetCategoryByWid(wid, category_id); this.Document.SetValue("category", category); this.Document.SetValue("wid", wid); //--=====end: 将这个列表(文章类别)的基本信息展示出来 ====-- Tag orderByTag = this.Document.GetChildTagById("norderby"); string orderby = orderByTag.Attributes["value"].Value.ToString(); Tag pagesizeTag = this.Document.GetChildTagById("npagesize"); string pagesizeStr = pagesizeTag.Attributes["value"].Value.ToString(); int currPage = 1; //当前页面 int recordCount = 0; //总记录数 int totPage = 1; //总页数 int pageSize = MyCommFun.Str2Int(pagesizeStr); //每页的记录数 if (pageSize <= 0) { pageSize = 10; } if (MyCommFun.RequestInt("page") > 0) { currPage = MyCommFun.RequestInt("page"); } DataSet productlist = new DataSet(); if (category_id != 0) { DAL.wx_book_product artDal = new DAL.wx_book_product(); productlist = artDal.GetList(wid, category_id, pageSize, currPage, "upselling=1", orderby, out recordCount); if (productlist != null && productlist.Tables.Count > 0 && productlist.Tables[0].Rows.Count > 0) { DataRow dr; for (int i = 0; i < productlist.Tables[0].Rows.Count; i++) { dr = productlist.Tables[0].Rows[i]; if (dr["link_url"] != null && dr["link_url"].ToString().Trim().Length > 0) { dr["link_url"] = MyCommFun.urlAddOpenid(dr["link_url"].ToString().Trim(), openid); } else { dr["link_url"] = MyCommFun.urlAddOpenid("detail.aspx?wid=" + wid + "&pid=" + dr["id"].ToString(), openid); } productlist.AcceptChanges(); } totPage = recordCount / pageSize; int yushu = recordCount % pageSize; if (yushu > 0) { totPage += 1; } if (totPage < 1) { totPage = 1; } } if (currPage > totPage) { currPage = totPage; } } else { currPage = 1; recordCount = 0; totPage = 1; } this.Document.SetValue("totPage", totPage); //总页数 this.Document.SetValue("currPage", currPage); //当前页 this.Document.SetValue("productlist", productlist); //文章列表 string beforePageStr = ""; //上一页 string nextPageStr = ""; //下一页 string bgrey = "c-p-grey"; string ngrey = "c-p-grey"; if (currPage <= 1) { beforePageStr = ""; bgrey = "c-p-grey"; } else { beforePageStr = MyCommFun.ChangePageNum(MyCommFun.getTotalUrl(), (currPage - 1)); beforePageStr = "href=\"" + beforePageStr + "\""; bgrey = ""; } if (currPage >= totPage) { nextPageStr = ""; ngrey = " c-p-grey"; } else { nextPageStr = MyCommFun.ChangePageNum(MyCommFun.getTotalUrl(), (currPage + 1)); nextPageStr = "href=\"" + nextPageStr + "\""; ngrey = ""; } this.Document.SetValue("bpage", beforePageStr); //上一页 this.Document.SetValue("npage", nextPageStr); //下一页 this.Document.SetValue("bgrey", bgrey); //上一页灰色的样式 this.Document.SetValue("ngrey", ngrey); //下一页灰色的样式 }