From 6e45121c1ff433607f52770f92e0650a6d1e3d46 Mon Sep 17 00:00:00 2001 From: Garritt McCune Date: Sat, 5 Nov 2016 14:38:21 -0500 Subject: [PATCH] Began implementing ad item repeat detection in the new Add Record Form but for the Projections table only. --- AdvertsingProfitControl/NewAddRecord.cs | 74 +++++++++++++++--- AdvertsingProfitControl/RowParsing.cs | 9 ++- .../bin/Debug/APCDatabase.accdb | Bin 2932736 -> 2932736 bytes .../Debug/AdvertsingProfitControl.application | 2 +- .../AdvertsingProfitControl.exe.manifest | 2 +- ...AdvertsingProfitControl.vshost.application | 2 +- ...dvertsingProfitControl.vshost.exe.manifest | 2 +- .../Debug/AdvertsingProfitControl.application | 2 +- .../AdvertsingProfitControl.exe.manifest | 2 +- 9 files changed, 75 insertions(+), 20 deletions(-) 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 0a4b7b744da9db07d17a19e6461489f12b8390ee..9fe8d250f64569ab1baf5bd01b3441e2ee5d0367 100644 GIT binary patch delta 376 zcmZo@*vtsR8<_YwIb?P+F)=bSGHw>+d(Svofsd_8piO|WO@OIQfO(q$3zGo1I&U!p z1V~NiRbVmQo>a^_k7weB&h|`QmhG9ktTR6;9_LGiC}H4cxZZ#0{O0pZ&Uf=yoR8u6 zJg>;l$Nze};00z~zKI)V%Q7(>XJBCX|IaNazbG+B!M8NGSiwZWGcP$KwOFQ|L!WIs zhdw(8BdZhx1B3r`Q3G~8M*ryn1{|u}GY!~h>NCIMEuOegoRx`%LqK8r$9Ym!8#lNz zPJfWdZpCWOz~IE#E}z8SE}z8FE}z8NE}z8JE}z8RE}z8HE}z8PE}z8LE}z8TE}taO zE}taWE}taSE}taaE}taQE}taYE}taUE}tacE}taPE}taXE}taTE}tabE}taRE}taZ zE}taVE}tadE}x{(E}x{>E}x{-E}x{_E}x{*E}x{@E}x{+d(Svofsd_8piO|WO@OIQfO(q$3zGo10BiS&cVnk&A`AAFkRGuU5_zfdVm3k>h??n_L=(34|$6xE)<_E)4;La>;ls& z#)%t*rawqzw_*)oU~rOZmrr7Emrvqomrvqsmrvqqmrvqumrvqpmrvqtmrvqrmrvqv zmroLCmroLGmroLEmroLImroLDmroLHmroLFmroLJmrs&tmrs&xmrnwjC*3ZeB-1XR zB-<{ZB-bvVB;PKdq|h#(q}VQ>q|`2-q}(o_q|z>*q}nc@q}DEk 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=