diff --git a/AdvertsingProfitControl/APCDatabase.accdb b/AdvertsingProfitControl/APCDatabase.accdb
index 6096142..78d0dd7 100644
Binary files a/AdvertsingProfitControl/APCDatabase.accdb and b/AdvertsingProfitControl/APCDatabase.accdb differ
diff --git a/AdvertsingProfitControl/AdvertisingProfitControlTableHelper.cs b/AdvertsingProfitControl/AdvertisingProfitControlTableHelper.cs
index 39fda49..a4d259e 100644
--- a/AdvertsingProfitControl/AdvertisingProfitControlTableHelper.cs
+++ b/AdvertsingProfitControl/AdvertisingProfitControlTableHelper.cs
@@ -289,6 +289,7 @@ namespace AdvertsingProfitControl
InvoiceNote = 6,
IsDirty = 7
}
+
///
/// TODO: Push into a stand alone object.
///
diff --git a/AdvertsingProfitControl/AdvertsingProfitControl.csproj b/AdvertsingProfitControl/AdvertsingProfitControl.csproj
index 6c623b6..1e3db06 100644
--- a/AdvertsingProfitControl/AdvertsingProfitControl.csproj
+++ b/AdvertsingProfitControl/AdvertsingProfitControl.csproj
@@ -106,6 +106,7 @@
+
diff --git a/AdvertsingProfitControl/ApplicationColors.cs b/AdvertsingProfitControl/ApplicationColors.cs
new file mode 100644
index 0000000..2a5c340
--- /dev/null
+++ b/AdvertsingProfitControl/ApplicationColors.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AdvertsingProfitControl
+{
+ ///
+ /// Defines the colors to be used for the rows on the DataGridViews based on their state.
+ ///
+ public static class ApplicationColors
+ {
+ public static Color EditingSaved = Color.ForestGreen;
+ public static Color PendingEdit = Color.Yellow;
+ public static Color RowError = Color.Red;
+ public static Color HeaderRow = Color.LightGray;
+ public static Color MemberRow = Color.LightBlue;
+ }
+}
diff --git a/AdvertsingProfitControl/DatabaseWriter.cs b/AdvertsingProfitControl/DatabaseWriter.cs
index 6de077b..fd405c7 100644
--- a/AdvertsingProfitControl/DatabaseWriter.cs
+++ b/AdvertsingProfitControl/DatabaseWriter.cs
@@ -532,21 +532,15 @@ namespace AdvertsingProfitControl
{
Connection = oleDbConnection
};
- OleDbTransaction oleDbTransaction = null;
try
{
oleDbConnection.Open();
- oleDbTransaction = oleDbConnection.BeginTransaction();
- oleDbCommand.Transaction = oleDbTransaction;
-
if (id == 0)
{
oleDbCommand.CommandText = "INSERT INTO Comment (Comment, FK_DateID) VALUES (?, ?)";
oleDbCommand.Parameters.AddWithValue("Comment", comments);
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
oleDbCommand.ExecuteNonQuery();
- //If the execute non query didn't throw an exception then we're good to go.
- oleDbTransaction.Commit();
//Now grab the ID number of the comment that was just added.
oleDbCommand.CommandText = "SELECT ID FROM Comment WHERE FK_DateID = ?";
oleDbCommand.Parameters.Clear();
@@ -564,8 +558,6 @@ namespace AdvertsingProfitControl
oleDbCommand.Parameters.AddWithValue("Comment", comments);
oleDbCommand.Parameters.AddWithValue("ID", id);
oleDbCommand.ExecuteNonQuery();
- //If the execute non query didn't throw an exception then we're good to go.
- oleDbTransaction.Commit();
}
}
catch (OleDbException e)
@@ -573,7 +565,6 @@ namespace AdvertsingProfitControl
status.SetStatus(WritingOperationStatus.Failed);
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed to process the comment(s): " + e.Message);
status.SetErrorMessage("Failed to update or insert comments into the database.");
- oleDbTransaction?.Rollback();
}
finally
{
@@ -590,12 +581,9 @@ namespace AdvertsingProfitControl
{
Connection = oleDbConnection
};
- OleDbTransaction oleDbTransaction = null;
try
{
oleDbConnection.Open();
- oleDbTransaction = oleDbConnection.BeginTransaction();
- oleDbCommand.Transaction = oleDbTransaction;
if (id == 0)
{
@@ -610,8 +598,6 @@ namespace AdvertsingProfitControl
oleDbCommand.Parameters.AddWithValue("TotalSales", weeklySales[7]);
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
oleDbCommand.ExecuteNonQuery();
- //If the execute non query didn't throw an exception then we're good to go.
- oleDbTransaction.Commit();
//Now grab the ID number of the comment that was just added.
oleDbCommand.CommandText = "SELECT ID FROM WeeklySales WHERE FK_DateID = ?";
oleDbCommand.Parameters.Clear();
@@ -636,8 +622,6 @@ namespace AdvertsingProfitControl
oleDbCommand.Parameters.AddWithValue("TotalSales", weeklySales[7]);
oleDbCommand.Parameters.AddWithValue("ID", id);
oleDbCommand.ExecuteNonQuery();
- //If the execute non query didn't throw an exception then we're good to go.
- oleDbTransaction.Commit();
}
}
catch (OleDbException e)
@@ -645,7 +629,126 @@ namespace AdvertsingProfitControl
status.SetStatus(WritingOperationStatus.Failed);
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed to process the weekly sales: " + e.Message);
status.SetErrorMessage("Failed to update or insert weekly sales into the database.");
- oleDbTransaction?.Rollback();
+ }
+ finally
+ {
+ oleDbConnection.Close();
+ }
+ return status;
+ }
+
+ public DbWriterStatus ProcessTaxable(double[] taxable, int dateId, string connectionString, int id = 0)
+ {
+ var status = new DbWriterStatus();
+ var oleDbConnection = new OleDbConnection(connectionString);
+ var oleDbCommand = new OleDbCommand
+ {
+ Connection = oleDbConnection
+ };
+ try
+ {
+ oleDbConnection.Open();
+
+ if (id == 0)
+ {
+ oleDbCommand.CommandText = "INSERT INTO Taxable (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Total, FK_DateID) VALUES (?,?,?,?,?,?,?,?,?)";
+ oleDbCommand.Parameters.AddWithValue("Sunday", taxable[0]);
+ oleDbCommand.Parameters.AddWithValue("Monday", taxable[1]);
+ oleDbCommand.Parameters.AddWithValue("Tuesday", taxable[2]);
+ oleDbCommand.Parameters.AddWithValue("Wednesday", taxable[3]);
+ oleDbCommand.Parameters.AddWithValue("Thursday", taxable[4]);
+ oleDbCommand.Parameters.AddWithValue("Friday", taxable[5]);
+ oleDbCommand.Parameters.AddWithValue("Saturday", taxable[6]);
+ oleDbCommand.Parameters.AddWithValue("TotalSales", taxable[7]);
+ oleDbCommand.Parameters.AddWithValue("DateID", dateId);
+ oleDbCommand.ExecuteNonQuery();
+ //Now grab the ID number of the comment that was just added.
+ oleDbCommand.CommandText = "SELECT ID FROM Taxable WHERE FK_DateID = ?";
+ oleDbCommand.Parameters.Clear();
+ oleDbCommand.Parameters.AddWithValue("DateID", dateId);
+ //Now read the ID number and add it to the collection with a default key.
+ var reader = oleDbCommand.ExecuteReader();
+ while (reader != null && reader.Read())
+ {
+ status.AddRowId(0, int.Parse(reader[0].ToString()));
+ }
+ }
+ else
+ {
+ oleDbCommand.CommandText = "UPDATE Taxable SET Sunday = ?, Monday = ?, Tuesday = ?, Wednesday = ?, Thursday = ?, Friday = ?, Saturday = ?, Total = ? WHERE ID = ?";
+ oleDbCommand.Parameters.AddWithValue("Sunday", taxable[0]);
+ oleDbCommand.Parameters.AddWithValue("Monday", taxable[1]);
+ oleDbCommand.Parameters.AddWithValue("Tuesday", taxable[2]);
+ oleDbCommand.Parameters.AddWithValue("Wednesday", taxable[3]);
+ oleDbCommand.Parameters.AddWithValue("Thursday", taxable[4]);
+ oleDbCommand.Parameters.AddWithValue("Friday", taxable[5]);
+ oleDbCommand.Parameters.AddWithValue("Saturday", taxable[6]);
+ oleDbCommand.Parameters.AddWithValue("TotalSales", taxable[7]);
+ oleDbCommand.Parameters.AddWithValue("ID", id);
+ oleDbCommand.ExecuteNonQuery();
+ }
+ }
+ catch (OleDbException e)
+ {
+ status.SetStatus(WritingOperationStatus.Failed);
+ _logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed to process the taxable: " + e.Message);
+ status.SetErrorMessage("Failed to update or insert taxable into the database.");
+ }
+ finally
+ {
+ oleDbConnection.Close();
+ }
+ return status;
+ }
+
+ public DbWriterStatus ProcessCostAnalysis(double[] costAnalysis, int dateId, string connectionString, int id = 0)
+ {
+ var status = new DbWriterStatus();
+ var oleDbConnection = new OleDbConnection(connectionString);
+ var oleDbCommand = new OleDbCommand
+ {
+ Connection = oleDbConnection
+ };
+ try
+ {
+ oleDbConnection.Open();
+
+ if (id == 0)
+ {
+ oleDbCommand.CommandText = "INSERT INTO CostOfSalesAnalysis (SalesPerManHour, SalaryPercentage, SalaryDollars, Supplies, FK_dateID) VALUES (?,?,?,?,?)";
+ oleDbCommand.Parameters.AddWithValue("SalesPerManHour", costAnalysis[0]);
+ oleDbCommand.Parameters.AddWithValue("SalaryPercentage", costAnalysis[1]);
+ oleDbCommand.Parameters.AddWithValue("SalaryDollars", costAnalysis[2]);
+ oleDbCommand.Parameters.AddWithValue("Supplies", costAnalysis[3]);
+ oleDbCommand.Parameters.AddWithValue("DateID", dateId);
+ oleDbCommand.ExecuteNonQuery();
+ //Now grab the ID number of the comment that was just added.
+ oleDbCommand.CommandText = "SELECT ID FROM Taxable WHERE FK_DateID = ?";
+ oleDbCommand.Parameters.Clear();
+ oleDbCommand.Parameters.AddWithValue("DateID", dateId);
+ //Now read the ID number and add it to the collection with a default key.
+ var reader = oleDbCommand.ExecuteReader();
+ while (reader != null && reader.Read())
+ {
+ status.AddRowId(0, int.Parse(reader[0].ToString()));
+ }
+ }
+ else
+ {
+ oleDbCommand.CommandText = "UPDATE CostOfSalesAnalysis SET SalesPerManHour = ?, SalaryPercentage = ?, SalaryDollars = ?, Supplies = ? WHERE ID = ?";
+ oleDbCommand.Parameters.AddWithValue("SalesPerManHour", costAnalysis[0]);
+ oleDbCommand.Parameters.AddWithValue("SalaryPercentage", costAnalysis[1]);
+ oleDbCommand.Parameters.AddWithValue("SalaryDollars", costAnalysis[2]);
+ oleDbCommand.Parameters.AddWithValue("Supplies", costAnalysis[3]);
+ oleDbCommand.Parameters.AddWithValue("ID", id);
+ oleDbCommand.ExecuteNonQuery();
+ }
+ }
+ catch (OleDbException e)
+ {
+ status.SetStatus(WritingOperationStatus.Failed);
+ _logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed to process the taxable: " + e.Message);
+ status.SetErrorMessage("Failed to update or insert taxable into the database.");
}
finally
{
diff --git a/AdvertsingProfitControl/DbWriterStatus.cs b/AdvertsingProfitControl/DbWriterStatus.cs
index 0471b88..8af4ede 100644
--- a/AdvertsingProfitControl/DbWriterStatus.cs
+++ b/AdvertsingProfitControl/DbWriterStatus.cs
@@ -30,11 +30,11 @@ namespace AdvertsingProfitControl
/// Adds a row to the Rows Dictionary that keeps track of what rows have been
/// added to the database including their IDs.
///
- /// The index of the row that was added to the database.
+ /// The index of the row that was added to the database.
/// The ID number of the row as represented in the database.
- public void AddRowId(int key, int rowIdNumber)
+ public void AddRowId(int rowIndex, int rowIdNumber)
{
- _rowIds.Add(key, rowIdNumber);
+ _rowIds.Add(rowIndex, rowIdNumber);
}
///
/// Removes a row from the Rows collection.
diff --git a/AdvertsingProfitControl/NewAddRecord.Designer.cs b/AdvertsingProfitControl/NewAddRecord.Designer.cs
index 4a96747..c143974 100644
--- a/AdvertsingProfitControl/NewAddRecord.Designer.cs
+++ b/AdvertsingProfitControl/NewAddRecord.Designer.cs
@@ -41,8 +41,19 @@
this.invoicesTabPage = new System.Windows.Forms.TabPage();
this.invoicesDataGridView = new System.Windows.Forms.DataGridView();
this.debugTabPage = new System.Windows.Forms.TabPage();
+ this.debugPanel = new System.Windows.Forms.Panel();
+ this.generateCostAnalysisIdButton = new System.Windows.Forms.Button();
+ this.generateTaxableIdButton = new System.Windows.Forms.Button();
+ this.generateWeeklySalesIdButton = new System.Windows.Forms.Button();
+ this.reminderLabel = new System.Windows.Forms.Label();
+ this.generateCommentIdButton = new System.Windows.Forms.Button();
+ this.isCostAnalysisDirtyCheckBox = new System.Windows.Forms.CheckBox();
+ this.isTaxableDirtyCheckBox = new System.Windows.Forms.CheckBox();
+ this.isWeeklySalesDirtyCheckBox = new System.Windows.Forms.CheckBox();
+ this.isCommentDirtyCheckBox = new System.Windows.Forms.CheckBox();
this.mainMenuStrip = new System.Windows.Forms.MenuStrip();
this.FileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
+ this.clearFormFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.exitFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.mainLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.costAnalysisGroupBox = new System.Windows.Forms.GroupBox();
@@ -99,17 +110,6 @@
this.informationPanel = new System.Windows.Forms.Panel();
this.informationLabel = new System.Windows.Forms.Label();
this.addRecordButton = new System.Windows.Forms.Button();
- this.debugPanel = new System.Windows.Forms.Panel();
- this.isCommentDirtyCheckBox = new System.Windows.Forms.CheckBox();
- this.isWeeklySalesDirtyCheckBox = new System.Windows.Forms.CheckBox();
- this.isTaxableDirtyCheckBox = new System.Windows.Forms.CheckBox();
- this.isCostAnalysisDirtyCheckBox = new System.Windows.Forms.CheckBox();
- this.clearFormFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
- this.generateCommentIdButton = new System.Windows.Forms.Button();
- this.reminderLabel = new System.Windows.Forms.Label();
- this.generateWeeklySalesIdButton = new System.Windows.Forms.Button();
- this.generateTaxableIdButton = new System.Windows.Forms.Button();
- this.generateCostAnalysisIdButton = new System.Windows.Forms.Button();
this.commentsGroupBox.SuspendLayout();
this.mainTabControl.SuspendLayout();
this.projectionTabPage.SuspendLayout();
@@ -121,6 +121,7 @@
this.invoicesTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.invoicesDataGridView)).BeginInit();
this.debugTabPage.SuspendLayout();
+ this.debugPanel.SuspendLayout();
this.mainMenuStrip.SuspendLayout();
this.mainLayoutPanel.SuspendLayout();
this.costAnalysisGroupBox.SuspendLayout();
@@ -130,11 +131,11 @@
this.dateGroupBox.SuspendLayout();
this.dateTimeMaskedTextBoxPanel.SuspendLayout();
this.informationPanel.SuspendLayout();
- this.debugPanel.SuspendLayout();
this.SuspendLayout();
//
// commentsGroupBox
//
+ this.commentsGroupBox.BackColor = System.Drawing.SystemColors.Control;
this.commentsGroupBox.Controls.Add(this.commentsTextBox);
this.commentsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.commentsGroupBox.Location = new System.Drawing.Point(473, 594);
@@ -192,10 +193,12 @@
this.projectionsDataGridView.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.projectionsDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.projectionsDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.projectionsDataGridView.EnableHeadersVisualStyles = false;
this.projectionsDataGridView.Location = new System.Drawing.Point(0, 0);
this.projectionsDataGridView.Margin = new System.Windows.Forms.Padding(4);
this.projectionsDataGridView.MultiSelect = false;
this.projectionsDataGridView.Name = "projectionsDataGridView";
+ this.projectionsDataGridView.RowHeadersWidth = 70;
this.projectionsDataGridView.RowTemplate.Height = 28;
this.projectionsDataGridView.Size = new System.Drawing.Size(1860, 510);
this.projectionsDataGridView.TabIndex = 2;
@@ -219,10 +222,12 @@
this.inventoryDataGridView.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.inventoryDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.inventoryDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.inventoryDataGridView.EnableHeadersVisualStyles = false;
this.inventoryDataGridView.Location = new System.Drawing.Point(0, 0);
this.inventoryDataGridView.Margin = new System.Windows.Forms.Padding(4);
this.inventoryDataGridView.MultiSelect = false;
this.inventoryDataGridView.Name = "inventoryDataGridView";
+ this.inventoryDataGridView.RowHeadersWidth = 70;
this.inventoryDataGridView.RowTemplate.Height = 28;
this.inventoryDataGridView.Size = new System.Drawing.Size(1860, 510);
this.inventoryDataGridView.TabIndex = 1;
@@ -246,10 +251,12 @@
this.actualSalesDataGridView.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.actualSalesDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.actualSalesDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.actualSalesDataGridView.EnableHeadersVisualStyles = false;
this.actualSalesDataGridView.Location = new System.Drawing.Point(0, 0);
this.actualSalesDataGridView.Margin = new System.Windows.Forms.Padding(4);
this.actualSalesDataGridView.MultiSelect = false;
this.actualSalesDataGridView.Name = "actualSalesDataGridView";
+ this.actualSalesDataGridView.RowHeadersWidth = 70;
this.actualSalesDataGridView.RowTemplate.Height = 28;
this.actualSalesDataGridView.Size = new System.Drawing.Size(1860, 510);
this.actualSalesDataGridView.TabIndex = 1;
@@ -273,10 +280,12 @@
this.invoicesDataGridView.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.invoicesDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.invoicesDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.invoicesDataGridView.EnableHeadersVisualStyles = false;
this.invoicesDataGridView.Location = new System.Drawing.Point(0, 0);
this.invoicesDataGridView.Margin = new System.Windows.Forms.Padding(4);
this.invoicesDataGridView.MultiSelect = false;
this.invoicesDataGridView.Name = "invoicesDataGridView";
+ this.invoicesDataGridView.RowHeadersWidth = 70;
this.invoicesDataGridView.RowTemplate.Height = 28;
this.invoicesDataGridView.Size = new System.Drawing.Size(1860, 510);
this.invoicesDataGridView.TabIndex = 1;
@@ -292,6 +301,112 @@
this.debugTabPage.Text = "DEBUG";
this.debugTabPage.UseVisualStyleBackColor = true;
//
+ // debugPanel
+ //
+ this.debugPanel.Controls.Add(this.generateCostAnalysisIdButton);
+ this.debugPanel.Controls.Add(this.generateTaxableIdButton);
+ this.debugPanel.Controls.Add(this.generateWeeklySalesIdButton);
+ this.debugPanel.Controls.Add(this.reminderLabel);
+ this.debugPanel.Controls.Add(this.generateCommentIdButton);
+ this.debugPanel.Controls.Add(this.isCostAnalysisDirtyCheckBox);
+ this.debugPanel.Controls.Add(this.isTaxableDirtyCheckBox);
+ this.debugPanel.Controls.Add(this.isWeeklySalesDirtyCheckBox);
+ this.debugPanel.Controls.Add(this.isCommentDirtyCheckBox);
+ this.debugPanel.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.debugPanel.Location = new System.Drawing.Point(3, 3);
+ this.debugPanel.Name = "debugPanel";
+ this.debugPanel.Size = new System.Drawing.Size(1854, 504);
+ this.debugPanel.TabIndex = 0;
+ //
+ // generateCostAnalysisIdButton
+ //
+ this.generateCostAnalysisIdButton.Location = new System.Drawing.Point(931, 283);
+ this.generateCostAnalysisIdButton.Name = "generateCostAnalysisIdButton";
+ this.generateCostAnalysisIdButton.Size = new System.Drawing.Size(299, 62);
+ this.generateCostAnalysisIdButton.TabIndex = 8;
+ this.generateCostAnalysisIdButton.Text = "Create / Clear Cost Analysis ID";
+ this.generateCostAnalysisIdButton.UseVisualStyleBackColor = true;
+ this.generateCostAnalysisIdButton.Click += new System.EventHandler(this.generateCostAnalysisIdButton_Click);
+ //
+ // generateTaxableIdButton
+ //
+ this.generateTaxableIdButton.Location = new System.Drawing.Point(638, 283);
+ this.generateTaxableIdButton.Name = "generateTaxableIdButton";
+ this.generateTaxableIdButton.Size = new System.Drawing.Size(286, 62);
+ this.generateTaxableIdButton.TabIndex = 7;
+ this.generateTaxableIdButton.Text = "Create / Clear Taxable ID";
+ this.generateTaxableIdButton.UseVisualStyleBackColor = true;
+ this.generateTaxableIdButton.Click += new System.EventHandler(this.generateTaxableIdButton_Click);
+ //
+ // generateWeeklySalesIdButton
+ //
+ this.generateWeeklySalesIdButton.Location = new System.Drawing.Point(346, 283);
+ this.generateWeeklySalesIdButton.Name = "generateWeeklySalesIdButton";
+ this.generateWeeklySalesIdButton.Size = new System.Drawing.Size(286, 62);
+ this.generateWeeklySalesIdButton.TabIndex = 6;
+ this.generateWeeklySalesIdButton.Text = "Create / Clear Weekly Sales ID";
+ this.generateWeeklySalesIdButton.UseVisualStyleBackColor = true;
+ this.generateWeeklySalesIdButton.Click += new System.EventHandler(this.generateWeeklySalesIdButton_Click);
+ //
+ // reminderLabel
+ //
+ this.reminderLabel.AutoSize = true;
+ this.reminderLabel.Location = new System.Drawing.Point(82, 94);
+ this.reminderLabel.Name = "reminderLabel";
+ this.reminderLabel.Size = new System.Drawing.Size(659, 25);
+ this.reminderLabel.TabIndex = 5;
+ this.reminderLabel.Text = "These checkboxes Tag properties hold the ID for their respective elements.";
+ //
+ // generateCommentIdButton
+ //
+ this.generateCommentIdButton.Location = new System.Drawing.Point(54, 283);
+ this.generateCommentIdButton.Name = "generateCommentIdButton";
+ this.generateCommentIdButton.Size = new System.Drawing.Size(286, 62);
+ this.generateCommentIdButton.TabIndex = 4;
+ this.generateCommentIdButton.Text = "Create / Clear Comments ID";
+ this.generateCommentIdButton.UseVisualStyleBackColor = true;
+ this.generateCommentIdButton.Click += new System.EventHandler(this.idButton_Click);
+ //
+ // isCostAnalysisDirtyCheckBox
+ //
+ this.isCostAnalysisDirtyCheckBox.AutoSize = true;
+ this.isCostAnalysisDirtyCheckBox.Location = new System.Drawing.Point(87, 227);
+ this.isCostAnalysisDirtyCheckBox.Name = "isCostAnalysisDirtyCheckBox";
+ this.isCostAnalysisDirtyCheckBox.Size = new System.Drawing.Size(207, 29);
+ this.isCostAnalysisDirtyCheckBox.TabIndex = 3;
+ this.isCostAnalysisDirtyCheckBox.Text = "IsCostAnalysisDirty";
+ this.isCostAnalysisDirtyCheckBox.UseVisualStyleBackColor = true;
+ //
+ // isTaxableDirtyCheckBox
+ //
+ this.isTaxableDirtyCheckBox.AutoSize = true;
+ this.isTaxableDirtyCheckBox.Location = new System.Drawing.Point(87, 192);
+ this.isTaxableDirtyCheckBox.Name = "isTaxableDirtyCheckBox";
+ this.isTaxableDirtyCheckBox.Size = new System.Drawing.Size(163, 29);
+ this.isTaxableDirtyCheckBox.TabIndex = 2;
+ this.isTaxableDirtyCheckBox.Text = "IsTaxableDirty";
+ this.isTaxableDirtyCheckBox.UseVisualStyleBackColor = true;
+ //
+ // isWeeklySalesDirtyCheckBox
+ //
+ this.isWeeklySalesDirtyCheckBox.AutoSize = true;
+ this.isWeeklySalesDirtyCheckBox.Location = new System.Drawing.Point(87, 157);
+ this.isWeeklySalesDirtyCheckBox.Name = "isWeeklySalesDirtyCheckBox";
+ this.isWeeklySalesDirtyCheckBox.Size = new System.Drawing.Size(208, 29);
+ this.isWeeklySalesDirtyCheckBox.TabIndex = 1;
+ this.isWeeklySalesDirtyCheckBox.Text = "IsWeeklySalesDirty";
+ this.isWeeklySalesDirtyCheckBox.UseVisualStyleBackColor = true;
+ //
+ // isCommentDirtyCheckBox
+ //
+ this.isCommentDirtyCheckBox.AutoSize = true;
+ this.isCommentDirtyCheckBox.Location = new System.Drawing.Point(87, 122);
+ this.isCommentDirtyCheckBox.Name = "isCommentDirtyCheckBox";
+ this.isCommentDirtyCheckBox.Size = new System.Drawing.Size(177, 29);
+ this.isCommentDirtyCheckBox.TabIndex = 0;
+ this.isCommentDirtyCheckBox.Text = "IsCommentDirty";
+ this.isCommentDirtyCheckBox.UseVisualStyleBackColor = true;
+ //
// mainMenuStrip
//
this.mainLayoutPanel.SetColumnSpan(this.mainMenuStrip, 4);
@@ -314,10 +429,16 @@
this.FileMainMenu.Size = new System.Drawing.Size(56, 31);
this.FileMainMenu.Text = "&File";
//
+ // clearFormFileMainMenu
+ //
+ this.clearFormFileMainMenu.Name = "clearFormFileMainMenu";
+ this.clearFormFileMainMenu.Size = new System.Drawing.Size(205, 34);
+ this.clearFormFileMainMenu.Text = "&Clear Form";
+ //
// exitFileMainMenu
//
this.exitFileMainMenu.Name = "exitFileMainMenu";
- this.exitFileMainMenu.Size = new System.Drawing.Size(240, 34);
+ this.exitFileMainMenu.Size = new System.Drawing.Size(205, 34);
this.exitFileMainMenu.Text = "E&xit";
//
// mainLayoutPanel
@@ -858,118 +979,6 @@
this.addRecordButton.UseVisualStyleBackColor = true;
this.addRecordButton.Click += new System.EventHandler(this.AddRecordsButtonClick);
//
- // debugPanel
- //
- this.debugPanel.Controls.Add(this.generateCostAnalysisIdButton);
- this.debugPanel.Controls.Add(this.generateTaxableIdButton);
- this.debugPanel.Controls.Add(this.generateWeeklySalesIdButton);
- this.debugPanel.Controls.Add(this.reminderLabel);
- this.debugPanel.Controls.Add(this.generateCommentIdButton);
- this.debugPanel.Controls.Add(this.isCostAnalysisDirtyCheckBox);
- this.debugPanel.Controls.Add(this.isTaxableDirtyCheckBox);
- this.debugPanel.Controls.Add(this.isWeeklySalesDirtyCheckBox);
- this.debugPanel.Controls.Add(this.isCommentDirtyCheckBox);
- this.debugPanel.Dock = System.Windows.Forms.DockStyle.Fill;
- this.debugPanel.Location = new System.Drawing.Point(3, 3);
- this.debugPanel.Name = "debugPanel";
- this.debugPanel.Size = new System.Drawing.Size(1854, 504);
- this.debugPanel.TabIndex = 0;
- //
- // isCommentDirtyCheckBox
- //
- this.isCommentDirtyCheckBox.AutoSize = true;
- this.isCommentDirtyCheckBox.Location = new System.Drawing.Point(87, 122);
- this.isCommentDirtyCheckBox.Name = "isCommentDirtyCheckBox";
- this.isCommentDirtyCheckBox.Size = new System.Drawing.Size(177, 29);
- this.isCommentDirtyCheckBox.TabIndex = 0;
- this.isCommentDirtyCheckBox.Text = "IsCommentDirty";
- this.isCommentDirtyCheckBox.UseVisualStyleBackColor = true;
- //
- // isWeeklySalesDirtyCheckBox
- //
- this.isWeeklySalesDirtyCheckBox.AutoSize = true;
- this.isWeeklySalesDirtyCheckBox.Location = new System.Drawing.Point(87, 157);
- this.isWeeklySalesDirtyCheckBox.Name = "isWeeklySalesDirtyCheckBox";
- this.isWeeklySalesDirtyCheckBox.Size = new System.Drawing.Size(208, 29);
- this.isWeeklySalesDirtyCheckBox.TabIndex = 1;
- this.isWeeklySalesDirtyCheckBox.Text = "IsWeeklySalesDirty";
- this.isWeeklySalesDirtyCheckBox.UseVisualStyleBackColor = true;
- //
- // isTaxableDirtyCheckBox
- //
- this.isTaxableDirtyCheckBox.AutoSize = true;
- this.isTaxableDirtyCheckBox.Location = new System.Drawing.Point(87, 192);
- this.isTaxableDirtyCheckBox.Name = "isTaxableDirtyCheckBox";
- this.isTaxableDirtyCheckBox.Size = new System.Drawing.Size(163, 29);
- this.isTaxableDirtyCheckBox.TabIndex = 2;
- this.isTaxableDirtyCheckBox.Text = "IsTaxableDirty";
- this.isTaxableDirtyCheckBox.UseVisualStyleBackColor = true;
- //
- // isCostAnalysisDirtyCheckBox
- //
- this.isCostAnalysisDirtyCheckBox.AutoSize = true;
- this.isCostAnalysisDirtyCheckBox.Location = new System.Drawing.Point(87, 227);
- this.isCostAnalysisDirtyCheckBox.Name = "isCostAnalysisDirtyCheckBox";
- this.isCostAnalysisDirtyCheckBox.Size = new System.Drawing.Size(207, 29);
- this.isCostAnalysisDirtyCheckBox.TabIndex = 3;
- this.isCostAnalysisDirtyCheckBox.Text = "IsCostAnalysisDirty";
- this.isCostAnalysisDirtyCheckBox.UseVisualStyleBackColor = true;
- //
- // clearFormFileMainMenu
- //
- this.clearFormFileMainMenu.Name = "clearFormFileMainMenu";
- this.clearFormFileMainMenu.Size = new System.Drawing.Size(240, 34);
- this.clearFormFileMainMenu.Text = "&Clear Form";
- //
- // generateCommentIdButton
- //
- this.generateCommentIdButton.Location = new System.Drawing.Point(54, 283);
- this.generateCommentIdButton.Name = "generateCommentIdButton";
- this.generateCommentIdButton.Size = new System.Drawing.Size(286, 62);
- this.generateCommentIdButton.TabIndex = 4;
- this.generateCommentIdButton.Text = "Create / Clear Comments ID";
- this.generateCommentIdButton.UseVisualStyleBackColor = true;
- this.generateCommentIdButton.Click += new System.EventHandler(this.idButton_Click);
- //
- // reminderLabel
- //
- this.reminderLabel.AutoSize = true;
- this.reminderLabel.Location = new System.Drawing.Point(82, 94);
- this.reminderLabel.Name = "reminderLabel";
- this.reminderLabel.Size = new System.Drawing.Size(659, 25);
- this.reminderLabel.TabIndex = 5;
- this.reminderLabel.Text = "These checkboxes Tag properties hold the ID for their respective elements.";
- //
- // generateWeeklySalesIdButton
- //
- this.generateWeeklySalesIdButton.Location = new System.Drawing.Point(346, 283);
- this.generateWeeklySalesIdButton.Name = "generateWeeklySalesIdButton";
- this.generateWeeklySalesIdButton.Size = new System.Drawing.Size(286, 62);
- this.generateWeeklySalesIdButton.TabIndex = 6;
- this.generateWeeklySalesIdButton.Text = "Create / Clear Weekly Sales ID";
- this.generateWeeklySalesIdButton.UseVisualStyleBackColor = true;
- this.generateWeeklySalesIdButton.Click += new System.EventHandler(this.generateWeeklySalesIdButton_Click);
- //
- // generateTaxableIdButton
- //
- this.generateTaxableIdButton.Location = new System.Drawing.Point(638, 283);
- this.generateTaxableIdButton.Name = "generateTaxableIdButton";
- this.generateTaxableIdButton.Size = new System.Drawing.Size(286, 62);
- this.generateTaxableIdButton.TabIndex = 7;
- this.generateTaxableIdButton.Text = "Create / Clear Taxable ID";
- this.generateTaxableIdButton.UseVisualStyleBackColor = true;
- this.generateTaxableIdButton.Click += new System.EventHandler(this.generateTaxableIdButton_Click);
- //
- // generateCostAnalysisIdButton
- //
- this.generateCostAnalysisIdButton.Location = new System.Drawing.Point(931, 283);
- this.generateCostAnalysisIdButton.Name = "generateCostAnalysisIdButton";
- this.generateCostAnalysisIdButton.Size = new System.Drawing.Size(299, 62);
- this.generateCostAnalysisIdButton.TabIndex = 8;
- this.generateCostAnalysisIdButton.Text = "Create / Clear Cost Analysis ID";
- this.generateCostAnalysisIdButton.UseVisualStyleBackColor = true;
- this.generateCostAnalysisIdButton.Click += new System.EventHandler(this.generateCostAnalysisIdButton_Click);
- //
// NewAddRecord
//
this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F);
@@ -995,6 +1004,8 @@
this.invoicesTabPage.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.invoicesDataGridView)).EndInit();
this.debugTabPage.ResumeLayout(false);
+ this.debugPanel.ResumeLayout(false);
+ this.debugPanel.PerformLayout();
this.mainMenuStrip.ResumeLayout(false);
this.mainMenuStrip.PerformLayout();
this.mainLayoutPanel.ResumeLayout(false);
@@ -1012,8 +1023,6 @@
this.dateTimeMaskedTextBoxPanel.PerformLayout();
this.informationPanel.ResumeLayout(false);
this.informationPanel.PerformLayout();
- this.debugPanel.ResumeLayout(false);
- this.debugPanel.PerformLayout();
this.ResumeLayout(false);
}
diff --git a/AdvertsingProfitControl/NewAddRecord.cs b/AdvertsingProfitControl/NewAddRecord.cs
index 35b4872..3e84263 100644
--- a/AdvertsingProfitControl/NewAddRecord.cs
+++ b/AdvertsingProfitControl/NewAddRecord.cs
@@ -100,6 +100,7 @@ namespace AdvertsingProfitControl
ConstructInvoicesDataGridView();//No weekly sales table is nice.
//Subscribe the comments text box to check if changes have been made on leave.
commentsTextBox.Enter += StoreBeginningTextBoxValue;
+ commentsTextBox.KeyDown += CheckForKeyCommand;
commentsTextBox.Leave += CheckForTextChangeOnLeave;
//Subscribe the weekly sales text boxes to validation, update required checks and auto-complete methods.
sundayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue;
@@ -146,182 +147,6 @@ namespace AdvertsingProfitControl
suppliesTextBox.Validating += ValidateCostAnalysisValues;
}
- private void ValidateCostAnalysisValues(object sender, CancelEventArgs e)
- {
- var textBox = (TextBox) sender;
- if (_beginningCellValue == textBox.Text) return;
- //There was a change to the starting value of the text box if we've made it this far.
- if (textBox.Text != "")
- {
- double value;
- if (double.TryParse(textBox.Text.Trim(), out value))
- {
- //Input is valid so mark the section as dirty.
- isCostAnalysisDirtyCheckBox.Checked = true;
- //And apply formatting.
- textBox.Text = Math.Round(value, 2).ToString("N", new CultureInfo("en-US"));
- //Check to see if the number is equal to zero (0) i.e. "0.00".
- if (textBox.Text == @"0.00") textBox.Text = "";
- }
- else
- {
- MessageBox.Show(@"The value must be numeric.", @"Input Must be Numeric");
- textBox.Text = "";
- }
- }
- else
- {
- //Since the text box that fired this event is empty check to see if this group has been committed to the database.
- if (isCostAnalysisDirtyCheckBox.Tag == null)
- {
- //Since it hasn't check to see if the other text boxes are empty.
- var isDirty = salesPerManHourTextBox.Text.Trim() == "";
- if (isDirty)
- {
- isCostAnalysisDirtyCheckBox.Checked = false;
- return;
- }
- isDirty = salaryPercentageTextBox.Text.Trim() == "";
- if (isDirty)
- {
- isCostAnalysisDirtyCheckBox.Checked = false;
- return;
- }
- isDirty = salaryDollarsTextBox.Text.Trim() == "";
- if (isDirty)
- {
- isCostAnalysisDirtyCheckBox.Checked = false;
- return;
- }
- isDirty = suppliesTextBox.Text.Trim() == "";
- if (isDirty)
- {
- isCostAnalysisDirtyCheckBox.Checked = false;
- }
- }
- else if (isCostAnalysisDirtyCheckBox.Tag != null && textBox.Text == "")
- {
- //If the user has already added the fields to the database but has removed a value
- //update that accordingly.
- isCostAnalysisDirtyCheckBox.Checked = true;
- }
- }
- }
-
- private void ValidateTaxableFields(object sender, CancelEventArgs e)
- {
- var textBox = (TextBox)sender;
- if (_beginningCellValue == textBox.Text) return;
- //There was a change to the starting value of the text box if we've made it this far.
- if (textBox.Text != "")
- {
- double dollarValue;
- if (double.TryParse(textBox.Text.Trim(), out dollarValue))
- {
- //Input is valid so mark the section as dirty.
- isTaxableDirtyCheckBox.Checked = true;
- //And apply formatting.
- textBox.Text = Math.Round(dollarValue, 2).ToString("N", new CultureInfo("en-US"));
- //Check to see if the number is equal to zero (0) i.e. "0.00".
- if (textBox.Text == @"0.00") textBox.Text = "";
- }
- else
- {
- MessageBox.Show(@"The value must be numeric.", @"Input Must be Numeric");
- textBox.Text = "";
- }
- }
- //Update the total sales text box before returning.
- var totalTaxable = 0.00;
- if (sundayTaxableTextBox.Text != "") totalTaxable += double.Parse(sundayTaxableTextBox.Text);
- if (mondayTaxableTextBox.Text != "") totalTaxable += double.Parse(mondayTaxableTextBox.Text);
- if (tuesdayTaxableTextBox.Text != "") totalTaxable += double.Parse(tuesdayTaxableTextBox.Text);
- if (wednesdayTaxableTextBox.Text != "") totalTaxable += double.Parse(wednesdayTaxableTextBox.Text);
- if (thursdayTaxableTextBox.Text != "") totalTaxable += double.Parse(thursdayTaxableTextBox.Text);
- if (fridayTaxableTextBox.Text != "") totalTaxable += double.Parse(fridayTaxableTextBox.Text);
- if (saturdayTaxableTextBox.Text != "") totalTaxable += double.Parse(saturdayTaxableTextBox.Text);
- if (Math.Abs(totalTaxable) > 0)
- {
- totalTaxableTextBox.Text = totalTaxable.ToString("N", new CultureInfo("en-US"));
- }
- else
- {
- //Check to see if the weekly sales have been added to the database.
- if (isTaxableDirtyCheckBox.Tag == null)
- {
- //If the tag doesn't have an ID in it then we're clear to simply clear the is dirty flag.
- isTaxableDirtyCheckBox.Checked = false;
- }
- else if (isTaxableDirtyCheckBox.Tag != null && textBox.Text == "")
- {
- //If the user has already added the fields to the database but has removed a value
- //update that accordingly.
- isTaxableDirtyCheckBox.Checked = true;
- }
- totalTaxableTextBox.Text = "";
- }
- }
-
- private void StoreBeginningTextBoxValue(object sender, EventArgs e)
- {
- var textBox = (TextBox) sender;
- _beginningCellValue = textBox.Text;
- }
-
- private void ValidateWeeklySales(object sender, CancelEventArgs e)
- {
- var textBox = (TextBox) sender;
- if (_beginningCellValue == textBox.Text) return;
- //There was a change to the starting value of the text box if we've made it this far.
- if (textBox.Text != "")
- {
- double dollarValue;
- if (double.TryParse(textBox.Text.Trim(), out dollarValue))
- {
- //Input is valid so mark the section as dirty.
- isWeeklySalesDirtyCheckBox.Checked = true;
- //And apply formatting.
- textBox.Text = Math.Round(dollarValue, 2).ToString("N", new CultureInfo("en-US"));
- //Check to see if the number is equal to zero (0) i.e. "0.00".
- if (textBox.Text == @"0.00") textBox.Text = "";
- }
- else
- {
- MessageBox.Show(@"The value must be numeric.", @"Input Must be Numeric");
- textBox.Text = "";
- }
- }
- //Update the total sales text box before returning.
- var totalWeeklySales = 0.00;
- if (sundayWeeklySalesTextBox.Text != "") totalWeeklySales += double.Parse(sundayWeeklySalesTextBox.Text);
- if (mondayWeeklySalesTextBox.Text != "") totalWeeklySales += double.Parse(mondayWeeklySalesTextBox.Text);
- if (tuesdayWeeklySalesTextBox.Text != "") totalWeeklySales += double.Parse(tuesdayWeeklySalesTextBox.Text);
- if (wednesdayWeeklySalesTextBox.Text != "") totalWeeklySales += double.Parse(wednesdayWeeklySalesTextBox.Text);
- if (thursdayWeeklySalesTextBox.Text != "") totalWeeklySales += double.Parse(thursdayWeeklySalesTextBox.Text);
- if (fridayWeeklySalesTextBox.Text != "") totalWeeklySales += double.Parse(fridayWeeklySalesTextBox.Text);
- if (saturdayWeeklySalesTextBox.Text != "") totalWeeklySales += double.Parse(saturdayWeeklySalesTextBox.Text);
- if (Math.Abs(totalWeeklySales) > 0)
- {
- totalWeeklySalesTextBox.Text = totalWeeklySales.ToString("N", new CultureInfo("en-US"));
- }
- else
- {
- //Check to see if the weekly sales have been added to the database.
- if (isWeeklySalesDirtyCheckBox.Tag == null)
- {
- //If the tag doesn't have an ID in it then we're clear to simply clear the is dirty flag.
- isWeeklySalesDirtyCheckBox.Checked = false;
- }
- else if(isWeeklySalesDirtyCheckBox.Tag != null && textBox.Text == "")
- {
- //If the user has already added the fields to the database but has removed a value
- //update that accordingly.
- isWeeklySalesDirtyCheckBox.Checked = true;
- }
- totalWeeklySalesTextBox.Text = "";
- }
- }
-
#region Invoice Table Events
///
@@ -330,7 +155,7 @@ namespace AdvertsingProfitControl
///
///
///
- private void ValidateInvoiceRow(object sender, DataGridViewCellCancelEventArgs e)
+ private static void ValidateInvoiceRow(object sender, DataGridViewCellCancelEventArgs e)
{
var dataGridView = (DataGridView) sender;
if (dataGridView.Rows[e.RowIndex].IsNewRow) return;
@@ -338,24 +163,30 @@ namespace AdvertsingProfitControl
//Check to make sure the Invoice Date, Invoice Number and the Supplier values are set.
if (dataGridView.Rows[e.RowIndex].Cells[(int) InvoiceTableColumns.InvoiceDate].EditedFormattedValue.ToString() == "" || !DateTime.TryParse(dataGridView.Rows[e.RowIndex].Cells[(int)InvoiceTableColumns.InvoiceDate].EditedFormattedValue.ToString(), out dateTime))
{
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.RowError;
MessageBox.Show(@"An invoice date must be specified.", @"Invalid Invoice Date", MessageBoxButtons.OK, MessageBoxIcon.Error);
e.Cancel = true;
- dataGridView.CurrentCell = dataGridView.Rows[e.RowIndex].Cells[(int)InvoiceTableColumns.InvoiceDate];
+ dataGridView.CurrentCell = dataGridView.Rows[e.RowIndex].Cells[(int) InvoiceTableColumns.InvoiceDate];
return;
}
if (dataGridView.Rows[e.RowIndex].Cells[(int)InvoiceTableColumns.Supplier].EditedFormattedValue.ToString() == "")
{
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.RowError;
MessageBox.Show(@"A supplier must be specified.", @"Invalid Supplier", MessageBoxButtons.OK, MessageBoxIcon.Error);
e.Cancel = true;
dataGridView.CurrentCell = dataGridView.Rows[e.RowIndex].Cells[(int) InvoiceTableColumns.Supplier];
return;
}
- if (dataGridView.Rows[e.RowIndex].Cells[(int) InvoiceTableColumns.InvoiceNumber].EditedFormattedValue.ToString() == "")
+ if (
+ dataGridView.Rows[e.RowIndex].Cells[(int) InvoiceTableColumns.InvoiceNumber].EditedFormattedValue
+ .ToString() == "")
{
- MessageBox.Show(@"An invoice number must be specified.", @"Invalid Invoice Number", MessageBoxButtons.OK, MessageBoxIcon.Error);
- dataGridView.CurrentCell = dataGridView.Rows[e.RowIndex].Cells[(int)InvoiceTableColumns.InvoiceNumber];
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.RowError;
+ MessageBox.Show(@"An invoice number must be specified.", @"Invalid Invoice Number", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ dataGridView.CurrentCell = dataGridView.Rows[e.RowIndex].Cells[(int) InvoiceTableColumns.InvoiceNumber];
e.Cancel = true;
}
}
@@ -399,6 +230,7 @@ namespace AdvertsingProfitControl
if (DateTime.TryParse(userInput, out date))
{
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = date.ToString("MM/dd/yyyy");
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
else
{
@@ -422,6 +254,7 @@ namespace AdvertsingProfitControl
if (long.TryParse(userInput, out parsedNumber))
{
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = parsedNumber;
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
else
{
@@ -444,6 +277,7 @@ namespace AdvertsingProfitControl
//TODO: Create a custom engine to do this.
//Pretty up the entered text since there is something here.
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = textInfo.ToTitleCase(userInput);
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
else
{
@@ -453,6 +287,7 @@ namespace AdvertsingProfitControl
break;
case (int)InvoiceTableColumns.InvoiceNote:
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = userInput;
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
break;
default:
//Should only process the InvoiceNetAmountAtCost and InvoiceNetAmount columns.
@@ -469,7 +304,7 @@ namespace AdvertsingProfitControl
{
//Since the input is a number format it to show the cents and display it.
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = Math.Round(parsedNumber, 2).ToString("N", new CultureInfo("en-US"));
- //dataGridView.RefreshEdit();
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
else
{
@@ -824,6 +659,8 @@ namespace AdvertsingProfitControl
else if (userInput != _beginningCellValue)
{
dataGridView.Rows[e.RowIndex].Cells[(int)SalesTableColumns.IsDirty].Value = true;
+ //Set the coloring for the header cell.
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
double parsedNumber;
//Check to see if the current column is the ad item column.
@@ -842,6 +679,7 @@ namespace AdvertsingProfitControl
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "";
//Send the ad item text through the formatting engine and assign the new value to the cell.
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = TextFormat.FormatAdItemText(userInput);
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
//Force a refresh so the cell's text updates and displays for the user.
dataGridView.RefreshEdit();
return;
@@ -859,6 +697,7 @@ namespace AdvertsingProfitControl
{
//IF a match has been found, then make sure the word 'bin(s)' is capitalized to keep things looking pretty.
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = textInfo.ToTitleCase(userInput);
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
dataGridView.RefreshEdit();
return;
}
@@ -867,6 +706,7 @@ namespace AdvertsingProfitControl
{
//Add the formatted value to the cell.
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = Math.Round(parsedNumber, 2).ToString("N", new CultureInfo("en-US"));
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
else
{
@@ -875,9 +715,9 @@ namespace AdvertsingProfitControl
return;
}
MessageBox.Show(@"Non numeric characters in column " + (e.ColumnIndex + 1) + @" are not allowed.", @"Invalid Characters Detected");
- e.Cancel = true;
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "";
dataGridView.RefreshEdit();
+ e.Cancel = true;
return;
}
break;
@@ -897,6 +737,7 @@ namespace AdvertsingProfitControl
//Format the last number as Currency, and round it up if necessary.
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value =
$@"{stringArray[0]}/{Math.Round(decimal.Parse(stringArray[1]), 2):C}";
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
//Always refresh edit so the new value shows up to the user.
dataGridView.RefreshEdit();
return; //And return, there is no need to go further.
@@ -905,6 +746,7 @@ namespace AdvertsingProfitControl
if (double.TryParse(userInput, out parsedNumber))
{
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = Math.Round(parsedNumber, 2).ToString("N", new CultureInfo("en-US"));
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
else
{
@@ -913,9 +755,9 @@ namespace AdvertsingProfitControl
return;
}
MessageBox.Show(@"Non numeric characters in column " + (e.ColumnIndex + 1) + @" are not allowed.", @"Invalid Characters Detected");
- e.Cancel = true;
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "";
dataGridView.RefreshEdit();
+ e.Cancel = true;
return;
}
break;
@@ -926,6 +768,7 @@ namespace AdvertsingProfitControl
if (double.TryParse(userInput, out parsedNumber))
{
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = Math.Round(parsedNumber, 2).ToString("N", new CultureInfo("en-US"));
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
else
{
@@ -934,9 +777,9 @@ namespace AdvertsingProfitControl
return;
}
MessageBox.Show(@"Non numeric characters in column " + (e.ColumnIndex + 1) + @" are not allowed.", @"Invalid Characters Detected");
- e.Cancel = true;
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "";
dataGridView.RefreshEdit();
+ e.Cancel = true;
return;
}
break;
@@ -969,6 +812,7 @@ namespace AdvertsingProfitControl
//Clear all whitespace and check for a null value in the ad item column.
if (Regex.Replace(projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString(), @"\s+", "") == "")
{
+ projectionsDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.RowError;
MessageBox.Show(@"An ad item is required.", @"No Ad Item Specified");
projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Selected = true;
e.Cancel = true;
@@ -978,109 +822,102 @@ namespace AdvertsingProfitControl
{
return;
}
- //Now check to make sure there is an ad item present, otherwise throw an error and block the user from leaving the current row.
- if (projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() != "")
+ //Next check to see if the user changed the ad item is the corresponding row.
+ if (projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() != actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString())
{
- //Next check to see if the user changed the ad item is the corresponding row.
- if (projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() != actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString())
+ if (projectionsDataGridView.RowCount == actualSalesDataGridView.RowCount)
{
- if (projectionsDataGridView.RowCount == actualSalesDataGridView.RowCount)
+ var adItemText = projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
+ actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
+ inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
+ projectionsDataGridView.RefreshEdit();
+ //Remove the last ad item from the UsedAdItem array, the new one will be added in the OnRowLeave event handler.
+ if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex)
{
- var adItemText = projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
- actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
- inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
- projectionsDataGridView.RefreshEdit();
- //Remove the last ad item from the UsedAdItem array, the new one will be added in the OnRowLeave event handler.
- if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex)
+ _usedAdItems[0].RemoveAll(I => I.Equals(_beginningCellValue, StringComparison.OrdinalIgnoreCase));
+ }
+ else
+ {
+ _usedAdItems[1].RemoveAll(I => I.Equals(_beginningCellValue, StringComparison.OrdinalIgnoreCase));
+ }
+
+ return;
+ }
+ }
+ var rowContents = new object[projectionsDataGridView.ColumnCount];
+ //Spin through the DataGridViewCells in the row and add their contents to an array.
+ for (var i = 0; i < projectionsDataGridView.ColumnCount; i++)
+ {
+ //Grab the Ad Item in the first cell and add it into the array.
+ switch (i)
+ {
+ case (int) SalesTableColumns.AdItem:
+ rowContents[i] = projectionsDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
+ break;
+ case (int) SalesTableColumns.SalePrice:
+ //IF the Sale Price cell is empty then place 0.00 into the array as a place holder value (assuming this row is a HeaderRow).
+ if (projectionsDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString() == "")
{
- _usedAdItems[0].RemoveAll(I => I.Equals(_beginningCellValue, StringComparison.OrdinalIgnoreCase));
+ rowContents[i] = "";
}
+ //ELSE place the value from the Projections table into the array, since Sale Price can be determined before actual data is used.
else
{
- _usedAdItems[1].RemoveAll(I => I.Equals(_beginningCellValue, StringComparison.OrdinalIgnoreCase));
- }
-
- return;
- }
- }
- var rowContents = new object[projectionsDataGridView.ColumnCount];
- //Spin through the DataGridViewCells in the row and add their contents to an array.
- for (var i = 0; i < projectionsDataGridView.ColumnCount; i++)
- {
- //Grab the Ad Item in the first cell and add it into the array.
- switch (i)
- {
- case (int) SalesTableColumns.AdItem:
rowContents[i] = projectionsDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
- break;
- case (int) SalesTableColumns.SalePrice:
- //IF the Sale Price cell is empty then place 0.00 into the array as a place holder value (assuming this row is a HeaderRow).
- if (projectionsDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString() == "")
- {
- rowContents[i] = "";
- }
- //ELSE place the value from the Projections table into the array, since Sale Price can be determined before actual data is used.
- else
- {
- rowContents[i] = projectionsDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
- }
- break;
- case (int) SalesTableColumns.Cost:
- //IF the Cost cell is empty then place 0.00 into the array as a place holder value (assuming this row is a HeaderRow).
- if (projectionsDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString() == "")
- {
- rowContents[i] = "";
- }
- //ELSE place the value from the Projections table into the array, since Cost can be determined before actual data is used.
- else
- {
- rowContents[i] = projectionsDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
- }
- break;
- case (int)SalesTableColumns.IsDirty:
- rowContents[i] = true;
- break;
- default:
- if(i >= (int)SalesTableColumns.IsHeaderRow) continue;
+ }
+ break;
+ case (int) SalesTableColumns.Cost:
+ //IF the Cost cell is empty then place 0.00 into the array as a place holder value (assuming this row is a HeaderRow).
+ if (projectionsDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString() == "")
+ {
rowContents[i] = "";
- break;
- }
+ }
+ //ELSE place the value from the Projections table into the array, since Cost can be determined before actual data is used.
+ else
+ {
+ rowContents[i] = projectionsDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
+ }
+ break;
+ case (int)SalesTableColumns.IsDirty:
+ rowContents[i] = true;
+ break;
+ default:
+ if(i >= (int)SalesTableColumns.IsHeaderRow) continue;
+ rowContents[i] = "";
+ break;
}
- actualSalesDataGridView.Rows.Add(rowContents);
- //Build a collection of objects for the inventory table to use.
- var inventoryNewRow = new object[inventoryDataGridView.ColumnCount];
- //Spin through the DataGridViewCells in the row and add their contents to an array.
- for (var i = 0; i < projectionsDataGridView.ColumnCount; i++)
- {
- //Grab the Ad Item in the first cell and add it into the array.
- switch (i)
- {
- case (int)SalesTableColumns.Id:
- inventoryNewRow[(int)InventoryTableColumns.Id] = "";
- break;
- case (int)SalesTableColumns.AdItem:
- inventoryNewRow[(int)InventoryTableColumns.AdItem] =
- projectionsDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
- break;
- case (int)SalesTableColumns.IsDirty:
- inventoryNewRow[(int)InventoryTableColumns.IsDirty] = true;
- break;
- default:
- if (i < (int) InventoryTableColumns.IsHeaderRow)
- {
- inventoryNewRow[i] = "";
- }
- break;
- }
- }
- inventoryDataGridView.Rows.Add(inventoryNewRow);
}
- else
+ actualSalesDataGridView.Rows.Add(rowContents);
+ //Build a collection of objects for the inventory table to use.
+ var inventoryNewRow = new object[inventoryDataGridView.ColumnCount];
+ //Spin through the DataGridViewCells in the row and add their contents to an array.
+ for (var i = 0; i < projectionsDataGridView.ColumnCount; i++)
{
- MessageBox.Show(@"An Ad Item is required.", @"Invalid Ad Item");
- projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Selected = true;
- e.Cancel = true;
+ //Grab the Ad Item in the first cell and add it into the array.
+ switch (i)
+ {
+ case (int)SalesTableColumns.Id:
+ inventoryNewRow[(int)InventoryTableColumns.Id] = "";
+ break;
+ case (int)SalesTableColumns.AdItem:
+ inventoryNewRow[(int)InventoryTableColumns.AdItem] =
+ projectionsDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
+ break;
+ case (int)SalesTableColumns.IsDirty:
+ inventoryNewRow[(int)InventoryTableColumns.IsDirty] = true;
+ break;
+ default:
+ if (i < (int) InventoryTableColumns.IsHeaderRow)
+ {
+ inventoryNewRow[i] = "";
+ }
+ break;
+ }
}
+ inventoryDataGridView.Rows.Add(inventoryNewRow);
+ //Set the row headers of the other tables to show up as pending; this row is valid without a doubt.
+ inventoryDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
+ actualSalesDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
private void ProjectionRowRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
@@ -1236,6 +1073,7 @@ namespace AdvertsingProfitControl
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "";
//Send the ad item text through the formatting engine and assign the new value to the cell.
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = TextFormat.FormatAdItemText(userInput);
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
//Force a refresh so the cell's text updates and displays for the user.
dataGridView.RefreshEdit();
return;
@@ -1255,23 +1093,27 @@ namespace AdvertsingProfitControl
{
//IF a match has been found, then make sure the word 'bin(s)' is capitalized to keep things looking pretty.
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = textInfo.ToTitleCase(userInput);
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
dataGridView.RefreshEdit();
return;
}
double parsedNumber;
//Try parsing the text entered as a number and if that fails then break out and clear the value entered.
- if (userInput != "" && !double.TryParse(userInput, out parsedNumber))
+ if (userInput != "" && double.TryParse(userInput, out parsedNumber))
{
- MessageBox.Show(
- @"Non numeric characters in column " + (e.ColumnIndex + 1) + @" are not allowed.",
- @"Invalid Characters Detected");
- e.Cancel = true;
- dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "";
- dataGridView.RefreshEdit();
+ //Add the value to the cell.
+ dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = userInput;
+ dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
return;
}
- //Add the value to the cell.
- dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = userInput;
+ //Prevent the user from being bombarded by message boxes. All validation has been completed at this point so there's nothing to worry about.
+ if (userInput != "")
+ {
+ MessageBox.Show(@"Non numeric characters in column " + (e.ColumnIndex + 1) + @" are not allowed.", @"Invalid Characters Detected");
+ dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "";
+ dataGridView.RefreshEdit();
+ e.Cancel = true;
+ }
break;
}
//Always refresh edit so the new value shows up to the user.
@@ -1298,6 +1140,7 @@ namespace AdvertsingProfitControl
//Clear all whitespace and check for a null value in the ad item column.
if (Regex.Replace(inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString(), @"\s+", "") == "")
{
+ inventoryDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.RowError;
MessageBox.Show(@"An ad item is required.", @"No Ad Item Specified");
inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Selected = true;
e.Cancel = true;
@@ -1307,62 +1150,55 @@ namespace AdvertsingProfitControl
{
return;
}
- //Now check to make sure there is an ad item present, otherwise throw an error and block the user from leaving the current row.
- if (inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() != "")
+ //Next check to see if the user changed the ad item is the corresponding row.
+ if (inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() != actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString())
{
- //Next check to see if the user changed the ad item is the corresponding row.
- if (inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() != actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString())
+ if (inventoryDataGridView.RowCount == actualSalesDataGridView.RowCount)
{
- if (inventoryDataGridView.RowCount == actualSalesDataGridView.RowCount)
+ var adItemText = inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
+ projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
+ actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
+ //inventoryDataGridView.RefreshEdit();
+ //Remove the last ad item from the UsedAdItem array, the new one will be added in the OnRowLeave event handler.
+ if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex)
{
- var adItemText = inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
- projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
- actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
- //inventoryDataGridView.RefreshEdit();
- //Remove the last ad item from the UsedAdItem array, the new one will be added in the OnRowLeave event handler.
- if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex)
- {
- _usedAdItems[0].RemoveAll(I => I.Equals(_beginningCellValue, StringComparison.OrdinalIgnoreCase));
- }
- else
- {
- _usedAdItems[1].RemoveAll(I => I.Equals(_beginningCellValue, StringComparison.OrdinalIgnoreCase));
- }
+ _usedAdItems[0].RemoveAll(I => I.Equals(_beginningCellValue, StringComparison.OrdinalIgnoreCase));
+ }
+ else
+ {
+ _usedAdItems[1].RemoveAll(I => I.Equals(_beginningCellValue, StringComparison.OrdinalIgnoreCase));
+ }
- return;
- }
+ return;
}
- var rowContents = new object[actualSalesDataGridView.ColumnCount];
- //Spin through the DataGridViewCells in the row and add their contents to an array.
- for (var i = 0; i < actualSalesDataGridView.ColumnCount; i++)
- {
- //Grab the Ad Item in the first cell and add it into the array.
- switch (i)
- {
- case (int)SalesTableColumns.AdItem:
- rowContents[i] = inventoryDataGridView.Rows[e.RowIndex].Cells[(int)InventoryTableColumns.AdItem].EditedFormattedValue.ToString();
- break;
- case (int)SalesTableColumns.IsDirty:
- rowContents[i] = true;
- break;
- default:
- if (i >= (int) InventoryTableColumns.IsHeaderRow)
- {
- continue;
- }
- rowContents[i] = "";
- break;
- }
- }
- projectionsDataGridView.Rows.Add(rowContents);
- actualSalesDataGridView.Rows.Add(rowContents);
}
- else
+ var rowContents = new object[actualSalesDataGridView.ColumnCount];
+ //Spin through the DataGridViewCells in the row and add their contents to an array.
+ for (var i = 0; i < actualSalesDataGridView.ColumnCount; i++)
{
- MessageBox.Show(@"An Ad Item is required.", @"Invalid Ad Item");
- inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Selected = true;
- e.Cancel = true;
+ //Grab the Ad Item in the first cell and add it into the array.
+ switch (i)
+ {
+ case (int)SalesTableColumns.AdItem:
+ rowContents[i] = inventoryDataGridView.Rows[e.RowIndex].Cells[(int)InventoryTableColumns.AdItem].EditedFormattedValue.ToString();
+ break;
+ case (int)SalesTableColumns.IsDirty:
+ rowContents[i] = true;
+ break;
+ default:
+ if (i >= (int) InventoryTableColumns.IsHeaderRow)
+ {
+ continue;
+ }
+ rowContents[i] = "";
+ break;
+ }
}
+ projectionsDataGridView.Rows.Add(rowContents);
+ actualSalesDataGridView.Rows.Add(rowContents);
+ //Apply color coding to the respective row headers on the other tables.
+ projectionsDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
+ actualSalesDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
private void InventoryRowRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
@@ -1450,6 +1286,7 @@ namespace AdvertsingProfitControl
//Clear all whitespace and check for a null value in the ad item column.
if (Regex.Replace(actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString(), @"\s+", "") == "")
{
+ actualSalesDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.RowError;
MessageBox.Show(@"An ad item is required.", @"No Ad Item Specified");
actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Selected = true;
e.Cancel = true;
@@ -1459,88 +1296,81 @@ namespace AdvertsingProfitControl
{
return;
}
- //Now check to make sure there is an ad item present, otherwise throw an error and block the user from leaving the current row.
- if (actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() != "")
+ //Next check to see if the user changed the ad item is the corresponding row.
+ if (actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() != projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString())
{
- //Next check to see if the user changed the ad item is the corresponding row.
- if (actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() != projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString())
+ if (actualSalesDataGridView.RowCount == projectionsDataGridView.RowCount)
{
- if (actualSalesDataGridView.RowCount == projectionsDataGridView.RowCount)
+ var adItemText = actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
+ projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
+ inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
+ //projectionsDataGridView.RefreshEdit();
+ //Remove the last ad item from the UsedAdItem array, the new one will be added in the OnRowLeave event handler.
+ if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex)
{
- var adItemText = actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
- projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
- inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
- //projectionsDataGridView.RefreshEdit();
- //Remove the last ad item from the UsedAdItem array, the new one will be added in the OnRowLeave event handler.
- if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex)
- {
- _usedAdItems[0].RemoveAll(I => I.Equals(_beginningCellValue, StringComparison.OrdinalIgnoreCase));
- }
- else
- {
- _usedAdItems[1].RemoveAll(I => I.Equals(_beginningCellValue, StringComparison.OrdinalIgnoreCase));
- }
+ _usedAdItems[0].RemoveAll(I => I.Equals(_beginningCellValue, StringComparison.OrdinalIgnoreCase));
+ }
+ else
+ {
+ _usedAdItems[1].RemoveAll(I => I.Equals(_beginningCellValue, StringComparison.OrdinalIgnoreCase));
+ }
- return;
- }
+ return;
}
- var rowContents = new object[actualSalesDataGridView.ColumnCount];
- //Spin through the DataGridViewCells in the row and add their contents to an array.
- for (var i = 0; i < actualSalesDataGridView.ColumnCount; i++)
- {
- //Grab the Ad Item in the first cell and add it into the array.
- switch (i)
- {
- case (int)SalesTableColumns.AdItem:
- rowContents[i] = actualSalesDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
- break;
- case (int)SalesTableColumns.SalePrice:
- rowContents[i] = actualSalesDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
- break;
- case (int)SalesTableColumns.Cost:
- rowContents[i] = actualSalesDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
- break;
- case (int)SalesTableColumns.IsDirty:
- rowContents[i] = true;
- break;
- default:
- if (i >= (int)SalesTableColumns.IsHeaderRow) continue;
- rowContents[i] = "";
- break;
- }
- }
- projectionsDataGridView.Rows.Add(rowContents);
- //Build a collection of objects for the inventory table to use.
- var inventoryNewRow = new object[inventoryDataGridView.ColumnCount];
- //Spin through the DataGridViewCells in the row and add their contents to an array.
- for (var i = 0; i < actualSalesDataGridView.ColumnCount; i++)
- {
- //Grab the Ad Item in the first cell and add it into the array.
- switch (i)
- {
- case (int)SalesTableColumns.AdItem:
- inventoryNewRow[(int)InventoryTableColumns.AdItem] =
- actualSalesDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
- break;
- case (int)SalesTableColumns.IsDirty:
- inventoryNewRow[(int)InventoryTableColumns.IsDirty] = true;
- break;
- default:
- if (i > (int)InventoryTableColumns.AdItem && i < (int)InventoryTableColumns.IsHeaderRow || i == (int)InventoryTableColumns.Id)
- {
- inventoryNewRow[i] = "";
- }
- break;
- }
- }
- inventoryDataGridView.Rows.Add(inventoryNewRow);
}
- else
+ var rowContents = new object[actualSalesDataGridView.ColumnCount];
+ //Spin through the DataGridViewCells in the row and add their contents to an array.
+ for (var i = 0; i < actualSalesDataGridView.ColumnCount; i++)
{
- MessageBox.Show(@"An Ad Item is required.", @"Invalid Ad Item");
- actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Selected = true;
- e.Cancel = true;
+ //Grab the Ad Item in the first cell and add it into the array.
+ switch (i)
+ {
+ case (int)SalesTableColumns.AdItem:
+ rowContents[i] = actualSalesDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
+ break;
+ case (int)SalesTableColumns.SalePrice:
+ rowContents[i] = actualSalesDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
+ break;
+ case (int)SalesTableColumns.Cost:
+ rowContents[i] = actualSalesDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
+ break;
+ case (int)SalesTableColumns.IsDirty:
+ rowContents[i] = true;
+ break;
+ default:
+ if (i >= (int)SalesTableColumns.IsHeaderRow) continue;
+ rowContents[i] = "";
+ break;
+ }
}
+ projectionsDataGridView.Rows.Add(rowContents);
+ //Build a collection of objects for the inventory table to use.
+ var inventoryNewRow = new object[inventoryDataGridView.ColumnCount];
+ //Spin through the DataGridViewCells in the row and add their contents to an array.
+ for (var i = 0; i < actualSalesDataGridView.ColumnCount; i++)
+ {
+ //Grab the Ad Item in the first cell and add it into the array.
+ switch (i)
+ {
+ case (int)SalesTableColumns.AdItem:
+ inventoryNewRow[(int)InventoryTableColumns.AdItem] =
+ actualSalesDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
+ break;
+ case (int)SalesTableColumns.IsDirty:
+ inventoryNewRow[(int)InventoryTableColumns.IsDirty] = true;
+ break;
+ default:
+ if (i > (int)InventoryTableColumns.AdItem && i < (int)InventoryTableColumns.IsHeaderRow || i == (int)InventoryTableColumns.Id)
+ {
+ inventoryNewRow[i] = "";
+ }
+ break;
+ }
+ }
+ inventoryDataGridView.Rows.Add(inventoryNewRow);
+ //Apply color coding to the respective row headers on the other tables.
+ projectionsDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
+ inventoryDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
private void ActualSalesRowRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
@@ -1755,7 +1585,32 @@ namespace AdvertsingProfitControl
#endregion
+ ///
+ /// Stores the beginning value in a text box into the _beginningCellValue field.
+ ///
+ ///
+ ///
+ private void StoreBeginningTextBoxValue(object sender, EventArgs e)
+ {
+ var textBox = (TextBox) sender;
+ _beginningCellValue = textBox.Text;
+ }
+
#region Comments TextBox Events
+
+ ///
+ /// Allows the user to select all the text in the comments text box.
+ /// TODO: Fix error chime when using CNTRL+A.
+ ///
+ ///
+ ///
+ private void CheckForKeyCommand(object sender, KeyEventArgs e)
+ {
+ if (!e.Control || e.KeyCode != Keys.A) return;
+ commentsTextBox.SelectionStart = 0;
+ commentsTextBox.SelectionLength = commentsTextBox.Text.Length;
+ }
+
///
/// Event Used: TextChanged
/// Calculates and displays the remaining number of characters available for the user to enter
@@ -1792,16 +1647,199 @@ namespace AdvertsingProfitControl
#region Weekly Sales Events
+ ///
+ /// Validates the contents of the weekly sales text boxes and adds up the total.
+ ///
+ ///
+ ///
+ private void ValidateWeeklySales(object sender, CancelEventArgs e)
+ {
+ var textBox = (TextBox)sender;
+ if (_beginningCellValue == textBox.Text) return;
+ //There was a change to the starting value of the text box if we've made it this far.
+ if (textBox.Text != "")
+ {
+ double dollarValue;
+ if (double.TryParse(textBox.Text.Trim(), out dollarValue))
+ {
+ //Input is valid so mark the section as dirty.
+ isWeeklySalesDirtyCheckBox.Checked = true;
+ //And apply formatting.
+ textBox.Text = Math.Round(dollarValue, 2).ToString("N", new CultureInfo("en-US"));
+ //Check to see if the number is equal to zero (0) i.e. "0.00".
+ if (textBox.Text == @"0.00") textBox.Text = "";
+ }
+ else
+ {
+ MessageBox.Show(@"The value must be numeric.", @"Input Must be Numeric");
+ textBox.Text = "";
+ }
+ }
+ //Update the total sales text box before returning.
+ var totalWeeklySales = 0.00;
+ if (sundayWeeklySalesTextBox.Text != "") totalWeeklySales += double.Parse(sundayWeeklySalesTextBox.Text);
+ if (mondayWeeklySalesTextBox.Text != "") totalWeeklySales += double.Parse(mondayWeeklySalesTextBox.Text);
+ if (tuesdayWeeklySalesTextBox.Text != "") totalWeeklySales += double.Parse(tuesdayWeeklySalesTextBox.Text);
+ if (wednesdayWeeklySalesTextBox.Text != "") totalWeeklySales += double.Parse(wednesdayWeeklySalesTextBox.Text);
+ if (thursdayWeeklySalesTextBox.Text != "") totalWeeklySales += double.Parse(thursdayWeeklySalesTextBox.Text);
+ if (fridayWeeklySalesTextBox.Text != "") totalWeeklySales += double.Parse(fridayWeeklySalesTextBox.Text);
+ if (saturdayWeeklySalesTextBox.Text != "") totalWeeklySales += double.Parse(saturdayWeeklySalesTextBox.Text);
+ if (Math.Abs(totalWeeklySales) > 0)
+ {
+ totalWeeklySalesTextBox.Text = totalWeeklySales.ToString("N", new CultureInfo("en-US"));
+ }
+ else
+ {
+ //Check to see if the weekly sales have been added to the database.
+ if (isWeeklySalesDirtyCheckBox.Tag == null)
+ {
+ //If the tag doesn't have an ID in it then we're clear to simply clear the is dirty flag.
+ isWeeklySalesDirtyCheckBox.Checked = false;
+ }
+ else if (isWeeklySalesDirtyCheckBox.Tag != null && textBox.Text == "")
+ {
+ //If the user has already added the fields to the database but has removed a value
+ //update that accordingly.
+ isWeeklySalesDirtyCheckBox.Checked = true;
+ }
+ totalWeeklySalesTextBox.Text = "";
+ }
+ }
#endregion
#region Taxable Events
+ ///
+ /// Validates the contents of the Taxable text boxes and adds up the total.
+ ///
+ ///
+ ///
+ private void ValidateTaxableFields(object sender, CancelEventArgs e)
+ {
+ var textBox = (TextBox)sender;
+ if (_beginningCellValue == textBox.Text) return;
+ //There was a change to the starting value of the text box if we've made it this far.
+ if (textBox.Text != "")
+ {
+ double dollarValue;
+ if (double.TryParse(textBox.Text.Trim(), out dollarValue))
+ {
+ //Input is valid so mark the section as dirty.
+ isTaxableDirtyCheckBox.Checked = true;
+ //And apply formatting.
+ textBox.Text = Math.Round(dollarValue, 2).ToString("N", new CultureInfo("en-US"));
+ //Check to see if the number is equal to zero (0) i.e. "0.00".
+ if (textBox.Text == @"0.00") textBox.Text = "";
+ }
+ else
+ {
+ MessageBox.Show(@"The value must be numeric.", @"Input Must be Numeric");
+ textBox.Text = "";
+ }
+ }
+ //Update the total sales text box before returning.
+ var totalTaxable = 0.00;
+ if (sundayTaxableTextBox.Text != "") totalTaxable += double.Parse(sundayTaxableTextBox.Text);
+ if (mondayTaxableTextBox.Text != "") totalTaxable += double.Parse(mondayTaxableTextBox.Text);
+ if (tuesdayTaxableTextBox.Text != "") totalTaxable += double.Parse(tuesdayTaxableTextBox.Text);
+ if (wednesdayTaxableTextBox.Text != "") totalTaxable += double.Parse(wednesdayTaxableTextBox.Text);
+ if (thursdayTaxableTextBox.Text != "") totalTaxable += double.Parse(thursdayTaxableTextBox.Text);
+ if (fridayTaxableTextBox.Text != "") totalTaxable += double.Parse(fridayTaxableTextBox.Text);
+ if (saturdayTaxableTextBox.Text != "") totalTaxable += double.Parse(saturdayTaxableTextBox.Text);
+ if (Math.Abs(totalTaxable) > 0)
+ {
+ totalTaxableTextBox.Text = totalTaxable.ToString("N", new CultureInfo("en-US"));
+ }
+ else
+ {
+ //Check to see if the weekly sales have been added to the database.
+ if (isTaxableDirtyCheckBox.Tag == null)
+ {
+ //If the tag doesn't have an ID in it then we're clear to simply clear the is dirty flag.
+ isTaxableDirtyCheckBox.Checked = false;
+ }
+ else if (isTaxableDirtyCheckBox.Tag != null && textBox.Text == "")
+ {
+ //If the user has already added the fields to the database but has removed a value
+ //update that accordingly.
+ isTaxableDirtyCheckBox.Checked = true;
+ }
+ totalTaxableTextBox.Text = "";
+ }
+ }
#endregion
#region Cost Analysis Events
+ ///
+ /// Validates the cost analysis text boxes.
+ ///
+ ///
+ ///
+ private void ValidateCostAnalysisValues(object sender, CancelEventArgs e)
+ {
+ var textBox = (TextBox)sender;
+ if (_beginningCellValue == textBox.Text) return;
+ //There was a change to the starting value of the text box if we've made it this far.
+ if (textBox.Text != "")
+ {
+ double value;
+ if (double.TryParse(textBox.Text.Trim(), out value))
+ {
+ //Input is valid so mark the section as dirty.
+ isCostAnalysisDirtyCheckBox.Checked = true;
+ //And apply formatting.
+ textBox.Text = Math.Round(value, 2).ToString("N", new CultureInfo("en-US"));
+ //Check to see if the number is equal to zero (0) i.e. "0.00".
+ if (textBox.Text == @"0.00") textBox.Text = "";
+ }
+ else
+ {
+ MessageBox.Show(@"The value must be numeric.", @"Input Must be Numeric");
+ textBox.Text = "";
+
+ }
+ }
+ else
+ {
+ //Since the text box that fired this event is empty check to see if this group has been committed to the database.
+ if (isCostAnalysisDirtyCheckBox.Tag == null)
+ {
+ //Since it hasn't check to see if the other text boxes are empty.
+ var isDirty = salesPerManHourTextBox.Text.Trim() == "";
+ if (isDirty)
+ {
+ isCostAnalysisDirtyCheckBox.Checked = false;
+ return;
+ }
+ isDirty = salaryPercentageTextBox.Text.Trim() == "";
+ if (isDirty)
+ {
+ isCostAnalysisDirtyCheckBox.Checked = false;
+ return;
+ }
+ isDirty = salaryDollarsTextBox.Text.Trim() == "";
+ if (isDirty)
+ {
+ isCostAnalysisDirtyCheckBox.Checked = false;
+ return;
+ }
+ isDirty = suppliesTextBox.Text.Trim() == "";
+ if (isDirty)
+ {
+ isCostAnalysisDirtyCheckBox.Checked = false;
+ }
+ }
+ else if (isCostAnalysisDirtyCheckBox.Tag != null && textBox.Text == "")
+ {
+ //If the user has already added the fields to the database but has removed a value
+ //update that accordingly.
+ isCostAnalysisDirtyCheckBox.Checked = true;
+ }
+ }
+ }
#endregion
@@ -1982,11 +2020,44 @@ namespace AdvertsingProfitControl
if (!ProcessTrimmingStatusResult(actualSalesDataGridView, "ActualSales", operationStatus, trimmedTable, updateTable)) return;
//Commit the Invoice table to the database.
var writerStatus = dbW.ProccessInvoiceTable(invoicesDataGridView, dateId, dbT.DatabaseConnectionString);
- if (writerStatus.GetWritingOperationStatus() != WritingOperationStatus.Failed)
+ if (writerStatus.GetWritingOperationStatus() == WritingOperationStatus.Failed)
{
errorLabel.Text = writerStatus.GetErrorMessage();
}
- informationLabel.Text = @"All operations completed successfully.";
+
+ if (isCommentDirtyCheckBox.Checked)
+ {
+ if (isCommentDirtyCheckBox.Tag == null)
+ {
+ informationLabel.Text += @"Inserting Comment(s).";
+ writerStatus = dbW.ProcessComments(commentsTextBox.Text, dateId, dbT.DatabaseConnectionString);
+ if (writerStatus.GetWritingOperationStatus() == WritingOperationStatus.Failed)
+ {
+ errorLabel.Text = writerStatus.GetErrorMessage();
+ }
+ else
+ {
+ informationLabel.Text += @"Comment(s) processed successfully.";
+ var id = writerStatus.GetRowCollection();
+
+ }
+ }
+ else
+ {
+ informationLabel.Text += @"Updating Comment(s).";
+ writerStatus = dbW.ProcessComments(commentsTextBox.Text, dateId, dbT.DatabaseConnectionString, int.Parse(isCommentDirtyCheckBox.Tag.ToString()));
+ }
+ if (writerStatus.GetWritingOperationStatus() == WritingOperationStatus.Failed)
+ {
+ errorLabel.Text = writerStatus.GetErrorMessage();
+ }
+ else
+ {
+ informationLabel.Text += @"Comment(s) processed successfully.";
+ }
+ }
+
+ informationLabel.Text += @"All operations completed successfully.";
//Create the transaction scope.
//By default the TransactionScopeOption is "Required", so if an ambient transaction does not
//exist then the new transaction that is made (in the first method) becomes the root transaction.
@@ -2642,6 +2713,9 @@ namespace AdvertsingProfitControl
#endregion
+ #region Debug Operations
+
+
private void idButton_Click(object sender, EventArgs e)
{
if (isCommentDirtyCheckBox.Tag == null)
@@ -2701,5 +2775,7 @@ namespace AdvertsingProfitControl
MessageBox.Show(@"ID cleared from Cost Analysis.", @"Clear ID Debug");
}
}
+
+ #endregion
}
}
diff --git a/AdvertsingProfitControl/NewAddRecord.resx b/AdvertsingProfitControl/NewAddRecord.resx
index ed00b2b..ad2c550 100644
--- a/AdvertsingProfitControl/NewAddRecord.resx
+++ b/AdvertsingProfitControl/NewAddRecord.resx
@@ -120,9 +120,6 @@
17, 17
-
- 17, 17
-
diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application
index d2725be..1019250 100644
--- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application
+++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application
@@ -14,7 +14,7 @@
- sJa3N/qFPRThckha4aReaPFLpwQDio7tNBSSDURtnBk=
+ OlX6CvX02QUSDXImEM6f2HKdWzzRripa5ZZRa0lenPo=
diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest
index 3ac2ed7..d1b8c33 100644
--- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest
+++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest
@@ -43,14 +43,14 @@
-
+
- KJrIBRsbaX/71nFWLgdvuorK6BWoYWZ05mGNqVbM0Y0=
+ 4TfzARAAxdb/PYNmotwSF5x29OfcgoIH9QiACmt25T0=
@@ -84,7 +84,7 @@
- dX2Dundhh4161Q3VUoRkM0RkUhpDPmRvgqyLNfiU3Nk=
+ OTOg6k+3pem3uA+Xpy/Nu0Ifwo+hXeYq3hn83njXnT4=