Created a container object to house messages, operation status and the rows added for the methods that add new items and update existing items in the database.
This commit is contained in:
@@ -1838,23 +1838,22 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
//Run the row parsing engine on all the APC tables.
|
||||
//Create the cleaned table objects that will be sent to the database.
|
||||
//var trimmed = new DataTable();
|
||||
//var update = new DataTable();
|
||||
//var trimmedProjectionsTable = ConstructCleanedProjectionsTable(dateId, out trimmed, out update);
|
||||
//var trimmedInventoryTable = ConstructCleanedInventoryTable(dateId);
|
||||
//var trimmedActualSalesTable = ConstructCleanedActualSalesTable(dateId);
|
||||
var trimmedTable = new DataTable();
|
||||
var updateTable = new DataTable();
|
||||
//var operationStatus = ConstructCleanedProjectionsTable(dateId, out trimmed, out update);
|
||||
//operationStatus = ConstructCleanedInventoryTable(dateId);
|
||||
//operationgStatus = ConstructCleanedActualSalesTable(dateId);
|
||||
//Create the transaction scope.
|
||||
//By default the TransactionScopeOption is "Required", so if an ambient transaction does not
|
||||
//exist then the new transaction that is made (in the first method) becomes the root transaction.
|
||||
//Transaction Scope: https://msdn.microsoft.com/en-us/library/ms172152.aspx
|
||||
//var projectionsAdditions = dbW.InsertIntoSalesTable(trimmedProjectionsTable, dbT.DatabaseConnectionString);
|
||||
//var projectionsAdditions = dbW.InsertIntoSalesTable(trimmedTable, dbT.DatabaseConnectionString);
|
||||
//foreach (var rowIndex in projectionsAdditions)
|
||||
//{
|
||||
// projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.Id].Value = rowIndex.Value;
|
||||
// projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false;
|
||||
// projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsInDatabase].Value = true;
|
||||
//}
|
||||
//dbW.UpdateSalesTable(trimmedProjectionsTable.ElementAt(1), dbT.DatabaseConnectionString);
|
||||
}
|
||||
|
||||
#region APC Table Trimming
|
||||
@@ -2125,6 +2124,18 @@ namespace AdvertsingProfitControl
|
||||
//LogConsole.WriteToLog(FrmLogConsole.Level.Verbose, "Row Position: " + row.Index + (_adSpecialIndex != -1 && row.Index > _adSpecialIndex ? 1 : 0) + " Date ID: " + dateId);
|
||||
}
|
||||
|
||||
if (insertNewTable.Rows.Count == 0 && updateExistingTable.Rows.Count == 0)
|
||||
{
|
||||
return TrimmingOperationResult.NoChangesRequired;
|
||||
}
|
||||
if (insertNewTable.Rows.Count > 0 && updateExistingTable.Rows.Count == 0)
|
||||
{
|
||||
return TrimmingOperationResult.CreatedNewInsertionTable;
|
||||
}
|
||||
if (insertNewTable.Rows.Count == 0 && updateExistingTable.Rows.Count > 0)
|
||||
{
|
||||
return TrimmingOperationResult.CreatedUpdateTable;
|
||||
}
|
||||
return TrimmingOperationResult.CreatedNewInsertionAndUpdateTables;
|
||||
}
|
||||
|
||||
@@ -2383,6 +2394,18 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
}
|
||||
|
||||
if (insertNewTable.Rows.Count == 0 && updateExistingTable.Rows.Count == 0)
|
||||
{
|
||||
return TrimmingOperationResult.NoChangesRequired;
|
||||
}
|
||||
if (insertNewTable.Rows.Count > 0 && updateExistingTable.Rows.Count == 0)
|
||||
{
|
||||
return TrimmingOperationResult.CreatedNewInsertionTable;
|
||||
}
|
||||
if (insertNewTable.Rows.Count == 0 && updateExistingTable.Rows.Count > 0)
|
||||
{
|
||||
return TrimmingOperationResult.CreatedUpdateTable;
|
||||
}
|
||||
return TrimmingOperationResult.CreatedNewInsertionAndUpdateTables;
|
||||
}
|
||||
|
||||
@@ -2644,6 +2667,19 @@ namespace AdvertsingProfitControl
|
||||
updateExistingTable.Rows.Add(newRow);
|
||||
}
|
||||
}
|
||||
|
||||
if (insertNewTable.Rows.Count == 0 && updateExistingTable.Rows.Count == 0)
|
||||
{
|
||||
return TrimmingOperationResult.NoChangesRequired;
|
||||
}
|
||||
if (insertNewTable.Rows.Count > 0 && updateExistingTable.Rows.Count == 0)
|
||||
{
|
||||
return TrimmingOperationResult.CreatedNewInsertionTable;
|
||||
}
|
||||
if (insertNewTable.Rows.Count == 0 && updateExistingTable.Rows.Count > 0)
|
||||
{
|
||||
return TrimmingOperationResult.CreatedUpdateTable;
|
||||
}
|
||||
return TrimmingOperationResult.CreatedNewInsertionAndUpdateTables;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user