This commit is contained in:
@@ -67,7 +67,7 @@ namespace AyaNovaQBI
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void linkSelectedItemsToolStripMenuItem_Click(object sender, EventArgs e)
|
private async void linkSelectedItemsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
bool IsAyaGrid = false;
|
bool IsAyaGrid = false;
|
||||||
if (gridAya.SelectedRows.Count == 0 && gridQB.SelectedRows.Count == 0) return;
|
if (gridAya.SelectedRows.Count == 0 && gridQB.SelectedRows.Count == 0) return;
|
||||||
@@ -108,57 +108,52 @@ namespace AyaNovaQBI
|
|||||||
|
|
||||||
|
|
||||||
////ok, link away...
|
////ok, link away...
|
||||||
//foreach (object o in moveData.Rows)
|
foreach (DataGridViewRow r in gridAya.SelectedRows)
|
||||||
//{
|
{
|
||||||
// //qb listid
|
string AyaName = r.Cells[0].Value.ToString();
|
||||||
// string dropID = rowdrop.Cells["ID"].Value.ToString();
|
long AyaId = (long)r.Cells[1].Value;
|
||||||
// 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();
|
|
||||||
|
//Is AyaNova object already mapped?
|
||||||
|
IntegrationItem m = util.QBIntegration.Items.FirstOrDefault(z => z.Id == AyaId && z.AType == _Type);
|
||||||
|
if (m != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
//Is it already linked to the selected qb object?
|
||||||
|
|
||||||
|
//Yes so do nothing and continue on to the next object
|
||||||
|
if (m.IntegrationItemId == QBItemId)
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
//No, AyaNova object was mapped elsewhere, prompt user if this is ok
|
||||||
|
if (MessageBox.Show(
|
||||||
|
$"AyaNova object: {AyaName}\r\nIs already linked to QuickBooks object: {m.IntegrationItemName}\r\nDo you really want to change the link to the QuickBooks object: {QBItemName}\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.IntegrationItemId = QBItemId;
|
||||||
|
m.IntegrationItemName = QBItemName;
|
||||||
|
m.LastSync = System.DateTime.Now;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//not already present, so add it, easy peasy...
|
||||||
|
m = new IntegrationItem { AType = _Type, IntegrationItemName = QBItemName, IntegrationItemId = QBItemId, LastSync = System.DateTime.Now, ObjectId = AyaId };
|
||||||
|
util.QBIntegration.Items.Add(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
await util.SaveIntegrationObject();
|
||||||
Initialize();
|
Initialize();
|
||||||
|
|
||||||
//#################################
|
//#################################
|
||||||
|
|||||||
@@ -1317,7 +1317,19 @@ namespace AyaNovaQBI
|
|||||||
}
|
}
|
||||||
#endregion validate user settings
|
#endregion validate user settings
|
||||||
|
|
||||||
|
#region Integration object persistance
|
||||||
|
public static async Task SaveIntegrationObject()
|
||||||
|
{
|
||||||
|
if (QDat.IsDirty)
|
||||||
|
{
|
||||||
|
await IntegrationLog("ValidateSettings: QBI settings modified by user, saving now");
|
||||||
|
QBIntegration.IntegrationData = Newtonsoft.Json.JsonConvert.SerializeObject(QDat);
|
||||||
|
}
|
||||||
|
ApiResponse r = await PutAsync("integration", Newtonsoft.Json.JsonConvert.SerializeObject(QBIntegration));
|
||||||
|
QBIntegration.Concurrency = r.ObjectResponse["data"]["concurrency"].Value<uint>();
|
||||||
|
QDat.IsDirty = false;
|
||||||
|
}
|
||||||
|
#endregion integration object persistance
|
||||||
|
|
||||||
#region PFC QB side
|
#region PFC QB side
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user