/// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveButton_Click(object sender, EventArgs e)
        {
            // Commit any uncommitted changes. Changes in a bound text box are
            // normally committed to the data source only when the text box
            // loses focus. However, application bar buttons do not receive or
            // change focus because they are not Silverlight controls.
            CommitItemWithFocus();

            if (!CheckParams())
            {
                return;
            }

            // Save the account, category, and/or subcategory if necessary
            if (AccountTextBox.Visibility == Visibility.Visible)
            {
                if (!Datastore.Accounts.Contains(AccountTextBox.Text))
                {
                    Datastore.Accounts.Add(AccountTextBox.Text);
                }
            }

            if (CategoryTextBox.Visibility == Visibility.Visible)
            {
                if (!Datastore.MasterCategories().Contains(CategoryTextBox.Text))
                {
                    Datastore.AddCategory(CategoryTextBox.Text);
                }
            }

            if (SubCategoryTextBox.Visibility == Visibility.Visible)
            {
                String cat = CategoryTextBox.Text;
                if (CategoryListPicker.Visibility == Visibility.Visible)
                {
                    cat = (String)CategoryListPicker.SelectedItem;
                }
                if (!Datastore.SubCategories(cat).Contains(SubCategoryTextBox.Text))
                {
                    Datastore.AddSubcategory(cat, SubCategoryTextBox.Text);
                }
            }

            SaveResult result = new SaveResult();

            if (transactionToEdit != null)
            {
                result = Datastore.DeleteTransaction(transactionToEdit, delegate { MessageBox.Show(Constants.MSG_DELETE); });
                if (!result.SaveSuccessful)
                {
                    goto Failure;
                }
            }

            result = Datastore.AddTransaction(currentTransaction, delegate { MessageBox.Show(Constants.MSG_NO_SPACE); });
            if (result.SaveSuccessful)
            {
                Microsoft.Phone.Shell.PhoneApplicationService.Current.State[Constants.SAVED_KEY_TRANSACTIONS] = true;
                NavigationService.GoBack();
            }

Failure:
            if (!result.SaveSuccessful)
            {
                string errorMessages = String.Join(Environment.NewLine + Environment.NewLine, result.ErrorMessages.ToArray());
                if (!String.IsNullOrEmpty(errorMessages))
                {
                    MessageBox.Show(errorMessages, "Warning: Invalid Values", MessageBoxButton.OK);
                }
            }
        }