Пример #1
0
        // This method is only ran when the user selects a zipcode from the
        // the zipcodeDataGrid. The purpose is to fill up the searchResultsDataGrid
        // and the categoriesDataGrid using the state, city and zipcode selected
        private void zipcodeGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (zipcodeGrid.SelectedIndex > -1)
            {
                searchResultsDataGrid.Items.Clear();
                categoriesDataGrid.Items.Clear();
                BusinessNameTextBox.Clear();
                addRemoveDataGrid.Items.Clear();
                dayOfWeekCombo.Items.Clear();
                FromCombo.Items.Clear();
                toCombo.Items.Clear();

                string state   = stateComboBox.SelectedItem.ToString();
                string city    = GetCellContentName(cityDataGrid);
                string zipcode = zipcode = GetCellContentName(zipcodeGrid);

                //Dont forget to add hoursopen
                string query = "SELECT bname, address, tips, checkins, bid, latitude, longitude " +
                               "FROM yelp_business " +
                               "WHERE state = '" + state + "' " +
                               "AND city = '" + city + "' " +
                               "AND zipcode = '" + zipcode + "' " +
                               "ORDER BY bname;";

                var data = database.RunQuery(query);
                PopulateDataGrid(searchResultsDataGrid, data, typeof(Business));

                PopulateCategories(state, city, zipcode);
                PopulateTimeFilter();
            }
        }
Пример #2
0
        // Updates the businessNameTextbox to the currently selected business from searchResultsDataGrid
        private void searchResultsDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            BusinessNameTextBox.Clear();

            if (searchResultsDataGrid.SelectedIndex > -1)
            {
                Business business = (Business)searchResultsDataGrid.SelectedItem;
                BusinessNameTextBox.Text     = business.bname;
                BusinessNameTextBox.FontSize = 15;
            }
        }
Пример #3
0
        // This method removes a category from one dataGrid, and adds it to the next
        // dataGrid depending on which 2 dataGrids are passed. And then
        // reruns the query for the searchResultsDataGrid with the added or
        // removed categories.
        private void ChangeAddRemoveDataGrid(DataGrid addTo, DataGrid removeFrom)
        {
            string state   = stateComboBox.SelectedItem.ToString();
            string city    = GetCellContentName(cityDataGrid);
            string zipcode = GetCellContentName(zipcodeGrid);

            BusinessNameTextBox.Clear();

            var itemToMove = removeFrom.SelectedItem;

            removeFrom.Items.RemoveAt(removeFrom.SelectedIndex);
            addTo.Items.Add(itemToMove as Category);
            SortCategoriesGrid(addTo);
            TimeFilterAndCategoryFilter();
        }
Пример #4
0
        // This method only runs when a state has been selected in the stateComboBox.
        // The purpose is to run a query in the DB and return all distinct cities
        // inside the chosen state.
        private void stateComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            cityDataGrid.Items.Clear();
            zipcodeGrid.Items.Clear();
            searchResultsDataGrid.Items.Clear();
            categoriesDataGrid.Items.Clear();
            addRemoveDataGrid.Items.Clear();
            BusinessNameTextBox.Clear();

            string query = "SELECT DISTINCT city " +
                           "FROM yelp_business " +
                           "WHERE state = '" + stateComboBox.SelectedItem.ToString() + "' " +
                           "ORDER BY city;";

            var data = database.RunQuery(query);

            PopulateDataGrid(cityDataGrid, data, typeof(Business));
        }
Пример #5
0
        // This method is the SelectionChanged event for the cityDataGrid.
        // It first clears all other grids that depend on the cityDateGrid (i.e zipcode, search results and categories)
        // and then it runs a query which returns all distinct zipcodes in this city and state
        private void cityDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cityDataGrid.SelectedIndex > -1)
            {
                addRemoveDataGrid.Items.Clear();
                categoriesDataGrid.Items.Clear();
                searchResultsDataGrid.Items.Clear();
                zipcodeGrid.Items.Clear();
                BusinessNameTextBox.Clear();

                string state = stateComboBox.SelectedItem.ToString();
                string city  = GetCellContentName(cityDataGrid);

                string query = "SELECT DISTINCT zipcode " +
                               "FROM yelp_business " +
                               "WHERE state = '" + state + "' " +
                               "AND city = '" + city + "' " +
                               "ORDER BY zipcode;";

                var data = database.RunQuery(query);
                PopulateDataGrid(zipcodeGrid, data, typeof(Business));
            }
        }