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; }
/// <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; }
/// <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; }