// Precondition: The Insert >> Letter menu item has been selected // Postcondition: A dialog box prompts the user for new Letter information. // If the user submits, a new Letter object is created. private void letterToolStripMenuItem_Click(object sender, EventArgs e) { AddLetterForm addLetter = new AddLetterForm(upv.AddressList); // Calls Add Letter Form DialogResult result = addLetter.ShowDialog(); // Result from dialog - OK/Cancel? if (result == DialogResult.OK) // Letter object is created if user selects OK from dialog box { upv.AddLetter(upv.AddressAt(addLetter.ReturnAddress), upv.AddressAt(addLetter.DestinationAddress), decimal.Parse(addLetter.FixedCost)); } }
// Precondition: Insert letter menu item selected // Postcondition: AddLetterForm is opened private void insertLetterMenuItem_Click(object sender, EventArgs e) { List <Parcel> listOfletters = new List <Parcel>(); // List of parcels listOfletters = upv.ParcelList; AddLetterForm addLetterForm = new AddLetterForm(upv.AddressList); // List of letters DialogResult result; // Holds result from dialog box result = addLetterForm.ShowDialog(); // Shows dialog box if (result == DialogResult.OK) { upv.AddLetter(upv.AddressAt(addLetterForm.AddOriginAddress), upv.AddressAt(addLetterForm.AddDestinationAddress), addLetterForm.AddFixedCost); } }
// Pre-Condition: None // Post-Condition: A new AddLetterForm will be created and shown. private void LetterToolStripMenuItem_Click(object sender, EventArgs e) { AddLetterForm addLetterForm = new AddLetterForm(this); addLetterForm.Show(); }