From 8bd5e8ae4fa777f20731002949212e9e97fd522c Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sun, 10 Jul 2022 23:15:10 +0000 Subject: [PATCH] --- AyaNovaQBI/FixInvoiceProblems.cs | 80 +++++++------------- AyaNovaQBI/LinkOrImportAyaObject.Designer.cs | 21 ++--- AyaNovaQBI/LinkOrImportAyaObject.cs | 10 ++- 3 files changed, 47 insertions(+), 64 deletions(-) diff --git a/AyaNovaQBI/FixInvoiceProblems.cs b/AyaNovaQBI/FixInvoiceProblems.cs index 42e72df..90400de 100644 --- a/AyaNovaQBI/FixInvoiceProblems.cs +++ b/AyaNovaQBI/FixInvoiceProblems.cs @@ -1,11 +1,8 @@ using System; +using System.Collections; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; using System.Linq; using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace AyaNovaQBI @@ -150,7 +147,7 @@ namespace AyaNovaQBI if (d.Choice == "IMPORT") { ArrayList alErrors = new ArrayList(); - util.ImportAyaClient((Guid)e.Cell.Row.Cells["RootObjectID"].Value, alErrors); + await util.ImportAyaCustomer(mm.ObjectId, alErrors); //display errors if any if (alErrors.Count != 0) { @@ -176,20 +173,18 @@ namespace AyaNovaQBI else { //it's a link by default - if (d.SelectedQBItem == null || d.SelectedQBItem == "" || !util.QBClients.Rows.Contains(d.SelectedQBItem)) + if (string.IsNullOrWhiteSpace(d.SelectedQBItemId) || !util.QBClients.Rows.Contains(d.SelectedQBItemId)) return; QBItemName = d.SelectedQBItemName; } - - break; case AyaType.ServiceRate: d.CanImport = false; d.QBItems = util.QBItems; if (d.ShowDialog() == DialogResult.Cancel) return; - if (d.SelectedQBItem == null || d.SelectedQBItem == "" || !util.QBItems.Rows.Contains(d.SelectedQBItem)) + if (string.IsNullOrWhiteSpace(d.SelectedQBItemId) || !util.QBItems.Rows.Contains(d.SelectedQBItemId)) return; QBItemName = d.SelectedQBItemName; break; @@ -198,7 +193,7 @@ namespace AyaNovaQBI d.QBItems = util.QBItems; if (d.ShowDialog() == DialogResult.Cancel) return; - if (d.SelectedQBItem == null || d.SelectedQBItem == "" || !util.QBItems.Rows.Contains(d.SelectedQBItem)) + if (string.IsNullOrWhiteSpace(d.SelectedQBItemId) || !util.QBItems.Rows.Contains(d.SelectedQBItemId)) return; QBItemName = d.SelectedQBItemName; break; @@ -207,87 +202,66 @@ namespace AyaNovaQBI d.QBItems = util.QBItems; if (d.ShowDialog() == DialogResult.Cancel) return; - if (d.SelectedQBItem == null || d.SelectedQBItem == "" || !util.QBItems.Rows.Contains(d.SelectedQBItem)) + if (string.IsNullOrWhiteSpace(d.SelectedQBItemId) || !util.QBItems.Rows.Contains(d.SelectedQBItemId)) return; QBItemName = d.SelectedQBItemName; break; - case AyaType.WorkorderItemOutsideService: + case AyaType.WorkOrderItemOutsideService: d.CanImport = false; d.QBItems = util.QBItems; if (d.ShowDialog() == DialogResult.Cancel) return; - if (d.SelectedQBItem == null || d.SelectedQBItem == "" || !util.QBItems.Rows.Contains(d.SelectedQBItem)) + if (string.IsNullOrWhiteSpace(d.SelectedQBItemId) || !util.QBItems.Rows.Contains(d.SelectedQBItemId)) return; - util.QDat.OutsideServiceChargeAs = d.SelectedQBItem; - - //Case 299 - util.QBI.AIObject = util.QDat.XMLData; - //util.QBI.AIObject = util.QDat; - - util.QBI = (Integration)util.QBI.Save(); - util.QDat.IsDirty = false; + util.QDat.OutsideServiceChargeAs = d.SelectedQBItemId; + await util.SaveIntegrationObject(); goto REMOVEITEMS; - - case AyaType.WorkorderItemLoan: + case AyaType.WorkOrderItemLoan: d.CanImport = false; d.QBItems = util.QBItems; if (d.ShowDialog() == DialogResult.Cancel) return; - if (d.SelectedQBItem == null || d.SelectedQBItem == "" || !util.QBItems.Rows.Contains(d.SelectedQBItem)) + if (string.IsNullOrWhiteSpace(d.SelectedQBItemId) || !util.QBItems.Rows.Contains(d.SelectedQBItemId)) return; - util.QDat.WorkorderItemLoanChargeAs = d.SelectedQBItem; - //Case 299 - util.QBI.AIObject = util.QDat.XMLData; - //util.QBI.AIObject = util.QDat; - util.QBI = (Integration)util.QBI.Save(); - util.QDat.IsDirty = false; + util.QDat.WorkorderItemLoanChargeAs = d.SelectedQBItemId; + await util.SaveIntegrationObject(); goto REMOVEITEMS; - case AyaType.WorkorderItemMiscExpense: + case AyaType.WorkOrderItemExpense: d.CanImport = false; d.QBItems = util.QBItems; if (d.ShowDialog() == DialogResult.Cancel) return; - if (d.SelectedQBItem == null || d.SelectedQBItem == "" || !util.QBItems.Rows.Contains(d.SelectedQBItem)) + if (string.IsNullOrWhiteSpace(d.SelectedQBItemId) || !util.QBItems.Rows.Contains(d.SelectedQBItemId)) return; - util.QDat.MiscExpenseChargeAs = d.SelectedQBItem; - //Case 299 - util.QBI.AIObject = util.QDat.XMLData; - //util.QBI.AIObject = util.QDat; - util.QBI = (Integration)util.QBI.Save(); - util.QDat.IsDirty = false; + util.QDat.MiscExpenseChargeAs = d.SelectedQBItemId; + await util.SaveIntegrationObject(); goto REMOVEITEMS; - } - - //add the new link - IntegrationMap m = util.QBI.Maps.Add(util.QBI); - m.RootObjectID = (Guid)e.Cell.Row.Cells["RootObjectID"].Value; - m.RootObjectType = (RootObjectTypes)e.Cell.Row.Cells["ObjectType"].Value; - m.ForeignID = d.SelectedQBItem; - m.Name = QBItemName; - m.LastSync = System.DateTime.Now; - util.QBI = (Integration)util.QBI.Save(); + //add the new link + util.QBIntegration.Items.Add(new IntegrationItem { AType = mm.ObjectType, IntegrationItemName = QBItemName, IntegrationItemId = d.SelectedQBItemId, LastSync = DateTime.Now, ObjectId = mm.ObjectId }); + await util.SaveIntegrationObject(); REMOVEITEMS: - //remove the object from the grid as it's now dealt with - e.Cell.Row.Delete(false); - _ChangesMade = true; + MisMatches.RemoveAt(e.RowIndex); + ChangesMade = true; //If all done then close up - if (grid.Rows.Count == 0) - this.Close(); + if (MisMatches.Count == 0) + Close(); + else + grid.DataSource = MisMatches;//rebind to refresh the grid } catch (Exception ex) diff --git a/AyaNovaQBI/LinkOrImportAyaObject.Designer.cs b/AyaNovaQBI/LinkOrImportAyaObject.Designer.cs index 91497c2..e5b2412 100644 --- a/AyaNovaQBI/LinkOrImportAyaObject.Designer.cs +++ b/AyaNovaQBI/LinkOrImportAyaObject.Designer.cs @@ -33,7 +33,7 @@ this.lblTitle = new System.Windows.Forms.Label(); this.cbQBItems = new System.Windows.Forms.ComboBox(); this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); + this.lblImport = new System.Windows.Forms.Label(); this.btnImport = new System.Windows.Forms.Button(); this.SuspendLayout(); // @@ -88,14 +88,14 @@ this.label1.TabIndex = 14; this.label1.Text = "Link to QuickBooks item:"; // - // label2 + // lblImport // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(4, 177); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(194, 13); - this.label2.TabIndex = 15; - this.label2.Text = "Or import AyaNova item to QuickBooks:"; + this.lblImport.AutoSize = true; + this.lblImport.Location = new System.Drawing.Point(4, 177); + this.lblImport.Name = "lblImport"; + this.lblImport.Size = new System.Drawing.Size(194, 13); + this.lblImport.TabIndex = 15; + this.lblImport.Text = "Or import AyaNova item to QuickBooks:"; // // btnImport // @@ -105,6 +105,7 @@ this.btnImport.TabIndex = 16; this.btnImport.Text = "Import to QuickBooks"; this.btnImport.UseVisualStyleBackColor = true; + this.btnImport.Click += new System.EventHandler(this.btnImport_Click); // // LinkOrImportAyaObject // @@ -115,7 +116,7 @@ this.ClientSize = new System.Drawing.Size(637, 403); this.ControlBox = false; this.Controls.Add(this.btnImport); - this.Controls.Add(this.label2); + this.Controls.Add(this.lblImport); this.Controls.Add(this.label1); this.Controls.Add(this.cbQBItems); this.Controls.Add(this.lblTitle); @@ -138,7 +139,7 @@ private System.Windows.Forms.Label lblTitle; private System.Windows.Forms.ComboBox cbQBItems; private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label lblImport; private System.Windows.Forms.Button btnImport; } } \ No newline at end of file diff --git a/AyaNovaQBI/LinkOrImportAyaObject.cs b/AyaNovaQBI/LinkOrImportAyaObject.cs index 118825e..2f777dc 100644 --- a/AyaNovaQBI/LinkOrImportAyaObject.cs +++ b/AyaNovaQBI/LinkOrImportAyaObject.cs @@ -49,21 +49,29 @@ namespace AyaNovaQBI cbQBItems.ValueMember = "id"; btnCancel.Text = util.AyaTranslations["Cancel"]; btnOK.Text = util.AyaTranslations["OK"]; + lblImport.Visible = btnImport.Visible = CanImport; } private void btnCancel_Click(object sender, EventArgs e) { + Choice = "CANCEL"; DialogResult = DialogResult.Cancel; Close(); } private void btnOK_Click(object sender, EventArgs e) { + Choice = "LINK"; DialogResult = DialogResult.OK; Close(); } - + private void btnImport_Click(object sender, EventArgs e) + { + Choice = "IMPORT"; + DialogResult = DialogResult.OK; + Close(); + } }//eoc }//eons