Exemple #1
0
        public static int InsertNews(string title, string summary, string content, DateTime createdate, string createuser)
        {
            NEWSINFO ni = new NEWSINFO();
            ni.TITLE = title;
            ni.SUMMARY = summary;
            ni.NEWS_CONTENT = content;
            ni.CREATEDATE = createdate;
            ni.CREATEUSER = createuser;

            using (DataClasses1DataContext db = new DataClasses1DataContext())
            {
                db.Log = Console.Out;
                db.NEWSINFO.InsertOnSubmit(ni);
                db.SubmitChanges();
            }
            return ni.id;
        }
Exemple #2
0
        /// <summary>
        /// 根据新闻ID返回新闻详细信息
        /// </summary>
        /// <param name="nid"></param>
        /// <returns></returns>
        public static List<NewsInfo> GetNewsInfo(int nid)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            var result = from a in db.NEWSINFO
                         where a.id == nid
                         select new NewsInfo
                         {
                             NID = a.id,
                             Title = a.TITLE,
                             News_Content = a.NEWS_CONTENT,
                             Summary = a.SUMMARY,
                             CreateDate = a.CREATEDATE,
                             User = a.CREATEUSER
                         };

            return result.ToList();
        }
Exemple #3
0
 /// <summary>
 /// 返回新闻列表
 /// </summary>
 /// <param name="_pageNo"></param>
 /// <param name="_pageSize"></param>
 /// <param name="pagCount"></param>
 /// <returns></returns>
 public static List<NewsInfo> GetNewsList(int _pageNo, int _pageSize,out int newscount)
 {
     List<NewsInfo> lstnews = new List<NewsInfo>();
     DataClasses1DataContext db = new DataClasses1DataContext();
     var query = from a in db.NEWSINFO
                 orderby a.CREATEDATE descending
                 select new NewsInfo
                 {
                     NID=a.id,
                     Title=a.TITLE,
                     News_Content =a.NEWS_CONTENT,
                     Summary=a.SUMMARY,
                     CreateDate=a.CREATEDATE,
                     User=a.CREATEUSER
                 };
     newscount = query.Count();
     lstnews = query.Skip(_pageSize * (_pageNo - 1)).Take<NewsInfo>(_pageSize).ToList<NewsInfo>();
     return lstnews;
 }
Exemple #4
0
 /// <summary>
 /// 修改咨询,回答咨询
 /// </summary>
 /// <param name="qid"></param>
 /// <param name="ansercontent"></param>
 /// <param name="anserdate"></param>
 /// <param name="anseruser"></param>
 /// <returns></returns>
 public static int UpdateQuestion(int qid, string ansercontent, DateTime anserdate, string anseruser)
 {
     using (DataClasses1DataContext db = new DataClasses1DataContext())
     {
         db.Log = Console.Out;
         var tb = db.QuestionInfo.SingleOrDefault<QuestionInfo>(s => s.ID == qid);
         if (tb == null)
         {
             return 0;
         }
         tb.AnserContent = ansercontent;
         tb.AnserDate = anserdate;
         tb.AnserUser = anseruser;
         tb.Status = 1;
         db.SubmitChanges();
     }
     return 1;
 }
Exemple #5
0
 /// <summary>
 /// 新增咨询
 /// </summary>
 /// <param name="title"></param>
 /// <param name="content"></param>
 /// <param name="createdate"></param>
 /// <param name="createuser"></param>
 /// <returns></returns>
 public static int InsertQuestion(string title, string content, DateTime createdate,int createuser)
 {
     QuestionInfo qi = new QuestionInfo();
     qi.TITLE = title;
     qi.QuestionContent = content;
     qi.CreateUser = createuser;
     qi.CreateDate = createdate;
     qi.Status = 0;
     using (DataClasses1DataContext db = new DataClasses1DataContext())
     {
         db.Log = Console.Out;
         db.QuestionInfo.InsertOnSubmit(qi);
         db.SubmitChanges();
     }
     return qi.ID;
 }
Exemple #6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="_pageNo"></param>
 /// <param name="_pageSize"></param>
 /// <param name="status"></param>
 /// <returns></returns>
 public static List<QuestionsInfo> GetQuestionList(int _pageNo, int _pageSize,int status)
 {
     List<QuestionsInfo> lstnews = new List<QuestionsInfo>();
     DataClasses1DataContext db = new DataClasses1DataContext();
     var query = from a in db.QuestionInfo
                 where a.Status==status
                 select new QuestionsInfo
                 {
                     QID = a.ID,
                     Title = a.TITLE,
                     Content = a.QuestionContent,
                     CreateDate = a.CreateDate,
                     AnserContent = a.AnserContent,
                     AnserDate = a.AnserDate,
                     Status = a.Status
                 };
     lstnews = query.Skip(_pageSize * (_pageNo - 1)).Take<QuestionsInfo>(_pageSize).ToList<QuestionsInfo>();
     return lstnews;
 }
Exemple #7
0
 /// <summary>
 /// 当前人咨询列表
 /// </summary>
 /// <param name="_pageNo"></param>
 /// <param name="_pageSize"></param>
 /// <param name="userid"></param>
 /// <param name="pagCount"></param>
 /// <returns></returns>
 public static List<QuestionsInfo> GetQuestionList(int _pageNo, int _pageSize, int userid, out int pagCount)
 {
     List<QuestionsInfo> lstnews = new List<QuestionsInfo>();
     DataClasses1DataContext db = new DataClasses1DataContext();
     var query = from a in db.QuestionInfo
                 where a.CreateUser == userid
                 orderby a.CreateDate descending
                 select new QuestionsInfo
                 {
                    QID=a.ID,
                    Title=a.TITLE,
                    Content=a.QuestionContent,
                    CreateDate=a.CreateDate,
                    AnserContent=a.AnserContent,
                    AnserDate=a.AnserDate,
                    Status=a.Status
                 };
     pagCount = query.Count();
     lstnews = query.Skip(_pageSize * (_pageNo - 1)).Take<QuestionsInfo>(_pageSize).ToList<QuestionsInfo>();
     return lstnews;
 }
Exemple #8
0
 /// <summary>
 /// 咨询详细信息
 /// </summary>
 /// <param name="qid"></param>
 /// <returns></returns>
 public static List<QuestionsInfo> GetQuestionInfo(int qid)
 {
     DataClasses1DataContext db = new DataClasses1DataContext();
     var query = from a in db.QuestionInfo
                 where a.ID == qid
                 select new QuestionsInfo
                 {
                     QID = a.ID,
                     Title = a.TITLE,
                     Content = a.QuestionContent,
                     CreateDate = a.CreateDate,
                     CreateUser =a.CreateUser,
                     AnserContent = a.AnserContent,
                     AnserDate = a.AnserDate,
                     AnserUser=a.AnserUser,
                     Status = a.Status
                 };
     return query.ToList();
 }