Exemplo n.º 1
0
 private void LetterForm_Load(object sender, EventArgs e)
 {
     for (int n = 0; n < upvList.AddressCount; n++)
     {
         originInput.Items.Add(upvList.AddressAt(n));
         destinationInput.Items.Add(upvList.AddressAt(n));
     }
 }
Exemplo n.º 2
0
        //PreConditions: User clicks edit button
        //PostConditions: Shows a Address Form
        private void editButton_Click(object sender, EventArgs e)
        {
            //Get the index of the selected value
            int selectedIndex = addressCBox.SelectedIndex;

            //If nothing is selected tell the user and return
            if (selectedIndex < 0)
            {
                MessageBox.Show("You must select an address to edit");
                return;
            }


            //The user selected a valid index lets create the form
            AddressForm addressForm = new AddressForm();

            //Get the address
            var address = _UPV.AddressAt(addressCBox.SelectedIndex);

            //Set the forms values based on the selected address
            addressForm.AddressName = address.Name;
            addressForm.Address1    = address.Address1;
            addressForm.Address2    = address.Address2;
            addressForm.City        = address.City;
            addressForm.State       = address.State;
            addressForm.ZipText     = address.Zip.ToString();

            //Lets hide the form to make it look cleaner
            this.Visible = false;

            //Show the address form and wait for a response
            var result = addressForm.ShowDialog();

            //The user closed the form, if they accepted the edit lets set the values, if not close the form
            if (result == DialogResult.OK)
            {
                //Set the values from the form to the address
                address.Name     = addressForm.AddressName;
                address.Address1 = addressForm.Address1;
                address.Address2 = addressForm.Address2;
                address.City     = addressForm.City;
                address.State    = addressForm.State;
                address.Zip      = int.Parse(addressForm.ZipText);

                //Close the form with an OK status
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                //Closes the form
                cancelButton_Click(sender, e);
            }
        }