Moved group table and row parsing into a separate DLL to clean up the main binary a bit. Added custom engine to detect for bin counts and updated the record form to total the bins for the user automatically. Updated the .gitignore file to include the necessary DLLs for the projects.
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Drawing;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
using DataTableParsingEngine;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
@@ -616,7 +617,7 @@ namespace AdvertsingProfitControl
|
||||
if (projectionsDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString() != "")
|
||||
{
|
||||
|
||||
var parser = new RowParsing();
|
||||
var parser = new RowParser();
|
||||
var rowContents = new string[11];
|
||||
//Check to make sure the user didn't simply leave a row that already exists.
|
||||
if (projectionsDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString() == actualSalesDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString())
|
||||
@@ -647,7 +648,7 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
_gLastAdItemEntered = projectionsDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString();
|
||||
//IF the current row is either a MemberRow OR an AdSpecialRow then only add the item in the first cell, place holder values are not needed.
|
||||
if (parser.GetRowAttribute(projectionsDataGridView.Rows[e.RowIndex]) == RowAttribute.MemberRow || parser.GetRowAttribute(projectionsDataGridView.Rows[e.RowIndex]) == RowAttribute.AdSpecialRow)
|
||||
if (parser.GetRowAttribute(projectionsDataGridView.Rows[e.RowIndex]) == RowParser.RowAttribute.MemberRow || parser.GetRowAttribute(projectionsDataGridView.Rows[e.RowIndex]) == RowParser.RowAttribute.AdSpecialRow)
|
||||
{
|
||||
rowContents[0] = projectionsDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString();
|
||||
actualSalesDataGridView.Rows.Add(rowContents);
|
||||
@@ -720,7 +721,7 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
if (actualSalesDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString() != "")
|
||||
{
|
||||
var parser = new RowParsing();
|
||||
var parser = new RowParser();
|
||||
object[] rowContents = new object[11];
|
||||
//Check to make sure the user didn't simply leave a row that already exists.
|
||||
if (projectionsDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString() == actualSalesDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString())
|
||||
@@ -750,7 +751,7 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
_gLastAdItemEntered = actualSalesDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString();
|
||||
//IF the current row is either a MemberRow OR an AdSpecialRow then only ad the item in the first cell, place holder values are not needed.
|
||||
if (parser.GetRowAttribute(actualSalesDataGridView.Rows[e.RowIndex]) == RowAttribute.MemberRow || parser.GetRowAttribute(actualSalesDataGridView.Rows[e.RowIndex]) == RowAttribute.AdSpecialRow)
|
||||
if (parser.GetRowAttribute(actualSalesDataGridView.Rows[e.RowIndex]) == RowParser.RowAttribute.MemberRow || parser.GetRowAttribute(actualSalesDataGridView.Rows[e.RowIndex]) == RowParser.RowAttribute.AdSpecialRow)
|
||||
{
|
||||
rowContents[0] = actualSalesDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString();
|
||||
projectionsDataGridView.Rows.Add(rowContents);
|
||||
@@ -917,9 +918,9 @@ namespace AdvertsingProfitControl
|
||||
/// <param name="dataGridView">A reference to the DataGridView that fired the event.</param>
|
||||
private void PaintRowsOnLeave(int startingIndex, DataGridView dataGridView)
|
||||
{
|
||||
var parser = new RowParsing();
|
||||
var parser = new RowParser();
|
||||
//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[0].EditedFormattedValue.ToString()) != "NoGroupFound")
|
||||
if (parser.GetRowAttribute(dataGridView.Rows[startingIndex]) != RowParser.RowAttribute.AdSpecialRow) ///TODo: check
|
||||
{
|
||||
_gAdSpecialIndex = startingIndex;
|
||||
dataGridView.Rows[startingIndex].DefaultCellStyle.BackColor = Color.Silver;
|
||||
@@ -931,13 +932,13 @@ namespace AdvertsingProfitControl
|
||||
//Get the status of the current row.
|
||||
var rowStatus = parser.GetRowAttribute(dataGridView.Rows[i]);
|
||||
//IF the current row is a header row...
|
||||
if (rowStatus == RowAttribute.HeaderRow)
|
||||
if (rowStatus == RowParser.RowAttribute.HeaderRow)
|
||||
{
|
||||
_gLastRowHeaderIndex = i;
|
||||
//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 != RowParser.RowAttribute.HeaderRow)
|
||||
{
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
}
|
||||
@@ -947,53 +948,53 @@ namespace AdvertsingProfitControl
|
||||
//The start by checking the previous row's status.
|
||||
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i - 1]);
|
||||
//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)
|
||||
if (rowStatus == RowParser.RowAttribute.HeaderRow || rowStatus == RowParser.RowAttribute.MemberRow && (i - 1) == 0)
|
||||
{
|
||||
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 its color and apply it to this row (i).
|
||||
else if (rowStatus == RowAttribute.HeaderRow && dataGridView.Rows[i - 1].DefaultCellStyle.BackColor == Color.LightGray)
|
||||
else if (rowStatus == RowParser.RowAttribute.HeaderRow && dataGridView.Rows[i - 1].DefaultCellStyle.BackColor == Color.LightGray)
|
||||
{
|
||||
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = Color.White;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
|
||||
}
|
||||
//IF previous row is Incomplete, then call the stable PaintRowGroups function.
|
||||
else if (rowStatus == RowAttribute.IncompleteRow)
|
||||
else if (rowStatus == RowParser.RowAttribute.IncompleteRow)
|
||||
{
|
||||
PaintRowGroups(dataGridView);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (rowStatus == RowAttribute.MemberRow)
|
||||
else if (rowStatus == RowParser.RowAttribute.MemberRow)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
//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 (rowStatus == RowAttribute.MemberRow && (i - 1) == 0)
|
||||
if (rowStatus == RowParser.RowAttribute.MemberRow && (i - 1) == 0)
|
||||
{
|
||||
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = Color.White;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
}
|
||||
//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 && dataGridView.Rows[i - 1].DefaultCellStyle.BackColor == Color.LightBlue)
|
||||
else if (rowStatus == RowParser.RowAttribute.MemberRow && dataGridView.Rows[i - 1].DefaultCellStyle.BackColor == Color.LightBlue)
|
||||
{
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
|
||||
}
|
||||
//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 == RowAttribute.MemberRow || rowStatus == RowAttribute.AdSpecialRow)
|
||||
else if (rowStatus == RowParser.RowAttribute.MemberRow || rowStatus == RowParser.RowAttribute.AdSpecialRow)
|
||||
{
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
}
|
||||
//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)
|
||||
else if (rowStatus == RowParser.RowAttribute.HeaderRow)
|
||||
{
|
||||
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = Color.LightGray;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
|
||||
}
|
||||
//IF the previous row is incomplete, then call the stable PaintRowGroups function.
|
||||
else if (rowStatus == RowAttribute.IncompleteRow)
|
||||
else if (rowStatus == RowParser.RowAttribute.IncompleteRow)
|
||||
{
|
||||
PaintRowGroups(dataGridView);
|
||||
}
|
||||
@@ -1009,7 +1010,7 @@ namespace AdvertsingProfitControl
|
||||
|
||||
private void PaintRowGroups(DataGridView dataGridView)
|
||||
{
|
||||
var parser = new RowParsing();
|
||||
var parser = new RowParser();
|
||||
var statusReport = "";
|
||||
var incompleteRowsFound = 0;
|
||||
var lastHeaderIndex = -1;
|
||||
@@ -1021,7 +1022,7 @@ namespace AdvertsingProfitControl
|
||||
//Get the current row's status.
|
||||
var rowType = parser.GetRowAttribute(row);
|
||||
//If the current row is not a group header, the first row in the grid, or a new row and in fact a member row...
|
||||
if (i != 0 && rowType == RowAttribute.MemberRow && !row.IsNewRow && rowType != RowAttribute.IncompleteRow)
|
||||
if (i != 0 && rowType == RowParser.RowAttribute.MemberRow && !row.IsNewRow && rowType != RowParser.RowAttribute.IncompleteRow)
|
||||
{
|
||||
//Remove all coloring on the current row.
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
@@ -1031,7 +1032,7 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
//Check to see if the previous row is a header row by subtracting the number of rows that are (incomplete + 1) from the total number of rows (i).
|
||||
//Adding one (1) to the incomplete count allows for checking the row right before the first incomplete row found so far to see if it's a header row.
|
||||
if (parser.GetRowAttribute(dataGridView.Rows[i - (1 + incompleteRowsFound)]) == RowAttribute.HeaderRow)
|
||||
if (parser.GetRowAttribute(dataGridView.Rows[i - (1 + incompleteRowsFound)]) == RowParser.RowAttribute.HeaderRow)
|
||||
{
|
||||
row.DefaultCellStyle.BackColor = Color.LightBlue; //Group member
|
||||
dataGridView.Rows[lastHeaderIndex].DefaultCellStyle.BackColor = Color.LightGray; //Group header
|
||||
@@ -1054,12 +1055,12 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
}
|
||||
//If the current row is a potential group header AND the next row is as well remove the coloring from the current row, no need for checks.
|
||||
else if (rowType == RowAttribute.HeaderRow && parser.GetRowAttribute(dataGridView.Rows[i + 1]) == RowAttribute.HeaderRow)
|
||||
else if (rowType == RowParser.RowAttribute.HeaderRow && parser.GetRowAttribute(dataGridView.Rows[i + 1]) == RowParser.RowAttribute.HeaderRow)
|
||||
{
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
}
|
||||
//Check to see if this row is the first row, a header index row, AND the next row is a MemberRow.
|
||||
else if (rowType == RowAttribute.HeaderRow && parser.GetRowAttribute(dataGridView.Rows[i + 1]) == RowAttribute.MemberRow && i == 0)
|
||||
else if (rowType == RowParser.RowAttribute.HeaderRow && parser.GetRowAttribute(dataGridView.Rows[i + 1]) == RowParser.RowAttribute.MemberRow && i == 0)
|
||||
{
|
||||
//IF so, set the last header index, and color code of this row along with the next row which is a MemberRow.
|
||||
lastHeaderIndex = 0;
|
||||
@@ -1069,7 +1070,7 @@ namespace AdvertsingProfitControl
|
||||
$"Group {groupCount} created with the header row 1 and the following row member(s): {(i + 2)}";
|
||||
}
|
||||
//Check to see if this row is a group header.
|
||||
else if (rowType == RowAttribute.HeaderRow)
|
||||
else if (rowType == RowParser.RowAttribute.HeaderRow)
|
||||
{
|
||||
//If so, reset the incomplete rows found count, set the lastHeaderIndex to this row's index (i) and change it's color to white.
|
||||
incompleteRowsFound = 0;
|
||||
@@ -1077,12 +1078,12 @@ namespace AdvertsingProfitControl
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
}
|
||||
//If the current row is the first row in the grid AND is not a group header then remove all color from it, since its not allowed to be a header or a member.
|
||||
else if (i == 0 && rowType == RowAttribute.MemberRow)
|
||||
else if (i == 0 && rowType == RowParser.RowAttribute.MemberRow)
|
||||
{
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
}
|
||||
//Mark an incomplete row to determine whether or not we found one and remove any coloring it may have, incomplete rows are not allowed to be members or headers.
|
||||
if (rowType == RowAttribute.IncompleteRow)
|
||||
if (rowType == RowParser.RowAttribute.IncompleteRow)
|
||||
{
|
||||
incompleteRowsFound++;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
|
||||
Reference in New Issue
Block a user