Пример #1
0
        public ActionResult Item_db_news()
        {
            BLL.DB_News dal = new BLL.DB_News();

            string pagenum    = this.Request.Form["pagenum"];
            string numPerPage = this.Request.Form["numPerPage"];

            string dbnewsdate = this.Request.Form["dbnewsdate"];

            string dbnewsname = this.Request.Form["dbnewsname"];
            string num        = this.Request.QueryString["Num"];

            string where = "", order = "news_addtime desc";

            if (string.IsNullOrEmpty(numPerPage))
            {
                numPerPage = "20";
            }
            if (string.IsNullOrEmpty(pagenum))
            {
                pagenum = "1";
            }

            where += " 1=1 ";

            if (!string.IsNullOrEmpty(num))
            {
                where += string.Format(" and news_num=''{0}''  ", num);
            }
            if (!string.IsNullOrEmpty(dbnewsdate))
            {
                where += string.Format(" and ( CONVERT(varchar(100), news_addtime, 23)=''{0}''  )", dbnewsdate);
            }

            if (!string.IsNullOrEmpty(dbnewsname))
            {
                where += string.Format(" and news_title like ''%{0}%''  ", dbnewsname);
            }

            string _where      = Server.UrlDecode(this.Request.QueryString["nwhere"] + "");
            bool   HasOneEqOne = !((_where + "").Trim().Length <= 3);

            bool IsOneEqOne = ((where + "").Trim().Length <= 3);

            if (IsOneEqOne && !string.IsNullOrEmpty(_where) && HasOneEqOne)
            {
                _where = this.Server.UrlDecode(_where);

                where = _where;
            }
            else
            {
                _where = where;
            }

            NModel.PageData <NModel.DB_News> PD = new NModel.PageData <NModel.DB_News>()
            {
                NumPerPage = numPerPage,
                PageNum    = pagenum,
                TotalPage  = dal.GetWhereListTotal(where),
                Where      = where,
                OrderField = order
            };
            dal.Close();
            return(View(PD));
        }
Пример #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));
        }