public ActionResult List() { PrepareTrainingApplyBLL bll = new PrepareTrainingApplyBLL(); int subjectId = Code.ExtendHelper.ToInt(Request["SubjectId"]); ViewBag.Subject = bll.GetSubject(); ViewBag.SubjectId = subjectId; //ViewBag.OutCourseType = bll.GetOutCourseType("Delflag=0", ""); int statusId = Code.ExtendHelper.ToInt(Request["StatusId"]); Dictionary<int, string> dict = new Dictionary<int, string>(); int[] dictKey = { 1, 2, 3, 4, 5, 6 }; string[] dictValue = { "草稿", "等待审核", "通过", "不通过", "已上架", "已下架" }; for (int i = 0; i < dictKey.Length; i++) { dict.Add(dictKey[i], dictValue[i]); } ViewBag.Status = dict; ViewBag.StatusId = statusId; string keyWords = ""; if (!string.IsNullOrEmpty(Request["KeyWords"])) keyWords = Request["KeyWords"].Trim(); ViewBag.KeyWords = keyWords; Code.SiteCache cache = Code.SiteCache.Instance; StringBuilder where = new StringBuilder(); where.Append("Delflag=0 and PartitionId=" + cache.LoginInfo.PartitionId + " and OrganId=" + cache.ManageOrganId); if (keyWords != "") where.Append(" and Title like '%" + keyWords.Replace("'", "''") + "%'"); if (subjectId != 0) where.Append(" and " + subjectId + " in (select value from [dbo].[split](Subject,','))"); if (statusId != 0) where.Append(" and Status=" + statusId); int recordCount = bll.GetTrainingInfoCount(where.ToString()); int pageSize = 8, pageIndex; int pageCount = (int)Math.Ceiling((double)recordCount / pageSize); int.TryParse(Request["PageIndex"], out pageIndex); if (pageCount == 0) { pageIndex = 0; } else { if (pageIndex < 1) pageIndex = 1; else if (pageIndex > pageCount) pageIndex = pageCount; } ViewBag.RecordCount = recordCount; ViewBag.PageCount = pageCount; ViewBag.PageIndex = pageIndex; ViewBag.PageSize = pageSize; ViewBag.SubjectData = bll.GetSubject(); return View(bll.GetTrainingInfoList(pageSize, pageIndex, where.ToString(), "CreateDate desc")); }