コード例 #1
0
 public ActionResult SelectGood()
 {
     string skip = Request.QueryString["skip"];
     if (string.IsNullOrWhiteSpace(skip))
     {
         skip = "1";
     }
     int count = 0;
     List<GoodClass> g = new List<GoodClass>();
     string alltype = Request.QueryString["tpy"];
     string fname = Request.QueryString["fname"];
     string tn = Request.QueryString["tn"];
     string thirdname = Request.QueryString["thirdname"];
     IEnumerable<商品> goods = null;
     IEnumerable<商品分类> twoClass = null;
     IEnumerable<商品分类> thirdClass = null;
     IEnumerable<商品分类> model = 商品分类管理.查找子分类();
     if (model != null)
     {
         foreach (var item in model)
         {
             if (item.分类名 == fname)
             {
                 twoClass = item.子分类;
                 break;
             }
         }
         if (alltype != "专用物资")
         {
             if (twoClass != null)
             {
                 foreach (var m in twoClass)
                 {
                     if (m.分类名 == tn)
                     {
                         thirdClass = m.子分类;
                         break;
                     }
                 }
             }
             if (thirdClass != null)
             {
                 foreach (var n in thirdClass)
                 {
                     if (n.分类名 == thirdname)
                     {
                         goods = n.获取分类下商品列表(false);
                         break;
                     }
                 }
             }
         }
         else
         {
             if (twoClass != null)
             {
                 foreach (var it in twoClass)
                 {
                     if (it.分类名 == tn)
                     {
                         goods = it.获取分类下商品列表(false);
                         break;
                     }
                 }
             }
         }
     }
     if (goods != null && goods.Count() != 0)
     {
         count = goods.Count() / 10;
         if ((goods.Count() % 10) > 0)
         {
             count++;
         }
         foreach (var item in goods.Skip(10 * (int.Parse(skip) - 1)).Take(10))
         {
             GoodClass gs = new GoodClass();
             gs.Name = item.商品信息.商品名;
             gs.Type = item.商品信息.精确型号;
             g.Add(gs);
         }
     }
     JsonResult json = new JsonResult() { Data = new { content = g, count = count } };
     return Json(json, JsonRequestBehavior.AllowGet);
 }