diff --git a/AdvertsingProfitControl/NewModifyRecord.cs b/AdvertsingProfitControl/NewModifyRecord.cs index 538825f..b4c5e0e 100644 --- a/AdvertsingProfitControl/NewModifyRecord.cs +++ b/AdvertsingProfitControl/NewModifyRecord.cs @@ -525,11 +525,13 @@ namespace AdvertsingProfitControl { _isFormDirty = true; } - //TableGroupParser.PaintRowGroupsFromIndex(e.RowIndex, dataGridView); } else { - //TODO: Update Inventory table parser. + if (TableGroupParser.PaintIneventory(inventoryDataGridView, projectionsDataGridView, e.RowIndex)) + { + _isFormDirty = true; + } } //Add in used Ad Items to the list. if (userInput == string.Empty) return; @@ -1028,7 +1030,12 @@ namespace AdvertsingProfitControl { inventoryDataGridView.Rows[e.RowIndex].Cells[(int) TableGroupParser.InventoryTableColumns.AdItem].Value = userInput; } - TableGroupParser.PaintInventoryRowGroups(e.RowIndex - 1, inventoryDataGridView, projectionsDataGridView); //TODO:CHANGED .PaintRowGroupsFromIndex(e.RowIndex - 1, inventoryDataGridView); + if (TableGroupParser.PaintIneventory(inventoryDataGridView, + projectionsDataGridView, + e.RowIndex - 1)) + { + _isFormDirty = true; + } if (actualSalesDataGridView.RowCount > e.RowIndex) { actualSalesDataGridView.Rows[e.RowIndex].Cells[(int) TableGroupParser.SalesTableColumns.AdItem].Value = userInput; @@ -1554,7 +1561,12 @@ namespace AdvertsingProfitControl { inventoryDataGridView.Rows[e.RowIndex].Cells[(int)TableGroupParser.InventoryTableColumns.AdItem].Value = userInput; } - TableGroupParser.PaintInventoryRowGroups(e.RowIndex - 1, inventoryDataGridView, projectionsDataGridView); //TODO:CHANGE .PaintRowGroupsFromIndex(e.RowIndex - 1, inventoryDataGridView); + if (TableGroupParser.PaintIneventory(inventoryDataGridView, + projectionsDataGridView, + e.RowIndex - 1)) + { + _isFormDirty = true; + } if (actualSalesDataGridView.RowCount > e.RowIndex) { actualSalesDataGridView.Rows[e.RowIndex].Cells[(int)TableGroupParser.SalesTableColumns.AdItem].Value = userInput; @@ -1884,7 +1896,10 @@ out double beginningBinCount, out string newBinText)) projectionsDataGridView.RefreshEdit(); inventoryDataGridView.RefreshEdit(); actualSalesDataGridView.RefreshEdit(); - TableGroupParser.PaintInventoryRowGroups(0, inventoryDataGridView, projectionsDataGridView); //TODO: CHANEG.PaintRowGroups(dataGridView); + if (TableGroupParser.PaintIneventory(inventoryDataGridView, projectionsDataGridView, 0)) + { + _isFormDirty = true; + } } #endregion @@ -2153,7 +2168,7 @@ out double beginningBinCount, out string newBinText)) Name = name, HeaderText = TextFormat.AddSpacesToSentence(name, false), ValueType = typeof(bool), - //Visible = false, + Visible = false, SortMode = DataGridViewColumnSortMode.NotSortable }; projectionsDataGridView.Columns.Add(column); @@ -3305,7 +3320,7 @@ out double beginningBinCount, out string newBinText)) //Force update all the data tables. //Paint the groups and check if the form should be marked as dirty. TableGroupParser.PaintRowGroups(projectionsDataGridView, 0, true); - TableGroupParser.PaintRowGroups(inventoryDataGridView, 0, true); + TableGroupParser.PaintIneventory(inventoryDataGridView, actualSalesDataGridView, 0, true); TableGroupParser.PaintRowGroups(actualSalesDataGridView, 0, true); using (var scope = new TransactionScope()) { diff --git a/AdvertsingProfitControl/Properties/AssemblyInfo.cs b/AdvertsingProfitControl/Properties/AssemblyInfo.cs index 6c6e9ec..a4b27c6 100644 --- a/AdvertsingProfitControl/Properties/AssemblyInfo.cs +++ b/AdvertsingProfitControl/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.2.0.0")] -[assembly: AssemblyFileVersion("3.2.0.0")] +[assembly: AssemblyVersion("3.3.0.0")] +[assembly: AssemblyFileVersion("3.3.0.0")] diff --git a/DataTableParsingEngine/Properties/AssemblyInfo.cs b/DataTableParsingEngine/Properties/AssemblyInfo.cs index 52c44a9..53ea4d4 100644 --- a/DataTableParsingEngine/Properties/AssemblyInfo.cs +++ b/DataTableParsingEngine/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.5.0.0")] -[assembly: AssemblyFileVersion("1.5.0.0")] +[assembly: AssemblyVersion("1.6.0.0")] +[assembly: AssemblyFileVersion("1.6.0.0")] diff --git a/DataTableParsingEngine/TableGroupParser.cs b/DataTableParsingEngine/TableGroupParser.cs index 8d80d6b..c7110d5 100644 --- a/DataTableParsingEngine/TableGroupParser.cs +++ b/DataTableParsingEngine/TableGroupParser.cs @@ -233,285 +233,215 @@ namespace DataTableParsingEngine return updatesOccured; } - public static void PaintInventoryRowGroups(int startingIndex, DataGridView inventoryDataGridView, - DataGridView masterDataGridView) + public static bool PaintIneventory(DataGridView inventoryDataGridView, DataGridView masterGridView, + int startingIndex, bool fullScan = false) { - var isHeaderColumn = (int)InventoryTableColumns.IsHeaderRow; - var isMemberColumn = (int)InventoryTableColumns.IsMemberRow; - var isDirtyColumn = (int)InventoryTableColumns.IsDirty; - var masterHeaderColumn = (int)SalesTableColumns.IsHeaderRow; - var masterMemberColumn = (int)SalesTableColumns.IsMemberRow; - var parser = new RowParser(); + var updatesOccured = false; + const int isHeaderColumn = (int)InventoryTableColumns.IsHeaderRow; + const int isMemberColumn = (int)InventoryTableColumns.IsMemberRow; + const int isDirtyColumn = (int)InventoryTableColumns.IsDirty; //Spin through the dataGridView rows starting at the row that fired the event. for (var i = startingIndex; i < (inventoryDataGridView.RowCount - 1); i++) { //Get the status of the current row. - var rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i]); - //IF the current row is a header row... - if (rowStatus == RowParser.RowAttribute.HeaderRow) + var masterCurrentRow = parser.GetRowAttribute(masterGridView.Rows[i]); + //var inventoryCurrentRow = parser.GetRowAttribute(inventoryDataGridView.Rows[i]); + //Get the previous row's status. + var masterPreviousRow = RowParser.RowAttribute.UnAssigned; + //var inventoryPreviousRow = RowParser.RowAttribute.UnAssigned; + if (i > 0) { - //Then check to see if the next row is a row header. - rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i + 1]); - //IF so, color code this row as White, since it is not a true group header. - if (rowStatus == RowParser.RowAttribute.HeaderRow) + masterPreviousRow = parser.GetRowAttribute(masterGridView.Rows[i - 1]); + //inventoryPreviousRow = parser.GetRowAttribute(inventoryDataGridView.Rows[i - 1]); + } + //Get the next row's attribute. + var masterNextRow = RowParser.RowAttribute.UnAssigned; + //var inventoryNextRow = RowParser.RowAttribute.UnAssigned; + if ((i + 1) < inventoryDataGridView.RowCount) + { + masterNextRow = parser.GetRowAttribute(masterGridView.Rows[i + 1]); + //inventoryNextRow = parser.GetRowAttribute(inventoryDataGridView.Rows[i + 1]); + } + //If current row is a header row... + if (masterCurrentRow == RowParser.RowAttribute.HeaderRow) + { + //...and the current row is index zero or the previous row is a header row + //then clear color coding from both. + if (masterPreviousRow == RowParser.RowAttribute.HeaderRow) { - //Clear the current row of its attributes. - inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false; - inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false; - inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color); - return; - } - //IF the current row is not the first row in the data grid (index zero)... - if (i > 0) - { - //The start by checking the previous row's status. - rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i - 1]); - //IF the previous row is a header row AND has color coding saying it is a group header, then clear the previous row's color and apply it to this row (i). - if (rowStatus == RowParser.RowAttribute.HeaderRow && (bool)masterDataGridView.Rows[i - 1].Cells[masterHeaderColumn].EditedFormattedValue) + //Check the previous row's attributes to see if it needs to be marked for updating. + if ((bool)inventoryDataGridView.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue || + (bool)inventoryDataGridView.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue) { - //Clear the previous row of its attributes. - inventoryDataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false; - inventoryDataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false; - //This condition means the user changed the members of a group, so the old header row needs to be updated in the database. + //The previous row had some attributes set, so mark the previous row for updating. inventoryDataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true; + updatesOccured = true; inventoryDataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit; inventoryDataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color); - //Check the next row to see if its a member row before declaring the current row a header row. - rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i + 1]); - if (rowStatus != RowParser.RowAttribute.MemberRow) + } + //Clear the previous row of its attributes. + inventoryDataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false; + inventoryDataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false; + //This condition means the user changed the members of a group, so the old header row needs to be updated in the database. + //Check the next row to see if its a member row before declaring the current row a header row. + if (masterNextRow == RowParser.RowAttribute.MemberRow)// && inventoryNextRow == RowParser.RowAttribute.MemberRow) + { + if (!(bool)inventoryDataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue || + (bool)inventoryDataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue) { - //Clear the coloring from the current row. - inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = true; - inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false; + //The current row had some attributes set, so mark the previous row for updating. + inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true; + updatesOccured = true; + inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit; inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color); - return; } //Set the current row as a header row. inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = true; inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false; inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.HeaderRow; - return; - } - //IF the previous row is a header row OR if the previous row is index zero AND a member row, clear its coloring. - if (rowStatus == RowParser.RowAttribute.HeaderRow || rowStatus == RowParser.RowAttribute.MemberRow && (i - 1) == 0) - { - //Set the current row and check for changes. - if ((bool)masterDataGridView.Rows[i - 1].Cells[masterMemberColumn].EditedFormattedValue) - { - inventoryDataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true; - inventoryDataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit; - } - //Clear the previous row of its attributes. - inventoryDataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false; - inventoryDataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false; - inventoryDataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color); - } - //Then check to see if the next row is a member row - rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i + 1]); - if (rowStatus == RowParser.RowAttribute.MemberRow) - { - //Set the current row and check for changes. - if (!(bool)masterDataGridView.Rows[i].Cells[masterHeaderColumn].EditedFormattedValue) - { - inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true; - inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit; - } - inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = true; - inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false; - inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.HeaderRow; - //Set the next row as a member row. - if (!(bool)masterDataGridView.Rows[i + 1].Cells[masterMemberColumn].EditedFormattedValue) + //Mark the next row as a member row. + if ((bool)inventoryDataGridView.Rows[i + 1].Cells[isHeaderColumn].EditedFormattedValue || + !(bool)inventoryDataGridView.Rows[i + 1].Cells[isMemberColumn].EditedFormattedValue) { + //The next row had some attributes set, so mark the previous row for updating. inventoryDataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true; + updatesOccured = true; inventoryDataGridView.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit; } inventoryDataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false; inventoryDataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true; inventoryDataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow; } + else + { + //If the current row is not a member row then clear the current row of any attributes it may have. + if ((bool)inventoryDataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue || + (bool)inventoryDataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue) + { + //The current row had some attributes set, so mark the previous row for updating. + inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true; + updatesOccured = true; + inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit; + } + //Clear the current row's attributes. + inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false; + inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false; + inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color); + if (!fullScan) return updatesOccured; + } } else { - //Then check to see if the next row is a member row - rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i + 1]); - if (rowStatus != RowParser.RowAttribute.MemberRow) continue; - //Set the current row and check for changes. - if (!(bool)masterDataGridView.Rows[i].Cells[masterHeaderColumn].EditedFormattedValue) + //Else if check to see if the previous row exists. + if (masterPreviousRow == RowParser.RowAttribute.UnAssigned) { + //This indicates that there is no previous row, so its safe to assume that + //we can simply continue on to the next row. + continue; + } + if (masterNextRow == RowParser.RowAttribute.MemberRow) + { + continue; + } + //If the current row is not a member row then clear the current row of any attributes it may have. + if ((bool)inventoryDataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue || + (bool)inventoryDataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue) + { + //The current row had some attributes set, so mark the previous row for updating. inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true; + updatesOccured = true; inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit; } - inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = true; + //Clear the current row's attributes. + inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false; inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false; - inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow; - //Set the next row as a member row. - if (!(bool)masterDataGridView.Rows[i + 1].Cells[masterMemberColumn].EditedFormattedValue) - { - inventoryDataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true; - inventoryDataGridView.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit; - } - inventoryDataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false; - inventoryDataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true; - inventoryDataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow; + inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color); + if (!fullScan) return updatesOccured; } } - else if (rowStatus == RowParser.RowAttribute.MemberRow) + if (masterCurrentRow == RowParser.RowAttribute.MemberRow)// && inventoryCurrentRow == RowParser.RowAttribute.MemberRow) { - if (i > 0) + //Check to see if the previous row is a header row. + if (masterPreviousRow == RowParser.RowAttribute.HeaderRow) { - //Check the previous row. - rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i - 1]); - //IF the previous row is a member row AND is the first row in the data grid, then remove the coloring from it and the current row (i). - if (rowStatus == RowParser.RowAttribute.MemberRow && (i - 1) == 0) + //Set the previous row as a header. + if (!(bool)inventoryDataGridView.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue || + (bool)inventoryDataGridView.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue) { - //Clear the previous row of its attributes. - if ((bool)masterDataGridView.Rows[i - 1].Cells[masterMemberColumn].EditedFormattedValue) - { - //And mark it as dirty if those attributes have been set for whatever reason. - inventoryDataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true; - inventoryDataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit; - } - inventoryDataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false; - inventoryDataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false; - inventoryDataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color); - //Check for changes in the current row. - if ((bool)masterDataGridView.Rows[i].Cells[masterMemberColumn].EditedFormattedValue) - { - inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true; - inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit; - } - //Clear the current row of its attributes. - inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false; - inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false; - inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color); - } - //IF the previous row is a member row AND it also has color coding suggesting that it is a member of a group, then add the current row (i) as well. - else if (rowStatus == RowParser.RowAttribute.MemberRow && (bool)masterDataGridView.Rows[i - 1].Cells[masterMemberColumn].EditedFormattedValue) - { - //Check for changes in the current row. - if (!(bool)masterDataGridView.Rows[i].Cells[masterMemberColumn].EditedFormattedValue) - { - inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true; - inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit; - } - //Set the current row as a member row. - inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false; - inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = true; - inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow; - } - //IF the previous row is simply a member row with no coloring at all, then remove the coloring from the current row (i). - else if (rowStatus == RowParser.RowAttribute.MemberRow || rowStatus == RowParser.RowAttribute.AdSpecialRow) - { - //Check for changes in the current row. - if ((bool)masterDataGridView.Rows[i].Cells[masterMemberColumn].EditedFormattedValue) - { - inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true; - inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit; - } - //Clear the current row of its attributes. - inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false; - inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false; - inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color); - } - //IF the previous row is a header row, then color it as a group header and color the current row as a member of said group. - else if (rowStatus == RowParser.RowAttribute.HeaderRow && !(bool)masterDataGridView.Rows[i - 1].Cells[masterHeaderColumn].EditedFormattedValue) - { - //Set the previous row as a header row. - if (!(bool)masterDataGridView.Rows[i - 1].Cells[masterMemberColumn].EditedFormattedValue) - { - inventoryDataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true; - inventoryDataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit; - } - inventoryDataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = true; - inventoryDataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false; - inventoryDataGridView.Rows[i - 1].DefaultCellStyle.BackColor = TableColors.HeaderRow; - //This condition means the user created a group so the newly made header row will need to be updated in the database as well. + //The current row had some attributes set, so mark the current row for updating. inventoryDataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true; + updatesOccured = true; inventoryDataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit; - //Check for changes in the current row. - if (!(bool)masterDataGridView.Rows[i].Cells[masterMemberColumn].EditedFormattedValue) + } + inventoryDataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = true; + inventoryDataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false; + inventoryDataGridView.Rows[i - 1].DefaultCellStyle.BackColor = TableColors.HeaderRow; + //Mark current row as member row. + if ((bool)inventoryDataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue || + !(bool)inventoryDataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue) + { + //The current row had some attributes set, so mark the current row for updating. + inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true; + updatesOccured = true; + inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit; + } + inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false; + inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = true; + inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow; + } + else if (masterPreviousRow == RowParser.RowAttribute.MemberRow) + { + //Check to see if the previous row is set as a member row. + if ((bool)inventoryDataGridView.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue) + { + //Assume that the current row is part of the group. + if ((bool)inventoryDataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue || + !(bool)inventoryDataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue) { + //The current row had some attributes set, so mark the current row for updating. inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true; + updatesOccured = true; inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit; } - //Set the current row as a member row. inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false; inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = true; inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow; } - else if (rowStatus == RowParser.RowAttribute.HeaderRow) + else { - //Check for changes in the current row. - if (!(bool)masterDataGridView.Rows[i].Cells[masterMemberColumn].EditedFormattedValue) + if ((bool)inventoryDataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue || + (bool)inventoryDataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue) { + //The current row had some attributes set, so mark the current row for updating. inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true; + updatesOccured = true; inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit; } - //Set the current row as a member row. inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false; - inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = true; - inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow; - } - //IF the previous row is incomplete, then call the stable PaintRowGroups function. - else if (rowStatus == RowParser.RowAttribute.IncompleteRow) - { - //PaintRowGroups(dataGridView); + inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false; + inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color); } } - //ELSE the current row is the first row in the data grid, therefore it can't be a member row so remove all coloring. else { - //Clear the current row of its attributes. - if (!(bool)masterDataGridView.Rows[0].Cells[masterMemberColumn].EditedFormattedValue) + if ((bool)inventoryDataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue || + (bool)inventoryDataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue) { - //If the row thinks that it's a member row then set it to dirty so the changes can be shown. - inventoryDataGridView.Rows[0].Cells[isDirtyColumn].Value = true; - inventoryDataGridView.Rows[0].HeaderCell.Style.BackColor = TableColors.PendingEdit; + //The current row had some attributes set, so mark the current row for updating. + inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true; + updatesOccured = true; + inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit; + inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color); } - inventoryDataGridView.Rows[0].Cells[isHeaderColumn].Value = false; - inventoryDataGridView.Rows[0].Cells[isMemberColumn].Value = false; - inventoryDataGridView.Rows[0].DefaultCellStyle.BackColor = default(Color); - } - } - else if (rowStatus == RowParser.RowAttribute.AdSpecialRow) - { - if (i == 0) return; - inventoryDataGridView.Rows[startingIndex].DefaultCellStyle.BackColor = TableColors.AdSpecial; - //Get the previous row's attribute. - rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i - 1]); - if (rowStatus == RowParser.RowAttribute.HeaderRow) - { - //Check to see if the previous row sees itself as a header row, if so mark it dirty. - if ((bool)masterDataGridView.Rows[i - 1].Cells[masterHeaderColumn].EditedFormattedValue) - { - inventoryDataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true; - inventoryDataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit; - } - //Clear its color coding. - inventoryDataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false; - inventoryDataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false; - inventoryDataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color); - } - //Next get the status of the next row. - rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i + 1]); - if (rowStatus == RowParser.RowAttribute.MemberRow) - { - //Check to see if the next row thinks it is a member row. - if (!(bool)masterDataGridView.Rows[i + 1].Cells[masterMemberColumn].EditedFormattedValue) - { - inventoryDataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true; - inventoryDataGridView.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit; - } - //Clear its color coding. - inventoryDataGridView.Rows[i + 1].Cells[isMemberColumn].Value = false; - inventoryDataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false; - inventoryDataGridView.Rows[i + 1].DefaultCellStyle.BackColor = default(Color); + inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false; + inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false; } } } - } + return updatesOccured; + } public enum SalesTableColumns {