Пример #1
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());
        }
Пример #2
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());
        }
Пример #3
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));
        }