/// <summary> /// 根据typeid查询商品信息的分布视图 /// </summary> /// <param name="pageindex">当前页</param> /// <returns></returns> public ActionResult Show_typeid(int?pageindex, int?typeid) { ViewBag.GoodsPhoto = GoodsPhotoBll.SelectAllGoodsPhoto(); List <GoodsTable> list = null; if (typeid == null) { list = Session["Goods_typeid"] as List <GoodsTable>; ViewBag.count = Math.Ceiling(list.Count() / 12.0); } else { list = GoodsBll.SelectTypeidGoods(typeid ?? 0); if (list == null) { ViewBag.isnull = true; return(PartialView("Show", null)); } else { ViewBag.count = Math.Ceiling(list.Count() / 12.0); } } ViewBag.pageindex = pageindex; return(PartialView("Show", list.Skip(((pageindex ?? 1) - 1) * 12).Take(12).ToList())); }
// GET: Goods public ActionResult GoodsIndex(int?tid_1, int?typeid_1, int?typeid_2, string txt = "") { //清空session数据 Session.Remove("Goods"); Session.Remove("Goods_tid"); Session.Remove("Goods_typeid"); //获得所有分类数据 ViewBag.Type = TypeTableBll.SelectAllType(); ViewBag.GoodsPhoto = GoodsPhotoBll.SelectAllGoodsPhoto(); if (tid_1 != null) { //根据tid查询 Session["Goods_tid"] = GoodsBll.SelectTidGoods(tid_1 ?? 0); //ViewBag.tid = tid_1 ?? 0; } else if (typeid_1 != null) { //根据tiyeid查询 Session["Goods_typeid"] = GoodsBll.SelectTypeidGoods(typeid_1 ?? 0); } else if (typeid_2 != null) { Session["Goods_typeid_2"] = GoodsBll.SelectType1Goods(typeid_2 ?? 0); } else { Session["Goods"] = GoodsBll.SelectAllGoods().Where(p => p.GoodsName.Contains(txt) && p.IsDelte == 0).OrderBy(p => p.GoodsHot).ToList(); } return(View()); }