Example #1
0
        //When you select an item from the 'City' list in the 'Select Location' group.
        private void cityDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            zipList.Clear();
            StringContainer cityObj = (StringContainer)cityDataGrid.SelectedItem;
            String          state   = (String)selectStateComboBox.SelectedItem;

            if (cityObj == null || state == null)
            {
                zipCodeDataGrid.Items.Refresh(); return;
            }
            String city = cityObj.ToString();

            using (NpgsqlConnection sqlconn = new NpgsqlConnection(login))
            {//Start SQL interaction
                sqlconn.Open();
                using (NpgsqlCommand cmd = new NpgsqlCommand())
                {
                    cmd.Connection  = sqlconn;
                    cmd.CommandText = "SELECT distinct zipcode FROM business WHERE state = '" + state + "' AND city = '" + city + "' order by zipcode; ";

                    using (NpgsqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            zipList.Add(new StringContainer(reader.GetString(0)));
                        }
                    }

                    zipCodeDataGrid.ItemsSource = zipList;
                    zipCodeDataGrid.Items.Refresh();
                }
                sqlconn.Close();
            }//End SQL interaction
        }
Example #2
0
        //-----Utility Functions------------------------------------------------------------------------
        //Generates a conditional for a SQL query based upon the selected items in the 'Select Location' group.
        private String LocationCondition()
        {
            String          state = (String)selectStateComboBox.SelectedItem;
            StringContainer city  = (StringContainer)cityDataGrid.SelectedItem;
            StringContainer zip   = (StringContainer)zipCodeDataGrid.SelectedItem;

            if (state == null)//No constraints selected.
            {
                return("true");
            }
            else if (city == null)//Only state selected.
            {
                return("state = '" + state + "'");
            }
            else if (zip == null)//Only state and city selected.
            {
                return("state = '" + state + "' AND city = '" + city.ToString() + "'");
            }
            else//State, City and Zip selected.
            {
                return("state = '" + state + "' AND city = '" + city.ToString() + "' AND zipcode = '" + zip.ToString() + "'");
            }
        }
Example #3
0
        //When you press the 'Add' button in the 'Business Category' group.
        private void businessCategoryAddButton_Click(object sender, RoutedEventArgs e)
        {
            StringContainer catObj = (StringContainer)mainBusinessCategorydataGrid.SelectedItem;

            if (catObj == null || catList.Contains(catObj))
            {
                return;
            }

            catList.Add(new StringContainer(catObj.ToString()));

            selectedBusinessCategorydataGrid.ItemsSource = catList;
            selectedBusinessCategorydataGrid.Items.Refresh();
        }
Example #4
0
            public override bool Equals(System.Object obj)
            {
                // If parameter is null return false.
                if (obj == null)
                {
                    return(false);
                }

                // If parameter cannot be cast to Point return false.
                StringContainer p = obj as StringContainer;

                if ((System.Object)p == null)
                {
                    return(false);
                }

                // Return true if the fields match:
                return(myString.Equals(p.ToString()));
            }