Cleaned up the table trimming methods. Group creation now proper marks rows as dirty when row attribute changes. Projections table processes successfully on the new modify record form.

This commit is contained in:
2017-01-20 22:46:48 -06:00
parent 9fa2e3c44a
commit 43bf07c212
10 changed files with 651 additions and 245 deletions
@@ -19,15 +19,18 @@ namespace AdvertsingProfitControl
var parser = new RowParsing();
int isHeaderColumn;
int isMemberColumn;
int isDirtyColumn;
if (dataGridView.Columns.Count == Enum.GetNames(typeof(SalesTableColumns)).Length)
{
isHeaderColumn = (int) SalesTableColumns.IsHeaderRow;
isMemberColumn = (int) SalesTableColumns.IsMemberRow;
isDirtyColumn = (int) SalesTableColumns.IsDirty;
}
else
{
isHeaderColumn = (int)InventoryTableColumns.IsHeaderRow;
isMemberColumn = (int)InventoryTableColumns.IsMemberRow;
isDirtyColumn = (int) InventoryTableColumns.IsDirty;
}
//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")
@@ -46,19 +49,35 @@ namespace AdvertsingProfitControl
//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 != RowAttribute.HeaderRow)
if (rowStatus == 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 = Color.White;
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 == RowAttribute.HeaderRow && (bool)dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value)
{
//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 = ApplicationColors.PendingEdit;
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = Color.White;
//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 = Color.LightGray;
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 == RowAttribute.HeaderRow || rowStatus == RowAttribute.MemberRow && (i - 1) == 0)
{
@@ -67,18 +86,6 @@ namespace AdvertsingProfitControl
dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = Color.White;
}
//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).
else if (rowStatus == RowAttribute.HeaderRow && (bool)dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value)
{
//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 = Color.White;
//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 = Color.LightGray;
}
//IF previous row is Incomplete, then call the stable PaintRowGroups function.
else if (rowStatus == RowAttribute.IncompleteRow)
{
@@ -108,7 +115,7 @@ namespace AdvertsingProfitControl
{
//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 for it and the current row (i).
//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 == RowAttribute.MemberRow && (i - 1) == 0)
{
//Clear the previous row of its attributes.
@@ -119,9 +126,10 @@ namespace AdvertsingProfitControl
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
return;
}
//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 == RowAttribute.MemberRow && (bool)dataGridView.Rows[i - 1].Cells[isMemberColumn].Value)
if (rowStatus == RowAttribute.MemberRow && (bool)dataGridView.Rows[i - 1].Cells[isMemberColumn].Value)
{
//Set the current row as a member row.
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
@@ -135,6 +143,7 @@ namespace AdvertsingProfitControl
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
return;
}
//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 == RowAttribute.HeaderRow)
@@ -143,6 +152,9 @@ namespace AdvertsingProfitControl
dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = true;
dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = Color.LightGray;
//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 = ApplicationColors.PendingEdit;
//Set the current row as a member row.
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i].Cells[isMemberColumn].Value = true;