Пример #1
0
        private void UpdateFilters(SearchType searchType)
        {
            deleteBtn.Visibility = Visibility.Hidden;
            switch (searchType)
            {
            case (SearchType.Property):
                EnablePropertySearch();
                deleteBtn.Visibility = Visibility.Visible;
                break;

            case (SearchType.District):
                EnableDistrictSearch();
                break;

            case (SearchType.Neighbourhood):
                EnableNeighbourhoodSearch();
                break;
            }

            District[] districts = AirbnbMain.GetInstance().GetDistricts();

            districtComboBox.ItemsSource = districts;
            resultsListBox.ItemsSource   = districts;

            districtComboBox.SelectedItem = null;
            neighbourComboBox.ItemsSource = null;
            propertyComboBox.ItemsSource  = null;

            resultsListBox.SelectedItem = null;
        }
Пример #2
0
        private void DeleteBtn_Click(object sender, RoutedEventArgs e)
        {
            if (resultsListBox.SelectedItem == null)
            {
                MessageBox.Show("Please select a property before deleting!");
            }
            else
            {
                Property[] properties = ((Neighbourhood)neighbourComboBox.SelectedItem).GetProperties();
                Property   property   = (Property)resultsListBox.SelectedItem;

                int index = DataUtils.GetPropertyIndexFromID(properties, property.GetId());

                DataUtils.RemoveAtIndex(ref properties, index);

                ((Neighbourhood)neighbourComboBox.SelectedItem).SetProperties(properties);
                ((Neighbourhood)neighbourComboBox.SelectedItem).SetNumInCollection(properties.Length);

                int neighbourIndex = neighbourComboBox.SelectedIndex;

                ((District)districtComboBox.SelectedItem)
                .SetNeighbourhood(((Neighbourhood)neighbourComboBox.SelectedItem)
                                  , neighbourIndex);

                AirbnbMain.GetInstance().SaveData();

                neighbourComboBox.ItemsSource = ((District)districtComboBox.SelectedItem).GetNeighbourhoods();

                neighbourComboBox.SelectedItem = null;
                propertyComboBox.SelectedItem  = null;

                MessageBox.Show("Successfully Deleted Property!");
            }
        }
        public AnalyticsWindow(MainWindow mainWindow)
        {
            InitializeComponent();
            this.mainWindow = mainWindow;

            // Set combobox item source to the districts from the AirbnbMain instance
            districtComboBox.ItemsSource = AirbnbMain.GetInstance().GetDistricts();
        }
Пример #4
0
        public AdminWindow(MainWindow mainWindow)
        {
            InitializeComponent();

            this.mainWindow = mainWindow;

            searchPage = new SearchPage(this);
            ChangeFrame(searchPage);

            AirbnbMain.GetInstance().SetAdminWindow(this);
        }
Пример #5
0
        private void DistrictComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (districtComboBox.SelectedItem != null)
            {
                string name = ((District)districtComboBox.SelectedItem).GetName();

                Neighbourhood[] neighbourhoods = ((District)DataUtils
                                                  .GetAirbnbCollectionFromName(AirbnbMain.GetInstance()
                                                                               .GetDistricts(), name))
                                                 .GetNeighbourhoods();

                neighbourComboBox.ItemsSource = neighbourhoods;

                if (searchType == SearchType.Neighbourhood || searchType == SearchType.Property)
                {
                    resultsListBox.ItemsSource = neighbourComboBox.ItemsSource;
                }
                else if (searchType == SearchType.District)
                {
                    resultsListBox.ItemsSource = new District[] { (District)districtComboBox.SelectedItem };
                }
            }
        }
Пример #6
0
        private void LoadDataFileBtn_Click(object sender, RoutedEventArgs e)
        {
            string dataFileName = dataFileTxt.Text;

            if (dataFileName == null || dataFileName.Length == 0)
            {
                MessageBox.Show("Please select a file before loading");
            }
            else
            {
                AirbnbMain.GetInstance().SetFileName(dataFileName);

                if (AirbnbMain.GetInstance().LoadData())
                {
                    MessageBox.Show("Successfully Loaded data.");
                    adminBtn.Visibility     = Visibility.Visible;
                    analyticsBtn.Visibility = Visibility.Visible;
                }
                else
                {
                    MessageBox.Show("Unable to load data, check data file is correct");
                }
            }
        }
Пример #7
0
        private void NeighbourComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (neighbourComboBox.SelectedItem != null && districtComboBox.SelectedItem != null)
            {
                string name = ((District)districtComboBox.SelectedItem).GetName();
                string neighbourhoodName = ((Neighbourhood)neighbourComboBox.SelectedItem).GetName();

                if (searchType == SearchType.Property)
                {
                    propertyComboBox.ItemsSource =
                        ((Neighbourhood)DataUtils.GetAirbnbCollectionFromName(
                             ((District)DataUtils.GetAirbnbCollectionFromName(
                                  AirbnbMain.GetInstance().GetDistricts(), name))
                             .GetNeighbourhoods(), neighbourhoodName))
                        .GetProperties();

                    resultsListBox.ItemsSource = propertyComboBox.ItemsSource;
                }
                else
                {
                    resultsListBox.ItemsSource = new Neighbourhood[] { (Neighbourhood)neighbourComboBox.SelectedItem };
                }
            }
        }