Esempio n. 1
0
        //Only use at aspx
        public RoomDTO getRoom(List <RoomDTO> roomList, int roomID)
        {
            RoomDTO dto = null;

            foreach (var room in roomList)
            {
                if (room.RoomID == roomID)
                {
                    dto = room;
                    break;
                }
            }
            return(dto);
        }
Esempio n. 2
0
        public List <RoomDTO> GetRoomList()
        {
            List <RoomDTO> listRoom = null;
            SqlConnection  con      = new SqlConnection(strConnection);

            if (con.State == System.Data.ConnectionState.Closed)
            {
                con.Open();
            }
            try
            {
                string        sql    = "Select roomID, numberOfSear, isAvailable FROM Room";
                SqlCommand    cmd    = new SqlCommand(sql, con);
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    listRoom = new List <RoomDTO>();
                    while (reader.Read())
                    {
                        RoomDTO dto = new RoomDTO
                        {
                            RoomID       = reader.GetInt32(0),
                            NumberOfSeat = reader.GetInt32(1),
                            IsActive     = reader.GetBoolean(2)
                        };
                        listRoom.Add(dto);
                    }
                }
            }
            catch (Exception)
            {
                listRoom = null;
            }
            finally
            {
                con.Close();
            }
            return(listRoom);
        }
Esempio n. 3
0
        public List <RoomDTO> GetRoomListForSchedule()
        {
            List <RoomDTO> listRoom = null;
            SqlConnection  con      = new SqlConnection(strConnection);

            if (con.State == System.Data.ConnectionState.Closed)
            {
                con.Open();
            }
            try
            {
                string        sql    = "Select roomID FROM Room WHERE isAvailable = 1";
                SqlCommand    cmd    = new SqlCommand(sql, con);
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    listRoom = new List <RoomDTO>();
                    while (reader.Read())
                    {
                        RoomDTO dto = new RoomDTO
                        {
                            RoomID = reader.GetInt32(0)
                        };
                        listRoom.Add(dto);
                    }
                }
            }
            catch (Exception)
            {
                listRoom = null;
            }
            finally
            {
                con.Close();
            }
            return(listRoom);
        }