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

This commit is contained in:
2021-01-28 19:58:37 -06:00
parent 665f4784e4
commit 75061c9d51
19 changed files with 904 additions and 2171 deletions
+212 -323
View File
@@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
@@ -13,54 +11,27 @@ namespace AdvertsingProfitControl
{
public partial class FrmMain : Form
{
private double _SalesProducedByAdItems = 0;
private double _TotalProfitReturnFromAdItems = 0;
private double _gActualTotaSalesCalculatedTotal = 0;
private double _gActualTotalProfitReturnCalculatedTotal = 0;
private double _gCostOfSalesCalculatedTotal = 0;
private double _departmentSales = 0;
private List<string> _gDateStringCollection = new List<string>();
readonly FrmLogConsole _console = FrmLogConsole.GetStaticInstance;
private int _LazyPageCounter = 0;
public FrmMain()
{
InitializeComponent();
//Set the maximum and minimum sizes for the form.
//MaximumSize = new Size(1200, 650);
//MinimumSize = new Size(1000, 550);
MaximumSize = new Size(1200, 650);
MinimumSize = new Size(1000, 550);
}
private void frmMain_Load(object sender, EventArgs e)
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var versionControl = new DatabaseVersionControl();
var version = versionControl.GetDatabaseVerionNumber(databaseTracker.DatabaseConnectionString);
if(version == "0.3.0.0")
{
MessageBox.Show("An older version of the APC database has been detected.\nAdvertising Profit Control " + Application.ProductVersion + " will now attempt to update it.", "Outdated Database Detected");
string versionNumber = "";
if (versionControl.UpdateVersionPointFive(databaseTracker.DatabaseConnectionString, out versionNumber))
{
MessageBox.Show("The database has been successfully upgraded to version " + versionNumber + ".\nA back up of the old database has been made called APCDatabase.bak in the same location as the current database.", "Half Baked Code For The Win");
}
}
RowParsing.AdSpecialGroups.AddRange(databaseReader.ReturnGroupNameList(databaseTracker.DatabaseConnectionString));
FillDateSuggestionComboBoxes();
BuildAndFillDataGridTables();
CalculateProfitAnalysis();
CalculateGrossProfit();
projectedSalesMainDataGrid.KeyDown += FrmMain_KeyDown;
//var margin = new Margins(50, 50, 0, 0);
//_printDoc.DefaultPageSettings.Margins = margin;
}
private void FrmMain_KeyDown(object sender, KeyEventArgs e)
{
if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.Up)
{
MessageBox.Show("My message");
}
}
private void UpdateDataGridViewInformation(object sender, EventArgs e)
@@ -104,37 +75,155 @@ namespace AdvertsingProfitControl
//Now check to make sure there were no errors grabbing the ID, IF there were return.
if (dateId == "0") return;
//Clear the class global variables to prevents calculation mishaps.
_SalesProducedByAdItems = 0;
_TotalProfitReturnFromAdItems = 0;
_gActualTotaSalesCalculatedTotal = 0;
_gActualTotalProfitReturnCalculatedTotal = 0;
_gCostOfSalesCalculatedTotal = 0;
//Clear all DataGridViews since the date supplied is valid and in the database.
projectedSalesMainDataGrid.DataSource = null;
projectedSalesMainDataGrid.Columns.Clear();
inventoryDataGridView.DataSource = null;
inventoryDataGridView.Columns.Clear();
actualSalesMainDataGidView.DataSource = null;
actualSalesMainDataGidView.Columns.Clear();
suppliersDataGridView.DataSource = null;
weeklySalesDataGridView.DataSource = null;
var indexOfAdSpecialRow = -1;
var regexGroupCategoryparser = new Regex(@"^(\d)?\|\d");
//Begin by grabbing the Projections table
var tempTable = dataBaseReader.ReturnProjectionsTable(dateId, databaseTracker.DatabaseConnectionString);
if (tempTable.Rows.Count > 0)
{
BuildSalesDataGridViews(projectedSalesMainDataGrid, tempTable);
projectedSalesMainDataGrid.DataSource = SumSalesTable(tempTable);
var adCategory = "";
for (var i = 0; i < projectedSalesMainDataGrid.Rows.Count; i++)
{
if ((string)projectedSalesMainDataGrid.Rows[i].Cells[7].EditedFormattedValue == "1")
{
projectedSalesMainDataGrid.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
}else if ((string) projectedSalesMainDataGrid.Rows[i].Cells[7].EditedFormattedValue == "2")
{
projectedSalesMainDataGrid.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
}
else if (
regexGroupCategoryparser.IsMatch(
(string) projectedSalesMainDataGrid.Rows[i].Cells[7].EditedFormattedValue))
{
string[] spam = new string[2];
spam = ParseAdSpecialRows(projectedSalesMainDataGrid.Rows[i].Cells[7].EditedFormattedValue.ToString());
if (spam.Length > 1)
{
adCategory = spam[1];
}
else
{
adCategory = spam[0];
}
if (indexOfAdSpecialRow == -1)
{
indexOfAdSpecialRow = i;
}
if (spam[0] == "1")
{
projectedSalesMainDataGrid.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
}else if (spam[0] == "2")
{
projectedSalesMainDataGrid.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
}
}
}
var dataGridViewColumn = projectedSalesMainDataGrid.Columns["FK_GroupID"];
if (dataGridViewColumn != null)
dataGridViewColumn.Visible = false;
}
//Grabbing the Inventory table
tempTable = dataBaseReader.ReturnInventoryTable(dateId, databaseTracker.DatabaseConnectionString);
if (tempTable.Rows.Count > 0)
{
BuildInventoryDataGridView(inventoryDataGridView, tempTable);
inventoryDataGridView.DataSource = tempTable;
string adCategory = "";
for (var i = 0; i < inventoryDataGridView.Rows.Count; i++)
{
if ((string)inventoryDataGridView.Rows[i].Cells[5].EditedFormattedValue == "1")
{
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
}
else if ((string)inventoryDataGridView.Rows[i].Cells[5].EditedFormattedValue == "2")
{
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
}
else if (
regexGroupCategoryparser.IsMatch(
(string)inventoryDataGridView.Rows[i].Cells[5].EditedFormattedValue))
{
string[] spam = new string[2];
spam = ParseAdSpecialRows(inventoryDataGridView.Rows[i].Cells[5].EditedFormattedValue.ToString());
if (spam.Length > 1)
{
adCategory = spam[1];
}
else
{
adCategory = spam[0];
}
if (spam[0] == "1")
{
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
}
else if (spam[0] == "2")
{
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
}
}
}
var dataGridViewColumn = inventoryDataGridView.Columns["FK_GroupID"];
if (dataGridViewColumn != null)
dataGridViewColumn.Visible = false;
}
//And the Actual Sales table
tempTable = dataBaseReader.ReturnActualSales(dateId, databaseTracker.DatabaseConnectionString);
if (tempTable.Rows.Count > 0)
{
BuildSalesDataGridViews(actualSalesMainDataGidView, tempTable);
actualSalesMainDataGidView.DataSource = SumSalesTable(tempTable);
var adCategory = "";
for (var i = 0; i < actualSalesMainDataGidView.Rows.Count; i++)
{
if ((string)actualSalesMainDataGidView.Rows[i].Cells[7].EditedFormattedValue == "1")
{
actualSalesMainDataGidView.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
}
else if ((string)actualSalesMainDataGidView.Rows[i].Cells[7].EditedFormattedValue == "2")
{
actualSalesMainDataGidView.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
}
else if (
regexGroupCategoryparser.IsMatch(
(string)actualSalesMainDataGidView.Rows[i].Cells[7].EditedFormattedValue))
{
string[] spam = new string[2];
spam = ParseAdSpecialRows(actualSalesMainDataGidView.Rows[i].Cells[7].EditedFormattedValue.ToString());
if (spam.Length > 1)
{
adCategory = spam[1];
}
else
{
adCategory = spam[0];
}
if (spam[0] == "1")
{
actualSalesMainDataGidView.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
}
else if (spam[0] == "2")
{
actualSalesMainDataGidView.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
}
}
}
var year = actualSalesMainDataGidView.Columns["FK_GroupID"];
if (year != null)
year.Visible = false;
}
//Next the Invoices table
@@ -156,7 +245,7 @@ namespace AdvertsingProfitControl
private void CalculateProfitAnalysis(double shrink = 0.30)
{
if (Math.Abs(_SalesProducedByAdItems) < 1 || Math.Abs(_TotalProfitReturnFromAdItems) < 1)
if (Math.Abs(_gActualTotaSalesCalculatedTotal) < 1 || Math.Abs(_gActualTotalProfitReturnCalculatedTotal) < 1)
{
//Clear the labels...
if (weeklySalesDataGridView.Rows.Count == 0 || weeklySalesDataGridView.Rows[0].Cells[7].EditedFormattedValue.ToString() == "0.0000")
@@ -165,14 +254,14 @@ namespace AdvertsingProfitControl
departmentSalesLabel.ForeColor = Color.Red;
}
if (_SalesProducedByAdItems == 0)
if (_gActualTotaSalesCalculatedTotal == 0)
{
salesProducedLabel.Text = "Sales Produced By Ad Items (A): No Values to Total.";
salesProducedLabel.ForeColor = Color.Red;
}
remainingSalesLabel.Text = "Remaining Sales: ";
if (_TotalProfitReturnFromAdItems == 0)
if (_gActualTotalProfitReturnCalculatedTotal == 0)
{
totalProfitFromAdItemsLabel.Text = "Total Profit Return From Ad Items (B): No Values to Total.";
totalProfitFromAdItemsLabel.ForeColor = Color.Red;
@@ -182,196 +271,31 @@ namespace AdvertsingProfitControl
totalProfitReturnLabel.Text = "Total Profit Return: ";
return;
}
double.TryParse(weeklySalesDataGridView.Rows[0].Cells[7].EditedFormattedValue.ToString(), out _departmentSales);
double departmentSales = 0;
Double.TryParse(weeklySalesDataGridView.Rows[0].Cells[7].EditedFormattedValue.ToString(), out departmentSales);
//Since there are department sales, change the label's color to make sure it doesn't appear as an error.
departmentSalesLabel.ForeColor = Color.Black;
departmentSalesLabel.Text = "Department Sales: " + _departmentSales.ToString("C");
departmentSalesLabel.Text = "Department Sales: " + departmentSales.ToString("C");
//Assume that the sales produced is larger then zero (0).
salesProducedLabel.ForeColor = Color.Black;
salesProducedLabel.Text = "Sales Produced By Ad Items (A): " + _SalesProducedByAdItems.ToString("C");
salesProducedLabel.Text = "Sales Produced By Ad Items (A): " + _gActualTotaSalesCalculatedTotal.ToString("C");
double remainingSales = _departmentSales - _SalesProducedByAdItems;
double remainingSales = departmentSales - _gActualTotaSalesCalculatedTotal;
remainingSalesLabel.Text = "Remaining Sales: " + remainingSales.ToString("C");
//Again assume the total profit return is larger then zero (0).
totalProfitFromAdItemsLabel.ForeColor = Color.Black;
totalProfitFromAdItemsLabel.Text = "Total Profit Return From Ad Items (B): " + _TotalProfitReturnFromAdItems.ToString("C");
totalProfitFromAdItemsLabel.Text = "Total Profit Return From Ad Items (B): " + _gActualTotalProfitReturnCalculatedTotal.ToString("C");
//Shrink is being used as a place holder for Cross Profit % which is obtained by dividing gActualTotalProfitReturnCalculatedTotal by the department weekly retail sales.
double totalProfitReturnFromRemainingSales = shrink * remainingSales;
//
totalProfitReturnFromRemaingLabel.Text = "Total Profit Return From Remaining Sales: " + totalProfitReturnFromRemainingSales.ToString("C");
double totalProfitReturn = _TotalProfitReturnFromAdItems + totalProfitReturnFromRemainingSales;
double totalProfitReturn = _gActualTotalProfitReturnCalculatedTotal + totalProfitReturnFromRemainingSales;
totalProfitReturnLabel.Text = "Total Profit Return: " + totalProfitReturn.ToString("C");
}
private void BuildSalesDataGridViews(DataGridView dataGridView, DataTable table)
private void CalculateCostOfSales()
{
var adSpecialIndex = -1;
double totalSales = 0;
double totalProfitReturn = 0;
foreach (DataColumn column in table.Columns)
{
var dataGridViewColumn = new DataGridViewColumn()
{
HeaderText = column.ColumnName,
CellTemplate = new DataGridViewTextBoxCell()
};
if (dataGridViewColumn.HeaderText.Contains("Projection"))
{
dataGridViewColumn.HeaderText = dataGridViewColumn.HeaderText.Replace("Projection", "");
}
else if (dataGridViewColumn.HeaderText.Contains("Actual"))
{
dataGridViewColumn.HeaderText = dataGridViewColumn.HeaderText.Replace("Actual", "");
}
if (dataGridViewColumn.HeaderText == "FK_GroupID" || dataGridViewColumn.HeaderText == "RowAttribute")
{
dataGridViewColumn.Visible = false;
}
dataGridViewColumn.HeaderText = TextFormat.AddSpacesToSentence(dataGridViewColumn.HeaderText, false);
dataGridView.Columns.Add(dataGridViewColumn);
}
for (var i = 0; i < table.Rows.Count; i++)
{
var row = new DataGridViewRow();
//Checks for the group, if any, the row or rows is/are part of.
if (table.Rows[i][8].ToString() != "" &&
int.Parse(table.Rows[i][8].ToString()) != 0 && adSpecialIndex == -1)
{
adSpecialIndex = i;
var adSpecialRow = new DataGridViewRow();
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var groupName = databaseReader.ReturnGroupNameFromGroupId(table.Rows[i][8].ToString(), databaseTracker.DatabaseConnectionString);
adSpecialRow.DefaultCellStyle.BackColor = Color.DarkGray;
dataGridView.Rows.Add(adSpecialRow);
dataGridView.Rows[i].Cells[0].Value = groupName;
}
//Checks for row attribute
if (table.Rows[i][7].ToString() != "")
{
//The seventh column contains the row's attribute if any.
var rowAttribute = int.Parse(table.Rows[i][7].ToString());
if (rowAttribute == 1)
{
row.DefaultCellStyle.BackColor = Color.LightGray;
}
else if (rowAttribute == 2)
{
row.DefaultCellStyle.BackColor = Color.LightBlue;
}
foreach (var dataCell in table.Rows[i].ItemArray.Select(cell => new DataGridViewTextBoxCell { Value = cell }))
{
row.Cells.Add(dataCell);
}
dataGridView.Rows.Add(row);
}
else
{
dataGridView.Rows.Add(table.Rows[i].ItemArray);
}
//Check for values in the Total Sales and Total Profit Return columns
double tempOut = 0;
if (double.TryParse(table.Rows[i][3].ToString(), out tempOut))
{
if (tempOut >= 0)
{
totalSales += tempOut;
}
}
if (double.TryParse(table.Rows[i][6].ToString(), out tempOut))
{
if (tempOut >= 0)
{
totalProfitReturn += tempOut;
}
}
}
var totalsRow = new object[9];
totalsRow[0] = "Totals";
totalsRow[3] = totalSales;
totalsRow[6] = totalProfitReturn;
dataGridView.Rows.Add(totalsRow);
if (dataGridView.Name == "actualSalesMainDataGidView")
{
_SalesProducedByAdItems = totalSales;
_TotalProfitReturnFromAdItems = totalProfitReturn;
}
}
private void BuildInventoryDataGridView(DataGridView dataGridView, DataTable table)
{
var lastAdSpecialIndex = -1;
for (var columnIndex = 0; columnIndex < table.Columns.Count; columnIndex++)
{
var dataGridViewColumn = new DataGridViewColumn
{
Name = table.Columns[columnIndex].ColumnName,
CellTemplate = new DataGridViewTextBoxCell()
};
var columnHeaderText = table.Columns[columnIndex].ColumnName;
columnHeaderText = TextFormat.AddSpacesToSentence(columnHeaderText, false);
//Make the row attribute column invisible.
if (table.Columns[columnIndex].ColumnName == "RowAttribute")
{
dataGridViewColumn.Visible = false;
}
//Make any columns with a foreign key invisible.
if (table.Columns[columnIndex].ColumnName.Contains("FK"))
{
dataGridViewColumn.Visible = false;
}
dataGridViewColumn.HeaderText = columnHeaderText;
dataGridView.Columns.Add(dataGridViewColumn);
}
for (var rowIndex = 0; rowIndex < table.Rows.Count; rowIndex++)
{
var row = new DataGridViewRow();
if (table.Rows[rowIndex][6].ToString() != "" && int.Parse(table.Rows[rowIndex][6].ToString()) != 0 && lastAdSpecialIndex == -1)
{
lastAdSpecialIndex = rowIndex;
var adSpecialRow = new DataGridViewRow();
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var groupName = databaseReader.ReturnGroupNameFromGroupId(table.Rows[rowIndex][6].ToString(), databaseTracker.DatabaseConnectionString);
adSpecialRow.DefaultCellStyle.BackColor = Color.DarkGray;
dataGridView.Rows.Add(adSpecialRow);
dataGridView.Rows[rowIndex].Cells[0].Value = groupName;
}
if (table.Rows[rowIndex][5].ToString() != "")
{
//The fifth column contains the row's attribute if any.
var rowAttribute = int.Parse(table.Rows[rowIndex][5].ToString());
if (rowAttribute == 1)
{
row.DefaultCellStyle.BackColor = Color.LightGray;
}
else if (rowAttribute == 2)
{
row.DefaultCellStyle.BackColor = Color.LightBlue;
}
foreach (var dataCell in table.Rows[rowIndex].ItemArray.Select(cell => new DataGridViewTextBoxCell { Value = cell }))
{
row.Cells.Add(dataCell);
}
dataGridView.Rows.Add(row);
}
else
{
dataGridView.Rows.Add(table.Rows[rowIndex].ItemArray);
}
}
//?
}
private void CalculateGrossProfit()
@@ -410,6 +334,48 @@ namespace AdvertsingProfitControl
CalculateGrossProfit();
}
/// <summary>
/// Appends a new "Totals" row to the end of the DataTable that is passed in
/// and sums up the Total Sales and Total Profit Return columns as well as
/// storing the Total Sales and Total Profit Return in their respective
/// class wide variables for use with other functions.
/// </summary>
/// <param name="table">The sales table to be summed up.</param>
/// <returns></returns>
private DataTable SumSalesTable(DataTable table)
{
//IF the table is null OR has an invalid column count then return.
if (table == null || table.Columns.Count < 7) return table;
//Both Projections and Actual tables have the Total Sales and Total Profit Return columns in the same position,
//indexes three (3) and six (6) respectively.
double totalSalesSum = 0;
double totalProfitReturnSum = 0;
for (var i = 0; i < table.Rows.Count; i++)
{
if (table.Rows[i][3].ToString() != "")
{
totalSalesSum += Convert.ToDouble(table.Rows[i][3]);
}
if (table.Rows[i][6].ToString() != "")
{
totalProfitReturnSum += Convert.ToDouble(table.Rows[i][6]);
}
}
//Once the totals have been calculated store them in the class wide variables so other methods can use them.
_gActualTotaSalesCalculatedTotal = totalSalesSum;
_gActualTotalProfitReturnCalculatedTotal = totalProfitReturnSum;
//Create an object array to store the summed values and add them at the end to the table before returning it.
object[] rowContents = new object[table.Columns.Count];
rowContents[0] = "Total";
rowContents[3] = totalSalesSum;
rowContents[6] = totalProfitReturnSum;
table.Rows.Add(rowContents);
return table;
}
/// <summary>
/// Appends a new "Totals" row to the end of the Invoice table that is passed in
/// and sums up the Net Cost of Invoices column as well as storing the total Costs of Sales
@@ -644,6 +610,34 @@ namespace AdvertsingProfitControl
CalculateGrossProfit();
}
private string[] ParseAdSpecialRows(string groupIdentifier)
{
var groupCategory = new string[2];
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var patternForOnlyPipeAndAdSpecial = new Regex(@"^\|\d{1}");
var patternForBothNumbersOnPipe = new Regex(@"^\d{1}\|\d{1}");
if (patternForOnlyPipeAndAdSpecial.IsMatch(groupIdentifier))
{
groupCategory[0] = groupIdentifier;
if (groupIdentifier[0].ToString() != "")
{
groupCategory[0] = groupCategory[0].Replace("|", "");
groupCategory[0] = databaseReader.ReturnGroupNameFromGroupId(groupCategory[0], databaseTracker.DatabaseConnectionString);
}
}else if (patternForBothNumbersOnPipe.IsMatch(groupIdentifier))
{
string[] temp = groupIdentifier.Split('|');
groupCategory[0] = temp[0];
groupCategory[1] = temp[1];
groupCategory[1] = databaseReader.ReturnGroupNameFromGroupId(groupCategory[1], databaseTracker.DatabaseConnectionString);
}
return groupCategory;
}
private void adSpecialKeyWordsToolsMainMenu_Click(object sender, EventArgs e)
{
var keyWordRegister = new FrmAdSpecialRegister();
@@ -668,111 +662,6 @@ namespace AdvertsingProfitControl
CalculateProfitAnalysis();
CalculateGrossProfit();
}
private void manageItemsToolsMainMenu_Click(object sender, EventArgs e)
{
var adItemManager = new FrmManageAdItems();
adItemManager.ShowDialog();
}
private void dbVersionHelpMainMenu_Click(object sender, EventArgs e)
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var version = databaseReader.GetDatabaseVersion(databaseTracker.DatabaseConnectionString);
if (version != "0.0.0.0")
{
MessageBox.Show("The current database's version is " + version + ".", "Database Version Number");
}
}
private void PrintPage(object sender, PrintPageEventArgs e)
{
Bitmap bitMap;
if (_LazyPageCounter == 0)
{
bitMap = new Bitmap(Application.StartupPath + "\\FrontPage.png");
}
else
{
bitMap = new Bitmap(Application.StartupPath + "\\BackPage.png");
}
var rect = e.MarginBounds;
if ((double)bitMap.Width / (double)bitMap.Height > (double)rect.Width / (double)rect.Height) // image is wider
{
rect.Height = (int)((double)bitMap.Height / (double)bitMap.Width * (double)rect.Width);
}
else
{
rect.Width = (int)((double)bitMap.Width / (double)bitMap.Height * (double)rect.Height);
}
if (_LazyPageCounter == 0)
{
e.Graphics.DrawImage(bitMap, new Rectangle(0, 25, 850, 1050));
_LazyPageCounter++;
e.HasMorePages = true;
}
else
{
e.Graphics.DrawImage(bitMap, new Rectangle(0, 0, 850, 1100));
_LazyPageCounter = 0;
e.HasMorePages = false;
}
}
private void DisplayPrintPreview(object sender, EventArgs e)
{
//Build and render the front and back forms of the document.
var test = new FrontPageGenerator();
var backPageTest = new BackPageGenerator();
var printTestPage = new PrintDocument();
var printDialog = new PrintPreviewDialog();
if (!usePreRenderedFilesCheckbox.Checked)
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var dateId =
databaseReader.RetrieveDateIdByDateString(
monthComboBox.SelectedItem + "/" + dayComboBox.SelectedItem + "/" + yearComboBox.SelectedItem,
databaseTracker.DatabaseConnectionString);
double remaingingSales = _departmentSales - _SalesProducedByAdItems;
double totalProfitReturnFromReminaingSales = remaingingSales*.3;
double totalProfitReturn = _TotalProfitReturnFromAdItems + totalProfitReturnFromReminaingSales;
test.BuildFormFrontCompressedLayout(dateId, _departmentSales, _SalesProducedByAdItems, remaingingSales,
_TotalProfitReturnFromAdItems, totalProfitReturnFromReminaingSales, totalProfitReturn,
commentsTextBox.Text);
test.RenderHtmlToImage();
backPageTest.GenerateWeeklyInventoryControlPage(dateId);
backPageTest.RenderHtmlToImage();
}
else
{
if (File.Exists(Application.StartupPath + "\\" + "FrontPage.html") &&
File.Exists(Application.StartupPath + "\\" + "Backpage.html"))
{
test.RenderHtmlToImage();
backPageTest.RenderHtmlToImage();
}
}
//var margin = new Margins(50, 50, 0, 0);
//printDoc.DefaultPageSettings.Margins = margin;
printTestPage.PrintPage += PrintPage;
printDialog.Document = printTestPage;
printDialog.ShowDialog();
printDialog.Document = new PrintDocument();
}
private void newFormTestToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = new NewAddRecord();
form.ShowDialog();
}
}
//http://stackoverflow.com/questions/487661/how-do-i-suspend-painting-for-a-control-and-its-children