private void btnOk_Click(object sender, EventArgs e) { tbTitle.Text = tbTitle.Text.Trim(); if (account != null) { // updating existing account account = keeper.UpdateAccount(account.ID, tbTitle.Text, tbDescription.Text, cbHideAccount.Checked, ttbTags.Tags); } else { // creating new account account = keeper.PreCreateAccount(cbAccountType.SelectedItem as MoneyDataSet.AccountTypesRow, tbTitle.Text, tbDescription.Text, cbCurrency.SelectedItem as MoneyDataSet.CurrenciesRow, 0); ValidationResult result = keeper.Validate(account: account); if (!result.Success) { if (result.PreventAction) { MessageBox.Show(String.Format(Resources.Labels.AccountValidationErrorsFoundFormat, result.Message), Resources.Labels.AccountValidationTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (MessageBox.Show(String.Format(Resources.Labels.AccountValidationWarningsFoundFormat, result.Message), Resources.Labels.AccountValidationTitle, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel) { return; } } } account = keeper.CreateAccount(account, ttbTags.Tags); } keeper.AddTextHistory(Consts.Keeper.AccountTitleHistoryID, tbTitle.Text); this.DialogResult = DialogResult.OK; this.Close(); }