예제 #1
0
 /// <summary>
 /// 删除新闻
 /// </summary>
 /// <param name="id">新闻ID</param>
 /// <returns>操作状态</returns>
 public static bool DelNews(int id)
 {
     try
     {
         using (var db = new en_scEntities())
         {
             db.News.DeleteObject(db.News.Single(n => n.Nid == id));
             db.SaveChanges();
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
예제 #2
0
 /// <summary>
 /// 删除公告下载
 /// </summary>
 /// <param name="id">文章ID</param>
 /// <returns>操作状态</returns>
 public static bool DelBulletin(int id)
 {
     try
     {
         using (var db = new en_scEntities())
         {
             db.ArticleWithAthmts.DeleteObject(db.ArticleWithAthmts.Single(a => a.Bid == id));
             db.SaveChanges();
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
예제 #3
0
        /// <summary>
        /// 添加公告、下载
        /// </summary>
        /// <param name="title"></param>
        /// <param name="cid"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static bool AddBulletin(string title, int cid, string content, string attachment, string filename, DateTime date)
        {
            DateTime Date = Convert.ToDateTime(date.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("HH:mm:ss.fff"));
            try
            {
                string sql = "insert into ArticleWithAthmt (Sid,Title,Content,PostTime,Attachment,AttachmentName) values({0},{1},{2},{3},{4},{5})";

                using (var db = new en_scEntities())
                {
                    db.ExecuteStoreCommand(sql, new object[] { cid, title, content, Date, attachment, filename });
                    db.SaveChanges();
                }

                return true;
            }
            catch
            {
                return false;
                throw;
            }
        }
예제 #4
0
        /// <summary>
        /// 添加新闻
        /// </summary>
        /// <param name="title"></param>
        /// <param name="cid"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static bool AddNews(string title, int cid, string author, string source, string content, bool ispic, bool isloop, string path, DateTime date)
        {
            DateTime Date = Convert.ToDateTime(date.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("HH:mm:ss.fff"));
            try
            {
                string sql = "insert into News (Sid,Title,Author,Source,Content,PostTime,IsPicNews,IsLoopPicNews,PicNewsPath) values({0},{1},{2},{3},{4},{5},{6},{7},{8})";

                using (var db = new en_scEntities())
                {
                    db.ExecuteStoreCommand(sql, new object[] {cid, title, author, source, content, Date, ispic, isloop, path});
                    db.SaveChanges();
                }

                return true;
            }
            catch
            {
                return false;
                throw;
            }
        }
예제 #5
0
 /// <summary>
 /// 修改文章
 /// </summary>
 /// <param name="id"></param>
 /// <param name="title"></param>
 /// <param name="cid"></param>
 /// <param name="content"></param>
 /// <param name="attachment"></param>
 /// <returns></returns>
 public static bool UpdateBulletin(int id, string title, int cid, string content, string attachment, string filename, DateTime date)
 {
     DateTime Date = Convert.ToDateTime(date.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("HH:mm:ss.fff"));
     try
     {
         using (var db = new en_scEntities())
         {
             var bulletin = db.ArticleWithAthmts.Single(a => a.Bid == id);
             bulletin.Title = title;
             bulletin.Content = content;
             bulletin.Sid = cid;
             bulletin.Attachment = attachment;
             bulletin.AttachmentName = filename;
             bulletin.PostTime = Date;
             db.SaveChanges();
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
예제 #6
0
 /// <summary>
 /// 修改文章
 /// </summary>
 /// <param name="id"></param>
 /// <param name="title"></param>
 /// <param name="cid"></param>
 /// <param name="content"></param>
 /// <returns></returns>
 public static bool UpdateArticle(int id, string title, int cid, string content, DateTime date)
 {
     DateTime Date = Convert.ToDateTime(date.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("HH:mm:ss.fff"));
     try
     {
         using (var db = new en_scEntities())
         {
             var news = db.Articles.Single(a => a.Aid == id);
             news.Title = title;
             news.Content = content;
             news.Sid = cid;
             news.PostTime = Date;
             db.SaveChanges();
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
예제 #7
0
 /// <summary>
 /// 修改新闻
 /// </summary>
 /// <param name="id"></param>
 /// <param name="title"></param>
 /// <param name="cid"></param>
 /// <param name="content"></param>
 /// <param name="ispic"></param>
 /// <param name="isloop"></param>
 /// <param name="path"></param>
 /// <returns></returns>
 public static bool UpdateNews(int id, string title, int cid, string author, string source, string content, bool ispic, bool isloop, string path, DateTime date)
 {
     DateTime Date = Convert.ToDateTime(date.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("HH:mm:ss.fff"));
     try
     {
         using (var db = new en_scEntities())
         {
             var news = db.News.Single(n => n.Nid == id);
             news.Title = title;
             news.Content = content;
             news.Sid = cid;
             news.Author = author;
             news.Source = source;
             news.IsPicNews = ispic;
             news.IsLoopPicNews = isloop;
             news.PicNewsPath = path;
             news.PostTime = Date;
             db.SaveChanges();
         }
         return true;
     }
     catch
     {
         return false;
     }
 }