diff --git a/AyaNovaQBI/AyaNovaQBI.csproj b/AyaNovaQBI/AyaNovaQBI.csproj index d2e2fc6..1f558d8 100644 --- a/AyaNovaQBI/AyaNovaQBI.csproj +++ b/AyaNovaQBI/AyaNovaQBI.csproj @@ -159,6 +159,12 @@ SetQBClass.cs + + Form + + + SetQBImportServiceRateAccounts.cs + Form @@ -248,6 +254,9 @@ SetQBClass.cs + + SetQBImportServiceRateAccounts.cs + SetQBInvoiceTemplate.cs diff --git a/AyaNovaQBI/Map.cs b/AyaNovaQBI/Map.cs index 8c0947d..74a4775 100644 --- a/AyaNovaQBI/Map.cs +++ b/AyaNovaQBI/Map.cs @@ -115,47 +115,35 @@ namespace AyaNovaQBI w.Ops = "Importing from QuickBooks..."; try { - - switch (_Type) + foreach (DataGridViewRow r in gridQB.SelectedRows) { - case AyaType.Customer: - foreach (object o in moveData.Rows) - { - w.Step = ((QBNameID)o).Name; + var QBItemName = r.Cells[0].Value.ToString(); + var QBItemId = r.Cells[1].Value.ToString(); + w.Step = QBItemName; - await util.ImportQBCustomer(((QBNameID)o).ID, alErrors); - } - break; - case AyaType.Vendor: - foreach (object o in moveData.Rows) - { - w.Step = ((QBNameID)o).Name; + switch (_Type) + { + case AyaType.Customer: + await util.ImportQBCustomer(QBItemId, alErrors); + break; + case AyaType.Vendor: + await util.ImportQBVendor(QBItemId, alErrors); + break; - Util.ImportQBVendor(((QBNameID)o).ID, this._currentVendorType, alErrors); - } - break; + case AyaType.ServiceRate: + await util.ImportQBServiceRate(QBItemId, alErrors); + break; - case AyaType.Rate: - foreach (object o in moveData.Rows) - { - w.Step = ((QBNameID)o).Name; + case AyaType.TravelRate: + await util.ImportQBTravelRate(QBItemId, alErrors); + break; + case AyaType.Part: + await util.ImportQBPart(QBItemId, alErrors); + break; - Util.ImportQBRate(((QBNameID)o).ID, this._currentRateType, _MostLikelyRateUnitChargeDescriptionID, alErrors); - } - break; - - - case AyaType.Part: - foreach (object o in moveData.Rows) - { - w.Step = ((QBNameID)o).Name; - - Util.ImportQBPart(((QBNameID)o).ID, alErrors); - } - break; - - default: - throw new System.NotSupportedException("ImportToAyaNova: NOT SUPPORTED (STUB): " + _Type.ToString()); + default: + throw new System.NotSupportedException("ImportToAyaNova: NOT SUPPORTED (STUB): " + _Type.ToString()); + } } //display errors if any @@ -172,20 +160,14 @@ namespace AyaNovaQBI } - CopyableMessageBox cb = new CopyableMessageBox(sb.ToString()); cb.ShowDialog(); - - } } catch (Exception ex) { w.Visible = false; - Util.CrackDisplayAndIntegrationLogException(ex, "QBI:Map:ImportToAyaNova");//case 3717 - //CopyableMessageBox cb = new CopyableMessageBox("ImportToAyaNova error: \r\n" + Util.CrackException(ex)); - //cb.ShowDialog(); - + await util.CrackDisplayAndIntegrationLogException(ex, "QBI:Map:ImportToAyaNova"); } finally { @@ -208,62 +190,71 @@ namespace AyaNovaQBI w.Ops = "Importing from AyaNova..."; try { - - switch (_Type) + bool firstPass = true; + foreach (DataGridViewRow r in gridAya.SelectedRows) { - case AyaType.Customer: - foreach (object o in moveData.Rows) - { - w.Step = ((AyaNameID)o).Name; - - util.ImportAyaClient(((AyaNameID)o).ID, alErrors); - } - break; - case AyaType.Vendor: - foreach (object o in moveData.Rows) - { - w.Step = ((AyaNameID)o).Name; - - Util.ImportAyaVendor(((AyaNameID)o).ID, alErrors); - } - break; - case AyaType.Rate: - { - SetQBImportServiceRateAccounts s = new SetQBImportServiceRateAccounts(); - if (s.ShowDialog() != DialogResult.OK) + string AyaName = r.Cells[0].Value.ToString(); + long AyaId = (long)r.Cells[1].Value; + w.Step = AyaName; + switch (_Type) + { + case AyaType.Customer: + await util.ImportAyaCustomer(AyaId, alErrors); + break; + case AyaType.Vendor: + await util.ImportAyaVendor(AyaId, alErrors); + break; + case AyaType.ServiceRate: { - s.Dispose(); - return; + if (firstPass) + { + SetQBImportServiceRateAccounts s = new SetQBImportServiceRateAccounts(); + if (s.ShowDialog() != DialogResult.OK) + { + s.Dispose(); + return; + } + s.Dispose(); + firstPass = false; + } + await util.ImportAyaServiceRate(AyaId, alErrors); } - s.Dispose(); - RatePickList rpl = RatePickList.GetList(false); - foreach (object o in moveData.Rows) + break; + case AyaType.TravelRate: { - w.Step = ((AyaNameID)o).Name; - - Util.ImportAyaRate(((AyaNameID)o).ID, rpl, alErrors); + if (firstPass) + { + SetQBImportServiceRateAccounts s = new SetQBImportServiceRateAccounts(); + if (s.ShowDialog() != DialogResult.OK) + { + s.Dispose(); + return; + } + s.Dispose(); + firstPass = false; + } + await util.ImportAyaTravelRate(AyaId, alErrors); } - } - break; - case AyaType.Part: - { - SetQBImportInventoryAccounts s = new SetQBImportInventoryAccounts(); - if (s.ShowDialog() != DialogResult.OK) + break; + case AyaType.Part: { - s.Dispose(); - return; + if (firstPass) + { + SetQBImportInventoryAccounts s = new SetQBImportInventoryAccounts(); + if (s.ShowDialog() != DialogResult.OK) + { + s.Dispose(); + return; + } + s.Dispose(); + firstPass = false; + } + await util.ImportAyaPart(AyaId, alErrors); } - s.Dispose(); - foreach (object o in moveData.Rows) - { - w.Step = ((AyaNameID)o).Name; - - Util.ImportAyaPart(((AyaNameID)o).ID, alErrors); - } - } - break; - default: - throw new System.NotSupportedException("ImportToQuickBooks: NOT SUPPORTED (STUB): " + _Type.ToString()); + break; + default: + throw new System.NotSupportedException("ImportToQuickBooks: NOT SUPPORTED (STUB): " + _Type.ToString()); + } } //display errors if any @@ -289,10 +280,7 @@ namespace AyaNovaQBI catch (Exception ex) { - //CopyableMessageBox cb=new CopyableMessageBox("ImportToQuickBooks error: " + ex.Message); - //cb.ShowDialog(); - //cb.Dispose(); - Util.CrackDisplayAndIntegrationLogException(ex, "QBI:Map:ImportToQuickBooks");//case 3717 + await util.CrackDisplayAndIntegrationLogException(ex, "QBI:Map:ImportToQuickBooks"); } finally { diff --git a/AyaNovaQBI/SetQBImportServiceRateAccounts.Designer.cs b/AyaNovaQBI/SetQBImportServiceRateAccounts.Designer.cs new file mode 100644 index 0000000..97b5c84 --- /dev/null +++ b/AyaNovaQBI/SetQBImportServiceRateAccounts.Designer.cs @@ -0,0 +1,130 @@ +namespace AyaNovaQBI +{ + partial class SetQBImportServiceRateAccounts + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnOK = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.cbIncomeAccount = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // btnOK + // + this.btnOK.Location = new System.Drawing.Point(357, 176); + this.btnOK.Name = "btnOK"; + this.btnOK.Size = new System.Drawing.Size(75, 23); + this.btnOK.TabIndex = 16; + this.btnOK.Text = "OK"; + this.btnOK.UseVisualStyleBackColor = true; + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(19, 176); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 15; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(16, 16); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(419, 32); + this.label1.TabIndex = 17; + this.label1.Text = "Default account"; + // + // label3 + // + this.label3.Dock = System.Windows.Forms.DockStyle.Top; + this.label3.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(16, 48); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(419, 30); + this.label3.TabIndex = 19; + this.label3.Text = "Sales information:"; + // + // cbIncomeAccount + // + this.cbIncomeAccount.Dock = System.Windows.Forms.DockStyle.Top; + this.cbIncomeAccount.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbIncomeAccount.FormattingEnabled = true; + this.cbIncomeAccount.Location = new System.Drawing.Point(16, 96); + this.cbIncomeAccount.Name = "cbIncomeAccount"; + this.cbIncomeAccount.Size = new System.Drawing.Size(419, 21); + this.cbIncomeAccount.TabIndex = 21; + // + // label2 + // + this.label2.Dock = System.Windows.Forms.DockStyle.Top; + this.label2.Location = new System.Drawing.Point(16, 78); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(419, 18); + this.label2.TabIndex = 20; + this.label2.Text = "Income account"; + // + // SetQBImportServiceRateAccounts + // + this.AcceptButton = this.btnOK; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(451, 218); + this.ControlBox = false; + this.Controls.Add(this.cbIncomeAccount); + this.Controls.Add(this.label2); + this.Controls.Add(this.label3); + this.Controls.Add(this.label1); + this.Controls.Add(this.btnOK); + this.Controls.Add(this.btnCancel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "SetQBImportServiceRateAccounts"; + this.Padding = new System.Windows.Forms.Padding(16); + this.ShowInTaskbar = false; + this.Text = "Import Rate"; + this.Load += new System.EventHandler(this.SetQBImportServiceRateAccounts_Load); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button btnOK; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.ComboBox cbIncomeAccount; + private System.Windows.Forms.Label label2; + } +} \ No newline at end of file diff --git a/AyaNovaQBI/SetQBImportServiceRateAccounts.cs b/AyaNovaQBI/SetQBImportServiceRateAccounts.cs new file mode 100644 index 0000000..ba5a413 --- /dev/null +++ b/AyaNovaQBI/SetQBImportServiceRateAccounts.cs @@ -0,0 +1,32 @@ +using System; +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 +{ + public partial class SetQBImportServiceRateAccounts : Form + { + public SetQBImportServiceRateAccounts() + { + InitializeComponent(); + } + + private void SetQBImportServiceRateAccounts_Load(object sender, EventArgs e) + { + btnCancel.Text = util.AyaTranslations["Cancel"]; + btnOK.Text = util.AyaTranslations["OK"]; + + cbIncomeAccount.DisplayMember = "FullName"; + cbIncomeAccount.ValueMember = "ID"; + cbIncomeAccount.DataSource = util.QBAccounts; + if (!string.IsNullOrEmpty(util.QDat.QBServiceIncomeAccountRef)) + cbIncomeAccount.SelectedValue = util.QDat.QBServiceIncomeAccountRef; + } + } +} diff --git a/AyaNovaQBI/SetQBImportServiceRateAccounts.resx b/AyaNovaQBI/SetQBImportServiceRateAccounts.resx new file mode 100644 index 0000000..29dcb1b --- /dev/null +++ b/AyaNovaQBI/SetQBImportServiceRateAccounts.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file