This commit is contained in:
2022-07-03 21:05:40 +00:00
parent 604a12bb1b
commit 0a54013ee4
3 changed files with 65 additions and 13 deletions

View File

@@ -73,6 +73,7 @@ namespace AyaNovaQBI
if (gridAya.SelectedRows.Count == 0 && gridQB.SelectedRows.Count == 0) return; if (gridAya.SelectedRows.Count == 0 && gridQB.SelectedRows.Count == 0) return;
IsAyaGrid = gridAya.SelectedRows.Count > 0; IsAyaGrid = gridAya.SelectedRows.Count > 0;
bool SaveIntegration = false;
if (IsAyaGrid) if (IsAyaGrid)
{ {
@@ -119,8 +120,6 @@ namespace AyaNovaQBI
IntegrationItem m = util.QBIntegration.Items.FirstOrDefault(z => z.Id == AyaId && z.AType == _Type); IntegrationItem m = util.QBIntegration.Items.FirstOrDefault(z => z.Id == AyaId && z.AType == _Type);
if (m != null) if (m != null)
{ {
//Is it already linked to the selected qb object? //Is it already linked to the selected qb object?
//Yes so do nothing and continue on to the next object //Yes so do nothing and continue on to the next object
@@ -139,22 +138,38 @@ namespace AyaNovaQBI
//If we're here it's because the object is already mapped //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... //but the users has signified they want to change the map to another object so...
if (!string.IsNullOrEmpty(QBItemId))//confirm not a removal
{
m.IntegrationItemId = QBItemId; m.IntegrationItemId = QBItemId;
m.IntegrationItemName = QBItemName; m.IntegrationItemName = QBItemName;
m.LastSync = System.DateTime.Now; m.LastSync = System.DateTime.Now;
SaveIntegration = true;
}
else
{
//user is removing mapping so remove the integrationitem entirely from the collection
util.QBIntegration.Items.Remove(m);
SaveIntegration = true;
}
} }
else else
{
if (!string.IsNullOrEmpty(QBItemId))//confirm not a removal
{ {
//not already present, so add it, easy peasy... //not already present, so add it, easy peasy...
m = new IntegrationItem { AType = _Type, IntegrationItemName = QBItemName, IntegrationItemId = QBItemId, LastSync = System.DateTime.Now, ObjectId = AyaId }; m = new IntegrationItem { AType = _Type, IntegrationItemName = QBItemName, IntegrationItemId = QBItemId, LastSync = System.DateTime.Now, ObjectId = AyaId };
util.QBIntegration.Items.Add(m); util.QBIntegration.Items.Add(m);
SaveIntegration = true;
}
} }
} }
if (SaveIntegration)
{
await util.SaveIntegrationObject(); await util.SaveIntegrationObject();
Initialize(); Initialize();
}
//################################# //#################################
} }

View File

@@ -32,6 +32,7 @@
this.cbQBItems = new System.Windows.Forms.ComboBox(); this.cbQBItems = new System.Windows.Forms.ComboBox();
this.btnOK = new System.Windows.Forms.Button(); this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button();
this.ckNothing = new System.Windows.Forms.CheckBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// label1 // label1
@@ -74,12 +75,24 @@
this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
// //
// ckNothing
//
this.ckNothing.AutoSize = true;
this.ckNothing.Location = new System.Drawing.Point(16, 56);
this.ckNothing.Name = "ckNothing";
this.ckNothing.Size = new System.Drawing.Size(80, 17);
this.ckNothing.TabIndex = 15;
this.ckNothing.Text = "checkBox1";
this.ckNothing.UseVisualStyleBackColor = true;
this.ckNothing.CheckedChanged += new System.EventHandler(this.ckNothing_CheckedChanged);
//
// MapSelectQBItem // MapSelectQBItem
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel; this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(747, 150); this.ClientSize = new System.Drawing.Size(747, 150);
this.Controls.Add(this.ckNothing);
this.Controls.Add(this.btnOK); this.Controls.Add(this.btnOK);
this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnCancel);
this.Controls.Add(this.cbQBItems); this.Controls.Add(this.cbQBItems);
@@ -91,6 +104,7 @@
this.Text = "QB Items"; this.Text = "QB Items";
this.Load += new System.EventHandler(this.MapSelectQBItem_Load); this.Load += new System.EventHandler(this.MapSelectQBItem_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
@@ -100,5 +114,6 @@
private System.Windows.Forms.ComboBox cbQBItems; private System.Windows.Forms.ComboBox cbQBItems;
private System.Windows.Forms.Button btnOK; private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel; private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.CheckBox ckNothing;
} }
} }

View File

@@ -17,12 +17,29 @@ namespace AyaNovaQBI
InitializeComponent(); InitializeComponent();
} }
public ComboBox SelectCombo => cbQBItems; public ComboBox SelectCombo => cbQBItems;
public string SelectedQBItemName => ((DataRowView)cbQBItems.SelectedItem).Row[0].ToString(); public string SelectedQBItemName
public string SelectedQBItemId => ((DataRowView)cbQBItems.SelectedItem).Row[1].ToString(); {
get
{
if (ckNothing.Checked) return "<nothing / remove link>";
return ((DataRowView)cbQBItems.SelectedItem).Row[0].ToString();
}
}
public string SelectedQBItemId
{
get
{
if (ckNothing.Checked) return string.Empty;
return ((DataRowView)cbQBItems.SelectedItem).Row[1].ToString();
}
}
public DataTable QBItems { get; set; } public DataTable QBItems { get; set; }
private void MapSelectQBItem_Load(object sender, EventArgs e) private void MapSelectQBItem_Load(object sender, EventArgs e)
{ {
cbQBItems.DataSource = QBItems; cbQBItems.DataSource = QBItems;
cbQBItems.DisplayMember = "name"; cbQBItems.DisplayMember = "name";
cbQBItems.ValueMember = "id"; cbQBItems.ValueMember = "id";
btnCancel.Text = util.AyaTranslations["Cancel"]; btnCancel.Text = util.AyaTranslations["Cancel"];
@@ -40,5 +57,10 @@ namespace AyaNovaQBI
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
private void ckNothing_CheckedChanged(object sender, EventArgs e)
{
cbQBItems.Enabled = !ckNothing.Checked;
}
} }
} }