diff --git a/AdvertsingProfitControl/AdvertisingProfitControlTableHelper.cs b/AdvertsingProfitControl/AdvertisingProfitControlTableHelper.cs index 0db9c03..3173e90 100644 --- a/AdvertsingProfitControl/AdvertisingProfitControlTableHelper.cs +++ b/AdvertsingProfitControl/AdvertisingProfitControlTableHelper.cs @@ -19,23 +19,19 @@ namespace AdvertsingProfitControl var parser = new RowParsing(); int isHeaderColumn; int isMemberColumn; - int adSpecialColumn; if (dataGridView.Columns.Count == Enum.GetNames(typeof(SalesTableColumns)).Length) { isHeaderColumn = (int) SalesTableColumns.IsHeaderRow; isMemberColumn = (int) SalesTableColumns.IsMemberRow; - adSpecialColumn = (int) SalesTableColumns.IsAdSpecialRow; } else { isHeaderColumn = (int)InventoryTableColumns.IsHeaderRow; isMemberColumn = (int)InventoryTableColumns.IsMemberRow; - adSpecialColumn = (int) InventoryTableColumns.IsAdSpecialRow; } //If the current row is an Ad Special Row, the color code it and return as nothing further needs to be done. if (parser.CheckForGroupKeyWord(dataGridView.Rows[startingIndex].Cells[(int) SalesTableColumns.AdItem].EditedFormattedValue.ToString()) != "NoGroupFound") { - dataGridView.Rows[startingIndex].Cells[adSpecialColumn].Value = true; dataGridView.Rows[startingIndex].DefaultCellStyle.BackColor = Color.Silver; return; } @@ -266,10 +262,7 @@ namespace AdvertsingProfitControl TotalProfitReturn = 7, IsHeaderRow = 8, IsMemberRow = 9, - IsAdSpecialRow = 10, - IsAdSpecialMember = 11, - IsDirty = 12, - IsInDatabase = 13 + IsDirty = 10, } public enum InventoryTableColumns @@ -282,10 +275,7 @@ namespace AdvertsingProfitControl EndingInventory = 5, IsHeaderRow = 6, IsMemberRow = 7, - IsAdSpecialRow = 8, - IsAdSpecialMember = 9, - IsDirty = 10, - IsInDatabase = 11 + IsDirty = 8, } public enum InvoiceTableColumns diff --git a/AdvertsingProfitControl/NewAddRecord.Designer.cs b/AdvertsingProfitControl/NewAddRecord.Designer.cs index 0bfd119..f05b7ef 100644 --- a/AdvertsingProfitControl/NewAddRecord.Designer.cs +++ b/AdvertsingProfitControl/NewAddRecord.Designer.cs @@ -44,8 +44,6 @@ this.mainMenuStrip = new System.Windows.Forms.MenuStrip(); this.FileMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.exitFileMainMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.debugMainMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.getCellValueDebugMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.mainLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); this.costAnalysisGroupBox = new System.Windows.Forms.GroupBox(); this.suppliesTextBox = new System.Windows.Forms.TextBox(); @@ -285,8 +283,7 @@ this.mainLayoutPanel.SetColumnSpan(this.mainMenuStrip, 4); this.mainMenuStrip.ImageScalingSize = new System.Drawing.Size(24, 24); this.mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.FileMainMenu, - this.debugMainMenu}); + this.FileMainMenu}); this.mainMenuStrip.Location = new System.Drawing.Point(0, 0); this.mainMenuStrip.Name = "mainMenuStrip"; this.mainMenuStrip.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2); @@ -305,24 +302,9 @@ // exitFileMainMenu // this.exitFileMainMenu.Name = "exitFileMainMenu"; - this.exitFileMainMenu.Size = new System.Drawing.Size(138, 34); + this.exitFileMainMenu.Size = new System.Drawing.Size(240, 34); this.exitFileMainMenu.Text = "E&xit"; // - // debugMainMenu - // - this.debugMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.getCellValueDebugMainMenu}); - this.debugMainMenu.Name = "debugMainMenu"; - this.debugMainMenu.Size = new System.Drawing.Size(87, 31); - this.debugMainMenu.Text = "Debug"; - // - // getCellValueDebugMainMenu - // - this.getCellValueDebugMainMenu.Name = "getCellValueDebugMainMenu"; - this.getCellValueDebugMainMenu.Size = new System.Drawing.Size(233, 34); - this.getCellValueDebugMainMenu.Text = "Get Cell Value"; - this.getCellValueDebugMainMenu.Click += new System.EventHandler(this.getCellValueDebugMainMenu_Click); - // // mainLayoutPanel // this.mainLayoutPanel.ColumnCount = 4; @@ -977,7 +959,5 @@ private System.Windows.Forms.Panel informationPanel; private System.Windows.Forms.Label errorLabel; private System.Windows.Forms.Label informationLabel; - private System.Windows.Forms.ToolStripMenuItem debugMainMenu; - private System.Windows.Forms.ToolStripMenuItem getCellValueDebugMainMenu; } } \ No newline at end of file diff --git a/AdvertsingProfitControl/NewAddRecord.cs b/AdvertsingProfitControl/NewAddRecord.cs index 9285bd9..2feaf0a 100644 --- a/AdvertsingProfitControl/NewAddRecord.cs +++ b/AdvertsingProfitControl/NewAddRecord.cs @@ -32,10 +32,6 @@ namespace AdvertsingProfitControl //Flag showing whether or not the AdSpecialRow has been made in this session. private int _adSpecialIndex = -1; private readonly AdvertisingProfitControlTableHelper _tableHelperFunctions = new AdvertisingProfitControlTableHelper(); - //Set flags to indicate whether or not a DataGridView needs to be painted. - private bool _projectionsRequirePainting; - //Inventory never needs to be parsed on tab page change since no data gets copied over from the other tables. - private bool _actualSalesRequiresPainting; public NewAddRecord() { @@ -90,8 +86,6 @@ namespace AdvertsingProfitControl projectionsDataGridView.EditingControlShowing += DisplayAutoCompleteOnEditingControlShowing; inventoryDataGridView.EditingControlShowing += DisplayAutoCompleteOnEditingControlShowing; actualSalesDataGridView.EditingControlShowing += DisplayAutoCompleteOnEditingControlShowing; - //Setup the event to handle painting the DataGridView on tab page change. - mainTabControl.SelectedIndexChanged += PaintDataGridViewOnTabPageChange; //After all events have been set, construct the DataGridVeiws for use. ConstructApcDataGridViews(); //Set-up events for the Invoice table. @@ -281,29 +275,6 @@ namespace AdvertsingProfitControl #endregion - private void PaintDataGridViewOnTabPageChange(object sender, EventArgs e) - { - var helper = new AdvertisingProfitControlTableHelper(); - switch (mainTabControl.SelectedIndex) - { - case 0: - if (_projectionsRequirePainting) - { - helper.PaintRowGroupsFromIndex(0, (DataGridView) mainTabControl.TabPages[0].Controls[0]); - _projectionsRequirePainting = false; - } - break; - //There is no need to deal with the inventory table here since no data is ever copied over beyond the ad item (or ad special). - case 2: - if (_actualSalesRequiresPainting) - { - helper.PaintRowGroupsFromIndex(0, (DataGridView)mainTabControl.TabPages[2].Controls[0]); - _actualSalesRequiresPainting = false; - } - break; - } - } - #region APC DataGridView Events /// @@ -315,22 +286,6 @@ namespace AdvertsingProfitControl private void DisplayRowNumbers(object sender, DataGridViewRowsAddedEventArgs e) { var table = ((DataGridView)sender); - //Set a flag based on what tab page is currently being used to indicate whether or not a DataGridView needs painting. - switch (mainTabControl.SelectedIndex) - { - case 0: - _projectionsRequirePainting = false; - _actualSalesRequiresPainting = true; - break; - case 1: - _projectionsRequirePainting = true; - _actualSalesRequiresPainting = true; - break; - case 2: - _projectionsRequirePainting = true; - _actualSalesRequiresPainting = false; - break; - } table.Rows[e.RowIndex].HeaderCell.Value = (e.RowIndex + 1).ToString(); } @@ -739,7 +694,7 @@ namespace AdvertsingProfitControl break; default: //Purely here for protection against parsing the Boolean columns by mistake. - if (e.ColumnIndex >= (int) SalesTableColumns.IsAdSpecialRow) {return;} + if (e.ColumnIndex == (int) SalesTableColumns.Id || e.ColumnIndex >= (int) SalesTableColumns.IsHeaderRow) {return;} //If the column is any other then check to see if the entered value can be parsed to a double (is a number), if not then throw an error to the user. if (double.TryParse(userInput, out parsedNumber)) { @@ -860,31 +815,9 @@ namespace AdvertsingProfitControl case (int)SalesTableColumns.IsMemberRow: rowContents[i] = projectionsDataGridView.Rows[e.RowIndex].Cells[(int)SalesTableColumns.IsMemberRow].Value; break; - case (int)SalesTableColumns.IsAdSpecialRow: - //Determine if the current row is the special row. - projectionsDataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsAdSpecialRow].Value = - e.RowIndex == _adSpecialIndex; - rowContents[i] = e.RowIndex == _adSpecialIndex; - break; - case (int)SalesTableColumns.IsAdSpecialMember: - //Check if this is a member of the ad special group. - if (_adSpecialIndex != -1) - { - projectionsDataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsAdSpecialMember - ].Value = e.RowIndex > _adSpecialIndex; - rowContents[i] = e.RowIndex > _adSpecialIndex; - } - else - { - rowContents[i] = false; - } - break; case (int)SalesTableColumns.IsDirty: rowContents[i] = true; break; - case (int)SalesTableColumns.IsInDatabase: - rowContents[i] = false; - break; default: rowContents[i] = ""; break; @@ -907,32 +840,14 @@ namespace AdvertsingProfitControl projectionsDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString(); break; case (int)SalesTableColumns.IsHeaderRow: - rowContents[(int)InventoryTableColumns.IsHeaderRow] = projectionsDataGridView.Rows[e.RowIndex].Cells[(int)SalesTableColumns.IsHeaderRow].Value; + rowContents[(int)InventoryTableColumns.IsHeaderRow] = projectionsDataGridView.Rows[e.RowIndex].Cells[i].Value; break; case (int)SalesTableColumns.IsMemberRow: - rowContents[(int)InventoryTableColumns.IsMemberRow] = projectionsDataGridView.Rows[e.RowIndex].Cells[(int)SalesTableColumns.IsMemberRow].Value; - break; - case (int)SalesTableColumns.IsAdSpecialRow: - //Determine if the current row is the special row. - inventoryNewRow[(int)InventoryTableColumns.IsAdSpecialRow] = (e.RowIndex == _adSpecialIndex); - break; - case (int)SalesTableColumns.IsAdSpecialMember: - //Check if this is a member of the ad special group. - if (_adSpecialIndex != -1) - { - inventoryNewRow[(int)InventoryTableColumns.IsAdSpecialMember] = (e.RowIndex > _adSpecialIndex); - } - else - { - inventoryNewRow[(int)InventoryTableColumns.IsAdSpecialMember] = false; - } + rowContents[(int)InventoryTableColumns.IsMemberRow] = projectionsDataGridView.Rows[e.RowIndex].Cells[i].Value; break; case (int)SalesTableColumns.IsDirty: inventoryNewRow[(int)InventoryTableColumns.IsDirty] = true; break; - case (int)SalesTableColumns.IsInDatabase: - inventoryNewRow[(int) InventoryTableColumns.IsInDatabase] = false; - break; default: if (i < (int) InventoryTableColumns.IsHeaderRow) { @@ -1113,7 +1028,7 @@ namespace AdvertsingProfitControl break; default: //Purely here for protection against parsing the Boolean columns by mistake. - if (e.ColumnIndex >= (int)InventoryTableColumns.IsAdSpecialRow) { return; } + if (e.ColumnIndex == (int)InventoryTableColumns.Id || e.ColumnIndex >= (int)InventoryTableColumns.IsHeaderRow) { return; } //This Reg-ex pattern will match any number followed by the word bin(s), to allow specifying the number of bins of product were ordered. var inventoryStringCheck = new Regex(@"^[0-9]{1,2} \bbin(s){0,1}\b", RegexOptions.IgnoreCase); @@ -1215,30 +1130,9 @@ namespace AdvertsingProfitControl case (int)SalesTableColumns.IsMemberRow: rowContents[i] = projectionsDataGridView.Rows[e.RowIndex].Cells[(int)InventoryTableColumns.IsMemberRow].Value; break; - case (int)SalesTableColumns.IsAdSpecialRow: - //Determine if the current row is the special row. - inventoryDataGridView.Rows[e.RowIndex].Cells[(int)InventoryTableColumns.IsAdSpecialRow].Value = - e.RowIndex == _adSpecialIndex; - rowContents[i] = e.RowIndex == _adSpecialIndex; - break; - case (int)SalesTableColumns.IsAdSpecialMember: - //Check if this is a member of the ad special group. - if (_adSpecialIndex != -1) - { - inventoryDataGridView.Rows[e.RowIndex].Cells[(int)InventoryTableColumns.IsAdSpecialMember].Value = e.RowIndex > _adSpecialIndex; - rowContents[i] = e.RowIndex > _adSpecialIndex; - } - else - { - rowContents[i] = false; - } - break; case (int)SalesTableColumns.IsDirty: rowContents[i] = true; break; - case (int)SalesTableColumns.IsInDatabase: - rowContents[i] = false; - break; default: rowContents[i] = ""; break; @@ -1395,31 +1289,9 @@ namespace AdvertsingProfitControl case (int)SalesTableColumns.IsMemberRow: rowContents[i] = actualSalesDataGridView.Rows[e.RowIndex].Cells[(int)SalesTableColumns.IsMemberRow].Value; break; - case (int)SalesTableColumns.IsAdSpecialRow: - //Determine if the current row is the special row. - actualSalesDataGridView.Rows[e.RowIndex].Cells[(int)SalesTableColumns.IsAdSpecialRow].Value = - e.RowIndex == _adSpecialIndex; - rowContents[i] = e.RowIndex == _adSpecialIndex; - break; - case (int)SalesTableColumns.IsAdSpecialMember: - //Check if this is a member of the ad special group. - if (_adSpecialIndex != -1) - { - actualSalesDataGridView.Rows[e.RowIndex].Cells[(int)SalesTableColumns.IsAdSpecialMember - ].Value = e.RowIndex > _adSpecialIndex; - rowContents[i] = e.RowIndex > _adSpecialIndex; - } - else - { - rowContents[i] = false; - } - break; case (int)SalesTableColumns.IsDirty: rowContents[i] = true; break; - case (int)SalesTableColumns.IsInDatabase: - rowContents[i] = false; - break; default: rowContents[i] = ""; break; @@ -1444,27 +1316,9 @@ namespace AdvertsingProfitControl case (int)SalesTableColumns.IsMemberRow: rowContents[(int)InventoryTableColumns.IsMemberRow] = actualSalesDataGridView.Rows[e.RowIndex].Cells[(int)SalesTableColumns.IsMemberRow].Value; break; - case (int)SalesTableColumns.IsAdSpecialRow: - //Determine if the current row is the special row. - inventoryNewRow[(int)InventoryTableColumns.IsAdSpecialRow] = e.RowIndex == _adSpecialIndex; - break; - case (int)SalesTableColumns.IsAdSpecialMember: - //Check if this is a member of the ad special group. - if (_adSpecialIndex != -1) - { - inventoryNewRow[(int) InventoryTableColumns.IsAdSpecialMember] = e.RowIndex > _adSpecialIndex; - } - else - { - inventoryNewRow[(int)InventoryTableColumns.IsAdSpecialMember] = false; - } - break; case (int)SalesTableColumns.IsDirty: inventoryNewRow[(int)InventoryTableColumns.IsDirty] = true; break; - case (int)SalesTableColumns.IsInDatabase: - inventoryNewRow[(int)InventoryTableColumns.IsInDatabase] = false; - break; default: if (i > (int)InventoryTableColumns.AdItem && i < (int)InventoryTableColumns.IsHeaderRow || i == (int)InventoryTableColumns.Id) { @@ -1558,11 +1412,11 @@ namespace AdvertsingProfitControl string[] saleColumnNames = { "ID", "AdItem", "Sold", "SalePrice", "TotalSales", "Cost", "ProfitReturn", - "TotalProfitReturn", "IsHeader", "IsMember", "IsAdSpecialRow", "IsAdSpecialMember", "IsDirty", "IsInDatabase" + "TotalProfitReturn", "IsHeader", "IsMember", "IsDirty" }; string[] inventoryColumnNames = { - "ID", "AdItem", "BeginningInventory", "Received", "Total", "EndingInventory", "IsHeader", "IsMember", "IsAdSpecialRow", "IsAdSpecialMember", "IsDirty", "IsInDatabase" + "ID", "AdItem", "BeginningInventory", "Received", "Total", "EndingInventory", "IsHeader", "IsMember", "IsDirty" }; foreach (var name in saleColumnNames) @@ -1766,10 +1620,6 @@ namespace AdvertsingProfitControl } #endregion - private void getCellValueDebugMainMenu_Click(object sender, EventArgs e) - { - } - private void AddRecordsButtonClick(object sender, EventArgs e) { //Make sure the mask in the text box is completed. @@ -1863,66 +1713,16 @@ namespace AdvertsingProfitControl //Create the cleaned table objects that will be sent to the database. DataTable trimmedTable; DataTable updateTable; - DbWriterStatus dbWriterStatus; - informationLabel.Text = @"Preparing data tables..."; + informationLabel.Text = @"Compressing data tables..."; var operationStatus = ConstructCleanedSalesTable("Projections", dateId, out trimmedTable, out updateTable); - switch (operationStatus) - { - case TrimmingOperationResult.NoChangesRequired: - informationLabel.Text += Environment.NewLine + @"No changes for the Projections table detected."; - break; - case TrimmingOperationResult.CreatedNewInsertionTable: - informationLabel.Text += Environment.NewLine + @"New table created."; - dbWriterStatus = dbW.InsertIntoSalesTable(trimmedTable, dbT.DatabaseConnectionString); - //Spin through the collection and update the affected rows. - foreach (var rowIndex in dbWriterStatus.GetRowCollection()) - { - projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.Id].Value = rowIndex.Value; - projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false; - projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsInDatabase].Value = true; - } - break; - case TrimmingOperationResult.CreatedUpdateTable: - informationLabel.Text += Environment.NewLine + @"Updates required."; - dbWriterStatus = dbW.UpdateSalesTable(updateTable, dbT.DatabaseConnectionString); - //Spin through the collection and update the affected rows. - foreach (var rowIndex in dbWriterStatus.GetRowCollection()) - { - //Only reset the IsDirty value to false since the updates when through. - projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false; - } - break; - case TrimmingOperationResult.CreatedNewInsertionAndUpdateTables: - //Insert the new values... - dbWriterStatus = dbW.InsertIntoSalesTable(trimmedTable, dbT.DatabaseConnectionString); - //Spin through the collection and update the affected rows. - foreach (var rowIndex in dbWriterStatus.GetRowCollection()) - { - projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.Id].Value = rowIndex.Value; - projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false; - projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsInDatabase].Value = true; - } - //... and update the existing values. - dbWriterStatus = dbW.UpdateSalesTable(updateTable, dbT.DatabaseConnectionString); - //Spin through the collection and update the affected rows. - foreach (var rowIndex in dbWriterStatus.GetRowCollection()) - { - //Only reset the IsDirty value to false since the updates when through. - projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false; - } - break; - case TrimmingOperationResult.FailedToTrim: - errorLabel.Text = @"Failed to trim."; - informationLabel.Text = ""; - return; - } + ProcessTrimmingStatusResult(projectionsDataGridView, "Projections", operationStatus, trimmedTable, updateTable); //Create the transaction scope. //By default the TransactionScopeOption is "Required", so if an ambient transaction does not //exist then the new transaction that is made (in the first method) becomes the root transaction. //Transaction Scope: https://msdn.microsoft.com/en-us/library/ms172152.aspx } - #region APC Table Trimming + #region Table Trimming Operations private TrimmingOperationResult ConstructCleanedSalesTable(string tableName, int dateId, out DataTable insertNewTable, out DataTable updateExistingTable) { @@ -1978,7 +1778,6 @@ namespace AdvertsingProfitControl //Check to see if the current row is the ad special row. if (row.Index == _adSpecialIndex) { - //LogConsole.WriteToLog(FrmLogConsole.Level.Verbose, "Ad Special Row found at index " + row.Index + "."); continue; } //Check to see if the row is dirty. @@ -2383,6 +2182,67 @@ namespace AdvertsingProfitControl } return TrimmingOperationResult.CreatedNewInsertionAndUpdateTables; } + + private void ProcessTrimmingStatusResult(DataGridView dataGridView, string tableName, TrimmingOperationResult operationStatus, DataTable trimmedTable, DataTable updateTable) + { + //Create the database interaction objects. + var dbT = new DatabaseTracker(); + var dbW = new DatabaseWriter(dbT.DatabaseConnectionString); + DbWriterStatus dbWriterStatus; + switch (operationStatus) + { + case TrimmingOperationResult.NoChangesRequired: + informationLabel.Text += Environment.NewLine + @"No changes for the " + tableName + @" table detected."; + break; + case TrimmingOperationResult.CreatedNewInsertionTable: + informationLabel.Text += Environment.NewLine + @"Inserting new changes to the " + tableName + @" table."; + dbWriterStatus = dbW.InsertIntoSalesTable(trimmedTable, dbT.DatabaseConnectionString); + //Spin through the collection and update the affected rows. + foreach (var rowIndex in dbWriterStatus.GetRowCollection()) + { + dataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.Id].Value = rowIndex.Value; + dataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false; + } + informationLabel.Text += Environment.NewLine + tableName + @" table successfully added to the database."; + break; + case TrimmingOperationResult.CreatedUpdateTable: + informationLabel.Text += Environment.NewLine + @"Updating changes made to the " + tableName + @" table."; + dbWriterStatus = dbW.UpdateSalesTable(updateTable, dbT.DatabaseConnectionString); + //Spin through the collection and update the affected rows. + foreach (var rowIndex in dbWriterStatus.GetRowCollection()) + { + //Only reset the IsDirty value to false since the updates when through. + dataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false; + } + informationLabel.Text += Environment.NewLine + tableName + @" table successfully updated."; + break; + case TrimmingOperationResult.CreatedNewInsertionAndUpdateTables: + //Insert the new values... + informationLabel.Text += Environment.NewLine + @"Inserting new changes to the " + tableName + @" table."; + dbWriterStatus = dbW.InsertIntoSalesTable(trimmedTable, dbT.DatabaseConnectionString); + //Spin through the collection and update the affected rows. + foreach (var rowIndex in dbWriterStatus.GetRowCollection()) + { + dataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.Id].Value = rowIndex.Value; + dataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false; + } + //... and update the existing values. + informationLabel.Text += Environment.NewLine + @"Updating changes made to the " + tableName + @" table."; + dbWriterStatus = dbW.UpdateSalesTable(updateTable, dbT.DatabaseConnectionString); + //Spin through the collection and update the affected rows. + foreach (var rowIndex in dbWriterStatus.GetRowCollection()) + { + //Only reset the IsDirty value to false since the updates when through. + dataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false; + } + informationLabel.Text += Environment.NewLine + @"All operations completed successfully."; + break; + case TrimmingOperationResult.FailedToTrim: + errorLabel.Text = @"Failed to trim " + tableName + @"."; + informationLabel.Text = ""; + return; + } + } #endregion } } diff --git a/AdvertsingProfitControl/RowParsing.cs b/AdvertsingProfitControl/RowParsing.cs index 77affa9..2099aaf 100644 --- a/AdvertsingProfitControl/RowParsing.cs +++ b/AdvertsingProfitControl/RowParsing.cs @@ -51,7 +51,7 @@ namespace AdvertsingProfitControl var i = 0; foreach (DataGridViewCell cell in row.Cells) { - if (cell.ColumnIndex >= (int) SalesTableColumns.IsHeaderRow) { i++; continue;} + if (cell.ColumnIndex >= (int) SalesTableColumns.IsHeaderRow || cell.ColumnIndex == 0) { i++; continue;} //Strip all whitespace characters from the cell, this includes vertical tabs, newlines, and any number of spaces. var cellContentsStripped = new string(cell.EditedFormattedValue.ToString().Where(c => !char.IsWhiteSpace(c)).ToArray()); //Now remove all zeros, including any decimal points as these values are meaningless. diff --git a/AdvertsingProfitControl/bin/Debug/APCDatabase.accdb b/AdvertsingProfitControl/bin/Debug/APCDatabase.accdb index 67a9e7b..cc80a4f 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 0e9f4b4..02e1b16 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.application +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.application @@ -14,7 +14,7 @@ - +ssiBRxAIMo1rYBk1za3itR7/whCFhhY9pJz/fEqrC4= + bbS3aUBt18bmu2EFWZGzfaB2KUwqvo/PJgwQ2X5UpGo= diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.exe.manifest b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.exe.manifest index 30ea602..087b38f 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.exe.manifest +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.exe.manifest @@ -50,7 +50,7 @@ - Yu2YbMJIbDdI4qvbL4hRtraLKoPxP0wq2Mbn7/XyWug= + BnL2vMS++iK9YFGaGKfELbajknBgq+TkNZn3K5yRC8w= diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application index 0e9f4b4..02e1b16 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application @@ -14,7 +14,7 @@ - +ssiBRxAIMo1rYBk1za3itR7/whCFhhY9pJz/fEqrC4= + bbS3aUBt18bmu2EFWZGzfaB2KUwqvo/PJgwQ2X5UpGo= diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest index 30ea602..087b38f 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest @@ -50,7 +50,7 @@ - Yu2YbMJIbDdI4qvbL4hRtraLKoPxP0wq2Mbn7/XyWug= + BnL2vMS++iK9YFGaGKfELbajknBgq+TkNZn3K5yRC8w= diff --git a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.application b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.application index 0e9f4b4..02e1b16 100644 --- a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.application +++ b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.application @@ -14,7 +14,7 @@ - +ssiBRxAIMo1rYBk1za3itR7/whCFhhY9pJz/fEqrC4= + bbS3aUBt18bmu2EFWZGzfaB2KUwqvo/PJgwQ2X5UpGo= diff --git a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.exe.manifest b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.exe.manifest index 30ea602..087b38f 100644 --- a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.exe.manifest +++ b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.exe.manifest @@ -50,7 +50,7 @@ - Yu2YbMJIbDdI4qvbL4hRtraLKoPxP0wq2Mbn7/XyWug= + BnL2vMS++iK9YFGaGKfELbajknBgq+TkNZn3K5yRC8w=