Пример #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 Edit_DB_News()
        {
            this.Response.ContentType = "text/plain";

            NModel.DB_News model = new NModel.DB_News();
            BLL.DB_News    dal   = new BLL.DB_News();

            String JsonStr = "";

            bool isGet = Tool.NStr.PostForSetVal <NModel.DB_News>(ref model, ref JsonStr, "");

            // 下面代码编写
            if (isGet && !string.IsNullOrEmpty(model.News_Content) &&
                !string.IsNullOrEmpty(model.News_Num) &&
                !string.IsNullOrEmpty(model.News_Title)

                && !string.IsNullOrEmpty(model.News_ClassifyName)

                && model.News_AddTime != null

                )
            {
                //取默认值

                model.News_EditTime = DateTime.Parse(DateTime.Now.ToString("s"));

                bool isEdit = dal.Edit(model) > 0 ? true : false;

                string msg = dal.ErrorMsg;
                if (!string.IsNullOrEmpty(msg))
                {
                    msg = "原因:" + msg;
                }

                if (isEdit)
                {
                    this.Response.Write(Tool.NMsg.SetMsg("修改成功", "1"));
                    this.Response.End();
                }
                else
                {
                    this.Response.Write(Tool.NMsg.SetMsg("修改失败" + msg, "0"));
                    this.Response.End();
                }

                dal.Close();
            }
            else
            {
                this.Response.Write(Tool.NMsg.SetMsg("提交失败", "0"));
                this.Response.End();
            }

            return(View());
        }
Пример #3
0
        public ActionResult Index()
        {
            NModel.NewsPager model_pager = LoadConfig("Index");

            BLL.DB_News bll_news = new BLL.DB_News();

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

            LoadLeftRight(ref model_pager);

            IList <NModel.DB_News> model_news_num = null;
            IList <string>         numList        = new List <string>();

            numList.Add("0101");
            numList.Add("0102");
            numList.Add("0103");
            numList.Add("0201");
            numList.Add("0202");
            numList.Add("0203");
            numList.Add("0301");
            numList.Add("0302");
            numList.Add("0303");
            numList.Add("0401");
            numList.Add("0402");
            numList.Add("0403");
            numList.Add("0501");
            numList.Add("0502");
            numList.Add("0503");
            numList.Add("0504");
            numList.Add("0601");
            numList.Add("0602");
            numList.Add("0603");

            foreach (string val in numList)
            {
                model_news_num = bll_news.GetNewListByWhereAndTop(string.Format(" news_num=''{0}''and  News_IsIndex=1", val), 6);

                model_pager.IDctNewsList.Add(val, model_news_num != null ? model_news_num : new List <NModel.DB_News>());
            }

            model_pager.IDictListAd = new Dictionary <string, IList <NModel.DB_AD> >();
            BLL.DB_AD            bll_ad        = new BLL.DB_AD();
            string               sql_ad        = string.Format(" ''01'' ");
            IList <NModel.DB_AD> model_ad_list = bll_ad.GetListByNumAndTop(sql_ad, 8);

            model_pager.IDictListAd.Add("中间广告", model_ad_list != null ? model_ad_list : new List <NModel.DB_AD>());

            bll_ad.Close();
            bll_news.Close();
            return(View(model_pager));
        }
Пример #4
0
        public void LoadLeftRight(ref NModel.NewsPager model_pager)
        {
            IList <NModel.DB_News> model_news_left  = null;
            IList <NModel.DB_News> model_news_right = null;

            BLL.DB_News bll_news = new BLL.DB_News();

            model_news_left  = bll_news.GetNewListByWhereAndTop(" News_IsHot=1 ", 6);
            model_news_right = bll_news.GetNewListByWhereAndTop(" News_IsRecommend=1 ", 6);
            model_pager.IDctNewsList.Add("left", model_news_left != null ? model_news_left : new List <NModel.DB_News>());
            model_pager.IDctNewsList.Add("right", model_news_right != null ? model_news_right : new List <NModel.DB_News>());

            bll_news.Close();
        }
Пример #5
0
        public ActionResult Add_DB_News()
        {
            this.Response.ContentType = "text/plain";
            NModel.DB_News model = new NModel.DB_News();
            BLL.DB_News    dal   = new BLL.DB_News();

            String JsonStr = "";

            bool isGet = Tool.NStr.PostForSetVal <NModel.DB_News>(ref model, ref JsonStr, "");

            // 下面代码编写
            if (isGet && !string.IsNullOrEmpty(model.News_Content) &&
                !string.IsNullOrEmpty(model.News_Num) &&
                !string.IsNullOrEmpty(model.News_Title)

                && !string.IsNullOrEmpty(model.News_ClassifyName)

                )
            {
                {
                    model.News_EditTime = DateTime.Parse(DateTime.Now.ToString("s"));
                    model.News_AddTime  = DateTime.Parse(DateTime.Now.ToString("s"));
                    //
                    bool isAdd = dal.Add(model) > 0 ? true : false;

                    if (isAdd)
                    {
                        this.Response.Write(Tool.NMsg.SetMsg("增加成功", "1"));
                        this.Response.End();
                    }
                    else
                    {
                        this.Response.Write(Tool.NMsg.SetMsg("增加失败" + dal.ErrorMsg, "1"));
                        this.Response.End();
                    }
                }
            }
            else
            {
                this.Response.Write(Tool.NMsg.SetMsg("提交失败", "0"));
            }

            dal.Close();

            return(View());
        }
Пример #6
0
        public ActionResult Del_DB_News()
        {
            this.Response.ContentType = "text/plain";

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

            if (!string.IsNullOrEmpty(delList))
            {
                string[] arrStr = delList.Split(',');

                int[] delIntArr = Tool.NTool.ArrayToAll <int, string>(arrStr);

                if (Tool.NTool.IsArrNULL <int>(delIntArr))
                {
                    BLL.DB_News dal         = new BLL.DB_News();
                    long        long_Result = dal.DelList(delIntArr);

                    if (long_Result > 0)
                    {
                        this.Response.Write(Tool.NMsg.SetMsg(string.Format("删除成功!总共删除{0}条", long_Result), "1"));
                        this.Response.End();
                    }
                    else
                    {
                        this.Response.Write(Tool.NMsg.SetMsg("删除失败!", "0"));
                        this.Response.End();
                    }

                    dal.Close();
                }
                else
                {
                    this.Response.Write(Tool.NMsg.SetMsg("提交失败/填写数据不完整!", "0"));
                    this.Response.End();
                }
            }
            else
            {
                this.Response.Write(Tool.NMsg.SetMsg("提交失败/填写数据不完整!", "0"));
                this.Response.End();
            }

            return(View());
        }
Пример #7
0
        public ActionResult Del_All_DB_News()
        {
            string num = this.Request.QueryString["Num"];

            BLL.DB_News bll       = new BLL.DB_News();
            long        delNumber = bll.DelAllByNum(num);

            if (delNumber > 0)
            {
                this.Response.Write(Tool.NMsg.SetMsg("删除成功", "1"));
                this.Response.End();
            }
            else
            {
                this.Response.Write(Tool.NMsg.SetMsg("删除失败", "0"));
                this.Response.End();
            }
            bll.Close();
            return(View());
        }
Пример #8
0
        public ActionResult Detailed(long?id)
        {
            BLL.DB_News bll_news = new BLL.DB_News();

            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.IDctNewsModel = new Dictionary <string, NModel.DB_News>();
            NModel.DB_News model_news = new NModel.DB_News();

            bll_news.UpdateClickRate(id);
            model_news = bll_news.GetModel(id);
            model_news = model_news != null ? model_news : new NModel.DB_News();

            ViewBag.Index   = model_news.News_Num;
            ViewBag.nIndex  = model_news.News_Num;
            ViewBag.NewsNum = model_news.News_Num;
            if (!string.IsNullOrEmpty(model_news.News_Num))
            {
                if (model_news.News_Num.Length >= 2)
                {
                    ViewBag.Index = ViewBag.NewsNum = model_news.News_Num.Substring(0, 2);
                }
            }

            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);
            model_pager.IDctNewsModel.Add("新闻实体", model_news);

            bll_news.Close();
            bll_Menu.Close();
            return(View(model_pager));
        }
Пример #9
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));
        }
Пример #10
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));
        }