Began implementing ad item repeat detection in the new Add Record Form but for the Projections table only.

This commit is contained in:
2016-11-05 14:38:21 -05:00
parent 95d5cd9943
commit 6e45121c1f
9 changed files with 75 additions and 20 deletions
+64 -10
View File
@@ -1687,7 +1687,6 @@ namespace AdvertsingProfitControl
//7:FK_AdItemID 8:RowAttribute 9:FK_AdSpecialGroupName (ID) 10:RowPosition (not index based) //7:FK_AdItemID 8:RowAttribute 9:FK_AdSpecialGroupName (ID) 10:RowPosition (not index based)
//11:FK_DateID //11:FK_DateID
trimmedUpdateProjectionsTable = new DataTable("Projections"); trimmedUpdateProjectionsTable = new DataTable("Projections");
DataTable[] trimmedTables = { trimmedNewProjectionsTable, trimmedUpdateProjectionsTable };
//Construct a list of column names for the projections/actual sales DataGridViews and the inventory DataGirdView. //Construct a list of column names for the projections/actual sales DataGridViews and the inventory DataGirdView.
string[] saleColumnNames = string[] saleColumnNames =
{ {
@@ -1698,12 +1697,12 @@ namespace AdvertsingProfitControl
{ {
if (columnName == "ID") continue; if (columnName == "ID") continue;
var column = new DataColumn(columnName); var column = new DataColumn(columnName);
trimmedTables[0].Columns.Add(column); trimmedNewProjectionsTable.Columns.Add(column);
} }
foreach (var columnName in saleColumnNames) foreach (var columnName in saleColumnNames)
{ {
var column = new DataColumn(columnName); var column = new DataColumn(columnName);
trimmedTables[1].Columns.Add(column); trimmedUpdateProjectionsTable.Columns.Add(column);
} }
//Create the database interaction objects. //Create the database interaction objects.
var databaseTracker = new DatabaseTracker(); var databaseTracker = new DatabaseTracker();
@@ -1748,12 +1747,11 @@ namespace AdvertsingProfitControl
{ {
//TODO: Throw an exception, this can not be allowed. //TODO: Throw an exception, this can not be allowed.
//AdItemInsertionFailedException //AdItemInsertionFailedException
trimmedTables[0].Rows.Clear(); //Work around for now trimmedNewProjectionsTable.Rows.Clear(); //Work around for now
trimmedTables[1].Rows.Clear(); trimmedUpdateProjectionsTable.Rows.Clear();
return TrimmingOperationResult.FailedToTrim; return TrimmingOperationResult.FailedToTrim;
} }
} }
var tableIndex = 0;
//Check for repeated ad items in the ad special section //Check for repeated ad items in the ad special section
if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex) if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex)
{ {
@@ -1763,6 +1761,64 @@ namespace AdvertsingProfitControl
//Check if a repeat was found. //Check if a repeat was found.
if (repeatedItemIndex != -1) 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, "Repeated ad item '" + row.Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue + "' found.");
LogConsole.WriteToLog(FrmLogConsole.Level.Info, "Its row index is " + repeatedItemIndex + "."); LogConsole.WriteToLog(FrmLogConsole.Level.Info, "Its row index is " + repeatedItemIndex + ".");
} }
@@ -1842,8 +1898,7 @@ namespace AdvertsingProfitControl
newRow[9] = row.Index + 1; newRow[9] = row.Index + 1;
} }
newRow[10] = dateId; newRow[10] = dateId;
trimmedTables[0].Rows.Add(newRow); trimmedNewProjectionsTable.Rows.Add(newRow);
//usedAdItems.Add(adItemId, "0");
} }
else else
{ {
@@ -1869,8 +1924,7 @@ namespace AdvertsingProfitControl
newRow[10] = row.Index + 1; newRow[10] = row.Index + 1;
} }
newRow[11] = dateId; newRow[11] = dateId;
trimmedTables[1].Rows.Add(newRow); trimmedUpdateProjectionsTable.Rows.Add(newRow);
//usedAdItems.Add(adItemId, "1");
} }
//LogConsole.WriteToLog(FrmLogConsole.Level.Verbose, "Row Dump for row number " + (row.Index + 1) + "."); //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); //LogConsole.WriteToLog(FrmLogConsole.Level.Verbose, "ID : " + rowIdNumber + " Sold: " + row.Cells[(int)SalesTableColumns.Sold].EditedFormattedValue);
+5 -4
View File
@@ -129,9 +129,10 @@ namespace AdvertsingProfitControl
public enum RowAttribute public enum RowAttribute
{ {
NewRow = 0, NewRow = 0,
MemberRow = 1, IncompleteRow = 1,
HeaderRow = 2, AdSpecialRow = 2,
AdSpecialRow = 3, RepeatedRow = 3,
IncompleteRow = 4 MemberRow = 4,
HeaderRow = 5
} }
} }
Binary file not shown.
@@ -14,7 +14,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>NTO0L5eo/+hVPkpkkG+l0Cwyq1UDJhAIhKLSFVe0G7M=</dsig:DigestValue> <dsig:DigestValue>a9nSyX771UnNpCxSLQTrqyr+/1DNpDIEZBXaQAVLi88=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
@@ -50,7 +50,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>F+SMPqUABgZezUBIYj70xi9mrD6XzMo/h89+58pb5mM=</dsig:DigestValue> <dsig:DigestValue>EvD+c0PqPuyMPwSjcVOB4gfL+Q/3iQ2v/e+IKDLio0Y=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
@@ -14,7 +14,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>NTO0L5eo/+hVPkpkkG+l0Cwyq1UDJhAIhKLSFVe0G7M=</dsig:DigestValue> <dsig:DigestValue>a9nSyX771UnNpCxSLQTrqyr+/1DNpDIEZBXaQAVLi88=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
@@ -50,7 +50,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>F+SMPqUABgZezUBIYj70xi9mrD6XzMo/h89+58pb5mM=</dsig:DigestValue> <dsig:DigestValue>EvD+c0PqPuyMPwSjcVOB4gfL+Q/3iQ2v/e+IKDLio0Y=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
@@ -14,7 +14,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>NTO0L5eo/+hVPkpkkG+l0Cwyq1UDJhAIhKLSFVe0G7M=</dsig:DigestValue> <dsig:DigestValue>a9nSyX771UnNpCxSLQTrqyr+/1DNpDIEZBXaQAVLi88=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
@@ -50,7 +50,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>F+SMPqUABgZezUBIYj70xi9mrD6XzMo/h89+58pb5mM=</dsig:DigestValue> <dsig:DigestValue>EvD+c0PqPuyMPwSjcVOB4gfL+Q/3iQ2v/e+IKDLio0Y=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>