This commit is contained in:
@@ -953,7 +953,7 @@ namespace AyaNovaQBI
|
||||
|
||||
|
||||
|
||||
private void updateSelectedItemsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private async void updateSelectedItemsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
//Parts in v7 default update would do price / cost both ways in addition to the part description and other fields
|
||||
// however the user could go to map and select to *only* update the prices in AyaNova from QB but not the other fields
|
||||
@@ -997,7 +997,118 @@ namespace AyaNovaQBI
|
||||
if (s.ShowDialog() == DialogResult.Cancel)
|
||||
return;
|
||||
|
||||
MessageBox.Show("STUB: UPDATE SELECTED ITEMS");
|
||||
bool PricesOnly = s.PriceOnly;
|
||||
s.Dispose();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool SaveIntegration = false;
|
||||
|
||||
if (IsAyaGrid)
|
||||
{
|
||||
#region AyaGrid so UPDATE AYANOVA FROM QB
|
||||
switch (_Type)
|
||||
{
|
||||
|
||||
case AyaType.Customer:
|
||||
await util.PopulateQBClientCacheAsync();
|
||||
break;
|
||||
case AyaType.Vendor:
|
||||
await util.PopulateQBVendorCacheAsync();
|
||||
break;
|
||||
case AyaType.Part:
|
||||
await util.PopulateQBItemCacheAsync();
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (DataGridViewRow r in gridAya.SelectedRows)
|
||||
{
|
||||
string AyaName = r.Cells[0].Value.ToString();
|
||||
long AyaId = (long)r.Cells[1].Value;
|
||||
|
||||
//only linked items can be updated
|
||||
IntegrationItem m = util.QBIntegration.Items.FirstOrDefault(z => z.ObjectId == AyaId && z.AType == _Type);
|
||||
if (m != null)
|
||||
{
|
||||
switch (_Type)
|
||||
{
|
||||
|
||||
case AyaType.Customer:
|
||||
sType = "Customers";
|
||||
break;
|
||||
case AyaType.Vendor:
|
||||
sType = "Vendors";
|
||||
break;
|
||||
case AyaType.Part:
|
||||
await util.RefreshAyaNovaPartFromQB(AyaId, PricesOnly);
|
||||
break;
|
||||
}
|
||||
SaveIntegration = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}//eof
|
||||
}//eoc
|
||||
|
||||
Reference in New Issue
Block a user