/// <summary> /// 获取列表 /// </summary> /// <param name="postId"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <param name="totalRecord"></param> /// <returns></returns> public List <CommentInfo> GetCommentList(int pageSize, int pageIndex, out int totalRecord, int order, int userId, int postId, int parentId, int approved, int emailNotify, string keyword) { string condition = " 1=1 ";// "[ParentId]=0 and [PostId]=" + postId; if (userId != -1) { condition += " and userid=" + userId; } if (postId != -1) { condition += " and postId=" + postId; } if (parentId != -1) { condition += " and parentId=" + parentId; } if (approved != -1) { condition += " and approved=" + approved; } if (emailNotify != -1) { condition += " and emailNotify=" + emailNotify; } if (!string.IsNullOrEmpty(keyword)) { condition += string.Format(" and (content like '%{0}%' or author like '%{0}%' or ipaddress like '%{0}%' or email like '%{0}%' or siteurl like '%{0}%' )", keyword); } string cmdTotalRecord = "select count(1) from Loachs_Comments where " + condition; totalRecord = Convert.ToInt32(MYSQLHelper.ExecuteScalar(CommandType.Text, cmdTotalRecord)); // throw new Exception(cmdTotalRecord); string cmdText = MYSQLHelper.GetPageSql("Loachs_Comments", "CommentId", "*", pageSize, pageIndex, order, condition); return(DataReaderToCommentList(MYSQLHelper.ExecuteReader(cmdText))); }
public List <PostInfo> GetPostList(int pageSize, int pageIndex, out int recordCount, int categoryId, int tagId, int userId, int recommend, int status, int topstatus, int hidestatus, string begindate, string enddate, string keyword) { string condition = " 1=1 "; if (categoryId != -1) { condition += " and categoryId=" + categoryId; } if (tagId != -1) { condition += " and tag like '%{" + tagId + "}%'"; } if (userId != -1) { condition += " and userid=" + userId; } if (recommend != -1) { condition += " and recommend=" + recommend; } if (status != -1) { condition += " and status=" + status; } if (topstatus != -1) { condition += " and topstatus=" + topstatus; } if (hidestatus != -1) { condition += " and hidestatus=" + hidestatus; } if (!string.IsNullOrEmpty(begindate)) { condition += " and createdate>=#" + begindate + "#"; } if (!string.IsNullOrEmpty(enddate)) { condition += " and createdate<#" + enddate + "#"; } if (!string.IsNullOrEmpty(keyword)) { condition += string.Format(" and (summary like '%{0}%' or title like '%{0}%' )", keyword); } string cmdTotalRecord = "select count(1) from Loachs_Posts where " + condition; // throw new Exception(cmdTotalRecord); recordCount = StringHelper.ObjectToInt(MYSQLHelper.ExecuteScalar(CommandType.Text, cmdTotalRecord)); string cmdText = MYSQLHelper.GetPageSql("Loachs_Posts", "PostId", "*", pageSize, pageIndex, 1, condition); return(DataReaderToCommentList(MYSQLHelper.ExecuteReader(cmdText))); }