First stages of a new logging system being put in place. Updated the group parsing engine for the Projections and Actual Sales tables, and removed the method. Fixed the issue where changes to groups didn't mark the record manipulation form as dirty.
This commit is contained in:
@@ -12,303 +12,225 @@ namespace DataTableParsingEngine
|
||||
/// fired the row leave even. As opposed to the PaintRowGroups function which spins through all the
|
||||
/// DataGridView's rows.
|
||||
/// </summary>
|
||||
/// <param name="table">The DataGridView to parse.</param>
|
||||
/// <param name="startingIndex">The starting index (the row that fired the RowLeave event)</param>
|
||||
/// <param name="dataGridView">The DataGridView to parse.</param>
|
||||
public static void PaintRowGroupsFromIndex(int startingIndex, DataGridView dataGridView)
|
||||
/// <param name="fullScan">True to force a full scan of all rows beginning at the starting index.</param>
|
||||
public static bool PaintRowGroups(DataGridView table, int startingIndex, bool fullScan = false)
|
||||
{
|
||||
//Underflow protection for the lazy.
|
||||
if (startingIndex < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var parser = new RowParser();
|
||||
var isHeaderColumn = (int)SalesTableColumns.IsHeaderRow;
|
||||
var isMemberColumn = (int)SalesTableColumns.IsMemberRow;
|
||||
var isDirtyColumn = (int)SalesTableColumns.IsDirty;
|
||||
if (dataGridView.ColumnCount < Enum.GetNames(typeof(SalesTableColumns)).Length)
|
||||
var isHeaderColumn = (int) SalesTableColumns.IsHeaderRow;
|
||||
var isMemberColumn = (int) SalesTableColumns.IsMemberRow;
|
||||
var isDirtyColumn = (int) SalesTableColumns.IsDirty;
|
||||
var updatesOccured = false;
|
||||
if (table.ColumnCount < Enum.GetNames(typeof(SalesTableColumns)).Length)
|
||||
{
|
||||
isHeaderColumn = (int)InventoryTableColumns.IsHeaderRow;
|
||||
isMemberColumn = (int)InventoryTableColumns.IsMemberRow;
|
||||
isDirtyColumn = (int)InventoryTableColumns.IsDirty;
|
||||
isHeaderColumn = (int) InventoryTableColumns.IsHeaderRow;
|
||||
isMemberColumn = (int) InventoryTableColumns.IsMemberRow;
|
||||
isDirtyColumn = (int) InventoryTableColumns.IsDirty;
|
||||
}
|
||||
//Spin through the dataGridView rows starting at the row that fired the event.
|
||||
for (var i = startingIndex; i < (dataGridView.RowCount - 1); i++)
|
||||
for (var i = startingIndex; i < (table.RowCount - 1); i++)
|
||||
{
|
||||
//Get the status of the current row.
|
||||
var rowStatus = parser.GetRowAttribute(dataGridView.Rows[i]);
|
||||
//IF the current row is a header row...
|
||||
if (rowStatus == RowParser.RowAttribute.HeaderRow)
|
||||
var currentRowAttribute = parser.GetRowAttribute(table.Rows[i]);
|
||||
//Get the previous row's status.
|
||||
var previousRow = RowParser.RowAttribute.UnAssigned;
|
||||
if (i > 0)
|
||||
{
|
||||
//Then check to see if the next row is a row header.
|
||||
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
|
||||
//IF so, color code this row as White, since it is not a true group header.
|
||||
if (rowStatus == RowParser.RowAttribute.HeaderRow)
|
||||
previousRow = parser.GetRowAttribute(table.Rows[i - 1]);
|
||||
}
|
||||
//Get the next row's attribute.
|
||||
var nextRow = RowParser.RowAttribute.UnAssigned;
|
||||
if ((i + 1) < table.RowCount)
|
||||
{
|
||||
nextRow = parser.GetRowAttribute(table.Rows[i + 1]);
|
||||
}
|
||||
//If current row is a header row...
|
||||
if (currentRowAttribute == 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 (previousRow == RowParser.RowAttribute.HeaderRow)
|
||||
{
|
||||
//Clear the current row of its attributes.
|
||||
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.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(dataGridView.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)dataGridView.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue)
|
||||
//Check the previous row's attributes to see if it needs to be marked for updating.
|
||||
if ((bool) table.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue ||
|
||||
(bool) table.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
//Clear the previous row of its attributes.
|
||||
dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.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.
|
||||
dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
dataGridView.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(dataGridView.Rows[i + 1]);
|
||||
if (rowStatus != RowParser.RowAttribute.MemberRow)
|
||||
//The previous row had some attributes set, so mark the previous row for updating.
|
||||
table.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
updatesOccured = true;
|
||||
table.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
table.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
//Clear the previous row of its attributes.
|
||||
table.Rows[i - 1].Cells[isHeaderColumn].Value = false;
|
||||
table.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 (nextRow == RowParser.RowAttribute.MemberRow)
|
||||
{
|
||||
if (!(bool)table.Rows[i].Cells[isHeaderColumn].EditedFormattedValue ||
|
||||
(bool) table.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
//Clear the coloring from the current row.
|
||||
dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
|
||||
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
return;
|
||||
//The current row had some attributes set, so mark the previous row for updating.
|
||||
table.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
updatesOccured = true;
|
||||
table.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
table.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
//Set the current row as a header row.
|
||||
dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
|
||||
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.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)dataGridView.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
|
||||
table.Rows[i].Cells[isHeaderColumn].Value = true;
|
||||
table.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
table.Rows[i].DefaultCellStyle.BackColor = TableColors.HeaderRow;
|
||||
//Mark the next row as a member row.
|
||||
if ((bool) table.Rows[i + 1].Cells[isHeaderColumn].EditedFormattedValue ||
|
||||
!(bool)table.Rows[i + 1].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
//The next row had some attributes set, so mark the previous row for updating.
|
||||
table.Rows[i + 1].Cells[isDirtyColumn].Value = true;
|
||||
updatesOccured = true;
|
||||
table.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
table.Rows[i + 1].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
//Clear the previous row of its attributes.
|
||||
dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
|
||||
|
||||
table.Rows[i + 1].Cells[isHeaderColumn].Value = false;
|
||||
table.Rows[i + 1].Cells[isMemberColumn].Value = true;
|
||||
table.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
//Then check to see if the next row is a member row
|
||||
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
|
||||
if (rowStatus == RowParser.RowAttribute.MemberRow)
|
||||
else
|
||||
{
|
||||
//Set the current row and check for changes.
|
||||
if (!(bool)dataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue)
|
||||
//If the current row is not a member row then clear the current row of any attributes it may have.
|
||||
if ((bool) table.Rows[i].Cells[isHeaderColumn].EditedFormattedValue ||
|
||||
(bool) table.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
//The current row had some attributes set, so mark the previous row for updating.
|
||||
table.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
updatesOccured = true;
|
||||
table.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
table.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
|
||||
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.HeaderRow;
|
||||
//Set the next row as a member row.
|
||||
if (!(bool)dataGridView.Rows[i + 1].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
dataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
dataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true;
|
||||
dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
//IF previous row is Incomplete, then call the stable PaintRowGroups function.
|
||||
else if (rowStatus == RowParser.RowAttribute.IncompleteRow)
|
||||
{
|
||||
//PaintRowGroups(dataGridView);
|
||||
//Clear the current row's attributes.
|
||||
table.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
table.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
table.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(dataGridView.Rows[i + 1]);
|
||||
if (rowStatus != RowParser.RowAttribute.MemberRow) continue;
|
||||
//Set the current row and check for changes.
|
||||
if (!(bool)dataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue)
|
||||
//Else if check to see if the previous row exists.
|
||||
if (previousRow == RowParser.RowAttribute.UnAssigned)
|
||||
{
|
||||
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
//This indicates that there is no previous row, so its safe to assume that
|
||||
//we can simply continue on to the next row.
|
||||
continue;
|
||||
}
|
||||
dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
|
||||
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
//Set the next row as a member row.
|
||||
if (!(bool)dataGridView.Rows[i + 1].Cells[isMemberColumn].EditedFormattedValue)
|
||||
if (nextRow == RowParser.RowAttribute.MemberRow)
|
||||
{
|
||||
dataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
continue;
|
||||
}
|
||||
dataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true;
|
||||
dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
//If the current row is not a member row then clear the current row of any attributes it may have.
|
||||
if ((bool)table.Rows[i].Cells[isHeaderColumn].EditedFormattedValue ||
|
||||
(bool)table.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
//The current row had some attributes set, so mark the previous row for updating.
|
||||
table.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
updatesOccured = true;
|
||||
table.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
table.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
//Clear the current row's attributes.
|
||||
table.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
table.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
table.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
if(!fullScan) return updatesOccured;
|
||||
}
|
||||
}
|
||||
else if (rowStatus == RowParser.RowAttribute.MemberRow)
|
||||
if (currentRowAttribute == RowParser.RowAttribute.MemberRow)
|
||||
{
|
||||
if (i > 0)
|
||||
//Check to see if the previous row is a header row.
|
||||
if (previousRow == RowParser.RowAttribute.HeaderRow)
|
||||
{
|
||||
//Check the previous row.
|
||||
rowStatus = parser.GetRowAttribute(dataGridView.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)table.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue ||
|
||||
(bool)table.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
//Clear the previous row of its attributes.
|
||||
if ((bool)dataGridView.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
//And mark it as dirty if those attributes have been set for whatever reason.
|
||||
dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
|
||||
//Check for changes in the current row.
|
||||
if ((bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
//Clear the current row of its attributes.
|
||||
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
//The current row had some attributes set, so mark the current row for updating.
|
||||
table.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
updatesOccured = true;
|
||||
table.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
table.Rows[i - 1].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)dataGridView.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
|
||||
table.Rows[i - 1].Cells[isHeaderColumn].Value = true;
|
||||
table.Rows[i - 1].Cells[isMemberColumn].Value = false;
|
||||
table.Rows[i - 1].DefaultCellStyle.BackColor = TableColors.HeaderRow;
|
||||
//Mark current row as member row.
|
||||
if ((bool)table.Rows[i].Cells[isHeaderColumn].EditedFormattedValue ||
|
||||
!(bool)table.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
//Check for changes in the current row.
|
||||
if (!(bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
//Set the current row as a member row.
|
||||
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i].Cells[isMemberColumn].Value = true;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
//The current row had some attributes set, so mark the current row for updating.
|
||||
table.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
updatesOccured = true;
|
||||
table.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
table.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
//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)
|
||||
table.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
table.Rows[i].Cells[isMemberColumn].Value = true;
|
||||
table.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
else if (previousRow == RowParser.RowAttribute.MemberRow)
|
||||
{
|
||||
//Check to see if the previous row is set as a member row.
|
||||
if ((bool) table.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
//Check for changes in the current row.
|
||||
if ((bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
|
||||
//Assume that the current row is part of the group.
|
||||
if ((bool) table.Rows[i].Cells[isHeaderColumn].EditedFormattedValue ||
|
||||
!(bool) table.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
//The current row had some attributes set, so mark the current row for updating.
|
||||
table.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
updatesOccured = true;
|
||||
table.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
table.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
//Clear the current row of its attributes.
|
||||
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
table.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
table.Rows[i].Cells[isMemberColumn].Value = true;
|
||||
table.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
//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)dataGridView.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue)
|
||||
else
|
||||
{
|
||||
//Set the previous row as a header row.
|
||||
if (!(bool)dataGridView.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
|
||||
if ((bool)table.Rows[i].Cells[isHeaderColumn].EditedFormattedValue ||
|
||||
(bool)table.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
//The current row had some attributes set, so mark the current row for updating.
|
||||
table.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
updatesOccured = true;
|
||||
table.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
table.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = true;
|
||||
dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.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.
|
||||
dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
//Check for changes in the current row.
|
||||
if (!(bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
//Set the current row as a member row.
|
||||
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i].Cells[isMemberColumn].Value = true;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
else if (rowStatus == RowParser.RowAttribute.HeaderRow)
|
||||
{
|
||||
//Check for changes in the current row.
|
||||
if (!(bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
//Set the current row as a member row.
|
||||
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i].Cells[isMemberColumn].Value = true;
|
||||
dataGridView.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);
|
||||
table.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
table.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
table.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)dataGridView.Rows[0].Cells[isMemberColumn].EditedFormattedValue)
|
||||
if ((bool)table.Rows[i].Cells[isHeaderColumn].EditedFormattedValue ||
|
||||
(bool)table.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.
|
||||
dataGridView.Rows[0].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[0].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
//The current row had some attributes set, so mark the current row for updating.
|
||||
table.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
updatesOccured = true;
|
||||
table.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
table.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
dataGridView.Rows[0].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[0].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[0].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
}
|
||||
else if (rowStatus == RowParser.RowAttribute.AdSpecialRow)
|
||||
{
|
||||
if (i == 0) return;
|
||||
dataGridView.Rows[startingIndex].DefaultCellStyle.BackColor = TableColors.AdSpecial;
|
||||
//Get the previous row's attribute.
|
||||
rowStatus = parser.GetRowAttribute(dataGridView.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)dataGridView.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue)
|
||||
{
|
||||
dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
//Clear its color coding.
|
||||
dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
//Next get the status of the next row.
|
||||
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
|
||||
if (rowStatus == RowParser.RowAttribute.MemberRow)
|
||||
{
|
||||
//Check to see if the next row thinks it is a member row.
|
||||
if (!(bool)dataGridView.Rows[i + 1].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
dataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
//Clear its color coding.
|
||||
dataGridView.Rows[i + 1].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = default(Color);
|
||||
table.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
table.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void PaintRowGroups(DataGridView table)
|
||||
{
|
||||
|
||||
return updatesOccured;
|
||||
}
|
||||
|
||||
public static void PaintInventoryRowGroups(int startingIndex, DataGridView inventoryDataGridView,
|
||||
@@ -408,11 +330,6 @@ namespace DataTableParsingEngine
|
||||
inventoryDataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
//IF previous row is Incomplete, then call the stable PaintRowGroups function.
|
||||
else if (rowStatus == RowParser.RowAttribute.IncompleteRow)
|
||||
{
|
||||
//PaintRowGroups(dataGridView);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user