コード例 #1
0
ファイル: EditCustomer.cs プロジェクト: mphayden/MyGarage
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (AllValidInputs() && IsValidEmail(txtEmail.Text))
            {
                Owner updatedOwner = new Owner();

                string updatedPhoneNumber =
                    txtPhoneAreaCode.Text + "-" +
                    txtPhoneFirstThreeDigits.Text + "-" +
                    txtPhoneLastFourDigits.Text;

                updatedOwner.firstName     = txtFirstName.Text;
                updatedOwner.lastName      = txtLastName.Text;
                updatedOwner.streetAddress = txtStreet.Text;
                updatedOwner.city          = txtCity.Text;
                updatedOwner.state         = cmbState.Text;
                updatedOwner.zip           = txtZip.Text;
                updatedOwner.emailAddress  = txtEmail.Text;
                updatedOwner.phoneNumber   = updatedPhoneNumber;

                int updateStatus = ownControl.UpdateOwner(editOwner, updatedOwner);

                if (updateStatus == 0)
                {
                    MessageBox.Show("You have successfully updated a customer!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("There was an error while saving, please try again.");
                }
            }
        }