Marked as 'AdvertsingProfitControl No Print' by its folder name. Updated the 'Mordify Record' form. I believe the 'No Print' was related to creating a PDF version of the Advertising Profit Control sheet. The next version after this was most likely to have the code for that.

This commit is contained in:
2021-01-28 19:58:37 -06:00
parent 665f4784e4
commit 75061c9d51
19 changed files with 904 additions and 2171 deletions
Binary file not shown.
+1 -7
View File
@@ -1,12 +1,10 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvertsingProfitControl", "AdvertsingProfitControl\AdvertsingProfitControl.csproj", "{4A45C665-5D02-4724-9CC5-C0C50CA44760}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StringInputParseTester", "StringInputParseTester\StringInputParseTester.csproj", "{2663661B-3D90-4D42-B05E-8038923A2891}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -17,10 +15,6 @@ Global
{4A45C665-5D02-4724-9CC5-C0C50CA44760}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A45C665-5D02-4724-9CC5-C0C50CA44760}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A45C665-5D02-4724-9CC5-C0C50CA44760}.Release|Any CPU.Build.0 = Release|Any CPU
{2663661B-3D90-4D42-B05E-8038923A2891}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2663661B-3D90-4D42-B05E-8038923A2891}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2663661B-3D90-4D42-B05E-8038923A2891}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2663661B-3D90-4D42-B05E-8038923A2891}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Binary file not shown.
@@ -38,7 +38,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>true</Prefer32Bit>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -56,7 +56,9 @@
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<StartupObject>AdvertsingProfitControl.Program</StartupObject>
</PropertyGroup>
@@ -78,41 +80,21 @@
<PropertyGroup>
<ApplicationIcon>Stretched Logo Collection.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="HtmlRenderer, Version=1.5.0.5, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlRenderer.Core.1.5.0.5\lib\net45\HtmlRenderer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="HtmlRenderer.WinForms, Version=1.5.0.6, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlRenderer.WinForms.1.5.0.6\lib\net45\HtmlRenderer.WinForms.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="AdItemCollectionModel.cs" />
<Compile Include="AdvertisingProfitControlTableHelper.cs" />
<Compile Include="TextFormat.cs" />
<Compile Include="APCDatabaseWriter.cs" />
<Compile Include="BackPageGenerator.cs" />
<Compile Include="DatabaseReader.cs" />
<Compile Include="DatabaseTracker.cs" />
<Compile Include="DatabaseVersionControl.cs" />
<Compile Include="DatabaseWriter.cs" />
<Compile Include="ExecuteCommand.cs" />
<Compile Include="FrmAddRecord.cs">
<SubType>Form</SubType>
</Compile>
@@ -137,19 +119,12 @@
<Compile Include="FrmMain.Designer.cs">
<DependentUpon>FrmMain.cs</DependentUpon>
</Compile>
<Compile Include="FrmManageAdItems.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmManageAdItems.Designer.cs">
<DependentUpon>FrmManageAdItems.cs</DependentUpon>
</Compile>
<Compile Include="FrmModifyRecord.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmModifyRecord.Designer.cs">
<DependentUpon>FrmModifyRecord.cs</DependentUpon>
</Compile>
<Compile Include="FrontPageGenerator.cs" />
<Compile Include="GlobalClasses.cs" />
<Compile Include="FrmLogConsole.cs">
<SubType>Form</SubType>
@@ -157,13 +132,8 @@
<Compile Include="FrmLogConsole.Designer.cs">
<DependentUpon>FrmLogConsole.cs</DependentUpon>
</Compile>
<Compile Include="NewAddRecord.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="NewAddRecord.Designer.cs">
<DependentUpon>NewAddRecord.cs</DependentUpon>
</Compile>
<Compile Include="RowParsing.cs" />
<Compile Include="HMergedCell.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FrmAddRecord.resx">
@@ -181,15 +151,9 @@
<EmbeddedResource Include="FrmLogConsole.resx">
<DependentUpon>FrmLogConsole.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmManageAdItems.resx">
<DependentUpon>FrmManageAdItems.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmModifyRecord.resx">
<DependentUpon>FrmModifyRecord.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="NewAddRecord.resx">
<DependentUpon>NewAddRecord.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -201,8 +165,8 @@
<DesignTime>True</DesignTime>
</Compile>
<None Include="AdvertsingProfitControl_TemporaryKey.pfx" />
<None Include="app.manifest" />
<None Include="packages.config" />
<None Include="app.config" />
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>C:\Users\glmcc\Desktop\</PublishUrlHistory>
<PublishUrlHistory />
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
@@ -10,7 +10,4 @@
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
<PropertyGroup>
<EnableSecurityDebugging>false</EnableSecurityDebugging>
</PropertyGroup>
</Project>
+41 -213
View File
@@ -8,34 +8,6 @@ namespace AdvertsingProfitControl
{
internal class DatabaseReader
{
public string GetDatabaseVersion(string connectionString)
{
var versionNumber = "0.0.0.0";
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT VersionNumber FROM Version"
};
var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection;
using (connection)
{
using (oleDbCommand)
{
connection.Open();
using (var reader = oleDbCommand.ExecuteReader())
{
while (reader != null && reader.Read())
{
versionNumber = reader[0].ToString();
}
}
}
}
return versionNumber;
}
#region Date Functions
/// <summary>
/// Retrieves the most recent date's ID from the database.
@@ -250,69 +222,12 @@ namespace AdvertsingProfitControl
#region Ad Item Functions
public Dictionary<int, string> GetAdItemsSuggestionDictionary(string connectionString)
{
var adItemDictionary = new Dictionary<int, string>();
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT AdItem.ID, AdItem.AdItem FROM AdItem ORDER BY AdItem.AdItem ASC"
};
var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection;
using (connection)
{
using (oleDbCommand)
{
connection.Open();
using (var reader = oleDbCommand.ExecuteReader())
{
while (reader != null && reader.Read())
{
adItemDictionary.Add(int.Parse(reader["ID"].ToString()), reader["AdItem"].ToString());
}
}
}
}
return adItemDictionary;
}
public int GetLargestKeyValueForAdItems(string connectionString)
{
var id = -1;
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT MAX(AdItem.ID) FROM AdItem"
};
var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection;
using (connection)
{
using (oleDbCommand)
{
connection.Open();
using (var reader = oleDbCommand.ExecuteReader())
{
while (reader != null && reader.Read())
{
int.TryParse(reader[0].ToString(), out id);
}
}
}
}
return id;
}
public string RetrieveAdItemId(string adItemName, string connectionString)
{
var id = "0";
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT AdItem.ID FROM AdItem WHERE UCASE(AdItem.AdItem) = UCASE(?)" //JUST MAKE A CUSTOM PARSING ENGINE
CommandText = "SELECT AdItem.ID FROM AdItem WHERE UCASE(AdItem.AdItem) = UCASE(?)"
};
oleDbCommand.Parameters.AddWithValue("AdItemName", adItemName);
var connection = new OleDbConnection(connectionString);
@@ -338,9 +253,9 @@ namespace AdvertsingProfitControl
public List<string> RetrieveUsedAdItemListByDateId(string dateId, string connectionString)
{
var adItemList = new List<string>();
var oleDbCommand = new OleDbCommand
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT AdItem.AdItem, ActualSales.RowAttribute, ActualSales.FK_AdSpecialGroupName FROM (ActualSales INNER JOIN AdItem ON ActualSales.FK_AdItemID = AdItem.ID) WHERE FK_DateID = ? ORDER BY RowPosition ASC"
CommandText = "SELECT AdItem.AdItem, APC.RowAttribute, APC.FK_GroupID FROM (APC INNER JOIN AdItem ON APC.FK_AdItemID = AdItem.ID) WHERE FK_DateID = ? ORDER BY RowPosition ASC"
};
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
var connection = new OleDbConnection(connectionString);
@@ -354,7 +269,7 @@ namespace AdvertsingProfitControl
{
while (reader != null && reader.Read())
{
if (reader["FK_AdSpecialGroupName"].ToString() != "" && int.Parse(reader["FK_AdSpecialGroupName"].ToString()) >= 3)
if (reader["FK_GroupID"].ToString() != "" && (int) reader["FK_GroupID"] >= 3)
{
adItemList.Add(reader[0] + ":2");
}
@@ -370,41 +285,6 @@ namespace AdvertsingProfitControl
return adItemList;
}
public List<string> RetrieveAdItemListByLetter(string connectionString, string letterFilter = "All")
{
var adItemsList = new List<string>();
var oleDbCommand = new OleDbCommand();
if(letterFilter == "All")
{
oleDbCommand.CommandText = "SELECT AdItem FROM AdItem ORDER BY AdItem ASC";
}
else
{
oleDbCommand.CommandText = "SELECT AdItem FROM AdItem WHERE LEFT(AdItem, 1) = ? ORDER BY AdItem ASC";
oleDbCommand.Parameters.AddWithValue("Filter", letterFilter);
}
var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection;
using (connection)
{
using (oleDbCommand)
{
connection.Open();
using (var reader = oleDbCommand.ExecuteReader())
{
while (reader != null && reader.Read())
{
adItemsList.Add((reader[0].ToString()));
}
}
}
}
return adItemsList;
}
#endregion
#region Comment Functions
@@ -440,16 +320,16 @@ namespace AdvertsingProfitControl
#endregion
#region Ad Special Functions
#region Group ID Functions
public string RetrieveGroupIdByString(string groupName, string connectionString)
{
var groupId = "0";
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT AdSpecialName.ID FROM AdSpecialName WHERE AdSpecialName.AdSpecialName = ?"
CommandText = "SELECT GroupCategory.ID FROM GroupCategory WHERE GroupCategory.GroupDescription = ?"
};
oleDbCommand.Parameters.AddWithValue("AdSpecialName", groupName);
oleDbCommand.Parameters.AddWithValue("GroupName", groupName);
var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection;
@@ -471,40 +351,12 @@ namespace AdvertsingProfitControl
return groupId;
}
public string ReturnAdSpecialDescriptionByAdSpecialName(string adSpecialString, string connectionString)
{
var descriptionString = "";
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT AdSpecialName.AdSpecialDescription FROM AdSpecialName WHERE AdSpecialName.AdSpecialDescription = ?"
};
oleDbCommand.Parameters.AddWithValue("AdspecialName", adSpecialString);
var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection;
using (connection)
{
using (oleDbCommand)
{
connection.Open();
using (var reader = oleDbCommand.ExecuteReader())
{
while (reader != null && reader.Read())
{
descriptionString = reader[0].ToString();
}
}
}
}
return descriptionString;
}
public List<string> ReturnGroupNameList(string connectionString)
{
var groupNames = new List<string>();
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT AdSpecialName.AdSpecialName FROM AdSpecialName"
CommandText = "SELECT GroupCategory.GroupDescription FROM GroupCategory WHERE NOT GroupDescription = 'HeaderRow' AND NOT GroupDescription = 'MemberRow'"
};
var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection;
@@ -527,14 +379,40 @@ namespace AdvertsingProfitControl
return groupNames;
}
public DataTable ReturnGroupIdTable(string dateId, string connectionString)
{
var dataTable = new DataTable();
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT APC.FK_GroupID FROM APC WHERE FK_DateID = ?"
};
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection;
using (connection)
{
using (oleDbCommand)
{
connection.Open();
using (var dataAdapter = new OleDbDataAdapter(oleDbCommand))
{
dataAdapter.Fill(dataTable);
}
}
}
return dataTable;
}
public string ReturnGroupNameFromGroupId(string id, string connectionString)
{
var name = "";
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT AdSpecialName FROM AdSpecialName WHERE ID = ?"
CommandText = "SELECT GroupDescription FROM GroupCategory WHERE ID = ?"
};
oleDbCommand.Parameters.AddWithValue("AdspecialName", id);
oleDbCommand.Parameters.AddWithValue("GroupID", id);
var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection;
@@ -561,7 +439,7 @@ namespace AdvertsingProfitControl
var adSpecialList = new AutoCompleteStringCollection();
var oleDbCommand = new OleDbCommand()
{
CommandText = "Select AdSpecialName FROM AdSpecialName"
CommandText = "Select GroupDescription FROM GroupCategory WHERE NOT GroupDescription = 'HeaderRow' AND NOT GroupDescription = 'MemberRow'"
};
var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection;
@@ -646,38 +524,12 @@ namespace AdvertsingProfitControl
#region Table Return Functions
public DataTable ReturnApcTableForReport(string dateId, string connectionString)
{
var dataTable = new DataTable();
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT AdItem.AdItem, APC.ProjectionSold, APC.ProjectionSalePrice, APC.ProjectionTotalSales, APC.ProjectionCost, APC.ProjectionProfitReturn, APC.ProjectionTotalProfitReturn, APC.BeginingInventory, APC.Received, APC.TotalInventory, APC.EndingInventory, APC.ActualSold, APC.ActualSalePrice, APC.ActualTotalSales, APC.ActualCost, APC.ActualProfitReturn, APC.ActualTotalProfitReturn, APC.GroupNumber, APC.FK_AdSpecialName FROM (AdItem INNER JOIN APC ON AdItem.ID = APC.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC"
};
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection;
using (connection)
{
using (oleDbCommand)
{
connection.Open();
using (var dataAdapter = new OleDbDataAdapter(oleDbCommand))
{
dataAdapter.Fill(dataTable);
}
}
}
return dataTable;
}
public DataTable ReturnProjectionsTable(string dateId, string connectionString)
{
var dataTable = new DataTable();
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT AdItem.AdItem, Projections.Sold, Projections.SalePrice, Projections.TotalSales, Projections.Cost, Projections.ProfitReturn, Projections.TotalProfitReturn, Projections.RowAttribute, Projections.FK_AdSpecialGroupName FROM (AdItem INNER JOIN Projections ON AdItem.ID = Projections.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC"
CommandText = "SELECT AdItem.AdItem, APC.ProjectionSold, APC.ProjectionSalePrice, APC.ProjectionTotalSales, APC.ProjectionCost, APC.ProjectionProfitReturn, APC.ProjectionTotalProfitReturn, RowAttribute, FK_GroupID FROM (AdItem INNER JOIN APC ON AdItem.ID = APC.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC"
};
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
var connection = new OleDbConnection(connectionString);
@@ -702,7 +554,7 @@ namespace AdvertsingProfitControl
var dataTable = new DataTable();
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT AdItem.AdItem, ActualSales.Sold, ActualSales.SalePrice, ActualSales.TotalSales, ActualSales.Cost, ActualSales.ProfitReturn, ActualSales.TotalProfitReturn, ActualSales.RowAttribute, ActualSales.FK_AdSpecialGroupName FROM (AdItem INNER JOIN ActualSales ON AdItem.ID = ActualSales.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC"
CommandText = "SELECT AdItem.AdItem, APC.ActualSold, APC.ActualSalePrice, APC.ActualTotalSales, APC.ActualCost, APC.ActualProfitReturn, APC.ActualTotalProfitReturn, RowAttribute, FK_GroupID FROM (AdItem INNER JOIN APC ON AdItem.ID = APC.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC"
};
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
var connection = new OleDbConnection(connectionString);
@@ -727,7 +579,7 @@ namespace AdvertsingProfitControl
var dataTable = new DataTable();
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT AdItem.AdItem, Inventory.BeginningInventory, Inventory.Received, Inventory.TotalInventory, Inventory.EndingInventory, Inventory.RowAttribute, Inventory.FK_AdSpecialGroupName FROM (AdItem INNER JOIN Inventory ON AdItem.ID = Inventory.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC"
CommandText = "SELECT AdItem.AdItem, APC.BeginingInventory, APC.Received, APC.TotalInventory, APC.EndingInventory, RowAttribute, FK_GroupID FROM (AdItem INNER JOIN APC ON AdItem.ID = APC.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC"
};
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
var connection = new OleDbConnection(connectionString);
@@ -753,7 +605,7 @@ namespace AdvertsingProfitControl
var dataTable = new DataTable();
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT Supplier.SupplierName, Invoice.InvoiceNumber, Invoice.InvoiceDate, Invoice.InvoiceNetAmountAtCost, Invoice.InvoiceNetAmount, Invoice.InvoiceNote FROM (Supplier INNER JOIN Invoice ON Supplier.ID = Invoice.FK_Supplier) WHERE FK_DateID = ?"
CommandText = "SELECT Supplier.SupplierName, InvoiceNumber, Invoice.InvoiceDate, Invoice.InvoiceNetAmountAtCost, Invoice.InvoiceNetAmount, Invoice.InvoiceNote FROM (Supplier INNER JOIN Invoice ON Supplier.ID = Invoice.FK_Supplier) WHERE FK_DateID = ?"
};
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
var connection = new OleDbConnection(connectionString);
@@ -798,30 +650,6 @@ namespace AdvertsingProfitControl
return dataTable;
}
public DataTable ReturnTaxableFromDateId(string dateId, string connectionString)
{
var dataTable = new DataTable();
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT Taxable.Sunday, Taxable.Monday, Taxable.Tuesday, Taxable.Wednesday, Taxable.Thursday, Taxable.Friday, Taxable.Saturday, Taxable.Total FROM Taxable WHERE FK_DateID = ?"
};
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection;
using (connection)
{
using (oleDbCommand)
{
connection.Open();
using (var dataAdapter = new OleDbDataAdapter(oleDbCommand))
{
dataAdapter.Fill(dataTable);
}
}
}
return dataTable;
}
public DataTable ReturnWeekEndingTable(string connectionString)
{
+62 -468
View File
@@ -1,321 +1,18 @@
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Transactions;
using System.Windows.Forms;
namespace AdvertsingProfitControl
{
internal class DatabaseWriter
class DatabaseWriter
{
private readonly OleDbConnection _oleDbConnection = new OleDbConnection();
private readonly OleDbConnection _connectionobject = new OleDbConnection();
private readonly FrmLogConsole _logConsole = FrmLogConsole.GetStaticInstance;
public DatabaseWriter(string connectionString)
{
_oleDbConnection.ConnectionString = connectionString;
_connectionobject.ConnectionString = connectionString;
}
#region New Code
/// <summary>
/// Inserts new records into the specified sales table.
/// Supports rolling back the database to prevent corruption.
/// </summary>
/// <param name="salesTable">The data table that contains the data to be inserted.</param>
/// <param name="connectionString"></param>
/// <returns></returns>
public Dictionary<int, int> InsertIntoSalesTable(DataTable salesTable, string connectionString)
{
var rowIndex = 0;
var rows = new Dictionary<int, int>();
var oleDbConnection = new OleDbConnection(connectionString);
//IDs from the database can not be zero (0), so this will be the default value (no group).
var oleDbCommand = new OleDbCommand
{
Connection = oleDbConnection
};
OleDbTransaction oleDbTransaction = null;
try
{
oleDbConnection.Open();
oleDbTransaction = oleDbConnection.BeginTransaction();
oleDbCommand.Transaction = oleDbTransaction;
for (var i = 0; i < salesTable.Rows.Count; i++)
{
oleDbCommand.CommandText =
"INSERT INTO " + salesTable.TableName + " (Sold, SalePrice, TotalSales, Cost, ProfitReturn, TotalProfitReturn, FK_AdItemID, RowAttribute, FK_AdSpecialGroupName, RowPosition, FK_DateID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
//New Sales Table Layout (Based on the Database's Physical Layout)
//0: Sold 1:SalePrice 2:TotalSales 3:cost 4:ProfitReturn 5:TotalProfitReturn
//6:FK_AdItemID 7:RowAttribute 8:FK_AdSpecialGroupName (ID) 9:RowPosition (not index based)
//10:FK_DateID
oleDbCommand.Parameters.AddWithValue("Sold", salesTable.Rows[i][0]);
oleDbCommand.Parameters.AddWithValue("SalesPrice", salesTable.Rows[i][1]);
oleDbCommand.Parameters.AddWithValue("TotalSales", salesTable.Rows[i][2]);
oleDbCommand.Parameters.AddWithValue("Cost", salesTable.Rows[i][3]);
oleDbCommand.Parameters.AddWithValue("ProfitReturn", salesTable.Rows[i][4]);
oleDbCommand.Parameters.AddWithValue("TotalProfitReturn", salesTable.Rows[i][5]);
oleDbCommand.Parameters.AddWithValue("adItemID", int.Parse(salesTable.Rows[i][6].ToString()));
oleDbCommand.Parameters.AddWithValue("RowAttribute", int.Parse(salesTable.Rows[i][7].ToString()));
oleDbCommand.Parameters.AddWithValue("adSpecialID", int.Parse(salesTable.Rows[i][8].ToString()));
oleDbCommand.Parameters.AddWithValue("RowPosition", int.Parse(salesTable.Rows[i][9].ToString()));
oleDbCommand.Parameters.AddWithValue("dateID", salesTable.Rows[i][10]);
oleDbCommand.ExecuteNonQuery();
oleDbCommand.Parameters.Clear();
rowIndex++;
}
oleDbTransaction.Commit();
foreach (DataRow row in salesTable.Rows)
{
var rowId = RetrieveRowId(salesTable.TableName, int.Parse(row[6].ToString()), int.Parse(row[10].ToString()));
if (int.Parse(row[8].ToString()) != 0)
{
//Account for the ad special row.
rows.Add(int.Parse(row[9].ToString()) + 1, rowId);
}
else
{
rows.Add(int.Parse(row[9].ToString()), rowId);
}
}
}
catch (OleDbException ex)
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed to write to database: " + ex.Message);
if (rowIndex <= 0)
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Failed to begin parsing data rows, var dump of erroneous row unavailable.");
}
else
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Failed on row " + (rowIndex + 1) + " due to the above error. Dumping contents of row " + (rowIndex + 1) + " from " + salesTable.TableName + ".");
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Ad Item ID: \"" +
salesTable.Rows[rowIndex][6] + "\" Sold: \"" + salesTable.Rows[rowIndex][0] + "\"");
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Sale Price: \"" + salesTable.Rows[rowIndex][1] + "\" Total Sales: \"" + salesTable.Rows[rowIndex][2] + "\"");
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Cost: \"" + salesTable.Rows[rowIndex][3] + "\" Profit Return: \"" + salesTable.Rows[rowIndex][4] + "\"");
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Total Profit Return: \"" +
salesTable.Rows[rowIndex][5] + "\" Ad Special Group: \"" + salesTable.Rows[rowIndex][8] + "\"");
}
oleDbTransaction?.Rollback();
_logConsole.WriteToLog(FrmLogConsole.Level.Critical, "Rollback completed successfully, " + salesTable.TableName+ " table failed on insertion.");
}
finally
{
_oleDbConnection.Close();
}
return rows;
}
public bool UpdateSalesTable(DataTable salesTable, string connectionString)
{
var wasSuccessful = false;
var rowIndex = 0;
var oleDbConnection = new OleDbConnection(connectionString);
//IDs from the database can not be zero (0), so this will be the default value (no group).
var oleDbCommand = new OleDbCommand
{
Connection = oleDbConnection
};
OleDbTransaction oleDbTransaction = null;
try
{
oleDbTransaction = oleDbConnection.BeginTransaction();
_oleDbConnection.Open();
oleDbCommand.Transaction = oleDbTransaction;
for (var i = 0; i < salesTable.Rows.Count; i++)
{
oleDbCommand.CommandText =
"UPDATE " + salesTable.TableName + " SET Sold = ?, SalePrice = ?, TotalSales = ?, Cost = ?, ProfitReturn = ?, TotalProfitReturn = ?, RowAttribute = ?, FK_AdSpecialGroupName = ?, RowPosition = ? WHERE ID = ?";
//Update Sales Table Layout (Based on the Database's Physical Layout)
//0:ID 1:Sold 2:SalePrice 3:TotalSales 4:cost 5:ProfitReturn 6:TotalProfitReturn
//7:FK_AdItemID 8:RowAttribute 9:FK_AdSpecialGroupName (ID) 10:RowPosition (not index based)
//11:FK_DateID
oleDbCommand.Parameters.AddWithValue("Sold", salesTable.Rows[i][1]);
oleDbCommand.Parameters.AddWithValue("SalesPrice", salesTable.Rows[i][2]);
oleDbCommand.Parameters.AddWithValue("TotalSales", salesTable.Rows[i][3]);
oleDbCommand.Parameters.AddWithValue("Cost", salesTable.Rows[i][4]);
oleDbCommand.Parameters.AddWithValue("ProfitReturn", salesTable.Rows[i][5]);
oleDbCommand.Parameters.AddWithValue("TotalProfitReturn", salesTable.Rows[i][6]);
oleDbCommand.Parameters.AddWithValue("RowAttribute", salesTable.Rows[i][8]);
oleDbCommand.Parameters.AddWithValue("adSpecialID", salesTable.Rows[i][9]);
oleDbCommand.Parameters.AddWithValue("RowPosition", salesTable.Rows[i][10]);
oleDbCommand.Parameters.AddWithValue("ID", salesTable.Rows[i][0]);
oleDbCommand.ExecuteNonQuery();
oleDbCommand.Parameters.Clear();
rowIndex++;
}
oleDbTransaction.Commit();
wasSuccessful = true;
}
catch (OleDbException ex)
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed to update the database for " + salesTable.TableName + ": " + ex.Message);
if (rowIndex <= 0)
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Failed to begin parsing data rows, var dump of erroneous row unavailable.");
}
else
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Failed on row " + (rowIndex + 1) + " due to the above error. Dumping contents of row " + (rowIndex + 1) + " from " + salesTable.TableName + ".");
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Ad Item ID: \"" +
salesTable.Rows[rowIndex][7] + "\" Sold: \"" + salesTable.Rows[rowIndex][1] + "\"");
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Sale Price: \"" + salesTable.Rows[rowIndex][2] + "\" Total Sales: \"" + salesTable.Rows[rowIndex][3] + "\"");
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Cost: \"" + salesTable.Rows[rowIndex][4] + "\" Profit Return: \"" + salesTable.Rows[rowIndex][5] + "\"");
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Total Profit Return: \"" +
salesTable.Rows[rowIndex][6] + "\" Ad Special Group: \"" + salesTable.Rows[rowIndex][9] + "\"");
}
oleDbTransaction?.Rollback();
_logConsole.WriteToLog(FrmLogConsole.Level.Critical, "Rollback completed successfully, " + salesTable.TableName + " table failed on update.");
}
finally
{
_oleDbConnection.Close();
}
return wasSuccessful;
}
/// <summary>
/// Inserts a new ad item into the database and returns the new item's ID number.
/// Supports rolling back as to not corrupt the database.
/// </summary>
/// <param name="adItemName">The ad item's name that is to be added.</param>
/// <param name="oleDbCommand">A reference to a command that already has a transaction active.</param>
/// <returns>The ID number of the ad item that was just added.</returns>
public int InsertNewAdItem(string adItemName, OleDbCommand oleDbCommand = null)
{
var adItemId = 0;
var needsTransaction = false;
if (oleDbCommand == null)
{
oleDbCommand = new OleDbCommand
{
Connection = _oleDbConnection
};
needsTransaction = true;
}
oleDbCommand.CommandText = "INSERT INTO AdItem (AdItem) VALUES (?)";
oleDbCommand.Parameters.Clear();
oleDbCommand.Parameters.AddWithValue("AdItem", adItemName);
OleDbTransaction oleDbTransaction = null;
try
{
if (needsTransaction)
{
//If the OleDbCommand object is not supplied, then we'll need to create and assign the transaction object.
oleDbCommand.Connection = _oleDbConnection;
_oleDbConnection.Open();
oleDbTransaction = _oleDbConnection.BeginTransaction();
oleDbCommand.Transaction = oleDbTransaction;
}
if (oleDbCommand.ExecuteNonQuery() == 1)
{
oleDbCommand.CommandText = "SELECT ID FROM AdItem WHERE AdItem.AdItem = ?";
oleDbCommand.Parameters.Clear();
oleDbCommand.Parameters.AddWithValue("AdItem", adItemName);
var reader = oleDbCommand.ExecuteReader();
//Get the ID of the new ad item.
while (reader != null && reader.Read())
{
int.TryParse(reader[0].ToString(), out adItemId);
}
reader?.Close();
if (adItemId != 0)
{
//All was successful.
oleDbTransaction?.Commit();
}
else
{
//
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Ad item \"" + adItemName + "\" was not found in the database; rolling back changes.");
oleDbTransaction?.Rollback();
}
}
else
{
//Something failed but wasn't caught.
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Failed to add the ad item \"" + adItemName + "\" into the database.");
oleDbTransaction?.Rollback();
}
}
catch (OleDbException e)
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error, e.Message);
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Failed to insert ad item " + adItemName + " into the database.");
oleDbTransaction?.Rollback();
}
finally
{
if (needsTransaction)
{
_oleDbConnection.Close();
}
}
return adItemId;
}
/// <summary>
/// Infrastructure for the DatabaseWriter class, not meant to be used with external code.
/// Grabs the ID of the specified row.
/// </summary>
/// <param name="tableName">The name of the table to check for the row in.</param>
/// <param name="adItemId">The ID of the ad item in the row.</param>
/// <param name="dateId">The ID of the date in the row.</param>
/// <returns>The ID of the row, zero(0) if no rows are found.</returns>
private int RetrieveRowId(string tableName, int adItemId, int dateId)
{
var id = 0;
var rowsEffected = 0;
var oleDbCommand = new OleDbCommand
{
CommandText = "SELECT ID FROM " + tableName + " WHERE FK_AdItemID = ? AND FK_DateID = ?",
Connection = _oleDbConnection
};
oleDbCommand.Parameters.AddWithValue("AdItemID", adItemId);
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
try
{
_oleDbConnection.Open();
var reader = oleDbCommand.ExecuteReader();
while (reader != null && reader.Read())
{
rowsEffected++;
int.TryParse(reader[0].ToString(), out id);
}
reader?.Close();
if (rowsEffected > 1)
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Redundancy found row with the ad item ID " + adItemId + " with the date ID " + dateId + ".");
}
}
catch (OleDbException e)
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed to look up the existence of a row with the ad item ID " + adItemId + " with the date ID " + dateId + ".");
_logConsole.WriteToLog(FrmLogConsole.Level.Error, e.Message);
}
_oleDbConnection.Close();
return id;
}
#endregion
//10 to 1 ratio of tries to code
//http://codebetter.com/karlseguin/2006/04/05/understanding-and-using-exceptions/nfrastructure
@@ -330,7 +27,7 @@ namespace AdvertsingProfitControl
CommandText = "INSERT INTO WeekEnding(EndOfWeekDate) VALUES ( dateString )"
};
oleDbCommand.Parameters.AddWithValue("dateString", dateString);
oleDbCommand.Connection = _oleDbConnection;
oleDbCommand.Connection = _connectionobject;
//Try to execute the query
try
{
@@ -338,8 +35,8 @@ namespace AdvertsingProfitControl
//Check for the existence of the date string that was provided.
oleDbCommand.CommandText = "SELECT ID FROM WeekEnding WHERE EndOfWeekDate = @dateString";
oleDbCommand.Parameters.AddWithValue("@dateString", dateString);
oleDbCommand.Connection = _oleDbConnection;
_oleDbConnection.Open();
oleDbCommand.Connection = _connectionobject;
_connectionobject.Open();
//Execute the SELECT statement and retrieve the row(s) effected.
var reader = oleDbCommand.ExecuteReader();
var recordIndex = 0;
@@ -351,7 +48,7 @@ namespace AdvertsingProfitControl
}
recordIndex++;
}
reader?.Close();
if (reader != null) reader.Close();
//IF one row was affected, then return with "True", since the value is already there.
if (numberOfRowsEffected == 1)
{
@@ -406,7 +103,7 @@ namespace AdvertsingProfitControl
finally
{
//Make certain that the connection is closed before returning.
_oleDbConnection.Close();
_connectionobject.Close();
}
return insertWasSuccessful;
@@ -418,7 +115,7 @@ namespace AdvertsingProfitControl
var insertWasSuccessful = false;
var storedComment = "";
//Set up the command object, SQL command string and parameters.
var oleDbCommand = new OleDbCommand {Connection = _oleDbConnection};
var oleDbCommand = new OleDbCommand {Connection = _connectionobject};
//Try to execute the query
try
{
@@ -430,7 +127,7 @@ namespace AdvertsingProfitControl
oleDbCommand.CommandText = "SELECT Comment FROM Comment WHERE FK_DateID = dateID";
oleDbCommand.Parameters.Clear();
oleDbCommand.Parameters.AddWithValue("dateID", dateIdString);
_oleDbConnection.Open();
_connectionobject.Open();
//OpenConnection();
var reader = oleDbCommand.ExecuteReader();
var recordIndex = 0;
@@ -449,7 +146,7 @@ namespace AdvertsingProfitControl
recordIndex++;
}
}
reader?.Close();
if (reader != null) reader.Close();
//IF there is a comment that has the same date then check to see if it is the same as the one entered.
if (recordIndex == 1)
{
@@ -538,7 +235,7 @@ namespace AdvertsingProfitControl
finally
{
//Make certain that the connection is closed before returning.
_oleDbConnection.Close();
_connectionobject.Close();
}
return insertWasSuccessful;
@@ -560,7 +257,7 @@ namespace AdvertsingProfitControl
var noRowsAdded = new List<int> {0};
return noRowsAdded;
}
_oleDbConnection.Open();
_connectionobject.Open();
var rowsAdded = new List<int>();
var rowNumber = 0;
//DataTable's structure will reflect the APC database table structure.
@@ -612,7 +309,7 @@ namespace AdvertsingProfitControl
oleDbCommand.Parameters.AddWithValue("AdItemID", adItemId);
oleDbCommand.Parameters.AddWithValue("GroupID", row[19]);
oleDbCommand.Parameters.AddWithValue("dateID", row[20]);
oleDbCommand.Connection = _oleDbConnection;
oleDbCommand.Connection = _connectionobject;
try
{
@@ -631,7 +328,7 @@ namespace AdvertsingProfitControl
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "An error occurred trying to write a record to the APC table.");
_logConsole.WriteToLog(FrmLogConsole.Level.Debug, e.Message);
_oleDbConnection.Close();
_connectionobject.Close();
//Add an error code at the end of array of rows that were added to show an error occurred.
rowsAdded.Add(-1);
return rowsAdded;
@@ -646,7 +343,7 @@ namespace AdvertsingProfitControl
rowsAdded.Add(0);
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "An error occurred trying to update a record APC table.");
_logConsole.WriteToLog(FrmLogConsole.Level.Debug, "An error occurred trying to update ad item ID " + adItemId + " and dateID " + dateId + ".");
_oleDbConnection.Close();
_connectionobject.Close();
return rowsAdded;
}
}
@@ -654,7 +351,7 @@ namespace AdvertsingProfitControl
}
//Close the database connection before returning.
_oleDbConnection.Close();
_connectionobject.Close();
return rowsAdded;
}
@@ -673,16 +370,15 @@ namespace AdvertsingProfitControl
oleDbCommand.CommandText = "SELECT ID FROM APC WHERE FK_AdItemID = adItemID AND FK_DateID = dateID";
oleDbCommand.Parameters.AddWithValue("adItemID", adItemId);
oleDbCommand.Parameters.AddWithValue("dateID", dateId);
oleDbCommand.Connection = _oleDbConnection;
oleDbCommand.Connection = _connectionobject;
try
{
oleDbCommand.Transaction = _oleDbConnection.BeginTransaction();
var reader = oleDbCommand.ExecuteReader();
while (reader != null && reader.Read())
{
rowsEffected++;
}
reader?.Close();
if (reader != null) reader.Close();
}
catch (OleDbException ex)
{
@@ -728,12 +424,10 @@ namespace AdvertsingProfitControl
}
//Record the number of rows affected when the statement is executed, again assume nothing was affected.
var adItemId = "0";
var oleDbCommand = new OleDbCommand
{
CommandText = "INSERT INTO AdItem (AdItem) VALUES (?)",
Connection = _oleDbConnection
};
var oleDbCommand = new OleDbCommand();
oleDbCommand.CommandText = "INSERT INTO AdItem (AdItem) VALUES (?)";
oleDbCommand.Parameters.AddWithValue("adItem", adItemName);
oleDbCommand.Connection = _connectionobject;
//Attempt to execute the INSERT SQL statement.
try
{
@@ -749,7 +443,7 @@ namespace AdvertsingProfitControl
{
adItemId = reader[0].ToString();
}
reader?.Close();
if (reader != null) reader.Close();
}
//ELSE IF more then one (1) row was affected...
else if (rowsEffected > 1)
@@ -793,7 +487,7 @@ namespace AdvertsingProfitControl
}
var oleDbCommand = new OleDbCommand {CommandText = "SELECT ID FROM AdItem WHERE UCASE(AdItem.AdItem) = UCASE(adItemName)"};
oleDbCommand.Parameters.AddWithValue("adItemName", adItemName);
oleDbCommand.Connection = _oleDbConnection;
oleDbCommand.Connection = _connectionobject;
try
{
@@ -863,7 +557,7 @@ namespace AdvertsingProfitControl
oleDbCommand.Parameters.AddWithValue("groupID", parameters[19]);
oleDbCommand.Parameters.AddWithValue("dateID", parameters[20]);
oleDbCommand.Parameters.AddWithValue("adItemID", adItemId);
oleDbCommand.Connection = _oleDbConnection;
oleDbCommand.Connection = _connectionobject;
try
{
@@ -903,22 +597,22 @@ namespace AdvertsingProfitControl
var supplierQueryCommand = new OleDbCommand
{
CommandText = "SELECT ID FROM Supplier WHERE SupplierName = ?",
Connection = _oleDbConnection
Connection = _connectionobject
};
//Grabbing the ID of the invoice by the invoice number and the supplier's ID.
var invoiceCheckCommand = new OleDbCommand
{
CommandText = "SELECT ID FROM Invoice WHERE InvoiceNumber = ? AND FK_Supplier = ?",
Connection = _oleDbConnection
Connection = _connectionobject
};
//Inserting a new record into the Invoice table.
var insertNewInvoice = new OleDbCommand
{
CommandText =
"INSERT INTO Invoice (InvoiceDate, InvoiceNumber, InvoiceNetAmountAtCost, InvoiceNetAmount, InvoiceNote, FK_Supplier, FK_DateID) VALUES (?, ?, ?, ?, ?, ?, ?)",
Connection = _oleDbConnection
Connection = _connectionobject
};
_oleDbConnection.Open();
_connectionobject.Open();
foreach (DataRow row in parameters.Rows)
{
var itemCount = 0;
@@ -1042,12 +736,12 @@ namespace AdvertsingProfitControl
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed to write supplier " + row[1] + " into the invoice table.");
_logConsole.WriteToLog(FrmLogConsole.Level.Debug, e.Message);
_oleDbConnection.Close();
_connectionobject.Close();
break;
}
}
_oleDbConnection.Close();
_connectionobject.Close();
return rowsAdded;
}
/// <summary>
@@ -1073,7 +767,7 @@ namespace AdvertsingProfitControl
var supplierNameId = "0";
var oleDbCommand = new OleDbCommand {CommandText = "INSERT INTO Supplier (SupplierName) VALUES (?)"};
oleDbCommand.Parameters.AddWithValue("SupplierName", supplierName);
oleDbCommand.Connection = _oleDbConnection;
oleDbCommand.Connection = _connectionobject;
try
{
@@ -1131,7 +825,7 @@ namespace AdvertsingProfitControl
oleDbCommand.Parameters.AddWithValue("InvoiceNumber", invoiceField[2]);
oleDbCommand.Parameters.AddWithValue("SupplierID", supplierId);
oleDbCommand.Parameters.AddWithValue("DateID", invoiceField[6]);
oleDbCommand.Connection = _oleDbConnection;
oleDbCommand.Connection = _connectionobject;
try
{
@@ -1169,7 +863,7 @@ namespace AdvertsingProfitControl
CommandText = "SELECT ID FROM WeeklySales WHERE FK_DateID = ?"
};
weekEndingDateCheck.Parameters.AddWithValue("DateID", parameters[8]);
weekEndingDateCheck.Connection = _oleDbConnection;
weekEndingDateCheck.Connection = _connectionobject;
//Object to update a field with the date supplied, assuming an entry was found with the previous object.
var updateWeeklySales = new OleDbCommand
{
@@ -1185,7 +879,7 @@ namespace AdvertsingProfitControl
updateWeeklySales.Parameters.AddWithValue("Saturday", parameters[6]);
updateWeeklySales.Parameters.AddWithValue("TotalSales", parameters[7]);
updateWeeklySales.Parameters.AddWithValue("DateID", parameters[8]);
updateWeeklySales.Connection = _oleDbConnection;
updateWeeklySales.Connection = _connectionobject;
//Object to insert a new field into the database if no entry is present.
var insertWeeklySales = new OleDbCommand
{
@@ -1201,10 +895,10 @@ namespace AdvertsingProfitControl
insertWeeklySales.Parameters.AddWithValue("Saturday", parameters[6]);
insertWeeklySales.Parameters.AddWithValue("TotalSales", parameters[7]);
insertWeeklySales.Parameters.AddWithValue("DateID", parameters[8]);
insertWeeklySales.Connection = _oleDbConnection;
insertWeeklySales.Connection = _connectionobject;
try
{
_oleDbConnection.Open();
_connectionobject.Open();
//Execute the select statement to check for the presence of an entry with the supplied date (parameters[8]).
var reader = weekEndingDateCheck.ExecuteReader();
@@ -1237,7 +931,7 @@ namespace AdvertsingProfitControl
}
finally
{
_oleDbConnection.Close();
_connectionobject.Close();
}
return rowsEffected;
@@ -1253,18 +947,18 @@ namespace AdvertsingProfitControl
CommandText = "SELECT ID FROM GroupCategory WHERE GroupDescription = ?"
};
categoryDescCheckQueryCommand.Parameters.AddWithValue("GroupName", groupName);
categoryDescCheckQueryCommand.Connection = _oleDbConnection;
categoryDescCheckQueryCommand.Connection = _connectionobject;
//Setting up an object to insert a new ad special keyword.
var insertNewCategoryDesc = new OleDbCommand
{
CommandText = "INSERT INTO GroupCategory (GroupDescription) VALUES (?)"
};
insertNewCategoryDesc.Parameters.AddWithValue("GroupName", groupName);
insertNewCategoryDesc.Connection = _oleDbConnection;
insertNewCategoryDesc.Connection = _connectionobject;
try
{
_oleDbConnection.Open();
_connectionobject.Open();
var reader = categoryDescCheckQueryCommand.ExecuteReader();
while (reader != null && reader.Read())
@@ -1291,7 +985,7 @@ namespace AdvertsingProfitControl
}
finally
{
_oleDbConnection.Close();
_connectionobject.Close();
}
return rowsEffected;
@@ -1305,11 +999,11 @@ namespace AdvertsingProfitControl
CommandText = "DELETE FROM GroupCategory WHERE GroupDescription = ?"
};
oleDbCommand.Parameters.AddWithValue("AdSpecialName", adSpecialName);
oleDbCommand.Connection = _oleDbConnection;
oleDbCommand.Connection = _connectionobject;
try
{
_oleDbConnection.Open();
_connectionobject.Open();
rowsEffected = oleDbCommand.ExecuteNonQuery();
}
catch (OleDbException e)
@@ -1320,7 +1014,7 @@ namespace AdvertsingProfitControl
}
finally
{
_oleDbConnection.Close();
_connectionobject.Close();
}
return rowsEffected;
@@ -1335,11 +1029,11 @@ namespace AdvertsingProfitControl
};
deleteCommand.Parameters.AddWithValue("AdItemID", adItemId);
deleteCommand.Parameters.AddWithValue("DateID", dateId);
deleteCommand.Connection = _oleDbConnection;
deleteCommand.Connection = _connectionobject;
try
{
_oleDbConnection.Open();
_connectionobject.Open();
recordsDeleted = deleteCommand.ExecuteNonQuery();
}
catch (OleDbException e)
@@ -1349,7 +1043,7 @@ namespace AdvertsingProfitControl
}
finally
{
_oleDbConnection.Close();
_connectionobject.Close();
}
return recordsDeleted;
@@ -1364,11 +1058,11 @@ namespace AdvertsingProfitControl
};
oleDbCommand.Parameters.AddWithValue("InvoiceNumber", invoiceNumber);
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
oleDbCommand.Connection = _oleDbConnection;
oleDbCommand.Connection = _connectionobject;
try
{
_oleDbConnection.Open();
_connectionobject.Open();
recordsAffected = oleDbCommand.ExecuteNonQuery();
}
catch (OleDbException e)
@@ -1378,7 +1072,7 @@ namespace AdvertsingProfitControl
}
finally
{
_oleDbConnection.Close();
_connectionobject.Close();
}
return recordsAffected;
@@ -1399,39 +1093,39 @@ namespace AdvertsingProfitControl
CommandText = "DELETE FROM APC WHERE FK_DateID = ?"
};
clearApCommand.Parameters.AddWithValue("DateID", dateId);
clearApCommand.Connection = _oleDbConnection;
clearApCommand.Connection = _connectionobject;
//Object to clear comments associated with the date ID.
var clearCommentsCommand = new OleDbCommand()
{
CommandText = "DELETE FROM Comment WHERE FK_DateID = ?"
};
clearCommentsCommand.Parameters.AddWithValue("DateID", dateId);
clearCommentsCommand.Connection = _oleDbConnection;
clearCommentsCommand.Connection = _connectionobject;
//Object to clear the invoices associated with the date ID.
var clearInvoicesCommand = new OleDbCommand()
{
CommandText = "DELETE FROM Invoice WHERE FK_DateID = ?"
};
clearInvoicesCommand.Parameters.AddWithValue("DateID", dateId);
clearInvoicesCommand.Connection = _oleDbConnection;
clearInvoicesCommand.Connection = _connectionobject;
//Object to clear the weekly sales associated with the date ID.
var clearWeeklySalesCommand = new OleDbCommand()
{
CommandText = "DELETE FROM WeeklySales WHERE FK_DateID = ?"
};
clearWeeklySalesCommand.Parameters.AddWithValue("DateID", dateId);
clearWeeklySalesCommand.Connection = _oleDbConnection;
clearWeeklySalesCommand.Connection = _connectionobject;
//Object to clear the date associated with the ID passed in.
var clearEndOfWeekDateCommand = new OleDbCommand()
{
CommandText = "DELETE FROM WeekEnding WHERE ID = ?"
};
clearEndOfWeekDateCommand.Parameters.AddWithValue("DateID", dateId);
clearEndOfWeekDateCommand.Connection = _oleDbConnection;
clearEndOfWeekDateCommand.Connection = _connectionobject;
try
{
_oleDbConnection.Open();
_connectionobject.Open();
recordsRemoved += clearApCommand.ExecuteNonQuery();
recordsRemoved += clearCommentsCommand.ExecuteNonQuery();
recordsRemoved += clearInvoicesCommand.ExecuteNonQuery();
@@ -1445,7 +1139,7 @@ namespace AdvertsingProfitControl
}
finally
{
_oleDbConnection.Close();
_connectionobject.Close();
}
return recordsRemoved;
}
@@ -1467,12 +1161,12 @@ namespace AdvertsingProfitControl
};
oleDbCommand.Parameters.AddWithValue("Comment", comment);
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
oleDbCommand.Connection = _oleDbConnection;
oleDbCommand.Connection = _connectionobject;
try
{
//IF the delete command deletes more then one row it returns 0.
_oleDbConnection.Open();
_connectionobject.Open();
var recordsEffected = oleDbCommand.ExecuteNonQuery();
if (recordsEffected == 1)
{
@@ -1486,110 +1180,10 @@ namespace AdvertsingProfitControl
}
finally
{
_oleDbConnection.Close();
_connectionobject.Close();
}
return wasSuccessful;
}
public bool RemoveAdItem(string adItemName)
{
var success = false;
var oleDbCommand = new OleDbCommand
{
CommandText = "DELETE FROM AdItem WHERE AdItem = ?"
};
oleDbCommand.Parameters.AddWithValue("AdItemName", adItemName);
oleDbCommand.Connection = _oleDbConnection;
try
{
_oleDbConnection.Open();
var rowsEffected = oleDbCommand.ExecuteNonQuery();
if(rowsEffected == 1)
{
success = true;
}
else if(rowsEffected > 1)
{
_logConsole.WriteToLog(FrmLogConsole.Level.Info, "Removed redundant entry " + adItemName + " from the database successfully.");
success = true;
}
else
{
}
}
catch (OleDbException e)
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed to delete the ad item " + adItemName + " from the database.");
_logConsole.WriteToLog(FrmLogConsole.Level.Error, e.Message);
}
finally
{
_oleDbConnection.Close();
}
return success;
}
public bool AddNewItem(string adItemName)
{
var success = false;
var oleDbCommand = new OleDbCommand
{
CommandText = "INSERT INTO AdItem (AdItem) VALUES (?)"
};
oleDbCommand.Parameters.AddWithValue("AdItemName", adItemName);
oleDbCommand.Connection = _oleDbConnection;
var redundantancyCheck = new OleDbCommand
{
CommandText = "SELECT AdItem FROM AdItem WHERE AdItem = ?"
};
redundantancyCheck.Parameters.AddWithValue("AdItemName", adItemName);
redundantancyCheck.Connection = _oleDbConnection;
try
{
_oleDbConnection.Open();
using(var reader = redundantancyCheck.ExecuteReader())
{
var rows = 0;
while(reader != null && reader.Read())
{
rows++;
}
if(rows == 0)
{
var rowsEffected = oleDbCommand.ExecuteNonQuery();
if (rowsEffected == 1)
{
success = true;
}
else
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed to insert new ad item " + adItemName + ".");
}
}
else
{
success = true;
_logConsole.WriteToLog(FrmLogConsole.Level.Debug, "Ad Item " + adItemName + " found with " + rows + " row(s).");
}
}
}
catch (OleDbException e)
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed to add the new ad item " + adItemName + " to the database.");
_logConsole.WriteToLog(FrmLogConsole.Level.Error, e.Message);
}
finally
{
_oleDbConnection.Close();
}
return success;
}
}
}
@@ -47,7 +47,6 @@ namespace AdvertsingProfitControl
if (rowsEffected == 1)
{
RowParsing.AdSpecialGroups.Add(enterNewKeyWordTextBox.Text);
var groupNameCollection = databaseReader.ReturnGroupNameList(databaseTracker.DatabaseConnectionString);
adSpecialKeyWordsListBox.Items.Clear();
foreach (var groupName in groupNameCollection)
+82 -72
View File
@@ -51,6 +51,7 @@
this.commentsTextBox = new System.Windows.Forms.TextBox();
this.errorReportingLabel = new System.Windows.Forms.Label();
this.addRecordsButton = new System.Windows.Forms.Button();
this.inventoryTabPage = new System.Windows.Forms.TabPage();
this.mainLayoutPanel.SuspendLayout();
this.addRecordTabControl.SuspendLayout();
this.projectionsTabPage.SuspendLayout();
@@ -71,43 +72,44 @@
//
this.mainLayoutPanel.ColumnCount = 1;
this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 37F));
this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.mainLayoutPanel.Controls.Add(this.addRecordTabControl, 0, 1);
this.mainLayoutPanel.Controls.Add(this.mainMenu, 0, 0);
this.mainLayoutPanel.Controls.Add(this.commentsAndDateLayoutPanel, 0, 2);
this.mainLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.mainLayoutPanel.Location = new System.Drawing.Point(0, 0);
this.mainLayoutPanel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.mainLayoutPanel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.mainLayoutPanel.Name = "mainLayoutPanel";
this.mainLayoutPanel.RowCount = 3;
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 46F));
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 38F));
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 80F));
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
this.mainLayoutPanel.Size = new System.Drawing.Size(1562, 894);
this.mainLayoutPanel.Size = new System.Drawing.Size(1278, 745);
this.mainLayoutPanel.TabIndex = 0;
//
// addRecordTabControl
//
this.addRecordTabControl.Controls.Add(this.projectionsTabPage);
this.addRecordTabControl.Controls.Add(this.inventoryTabPage);
this.addRecordTabControl.Controls.Add(this.actualSalesTabPage);
this.addRecordTabControl.Controls.Add(this.suppliersTabPage);
this.addRecordTabControl.Controls.Add(this.weeklySalesTabPage);
this.addRecordTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.addRecordTabControl.Location = new System.Drawing.Point(5, 52);
this.addRecordTabControl.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.addRecordTabControl.Location = new System.Drawing.Point(4, 43);
this.addRecordTabControl.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.addRecordTabControl.Name = "addRecordTabControl";
this.addRecordTabControl.SelectedIndex = 0;
this.addRecordTabControl.Size = new System.Drawing.Size(1552, 666);
this.addRecordTabControl.Size = new System.Drawing.Size(1270, 555);
this.addRecordTabControl.TabIndex = 1;
//
// projectionsTabPage
//
this.projectionsTabPage.Controls.Add(this.projectionsDataGridView);
this.projectionsTabPage.Location = new System.Drawing.Point(4, 33);
this.projectionsTabPage.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.projectionsTabPage.Location = new System.Drawing.Point(4, 29);
this.projectionsTabPage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.projectionsTabPage.Name = "projectionsTabPage";
this.projectionsTabPage.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.projectionsTabPage.Size = new System.Drawing.Size(1544, 629);
this.projectionsTabPage.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.projectionsTabPage.Size = new System.Drawing.Size(1262, 522);
this.projectionsTabPage.TabIndex = 0;
this.projectionsTabPage.Text = "Projections";
this.projectionsTabPage.UseVisualStyleBackColor = true;
@@ -119,21 +121,21 @@
this.projectionsDataGridView.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.projectionsDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.projectionsDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.projectionsDataGridView.Location = new System.Drawing.Point(5, 6);
this.projectionsDataGridView.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.projectionsDataGridView.Location = new System.Drawing.Point(4, 5);
this.projectionsDataGridView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.projectionsDataGridView.MultiSelect = false;
this.projectionsDataGridView.Name = "projectionsDataGridView";
this.projectionsDataGridView.Size = new System.Drawing.Size(1534, 617);
this.projectionsDataGridView.Size = new System.Drawing.Size(1254, 512);
this.projectionsDataGridView.TabIndex = 0;
//
// actualSalesTabPage
//
this.actualSalesTabPage.Controls.Add(this.actualSalesDataGridView);
this.actualSalesTabPage.Location = new System.Drawing.Point(4, 33);
this.actualSalesTabPage.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.actualSalesTabPage.Location = new System.Drawing.Point(4, 29);
this.actualSalesTabPage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.actualSalesTabPage.Name = "actualSalesTabPage";
this.actualSalesTabPage.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.actualSalesTabPage.Size = new System.Drawing.Size(1544, 629);
this.actualSalesTabPage.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.actualSalesTabPage.Size = new System.Drawing.Size(1262, 522);
this.actualSalesTabPage.TabIndex = 1;
this.actualSalesTabPage.Text = "Actual Sales";
this.actualSalesTabPage.UseVisualStyleBackColor = true;
@@ -145,21 +147,21 @@
this.actualSalesDataGridView.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.actualSalesDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.actualSalesDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.actualSalesDataGridView.Location = new System.Drawing.Point(5, 6);
this.actualSalesDataGridView.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.actualSalesDataGridView.Location = new System.Drawing.Point(4, 5);
this.actualSalesDataGridView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.actualSalesDataGridView.MultiSelect = false;
this.actualSalesDataGridView.Name = "actualSalesDataGridView";
this.actualSalesDataGridView.Size = new System.Drawing.Size(1534, 617);
this.actualSalesDataGridView.Size = new System.Drawing.Size(1254, 512);
this.actualSalesDataGridView.TabIndex = 0;
//
// suppliersTabPage
//
this.suppliersTabPage.Controls.Add(this.suppliersDataGridView);
this.suppliersTabPage.Location = new System.Drawing.Point(4, 33);
this.suppliersTabPage.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.suppliersTabPage.Location = new System.Drawing.Point(4, 29);
this.suppliersTabPage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.suppliersTabPage.Name = "suppliersTabPage";
this.suppliersTabPage.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.suppliersTabPage.Size = new System.Drawing.Size(1544, 629);
this.suppliersTabPage.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.suppliersTabPage.Size = new System.Drawing.Size(1262, 522);
this.suppliersTabPage.TabIndex = 2;
this.suppliersTabPage.Text = "Suppliers";
this.suppliersTabPage.UseVisualStyleBackColor = true;
@@ -171,21 +173,21 @@
this.suppliersDataGridView.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.suppliersDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.suppliersDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.suppliersDataGridView.Location = new System.Drawing.Point(5, 6);
this.suppliersDataGridView.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.suppliersDataGridView.Location = new System.Drawing.Point(4, 5);
this.suppliersDataGridView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.suppliersDataGridView.MultiSelect = false;
this.suppliersDataGridView.Name = "suppliersDataGridView";
this.suppliersDataGridView.Size = new System.Drawing.Size(1534, 617);
this.suppliersDataGridView.Size = new System.Drawing.Size(1254, 512);
this.suppliersDataGridView.TabIndex = 0;
//
// weeklySalesTabPage
//
this.weeklySalesTabPage.Controls.Add(this.weeklySalesDataGridView);
this.weeklySalesTabPage.Location = new System.Drawing.Point(4, 33);
this.weeklySalesTabPage.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.weeklySalesTabPage.Location = new System.Drawing.Point(4, 29);
this.weeklySalesTabPage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.weeklySalesTabPage.Name = "weeklySalesTabPage";
this.weeklySalesTabPage.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.weeklySalesTabPage.Size = new System.Drawing.Size(1544, 629);
this.weeklySalesTabPage.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.weeklySalesTabPage.Size = new System.Drawing.Size(1262, 522);
this.weeklySalesTabPage.TabIndex = 3;
this.weeklySalesTabPage.Text = "Weekly Sales";
this.weeklySalesTabPage.UseVisualStyleBackColor = true;
@@ -199,22 +201,21 @@
this.weeklySalesDataGridView.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.weeklySalesDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.weeklySalesDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.weeklySalesDataGridView.Location = new System.Drawing.Point(5, 6);
this.weeklySalesDataGridView.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.weeklySalesDataGridView.Location = new System.Drawing.Point(4, 5);
this.weeklySalesDataGridView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.weeklySalesDataGridView.MultiSelect = false;
this.weeklySalesDataGridView.Name = "weeklySalesDataGridView";
this.weeklySalesDataGridView.Size = new System.Drawing.Size(1534, 617);
this.weeklySalesDataGridView.Size = new System.Drawing.Size(1254, 512);
this.weeklySalesDataGridView.TabIndex = 0;
//
// mainMenu
//
this.mainMenu.ImageScalingSize = new System.Drawing.Size(24, 24);
this.mainMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileMainMenu});
this.mainMenu.Location = new System.Drawing.Point(0, 0);
this.mainMenu.Name = "mainMenu";
this.mainMenu.Padding = new System.Windows.Forms.Padding(11, 4, 0, 4);
this.mainMenu.Size = new System.Drawing.Size(1562, 42);
this.mainMenu.Padding = new System.Windows.Forms.Padding(9, 3, 0, 3);
this.mainMenu.Size = new System.Drawing.Size(1278, 35);
this.mainMenu.TabIndex = 2;
this.mainMenu.Text = "menuStrip1";
//
@@ -224,20 +225,20 @@
this.clearFormFileMainMenu,
this.closeFormFileMainMenu});
this.fileMainMenu.Name = "fileMainMenu";
this.fileMainMenu.Size = new System.Drawing.Size(56, 34);
this.fileMainMenu.Size = new System.Drawing.Size(50, 29);
this.fileMainMenu.Text = "&File";
//
// clearFormFileMainMenu
//
this.clearFormFileMainMenu.Name = "clearFormFileMainMenu";
this.clearFormFileMainMenu.Size = new System.Drawing.Size(208, 34);
this.clearFormFileMainMenu.Size = new System.Drawing.Size(174, 30);
this.clearFormFileMainMenu.Text = "C&lear Form";
this.clearFormFileMainMenu.Click += new System.EventHandler(this.clearFormFileMainMenu_Click);
//
// closeFormFileMainMenu
//
this.closeFormFileMainMenu.Name = "closeFormFileMainMenu";
this.closeFormFileMainMenu.Size = new System.Drawing.Size(208, 34);
this.closeFormFileMainMenu.Size = new System.Drawing.Size(174, 30);
this.closeFormFileMainMenu.Text = "&Close Form";
this.closeFormFileMainMenu.Click += new System.EventHandler(this.closeFileMainMenu_Click);
//
@@ -254,12 +255,12 @@
this.commentsAndDateLayoutPanel.Controls.Add(this.errorReportingLabel, 2, 0);
this.commentsAndDateLayoutPanel.Controls.Add(this.addRecordsButton, 3, 0);
this.commentsAndDateLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.commentsAndDateLayoutPanel.Location = new System.Drawing.Point(5, 730);
this.commentsAndDateLayoutPanel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.commentsAndDateLayoutPanel.Location = new System.Drawing.Point(4, 608);
this.commentsAndDateLayoutPanel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.commentsAndDateLayoutPanel.Name = "commentsAndDateLayoutPanel";
this.commentsAndDateLayoutPanel.RowCount = 1;
this.commentsAndDateLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.commentsAndDateLayoutPanel.Size = new System.Drawing.Size(1552, 158);
this.commentsAndDateLayoutPanel.Size = new System.Drawing.Size(1270, 132);
this.commentsAndDateLayoutPanel.TabIndex = 3;
//
// dateGroupBox
@@ -267,11 +268,11 @@
this.dateGroupBox.Controls.Add(this.dateFormatLabel);
this.dateGroupBox.Controls.Add(this.weekEndingDateMaskedTextBox);
this.dateGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.dateGroupBox.Location = new System.Drawing.Point(5, 6);
this.dateGroupBox.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.dateGroupBox.Location = new System.Drawing.Point(4, 5);
this.dateGroupBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.dateGroupBox.Name = "dateGroupBox";
this.dateGroupBox.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.dateGroupBox.Size = new System.Drawing.Size(222, 146);
this.dateGroupBox.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.dateGroupBox.Size = new System.Drawing.Size(182, 122);
this.dateGroupBox.TabIndex = 0;
this.dateGroupBox.TabStop = false;
this.dateGroupBox.Text = "Week Ending Date";
@@ -279,21 +280,20 @@
// dateFormatLabel
//
this.dateFormatLabel.AutoSize = true;
this.dateFormatLabel.Location = new System.Drawing.Point(35, 32);
this.dateFormatLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.dateFormatLabel.Location = new System.Drawing.Point(29, 27);
this.dateFormatLabel.Name = "dateFormatLabel";
this.dateFormatLabel.Size = new System.Drawing.Size(138, 50);
this.dateFormatLabel.Size = new System.Drawing.Size(111, 40);
this.dateFormatLabel.TabIndex = 1;
this.dateFormatLabel.Text = "Date Format: \r\nMM/DD/YYYY";
//
// weekEndingDateMaskedTextBox
//
this.weekEndingDateMaskedTextBox.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.weekEndingDateMaskedTextBox.Location = new System.Drawing.Point(32, 92);
this.weekEndingDateMaskedTextBox.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.weekEndingDateMaskedTextBox.Location = new System.Drawing.Point(26, 77);
this.weekEndingDateMaskedTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.weekEndingDateMaskedTextBox.Mask = "00/00/0000";
this.weekEndingDateMaskedTextBox.Name = "weekEndingDateMaskedTextBox";
this.weekEndingDateMaskedTextBox.Size = new System.Drawing.Size(141, 40);
this.weekEndingDateMaskedTextBox.Size = new System.Drawing.Size(116, 35);
this.weekEndingDateMaskedTextBox.TabIndex = 0;
this.weekEndingDateMaskedTextBox.ValidatingType = typeof(System.DateTime);
//
@@ -301,11 +301,11 @@
//
this.commentsGroupBox.Controls.Add(this.commentsTextBox);
this.commentsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.commentsGroupBox.Location = new System.Drawing.Point(237, 6);
this.commentsGroupBox.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.commentsGroupBox.Location = new System.Drawing.Point(194, 5);
this.commentsGroupBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.commentsGroupBox.Name = "commentsGroupBox";
this.commentsGroupBox.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.commentsGroupBox.Size = new System.Drawing.Size(533, 146);
this.commentsGroupBox.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.commentsGroupBox.Size = new System.Drawing.Size(436, 122);
this.commentsGroupBox.TabIndex = 1;
this.commentsGroupBox.TabStop = false;
this.commentsGroupBox.Text = "Comments";
@@ -313,46 +313,55 @@
// commentsTextBox
//
this.commentsTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.commentsTextBox.Location = new System.Drawing.Point(5, 28);
this.commentsTextBox.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.commentsTextBox.Location = new System.Drawing.Point(4, 24);
this.commentsTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.commentsTextBox.Multiline = true;
this.commentsTextBox.Name = "commentsTextBox";
this.commentsTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.commentsTextBox.Size = new System.Drawing.Size(523, 112);
this.commentsTextBox.Size = new System.Drawing.Size(428, 93);
this.commentsTextBox.TabIndex = 0;
//
// errorReportingLabel
//
this.errorReportingLabel.AutoSize = true;
this.errorReportingLabel.Location = new System.Drawing.Point(780, 0);
this.errorReportingLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.errorReportingLabel.Location = new System.Drawing.Point(638, 0);
this.errorReportingLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.errorReportingLabel.Name = "errorReportingLabel";
this.errorReportingLabel.Size = new System.Drawing.Size(0, 25);
this.errorReportingLabel.Size = new System.Drawing.Size(0, 20);
this.errorReportingLabel.TabIndex = 2;
//
// addRecordsButton
//
this.addRecordsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.addRecordsButton.Location = new System.Drawing.Point(1400, 110);
this.addRecordsButton.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.addRecordsButton.Location = new System.Drawing.Point(1146, 92);
this.addRecordsButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.addRecordsButton.Name = "addRecordsButton";
this.addRecordsButton.Size = new System.Drawing.Size(147, 42);
this.addRecordsButton.Size = new System.Drawing.Size(120, 35);
this.addRecordsButton.TabIndex = 3;
this.addRecordsButton.Text = "Add Records";
this.addRecordsButton.UseVisualStyleBackColor = true;
this.addRecordsButton.Click += new System.EventHandler(this.addRecordsButton_Click);
//
// inventoryTabPage
//
this.inventoryTabPage.Location = new System.Drawing.Point(4, 29);
this.inventoryTabPage.Name = "inventoryTabPage";
this.inventoryTabPage.Size = new System.Drawing.Size(1262, 522);
this.inventoryTabPage.TabIndex = 4;
this.inventoryTabPage.Text = "Inventory";
this.inventoryTabPage.UseVisualStyleBackColor = true;
//
// FrmAddRecord
//
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1562, 894);
this.ClientSize = new System.Drawing.Size(1278, 745);
this.Controls.Add(this.mainLayoutPanel);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.mainMenu;
this.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.MaximumSize = new System.Drawing.Size(1631, 1059);
this.MinimumSize = new System.Drawing.Size(1448, 874);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.MaximumSize = new System.Drawing.Size(1339, 893);
this.MinimumSize = new System.Drawing.Size(1189, 739);
this.Name = "FrmAddRecord";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Add New Records";
@@ -404,6 +413,7 @@
private System.Windows.Forms.Button addRecordsButton;
private System.Windows.Forms.ToolStripMenuItem clearFormFileMainMenu;
private System.Windows.Forms.Label dateFormatLabel;
private System.Windows.Forms.TabPage inventoryTabPage;
}
}
+46 -61
View File
@@ -35,9 +35,6 @@ namespace AdvertsingProfitControl
public FrmAddRecord()
{
InitializeComponent();
//Set the maximum and minimum sizes for the form.
MaximumSize = new Size(1200, 650);
MinimumSize = new Size(1000, 550);
}
private void frmAddRecord_Load(object sender, EventArgs e)
@@ -53,7 +50,7 @@ namespace AdvertsingProfitControl
_AdSpecialList = databaseReader.RetrieveAdSpecialList(databaseTracker.DatabaseConnectionString);
//Event handlers for the Projections DataGridView
projectionsDataGridView.CellValidating += OnCellValidating;
//projectionsDataGridView.RowEnter += DetectAndDisplayIncompleteRows;
projectionsDataGridView.RowEnter += DetectAndDisplayIncompleteRows;
projectionsDataGridView.RowLeave += OnRowLeave;
projectionsDataGridView.RowsAdded += DisplayRowNumbers;
projectionsDataGridView.RowsRemoved += OnRowRemoved;
@@ -62,14 +59,14 @@ namespace AdvertsingProfitControl
projectionsDataGridView.RowValidating += UpdateInventoryActualSalesDataGridView;
//Event handlers for the Inventory / Actual Sales DataGridView
actualSalesDataGridView.CellValidating += OnCellValidating; //
actualSalesDataGridView.CellValidating += OnCellValidating;
actualSalesDataGridView.RowEnter += DetectAndDisplayIncompleteRows;
actualSalesDataGridView.RowLeave += OnRowLeave; //
actualSalesDataGridView.RowsAdded += DisplayRowNumbers;//
actualSalesDataGridView.RowsRemoved += OnRowRemoved;//
actualSalesDataGridView.UserDeletingRow += OnRowRemoving; //
actualSalesDataGridView.EditingControlShowing += DisplayAutoCompleteOnEditingControlShowing; //
actualSalesDataGridView.RowValidating += UpdateProjectionsDataGridView;//
actualSalesDataGridView.RowLeave += OnRowLeave;
actualSalesDataGridView.RowsAdded += DisplayRowNumbers;
actualSalesDataGridView.RowsRemoved += OnRowRemoved;
actualSalesDataGridView.UserDeletingRow += OnRowRemoving;
actualSalesDataGridView.EditingControlShowing += DisplayAutoCompleteOnEditingControlShowing;
actualSalesDataGridView.RowValidating += UpdateProjectionsDataGridView;
//Event handlers for the Suppliers DataGridView
suppliersDataGridView.CellValidating += SupplierOnCellValidating;
@@ -85,15 +82,14 @@ namespace AdvertsingProfitControl
//Begin DataGridView event handlers
/// <summary>
/// Event Used: Leave
/// Attempts to parse the date entered when the user leaves the DateMaskedTextbox.
/// Clears the date if it is invalid, otherwise formats it and places it in the textbox.
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnWeekEndingDateMaskedTextBoxLeave(object sender, EventArgs e)
{
string input = weekEndingDateMaskedTextBox.Text;
input = input.Replace(" ", ""); //The forwardslashes "/" in the masked textbox are sent programmically as spaces.
input = input.Replace(" ", "");
DateTime processedDate;
if (!DateTime.TryParse(input, out processedDate))
{
@@ -108,7 +104,7 @@ namespace AdvertsingProfitControl
/// <summary>
/// Event Used: CellValidating
/// Performs formatting and validation based on what column the cell is in.
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
@@ -152,7 +148,7 @@ namespace AdvertsingProfitControl
}
}
//Make an ugly check for the Inventory / Actual Sales table, and perform logic on the inventory columns to allow 'Bin(s) [0-9]'.
if (dataGridView.Name == "inventoryActualSalesDataGridView" && e.ColumnIndex > 0 && e.ColumnIndex < 6 || dataGridView.Name == "projectionsDataGridView" && e.ColumnIndex == 1)
if (dataGridView.Name == "inventoryActualSalesDataGridView" && e.ColumnIndex > 0 && e.ColumnIndex < 6)
{
var invenotryStringCheck = new Regex(@"^[0-9] \bbin(s){0,1}\b", RegexOptions.IgnoreCase);
@@ -169,7 +165,7 @@ namespace AdvertsingProfitControl
}
//Check to see if whether or not the current cell is not in the first column and not empty.
if (e.ColumnIndex != 0 && !string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue.ToString()))
if (e.ColumnIndex != 0 && !String.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue.ToString()))
{
//IF so, try to parse the contents to a Double and apply number formatting to the contents.
//Check for the cost column to see if there are any strings formatted like such:
@@ -567,7 +563,7 @@ namespace AdvertsingProfitControl
{
customAutoComplete.Add(item);
}
autoText.KeyDown += AutoText_KeyPress;
autoText.KeyPress += AutoText_KeyPress;
_CustomAdItemCollection = customAutoComplete; //Make a temporary copy of the list for use with the TextBox event handler.
autoText.AutoCompleteMode = AutoCompleteMode.Suggest;
autoText.AutoCompleteSource = AutoCompleteSource.CustomSource;
@@ -579,29 +575,20 @@ namespace AdvertsingProfitControl
}
}//End DisplayAutoCompleteOnEditingControlShowing
private void AutoText_KeyPress(object sender, KeyEventArgs e)
private void AutoText_KeyPress(object sender, KeyPressEventArgs e)
{
var textBox = (TextBox)sender;
var textBox = (TextBox) sender;
errorReportingLabel.Text = "";
if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.Up)
{
if (_gAdSpecialIndex == -1)
if (e.KeyChar == ':' && textBox.Text.Length == 0)
{
textBox.AutoCompleteCustomSource = _AdSpecialList;
errorReportingLabel.Text = "Auto complete mode changed to Ad Special.";
}
else
{
errorReportingLabel.Text = "An Ad Special row already exists, auto complete mode\n can not be changed.";
}
}
else if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.Down)
else if (e.KeyChar == ';' && textBox.Text.Length == 0)
{
textBox.AutoCompleteCustomSource = _CustomAdItemCollection;
errorReportingLabel.Text = "Auto complete mode changed to Ad Items.";
errorReportingLabel.Text = "Auto complete mode changed to Ad Items only.";
}
e.Handled = false;
}
/// <summary>
@@ -652,7 +639,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]) == "MemberRow" || parser.GetRowAttribute(projectionsDataGridView.Rows[e.RowIndex]) == "AdSpecialRow")
{
rowContents[0] = projectionsDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString();
actualSalesDataGridView.Rows.Add(rowContents);
@@ -726,7 +713,7 @@ namespace AdvertsingProfitControl
if (actualSalesDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString() != "")
{
var parser = new RowParsing();
object[] rowContents = new object[11];
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())
{
@@ -755,7 +742,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]) == "MemberRow" || parser.GetRowAttribute(actualSalesDataGridView.Rows[e.RowIndex]) == "AdSpecialRow")
{
rowContents[0] = actualSalesDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString();
projectionsDataGridView.Rows.Add(rowContents);
@@ -936,13 +923,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 == "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 != "HeaderRow")
{
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
}
@@ -952,53 +939,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 == "HeaderRow" || rowStatus == "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 == "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 == "IncompleteRow")
{
PaintRowGroups(dataGridView);
}
}
}
else if (rowStatus == RowAttribute.MemberRow)
else if (rowStatus == "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 == "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 == "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 == "MemberRow" || rowStatus == "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 == "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 == "IncompleteRow")
{
PaintRowGroups(dataGridView);
}
@@ -1026,7 +1013,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 == "MemberRow" && !row.IsNewRow && rowType != "IncompleteRow")
{
//Remove all coloring on the current row.
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
@@ -1036,14 +1023,13 @@ 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)]) == "HeaderRow")
{
row.DefaultCellStyle.BackColor = Color.LightBlue; //Group member
dataGridView.Rows[lastHeaderIndex].DefaultCellStyle.BackColor = Color.LightGray; //Group header
groupCount++;
statusReport +=
$"\nGroup {groupCount} created with the header row {(i - incompleteRowsFound)} and the following row members: {(i + 1)} ";
statusReport += string.Format("\nGroup {0} created with the header row {1} and the following row members: {2} ", groupCount, (i - incompleteRowsFound).ToString(), (i + 1).ToString());
}
//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)
@@ -1059,22 +1045,21 @@ 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 == "HeaderRow" && parser.GetRowAttribute(dataGridView.Rows[i + 1]) == "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 == "HeaderRow" && parser.GetRowAttribute(dataGridView.Rows[i + 1]) == "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;
statusReport +=
$"Group {groupCount} created with the header row 1 and the following row member(s): {(i + 2)}";
statusReport += string.Format("Group {0} created with the header row 1 and the following row member(s): {1}", groupCount, (i + 2).ToString());
}
//Check to see if this row is a group header.
else if (rowType == RowAttribute.HeaderRow)
else if (rowType == "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;
@@ -1082,12 +1067,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 == "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 == "IncompleteRow")
{
incompleteRowsFound++;
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
@@ -1281,7 +1266,7 @@ namespace AdvertsingProfitControl
//Get the current row's attribute.
var currentRowAttribute = parser.GetRowAttribute(row);
//IF the current row is invalid then skip it.
if (currentRowAttribute == RowAttribute.IncompleteRow || currentRowAttribute == RowAttribute.MemberRow && rowIndexNumber == 0)
if (currentRowAttribute == "IncompleteRow" || currentRowAttribute == "MemberRow" && rowIndexNumber == 0)
{
continue;
}
@@ -1301,12 +1286,12 @@ namespace AdvertsingProfitControl
//BEGIN row attribute check.
//Do an in-depth check to determine if the row should be marked with a "Header Row" group tag.
//Only rows that have members will be explicitly marked as such.
if (currentRowAttribute == RowAttribute.HeaderRow)
if (currentRowAttribute == "HeaderRow")
{
if ((rowIndexNumber + 1) <= projectionsDataGridView.Rows.Count)
{
//Check to see if the next row is a Member Row.
if ((parser.GetRowAttribute(projectionsDataGridView.Rows[rowIndexNumber + 1])) == RowAttribute.MemberRow)
if ((parser.GetRowAttribute(projectionsDataGridView.Rows[rowIndexNumber + 1])) == "MemberRow")
{
//Set the current row's attribute to HeaderRow in the database.
parameters[16] = "1";
@@ -1321,7 +1306,7 @@ namespace AdvertsingProfitControl
}
}
}
else if (currentRowAttribute == RowAttribute.MemberRow && lastHeaderRowNumber != -1)
else if (currentRowAttribute == "MemberRow" && lastHeaderRowNumber != -1)
{
//ELSE IF this row is a member, then mark it as such.
parameters[16] = "2";
+30 -29
View File
@@ -7,7 +7,8 @@ namespace AdvertsingProfitControl
public sealed partial class FrmLogConsole : Form
{
//Source code: https://hashfactor.wordpress.com/2009/03/31/c-winforms-create-a-single-instance-form/
private static bool _gIsShown;
private static readonly FrmLogConsole gLogConsoleInstance = new FrmLogConsole();
private static bool gIsShown = false;
public FrmLogConsole()
{
@@ -17,18 +18,16 @@ namespace AdvertsingProfitControl
logListView.View = View.Details;
//Information for drawing header columns and sub-items in ListView:
//http://stackoverflow.com/questions/561798/how-do-i-align-text-for-a-single-subitem-in-a-listview-using-c
var header = new ColumnHeader
{
Text = @"Advertising Profit Control " + Application.ProductVersion + @" Debug Console",
Name = "LogConsoleHeader",
Width = logListView.Width
};
ColumnHeader header = new ColumnHeader();
header.Text = "Advertising Profit Control " + Application.ProductVersion + " Debug Console";
header.Name = "LogConsoleHeader";
header.Width = logListView.Width;
logListView.Columns.Add(header);
}
static FrmLogConsole()
{
GetStaticInstance.FormClosing += LogConsole_FormClosing;
GetStaticInstance.FormClosing += new FormClosingEventHandler(LogConsole_FormClosing);
//Set the maximum and minimum size of the form.
GetStaticInstance.MaximumSize = new Size(900, 900);
GetStaticInstance.MinimumSize = new Size(400, 400);
@@ -36,25 +35,27 @@ namespace AdvertsingProfitControl
public new void Show()
{
if (_gIsShown)
if (gIsShown)
{
base.Show();
}
else
{
base.Show();
_gIsShown = true;
gIsShown = true;
}
}
public new void Hide()
{
if (!_gIsShown) return;
if (gIsShown)
{
base.Hide();
_gIsShown = false;
gIsShown = false;
}
}
public enum Level
public enum Level : int
{
Critical = 0,
Error = 1,
@@ -67,6 +68,7 @@ namespace AdvertsingProfitControl
public void WriteToLog(Level level, string message)
{
Color color;
int index;
switch (level)
{
@@ -85,17 +87,14 @@ namespace AdvertsingProfitControl
case Level.Verbose:
color = Color.Blue;
break;
case Level.Debug:
color = Color.Black;
break;
default:
color = Color.Black;
break;
}
var index = logListView.Items.Count;
index = logListView.Items.Count;
try
{
message = $"{level}: {message}";
message = String.Format("{0}: {1}", level, message);
if (level != Level.Info)
{
GlobalClasses.WriteToLog(DateTime.Now + ": " + message + Environment.NewLine);
@@ -108,17 +107,13 @@ namespace AdvertsingProfitControl
MessageBox.Show(e.Message);
}
switch (level)
if (level == Level.Critical)
{
case Level.Critical:
logListView.Items[index].BackColor = Color.Red;
break;
case Level.Error:
logListView.Items[index].ForeColor = Color.Maroon;
break;
default:
}
else
{
logListView.Items[index].BackColor = Color.WhiteSmoke;
break;
}
}
@@ -126,11 +121,17 @@ namespace AdvertsingProfitControl
{
e.Cancel = true;
GetStaticInstance.Hide();
_gIsShown = false;
gIsShown = false;
}
public static FrmLogConsole GetStaticInstance { get; } = new FrmLogConsole();
public static FrmLogConsole GetStaticInstance
{
get { return gLogConsoleInstance; }
}
public bool IsVisable => _gIsShown;
public bool IsVisable
{
get { return gIsShown; }
}
}
}
+237 -221
View File
@@ -37,34 +37,35 @@
this.addRecordsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.modifyRecordMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.deleteRecordsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.newFormTestToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.adSpecialKeyWordsToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.manageItemsToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.helpMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.showHideConsoleHelpMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.dbVersionHelpMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.commentMainTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.commentMainGroupBox = new System.Windows.Forms.GroupBox();
this.commentsTextBox = new System.Windows.Forms.TextBox();
this.profitAnalysisMainGroupBox = new System.Windows.Forms.GroupBox();
this.shrinkLinkLabel = new System.Windows.Forms.LinkLabel();
this.changeShrinkLinkLabel = new System.Windows.Forms.LinkLabel();
this.shrinkLabel = new System.Windows.Forms.Label();
this.totalProfitReturnLabel = new System.Windows.Forms.Label();
this.totalProfitReturnFromRemaingLabel = new System.Windows.Forms.Label();
this.totalProfitFromAdItemsLabel = new System.Windows.Forms.Label();
this.remainingSalesLabel = new System.Windows.Forms.Label();
this.salesProducedLabel = new System.Windows.Forms.Label();
this.departmentSalesLabel = new System.Windows.Forms.Label();
this.costOfSalesMainGroupBox = new System.Windows.Forms.GroupBox();
this.costOfSalesLabel = new System.Windows.Forms.Label();
this.lessInventoryEndOfWeekAtCostLabel = new System.Windows.Forms.Label();
this.totalLabel = new System.Windows.Forms.Label();
this.plusTotalPurchases = new System.Windows.Forms.Label();
this.inventoryBeginingOfWeekAtCostLabel = new System.Windows.Forms.Label();
this.grossProfitGroupBox = new System.Windows.Forms.GroupBox();
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel = new System.Windows.Forms.Label();
this.grossProfitDollarGrossProfitLabel = new System.Windows.Forms.Label();
this.perfectGrossProfitLabel = new System.Windows.Forms.Label();
this.grossProfitTotalSales = new System.Windows.Forms.Label();
this.grossProfitDollarGrossProfitLabel = new System.Windows.Forms.Label();
this.grossProfitLessCostOfSales = new System.Windows.Forms.Label();
this.taxableGroupBox = new System.Windows.Forms.GroupBox();
this.usePreRenderedFilesCheckbox = new System.Windows.Forms.CheckBox();
this.grossProfitTotalSales = new System.Windows.Forms.Label();
this.dateSelectorPanel = new System.Windows.Forms.Panel();
this.printPreviewButton = new System.Windows.Forms.Button();
this.yearComboBox = new System.Windows.Forms.ComboBox();
this.dayComboBox = new System.Windows.Forms.ComboBox();
this.monthComboBox = new System.Windows.Forms.ComboBox();
@@ -86,8 +87,8 @@
this.commentMainTableLayoutPanel.SuspendLayout();
this.commentMainGroupBox.SuspendLayout();
this.profitAnalysisMainGroupBox.SuspendLayout();
this.costOfSalesMainGroupBox.SuspendLayout();
this.grossProfitGroupBox.SuspendLayout();
this.taxableGroupBox.SuspendLayout();
this.dateSelectorPanel.SuspendLayout();
this.mainViewTabControl.SuspendLayout();
this.projectionTab.SuspendLayout();
@@ -112,19 +113,18 @@
this.mainTableLayoutPanel.Controls.Add(this.mainViewTabControl, 0, 1);
this.mainTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.mainTableLayoutPanel.Location = new System.Drawing.Point(0, 0);
this.mainTableLayoutPanel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.mainTableLayoutPanel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.mainTableLayoutPanel.Name = "mainTableLayoutPanel";
this.mainTableLayoutPanel.RowCount = 3;
this.mainTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 41F));
this.mainTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F));
this.mainTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 65F));
this.mainTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 35F));
this.mainTableLayoutPanel.Size = new System.Drawing.Size(1734, 892);
this.mainTableLayoutPanel.Size = new System.Drawing.Size(1478, 794);
this.mainTableLayoutPanel.TabIndex = 0;
//
// mainMenu
//
this.mainMenu.Dock = System.Windows.Forms.DockStyle.Fill;
this.mainMenu.ImageScalingSize = new System.Drawing.Size(24, 24);
this.mainMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileMainMenu,
this.recordsToolStripMenuItem,
@@ -132,8 +132,8 @@
this.helpMainMenu});
this.mainMenu.Location = new System.Drawing.Point(0, 0);
this.mainMenu.Name = "mainMenu";
this.mainMenu.Padding = new System.Windows.Forms.Padding(10, 3, 0, 3);
this.mainMenu.Size = new System.Drawing.Size(1734, 41);
this.mainMenu.Padding = new System.Windows.Forms.Padding(9, 3, 0, 3);
this.mainMenu.Size = new System.Drawing.Size(1478, 35);
this.mainMenu.TabIndex = 1;
this.mainMenu.Text = "menuStrip1";
//
@@ -142,13 +142,13 @@
this.fileMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.exitFileMainMenu});
this.fileMainMenu.Name = "fileMainMenu";
this.fileMainMenu.Size = new System.Drawing.Size(56, 35);
this.fileMainMenu.Size = new System.Drawing.Size(50, 29);
this.fileMainMenu.Text = "&File";
//
// exitFileMainMenu
//
this.exitFileMainMenu.Name = "exitFileMainMenu";
this.exitFileMainMenu.Size = new System.Drawing.Size(138, 34);
this.exitFileMainMenu.Size = new System.Drawing.Size(111, 30);
this.exitFileMainMenu.Text = "E&xit";
//
// recordsToolStripMenuItem
@@ -156,86 +156,62 @@
this.recordsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addRecordsToolStripMenuItem,
this.modifyRecordMainMenu,
this.deleteRecordsMainMenu,
this.newFormTestToolStripMenuItem});
this.deleteRecordsMainMenu});
this.recordsToolStripMenuItem.Name = "recordsToolStripMenuItem";
this.recordsToolStripMenuItem.Size = new System.Drawing.Size(98, 35);
this.recordsToolStripMenuItem.Size = new System.Drawing.Size(87, 29);
this.recordsToolStripMenuItem.Text = "&Records";
//
// addRecordsToolStripMenuItem
//
this.addRecordsToolStripMenuItem.Name = "addRecordsToolStripMenuItem";
this.addRecordsToolStripMenuItem.Size = new System.Drawing.Size(323, 34);
this.addRecordsToolStripMenuItem.Size = new System.Drawing.Size(271, 30);
this.addRecordsToolStripMenuItem.Text = "&Add New Record";
this.addRecordsToolStripMenuItem.Click += new System.EventHandler(this.addRecordToolStripMenuItem_Click);
//
// modifyRecordMainMenu
//
this.modifyRecordMainMenu.Name = "modifyRecordMainMenu";
this.modifyRecordMainMenu.Size = new System.Drawing.Size(323, 34);
this.modifyRecordMainMenu.Size = new System.Drawing.Size(271, 30);
this.modifyRecordMainMenu.Text = "&Modify Existing Record ";
this.modifyRecordMainMenu.Click += new System.EventHandler(this.modifyRecordMainMenu_Click);
//
// deleteRecordsMainMenu
//
this.deleteRecordsMainMenu.Name = "deleteRecordsMainMenu";
this.deleteRecordsMainMenu.Size = new System.Drawing.Size(323, 34);
this.deleteRecordsMainMenu.Size = new System.Drawing.Size(271, 30);
this.deleteRecordsMainMenu.Text = "&Delete Existing record";
this.deleteRecordsMainMenu.Click += new System.EventHandler(this.deleteRecordsMainMenu_Click);
//
// newFormTestToolStripMenuItem
//
this.newFormTestToolStripMenuItem.Name = "newFormTestToolStripMenuItem";
this.newFormTestToolStripMenuItem.Size = new System.Drawing.Size(323, 34);
this.newFormTestToolStripMenuItem.Text = "&New Form Test";
this.newFormTestToolStripMenuItem.Click += new System.EventHandler(this.newFormTestToolStripMenuItem_Click);
//
// toolsMainMenu
//
this.toolsMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.adSpecialKeyWordsToolsMainMenu,
this.manageItemsToolsMainMenu});
this.adSpecialKeyWordsToolsMainMenu});
this.toolsMainMenu.Name = "toolsMainMenu";
this.toolsMainMenu.Size = new System.Drawing.Size(72, 35);
this.toolsMainMenu.Size = new System.Drawing.Size(65, 29);
this.toolsMainMenu.Text = "&Tools";
//
// adSpecialKeyWordsToolsMainMenu
//
this.adSpecialKeyWordsToolsMainMenu.Name = "adSpecialKeyWordsToolsMainMenu";
this.adSpecialKeyWordsToolsMainMenu.Size = new System.Drawing.Size(282, 34);
this.adSpecialKeyWordsToolsMainMenu.Size = new System.Drawing.Size(235, 30);
this.adSpecialKeyWordsToolsMainMenu.Text = "&Register Ad Special";
this.adSpecialKeyWordsToolsMainMenu.Click += new System.EventHandler(this.adSpecialKeyWordsToolsMainMenu_Click);
//
// manageItemsToolsMainMenu
//
this.manageItemsToolsMainMenu.Name = "manageItemsToolsMainMenu";
this.manageItemsToolsMainMenu.Size = new System.Drawing.Size(282, 34);
this.manageItemsToolsMainMenu.Text = "&Manage Ad Items";
this.manageItemsToolsMainMenu.Click += new System.EventHandler(this.manageItemsToolsMainMenu_Click);
//
// helpMainMenu
//
this.helpMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.showHideConsoleHelpMainMenu,
this.dbVersionHelpMainMenu});
this.showHideConsoleHelpMainMenu});
this.helpMainMenu.Name = "helpMainMenu";
this.helpMainMenu.Size = new System.Drawing.Size(68, 35);
this.helpMainMenu.Size = new System.Drawing.Size(61, 29);
this.helpMainMenu.Text = "&Help";
//
// showHideConsoleHelpMainMenu
//
this.showHideConsoleHelpMainMenu.Name = "showHideConsoleHelpMainMenu";
this.showHideConsoleHelpMainMenu.Size = new System.Drawing.Size(304, 34);
this.showHideConsoleHelpMainMenu.Size = new System.Drawing.Size(241, 30);
this.showHideConsoleHelpMainMenu.Text = "&Show/Hide Console";
this.showHideConsoleHelpMainMenu.Click += new System.EventHandler(this.showHideConsoleHelpMainMenu_Click);
//
// dbVersionHelpMainMenu
//
this.dbVersionHelpMainMenu.Name = "dbVersionHelpMainMenu";
this.dbVersionHelpMainMenu.Size = new System.Drawing.Size(304, 34);
this.dbVersionHelpMainMenu.Text = "Get &Database Version";
this.dbVersionHelpMainMenu.Click += new System.EventHandler(this.dbVersionHelpMainMenu_Click);
//
// commentMainTableLayoutPanel
//
this.commentMainTableLayoutPanel.ColumnCount = 4;
@@ -245,30 +221,30 @@
this.commentMainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 26F));
this.commentMainTableLayoutPanel.Controls.Add(this.commentMainGroupBox, 0, 0);
this.commentMainTableLayoutPanel.Controls.Add(this.profitAnalysisMainGroupBox, 1, 0);
this.commentMainTableLayoutPanel.Controls.Add(this.grossProfitGroupBox, 2, 0);
this.commentMainTableLayoutPanel.Controls.Add(this.taxableGroupBox, 3, 0);
this.commentMainTableLayoutPanel.Controls.Add(this.costOfSalesMainGroupBox, 2, 0);
this.commentMainTableLayoutPanel.Controls.Add(this.grossProfitGroupBox, 3, 0);
this.commentMainTableLayoutPanel.Controls.Add(this.dateSelectorPanel, 2, 1);
this.commentMainTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.commentMainTableLayoutPanel.Location = new System.Drawing.Point(5, 600);
this.commentMainTableLayoutPanel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.commentMainTableLayoutPanel.Location = new System.Drawing.Point(4, 533);
this.commentMainTableLayoutPanel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.commentMainTableLayoutPanel.Name = "commentMainTableLayoutPanel";
this.commentMainTableLayoutPanel.RowCount = 2;
this.commentMainTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 80F));
this.commentMainTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
this.commentMainTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 23F));
this.commentMainTableLayoutPanel.Size = new System.Drawing.Size(1724, 286);
this.commentMainTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.commentMainTableLayoutPanel.Size = new System.Drawing.Size(1470, 256);
this.commentMainTableLayoutPanel.TabIndex = 2;
//
// commentMainGroupBox
//
this.commentMainGroupBox.Controls.Add(this.commentsTextBox);
this.commentMainGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.commentMainGroupBox.Location = new System.Drawing.Point(5, 6);
this.commentMainGroupBox.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.commentMainGroupBox.Location = new System.Drawing.Point(4, 5);
this.commentMainGroupBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.commentMainGroupBox.Name = "commentMainGroupBox";
this.commentMainGroupBox.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.commentMainGroupBox.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.commentMainTableLayoutPanel.SetRowSpan(this.commentMainGroupBox, 2);
this.commentMainGroupBox.Size = new System.Drawing.Size(334, 274);
this.commentMainGroupBox.Size = new System.Drawing.Size(286, 246);
this.commentMainGroupBox.TabIndex = 0;
this.commentMainGroupBox.TabStop = false;
this.commentMainGroupBox.Text = "Comments";
@@ -277,16 +253,17 @@
//
this.commentsTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.commentsTextBox.Enabled = false;
this.commentsTextBox.Location = new System.Drawing.Point(5, 28);
this.commentsTextBox.Location = new System.Drawing.Point(4, 24);
this.commentsTextBox.Multiline = true;
this.commentsTextBox.Name = "commentsTextBox";
this.commentsTextBox.ReadOnly = true;
this.commentsTextBox.Size = new System.Drawing.Size(324, 240);
this.commentsTextBox.Size = new System.Drawing.Size(278, 217);
this.commentsTextBox.TabIndex = 0;
//
// profitAnalysisMainGroupBox
//
this.profitAnalysisMainGroupBox.Controls.Add(this.shrinkLinkLabel);
this.profitAnalysisMainGroupBox.Controls.Add(this.changeShrinkLinkLabel);
this.profitAnalysisMainGroupBox.Controls.Add(this.shrinkLabel);
this.profitAnalysisMainGroupBox.Controls.Add(this.totalProfitReturnLabel);
this.profitAnalysisMainGroupBox.Controls.Add(this.totalProfitReturnFromRemaingLabel);
this.profitAnalysisMainGroupBox.Controls.Add(this.totalProfitFromAdItemsLabel);
@@ -294,230 +271,267 @@
this.profitAnalysisMainGroupBox.Controls.Add(this.salesProducedLabel);
this.profitAnalysisMainGroupBox.Controls.Add(this.departmentSalesLabel);
this.profitAnalysisMainGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.profitAnalysisMainGroupBox.Location = new System.Drawing.Point(349, 6);
this.profitAnalysisMainGroupBox.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.profitAnalysisMainGroupBox.Location = new System.Drawing.Point(298, 5);
this.profitAnalysisMainGroupBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.profitAnalysisMainGroupBox.Name = "profitAnalysisMainGroupBox";
this.profitAnalysisMainGroupBox.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.profitAnalysisMainGroupBox.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.commentMainTableLayoutPanel.SetRowSpan(this.profitAnalysisMainGroupBox, 2);
this.profitAnalysisMainGroupBox.Size = new System.Drawing.Size(472, 274);
this.profitAnalysisMainGroupBox.Size = new System.Drawing.Size(403, 246);
this.profitAnalysisMainGroupBox.TabIndex = 1;
this.profitAnalysisMainGroupBox.TabStop = false;
this.profitAnalysisMainGroupBox.Text = "Profit Analysis";
//
// shrinkLinkLabel
// changeShrinkLinkLabel
//
this.shrinkLinkLabel.AutoSize = true;
this.shrinkLinkLabel.LinkArea = new System.Windows.Forms.LinkArea(20, 6);
this.shrinkLinkLabel.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
this.shrinkLinkLabel.LinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
this.shrinkLinkLabel.Location = new System.Drawing.Point(0, 37);
this.shrinkLinkLabel.Name = "shrinkLinkLabel";
this.shrinkLinkLabel.Size = new System.Drawing.Size(272, 27);
this.shrinkLinkLabel.TabIndex = 6;
this.shrinkLinkLabel.TabStop = true;
this.shrinkLinkLabel.Text = "Assuming 30% Shrink Change";
this.shrinkLinkLabel.UseCompatibleTextRendering = true;
this.changeShrinkLinkLabel.AutoSize = true;
this.changeShrinkLinkLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.changeShrinkLinkLabel.Location = new System.Drawing.Point(166, 29);
this.changeShrinkLinkLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.changeShrinkLinkLabel.Name = "changeShrinkLinkLabel";
this.changeShrinkLinkLabel.Size = new System.Drawing.Size(57, 17);
this.changeShrinkLinkLabel.TabIndex = 7;
this.changeShrinkLinkLabel.TabStop = true;
this.changeShrinkLinkLabel.Text = "Change";
this.changeShrinkLinkLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// shrinkLabel
//
this.shrinkLabel.AutoSize = true;
this.shrinkLabel.Location = new System.Drawing.Point(9, 31);
this.shrinkLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.shrinkLabel.Name = "shrinkLabel";
this.shrinkLabel.Size = new System.Drawing.Size(164, 20);
this.shrinkLabel.TabIndex = 6;
this.shrinkLabel.Text = "Assuming 30% Shrink";
//
// totalProfitReturnLabel
//
this.totalProfitReturnLabel.AutoSize = true;
this.totalProfitReturnLabel.Location = new System.Drawing.Point(0, 251);
this.totalProfitReturnLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.totalProfitReturnLabel.Location = new System.Drawing.Point(9, 215);
this.totalProfitReturnLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.totalProfitReturnLabel.Name = "totalProfitReturnLabel";
this.totalProfitReturnLabel.Size = new System.Drawing.Size(178, 25);
this.totalProfitReturnLabel.Size = new System.Drawing.Size(146, 20);
this.totalProfitReturnLabel.TabIndex = 5;
this.totalProfitReturnLabel.Text = "Total Profit Return: ";
//
// totalProfitReturnFromRemaingLabel
//
this.totalProfitReturnFromRemaingLabel.AutoSize = true;
this.totalProfitReturnFromRemaingLabel.Location = new System.Drawing.Point(0, 216);
this.totalProfitReturnFromRemaingLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.totalProfitReturnFromRemaingLabel.Location = new System.Drawing.Point(9, 185);
this.totalProfitReturnFromRemaingLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.totalProfitReturnFromRemaingLabel.Name = "totalProfitReturnFromRemaingLabel";
this.totalProfitReturnFromRemaingLabel.Size = new System.Drawing.Size(380, 25);
this.totalProfitReturnFromRemaingLabel.Size = new System.Drawing.Size(311, 20);
this.totalProfitReturnFromRemaingLabel.TabIndex = 4;
this.totalProfitReturnFromRemaingLabel.Text = "Total Profit Return From Remaining Sales: ";
//
// totalProfitFromAdItemsLabel
//
this.totalProfitFromAdItemsLabel.AutoSize = true;
this.totalProfitFromAdItemsLabel.Location = new System.Drawing.Point(0, 180);
this.totalProfitFromAdItemsLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.totalProfitFromAdItemsLabel.Location = new System.Drawing.Point(9, 154);
this.totalProfitFromAdItemsLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.totalProfitFromAdItemsLabel.Name = "totalProfitFromAdItemsLabel";
this.totalProfitFromAdItemsLabel.Size = new System.Drawing.Size(342, 25);
this.totalProfitFromAdItemsLabel.Size = new System.Drawing.Size(280, 20);
this.totalProfitFromAdItemsLabel.TabIndex = 3;
this.totalProfitFromAdItemsLabel.Text = "Total Profit Return From Ad Items (B): ";
//
// remainingSalesLabel
//
this.remainingSalesLabel.AutoSize = true;
this.remainingSalesLabel.Location = new System.Drawing.Point(0, 143);
this.remainingSalesLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.remainingSalesLabel.Location = new System.Drawing.Point(9, 123);
this.remainingSalesLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.remainingSalesLabel.Name = "remainingSalesLabel";
this.remainingSalesLabel.Size = new System.Drawing.Size(170, 25);
this.remainingSalesLabel.Size = new System.Drawing.Size(125, 20);
this.remainingSalesLabel.TabIndex = 2;
this.remainingSalesLabel.Text = "Remaining Sales: ";
this.remainingSalesLabel.Text = "Remaing Sales: ";
//
// salesProducedLabel
//
this.salesProducedLabel.AutoSize = true;
this.salesProducedLabel.Location = new System.Drawing.Point(0, 107);
this.salesProducedLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.salesProducedLabel.Location = new System.Drawing.Point(9, 92);
this.salesProducedLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.salesProducedLabel.Name = "salesProducedLabel";
this.salesProducedLabel.Size = new System.Drawing.Size(300, 25);
this.salesProducedLabel.Size = new System.Drawing.Size(240, 20);
this.salesProducedLabel.TabIndex = 1;
this.salesProducedLabel.Text = "Sales Produced By Ad Items (A):";
//
// departmentSalesLabel
//
this.departmentSalesLabel.AutoSize = true;
this.departmentSalesLabel.Location = new System.Drawing.Point(0, 72);
this.departmentSalesLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.departmentSalesLabel.Location = new System.Drawing.Point(9, 62);
this.departmentSalesLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.departmentSalesLabel.Name = "departmentSalesLabel";
this.departmentSalesLabel.Size = new System.Drawing.Size(179, 25);
this.departmentSalesLabel.Size = new System.Drawing.Size(146, 20);
this.departmentSalesLabel.TabIndex = 0;
this.departmentSalesLabel.Text = "Department Sales: ";
//
// costOfSalesMainGroupBox
//
this.costOfSalesMainGroupBox.Controls.Add(this.costOfSalesLabel);
this.costOfSalesMainGroupBox.Controls.Add(this.lessInventoryEndOfWeekAtCostLabel);
this.costOfSalesMainGroupBox.Controls.Add(this.totalLabel);
this.costOfSalesMainGroupBox.Controls.Add(this.plusTotalPurchases);
this.costOfSalesMainGroupBox.Controls.Add(this.inventoryBeginingOfWeekAtCostLabel);
this.costOfSalesMainGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.costOfSalesMainGroupBox.Location = new System.Drawing.Point(709, 5);
this.costOfSalesMainGroupBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.costOfSalesMainGroupBox.Name = "costOfSalesMainGroupBox";
this.costOfSalesMainGroupBox.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.costOfSalesMainGroupBox.Size = new System.Drawing.Size(374, 194);
this.costOfSalesMainGroupBox.TabIndex = 2;
this.costOfSalesMainGroupBox.TabStop = false;
this.costOfSalesMainGroupBox.Text = "Cost of Sales";
//
// costOfSalesLabel
//
this.costOfSalesLabel.AutoSize = true;
this.costOfSalesLabel.Location = new System.Drawing.Point(8, 154);
this.costOfSalesLabel.Name = "costOfSalesLabel";
this.costOfSalesLabel.Size = new System.Drawing.Size(112, 20);
this.costOfSalesLabel.TabIndex = 4;
this.costOfSalesLabel.Text = "Cost of Sales: ";
//
// lessInventoryEndOfWeekAtCostLabel
//
this.lessInventoryEndOfWeekAtCostLabel.AutoSize = true;
this.lessInventoryEndOfWeekAtCostLabel.Location = new System.Drawing.Point(8, 123);
this.lessInventoryEndOfWeekAtCostLabel.Name = "lessInventoryEndOfWeekAtCostLabel";
this.lessInventoryEndOfWeekAtCostLabel.Size = new System.Drawing.Size(267, 20);
this.lessInventoryEndOfWeekAtCostLabel.TabIndex = 3;
this.lessInventoryEndOfWeekAtCostLabel.Text = "Less Inventory End of Week at Cost:";
//
// totalLabel
//
this.totalLabel.AutoSize = true;
this.totalLabel.Location = new System.Drawing.Point(8, 92);
this.totalLabel.Name = "totalLabel";
this.totalLabel.Size = new System.Drawing.Size(52, 20);
this.totalLabel.TabIndex = 2;
this.totalLabel.Text = "Total: ";
//
// plusTotalPurchases
//
this.plusTotalPurchases.AutoSize = true;
this.plusTotalPurchases.Location = new System.Drawing.Point(8, 62);
this.plusTotalPurchases.Name = "plusTotalPurchases";
this.plusTotalPurchases.Size = new System.Drawing.Size(165, 20);
this.plusTotalPurchases.TabIndex = 1;
this.plusTotalPurchases.Text = "Plus Total Purchases: ";
//
// inventoryBeginingOfWeekAtCostLabel
//
this.inventoryBeginingOfWeekAtCostLabel.AutoSize = true;
this.inventoryBeginingOfWeekAtCostLabel.Location = new System.Drawing.Point(8, 29);
this.inventoryBeginingOfWeekAtCostLabel.Name = "inventoryBeginingOfWeekAtCostLabel";
this.inventoryBeginingOfWeekAtCostLabel.Size = new System.Drawing.Size(266, 20);
this.inventoryBeginingOfWeekAtCostLabel.TabIndex = 0;
this.inventoryBeginingOfWeekAtCostLabel.Text = "Inventory Begining of Week at Cost: ";
//
// grossProfitGroupBox
//
this.grossProfitGroupBox.Controls.Add(this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel);
this.grossProfitGroupBox.Controls.Add(this.grossProfitDollarGrossProfitLabel);
this.grossProfitGroupBox.Controls.Add(this.perfectGrossProfitLabel);
this.grossProfitGroupBox.Controls.Add(this.grossProfitTotalSales);
this.grossProfitGroupBox.Controls.Add(this.grossProfitDollarGrossProfitLabel);
this.grossProfitGroupBox.Controls.Add(this.grossProfitLessCostOfSales);
this.grossProfitGroupBox.Controls.Add(this.grossProfitTotalSales);
this.grossProfitGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.grossProfitGroupBox.Location = new System.Drawing.Point(831, 6);
this.grossProfitGroupBox.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.grossProfitGroupBox.Location = new System.Drawing.Point(1090, 3);
this.grossProfitGroupBox.Name = "grossProfitGroupBox";
this.grossProfitGroupBox.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.grossProfitGroupBox.Size = new System.Drawing.Size(438, 216);
this.grossProfitGroupBox.TabIndex = 2;
this.grossProfitGroupBox.Size = new System.Drawing.Size(377, 198);
this.grossProfitGroupBox.TabIndex = 3;
this.grossProfitGroupBox.TabStop = false;
this.grossProfitGroupBox.Text = "Gross Profit";
//
// grossProfitEstimatedWeeklyDeptmartmentExpenseLabel
//
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.AutoSize = true;
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Location = new System.Drawing.Point(8, 177);
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Location = new System.Drawing.Point(10, 152);
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Name = "grossProfitEstimatedWeeklyDeptmartmentExpenseLabel";
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Size = new System.Drawing.Size(368, 25);
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Size = new System.Drawing.Size(299, 20);
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.TabIndex = 4;
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Text = "Estimated Weekly Department Expense: ";
//
// grossProfitDollarGrossProfitLabel
//
this.grossProfitDollarGrossProfitLabel.AutoSize = true;
this.grossProfitDollarGrossProfitLabel.Location = new System.Drawing.Point(8, 107);
this.grossProfitDollarGrossProfitLabel.Name = "grossProfitDollarGrossProfitLabel";
this.grossProfitDollarGrossProfitLabel.Size = new System.Drawing.Size(179, 25);
this.grossProfitDollarGrossProfitLabel.TabIndex = 2;
this.grossProfitDollarGrossProfitLabel.Text = "Dollar Gross Profit: ";
//
// perfectGrossProfitLabel
//
this.perfectGrossProfitLabel.AutoSize = true;
this.perfectGrossProfitLabel.Location = new System.Drawing.Point(8, 142);
this.perfectGrossProfitLabel.Location = new System.Drawing.Point(10, 122);
this.perfectGrossProfitLabel.Name = "perfectGrossProfitLabel";
this.perfectGrossProfitLabel.Size = new System.Drawing.Size(196, 25);
this.perfectGrossProfitLabel.Size = new System.Drawing.Size(160, 20);
this.perfectGrossProfitLabel.TabIndex = 3;
this.perfectGrossProfitLabel.Text = "Percent Gross Profit: ";
//
// grossProfitTotalSales
// grossProfitDollarGrossProfitLabel
//
this.grossProfitTotalSales.AutoSize = true;
this.grossProfitTotalSales.Location = new System.Drawing.Point(8, 37);
this.grossProfitTotalSales.Name = "grossProfitTotalSales";
this.grossProfitTotalSales.Size = new System.Drawing.Size(122, 25);
this.grossProfitTotalSales.TabIndex = 0;
this.grossProfitTotalSales.Text = "Total Sales: ";
this.grossProfitDollarGrossProfitLabel.AutoSize = true;
this.grossProfitDollarGrossProfitLabel.Location = new System.Drawing.Point(10, 92);
this.grossProfitDollarGrossProfitLabel.Name = "grossProfitDollarGrossProfitLabel";
this.grossProfitDollarGrossProfitLabel.Size = new System.Drawing.Size(146, 20);
this.grossProfitDollarGrossProfitLabel.TabIndex = 2;
this.grossProfitDollarGrossProfitLabel.Text = "Dollar Gross Profit: ";
//
// grossProfitLessCostOfSales
//
this.grossProfitLessCostOfSales.AutoSize = true;
this.grossProfitLessCostOfSales.Location = new System.Drawing.Point(8, 72);
this.grossProfitLessCostOfSales.Location = new System.Drawing.Point(10, 62);
this.grossProfitLessCostOfSales.Name = "grossProfitLessCostOfSales";
this.grossProfitLessCostOfSales.Size = new System.Drawing.Size(187, 25);
this.grossProfitLessCostOfSales.Size = new System.Drawing.Size(150, 20);
this.grossProfitLessCostOfSales.TabIndex = 1;
this.grossProfitLessCostOfSales.Text = "Less Cost of Sales: ";
//
// taxableGroupBox
// grossProfitTotalSales
//
this.taxableGroupBox.Controls.Add(this.usePreRenderedFilesCheckbox);
this.taxableGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.taxableGroupBox.Location = new System.Drawing.Point(1277, 3);
this.taxableGroupBox.Name = "taxableGroupBox";
this.taxableGroupBox.Size = new System.Drawing.Size(444, 222);
this.taxableGroupBox.TabIndex = 3;
this.taxableGroupBox.TabStop = false;
this.taxableGroupBox.Text = "Taxable";
//
// usePreRenderedFilesCheckbox
//
this.usePreRenderedFilesCheckbox.AutoSize = true;
this.usePreRenderedFilesCheckbox.Location = new System.Drawing.Point(206, 191);
this.usePreRenderedFilesCheckbox.Name = "usePreRenderedFilesCheckbox";
this.usePreRenderedFilesCheckbox.Size = new System.Drawing.Size(239, 29);
this.usePreRenderedFilesCheckbox.TabIndex = 5;
this.usePreRenderedFilesCheckbox.Text = "Use Pre-rendered Files";
this.usePreRenderedFilesCheckbox.UseVisualStyleBackColor = true;
this.grossProfitTotalSales.AutoSize = true;
this.grossProfitTotalSales.Location = new System.Drawing.Point(10, 32);
this.grossProfitTotalSales.Name = "grossProfitTotalSales";
this.grossProfitTotalSales.Size = new System.Drawing.Size(96, 20);
this.grossProfitTotalSales.TabIndex = 0;
this.grossProfitTotalSales.Text = "Total Sales: ";
//
// dateSelectorPanel
//
this.commentMainTableLayoutPanel.SetColumnSpan(this.dateSelectorPanel, 2);
this.dateSelectorPanel.Controls.Add(this.printPreviewButton);
this.dateSelectorPanel.Controls.Add(this.yearComboBox);
this.dateSelectorPanel.Controls.Add(this.dayComboBox);
this.dateSelectorPanel.Controls.Add(this.monthComboBox);
this.dateSelectorPanel.Controls.Add(this.dateSelectLabel);
this.dateSelectorPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.dateSelectorPanel.Location = new System.Drawing.Point(829, 231);
this.dateSelectorPanel.Location = new System.Drawing.Point(708, 207);
this.dateSelectorPanel.Name = "dateSelectorPanel";
this.dateSelectorPanel.Size = new System.Drawing.Size(892, 52);
this.dateSelectorPanel.Size = new System.Drawing.Size(759, 46);
this.dateSelectorPanel.TabIndex = 4;
//
// printPreviewButton
//
this.printPreviewButton.Location = new System.Drawing.Point(744, 0);
this.printPreviewButton.Name = "printPreviewButton";
this.printPreviewButton.Size = new System.Drawing.Size(138, 49);
this.printPreviewButton.TabIndex = 4;
this.printPreviewButton.Text = "Print Preview";
this.printPreviewButton.UseVisualStyleBackColor = true;
this.printPreviewButton.Click += new System.EventHandler(this.DisplayPrintPreview);
//
// yearComboBox
//
this.yearComboBox.FormattingEnabled = true;
this.yearComboBox.Location = new System.Drawing.Point(446, 13);
this.yearComboBox.Location = new System.Drawing.Point(532, 12);
this.yearComboBox.Name = "yearComboBox";
this.yearComboBox.Size = new System.Drawing.Size(111, 32);
this.yearComboBox.Size = new System.Drawing.Size(96, 28);
this.yearComboBox.Sorted = true;
this.yearComboBox.TabIndex = 3;
//
// dayComboBox
//
this.dayComboBox.FormattingEnabled = true;
this.dayComboBox.Location = new System.Drawing.Point(327, 13);
this.dayComboBox.Location = new System.Drawing.Point(430, 12);
this.dayComboBox.Name = "dayComboBox";
this.dayComboBox.Size = new System.Drawing.Size(111, 32);
this.dayComboBox.Size = new System.Drawing.Size(96, 28);
this.dayComboBox.Sorted = true;
this.dayComboBox.TabIndex = 2;
//
// monthComboBox
//
this.monthComboBox.FormattingEnabled = true;
this.monthComboBox.Location = new System.Drawing.Point(208, 13);
this.monthComboBox.Location = new System.Drawing.Point(328, 12);
this.monthComboBox.Name = "monthComboBox";
this.monthComboBox.Size = new System.Drawing.Size(111, 32);
this.monthComboBox.Size = new System.Drawing.Size(96, 28);
this.monthComboBox.Sorted = true;
this.monthComboBox.TabIndex = 1;
//
// dateSelectLabel
//
this.dateSelectLabel.AutoSize = true;
this.dateSelectLabel.Location = new System.Drawing.Point(7, 14);
this.dateSelectLabel.Location = new System.Drawing.Point(156, 14);
this.dateSelectLabel.Name = "dateSelectLabel";
this.dateSelectLabel.Size = new System.Drawing.Size(204, 25);
this.dateSelectLabel.Size = new System.Drawing.Size(166, 20);
this.dateSelectLabel.TabIndex = 0;
this.dateSelectLabel.Text = "Select a Date to View:";
//
@@ -529,21 +543,21 @@
this.mainViewTabControl.Controls.Add(this.suppliersTabPage);
this.mainViewTabControl.Controls.Add(this.WeeklySalesTabPage);
this.mainViewTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.mainViewTabControl.Location = new System.Drawing.Point(5, 47);
this.mainViewTabControl.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.mainViewTabControl.Location = new System.Drawing.Point(4, 40);
this.mainViewTabControl.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.mainViewTabControl.Name = "mainViewTabControl";
this.mainViewTabControl.SelectedIndex = 0;
this.mainViewTabControl.Size = new System.Drawing.Size(1724, 541);
this.mainViewTabControl.Size = new System.Drawing.Size(1470, 483);
this.mainViewTabControl.TabIndex = 3;
//
// projectionTab
//
this.projectionTab.Controls.Add(this.projectedSalesMainDataGrid);
this.projectionTab.Location = new System.Drawing.Point(4, 33);
this.projectionTab.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.projectionTab.Location = new System.Drawing.Point(4, 29);
this.projectionTab.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.projectionTab.Name = "projectionTab";
this.projectionTab.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.projectionTab.Size = new System.Drawing.Size(1716, 504);
this.projectionTab.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.projectionTab.Size = new System.Drawing.Size(1462, 450);
this.projectionTab.TabIndex = 0;
this.projectionTab.Text = "Projections";
this.projectionTab.UseVisualStyleBackColor = true;
@@ -558,23 +572,23 @@
this.projectedSalesMainDataGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.projectedSalesMainDataGrid.Dock = System.Windows.Forms.DockStyle.Fill;
this.projectedSalesMainDataGrid.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnKeystroke;
this.projectedSalesMainDataGrid.Location = new System.Drawing.Point(5, 6);
this.projectedSalesMainDataGrid.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.projectedSalesMainDataGrid.Location = new System.Drawing.Point(4, 5);
this.projectedSalesMainDataGrid.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.projectedSalesMainDataGrid.Name = "projectedSalesMainDataGrid";
this.projectedSalesMainDataGrid.ReadOnly = true;
this.projectedSalesMainDataGrid.RowHeadersVisible = false;
this.projectedSalesMainDataGrid.ShowCellErrors = false;
this.projectedSalesMainDataGrid.ShowRowErrors = false;
this.projectedSalesMainDataGrid.Size = new System.Drawing.Size(1706, 492);
this.projectedSalesMainDataGrid.Size = new System.Drawing.Size(1454, 440);
this.projectedSalesMainDataGrid.TabIndex = 0;
//
// inventoryTabPage
//
this.inventoryTabPage.Controls.Add(this.inventoryDataGridView);
this.inventoryTabPage.Location = new System.Drawing.Point(4, 33);
this.inventoryTabPage.Location = new System.Drawing.Point(4, 29);
this.inventoryTabPage.Name = "inventoryTabPage";
this.inventoryTabPage.Padding = new System.Windows.Forms.Padding(3);
this.inventoryTabPage.Size = new System.Drawing.Size(1716, 504);
this.inventoryTabPage.Size = new System.Drawing.Size(1462, 450);
this.inventoryTabPage.TabIndex = 4;
this.inventoryTabPage.Text = "Inventory";
this.inventoryTabPage.UseVisualStyleBackColor = true;
@@ -593,16 +607,16 @@
this.inventoryDataGridView.RowHeadersVisible = false;
this.inventoryDataGridView.RowTemplate.Height = 28;
this.inventoryDataGridView.ShowRowErrors = false;
this.inventoryDataGridView.Size = new System.Drawing.Size(1710, 498);
this.inventoryDataGridView.Size = new System.Drawing.Size(1456, 444);
this.inventoryDataGridView.TabIndex = 0;
//
// actualSalesTab
//
this.actualSalesTab.Controls.Add(this.actualSalesMainLayoutPanel);
this.actualSalesTab.Location = new System.Drawing.Point(4, 33);
this.actualSalesTab.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.actualSalesTab.Location = new System.Drawing.Point(4, 29);
this.actualSalesTab.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.actualSalesTab.Name = "actualSalesTab";
this.actualSalesTab.Size = new System.Drawing.Size(1716, 504);
this.actualSalesTab.Size = new System.Drawing.Size(1462, 450);
this.actualSalesTab.TabIndex = 2;
this.actualSalesTab.Text = "Actual Sales";
this.actualSalesTab.UseVisualStyleBackColor = true;
@@ -614,12 +628,12 @@
this.actualSalesMainLayoutPanel.Controls.Add(this.actualSalesMainDataGidView, 0, 0);
this.actualSalesMainLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.actualSalesMainLayoutPanel.Location = new System.Drawing.Point(0, 0);
this.actualSalesMainLayoutPanel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.actualSalesMainLayoutPanel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.actualSalesMainLayoutPanel.Name = "actualSalesMainLayoutPanel";
this.actualSalesMainLayoutPanel.RowCount = 1;
this.actualSalesMainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.actualSalesMainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 504F));
this.actualSalesMainLayoutPanel.Size = new System.Drawing.Size(1716, 504);
this.actualSalesMainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 450F));
this.actualSalesMainLayoutPanel.Size = new System.Drawing.Size(1462, 450);
this.actualSalesMainLayoutPanel.TabIndex = 0;
//
// actualSalesMainDataGidView
@@ -632,24 +646,24 @@
this.actualSalesMainDataGidView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.actualSalesMainDataGidView.Dock = System.Windows.Forms.DockStyle.Fill;
this.actualSalesMainDataGidView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnKeystroke;
this.actualSalesMainDataGidView.Location = new System.Drawing.Point(5, 6);
this.actualSalesMainDataGidView.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.actualSalesMainDataGidView.Location = new System.Drawing.Point(4, 5);
this.actualSalesMainDataGidView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.actualSalesMainDataGidView.Name = "actualSalesMainDataGidView";
this.actualSalesMainDataGidView.ReadOnly = true;
this.actualSalesMainDataGidView.RowHeadersVisible = false;
this.actualSalesMainDataGidView.ShowCellErrors = false;
this.actualSalesMainDataGidView.ShowRowErrors = false;
this.actualSalesMainDataGidView.Size = new System.Drawing.Size(1706, 492);
this.actualSalesMainDataGidView.Size = new System.Drawing.Size(1454, 440);
this.actualSalesMainDataGidView.TabIndex = 1;
//
// suppliersTabPage
//
this.suppliersTabPage.Controls.Add(this.suppliersDataGridView);
this.suppliersTabPage.Location = new System.Drawing.Point(4, 33);
this.suppliersTabPage.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.suppliersTabPage.Location = new System.Drawing.Point(4, 29);
this.suppliersTabPage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.suppliersTabPage.Name = "suppliersTabPage";
this.suppliersTabPage.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.suppliersTabPage.Size = new System.Drawing.Size(1716, 504);
this.suppliersTabPage.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.suppliersTabPage.Size = new System.Drawing.Size(1462, 450);
this.suppliersTabPage.TabIndex = 1;
this.suppliersTabPage.Text = "Suppliers";
this.suppliersTabPage.UseVisualStyleBackColor = true;
@@ -664,22 +678,22 @@
this.suppliersDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.suppliersDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.suppliersDataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnKeystroke;
this.suppliersDataGridView.Location = new System.Drawing.Point(5, 6);
this.suppliersDataGridView.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.suppliersDataGridView.Location = new System.Drawing.Point(4, 5);
this.suppliersDataGridView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.suppliersDataGridView.Name = "suppliersDataGridView";
this.suppliersDataGridView.ReadOnly = true;
this.suppliersDataGridView.RowHeadersVisible = false;
this.suppliersDataGridView.Size = new System.Drawing.Size(1706, 492);
this.suppliersDataGridView.Size = new System.Drawing.Size(1454, 440);
this.suppliersDataGridView.TabIndex = 0;
//
// WeeklySalesTabPage
//
this.WeeklySalesTabPage.Controls.Add(this.weeklySalesDataGridView);
this.WeeklySalesTabPage.Location = new System.Drawing.Point(4, 33);
this.WeeklySalesTabPage.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.WeeklySalesTabPage.Location = new System.Drawing.Point(4, 29);
this.WeeklySalesTabPage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.WeeklySalesTabPage.Name = "WeeklySalesTabPage";
this.WeeklySalesTabPage.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.WeeklySalesTabPage.Size = new System.Drawing.Size(1716, 504);
this.WeeklySalesTabPage.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.WeeklySalesTabPage.Size = new System.Drawing.Size(1462, 450);
this.WeeklySalesTabPage.TabIndex = 3;
this.WeeklySalesTabPage.Text = "Weekly Sales";
this.WeeklySalesTabPage.UseVisualStyleBackColor = true;
@@ -693,23 +707,24 @@
this.weeklySalesDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.weeklySalesDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.weeklySalesDataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnKeystroke;
this.weeklySalesDataGridView.Location = new System.Drawing.Point(5, 6);
this.weeklySalesDataGridView.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.weeklySalesDataGridView.Location = new System.Drawing.Point(4, 5);
this.weeklySalesDataGridView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.weeklySalesDataGridView.Name = "weeklySalesDataGridView";
this.weeklySalesDataGridView.ReadOnly = true;
this.weeklySalesDataGridView.RowHeadersVisible = false;
this.weeklySalesDataGridView.Size = new System.Drawing.Size(1706, 492);
this.weeklySalesDataGridView.Size = new System.Drawing.Size(1454, 440);
this.weeklySalesDataGridView.TabIndex = 0;
//
// FrmMain
// frmMain
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(1734, 892);
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1478, 794);
this.Controls.Add(this.mainTableLayoutPanel);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.MaximizeBox = false;
this.Name = "FrmMain";
this.Name = "frmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Advertising Profit Control";
this.Load += new System.EventHandler(this.frmMain_Load);
@@ -722,10 +737,10 @@
this.commentMainGroupBox.PerformLayout();
this.profitAnalysisMainGroupBox.ResumeLayout(false);
this.profitAnalysisMainGroupBox.PerformLayout();
this.costOfSalesMainGroupBox.ResumeLayout(false);
this.costOfSalesMainGroupBox.PerformLayout();
this.grossProfitGroupBox.ResumeLayout(false);
this.grossProfitGroupBox.PerformLayout();
this.taxableGroupBox.ResumeLayout(false);
this.taxableGroupBox.PerformLayout();
this.dateSelectorPanel.ResumeLayout(false);
this.dateSelectorPanel.PerformLayout();
this.mainViewTabControl.ResumeLayout(false);
@@ -752,7 +767,7 @@
private System.Windows.Forms.TableLayoutPanel commentMainTableLayoutPanel;
private System.Windows.Forms.GroupBox commentMainGroupBox;
private System.Windows.Forms.GroupBox profitAnalysisMainGroupBox;
private System.Windows.Forms.GroupBox grossProfitGroupBox;
private System.Windows.Forms.GroupBox costOfSalesMainGroupBox;
private System.Windows.Forms.ToolStripMenuItem exitFileMainMenu;
private System.Windows.Forms.TabControl mainViewTabControl;
private System.Windows.Forms.TabPage projectionTab;
@@ -772,9 +787,16 @@
private System.Windows.Forms.Label departmentSalesLabel;
private System.Windows.Forms.TabPage WeeklySalesTabPage;
private System.Windows.Forms.DataGridView weeklySalesDataGridView;
private System.Windows.Forms.LinkLabel changeShrinkLinkLabel;
private System.Windows.Forms.Label shrinkLabel;
private System.Windows.Forms.ToolStripMenuItem helpMainMenu;
private System.Windows.Forms.ToolStripMenuItem showHideConsoleHelpMainMenu;
private System.Windows.Forms.GroupBox taxableGroupBox;
private System.Windows.Forms.Label costOfSalesLabel;
private System.Windows.Forms.Label lessInventoryEndOfWeekAtCostLabel;
private System.Windows.Forms.Label totalLabel;
private System.Windows.Forms.Label plusTotalPurchases;
private System.Windows.Forms.Label inventoryBeginingOfWeekAtCostLabel;
private System.Windows.Forms.GroupBox grossProfitGroupBox;
private System.Windows.Forms.Label grossProfitEstimatedWeeklyDeptmartmentExpenseLabel;
private System.Windows.Forms.Label perfectGrossProfitLabel;
private System.Windows.Forms.Label grossProfitDollarGrossProfitLabel;
@@ -792,12 +814,6 @@
private System.Windows.Forms.ToolStripMenuItem deleteRecordsMainMenu;
private System.Windows.Forms.TextBox commentsTextBox;
private System.Windows.Forms.ToolStripMenuItem modifyRecordMainMenu;
private System.Windows.Forms.ToolStripMenuItem manageItemsToolsMainMenu;
private System.Windows.Forms.ToolStripMenuItem dbVersionHelpMainMenu;
private System.Windows.Forms.Button printPreviewButton;
private System.Windows.Forms.CheckBox usePreRenderedFilesCheckbox;
private System.Windows.Forms.ToolStripMenuItem newFormTestToolStripMenuItem;
private System.Windows.Forms.LinkLabel shrinkLinkLabel;
}
}
+212 -323
View File
@@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
@@ -13,54 +11,27 @@ namespace AdvertsingProfitControl
{
public partial class FrmMain : Form
{
private double _SalesProducedByAdItems = 0;
private double _TotalProfitReturnFromAdItems = 0;
private double _gActualTotaSalesCalculatedTotal = 0;
private double _gActualTotalProfitReturnCalculatedTotal = 0;
private double _gCostOfSalesCalculatedTotal = 0;
private double _departmentSales = 0;
private List<string> _gDateStringCollection = new List<string>();
readonly FrmLogConsole _console = FrmLogConsole.GetStaticInstance;
private int _LazyPageCounter = 0;
public FrmMain()
{
InitializeComponent();
//Set the maximum and minimum sizes for the form.
//MaximumSize = new Size(1200, 650);
//MinimumSize = new Size(1000, 550);
MaximumSize = new Size(1200, 650);
MinimumSize = new Size(1000, 550);
}
private void frmMain_Load(object sender, EventArgs e)
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var versionControl = new DatabaseVersionControl();
var version = versionControl.GetDatabaseVerionNumber(databaseTracker.DatabaseConnectionString);
if(version == "0.3.0.0")
{
MessageBox.Show("An older version of the APC database has been detected.\nAdvertising Profit Control " + Application.ProductVersion + " will now attempt to update it.", "Outdated Database Detected");
string versionNumber = "";
if (versionControl.UpdateVersionPointFive(databaseTracker.DatabaseConnectionString, out versionNumber))
{
MessageBox.Show("The database has been successfully upgraded to version " + versionNumber + ".\nA back up of the old database has been made called APCDatabase.bak in the same location as the current database.", "Half Baked Code For The Win");
}
}
RowParsing.AdSpecialGroups.AddRange(databaseReader.ReturnGroupNameList(databaseTracker.DatabaseConnectionString));
FillDateSuggestionComboBoxes();
BuildAndFillDataGridTables();
CalculateProfitAnalysis();
CalculateGrossProfit();
projectedSalesMainDataGrid.KeyDown += FrmMain_KeyDown;
//var margin = new Margins(50, 50, 0, 0);
//_printDoc.DefaultPageSettings.Margins = margin;
}
private void FrmMain_KeyDown(object sender, KeyEventArgs e)
{
if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.Up)
{
MessageBox.Show("My message");
}
}
private void UpdateDataGridViewInformation(object sender, EventArgs e)
@@ -104,37 +75,155 @@ namespace AdvertsingProfitControl
//Now check to make sure there were no errors grabbing the ID, IF there were return.
if (dateId == "0") return;
//Clear the class global variables to prevents calculation mishaps.
_SalesProducedByAdItems = 0;
_TotalProfitReturnFromAdItems = 0;
_gActualTotaSalesCalculatedTotal = 0;
_gActualTotalProfitReturnCalculatedTotal = 0;
_gCostOfSalesCalculatedTotal = 0;
//Clear all DataGridViews since the date supplied is valid and in the database.
projectedSalesMainDataGrid.DataSource = null;
projectedSalesMainDataGrid.Columns.Clear();
inventoryDataGridView.DataSource = null;
inventoryDataGridView.Columns.Clear();
actualSalesMainDataGidView.DataSource = null;
actualSalesMainDataGidView.Columns.Clear();
suppliersDataGridView.DataSource = null;
weeklySalesDataGridView.DataSource = null;
var indexOfAdSpecialRow = -1;
var regexGroupCategoryparser = new Regex(@"^(\d)?\|\d");
//Begin by grabbing the Projections table
var tempTable = dataBaseReader.ReturnProjectionsTable(dateId, databaseTracker.DatabaseConnectionString);
if (tempTable.Rows.Count > 0)
{
BuildSalesDataGridViews(projectedSalesMainDataGrid, tempTable);
projectedSalesMainDataGrid.DataSource = SumSalesTable(tempTable);
var adCategory = "";
for (var i = 0; i < projectedSalesMainDataGrid.Rows.Count; i++)
{
if ((string)projectedSalesMainDataGrid.Rows[i].Cells[7].EditedFormattedValue == "1")
{
projectedSalesMainDataGrid.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
}else if ((string) projectedSalesMainDataGrid.Rows[i].Cells[7].EditedFormattedValue == "2")
{
projectedSalesMainDataGrid.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
}
else if (
regexGroupCategoryparser.IsMatch(
(string) projectedSalesMainDataGrid.Rows[i].Cells[7].EditedFormattedValue))
{
string[] spam = new string[2];
spam = ParseAdSpecialRows(projectedSalesMainDataGrid.Rows[i].Cells[7].EditedFormattedValue.ToString());
if (spam.Length > 1)
{
adCategory = spam[1];
}
else
{
adCategory = spam[0];
}
if (indexOfAdSpecialRow == -1)
{
indexOfAdSpecialRow = i;
}
if (spam[0] == "1")
{
projectedSalesMainDataGrid.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
}else if (spam[0] == "2")
{
projectedSalesMainDataGrid.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
}
}
}
var dataGridViewColumn = projectedSalesMainDataGrid.Columns["FK_GroupID"];
if (dataGridViewColumn != null)
dataGridViewColumn.Visible = false;
}
//Grabbing the Inventory table
tempTable = dataBaseReader.ReturnInventoryTable(dateId, databaseTracker.DatabaseConnectionString);
if (tempTable.Rows.Count > 0)
{
BuildInventoryDataGridView(inventoryDataGridView, tempTable);
inventoryDataGridView.DataSource = tempTable;
string adCategory = "";
for (var i = 0; i < inventoryDataGridView.Rows.Count; i++)
{
if ((string)inventoryDataGridView.Rows[i].Cells[5].EditedFormattedValue == "1")
{
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
}
else if ((string)inventoryDataGridView.Rows[i].Cells[5].EditedFormattedValue == "2")
{
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
}
else if (
regexGroupCategoryparser.IsMatch(
(string)inventoryDataGridView.Rows[i].Cells[5].EditedFormattedValue))
{
string[] spam = new string[2];
spam = ParseAdSpecialRows(inventoryDataGridView.Rows[i].Cells[5].EditedFormattedValue.ToString());
if (spam.Length > 1)
{
adCategory = spam[1];
}
else
{
adCategory = spam[0];
}
if (spam[0] == "1")
{
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
}
else if (spam[0] == "2")
{
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
}
}
}
var dataGridViewColumn = inventoryDataGridView.Columns["FK_GroupID"];
if (dataGridViewColumn != null)
dataGridViewColumn.Visible = false;
}
//And the Actual Sales table
tempTable = dataBaseReader.ReturnActualSales(dateId, databaseTracker.DatabaseConnectionString);
if (tempTable.Rows.Count > 0)
{
BuildSalesDataGridViews(actualSalesMainDataGidView, tempTable);
actualSalesMainDataGidView.DataSource = SumSalesTable(tempTable);
var adCategory = "";
for (var i = 0; i < actualSalesMainDataGidView.Rows.Count; i++)
{
if ((string)actualSalesMainDataGidView.Rows[i].Cells[7].EditedFormattedValue == "1")
{
actualSalesMainDataGidView.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
}
else if ((string)actualSalesMainDataGidView.Rows[i].Cells[7].EditedFormattedValue == "2")
{
actualSalesMainDataGidView.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
}
else if (
regexGroupCategoryparser.IsMatch(
(string)actualSalesMainDataGidView.Rows[i].Cells[7].EditedFormattedValue))
{
string[] spam = new string[2];
spam = ParseAdSpecialRows(actualSalesMainDataGidView.Rows[i].Cells[7].EditedFormattedValue.ToString());
if (spam.Length > 1)
{
adCategory = spam[1];
}
else
{
adCategory = spam[0];
}
if (spam[0] == "1")
{
actualSalesMainDataGidView.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
}
else if (spam[0] == "2")
{
actualSalesMainDataGidView.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
}
}
}
var year = actualSalesMainDataGidView.Columns["FK_GroupID"];
if (year != null)
year.Visible = false;
}
//Next the Invoices table
@@ -156,7 +245,7 @@ namespace AdvertsingProfitControl
private void CalculateProfitAnalysis(double shrink = 0.30)
{
if (Math.Abs(_SalesProducedByAdItems) < 1 || Math.Abs(_TotalProfitReturnFromAdItems) < 1)
if (Math.Abs(_gActualTotaSalesCalculatedTotal) < 1 || Math.Abs(_gActualTotalProfitReturnCalculatedTotal) < 1)
{
//Clear the labels...
if (weeklySalesDataGridView.Rows.Count == 0 || weeklySalesDataGridView.Rows[0].Cells[7].EditedFormattedValue.ToString() == "0.0000")
@@ -165,14 +254,14 @@ namespace AdvertsingProfitControl
departmentSalesLabel.ForeColor = Color.Red;
}
if (_SalesProducedByAdItems == 0)
if (_gActualTotaSalesCalculatedTotal == 0)
{
salesProducedLabel.Text = "Sales Produced By Ad Items (A): No Values to Total.";
salesProducedLabel.ForeColor = Color.Red;
}
remainingSalesLabel.Text = "Remaining Sales: ";
if (_TotalProfitReturnFromAdItems == 0)
if (_gActualTotalProfitReturnCalculatedTotal == 0)
{
totalProfitFromAdItemsLabel.Text = "Total Profit Return From Ad Items (B): No Values to Total.";
totalProfitFromAdItemsLabel.ForeColor = Color.Red;
@@ -182,196 +271,31 @@ namespace AdvertsingProfitControl
totalProfitReturnLabel.Text = "Total Profit Return: ";
return;
}
double.TryParse(weeklySalesDataGridView.Rows[0].Cells[7].EditedFormattedValue.ToString(), out _departmentSales);
double departmentSales = 0;
Double.TryParse(weeklySalesDataGridView.Rows[0].Cells[7].EditedFormattedValue.ToString(), out departmentSales);
//Since there are department sales, change the label's color to make sure it doesn't appear as an error.
departmentSalesLabel.ForeColor = Color.Black;
departmentSalesLabel.Text = "Department Sales: " + _departmentSales.ToString("C");
departmentSalesLabel.Text = "Department Sales: " + departmentSales.ToString("C");
//Assume that the sales produced is larger then zero (0).
salesProducedLabel.ForeColor = Color.Black;
salesProducedLabel.Text = "Sales Produced By Ad Items (A): " + _SalesProducedByAdItems.ToString("C");
salesProducedLabel.Text = "Sales Produced By Ad Items (A): " + _gActualTotaSalesCalculatedTotal.ToString("C");
double remainingSales = _departmentSales - _SalesProducedByAdItems;
double remainingSales = departmentSales - _gActualTotaSalesCalculatedTotal;
remainingSalesLabel.Text = "Remaining Sales: " + remainingSales.ToString("C");
//Again assume the total profit return is larger then zero (0).
totalProfitFromAdItemsLabel.ForeColor = Color.Black;
totalProfitFromAdItemsLabel.Text = "Total Profit Return From Ad Items (B): " + _TotalProfitReturnFromAdItems.ToString("C");
totalProfitFromAdItemsLabel.Text = "Total Profit Return From Ad Items (B): " + _gActualTotalProfitReturnCalculatedTotal.ToString("C");
//Shrink is being used as a place holder for Cross Profit % which is obtained by dividing gActualTotalProfitReturnCalculatedTotal by the department weekly retail sales.
double totalProfitReturnFromRemainingSales = shrink * remainingSales;
//
totalProfitReturnFromRemaingLabel.Text = "Total Profit Return From Remaining Sales: " + totalProfitReturnFromRemainingSales.ToString("C");
double totalProfitReturn = _TotalProfitReturnFromAdItems + totalProfitReturnFromRemainingSales;
double totalProfitReturn = _gActualTotalProfitReturnCalculatedTotal + totalProfitReturnFromRemainingSales;
totalProfitReturnLabel.Text = "Total Profit Return: " + totalProfitReturn.ToString("C");
}
private void BuildSalesDataGridViews(DataGridView dataGridView, DataTable table)
private void CalculateCostOfSales()
{
var adSpecialIndex = -1;
double totalSales = 0;
double totalProfitReturn = 0;
foreach (DataColumn column in table.Columns)
{
var dataGridViewColumn = new DataGridViewColumn()
{
HeaderText = column.ColumnName,
CellTemplate = new DataGridViewTextBoxCell()
};
if (dataGridViewColumn.HeaderText.Contains("Projection"))
{
dataGridViewColumn.HeaderText = dataGridViewColumn.HeaderText.Replace("Projection", "");
}
else if (dataGridViewColumn.HeaderText.Contains("Actual"))
{
dataGridViewColumn.HeaderText = dataGridViewColumn.HeaderText.Replace("Actual", "");
}
if (dataGridViewColumn.HeaderText == "FK_GroupID" || dataGridViewColumn.HeaderText == "RowAttribute")
{
dataGridViewColumn.Visible = false;
}
dataGridViewColumn.HeaderText = TextFormat.AddSpacesToSentence(dataGridViewColumn.HeaderText, false);
dataGridView.Columns.Add(dataGridViewColumn);
}
for (var i = 0; i < table.Rows.Count; i++)
{
var row = new DataGridViewRow();
//Checks for the group, if any, the row or rows is/are part of.
if (table.Rows[i][8].ToString() != "" &&
int.Parse(table.Rows[i][8].ToString()) != 0 && adSpecialIndex == -1)
{
adSpecialIndex = i;
var adSpecialRow = new DataGridViewRow();
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var groupName = databaseReader.ReturnGroupNameFromGroupId(table.Rows[i][8].ToString(), databaseTracker.DatabaseConnectionString);
adSpecialRow.DefaultCellStyle.BackColor = Color.DarkGray;
dataGridView.Rows.Add(adSpecialRow);
dataGridView.Rows[i].Cells[0].Value = groupName;
}
//Checks for row attribute
if (table.Rows[i][7].ToString() != "")
{
//The seventh column contains the row's attribute if any.
var rowAttribute = int.Parse(table.Rows[i][7].ToString());
if (rowAttribute == 1)
{
row.DefaultCellStyle.BackColor = Color.LightGray;
}
else if (rowAttribute == 2)
{
row.DefaultCellStyle.BackColor = Color.LightBlue;
}
foreach (var dataCell in table.Rows[i].ItemArray.Select(cell => new DataGridViewTextBoxCell { Value = cell }))
{
row.Cells.Add(dataCell);
}
dataGridView.Rows.Add(row);
}
else
{
dataGridView.Rows.Add(table.Rows[i].ItemArray);
}
//Check for values in the Total Sales and Total Profit Return columns
double tempOut = 0;
if (double.TryParse(table.Rows[i][3].ToString(), out tempOut))
{
if (tempOut >= 0)
{
totalSales += tempOut;
}
}
if (double.TryParse(table.Rows[i][6].ToString(), out tempOut))
{
if (tempOut >= 0)
{
totalProfitReturn += tempOut;
}
}
}
var totalsRow = new object[9];
totalsRow[0] = "Totals";
totalsRow[3] = totalSales;
totalsRow[6] = totalProfitReturn;
dataGridView.Rows.Add(totalsRow);
if (dataGridView.Name == "actualSalesMainDataGidView")
{
_SalesProducedByAdItems = totalSales;
_TotalProfitReturnFromAdItems = totalProfitReturn;
}
}
private void BuildInventoryDataGridView(DataGridView dataGridView, DataTable table)
{
var lastAdSpecialIndex = -1;
for (var columnIndex = 0; columnIndex < table.Columns.Count; columnIndex++)
{
var dataGridViewColumn = new DataGridViewColumn
{
Name = table.Columns[columnIndex].ColumnName,
CellTemplate = new DataGridViewTextBoxCell()
};
var columnHeaderText = table.Columns[columnIndex].ColumnName;
columnHeaderText = TextFormat.AddSpacesToSentence(columnHeaderText, false);
//Make the row attribute column invisible.
if (table.Columns[columnIndex].ColumnName == "RowAttribute")
{
dataGridViewColumn.Visible = false;
}
//Make any columns with a foreign key invisible.
if (table.Columns[columnIndex].ColumnName.Contains("FK"))
{
dataGridViewColumn.Visible = false;
}
dataGridViewColumn.HeaderText = columnHeaderText;
dataGridView.Columns.Add(dataGridViewColumn);
}
for (var rowIndex = 0; rowIndex < table.Rows.Count; rowIndex++)
{
var row = new DataGridViewRow();
if (table.Rows[rowIndex][6].ToString() != "" && int.Parse(table.Rows[rowIndex][6].ToString()) != 0 && lastAdSpecialIndex == -1)
{
lastAdSpecialIndex = rowIndex;
var adSpecialRow = new DataGridViewRow();
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var groupName = databaseReader.ReturnGroupNameFromGroupId(table.Rows[rowIndex][6].ToString(), databaseTracker.DatabaseConnectionString);
adSpecialRow.DefaultCellStyle.BackColor = Color.DarkGray;
dataGridView.Rows.Add(adSpecialRow);
dataGridView.Rows[rowIndex].Cells[0].Value = groupName;
}
if (table.Rows[rowIndex][5].ToString() != "")
{
//The fifth column contains the row's attribute if any.
var rowAttribute = int.Parse(table.Rows[rowIndex][5].ToString());
if (rowAttribute == 1)
{
row.DefaultCellStyle.BackColor = Color.LightGray;
}
else if (rowAttribute == 2)
{
row.DefaultCellStyle.BackColor = Color.LightBlue;
}
foreach (var dataCell in table.Rows[rowIndex].ItemArray.Select(cell => new DataGridViewTextBoxCell { Value = cell }))
{
row.Cells.Add(dataCell);
}
dataGridView.Rows.Add(row);
}
else
{
dataGridView.Rows.Add(table.Rows[rowIndex].ItemArray);
}
}
//?
}
private void CalculateGrossProfit()
@@ -410,6 +334,48 @@ namespace AdvertsingProfitControl
CalculateGrossProfit();
}
/// <summary>
/// Appends a new "Totals" row to the end of the DataTable that is passed in
/// and sums up the Total Sales and Total Profit Return columns as well as
/// storing the Total Sales and Total Profit Return in their respective
/// class wide variables for use with other functions.
/// </summary>
/// <param name="table">The sales table to be summed up.</param>
/// <returns></returns>
private DataTable SumSalesTable(DataTable table)
{
//IF the table is null OR has an invalid column count then return.
if (table == null || table.Columns.Count < 7) return table;
//Both Projections and Actual tables have the Total Sales and Total Profit Return columns in the same position,
//indexes three (3) and six (6) respectively.
double totalSalesSum = 0;
double totalProfitReturnSum = 0;
for (var i = 0; i < table.Rows.Count; i++)
{
if (table.Rows[i][3].ToString() != "")
{
totalSalesSum += Convert.ToDouble(table.Rows[i][3]);
}
if (table.Rows[i][6].ToString() != "")
{
totalProfitReturnSum += Convert.ToDouble(table.Rows[i][6]);
}
}
//Once the totals have been calculated store them in the class wide variables so other methods can use them.
_gActualTotaSalesCalculatedTotal = totalSalesSum;
_gActualTotalProfitReturnCalculatedTotal = totalProfitReturnSum;
//Create an object array to store the summed values and add them at the end to the table before returning it.
object[] rowContents = new object[table.Columns.Count];
rowContents[0] = "Total";
rowContents[3] = totalSalesSum;
rowContents[6] = totalProfitReturnSum;
table.Rows.Add(rowContents);
return table;
}
/// <summary>
/// Appends a new "Totals" row to the end of the Invoice table that is passed in
/// and sums up the Net Cost of Invoices column as well as storing the total Costs of Sales
@@ -644,6 +610,34 @@ namespace AdvertsingProfitControl
CalculateGrossProfit();
}
private string[] ParseAdSpecialRows(string groupIdentifier)
{
var groupCategory = new string[2];
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var patternForOnlyPipeAndAdSpecial = new Regex(@"^\|\d{1}");
var patternForBothNumbersOnPipe = new Regex(@"^\d{1}\|\d{1}");
if (patternForOnlyPipeAndAdSpecial.IsMatch(groupIdentifier))
{
groupCategory[0] = groupIdentifier;
if (groupIdentifier[0].ToString() != "")
{
groupCategory[0] = groupCategory[0].Replace("|", "");
groupCategory[0] = databaseReader.ReturnGroupNameFromGroupId(groupCategory[0], databaseTracker.DatabaseConnectionString);
}
}else if (patternForBothNumbersOnPipe.IsMatch(groupIdentifier))
{
string[] temp = groupIdentifier.Split('|');
groupCategory[0] = temp[0];
groupCategory[1] = temp[1];
groupCategory[1] = databaseReader.ReturnGroupNameFromGroupId(groupCategory[1], databaseTracker.DatabaseConnectionString);
}
return groupCategory;
}
private void adSpecialKeyWordsToolsMainMenu_Click(object sender, EventArgs e)
{
var keyWordRegister = new FrmAdSpecialRegister();
@@ -668,111 +662,6 @@ namespace AdvertsingProfitControl
CalculateProfitAnalysis();
CalculateGrossProfit();
}
private void manageItemsToolsMainMenu_Click(object sender, EventArgs e)
{
var adItemManager = new FrmManageAdItems();
adItemManager.ShowDialog();
}
private void dbVersionHelpMainMenu_Click(object sender, EventArgs e)
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var version = databaseReader.GetDatabaseVersion(databaseTracker.DatabaseConnectionString);
if (version != "0.0.0.0")
{
MessageBox.Show("The current database's version is " + version + ".", "Database Version Number");
}
}
private void PrintPage(object sender, PrintPageEventArgs e)
{
Bitmap bitMap;
if (_LazyPageCounter == 0)
{
bitMap = new Bitmap(Application.StartupPath + "\\FrontPage.png");
}
else
{
bitMap = new Bitmap(Application.StartupPath + "\\BackPage.png");
}
var rect = e.MarginBounds;
if ((double)bitMap.Width / (double)bitMap.Height > (double)rect.Width / (double)rect.Height) // image is wider
{
rect.Height = (int)((double)bitMap.Height / (double)bitMap.Width * (double)rect.Width);
}
else
{
rect.Width = (int)((double)bitMap.Width / (double)bitMap.Height * (double)rect.Height);
}
if (_LazyPageCounter == 0)
{
e.Graphics.DrawImage(bitMap, new Rectangle(0, 25, 850, 1050));
_LazyPageCounter++;
e.HasMorePages = true;
}
else
{
e.Graphics.DrawImage(bitMap, new Rectangle(0, 0, 850, 1100));
_LazyPageCounter = 0;
e.HasMorePages = false;
}
}
private void DisplayPrintPreview(object sender, EventArgs e)
{
//Build and render the front and back forms of the document.
var test = new FrontPageGenerator();
var backPageTest = new BackPageGenerator();
var printTestPage = new PrintDocument();
var printDialog = new PrintPreviewDialog();
if (!usePreRenderedFilesCheckbox.Checked)
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var dateId =
databaseReader.RetrieveDateIdByDateString(
monthComboBox.SelectedItem + "/" + dayComboBox.SelectedItem + "/" + yearComboBox.SelectedItem,
databaseTracker.DatabaseConnectionString);
double remaingingSales = _departmentSales - _SalesProducedByAdItems;
double totalProfitReturnFromReminaingSales = remaingingSales*.3;
double totalProfitReturn = _TotalProfitReturnFromAdItems + totalProfitReturnFromReminaingSales;
test.BuildFormFrontCompressedLayout(dateId, _departmentSales, _SalesProducedByAdItems, remaingingSales,
_TotalProfitReturnFromAdItems, totalProfitReturnFromReminaingSales, totalProfitReturn,
commentsTextBox.Text);
test.RenderHtmlToImage();
backPageTest.GenerateWeeklyInventoryControlPage(dateId);
backPageTest.RenderHtmlToImage();
}
else
{
if (File.Exists(Application.StartupPath + "\\" + "FrontPage.html") &&
File.Exists(Application.StartupPath + "\\" + "Backpage.html"))
{
test.RenderHtmlToImage();
backPageTest.RenderHtmlToImage();
}
}
//var margin = new Margins(50, 50, 0, 0);
//printDoc.DefaultPageSettings.Margins = margin;
printTestPage.PrintPage += PrintPage;
printDialog.Document = printTestPage;
printDialog.ShowDialog();
printDialog.Document = new PrintDocument();
}
private void newFormTestToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = new NewAddRecord();
form.ShowDialog();
}
}
//http://stackoverflow.com/questions/487661/how-do-i-suspend-painting-for-a-control-and-its-children
+32 -36
View File
@@ -45,16 +45,16 @@
this.invoicesTabPage = new System.Windows.Forms.TabPage();
this.invoicesDataGridView = new System.Windows.Forms.DataGridView();
this.weeklySalesTabPage = new System.Windows.Forms.TabPage();
this.weeklySalesDataGridView = new System.Windows.Forms.DataGridView();
this.secondaryTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.commentsGroupBox = new System.Windows.Forms.GroupBox();
this.commentsTextBox = new System.Windows.Forms.TextBox();
this.dateSelectorGroupBox = new System.Windows.Forms.GroupBox();
this.updateRecords = new System.Windows.Forms.Button();
this.notificationLabel = new System.Windows.Forms.Label();
this.yearComboBox = new System.Windows.Forms.ComboBox();
this.dayComboBox = new System.Windows.Forms.ComboBox();
this.monthComboBox = new System.Windows.Forms.ComboBox();
this.updateRecords = new System.Windows.Forms.Button();
this.weeklySalesDataGridView = new System.Windows.Forms.DataGridView();
this.mainTableLayoutPanel.SuspendLayout();
this.mainMenu.SuspendLayout();
this.mainTabControl.SuspendLayout();
@@ -67,10 +67,10 @@
this.invoicesTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.invoicesDataGridView)).BeginInit();
this.weeklySalesTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.weeklySalesDataGridView)).BeginInit();
this.secondaryTableLayoutPanel.SuspendLayout();
this.commentsGroupBox.SuspendLayout();
this.dateSelectorGroupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.weeklySalesDataGridView)).BeginInit();
this.SuspendLayout();
//
// mainTableLayoutPanel
@@ -129,7 +129,7 @@
// getAttributeToolStripMenuItem
//
this.getAttributeToolStripMenuItem.Name = "getAttributeToolStripMenuItem";
this.getAttributeToolStripMenuItem.Size = new System.Drawing.Size(211, 30);
this.getAttributeToolStripMenuItem.Size = new System.Drawing.Size(199, 30);
this.getAttributeToolStripMenuItem.Text = "Get Attribute";
this.getAttributeToolStripMenuItem.Click += new System.EventHandler(this.getAttributeToolStripMenuItem_Click);
//
@@ -189,7 +189,6 @@
//
// inventoryDataGridView
//
this.inventoryDataGridView.AllowDrop = true;
this.inventoryDataGridView.AllowUserToResizeRows = false;
this.inventoryDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.inventoryDataGridView.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
@@ -215,7 +214,6 @@
//
// actualSalesDataGridView
//
this.actualSalesDataGridView.AllowDrop = true;
this.actualSalesDataGridView.AllowUserToResizeRows = false;
this.actualSalesDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.actualSalesDataGridView.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
@@ -265,19 +263,6 @@
this.weeklySalesTabPage.Text = "Weekly Sales";
this.weeklySalesTabPage.UseVisualStyleBackColor = true;
//
// weeklySalesDataGridView
//
this.weeklySalesDataGridView.AllowUserToAddRows = false;
this.weeklySalesDataGridView.AllowUserToDeleteRows = false;
this.weeklySalesDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.weeklySalesDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.weeklySalesDataGridView.Location = new System.Drawing.Point(0, 0);
this.weeklySalesDataGridView.MultiSelect = false;
this.weeklySalesDataGridView.Name = "weeklySalesDataGridView";
this.weeklySalesDataGridView.RowTemplate.Height = 28;
this.weeklySalesDataGridView.Size = new System.Drawing.Size(1164, 428);
this.weeklySalesDataGridView.TabIndex = 0;
//
// secondaryTableLayoutPanel
//
this.secondaryTableLayoutPanel.ColumnCount = 3;
@@ -289,13 +274,13 @@
this.secondaryTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.secondaryTableLayoutPanel.Controls.Add(this.commentsGroupBox, 0, 0);
this.secondaryTableLayoutPanel.Controls.Add(this.dateSelectorGroupBox, 1, 0);
this.secondaryTableLayoutPanel.Controls.Add(this.updateRecords, 2, 0);
this.secondaryTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.secondaryTableLayoutPanel.Location = new System.Drawing.Point(4, 514);
this.secondaryTableLayoutPanel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.secondaryTableLayoutPanel.Name = "secondaryTableLayoutPanel";
this.secondaryTableLayoutPanel.RowCount = 1;
this.secondaryTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.secondaryTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.secondaryTableLayoutPanel.Size = new System.Drawing.Size(1172, 193);
this.secondaryTableLayoutPanel.TabIndex = 2;
//
@@ -321,8 +306,6 @@
//
// dateSelectorGroupBox
//
this.secondaryTableLayoutPanel.SetColumnSpan(this.dateSelectorGroupBox, 2);
this.dateSelectorGroupBox.Controls.Add(this.updateRecords);
this.dateSelectorGroupBox.Controls.Add(this.notificationLabel);
this.dateSelectorGroupBox.Controls.Add(this.yearComboBox);
this.dateSelectorGroupBox.Controls.Add(this.dayComboBox);
@@ -330,26 +313,15 @@
this.dateSelectorGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.dateSelectorGroupBox.Location = new System.Drawing.Point(393, 3);
this.dateSelectorGroupBox.Name = "dateSelectorGroupBox";
this.dateSelectorGroupBox.Size = new System.Drawing.Size(776, 187);
this.dateSelectorGroupBox.Size = new System.Drawing.Size(384, 187);
this.dateSelectorGroupBox.TabIndex = 1;
this.dateSelectorGroupBox.TabStop = false;
this.dateSelectorGroupBox.Text = "Select a date to modify:";
//
// updateRecords
//
this.updateRecords.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.updateRecords.Location = new System.Drawing.Point(598, 143);
this.updateRecords.Name = "updateRecords";
this.updateRecords.Size = new System.Drawing.Size(178, 40);
this.updateRecords.TabIndex = 2;
this.updateRecords.Text = "Update Records";
this.updateRecords.UseVisualStyleBackColor = true;
this.updateRecords.Click += new System.EventHandler(this.addRecords_Click);
//
// notificationLabel
//
this.notificationLabel.AutoSize = true;
this.notificationLabel.Location = new System.Drawing.Point(6, 105);
this.notificationLabel.Location = new System.Drawing.Point(7, 122);
this.notificationLabel.Name = "notificationLabel";
this.notificationLabel.Size = new System.Drawing.Size(0, 20);
this.notificationLabel.TabIndex = 3;
@@ -378,6 +350,30 @@
this.monthComboBox.Size = new System.Drawing.Size(121, 28);
this.monthComboBox.TabIndex = 0;
//
// updateRecords
//
this.updateRecords.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.updateRecords.Location = new System.Drawing.Point(991, 150);
this.updateRecords.Name = "updateRecords";
this.updateRecords.Size = new System.Drawing.Size(178, 40);
this.updateRecords.TabIndex = 2;
this.updateRecords.Text = "Update Records";
this.updateRecords.UseVisualStyleBackColor = true;
this.updateRecords.Click += new System.EventHandler(this.addRecords_Click);
//
// weeklySalesDataGridView
//
this.weeklySalesDataGridView.AllowUserToAddRows = false;
this.weeklySalesDataGridView.AllowUserToDeleteRows = false;
this.weeklySalesDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.weeklySalesDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.weeklySalesDataGridView.Location = new System.Drawing.Point(0, 0);
this.weeklySalesDataGridView.MultiSelect = false;
this.weeklySalesDataGridView.Name = "weeklySalesDataGridView";
this.weeklySalesDataGridView.RowTemplate.Height = 28;
this.weeklySalesDataGridView.Size = new System.Drawing.Size(1164, 428);
this.weeklySalesDataGridView.TabIndex = 0;
//
// FrmModifyRecord
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
@@ -406,12 +402,12 @@
this.invoicesTabPage.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.invoicesDataGridView)).EndInit();
this.weeklySalesTabPage.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.weeklySalesDataGridView)).EndInit();
this.secondaryTableLayoutPanel.ResumeLayout(false);
this.commentsGroupBox.ResumeLayout(false);
this.commentsGroupBox.PerformLayout();
this.dateSelectorGroupBox.ResumeLayout(false);
this.dateSelectorGroupBox.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.weeklySalesDataGridView)).EndInit();
this.ResumeLayout(false);
}
File diff suppressed because it is too large Load Diff
+3 -1
View File
@@ -1,4 +1,5 @@
using System;
using System.Threading;
using System.Windows.Forms;
namespace AdvertsingProfitControl
@@ -9,8 +10,9 @@ namespace AdvertsingProfitControl
/// The main entry point for the application.
/// </summary>
[STAThread]
private static void Main()
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ThreadException += GlobalClasses.LogError;
@@ -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("0.9.5.2")]
[assembly: AssemblyFileVersion("0.9.5.2")]
[assembly: AssemblyVersion("0.8.5.0")]
[assembly: AssemblyFileVersion("0.8.5.0")]
@@ -26,7 +26,6 @@
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<dpiAware>true/PM</dpiAware>
<!-- A list of all Windows versions that this application is designed to work with.
Windows will automatically select the most compatible environment.-->
<!-- If your application is designed to work with Windows Vista, uncomment the following supportedOS node-->
@@ -35,7 +34,6 @@
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->
<!-- If your application is designed to work with Windows 8, uncomment the following supportedOS node-->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>-->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>-->
</application>
</compatibility>
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
+20 -39
View File
@@ -6,23 +6,22 @@ using System.Linq;
namespace AdvertsingProfitControl
{
internal class RowParsing
class RowParsing
{
public static List<string> AdSpecialGroups = new List<string>();
public string CheckForGroupKeyWord(string cellContents)
{
string[] weekendAdIdentifiers = {"Weekend Ad", "Valentines", "Affiliated Weekend Ad", "Daily Coupons", "New Years Ad", "Christmas", "Mother's Day"};
var keyWord = "NoGroupFound";
var query = from adI in AdSpecialGroups
var query = from adI in weekendAdIdentifiers
where adI.Equals(cellContents, StringComparison.InvariantCultureIgnoreCase)
select adI;
var enumerable = query as string[] ?? query.ToArray();
if (enumerable.ToArray().Length > 0)
if (query.ToArray().Length > 0)
{
//Grab the first object in the array and return it.
keyWord = enumerable.ToArray().First();
keyWord = query.ToArray().First();
}
return keyWord;
@@ -32,26 +31,25 @@ namespace AdvertsingProfitControl
/// </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)
public string GetRowAttribute(DataGridViewRow row)
{
//IF the supplied row is null, then simply declare it an IncompleteRow.
if (row == null)
{
return RowAttribute.IncompleteRow;
return "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;
return "NewRow";
}
var rowContents = new List<string>();
var rowAttribute = RowAttribute.MemberRow;
var 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 >= (int) SalesTableColumns.IsHeaderRow) { 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.
@@ -61,10 +59,10 @@ namespace AdvertsingProfitControl
{
rowContents.Add(cell.EditedFormattedValue.ToString());
}
//If the first cell contains nothing, then return as IncompleteRow.
else if (cellContentsStripped == "" && i == (int) SalesTableColumns.AdItem)
//If the first cell contains nothing, than return as IncompleteRow.
else if (cellContentsStripped == "" && i == 0)
{
return RowAttribute.IncompleteRow;
return "IncompleteRow";
}
i++;
}
@@ -73,7 +71,7 @@ namespace AdvertsingProfitControl
//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;
rowAttribute = "HeaderRow";
}
else if (rowContents.Count == 1) //Check to see if this row is intended to be for a special ad.
{
@@ -81,31 +79,21 @@ namespace AdvertsingProfitControl
//IF a keyword is found then declare this row an AdSpecialRow.
if (keyWord != "NoGroupFound")
{
return RowAttribute.AdSpecialRow;
return "AdSpecialRow";
}
}
return rowAttribute;
}
public RowAttribute GetRowAttribute(object[] row)
{
var rowAttribute = RowAttribute.MemberRow;
return rowAttribute;
}
public void PaintDataGridViewRowGroups(DataGridView dataGridView, DataGridView companionDataGridView = null, int startIndex = 0,
public void PaintDataGridViewRowGroups(DataGridView dataGridView, int startIndex = 0,
bool stopOnFirstFullGroupFound = false)
{
}
/// <summary>
/// Checks for the presents of a repeat command using the Reg-ex engine.
/// Checks for the presents of a repeat command using the Regex engine.
/// If a repeat command is found it returns the line number the command
/// specifies to repeat.
/// </summary>
@@ -113,25 +101,18 @@ namespace AdvertsingProfitControl
/// <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 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;
if (rgx.IsMatch(rowCommandField))
{
//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,
MemberRow = 1,
HeaderRow = 2,
AdSpecialRow = 3,
IncompleteRow = 4
}
}