Example #1
0
        /// <summary>
        /// 得到分页转换帖子泛型列表
        /// </summary>
        /// <param name="CurrentPage">当前分页</param>
        /// <returns></returns>
        public List<Posts> GetPostList(int CurrentPage)
        {
            string sql;

            #region 分页语句
            if (CurrentPage <= 1)
            {
                sql = string.Format
                       ("SELECT TOP {1} * FROM {0}Reply ORDER BY Id", MainForm.cic.SrcDbTablePrefix, MainForm.PageSize);
            }
            else
            {
                sql = string.Format
                       ("SELECT TOP {1} * FROM {0}Reply WHERE Id NOT IN (SELECT TOP {2} Id FROM {0}Reply ORDER BY Id) ORDER BY Id", MainForm.cic.SrcDbTablePrefix, MainForm.PageSize, MainForm.PageSize * (CurrentPage - 1));
            }
            #endregion

            System.Data.Common.DbDataReader dr = MainForm.srcDBH.ExecuteReader(sql);
            List<Posts> postlist = new List<Posts>();
            while (dr.Read())
            {
                Posts objPost = new Posts();
                objPost.pid = Convert.ToInt32(dr["Id"]);
                objPost.tid = Convert.ToInt32(dr["TopicId"]);
                objPost.message = ConvertUBB(dr["Body"].ToString());
                objPost.lastedit = GetLastEditInfo(dr["Body"].ToString());
                objPost.posterid = Convert.ToInt32(dr["AuthorId"]);
                objPost.poster = dr["AuthorName"].ToString();//CVC长度40>20
                objPost.ip = dr["ip"].ToString();
                objPost.postdatetime = Convert.ToDateTime(dr["IssueTime"]);
                if (dr["AttachIds"] != DBNull.Value && dr["AttachIds"].ToString().Trim() != "")
                {
                    objPost.attachment = 1;
                }
                objPost.invisible = Convert.ToInt32(dr["Deleted"]);

                objPost.parentid = objPost.pid;
                //TODO 板块id需要在后面整理更新
                //layer没有指定

                postlist.Add(objPost);
            }
            dr.Close();
            dr.Dispose();
            return postlist;
        }
Example #2
0
        /// <summary>
        /// 得到分页转换帖子泛型列表
        /// </summary>
        /// <param name="CurrentPage">当前分页</param>
        /// <returns></returns>
        public List<Posts> GetPostList(int CurrentPage)
        {
            string sql;

            #region 分页语句
            sql = string.Format(
                "SELECT * FROM {0}posts p LEFT JOIN {0}postcontent pc ON p.id = pc.postID ORDER BY id LIMIT {1},{2}",
                MainForm.cic.SrcDbTablePrefix,
                MainForm.PageSize * (CurrentPage - 1),
                MainForm.PageSize
                );
            #endregion

            System.Data.Common.DbDataReader dr = MainForm.srcDBH.ExecuteReader(sql);
            List<Posts> postlist = new List<Posts>();
            while (dr.Read())
            {
                Posts objPost = new Posts();
                objPost.pid = Convert.ToInt32(dr["id"]);
                objPost.tid = Convert.ToInt32(dr["parentid"]) == 0 ? objPost.pid : Convert.ToInt32(dr["parentid"]);//如果没有父ID,就说明它是主题贴
                objPost.message = ConvertUBB(dr["content"].ToString());
                //objPost.lastedit = GetLastEditInfo(dr["Body"].ToString());
                objPost.posterid = Convert.ToInt32(dr["authorid"]);
                objPost.poster = dr["author"].ToString();//CVC长度40>20
                objPost.ip = dr["ipfrom"].ToString();
                objPost.postdatetime = Convert.ToDateTime(dr["postat"]);
                if (dr["accessaryname"] != DBNull.Value && dr["accessaryname"].ToString().Trim() != "")
                {
                    objPost.attachment = 1;
                }
                //objPost.invisible = Convert.ToInt32(dr["Deleted"]);

                objPost.parentid = objPost.pid;
                //TODO 板块id需要在后面整理更新
                //layer没有指定

                postlist.Add(objPost);
            }
            dr.Close();
            dr.Dispose();
            return postlist;
        }