Beispiel #1
0
        private void BtnAddStreet_Click(object sender, EventArgs e)
        {
            Street addStreet = new Street()
            {
                StreetName = txtStreetName.Text
            };

            try
            {
                if (string.IsNullOrWhiteSpace(txtStreetName.Text))
                {
                    MessageBox.Show("You must enter a street name!");
                    return;
                }
                StreetsDB.AddStreet(addStreet);
                MessageBox.Show("Street Added!");
                PopulateStreetComboBox();
                PopulateStreetList();

                txtStreetName.Clear();
                txtStreetName.Focus();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("We are having server issues, please try again later");
            }
        }
Beispiel #2
0
        private void PopulateStreetComboBox()
        {
            cboStreetName.Items.Clear();

            try
            {
                List <Street> streets = StreetsDB.GetAllStreets();

                foreach (Street street in streets)
                {
                    cboStreetName.Items.Add(street);
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show("We are having trouble loading data, try again later");
                Application.Exit();
            }
        }