Fixed a bug in the row parsing engine related to ad special rows. Move all data from the old format to the new format. Updated the main form's UI.
This commit is contained in:
@@ -16,7 +16,7 @@ namespace AdvertsingProfitControl
|
||||
private double _totalInvoicePurchases; //Total Purchases
|
||||
private double _departmentSales; //weekly sales total
|
||||
private DateTime _currentActiveDate;
|
||||
readonly FrmLogConsole _console = FrmLogConsole.GetStaticInstance;
|
||||
private readonly FrmLogConsole _console = FrmLogConsole.GetStaticInstance;
|
||||
private int _LazyPageCounter;
|
||||
|
||||
public FrmMain()
|
||||
@@ -33,7 +33,6 @@ namespace AdvertsingProfitControl
|
||||
ConstructInvoicesDataGridView();
|
||||
RowParsing.AdSpecialGroups.AddRange(databaseReader.ReturnGroupNameList(databaseTracker.DatabaseConnectionString));
|
||||
var date = databaseReader.RetrieveMostRecentDate(databaseTracker.DatabaseConnectionString);
|
||||
monthCalendar.SelectionStart = date;
|
||||
_currentActiveDate = date;
|
||||
LoadDate(date);
|
||||
monthCalendar.DateChanged += ValidateDateChanged;
|
||||
@@ -47,7 +46,7 @@ namespace AdvertsingProfitControl
|
||||
if (actualSalesDataGridView.Rows.Count == 0)
|
||||
{
|
||||
salesProducedLabel.Text = @"Sales Produced By Ad Items (A): No Data";
|
||||
totalProfitFromAdItemsLabel.Text = @"Total Profit Return From Ad Items (B): No Data";
|
||||
totalProfitFromAdItemsLabel.Text = @"Total Profit Return " + Environment.NewLine + @" From Ad Items (B): No Data";
|
||||
if (Math.Abs(_departmentSales) < 1)
|
||||
{
|
||||
departmentSalesLabel.Text = @"Department Sales: No Data";
|
||||
@@ -76,7 +75,7 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
if (Math.Abs(_totalProfitReturnFromAdItems) < 1)
|
||||
{
|
||||
totalProfitFromAdItemsLabel.Text = @"Total Profit Return From Ad Items (B): No Data";
|
||||
totalProfitFromAdItemsLabel.Text = @"Total Profit Return " + Environment.NewLine + @"From Ad Items (B): No Data";
|
||||
incompleteData = true;
|
||||
}
|
||||
if (Math.Abs(_departmentSales) < 1)
|
||||
@@ -94,11 +93,11 @@ namespace AdvertsingProfitControl
|
||||
var remainingSales = _departmentSales - _salesProducedByAdItems;
|
||||
remainingSalesLabel.Text = @"Remaining Sales: " + remainingSales.ToString("C");
|
||||
//Again assume the total profit return is larger then zero (0).
|
||||
totalProfitFromAdItemsLabel.Text = @"Total Profit Return From Ad Items (B): " + _totalProfitReturnFromAdItems.ToString("C");
|
||||
totalProfitFromAdItemsLabel.Text = @"Total Profit Return" + Environment.NewLine + @" From Ad Items (B): " + _totalProfitReturnFromAdItems.ToString("C");
|
||||
//Shrink is being used as a place holder for Cross Profit % which is obtained by dividing the total profit return from the department weekly retail sales.
|
||||
var totalProfitReturnFromRemainingSales = shrink*remainingSales;
|
||||
//
|
||||
totalProfitReturnFromRemaingLabel.Text = @"Total Profit Return From Remaining Sales: " + totalProfitReturnFromRemainingSales.ToString("C");
|
||||
totalProfitReturnFromRemaingLabel.Text = @"Total Profit Return" + Environment.NewLine + @" From Remaining Sales: " + totalProfitReturnFromRemainingSales.ToString("C");
|
||||
var totalProfitReturn = _totalProfitReturnFromAdItems + totalProfitReturnFromRemainingSales;
|
||||
totalProfitReturnLabel.Text = @"Total Profit Return: " + totalProfitReturn.ToString("C");
|
||||
}
|
||||
@@ -125,8 +124,15 @@ namespace AdvertsingProfitControl
|
||||
|
||||
private void addRecordToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var form = new NewAddRecord();
|
||||
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);
|
||||
}
|
||||
|
||||
private void showHideConsoleHelpMainMenu_Click(object sender, EventArgs e)
|
||||
@@ -153,6 +159,8 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
var form = new NewModifyRecord(monthCalendar.SelectionStart);
|
||||
form.ShowDialog();
|
||||
//On return reload the date that was just modified by the modify record form.
|
||||
LoadDate(monthCalendar.SelectionStart);
|
||||
}
|
||||
|
||||
private void manageItemsToolsMainMenu_Click(object sender, EventArgs e)
|
||||
@@ -253,20 +261,6 @@ namespace AdvertsingProfitControl
|
||||
printDialog.Document = new PrintDocument();
|
||||
}
|
||||
|
||||
private void newFormTestToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = new NewAddRecord();
|
||||
form.ShowDialog();
|
||||
|
||||
}
|
||||
|
||||
private void newModifyRecordToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var date = monthCalendar.SelectionStart;
|
||||
var form = new NewModifyRecord(date);
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
public enum FormRoll
|
||||
{
|
||||
AddRecords = 0,
|
||||
@@ -339,7 +333,7 @@ namespace AdvertsingProfitControl
|
||||
string[] invoicesColumnNames =
|
||||
{
|
||||
"InvoiceDate", "Supplier", "InvoiceNumber", "InvoiceNetAmountAtCost",
|
||||
"InvoiceNetAmount", "InvoiceNote"
|
||||
"InvoiceNetAmountExtendedRetail", "InvoiceNote"
|
||||
};
|
||||
|
||||
foreach (var name in invoicesColumnNames)
|
||||
@@ -428,6 +422,8 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
CalculateProfitAnalysis();
|
||||
CalculateGrossProfit();
|
||||
monthCalendar.BoldedDates = databaseReader.RetrieveDates(databaseTracker.DatabaseConnectionString).ToArray();
|
||||
monthCalendar.SelectionStart = date;
|
||||
dateTimeGroupBox.Text = @"Loaded " + date.ToString("d");
|
||||
}
|
||||
|
||||
@@ -440,7 +436,7 @@ namespace AdvertsingProfitControl
|
||||
for (var rowIndex = 0; rowIndex < projections.Rows.Count; rowIndex++)
|
||||
{
|
||||
var newRow = new DataGridViewRow();
|
||||
for (var cellIndex = 0; cellIndex < projections.Rows[rowIndex].ItemArray.Length; cellIndex++)
|
||||
for (var cellIndex = 1; cellIndex < projections.Rows[rowIndex].ItemArray.Length; cellIndex++)
|
||||
{
|
||||
//ID and Ad Item.
|
||||
if (cellIndex == 1)
|
||||
@@ -671,7 +667,7 @@ namespace AdvertsingProfitControl
|
||||
for (var rowIndex = 0; rowIndex < actualSales.Rows.Count; rowIndex++)
|
||||
{
|
||||
var newRow = new DataGridViewRow();
|
||||
for (var cellIndex = 0; cellIndex < actualSales.Rows[rowIndex].ItemArray.Length; cellIndex++)
|
||||
for (var cellIndex = 1; cellIndex < actualSales.Rows[rowIndex].ItemArray.Length; cellIndex++)
|
||||
{
|
||||
//ID and Ad Item.
|
||||
if (cellIndex == 1)
|
||||
@@ -849,15 +845,15 @@ namespace AdvertsingProfitControl
|
||||
var netAmountAtCost = double.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString());
|
||||
if (netAmountAtCost.ToString("N2") != "0.00")
|
||||
{
|
||||
_totalInvoicePurchases += netAmountAtCost;
|
||||
cell.Value = netAmountAtCost;
|
||||
cell.Value = netAmountAtCost.ToString("N2");
|
||||
}
|
||||
row.Cells.Add(cell);
|
||||
break;
|
||||
case 5:
|
||||
var netAmoundExtendedRetail = double.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString());
|
||||
if (netAmoundExtendedRetail.ToString("N2") != "0.00")
|
||||
{
|
||||
{
|
||||
_totalInvoicePurchases += netAmoundExtendedRetail;
|
||||
cell.Value = netAmoundExtendedRetail.ToString("N2");
|
||||
}
|
||||
row.Cells.Add(cell);
|
||||
@@ -897,7 +893,7 @@ namespace AdvertsingProfitControl
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
_departmentSales += dollarAmount;
|
||||
sundayWeeklySalesLabel.Text = @"Sunday: $" + dollarAmount;
|
||||
sundayWeeklySalesLabel.Text = @"Sunday: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -909,7 +905,7 @@ namespace AdvertsingProfitControl
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
_departmentSales += dollarAmount;
|
||||
mondayWeeklySalesLabel.Text = @"Monday: $" + dollarAmount;
|
||||
mondayWeeklySalesLabel.Text = @"Monday: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -921,7 +917,7 @@ namespace AdvertsingProfitControl
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
_departmentSales += dollarAmount;
|
||||
tuesadayWeeklySalesLabel.Text = @"Tuesday: $" + dollarAmount;
|
||||
tuesadayWeeklySalesLabel.Text = @"Tuesday: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -933,7 +929,7 @@ namespace AdvertsingProfitControl
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
_departmentSales += dollarAmount;
|
||||
wednesdayWeeklySalesLabel.Text = @"Wednesday: $" + dollarAmount;
|
||||
wednesdayWeeklySalesLabel.Text = @"Wednesday: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -945,7 +941,7 @@ namespace AdvertsingProfitControl
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
_departmentSales += dollarAmount;
|
||||
thursdayWeeklySalesLabel.Text = @"Thursday: $" + dollarAmount;
|
||||
thursdayWeeklySalesLabel.Text = @"Thursday: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -957,7 +953,7 @@ namespace AdvertsingProfitControl
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
_departmentSales += dollarAmount;
|
||||
fridayWeeklySalesLabel.Text = @"Friday: $" + dollarAmount;
|
||||
fridayWeeklySalesLabel.Text = @"Friday: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -969,7 +965,7 @@ namespace AdvertsingProfitControl
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
_departmentSales += dollarAmount;
|
||||
saturdayWeeklySalesLabel.Text = @"Saturday: $" + dollarAmount;
|
||||
saturdayWeeklySalesLabel.Text = @"Saturday: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -980,7 +976,7 @@ namespace AdvertsingProfitControl
|
||||
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
totalWeeklySalesLabel.Text = @"Total Sales: $" + dollarAmount;
|
||||
totalWeeklySalesLabel.Text = @"Total Sales: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1165,7 +1161,8 @@ namespace AdvertsingProfitControl
|
||||
switch (holiday)
|
||||
{
|
||||
case Holidays.Thanksgiving:
|
||||
case Holidays.Christmas:
|
||||
case Holidays.Christmas:
|
||||
case Holidays.NewYearsDay:
|
||||
holidayText = @"Closed for " + TextFormat.AddSpacesToSentence(holiday.ToString(), false);
|
||||
break;
|
||||
}
|
||||
@@ -1215,20 +1212,28 @@ namespace AdvertsingProfitControl
|
||||
departmentSalesLabel.Text = @"Department Sales: ";
|
||||
salesProducedLabel.Text = @"Sales Produced By Ad Items (A):";
|
||||
remainingSalesLabel.Text = @"Remaining Sales:";
|
||||
totalProfitFromAdItemsLabel.Text = @"Total Profit Return From Ad Items (B): ";
|
||||
totalProfitReturnFromRemaingLabel.Text = @"Total Profit Return From Remaining Sales: ";
|
||||
totalProfitFromAdItemsLabel.Text = @"Total Profit Return" + Environment.NewLine + @" From Ad Items (B): ";
|
||||
totalProfitReturnFromRemaingLabel.Text = @"Total Profit Return" + Environment.NewLine + @" From Remaining Sales: ";
|
||||
totalProfitReturnLabel.Text = @"Total Profit Return: ";
|
||||
grossProfitTotalSales.Text = @"Total Sales:";
|
||||
grossProfitLessCostOfSales.Text = @"Less Cost of Sales: ";
|
||||
grossProfitDollarGrossProfitLabel.Text = @"Dollar Gross Profit: ";
|
||||
perfectGrossProfitLabel.Text = @"Percent Gross Profit: ";
|
||||
grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Text = @"Estimated Weekly Department Expense: ";
|
||||
grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Text = @"Estimated Weekly" + Environment.NewLine + @" Department Expense: ";
|
||||
}
|
||||
|
||||
private void debugToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = new DebugDatabaseConverter();
|
||||
form.ShowDialog();
|
||||
RefreshDateListing();
|
||||
}
|
||||
|
||||
private void RefreshDateListing()
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
monthCalendar.BoldedDates = databaseReader.RetrieveDates(databaseTracker.DatabaseConnectionString).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user