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:
@@ -1 +1,10 @@
|
||||
!*.dll
|
||||
packages/
|
||||
AdvertisingProfitControlData/bin
|
||||
AdvertisingProfitControlData/obj
|
||||
AdvertsingProfitControl/bin
|
||||
AdvertsingProfitControl/obj
|
||||
DataTableParsingEngine/bin
|
||||
DataTableParsingEngine/obj
|
||||
SetupProject/bin
|
||||
SetupProject/obj
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26228.4
|
||||
VisualStudioVersion = 15.0.26403.3
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvertsingProfitControl", "AdvertsingProfitControl\AdvertsingProfitControl.csproj", "{4A45C665-5D02-4724-9CC5-C0C50CA44760}"
|
||||
EndProject
|
||||
@@ -9,6 +9,8 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "SetupProject", "SetupProjec
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvertisingProfitControlData", "AdvertisingProfitControlData\AdvertisingProfitControlData.csproj", "{E30F8B0E-DFF3-4AB7-8D0C-47BD11164E51}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataTableParsingEngine", "DataTableParsingEngine\DataTableParsingEngine.csproj", "{63CE4D0A-1F70-4692-B895-073A9B3AF5F2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -39,6 +41,14 @@ Global
|
||||
{E30F8B0E-DFF3-4AB7-8D0C-47BD11164E51}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E30F8B0E-DFF3-4AB7-8D0C-47BD11164E51}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{E30F8B0E-DFF3-4AB7-8D0C-47BD11164E51}.Release|x86.Build.0 = Release|Any CPU
|
||||
{63CE4D0A-1F70-4692-B895-073A9B3AF5F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{63CE4D0A-1F70-4692-B895-073A9B3AF5F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{63CE4D0A-1F70-4692-B895-073A9B3AF5F2}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{63CE4D0A-1F70-4692-B895-073A9B3AF5F2}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{63CE4D0A-1F70-4692-B895-073A9B3AF5F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{63CE4D0A-1F70-4692-B895-073A9B3AF5F2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{63CE4D0A-1F70-4692-B895-073A9B3AF5F2}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{63CE4D0A-1F70-4692-B895-073A9B3AF5F2}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -125,8 +125,6 @@
|
||||
<Compile Include="AboutBox.Designer.cs">
|
||||
<DependentUpon>AboutBox.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="AdvertisingProfitControlTableHelper.cs" />
|
||||
<Compile Include="ApplicationColors.cs" />
|
||||
<Compile Include="DatabaseRecovery.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -210,7 +208,6 @@
|
||||
<Compile Include="FrmLogConsole.Designer.cs">
|
||||
<DependentUpon>FrmLogConsole.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="RowParsing.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="AboutBox.resx">
|
||||
@@ -316,6 +313,10 @@
|
||||
<Project>{e30f8b0e-dff3-4ab7-8d0c-47bd11164e51}</Project>
|
||||
<Name>AdvertisingProfitControlData</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DataTableParsingEngine\DataTableParsingEngine.csproj">
|
||||
<Project>{63ce4d0a-1f70-4692-b895-073a9b3af5f2}</Project>
|
||||
<Name>DataTableParsingEngine</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -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;
|
||||
|
||||
+12
-22
@@ -40,6 +40,7 @@
|
||||
this.generateReportMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.backupRestoreToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.clearRecordToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.clearCurrentRecordSelectedDateToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.clearCurrentActiveYearTools = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -52,7 +53,6 @@
|
||||
this.examineLogsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.debugMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.rawViewDebugMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.migrateDatabaseDebugMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.addRecordToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.testToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mainTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||
@@ -112,7 +112,6 @@
|
||||
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel = new System.Windows.Forms.Label();
|
||||
this.perfectGrossProfitLabel = new System.Windows.Forms.Label();
|
||||
this.grossProfitDollarGrossProfitLabel = new System.Windows.Forms.Label();
|
||||
this.backupRestoreToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mainMenu.SuspendLayout();
|
||||
this.mainTableLayoutPanel.SuspendLayout();
|
||||
this.commentMainTableLayoutPanel.SuspendLayout();
|
||||
@@ -177,7 +176,7 @@
|
||||
// exitFileMainMenu
|
||||
//
|
||||
this.exitFileMainMenu.Name = "exitFileMainMenu";
|
||||
this.exitFileMainMenu.Size = new System.Drawing.Size(240, 34);
|
||||
this.exitFileMainMenu.Size = new System.Drawing.Size(138, 34);
|
||||
this.exitFileMainMenu.Text = "E&xit";
|
||||
this.exitFileMainMenu.Click += new System.EventHandler(this.ExitProgram);
|
||||
//
|
||||
@@ -239,6 +238,13 @@
|
||||
this.toolsMainMenu.Size = new System.Drawing.Size(72, 34);
|
||||
this.toolsMainMenu.Text = "&Tools";
|
||||
//
|
||||
// backupRestoreToolsMainMenu
|
||||
//
|
||||
this.backupRestoreToolsMainMenu.Name = "backupRestoreToolsMainMenu";
|
||||
this.backupRestoreToolsMainMenu.Size = new System.Drawing.Size(282, 34);
|
||||
this.backupRestoreToolsMainMenu.Text = "&Database Backup";
|
||||
this.backupRestoreToolsMainMenu.Click += new System.EventHandler(this.DisplayDatabaseRecoveryFormOnBackupRestoreClick);
|
||||
//
|
||||
// clearRecordToolsMainMenu
|
||||
//
|
||||
this.clearRecordToolsMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
@@ -318,7 +324,6 @@
|
||||
//
|
||||
this.debugMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.rawViewDebugMainMenu,
|
||||
this.migrateDatabaseDebugMainMenu,
|
||||
this.addRecordToolStripMenuItem,
|
||||
this.testToolStripMenuItem});
|
||||
this.debugMainMenu.Name = "debugMainMenu";
|
||||
@@ -329,28 +334,21 @@
|
||||
// rawViewDebugMainMenu
|
||||
//
|
||||
this.rawViewDebugMainMenu.Name = "rawViewDebugMainMenu";
|
||||
this.rawViewDebugMainMenu.Size = new System.Drawing.Size(270, 34);
|
||||
this.rawViewDebugMainMenu.Size = new System.Drawing.Size(240, 34);
|
||||
this.rawViewDebugMainMenu.Text = "Ra&w View";
|
||||
this.rawViewDebugMainMenu.Click += new System.EventHandler(this.DisplayRawDatabaseView);
|
||||
//
|
||||
// migrateDatabaseDebugMainMenu
|
||||
//
|
||||
this.migrateDatabaseDebugMainMenu.Name = "migrateDatabaseDebugMainMenu";
|
||||
this.migrateDatabaseDebugMainMenu.Size = new System.Drawing.Size(270, 34);
|
||||
this.migrateDatabaseDebugMainMenu.Text = "&Migrate Database";
|
||||
this.migrateDatabaseDebugMainMenu.Click += new System.EventHandler(this.DisplayDebugTool);
|
||||
//
|
||||
// addRecordToolStripMenuItem
|
||||
//
|
||||
this.addRecordToolStripMenuItem.Name = "addRecordToolStripMenuItem";
|
||||
this.addRecordToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
|
||||
this.addRecordToolStripMenuItem.Size = new System.Drawing.Size(240, 34);
|
||||
this.addRecordToolStripMenuItem.Text = "Add Re&cord";
|
||||
this.addRecordToolStripMenuItem.Click += new System.EventHandler(this.DisplayLegacyAddRecord);
|
||||
//
|
||||
// testToolStripMenuItem
|
||||
//
|
||||
this.testToolStripMenuItem.Name = "testToolStripMenuItem";
|
||||
this.testToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
|
||||
this.testToolStripMenuItem.Size = new System.Drawing.Size(240, 34);
|
||||
this.testToolStripMenuItem.Text = "Test";
|
||||
this.testToolStripMenuItem.Click += new System.EventHandler(this.testToolStripMenuItem_Click);
|
||||
//
|
||||
@@ -1017,13 +1015,6 @@
|
||||
this.grossProfitDollarGrossProfitLabel.TabIndex = 2;
|
||||
this.grossProfitDollarGrossProfitLabel.Text = "Dollar Gross Profit: ";
|
||||
//
|
||||
// backupRestoreToolsMainMenu
|
||||
//
|
||||
this.backupRestoreToolsMainMenu.Name = "backupRestoreToolsMainMenu";
|
||||
this.backupRestoreToolsMainMenu.Size = new System.Drawing.Size(282, 34);
|
||||
this.backupRestoreToolsMainMenu.Text = "&Database Backup";
|
||||
this.backupRestoreToolsMainMenu.Click += new System.EventHandler(this.DisplayDatabaseRecoveryFormOnBackupRestoreClick);
|
||||
//
|
||||
// FrmMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F);
|
||||
@@ -1143,7 +1134,6 @@
|
||||
private System.Windows.Forms.TabPage suppliersTabPage;
|
||||
private System.Windows.Forms.DataGridView invoicesDataGridView;
|
||||
private System.Windows.Forms.ToolStripMenuItem debugMainMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem migrateDatabaseDebugMainMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem clearRecordToolsMainMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem addRecordToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem rawViewDebugMainMenu;
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Transactions;
|
||||
using System.Windows.Forms;
|
||||
using AdvertisingProfitControlData;
|
||||
using DataTableParsingEngine;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
@@ -27,11 +28,12 @@ namespace AdvertsingProfitControl
|
||||
|
||||
private void frmMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
//Load the ad special groups into the row parser class.
|
||||
RowParser.BuildAdSpecialListings();
|
||||
var db = new AdvertisingProfitControlDbContext();
|
||||
RefreshDateListing();
|
||||
ConstructApcDataGridViews();
|
||||
ConstructInvoicesDataGridView();
|
||||
RowParsing.AdSpecialGroups.AddRange(db.AdSpecials.Select(x => x.Name));
|
||||
//Select the most recent date from the database.
|
||||
var recentDate = db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault();
|
||||
if (recentDate != null)
|
||||
@@ -265,6 +267,8 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
var form = new FrmRegisterAdSpecial();
|
||||
form.ShowDialog();
|
||||
//Load any changes to the ad special groups into the row parser class.
|
||||
RowParser.BuildAdSpecialListings();
|
||||
}
|
||||
|
||||
private void ShowHideLogConsole(object sender, EventArgs e)
|
||||
@@ -511,18 +515,18 @@ namespace AdvertsingProfitControl
|
||||
if (p.TotalProfitReturn != null) totalProfitReturn += (decimal)p.TotalProfitReturn;
|
||||
if (p.RowAttribute == 1)
|
||||
{
|
||||
projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
|
||||
projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = TableColors.HeaderRow;
|
||||
}
|
||||
else if (p.RowAttribute == 2)
|
||||
{
|
||||
projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
|
||||
projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
|
||||
if (p.FkAdSpecialId == null || adSpecialIndex != -1) continue;
|
||||
//TODO: Fix null reference when no object is found.
|
||||
adSpecialIndex = index;
|
||||
projectionsDataGridView.Rows.Insert(index, 1);
|
||||
projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
|
||||
projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = TableColors.AdSpecial;
|
||||
projectionsDataGridView.Rows[index].Cells[3].Value = db.AdSpecials.Single(x => x.Id == p.FkAdSpecialId).Name;
|
||||
}
|
||||
//Now add the totals row.
|
||||
@@ -565,17 +569,17 @@ namespace AdvertsingProfitControl
|
||||
inventoryDataGridView.Rows[index].Cells[4].Value = i.EndingInventory;
|
||||
if (i.RowAttribute == 1)
|
||||
{
|
||||
inventoryDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
|
||||
inventoryDataGridView.Rows[index].DefaultCellStyle.BackColor = TableColors.HeaderRow;
|
||||
}
|
||||
else if (i.RowAttribute == 2)
|
||||
{
|
||||
inventoryDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
|
||||
inventoryDataGridView.Rows[index].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
|
||||
if (i.FkAdSpecialId == null || adSpecialIndex != -1) continue;
|
||||
adSpecialIndex = index;
|
||||
inventoryDataGridView.Rows.Insert(index, 1);
|
||||
inventoryDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
|
||||
inventoryDataGridView.Rows[index].DefaultCellStyle.BackColor = TableColors.AdSpecial;
|
||||
inventoryDataGridView.Rows[index].Cells[2].Value = db.AdSpecials.Single(x => x.Id == i.FkAdSpecialId).Name;
|
||||
}
|
||||
}
|
||||
@@ -603,17 +607,17 @@ namespace AdvertsingProfitControl
|
||||
if (a.TotalProfitReturn != null) totalProfitReturn += (decimal)a.TotalProfitReturn;
|
||||
if (a.RowAttribute == 1)
|
||||
{
|
||||
actualSalesDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
|
||||
actualSalesDataGridView.Rows[index].DefaultCellStyle.BackColor = TableColors.HeaderRow;
|
||||
}
|
||||
else if (a.RowAttribute == 2)
|
||||
{
|
||||
actualSalesDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
|
||||
actualSalesDataGridView.Rows[index].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
|
||||
if (a.FkAdSpecialId == null || adSpecialIndex != -1) continue;
|
||||
adSpecialIndex = index;
|
||||
actualSalesDataGridView.Rows.Insert(index, 1);
|
||||
actualSalesDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
|
||||
actualSalesDataGridView.Rows[index].DefaultCellStyle.BackColor = TableColors.AdSpecial;
|
||||
actualSalesDataGridView.Rows[index].Cells[3].Value = db.AdSpecials.Single(x => x.Id == a.FkAdSpecialId).Name;
|
||||
}
|
||||
//Now add the totals row.
|
||||
@@ -911,11 +915,6 @@ namespace AdvertsingProfitControl
|
||||
|
||||
#region Debug Tool Menu Items
|
||||
|
||||
private void DisplayDebugTool(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the legacy Add Record form. Completely for looks.
|
||||
/// </summary>
|
||||
|
||||
+9
-9
@@ -36,6 +36,7 @@
|
||||
this.editMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.createNewRecordEditMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.helpMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.showConsoleHelpMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.examineLogsHelpMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mainTabControl = new System.Windows.Forms.TabControl();
|
||||
this.projectionTabPage = new System.Windows.Forms.TabPage();
|
||||
@@ -110,7 +111,6 @@
|
||||
this.informationPanel = new System.Windows.Forms.Panel();
|
||||
this.errorLabel = new System.Windows.Forms.Label();
|
||||
this.addRecordButton = new System.Windows.Forms.Button();
|
||||
this.showConsoleHelpMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mainLayoutPanel.SuspendLayout();
|
||||
this.mainMenuStrip.SuspendLayout();
|
||||
this.mainTabControl.SuspendLayout();
|
||||
@@ -187,7 +187,7 @@
|
||||
// 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";
|
||||
//
|
||||
// editMainMenu
|
||||
@@ -214,6 +214,13 @@
|
||||
this.helpMainMenu.Size = new System.Drawing.Size(68, 31);
|
||||
this.helpMainMenu.Text = "&Help";
|
||||
//
|
||||
// showConsoleHelpMainMenu
|
||||
//
|
||||
this.showConsoleHelpMainMenu.Name = "showConsoleHelpMainMenu";
|
||||
this.showConsoleHelpMainMenu.Size = new System.Drawing.Size(286, 34);
|
||||
this.showConsoleHelpMainMenu.Text = "Sh&ow/Hide Console";
|
||||
this.showConsoleHelpMainMenu.Click += new System.EventHandler(this.DisplayLogConsole);
|
||||
//
|
||||
// examineLogsHelpMainMenu
|
||||
//
|
||||
this.examineLogsHelpMainMenu.Name = "examineLogsHelpMainMenu";
|
||||
@@ -967,13 +974,6 @@
|
||||
this.addRecordButton.UseVisualStyleBackColor = true;
|
||||
this.addRecordButton.Click += new System.EventHandler(this.addRecordButton_Click);
|
||||
//
|
||||
// showConsoleHelpMainMenu
|
||||
//
|
||||
this.showConsoleHelpMainMenu.Name = "showConsoleHelpMainMenu";
|
||||
this.showConsoleHelpMainMenu.Size = new System.Drawing.Size(286, 34);
|
||||
this.showConsoleHelpMainMenu.Text = "Sh&ow/Hide Console";
|
||||
this.showConsoleHelpMainMenu.Click += new System.EventHandler(this.DisplayLogConsole);
|
||||
//
|
||||
// NewModifyRecord
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("3.0.0.0")]
|
||||
[assembly: AssemblyVersion("3.0.1.0")]
|
||||
[assembly: AssemblyFileVersion("3.0.1.0")]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,7 +10,7 @@ namespace AdvertsingProfitControl
|
||||
/// </summary>
|
||||
internal static class TextFormat
|
||||
{
|
||||
private static readonly FrmLogConsole LogConsole = FrmLogConsole.GetStaticInstance;
|
||||
//private static readonly FrmLogConsole LogConsole = FrmLogConsole.GetStaticInstance;
|
||||
|
||||
/// <summary>
|
||||
/// Formats an ad item's name / text into a standard format so as to help reduce redundancy in the database.
|
||||
@@ -248,8 +249,7 @@ namespace AdvertsingProfitControl
|
||||
/// <param name="abbreviations">A list of abbreviations that were found in the text.</param>
|
||||
/// <param name="words">A list of words found in the text.</param>
|
||||
/// <param name="preserveAcronyms">Whether or not to force normal casing rules on abbreviations.</param>
|
||||
private static void BuildAbbreviationsAndWordsLists(string adItemText, int startingIndex, out List<string> abbreviations,
|
||||
out List<string> words, bool preserveAcronyms = false)
|
||||
private static void BuildAbbreviationsAndWordsLists(string adItemText, int startingIndex, out List<string> abbreviations, out List<string> words, bool preserveAcronyms = false)
|
||||
{
|
||||
abbreviations = new List<string>();
|
||||
words = new List<string>();
|
||||
@@ -340,6 +340,64 @@ namespace AdvertsingProfitControl
|
||||
return isWord;
|
||||
}
|
||||
|
||||
public static bool TryParseBinCount(string inputText, out double binCount, out string binCountString)
|
||||
{
|
||||
if (inputText.Length == 0)
|
||||
{
|
||||
binCountString = string.Empty;
|
||||
binCount = 0;
|
||||
return false;
|
||||
}
|
||||
var success = false;
|
||||
binCountString = string.Empty;
|
||||
var number = new StringBuilder();
|
||||
var binString = new StringBuilder(); //
|
||||
var characterReached = false;
|
||||
|
||||
for (var i = 0; i < inputText.Length; i++)
|
||||
{
|
||||
if (char.IsNumber(inputText[i]) && !characterReached)
|
||||
{
|
||||
number.Append(inputText[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inputText[i] == '-' || inputText[i] == '.')
|
||||
{
|
||||
number.Append(inputText[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!char.IsLetter(inputText[i])) continue;
|
||||
binString.Append(inputText[i]);
|
||||
characterReached = true;
|
||||
}
|
||||
|
||||
if (number.ToString() == string.Empty)
|
||||
{
|
||||
binCount = 0;
|
||||
return false;
|
||||
}
|
||||
if (double.TryParse(number.ToString(), out binCount))
|
||||
{
|
||||
if (binString.ToString().Equals("bin", StringComparison.InvariantCultureIgnoreCase) ||
|
||||
binString.ToString().Equals("bins", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
if (binCount < 1 || binCount > 1)
|
||||
{
|
||||
binCountString = binCount + " Bins";
|
||||
}
|
||||
else
|
||||
{
|
||||
binCountString = "1 Bin";
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Capitalizes the first letter of the text sent to this method.
|
||||
/// </summary>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</configSections>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
|
||||
<parameters>
|
||||
<parameter value="mssqllocaldb" />
|
||||
</parameters>
|
||||
</defaultConnectionFactory>
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
||||
</providers>
|
||||
</entityFramework>
|
||||
</configuration>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{63CE4D0A-1F70-4692-B895-073A9B3AF5F2}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DataTableParsingEngine</RootNamespace>
|
||||
<AssemblyName>DataTableParsingEngine</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="TableColors.cs" />
|
||||
<Compile Include="TableGroupParser.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RowParser.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AdvertisingProfitControlData\AdvertisingProfitControlData.csproj">
|
||||
<Project>{e30f8b0e-dff3-4ab7-8d0c-47bd11164e51}</Project>
|
||||
<Name>AdvertisingProfitControlData</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("DataTableParsingEngine")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("DataTableParsingEngine")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("63ce4d0a-1f70-4692-b895-073a9b3af5f2")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// 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.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -1,18 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using AdvertisingProfitControlData;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
namespace DataTableParsingEngine
|
||||
{
|
||||
internal class RowParsing
|
||||
public class RowParser
|
||||
{
|
||||
public static List<string> AdSpecialGroups = new List<string>();
|
||||
|
||||
public string CheckForGroupKeyWord(string cellContents)
|
||||
/// <summary>
|
||||
/// Clears and rebuilds the ad special list that is held in memory.
|
||||
/// This is important as this prevents this engine from grabbing the
|
||||
/// list from the database every time this class is called. Otherwise,
|
||||
/// there would be noticeable lag getting the list from the SQL server.
|
||||
/// </summary>
|
||||
public static void BuildAdSpecialListings()
|
||||
{
|
||||
var keyWord = "NoGroupFound";
|
||||
AdSpecialGroups.Clear();
|
||||
var db = new AdvertisingProfitControlDbContext();
|
||||
AdSpecialGroups.AddRange(db.AdSpecials.Select(x => x.Name));
|
||||
}
|
||||
|
||||
private static readonly List<string> AdSpecialGroups = new List<string>();
|
||||
|
||||
private static string CheckForGroupKeyWord(string cellContents)
|
||||
{
|
||||
var keyWord = string.Empty;
|
||||
|
||||
var query = from adI in AdSpecialGroups
|
||||
where adI.Equals(cellContents, StringComparison.InvariantCultureIgnoreCase)
|
||||
@@ -45,14 +58,14 @@ namespace AdvertsingProfitControl
|
||||
return RowAttribute.NewRow;
|
||||
}
|
||||
//Determine the range to use during the looping process.
|
||||
var headerCellIndex = row.Cells.Count == Enum.GetNames(typeof(SalesTableColumns)).Length ? (int)SalesTableColumns.IsHeaderRow : (int)InventoryTableColumns.IsHeaderRow;
|
||||
var headerCellIndex = row.Cells.Count == Enum.GetNames(typeof(TableGroupParser.SalesTableColumns)).Length ? (int)TableGroupParser.SalesTableColumns.IsHeaderRow : (int)TableGroupParser.InventoryTableColumns.IsHeaderRow;
|
||||
var rowContents = new List<string>();
|
||||
var rowAttribute = RowAttribute.MemberRow;
|
||||
//Get the contents of the row that's being examined and add then to a List<string> array.
|
||||
var i = 0;
|
||||
foreach (DataGridViewCell cell in row.Cells)
|
||||
{
|
||||
if (cell.ColumnIndex >= headerCellIndex || cell.ColumnIndex == 0) { i++; continue;}
|
||||
if (cell.ColumnIndex >= headerCellIndex || 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.
|
||||
@@ -63,7 +76,7 @@ namespace AdvertsingProfitControl
|
||||
rowContents.Add(cell.EditedFormattedValue.ToString());
|
||||
}
|
||||
//If the first cell contains nothing, then return as IncompleteRow.
|
||||
else if (cellContentsStripped == "" && i == (int) SalesTableColumns.AdItem)
|
||||
else if (cellContentsStripped == "" && i == (int)TableGroupParser.SalesTableColumns.AdItem)
|
||||
{
|
||||
return RowAttribute.IncompleteRow;
|
||||
}
|
||||
@@ -80,7 +93,7 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
var keyWord = CheckForGroupKeyWord(rowContents[0]);
|
||||
//IF a keyword is found then declare this row an AdSpecialRow.
|
||||
if (keyWord != "NoGroupFound")
|
||||
if (keyWord != string.Empty)
|
||||
{
|
||||
return RowAttribute.AdSpecialRow;
|
||||
}
|
||||
@@ -89,51 +102,14 @@ namespace AdvertsingProfitControl
|
||||
return rowAttribute;
|
||||
}
|
||||
|
||||
public RowAttribute GetRowAttribute(object[] row)
|
||||
public enum RowAttribute
|
||||
{
|
||||
var rowAttribute = RowAttribute.MemberRow;
|
||||
|
||||
|
||||
|
||||
return rowAttribute;
|
||||
NewRow = 0,
|
||||
IncompleteRow = 1,
|
||||
AdSpecialRow = 2,
|
||||
RepeatedRow = 3,
|
||||
MemberRow = 4,
|
||||
HeaderRow = 5
|
||||
}
|
||||
|
||||
public void PaintDataGridViewRowGroups(DataGridView dataGridView, DataGridView companionDataGridView = null, int startIndex = 0,
|
||||
bool stopOnFirstFullGroupFound = false)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks for the presents of a repeat command using the Reg-ex engine.
|
||||
/// If a repeat command is found it returns the line number the command
|
||||
/// specifies to repeat.
|
||||
/// </summary>
|
||||
/// <param name="rowCommandField">The contents of Cell[0] in the row being parsed.</param>
|
||||
/// <returns>Line number to be repeated, -1 if no command is found.</returns>
|
||||
public int CheckForRepeatCommand(string rowCommandField)
|
||||
{
|
||||
const string repeatCommandPattern = @"^repeat( line)?:? [0-9]"; //Reference sheet: https://msdn.microsoft.com/en-us/library/az24scfc.aspx
|
||||
var rgx = new Regex(repeatCommandPattern, RegexOptions.IgnoreCase);
|
||||
var lineNumber = -1;
|
||||
|
||||
if (!rgx.IsMatch(rowCommandField)) return lineNumber;
|
||||
//Parse the string and retrieve the line number
|
||||
var numbers = Regex.Split(rowCommandField, @"\D+");
|
||||
|
||||
lineNumber = int.Parse(numbers[1]);
|
||||
return lineNumber;
|
||||
}
|
||||
}
|
||||
|
||||
public enum RowAttribute
|
||||
{
|
||||
NewRow = 0,
|
||||
IncompleteRow = 1,
|
||||
AdSpecialRow = 2,
|
||||
RepeatedRow = 3,
|
||||
MemberRow = 4,
|
||||
HeaderRow = 5
|
||||
}
|
||||
}
|
||||
+2
-5
@@ -1,11 +1,8 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
namespace DataTableParsingEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the colors to be used for the rows on the DataGridViews based on their state.
|
||||
/// </summary>
|
||||
public static class ApplicationColors
|
||||
public class TableColors
|
||||
{
|
||||
public static Color EditingSaved = Color.ForestGreen;
|
||||
public static Color PendingEdit = Color.Yellow;
|
||||
+108
-180
@@ -2,9 +2,9 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
namespace DataTableParsingEngine
|
||||
{
|
||||
internal class AdvertisingProfitControlTableHelper
|
||||
public class TableGroupParser
|
||||
{
|
||||
/// <summary>
|
||||
/// Paints rows according to their RowAttribute and detects whether or not they are part of a group.
|
||||
@@ -14,28 +14,28 @@ namespace AdvertsingProfitControl
|
||||
/// </summary>
|
||||
/// <param name="startingIndex">The starting index (the row that fired the RowLeave event)</param>
|
||||
/// <param name="dataGridView">The DataGridView to parse.</param>
|
||||
public void PaintRowGroupsFromIndex(int startingIndex, DataGridView dataGridView)
|
||||
public static void PaintRowGroupsFromIndex(int startingIndex, DataGridView dataGridView)
|
||||
{
|
||||
//Underflow protection for the lazy.
|
||||
if (startingIndex < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var parser = new RowParsing();
|
||||
var parser = new RowParser();
|
||||
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;
|
||||
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;
|
||||
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++)
|
||||
@@ -43,17 +43,17 @@ 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)
|
||||
{
|
||||
//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)
|
||||
{
|
||||
//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;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
return;
|
||||
}
|
||||
//IF the current row is not the first row in the data grid (index zero)...
|
||||
@@ -62,190 +62,190 @@ 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 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].EditedFormattedValue)
|
||||
if (rowStatus == RowParser.RowAttribute.HeaderRow && (bool)dataGridView.Rows[i - 1].Cells[isHeaderColumn].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 = ApplicationColors.PendingEdit;
|
||||
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = Color.White;
|
||||
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 != RowAttribute.MemberRow)
|
||||
if (rowStatus != RowParser.RowAttribute.MemberRow)
|
||||
{
|
||||
//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 = Color.White;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
return;
|
||||
}
|
||||
//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;
|
||||
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 == RowAttribute.HeaderRow || rowStatus == RowAttribute.MemberRow && (i - 1) == 0)
|
||||
if (rowStatus == RowParser.RowAttribute.HeaderRow || rowStatus == RowParser.RowAttribute.MemberRow && (i - 1) == 0)
|
||||
{
|
||||
//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;
|
||||
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
//Then check to see if the next row is a member row
|
||||
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
|
||||
if (rowStatus == RowAttribute.MemberRow)
|
||||
if (rowStatus == RowParser.RowAttribute.MemberRow)
|
||||
{
|
||||
//Set the current row and check for changes.
|
||||
if (!(bool)dataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue)
|
||||
{
|
||||
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
|
||||
dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
|
||||
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
|
||||
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 = ApplicationColors.PendingEdit;
|
||||
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 = Color.LightBlue;
|
||||
dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
//IF previous row is Incomplete, then call the stable PaintRowGroups function.
|
||||
else if (rowStatus == RowAttribute.IncompleteRow)
|
||||
else if (rowStatus == RowParser.RowAttribute.IncompleteRow)
|
||||
{
|
||||
PaintRowGroups(dataGridView);
|
||||
//PaintRowGroups(dataGridView);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Then check to see if the next row is a member row
|
||||
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
|
||||
if (rowStatus == RowAttribute.MemberRow)
|
||||
if (rowStatus == RowParser.RowAttribute.MemberRow)
|
||||
{
|
||||
//Set the current row and check for changes.
|
||||
if (!(bool)dataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue)
|
||||
{
|
||||
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
|
||||
dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
|
||||
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
//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 = ApplicationColors.PendingEdit;
|
||||
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 = Color.LightBlue;
|
||||
dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
}
|
||||
}
|
||||
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 from it and the current row (i).
|
||||
if (rowStatus == RowAttribute.MemberRow && (i - 1) == 0)
|
||||
if (rowStatus == RowParser.RowAttribute.MemberRow && (i - 1) == 0)
|
||||
{
|
||||
//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;
|
||||
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
|
||||
//Check for changes in the current row.
|
||||
if ((bool) dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
|
||||
if ((bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
|
||||
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 = Color.White;
|
||||
dataGridView.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 == RowAttribute.MemberRow && (bool)dataGridView.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
|
||||
else if (rowStatus == RowParser.RowAttribute.MemberRow && (bool)dataGridView.Rows[i - 1].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 = ApplicationColors.PendingEdit;
|
||||
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 = Color.LightBlue;
|
||||
dataGridView.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 == RowAttribute.MemberRow || rowStatus == RowAttribute.AdSpecialRow)
|
||||
else if (rowStatus == RowParser.RowAttribute.MemberRow || rowStatus == RowParser.RowAttribute.AdSpecialRow)
|
||||
{
|
||||
//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 = ApplicationColors.PendingEdit;
|
||||
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 = Color.White;
|
||||
dataGridView.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 == RowAttribute.HeaderRow && !(bool)dataGridView.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue)
|
||||
else if (rowStatus == RowParser.RowAttribute.HeaderRow && !(bool)dataGridView.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue)
|
||||
{
|
||||
//Set the previous row as a header 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 = ApplicationColors.PendingEdit;
|
||||
dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = true;
|
||||
dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = Color.LightGray;
|
||||
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 = ApplicationColors.PendingEdit;
|
||||
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 = ApplicationColors.PendingEdit;
|
||||
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 = Color.LightBlue;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
else if (rowStatus == RowAttribute.HeaderRow)
|
||||
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 = ApplicationColors.PendingEdit;
|
||||
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 = Color.LightBlue;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
//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);
|
||||
//PaintRowGroups(dataGridView);
|
||||
}
|
||||
}
|
||||
//ELSE the current row is the first row in the data grid, therefore it can't be a member row so remove all coloring.
|
||||
@@ -254,167 +254,95 @@ namespace AdvertsingProfitControl
|
||||
//Clear the current row of its attributes.
|
||||
dataGridView.Rows[0].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[0].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[0].DefaultCellStyle.BackColor = Color.White;
|
||||
dataGridView.Rows[0].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
}
|
||||
else if (rowStatus == RowAttribute.AdSpecialRow)
|
||||
else if (rowStatus == RowParser.RowAttribute.AdSpecialRow)
|
||||
{
|
||||
if(i == 0) return;
|
||||
dataGridView.Rows[startingIndex].DefaultCellStyle.BackColor = Color.Silver;
|
||||
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 == RowAttribute.HeaderRow)
|
||||
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 = ApplicationColors.PendingEdit;
|
||||
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 = Color.White;
|
||||
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 == RowAttribute.MemberRow)
|
||||
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 = ApplicationColors.PendingEdit;
|
||||
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 = Color.White;
|
||||
dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PaintRowGroups(DataGridView dataGridView)
|
||||
public static void PaintRowGroups(DataGridView table)
|
||||
{
|
||||
var parser = new RowParsing();
|
||||
var incompleteRowsFound = 0;
|
||||
var lastHeaderIndex = -1;
|
||||
var i = 0;
|
||||
var adSpecialIndex = -1;
|
||||
|
||||
}
|
||||
|
||||
foreach (DataGridViewRow row in dataGridView.Rows)
|
||||
{
|
||||
//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)
|
||||
{
|
||||
//Remove all coloring on the current row.
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
public static void PaintInventoryRowGroups(int startingIndex, DataGridView inventoryDataGridView,
|
||||
DataGridView companionDataGridView = null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//Check to make sure the numbers are within bounds, errors occurs when an incomplete row is found at index zero (0), and the current row is one (1).
|
||||
if ((i - (1 + incompleteRowsFound)) > 0)
|
||||
{
|
||||
//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)
|
||||
{
|
||||
row.DefaultCellStyle.BackColor = Color.LightBlue; //Group member
|
||||
dataGridView.Rows[lastHeaderIndex].DefaultCellStyle.BackColor = Color.LightGray; //Group header
|
||||
}
|
||||
//Else if a header row was not found from the previous operation but a header row is set, then its safe to assume that this row can be a member.
|
||||
else if (lastHeaderIndex >= 0)
|
||||
{
|
||||
//Check to make sure that the last header index is underneath the Ad Special Row OR that the current row (i) is before the Ad Special Index.
|
||||
if (lastHeaderIndex > adSpecialIndex || i < adSpecialIndex)
|
||||
{
|
||||
//Assume that the current row is a member of that group header and color it as such.
|
||||
row.DefaultCellStyle.BackColor = Color.LightBlue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
//IF so, set the last header index, and color code of this row along with the next row which is a MemberRow.
|
||||
lastHeaderIndex = 0;
|
||||
dataGridView.Rows[0].DefaultCellStyle.BackColor = Color.LightGray;
|
||||
dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = Color.LightBlue;
|
||||
}
|
||||
//Check to see if this row is a group header.
|
||||
else if (rowType == 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;
|
||||
lastHeaderIndex = i;
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
incompleteRowsFound++;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
}
|
||||
//
|
||||
if (rowType == RowAttribute.AdSpecialRow)
|
||||
{
|
||||
adSpecialIndex = i;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.Silver;
|
||||
}
|
||||
i++;
|
||||
}//end for-each
|
||||
dataGridView.Refresh();
|
||||
}//End PaintRowGroups
|
||||
}
|
||||
public enum SalesTableColumns
|
||||
{
|
||||
Id = 0,
|
||||
AdItem = 1,
|
||||
Sold = 2,
|
||||
SalePrice = 3,
|
||||
TotalSales = 4,
|
||||
Cost = 5,
|
||||
ProfitReturn = 6,
|
||||
TotalProfitReturn = 7,
|
||||
IsHeaderRow = 8,
|
||||
IsMemberRow = 9,
|
||||
IsDirty = 10
|
||||
}
|
||||
|
||||
public enum SalesTableColumns
|
||||
{
|
||||
Id = 0,
|
||||
AdItem = 1,
|
||||
Sold = 2,
|
||||
SalePrice = 3,
|
||||
TotalSales = 4,
|
||||
Cost = 5,
|
||||
ProfitReturn = 6,
|
||||
TotalProfitReturn = 7,
|
||||
IsHeaderRow = 8,
|
||||
IsMemberRow = 9,
|
||||
IsDirty = 10
|
||||
}
|
||||
public enum InventoryTableColumns
|
||||
{
|
||||
Id = 0,
|
||||
AdItem = 1,
|
||||
BeginningInventory = 2,
|
||||
Recieved = 3,
|
||||
Total = 4,
|
||||
EndingInventory = 5,
|
||||
IsHeaderRow = 6,
|
||||
IsMemberRow = 7,
|
||||
IsDirty = 8
|
||||
}
|
||||
|
||||
public enum InventoryTableColumns
|
||||
{
|
||||
Id = 0,
|
||||
AdItem = 1,
|
||||
BeginningInventory = 2,
|
||||
Recieved = 3,
|
||||
Total = 4,
|
||||
EndingInventory = 5,
|
||||
IsHeaderRow = 6,
|
||||
IsMemberRow = 7,
|
||||
IsDirty = 8
|
||||
}
|
||||
|
||||
public enum InvoiceTableColumns
|
||||
{
|
||||
Id = 0,
|
||||
InvoiceDate = 1,
|
||||
Supplier = 2,
|
||||
InvoiceNumber = 3,
|
||||
InvoiceNetAmountAtCost = 4,
|
||||
InvoiceNote = 5,
|
||||
IsDirty = 6
|
||||
public enum InvoiceTableColumns
|
||||
{
|
||||
Id = 0,
|
||||
InvoiceDate = 1,
|
||||
Supplier = 2,
|
||||
InvoiceNumber = 3,
|
||||
InvoiceNetAmountAtCost = 4,
|
||||
InvoiceNote = 5,
|
||||
IsDirty = 6
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="EntityFramework" version="6.1.3" targetFramework="net45" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user