Esempio n. 1
0
 /// <summary>
 /// 构造数据源
 /// </summary>
 public AcfunDataSource()
 {
     for (int count = 1; count < 11; count++)
     {
         //页码
         dataCore.CreateGroup(" 第-" + count + "-页 ",
                              "Group Title: " + count,
                              "Group Subtitle: " + count,
                              typeof(MainForm).Namespace + ".Assets.DarkGray.png",
                              "哈哈哈哈哈哈哈哈哈哈");
         //数据库分页查10个
         string sql = "";
         dt = conn.ExecuteDataTable(sql);
         //循环写入
         for (int dtcount = 0; dtcount < dt.Rows.Count; dtcount++)
         {
             Article.Model.Article article = new Model.Article();
             article.setComments(dt.Rows[dtcount]["comments"].ToString());
             article.setTitle(dt.Rows[dtcount]["title"].ToString());
             article.setContentId(dt.Rows[dtcount]["contentId"].ToString());
             article.setDescription(dt.Rows[dtcount]["description"].ToString());
             article.setTxt(dt.Rows[dtcount]["txt"].ToString());
             dataCore.AddItem(new ArticleDataItem(article.getTitle(),
                                                  "  评论数:  " + article.getComments(),
                                                  typeof(MainForm).Namespace + ".Assets.LightGray.png",
                                                  "Description: " + article.getDescription(),
                                                  article.getTxt(),
                                                  " 第-" + count + "-页 ", article.getComments(), article.getContentId()));
         }
     }
 }
 /// <summary>
 /// 绑定界面
 /// </summary>
 private void BindControls()
 {
     pictureBox1.Image   = Image.FromFile(System.Environment.CurrentDirectory + user.getlocalavatar());
     label_up.Text      += user.getName();
     label_time.Text    += article.getReleaseDate();
     label_sign.Text    += user.getSign();
     label_context.Text += article.getDescription();
     richTextBox1.Text   = article.getTxt();
 }
Esempio n. 3
0
        /// <summary>
        /// 保存文章到数据库
        /// </summary>
        /// <param name="article"></param>
        /// <returns></returns>
        public bool SaveArticle(Article.Model.Article article)
        {
            string sql = "select * from Article where contentId =" + article.getContentId();

            dt = conn.ExecuteDataTable(sql);
            if (dt.Rows.Count == 0)
            {
                string sqlInsert = "INSERT INTO 'Article' ('user', 'txt', 'description', 'contentId', 'isArticle', 'channelId', 'releaseDate', 'title', 'isRecommend', 'views', 'comments', 'stows', 'toplevel', 'cover', 'viewOnly') VALUES ('" + article.getUser() + "', '" + article.getTxt() + "', '" + article.getDescription() + "', '" + article.getContentId() + "', '" + article.getIsArticle() + "', '" + article.getChannelId() + "', '" + article.getReleaseDate() + "', '" + article.getTitle() + "', '" + article.getIsRecommend() + "', '" + article.getViews() + "', '" + article.getComments() + "', '" + article
                                   .getStows() + "', '" + article.getToplevel() + "', '" + article.getCover() + "', '" + article.getViewOnly() + "');";
                conn.ExecuteScalar(sqlInsert);
            }
            return(true);
        }