diff --git a/AyaNovaQBI/AyaNovaQBI.csproj b/AyaNovaQBI/AyaNovaQBI.csproj
index 412a0b7..d2e2fc6 100644
--- a/AyaNovaQBI/AyaNovaQBI.csproj
+++ b/AyaNovaQBI/AyaNovaQBI.csproj
@@ -111,6 +111,12 @@
Map.cs
+
+ Form
+
+
+ MapSelectAyaNovaItem.cs
+
Form
@@ -211,6 +217,9 @@
Map.cs
+
+ MapSelectAyaNovaItem.cs
+
MapSelectQBItem.cs
diff --git a/AyaNovaQBI/Map.cs b/AyaNovaQBI/Map.cs
index 2a624c2..a114468 100644
--- a/AyaNovaQBI/Map.cs
+++ b/AyaNovaQBI/Map.cs
@@ -77,6 +77,7 @@ namespace AyaNovaQBI
if (IsAyaGrid)
{
+ #region AyaGrid
//we have selection now get qb item
MapSelectQBItem s = new MapSelectQBItem();
@@ -165,17 +166,60 @@ namespace AyaNovaQBI
}
}
- if (SaveIntegration)
- {
- await util.SaveIntegrationObject();
- Initialize();
- }
- //#################################
+
+ #endregion AyaGrid
}
else
{
+ #region QB GRID
+ //################
+ //QB GRID
+ //
+ if (gridQB.SelectedRows.Count > 1)
+ {
+ MessageBox.Show("You can not link more than one QuickBooks\r\n" +
+ "object to a single AyaNova object", "Not supported", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ return;
+ }
+
+ var QBItemName = gridQB.SelectedRows[0].Cells[0].Value.ToString();
+ var QBItemId = gridQB.SelectedRows[0].Cells[1].Value.ToString();
+
+ MapSelectAyaNovaItem s = new MapSelectAyaNovaItem();
+ s.Items = _aya;
+ if (s.ShowDialog() == DialogResult.Cancel)
+ return;
+
+ var AyaId = s.SelectedItemId;
+ s.Dispose();
+
+ //This way is a one to one mapping so only one iteration and two potential things to do, add or change link
+ //Is it already present?
+ IntegrationItem m = util.QBIntegration.Items.FirstOrDefault(z => z.ObjectId == AyaId && z.AType == _Type);
+ if (m != null)
+ {
+ m.IntegrationItemId = QBItemId;
+ m.IntegrationItemName = QBItemName;
+ m.LastSync = System.DateTime.Now;
+ SaveIntegration = true;
+ }
+ else
+ {
+ //not already present, so add it
+ m = new IntegrationItem { AType = _Type, IntegrationItemName = QBItemName, IntegrationItemId = QBItemId, LastSync = System.DateTime.Now, ObjectId = AyaId };
+ util.QBIntegration.Items.Add(m);
+ SaveIntegration = true;
+ }
+
+ #endregion qb grid
+ }
+
+ if (SaveIntegration)
+ {
+ await util.SaveIntegrationObject();
+ Initialize();
}
}
@@ -548,30 +592,5 @@ namespace AyaNovaQBI
-
- /*
- * Simplified, no drag and drop just pick and choose with clicks
- * A menu to select the ayanova object type which then populates the ayanova items grid of that type showing:
- A single grid showing all ayanova items of the selected type with their name in the first column and a second column showing what they are mapped to in qb item name, easy peasy, no drag and drop
- User can select one or more items
- when one or more are selected
- a menu item appears saying "MAP Selected items" when they select they can pick a qb item of the type they want and accept in a popup dialog which also shows how many ayanova items are selected
- a menyu tiem apepars saying UNMAP selected items when they select it it removes the mapping after confirmation dialog from all selected items
-
- //public static List GetInvoiceableItems()
- //{
- // var random = new Random();
- // var l = new List();
- // for (int i = 1; i < random.Next(25, 100); i++)
- // l.Add(new InvoiceableItem { Customer = $"Customer {random.Next(1, 5)}", Linked = random.Next(2) == 1, Project = $"project {i}", ServiceDate = DateTime.Now.ToString("g"), ServiceNumber = (40 + i).ToString(), Status = $"Waiting to be invoiced", StatusColor = "FF00FFAA", WorkorderId = 4 });
-
- // return l.OrderBy(x => x.Customer)
- // .ThenBy(x => x.ServiceNumber)
- // .ThenBy(x => x.ServiceDate)
- // .ToList();
-
- //}
-
- */
}
}
diff --git a/AyaNovaQBI/MapSelectAyaNovaItem.Designer.cs b/AyaNovaQBI/MapSelectAyaNovaItem.Designer.cs
new file mode 100644
index 0000000..10befc0
--- /dev/null
+++ b/AyaNovaQBI/MapSelectAyaNovaItem.Designer.cs
@@ -0,0 +1,106 @@
+namespace AyaNovaQBI
+{
+ partial class MapSelectAyaNovaItem
+ {
+ ///
+ /// 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.cbItems = new System.Windows.Forms.ComboBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // btnOK
+ //
+ this.btnOK.Location = new System.Drawing.Point(656, 108);
+ this.btnOK.Name = "btnOK";
+ this.btnOK.Size = new System.Drawing.Size(75, 23);
+ this.btnOK.TabIndex = 19;
+ this.btnOK.Text = "OK";
+ this.btnOK.UseVisualStyleBackColor = true;
+ this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
+ //
+ // btnCancel
+ //
+ this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.btnCancel.Location = new System.Drawing.Point(19, 107);
+ this.btnCancel.Name = "btnCancel";
+ this.btnCancel.Size = new System.Drawing.Size(75, 23);
+ this.btnCancel.TabIndex = 18;
+ this.btnCancel.Text = "Cancel";
+ this.btnCancel.UseVisualStyleBackColor = true;
+ this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
+ //
+ // cbItems
+ //
+ this.cbItems.Dock = System.Windows.Forms.DockStyle.Top;
+ this.cbItems.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.cbItems.FormattingEnabled = true;
+ this.cbItems.Location = new System.Drawing.Point(16, 29);
+ this.cbItems.Name = "cbItems";
+ this.cbItems.Size = new System.Drawing.Size(715, 21);
+ this.cbItems.TabIndex = 17;
+ //
+ // label1
+ //
+ this.label1.Dock = System.Windows.Forms.DockStyle.Top;
+ this.label1.Location = new System.Drawing.Point(16, 16);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(715, 13);
+ this.label1.TabIndex = 16;
+ this.label1.Text = "Link selected QuickBooks item to:";
+ //
+ // MapSelectAyaNovaItem
+ //
+ 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(747, 150);
+ this.ControlBox = false;
+ this.Controls.Add(this.btnOK);
+ this.Controls.Add(this.btnCancel);
+ this.Controls.Add(this.cbItems);
+ this.Controls.Add(this.label1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
+ this.Name = "MapSelectAyaNovaItem";
+ this.Padding = new System.Windows.Forms.Padding(16);
+ this.ShowIcon = false;
+ this.ShowInTaskbar = false;
+ this.Text = "AyaNova items";
+ this.Load += new System.EventHandler(this.MapSelectAyaNovaItem_Load);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+ private System.Windows.Forms.Button btnOK;
+ private System.Windows.Forms.Button btnCancel;
+ private System.Windows.Forms.ComboBox cbItems;
+ private System.Windows.Forms.Label label1;
+ }
+}
\ No newline at end of file
diff --git a/AyaNovaQBI/MapSelectAyaNovaItem.cs b/AyaNovaQBI/MapSelectAyaNovaItem.cs
new file mode 100644
index 0000000..80cabb4
--- /dev/null
+++ b/AyaNovaQBI/MapSelectAyaNovaItem.cs
@@ -0,0 +1,63 @@
+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 MapSelectAyaNovaItem : Form
+ {
+ public MapSelectAyaNovaItem()
+ {
+ InitializeComponent();
+ }
+
+ public string SelectedItemName
+ {
+ get
+ {
+ return ((DataRowView)cbItems.SelectedItem).Row[0].ToString();
+ }
+ }
+
+ public long SelectedItemId
+ {
+ get
+ {
+ return (long)((DataRowView)cbItems.SelectedItem).Row[1];
+ }
+ }
+
+ public DataTable Items { get; set; }
+
+ private void MapSelectAyaNovaItem_Load(object sender, EventArgs e)
+ {
+
+ cbItems.DataSource = Items;
+
+ cbItems.DisplayMember = "name";
+ cbItems.ValueMember = "id";
+ btnCancel.Text = util.AyaTranslations["Cancel"];
+ btnOK.Text = util.AyaTranslations["OK"];
+ }
+
+ private void btnCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+
+ private void btnOK_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+
+
+ }
+}
diff --git a/AyaNovaQBI/MapSelectAyaNovaItem.resx b/AyaNovaQBI/MapSelectAyaNovaItem.resx
new file mode 100644
index 0000000..29dcb1b
--- /dev/null
+++ b/AyaNovaQBI/MapSelectAyaNovaItem.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
diff --git a/AyaNovaQBI/MapSelectQBItem.Designer.cs b/AyaNovaQBI/MapSelectQBItem.Designer.cs
index 21c6140..ada936b 100644
--- a/AyaNovaQBI/MapSelectQBItem.Designer.cs
+++ b/AyaNovaQBI/MapSelectQBItem.Designer.cs
@@ -88,10 +88,12 @@
//
// MapSelectQBItem
//
+ 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(747, 150);
+ this.ControlBox = false;
this.Controls.Add(this.ckNothing);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.btnCancel);
@@ -100,6 +102,7 @@
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "MapSelectQBItem";
this.Padding = new System.Windows.Forms.Padding(16);
+ this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "QB Items";
this.Load += new System.EventHandler(this.MapSelectQBItem_Load);