public IList<Core.Business.VoteRecord> GetAllVoteRecord() { IList<Core.Business.VoteRecord> voteRecordlist = new List<Core.Business.VoteRecord>(); SqlServerUtility sql = new SqlServerUtility(); SqlDataReader reader = sql.ExecuteSqlReader(SqlGetAllVoteRecord); if(reader != null) { while(reader.Read()) { Core.Business.VoteRecord voteRecord = new Core.Business.VoteRecord(); if (!reader.IsDBNull(0)) voteRecord.Id = reader.GetInt32(0); if (!reader.IsDBNull(1)) voteRecord.VoteID = reader.GetInt32(1); if (!reader.IsDBNull(2)) voteRecord.UserID = reader.GetInt32(2); if (!reader.IsDBNull(3)) voteRecord.VoteTime = reader.GetDateTime(3); if (!reader.IsDBNull(4)) voteRecord.Additional = reader.GetString(4); if (!reader.IsDBNull(5)) voteRecord.IP = reader.GetString(5); voteRecord.MarkOld(); voteRecordlist.Add(voteRecord); } reader.Close(); } return voteRecordlist; }
public Core.Business.VoteRecord SelectByLimit6(int voteid, int userid, string IP, string votetime) { SqlServerUtility sql = new SqlServerUtility(); sql.AddParameter("@UserID", SqlDbType.Int, userid); sql.AddParameter("@VoteID", SqlDbType.Int, voteid); sql.AddParameter("@IP", SqlDbType.NVarChar, IP); sql.AddParameter("@VoteTime", SqlDbType.DateTime, votetime); SqlDataReader reader = sql.ExecuteSqlReader(SqlSelectVoteRecordByLimit6); if (reader != null && !reader.IsClosed && reader.Read()) { Core.Business.VoteRecord voteRecord = new Core.Business.VoteRecord(); if (!reader.IsDBNull(0)) voteRecord.Id = reader.GetInt32(0); if (!reader.IsDBNull(1)) voteRecord.VoteID = reader.GetInt32(1); if (!reader.IsDBNull(2)) voteRecord.UserID = reader.GetInt32(2); if (!reader.IsDBNull(3)) voteRecord.VoteTime = reader.GetDateTime(3); if (!reader.IsDBNull(4)) voteRecord.Additional = reader.GetString(4); if (!reader.IsDBNull(5)) voteRecord.IP = reader.GetString(5); voteRecord.MarkOld(); reader.Close(); return voteRecord; } else { if (reader != null && !reader.IsClosed) reader.Close(); return null; } }