diff --git a/AdvertsingProfitControl/NewAddRecord.cs b/AdvertsingProfitControl/NewAddRecord.cs
index 7c16aa2..dabe105 100644
--- a/AdvertsingProfitControl/NewAddRecord.cs
+++ b/AdvertsingProfitControl/NewAddRecord.cs
@@ -1687,7 +1687,6 @@ namespace AdvertsingProfitControl
//7:FK_AdItemID 8:RowAttribute 9:FK_AdSpecialGroupName (ID) 10:RowPosition (not index based)
//11:FK_DateID
trimmedUpdateProjectionsTable = new DataTable("Projections");
- DataTable[] trimmedTables = { trimmedNewProjectionsTable, trimmedUpdateProjectionsTable };
//Construct a list of column names for the projections/actual sales DataGridViews and the inventory DataGirdView.
string[] saleColumnNames =
{
@@ -1698,12 +1697,12 @@ namespace AdvertsingProfitControl
{
if (columnName == "ID") continue;
var column = new DataColumn(columnName);
- trimmedTables[0].Columns.Add(column);
+ trimmedNewProjectionsTable.Columns.Add(column);
}
foreach (var columnName in saleColumnNames)
{
var column = new DataColumn(columnName);
- trimmedTables[1].Columns.Add(column);
+ trimmedUpdateProjectionsTable.Columns.Add(column);
}
//Create the database interaction objects.
var databaseTracker = new DatabaseTracker();
@@ -1748,12 +1747,11 @@ namespace AdvertsingProfitControl
{
//TODO: Throw an exception, this can not be allowed.
//AdItemInsertionFailedException
- trimmedTables[0].Rows.Clear(); //Work around for now
- trimmedTables[1].Rows.Clear();
+ trimmedNewProjectionsTable.Rows.Clear(); //Work around for now
+ trimmedUpdateProjectionsTable.Rows.Clear();
return TrimmingOperationResult.FailedToTrim;
}
}
- var tableIndex = 0;
//Check for repeated ad items in the ad special section
if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex)
{
@@ -1763,6 +1761,64 @@ namespace AdvertsingProfitControl
//Check if a repeat was found.
if (repeatedItemIndex != -1)
{
+ //A row index has been found so check to see if the row in question has already been added to any of the trimmed tables.
+ if ((bool)projectionsDataGridView.Rows[repeatedItemIndex].Cells[(int) SalesTableColumns.IsDirty].Value)
+ {
+ //If the row is dirty then its going to be found in either...
+ if (!(bool)projectionsDataGridView.Rows[repeatedItemIndex].Cells[(int)SalesTableColumns.IsInDatabase].Value)
+ {
+ //... or the add new items table.
+ //If the ad item is being used in section one then locate it and update it in the trimmed table.
+ var foundRow = trimmedNewProjectionsTable.Select("AdItemID = '" + adItemId + "'");
+ if (foundRow.Length == 1)
+ {
+ LogConsole.WriteToLog(FrmLogConsole.Level.Info,
+ "Ad item '" + row.Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue +
+ "' found in the trimmed new table.");
+ }
+ //Else error condition?
+ //With the row found obtain the row's index and modify it in the table to
+ //include the ad special ID number. No other modifications are required so we can return.
+ }
+ else
+ {
+ //... the update existing items table
+ //If the ad item is being used in section two then locate it and update it in the trimmed table.
+ var foundRow = trimmedUpdateProjectionsTable.Select("AdItemID = '" + adItemId + "'");
+ if (foundRow.Length == 1)
+ {
+ LogConsole.WriteToLog(FrmLogConsole.Level.Info,
+ "Ad item '" + row.Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue +
+ "' found in the trimmed update table.");
+ }
+ //Else error condition?
+ //With the row found obtain the row's index and modify it in the table to
+ //include the ad special ID number. No other modifications are required so we can return.
+ }
+ }
+ else
+ {
+ //If the row is not dirty then it would not be included in any trimmed table just yet.
+ if ((bool)projectionsDataGridView.Rows[repeatedItemIndex].Cells[(int) SalesTableColumns.IsInDatabase].Value)
+ {
+ //If its in the database already then add the row to the update table, including the ad special ID number.
+ //If the ad item is being used in section two then locate it and update it in the trimmed table.
+ var foundRow = trimmedUpdateProjectionsTable.Select("AdItemID = '" + adItemId + "'");
+ if (foundRow.Length == 1)
+ {
+ LogConsole.WriteToLog(FrmLogConsole.Level.Info,
+ "Ad item '" + row.Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue +
+ "' found in the trimmed update table.");
+ }
+ //Else error condition?
+ //With the row found obtain the row's index and modify it in the table to
+ //include the ad special ID number. No other modifications are required so we can return.
+ }
+ //else
+ //{
+ // //Otherwise add it to the add new item trimmed table (should never happen).
+ //}
+ }
LogConsole.WriteToLog(FrmLogConsole.Level.Info, "Repeated ad item '" + row.Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue + "' found.");
LogConsole.WriteToLog(FrmLogConsole.Level.Info, "Its row index is " + repeatedItemIndex + ".");
}
@@ -1842,8 +1898,7 @@ namespace AdvertsingProfitControl
newRow[9] = row.Index + 1;
}
newRow[10] = dateId;
- trimmedTables[0].Rows.Add(newRow);
- //usedAdItems.Add(adItemId, "0");
+ trimmedNewProjectionsTable.Rows.Add(newRow);
}
else
{
@@ -1869,8 +1924,7 @@ namespace AdvertsingProfitControl
newRow[10] = row.Index + 1;
}
newRow[11] = dateId;
- trimmedTables[1].Rows.Add(newRow);
- //usedAdItems.Add(adItemId, "1");
+ trimmedUpdateProjectionsTable.Rows.Add(newRow);
}
//LogConsole.WriteToLog(FrmLogConsole.Level.Verbose, "Row Dump for row number " + (row.Index + 1) + ".");
//LogConsole.WriteToLog(FrmLogConsole.Level.Verbose, "ID : " + rowIdNumber + " Sold: " + row.Cells[(int)SalesTableColumns.Sold].EditedFormattedValue);
diff --git a/AdvertsingProfitControl/RowParsing.cs b/AdvertsingProfitControl/RowParsing.cs
index 7ac13cb..77affa9 100644
--- a/AdvertsingProfitControl/RowParsing.cs
+++ b/AdvertsingProfitControl/RowParsing.cs
@@ -129,9 +129,10 @@ namespace AdvertsingProfitControl
public enum RowAttribute
{
NewRow = 0,
- MemberRow = 1,
- HeaderRow = 2,
- AdSpecialRow = 3,
- IncompleteRow = 4
+ IncompleteRow = 1,
+ AdSpecialRow = 2,
+ RepeatedRow = 3,
+ MemberRow = 4,
+ HeaderRow = 5
}
}
diff --git a/AdvertsingProfitControl/bin/Debug/APCDatabase.accdb b/AdvertsingProfitControl/bin/Debug/APCDatabase.accdb
index 0a4b7b7..9fe8d25 100644
Binary files a/AdvertsingProfitControl/bin/Debug/APCDatabase.accdb and b/AdvertsingProfitControl/bin/Debug/APCDatabase.accdb differ
diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.application b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.application
index 680be7d..e0d94e7 100644
--- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.application
+++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.application
@@ -14,7 +14,7 @@
- NTO0L5eo/+hVPkpkkG+l0Cwyq1UDJhAIhKLSFVe0G7M=
+ a9nSyX771UnNpCxSLQTrqyr+/1DNpDIEZBXaQAVLi88=
diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.exe.manifest b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.exe.manifest
index 7d65bf5..07db5d4 100644
--- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.exe.manifest
+++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.exe.manifest
@@ -50,7 +50,7 @@
- F+SMPqUABgZezUBIYj70xi9mrD6XzMo/h89+58pb5mM=
+ EvD+c0PqPuyMPwSjcVOB4gfL+Q/3iQ2v/e+IKDLio0Y=
diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application
index 680be7d..e0d94e7 100644
--- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application
+++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application
@@ -14,7 +14,7 @@
- NTO0L5eo/+hVPkpkkG+l0Cwyq1UDJhAIhKLSFVe0G7M=
+ a9nSyX771UnNpCxSLQTrqyr+/1DNpDIEZBXaQAVLi88=
diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest
index 7d65bf5..07db5d4 100644
--- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest
+++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest
@@ -50,7 +50,7 @@
- F+SMPqUABgZezUBIYj70xi9mrD6XzMo/h89+58pb5mM=
+ EvD+c0PqPuyMPwSjcVOB4gfL+Q/3iQ2v/e+IKDLio0Y=
diff --git a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.application b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.application
index 680be7d..e0d94e7 100644
--- a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.application
+++ b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.application
@@ -14,7 +14,7 @@
- NTO0L5eo/+hVPkpkkG+l0Cwyq1UDJhAIhKLSFVe0G7M=
+ a9nSyX771UnNpCxSLQTrqyr+/1DNpDIEZBXaQAVLi88=
diff --git a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.exe.manifest b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.exe.manifest
index 7d65bf5..07db5d4 100644
--- a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.exe.manifest
+++ b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.exe.manifest
@@ -50,7 +50,7 @@
- F+SMPqUABgZezUBIYj70xi9mrD6XzMo/h89+58pb5mM=
+ EvD+c0PqPuyMPwSjcVOB4gfL+Q/3iQ2v/e+IKDLio0Y=