Added the new modify record form, can only pull in the Projections table and parse it. Fixed a bug in the modify record form where the first row would be marked as pending edit due to not checking the beginning cell variable correctly.

This commit is contained in:
2017-01-17 12:20:48 -06:00
parent bd586580e6
commit c9d8186d75
14 changed files with 3611 additions and 32 deletions
Binary file not shown.
@@ -106,9 +106,16 @@
<ItemGroup>
<Compile Include="AdItemCollectionModel.cs" />
<Compile Include="AdvertisingProfitControlTableHelper.cs" />
<Compile Include="ApcTableStatus.cs" />
<Compile Include="ApplicationColors.cs" />
<Compile Include="DbTableWriterStatus.cs" />
<Compile Include="DbWriterStatus.cs" />
<Compile Include="NewModifyRecord.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="NewModifyRecord.Designer.cs">
<DependentUpon>NewModifyRecord.cs</DependentUpon>
</Compile>
<Compile Include="TextFormat.cs" />
<Compile Include="APCDatabaseWriter.cs" />
<Compile Include="BackPageGenerator.cs" />
@@ -193,6 +200,9 @@
<EmbeddedResource Include="NewAddRecord.resx">
<DependentUpon>NewAddRecord.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="NewModifyRecord.resx">
<DependentUpon>NewModifyRecord.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
+45
View File
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdvertsingProfitControl
{
internal class ApcTableStatus
{
private DbTableWriterStatus _projectionsTableStatus = new DbTableWriterStatus();
private DbTableWriterStatus _inventoryTableStatus = new DbTableWriterStatus();
private DbTableWriterStatus _actualSalesStatus = new DbTableWriterStatus();
public void SetProjectionsTableStatus(DbTableWriterStatus status)
{
_projectionsTableStatus = status;
}
public DbTableWriterStatus GetProjectionsStatus()
{
return _projectionsTableStatus;
}
public void SetInventoryStatus(DbTableWriterStatus status)
{
_inventoryTableStatus = status;
}
public DbTableWriterStatus GetInventoryStatus()
{
return _inventoryTableStatus;
}
public void SetActualSalesStatus(DbTableWriterStatus status)
{
_actualSalesStatus = status;
}
public DbTableWriterStatus GetActualSalesStatus()
{
return _actualSalesStatus;
}
}
}
+2 -6
View File
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace AdvertsingProfitControl
{
@@ -17,5 +12,6 @@ namespace AdvertsingProfitControl
public static Color RowError = Color.Red;
public static Color HeaderRow = Color.LightGray;
public static Color MemberRow = Color.LightBlue;
public static Color AdSpecial = Color.Silver;
}
}
+31 -3
View File
@@ -128,6 +128,34 @@ namespace AdvertsingProfitControl
return dateString;
}
public List<DateTime> RetrieveDates(string connectionString)
{
var dates = new List<DateTime>();
var oleDbCommand = new OleDbCommand
{
CommandText = "SELECT EndOfWeekDate FROM WeekEnding"
};
var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection;
using (connection)
{
using (oleDbCommand)
{
connection.Open();
using (var reader = oleDbCommand.ExecuteReader())
{
while (reader != null && reader.Read())
{
dates.Add(DateTime.Parse(reader[0].ToString()));
}
}
}
}
return dates;
}
public List<string> RetrieveUniqueYearsList(string connectionString)
{
var datesList = new List<string>();
@@ -677,7 +705,7 @@ namespace AdvertsingProfitControl
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 Projections.ID, 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"
};
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
var connection = new OleDbConnection(connectionString);
@@ -702,7 +730,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 ActualSales.ID, 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"
};
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
var connection = new OleDbConnection(connectionString);
@@ -727,7 +755,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 Inventory.ID, 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"
};
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
var connection = new OleDbConnection(connectionString);
+56 -1
View File
@@ -15,7 +15,7 @@ namespace AdvertsingProfitControl
_oleDbConnection.ConnectionString = connectionString;
}
#region New Code
#region New Code
/// <summary>
/// Inserts new records into the specified sales table.
@@ -1134,6 +1134,61 @@ namespace AdvertsingProfitControl
return result;
}
public bool NormalizeApcTables(int dateId)
{
var successful = false;
var oleDbCommand = new OleDbCommand
{
CommandText = "SELECT COUNT(*) FROM Projections WHERE FK_DateID = ?",
Connection = _oleDbConnection
};
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
OleDbTransaction oleDbTransaction = null;
try
{
_oleDbConnection.Open();
oleDbTransaction = _oleDbConnection.BeginTransaction();
oleDbCommand.Transaction = oleDbTransaction;
var projectionsRowCount = 0;
var inventoryRowCount = 0;
var actualSalesRowCount = 0;
var reader = oleDbCommand.ExecuteReader();
while (reader != null && reader.Read())
{
projectionsRowCount = int.Parse(reader[0].ToString());
}
oleDbCommand.CommandText = "SELECT COUNT(*) FROM Inventory WHERE FK_DateID = ?";
reader = oleDbCommand.ExecuteReader();
while (reader != null && reader.Read())
{
inventoryRowCount = int.Parse(reader[0].ToString());
}
oleDbCommand.CommandText = "SELECT COUNT(*) FROM ActualSales WHERE FK_DateID = ?";
reader = oleDbCommand.ExecuteReader();
while (reader != null && reader.Read())
{
actualSalesRowCount = int.Parse(reader[0].ToString());
}
//
if (projectionsRowCount != inventoryRowCount)
{
}
}
catch (OleDbException e)
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error, e.Message);
oleDbTransaction?.Rollback();
}
finally
{
_oleDbConnection.Close();
}
return successful;
}
/// <summary>
/// Removes the invoice record with the specified internal ID number.
/// </summary>
+30
View File
@@ -83,6 +83,8 @@
this.weeklySalesDataGridView = new System.Windows.Forms.DataGridView();
this.taxableTabPage = new System.Windows.Forms.TabPage();
this.taxableDataGridView = new System.Windows.Forms.DataGridView();
this.debugTabPage = new System.Windows.Forms.TabPage();
this.monthCalendar = new System.Windows.Forms.MonthCalendar();
this.mainTableLayoutPanel.SuspendLayout();
this.mainMenu.SuspendLayout();
this.commentMainTableLayoutPanel.SuspendLayout();
@@ -105,6 +107,7 @@
((System.ComponentModel.ISupportInitialize)(this.weeklySalesDataGridView)).BeginInit();
this.taxableTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.taxableDataGridView)).BeginInit();
this.debugTabPage.SuspendLayout();
this.SuspendLayout();
//
// mainTableLayoutPanel
@@ -535,6 +538,7 @@
this.mainViewTabControl.Controls.Add(this.suppliersTabPage);
this.mainViewTabControl.Controls.Add(this.WeeklySalesTabPage);
this.mainViewTabControl.Controls.Add(this.taxableTabPage);
this.mainViewTabControl.Controls.Add(this.debugTabPage);
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);
@@ -733,6 +737,29 @@
this.taxableDataGridView.Size = new System.Drawing.Size(1710, 498);
this.taxableDataGridView.TabIndex = 0;
//
// debugTabPage
//
this.debugTabPage.Controls.Add(this.monthCalendar);
this.debugTabPage.Location = new System.Drawing.Point(4, 33);
this.debugTabPage.Name = "debugTabPage";
this.debugTabPage.Padding = new System.Windows.Forms.Padding(3);
this.debugTabPage.Size = new System.Drawing.Size(1716, 504);
this.debugTabPage.TabIndex = 6;
this.debugTabPage.Text = "Debug";
this.debugTabPage.UseVisualStyleBackColor = true;
//
// monthCalendar
//
this.monthCalendar.Location = new System.Drawing.Point(12, 12);
this.monthCalendar.MaxSelectionCount = 1;
this.monthCalendar.MonthlyBoldedDates = new System.DateTime[] {
new System.DateTime(2017, 1, 1, 0, 0, 0, 0)};
this.monthCalendar.Name = "monthCalendar";
this.monthCalendar.ShowTodayCircle = false;
this.monthCalendar.ShowWeekNumbers = true;
this.monthCalendar.TabIndex = 0;
this.monthCalendar.TabStop = false;
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F);
@@ -775,6 +802,7 @@
((System.ComponentModel.ISupportInitialize)(this.weeklySalesDataGridView)).EndInit();
this.taxableTabPage.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.taxableDataGridView)).EndInit();
this.debugTabPage.ResumeLayout(false);
this.ResumeLayout(false);
}
@@ -835,6 +863,8 @@
private System.Windows.Forms.LinkLabel shrinkLinkLabel;
private System.Windows.Forms.TabPage taxableTabPage;
private System.Windows.Forms.DataGridView taxableDataGridView;
private System.Windows.Forms.TabPage debugTabPage;
private System.Windows.Forms.MonthCalendar monthCalendar;
}
}
+9 -6
View File
@@ -374,7 +374,7 @@ namespace AdvertsingProfitControl
perfectGrossProfitLabel.Text = "Percent Gross Profit: ";
return;
}
if (weeklySalesDataGridView.RowCount == 0) return;
double totalSales = Convert.ToDouble(weeklySalesDataGridView.Rows[0].Cells[7].EditedFormattedValue.ToString());
grossProfitTotalSales.ForeColor = Color.Black;
grossProfitTotalSales.Text = "Total Sales: " + totalSales.ToString("C");
@@ -647,11 +647,14 @@ namespace AdvertsingProfitControl
private void modifyRecordMainMenu_Click(object sender, EventArgs e)
{
var modifyForm = new FrmModifyRecord();
modifyForm.ShowDialog();
BuildAndFillDataGridTables();
CalculateProfitAnalysis();
CalculateGrossProfit();
//var modifyForm = new FrmModifyRecord();
//modifyForm.ShowDialog();
//BuildAndFillDataGridTables();
//CalculateProfitAnalysis();
//CalculateGrossProfit();
var date = DateTime.Parse(monthComboBox.SelectedItem + @"/" + dayComboBox.SelectedItem + @"/" + yearComboBox.SelectedItem);
var form = new NewModifyRecord(date);
form.ShowDialog();
}
private void manageItemsToolsMainMenu_Click(object sender, EventArgs e)
+1 -12
View File
@@ -2109,7 +2109,6 @@ namespace AdvertsingProfitControl
{
errorLabel.Text = @"Failed to trim the Inventory table.";
//Delete the Projections table.
dbW.DeleteApcDataEntriesByDate("Projections", dateId, dbT.DatabaseConnectionString);
}
else
{
@@ -2123,25 +2122,15 @@ namespace AdvertsingProfitControl
if (operationStatus == TrimmingOperationResult.FailedToTrim)
{
errorLabel.Text = @"Failed to trim the Actual Sales table.";
//Delete the Projections table and the Inventory table.
dbW.DeleteApcDataEntriesByDate("Projections", dateId, dbT.DatabaseConnectionString);
dbW.DeleteApcDataEntriesByDate("Inventory", dateId, dbT.DatabaseConnectionString);
}
else
{
if (!ProcessTrimmingStatusResult(actualSalesDataGridView, "ActualSales", operationStatus, trimmedTable, updateTable))
{
//Delete the Projections and Inventory table.
dbW.DeleteApcDataEntriesByDate("Projections", dateId, dbT.DatabaseConnectionString);
dbW.DeleteApcDataEntriesByDate("Inventory", dateId, dbT.DatabaseConnectionString);
errorLabel.Text = @"Failed to add actual sales to the database.";
}
}
}
else
{
//Delete the Projections table.
dbW.DeleteApcDataEntriesByDate("Projections", dateId, dbT.DatabaseConnectionString);
}
}
}
//Commit the Invoice table to the database.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="mainMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
@@ -14,7 +14,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>VSIqTBM/2qcZ+QvdjsN5nrzGeyUkofXt8gkwA+ifCeM=</dsig:DigestValue>
<dsig:DigestValue>BL2VwteFPdU1C5eFgLcNJB6t71bYUCKbAJpayKyfE2c=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
@@ -43,14 +43,14 @@
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="3549696">
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="3592192">
<assemblyIdentity name="AdvertsingProfitControl" version="0.9.5.2" language="neutral" processorArchitecture="amd64" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>Twcy9tLeC7tLOMd3Kt+tpcRMhnW/2zLmImwOYH8DbJw=</dsig:DigestValue>
<dsig:DigestValue>E5XDgx2BUQtUy2BTSxYDHOSv9/kMPusOEpgSdyhYHzk=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
@@ -93,7 +93,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>vIWbpHhaPK+/SPRL5GUWOfjJsfzpB/rCMLUdLPlUB+s=</dsig:DigestValue>
<dsig:DigestValue>UQFU3HlwUiJQK2YXuAkDK9mSdSFJnVT3pbRsOpcjnAg=</dsig:DigestValue>
</hash>
</file>
<file name="Stretched Logo Collection.ico" size="370070">