diff --git a/AdvertsingProfitControl/AdvertsingProfitControl.csproj b/AdvertsingProfitControl/AdvertsingProfitControl.csproj index 8f27213..519b8b5 100644 --- a/AdvertsingProfitControl/AdvertsingProfitControl.csproj +++ b/AdvertsingProfitControl/AdvertsingProfitControl.csproj @@ -231,6 +231,9 @@ + + Always + diff --git a/AdvertsingProfitControl/NewAddRecord.cs b/AdvertsingProfitControl/NewAddRecord.cs index 04d9f90..7c16aa2 100644 --- a/AdvertsingProfitControl/NewAddRecord.cs +++ b/AdvertsingProfitControl/NewAddRecord.cs @@ -280,15 +280,22 @@ namespace AdvertsingProfitControl private void UpdateUsedAdItemCollectionOnRowRemoving(object sender, CancelEventArgs e) { //Create an object that represents the DataGridView that fired the event. - var dataGridView = ((DataGridView)sender); + var dataGridView = (DataGridView)sender; if (dataGridView.CurrentRow == null) return; var currentRowIndex = dataGridView.CurrentRow.Index; //Remove the ad item from the gUsedAdItem collection, if it exists. - if (_adSpecialIndex == -1 || currentRowIndex < _adSpecialIndex) + if (_adSpecialIndex == -1) { //If the ad item entered in the first cell is in the gUsedAdItems collection, then remove it from there. _usedAdItems[0].Remove(dataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue.ToString()); } + else if (currentRowIndex < _adSpecialIndex) + { + //If the ad item entered in the first cell is in the gUsedAdItems collection, then remove it from there. + _usedAdItems[0].Remove(dataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue.ToString()); + //Also decrement the _adSpecialIndex so that it points to the correct row. + _adSpecialIndex--; + } else if (currentRowIndex > _adSpecialIndex) { //If the ad item entered in the first cell is in the gUsedAdItems collection, then remove it from there. @@ -1552,8 +1559,6 @@ namespace AdvertsingProfitControl private void getCellValueDebugMainMenu_Click(object sender, EventArgs e) { - var dataGridView = (DataGridView)mainTabControl.TabPages[0].Controls[0]; - MessageBox.Show(dataGridView.CurrentRow.DefaultCellStyle.BackColor.Name); } private void AddRecordsButtonClick(object sender, EventArgs e) @@ -1647,7 +1652,9 @@ 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 trimmedProjectionsTable = ConstructCleanedProjectionsTable(dateId); + var trimmed = new DataTable(); + var update = new DataTable(); + var trimmedProjectionsTable = ConstructCleanedProjectionsTable(dateId, out trimmed, out update); //var trimmedInventoryTable = ConstructCleanedInventoryTable(dateId); //var trimmedActualSalesTable = ConstructCleanedActualSalesTable(dateId); //Create the transaction scope. @@ -1703,8 +1710,6 @@ namespace AdvertsingProfitControl var databaseReader = new DatabaseReader(); var databaseWriter = new DatabaseWriter(databaseTracker.DatabaseConnectionString); var adSpecialId = 0; //Entries in the database are not allowed to be zero (unique ID wise that is). - //Dictionary The table ID is zero (0) for the new table and one (1) for the update table. - var usedAdItems = new Dictionary(); //Contains ad items that are used in section one, used for checking for repeats. //Grab the ad special ID, assuming there is one. if (_adSpecialIndex != -1) { @@ -1727,11 +1732,6 @@ namespace AdvertsingProfitControl //Check to see if the row is dirty. if (!(bool)row.Cells[(int)SalesTableColumns.IsDirty].Value) { - //Log ad items from section one (1), recording their row index as the key. - //If the ad special isn't set then ignore this operation entirely as its not necessary. - if (_adSpecialIndex != -1 && row.Index < _adSpecialIndex) - { - } //If it is not then continue on to the next row. continue; } @@ -1746,53 +1746,62 @@ namespace AdvertsingProfitControl adItemId = databaseWriter.InsertNewAdItem(row.Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue.ToString()); if (adItemId == 0) { - errorLabel.Text = @"Failed to insert new ad item."; //TODO: Throw an exception, this can not be allowed. //AdItemInsertionFailedException trimmedTables[0].Rows.Clear(); //Work around for now trimmedTables[1].Rows.Clear(); - //throw new InvalidOperationException("Failed to add ad item."); - //break; + return TrimmingOperationResult.FailedToTrim; } } var tableIndex = 0; - string spma; //Check for repeated ad items in the ad special section - if (usedAdItems.TryGetValue(adItemId, out spma)) + if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex) { - //If the ad item is being used in section one then locate it and update it in the trimmed table. - var foundRow = trimmedTables[tableIndex].Select("AdItemID = '" + adItemId + "'"); - if (foundRow.Length == 1) + //Attempt to grab the index of an ad item, if it is not found then the return value is -1. + var repeatedItemIndex = + _usedAdItems[0].FindIndex(x => x == row.Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue.ToString()); + //Check if a repeat was found. + if (repeatedItemIndex != -1) { - LogConsole.WriteToLog(FrmLogConsole.Level.Info, - "Ad item '" + row.Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue + - "' found in the trimmed table."); + 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 + "."); } - else - { - //TODO: Throw an exception, this can not be allowed. - //InvalidTrimmedRowCountException - trimmedTables[0].Rows.Clear(); //Work around for now - trimmedTables[1].Rows.Clear(); - break; - } - //Begin spinning through all the rows to find the one selected above. - for (var i = 0; i < trimmedTables[tableIndex].Rows.Count; i++) - { - //Check to see if the selected row is equal. - if (foundRow[0] != trimmedTables[tableIndex].Rows[i]) continue; - //If so then update that row index with the group ID number. - if (tableIndex == 0) - { - trimmedTables[0].Rows[i][8] = adSpecialId; - } - else - { - trimmedTables[1].Rows[i][9] = adSpecialId; - } - } - //Once ad special ID has been updated jump to the next row. - continue; + //if (_usedAdItems[0].Contains(row.Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue.ToString())) + //{ + // //If the ad item is being used in section one then locate it and update it in the trimmed table. + // var foundRow = trimmedTables[tableIndex].Select("AdItemID = '" + adItemId + "'"); + // if (foundRow.Length == 1) + // { + // LogConsole.WriteToLog(FrmLogConsole.Level.Info, + // "Ad item '" + row.Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue + + // "' found in the trimmed table."); + // } + // else + // { + // //TODO: Throw an exception, this can not be allowed. + // //InvalidTrimmedRowCountException + // trimmedTables[0].Rows.Clear(); //Work around for now + // trimmedTables[1].Rows.Clear(); + // return TrimmingOperationResult.FailedToTrim; + // } + // //Begin spinning through all the rows to find the one selected above. + // for (var i = 0; i < trimmedTables[tableIndex].Rows.Count; i++) + // { + // //Check to see if the selected row is equal. + // if (foundRow[0] != trimmedTables[tableIndex].Rows[i]) continue; + // //If so then update that row index with the group ID number. + // if (tableIndex == 0) + // { + // trimmedTables[0].Rows[i][8] = adSpecialId; + // } + // else + // { + // trimmedTables[1].Rows[i][9] = adSpecialId; + // } + // } + // //Once ad special ID has been updated jump to the next row. + // continue; + //} } //Determine the row's attribute. var rowAttribute = 0; //Zero (0) means no grouping, its not a header nor a member. @@ -1807,7 +1816,7 @@ namespace AdvertsingProfitControl //Since we've made it this far, add the ad item into the dictionary if we're not in the ad special group. if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex) { - usedAdItems.Add(row.Index, "s"); + //usedAdItems.Add(row.Index, "s"); } //Add the values to their respective data table. if (rowIdNumber == 0) @@ -1834,7 +1843,7 @@ namespace AdvertsingProfitControl } newRow[10] = dateId; trimmedTables[0].Rows.Add(newRow); - usedAdItems.Add(adItemId, "0"); + //usedAdItems.Add(adItemId, "0"); } else { @@ -1861,7 +1870,7 @@ namespace AdvertsingProfitControl } newRow[11] = dateId; trimmedTables[1].Rows.Add(newRow); - usedAdItems.Add(adItemId, "1"); + //usedAdItems.Add(adItemId, "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); diff --git a/AdvertsingProfitControl/bin/Debug/APCDatabase.accdb b/AdvertsingProfitControl/bin/Debug/APCDatabase.accdb new file mode 100644 index 0000000..0a4b7b7 Binary files /dev/null and b/AdvertsingProfitControl/bin/Debug/APCDatabase.accdb differ diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.application b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.application index 028da03..680be7d 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.application +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.application @@ -7,14 +7,14 @@ - + - BdpMI18xuF58t84pN4xrCnguGw/WzgI8+4NoHv0AZ2Q= + NTO0L5eo/+hVPkpkkG+l0Cwyq1UDJhAIhKLSFVe0G7M= diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.exe.manifest b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.exe.manifest index 7938644..7d65bf5 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.exe.manifest +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.exe.manifest @@ -50,7 +50,7 @@ - OJ71svPIgpljDYB7Isp1dyJ+HAA2f5EAkzyTUGfVCPE= + F+SMPqUABgZezUBIYj70xi9mrD6XzMo/h89+58pb5mM= @@ -78,6 +78,15 @@ + + + + + + + jHrcUaYXYq1n7JCrmyieXoxYIayP5Xf8FNLYAJKW198= + + diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application index 028da03..680be7d 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application @@ -7,14 +7,14 @@ - + - BdpMI18xuF58t84pN4xrCnguGw/WzgI8+4NoHv0AZ2Q= + NTO0L5eo/+hVPkpkkG+l0Cwyq1UDJhAIhKLSFVe0G7M= diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest index 7938644..7d65bf5 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest @@ -50,7 +50,7 @@ - OJ71svPIgpljDYB7Isp1dyJ+HAA2f5EAkzyTUGfVCPE= + F+SMPqUABgZezUBIYj70xi9mrD6XzMo/h89+58pb5mM= @@ -78,6 +78,15 @@ + + + + + + + jHrcUaYXYq1n7JCrmyieXoxYIayP5Xf8FNLYAJKW198= + + diff --git a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.application b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.application index 028da03..680be7d 100644 --- a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.application +++ b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.application @@ -7,14 +7,14 @@ - + - BdpMI18xuF58t84pN4xrCnguGw/WzgI8+4NoHv0AZ2Q= + NTO0L5eo/+hVPkpkkG+l0Cwyq1UDJhAIhKLSFVe0G7M= diff --git a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.csproj.FileListAbsolute.txt b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.csproj.FileListAbsolute.txt index 84d1576..10c3291 100644 --- a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.csproj.FileListAbsolute.txt +++ b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.csproj.FileListAbsolute.txt @@ -165,3 +165,26 @@ C:\Users\Crypto\Documents\Visual Studio 2015\Projects\AdvertsingProfitControl\Ad C:\Users\Crypto\Documents\Visual Studio 2015\Projects\AdvertsingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.application C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.exe C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.pdb +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.csprojResolveAssemblyReference.cache +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmAddRecord.resources +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmAdSpecialRegister.resources +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmDeleteRecord.resources +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmMain.resources +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmLogConsole.resources +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmManageAdItems.resources +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmModifyRecord.resources +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.NewAddRecord.resources +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.Properties.Resources.resources +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.csproj.GenerateResource.Cache +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\APCDatabase.accdb +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\AdvertsingProfitControl.exe.manifest +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\AdvertsingProfitControl.application +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\AdvertsingProfitControl.exe +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\AdvertsingProfitControl.pdb +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\HtmlRenderer.dll +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\HtmlRenderer.WinForms.dll +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\HtmlRenderer.pdb +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\HtmlRenderer.WinForms.pdb +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.TrustInfo.xml +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.exe.manifest +C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.application diff --git a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.exe.manifest b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.exe.manifest index 7938644..7d65bf5 100644 --- a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.exe.manifest +++ b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.exe.manifest @@ -50,7 +50,7 @@ - OJ71svPIgpljDYB7Isp1dyJ+HAA2f5EAkzyTUGfVCPE= + F+SMPqUABgZezUBIYj70xi9mrD6XzMo/h89+58pb5mM= @@ -78,6 +78,15 @@ + + + + + + + jHrcUaYXYq1n7JCrmyieXoxYIayP5Xf8FNLYAJKW198= + +