public IList<Core.Business.StudentRoom> GetStudentRoomByRoomCode(string roomCode) { IList<Core.Business.StudentRoom> studentRoomlist = new List<Core.Business.StudentRoom>(); SqlServerUtility sqlhelper = new SqlServerUtility(); sqlhelper.AddParameter("@RoomCode", SqlDbType.NVarChar, roomCode); SqlDataReader reader = sqlhelper.ExecuteSqlReader(SqlGetStudentRoomByRoomCode); if (reader != null) { while (reader.Read()) { Core.Business.StudentRoom studentRoom = new Core.Business.StudentRoom(); if (!reader.IsDBNull(0)) studentRoom.Id = reader.GetInt32(0); if (!reader.IsDBNull(1)) studentRoom.StudentCode = reader.GetString(1); if (!reader.IsDBNull(2)) studentRoom.RoomCode = reader.GetString(2); if (!reader.IsDBNull(3)) studentRoom.StayStartDate = reader.GetDateTime(3); if (!reader.IsDBNull(4)) studentRoom.StayEndDate = reader.GetDateTime(4); if (!reader.IsDBNull(5)) studentRoom.IsState = reader.GetBoolean(5); studentRoom.MarkOld(); studentRoomlist.Add(studentRoom); } reader.Close(); } return studentRoomlist; }
public Core.Business.StudentRoom Select(int id) { SqlServerUtility sql = new SqlServerUtility(); sql.AddParameter("@Id", SqlDbType.Int, id); SqlDataReader reader = sql.ExecuteSqlReader(SqlSelectStudentRoom); if (reader != null && !reader.IsClosed && reader.Read()) { Core.Business.StudentRoom studentRoom = new Core.Business.StudentRoom(); if (!reader.IsDBNull(0)) studentRoom.Id = reader.GetInt32(0); if (!reader.IsDBNull(1)) studentRoom.StudentCode = reader.GetString(1); if (!reader.IsDBNull(2)) studentRoom.RoomCode = reader.GetString(2); if (!reader.IsDBNull(3)) studentRoom.StayStartDate = reader.GetDateTime(3); if (!reader.IsDBNull(4)) studentRoom.StayEndDate = reader.GetDateTime(4); if (!reader.IsDBNull(5)) studentRoom.IsState = reader.GetBoolean(5); reader.Close(); return studentRoom; } else { if (reader != null && !reader.IsClosed) reader.Close(); return null; } }