public IList<Core.Business.RoomInfo> GetAllRoomInfo() { IList<Core.Business.RoomInfo> roomInfolist = new List<Core.Business.RoomInfo>(); SqlServerUtility sql = new SqlServerUtility(); SqlDataReader reader = sql.ExecuteSqlReader(SqlGetAllRoomInfo); if (reader != null) { while (reader.Read()) { Core.Business.RoomInfo roomInfo = new Core.Business.RoomInfo(); if (!reader.IsDBNull(0)) roomInfo.Id = reader.GetInt32(0); if (!reader.IsDBNull(1)) roomInfo.RoomCode = reader.GetString(1); if (!reader.IsDBNull(2)) roomInfo.BuildingCode = reader.GetString(2); if (!reader.IsDBNull(3)) roomInfo.RoomNum = reader.GetString(3); if (!reader.IsDBNull(4)) roomInfo.TotalNum = reader.GetInt32(4); //if (!reader.IsDBNull(5)) roomInfo.ExistNum = reader.GetInt32(5); //if (!reader.IsDBNull(6)) roomInfo.AvailNum = reader.GetInt32(6); if (!reader.IsDBNull(7)) roomInfo.RoomState = reader.GetString(7); roomInfo.MarkOld(); roomInfolist.Add(roomInfo); } reader.Close(); } return roomInfolist; }
public Core.Business.RoomInfo GetByBuildAndNo(string BuildCode, string RoomNo) { SqlServerUtility sql = new SqlServerUtility(); sql.AddParameter("@BuildingCode", SqlDbType.NVarChar, BuildCode); sql.AddParameter("@RoomNum", SqlDbType.NVarChar, RoomNo); SqlDataReader reader = sql.ExecuteSqlReader(SqlGetByBuildAndNo); if (reader != null && !reader.IsClosed && reader.Read()) { Core.Business.RoomInfo roomInfo = new Core.Business.RoomInfo(); if (!reader.IsDBNull(0)) roomInfo.Id = reader.GetInt32(0); if (!reader.IsDBNull(1)) roomInfo.RoomCode = reader.GetString(1); if (!reader.IsDBNull(2)) roomInfo.BuildingCode = reader.GetString(2); if (!reader.IsDBNull(3)) roomInfo.RoomNum = reader.GetString(3); if (!reader.IsDBNull(4)) roomInfo.TotalNum = reader.GetInt32(4); //if (!reader.IsDBNull(5)) roomInfo.ExistNum = reader.GetInt32(5); //if (!reader.IsDBNull(6)) roomInfo.AvailNum = reader.GetInt32(6); if (!reader.IsDBNull(7)) roomInfo.RoomState = reader.GetString(7); reader.Close(); roomInfo.MarkOld(); return roomInfo; } else { if (reader != null && !reader.IsClosed) reader.Close(); return null; } }
public IList<Core.Business.RoomInfo> GetListByQuery(string wherestr) { IList<Core.Business.RoomInfo> roomInfolist = new List<Core.Business.RoomInfo>(); SqlServerUtility sql = new SqlServerUtility(); StringBuilder sb = new StringBuilder(); sb.Append(SqlGetAllRoomInfo); if (!string.IsNullOrEmpty(wherestr)) sb.Append(" Where 1=1 AND " + wherestr); SqlDataReader reader = sql.ExecuteSqlReader(sb.ToString()); if (reader != null) { while (reader.Read()) { Core.Business.RoomInfo roomInfo = new Core.Business.RoomInfo(); if (!reader.IsDBNull(0)) roomInfo.Id = reader.GetInt32(0); if (!reader.IsDBNull(1)) roomInfo.RoomCode = reader.GetString(1); if (!reader.IsDBNull(2)) roomInfo.BuildingCode = reader.GetString(2); if (!reader.IsDBNull(3)) roomInfo.RoomNum = reader.GetString(3); if (!reader.IsDBNull(4)) roomInfo.TotalNum = reader.GetInt32(4); //if (!reader.IsDBNull(5)) roomInfo.ExistNum = reader.GetInt32(5); //if (!reader.IsDBNull(6)) roomInfo.AvailNum = reader.GetInt32(6); if (!reader.IsDBNull(7)) roomInfo.RoomState = reader.GetString(7); roomInfo.MarkOld(); roomInfolist.Add(roomInfo); } reader.Close(); } return roomInfolist; }