diff --git a/AyaNovaQBI/AyaNovaQBI.csproj b/AyaNovaQBI/AyaNovaQBI.csproj index abca2d7..412a0b7 100644 --- a/AyaNovaQBI/AyaNovaQBI.csproj +++ b/AyaNovaQBI/AyaNovaQBI.csproj @@ -92,6 +92,12 @@ CopyableMessageBox.cs + + Form + + + LinkAyaObjectToQBConfirm.cs + Form @@ -196,6 +202,9 @@ CopyableMessageBox.cs + + LinkAyaObjectToQBConfirm.cs + MainForm.cs diff --git a/AyaNovaQBI/LinkAyaObjectToQBConfirm.Designer.cs b/AyaNovaQBI/LinkAyaObjectToQBConfirm.Designer.cs new file mode 100644 index 0000000..a269818 --- /dev/null +++ b/AyaNovaQBI/LinkAyaObjectToQBConfirm.Designer.cs @@ -0,0 +1,126 @@ +namespace AyaNovaQBI +{ + partial class LinkAyaObjectToQBConfirm + { + /// + /// 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.edAyaObjects = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.edQBItem = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // btnOK + // + this.btnOK.Location = new System.Drawing.Point(550, 368); + 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(12, 368); + 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; + // + // edAyaObjects + // + this.edAyaObjects.Enabled = false; + this.edAyaObjects.Location = new System.Drawing.Point(12, 33); + this.edAyaObjects.Multiline = true; + this.edAyaObjects.Name = "edAyaObjects"; + this.edAyaObjects.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.edAyaObjects.Size = new System.Drawing.Size(613, 224); + this.edAyaObjects.TabIndex = 17; + // + // label1 + // + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(613, 21); + this.label1.TabIndex = 18; + this.label1.Text = "Link the following AyaNova objects:"; + // + // label2 + // + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.Location = new System.Drawing.Point(15, 279); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(610, 21); + this.label2.TabIndex = 19; + this.label2.Text = "To QuickBooks object:"; + // + // edQBItem + // + this.edQBItem.Enabled = false; + this.edQBItem.Location = new System.Drawing.Point(12, 303); + this.edQBItem.Name = "edQBItem"; + this.edQBItem.Size = new System.Drawing.Size(610, 20); + this.edQBItem.TabIndex = 20; + // + // LinkAyaObjectToQBConfirm + // + 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(637, 403); + this.ControlBox = false; + this.Controls.Add(this.edQBItem); + this.Controls.Add(this.label2); + this.Controls.Add(this.edAyaObjects); + this.Controls.Add(this.btnOK); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.label1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "LinkAyaObjectToQBConfirm"; + this.Text = "Link AyaNova object(s)"; + this.Load += new System.EventHandler(this.LinkAyaObjectToQBConfirm_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button btnOK; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.TextBox edAyaObjects; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox edQBItem; + } +} \ No newline at end of file diff --git a/AyaNovaQBI/LinkAyaObjectToQBConfirm.cs b/AyaNovaQBI/LinkAyaObjectToQBConfirm.cs new file mode 100644 index 0000000..8b4e293 --- /dev/null +++ b/AyaNovaQBI/LinkAyaObjectToQBConfirm.cs @@ -0,0 +1,22 @@ +using System; +using System.Windows.Forms; + +namespace AyaNovaQBI +{ + public partial class LinkAyaObjectToQBConfirm : Form + { + public LinkAyaObjectToQBConfirm() + { + InitializeComponent(); + } + + public string AyaItems { set { this.edAyaObjects.Text = value; } } + public string QBItem { set { this.edQBItem.Text = value; } } + + private void LinkAyaObjectToQBConfirm_Load(object sender, EventArgs e) + { + btnCancel.Text = util.AyaTranslations["Cancel"]; + btnOK.Text = util.AyaTranslations["OK"]; + } + } +} diff --git a/AyaNovaQBI/LinkAyaObjectToQBConfirm.resx b/AyaNovaQBI/LinkAyaObjectToQBConfirm.resx new file mode 100644 index 0000000..29dcb1b --- /dev/null +++ b/AyaNovaQBI/LinkAyaObjectToQBConfirm.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/Map.cs b/AyaNovaQBI/Map.cs index 8f14047..2cc0e3e 100644 --- a/AyaNovaQBI/Map.cs +++ b/AyaNovaQBI/Map.cs @@ -61,30 +61,6 @@ namespace AyaNovaQBI - private void mapSelectedItemsToolStripMenuItem_Click(object sender, EventArgs e) - { - if (gridAya.SelectedRows.Count == 0) return; - - //we have selection now get qb item - MapSelectQBItem s = new MapSelectQBItem(); - - s.QBItems = _qb; - string SelectedQBItem = string.Empty; - if (s.ShowDialog() == DialogResult.Cancel) - return; - else - SelectedQBItem = s.SelectedQBItem; - s.Dispose(); - var selectedAyaNovaIndexes = new List(); - foreach (DataGridViewRow r in gridAya.SelectedRows) - { - selectedAyaNovaIndexes.Add((long)r.Cells[0].Value); - } - - //todo: here we need to update the linking (and save right away or wait??) - var v = SelectedQBItem; - - } private void importSelectedItemsToolStripMenuItem_Click(object sender, EventArgs e) { @@ -93,7 +69,113 @@ namespace AyaNovaQBI private void linkSelectedItemsToolStripMenuItem_Click(object sender, EventArgs e) { + bool IsAyaGrid = false; + if (gridAya.SelectedRows.Count == 0 && gridQB.SelectedRows.Count == 0) return; + IsAyaGrid = gridAya.SelectedRows.Count > 0; + + if (IsAyaGrid) + { + //we have selection now get qb item + MapSelectQBItem s = new MapSelectQBItem(); + + s.QBItems = _qb; + string SelectedQBItem = string.Empty; + if (s.ShowDialog() == DialogResult.Cancel) + return; + else + SelectedQBItem = s.SelectedQBItem.ToString(); + s.Dispose(); + var selectedAyaNovaIds = new List(); + foreach (DataGridViewRow r in gridAya.SelectedRows) + { + selectedAyaNovaIds.Add((long)r.Cells[0].Value); + } + + //todo: here we need to update the linking (and save right away or wait??) + //################################# + //LINKING + + + //LinkAyaObjectToQBConfirm d = new LinkAyaObjectToQBConfirm(); + //d.ToLabel = "To QuickBooks object:\r\n" + rowdrop.Cells["Name"].Value.ToString(); + //DataTable dtTemp = new DataTable(); + //dtTemp.Columns.Add("Name", typeof(string)); + //foreach (object o in moveData.Rows) + //{ + // dtTemp.Rows.Add(new object[] { ((AyaNameID)o).Name }); + //} + //d.DTRows = dtTemp; + //if (d.ShowDialog() != DialogResult.OK) return; + + //// + //// QBNameID q=(QBNameID)moveData.Rows[0]; + //// if(MessageBox.Show( + //// "Link the AyaNova object(s): " + q.Name + "\r\n" + + //// "to the QuickBooks object: " + + "\r\n\r\n" + + //// "Are you sure?","Link QuickBooks object",MessageBoxButtons.YesNo,MessageBoxIcon.Question) + //// ==DialogResult.No) return; + + ////ok, link away... + //foreach (object o in moveData.Rows) + //{ + // //qb listid + // string dropID = rowdrop.Cells["ID"].Value.ToString(); + // string dropName = rowdrop.Cells["Name"].Value.ToString(); + // IntegrationMap m = null; + // //Is AyaNova object already mapped? + // if (Util.QBI.Maps.Contains(((AyaNameID)o).ID)) + // { + // //Get the mapping + // m = Util.QBI.Maps[((AyaNameID)o).ID]; + + // //Is it already linked to the selected qb object? + + // //Yes so do nothing and continue on to the next object + // if (m.ForeignID == dropID) + // continue; + // else + // { + + // //No, AyaNova object was mapped elsewhere, prompt user if this is ok + // if (MessageBox.Show( + // "AyaNova object: " + ((AyaNameID)o).Name + "\r\n" + + // "Is already linked to QuickBooks object: " + m.Name + "\r\n" + + // "Do you really want to change the link to the QuickBooks object: " + dropName + "\r\n", + // "Change link?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) + // == DialogResult.No) continue; + + // } + + // //If we're here it's because the object is already mapped + // //but the users has signified they want to change the map to another object so... + // m.ForeignID = dropID; + // m.Name = rowdrop.Cells["Name"].Value.ToString(); + // m.LastSync = System.DateTime.Now; + + // } + // else + // { + // //not already present, so add it, easy peasy... + // m = Util.QBI.Maps.Add(Util.QBI); + // m.RootObjectID = ((AyaNameID)o).ID; + // m.RootObjectType = _Type; + // m.ForeignID = dropID; + // m.Name = dropName; + // m.LastSync = System.DateTime.Now; + // } + //} + + + //Util.QBI = (Integration)Util.QBI.Save(); + Initialize(); + + //################################# + } + else + { + + } } @@ -366,7 +448,7 @@ namespace AyaNovaQBI } } - + @@ -404,7 +486,7 @@ namespace AyaNovaQBI _Type = AyaType.Part; this.Text = "Map / Import - Parts"; Initialize(); - if (!util.QBIntegration.Items.Any(z=>z.AType==AyaType.Vendor)) + if (!util.QBIntegration.Items.Any(z => z.AType == AyaType.Vendor)) { MessageBox.Show( "If you plan on importing QuickBooks items into AyaNova parts\r\n" + @@ -506,7 +588,7 @@ namespace AyaNovaQBI } - + private void gridQB_CellClick(object sender, DataGridViewCellEventArgs e) { @@ -516,7 +598,7 @@ namespace AyaNovaQBI private void gridQB_SelectionChanged(object sender, EventArgs e) { var hasSelection = gridQB.SelectedRows.Count > 0; - + if (hasSelection) gridAya.ClearSelection(); } @@ -524,13 +606,13 @@ namespace AyaNovaQBI private void gridAya_SelectionChanged(object sender, EventArgs e) { var hasSelection = gridAya.SelectedRows.Count > 0; - + if (hasSelection) - gridQB.ClearSelection(); + gridQB.ClearSelection(); } - - + + diff --git a/AyaNovaQBI/MapSelectQBItem.cs b/AyaNovaQBI/MapSelectQBItem.cs index 7dee588..bf764a4 100644 --- a/AyaNovaQBI/MapSelectQBItem.cs +++ b/AyaNovaQBI/MapSelectQBItem.cs @@ -17,12 +17,13 @@ namespace AyaNovaQBI InitializeComponent(); } public string SelectedQBItem => cbQBItems.SelectedValue.ToString(); + // public string SelectedQBItemName => cbQBItems.selected.ToString(); public DataTable QBItems { get; set; } private void MapSelectQBItem_Load(object sender, EventArgs e) { cbQBItems.DataSource = QBItems; cbQBItems.DisplayMember = "FullName"; - cbQBItems.ValueMember = "ID"; + //cbQBItems.ValueMember = "ID"; btnCancel.Text = util.AyaTranslations["Cancel"]; btnOK.Text = util.AyaTranslations["OK"]; }