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:
2017-07-02 20:59:33 -05:00
parent 12a6b36370
commit fd47690224
22 changed files with 878 additions and 727 deletions
+17
View File
@@ -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")]
+115
View File
@@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using AdvertisingProfitControlData;
namespace DataTableParsingEngine
{
public class RowParser
{
/// <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()
{
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)
select adI;
var enumerable = query as string[] ?? query.ToArray();
if (enumerable.ToArray().Length > 0)
{
//Grab the first object in the array and return it.
keyWord = enumerable.ToArray().First();
}
return keyWord;
}
/// <summary>
/// Determines a row's status.
/// </summary>
/// <param name="row">The row from a DataGridView object to be examined.</param>
/// <returns>The row's status, such as HeaderRow or NewRow.</returns>
public RowAttribute GetRowAttribute(DataGridViewRow row)
{
//IF the supplied row is null, then simply declare it an IncompleteRow.
if (row == null)
{
return RowAttribute.IncompleteRow;
}
//IF the supplied row is a new row, by the definition of the DataGridViewRow class, then return NewRow.
if (row.IsNewRow)
{
return RowAttribute.NewRow;
}
//Determine the range to use during the looping process.
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; }
//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.
cellContentsStripped = cellContentsStripped.Replace("0", "");
cellContentsStripped = cellContentsStripped.Replace(".", "");
if (cellContentsStripped != "")
{
rowContents.Add(cell.EditedFormattedValue.ToString());
}
//If the first cell contains nothing, then return as IncompleteRow.
else if (cellContentsStripped == "" && i == (int)TableGroupParser.SalesTableColumns.AdItem)
{
return RowAttribute.IncompleteRow;
}
i++;
}
//With all meaningless content removed, only actual data should be here. So if there are more then one items, than that means there are more then one
//cells with meaningful data in them. Which means that this row can be a header row with member rows under it.
if (rowContents.Count > 1)
{
rowAttribute = RowAttribute.HeaderRow;
}
else if (rowContents.Count == 1) //Check to see if this row is intended to be for a special ad.
{
var keyWord = CheckForGroupKeyWord(rowContents[0]);
//IF a keyword is found then declare this row an AdSpecialRow.
if (keyWord != string.Empty)
{
return RowAttribute.AdSpecialRow;
}
}
return rowAttribute;
}
public enum RowAttribute
{
NewRow = 0,
IncompleteRow = 1,
AdSpecialRow = 2,
RepeatedRow = 3,
MemberRow = 4,
HeaderRow = 5
}
}
}
+14
View File
@@ -0,0 +1,14 @@
using System.Drawing;
namespace DataTableParsingEngine
{
public class TableColors
{
public static Color EditingSaved = Color.ForestGreen;
public static Color PendingEdit = Color.Yellow;
public static Color RowError = Color.Red;
public static Color HeaderRow = Color.LightGray;
public static Color MemberRow = Color.LightBlue;
public static Color AdSpecial = Color.Silver;
}
}
+348
View File
@@ -0,0 +1,348 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace DataTableParsingEngine
{
public class TableGroupParser
{
/// <summary>
/// Paints rows according to their RowAttribute and detects whether or not they are part of a group.
/// This function offers a faster method of determining all of this by starting at the row index that
/// fired the row leave even. As opposed to the PaintRowGroups function which spins through all the
/// DataGridView's rows.
/// </summary>
/// <param name="startingIndex">The starting index (the row that fired the RowLeave event)</param>
/// <param name="dataGridView">The DataGridView to parse.</param>
public static void PaintRowGroupsFromIndex(int startingIndex, DataGridView dataGridView)
{
//Underflow protection for the lazy.
if (startingIndex < 0)
{
return;
}
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;
}
else
{
isHeaderColumn = (int)InventoryTableColumns.IsHeaderRow;
isMemberColumn = (int)InventoryTableColumns.IsMemberRow;
isDirtyColumn = (int)InventoryTableColumns.IsDirty;
}
//Spin through the dataGridView rows starting at the row that fired the event.
for (var i = startingIndex; i < (dataGridView.RowCount - 1); i++)
{
//Get the status of the current row.
var rowStatus = parser.GetRowAttribute(dataGridView.Rows[i]);
//IF the current row is a header row...
if (rowStatus == RowParser.RowAttribute.HeaderRow)
{
//Then check to see if the next row is a row header.
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
//IF so, color code this row as White, since it is not a true group header.
if (rowStatus == RowParser.RowAttribute.HeaderRow)
{
//Clear the current row of its attributes.
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
return;
}
//IF the current row is not the first row in the data grid (index zero)...
if (i > 0)
{
//The start by checking the previous row's status.
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i - 1]);
//IF the previous row is a header row AND has color coding saying it is a group header, then clear the previous row's color and apply it to this row (i).
if (rowStatus == RowParser.RowAttribute.HeaderRow && (bool)dataGridView.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue)
{
//Clear the previous row of its attributes.
dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
//This condition means the user changed the members of a group, so the old header row needs to be updated in the database.
dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
//Check the next row to see if its a member row before declaring the current row a header row.
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
if (rowStatus != RowParser.RowAttribute.MemberRow)
{
//Clear the coloring from the current row.
dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
return;
}
//Set the current row as a header row.
dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.HeaderRow;
return;
}
//IF the previous row is a header row OR if the previous row is index zero AND a member row, clear its coloring.
if (rowStatus == RowParser.RowAttribute.HeaderRow || rowStatus == RowParser.RowAttribute.MemberRow && (i - 1) == 0)
{
//Clear the previous row of its attributes.
dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
}
//Then check to see if the next row is a member row
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
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 = TableColors.PendingEdit;
}
dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.HeaderRow;
//Set the next row as a member row.
if (!(bool)dataGridView.Rows[i + 1].Cells[isMemberColumn].EditedFormattedValue)
{
dataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
}
dataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true;
dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
}
//IF previous row is Incomplete, then call the stable PaintRowGroups function.
else if (rowStatus == RowParser.RowAttribute.IncompleteRow)
{
//PaintRowGroups(dataGridView);
}
}
else
{
//Then check to see if the next row is a member row
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
if (rowStatus == RowParser.RowAttribute.MemberRow)
{
//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 = TableColors.PendingEdit;
}
dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
//Set the next row as a member row.
if (!(bool)dataGridView.Rows[i + 1].Cells[isMemberColumn].EditedFormattedValue)
{
dataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
}
dataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true;
dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
}
}
}
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 == 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 = default(Color);
//Check for changes in the current row.
if ((bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
{
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
}
//Clear the current row of its attributes.
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
}
//IF the previous row is a member row AND it also has color coding suggesting that it is a member of a group, then add the current row (i) as well.
else if (rowStatus == RowParser.RowAttribute.MemberRow && (bool)dataGridView.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
{
//Check for changes in the current row.
if (!(bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
{
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
}
//Set the current row as a member row.
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i].Cells[isMemberColumn].Value = true;
dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
}
//IF the previous row is simply a member row with no coloring at all, then remove the coloring from the current row (i).
else if (rowStatus == RowParser.RowAttribute.MemberRow || rowStatus == RowParser.RowAttribute.AdSpecialRow)
{
//Check for changes in the current row.
if ((bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
{
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
}
//Clear the current row of its attributes.
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
}
//IF the previous row is a header row, then color it as a group header and color the current row as a member of said group.
else if (rowStatus == RowParser.RowAttribute.HeaderRow && !(bool)dataGridView.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue)
{
//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 = TableColors.PendingEdit;
}
dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = true;
dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = TableColors.HeaderRow;
//This condition means the user created a group so the newly made header row will need to be updated in the database as well.
dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
//Check for changes in the current row.
if (!(bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
{
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
}
//Set the current row as a member row.
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i].Cells[isMemberColumn].Value = true;
dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
}
else if (rowStatus == RowParser.RowAttribute.HeaderRow)
{
//Check for changes in the current row.
if (!(bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
{
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
}
//Set the current row as a member row.
dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i].Cells[isMemberColumn].Value = true;
dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
}
//IF the previous row is incomplete, then call the stable PaintRowGroups function.
else if (rowStatus == RowParser.RowAttribute.IncompleteRow)
{
//PaintRowGroups(dataGridView);
}
}
//ELSE the current row is the first row in the data grid, therefore it can't be a member row so remove all coloring.
else
{
//Clear the current row of its attributes.
dataGridView.Rows[0].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[0].Cells[isMemberColumn].Value = false;
dataGridView.Rows[0].DefaultCellStyle.BackColor = default(Color);
}
}
else if (rowStatus == RowParser.RowAttribute.AdSpecialRow)
{
if (i == 0) return;
dataGridView.Rows[startingIndex].DefaultCellStyle.BackColor = TableColors.AdSpecial;
//Get the previous row's attribute.
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i - 1]);
if (rowStatus == RowParser.RowAttribute.HeaderRow)
{
//Check to see if the previous row sees itself as a header row, if so mark it dirty.
if ((bool)dataGridView.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue)
{
dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
}
//Clear its color coding.
dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
}
//Next get the status of the next row.
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
if (rowStatus == RowParser.RowAttribute.MemberRow)
{
//Check to see if the next row thinks it is a member row.
if (!(bool)dataGridView.Rows[i + 1].Cells[isMemberColumn].EditedFormattedValue)
{
dataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
}
//Clear its color coding.
dataGridView.Rows[i + 1].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = default(Color);
}
}
}
}
public static void PaintRowGroups(DataGridView table)
{
}
public static void PaintInventoryRowGroups(int startingIndex, DataGridView inventoryDataGridView,
DataGridView companionDataGridView = null)
{
}
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 InvoiceTableColumns
{
Id = 0,
InvoiceDate = 1,
Supplier = 2,
InvoiceNumber = 3,
InvoiceNetAmountAtCost = 4,
InvoiceNote = 5,
IsDirty = 6
}
}
}
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.3" targetFramework="net45" />
</packages>