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:
2017-01-23 00:26:46 -06:00
parent 9f045175ed
commit 739c4c179d
11 changed files with 228 additions and 158 deletions
Binary file not shown.
@@ -32,12 +32,6 @@ namespace AdvertsingProfitControl
isMemberColumn = (int)InventoryTableColumns.IsMemberRow; isMemberColumn = (int)InventoryTableColumns.IsMemberRow;
isDirtyColumn = (int) InventoryTableColumns.IsDirty; isDirtyColumn = (int) InventoryTableColumns.IsDirty;
} }
//If the current row is an Ad Special Row, the color code it and return as nothing further needs to be done.
if (parser.CheckForGroupKeyWord(dataGridView.Rows[startingIndex].Cells[(int) SalesTableColumns.AdItem].EditedFormattedValue.ToString()) != "NoGroupFound")
{
dataGridView.Rows[startingIndex].DefaultCellStyle.BackColor = Color.Silver;
return;
}
//Spin through the dataGridView rows starting at the row that fired the event. //Spin through the dataGridView rows starting at the row that fired the event.
for (var i = startingIndex; i < (dataGridView.RowCount - 1); i++) for (var i = startingIndex; i < (dataGridView.RowCount - 1); i++)
{ {
@@ -261,12 +255,13 @@ namespace AdvertsingProfitControl
else if (rowStatus == RowAttribute.AdSpecialRow) else if (rowStatus == RowAttribute.AdSpecialRow)
{ {
if(i == 0) return; if(i == 0) return;
dataGridView.Rows[startingIndex].DefaultCellStyle.BackColor = Color.Silver;
//Get the previous row's attribute. //Get the previous row's attribute.
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i - 1]); rowStatus = parser.GetRowAttribute(dataGridView.Rows[i - 1]);
if (rowStatus == RowAttribute.HeaderRow) if (rowStatus == RowAttribute.HeaderRow)
{ {
//Check to see if the previous row sees itself as a header row, if so mark it dirty. //Check to see if the previous row sees itself as a header row, if so mark it dirty.
if (!(bool)dataGridView.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue) if ((bool)dataGridView.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue)
{ {
dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true; dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit; dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
+3 -3
View File
@@ -168,7 +168,7 @@ namespace AdvertsingProfitControl
var dates = new List<DateTime>(); var dates = new List<DateTime>();
var oleDbCommand = new OleDbCommand var oleDbCommand = new OleDbCommand
{ {
CommandText = "SELECT EndOfWeekDate FROM WeekEnding" CommandText = "SELECT WeekEnding.EndOfWeekDate FROM WeekEnding"
}; };
var connection = new OleDbConnection(connectionString); var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection; oleDbCommand.Connection = connection;
@@ -414,9 +414,9 @@ namespace AdvertsingProfitControl
} }
} }
} }
catch (OleDbException e) finally
{ {
connection.Close();
} }
} }
} }
+22 -14
View File
@@ -477,27 +477,35 @@ namespace AdvertsingProfitControl
oleDbCommand.Parameters.AddWithValue("ID", int.Parse(table.Rows[i].Cells[(int)InvoiceTableColumns.Id].EditedFormattedValue.ToString())); oleDbCommand.Parameters.AddWithValue("ID", int.Parse(table.Rows[i].Cells[(int)InvoiceTableColumns.Id].EditedFormattedValue.ToString()));
oleDbCommand.ExecuteNonQuery(); oleDbCommand.ExecuteNonQuery();
oleDbCommand.Parameters.Clear(); oleDbCommand.Parameters.Clear();
rowsAdded.Add(i);
} }
//Row index is only used to keep track of what row failed to update. //Row index is only used to keep track of what row failed to update.
lastRowProcessed = i + 1; lastRowProcessed = i + 1;
} }
oleDbTransaction.Commit(); oleDbTransaction.Commit();
foreach (DataGridViewRow row in table.Rows) //Spin through the collection and update the affected rows.
foreach (var rowIndex in rowsAdded)
{ {
if(row.IsNewRow) continue; //Only reset the IsDirty value to false since the updates when through.
if (!rowsAdded.Contains(row.Index)) continue; table.Rows[rowIndex].Cells[(int)InvoiceTableColumns.IsDirty].Value = false;
var supplierId = RetrieveSupplierId(row.Cells[(int)InvoiceTableColumns.Supplier].EditedFormattedValue.ToString()); table.Rows[rowIndex].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
var invoiceIdNumber =
RetrieveInvoiceId(
row.Cells[(int)InvoiceTableColumns.InvoiceDate].EditedFormattedValue
.ToString(),
long.Parse(
row.Cells[(int)InvoiceTableColumns.InvoiceNumber].EditedFormattedValue
.ToString()), supplierId, dateId);
row.Cells[(int)InvoiceTableColumns.Id].Value = invoiceIdNumber;
row.Cells[(int)InvoiceTableColumns.IsDirty].Value = false;
row.HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
} }
//foreach (DataGridViewRow row in table.Rows)
//{
// if(row.IsNewRow) continue;
// if (!rowsAdded.Contains(row.Index)) continue;
// var supplierId = RetrieveSupplierId(row.Cells[(int)InvoiceTableColumns.Supplier].EditedFormattedValue.ToString());
// var invoiceIdNumber =
// RetrieveInvoiceId(
// row.Cells[(int)InvoiceTableColumns.InvoiceDate].EditedFormattedValue
// .ToString(),
// long.Parse(
// row.Cells[(int)InvoiceTableColumns.InvoiceNumber].EditedFormattedValue
// .ToString()), supplierId, dateId);
// row.Cells[(int)InvoiceTableColumns.Id].Value = invoiceIdNumber;
// row.Cells[(int)InvoiceTableColumns.IsDirty].Value = false;
// row.HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
//}
table.RefreshEdit(); table.RefreshEdit();
//Set the status. //Set the status.
status.SetStatus(WritingOperationStatus.InsertionSuccessful); status.SetStatus(WritingOperationStatus.InsertionSuccessful);
@@ -64,6 +64,7 @@ namespace AdvertsingProfitControl
} }
} }
} }
connection.Close();
} }
foreach (var date in dates) foreach (var date in dates)
@@ -99,15 +100,14 @@ namespace AdvertsingProfitControl
var actualSales = ReturnActualSales(oldDateId); var actualSales = ReturnActualSales(oldDateId);
var invoices = ReturnInvoiceTable(oldDateId); var invoices = ReturnInvoiceTable(oldDateId);
var weeklySales = ReturnWeeklySalesFromDateId(oldDateId); var weeklySales = ReturnWeeklySalesFromDateId(oldDateId);
MassiveWriteFunction(date.ToString(), projectionsTable, inventoryTable, actualSales, invoices, weeklySales); var comment = GetComments(oldDateId);
MassiveWriteFunction(date.ToString(), projectionsTable, inventoryTable, actualSales, invoices, weeklySales, comment);
} }
} }
private void MassiveWriteFunction(string dateString, DataTable projections, DataTable inventory, DataTable actualSales, DataTable invoice, DataTable weeklySales, string comments)
private void MassiveWriteFunction(string dateString, DataTable projections, DataTable inventory, DataTable actualSales, DataTable invoice, DataTable weeklySales)
{ {
var dbT = new DatabaseTracker(); var dbT = new DatabaseTracker();
var dbR = new DatabaseReader();
//Get a new ID number for the date supplied. //Get a new ID number for the date supplied.
var oleDbConnection = new OleDbConnection(dbT.DatabaseConnectionString); var oleDbConnection = new OleDbConnection(dbT.DatabaseConnectionString);
var oleDbCommand = new OleDbCommand var oleDbCommand = new OleDbCommand
@@ -149,7 +149,7 @@ namespace AdvertsingProfitControl
//Get the group name of the ad special its in. //Get the group name of the ad special its in.
adspecialId = GetAdSpecialId(int.Parse(projections.Rows[rowIndex][8].ToString())); adspecialId = GetAdSpecialId(int.Parse(projections.Rows[rowIndex][8].ToString()));
oleDbCommand.CommandText = oleDbCommand.CommandText =
"INSERT INTO Projections (Sold, SalePrice, TotalSales, Cost, ProfitReturn, TotalProfitReturn, FK_AdItemID, RowAttribute, FK_AdSpecialGroupName, RowPosition, FK_DateID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; "INSERT INTO Projections (Sold, SalePrice, TotalSales, Cost, ProfitReturn, TotalProfitReturn, FK_AdItemID, RowAttribute, FK_AdSpecialGroupName, RowPosition, FK_DateID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
//SELECT AdItem.AdItem, APC.ProjectionSold, APC.ProjectionSalePrice, APC.ProjectionTotalSales, APC.ProjectionCost, APC.ProjectionProfitReturn, APC.ProjectionTotalProfitReturn, APC.RowAttribute, APC.FK_GroupID FROM (AdItem INNER JOIN APC ON AdItem.ID = APC.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC //SELECT AdItem.AdItem, APC.ProjectionSold, APC.ProjectionSalePrice, APC.ProjectionTotalSales, APC.ProjectionCost, APC.ProjectionProfitReturn, APC.ProjectionTotalProfitReturn, APC.RowAttribute, APC.FK_GroupID FROM (AdItem INNER JOIN APC ON AdItem.ID = APC.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC
oleDbCommand.Parameters.AddWithValue("Sold", projections.Rows[rowIndex][1]); oleDbCommand.Parameters.AddWithValue("Sold", projections.Rows[rowIndex][1]);
oleDbCommand.Parameters.AddWithValue("SalesPrice", projections.Rows[rowIndex][2]); oleDbCommand.Parameters.AddWithValue("SalesPrice", projections.Rows[rowIndex][2]);
@@ -158,7 +158,8 @@ namespace AdvertsingProfitControl
oleDbCommand.Parameters.AddWithValue("ProfitReturn", projections.Rows[rowIndex][5]); oleDbCommand.Parameters.AddWithValue("ProfitReturn", projections.Rows[rowIndex][5]);
oleDbCommand.Parameters.AddWithValue("TotalProfitReturn", projections.Rows[rowIndex][6]); oleDbCommand.Parameters.AddWithValue("TotalProfitReturn", projections.Rows[rowIndex][6]);
oleDbCommand.Parameters.AddWithValue("adItemID", adItemId); oleDbCommand.Parameters.AddWithValue("adItemID", adItemId);
oleDbCommand.Parameters.AddWithValue("RowAttribute", int.Parse(projections.Rows[rowIndex][7].ToString())); oleDbCommand.Parameters.AddWithValue("RowAttribute",
int.Parse(projections.Rows[rowIndex][7].ToString()));
oleDbCommand.Parameters.AddWithValue("adSpecialID", adspecialId); oleDbCommand.Parameters.AddWithValue("adSpecialID", adspecialId);
oleDbCommand.Parameters.AddWithValue("RowPosition", (rowIndex + 1)); oleDbCommand.Parameters.AddWithValue("RowPosition", (rowIndex + 1));
oleDbCommand.Parameters.AddWithValue("dateID", dateId); oleDbCommand.Parameters.AddWithValue("dateID", dateId);
@@ -173,10 +174,10 @@ namespace AdvertsingProfitControl
oleDbCommand.CommandText = oleDbCommand.CommandText =
"INSERT INTO Inventory (BeginningInventory, Received, TotalInventory, EndingInventory, FK_AdItemID, RowAttribute, FK_AdSpecialGroupName, RowPosition, FK_DateID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; "INSERT INTO Inventory (BeginningInventory, Received, TotalInventory, EndingInventory, FK_AdItemID, RowAttribute, FK_AdSpecialGroupName, RowPosition, FK_DateID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
//"SELECT AdItem.AdItem, APC.BeginingInventory, APC.Received, APC.TotalInventory, APC.EndingInventory, APC.RowAttribute, APC.FK_GroupID FROM (AdItem INNER JOIN APC ON AdItem.ID = APC.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC" //"SELECT AdItem.AdItem, APC.BeginingInventory, APC.Received, APC.TotalInventory, APC.EndingInventory, APC.RowAttribute, APC.FK_GroupID FROM (AdItem INNER JOIN APC ON AdItem.ID = APC.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC"
oleDbCommand.Parameters.AddWithValue("BegnningInventory", inventory.Rows[i][1]); oleDbCommand.Parameters.AddWithValue("BeginningInventory", inventory.Rows[i][1].ToString());
oleDbCommand.Parameters.AddWithValue("Received", inventory.Rows[i][2]); oleDbCommand.Parameters.AddWithValue("Received", inventory.Rows[i][2].ToString());
oleDbCommand.Parameters.AddWithValue("TotalInventory", inventory.Rows[i][3]); oleDbCommand.Parameters.AddWithValue("TotalInventory", inventory.Rows[i][3].ToString());
oleDbCommand.Parameters.AddWithValue("EndingInventory", inventory.Rows[i][4]); oleDbCommand.Parameters.AddWithValue("EndingInventory", inventory.Rows[i][4].ToString());
oleDbCommand.Parameters.AddWithValue("AdItemID", adItemId); oleDbCommand.Parameters.AddWithValue("AdItemID", adItemId);
oleDbCommand.Parameters.AddWithValue("RowAttribute", int.Parse(inventory.Rows[i][5].ToString())); oleDbCommand.Parameters.AddWithValue("RowAttribute", int.Parse(inventory.Rows[i][5].ToString()));
oleDbCommand.Parameters.AddWithValue("FK_AdSpecialGroup", adspecialId); oleDbCommand.Parameters.AddWithValue("FK_AdSpecialGroup", adspecialId);
@@ -193,7 +194,7 @@ namespace AdvertsingProfitControl
var adItemId = int.Parse(RetrieveAdItemId(actualSales.Rows[rowIndex][0].ToString())); var adItemId = int.Parse(RetrieveAdItemId(actualSales.Rows[rowIndex][0].ToString()));
adspecialId = GetAdSpecialId(int.Parse(actualSales.Rows[rowIndex][8].ToString())); adspecialId = GetAdSpecialId(int.Parse(actualSales.Rows[rowIndex][8].ToString()));
oleDbCommand.CommandText = oleDbCommand.CommandText =
"INSERT INTO ActualSales (Sold, SalePrice, TotalSales, Cost, ProfitReturn, TotalProfitReturn, FK_AdItemID, RowAttribute, FK_AdSpecialGroupName, RowPosition, FK_DateID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; "INSERT INTO ActualSales (Sold, SalePrice, TotalSales, Cost, ProfitReturn, TotalProfitReturn, FK_AdItemID, RowAttribute, FK_AdSpecialGroupName, RowPosition, FK_DateID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
//SELECT AdItem.AdItem, APC.ProjectionSold, APC.ProjectionSalePrice, APC.ProjectionTotalSales, APC.ProjectionCost, APC.ProjectionProfitReturn, APC.ProjectionTotalProfitReturn, APC.RowAttribute, APC.FK_GroupID FROM (AdItem INNER JOIN APC ON AdItem.ID = APC.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC //SELECT AdItem.AdItem, APC.ProjectionSold, APC.ProjectionSalePrice, APC.ProjectionTotalSales, APC.ProjectionCost, APC.ProjectionProfitReturn, APC.ProjectionTotalProfitReturn, APC.RowAttribute, APC.FK_GroupID FROM (AdItem INNER JOIN APC ON AdItem.ID = APC.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC
oleDbCommand.Parameters.AddWithValue("Sold", actualSales.Rows[rowIndex][1]); oleDbCommand.Parameters.AddWithValue("Sold", actualSales.Rows[rowIndex][1]);
oleDbCommand.Parameters.AddWithValue("SalesPrice", actualSales.Rows[rowIndex][2]); oleDbCommand.Parameters.AddWithValue("SalesPrice", actualSales.Rows[rowIndex][2]);
@@ -202,7 +203,8 @@ namespace AdvertsingProfitControl
oleDbCommand.Parameters.AddWithValue("ProfitReturn", actualSales.Rows[rowIndex][5]); oleDbCommand.Parameters.AddWithValue("ProfitReturn", actualSales.Rows[rowIndex][5]);
oleDbCommand.Parameters.AddWithValue("TotalProfitReturn", actualSales.Rows[rowIndex][6]); oleDbCommand.Parameters.AddWithValue("TotalProfitReturn", actualSales.Rows[rowIndex][6]);
oleDbCommand.Parameters.AddWithValue("adItemID", adItemId); oleDbCommand.Parameters.AddWithValue("adItemID", adItemId);
oleDbCommand.Parameters.AddWithValue("RowAttribute", int.Parse(projections.Rows[rowIndex][7].ToString())); oleDbCommand.Parameters.AddWithValue("RowAttribute",
int.Parse(projections.Rows[rowIndex][7].ToString()));
oleDbCommand.Parameters.AddWithValue("adSpecialID", adspecialId); oleDbCommand.Parameters.AddWithValue("adSpecialID", adspecialId);
oleDbCommand.Parameters.AddWithValue("RowPosition", (rowIndex + 1)); oleDbCommand.Parameters.AddWithValue("RowPosition", (rowIndex + 1));
oleDbCommand.Parameters.AddWithValue("dateID", dateId); oleDbCommand.Parameters.AddWithValue("dateID", dateId);
@@ -215,11 +217,13 @@ namespace AdvertsingProfitControl
var supplierId = GetSupplierId(invoice.Rows[i][1].ToString()); var supplierId = GetSupplierId(invoice.Rows[i][1].ToString());
//SELECT Invoice.InvoiceDate, Supplier.SupplierName, Invoice.InvoiceNumber, Invoice.InvoiceNetAmountAtCost, Invoice.InvoiceNetAmount, Invoice.InvoiceNote FROM (Supplier INNER JOIN Invoice ON Supplier.ID = Invoice.FK_Supplier) WHERE FK_DateID = ? //SELECT Invoice.InvoiceDate, Supplier.SupplierName, Invoice.InvoiceNumber, Invoice.InvoiceNetAmountAtCost, Invoice.InvoiceNetAmount, Invoice.InvoiceNote FROM (Supplier INNER JOIN Invoice ON Supplier.ID = Invoice.FK_Supplier) WHERE FK_DateID = ?
oleDbCommand.CommandText = oleDbCommand.CommandText =
"INSERT INTO Invoice (InvoiceDate, InvoiceNumber, InvoiceNetAmountAtCost, InvoiceNetAmount, InvoiceNote, FK_Supplier, FK_DateID) VALUES(?,?,?,?,?,?,?)"; "INSERT INTO Invoice (InvoiceDate, InvoiceNumber, InvoiceNetAmountAtCost, InvoiceNetAmount, InvoiceNote, FK_Supplier, FK_DateID) VALUES(?,?,?,?,?,?,?)";
oleDbCommand.Parameters.AddWithValue("InvoiceDate", invoice.Rows[i][0].ToString()); oleDbCommand.Parameters.AddWithValue("InvoiceDate", invoice.Rows[i][0].ToString());
oleDbCommand.Parameters.AddWithValue("InvoiceNumber", invoice.Rows[i][2].ToString()); oleDbCommand.Parameters.AddWithValue("InvoiceNumber", invoice.Rows[i][2].ToString());
oleDbCommand.Parameters.AddWithValue("InvoiceNetAmountAtCost", invoice.Rows[i][3].ToString() == "" ? 0 : double.Parse(invoice.Rows[i][3].ToString())); oleDbCommand.Parameters.AddWithValue("InvoiceNetAmountAtCost",
oleDbCommand.Parameters.AddWithValue("InvoiceNetAmount", invoice.Rows[i][4].ToString() == "" ? 0 : double.Parse(invoice.Rows[i][4].ToString())); invoice.Rows[i][3].ToString() == "" ? 0 : double.Parse(invoice.Rows[i][3].ToString()));
oleDbCommand.Parameters.AddWithValue("InvoiceNetAmount",
invoice.Rows[i][4].ToString() == "" ? 0 : double.Parse(invoice.Rows[i][4].ToString()));
oleDbCommand.Parameters.AddWithValue("InvoiceNote", invoice.Rows[i][5].ToString()); oleDbCommand.Parameters.AddWithValue("InvoiceNote", invoice.Rows[i][5].ToString());
oleDbCommand.Parameters.AddWithValue("FK_Supplier", supplierId); oleDbCommand.Parameters.AddWithValue("FK_Supplier", supplierId);
oleDbCommand.Parameters.AddWithValue("FK_DateID", dateId); oleDbCommand.Parameters.AddWithValue("FK_DateID", dateId);
@@ -227,7 +231,8 @@ namespace AdvertsingProfitControl
oleDbCommand.Parameters.Clear(); oleDbCommand.Parameters.Clear();
} }
//"SELECT WeeklySales.Sunday, WeeklySales.Monday, WeeklySales.Tuesday, WeeklySales.Wednesday, WeeklySales.Thursday, WeeklySales.Friday, WeeklySales.Saturday, WeeklySales.TotalSales FROM WeeklySales WHERE FK_DateID = ?" //"SELECT WeeklySales.Sunday, WeeklySales.Monday, WeeklySales.Tuesday, WeeklySales.Wednesday, WeeklySales.Thursday, WeeklySales.Friday, WeeklySales.Saturday, WeeklySales.TotalSales FROM WeeklySales WHERE FK_DateID = ?"
oleDbCommand.CommandText = "INSERT INTO WeeklySales (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, TotalSales, FK_DateID) VALUES (?,?,?,?,?,?,?,?,?)"; oleDbCommand.CommandText =
"INSERT INTO WeeklySales (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, TotalSales, FK_DateID) VALUES (?,?,?,?,?,?,?,?,?)";
oleDbCommand.Parameters.AddWithValue("Sunday", weeklySales.Rows[0][0]); oleDbCommand.Parameters.AddWithValue("Sunday", weeklySales.Rows[0][0]);
oleDbCommand.Parameters.AddWithValue("Monday", weeklySales.Rows[0][1]); oleDbCommand.Parameters.AddWithValue("Monday", weeklySales.Rows[0][1]);
oleDbCommand.Parameters.AddWithValue("Tuesday", weeklySales.Rows[0][2]); oleDbCommand.Parameters.AddWithValue("Tuesday", weeklySales.Rows[0][2]);
@@ -239,13 +244,22 @@ namespace AdvertsingProfitControl
oleDbCommand.Parameters.AddWithValue("DateID", dateId); oleDbCommand.Parameters.AddWithValue("DateID", dateId);
oleDbCommand.ExecuteNonQuery(); oleDbCommand.ExecuteNonQuery();
oleDbTransaction.Commit(); oleDbCommand.Parameters.Clear();
oleDbCommand.CommandText = "INSERT INTO Comment (Comment, FK_DateID) VALUES (?, ?)";
oleDbCommand.Parameters.AddWithValue("Com", comments);
oleDbCommand.Parameters.AddWithValue("FK", dateId);
oleDbCommand.ExecuteNonQuery();
oleDbTransaction.Commit();
} }
catch (OleDbException e) catch (OleDbException e)
{ {
MessageBox.Show(e.Message); MessageBox.Show(e.Message);
oleDbTransaction?.Rollback(); oleDbTransaction?.Rollback();
} }
finally
{
oleDbConnection.Close();
}
} }
public int GetSupplierId(string supplierName) public int GetSupplierId(string supplierName)
@@ -273,7 +287,10 @@ namespace AdvertsingProfitControl
{ {
MessageBox.Show(e.Message); MessageBox.Show(e.Message);
} }
finally
{
oleDbConnection.Close();
}
return supplierId; return supplierId;
} }
@@ -318,15 +335,46 @@ namespace AdvertsingProfitControl
id = int.Parse(reader[0].ToString()); id = int.Parse(reader[0].ToString());
} }
reader?.Close(); reader?.Close();
spam.Close();
} }
catch (OleDbException e) catch (OleDbException e)
{ {
MessageBox.Show(e.Message); MessageBox.Show(e.Message);
throw; throw;
} }
finally
{
oleDbConnection.Close();
}
return id; return id;
} }
private string GetComments(int dateId)
{
var comments = "";
var oleDbCommand = new OleDbCommand
{
CommandText = "SELECT Comment.Comment FROM Comment WHERE Comment.FK_DateID = ?"
};
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
var connection = new OleDbConnection(_connectionString);
oleDbCommand.Connection = connection;
using (connection)
{
using (oleDbCommand)
{
connection.Open();
var reader = oleDbCommand.ExecuteReader();
while (reader != null && reader.Read())
{
comments = reader[0].ToString();
}
}
}
return comments;
}
public string RetrieveAdItemId(string adItemName) public string RetrieveAdItemId(string adItemName)
{ {
var dbT = new DatabaseTracker(); var dbT = new DatabaseTracker();
@@ -359,6 +407,7 @@ namespace AdvertsingProfitControl
} }
} }
} }
connection.Close();
} }
return dateId; return dateId;
@@ -385,6 +434,7 @@ namespace AdvertsingProfitControl
dataAdapter.Fill(dataTable); dataAdapter.Fill(dataTable);
} }
} }
connection.Close();
} }
return dataTable; return dataTable;
} }
@@ -410,6 +460,7 @@ namespace AdvertsingProfitControl
dataAdapter.Fill(dataTable); dataAdapter.Fill(dataTable);
} }
} }
connection.Close();
} }
return dataTable; return dataTable;
} }
@@ -435,6 +486,7 @@ namespace AdvertsingProfitControl
dataAdapter.Fill(dataTable); dataAdapter.Fill(dataTable);
} }
} }
connection.Close();
} }
return dataTable; return dataTable;
} }
@@ -459,6 +511,7 @@ namespace AdvertsingProfitControl
adapter.Fill(dataTable); adapter.Fill(dataTable);
} }
} }
connection.Close();
} }
return dataTable; return dataTable;
@@ -484,6 +537,7 @@ namespace AdvertsingProfitControl
dataAdapter.Fill(dataTable); dataAdapter.Fill(dataTable);
} }
} }
connection.Close();
} }
return dataTable; return dataTable;
+63 -63
View File
@@ -43,6 +43,8 @@
this.helpMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.helpMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.showHideConsoleHelpMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.showHideConsoleHelpMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.dbVersionHelpMainMenu = 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.mainTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); this.mainTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.commentMainTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); this.commentMainTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.profitAnalysisMainGroupBox = new System.Windows.Forms.GroupBox(); this.profitAnalysisMainGroupBox = new System.Windows.Forms.GroupBox();
@@ -100,8 +102,6 @@
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel = new System.Windows.Forms.Label(); this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel = new System.Windows.Forms.Label();
this.perfectGrossProfitLabel = new System.Windows.Forms.Label(); this.perfectGrossProfitLabel = new System.Windows.Forms.Label();
this.grossProfitDollarGrossProfitLabel = new System.Windows.Forms.Label(); this.grossProfitDollarGrossProfitLabel = new System.Windows.Forms.Label();
this.debugToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.debugToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.mainMenu.SuspendLayout(); this.mainMenu.SuspendLayout();
this.mainTableLayoutPanel.SuspendLayout(); this.mainTableLayoutPanel.SuspendLayout();
this.commentMainTableLayoutPanel.SuspendLayout(); this.commentMainTableLayoutPanel.SuspendLayout();
@@ -127,7 +127,7 @@
// //
// printPreviewButton // printPreviewButton
// //
this.printPreviewButton.Location = new System.Drawing.Point(313, 277); this.printPreviewButton.Location = new System.Drawing.Point(171, 273);
this.printPreviewButton.Name = "printPreviewButton"; this.printPreviewButton.Name = "printPreviewButton";
this.printPreviewButton.Size = new System.Drawing.Size(138, 49); this.printPreviewButton.Size = new System.Drawing.Size(138, 49);
this.printPreviewButton.TabIndex = 4; this.printPreviewButton.TabIndex = 4;
@@ -248,11 +248,27 @@
this.dbVersionHelpMainMenu.Text = "Get &Database Version"; this.dbVersionHelpMainMenu.Text = "Get &Database Version";
this.dbVersionHelpMainMenu.Click += new System.EventHandler(this.dbVersionHelpMainMenu_Click); this.dbVersionHelpMainMenu.Click += new System.EventHandler(this.dbVersionHelpMainMenu_Click);
// //
// debugToolStripMenuItem
//
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;
//
// debugToolStripMenuItem1
//
this.debugToolStripMenuItem1.Name = "debugToolStripMenuItem1";
this.debugToolStripMenuItem1.Size = new System.Drawing.Size(240, 34);
this.debugToolStripMenuItem1.Text = "Debug";
this.debugToolStripMenuItem1.Click += new System.EventHandler(this.debugToolStripMenuItem1_Click);
//
// mainTableLayoutPanel // mainTableLayoutPanel
// //
this.mainTableLayoutPanel.ColumnCount = 2; this.mainTableLayoutPanel.ColumnCount = 2;
this.mainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 75F)); this.mainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 80F));
this.mainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); this.mainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F));
this.mainTableLayoutPanel.Controls.Add(this.commentMainTableLayoutPanel, 0, 2); this.mainTableLayoutPanel.Controls.Add(this.commentMainTableLayoutPanel, 0, 2);
this.mainTableLayoutPanel.Controls.Add(this.mainMenu, 0, 0); this.mainTableLayoutPanel.Controls.Add(this.mainMenu, 0, 0);
this.mainTableLayoutPanel.Controls.Add(this.mainViewTabControl, 0, 1); this.mainTableLayoutPanel.Controls.Add(this.mainViewTabControl, 0, 1);
@@ -272,10 +288,10 @@
// commentMainTableLayoutPanel // commentMainTableLayoutPanel
// //
this.commentMainTableLayoutPanel.ColumnCount = 4; this.commentMainTableLayoutPanel.ColumnCount = 4;
this.commentMainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 355F)); this.commentMainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 365F));
this.commentMainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 27.5F)); this.commentMainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F));
this.commentMainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 27.5F)); this.commentMainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F));
this.commentMainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 45F)); this.commentMainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 40F));
this.commentMainTableLayoutPanel.Controls.Add(this.profitAnalysisMainGroupBox, 3, 0); this.commentMainTableLayoutPanel.Controls.Add(this.profitAnalysisMainGroupBox, 3, 0);
this.commentMainTableLayoutPanel.Controls.Add(this.weeklySalesGroupBox, 1, 0); this.commentMainTableLayoutPanel.Controls.Add(this.weeklySalesGroupBox, 1, 0);
this.commentMainTableLayoutPanel.Controls.Add(this.taxableGroupBox, 2, 0); this.commentMainTableLayoutPanel.Controls.Add(this.taxableGroupBox, 2, 0);
@@ -286,7 +302,7 @@
this.commentMainTableLayoutPanel.Name = "commentMainTableLayoutPanel"; this.commentMainTableLayoutPanel.Name = "commentMainTableLayoutPanel";
this.commentMainTableLayoutPanel.RowCount = 1; this.commentMainTableLayoutPanel.RowCount = 1;
this.commentMainTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.commentMainTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.commentMainTableLayoutPanel.Size = new System.Drawing.Size(1375, 329); this.commentMainTableLayoutPanel.Size = new System.Drawing.Size(1467, 329);
this.commentMainTableLayoutPanel.TabIndex = 5; this.commentMainTableLayoutPanel.TabIndex = 5;
// //
// profitAnalysisMainGroupBox // profitAnalysisMainGroupBox
@@ -300,9 +316,9 @@
this.profitAnalysisMainGroupBox.Controls.Add(this.remainingSalesLabel); this.profitAnalysisMainGroupBox.Controls.Add(this.remainingSalesLabel);
this.profitAnalysisMainGroupBox.Controls.Add(this.totalProfitFromAdItemsLabel); this.profitAnalysisMainGroupBox.Controls.Add(this.totalProfitFromAdItemsLabel);
this.profitAnalysisMainGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; this.profitAnalysisMainGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.profitAnalysisMainGroupBox.Location = new System.Drawing.Point(918, 3); this.profitAnalysisMainGroupBox.Location = new System.Drawing.Point(1028, 3);
this.profitAnalysisMainGroupBox.Name = "profitAnalysisMainGroupBox"; this.profitAnalysisMainGroupBox.Name = "profitAnalysisMainGroupBox";
this.profitAnalysisMainGroupBox.Size = new System.Drawing.Size(454, 323); this.profitAnalysisMainGroupBox.Size = new System.Drawing.Size(436, 323);
this.profitAnalysisMainGroupBox.TabIndex = 2; this.profitAnalysisMainGroupBox.TabIndex = 2;
this.profitAnalysisMainGroupBox.TabStop = false; this.profitAnalysisMainGroupBox.TabStop = false;
this.profitAnalysisMainGroupBox.Text = "Profit Analysis"; this.profitAnalysisMainGroupBox.Text = "Profit Analysis";
@@ -332,7 +348,7 @@
// departmentSalesLabel // departmentSalesLabel
// //
this.departmentSalesLabel.AutoSize = true; this.departmentSalesLabel.AutoSize = true;
this.departmentSalesLabel.Location = new System.Drawing.Point(11, 61); this.departmentSalesLabel.Location = new System.Drawing.Point(11, 64);
this.departmentSalesLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.departmentSalesLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.departmentSalesLabel.Name = "departmentSalesLabel"; this.departmentSalesLabel.Name = "departmentSalesLabel";
this.departmentSalesLabel.Size = new System.Drawing.Size(179, 25); this.departmentSalesLabel.Size = new System.Drawing.Size(179, 25);
@@ -342,7 +358,7 @@
// totalProfitReturnLabel // totalProfitReturnLabel
// //
this.totalProfitReturnLabel.AutoSize = true; this.totalProfitReturnLabel.AutoSize = true;
this.totalProfitReturnLabel.Location = new System.Drawing.Point(11, 221); this.totalProfitReturnLabel.Location = new System.Drawing.Point(11, 279);
this.totalProfitReturnLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.totalProfitReturnLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.totalProfitReturnLabel.Name = "totalProfitReturnLabel"; this.totalProfitReturnLabel.Name = "totalProfitReturnLabel";
this.totalProfitReturnLabel.Size = new System.Drawing.Size(178, 25); this.totalProfitReturnLabel.Size = new System.Drawing.Size(178, 25);
@@ -352,7 +368,7 @@
// salesProducedLabel // salesProducedLabel
// //
this.salesProducedLabel.AutoSize = true; this.salesProducedLabel.AutoSize = true;
this.salesProducedLabel.Location = new System.Drawing.Point(11, 93); this.salesProducedLabel.Location = new System.Drawing.Point(11, 97);
this.salesProducedLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.salesProducedLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.salesProducedLabel.Name = "salesProducedLabel"; this.salesProducedLabel.Name = "salesProducedLabel";
this.salesProducedLabel.Size = new System.Drawing.Size(300, 25); this.salesProducedLabel.Size = new System.Drawing.Size(300, 25);
@@ -362,17 +378,17 @@
// totalProfitReturnFromRemaingLabel // totalProfitReturnFromRemaingLabel
// //
this.totalProfitReturnFromRemaingLabel.AutoSize = true; this.totalProfitReturnFromRemaingLabel.AutoSize = true;
this.totalProfitReturnFromRemaingLabel.Location = new System.Drawing.Point(11, 189); this.totalProfitReturnFromRemaingLabel.Location = new System.Drawing.Point(11, 221);
this.totalProfitReturnFromRemaingLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.totalProfitReturnFromRemaingLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.totalProfitReturnFromRemaingLabel.Name = "totalProfitReturnFromRemaingLabel"; this.totalProfitReturnFromRemaingLabel.Name = "totalProfitReturnFromRemaingLabel";
this.totalProfitReturnFromRemaingLabel.Size = new System.Drawing.Size(380, 25); this.totalProfitReturnFromRemaingLabel.Size = new System.Drawing.Size(220, 50);
this.totalProfitReturnFromRemaingLabel.TabIndex = 4; this.totalProfitReturnFromRemaingLabel.TabIndex = 4;
this.totalProfitReturnFromRemaingLabel.Text = "Total Profit Return From Remaining Sales: "; this.totalProfitReturnFromRemaingLabel.Text = "Total Profit Return \r\nFrom Remaining Sales: ";
// //
// remainingSalesLabel // remainingSalesLabel
// //
this.remainingSalesLabel.AutoSize = true; this.remainingSalesLabel.AutoSize = true;
this.remainingSalesLabel.Location = new System.Drawing.Point(11, 125); this.remainingSalesLabel.Location = new System.Drawing.Point(11, 130);
this.remainingSalesLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.remainingSalesLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.remainingSalesLabel.Name = "remainingSalesLabel"; this.remainingSalesLabel.Name = "remainingSalesLabel";
this.remainingSalesLabel.Size = new System.Drawing.Size(170, 25); this.remainingSalesLabel.Size = new System.Drawing.Size(170, 25);
@@ -382,12 +398,12 @@
// totalProfitFromAdItemsLabel // totalProfitFromAdItemsLabel
// //
this.totalProfitFromAdItemsLabel.AutoSize = true; this.totalProfitFromAdItemsLabel.AutoSize = true;
this.totalProfitFromAdItemsLabel.Location = new System.Drawing.Point(11, 157); this.totalProfitFromAdItemsLabel.Location = new System.Drawing.Point(11, 163);
this.totalProfitFromAdItemsLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.totalProfitFromAdItemsLabel.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.totalProfitFromAdItemsLabel.Name = "totalProfitFromAdItemsLabel"; this.totalProfitFromAdItemsLabel.Name = "totalProfitFromAdItemsLabel";
this.totalProfitFromAdItemsLabel.Size = new System.Drawing.Size(342, 25); this.totalProfitFromAdItemsLabel.Size = new System.Drawing.Size(182, 50);
this.totalProfitFromAdItemsLabel.TabIndex = 3; this.totalProfitFromAdItemsLabel.TabIndex = 3;
this.totalProfitFromAdItemsLabel.Text = "Total Profit Return From Ad Items (B): "; this.totalProfitFromAdItemsLabel.Text = "Total Profit Return \r\nFrom Ad Items (B): ";
// //
// weeklySalesGroupBox // weeklySalesGroupBox
// //
@@ -400,9 +416,9 @@
this.weeklySalesGroupBox.Controls.Add(this.wednesdayWeeklySalesLabel); this.weeklySalesGroupBox.Controls.Add(this.wednesdayWeeklySalesLabel);
this.weeklySalesGroupBox.Controls.Add(this.sundayWeeklySalesLabel); this.weeklySalesGroupBox.Controls.Add(this.sundayWeeklySalesLabel);
this.weeklySalesGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; this.weeklySalesGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.weeklySalesGroupBox.Location = new System.Drawing.Point(358, 3); this.weeklySalesGroupBox.Location = new System.Drawing.Point(368, 3);
this.weeklySalesGroupBox.Name = "weeklySalesGroupBox"; this.weeklySalesGroupBox.Name = "weeklySalesGroupBox";
this.weeklySalesGroupBox.Size = new System.Drawing.Size(274, 323); this.weeklySalesGroupBox.Size = new System.Drawing.Size(324, 323);
this.weeklySalesGroupBox.TabIndex = 3; this.weeklySalesGroupBox.TabIndex = 3;
this.weeklySalesGroupBox.TabStop = false; this.weeklySalesGroupBox.TabStop = false;
this.weeklySalesGroupBox.Text = "Weekly Sales"; this.weeklySalesGroupBox.Text = "Weekly Sales";
@@ -490,9 +506,9 @@
this.taxableGroupBox.Controls.Add(this.wednesdayTaxableLabel); this.taxableGroupBox.Controls.Add(this.wednesdayTaxableLabel);
this.taxableGroupBox.Controls.Add(this.sundayTaxableLabel); this.taxableGroupBox.Controls.Add(this.sundayTaxableLabel);
this.taxableGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; this.taxableGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.taxableGroupBox.Location = new System.Drawing.Point(638, 3); this.taxableGroupBox.Location = new System.Drawing.Point(698, 3);
this.taxableGroupBox.Name = "taxableGroupBox"; this.taxableGroupBox.Name = "taxableGroupBox";
this.taxableGroupBox.Size = new System.Drawing.Size(274, 323); this.taxableGroupBox.Size = new System.Drawing.Size(324, 323);
this.taxableGroupBox.TabIndex = 4; this.taxableGroupBox.TabIndex = 4;
this.taxableGroupBox.TabStop = false; this.taxableGroupBox.TabStop = false;
this.taxableGroupBox.Text = "Taxable"; this.taxableGroupBox.Text = "Taxable";
@@ -575,7 +591,7 @@
this.dateTimeGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; this.dateTimeGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.dateTimeGroupBox.Location = new System.Drawing.Point(3, 3); this.dateTimeGroupBox.Location = new System.Drawing.Point(3, 3);
this.dateTimeGroupBox.Name = "dateTimeGroupBox"; this.dateTimeGroupBox.Name = "dateTimeGroupBox";
this.dateTimeGroupBox.Size = new System.Drawing.Size(349, 323); this.dateTimeGroupBox.Size = new System.Drawing.Size(359, 323);
this.dateTimeGroupBox.TabIndex = 5; this.dateTimeGroupBox.TabIndex = 5;
this.dateTimeGroupBox.TabStop = false; this.dateTimeGroupBox.TabStop = false;
// //
@@ -598,7 +614,7 @@
this.mainViewTabControl.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6); this.mainViewTabControl.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.mainViewTabControl.Name = "mainViewTabControl"; this.mainViewTabControl.Name = "mainViewTabControl";
this.mainViewTabControl.SelectedIndex = 0; this.mainViewTabControl.SelectedIndex = 0;
this.mainViewTabControl.Size = new System.Drawing.Size(1375, 499); this.mainViewTabControl.Size = new System.Drawing.Size(1467, 499);
this.mainViewTabControl.TabIndex = 3; this.mainViewTabControl.TabIndex = 3;
// //
// projectionTab // projectionTab
@@ -608,7 +624,7 @@
this.projectionTab.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6); this.projectionTab.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.projectionTab.Name = "projectionTab"; this.projectionTab.Name = "projectionTab";
this.projectionTab.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6); this.projectionTab.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.projectionTab.Size = new System.Drawing.Size(1367, 462); this.projectionTab.Size = new System.Drawing.Size(1459, 462);
this.projectionTab.TabIndex = 0; this.projectionTab.TabIndex = 0;
this.projectionTab.Text = "Projections"; this.projectionTab.Text = "Projections";
this.projectionTab.UseVisualStyleBackColor = true; this.projectionTab.UseVisualStyleBackColor = true;
@@ -630,7 +646,7 @@
this.projectionsDataGridView.RowHeadersVisible = false; this.projectionsDataGridView.RowHeadersVisible = false;
this.projectionsDataGridView.ShowCellErrors = false; this.projectionsDataGridView.ShowCellErrors = false;
this.projectionsDataGridView.ShowRowErrors = false; this.projectionsDataGridView.ShowRowErrors = false;
this.projectionsDataGridView.Size = new System.Drawing.Size(1357, 450); this.projectionsDataGridView.Size = new System.Drawing.Size(1449, 450);
this.projectionsDataGridView.TabIndex = 0; this.projectionsDataGridView.TabIndex = 0;
// //
// inventoryTabPage // inventoryTabPage
@@ -639,7 +655,7 @@
this.inventoryTabPage.Location = new System.Drawing.Point(4, 33); this.inventoryTabPage.Location = new System.Drawing.Point(4, 33);
this.inventoryTabPage.Name = "inventoryTabPage"; this.inventoryTabPage.Name = "inventoryTabPage";
this.inventoryTabPage.Padding = new System.Windows.Forms.Padding(3); this.inventoryTabPage.Padding = new System.Windows.Forms.Padding(3);
this.inventoryTabPage.Size = new System.Drawing.Size(1367, 462); this.inventoryTabPage.Size = new System.Drawing.Size(1521, 462);
this.inventoryTabPage.TabIndex = 4; this.inventoryTabPage.TabIndex = 4;
this.inventoryTabPage.Text = "Inventory"; this.inventoryTabPage.Text = "Inventory";
this.inventoryTabPage.UseVisualStyleBackColor = true; this.inventoryTabPage.UseVisualStyleBackColor = true;
@@ -658,7 +674,7 @@
this.inventoryDataGridView.RowHeadersVisible = false; this.inventoryDataGridView.RowHeadersVisible = false;
this.inventoryDataGridView.RowTemplate.Height = 28; this.inventoryDataGridView.RowTemplate.Height = 28;
this.inventoryDataGridView.ShowRowErrors = false; this.inventoryDataGridView.ShowRowErrors = false;
this.inventoryDataGridView.Size = new System.Drawing.Size(1361, 456); this.inventoryDataGridView.Size = new System.Drawing.Size(1515, 456);
this.inventoryDataGridView.TabIndex = 0; this.inventoryDataGridView.TabIndex = 0;
// //
// actualSalesTab // actualSalesTab
@@ -667,7 +683,7 @@
this.actualSalesTab.Location = new System.Drawing.Point(4, 33); this.actualSalesTab.Location = new System.Drawing.Point(4, 33);
this.actualSalesTab.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6); this.actualSalesTab.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.actualSalesTab.Name = "actualSalesTab"; this.actualSalesTab.Name = "actualSalesTab";
this.actualSalesTab.Size = new System.Drawing.Size(1367, 462); this.actualSalesTab.Size = new System.Drawing.Size(1521, 462);
this.actualSalesTab.TabIndex = 2; this.actualSalesTab.TabIndex = 2;
this.actualSalesTab.Text = "Actual Sales"; this.actualSalesTab.Text = "Actual Sales";
this.actualSalesTab.UseVisualStyleBackColor = true; this.actualSalesTab.UseVisualStyleBackColor = true;
@@ -684,7 +700,7 @@
this.actualSalesMainLayoutPanel.RowCount = 1; this.actualSalesMainLayoutPanel.RowCount = 1;
this.actualSalesMainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.actualSalesMainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.actualSalesMainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 462F)); this.actualSalesMainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 462F));
this.actualSalesMainLayoutPanel.Size = new System.Drawing.Size(1367, 462); this.actualSalesMainLayoutPanel.Size = new System.Drawing.Size(1521, 462);
this.actualSalesMainLayoutPanel.TabIndex = 0; this.actualSalesMainLayoutPanel.TabIndex = 0;
// //
// actualSalesDataGridView // actualSalesDataGridView
@@ -704,7 +720,7 @@
this.actualSalesDataGridView.RowHeadersVisible = false; this.actualSalesDataGridView.RowHeadersVisible = false;
this.actualSalesDataGridView.ShowCellErrors = false; this.actualSalesDataGridView.ShowCellErrors = false;
this.actualSalesDataGridView.ShowRowErrors = false; this.actualSalesDataGridView.ShowRowErrors = false;
this.actualSalesDataGridView.Size = new System.Drawing.Size(1357, 450); this.actualSalesDataGridView.Size = new System.Drawing.Size(1511, 450);
this.actualSalesDataGridView.TabIndex = 1; this.actualSalesDataGridView.TabIndex = 1;
// //
// suppliersTabPage // suppliersTabPage
@@ -714,7 +730,7 @@
this.suppliersTabPage.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6); this.suppliersTabPage.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.suppliersTabPage.Name = "suppliersTabPage"; this.suppliersTabPage.Name = "suppliersTabPage";
this.suppliersTabPage.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6); this.suppliersTabPage.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.suppliersTabPage.Size = new System.Drawing.Size(1367, 462); this.suppliersTabPage.Size = new System.Drawing.Size(1521, 462);
this.suppliersTabPage.TabIndex = 1; this.suppliersTabPage.TabIndex = 1;
this.suppliersTabPage.Text = "Invoices"; this.suppliersTabPage.Text = "Invoices";
this.suppliersTabPage.UseVisualStyleBackColor = true; this.suppliersTabPage.UseVisualStyleBackColor = true;
@@ -734,7 +750,7 @@
this.invoicesDataGridView.Name = "invoicesDataGridView"; this.invoicesDataGridView.Name = "invoicesDataGridView";
this.invoicesDataGridView.ReadOnly = true; this.invoicesDataGridView.ReadOnly = true;
this.invoicesDataGridView.RowHeadersVisible = false; this.invoicesDataGridView.RowHeadersVisible = false;
this.invoicesDataGridView.Size = new System.Drawing.Size(1357, 450); this.invoicesDataGridView.Size = new System.Drawing.Size(1511, 450);
this.invoicesDataGridView.TabIndex = 0; this.invoicesDataGridView.TabIndex = 0;
// //
// commentsAndAnalysisLayoutPanel // commentsAndAnalysisLayoutPanel
@@ -745,12 +761,12 @@
this.commentsAndAnalysisLayoutPanel.Controls.Add(this.costAnalysisGroupBox, 0, 1); this.commentsAndAnalysisLayoutPanel.Controls.Add(this.costAnalysisGroupBox, 0, 1);
this.commentsAndAnalysisLayoutPanel.Controls.Add(this.commentMainGroupBox, 0, 0); this.commentsAndAnalysisLayoutPanel.Controls.Add(this.commentMainGroupBox, 0, 0);
this.commentsAndAnalysisLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.commentsAndAnalysisLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.commentsAndAnalysisLayoutPanel.Location = new System.Drawing.Point(1388, 43); this.commentsAndAnalysisLayoutPanel.Location = new System.Drawing.Point(1480, 43);
this.commentsAndAnalysisLayoutPanel.Name = "commentsAndAnalysisLayoutPanel"; this.commentsAndAnalysisLayoutPanel.Name = "commentsAndAnalysisLayoutPanel";
this.commentsAndAnalysisLayoutPanel.RowCount = 2; this.commentsAndAnalysisLayoutPanel.RowCount = 2;
this.commentsAndAnalysisLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.commentsAndAnalysisLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.commentsAndAnalysisLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.commentsAndAnalysisLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.commentsAndAnalysisLayoutPanel.Size = new System.Drawing.Size(456, 505); this.commentsAndAnalysisLayoutPanel.Size = new System.Drawing.Size(364, 505);
this.commentsAndAnalysisLayoutPanel.TabIndex = 6; this.commentsAndAnalysisLayoutPanel.TabIndex = 6;
// //
// costAnalysisGroupBox // costAnalysisGroupBox
@@ -763,7 +779,7 @@
this.costAnalysisGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; this.costAnalysisGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.costAnalysisGroupBox.Location = new System.Drawing.Point(3, 255); this.costAnalysisGroupBox.Location = new System.Drawing.Point(3, 255);
this.costAnalysisGroupBox.Name = "costAnalysisGroupBox"; this.costAnalysisGroupBox.Name = "costAnalysisGroupBox";
this.costAnalysisGroupBox.Size = new System.Drawing.Size(450, 247); this.costAnalysisGroupBox.Size = new System.Drawing.Size(358, 247);
this.costAnalysisGroupBox.TabIndex = 4; this.costAnalysisGroupBox.TabIndex = 4;
this.costAnalysisGroupBox.TabStop = false; this.costAnalysisGroupBox.TabStop = false;
this.costAnalysisGroupBox.Text = "Cost Analysis"; this.costAnalysisGroupBox.Text = "Cost Analysis";
@@ -822,7 +838,7 @@
this.commentMainGroupBox.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6); this.commentMainGroupBox.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.commentMainGroupBox.Name = "commentMainGroupBox"; this.commentMainGroupBox.Name = "commentMainGroupBox";
this.commentMainGroupBox.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6); this.commentMainGroupBox.Padding = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.commentMainGroupBox.Size = new System.Drawing.Size(446, 240); this.commentMainGroupBox.Size = new System.Drawing.Size(354, 240);
this.commentMainGroupBox.TabIndex = 1; this.commentMainGroupBox.TabIndex = 1;
this.commentMainGroupBox.TabStop = false; this.commentMainGroupBox.TabStop = false;
this.commentMainGroupBox.Text = "Comments"; this.commentMainGroupBox.Text = "Comments";
@@ -836,7 +852,7 @@
this.commentsTextBox.Name = "commentsTextBox"; this.commentsTextBox.Name = "commentsTextBox";
this.commentsTextBox.ReadOnly = true; this.commentsTextBox.ReadOnly = true;
this.commentsTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.commentsTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.commentsTextBox.Size = new System.Drawing.Size(436, 206); this.commentsTextBox.Size = new System.Drawing.Size(344, 206);
this.commentsTextBox.TabIndex = 0; this.commentsTextBox.TabIndex = 0;
// //
// grossProfitGroupBox // grossProfitGroupBox
@@ -849,9 +865,9 @@
this.grossProfitGroupBox.Controls.Add(this.perfectGrossProfitLabel); this.grossProfitGroupBox.Controls.Add(this.perfectGrossProfitLabel);
this.grossProfitGroupBox.Controls.Add(this.grossProfitDollarGrossProfitLabel); this.grossProfitGroupBox.Controls.Add(this.grossProfitDollarGrossProfitLabel);
this.grossProfitGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; this.grossProfitGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.grossProfitGroupBox.Location = new System.Drawing.Point(1388, 554); this.grossProfitGroupBox.Location = new System.Drawing.Point(1480, 554);
this.grossProfitGroupBox.Name = "grossProfitGroupBox"; this.grossProfitGroupBox.Name = "grossProfitGroupBox";
this.grossProfitGroupBox.Size = new System.Drawing.Size(456, 335); this.grossProfitGroupBox.Size = new System.Drawing.Size(364, 335);
this.grossProfitGroupBox.TabIndex = 7; this.grossProfitGroupBox.TabIndex = 7;
this.grossProfitGroupBox.TabStop = false; this.grossProfitGroupBox.TabStop = false;
this.grossProfitGroupBox.Text = "Gross Profit"; this.grossProfitGroupBox.Text = "Gross Profit";
@@ -859,13 +875,12 @@
// usePreRenderedFilesCheckbox // usePreRenderedFilesCheckbox
// //
this.usePreRenderedFilesCheckbox.AutoSize = true; this.usePreRenderedFilesCheckbox.AutoSize = true;
this.usePreRenderedFilesCheckbox.Location = new System.Drawing.Point(40, 288); this.usePreRenderedFilesCheckbox.Location = new System.Drawing.Point(16, 288);
this.usePreRenderedFilesCheckbox.Name = "usePreRenderedFilesCheckbox"; this.usePreRenderedFilesCheckbox.Name = "usePreRenderedFilesCheckbox";
this.usePreRenderedFilesCheckbox.Size = new System.Drawing.Size(239, 29); this.usePreRenderedFilesCheckbox.Size = new System.Drawing.Size(239, 29);
this.usePreRenderedFilesCheckbox.TabIndex = 5; this.usePreRenderedFilesCheckbox.TabIndex = 5;
this.usePreRenderedFilesCheckbox.Text = "Use Pre-rendered Files"; this.usePreRenderedFilesCheckbox.Text = "Use Pre-rendered Files";
this.usePreRenderedFilesCheckbox.UseVisualStyleBackColor = true; this.usePreRenderedFilesCheckbox.UseVisualStyleBackColor = true;
this.usePreRenderedFilesCheckbox.Visible = false;
// //
// grossProfitLessCostOfSales // grossProfitLessCostOfSales
// //
@@ -890,9 +905,9 @@
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.AutoSize = true; this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.AutoSize = true;
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Location = new System.Drawing.Point(6, 163); this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Location = new System.Drawing.Point(6, 163);
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Name = "grossProfitEstimatedWeeklyDeptmartmentExpenseLabel"; this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Name = "grossProfitEstimatedWeeklyDeptmartmentExpenseLabel";
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Size = new System.Drawing.Size(368, 25); this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Size = new System.Drawing.Size(206, 50);
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.TabIndex = 4; this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.TabIndex = 4;
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Text = "Estimated Weekly Department Expense: "; this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Text = "Estimated Weekly \r\nDepartment Expense: ";
// //
// perfectGrossProfitLabel // perfectGrossProfitLabel
// //
@@ -912,21 +927,6 @@
this.grossProfitDollarGrossProfitLabel.TabIndex = 2; this.grossProfitDollarGrossProfitLabel.TabIndex = 2;
this.grossProfitDollarGrossProfitLabel.Text = "Dollar Gross Profit: "; this.grossProfitDollarGrossProfitLabel.Text = "Dollar Gross Profit: ";
// //
// debugToolStripMenuItem
//
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";
//
// debugToolStripMenuItem1
//
this.debugToolStripMenuItem1.Name = "debugToolStripMenuItem1";
this.debugToolStripMenuItem1.Size = new System.Drawing.Size(240, 34);
this.debugToolStripMenuItem1.Text = "Debug";
this.debugToolStripMenuItem1.Click += new System.EventHandler(this.debugToolStripMenuItem1_Click);
//
// FrmMain // FrmMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F); this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F);
+43 -38
View File
@@ -16,7 +16,7 @@ namespace AdvertsingProfitControl
private double _totalInvoicePurchases; //Total Purchases private double _totalInvoicePurchases; //Total Purchases
private double _departmentSales; //weekly sales total private double _departmentSales; //weekly sales total
private DateTime _currentActiveDate; private DateTime _currentActiveDate;
readonly FrmLogConsole _console = FrmLogConsole.GetStaticInstance; private readonly FrmLogConsole _console = FrmLogConsole.GetStaticInstance;
private int _LazyPageCounter; private int _LazyPageCounter;
public FrmMain() public FrmMain()
@@ -33,7 +33,6 @@ namespace AdvertsingProfitControl
ConstructInvoicesDataGridView(); ConstructInvoicesDataGridView();
RowParsing.AdSpecialGroups.AddRange(databaseReader.ReturnGroupNameList(databaseTracker.DatabaseConnectionString)); RowParsing.AdSpecialGroups.AddRange(databaseReader.ReturnGroupNameList(databaseTracker.DatabaseConnectionString));
var date = databaseReader.RetrieveMostRecentDate(databaseTracker.DatabaseConnectionString); var date = databaseReader.RetrieveMostRecentDate(databaseTracker.DatabaseConnectionString);
monthCalendar.SelectionStart = date;
_currentActiveDate = date; _currentActiveDate = date;
LoadDate(date); LoadDate(date);
monthCalendar.DateChanged += ValidateDateChanged; monthCalendar.DateChanged += ValidateDateChanged;
@@ -47,7 +46,7 @@ namespace AdvertsingProfitControl
if (actualSalesDataGridView.Rows.Count == 0) if (actualSalesDataGridView.Rows.Count == 0)
{ {
salesProducedLabel.Text = @"Sales Produced By Ad Items (A): No Data"; 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) if (Math.Abs(_departmentSales) < 1)
{ {
departmentSalesLabel.Text = @"Department Sales: No Data"; departmentSalesLabel.Text = @"Department Sales: No Data";
@@ -76,7 +75,7 @@ namespace AdvertsingProfitControl
} }
if (Math.Abs(_totalProfitReturnFromAdItems) < 1) 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; incompleteData = true;
} }
if (Math.Abs(_departmentSales) < 1) if (Math.Abs(_departmentSales) < 1)
@@ -94,11 +93,11 @@ namespace AdvertsingProfitControl
var remainingSales = _departmentSales - _salesProducedByAdItems; var remainingSales = _departmentSales - _salesProducedByAdItems;
remainingSalesLabel.Text = @"Remaining Sales: " + remainingSales.ToString("C"); remainingSalesLabel.Text = @"Remaining Sales: " + remainingSales.ToString("C");
//Again assume the total profit return is larger then zero (0). //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. //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; 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; var totalProfitReturn = _totalProfitReturnFromAdItems + totalProfitReturnFromRemainingSales;
totalProfitReturnLabel.Text = @"Total Profit Return: " + totalProfitReturn.ToString("C"); totalProfitReturnLabel.Text = @"Total Profit Return: " + totalProfitReturn.ToString("C");
} }
@@ -125,8 +124,15 @@ namespace AdvertsingProfitControl
private void addRecordToolStripMenuItem_Click(object sender, EventArgs e) private void addRecordToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var form = new NewAddRecord(); var form = new NewAddRecord();
form.ShowDialog(); 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) private void showHideConsoleHelpMainMenu_Click(object sender, EventArgs e)
@@ -153,6 +159,8 @@ namespace AdvertsingProfitControl
{ {
var form = new NewModifyRecord(monthCalendar.SelectionStart); var form = new NewModifyRecord(monthCalendar.SelectionStart);
form.ShowDialog(); 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) private void manageItemsToolsMainMenu_Click(object sender, EventArgs e)
@@ -253,20 +261,6 @@ namespace AdvertsingProfitControl
printDialog.Document = new PrintDocument(); 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 public enum FormRoll
{ {
AddRecords = 0, AddRecords = 0,
@@ -339,7 +333,7 @@ namespace AdvertsingProfitControl
string[] invoicesColumnNames = string[] invoicesColumnNames =
{ {
"InvoiceDate", "Supplier", "InvoiceNumber", "InvoiceNetAmountAtCost", "InvoiceDate", "Supplier", "InvoiceNumber", "InvoiceNetAmountAtCost",
"InvoiceNetAmount", "InvoiceNote" "InvoiceNetAmountExtendedRetail", "InvoiceNote"
}; };
foreach (var name in invoicesColumnNames) foreach (var name in invoicesColumnNames)
@@ -428,6 +422,8 @@ namespace AdvertsingProfitControl
} }
CalculateProfitAnalysis(); CalculateProfitAnalysis();
CalculateGrossProfit(); CalculateGrossProfit();
monthCalendar.BoldedDates = databaseReader.RetrieveDates(databaseTracker.DatabaseConnectionString).ToArray();
monthCalendar.SelectionStart = date;
dateTimeGroupBox.Text = @"Loaded " + date.ToString("d"); dateTimeGroupBox.Text = @"Loaded " + date.ToString("d");
} }
@@ -440,7 +436,7 @@ namespace AdvertsingProfitControl
for (var rowIndex = 0; rowIndex < projections.Rows.Count; rowIndex++) for (var rowIndex = 0; rowIndex < projections.Rows.Count; rowIndex++)
{ {
var newRow = new DataGridViewRow(); 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. //ID and Ad Item.
if (cellIndex == 1) if (cellIndex == 1)
@@ -671,7 +667,7 @@ namespace AdvertsingProfitControl
for (var rowIndex = 0; rowIndex < actualSales.Rows.Count; rowIndex++) for (var rowIndex = 0; rowIndex < actualSales.Rows.Count; rowIndex++)
{ {
var newRow = new DataGridViewRow(); 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. //ID and Ad Item.
if (cellIndex == 1) if (cellIndex == 1)
@@ -849,15 +845,15 @@ namespace AdvertsingProfitControl
var netAmountAtCost = double.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString()); var netAmountAtCost = double.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString());
if (netAmountAtCost.ToString("N2") != "0.00") if (netAmountAtCost.ToString("N2") != "0.00")
{ {
_totalInvoicePurchases += netAmountAtCost; cell.Value = netAmountAtCost.ToString("N2");
cell.Value = netAmountAtCost;
} }
row.Cells.Add(cell); row.Cells.Add(cell);
break; break;
case 5: case 5:
var netAmoundExtendedRetail = double.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString()); var netAmoundExtendedRetail = double.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString());
if (netAmoundExtendedRetail.ToString("N2") != "0.00") if (netAmoundExtendedRetail.ToString("N2") != "0.00")
{ {
_totalInvoicePurchases += netAmoundExtendedRetail;
cell.Value = netAmoundExtendedRetail.ToString("N2"); cell.Value = netAmoundExtendedRetail.ToString("N2");
} }
row.Cells.Add(cell); row.Cells.Add(cell);
@@ -897,7 +893,7 @@ namespace AdvertsingProfitControl
if (dollarAmount.ToString("N2") != "0.00") if (dollarAmount.ToString("N2") != "0.00")
{ {
_departmentSales += dollarAmount; _departmentSales += dollarAmount;
sundayWeeklySalesLabel.Text = @"Sunday: $" + dollarAmount; sundayWeeklySalesLabel.Text = @"Sunday: $" + dollarAmount.ToString("N2");
} }
else else
{ {
@@ -909,7 +905,7 @@ namespace AdvertsingProfitControl
if (dollarAmount.ToString("N2") != "0.00") if (dollarAmount.ToString("N2") != "0.00")
{ {
_departmentSales += dollarAmount; _departmentSales += dollarAmount;
mondayWeeklySalesLabel.Text = @"Monday: $" + dollarAmount; mondayWeeklySalesLabel.Text = @"Monday: $" + dollarAmount.ToString("N2");
} }
else else
{ {
@@ -921,7 +917,7 @@ namespace AdvertsingProfitControl
if (dollarAmount.ToString("N2") != "0.00") if (dollarAmount.ToString("N2") != "0.00")
{ {
_departmentSales += dollarAmount; _departmentSales += dollarAmount;
tuesadayWeeklySalesLabel.Text = @"Tuesday: $" + dollarAmount; tuesadayWeeklySalesLabel.Text = @"Tuesday: $" + dollarAmount.ToString("N2");
} }
else else
{ {
@@ -933,7 +929,7 @@ namespace AdvertsingProfitControl
if (dollarAmount.ToString("N2") != "0.00") if (dollarAmount.ToString("N2") != "0.00")
{ {
_departmentSales += dollarAmount; _departmentSales += dollarAmount;
wednesdayWeeklySalesLabel.Text = @"Wednesday: $" + dollarAmount; wednesdayWeeklySalesLabel.Text = @"Wednesday: $" + dollarAmount.ToString("N2");
} }
else else
{ {
@@ -945,7 +941,7 @@ namespace AdvertsingProfitControl
if (dollarAmount.ToString("N2") != "0.00") if (dollarAmount.ToString("N2") != "0.00")
{ {
_departmentSales += dollarAmount; _departmentSales += dollarAmount;
thursdayWeeklySalesLabel.Text = @"Thursday: $" + dollarAmount; thursdayWeeklySalesLabel.Text = @"Thursday: $" + dollarAmount.ToString("N2");
} }
else else
{ {
@@ -957,7 +953,7 @@ namespace AdvertsingProfitControl
if (dollarAmount.ToString("N2") != "0.00") if (dollarAmount.ToString("N2") != "0.00")
{ {
_departmentSales += dollarAmount; _departmentSales += dollarAmount;
fridayWeeklySalesLabel.Text = @"Friday: $" + dollarAmount; fridayWeeklySalesLabel.Text = @"Friday: $" + dollarAmount.ToString("N2");
} }
else else
{ {
@@ -969,7 +965,7 @@ namespace AdvertsingProfitControl
if (dollarAmount.ToString("N2") != "0.00") if (dollarAmount.ToString("N2") != "0.00")
{ {
_departmentSales += dollarAmount; _departmentSales += dollarAmount;
saturdayWeeklySalesLabel.Text = @"Saturday: $" + dollarAmount; saturdayWeeklySalesLabel.Text = @"Saturday: $" + dollarAmount.ToString("N2");
} }
else else
{ {
@@ -980,7 +976,7 @@ namespace AdvertsingProfitControl
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()); dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
if (dollarAmount.ToString("N2") != "0.00") if (dollarAmount.ToString("N2") != "0.00")
{ {
totalWeeklySalesLabel.Text = @"Total Sales: $" + dollarAmount; totalWeeklySalesLabel.Text = @"Total Sales: $" + dollarAmount.ToString("N2");
} }
else else
{ {
@@ -1165,7 +1161,8 @@ namespace AdvertsingProfitControl
switch (holiday) switch (holiday)
{ {
case Holidays.Thanksgiving: case Holidays.Thanksgiving:
case Holidays.Christmas: case Holidays.Christmas:
case Holidays.NewYearsDay:
holidayText = @"Closed for " + TextFormat.AddSpacesToSentence(holiday.ToString(), false); holidayText = @"Closed for " + TextFormat.AddSpacesToSentence(holiday.ToString(), false);
break; break;
} }
@@ -1215,20 +1212,28 @@ namespace AdvertsingProfitControl
departmentSalesLabel.Text = @"Department Sales: "; departmentSalesLabel.Text = @"Department Sales: ";
salesProducedLabel.Text = @"Sales Produced By Ad Items (A):"; salesProducedLabel.Text = @"Sales Produced By Ad Items (A):";
remainingSalesLabel.Text = @"Remaining Sales:"; remainingSalesLabel.Text = @"Remaining Sales:";
totalProfitFromAdItemsLabel.Text = @"Total Profit Return From Ad Items (B): "; totalProfitFromAdItemsLabel.Text = @"Total Profit Return" + Environment.NewLine + @" From Ad Items (B): ";
totalProfitReturnFromRemaingLabel.Text = @"Total Profit Return From Remaining Sales: "; totalProfitReturnFromRemaingLabel.Text = @"Total Profit Return" + Environment.NewLine + @" From Remaining Sales: ";
totalProfitReturnLabel.Text = @"Total Profit Return: "; totalProfitReturnLabel.Text = @"Total Profit Return: ";
grossProfitTotalSales.Text = @"Total Sales:"; grossProfitTotalSales.Text = @"Total Sales:";
grossProfitLessCostOfSales.Text = @"Less Cost of Sales: "; grossProfitLessCostOfSales.Text = @"Less Cost of Sales: ";
grossProfitDollarGrossProfitLabel.Text = @"Dollar Gross Profit: "; grossProfitDollarGrossProfitLabel.Text = @"Dollar Gross Profit: ";
perfectGrossProfitLabel.Text = @"Percent 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) private void debugToolStripMenuItem1_Click(object sender, EventArgs e)
{ {
var form = new DebugDatabaseConverter(); var form = new DebugDatabaseConverter();
form.ShowDialog(); form.ShowDialog();
RefreshDateListing();
}
private void RefreshDateListing()
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
monthCalendar.BoldedDates = databaseReader.RetrieveDates(databaseTracker.DatabaseConnectionString).ToArray();
} }
} }
} }
+9 -5
View File
@@ -32,6 +32,7 @@ namespace AdvertsingProfitControl
//Flag showing whether or not the AdSpecialRow has been made in this session. //Flag showing whether or not the AdSpecialRow has been made in this session.
private int _adSpecialIndex = -1; private int _adSpecialIndex = -1;
private readonly AdvertisingProfitControlTableHelper _tableHelperFunctions = new AdvertisingProfitControlTableHelper(); private readonly AdvertisingProfitControlTableHelper _tableHelperFunctions = new AdvertisingProfitControlTableHelper();
private TabPage _debugTabPage;
public NewAddRecord() public NewAddRecord()
{ {
@@ -145,6 +146,9 @@ namespace AdvertsingProfitControl
salaryDollarsTextBox.Validating += ValidateCostAnalysisValues; salaryDollarsTextBox.Validating += ValidateCostAnalysisValues;
suppliesTextBox.Enter += StoreBeginningTextBoxValue; suppliesTextBox.Enter += StoreBeginningTextBoxValue;
suppliesTextBox.Validating += ValidateCostAnalysisValues; suppliesTextBox.Validating += ValidateCostAnalysisValues;
//
_debugTabPage = mainTabControl.TabPages[4];
mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]);
} }
#region Invoice Table Events #region Invoice Table Events
@@ -1741,7 +1745,7 @@ namespace AdvertsingProfitControl
HeaderText = TextFormat.AddSpacesToSentence(name, false), HeaderText = TextFormat.AddSpacesToSentence(name, false),
ValueType = typeof(string), ValueType = typeof(string),
SortMode = DataGridViewColumnSortMode.NotSortable, SortMode = DataGridViewColumnSortMode.NotSortable,
MaxInputLength = 20 MaxInputLength = 32
}; };
if (name.Contains("ID")) if (name.Contains("ID"))
{ {
@@ -1777,7 +1781,7 @@ namespace AdvertsingProfitControl
HeaderText = TextFormat.AddSpacesToSentence(name, false), HeaderText = TextFormat.AddSpacesToSentence(name, false),
ValueType = typeof(string), ValueType = typeof(string),
SortMode = DataGridViewColumnSortMode.NotSortable, SortMode = DataGridViewColumnSortMode.NotSortable,
MaxInputLength = 20 MaxInputLength = 32
}; };
if (name.Contains("ID")) if (name.Contains("ID"))
{ {
@@ -1813,7 +1817,7 @@ namespace AdvertsingProfitControl
HeaderText = TextFormat.AddSpacesToSentence(name, false), HeaderText = TextFormat.AddSpacesToSentence(name, false),
ValueType = typeof(string), ValueType = typeof(string),
SortMode = DataGridViewColumnSortMode.NotSortable, SortMode = DataGridViewColumnSortMode.NotSortable,
MaxInputLength = 20 MaxInputLength = 32
}; };
if (name.Contains("ID")) if (name.Contains("ID"))
{ {
@@ -1845,7 +1849,7 @@ namespace AdvertsingProfitControl
/// </summary> /// </summary>
private void ConstructInvoicesDataGridView() private void ConstructInvoicesDataGridView()
{ {
string[] invoicesColumnNames = { "ID", "InvoiceDate", "Supplier", "InvoiceNumber", "InvoiceNetAmountAtCost", "InvoiceNetAmount", "InvoiceNote", "IsDirty"}; string[] invoicesColumnNames = { "ID", "InvoiceDate", "Supplier", "InvoiceNumber", "InvoiceNetAmountAtCost", "InvoiceNetAmountExtendedRetail", "InvoiceNote", "IsDirty"};
foreach (var name in invoicesColumnNames) foreach (var name in invoicesColumnNames)
{ {
@@ -1857,7 +1861,7 @@ namespace AdvertsingProfitControl
HeaderText = TextFormat.AddSpacesToSentence(name, false), HeaderText = TextFormat.AddSpacesToSentence(name, false),
ValueType = typeof(string), ValueType = typeof(string),
SortMode = DataGridViewColumnSortMode.NotSortable, SortMode = DataGridViewColumnSortMode.NotSortable,
MaxInputLength = 20 MaxInputLength = 32
}; };
if (name.Contains("ID")) if (name.Contains("ID"))
{ {
+9 -5
View File
@@ -37,6 +37,7 @@ namespace AdvertsingProfitControl
private DateTime _currentActiveDate; private DateTime _currentActiveDate;
// //
private bool _isFormDirty; private bool _isFormDirty;
private TabPage _debugTabPage;
public NewModifyRecord(DateTime date) public NewModifyRecord(DateTime date)
{ {
@@ -155,6 +156,9 @@ namespace AdvertsingProfitControl
salaryDollarsTextBox.Validating += ValidateCostAnalysisValues; salaryDollarsTextBox.Validating += ValidateCostAnalysisValues;
suppliesTextBox.Enter += StoreBeginningTextBoxValue; suppliesTextBox.Enter += StoreBeginningTextBoxValue;
suppliesTextBox.Validating += ValidateCostAnalysisValues; suppliesTextBox.Validating += ValidateCostAnalysisValues;
//
_debugTabPage = mainTabControl.TabPages[4];
mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]);
LoadDate(date); LoadDate(date);
} }
@@ -1772,7 +1776,7 @@ namespace AdvertsingProfitControl
HeaderText = TextFormat.AddSpacesToSentence(name, false), HeaderText = TextFormat.AddSpacesToSentence(name, false),
ValueType = typeof(string), ValueType = typeof(string),
SortMode = DataGridViewColumnSortMode.NotSortable, SortMode = DataGridViewColumnSortMode.NotSortable,
MaxInputLength = 20 MaxInputLength = 32
}; };
if (name.Contains("ID")) if (name.Contains("ID"))
{ {
@@ -1808,7 +1812,7 @@ namespace AdvertsingProfitControl
HeaderText = TextFormat.AddSpacesToSentence(name, false), HeaderText = TextFormat.AddSpacesToSentence(name, false),
ValueType = typeof(string), ValueType = typeof(string),
SortMode = DataGridViewColumnSortMode.NotSortable, SortMode = DataGridViewColumnSortMode.NotSortable,
MaxInputLength = 20 MaxInputLength = 32
}; };
if (name.Contains("ID")) if (name.Contains("ID"))
{ {
@@ -1844,7 +1848,7 @@ namespace AdvertsingProfitControl
HeaderText = TextFormat.AddSpacesToSentence(name, false), HeaderText = TextFormat.AddSpacesToSentence(name, false),
ValueType = typeof(string), ValueType = typeof(string),
SortMode = DataGridViewColumnSortMode.NotSortable, SortMode = DataGridViewColumnSortMode.NotSortable,
MaxInputLength = 20 MaxInputLength = 32
}; };
if (name.Contains("ID")) if (name.Contains("ID"))
{ {
@@ -1876,7 +1880,7 @@ namespace AdvertsingProfitControl
/// </summary> /// </summary>
private void ConstructInvoicesDataGridView() private void ConstructInvoicesDataGridView()
{ {
string[] invoicesColumnNames = { "ID", "InvoiceDate", "Supplier", "InvoiceNumber", "InvoiceNetAmountAtCost", "InvoiceNetAmount", "InvoiceNote", "IsDirty" }; string[] invoicesColumnNames = { "ID", "InvoiceDate", "Supplier", "InvoiceNumber", "InvoiceNetAmountAtCost", "InvoiceNetAmountExtendedRetail", "InvoiceNote", "IsDirty" };
foreach (var name in invoicesColumnNames) foreach (var name in invoicesColumnNames)
{ {
@@ -1888,7 +1892,7 @@ namespace AdvertsingProfitControl
HeaderText = TextFormat.AddSpacesToSentence(name, false), HeaderText = TextFormat.AddSpacesToSentence(name, false),
ValueType = typeof(string), ValueType = typeof(string),
SortMode = DataGridViewColumnSortMode.NotSortable, SortMode = DataGridViewColumnSortMode.NotSortable,
MaxInputLength = 20 MaxInputLength = 32
}; };
if (name.Contains("ID")) if (name.Contains("ID"))
{ {
@@ -14,7 +14,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>ZmIrPQhvIF7GlBAJN0yBg3h1MuQtzkOJb1/UsrzEMy4=</dsig:DigestValue> <dsig:DigestValue>nyOAXUjfnUbIVrYC0oB0cu8gLrSavJvwTjvTea8xOas=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
@@ -43,14 +43,14 @@
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
<dependency> <dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="3640832"> <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="3641856">
<assemblyIdentity name="AdvertsingProfitControl" version="0.9.5.2" language="neutral" processorArchitecture="amd64" /> <assemblyIdentity name="AdvertsingProfitControl" version="0.9.5.2" language="neutral" processorArchitecture="amd64" />
<hash> <hash>
<dsig:Transforms> <dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>SWhDdqr4Cdz7+qIONWqHGBLDH1kQ6iFOt1ruAj6rHJo=</dsig:DigestValue> <dsig:DigestValue>ls/iyC2eDGY0BQ9Li7lpS1H7GbQd5K5JGHSlWNDaCgA=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
@@ -87,13 +87,13 @@
<dsig:DigestValue>e48EkTyChGHXYJETENSLw7RKQ1LZ5ZDUghEtiv5DmqY=</dsig:DigestValue> <dsig:DigestValue>e48EkTyChGHXYJETENSLw7RKQ1LZ5ZDUghEtiv5DmqY=</dsig:DigestValue>
</hash> </hash>
</file> </file>
<file name="APCDatabase.accdb" size="851968"> <file name="APCDatabase.accdb" size="864256">
<hash> <hash>
<dsig:Transforms> <dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>nhqBAxGBZPH2N33Fm5tbmCgDtejNQUBm/H3EHe0p9bg=</dsig:DigestValue> <dsig:DigestValue>eoYVACg6mHeh3mJvCxuTkhCu87etUvZtA+DNmRHH5Vo=</dsig:DigestValue>
</hash> </hash>
</file> </file>
<file name="APCTemplate.accdb" size="819200"> <file name="APCTemplate.accdb" size="819200">