private void btnSaveArticle_Click(object sender, RoutedEventArgs e) { //if (_documentManager.SaveDocument()) //{ // MessageBox.Show("保存成功!"); //} //TextRange range = new TextRange(body.Document.ContentStart, body.Document.ContentEnd); Article article = new Article(); article.ArticleTitle = tbArticleTitle.Text; article.ArticleContent = rtbArticleBody.RTF(); //article.AUserID = ClassRoom.Common.TicketInfo.UserNO; article.AUserID = 4; article.UploadTime = DateTime.Now; ClassRoomEntities entities = new ClassRoomEntities(); try { entities.Articles.AddObject(article); int result =entities.SaveChanges(); if (result > 0) MessageBox.Show("保存成功"); } catch (Exception ee) { throw ee.InnerException; } }
/// <summary> /// 复制 /// </summary> public void Clone(Article entity) { this.ArticleID = entity.ArticleID; this.ArticleContent = entity.ArticleContent; this.UploadTime = entity.UploadTime; this.AUserID = entity.AUserID; this.ArticleTitle = entity.ArticleTitle; }
/// <summary> /// 创建新的 Article 对象。 /// </summary> /// <param name="articleID">ArticleID 属性的初始值。</param> /// <param name="articleContent">ArticleContent 属性的初始值。</param> /// <param name="uploadTime">UploadTime 属性的初始值。</param> /// <param name="aUserID">AUserID 属性的初始值。</param> /// <param name="articleTitle">ArticleTitle 属性的初始值。</param> public static Article CreateArticle(global::System.Int32 articleID, global::System.String articleContent, global::System.DateTime uploadTime, global::System.Int32 aUserID, global::System.String articleTitle) { Article article = new Article(); article.ArticleID = articleID; article.ArticleContent = articleContent; article.UploadTime = uploadTime; article.AUserID = aUserID; article.ArticleTitle = articleTitle; return article; }
/// <summary> /// 用于向 Articles EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToArticles(Article article) { base.AddObject("Articles", article); }