Completely removed all the old database interaction code, save the database converter form. Updated the formatting in the weekly and taxable areas on the modify record form. Re-enabled holiday checking on the main form.
This commit is contained in:
Binary file not shown.
@@ -122,8 +122,6 @@
|
||||
<Compile Include="AdvertisingProfitControlTableHelper.cs" />
|
||||
<Compile Include="ApplicationColors.cs" />
|
||||
<Compile Include="CostAnalysi.cs" />
|
||||
<Compile Include="DbTableWriterStatus.cs" />
|
||||
<Compile Include="DbWriterStatus.cs" />
|
||||
<Compile Include="DebugDatabaseConverter.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -145,34 +143,19 @@
|
||||
<Compile Include="Taxable.cs" />
|
||||
<Compile Include="TextFormat.cs" />
|
||||
<Compile Include="BackPageGenerator.cs" />
|
||||
<Compile Include="DatabaseReader.cs" />
|
||||
<Compile Include="DatabaseTracker.cs" />
|
||||
<Compile Include="DatabaseVersionControl.cs" />
|
||||
<Compile Include="DatabaseWriter.cs" />
|
||||
<Compile Include="FrmAddRecord.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FrmAddRecord.Designer.cs">
|
||||
<DependentUpon>FrmAddRecord.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FrmAdSpecialRegister.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FrmAdSpecialRegister.Designer.cs">
|
||||
<DependentUpon>FrmAdSpecialRegister.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FrmMain.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<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="FrontPageGenerator.cs" />
|
||||
<Compile Include="GlobalClasses.cs" />
|
||||
<Compile Include="FrmLogConsole.cs">
|
||||
@@ -193,18 +176,12 @@
|
||||
<EmbeddedResource Include="FrmAddRecord.resx">
|
||||
<DependentUpon>FrmAddRecord.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="FrmAdSpecialRegister.resx">
|
||||
<DependentUpon>FrmAdSpecialRegister.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="FrmMain.resx">
|
||||
<DependentUpon>FrmMain.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="FrmLogConsole.resx">
|
||||
<DependentUpon>FrmLogConsole.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="FrmManageAdItems.resx">
|
||||
<DependentUpon>FrmManageAdItems.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="NewModifyRecord.resx">
|
||||
<DependentUpon>NewModifyRecord.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
@@ -38,11 +38,11 @@ namespace AdvertsingProfitControl
|
||||
|
||||
public void GenerateWeeklyInventoryControlPage(int dateId)
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var invoiceTable = databaseReader.ReturnInvoiceTable(dateId, databaseTracker.DatabaseConnectionString);
|
||||
var weeklySalesTable = databaseReader.ReturnWeeklySalesFromDateId(dateId,
|
||||
databaseTracker.DatabaseConnectionString);
|
||||
//var databaseTracker = new DatabaseTracker();
|
||||
//var databaseReader = new DatabaseReader();
|
||||
//var invoiceTable = databaseReader.ReturnInvoiceTable(dateId, databaseTracker.DatabaseConnectionString);
|
||||
//var weeklySalesTable = databaseReader.ReturnWeeklySalesFromDateId(dateId,
|
||||
// databaseTracker.DatabaseConnectionString);
|
||||
var stringWriter = new StringWriter();
|
||||
var writer = new HtmlTextWriter(stringWriter);
|
||||
writer.Write("<!DOCTYPE html>\n");
|
||||
@@ -74,7 +74,7 @@ namespace AdvertsingProfitControl
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "3");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:none"); //; width:240px
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("Week Ending <u>" + CleanDate(databaseReader.RetrieveDateStringById(dateId, databaseTracker.DatabaseConnectionString)) + "</u>");
|
||||
writer.Write("Week Ending <u>");// + CleanDate(databaseReader.RetrieveDateStringById(dateId, databaseTracker.DatabaseConnectionString)) + "</u>");
|
||||
writer.RenderEndTag();//td
|
||||
writer.RenderEndTag();//tr
|
||||
//Begin rendering the proper header row for the table itself.
|
||||
@@ -123,7 +123,7 @@ namespace AdvertsingProfitControl
|
||||
//Dollar amount for Sunday
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "text-align:right");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
var sundaySalesAmount = FormatNumberForDisplay(weeklySalesTable.Rows[0].ItemArray[0]).Split('.');
|
||||
var sundaySalesAmount = "Spam";//FormatNumberForDisplay(weeklySalesTable.Rows[0].ItemArray[0]).Split('.');
|
||||
writer.Write(sundaySalesAmount[0]);
|
||||
writer.RenderEndTag();//td
|
||||
//cents amount td
|
||||
@@ -134,25 +134,25 @@ namespace AdvertsingProfitControl
|
||||
writer.RenderEndTag();//tr
|
||||
//Loop 35 times to build all the rows.
|
||||
double totalCostsOfSales = 0; //holds the total value of all the invoices purchases.
|
||||
foreach (DataRow row in invoiceTable.Rows)
|
||||
{
|
||||
//Index four (4) contains the Net Amount of Invoices Extended Retail values.
|
||||
double parsedString = 0;
|
||||
if (double.TryParse(row.ItemArray[4].ToString(), out parsedString))
|
||||
{
|
||||
totalCostsOfSales += parsedString;
|
||||
}
|
||||
}
|
||||
//foreach (DataRow row in invoiceTable.Rows)
|
||||
//{
|
||||
// //Index four (4) contains the Net Amount of Invoices Extended Retail values.
|
||||
// double parsedString = 0;
|
||||
// if (double.TryParse(row.ItemArray[4].ToString(), out parsedString))
|
||||
// {
|
||||
// totalCostsOfSales += parsedString;
|
||||
// }
|
||||
//}
|
||||
|
||||
for (var i = 0; i < 34; i++)
|
||||
{
|
||||
var purchasesColumnsRendered = false;
|
||||
var salesColumnsRendered = false;
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
|
||||
if (i < invoiceTable.Rows.Count)
|
||||
{
|
||||
purchasesColumnsRendered = RenderPurchasesColumns(i, writer, invoiceTable);
|
||||
}
|
||||
//if (i < invoiceTable.Rows.Count)
|
||||
//{
|
||||
// purchasesColumnsRendered = RenderPurchasesColumns(i, writer, invoiceTable);
|
||||
//}
|
||||
if ((i + 1) < 8)
|
||||
{
|
||||
//padding
|
||||
@@ -172,7 +172,7 @@ namespace AdvertsingProfitControl
|
||||
purchasesColumnsRendered = true;
|
||||
}
|
||||
//Generates the SALES columns.
|
||||
salesColumnsRendered = RenderWeeklySalesColumns(i, writer, weeklySalesTable);
|
||||
//salesColumnsRendered = RenderWeeklySalesColumns(i, writer, weeklySalesTable);
|
||||
}
|
||||
if (i == 7)
|
||||
{
|
||||
@@ -267,27 +267,27 @@ namespace AdvertsingProfitControl
|
||||
writer.RenderEndTag();//td
|
||||
double totalSales = 0;
|
||||
|
||||
if (double.TryParse(weeklySalesTable.Rows[0].ItemArray[7].ToString(), out totalSales))
|
||||
{
|
||||
var dollarGrossProfit = totalSales - totalCostsOfSales;
|
||||
var dollarGrossProfitSplit = FormatNumberForDisplay(dollarGrossProfit).Split('.');
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "text-align:right");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write(dollarGrossProfitSplit[0]);
|
||||
writer.RenderEndTag(); //td
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write(dollarGrossProfitSplit[1]);
|
||||
writer.RenderEndTag(); //td
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.RenderEndTag();//td
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.RenderEndTag();//td
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.RenderEndTag();//td
|
||||
}
|
||||
//if (double.TryParse(weeklySalesTable.Rows[0].ItemArray[7].ToString(), out totalSales))
|
||||
//{
|
||||
// var dollarGrossProfit = totalSales - totalCostsOfSales;
|
||||
// var dollarGrossProfitSplit = FormatNumberForDisplay(dollarGrossProfit).Split('.');
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "text-align:right");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write(dollarGrossProfitSplit[0]);
|
||||
// writer.RenderEndTag(); //td
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write(dollarGrossProfitSplit[1]);
|
||||
// writer.RenderEndTag(); //td
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.RenderEndTag();//td
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.RenderEndTag();//td
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.RenderEndTag();//td
|
||||
//}
|
||||
}
|
||||
if (i == 21)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,22 +0,0 @@
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
class DatabaseTracker
|
||||
{
|
||||
//private string _DatabaseProvider = "Provider=Microsoft.ACE.OLEDB.12.0;";
|
||||
//private string _SecuritySettings = "Persist Security Info=False";
|
||||
|
||||
public DatabaseTracker()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string DatabaseConnectionString
|
||||
{
|
||||
get { return "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=APCDatabase.accdb;Persist Security Info=False"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,95 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
internal class DbTableWriterStatus
|
||||
{
|
||||
//Initialize the _status to failed just to have it not be null.
|
||||
private WritingOperationStatus _status = WritingOperationStatus.Failed;
|
||||
private readonly Dictionary<int, int> _rowIds;
|
||||
private string _errorMessage;
|
||||
|
||||
public DbTableWriterStatus()
|
||||
{
|
||||
_rowIds = new Dictionary<int, int>();
|
||||
}
|
||||
|
||||
public void SetStatus(WritingOperationStatus status)
|
||||
{
|
||||
_status = status;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the status from the operation.
|
||||
/// </summary>
|
||||
/// <returns>A status indicating whether or not it was successful, default is failed.</returns>
|
||||
public WritingOperationStatus GetWritingOperationStatus()
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a row to the Rows Dictionary that keeps track of what rows have been
|
||||
/// added to the database including their IDs.
|
||||
/// </summary>
|
||||
/// <param name="rowIndex">The index of the row that was added to the database.</param>
|
||||
/// <param name="rowIdNumber">The ID number of the row as represented in the database.</param>
|
||||
public void AddRowId(int rowIndex, int rowIdNumber)
|
||||
{
|
||||
_rowIds.Add(rowIndex, rowIdNumber);
|
||||
}
|
||||
/// <summary>
|
||||
/// Removes a row from the Rows collection.
|
||||
/// </summary>
|
||||
/// <param name="key">The row's index that is to be deleted.</param>
|
||||
public void DeleteRow(int key)
|
||||
{
|
||||
_rowIds.Remove(key);
|
||||
}
|
||||
/// <summary>
|
||||
/// Clears the collection of row IDs.
|
||||
/// </summary>
|
||||
public void ClearRowCollection()
|
||||
{
|
||||
_rowIds.Clear();
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the Dictionary containing rows that have been added to the database.
|
||||
/// The keys are the row's index and the value is the row's ID as represented
|
||||
/// in the database.
|
||||
/// Returns an empty Dictionary if no rows have been added.
|
||||
/// </summary>
|
||||
/// <returns>The rows that have been added to the database.</returns>
|
||||
public Dictionary<int, int> GetRowCollection()
|
||||
{
|
||||
return _rowIds;
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets an error message.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message to be set.</param>
|
||||
public void SetErrorMessage(string message)
|
||||
{
|
||||
_errorMessage = message;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets any error message set by the Insertion/Update operation function.
|
||||
/// If none are set returns an empty string.
|
||||
/// </summary>
|
||||
/// <returns>The error message, string.Empty if no message is set.</returns>
|
||||
public string GetErrorMessage()
|
||||
{
|
||||
//If the error message is null then return string.Empty.
|
||||
//Otherwise return the error message.
|
||||
return _errorMessage ?? string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Operation status emus to keep things consistent.
|
||||
/// </summary>
|
||||
public enum WritingOperationStatus
|
||||
{
|
||||
Failed = 0,
|
||||
InsertionSuccessful = 1,
|
||||
UpdateSuccessful = 2
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
internal class DbWriterStatus
|
||||
{
|
||||
public string ErrorMessage;
|
||||
public int Id;
|
||||
public WritingOperationStatus Status;
|
||||
}
|
||||
}
|
||||
@@ -122,10 +122,9 @@ namespace AdvertsingProfitControl
|
||||
var actualSales = ReturnActualSales(oldDateId);
|
||||
var invoices = ReturnInvoiceTable(oldDateId);
|
||||
var weeklySales = ReturnWeeklySalesFromDateId(oldDateId);
|
||||
var dbR = new DatabaseReader();
|
||||
var taxable = dbR.ReturnTaxableFromDateId(oldDateId, _connectionString);
|
||||
var taxable = ReturnTaxableFromDateId(oldDateId, _connectionString);
|
||||
var comment = GetComments(oldDateId);
|
||||
var costs = dbR.ReturnCostAnalysis(oldDateId, _connectionString);
|
||||
var costs = ReturnCostAnalysis(oldDateId, _connectionString);
|
||||
MassiveWriteFunction(date.ToString(), projectionsTable, inventoryTable, actualSales, invoices, weeklySales, taxable, costs, comment);
|
||||
}
|
||||
}
|
||||
@@ -710,5 +709,56 @@ namespace AdvertsingProfitControl
|
||||
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTable ReturnTaxableFromDateId(int dateId, string connectionString)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand
|
||||
{
|
||||
CommandText = "SELECT Taxable.ID, 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 ReturnCostAnalysis(int dateId, string connectionString)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand
|
||||
{
|
||||
CommandText = "SELECT CostOfSalesAnalysis.ID, CostOfSalesAnalysis.SalesPerManHour, CostOfSalesAnalysis.SalaryPercentage, CostOfSalesAnalysis.SalaryDollars, CostOfSalesAnalysis.Supplies FROM CostOfSalesAnalysis 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,189 +0,0 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
partial class FrmAdSpecialRegister
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmAdSpecialRegister));
|
||||
this.mainLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.currentAdSpecialKeyWords = new System.Windows.Forms.Label();
|
||||
this.adSpecialKeyWordsListBox = new System.Windows.Forms.ListBox();
|
||||
this.registerAdSpecialPanel = new System.Windows.Forms.Panel();
|
||||
this.notificationLabel = new System.Windows.Forms.Label();
|
||||
this.enterNewKeyWordTextBox = new System.Windows.Forms.TextBox();
|
||||
this.registerKeyWordButton = new System.Windows.Forms.Button();
|
||||
this.enterKeyWordHeaderLabel = new System.Windows.Forms.Label();
|
||||
this.DELETE = new System.Windows.Forms.Button();
|
||||
this.mainLayoutPanel.SuspendLayout();
|
||||
this.registerAdSpecialPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// mainLayoutPanel
|
||||
//
|
||||
this.mainLayoutPanel.ColumnCount = 2;
|
||||
this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.mainLayoutPanel.Controls.Add(this.currentAdSpecialKeyWords, 1, 0);
|
||||
this.mainLayoutPanel.Controls.Add(this.adSpecialKeyWordsListBox, 1, 1);
|
||||
this.mainLayoutPanel.Controls.Add(this.registerAdSpecialPanel, 0, 1);
|
||||
this.mainLayoutPanel.Controls.Add(this.enterKeyWordHeaderLabel, 0, 0);
|
||||
this.mainLayoutPanel.Controls.Add(this.DELETE, 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(4, 4, 4, 4);
|
||||
this.mainLayoutPanel.Name = "mainLayoutPanel";
|
||||
this.mainLayoutPanel.RowCount = 3;
|
||||
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 42F));
|
||||
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.mainLayoutPanel.Size = new System.Drawing.Size(915, 676);
|
||||
this.mainLayoutPanel.TabIndex = 0;
|
||||
//
|
||||
// currentAdSpecialKeyWords
|
||||
//
|
||||
this.currentAdSpecialKeyWords.AutoSize = true;
|
||||
this.currentAdSpecialKeyWords.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.currentAdSpecialKeyWords.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.currentAdSpecialKeyWords.Location = new System.Drawing.Point(461, 0);
|
||||
this.currentAdSpecialKeyWords.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.currentAdSpecialKeyWords.Name = "currentAdSpecialKeyWords";
|
||||
this.currentAdSpecialKeyWords.Size = new System.Drawing.Size(450, 42);
|
||||
this.currentAdSpecialKeyWords.TabIndex = 0;
|
||||
this.currentAdSpecialKeyWords.Text = "Registered Key Words:";
|
||||
//
|
||||
// adSpecialKeyWordsListBox
|
||||
//
|
||||
this.adSpecialKeyWordsListBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.adSpecialKeyWordsListBox.FormattingEnabled = true;
|
||||
this.adSpecialKeyWordsListBox.ItemHeight = 24;
|
||||
this.adSpecialKeyWordsListBox.Location = new System.Drawing.Point(461, 46);
|
||||
this.adSpecialKeyWordsListBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.adSpecialKeyWordsListBox.Name = "adSpecialKeyWordsListBox";
|
||||
this.mainLayoutPanel.SetRowSpan(this.adSpecialKeyWordsListBox, 2);
|
||||
this.adSpecialKeyWordsListBox.Size = new System.Drawing.Size(450, 626);
|
||||
this.adSpecialKeyWordsListBox.Sorted = true;
|
||||
this.adSpecialKeyWordsListBox.TabIndex = 1;
|
||||
//
|
||||
// registerAdSpecialPanel
|
||||
//
|
||||
this.registerAdSpecialPanel.Controls.Add(this.notificationLabel);
|
||||
this.registerAdSpecialPanel.Controls.Add(this.enterNewKeyWordTextBox);
|
||||
this.registerAdSpecialPanel.Controls.Add(this.registerKeyWordButton);
|
||||
this.registerAdSpecialPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.registerAdSpecialPanel.Location = new System.Drawing.Point(4, 46);
|
||||
this.registerAdSpecialPanel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.registerAdSpecialPanel.Name = "registerAdSpecialPanel";
|
||||
this.registerAdSpecialPanel.Size = new System.Drawing.Size(449, 309);
|
||||
this.registerAdSpecialPanel.TabIndex = 3;
|
||||
//
|
||||
// notificationLabel
|
||||
//
|
||||
this.notificationLabel.AutoSize = true;
|
||||
this.notificationLabel.Location = new System.Drawing.Point(11, 100);
|
||||
this.notificationLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.notificationLabel.Name = "notificationLabel";
|
||||
this.notificationLabel.Size = new System.Drawing.Size(0, 25);
|
||||
this.notificationLabel.TabIndex = 3;
|
||||
//
|
||||
// enterNewKeyWordTextBox
|
||||
//
|
||||
this.enterNewKeyWordTextBox.Location = new System.Drawing.Point(4, 17);
|
||||
this.enterNewKeyWordTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.enterNewKeyWordTextBox.Name = "enterNewKeyWordTextBox";
|
||||
this.enterNewKeyWordTextBox.Size = new System.Drawing.Size(313, 29);
|
||||
this.enterNewKeyWordTextBox.TabIndex = 0;
|
||||
//
|
||||
// registerKeyWordButton
|
||||
//
|
||||
this.registerKeyWordButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.registerKeyWordButton.Location = new System.Drawing.Point(207, 252);
|
||||
this.registerKeyWordButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.registerKeyWordButton.Name = "registerKeyWordButton";
|
||||
this.registerKeyWordButton.Size = new System.Drawing.Size(238, 53);
|
||||
this.registerKeyWordButton.TabIndex = 2;
|
||||
this.registerKeyWordButton.Text = "Add new Key Word";
|
||||
this.registerKeyWordButton.UseVisualStyleBackColor = true;
|
||||
this.registerKeyWordButton.Click += new System.EventHandler(this.registerKeyWordButton_Click);
|
||||
//
|
||||
// enterKeyWordHeaderLabel
|
||||
//
|
||||
this.enterKeyWordHeaderLabel.AutoSize = true;
|
||||
this.enterKeyWordHeaderLabel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.enterKeyWordHeaderLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.enterKeyWordHeaderLabel.Location = new System.Drawing.Point(4, 0);
|
||||
this.enterKeyWordHeaderLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.enterKeyWordHeaderLabel.Name = "enterKeyWordHeaderLabel";
|
||||
this.enterKeyWordHeaderLabel.Size = new System.Drawing.Size(449, 42);
|
||||
this.enterKeyWordHeaderLabel.TabIndex = 4;
|
||||
this.enterKeyWordHeaderLabel.Text = "Enter New Ad Special Key Word:";
|
||||
//
|
||||
// DELETE
|
||||
//
|
||||
this.DELETE.Enabled = false;
|
||||
this.DELETE.Location = new System.Drawing.Point(4, 363);
|
||||
this.DELETE.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.DELETE.Name = "DELETE";
|
||||
this.DELETE.Size = new System.Drawing.Size(200, 43);
|
||||
this.DELETE.TabIndex = 5;
|
||||
this.DELETE.Text = "Delete Ad Special";
|
||||
this.DELETE.UseVisualStyleBackColor = true;
|
||||
this.DELETE.Click += new System.EventHandler(this.DELETE_Click);
|
||||
//
|
||||
// FrmAdSpecialRegister
|
||||
//
|
||||
this.AcceptButton = this.registerKeyWordButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.ClientSize = new System.Drawing.Size(915, 676);
|
||||
this.Controls.Add(this.mainLayoutPanel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.Name = "FrmAdSpecialRegister";
|
||||
this.Text = "Register Ad Specials";
|
||||
this.Load += new System.EventHandler(this.frmAdSpecialRegister_Load);
|
||||
this.mainLayoutPanel.ResumeLayout(false);
|
||||
this.mainLayoutPanel.PerformLayout();
|
||||
this.registerAdSpecialPanel.ResumeLayout(false);
|
||||
this.registerAdSpecialPanel.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TableLayoutPanel mainLayoutPanel;
|
||||
private System.Windows.Forms.Label currentAdSpecialKeyWords;
|
||||
private System.Windows.Forms.ListBox adSpecialKeyWordsListBox;
|
||||
private System.Windows.Forms.Panel registerAdSpecialPanel;
|
||||
private System.Windows.Forms.TextBox enterNewKeyWordTextBox;
|
||||
private System.Windows.Forms.Button registerKeyWordButton;
|
||||
private System.Windows.Forms.Label enterKeyWordHeaderLabel;
|
||||
private System.Windows.Forms.Button DELETE;
|
||||
private System.Windows.Forms.Label notificationLabel;
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
public partial class FrmAdSpecialRegister : Form
|
||||
{
|
||||
public FrmAdSpecialRegister()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void frmAdSpecialRegister_Load(object sender, EventArgs e)
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var groupNameCollection = databaseReader.ReturnGroupNameList(databaseTracker.DatabaseConnectionString);
|
||||
|
||||
adSpecialKeyWordsListBox.SelectedIndexChanged += AdSpecialKeyWordsListBox_SelectedIndexChanged;
|
||||
|
||||
foreach (var groupName in groupNameCollection)
|
||||
{
|
||||
adSpecialKeyWordsListBox.Items.Add(groupName);
|
||||
}
|
||||
}
|
||||
|
||||
private void AdSpecialKeyWordsListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
var listBox = (ListBox) sender;
|
||||
if (listBox.SelectedIndex == -1)
|
||||
{
|
||||
DELETE.Enabled = false;
|
||||
return;
|
||||
}
|
||||
DELETE.Enabled = true;
|
||||
}
|
||||
|
||||
private void registerKeyWordButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var databaseWriter = new DatabaseWriter(databaseTracker.DatabaseConnectionString);
|
||||
int rowsEffected = 0;
|
||||
|
||||
if (enterNewKeyWordTextBox.Text == "") return;
|
||||
rowsEffected = databaseWriter.RedundantlessInsertIntoGroupCategory(enterNewKeyWordTextBox.Text);
|
||||
|
||||
if (rowsEffected == 1)
|
||||
{
|
||||
RowParsing.AdSpecialGroups.Add(enterNewKeyWordTextBox.Text);
|
||||
var groupNameCollection = databaseReader.ReturnGroupNameList(databaseTracker.DatabaseConnectionString);
|
||||
adSpecialKeyWordsListBox.Items.Clear();
|
||||
foreach (var groupName in groupNameCollection)
|
||||
{
|
||||
adSpecialKeyWordsListBox.Items.Add(groupName);
|
||||
}
|
||||
enterNewKeyWordTextBox.Text = "";
|
||||
enterNewKeyWordTextBox.Focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(
|
||||
"An error has occurred trying to write " + enterNewKeyWordTextBox.Text + " to the database.",
|
||||
"Unknown Write Error");
|
||||
}
|
||||
}
|
||||
|
||||
private void DELETE_Click(object sender, EventArgs e)
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var databaseWriter = new DatabaseWriter(databaseTracker.DatabaseConnectionString);
|
||||
var adSpecial = adSpecialKeyWordsListBox.SelectedItem.ToString();
|
||||
var rowsEffected = databaseWriter.RemoveAdSpecialMember(adSpecial);
|
||||
|
||||
if (rowsEffected == 0)
|
||||
{
|
||||
notificationLabel.Text = "Failed to delete " + adSpecial + " from the database.";
|
||||
}
|
||||
else if (rowsEffected > 0)
|
||||
{
|
||||
notificationLabel.Text = "Successfully deleted " + adSpecial + " from the database.";
|
||||
}
|
||||
adSpecialKeyWordsListBox.Items.Clear();
|
||||
var groupNameCollection = databaseReader.ReturnGroupNameList(databaseTracker.DatabaseConnectionString);
|
||||
foreach (var groupName in groupNameCollection)
|
||||
{
|
||||
adSpecialKeyWordsListBox.Items.Add(groupName);
|
||||
}
|
||||
DELETE.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
@@ -35,22 +33,19 @@ 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)
|
||||
{
|
||||
//Start by grabbing all the AdItems and putting them into memory.
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
_gAdItemCollection = databaseReader.GetAdItemsSuggestionList(databaseTracker.DatabaseConnectionString);
|
||||
//var databaseTracker = new DatabaseTracker();
|
||||
//var databaseReader = new DatabaseReader();
|
||||
//_gAdItemCollection = databaseReader.GetAdItemsSuggestionList(databaseTracker.DatabaseConnectionString);
|
||||
//
|
||||
weekEndingDateMaskedTextBox.Leave += OnWeekEndingDateMaskedTextBoxLeave;
|
||||
//Now pull all the suppliers into memory.
|
||||
_gSupplierCollection = databaseReader.GetSupplierSuggestionList(databaseTracker.DatabaseConnectionString);
|
||||
_AdSpecialList = databaseReader.RetrieveAdSpecialList(databaseTracker.DatabaseConnectionString);
|
||||
//_gSupplierCollection = databaseReader.GetSupplierSuggestionList(databaseTracker.DatabaseConnectionString);
|
||||
//_AdSpecialList = databaseReader.RetrieveAdSpecialList(databaseTracker.DatabaseConnectionString);
|
||||
//Event handlers for the Projections DataGridView
|
||||
projectionsDataGridView.CellValidating += OnCellValidating;
|
||||
//projectionsDataGridView.RowEnter += DetectAndDisplayIncompleteRows;
|
||||
@@ -1190,22 +1185,22 @@ namespace AdvertsingProfitControl
|
||||
return;
|
||||
}
|
||||
//Initialize the database reader and writer classes.
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var databaseWriter = new DatabaseWriter(databaseTracker.DatabaseConnectionString);
|
||||
//var databaseTracker = new DatabaseTracker();
|
||||
//var databaseReader = new DatabaseReader();
|
||||
//var databaseWriter = new DatabaseWriter(databaseTracker.DatabaseConnectionString);
|
||||
if (weekEndingDateMaskedTextBox.MaskCompleted)
|
||||
{
|
||||
if (databaseReader.RetrieveDateIdByDateString(weekEndingDateMaskedTextBox.Text, databaseTracker.DatabaseConnectionString) == 0)
|
||||
{
|
||||
//Assume the date is correct and add it to the database.
|
||||
//TODO: Check the date vs the last date entered (obtained by sorting dates) and check to see if the two are seven (7) or more days apart.
|
||||
if (!databaseWriter.InsertIntoWeekEnding(weekEndingDateMaskedTextBox.Text))
|
||||
{
|
||||
//IF the date failed to add for whatever reason, inform the user and break.
|
||||
MessageBox.Show("An error has occurred attempting to write the new date into the database.", "Insert Error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
//if (databaseReader.RetrieveDateIdByDateString(weekEndingDateMaskedTextBox.Text, databaseTracker.DatabaseConnectionString) == 0)
|
||||
//{
|
||||
// //Assume the date is correct and add it to the database.
|
||||
// //TODO: Check the date vs the last date entered (obtained by sorting dates) and check to see if the two are seven (7) or more days apart.
|
||||
// if (!databaseWriter.InsertIntoWeekEnding(weekEndingDateMaskedTextBox.Text))
|
||||
// {
|
||||
// //IF the date failed to add for whatever reason, inform the user and break.
|
||||
// MessageBox.Show("An error has occurred attempting to write the new date into the database.", "Insert Error");
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1213,34 +1208,34 @@ namespace AdvertsingProfitControl
|
||||
return;
|
||||
}
|
||||
//Most recent date ID, the hell was I thinking..
|
||||
var dateIdString = databaseReader.RetrieveDateIdByDateString(weekEndingDateMaskedTextBox.Text, databaseTracker.DatabaseConnectionString);
|
||||
var commentsText = commentsTextBox.Text;
|
||||
if (Regex.Replace(commentsText, @"\s+", "") != "")
|
||||
{
|
||||
databaseWriter.RedundantlessInsertIntoComments(commentsTextBox.Text, dateIdString.ToString());
|
||||
}
|
||||
//var dateIdString = databaseReader.RetrieveDateIdByDateString(weekEndingDateMaskedTextBox.Text, databaseTracker.DatabaseConnectionString);
|
||||
//var commentsText = commentsTextBox.Text;
|
||||
//if (Regex.Replace(commentsText, @"\s+", "") != "")
|
||||
//{
|
||||
// databaseWriter.RedundantlessInsertIntoComments(commentsTextBox.Text, dateIdString.ToString());
|
||||
//}
|
||||
|
||||
//Send the table's data to their respective functions.
|
||||
_gLogConsole.WriteToLog(FrmLogConsole.Level.Info, "Added the following rows to the APC table:");
|
||||
var rowsEffected = BuildAPCAndSendToDatabase(dateIdString.ToString());
|
||||
foreach (var i in rowsEffected)
|
||||
{
|
||||
_gLogConsole.WriteToLog(FrmLogConsole.Level.Info, (i + 1).ToString());
|
||||
}
|
||||
_gLogConsole.WriteToLog(FrmLogConsole.Level.Info, "Added the following rows to the Invoices table:");
|
||||
rowsEffected = BuildInvoiceTableAndSendToDatabase();
|
||||
foreach (int i in rowsEffected)
|
||||
{
|
||||
_gLogConsole.WriteToLog(FrmLogConsole.Level.Info, (i + 1).ToString());
|
||||
}
|
||||
if (InsertWeeklySalesIntoDatabase())
|
||||
{
|
||||
_gLogConsole.WriteToLog(FrmLogConsole.Level.Info, "Successfully added weekly sales to the database.");
|
||||
}
|
||||
else
|
||||
{
|
||||
_gLogConsole.WriteToLog(FrmLogConsole.Level.Info, "Failed to add weekly sales to the database.");
|
||||
}
|
||||
//var rowsEffected = BuildAPCAndSendToDatabase(dateIdString.ToString());
|
||||
//foreach (var i in rowsEffected)
|
||||
//{
|
||||
// _gLogConsole.WriteToLog(FrmLogConsole.Level.Info, (i + 1).ToString());
|
||||
//}
|
||||
//_gLogConsole.WriteToLog(FrmLogConsole.Level.Info, "Added the following rows to the Invoices table:");
|
||||
//rowsEffected = BuildInvoiceTableAndSendToDatabase();
|
||||
//foreach (int i in rowsEffected)
|
||||
//{
|
||||
// _gLogConsole.WriteToLog(FrmLogConsole.Level.Info, (i + 1).ToString());
|
||||
//}
|
||||
//if (InsertWeeklySalesIntoDatabase())
|
||||
//{
|
||||
// _gLogConsole.WriteToLog(FrmLogConsole.Level.Info, "Successfully added weekly sales to the database.");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// _gLogConsole.WriteToLog(FrmLogConsole.Level.Info, "Failed to add weekly sales to the database.");
|
||||
//}
|
||||
}
|
||||
|
||||
private void closeFileMainMenu_Click(object sender, EventArgs e)
|
||||
@@ -1248,253 +1243,6 @@ namespace AdvertsingProfitControl
|
||||
Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private List<int> BuildAPCAndSendToDatabase(string dateIdString)
|
||||
{
|
||||
var rowsAffected = new List<int>();
|
||||
//Initialize the database reader and writer classes.
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var databaseWriter = new DatabaseWriter(databaseTracker.DatabaseConnectionString);
|
||||
var parser = new RowParsing();
|
||||
//The layout of the table to be sent shall reflect the physical layout of the database's table
|
||||
//Rows 0-5 are projections, 6-9 are inventory, 10-15 are the actual sales and 16-21 are the row attributes, position, ad item (FK), group (FK) and then the date id (FK).
|
||||
var parameters = new object[21];
|
||||
var rowIndexNumber = 0;
|
||||
var groupId = "";
|
||||
//Negative one (-1) shows that the variable is not set.
|
||||
var lastHeaderRowNumber = -1;
|
||||
var rowPosition = 1;
|
||||
var table = new DataTable();
|
||||
//Build the table's columns.
|
||||
for (var i = 0; i <= 20; i++)
|
||||
{
|
||||
var column = new DataColumn { ColumnName = "Column" + i };
|
||||
table.Columns.Add(column);
|
||||
}
|
||||
|
||||
foreach (var row in projectionsDataGridView.Rows.Cast<DataGridViewRow>().TakeWhile(row => !row.IsNewRow))
|
||||
{
|
||||
//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)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//IF the current row is the ad special row, then fill the group ID, increment the row index and move on.
|
||||
if(rowIndexNumber == _gAdSpecialIndex)
|
||||
{
|
||||
//Get the group ID for the Ad Special Row.
|
||||
groupId =
|
||||
databaseReader.RetrieveGroupIdByString(
|
||||
parser.CheckForGroupKeyWord(row.Cells[0].EditedFormattedValue.ToString()),
|
||||
databaseTracker.DatabaseConnectionString);
|
||||
rowIndexNumber++;
|
||||
continue;
|
||||
}
|
||||
//Add the ad item into it's respective column.
|
||||
parameters[18] = row.Cells[0].EditedFormattedValue.ToString();
|
||||
//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 ((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)
|
||||
{
|
||||
//Set the current row's attribute to HeaderRow in the database.
|
||||
parameters[16] = "1";
|
||||
lastHeaderRowNumber = rowIndexNumber;
|
||||
}
|
||||
//IF the next row is not a member row, then do not apply any attribute to this row.
|
||||
else
|
||||
{
|
||||
//Clear the row number to prevent any mix ups down the line and the row attribute.
|
||||
lastHeaderRowNumber = -1;
|
||||
parameters[16] = "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (currentRowAttribute == RowAttribute.MemberRow && lastHeaderRowNumber != -1)
|
||||
{
|
||||
//ELSE IF this row is a member, then mark it as such.
|
||||
parameters[16] = "2";
|
||||
}
|
||||
//END row attribute check.
|
||||
//BEGIN checking to see if the current row is an ad special row.
|
||||
if (rowIndexNumber > _gAdSpecialIndex && _gAdSpecialIndex != -1)
|
||||
{
|
||||
//IF the ad item is already in the used ad item list, then skip it as it has already been added to the data table.
|
||||
if (_gUsedAdItems.Contains(parameters[18] + ":1"))
|
||||
{
|
||||
//IF this item has already been used, then search for its row that's in the data table and update it.
|
||||
var indexOfUsedItem = table.Rows.IndexOf(table.Select("column18 = '" + row.Cells[0].EditedFormattedValue + "'").First());
|
||||
_gLogConsole.WriteToLog(FrmLogConsole.Level.Debug,
|
||||
"Matched index at " + indexOfUsedItem + " with the item " +
|
||||
row.Cells[0].EditedFormattedValue + ".");
|
||||
if (indexOfUsedItem != -1)
|
||||
{
|
||||
table.Rows[indexOfUsedItem][19] = databaseReader.RetrieveGroupIdByString(groupId,
|
||||
databaseTracker.DatabaseConnectionString);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//ELSE if the ad item isn't used, then simply add the group id to the current row.
|
||||
parameters[19] = groupId;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Add a zero to ensure that null is not sent to the database.
|
||||
parameters[19] = "0";
|
||||
}
|
||||
//Now add the contents of the cells to the parameters.
|
||||
parameters[20] = dateIdString;
|
||||
var cellNumberTotal = 0;
|
||||
var currentCellIndex = 0;
|
||||
foreach (DataGridViewCell cell in projectionsDataGridView.Rows[rowIndexNumber].Cells)
|
||||
{
|
||||
if (currentCellIndex != 0)
|
||||
{
|
||||
var formattedValue = row.Cells[currentCellIndex].FormattedValue;
|
||||
if (formattedValue != null && formattedValue.ToString() == "")
|
||||
{
|
||||
parameters[cellNumberTotal] = "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
var value = row.Cells[currentCellIndex].FormattedValue;
|
||||
if (value != null)
|
||||
parameters[cellNumberTotal] = value.ToString();
|
||||
}
|
||||
cellNumberTotal++;
|
||||
}
|
||||
|
||||
currentCellIndex++;
|
||||
}
|
||||
currentCellIndex = 0;
|
||||
foreach (DataGridViewCell cell in actualSalesDataGridView.Rows[rowIndexNumber].Cells)
|
||||
{
|
||||
if (currentCellIndex != 0)
|
||||
{
|
||||
var formattedValue = actualSalesDataGridView.Rows[rowIndexNumber].Cells[currentCellIndex].FormattedValue;
|
||||
if (formattedValue != null && formattedValue.ToString() == "")
|
||||
{
|
||||
parameters[cellNumberTotal] = "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
var value = actualSalesDataGridView.Rows[rowIndexNumber].Cells[currentCellIndex].FormattedValue;
|
||||
if (value !=
|
||||
null)
|
||||
parameters[cellNumberTotal] = value.ToString();
|
||||
}
|
||||
cellNumberTotal++;
|
||||
}
|
||||
currentCellIndex++;
|
||||
}
|
||||
|
||||
//Finally add the row's position to the parameters. converting to a non zero indexed number.
|
||||
parameters[17] = rowPosition;
|
||||
table.Rows.Add(parameters);
|
||||
rowPosition++;
|
||||
rowIndexNumber++;
|
||||
}
|
||||
|
||||
rowsAffected = databaseWriter.RedundantlessInsertIntoApc(table);
|
||||
return rowsAffected;
|
||||
}
|
||||
|
||||
private List<int> BuildInvoiceTableAndSendToDatabase()
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseWriter = new DatabaseWriter(databaseTracker.DatabaseConnectionString);
|
||||
var databaseReader = new DatabaseReader();
|
||||
var supplierTable = new DataTable();
|
||||
//Build the new DataTable so that the scheme is the same.
|
||||
for (var i = 0; i <= 9; i++)
|
||||
{
|
||||
var column = new DataColumn {ColumnName = "Column" + i};
|
||||
supplierTable.Columns.Add(column);
|
||||
}
|
||||
|
||||
foreach (DataGridViewRow row in suppliersDataGridView.Rows)
|
||||
{
|
||||
var newRow = supplierTable.NewRow();
|
||||
newRow[0] = row.Cells[0].EditedFormattedValue.ToString();
|
||||
newRow[1] = row.Cells[1].EditedFormattedValue.ToString();
|
||||
newRow[2] = row.Cells[2].EditedFormattedValue.ToString();
|
||||
newRow[3] = row.Cells[3].EditedFormattedValue.ToString();
|
||||
newRow[4] = row.Cells[4].EditedFormattedValue.ToString();
|
||||
newRow[5] = row.Cells[5].EditedFormattedValue.ToString();
|
||||
newRow[6] = databaseReader.RetrieveDateIdByDateString(weekEndingDateMaskedTextBox.Text, databaseTracker.DatabaseConnectionString);
|
||||
|
||||
supplierTable.Rows.Add(newRow);
|
||||
}
|
||||
|
||||
var rowsAdded = databaseWriter.RedundantlessInsertIntoInvoice(supplierTable);
|
||||
|
||||
return rowsAdded;
|
||||
}
|
||||
|
||||
private bool InsertWeeklySalesIntoDatabase()
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var wasSuccessful = false;
|
||||
var rowsEffected = 0;
|
||||
var dateId = databaseReader.RetrieveDateIdByDateString(weekEndingDateMaskedTextBox.Text, databaseTracker.DatabaseConnectionString);
|
||||
var tracker = new DatabaseTracker();
|
||||
var writer = new DatabaseWriter(tracker.DatabaseConnectionString);
|
||||
var weeklySalesTable = new DataTable();
|
||||
weeklySalesTable.Columns.Add("Sunday", typeof(string));
|
||||
weeklySalesTable.Columns.Add("Monday", typeof(string));
|
||||
weeklySalesTable.Columns.Add("Tuesday", typeof(string));
|
||||
weeklySalesTable.Columns.Add("Wednesday", typeof(string));
|
||||
weeklySalesTable.Columns.Add("Thursday", typeof(string));
|
||||
weeklySalesTable.Columns.Add("Friday", typeof(string));
|
||||
weeklySalesTable.Columns.Add("Saturday", typeof(string));
|
||||
weeklySalesTable.Columns.Add("TotalSales", typeof(string));
|
||||
weeklySalesTable.Columns.Add("DateID", typeof(string));
|
||||
|
||||
var sunday = weeklySalesDataGridView.Rows[0].Cells[0].EditedFormattedValue.ToString();
|
||||
var monday = weeklySalesDataGridView.Rows[0].Cells[1].EditedFormattedValue.ToString();
|
||||
var tuesday = weeklySalesDataGridView.Rows[0].Cells[2].EditedFormattedValue.ToString();
|
||||
var wednesday = weeklySalesDataGridView.Rows[0].Cells[3].EditedFormattedValue.ToString();
|
||||
var thursday = weeklySalesDataGridView.Rows[0].Cells[4].EditedFormattedValue.ToString();
|
||||
var friday = weeklySalesDataGridView.Rows[0].Cells[5].EditedFormattedValue.ToString();
|
||||
var saturday = weeklySalesDataGridView.Rows[0].Cells[6].EditedFormattedValue.ToString();
|
||||
var totalSales = weeklySalesDataGridView.Rows[0].Cells[7].EditedFormattedValue.ToString();
|
||||
|
||||
weeklySalesTable.Rows.Add(sunday, monday, tuesday, wednesday, thursday, friday, saturday, totalSales, dateId);
|
||||
|
||||
rowsEffected = writer.RedundantlessInsertIntoWeeklySales(weeklySalesTable.Rows[0]);
|
||||
|
||||
if (rowsEffected == 1)
|
||||
{
|
||||
wasSuccessful = true;
|
||||
}
|
||||
return wasSuccessful;
|
||||
}
|
||||
|
||||
private List<int> InsertSalesAndInventoryIntoDatabase()
|
||||
{
|
||||
var rowsAdded = new List<int>();
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var databaseWriter = new DatabaseWriter(databaseTracker.DatabaseConnectionString);
|
||||
|
||||
|
||||
return rowsAdded;
|
||||
}
|
||||
|
||||
private void clearFormFileMainMenu_Click(object sender, EventArgs e)
|
||||
{
|
||||
projectionsDataGridView.Rows.Clear();
|
||||
|
||||
+37
-17
@@ -43,8 +43,10 @@
|
||||
this.helpMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.showHideConsoleHelpMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.dbVersionHelpMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.debugToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.debugToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.debugMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.rawViewDebugMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.migrateDatabaseDebugMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.addRecordToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mainTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.commentMainTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.profitAnalysisMainGroupBox = new System.Windows.Forms.GroupBox();
|
||||
@@ -146,7 +148,7 @@
|
||||
this.recordsToolStripMenuItem,
|
||||
this.toolsMainMenu,
|
||||
this.helpMainMenu,
|
||||
this.debugToolStripMenuItem});
|
||||
this.debugMainMenu});
|
||||
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);
|
||||
@@ -246,21 +248,37 @@
|
||||
this.dbVersionHelpMainMenu.Text = "Get &Database Version";
|
||||
this.dbVersionHelpMainMenu.Click += new System.EventHandler(this.dbVersionHelpMainMenu_Click);
|
||||
//
|
||||
// debugToolStripMenuItem
|
||||
// debugMainMenu
|
||||
//
|
||||
this.debugToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.debugToolStripMenuItem1});
|
||||
this.debugToolStripMenuItem.Name = "debugToolStripMenuItem";
|
||||
this.debugToolStripMenuItem.Size = new System.Drawing.Size(87, 34);
|
||||
this.debugToolStripMenuItem.Text = "Debug";
|
||||
this.debugToolStripMenuItem.Visible = false;
|
||||
this.debugMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.rawViewDebugMainMenu,
|
||||
this.migrateDatabaseDebugMainMenu,
|
||||
this.addRecordToolStripMenuItem});
|
||||
this.debugMainMenu.Name = "debugMainMenu";
|
||||
this.debugMainMenu.Size = new System.Drawing.Size(87, 34);
|
||||
this.debugMainMenu.Text = "Debug";
|
||||
this.debugMainMenu.Visible = false;
|
||||
//
|
||||
// debugToolStripMenuItem1
|
||||
// rawViewDebugMainMenu
|
||||
//
|
||||
this.debugToolStripMenuItem1.Name = "debugToolStripMenuItem1";
|
||||
this.debugToolStripMenuItem1.Size = new System.Drawing.Size(167, 34);
|
||||
this.debugToolStripMenuItem1.Text = "Debug";
|
||||
this.debugToolStripMenuItem1.Click += new System.EventHandler(this.debugToolStripMenuItem1_Click);
|
||||
this.rawViewDebugMainMenu.Name = "rawViewDebugMainMenu";
|
||||
this.rawViewDebugMainMenu.Size = new System.Drawing.Size(270, 34);
|
||||
this.rawViewDebugMainMenu.Text = "Raw View";
|
||||
this.rawViewDebugMainMenu.Click += new System.EventHandler(this.rawViewDebugMainMenu_Click);
|
||||
//
|
||||
// migrateDatabaseDebugMainMenu
|
||||
//
|
||||
this.migrateDatabaseDebugMainMenu.Name = "migrateDatabaseDebugMainMenu";
|
||||
this.migrateDatabaseDebugMainMenu.Size = new System.Drawing.Size(270, 34);
|
||||
this.migrateDatabaseDebugMainMenu.Text = "Migrate Database";
|
||||
this.migrateDatabaseDebugMainMenu.Click += new System.EventHandler(this.debugToolStripMenuItem1_Click);
|
||||
//
|
||||
// addRecordToolStripMenuItem
|
||||
//
|
||||
this.addRecordToolStripMenuItem.Name = "addRecordToolStripMenuItem";
|
||||
this.addRecordToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
|
||||
this.addRecordToolStripMenuItem.Text = "Add Record";
|
||||
this.addRecordToolStripMenuItem.Click += new System.EventHandler(this.addRecordToolStripMenuItem_Click_1);
|
||||
//
|
||||
// mainTableLayoutPanel
|
||||
//
|
||||
@@ -1044,9 +1062,11 @@
|
||||
private System.Windows.Forms.DataGridView actualSalesDataGridView;
|
||||
private System.Windows.Forms.TabPage suppliersTabPage;
|
||||
private System.Windows.Forms.DataGridView invoicesDataGridView;
|
||||
private System.Windows.Forms.ToolStripMenuItem debugToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem debugToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem debugMainMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem migrateDatabaseDebugMainMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem clearSelectedDateToolsMainMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem addRecordToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem rawViewDebugMainMenu;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Entity;
|
||||
using System.Diagnostics;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Printing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Transactions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
@@ -20,7 +18,7 @@ namespace AdvertsingProfitControl
|
||||
private decimal _departmentSales; //weekly sales total
|
||||
private DateTime _currentActiveDate;
|
||||
private readonly FrmLogConsole _console = FrmLogConsole.GetStaticInstance;
|
||||
private int _LazyPageCounter;
|
||||
private int _lazyPageCounter;
|
||||
private bool isDebug;
|
||||
|
||||
public FrmMain(bool isDebug)
|
||||
@@ -28,9 +26,8 @@ namespace AdvertsingProfitControl
|
||||
InitializeComponent();
|
||||
this.isDebug = isDebug;
|
||||
isDebug = true;
|
||||
debugToolStripMenuItem.Visible = isDebug;
|
||||
debugMainMenu.Visible = isDebug;
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
db.Versions.Count();
|
||||
}
|
||||
|
||||
private void frmMain_Load(object sender, EventArgs e)
|
||||
@@ -137,15 +134,15 @@ namespace AdvertsingProfitControl
|
||||
|
||||
private void addRecordToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var form = new NewModifyRecord();
|
||||
form.ShowDialog();
|
||||
//One the user has closed the add record form, check to see if there is a newer date
|
||||
//available. If so, reload the form.
|
||||
var date = databaseReader.RetrieveMostRecentDate(databaseTracker.DatabaseConnectionString);
|
||||
if (date == _currentActiveDate) return;
|
||||
LoadDate(date);
|
||||
var date = db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault();
|
||||
if (date == null) return;
|
||||
if (date.EndingDate == _currentActiveDate) return;
|
||||
LoadDate(date.EndingDate);
|
||||
}
|
||||
|
||||
private void showHideConsoleHelpMainMenu_Click(object sender, EventArgs e)
|
||||
@@ -165,31 +162,34 @@ namespace AdvertsingProfitControl
|
||||
var form = new NewModifyRecord(_currentActiveDate);
|
||||
form.ShowDialog();
|
||||
//On return reload the date that was just modified by the modify record form.
|
||||
LoadDate(monthCalendar.SelectionStart);
|
||||
LoadDate(_currentActiveDate);
|
||||
}
|
||||
|
||||
private void manageItemsToolsMainMenu_Click(object sender, EventArgs e)
|
||||
{
|
||||
var adItemManager = new FrmManageAdItems();
|
||||
adItemManager.ShowDialog();
|
||||
//TODO: Bring back Manage Ad Items form and managing AdSpecials.
|
||||
//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")
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var version = db.Versions.FirstOrDefault(x => x.Id == 1);
|
||||
if (version == null)
|
||||
{
|
||||
MessageBox.Show(@"The current database's version is " + version + @".", @"Database Version Number", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
MessageBox.Show(@"Failed to retrieve the version number of the SQL database", @"Database Version Number",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
MessageBox.Show(@"The current database's version is " + version + @".", @"Database Version Number", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
}
|
||||
|
||||
private void PrintPage(object sender, PrintPageEventArgs e)
|
||||
{
|
||||
Bitmap bitMap;
|
||||
if (_LazyPageCounter == 0)
|
||||
if (_lazyPageCounter == 0)
|
||||
{
|
||||
bitMap = new Bitmap(Application.StartupPath + "\\FrontPage.png");
|
||||
}
|
||||
@@ -210,16 +210,16 @@ namespace AdvertsingProfitControl
|
||||
rect.Width = (int) ((double) bitMap.Width/(double) bitMap.Height*(double) rect.Height);
|
||||
}
|
||||
|
||||
if (_LazyPageCounter == 0)
|
||||
if (_lazyPageCounter == 0)
|
||||
{
|
||||
e.Graphics.DrawImage(bitMap, new Rectangle(0, 25, 850, 1050));
|
||||
_LazyPageCounter++;
|
||||
_lazyPageCounter++;
|
||||
e.HasMorePages = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Graphics.DrawImage(bitMap, new Rectangle(0, 0, 850, 1100));
|
||||
_LazyPageCounter = 0;
|
||||
_lazyPageCounter = 0;
|
||||
e.HasMorePages = false;
|
||||
}
|
||||
}
|
||||
@@ -233,20 +233,20 @@ namespace AdvertsingProfitControl
|
||||
var printDialog = new PrintPreviewDialog();
|
||||
if (!usePreRenderedFilesCheckbox.Checked)
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var dateId =
|
||||
databaseReader.RetrieveDateIdByDateString(monthCalendar.SelectionStart.ToShortDateString(),
|
||||
databaseTracker.DatabaseConnectionString);
|
||||
var remaingingSales = _departmentSales - _salesProducedByAdItems;
|
||||
var totalProfitReturnFromReminaingSales = remaingingSales * .3m;
|
||||
var totalProfitReturn = _totalProfitReturnFromAdItems + totalProfitReturnFromReminaingSales;
|
||||
//test.BuildFormFrontCompressedLayout(dateId, _departmentSales, _salesProducedByAdItems, remaingingSales,
|
||||
//_totalProfitReturnFromAdItems, totalProfitReturnFromReminaingSales, totalProfitReturn,
|
||||
//commentsTextBox.Text);
|
||||
test.RenderHtmlToImage();
|
||||
backPageTest.GenerateWeeklyInventoryControlPage(dateId);
|
||||
backPageTest.RenderHtmlToImage();
|
||||
//var databaseTracker = new DatabaseTracker();
|
||||
//var databaseReader = new DatabaseReader();
|
||||
//var dateId =
|
||||
// databaseReader.RetrieveDateIdByDateString(monthCalendar.SelectionStart.ToShortDateString(),
|
||||
// databaseTracker.DatabaseConnectionString);
|
||||
//var remaingingSales = _departmentSales - _salesProducedByAdItems;
|
||||
//var totalProfitReturnFromReminaingSales = remaingingSales * .3m;
|
||||
//var totalProfitReturn = _totalProfitReturnFromAdItems + totalProfitReturnFromReminaingSales;
|
||||
////test.BuildFormFrontCompressedLayout(dateId, _departmentSales, _salesProducedByAdItems, remaingingSales,
|
||||
// //_totalProfitReturnFromAdItems, totalProfitReturnFromReminaingSales, totalProfitReturn,
|
||||
// //commentsTextBox.Text);
|
||||
//test.RenderHtmlToImage();
|
||||
//backPageTest.GenerateWeeklyInventoryControlPage(dateId);
|
||||
//backPageTest.RenderHtmlToImage();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -361,7 +361,12 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
modifyRecordMainMenu.Enabled = true;
|
||||
modifyRecordMainMenu.ToolTipText = @"";
|
||||
var dateRecord = db.WeekEndingDates.Single(x => x.EndingDate == date);
|
||||
var dateRecord = db.WeekEndingDates.SingleOrDefault(x => x.EndingDate == date);
|
||||
if (dateRecord == null)
|
||||
{
|
||||
dateTimeGroupBox.Text = @"Failed to retrieve " + date.ToString("d") + @".";
|
||||
return;
|
||||
}
|
||||
ClearForm();
|
||||
LoadProjectionsTable(dateRecord);
|
||||
LoadInventoryTable(dateRecord);
|
||||
@@ -575,45 +580,88 @@ namespace AdvertsingProfitControl
|
||||
var weeklySales = db.WeeklySales.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
||||
foreach (var sale in weeklySales)
|
||||
{
|
||||
if (sale.Sunday != null) _departmentSales += (decimal) sale.Sunday;
|
||||
sundayWeeklySalesLabel.Text = @"Sunday: " + $@"{sale.Sunday:c}";
|
||||
if (sale.Monday != null) _departmentSales += (decimal) sale.Monday;
|
||||
mondayWeeklySalesLabel.Text = @"Monday: " + $@"{sale.Monday:c}";
|
||||
if (sale.Tuesday != null) _departmentSales += (decimal) sale.Tuesday;
|
||||
tuesadayWeeklySalesLabel.Text = @"Tuesday: " + $@"{sale.Tuesday:c}";
|
||||
if (sale.Wednesday != null) _departmentSales += (decimal) sale.Wednesday;
|
||||
wednesdayWeeklySalesLabel.Text = @"Wednesday: " + $@"{sale.Wednesday:c}";
|
||||
if (sale.Thursday != null) _departmentSales += (decimal)sale.Thursday;
|
||||
thursdayWeeklySalesLabel.Text = @"Thursday: " + $@"{sale.Thursday:c}";
|
||||
if (sale.Friday != null) _departmentSales += (decimal) sale.Friday;
|
||||
fridayWeeklySalesLabel.Text = @"Friday: " + $@"{sale.Friday:c}";
|
||||
if (sale.Saturday != null) _departmentSales += (decimal) sale.Saturday;
|
||||
saturdayWeeklySalesLabel.Text = @"Saturday: " + $@"{sale.Saturday:c}";
|
||||
if (sale.Sunday != null)
|
||||
{
|
||||
sundayWeeklySalesLabel.Text = sale.Sunday != 0
|
||||
? @"Sunday: " + $@"{sale.Sunday:c}"
|
||||
: @"Sunday: " + CheckForHoliday(DayOfWeek.Sunday);
|
||||
_departmentSales += (decimal) sale.Sunday;
|
||||
}
|
||||
if (sale.Monday != null)
|
||||
{
|
||||
mondayWeeklySalesLabel.Text = sale.Monday != 0
|
||||
? @"Monday: " + $@"{sale.Monday:c}"
|
||||
: @"Monday: " + CheckForHoliday(DayOfWeek.Monday);
|
||||
_departmentSales += (decimal) sale.Monday;
|
||||
}
|
||||
if (sale.Tuesday != null)
|
||||
{
|
||||
tuesadayWeeklySalesLabel.Text = sale.Tuesday != 0
|
||||
? @"Tuesday: " + $@"{sale.Tuesday:c}"
|
||||
: @"Tuesday: " + CheckForHoliday(DayOfWeek.Tuesday);
|
||||
_departmentSales += (decimal) sale.Tuesday;
|
||||
}
|
||||
if (sale.Wednesday != null)
|
||||
{
|
||||
wednesdayWeeklySalesLabel.Text = sale.Wednesday != 0
|
||||
? @"Wednesday: " + $@"{sale.Wednesday:c}"
|
||||
: @"Wednesday: " + CheckForHoliday(DayOfWeek.Wednesday);
|
||||
_departmentSales += (decimal) sale.Wednesday;
|
||||
}
|
||||
if (sale.Thursday != null)
|
||||
{
|
||||
thursdayWeeklySalesLabel.Text = sale.Thursday != 0
|
||||
? @"Thursday: " + $@"{sale.Thursday:c}"
|
||||
: @"Thursday: " + CheckForHoliday(DayOfWeek.Thursday);
|
||||
_departmentSales += (decimal)sale.Thursday;
|
||||
}
|
||||
if (sale.Friday != null)
|
||||
{
|
||||
fridayWeeklySalesLabel.Text = sale.Friday != 0
|
||||
? @"Friday: " + $@"{sale.Friday:c}"
|
||||
: @"Friday: " + CheckForHoliday(DayOfWeek.Friday);
|
||||
_departmentSales += (decimal) sale.Friday;
|
||||
}
|
||||
if (sale.Saturday != null)
|
||||
{
|
||||
saturdayWeeklySalesLabel.Text = sale.Saturday != 0
|
||||
? @"Saturday: " + $@"{sale.Saturday:c}"
|
||||
: @"Saturday: " + CheckForHoliday(DayOfWeek.Saturday);
|
||||
_departmentSales += (decimal) sale.Saturday;
|
||||
}
|
||||
totalWeeklySalesLabel.Text = @"Total Sales: " + $@"{sale.TotalSales:c}";
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadTaxable(WeekEndingDate dateRecord)
|
||||
{
|
||||
//TODO: Check for holidays
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var taxables = db.Taxables.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
||||
foreach (var taxable in taxables)
|
||||
{
|
||||
sundayTaxableLabel.Text = @"Sunday: " + $@"{taxable.Sunday:c}";
|
||||
mondayTaxableLabel.Text = @"Monday: " + $@"{taxable.Monday:c}";
|
||||
tuesdayTaxableLabel.Text = @"Tuesday: " + $@"{taxable.Tuesday:c}";
|
||||
wednesdayTaxableLabel.Text = @"Wednesday: " + $@"{taxable.Wednesday:c}";
|
||||
thursdayTaxableLabel.Text = @"Thursday: " + $@"{taxable.Thursday:c}";
|
||||
fridayTaxableLabel.Text = @"Friday: " + $@"{taxable.Friday:c}";
|
||||
saturdayTaxableLabel.Text = @"Saturday: " + $@"{taxable.Saturday:c}";
|
||||
sundayTaxableLabel.Text = taxable.Sunday != 0
|
||||
? @"Sunday: " + $@"{taxable.Sunday:c}"
|
||||
: @"Sunday: " + CheckForHoliday(DayOfWeek.Sunday);
|
||||
mondayTaxableLabel.Text = taxable.Monday != 0
|
||||
? @"Monday: " + $@"{taxable.Monday:c}"
|
||||
: @"Monday: " + CheckForHoliday(DayOfWeek.Monday);
|
||||
tuesdayTaxableLabel.Text = taxable.Tuesday != 0
|
||||
? @"Tuesday: " + $@"{taxable.Tuesday:c}"
|
||||
: @"Tuesday: " + CheckForHoliday(DayOfWeek.Tuesday);
|
||||
wednesdayTaxableLabel.Text = taxable.Wednesday != 0
|
||||
? @"Wednesday: " + $@"{taxable.Wednesday:c}"
|
||||
: @"Wednesday: " + CheckForHoliday(DayOfWeek.Wednesday);
|
||||
thursdayTaxableLabel.Text = taxable.Thursday != 0
|
||||
? @"Thursday: " + $@"{taxable.Thursday:c}"
|
||||
: @"Thursday: " + CheckForHoliday(DayOfWeek.Thursday);
|
||||
fridayTaxableLabel.Text = taxable.Friday != 0
|
||||
? @"Friday: " + $@"{taxable.Friday:c}"
|
||||
: @"Friday: " + CheckForHoliday(DayOfWeek.Friday);
|
||||
saturdayTaxableLabel.Text = taxable.Saturday != 0
|
||||
? @"Saturday: " + $@"{taxable.Saturday:c}"
|
||||
: @"Saturday: " + CheckForHoliday(DayOfWeek.Saturday);
|
||||
totalTaxableLabel.Text = @"Total: " + $@"{taxable.Total:c}";
|
||||
}
|
||||
////See if there are any items and see if any of them are holidays (have a value of zero).
|
||||
//if (taxables.ToList().Count == 1)
|
||||
//{
|
||||
// var Spam = taxables.Select(x => x.)
|
||||
//}
|
||||
}
|
||||
|
||||
private void LoadCostAnalysis(WeekEndingDate dateRecord)
|
||||
@@ -665,8 +713,8 @@ namespace AdvertsingProfitControl
|
||||
switch (holiday)
|
||||
{
|
||||
case Holidays.Thanksgiving:
|
||||
case Holidays.Christmas:
|
||||
case Holidays.NewYearsDay:
|
||||
case Holidays.Christmas:
|
||||
case Holidays.NewYearsDay:
|
||||
holidayText = @"Closed for " + TextFormat.AddSpacesToSentence(holiday.ToString(), false);
|
||||
break;
|
||||
}
|
||||
@@ -735,15 +783,8 @@ namespace AdvertsingProfitControl
|
||||
|
||||
private void RefreshDateListing()
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
monthCalendar.BoldedDates = databaseReader.RetrieveDates(databaseTracker.DatabaseConnectionString).ToArray();
|
||||
}
|
||||
|
||||
public enum FormDefaultRoll
|
||||
{
|
||||
AddNewRecord = 0,
|
||||
ModifyExistingRecord = 1
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
monthCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray();
|
||||
}
|
||||
|
||||
private void clearSelectedDateToolsMainMenu_Click(object sender, EventArgs e)
|
||||
@@ -753,27 +794,82 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
return;
|
||||
}
|
||||
var dbT = new DatabaseTracker();
|
||||
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
|
||||
var dbR = new DatabaseReader();
|
||||
var dateId = dbR.RetrieveDateIdByDateString(_currentActiveDate.ToShortDateString(), dbT.DatabaseConnectionString);
|
||||
if (dateId != 0)
|
||||
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var dateRecord = db.WeekEndingDates.Single(x => x.EndingDate == _currentActiveDate);
|
||||
var projections = db.Projections.Where(x => x.WeekEndingDate.EndingDate == dateRecord.EndingDate);
|
||||
var inventories = db.Inventories.Where(x => x.WeekEndingDate.EndingDate == dateRecord.EndingDate);
|
||||
var actualSales = db.ActualSales.Where(x => x.WeekEndingDate.EndingDate == dateRecord.EndingDate);
|
||||
var invoices = db.Invoices.Where(x => x.WeekEndingDate.EndingDate == dateRecord.EndingDate);
|
||||
var weeklySale = db.WeeklySales.SingleOrDefault(x => x.WeekEndingDate.EndingDate == dateRecord.EndingDate);
|
||||
var taxable = db.Taxables.SingleOrDefault(x => x.WeekEndingDate.EndingDate == dateRecord.EndingDate);
|
||||
var costAnalysis = db.CostAnalysis.SingleOrDefault(x => x.WeekEndingDate.EndingDate == dateRecord.EndingDate);
|
||||
var comment = db.Notes.SingleOrDefault(x => x.WeekEndingDate.EndingDate == dateRecord.EndingDate);
|
||||
|
||||
using (var scope = new TransactionScope())
|
||||
{
|
||||
if (dbW.ClearDateById(dateId))
|
||||
try
|
||||
{
|
||||
RefreshDateListing();
|
||||
var date = dbR.RetrieveMostRecentDate(dbT.DatabaseConnectionString);
|
||||
LoadDate(date);
|
||||
//Clear projections
|
||||
foreach (var projection in projections)
|
||||
{
|
||||
db.Projections.Remove(projection);
|
||||
}
|
||||
//Clear inventory
|
||||
foreach (var inventory in inventories)
|
||||
{
|
||||
db.Inventories.Remove(inventory);
|
||||
}
|
||||
//Clear actual sales
|
||||
foreach (var sale in actualSales)
|
||||
{
|
||||
db.ActualSales.Remove(sale);
|
||||
}
|
||||
//Clear invoices
|
||||
foreach (var invoice in invoices)
|
||||
{
|
||||
db.Invoices.Remove(invoice);
|
||||
}
|
||||
if (weeklySale != null)
|
||||
{
|
||||
db.WeeklySales.Remove(weeklySale);
|
||||
}
|
||||
if (taxable != null)
|
||||
{
|
||||
db.Taxables.Remove(taxable);
|
||||
}
|
||||
if (costAnalysis != null)
|
||||
{
|
||||
db.CostAnalysis.Remove(costAnalysis);
|
||||
}
|
||||
if (comment != null)
|
||||
{
|
||||
db.Notes.Remove(comment);
|
||||
}
|
||||
db.WeekEndingDates.Remove(dateRecord);
|
||||
db.SaveChanges();
|
||||
scope.Complete();
|
||||
}
|
||||
else
|
||||
catch (DbUpdateException ex)
|
||||
{
|
||||
errorLabel.Text = @"Failed to clear the selected date.";
|
||||
MessageBox.Show(@"Failed to clear selected date.", @"Error");
|
||||
_console.WriteToLog(FrmLogConsole.Level.Error, ex.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
errorLabel.Text = @"Failed to get the date ID number.";
|
||||
}
|
||||
|
||||
RefreshDateListing();
|
||||
LoadDate(db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault().EndingDate);
|
||||
}
|
||||
|
||||
private void addRecordToolStripMenuItem_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
var form = new FrmAddRecord();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void rawViewDebugMainMenu_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
public partial class FrmManageAdItems : Form
|
||||
{
|
||||
public FrmManageAdItems()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void frmManageAdItems_Load(object sender, EventArgs e)
|
||||
{
|
||||
FillAdItemComboBoxFilter();
|
||||
adItemFilterComboBox.SelectedIndexChanged += UpdateFiltering;
|
||||
adItemListView.SelectedIndexChanged += OnListItemSelectionChanged;
|
||||
adItemTextBox.TextChanged += NewAdItemTextChanged;
|
||||
}
|
||||
|
||||
private void NewAdItemTextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(adItemTextBox.TextLength == 0)
|
||||
{
|
||||
addItemButton.Enabled = false;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
addItemButton.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnListItemSelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(adItemListView.SelectedItems.Count > 0)
|
||||
{
|
||||
deleteSelectedItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
deleteSelectedItem.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateFiltering(object sender, EventArgs e)
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var itemList = new List<string>();
|
||||
adItemListView.Items.Clear();
|
||||
if(adItemFilterComboBox.Text == "All Items")
|
||||
{
|
||||
itemList = databaseReader.RetrieveAdItemListByLetter(databaseTracker.DatabaseConnectionString);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemList = databaseReader.RetrieveAdItemListByLetter(databaseTracker.DatabaseConnectionString, adItemFilterComboBox.Text);
|
||||
}
|
||||
foreach (var item in itemList)
|
||||
{
|
||||
var listViewItem = new ListViewItem(item);
|
||||
adItemListView.Items.Add(listViewItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteSelectedItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(adItemListView.SelectedItems.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseWriter = new DatabaseWriter(databaseTracker.DatabaseConnectionString);
|
||||
|
||||
if (databaseWriter.RemoveAdItem(adItemListView.SelectedItems[0].Text))
|
||||
{
|
||||
notificationLabel.Text = "Successfully removed " + adItemListView.SelectedItems[0].Text + "\n from the database.";
|
||||
adItemListView.Items.Remove(adItemListView.SelectedItems[0]);
|
||||
}
|
||||
|
||||
deleteSelectedItem.Enabled = false;
|
||||
}
|
||||
|
||||
private void addItemButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseWriter = new DatabaseWriter(databaseTracker.DatabaseConnectionString);
|
||||
if (adItemTextBox.Text == "") return;
|
||||
TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
|
||||
//Clean up the input string.
|
||||
//Pretty up the ad item's name by uppercasing the name.
|
||||
var adItemText = adItemTextBox.Text;
|
||||
adItemText = textInfo.ToTitleCase(adItemText);
|
||||
//Eliminate the upper cased pound abbreviation ("Lb") with a standard "lb".
|
||||
adItemText = adItemText.Replace("Lb", "lb");
|
||||
adItemText = adItemText.Replace("LB", "lb");
|
||||
adItemText = adItemText.Replace("lB", "lb");
|
||||
adItemText = adItemText.Replace(":", "");
|
||||
adItemText = adItemText.Replace(";", "");
|
||||
adItemText = adItemText.Replace("/", "");
|
||||
adItemText = adItemText.Replace("\\", "");
|
||||
|
||||
if (databaseWriter.AddNewItem(adItemText))
|
||||
{
|
||||
notificationLabel.Text = "Successfully inserted " + adItemText + "\n into the database.";
|
||||
if (adItemFilterComboBox.SelectedIndex == 0 || adItemFilterComboBox.SelectedItem.ToString()[0] == adItemText[0])
|
||||
{
|
||||
adItemListView.Items.Add(adItemText);
|
||||
}
|
||||
if (!adItemFilterComboBox.Items.Contains(adItemText[0]))
|
||||
{
|
||||
adItemFilterComboBox.Items.Add(adItemText[0]);
|
||||
}
|
||||
}
|
||||
addItemLabel.Select();
|
||||
adItemTextBox.Text = "";
|
||||
addItemButton.Enabled = false;
|
||||
}
|
||||
|
||||
private void FillAdItemComboBoxFilter()
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var columnHeader = new ColumnHeader();
|
||||
columnHeader.Text = "Ad Items";
|
||||
columnHeader.Width = 300;
|
||||
adItemListView.Columns.Add(columnHeader);
|
||||
var itemList = databaseReader.RetrieveAdItemListByLetter(databaseTracker.DatabaseConnectionString);
|
||||
foreach (var item in itemList)
|
||||
{
|
||||
var listViewItem = new ListViewItem(item);
|
||||
if (!adItemFilterComboBox.Items.Contains(item[0]))
|
||||
{
|
||||
adItemFilterComboBox.Items.Add(item[0]);
|
||||
}
|
||||
adItemListView.Items.Add(listViewItem);
|
||||
}
|
||||
adItemFilterComboBox.Items.Insert(0, "All Items");
|
||||
columnHeader.Width = -1;
|
||||
adItemFilterComboBox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void closeFormFileMainMenu_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -40,25 +40,25 @@ namespace AdvertsingProfitControl
|
||||
|
||||
public void BuildFormFrontCompressedLayout(int dateId, double departmentSales, double salesProducedByAdItems, double remainingSales, double totalProfitReturnFromAdItems, double totalProfitReturnFromRemainingSales, double totalProfitReturn, string comments)
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
//var databaseTracker = new DatabaseTracker();
|
||||
//var databaseReader = new DatabaseReader();
|
||||
var stringWriter = new StringWriter();
|
||||
var writer = new HtmlTextWriter(stringWriter);
|
||||
var table = databaseReader.ReturnApcTableForReport(dateId, databaseTracker.DatabaseConnectionString);
|
||||
var dateString = databaseReader.RetrieveDateStringById(dateId, databaseTracker.DatabaseConnectionString);
|
||||
var spam = dateString.Split(' ');
|
||||
dateString = spam[0];
|
||||
//var table = databaseReader.ReturnApcTableForReport(dateId, databaseTracker.DatabaseConnectionString);
|
||||
//var dateString = databaseReader.RetrieveDateStringById(dateId, databaseTracker.DatabaseConnectionString);
|
||||
//var spam = dateString.Split(' ');
|
||||
//dateString = spam[0];
|
||||
//Begin evaluating the size of the table.
|
||||
var isCompressedFormat = false;
|
||||
var willGenerateCommentRow = false;
|
||||
if ((table.Rows.Count + 1) == 15)
|
||||
{
|
||||
willGenerateCommentRow = true;
|
||||
}
|
||||
else if ((table.Rows.Count + 1) < 15)
|
||||
{
|
||||
isCompressedFormat = true;
|
||||
}
|
||||
//if ((table.Rows.Count + 1) == 15)
|
||||
//{
|
||||
// willGenerateCommentRow = true;
|
||||
//}
|
||||
//else if ((table.Rows.Count + 1) < 15)
|
||||
//{
|
||||
// isCompressedFormat = true;
|
||||
//}
|
||||
writer.Write("<!DOCTYPE html>\n");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Html);
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Head);
|
||||
@@ -85,7 +85,7 @@ namespace AdvertsingProfitControl
|
||||
writer.RenderEndTag();//td
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "width:33%; padding: 0px 0px 0px 0px; margin:0px; border:none; vertical-align:bottom");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("<p><span style=\"margin-left:102px\">Week Ending: <u>" + dateString + "</u></span><br><span style=\"margin-left:86px\">Department: <u>Produce</u></span></p>");
|
||||
writer.Write("<p><span style=\"margin-left:102px\">Week Ending: <u> + dateString + </u></span><br><span style=\"margin-left:86px\">Department: <u>Produce</u></span></p>");
|
||||
writer.RenderEndTag();//td
|
||||
writer.RenderEndTag();//tr
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "margin:0px; padding:0px");
|
||||
@@ -183,281 +183,281 @@ namespace AdvertsingProfitControl
|
||||
double actualTotalProfitReturn = 0;
|
||||
var adSpecialOffset = 0;
|
||||
//Profit Analysis values.
|
||||
for (var rowIndex = 0; rowIndex < (table.Rows.Count < 19 ? 19 : table.Rows.Count); rowIndex++) //The comparison in the for loop is index based, so no need to add one to the row count.
|
||||
{
|
||||
var isProfitAnalysisCell = false;
|
||||
//IF the row index goes beyond the number of rows that are in the table, then start padding with blank cells to fit the Profit Analysis cells.
|
||||
if (rowIndex < table.Rows.Count)
|
||||
{
|
||||
var row = table.Rows[rowIndex];
|
||||
var rowAttribute = 0;
|
||||
var groupId = 0;
|
||||
if (int.TryParse(row.ItemArray[17].ToString(), out rowAttribute))
|
||||
{
|
||||
if (rowAttribute != 0)
|
||||
{
|
||||
if (rowAttribute == 1)
|
||||
{
|
||||
isRowMember = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
isRowMember = true;
|
||||
}
|
||||
isRenderingGroup = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isRenderingGroup = false;
|
||||
isRowMember = false;
|
||||
}
|
||||
}
|
||||
if (adSpecialRowIndex == -1 && int.TryParse(row.ItemArray[18].ToString(), out groupId))
|
||||
{
|
||||
if (groupId != 0)
|
||||
{
|
||||
adSpecialRowIndex = rowIndex;
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "17");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border-left:none");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("<center>" +
|
||||
databaseReader.ReturnGroupNameFromGroupId(groupId.ToString(),
|
||||
databaseTracker.DatabaseConnectionString) + "</center>");
|
||||
writer.RenderEndTag(); //td
|
||||
writer.RenderEndTag(); //tr
|
||||
BuildProfitAnalysisCell(ref writer, rowIndex, out isProfitAnalysisCell, salesProducedByAdItems, remainingSales, totalProfitReturnFromAdItems, totalProfitReturnFromRemainingSales, totalProfitReturn);
|
||||
adSpecialOffset++;
|
||||
}
|
||||
}
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
|
||||
for (var i = 0; i < row.ItemArray.Length; i++)
|
||||
{
|
||||
if (i >= 17) continue;
|
||||
if (i == 0)
|
||||
{
|
||||
writer.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, "left");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border-left:none");
|
||||
}
|
||||
else if (i > 0 && i < 7)
|
||||
{
|
||||
//background-color:#e9e9e9
|
||||
writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "#e9e9e9");
|
||||
}
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
decimal number;
|
||||
if (decimal.TryParse(row.ItemArray[i].ToString(), out number))
|
||||
{
|
||||
//Check for the inventory columns and the sold columns.
|
||||
if (!isRowMember)
|
||||
{
|
||||
if (i == 1 || i > 6 && i < 12)
|
||||
{
|
||||
writer.Write(number == 0 ? "0" : row.ItemArray[i].ToString());
|
||||
}
|
||||
if (i > 1 && i < 7 || i > 11)
|
||||
{
|
||||
writer.Write(number == 0 ? "0.00" : $"{number:N}");
|
||||
}
|
||||
}
|
||||
//for (var rowIndex = 0; rowIndex < (table.Rows.Count < 19 ? 19 : table.Rows.Count); rowIndex++) //The comparison in the for loop is index based, so no need to add one to the row count.
|
||||
//{
|
||||
// var isProfitAnalysisCell = false;
|
||||
// //IF the row index goes beyond the number of rows that are in the table, then start padding with blank cells to fit the Profit Analysis cells.
|
||||
// if (rowIndex < table.Rows.Count)
|
||||
// {
|
||||
// var row = table.Rows[rowIndex];
|
||||
// var rowAttribute = 0;
|
||||
// var groupId = 0;
|
||||
// if (int.TryParse(row.ItemArray[17].ToString(), out rowAttribute))
|
||||
// {
|
||||
// if (rowAttribute != 0)
|
||||
// {
|
||||
// if (rowAttribute == 1)
|
||||
// {
|
||||
// isRowMember = false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// isRowMember = true;
|
||||
// }
|
||||
// isRenderingGroup = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// isRenderingGroup = false;
|
||||
// isRowMember = false;
|
||||
// }
|
||||
// }
|
||||
// if (adSpecialRowIndex == -1 && int.TryParse(row.ItemArray[18].ToString(), out groupId))
|
||||
// {
|
||||
// if (groupId != 0)
|
||||
// {
|
||||
// adSpecialRowIndex = rowIndex;
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Tr);
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "17");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border-left:none");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("<center>" +
|
||||
// databaseReader.ReturnGroupNameFromGroupId(groupId.ToString(),
|
||||
// databaseTracker.DatabaseConnectionString) + "</center>");
|
||||
// writer.RenderEndTag(); //td
|
||||
// writer.RenderEndTag(); //tr
|
||||
// BuildProfitAnalysisCell(ref writer, rowIndex, out isProfitAnalysisCell, salesProducedByAdItems, remainingSales, totalProfitReturnFromAdItems, totalProfitReturnFromRemainingSales, totalProfitReturn);
|
||||
// adSpecialOffset++;
|
||||
// }
|
||||
// }
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Tr);
|
||||
// for (var i = 0; i < row.ItemArray.Length; i++)
|
||||
// {
|
||||
// if (i >= 17) continue;
|
||||
// if (i == 0)
|
||||
// {
|
||||
// writer.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, "left");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border-left:none");
|
||||
// }
|
||||
// else if (i > 0 && i < 7)
|
||||
// {
|
||||
// //background-color:#e9e9e9
|
||||
// writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "#e9e9e9");
|
||||
// }
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// decimal number;
|
||||
// if (decimal.TryParse(row.ItemArray[i].ToString(), out number))
|
||||
// {
|
||||
// //Check for the inventory columns and the sold columns.
|
||||
// if (!isRowMember)
|
||||
// {
|
||||
// if (i == 1 || i > 6 && i < 12)
|
||||
// {
|
||||
// writer.Write(number == 0 ? "0" : row.ItemArray[i].ToString());
|
||||
// }
|
||||
// if (i > 1 && i < 7 || i > 11)
|
||||
// {
|
||||
// writer.Write(number == 0 ? "0.00" : $"{number:N}");
|
||||
// }
|
||||
// }
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 3:
|
||||
projectionProfitReturn += double.Parse(row.ItemArray[3].ToString());
|
||||
break;
|
||||
case 6:
|
||||
projectionTotalProfitReturn += double.Parse(row.ItemArray[6].ToString());
|
||||
break;
|
||||
case 13:
|
||||
actualProfitReturn += double.Parse(row.ItemArray[13].ToString());
|
||||
break;
|
||||
case 16:
|
||||
actualTotalProfitReturn += double.Parse(row.ItemArray[16].ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(row.ItemArray[i]);
|
||||
}
|
||||
writer.RenderEndTag(); //td
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Padding
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
|
||||
//Generate padding rows to fit the Profit Analysis cells properly onto the sheet.
|
||||
//Check to see if the row index is equal to the number of rows in the table.
|
||||
if (rowIndex == table.Rows.Count)
|
||||
{
|
||||
//IF so, then that means the current row index represents the index of the Totals row. So build the totals row with the added values from above.
|
||||
//Begin rendering the totals row.
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:1px solid black; border-left:none");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.RenderEndTag();
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "background-color:#e9e9e9; text-align:right");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("Total");
|
||||
writer.RenderEndTag(); //td
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "background-color:#e9e9e9; padding: 0px 0px 0px 5px");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("(A) " + $"{projectionProfitReturn:C}");
|
||||
writer.RenderEndTag();
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "background-color:#e9e9e9; padding: 0px 0px 0px 5px");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("(B) " + $"{projectionTotalProfitReturn:C}");
|
||||
writer.RenderEndTag();
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "text-align:right");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "5");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("Total");
|
||||
writer.RenderEndTag();
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "padding: 0px 0px 0px 5px");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("(A) " + $"{actualProfitReturn:C}");
|
||||
writer.RenderEndTag();
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.RenderEndTag();
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "padding: 0px 0px 0px 5px");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("(B) " + $"{actualTotalProfitReturn:C}");
|
||||
writer.RenderEndTag();//td
|
||||
//END rending the totals row.
|
||||
BuildProfitAnalysisCell(ref writer, rowIndex + adSpecialOffset, out isProfitAnalysisCell, salesProducedByAdItems, remainingSales, totalProfitReturnFromAdItems, totalProfitReturnFromRemainingSales, totalProfitReturn);
|
||||
}
|
||||
else if (rowIndex == (table.Rows.Count + 1))
|
||||
//Check to see if the current index is equal to the row after the totals row and, if so, create the comments row.
|
||||
{
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "17");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border-left:none");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write(
|
||||
"<b>Comments:</b> " + comments);
|
||||
writer.RenderEndTag(); //td
|
||||
BuildProfitAnalysisCell(ref writer, rowIndex + adSpecialOffset, out isProfitAnalysisCell, salesProducedByAdItems, remainingSales, totalProfitReturnFromAdItems, totalProfitReturnFromRemainingSales, totalProfitReturn);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cellCount = 0;
|
||||
while (cellCount < 17)
|
||||
{
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:none");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.RenderEndTag();//td
|
||||
cellCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// switch (i)
|
||||
// {
|
||||
// case 3:
|
||||
// projectionProfitReturn += double.Parse(row.ItemArray[3].ToString());
|
||||
// break;
|
||||
// case 6:
|
||||
// projectionTotalProfitReturn += double.Parse(row.ItemArray[6].ToString());
|
||||
// break;
|
||||
// case 13:
|
||||
// actualProfitReturn += double.Parse(row.ItemArray[13].ToString());
|
||||
// break;
|
||||
// case 16:
|
||||
// actualTotalProfitReturn += double.Parse(row.ItemArray[16].ToString());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// writer.Write(row.ItemArray[i]);
|
||||
// }
|
||||
// writer.RenderEndTag(); //td
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //Padding
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Tr);
|
||||
// //Generate padding rows to fit the Profit Analysis cells properly onto the sheet.
|
||||
// //Check to see if the row index is equal to the number of rows in the table.
|
||||
// if (rowIndex == table.Rows.Count)
|
||||
// {
|
||||
// //IF so, then that means the current row index represents the index of the Totals row. So build the totals row with the added values from above.
|
||||
// //Begin rendering the totals row.
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:1px solid black; border-left:none");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.RenderEndTag();
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "background-color:#e9e9e9; text-align:right");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("Total");
|
||||
// writer.RenderEndTag(); //td
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "background-color:#e9e9e9; padding: 0px 0px 0px 5px");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("(A) " + $"{projectionProfitReturn:C}");
|
||||
// writer.RenderEndTag();
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "background-color:#e9e9e9; padding: 0px 0px 0px 5px");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("(B) " + $"{projectionTotalProfitReturn:C}");
|
||||
// writer.RenderEndTag();
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "text-align:right");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "5");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("Total");
|
||||
// writer.RenderEndTag();
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "padding: 0px 0px 0px 5px");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("(A) " + $"{actualProfitReturn:C}");
|
||||
// writer.RenderEndTag();
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.RenderEndTag();
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "padding: 0px 0px 0px 5px");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("(B) " + $"{actualTotalProfitReturn:C}");
|
||||
// writer.RenderEndTag();//td
|
||||
// //END rending the totals row.
|
||||
// BuildProfitAnalysisCell(ref writer, rowIndex + adSpecialOffset, out isProfitAnalysisCell, salesProducedByAdItems, remainingSales, totalProfitReturnFromAdItems, totalProfitReturnFromRemainingSales, totalProfitReturn);
|
||||
// }
|
||||
// else if (rowIndex == (table.Rows.Count + 1))
|
||||
// //Check to see if the current index is equal to the row after the totals row and, if so, create the comments row.
|
||||
// {
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "17");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border-left:none");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write(
|
||||
// "<b>Comments:</b> " + comments);
|
||||
// writer.RenderEndTag(); //td
|
||||
// BuildProfitAnalysisCell(ref writer, rowIndex + adSpecialOffset, out isProfitAnalysisCell, salesProducedByAdItems, remainingSales, totalProfitReturnFromAdItems, totalProfitReturnFromRemainingSales, totalProfitReturn);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var cellCount = 0;
|
||||
// while (cellCount < 17)
|
||||
// {
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:none");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.RenderEndTag();//td
|
||||
// cellCount++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//Check for every 3rd row to append a Profit Analysis cell onto.
|
||||
switch (rowIndex + adSpecialOffset)
|
||||
{
|
||||
case 0:
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, "2");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:none; border-right:none");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("<center style=\"margin-top:1px\">Sales Produced By<br>Ad Items (A)</center><p><span style=\"font-size:9px; vertical-align:bottom\">2</span><span style=\"margin-left:60px\">" + $"{salesProducedByAdItems:C}" + "</span></p>");
|
||||
writer.RenderEndTag();
|
||||
break;
|
||||
case 3:
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, "2");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:none; border-top:1px solid black; border-right:none");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("<center style=\"margin-top:1px\">Remaining<br>Sales</center><p><span style=\"font-size:9px; vertical-align:bottom\">3</span><span style=\"margin-left:60px\">" + $"{remainingSales:C}" + " </span></p>");
|
||||
writer.RenderEndTag();
|
||||
break;
|
||||
case 6:
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, "2");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:none; border-top:1px solid black; border-right:none");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("<center style=\"margin-top:1px;\">Total $ Profit Return<br>From Ad Items (B)</center><p><span style=\"font-size:9px; vertical-align:bottom\">4</span><span style=\"margin-left:60px\">" + $"{totalProfitReturnFromAdItems:C}" + " </span></p>");
|
||||
writer.RenderEndTag();
|
||||
break;
|
||||
case 9:
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, "2");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:none; border-top:1px solid black; border-right:none");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("<center style=\"margin-top:2px\">Total $ Profit Return<br>From Remaining Sales</center><p><span style=\"font-size:9px; vertical-align:bottom\">5</span><span style=\"margin-left:60px\">" + $"{totalProfitReturnFromRemainingSales:C}" + "</span></p>");
|
||||
writer.RenderEndTag();
|
||||
break;
|
||||
case 12:
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, "2");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border-right:none");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("<center style=\"margin-top:1px\">Total $ Profit<br>Return</center><p><span style=\"font-size:9px; vertical-align:bottom\">6</span><span style=\"margin-left:60px\">" + $"{totalProfitReturn:C}" + "</span></p>");
|
||||
writer.RenderEndTag();
|
||||
break;
|
||||
case 15:
|
||||
//IF either the compressed format or the generate comment row flags are set, then ignore this case. Only tables with 19 or more rows can generate a full comments cell due to the amount of text it can contain.
|
||||
if (isCompressedFormat || willGenerateCommentRow) break;
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, "4");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border-right:none");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("Comments: " + comments);
|
||||
writer.RenderEndTag();
|
||||
break;
|
||||
}
|
||||
// switch (rowIndex + adSpecialOffset)
|
||||
// {
|
||||
// case 0:
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, "2");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:none; border-right:none");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("<center style=\"margin-top:1px\">Sales Produced By<br>Ad Items (A)</center><p><span style=\"font-size:9px; vertical-align:bottom\">2</span><span style=\"margin-left:60px\">" + $"{salesProducedByAdItems:C}" + "</span></p>");
|
||||
// writer.RenderEndTag();
|
||||
// break;
|
||||
// case 3:
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, "2");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:none; border-top:1px solid black; border-right:none");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("<center style=\"margin-top:1px\">Remaining<br>Sales</center><p><span style=\"font-size:9px; vertical-align:bottom\">3</span><span style=\"margin-left:60px\">" + $"{remainingSales:C}" + " </span></p>");
|
||||
// writer.RenderEndTag();
|
||||
// break;
|
||||
// case 6:
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, "2");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:none; border-top:1px solid black; border-right:none");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("<center style=\"margin-top:1px;\">Total $ Profit Return<br>From Ad Items (B)</center><p><span style=\"font-size:9px; vertical-align:bottom\">4</span><span style=\"margin-left:60px\">" + $"{totalProfitReturnFromAdItems:C}" + " </span></p>");
|
||||
// writer.RenderEndTag();
|
||||
// break;
|
||||
// case 9:
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, "2");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:none; border-top:1px solid black; border-right:none");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("<center style=\"margin-top:2px\">Total $ Profit Return<br>From Remaining Sales</center><p><span style=\"font-size:9px; vertical-align:bottom\">5</span><span style=\"margin-left:60px\">" + $"{totalProfitReturnFromRemainingSales:C}" + "</span></p>");
|
||||
// writer.RenderEndTag();
|
||||
// break;
|
||||
// case 12:
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, "2");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border-right:none");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("<center style=\"margin-top:1px\">Total $ Profit<br>Return</center><p><span style=\"font-size:9px; vertical-align:bottom\">6</span><span style=\"margin-left:60px\">" + $"{totalProfitReturn:C}" + "</span></p>");
|
||||
// writer.RenderEndTag();
|
||||
// break;
|
||||
// case 15:
|
||||
// //IF either the compressed format or the generate comment row flags are set, then ignore this case. Only tables with 19 or more rows can generate a full comments cell due to the amount of text it can contain.
|
||||
// if (isCompressedFormat || willGenerateCommentRow) break;
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, "4");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border-right:none");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("Comments: " + comments);
|
||||
// writer.RenderEndTag();
|
||||
// break;
|
||||
// }
|
||||
|
||||
writer.RenderEndTag();//tr
|
||||
}//end for loop
|
||||
// writer.RenderEndTag();//tr
|
||||
//}//end for loop
|
||||
|
||||
if (!willGenerateCommentRow && !isCompressedFormat)
|
||||
{
|
||||
//Begin rendering the totals row.
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:1px solid black; border-left:none");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.RenderEndTag();
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "background-color:#e9e9e9; border:1px solid black; font-size:12px; border-left: 1px solid #000; text-align:right");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("Total");
|
||||
writer.RenderEndTag(); //td
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "background-color:#e9e9e9; border:1px solid black; font-size:12px; border-left: 1px solid #000; padding: 0px 0px 0px 5px");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("(A) " + $"{projectionProfitReturn:C}");
|
||||
writer.RenderEndTag();
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "background-color:#e9e9e9; border:1px solid black; font-size:12px; border-left: 1px solid #000; padding: 0px 0px 0px 5px");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("(B) " + $"{projectionTotalProfitReturn:C}");
|
||||
writer.RenderEndTag();
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:1px solid black; font-size:12px; border-left: 1px solid #000; text-align:right");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "5");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("Total");
|
||||
writer.RenderEndTag();
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:1px solid black; font-size:12px; border-left: 1px solid #000; padding: 0px 0px 0px 5px");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("(A) " + $"{actualProfitReturn:C}");
|
||||
writer.RenderEndTag();
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:1px solid black");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.RenderEndTag();
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:1px solid black; font-size:12px; border-left: 1px solid #000; padding: 0px 0px 0px 5px");
|
||||
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
writer.Write("(B) " + $"{actualTotalProfitReturn:C}");
|
||||
writer.RenderEndTag();//td
|
||||
writer.RenderEndTag(); //tr
|
||||
}
|
||||
writer.RenderEndTag();//table
|
||||
writer.RenderEndTag();//body
|
||||
writer.RenderEndTag();//HTML
|
||||
//if (!willGenerateCommentRow && !isCompressedFormat)
|
||||
//{
|
||||
// //Begin rendering the totals row.
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Tr);
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:1px solid black; border-left:none");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.RenderEndTag();
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "background-color:#e9e9e9; border:1px solid black; font-size:12px; border-left: 1px solid #000; text-align:right");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("Total");
|
||||
// writer.RenderEndTag(); //td
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "background-color:#e9e9e9; border:1px solid black; font-size:12px; border-left: 1px solid #000; padding: 0px 0px 0px 5px");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("(A) " + $"{projectionProfitReturn:C}");
|
||||
// writer.RenderEndTag();
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "background-color:#e9e9e9; border:1px solid black; font-size:12px; border-left: 1px solid #000; padding: 0px 0px 0px 5px");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("(B) " + $"{projectionTotalProfitReturn:C}");
|
||||
// writer.RenderEndTag();
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:1px solid black; font-size:12px; border-left: 1px solid #000; text-align:right");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "5");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("Total");
|
||||
// writer.RenderEndTag();
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:1px solid black; font-size:12px; border-left: 1px solid #000; padding: 0px 0px 0px 5px");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("(A) " + $"{actualProfitReturn:C}");
|
||||
// writer.RenderEndTag();
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:1px solid black");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.RenderEndTag();
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:1px solid black; font-size:12px; border-left: 1px solid #000; padding: 0px 0px 0px 5px");
|
||||
// writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
|
||||
// writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
||||
// writer.Write("(B) " + $"{actualTotalProfitReturn:C}");
|
||||
// writer.RenderEndTag();//td
|
||||
// writer.RenderEndTag(); //tr
|
||||
//}
|
||||
//writer.RenderEndTag();//table
|
||||
//writer.RenderEndTag();//body
|
||||
//writer.RenderEndTag();//HTML
|
||||
|
||||
using (var streamWriter = new StreamWriter(Application.StartupPath + "\\FrontPage.html"))
|
||||
{
|
||||
streamWriter.WriteLine(stringWriter.ToString());
|
||||
}
|
||||
RenderHtmlToImage();
|
||||
//using (var streamWriter = new StreamWriter(Application.StartupPath + "\\FrontPage.html"))
|
||||
//{
|
||||
// streamWriter.WriteLine(stringWriter.ToString());
|
||||
//}
|
||||
//RenderHtmlToImage();
|
||||
}
|
||||
|
||||
private void BuildProfitAnalysisCell(ref HtmlTextWriter writer, int rowIndex, out bool isProfitAnalysisCell, double salesProducedByAdItems, double remainingSales, double totalProfitReturnFromAdItems, double totalProfitReturnFromRemainingSales, double totalProfitReturn)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
@@ -14,6 +13,7 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
public partial class NewModifyRecord : Form
|
||||
{
|
||||
//TODO: Re-enable drag and drop on the modify record form.
|
||||
//http://stackoverflow.com/questions/6219454/efficient-way-to-remove-all-whitespace-from-string
|
||||
private static readonly FrmLogConsole LogConsole = FrmLogConsole.GetStaticInstance;
|
||||
//Create an array that contains all the ad items from the database.
|
||||
@@ -422,13 +422,11 @@ namespace AdvertsingProfitControl
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
//If so create the database interaction objects.
|
||||
var dbTracker = new DatabaseTracker();
|
||||
var dbWriter = new DatabaseWriter(dbTracker.DatabaseConnectionString);
|
||||
var id =
|
||||
int.Parse(
|
||||
invoicesDataGridView.Rows[rowIndex].Cells[(int)InvoiceTableColumns.Id].EditedFormattedValue
|
||||
.ToString());
|
||||
if (dbWriter.DeleteInvoiceRow(id))
|
||||
if (DeleteInvoiceRow(id))
|
||||
{
|
||||
informationLabel.Text = @"Successfully removed row " + (rowIndex + 1) + @" from the database.";
|
||||
}
|
||||
@@ -583,8 +581,6 @@ namespace AdvertsingProfitControl
|
||||
var dataGridView = (DataGridView)sender;
|
||||
if (dataGridView.CurrentRow == null) return;
|
||||
//Create the database writer object so rows that are in the database can be deleted.
|
||||
var dbTracker = new DatabaseTracker();
|
||||
var dbWriter = new DatabaseWriter(dbTracker.DatabaseConnectionString);
|
||||
var currentRowIndex = dataGridView.CurrentRow.Index;
|
||||
//Remove the ad item from the gUsedAdItem collection, if it exists.
|
||||
if (_adSpecialIndex == -1)
|
||||
@@ -596,20 +592,17 @@ namespace AdvertsingProfitControl
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
//Attempt to delete the row from the database by its ID number.
|
||||
int projectionsRowId;
|
||||
int inventoryRowId;
|
||||
int actualSalesRowId;
|
||||
//Attempt to delete the row from the database by its ID number.
|
||||
int.TryParse(
|
||||
projectionsDataGridView.Rows[currentRowIndex].Cells[(int) SalesTableColumns.Id]
|
||||
.EditedFormattedValue.ToString(), out projectionsRowId);
|
||||
projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id]
|
||||
.EditedFormattedValue.ToString(), out int projectionsRowId);
|
||||
int.TryParse(
|
||||
inventoryDataGridView.Rows[currentRowIndex].Cells[(int) SalesTableColumns.Id]
|
||||
.EditedFormattedValue.ToString(), out inventoryRowId);
|
||||
.EditedFormattedValue.ToString(), out int inventoryRowId);
|
||||
int.TryParse(
|
||||
actualSalesDataGridView.Rows[currentRowIndex].Cells[(int) SalesTableColumns.Id]
|
||||
.EditedFormattedValue.ToString(), out actualSalesRowId);
|
||||
if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
|
||||
.EditedFormattedValue.ToString(), out int actualSalesRowId);
|
||||
if (DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
|
||||
{
|
||||
informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) +
|
||||
@" from the database.";
|
||||
@@ -643,14 +636,11 @@ namespace AdvertsingProfitControl
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
//Attempt to delete the row from the database by its ID number.
|
||||
int projectionsRowId;
|
||||
int inventoryRowId;
|
||||
int actualSalesRowId;
|
||||
//Attempt to delete the row from the database by its ID number.
|
||||
int.TryParse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out projectionsRowId);
|
||||
int.TryParse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out inventoryRowId);
|
||||
int.TryParse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out actualSalesRowId);
|
||||
if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
|
||||
int.TryParse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out int projectionsRowId);
|
||||
int.TryParse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out int inventoryRowId);
|
||||
int.TryParse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out int actualSalesRowId);
|
||||
if (DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
|
||||
{
|
||||
informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) + @" from the database.";
|
||||
}
|
||||
@@ -688,7 +678,7 @@ namespace AdvertsingProfitControl
|
||||
var projectionsRowId = int.Parse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
|
||||
var inventoryRowId = int.Parse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
|
||||
var actualSalesRowId = int.Parse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
|
||||
if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
|
||||
if (DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
|
||||
{
|
||||
informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) + @" from the database.";
|
||||
}
|
||||
@@ -743,7 +733,7 @@ namespace AdvertsingProfitControl
|
||||
int.TryParse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out projectionsRowId);
|
||||
int.TryParse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out inventoryRowId);
|
||||
int.TryParse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out actualSalesRowId);
|
||||
if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
|
||||
if (DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
|
||||
{
|
||||
informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) + @" from the database.";
|
||||
}
|
||||
@@ -983,9 +973,7 @@ namespace AdvertsingProfitControl
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
var dbT = new DatabaseTracker();
|
||||
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
|
||||
if (!dbW.DeleteApcRow(
|
||||
if (!DeleteApcRow(
|
||||
int.Parse(
|
||||
projectionsDataGridView.Rows[e.RowIndex].Cells[
|
||||
(int) SalesTableColumns.Id].EditedFormattedValue.ToString()),
|
||||
@@ -1509,9 +1497,7 @@ namespace AdvertsingProfitControl
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
var dbT = new DatabaseTracker();
|
||||
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
|
||||
if (!dbW.DeleteApcRow(
|
||||
if (DeleteApcRow(
|
||||
int.Parse(
|
||||
projectionsDataGridView.Rows[e.RowIndex].Cells[
|
||||
(int)SalesTableColumns.Id].EditedFormattedValue.ToString()),
|
||||
@@ -2732,12 +2718,9 @@ namespace AdvertsingProfitControl
|
||||
|
||||
private void LoadDate(DateTime date)
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var dateRecord = db.WeekEndingDates.Single(x => x.EndingDate == date);
|
||||
var dateId = databaseReader.RetrieveDateIdByDateString(date.ToString("d"), databaseTracker.DatabaseConnectionString);
|
||||
if (dateId == 0)
|
||||
var dateRecord = db.WeekEndingDates.SingleOrDefault(x => x.EndingDate == date);
|
||||
if (dateRecord == null)
|
||||
{
|
||||
errorLabel.Text = @"Failed to get the date ID number, aborting load operation." + Environment.NewLine;
|
||||
return;
|
||||
@@ -2746,45 +2729,11 @@ namespace AdvertsingProfitControl
|
||||
LoadProjectionsTable(dateRecord);
|
||||
LoadInventory(dateRecord);
|
||||
LoadActualSales(dateRecord);
|
||||
var invoices = databaseReader.ReturnInvoiceTable(dateId, databaseTracker.DatabaseConnectionString);
|
||||
var comments = databaseReader.RetrieveComments(int.Parse(dateId.ToString()), databaseTracker.DatabaseConnectionString);
|
||||
if (comments.Count == 2)
|
||||
{
|
||||
LoadComments(int.Parse(comments[0]), comments[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
informationLabel.Text += @"No comments to display." + Environment.NewLine;
|
||||
}
|
||||
var weeklySales = databaseReader.ReturnWeeklySalesFromDateId(dateId, databaseTracker.DatabaseConnectionString);
|
||||
if (weeklySales.Rows.Count == 1)
|
||||
{
|
||||
LoadWeeklySales(weeklySales);
|
||||
}
|
||||
else
|
||||
{
|
||||
informationLabel.Text += @"No sales to display." + Environment.NewLine;
|
||||
}
|
||||
|
||||
var taxable = databaseReader.ReturnTaxableFromDateId(dateId, databaseTracker.DatabaseConnectionString);
|
||||
if (taxable.Rows.Count == 1)
|
||||
{
|
||||
LoadTaxable(taxable);
|
||||
}
|
||||
else
|
||||
{
|
||||
informationLabel.Text += @"No taxable data to display." + Environment.NewLine;
|
||||
}
|
||||
LoadInvoices(invoices);
|
||||
var costAnalysis = databaseReader.ReturnCostAnalysis(dateId, databaseTracker.DatabaseConnectionString);
|
||||
if (costAnalysis.Rows.Count == 1)
|
||||
{
|
||||
LoadCostAnalysis(costAnalysis);
|
||||
}
|
||||
else
|
||||
{
|
||||
informationLabel.Text += @"No cost analysis data to display." + Environment.NewLine;
|
||||
}
|
||||
LoadInvoices(dateRecord);
|
||||
LoadComments(dateRecord);
|
||||
LoadWeeklySales(dateRecord);
|
||||
LoadTaxable(dateRecord);
|
||||
LoadCostAnalysis(dateRecord);
|
||||
_formRoll = FormRoll.ModifyRecord;
|
||||
}
|
||||
|
||||
@@ -2978,59 +2927,44 @@ namespace AdvertsingProfitControl
|
||||
actualSalesDataGridView.RowValidating += ValidateActualSalesRow;
|
||||
}
|
||||
|
||||
private void LoadInvoices(DataTable invoices)
|
||||
private void LoadInvoices(WeekEndingDate dateRecord)
|
||||
{
|
||||
for (var rowIndex = 0; rowIndex < invoices.Rows.Count; rowIndex++)
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var invoices = db.Invoices.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
||||
var index = 0;
|
||||
foreach (var invoice in invoices)
|
||||
{
|
||||
var row = new DataGridViewRow();
|
||||
for (var cellIndex = 0; cellIndex < invoices.Rows[rowIndex].ItemArray.Length; cellIndex++)
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell();
|
||||
//Format the invoice date.
|
||||
if (cellIndex == 1)
|
||||
{
|
||||
var date = DateTime.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString());
|
||||
cell.Value = date.ToString("d");
|
||||
row.Cells.Add(cell);
|
||||
continue;
|
||||
}
|
||||
//Apply formatting to the only cells that will have currency values in them.
|
||||
if (cellIndex == 4 || cellIndex == 5)
|
||||
{
|
||||
var formattedNumber = Math.Round(double.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
cell.Value = formattedNumber;
|
||||
}
|
||||
row.Cells.Add(cell);
|
||||
continue;
|
||||
}
|
||||
//No special formatting rules here so just put the value in and move on.
|
||||
cell.Value = invoices.Rows[rowIndex].ItemArray[cellIndex].ToString();
|
||||
row.Cells.Add(cell);
|
||||
}
|
||||
//Set the is dirty cell to false.
|
||||
var isDirtyCell = new DataGridViewCheckBoxCell
|
||||
{
|
||||
Value = false
|
||||
};
|
||||
row.Cells.Add(isDirtyCell);
|
||||
invoicesDataGridView.Rows.Add(row);
|
||||
invoicesDataGridView.Rows.Add();
|
||||
invoicesDataGridView.Rows[index].Cells[0].Value = invoice.Id;
|
||||
invoicesDataGridView.Rows[index].Cells[2].Value = invoice.Supplier.Name;
|
||||
invoicesDataGridView.Rows[index].Cells[1].Value = invoice.InvoiceDate.ToString("d");
|
||||
invoicesDataGridView.Rows[index].Cells[3].Value = invoice.InvoiceNumber;
|
||||
invoicesDataGridView.Rows[index].Cells[4].Value = invoice.InvoiceNetAmountAtCost == 0 ? "" : invoice.InvoiceNetAmountAtCost.ToString();
|
||||
invoicesDataGridView.Rows[index].Cells[5].Value = invoice.InvoiceNetAmount == 0 ? "" : invoice.InvoiceNetAmount.ToString();
|
||||
invoicesDataGridView.Rows[index].Cells[6].Value = invoice.InvoiceNote;
|
||||
invoicesDataGridView.Rows[index].Cells[(int)InvoiceTableColumns.IsDirty].Value = false;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadComments(int id, string comments)
|
||||
private void LoadComments(WeekEndingDate dateRecord)
|
||||
{
|
||||
//commentsTextBox.TextChanged -= DisplayRemainingCommentCharacterCount;
|
||||
commentsTextBox.Enter -= StoreBeginningTextBoxValue;
|
||||
commentsTextBox.KeyDown -= CheckForKeyCommand;
|
||||
commentsTextBox.Leave -= CheckForTextChangeOnLeave;
|
||||
|
||||
isCommentDirtyCheckBox.Text = @"isCommentsDirty (" + id + @")";
|
||||
isCommentDirtyCheckBox.Tag = id;
|
||||
|
||||
commentsTextBox.Text = comments;
|
||||
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var comments = db.Notes.SingleOrDefault(x => x.FkDateId == dateRecord.Id);
|
||||
if (comments != null)
|
||||
{
|
||||
isCommentDirtyCheckBox.Tag = comments.Id;
|
||||
isCommentDirtyCheckBox.Text = @"IsCommentsDirty (" + comments.Id + @")";
|
||||
commentsTextBox.Text = comments.Remark;
|
||||
}
|
||||
else
|
||||
{
|
||||
informationLabel.Text += @"No comments to display." + Environment.NewLine;
|
||||
}
|
||||
//commentsGroupBox.Text = @"Comments (Characters Remaining: " + commentsTextBox.MaxLength + @")";
|
||||
//commentsTextBox.TextChanged += DisplayRemainingCommentCharacterCount;
|
||||
commentsTextBox.Enter += StoreBeginningTextBoxValue;
|
||||
@@ -3038,7 +2972,7 @@ namespace AdvertsingProfitControl
|
||||
commentsTextBox.Leave += CheckForTextChangeOnLeave;
|
||||
}
|
||||
|
||||
private void LoadWeeklySales(DataTable weeklySales)
|
||||
private void LoadWeeklySales(WeekEndingDate dateRecord)
|
||||
{
|
||||
sundayWeeklySalesTextBox.Enter -= StoreBeginningTextBoxValue;
|
||||
sundayWeeklySalesTextBox.Validating -= ValidateWeeklySales;
|
||||
@@ -3057,80 +2991,27 @@ namespace AdvertsingProfitControl
|
||||
totalWeeklySalesTextBox.Enter -= StoreBeginningTextBoxValue;
|
||||
totalWeeklySalesTextBox.Validating -= ValidateWeeklySales;
|
||||
|
||||
//Spin through the only row in the weekly sales table. Item in item
|
||||
//array index zero (0) is the ID number of the weekly sales.
|
||||
for (var cellIndex = 0; cellIndex < weeklySales.Rows[0].ItemArray.Length; cellIndex++)
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var weeklySale = db.WeeklySales.SingleOrDefault(x => x.FkDateId == dateRecord.Id);
|
||||
if (weeklySale == null)
|
||||
{
|
||||
if (cellIndex == 0)
|
||||
{
|
||||
//ID number
|
||||
var id = int.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
|
||||
isWeeklySalesDirtyCheckBox.Tag = id;
|
||||
isWeeklySalesDirtyCheckBox.Text = @"IsWeeklySalesDirty (" + id + @")";
|
||||
continue;
|
||||
}
|
||||
string formattedNumber;
|
||||
switch (cellIndex)
|
||||
{
|
||||
case 1: //Sunday
|
||||
formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
sundayWeeklySalesTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 2: //Monday
|
||||
formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
mondayWeeklySalesTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 3: //Tuesday
|
||||
formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
tuesdayWeeklySalesTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 4: //Wednesday
|
||||
formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
wednesdayWeeklySalesTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 5: //Thursday
|
||||
formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
thursdayWeeklySalesTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 6: //Friday
|
||||
formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
fridayWeeklySalesTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 7: //Saturday
|
||||
formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
saturdayWeeklySalesTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 8: //Total Sales
|
||||
formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
totalWeeklySalesTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
}
|
||||
informationLabel.Text += @"No weekly sales to display." + Environment.NewLine;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
sundayWeeklySalesTextBox.Text = weeklySale.Sunday == 0 ? string.Empty : $"{weeklySale.Sunday:N2}";
|
||||
mondayWeeklySalesTextBox.Text = weeklySale.Monday == 0 ? string.Empty : $"{weeklySale.Monday:N2}";
|
||||
tuesdayWeeklySalesTextBox.Text = weeklySale.Tuesday == 0 ? string.Empty : $"{weeklySale.Tuesday:N2}";
|
||||
wednesdayWeeklySalesTextBox.Text = weeklySale.Wednesday == 0 ? string.Empty : $"{weeklySale.Wednesday:N2}";
|
||||
thursdayWeeklySalesTextBox.Text = weeklySale.Thursday == 0 ? string.Empty : $"{weeklySale.Thursday:N2}";
|
||||
fridayWeeklySalesTextBox.Text = weeklySale.Friday == 0 ? string.Empty : $"{weeklySale.Friday:N2}";
|
||||
saturdayWeeklySalesTextBox.Text = weeklySale.Saturday == 0 ? string.Empty : $"{weeklySale.Saturday:N2}";
|
||||
totalWeeklySalesTextBox.Text = weeklySale.TotalSales == 0 ? string.Empty : $"{weeklySale.TotalSales:N2}";
|
||||
//Set the internal state
|
||||
isWeeklySalesDirtyCheckBox.Text = @"IsWeeklySalesDirty (" + weeklySale.Id + @")";
|
||||
isWeeklySalesDirtyCheckBox.Tag = weeklySale.Id;
|
||||
}
|
||||
//Re-enable the events
|
||||
sundayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue;
|
||||
sundayWeeklySalesTextBox.Validating += ValidateWeeklySales;
|
||||
mondayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue;
|
||||
@@ -3149,7 +3030,7 @@ namespace AdvertsingProfitControl
|
||||
totalWeeklySalesTextBox.Validating += ValidateWeeklySales;
|
||||
}
|
||||
|
||||
private void LoadTaxable(DataTable taxable)
|
||||
private void LoadTaxable(WeekEndingDate dateRecord)
|
||||
{
|
||||
sundayTaxableTextBox.Enter -= StoreBeginningTextBoxValue;
|
||||
sundayTaxableTextBox.Validating -= ValidateTaxableFields;
|
||||
@@ -3167,78 +3048,25 @@ namespace AdvertsingProfitControl
|
||||
saturdayTaxableTextBox.Validating -= ValidateTaxableFields;
|
||||
totalTaxableTextBox.Enter -= StoreBeginningTextBoxValue;
|
||||
totalTaxableTextBox.Validating -= ValidateTaxableFields;
|
||||
//Spin through the only row in the taxable table. Item in item
|
||||
//array index zero (0) is the ID number of the weekly sales.
|
||||
for (var cellIndex = 0; cellIndex < taxable.Rows[0].ItemArray.Length; cellIndex++)
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var taxable = db.Taxables.SingleOrDefault(x => x.FkDateId == dateRecord.Id);
|
||||
if (taxable == null)
|
||||
{
|
||||
if (cellIndex == 0)
|
||||
{
|
||||
//ID number
|
||||
var id = int.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString());
|
||||
isTaxableDirtyCheckBox.Tag = id;
|
||||
isTaxableDirtyCheckBox.Text = @"IsTaxableDirty (" + id + @")";
|
||||
continue;
|
||||
}
|
||||
string formattedNumber;
|
||||
switch (cellIndex)
|
||||
{
|
||||
case 1: //Sunday
|
||||
formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
sundayTaxableTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 2: //Monday
|
||||
formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
mondayTaxableTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 3: //Tuesday
|
||||
formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
tuesdayTaxableTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 4: //Wednesday
|
||||
formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
wednesdayTaxableTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 5: //Thursday
|
||||
formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
thursdayTaxableTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 6: //Friday
|
||||
formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
fridayTaxableTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 7: //Saturday
|
||||
formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
saturdayTaxableTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 8: //Total Taxable
|
||||
formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
totalTaxableTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
}
|
||||
informationLabel.Text += @"No taxables to display." + Environment.NewLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
sundayTaxableTextBox.Text = taxable.Sunday == 0 ? string.Empty : $"{taxable.Sunday:N2}";
|
||||
mondayTaxableTextBox.Text = taxable.Monday == 0 ? string.Empty : $"{taxable.Monday:N2}";
|
||||
tuesdayTaxableTextBox.Text = taxable.Tuesday == 0 ? string.Empty : $"{taxable.Tuesday:N2}";
|
||||
wednesdayTaxableTextBox.Text = taxable.Wednesday == 0 ? string.Empty : $"{taxable.Wednesday:N2}";
|
||||
thursdayTaxableTextBox.Text = taxable.Thursday == 0 ? string.Empty : $"{taxable.Thursday:N2}";
|
||||
fridayTaxableTextBox.Text = taxable.Friday == 0 ? string.Empty : $"{taxable.Friday:N2}";
|
||||
saturdayTaxableTextBox.Text = taxable.Saturday == 0 ? string.Empty : $"{taxable.Saturday:N2}";
|
||||
totalTaxableTextBox.Text = taxable.Total == 0 ? string.Empty : $"{taxable.Total:N2}";
|
||||
//Set the internal state
|
||||
isTaxableDirtyCheckBox.Text = @"IsTaxableDirty (" + taxable.Id + @")";
|
||||
isTaxableDirtyCheckBox.Tag = taxable.Id;
|
||||
}
|
||||
sundayTaxableTextBox.Enter += StoreBeginningTextBoxValue;
|
||||
sundayTaxableTextBox.Validating += ValidateTaxableFields;
|
||||
@@ -3258,7 +3086,7 @@ namespace AdvertsingProfitControl
|
||||
totalTaxableTextBox.Validating += ValidateTaxableFields;
|
||||
}
|
||||
|
||||
private void LoadCostAnalysis(DataTable costAnalysis)
|
||||
private void LoadCostAnalysis(WeekEndingDate dateRecord)
|
||||
{
|
||||
salesPerManHourTextBox.Enter -= StoreBeginningTextBoxValue;
|
||||
salesPerManHourTextBox.Validating -= ValidateCostAnalysisValues;
|
||||
@@ -3268,50 +3096,22 @@ namespace AdvertsingProfitControl
|
||||
salaryDollarsTextBox.Validating -= ValidateCostAnalysisValues;
|
||||
suppliesTextBox.Enter -= StoreBeginningTextBoxValue;
|
||||
suppliesTextBox.Validating -= ValidateCostAnalysisValues;
|
||||
//Spin through the only row in the taxable table. Item in item
|
||||
//array index zero (0) is the ID number of the weekly sales.
|
||||
for (var cellIndex = 0; cellIndex < costAnalysis.Rows[0].ItemArray.Length; cellIndex++)
|
||||
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var costAnalysis = db.CostAnalysis.SingleOrDefault(x => x.FkDateId == dateRecord.Id);
|
||||
if (costAnalysis == null)
|
||||
{
|
||||
if (cellIndex == 0)
|
||||
{
|
||||
//ID number
|
||||
var id = int.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString());
|
||||
isCostAnalysisDirtyCheckBox.Tag = id;
|
||||
isCostAnalysisDirtyCheckBox.Text = @"IsCostAnalysisDirty (" + id + @")";
|
||||
continue;
|
||||
}
|
||||
string formattedNumber;
|
||||
switch (cellIndex)
|
||||
{
|
||||
case 1: //Sales per man hour
|
||||
formattedNumber = Math.Round(double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
salesPerManHourTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 2: //Salary Percentage
|
||||
formattedNumber = Math.Round(double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
salaryPercentageTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 3: //Salary Dollars
|
||||
formattedNumber = Math.Round(double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
salaryDollarsTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 4: //Supplies
|
||||
formattedNumber = Math.Round(double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
suppliesTextBox.Text = formattedNumber;
|
||||
}
|
||||
break;
|
||||
}
|
||||
informationLabel.Text += @"No cost analysis to display." + Environment.NewLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
salaryDollarsTextBox.Text = costAnalysis.SalaryDollar == 0 ? string.Empty : costAnalysis.SalaryDollar.ToString();
|
||||
salesPerManHourTextBox.Text = costAnalysis.SalesPerManHour == 0 ? string.Empty : costAnalysis.SalesPerManHour.ToString();
|
||||
salaryPercentageTextBox.Text = costAnalysis.SalaryPercentage == 0 ? string.Empty : costAnalysis.SalaryPercentage.ToString();
|
||||
suppliesTextBox.Text = costAnalysis.Supplies == 0 ? string.Empty : costAnalysis.Supplies.ToString();
|
||||
//Set the internal state
|
||||
isCostAnalysisDirtyCheckBox.Text = @"IsCostAnalysisDirty (" + costAnalysis.Id + @")";
|
||||
isCostAnalysisDirtyCheckBox.Tag = costAnalysis.Id;
|
||||
}
|
||||
salesPerManHourTextBox.Enter += StoreBeginningTextBoxValue;
|
||||
salesPerManHourTextBox.Validating += ValidateCostAnalysisValues;
|
||||
@@ -4337,6 +4137,67 @@ namespace AdvertsingProfitControl
|
||||
return adSpecial;
|
||||
}
|
||||
|
||||
private static bool DeleteApcRow(int projectionId, int inventoryId, int actualSalesId)
|
||||
{
|
||||
var result = true;
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
using (var scope = new TransactionScope())
|
||||
{
|
||||
try
|
||||
{
|
||||
var projection = db.Projections.SingleOrDefault(x => x.Id == projectionId);
|
||||
if (projection != null)
|
||||
{
|
||||
db.Projections.Remove(projection);
|
||||
}
|
||||
var inventory = db.Inventories.SingleOrDefault(x => x.Id == inventoryId);
|
||||
if (inventory != null)
|
||||
{
|
||||
db.Inventories.Remove(inventory);
|
||||
}
|
||||
var actualSale = db.ActualSales.SingleOrDefault(x => x.Id == actualSalesId);
|
||||
if (actualSale != null)
|
||||
{
|
||||
db.ActualSales.Remove(actualSale);
|
||||
}
|
||||
db.SaveChanges();
|
||||
scope.Complete();
|
||||
}
|
||||
catch (DbUpdateException e)
|
||||
{
|
||||
LogConsole.WriteToLog(FrmLogConsole.Level.Error, e.Message);
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static bool DeleteInvoiceRow(int invoiceId)
|
||||
{
|
||||
var result = true;
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
using (var scope = new TransactionScope())
|
||||
{
|
||||
try
|
||||
{
|
||||
var invoice = db.Invoices.SingleOrDefault(x => x.Id == invoiceId);
|
||||
if (invoice != null)
|
||||
{
|
||||
db.Invoices.Remove(invoice);
|
||||
}
|
||||
db.SaveChanges();
|
||||
scope.Complete();
|
||||
}
|
||||
catch (DbUpdateException e)
|
||||
{
|
||||
LogConsole.WriteToLog(FrmLogConsole.Level.Error, e.Message);
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void addRecordButton_Click(object sender, EventArgs e)
|
||||
@@ -4377,9 +4238,14 @@ namespace AdvertsingProfitControl
|
||||
|
||||
ClearFormState();
|
||||
addRecordButton.Text = @"Add Record";
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
_currentActiveDate = databaseReader.RetrieveMostRecentDate(databaseTracker.DatabaseConnectionString, _currentActiveDate.Year).AddDays(7);
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var recentDate = db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault(x => x.EndingDate.Year == _currentActiveDate.Year);
|
||||
if (recentDate == null)
|
||||
{
|
||||
errorLabel.Text = @"Bad things...";
|
||||
return;
|
||||
}
|
||||
_currentActiveDate = recentDate.EndingDate.AddDays(7);
|
||||
weekEndingCalendar.SelectionStart = _currentActiveDate;
|
||||
Text = @"Add New Record (Current Date: " + _currentActiveDate.ToShortDateString() + @")";
|
||||
informationLabel.Text = string.Empty;
|
||||
|
||||
@@ -214,24 +214,24 @@ namespace AdvertsingProfitControl
|
||||
//removedCharacterOffset++;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
if (abbreviations.Count > 0)
|
||||
{
|
||||
LogConsole.WriteToLog(FrmLogConsole.Level.Debug, "Detected abbreviation(s) in input string \"" + adItemText + "\":");
|
||||
foreach (var abbreviation in abbreviations)
|
||||
{
|
||||
LogConsole.WriteToLog(FrmLogConsole.Level.Debug, abbreviation);
|
||||
}
|
||||
}
|
||||
else if (words.Count > 0)
|
||||
{
|
||||
LogConsole.WriteToLog(FrmLogConsole.Level.Debug, "Detected words(s) in input string \"" + adItemText + "\":");
|
||||
foreach (var word in words)
|
||||
{
|
||||
LogConsole.WriteToLog(FrmLogConsole.Level.Debug, word);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//#if DEBUG
|
||||
// if (abbreviations.Count > 0)
|
||||
// {
|
||||
// LogConsole.WriteToLog(FrmLogConsole.Level.Debug, "Detected abbreviation(s) in input string \"" + adItemText + "\":");
|
||||
// foreach (var abbreviation in abbreviations)
|
||||
// {
|
||||
// LogConsole.WriteToLog(FrmLogConsole.Level.Debug, abbreviation);
|
||||
// }
|
||||
// }
|
||||
// else if (words.Count > 0)
|
||||
// {
|
||||
// LogConsole.WriteToLog(FrmLogConsole.Level.Debug, "Detected words(s) in input string \"" + adItemText + "\":");
|
||||
// foreach (var word in words)
|
||||
// {
|
||||
// LogConsole.WriteToLog(FrmLogConsole.Level.Debug, word);
|
||||
// }
|
||||
// }
|
||||
//#endif
|
||||
|
||||
return cleanedInputString;
|
||||
}
|
||||
|
||||
-238
@@ -1,238 +0,0 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
partial class FrmManageAdItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmManageAdItems));
|
||||
this.mainLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.adItemListView = new System.Windows.Forms.ListView();
|
||||
this.columnOnePanel = new System.Windows.Forms.Panel();
|
||||
this.addItemLabel = new System.Windows.Forms.Label();
|
||||
this.adItemTextBox = new System.Windows.Forms.TextBox();
|
||||
this.addItemButton = new System.Windows.Forms.Button();
|
||||
this.notificationLabel = new System.Windows.Forms.Label();
|
||||
this.deleteSelectedItem = new System.Windows.Forms.Button();
|
||||
this.adItemFilterComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.letterSelectionLabel = new System.Windows.Forms.Label();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.closeFormFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mainLayoutPanel.SuspendLayout();
|
||||
this.columnOnePanel.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// mainLayoutPanel
|
||||
//
|
||||
this.mainLayoutPanel.ColumnCount = 2;
|
||||
this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 45F));
|
||||
this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 55F));
|
||||
this.mainLayoutPanel.Controls.Add(this.adItemListView, 1, 1);
|
||||
this.mainLayoutPanel.Controls.Add(this.columnOnePanel, 0, 1);
|
||||
this.mainLayoutPanel.Controls.Add(this.menuStrip1, 0, 0);
|
||||
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(4, 4, 4, 4);
|
||||
this.mainLayoutPanel.Name = "mainLayoutPanel";
|
||||
this.mainLayoutPanel.RowCount = 3;
|
||||
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F));
|
||||
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.mainLayoutPanel.Size = new System.Drawing.Size(909, 822);
|
||||
this.mainLayoutPanel.TabIndex = 0;
|
||||
//
|
||||
// adItemListView
|
||||
//
|
||||
this.adItemListView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.adItemListView.Location = new System.Drawing.Point(413, 39);
|
||||
this.adItemListView.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.adItemListView.Name = "adItemListView";
|
||||
this.mainLayoutPanel.SetRowSpan(this.adItemListView, 2);
|
||||
this.adItemListView.Size = new System.Drawing.Size(492, 779);
|
||||
this.adItemListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
|
||||
this.adItemListView.TabIndex = 5;
|
||||
this.adItemListView.UseCompatibleStateImageBehavior = false;
|
||||
this.adItemListView.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// columnOnePanel
|
||||
//
|
||||
this.columnOnePanel.Controls.Add(this.addItemLabel);
|
||||
this.columnOnePanel.Controls.Add(this.adItemTextBox);
|
||||
this.columnOnePanel.Controls.Add(this.addItemButton);
|
||||
this.columnOnePanel.Controls.Add(this.notificationLabel);
|
||||
this.columnOnePanel.Controls.Add(this.deleteSelectedItem);
|
||||
this.columnOnePanel.Controls.Add(this.adItemFilterComboBox);
|
||||
this.columnOnePanel.Controls.Add(this.letterSelectionLabel);
|
||||
this.columnOnePanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.columnOnePanel.Location = new System.Drawing.Point(4, 39);
|
||||
this.columnOnePanel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.columnOnePanel.Name = "columnOnePanel";
|
||||
this.mainLayoutPanel.SetRowSpan(this.columnOnePanel, 2);
|
||||
this.columnOnePanel.Size = new System.Drawing.Size(401, 779);
|
||||
this.columnOnePanel.TabIndex = 1;
|
||||
//
|
||||
// addItemLabel
|
||||
//
|
||||
this.addItemLabel.AutoSize = true;
|
||||
this.addItemLabel.Location = new System.Drawing.Point(35, 378);
|
||||
this.addItemLabel.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.addItemLabel.Name = "addItemLabel";
|
||||
this.addItemLabel.Size = new System.Drawing.Size(140, 25);
|
||||
this.addItemLabel.TabIndex = 6;
|
||||
this.addItemLabel.Text = "Add New Item:";
|
||||
//
|
||||
// adItemTextBox
|
||||
//
|
||||
this.adItemTextBox.Location = new System.Drawing.Point(213, 373);
|
||||
this.adItemTextBox.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
||||
this.adItemTextBox.Name = "adItemTextBox";
|
||||
this.adItemTextBox.Size = new System.Drawing.Size(180, 29);
|
||||
this.adItemTextBox.TabIndex = 2;
|
||||
//
|
||||
// addItemButton
|
||||
//
|
||||
this.addItemButton.Enabled = false;
|
||||
this.addItemButton.Location = new System.Drawing.Point(213, 421);
|
||||
this.addItemButton.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
||||
this.addItemButton.Name = "addItemButton";
|
||||
this.addItemButton.Size = new System.Drawing.Size(183, 59);
|
||||
this.addItemButton.TabIndex = 3;
|
||||
this.addItemButton.Text = "Add Item";
|
||||
this.addItemButton.UseVisualStyleBackColor = true;
|
||||
this.addItemButton.Click += new System.EventHandler(this.addItemButton_Click);
|
||||
//
|
||||
// notificationLabel
|
||||
//
|
||||
this.notificationLabel.AutoSize = true;
|
||||
this.notificationLabel.Location = new System.Drawing.Point(17, 78);
|
||||
this.notificationLabel.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.notificationLabel.Name = "notificationLabel";
|
||||
this.notificationLabel.Size = new System.Drawing.Size(0, 25);
|
||||
this.notificationLabel.TabIndex = 3;
|
||||
//
|
||||
// deleteSelectedItem
|
||||
//
|
||||
this.deleteSelectedItem.Enabled = false;
|
||||
this.deleteSelectedItem.Location = new System.Drawing.Point(17, 702);
|
||||
this.deleteSelectedItem.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.deleteSelectedItem.Name = "deleteSelectedItem";
|
||||
this.deleteSelectedItem.Size = new System.Drawing.Size(220, 61);
|
||||
this.deleteSelectedItem.TabIndex = 4;
|
||||
this.deleteSelectedItem.Text = "Delete Selected Item";
|
||||
this.deleteSelectedItem.UseVisualStyleBackColor = true;
|
||||
this.deleteSelectedItem.Click += new System.EventHandler(this.deleteSelectedItem_Click);
|
||||
//
|
||||
// adItemFilterComboBox
|
||||
//
|
||||
this.adItemFilterComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.adItemFilterComboBox.FormattingEnabled = true;
|
||||
this.adItemFilterComboBox.Location = new System.Drawing.Point(149, 4);
|
||||
this.adItemFilterComboBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.adItemFilterComboBox.Name = "adItemFilterComboBox";
|
||||
this.adItemFilterComboBox.Size = new System.Drawing.Size(246, 32);
|
||||
this.adItemFilterComboBox.TabIndex = 1;
|
||||
//
|
||||
// letterSelectionLabel
|
||||
//
|
||||
this.letterSelectionLabel.AutoSize = true;
|
||||
this.letterSelectionLabel.Location = new System.Drawing.Point(11, 4);
|
||||
this.letterSelectionLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.letterSelectionLabel.Name = "letterSelectionLabel";
|
||||
this.letterSelectionLabel.Size = new System.Drawing.Size(129, 25);
|
||||
this.letterSelectionLabel.TabIndex = 0;
|
||||
this.letterSelectionLabel.Text = "Select a filter:";
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.mainLayoutPanel.SetColumnSpan(this.menuStrip1, 2);
|
||||
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileMainMenu});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2);
|
||||
this.menuStrip1.Size = new System.Drawing.Size(909, 35);
|
||||
this.menuStrip1.TabIndex = 2;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// fileMainMenu
|
||||
//
|
||||
this.fileMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.closeFormFileMainMenu});
|
||||
this.fileMainMenu.Name = "fileMainMenu";
|
||||
this.fileMainMenu.Size = new System.Drawing.Size(56, 31);
|
||||
this.fileMainMenu.Text = "&File";
|
||||
//
|
||||
// closeFormFileMainMenu
|
||||
//
|
||||
this.closeFormFileMainMenu.Name = "closeFormFileMainMenu";
|
||||
this.closeFormFileMainMenu.Size = new System.Drawing.Size(208, 34);
|
||||
this.closeFormFileMainMenu.Text = "&Close Form";
|
||||
this.closeFormFileMainMenu.Click += new System.EventHandler(this.closeFormFileMainMenu_Click);
|
||||
//
|
||||
// FrmManageAdItems
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.ClientSize = new System.Drawing.Size(909, 822);
|
||||
this.Controls.Add(this.mainLayoutPanel);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FrmManageAdItems";
|
||||
this.Text = "Manage Ad Items";
|
||||
this.Load += new System.EventHandler(this.frmManageAdItems_Load);
|
||||
this.mainLayoutPanel.ResumeLayout(false);
|
||||
this.mainLayoutPanel.PerformLayout();
|
||||
this.columnOnePanel.ResumeLayout(false);
|
||||
this.columnOnePanel.PerformLayout();
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TableLayoutPanel mainLayoutPanel;
|
||||
private System.Windows.Forms.ListView adItemListView;
|
||||
private System.Windows.Forms.Panel columnOnePanel;
|
||||
private System.Windows.Forms.ComboBox adItemFilterComboBox;
|
||||
private System.Windows.Forms.Label letterSelectionLabel;
|
||||
private System.Windows.Forms.Button deleteSelectedItem;
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileMainMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem closeFormFileMainMenu;
|
||||
private System.Windows.Forms.Label notificationLabel;
|
||||
private System.Windows.Forms.Label addItemLabel;
|
||||
private System.Windows.Forms.TextBox adItemTextBox;
|
||||
private System.Windows.Forms.Button addItemButton;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user