Exemple #1
0
        private static void AddRoomButton_Click(object sender, RoutedEventArgs e)
        {
            Button        addRoomButton         = (Button)sender;
            List <object> objects               = (List <object>)addRoomButton.Tag;
            ComboBox      hotelComboBox         = (ComboBox)objects[0];
            TextBox       roomNumberTextBox     = (TextBox)objects[1];
            ComboBox      roomTypeComboBox      = (ComboBox)objects[2];
            Button        browseRoomPhotoButton = (Button)objects[3];
            Window        popup    = (Window)objects[4];
            DataModels    database = DataModels.GetInstance();

            if (hotelComboBox.SelectedItem == null)
            {
                MessageBox.Show("Please select a hotel");
                return;
            }
            Hotel hotel = (Hotel)((ComboBoxItem)hotelComboBox.SelectedItem).Content;

            int roomNumber;

            if (!int.TryParse(roomNumberTextBox.Text, out roomNumber))
            {
                MessageBox.Show("Please enter a valid room number");
                return;
            }

            if (roomTypeComboBox.SelectedItem == null)
            {
                MessageBox.Show("Please select a room type");
                return;
            }
            RoomType roomType = (RoomType)((ComboBoxItem)roomTypeComboBox.SelectedItem).Content;

            if ((string)browseRoomPhotoButton.Tag == "")
            {
                MessageBox.Show("Please select a photo path");
                return;
            }
            CustomImage roomImage = new CustomImage((string)browseRoomPhotoButton.Tag);

            Room room = new Room(roomNumber, hotel, roomType, roomImage, new List <RoomView>());

            if (database.AddRoom(room) == true)
            {
                MessageBox.Show("Added");
                if (adminWindow.currentCanvas != null)
                {
                    adminWindow.currentCanvas.Hide();
                }
                adminWindow.InitializeRoomsCanvas(database.GetAllRooms());
                popup.Close();
                return;
            }
            else
            {
                MessageBox.Show("please enter a valid room number");
                return;
            }
        }
Exemple #2
0
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            Button     deleteButton = (Button)sender;
            DataModels database     = DataModels.GetInstance();

            // remove rroom
            //database.deleteRoom();

            Admin_window adminWindow = FrontEndHelper.GetAdminWindow();

            if (adminWindow.currentCanvas != null)
            {
                adminWindow.currentCanvas.Hide();
            }
            adminWindow.InitializeRoomsCanvas(database.GetAllRooms());
        }