Example #1
0
        public ActionResult AddNews(NewsModel model)
        {
            if (AdminNews.AdminGetNewsIdByTitle(model.Title) > 0)
                ModelState.AddModelError("Title", "标题已经存在");

            if (ModelState.IsValid)
            {
                NewsInfo newsInfo = new NewsInfo()
                {
                    NewsTypeId = model.NewsTypeId,
                    IsShow = model.IsShow,
                    IsTop = model.IsTop,
                    IsHome = model.IsHome,
                    DisplayOrder = model.DisplayOrder,
                    AddTime = DateTime.Now,
                    Title = model.Title,
                    Url = model.Url == null ? "" : model.Url,
                    Body = model.Body ?? ""
                };

                AdminNews.CreateNews(newsInfo);
                AddAdminOperateLog("添加新闻", "添加新闻,新闻为:" + model.Title);
                return PromptView("新闻添加成功");
            }

            Load();
            return View(model);
        }
Example #2
0
 /// <summary>
 /// 创建新闻
 /// </summary>
 public static void CreateNews(NewsInfo newsInfo)
 {
     BrnShop.Data.News.CreateNews(newsInfo);
     BrnShop.Core.BSPCache.Remove(CacheKeys.SHOP_NEWS_HOMELIST + newsInfo.NewsTypeId);
     BrnShop.Core.BSPCache.Remove(CacheKeys.SHOP_NEWS_HOMELIST + "\\d+");
 }
Example #3
0
 /// <summary>
 /// 创建新闻
 /// </summary>
 public void CreateNews(NewsInfo newsInfo)
 {
     DbParameter[] parms = {
                                 GenerateInParam("@newstypeid", SqlDbType.SmallInt, 2, newsInfo.NewsTypeId),
                                 GenerateInParam("@isshow", SqlDbType.TinyInt, 1, newsInfo.IsShow),
                                 GenerateInParam("@istop", SqlDbType.TinyInt, 1, newsInfo.IsTop),
                                 GenerateInParam("@ishome", SqlDbType.TinyInt, 1, newsInfo.IsHome),
                                 GenerateInParam("@displayorder", SqlDbType.Int,4,newsInfo.DisplayOrder),
                                 GenerateInParam("@addtime", SqlDbType.DateTime,8,newsInfo.AddTime),
                                 GenerateInParam("@title", SqlDbType.NVarChar,100,newsInfo.Title),
                                 GenerateInParam("@url", SqlDbType.NVarChar,200,newsInfo.Url),
                                 GenerateInParam("@body", SqlDbType.NText, 0, newsInfo.Body)
                             };
     string commandText = string.Format("INSERT INTO [{0}news]([newstypeid],[isshow],[istop],[ishome],[displayorder],[addtime],[title],[url],[body]) VALUES(@newstypeid,@isshow,@istop,@ishome,@displayorder,@addtime,@title,@url,@body)",
                                         RDBSHelper.RDBSTablePre);
     RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, parms);
 }
Example #4
0
 /// <summary>
 /// 更新新闻
 /// </summary>
 public void UpdateNews(NewsInfo newsInfo)
 {
     DbParameter[] parms = {
                                 GenerateInParam("@newstypeid", SqlDbType.SmallInt, 2, newsInfo.NewsTypeId),
                                 GenerateInParam("@isshow", SqlDbType.TinyInt, 1, newsInfo.IsShow),
                                 GenerateInParam("@istop", SqlDbType.TinyInt, 1, newsInfo.IsTop),
                                 GenerateInParam("@ishome", SqlDbType.TinyInt, 1, newsInfo.IsHome),
                                 GenerateInParam("@displayorder", SqlDbType.Int,4,newsInfo.DisplayOrder),
                                 GenerateInParam("@addtime", SqlDbType.DateTime,8,newsInfo.AddTime),
                                 GenerateInParam("@title", SqlDbType.NVarChar,100,newsInfo.Title),
                                 GenerateInParam("@url", SqlDbType.NVarChar,200,newsInfo.Url),
                                 GenerateInParam("@body", SqlDbType.NText, 0, newsInfo.Body),
                                 GenerateInParam("@newsid", SqlDbType.Int, 4, newsInfo.NewsId),
                             };
     string commandText = string.Format("UPDATE [{0}news] SET [newstypeid]=@newstypeid,[isshow]=@isshow,[istop]=@istop,[ishome]=@ishome,[displayorder]=@displayorder,[addtime]=@addtime,[title]=@title,[url]=@url,[body]=@body WHERE [newsid]=@newsid",
                                         RDBSHelper.RDBSTablePre);
     RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, parms);
 }
Example #5
0
        /// <summary>
        /// 通过IDataReader创建NewsInfo
        /// </summary>
        public static NewsInfo BuildNewsFromReader(IDataReader reader)
        {
            NewsInfo newsInfo = new NewsInfo();

            newsInfo.NewsId = TypeHelper.ObjectToInt(reader["newsid"]);
            newsInfo.NewsTypeId = TypeHelper.ObjectToInt(reader["newstypeid"]);
            newsInfo.IsShow = TypeHelper.ObjectToInt(reader["isshow"]);
            newsInfo.IsTop = TypeHelper.ObjectToInt(reader["istop"]);
            newsInfo.IsHome = TypeHelper.ObjectToInt(reader["ishome"]);
            newsInfo.DisplayOrder = TypeHelper.ObjectToInt(reader["displayorder"]);
            newsInfo.AddTime = TypeHelper.ObjectToDateTime(reader["addtime"]);
            newsInfo.Title = reader["title"].ToString();
            newsInfo.Url = reader["url"].ToString();
            newsInfo.Body = reader["body"].ToString();

            return newsInfo;
        }
Example #6
0
 /// <summary>
 /// 更新新闻
 /// </summary>
 public static void UpdateNews(NewsInfo newsInfo)
 {
     BrnShop.Core.BSPData.RDBS.UpdateNews(newsInfo);
 }