//Precondition: User clicks "address" menu item //Postcondition: Address form is created and shown // as a dialog box private void addressToolStripMenuItem_Click(object sender, EventArgs e) { Prog2.AddressForm addressForm = new Prog2.AddressForm(); // creates address form DialogResult result; // Result from dialog - OK/Cancel? string name; // User's input for name (gather from dialog box) string address1; // User's input for address 1 (gather from dialog box) string address2; // User's input for address 2 (gather from dialog box) string city; // User's input for city (gather from dialog box) string state; // User's input for state (gather from dialog box) int zip; // User's input for zip (gather from dialog box) result = addressForm.ShowDialog(); // Show dialog box form - modal, waits for OK/Cancel // Even after user dismisses, the form still exists // and can be interacted with using methods/properties //if the user clicks the OK button, the data will be input if (result == DialogResult.OK) { zip = int.Parse(addressForm.ZipInputValue); name = addressForm.NameInputValue; address1 = addressForm.Address1InputValue; address2 = addressForm.Address2InputValue; city = addressForm.CityInputValue; state = addressForm.StateInputValue; upv.AddAddress(name, address1, address2, city, state, zip); //adds the address input into the upv object } }
// Precondition: addressToolStripMenuItem has been clicked // Postcondition: AddressForm has appeared private void addressToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult result; Prog2.AddressForm addressObject = new Prog2.AddressForm(); result = addressObject.ShowDialog(); int zip; if (result == DialogResult.OK) { zip = int.Parse(addressObject.ZipValue); upv.AddAddress(addressObject.NameValue, addressObject.AddressValue, addressObject.CityValue, addressObject.StateValue, zip); } }