Пример #1
0
        public ActionResult Data_DB_News()
        {
            string[] keys = this.Request.Form.AllKeys;
            string   page = this.Request.Form["page"];
            string   rows = this.Request.Form["rows"];

            string where = this.Request.Form["where"];
            string order = this.Request.Form["order"];

            int _page = 0, _rows = 0;

            int.TryParse(page, out _page);
            int.TryParse(rows, out _rows);
            if (_page == 0)
            {
                _page = 1;
            }
            if (_rows == 0)
            {
                _rows = 50;
            }

            BLL.DB_News           dal = new BLL.DB_News();
            List <NModel.DB_News> inModel = new List <NModel.DB_News>();

            inModel = dal.GetSortAndWherePagerList(_page, _rows, order, where);

            NModel.PageData <NModel.DB_News> outModel = BLL.Fun.SetJsonData <NModel.DB_News>(inModel);

            // inModel[0].Count_Show
            dal.Close();

            return(View(outModel));
        }
Пример #2
0
        public ActionResult List(string id)
        {
            ViewBag.Index   = id;
            ViewBag.nIndex  = id;
            ViewBag.NewsNum = id;
            if (!string.IsNullOrEmpty(id))
            {
                if (id.Length >= 2)
                {
                    ViewBag.Index = ViewBag.NewsNum = id.Substring(0, 2);
                }
            }

            int    pageSize = 20;
            string order    = "news_addtime desc";

            StringBuilder where = new StringBuilder();
            where.Append("1=1 ");
            where.AppendFormat("and news_num like ''{0}%''", id);

            NModel.NewsPager model_pager = LoadConfig("Index");

            model_pager.IDctNewsList = new Dictionary <string, IList <NModel.DB_News> >();

            LoadLeftRight(ref model_pager);

            model_pager.IDictMenu     = new Dictionary <string, IList <NModel.Admin_Menu> >();
            model_pager.IDctPagedNews = new Dictionary <string, IPagedList <NModel.DB_News> >();

            BLL.Admin_Menu            bll_Menu = new BLL.Admin_Menu();
            IList <NModel.Admin_Menu> menuList = bll_Menu.GetNewListByWhereAndTop("menu_num like ''" + ViewBag.NewsNum + "%'' and len(menu_num)<=4  ", 12);

            menuList = menuList != null ? menuList : new List <NModel.Admin_Menu>();

            model_pager.IDictMenu.Add("新闻分类", menuList);
            int pageIndex = 0;

            int.TryParse(this.Request.QueryString["pageindex"], out pageIndex);
            if (pageIndex <= 0)
            {
                pageIndex = 1;
            }
            BLL.DB_News bll_news = new BLL.DB_News();

            List <NModel.DB_News> model_news_list = new List <NModel.DB_News>();

            model_news_list = bll_news.GetSortAndWherePagerList(pageIndex, pageSize, order, where.ToString());
            int totalItems = 0;

            int.TryParse(bll_news.GetWhereListTotal(where.ToString()) + "", out totalItems);
            if (model_news_list != null)
            {
                model_pager.IDctPagedNews.Add("新闻列表", new PagedList <NModel.DB_News>(model_news_list, pageIndex, pageSize, totalItems));
            }
            else
            {
                model_pager.IDctPagedNews.Add("新闻列表", null);
            }

            bll_news.Close();
            bll_Menu.Close();
            return(View(model_pager));
        }