First version of the Main form that is able to pull all the required data from the SQL database. Holiday detection is disabled for this build. Fixed some bugs with the debug database conversion code. Still missing Ad Special data in the conversion code.
This commit is contained in:
+192
-679
@@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Entity;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Printing;
|
||||
using System.IO;
|
||||
@@ -18,27 +21,41 @@ namespace AdvertsingProfitControl
|
||||
private DateTime _currentActiveDate;
|
||||
private readonly FrmLogConsole _console = FrmLogConsole.GetStaticInstance;
|
||||
private int _LazyPageCounter;
|
||||
private bool isDebug;
|
||||
|
||||
public FrmMain()
|
||||
public FrmMain(bool isDebug)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.isDebug = isDebug;
|
||||
isDebug = true;
|
||||
debugToolStripMenuItem.Visible = isDebug;
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
db.Versions.Count();
|
||||
}
|
||||
|
||||
private void frmMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
monthCalendar.BoldedDates = databaseReader.RetrieveDates(databaseTracker.DatabaseConnectionString).ToArray();
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
monthCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray();
|
||||
ConstructApcDataGridViews();
|
||||
ConstructInvoicesDataGridView();
|
||||
RowParsing.AdSpecialGroups.AddRange(databaseReader.ReturnGroupNameList(databaseTracker.DatabaseConnectionString));
|
||||
var date = databaseReader.RetrieveMostRecentDate(databaseTracker.DatabaseConnectionString);
|
||||
_currentActiveDate = date;
|
||||
LoadDate(date);
|
||||
//RowParsing.AdSpecialGroups.AddRange(databaseReader.ReturnGroupNameList(databaseTracker.DatabaseConnectionString));
|
||||
//Select the most recent date from the database.
|
||||
var recentDate = db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault();
|
||||
if (recentDate != null)
|
||||
{
|
||||
_currentActiveDate = recentDate.EndingDate;
|
||||
LoadDate(recentDate.EndingDate);
|
||||
}
|
||||
monthCalendar.DateChanged += ValidateDateChanged;
|
||||
//projectionsDataGridView.KeyDown += FrmMain_KeyDown;
|
||||
//var margin = new Margins(50, 50, 0, 0);
|
||||
//_printDoc.DefaultPageSettings.Margins = margin;
|
||||
//var adItem = new AdItem {Name = "Celery"};
|
||||
//var db = new AdvertisingProfitControlContext();
|
||||
//db.AdItems.Add(adItem);
|
||||
//db.SaveChanges();
|
||||
|
||||
}
|
||||
|
||||
private void CalculateProfitAnalysis(double shrink = 0.30)
|
||||
@@ -337,8 +354,7 @@ namespace AdvertsingProfitControl
|
||||
|
||||
private void LoadDate(DateTime date)
|
||||
{
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
if (monthCalendar.BoldedDates.Length == 0)
|
||||
{
|
||||
//The database is most likely empty so halt everything.
|
||||
@@ -349,210 +365,62 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
modifyRecordMainMenu.Enabled = true;
|
||||
modifyRecordMainMenu.ToolTipText = @"";
|
||||
var dateId = databaseReader.RetrieveDateIdByDateString(date.ToString("d"),
|
||||
databaseTracker.DatabaseConnectionString);
|
||||
if (dateId == 0)
|
||||
{
|
||||
errorLabel.Text = @"Failed to get the date ID number, aborting load operation." + Environment.NewLine;
|
||||
return;
|
||||
}
|
||||
var dateRecord = db.WeekEndingDates.Single(x => x.EndingDate == date);
|
||||
ClearForm();
|
||||
var projections = databaseReader.ReturnProjectionsTable(dateId, databaseTracker.DatabaseConnectionString);
|
||||
var inventory = databaseReader.ReturnInventoryTable(dateId, databaseTracker.DatabaseConnectionString);
|
||||
var actualSales = databaseReader.ReturnActualSales(dateId, databaseTracker.DatabaseConnectionString);
|
||||
LoadProjectionsTable(projections);
|
||||
LoadInventoryTable(inventory);
|
||||
LoadActualSalesTable(actualSales);
|
||||
var invoices = databaseReader.ReturnInvoiceTable(dateId, databaseTracker.DatabaseConnectionString);
|
||||
LoadInvoices(invoices);
|
||||
var comments = databaseReader.RetrieveComments(int.Parse(dateId.ToString()),
|
||||
databaseTracker.DatabaseConnectionString);
|
||||
if (comments.Count == 2)
|
||||
{
|
||||
commentsTextBox.Text = comments[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
commentMainGroupBox.Text = @"Comments (None to Display)";
|
||||
}
|
||||
var weeklySales = databaseReader.ReturnWeeklySalesFromDateId(dateId,
|
||||
databaseTracker.DatabaseConnectionString);
|
||||
if (weeklySales.Rows.Count == 1)
|
||||
{
|
||||
LoadWeeklySales(weeklySales);
|
||||
}
|
||||
else
|
||||
{
|
||||
weeklySalesGroupBox.Text = @"Weekly Sales (Nothing to Display)";
|
||||
}
|
||||
|
||||
var taxable = databaseReader.ReturnTaxableFromDateId(dateId, databaseTracker.DatabaseConnectionString);
|
||||
if (taxable.Rows.Count == 1)
|
||||
{
|
||||
LoadTaxable(taxable);
|
||||
}
|
||||
else
|
||||
{
|
||||
taxableGroupBox.Text = @"Taxable (Nothing to Display)";
|
||||
}
|
||||
var costAnalysis = databaseReader.ReturnCostAnalysis(dateId,
|
||||
databaseTracker.DatabaseConnectionString);
|
||||
if (costAnalysis.Rows.Count == 1)
|
||||
{
|
||||
LoadCostAnalysis(costAnalysis);
|
||||
}
|
||||
else
|
||||
{
|
||||
costAnalysisGroupBox.Text = @"Cost Analysis (Nothing to Display)";
|
||||
}
|
||||
LoadProjectionsTable(dateRecord);
|
||||
LoadInventoryTable(dateRecord);
|
||||
LoadActualSalesTable(dateRecord);
|
||||
LoadInvoices(dateRecord);
|
||||
var note = db.Notes.Single(x => x.FkDateId == dateRecord.Id);
|
||||
commentsTextBox.Text = note.Remark;
|
||||
LoadWeeklySales(dateRecord);
|
||||
LoadTaxable(dateRecord);
|
||||
LoadCostAnalysis(dateRecord);
|
||||
CalculateProfitAnalysis();
|
||||
CalculateGrossProfit();
|
||||
monthCalendar.BoldedDates = databaseReader.RetrieveDates(databaseTracker.DatabaseConnectionString).ToArray();
|
||||
monthCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray();
|
||||
monthCalendar.SelectionStart = date;
|
||||
dateTimeGroupBox.Text = @"Loaded " + date.ToString("d");
|
||||
}
|
||||
|
||||
private void LoadProjectionsTable(DataTable projections)
|
||||
private void LoadProjectionsTable(WeekEndingDate dateRecord)
|
||||
{
|
||||
if (projections.Rows.Count == 0) return;
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var adSpecialIndex = -1;
|
||||
double totalSales = 0;
|
||||
double totalProfitReturn = 0;
|
||||
for (var rowIndex = 0; rowIndex < projections.Rows.Count; rowIndex++)
|
||||
decimal totalSales = 0;
|
||||
decimal totalProfitReturn = 0;
|
||||
var projections = db.Projections.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
||||
|
||||
foreach (var p in projections)
|
||||
{
|
||||
var newRow = new DataGridViewRow();
|
||||
for (var cellIndex = 1; cellIndex < projections.Rows[rowIndex].ItemArray.Length; cellIndex++)
|
||||
projectionsDataGridView.Rows.Add();
|
||||
var index = projectionsDataGridView.RowCount - 1;
|
||||
projectionsDataGridView.Rows[index].Cells[0].Value = p.AdItem.Name;
|
||||
projectionsDataGridView.Rows[index].Cells[1].Value = p.Sold;
|
||||
projectionsDataGridView.Rows[index].Cells[2].Value = p.SalePrice;
|
||||
projectionsDataGridView.Rows[index].Cells[3].Value = $@"{p.TotalSales:N2}";
|
||||
if (p.TotalSales != null) totalSales += (decimal)p.TotalSales;
|
||||
projectionsDataGridView.Rows[index].Cells[4].Value = $@"{p.Cost:N2}";
|
||||
projectionsDataGridView.Rows[index].Cells[5].Value = $@"{p.ProfitReturn:N2}";
|
||||
projectionsDataGridView.Rows[index].Cells[6].Value = $@"{p.TotalProfitReturn:N2}";
|
||||
if (p.TotalProfitReturn != null) totalProfitReturn += (decimal)p.TotalProfitReturn;
|
||||
if (p.RowAttribute == 1)
|
||||
{
|
||||
//ID and Ad Item.
|
||||
if (cellIndex == 1)
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell
|
||||
{
|
||||
Value = projections.Rows[rowIndex].ItemArray[cellIndex].ToString()
|
||||
};
|
||||
newRow.Cells.Add(cell);
|
||||
continue;
|
||||
}
|
||||
//String allowed columns
|
||||
if (cellIndex > 1 && cellIndex <= 3)
|
||||
{
|
||||
if (projections.Rows[rowIndex].ItemArray[cellIndex].ToString() != string.Empty)
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell
|
||||
{
|
||||
Value = projections.Rows[rowIndex].ItemArray[cellIndex].ToString()
|
||||
};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//If the cell is meant to be summed into a totals roll add its contents to the total.
|
||||
//If the cell is the total sales cell..
|
||||
if (cellIndex == 4)
|
||||
{
|
||||
if (projections.Rows[rowIndex].ItemArray[cellIndex].ToString() != string.Empty &&
|
||||
Math.Abs(double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString())) > 0)
|
||||
{
|
||||
totalSales += double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString());
|
||||
var cell = new DataGridViewTextBoxCell
|
||||
{
|
||||
Value =
|
||||
double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString())
|
||||
.ToString("N2")
|
||||
};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//or the total profit return cell.
|
||||
if (cellIndex == 7)
|
||||
{
|
||||
if (projections.Rows[rowIndex].ItemArray[cellIndex].ToString() != string.Empty &&
|
||||
Math.Abs(double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString())) > 0)
|
||||
{
|
||||
totalProfitReturn += double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString());
|
||||
var cell = new DataGridViewTextBoxCell
|
||||
{
|
||||
Value =
|
||||
double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString())
|
||||
.ToString("N2")
|
||||
};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//Everything in between the ad item cell and the row attribute cells.
|
||||
if (cellIndex > 3 && cellIndex < 8)
|
||||
{
|
||||
if (Math.Abs(double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString())) > 0)
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell
|
||||
{
|
||||
Value =
|
||||
double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString())
|
||||
.ToString("N2")
|
||||
};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//Check the attribute cell.
|
||||
if (cellIndex == 8)
|
||||
{
|
||||
var rowAttribute = int.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString());
|
||||
switch (rowAttribute)
|
||||
{
|
||||
case 1:
|
||||
//Header row
|
||||
newRow.DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
|
||||
break;
|
||||
case 2:
|
||||
//Member Row
|
||||
newRow.DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//Check the group it is part of if any.
|
||||
if (cellIndex != 9) continue;
|
||||
//Check to see if this row belongs to an ad special group.
|
||||
if (projections.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0") continue;
|
||||
//If the ad special index is not set, then create the ad special row with the human friendly group name.
|
||||
if (adSpecialIndex != -1) continue;
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var groupName =
|
||||
databaseReader.ReturnGroupNameFromGroupId(
|
||||
projections.Rows[rowIndex].ItemArray[cellIndex].ToString(),
|
||||
databaseTracker.DatabaseConnectionString);
|
||||
var adSpecialRow = new DataGridViewRow();
|
||||
projectionsDataGridView.Rows.Add(adSpecialRow);
|
||||
projectionsDataGridView.Rows[rowIndex].Cells[3].Value = groupName;
|
||||
projectionsDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor =
|
||||
ApplicationColors.AdSpecial;
|
||||
adSpecialIndex = rowIndex;
|
||||
projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
|
||||
}
|
||||
else if (p.RowAttribute == 2)
|
||||
{
|
||||
projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
|
||||
}
|
||||
|
||||
if (p.FkAdSpecialId != 0 && adSpecialIndex == -1)
|
||||
{
|
||||
//TODO: Fix null reference when no object is found.
|
||||
adSpecialIndex = index;
|
||||
projectionsDataGridView.Rows.Insert(index, 1);
|
||||
projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
|
||||
projectionsDataGridView.Rows[index].Cells[3].Value = db.AdSpecials.Single(x => x.Id == p.FkAdSpecialId).Name;
|
||||
}
|
||||
projectionsDataGridView.Rows.Add(newRow);
|
||||
}
|
||||
//Now add the totals row.
|
||||
var totalsRow = new DataGridViewRow();
|
||||
@@ -576,215 +444,78 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadInventoryTable(DataTable inventory)
|
||||
private void LoadInventoryTable(WeekEndingDate dateRecord)
|
||||
{
|
||||
if (inventory.Rows.Count == 0) return;
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var adSpecialIndex = -1;
|
||||
for (var rowIndex = 0; rowIndex < inventory.Rows.Count; rowIndex++)
|
||||
var inventories = db.Inventories.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
||||
|
||||
foreach (var i in inventories)
|
||||
{
|
||||
var newRow = new DataGridViewRow();
|
||||
for (var cellIndex = 1; cellIndex < inventory.Rows[rowIndex].ItemArray.Length; cellIndex++)
|
||||
inventoryDataGridView.Rows.Add();
|
||||
var index = inventoryDataGridView.RowCount - 1;
|
||||
inventoryDataGridView.Rows[index].Cells[0].Value = i.AdItem.Name;
|
||||
inventoryDataGridView.Rows[index].Cells[1].Value = i.BeginningInventory;
|
||||
inventoryDataGridView.Rows[index].Cells[2].Value = i.Recieved;
|
||||
inventoryDataGridView.Rows[index].Cells[3].Value = i.TotalInventory;
|
||||
inventoryDataGridView.Rows[index].Cells[4].Value = i.EndingInventory;
|
||||
if (i.RowAttribute == 1)
|
||||
{
|
||||
//String allowed columns
|
||||
if (cellIndex < 6)
|
||||
{
|
||||
if (inventory.Rows[rowIndex].ItemArray[cellIndex].ToString() != string.Empty)
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell
|
||||
{
|
||||
Value = inventory.Rows[rowIndex].ItemArray[cellIndex].ToString()
|
||||
};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//Check the attribute cell.
|
||||
if (cellIndex == 6)
|
||||
{
|
||||
var rowAttribute = int.Parse(inventory.Rows[rowIndex].ItemArray[cellIndex].ToString());
|
||||
switch (rowAttribute)
|
||||
{
|
||||
case 1:
|
||||
//Header row
|
||||
newRow.DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
|
||||
break;
|
||||
case 2:
|
||||
//Member Row
|
||||
newRow.DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//Check the group it is part of if any.
|
||||
if (cellIndex != 7) continue;
|
||||
//Check to see if this row belongs to an ad special group.
|
||||
if (inventory.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0") continue;
|
||||
//If the ad special index is not set, then create the ad special row with the human friendly group name.
|
||||
if (adSpecialIndex != -1) continue;
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var groupName =
|
||||
databaseReader.ReturnGroupNameFromGroupId(
|
||||
inventory.Rows[rowIndex].ItemArray[cellIndex].ToString(),
|
||||
databaseTracker.DatabaseConnectionString);
|
||||
var adSpecialRow = new DataGridViewRow();
|
||||
inventoryDataGridView.Rows.Add(adSpecialRow);
|
||||
inventoryDataGridView.Rows[rowIndex].Cells[2].Value = groupName;
|
||||
inventoryDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor =
|
||||
ApplicationColors.AdSpecial;
|
||||
adSpecialIndex = rowIndex;
|
||||
inventoryDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
|
||||
}
|
||||
else if (i.RowAttribute == 2)
|
||||
{
|
||||
inventoryDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
|
||||
}
|
||||
|
||||
if (i.FkAdSpecialId != 0 && adSpecialIndex == -1)
|
||||
{
|
||||
adSpecialIndex = index;
|
||||
inventoryDataGridView.Rows.Insert(index, 1);
|
||||
inventoryDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
|
||||
inventoryDataGridView.Rows[index].Cells[2].Value = db.AdSpecials.Single(x => x.Id == i.FkAdSpecialId).Name;
|
||||
}
|
||||
inventoryDataGridView.Rows.Add(newRow);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadActualSalesTable(DataTable actualSales)
|
||||
private void LoadActualSalesTable(WeekEndingDate dateRecord)
|
||||
{
|
||||
if (actualSales.Rows.Count == 0) return;
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var adSpecialIndex = -1;
|
||||
double totalSales = 0;
|
||||
double totalProfitReturn = 0;
|
||||
for (var rowIndex = 0; rowIndex < actualSales.Rows.Count; rowIndex++)
|
||||
decimal totalSales = 0;
|
||||
decimal totalProfitReturn = 0;
|
||||
var actualSales = db.ActualSales.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
||||
|
||||
foreach (var a in actualSales)
|
||||
{
|
||||
var newRow = new DataGridViewRow();
|
||||
for (var cellIndex = 1; cellIndex < actualSales.Rows[rowIndex].ItemArray.Length; cellIndex++)
|
||||
actualSalesDataGridView.Rows.Add();
|
||||
var index = actualSalesDataGridView.RowCount - 1;
|
||||
actualSalesDataGridView.Rows[index].Cells[0].Value = a.AdItem.Name;
|
||||
actualSalesDataGridView.Rows[index].Cells[1].Value = a.Sold;
|
||||
actualSalesDataGridView.Rows[index].Cells[2].Value = a.SalePrice;
|
||||
actualSalesDataGridView.Rows[index].Cells[3].Value = $@"{a.TotalSales:N2}";
|
||||
if (a.TotalSales != null) totalSales += (decimal)a.TotalSales;
|
||||
actualSalesDataGridView.Rows[index].Cells[4].Value = $@"{a.Cost:N2}";
|
||||
actualSalesDataGridView.Rows[index].Cells[5].Value = $@"{a.ProfitReturn:N2}";
|
||||
actualSalesDataGridView.Rows[index].Cells[6].Value = $@"{a.TotalProfitReturn:N2}";
|
||||
if (a.TotalProfitReturn != null) totalProfitReturn += (decimal)a.TotalProfitReturn;
|
||||
if (a.RowAttribute == 1)
|
||||
{
|
||||
//ID and Ad Item.
|
||||
if (cellIndex == 1)
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell
|
||||
{
|
||||
Value = actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString()
|
||||
};
|
||||
newRow.Cells.Add(cell);
|
||||
continue;
|
||||
}
|
||||
//String allowed columns
|
||||
if (cellIndex > 1 && cellIndex <= 3)
|
||||
{
|
||||
if (actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString() != string.Empty)
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell
|
||||
{
|
||||
Value = actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString()
|
||||
};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//If the cell is meant to be summed into a totals roll add its contents to the total.
|
||||
//If the cell is the total sales cell..
|
||||
if (cellIndex == 4)
|
||||
{
|
||||
if (actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString() != string.Empty &&
|
||||
Math.Abs(double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString())) > 0)
|
||||
{
|
||||
totalSales += double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString());
|
||||
var cell = new DataGridViewTextBoxCell
|
||||
{
|
||||
Value =
|
||||
double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString())
|
||||
.ToString("N2")
|
||||
};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//or the total profit return cell.
|
||||
if (cellIndex == 7)
|
||||
{
|
||||
if (actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString() != string.Empty &&
|
||||
Math.Abs(double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString())) > 0)
|
||||
{
|
||||
totalProfitReturn += double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString());
|
||||
var cell = new DataGridViewTextBoxCell
|
||||
{
|
||||
Value =
|
||||
double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString())
|
||||
.ToString("N2")
|
||||
};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//Everything in between the ad item cell and the row attribute cells.
|
||||
if (cellIndex > 3 && cellIndex < 8)
|
||||
{
|
||||
if (Math.Abs(double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString())) > 0)
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell
|
||||
{
|
||||
Value =
|
||||
double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString())
|
||||
.ToString("N2")
|
||||
};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
|
||||
newRow.Cells.Add(cell);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//Check the attribute cell.
|
||||
if (cellIndex == 8)
|
||||
{
|
||||
var rowAttribute = int.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString());
|
||||
switch (rowAttribute)
|
||||
{
|
||||
case 1:
|
||||
//Header row
|
||||
newRow.DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
|
||||
break;
|
||||
case 2:
|
||||
//Member Row
|
||||
newRow.DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
//Check the group it is part of if any.
|
||||
if (cellIndex != 9) continue;
|
||||
//Check to see if this row belongs to an ad special group.
|
||||
if (actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0") continue;
|
||||
//If the ad special index is not set, then create the ad special row with the human friendly group name.
|
||||
if (adSpecialIndex != -1) continue;
|
||||
var databaseTracker = new DatabaseTracker();
|
||||
var databaseReader = new DatabaseReader();
|
||||
var groupName =
|
||||
databaseReader.ReturnGroupNameFromGroupId(
|
||||
actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString(),
|
||||
databaseTracker.DatabaseConnectionString);
|
||||
var adSpecialRow = new DataGridViewRow();
|
||||
actualSalesDataGridView.Rows.Add(adSpecialRow);
|
||||
actualSalesDataGridView.Rows[rowIndex].Cells[3].Value = groupName;
|
||||
actualSalesDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor =
|
||||
ApplicationColors.AdSpecial;
|
||||
adSpecialIndex = rowIndex;
|
||||
actualSalesDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
|
||||
}
|
||||
actualSalesDataGridView.Rows.Add(newRow);
|
||||
}
|
||||
else if (a.RowAttribute == 2)
|
||||
{
|
||||
actualSalesDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
|
||||
}
|
||||
|
||||
if (a.FkAdSpecialId != 0 && adSpecialIndex == -1)
|
||||
{
|
||||
adSpecialIndex = index;
|
||||
actualSalesDataGridView.Rows.Insert(index, 1);
|
||||
actualSalesDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
|
||||
actualSalesDataGridView.Rows[index].Cells[3].Value = db.AdSpecials.Single(x => x.Id == a.FkAdSpecialId).Name;
|
||||
}
|
||||
}
|
||||
//Now add the totals row.
|
||||
var totalsRow = new DataGridViewRow();
|
||||
actualSalesDataGridView.Rows.Add(totalsRow);
|
||||
@@ -807,50 +538,23 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadInvoices(DataTable invoices)
|
||||
private void LoadInvoices(WeekEndingDate dateRecord)
|
||||
{
|
||||
if (invoices.Rows.Count == 0) return;
|
||||
_totalInvoicePurchases = 0;
|
||||
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);
|
||||
|
||||
foreach (var invoice in invoices)
|
||||
{
|
||||
var row = new DataGridViewRow();
|
||||
for (var cellIndex = 1; cellIndex < invoices.Rows[rowIndex].ItemArray.Length; cellIndex++)
|
||||
{
|
||||
var cell = new DataGridViewTextBoxCell();
|
||||
switch (cellIndex)
|
||||
{
|
||||
//Apply formatting to the invoice date to trim the 12:00:00 time stamp.
|
||||
case 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.
|
||||
case 4:
|
||||
var netAmountAtCost = double.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString());
|
||||
if (netAmountAtCost.ToString("N2") != "0.00")
|
||||
{
|
||||
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);
|
||||
break;
|
||||
default:
|
||||
//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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
invoicesDataGridView.Rows.Add(row);
|
||||
invoicesDataGridView.Rows.Add();
|
||||
var index = invoicesDataGridView.RowCount - 1;
|
||||
invoicesDataGridView.Rows[index].Cells[0].Value = invoice.InvoiceDate.ToString("d");
|
||||
invoicesDataGridView.Rows[index].Cells[1].Value = invoice.Supplier.Name;
|
||||
invoicesDataGridView.Rows[index].Cells[2].Value = invoice.InvoiceNumber;
|
||||
invoicesDataGridView.Rows[index].Cells[3].Value = $@"{invoice.InvoiceNetAmountAtCost:N2}";
|
||||
invoicesDataGridView.Rows[index].Cells[4].Value = $@"{invoice.InvoiceNetAmount:N2}";
|
||||
if (invoice.InvoiceNetAmount != null) _totalInvoicePurchases += (double)invoice.InvoiceNetAmount;
|
||||
invoicesDataGridView.Rows[index].Cells[5].Value = invoice.InvoiceNote;
|
||||
}
|
||||
//Add the total purchases row to the invoice table.
|
||||
var totalPurchaesRow = new DataGridViewRow();
|
||||
@@ -862,252 +566,61 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadWeeklySales(DataTable weeklySales)
|
||||
private void LoadWeeklySales(WeekEndingDate dateRecord)
|
||||
{
|
||||
//Clear the department sales and prepare to add up a total.
|
||||
_departmentSales = 0;
|
||||
//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 = 1; cellIndex < weeklySales.Rows[0].ItemArray.Length; cellIndex++)
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var weeklySales = db.WeeklySales.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
||||
foreach (var sale in weeklySales)
|
||||
{
|
||||
double dollarAmount;
|
||||
switch (cellIndex)
|
||||
{
|
||||
case 1: //Sunday
|
||||
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
_departmentSales += dollarAmount;
|
||||
sundayWeeklySalesLabel.Text = @"Sunday: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
sundayWeeklySalesLabel.Text = @"Sunday: " + CheckForHoliday(DayOfWeek.Sunday);
|
||||
}
|
||||
break;
|
||||
case 2: //Monday
|
||||
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
_departmentSales += dollarAmount;
|
||||
mondayWeeklySalesLabel.Text = @"Monday: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
mondayWeeklySalesLabel.Text = @"Monday: " + CheckForHoliday(DayOfWeek.Monday);
|
||||
}
|
||||
break;
|
||||
case 3: //Tuesday
|
||||
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
_departmentSales += dollarAmount;
|
||||
tuesadayWeeklySalesLabel.Text = @"Tuesday: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
tuesadayWeeklySalesLabel.Text = @"Tuesday: " + CheckForHoliday(DayOfWeek.Tuesday);
|
||||
}
|
||||
break;
|
||||
case 4: //Wednesday
|
||||
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
_departmentSales += dollarAmount;
|
||||
wednesdayWeeklySalesLabel.Text = @"Wednesday: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
wednesdayWeeklySalesLabel.Text = @"Wednesday: " + CheckForHoliday(DayOfWeek.Wednesday);
|
||||
}
|
||||
break;
|
||||
case 5: //Thursday
|
||||
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
_departmentSales += dollarAmount;
|
||||
thursdayWeeklySalesLabel.Text = @"Thursday: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
thursdayWeeklySalesLabel.Text = @"Thursday: " + CheckForHoliday(DayOfWeek.Thursday);
|
||||
}
|
||||
break;
|
||||
case 6: //Friday
|
||||
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
_departmentSales += dollarAmount;
|
||||
fridayWeeklySalesLabel.Text = @"Friday: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
fridayWeeklySalesLabel.Text = @"Friday: " + CheckForHoliday(DayOfWeek.Friday);
|
||||
}
|
||||
break;
|
||||
case 7: //Saturday
|
||||
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
_departmentSales += dollarAmount;
|
||||
saturdayWeeklySalesLabel.Text = @"Saturday: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
saturdayWeeklySalesLabel.Text = @"Saturday: " + CheckForHoliday(DayOfWeek.Saturday);
|
||||
}
|
||||
break;
|
||||
case 8: //Total Sales
|
||||
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
|
||||
if (dollarAmount.ToString("N2") != "0.00")
|
||||
{
|
||||
totalWeeklySalesLabel.Text = @"Total Sales: $" + dollarAmount.ToString("N2");
|
||||
}
|
||||
else
|
||||
{
|
||||
totalWeeklySalesLabel.Text = @"Total Sales: ";
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (sale.Sunday != null) _departmentSales += (double)sale.Sunday;
|
||||
sundayWeeklySalesLabel.Text = @"Sunday: " + $@"{sale.Sunday:c}";
|
||||
if (sale.Monday != null) _departmentSales += (double)sale.Monday;
|
||||
mondayWeeklySalesLabel.Text = @"Monday: " + $@"{sale.Monday:c}";
|
||||
if (sale.Tuesday != null) _departmentSales += (double)sale.Tuesday;
|
||||
tuesadayWeeklySalesLabel.Text = @"Tuesday: " + $@"{sale.Tuesday:c}";
|
||||
if (sale.Wednesday != null) _departmentSales += (double)sale.Wednesday;
|
||||
wednesdayWeeklySalesLabel.Text = @"Wednesday: " + $@"{sale.Wednesday:c}";
|
||||
if (sale.Thursday != null) _departmentSales += (double)sale.Thursday;
|
||||
thursdayWeeklySalesLabel.Text = @"Thursday: " + $@"{sale.Thursday:c}";
|
||||
if (sale.Friday != null) _departmentSales += (double)sale.Friday;
|
||||
fridayWeeklySalesLabel.Text = @"Friday: " + $@"{sale.Friday:c}";
|
||||
if (sale.Saturday != null) _departmentSales += (double)sale.Saturday;
|
||||
saturdayWeeklySalesLabel.Text = @"Saturday: " + $@"{sale.Saturday:c}";
|
||||
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}";
|
||||
totalTaxableLabel.Text = @"Total: " + $@"{taxable.Total:c}";
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadTaxable(DataTable taxable)
|
||||
private void LoadCostAnalysis(WeekEndingDate dateRecord)
|
||||
{
|
||||
//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 = 1; cellIndex < taxable.Rows[0].ItemArray.Length; cellIndex++)
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var analysis = db.CostAnalysis.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
||||
foreach (var a in analysis)
|
||||
{
|
||||
string formattedNumber;
|
||||
switch (cellIndex)
|
||||
{
|
||||
case 1: //Sunday
|
||||
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
sundayTaxableLabel.Text = @"Sunday: $" + formattedNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
sundayTaxableLabel.Text = @"Sunday: " + CheckForHoliday(DayOfWeek.Sunday);
|
||||
}
|
||||
break;
|
||||
case 2: //Monday
|
||||
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
mondayTaxableLabel.Text = @"Monday: $" + formattedNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
mondayTaxableLabel.Text = @"Monday: " + CheckForHoliday(DayOfWeek.Monday);
|
||||
}
|
||||
break;
|
||||
case 3: //Tuesday
|
||||
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
tuesdayTaxableLabel.Text = @"Tuesday: $" + formattedNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
tuesdayTaxableLabel.Text = @"Tuesday: " + CheckForHoliday(DayOfWeek.Tuesday);
|
||||
}
|
||||
break;
|
||||
case 4: //Wednesday
|
||||
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
wednesdayTaxableLabel.Text = @"Wednesday: $" + formattedNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
wednesdayTaxableLabel.Text = @"Wednesday: " + CheckForHoliday(DayOfWeek.Wednesday);
|
||||
}
|
||||
break;
|
||||
case 5: //Thursday
|
||||
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
thursdayTaxableLabel.Text = @"Thursday: $" + formattedNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
thursdayTaxableLabel.Text = @"Thursday: " + CheckForHoliday(DayOfWeek.Thursday);
|
||||
}
|
||||
break;
|
||||
case 6: //Friday
|
||||
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
fridayTaxableLabel.Text = @"Friday: $" + formattedNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
fridayTaxableLabel.Text = @"Friday: " + CheckForHoliday(DayOfWeek.Friday);
|
||||
}
|
||||
break;
|
||||
case 7: //Saturday
|
||||
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
saturdayTaxableLabel.Text = @"Saturday: $" + formattedNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
saturdayTaxableLabel.Text = @"Saturday: " + CheckForHoliday(DayOfWeek.Saturday);
|
||||
}
|
||||
break;
|
||||
case 8: //Total Taxable
|
||||
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
totalTaxableLabel.Text = @"Total Taxable: $" + formattedNumber;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadCostAnalysis(DataTable costAnalysis)
|
||||
{
|
||||
//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 = 1; cellIndex < costAnalysis.Rows[0].ItemArray.Length; cellIndex++)
|
||||
{
|
||||
string formattedNumber;
|
||||
switch (cellIndex)
|
||||
{
|
||||
case 1: //Sales per man hour
|
||||
formattedNumber = double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
salesPerManHourLabel.Text = @"Sales Per Man Hour: $" + formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 2: //Salary Percentage
|
||||
formattedNumber = double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()).ToString("P2");
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
salaryPercentageLabel.Text = @"Salary Percentage: " + formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 3: //Salary Dollars
|
||||
formattedNumber = double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
salaryDollarsLabel.Text = @"Salary Dollars: $" + formattedNumber;
|
||||
}
|
||||
break;
|
||||
case 4: //Supplies
|
||||
formattedNumber = double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
|
||||
if (formattedNumber != "0.00")
|
||||
{
|
||||
suppliesLabel.Text = @"Supplies: $" + formattedNumber;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
salesPerManHourLabel.Text = @"Sales Per Man Hour: " + $@"{a.SalesPerManHour:c}";
|
||||
salaryPercentageLabel.Text = @"Salary Percentage: " + $@"{a.SalaryPercentage:p}";
|
||||
salaryDollarsLabel.Text = @"Salary Dollars: " + $@"{a.SalaryDollar:c}";
|
||||
suppliesLabel.Text = @"Supplies: " + $@"{a.Supplies}";
|
||||
}
|
||||
}
|
||||
|
||||
private string CheckForHoliday(DayOfWeek day)
|
||||
@@ -1197,14 +710,14 @@ namespace AdvertsingProfitControl
|
||||
departmentSalesLabel.Text = @"Department Sales: ";
|
||||
salesProducedLabel.Text = @"Sales Produced By Ad Items (A):";
|
||||
remainingSalesLabel.Text = @"Remaining Sales:";
|
||||
totalProfitFromAdItemsLabel.Text = @"Total Profit Return" + Environment.NewLine + @" From Ad Items (B): ";
|
||||
totalProfitReturnFromRemaingLabel.Text = @"Total Profit Return" + Environment.NewLine + @" 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" + Environment.NewLine + @" Department Expense: ";
|
||||
grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Text = @"Estimated Weekly" + Environment.NewLine + @"Department Expense: ";
|
||||
}
|
||||
|
||||
private void debugToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user