Пример #1
0
        // Click create new transaction
        private void button4_Click(object sender, EventArgs e)
        {
            // If there hasn't been a room selected, throw an exception and exit
            if (this.roomListBox.SelectedIndex == -1)
            {
                ExceptionInterface excep = new ExceptionInterface("Please select a room and try again");
                excep.Show();
                return;
            }

            // If there hasn't been a date range selected, throw an exception and exit
            if (roomReservationCalendar.SelectionStart == null || roomReservationCalendar.SelectionEnd == null)
            {
                ExceptionInterface excep = new ExceptionInterface("Please select a date range and try again");
                excep.Show();
                return;
            }

            // Parse room id from selected item
            string item   = roomListBox.SelectedItem.ToString();
            int    roomId = Convert.ToInt32(item.Substring(0, item.IndexOf(' ')));

            // Get start and end dates from calendar
            DateTime startDate = roomReservationCalendar.SelectionStart;
            DateTime endDate   = roomReservationCalendar.SelectionEnd;

            Dictionary <int, Reservation> reservations = this.hms.getReservationsByRoom(roomId); // Fetch all existing reservations for the room

            // Check selected range against all reservations. If there's an overlap, throw an exception and exit
            foreach (var pair in reservations)
            {
                if (!(DateTime.Compare(endDate, pair.Value.getStartDate()) <= 0 || DateTime.Compare(startDate, pair.Value.getEndDate()) >= 0))
                {
                    // If the dates overlap, throw an exception and exit
                    ExceptionInterface excep = new ExceptionInterface("Selected reservation overlaps with another. Please try again");
                    excep.Show();
                    return;
                }
            }

            // Spawn the transaction interface and give it everything it needs to continue the use case
            TransactionInterface transactionInterface = new TransactionInterface(this.customer, this.hms.getRoomData()[roomId], startDate, endDate);

            transactionInterface.Show();    // Show a transaction interface

            this.customer = hms.getCustomerData()[this.customer.getId()];
        }
Пример #2
0
        // On load
        private void EmployeeInterface_Load(object sender, EventArgs e)
        {
            hms = new HotelManagementSystem(); // Instantiate hms

            customers = hms.getCustomerData(); // Get a list of all customers

            foreach (var pair in customers)    // Add each to the listbox for customers
            {
                customerListBox.Items.Add($"{pair.Value.getId()} - {pair.Value.getName()} - {pair.Value.getDateOfBirth()}");
            }

            hotels = hms.getHotelData();    // Get a list of all hotels

            foreach (var pair in hotels)    // Add each to the listbox for hotels
            {
                hotelListBox.Items.Add($"{pair.Value.getId()} - {pair.Value.getName()} - {pair.Value.getStreetAddress()}, {pair.Value.getCity()}, {pair.Value.getState()}");
                managementHotelListBox.Items.Add($"{pair.Value.getId()} - {pair.Value.getName()} - {pair.Value.getStreetAddress()}, {pair.Value.getCity()}, {pair.Value.getState()}");
            }
        }