private void address_Load(object sender, EventArgs e) //this will load when the address form loads. this code will open a connection ot the database and then run the query we want it to run
        {
            citiesForm cityForm = new citiesForm();

            connection.Open();                         //this will open the connection to the access database
            OleDbCommand command = new OleDbCommand(); //this will give a command to the access database

            command.Connection = connection;           //now the command knows what the connection information is.
            string commandString;

            if (citiesForm.city != null)
            {
                commandString = "SELECT * FROM Addresses WHERE [City] ='" + citiesForm.city + "'";
            }
            else
            {
                commandString = "SELECT * FROM addresses WHERE [State ab]='" + stateForm.selectedState + "'";
            }


            command.CommandText = commandString; //this declares what query we want to execute;
            OleDbDataReader reader = command.ExecuteReader();


            while (reader.Read())                //we read through the information in the database
            {
                cities.Add(reader.GetString(2)); //we all the cities that were in the state into a list. GetString(2) gets the select element, which is cities in the database
            }
            connection.Close();                  //close the connection since we have all the data we need
        }
        private void btnBack_Click(object sender, EventArgs e)
        {
            citiesForm citiesform = new citiesForm();

            citiesform.Show();

            this.Close();
        }
예제 #3
0
 //the submit button that sends us to the next page.
 private void btn_addressNumberSubmit_Click(object sender, EventArgs e)
 {
     {
         this.Visible = false;
         citiesForm cities = new citiesForm();
         cities.Show();
         number = tb_addressNumber.Text.ToString();
     }
 }
        } //this is the method with the logic to hide ALL letters. The logic to show letters is in the method show letters.

        private void btnAddressSubmit_Click(object sender, EventArgs e)  //the submit button logic. Makes current form invisible and then opens the next form.
        {
            street       = tb_address.Text.ToString().ToLower();
            this.Visible = false;
            finalForm final = new finalForm();

            final.Show();
            citiesForm form = new citiesForm();

            //logic to determine what to do next based on what information is missing
            if (citiesForm.city == null)
            {
                street       = tb_address.Text.ToString().ToLower();
                this.Visible = false;
                form.Show();
            }
            else
            {
                final.Show();
                this.Visible = false;
            }
        }