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(OleDbHelper.ExecuteScalar(CommandType.Text, cmdTotalRecord)); string cmdText = OleDbHelper.GetPageSql("[Loachs_Posts]", "[PostId]", "*", pageSize, pageIndex, 1, condition); return(DataReaderToCommentList(OleDbHelper.ExecuteReader(cmdText))); }
//public LinkInfo GetLink(int linkid) //{ // string cmdText = "select * from [loachs_links] where [linkid] = @linkid"; // OleDbParameter[] prams = { // OleDbHelper.MakeInParam("@linkid",OleDbType.Integer,4,linkid) // }; // List<LinkInfo> list = DataReaderToList(OleDbHelper.ExecuteReader(CommandType.Text, cmdText, prams)); // return list.Count > 0 ? list[0] : null; //} //public List<LinkInfo> GetLinkList(int type, int position, int status) //{ // string condition = " 1=1 "; // if (type != -1) // { // condition += " and [type]=" + type; // } // if (position != -1) // { // condition += " and [position]=" + position; // } // if (status != -1) // { // condition += " and [status]=" + status; // } // string cmdText = "select * from [loachs_links] where " + condition + " order by [displayorder] asc"; // return DataReaderToList(OleDbHelper.ExecuteReader(cmdText)); //} public List <LinkInfo> GetLinkList() { string cmdText = "select * from [loachs_links] order by [displayorder] asc,[linkid] asc"; return(DataReaderToList(OleDbHelper.ExecuteReader(cmdText))); }
/// <summary> /// 获取列表 /// </summary> /// <returns>IList</returns> public List <PostInfo> GetPostList() { string cmdText = "select * from [loachs_posts] order by [postid] desc"; return(DataReaderToCommentList(OleDbHelper.ExecuteReader(cmdText))); }
///// <summary> ///// 获取实体 ///// </summary> ///// <param name="userName"></param> ///// <param name="password"></param> ///// <returns></returns> //public UserInfo GetUser(string userName, string password) //{ // string cmdText = "select * from [loachs_users] where [userName] = @userName and [Password]=@password"; // OleDbParameter[] prams = { // OleDbHelper.MakeInParam("@userName",OleDbType.VarWChar,50,userName), // OleDbHelper.MakeInParam("@password",OleDbType.VarWChar,50,password), // }; // List<UserInfo> list = DataReaderToUserList(OleDbHelper.ExecuteReader(CommandType.Text, cmdText, prams)); // if (list.Count > 0) // { // return list[0]; // } // return null; //} /// <summary> /// 获取全部 /// </summary> /// <returns></returns> public List <UserInfo> GetUserList() { string cmdText = "select * from [loachs_users] order by [displayorder] asc,[userid] asc"; return(DataReaderToUserList(OleDbHelper.ExecuteReader(cmdText))); }