Began implementing ad item repeat detection in the new Add Record Form but for the Projections table only.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -14,7 +14,7 @@
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<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>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<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>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<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>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<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>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<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>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<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>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
||||
Reference in New Issue
Block a user