From e2ecec24d330cc5db2b552a757244a3344831cbe Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 1 Jul 2022 21:14:51 +0000 Subject: [PATCH] --- AyaNovaQBI/SetQBInvoiceTemplate.cs | 21 ++++++++++++++++++++- AyaNovaQBI/SetQBTerms.cs | 15 ++++++++++++++- AyaNovaQBI/util.cs | 16 ++++------------ 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/AyaNovaQBI/SetQBInvoiceTemplate.cs b/AyaNovaQBI/SetQBInvoiceTemplate.cs index 642e427..17c5ad3 100644 --- a/AyaNovaQBI/SetQBInvoiceTemplate.cs +++ b/AyaNovaQBI/SetQBInvoiceTemplate.cs @@ -21,7 +21,21 @@ namespace AyaNovaQBI public DataTable QBInvoiceTemplates { get; set; } - public string SelectedQBInvoiceTemplate { get => (string)cbQBItems.SelectedValue; set { } } + + + public string SelectedQBInvoiceTemplate + { + get + { + return _selectedQBInvoiceTemplate; + } + + set + { + _selectedQBInvoiceTemplate = value; + } + } + private string _selectedQBInvoiceTemplate; private void SetQBClass_load(object sender, EventArgs e) { @@ -35,6 +49,11 @@ namespace AyaNovaQBI cbQBItems.DisplayMember = "FullName"; cbQBItems.ValueMember = "ID"; lblStatus.Text = "QuickBooks invoice template:"; + + if (string.IsNullOrWhiteSpace(_selectedQBInvoiceTemplate)) + cbQBItems.SelectedIndex = 0; + else + this.cbQBItems.SelectedValue = _selectedQBInvoiceTemplate; } diff --git a/AyaNovaQBI/SetQBTerms.cs b/AyaNovaQBI/SetQBTerms.cs index f546761..09f84a8 100644 --- a/AyaNovaQBI/SetQBTerms.cs +++ b/AyaNovaQBI/SetQBTerms.cs @@ -21,7 +21,20 @@ namespace AyaNovaQBI public DataTable QBTerms { get; set; } - public string SelectedQBTerm { get => (string)cbQBTerms.SelectedValue; set { } } + + public string SelectedQBTerm + { + get + { + return _selectedQBTerm; + } + + set + { + _selectedQBTerm = value; + } + } + private string _selectedQBTerm; private void SetQBClass_load(object sender, EventArgs e) { diff --git a/AyaNovaQBI/util.cs b/AyaNovaQBI/util.cs index 8e514b3..d7b1c38 100644 --- a/AyaNovaQBI/util.cs +++ b/AyaNovaQBI/util.cs @@ -996,7 +996,7 @@ namespace AyaNovaQBI #region QB Transaction class //Validate any existing - if (SetEverything == false && QDat.TransactionClass != null && QDat.TransactionClass != "") + if (SetEverything == false && !string.IsNullOrWhiteSpace(QDat.TransactionClass)) { //if something is set but there are no tr classes //then just clear it and move along @@ -1039,9 +1039,9 @@ namespace AyaNovaQBI if (QBClasses.Rows.Contains(QDat.TransactionClass)) s3.SelectedQBClass = QDat.TransactionClass; else - s3.SelectedQBClass = TRANSACTION_CLASS_NO_CLASS_SELECTED; + s3.SelectedQBClass = TRANSACTION_CLASS_NO_CLASS_SELECTED; - if (s3.ShowDialog() == DialogResult.Cancel) + if (s3.ShowDialog() == DialogResult.Cancel) { return pfstat.Cancel; @@ -1076,7 +1076,6 @@ namespace AyaNovaQBI "for now it is disabled and the default invoice template will be used"; s3a.ShowDialog(); - goto TRInvoiceTemplateOK; } @@ -1132,8 +1131,7 @@ namespace AyaNovaQBI "for invoices. If you do not use Invoice templates or are not sure what they are\r\n" + "select < Use default > from the list below.\r\n\r\n" + "This setting is required."; - s3b.QBInvoiceTemplates = QBInvoiceTemplates; - + s3b.QBInvoiceTemplates = QBInvoiceTemplates; s3b.SelectedQBInvoiceTemplate = QDat.QBInvoiceTemplate; if (s3b.ShowDialog() == DialogResult.Cancel) @@ -1195,7 +1193,6 @@ namespace AyaNovaQBI "When an invoice for a customer is created the selected terms will be applied.\r\n\r\n" + "This setting is required."; termsdialog.QBTerms = QBTerms; - termsdialog.SelectedQBTerm = QDat.TermsDefault; if (termsdialog.ShowDialog() == DialogResult.Cancel) @@ -1221,10 +1218,6 @@ namespace AyaNovaQBI goto TBPOK; } - - - - SetToBePrinted s4 = new SetToBePrinted(); s4.DialogTitle = "AyaNova QBI setup - Set invoice to be printed?"; s4.OptionTitle = "Invoice to be printed"; @@ -1257,7 +1250,6 @@ namespace AyaNovaQBI goto SETMEMOOK; } - SetMemoField s5 = new SetMemoField(); s5.DialogTitle = "AyaNova QBI setup - Set Memo field?"; s5.OptionTitle = "Invoice memo field";