diff --git a/AdvertsingProfitControl/APCDatabase.accdb b/AdvertsingProfitControl/APCDatabase.accdb index 6b6c2f6..2cfb184 100644 Binary files a/AdvertsingProfitControl/APCDatabase.accdb and b/AdvertsingProfitControl/APCDatabase.accdb differ diff --git a/AdvertsingProfitControl/AdvertsingProfitControl.csproj b/AdvertsingProfitControl/AdvertsingProfitControl.csproj index 06824c7..92a6ce2 100644 --- a/AdvertsingProfitControl/AdvertsingProfitControl.csproj +++ b/AdvertsingProfitControl/AdvertsingProfitControl.csproj @@ -106,9 +106,16 @@ + + + Form + + + NewModifyRecord.cs + @@ -193,6 +200,9 @@ NewAddRecord.cs + + NewModifyRecord.cs + ResXFileCodeGenerator Resources.Designer.cs diff --git a/AdvertsingProfitControl/ApcTableStatus.cs b/AdvertsingProfitControl/ApcTableStatus.cs new file mode 100644 index 0000000..9667c2e --- /dev/null +++ b/AdvertsingProfitControl/ApcTableStatus.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdvertsingProfitControl +{ + internal class ApcTableStatus + { + private DbTableWriterStatus _projectionsTableStatus = new DbTableWriterStatus(); + private DbTableWriterStatus _inventoryTableStatus = new DbTableWriterStatus(); + private DbTableWriterStatus _actualSalesStatus = new DbTableWriterStatus(); + + public void SetProjectionsTableStatus(DbTableWriterStatus status) + { + _projectionsTableStatus = status; + } + + public DbTableWriterStatus GetProjectionsStatus() + { + return _projectionsTableStatus; + } + + public void SetInventoryStatus(DbTableWriterStatus status) + { + _inventoryTableStatus = status; + } + + public DbTableWriterStatus GetInventoryStatus() + { + return _inventoryTableStatus; + } + + public void SetActualSalesStatus(DbTableWriterStatus status) + { + _actualSalesStatus = status; + } + + public DbTableWriterStatus GetActualSalesStatus() + { + return _actualSalesStatus; + } + } +} diff --git a/AdvertsingProfitControl/ApplicationColors.cs b/AdvertsingProfitControl/ApplicationColors.cs index 2a5c340..ddf64d5 100644 --- a/AdvertsingProfitControl/ApplicationColors.cs +++ b/AdvertsingProfitControl/ApplicationColors.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Drawing; namespace AdvertsingProfitControl { @@ -17,5 +12,6 @@ namespace AdvertsingProfitControl public static Color RowError = Color.Red; public static Color HeaderRow = Color.LightGray; public static Color MemberRow = Color.LightBlue; + public static Color AdSpecial = Color.Silver; } } diff --git a/AdvertsingProfitControl/DatabaseReader.cs b/AdvertsingProfitControl/DatabaseReader.cs index 007bdd0..a1101c9 100644 --- a/AdvertsingProfitControl/DatabaseReader.cs +++ b/AdvertsingProfitControl/DatabaseReader.cs @@ -128,6 +128,34 @@ namespace AdvertsingProfitControl return dateString; } + public List RetrieveDates(string connectionString) + { + var dates = new List(); + var oleDbCommand = new OleDbCommand + { + CommandText = "SELECT EndOfWeekDate FROM WeekEnding" + }; + var connection = new OleDbConnection(connectionString); + oleDbCommand.Connection = connection; + + using (connection) + { + using (oleDbCommand) + { + connection.Open(); + using (var reader = oleDbCommand.ExecuteReader()) + { + while (reader != null && reader.Read()) + { + dates.Add(DateTime.Parse(reader[0].ToString())); + } + } + } + } + + return dates; + } + public List RetrieveUniqueYearsList(string connectionString) { var datesList = new List(); @@ -677,7 +705,7 @@ namespace AdvertsingProfitControl var dataTable = new DataTable(); var oleDbCommand = new OleDbCommand() { - CommandText = "SELECT AdItem.AdItem, Projections.Sold, Projections.SalePrice, Projections.TotalSales, Projections.Cost, Projections.ProfitReturn, Projections.TotalProfitReturn, Projections.RowAttribute, Projections.FK_AdSpecialGroupName FROM (AdItem INNER JOIN Projections ON AdItem.ID = Projections.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC" + CommandText = "SELECT Projections.ID, AdItem.AdItem, Projections.Sold, Projections.SalePrice, Projections.TotalSales, Projections.Cost, Projections.ProfitReturn, Projections.TotalProfitReturn, Projections.RowAttribute, Projections.FK_AdSpecialGroupName FROM (AdItem INNER JOIN Projections ON AdItem.ID = Projections.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC" }; oleDbCommand.Parameters.AddWithValue("DateID", dateId); var connection = new OleDbConnection(connectionString); @@ -702,7 +730,7 @@ namespace AdvertsingProfitControl var dataTable = new DataTable(); var oleDbCommand = new OleDbCommand() { - CommandText = "SELECT AdItem.AdItem, ActualSales.Sold, ActualSales.SalePrice, ActualSales.TotalSales, ActualSales.Cost, ActualSales.ProfitReturn, ActualSales.TotalProfitReturn, ActualSales.RowAttribute, ActualSales.FK_AdSpecialGroupName FROM (AdItem INNER JOIN ActualSales ON AdItem.ID = ActualSales.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC" + CommandText = "SELECT ActualSales.ID, AdItem.AdItem, ActualSales.Sold, ActualSales.SalePrice, ActualSales.TotalSales, ActualSales.Cost, ActualSales.ProfitReturn, ActualSales.TotalProfitReturn, ActualSales.RowAttribute, ActualSales.FK_AdSpecialGroupName FROM (AdItem INNER JOIN ActualSales ON AdItem.ID = ActualSales.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC" }; oleDbCommand.Parameters.AddWithValue("DateID", dateId); var connection = new OleDbConnection(connectionString); @@ -727,7 +755,7 @@ namespace AdvertsingProfitControl var dataTable = new DataTable(); var oleDbCommand = new OleDbCommand() { - CommandText = "SELECT AdItem.AdItem, Inventory.BeginningInventory, Inventory.Received, Inventory.TotalInventory, Inventory.EndingInventory, Inventory.RowAttribute, Inventory.FK_AdSpecialGroupName FROM (AdItem INNER JOIN Inventory ON AdItem.ID = Inventory.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC" + CommandText = "SELECT Inventory.ID, AdItem.AdItem, Inventory.BeginningInventory, Inventory.Received, Inventory.TotalInventory, Inventory.EndingInventory, Inventory.RowAttribute, Inventory.FK_AdSpecialGroupName FROM (AdItem INNER JOIN Inventory ON AdItem.ID = Inventory.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC" }; oleDbCommand.Parameters.AddWithValue("DateID", dateId); var connection = new OleDbConnection(connectionString); diff --git a/AdvertsingProfitControl/DatabaseWriter.cs b/AdvertsingProfitControl/DatabaseWriter.cs index a973730..c39dabd 100644 --- a/AdvertsingProfitControl/DatabaseWriter.cs +++ b/AdvertsingProfitControl/DatabaseWriter.cs @@ -15,7 +15,7 @@ namespace AdvertsingProfitControl _oleDbConnection.ConnectionString = connectionString; } - #region New Code + #region New Code /// /// Inserts new records into the specified sales table. @@ -1134,6 +1134,61 @@ namespace AdvertsingProfitControl return result; } + public bool NormalizeApcTables(int dateId) + { + var successful = false; + var oleDbCommand = new OleDbCommand + { + CommandText = "SELECT COUNT(*) FROM Projections WHERE FK_DateID = ?", + Connection = _oleDbConnection + }; + oleDbCommand.Parameters.AddWithValue("DateID", dateId); + OleDbTransaction oleDbTransaction = null; + try + { + _oleDbConnection.Open(); + oleDbTransaction = _oleDbConnection.BeginTransaction(); + oleDbCommand.Transaction = oleDbTransaction; + var projectionsRowCount = 0; + var inventoryRowCount = 0; + var actualSalesRowCount = 0; + var reader = oleDbCommand.ExecuteReader(); + while (reader != null && reader.Read()) + { + projectionsRowCount = int.Parse(reader[0].ToString()); + } + + oleDbCommand.CommandText = "SELECT COUNT(*) FROM Inventory WHERE FK_DateID = ?"; + reader = oleDbCommand.ExecuteReader(); + while (reader != null && reader.Read()) + { + inventoryRowCount = int.Parse(reader[0].ToString()); + } + + oleDbCommand.CommandText = "SELECT COUNT(*) FROM ActualSales WHERE FK_DateID = ?"; + reader = oleDbCommand.ExecuteReader(); + while (reader != null && reader.Read()) + { + actualSalesRowCount = int.Parse(reader[0].ToString()); + } + // + if (projectionsRowCount != inventoryRowCount) + { + + } + } + catch (OleDbException e) + { + _logConsole.WriteToLog(FrmLogConsole.Level.Error, e.Message); + oleDbTransaction?.Rollback(); + } + finally + { + _oleDbConnection.Close(); + } + return successful; + } + /// /// Removes the invoice record with the specified internal ID number. /// diff --git a/AdvertsingProfitControl/FrmMain.Designer.cs b/AdvertsingProfitControl/FrmMain.Designer.cs index 82d1d26..129a96b 100644 --- a/AdvertsingProfitControl/FrmMain.Designer.cs +++ b/AdvertsingProfitControl/FrmMain.Designer.cs @@ -83,6 +83,8 @@ this.weeklySalesDataGridView = new System.Windows.Forms.DataGridView(); this.taxableTabPage = new System.Windows.Forms.TabPage(); this.taxableDataGridView = new System.Windows.Forms.DataGridView(); + this.debugTabPage = new System.Windows.Forms.TabPage(); + this.monthCalendar = new System.Windows.Forms.MonthCalendar(); this.mainTableLayoutPanel.SuspendLayout(); this.mainMenu.SuspendLayout(); this.commentMainTableLayoutPanel.SuspendLayout(); @@ -105,6 +107,7 @@ ((System.ComponentModel.ISupportInitialize)(this.weeklySalesDataGridView)).BeginInit(); this.taxableTabPage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.taxableDataGridView)).BeginInit(); + this.debugTabPage.SuspendLayout(); this.SuspendLayout(); // // mainTableLayoutPanel @@ -535,6 +538,7 @@ this.mainViewTabControl.Controls.Add(this.suppliersTabPage); this.mainViewTabControl.Controls.Add(this.WeeklySalesTabPage); this.mainViewTabControl.Controls.Add(this.taxableTabPage); + this.mainViewTabControl.Controls.Add(this.debugTabPage); this.mainViewTabControl.Dock = System.Windows.Forms.DockStyle.Fill; this.mainViewTabControl.Location = new System.Drawing.Point(5, 47); this.mainViewTabControl.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6); @@ -733,6 +737,29 @@ this.taxableDataGridView.Size = new System.Drawing.Size(1710, 498); this.taxableDataGridView.TabIndex = 0; // + // debugTabPage + // + this.debugTabPage.Controls.Add(this.monthCalendar); + this.debugTabPage.Location = new System.Drawing.Point(4, 33); + this.debugTabPage.Name = "debugTabPage"; + this.debugTabPage.Padding = new System.Windows.Forms.Padding(3); + this.debugTabPage.Size = new System.Drawing.Size(1716, 504); + this.debugTabPage.TabIndex = 6; + this.debugTabPage.Text = "Debug"; + this.debugTabPage.UseVisualStyleBackColor = true; + // + // monthCalendar + // + this.monthCalendar.Location = new System.Drawing.Point(12, 12); + this.monthCalendar.MaxSelectionCount = 1; + this.monthCalendar.MonthlyBoldedDates = new System.DateTime[] { + new System.DateTime(2017, 1, 1, 0, 0, 0, 0)}; + this.monthCalendar.Name = "monthCalendar"; + this.monthCalendar.ShowTodayCircle = false; + this.monthCalendar.ShowWeekNumbers = true; + this.monthCalendar.TabIndex = 0; + this.monthCalendar.TabStop = false; + // // FrmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F); @@ -775,6 +802,7 @@ ((System.ComponentModel.ISupportInitialize)(this.weeklySalesDataGridView)).EndInit(); this.taxableTabPage.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.taxableDataGridView)).EndInit(); + this.debugTabPage.ResumeLayout(false); this.ResumeLayout(false); } @@ -835,6 +863,8 @@ private System.Windows.Forms.LinkLabel shrinkLinkLabel; private System.Windows.Forms.TabPage taxableTabPage; private System.Windows.Forms.DataGridView taxableDataGridView; + private System.Windows.Forms.TabPage debugTabPage; + private System.Windows.Forms.MonthCalendar monthCalendar; } } diff --git a/AdvertsingProfitControl/FrmMain.cs b/AdvertsingProfitControl/FrmMain.cs index a4a1e57..5c19020 100644 --- a/AdvertsingProfitControl/FrmMain.cs +++ b/AdvertsingProfitControl/FrmMain.cs @@ -374,7 +374,7 @@ namespace AdvertsingProfitControl perfectGrossProfitLabel.Text = "Percent Gross Profit: "; return; } - + if (weeklySalesDataGridView.RowCount == 0) return; double totalSales = Convert.ToDouble(weeklySalesDataGridView.Rows[0].Cells[7].EditedFormattedValue.ToString()); grossProfitTotalSales.ForeColor = Color.Black; grossProfitTotalSales.Text = "Total Sales: " + totalSales.ToString("C"); @@ -647,11 +647,14 @@ namespace AdvertsingProfitControl private void modifyRecordMainMenu_Click(object sender, EventArgs e) { - var modifyForm = new FrmModifyRecord(); - modifyForm.ShowDialog(); - BuildAndFillDataGridTables(); - CalculateProfitAnalysis(); - CalculateGrossProfit(); + //var modifyForm = new FrmModifyRecord(); + //modifyForm.ShowDialog(); + //BuildAndFillDataGridTables(); + //CalculateProfitAnalysis(); + //CalculateGrossProfit(); + var date = DateTime.Parse(monthComboBox.SelectedItem + @"/" + dayComboBox.SelectedItem + @"/" + yearComboBox.SelectedItem); + var form = new NewModifyRecord(date); + form.ShowDialog(); } private void manageItemsToolsMainMenu_Click(object sender, EventArgs e) diff --git a/AdvertsingProfitControl/NewAddRecord.cs b/AdvertsingProfitControl/NewAddRecord.cs index 7fbfb41..0705c7e 100644 --- a/AdvertsingProfitControl/NewAddRecord.cs +++ b/AdvertsingProfitControl/NewAddRecord.cs @@ -2109,7 +2109,6 @@ namespace AdvertsingProfitControl { errorLabel.Text = @"Failed to trim the Inventory table."; //Delete the Projections table. - dbW.DeleteApcDataEntriesByDate("Projections", dateId, dbT.DatabaseConnectionString); } else { @@ -2123,25 +2122,15 @@ namespace AdvertsingProfitControl if (operationStatus == TrimmingOperationResult.FailedToTrim) { errorLabel.Text = @"Failed to trim the Actual Sales table."; - //Delete the Projections table and the Inventory table. - dbW.DeleteApcDataEntriesByDate("Projections", dateId, dbT.DatabaseConnectionString); - dbW.DeleteApcDataEntriesByDate("Inventory", dateId, dbT.DatabaseConnectionString); } else { if (!ProcessTrimmingStatusResult(actualSalesDataGridView, "ActualSales", operationStatus, trimmedTable, updateTable)) { - //Delete the Projections and Inventory table. - dbW.DeleteApcDataEntriesByDate("Projections", dateId, dbT.DatabaseConnectionString); - dbW.DeleteApcDataEntriesByDate("Inventory", dateId, dbT.DatabaseConnectionString); + errorLabel.Text = @"Failed to add actual sales to the database."; } } } - else - { - //Delete the Projections table. - dbW.DeleteApcDataEntriesByDate("Projections", dateId, dbT.DatabaseConnectionString); - } } } //Commit the Invoice table to the database. diff --git a/AdvertsingProfitControl/NewModifyRecord.Designer.cs b/AdvertsingProfitControl/NewModifyRecord.Designer.cs new file mode 100644 index 0000000..08b9511 --- /dev/null +++ b/AdvertsingProfitControl/NewModifyRecord.Designer.cs @@ -0,0 +1,1071 @@ +namespace AdvertsingProfitControl +{ + partial class NewModifyRecord + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.mainLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); + 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.debugMainMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.mainTabControl = new System.Windows.Forms.TabControl(); + this.projectionTabPage = new System.Windows.Forms.TabPage(); + this.projectionsDataGridView = new System.Windows.Forms.DataGridView(); + this.inventoryTabPage = new System.Windows.Forms.TabPage(); + this.inventoryDataGridView = new System.Windows.Forms.DataGridView(); + this.actualSalesTabPage = new System.Windows.Forms.TabPage(); + this.actualSalesDataGridView = new System.Windows.Forms.DataGridView(); + 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.costAnalysisGroupBox = new System.Windows.Forms.GroupBox(); + this.suppliesTextBox = new System.Windows.Forms.TextBox(); + this.salaryPercentageTextBox = new System.Windows.Forms.TextBox(); + this.salaryDollarsTextBox = new System.Windows.Forms.TextBox(); + this.salesPerManHourLabel = new System.Windows.Forms.Label(); + this.salaryPercentageLabel = new System.Windows.Forms.Label(); + this.salesPerManHourTextBox = new System.Windows.Forms.TextBox(); + this.salaryDollarsLabel = new System.Windows.Forms.Label(); + this.suppliesLabel = new System.Windows.Forms.Label(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.weeklySalesTabPage = new System.Windows.Forms.TabPage(); + this.mondayWeeklySalesTextBox = new System.Windows.Forms.TextBox(); + this.totalWeeklySalesTextBox = new System.Windows.Forms.TextBox(); + this.saturdayWeeklySalesTextBox = new System.Windows.Forms.TextBox(); + this.thursdayWeeklySalesTextBox = new System.Windows.Forms.TextBox(); + this.tuesdayWeeklySalesTextBox = new System.Windows.Forms.TextBox(); + this.mondayWeeklySalesLabel = new System.Windows.Forms.Label(); + this.thursdayWeeklySalesLabel = new System.Windows.Forms.Label(); + this.saturdayWeeklySalesLabel = new System.Windows.Forms.Label(); + this.sundayWeeklySalesTextBox = new System.Windows.Forms.TextBox(); + this.totalWeeklySalesLabel = new System.Windows.Forms.Label(); + this.fridayWeeklySalesLabel = new System.Windows.Forms.Label(); + this.wednesdayWeeklySalesLabel = new System.Windows.Forms.Label(); + this.tuesdayWeeklySalesLabel = new System.Windows.Forms.Label(); + this.fridayWeeklySalesTextBox = new System.Windows.Forms.TextBox(); + this.sundayWeeklySalesLabel = new System.Windows.Forms.Label(); + this.wednesdayWeeklySalesTextBox = new System.Windows.Forms.TextBox(); + this.taxableTabPage = new System.Windows.Forms.TabPage(); + this.totalTaxableTextBox = new System.Windows.Forms.TextBox(); + this.mondayTaxableTextBox = new System.Windows.Forms.TextBox(); + this.thursdayTaxableTextBox = new System.Windows.Forms.TextBox(); + this.tuesdayTaxableTextBox = new System.Windows.Forms.TextBox(); + this.fridayTaxableLabel = new System.Windows.Forms.Label(); + this.sundayTaxableLabel = new System.Windows.Forms.Label(); + this.thursdayTaxableLabel = new System.Windows.Forms.Label(); + this.wednesdayTaxableTextBox = new System.Windows.Forms.TextBox(); + this.fridayTaxableTextBox = new System.Windows.Forms.TextBox(); + this.mondayTaxableLabel = new System.Windows.Forms.Label(); + this.wednesdayTaxableLabel = new System.Windows.Forms.Label(); + this.totalTaxableLabel = new System.Windows.Forms.Label(); + this.saturdayTaxableLabel = new System.Windows.Forms.Label(); + this.sundayTaxableTextBox = new System.Windows.Forms.TextBox(); + this.tuesdayTaxableLabel = new System.Windows.Forms.Label(); + this.saturdayTaxableTextBox = new System.Windows.Forms.TextBox(); + this.commentsGroupBox = new System.Windows.Forms.GroupBox(); + this.commentsTextBox = new System.Windows.Forms.TextBox(); + this.dateGroupBox = new System.Windows.Forms.GroupBox(); + this.weekEndingCalendar = new System.Windows.Forms.MonthCalendar(); + this.dateTimeMaskedTextBoxPanel = new System.Windows.Forms.Panel(); + this.informationLabel = new System.Windows.Forms.Label(); + this.informationPanel = new System.Windows.Forms.Panel(); + this.errorLabel = new System.Windows.Forms.Label(); + this.addRecordButton = new System.Windows.Forms.Button(); + this.mainLayoutPanel.SuspendLayout(); + this.mainMenuStrip.SuspendLayout(); + this.mainTabControl.SuspendLayout(); + this.projectionTabPage.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.projectionsDataGridView)).BeginInit(); + this.inventoryTabPage.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.inventoryDataGridView)).BeginInit(); + this.actualSalesTabPage.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.actualSalesDataGridView)).BeginInit(); + this.invoicesTabPage.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.invoicesDataGridView)).BeginInit(); + this.debugTabPage.SuspendLayout(); + this.debugPanel.SuspendLayout(); + this.costAnalysisGroupBox.SuspendLayout(); + this.tabControl1.SuspendLayout(); + this.weeklySalesTabPage.SuspendLayout(); + this.taxableTabPage.SuspendLayout(); + this.commentsGroupBox.SuspendLayout(); + this.dateGroupBox.SuspendLayout(); + this.dateTimeMaskedTextBoxPanel.SuspendLayout(); + this.informationPanel.SuspendLayout(); + this.SuspendLayout(); + // + // mainLayoutPanel + // + this.mainLayoutPanel.ColumnCount = 4; + this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.mainLayoutPanel.Controls.Add(this.mainMenuStrip, 0, 0); + this.mainLayoutPanel.Controls.Add(this.mainTabControl, 0, 1); + this.mainLayoutPanel.Controls.Add(this.costAnalysisGroupBox, 3, 2); + this.mainLayoutPanel.Controls.Add(this.tabControl1, 2, 2); + this.mainLayoutPanel.Controls.Add(this.commentsGroupBox, 1, 2); + this.mainLayoutPanel.Controls.Add(this.dateGroupBox, 0, 2); + this.mainLayoutPanel.Controls.Add(this.dateTimeMaskedTextBoxPanel, 1, 3); + this.mainLayoutPanel.Controls.Add(this.informationPanel, 3, 3); + this.mainLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.mainLayoutPanel.Location = new System.Drawing.Point(0, 0); + this.mainLayoutPanel.Margin = new System.Windows.Forms.Padding(4); + this.mainLayoutPanel.Name = "mainLayoutPanel"; + this.mainLayoutPanel.RowCount = 4; + this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F)); + this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 60F)); + this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); + this.mainLayoutPanel.Size = new System.Drawing.Size(1821, 980); + this.mainLayoutPanel.TabIndex = 1; + // + // mainMenuStrip + // + this.mainLayoutPanel.SetColumnSpan(this.mainMenuStrip, 4); + this.mainMenuStrip.ImageScalingSize = new System.Drawing.Size(24, 24); + this.mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.FileMainMenu, + this.debugMainMenu}); + this.mainMenuStrip.Location = new System.Drawing.Point(0, 0); + this.mainMenuStrip.Name = "mainMenuStrip"; + this.mainMenuStrip.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2); + this.mainMenuStrip.Size = new System.Drawing.Size(1821, 35); + this.mainMenuStrip.TabIndex = 0; + this.mainMenuStrip.Text = "menuStrip1"; + // + // FileMainMenu + // + this.FileMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.clearFormFileMainMenu, + this.exitFileMainMenu}); + this.FileMainMenu.Name = "FileMainMenu"; + 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(205, 34); + this.exitFileMainMenu.Text = "E&xit"; + // + // debugMainMenu + // + this.debugMainMenu.Name = "debugMainMenu"; + this.debugMainMenu.Size = new System.Drawing.Size(87, 31); + this.debugMainMenu.Text = "&Debug"; + // + // mainTabControl + // + this.mainLayoutPanel.SetColumnSpan(this.mainTabControl, 4); + this.mainTabControl.Controls.Add(this.projectionTabPage); + this.mainTabControl.Controls.Add(this.inventoryTabPage); + this.mainTabControl.Controls.Add(this.actualSalesTabPage); + this.mainTabControl.Controls.Add(this.invoicesTabPage); + this.mainTabControl.Controls.Add(this.debugTabPage); + this.mainTabControl.Dock = System.Windows.Forms.DockStyle.Fill; + this.mainTabControl.Location = new System.Drawing.Point(4, 39); + this.mainTabControl.Margin = new System.Windows.Forms.Padding(4); + this.mainTabControl.Name = "mainTabControl"; + this.mainTabControl.SelectedIndex = 0; + this.mainTabControl.Size = new System.Drawing.Size(1813, 559); + this.mainTabControl.TabIndex = 1; + this.mainTabControl.TabStop = false; + // + // projectionTabPage + // + this.projectionTabPage.Controls.Add(this.projectionsDataGridView); + this.projectionTabPage.Location = new System.Drawing.Point(4, 33); + this.projectionTabPage.Margin = new System.Windows.Forms.Padding(4); + this.projectionTabPage.Name = "projectionTabPage"; + this.projectionTabPage.Size = new System.Drawing.Size(1805, 522); + this.projectionTabPage.TabIndex = 0; + this.projectionTabPage.Text = "Projected Sales"; + this.projectionTabPage.UseVisualStyleBackColor = true; + // + // projectionsDataGridView + // + this.projectionsDataGridView.AllowDrop = true; + this.projectionsDataGridView.AllowUserToResizeRows = false; + this.projectionsDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + 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(1805, 522); + this.projectionsDataGridView.TabIndex = 2; + // + // inventoryTabPage + // + this.inventoryTabPage.Controls.Add(this.inventoryDataGridView); + this.inventoryTabPage.Location = new System.Drawing.Point(4, 33); + this.inventoryTabPage.Margin = new System.Windows.Forms.Padding(4); + this.inventoryTabPage.Name = "inventoryTabPage"; + this.inventoryTabPage.Size = new System.Drawing.Size(1805, 522); + this.inventoryTabPage.TabIndex = 1; + this.inventoryTabPage.Text = "Inventory"; + this.inventoryTabPage.UseVisualStyleBackColor = true; + // + // inventoryDataGridView + // + this.inventoryDataGridView.AllowDrop = true; + this.inventoryDataGridView.AllowUserToResizeRows = false; + this.inventoryDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + 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(1805, 522); + this.inventoryDataGridView.TabIndex = 1; + // + // actualSalesTabPage + // + this.actualSalesTabPage.Controls.Add(this.actualSalesDataGridView); + this.actualSalesTabPage.Location = new System.Drawing.Point(4, 33); + this.actualSalesTabPage.Margin = new System.Windows.Forms.Padding(4); + this.actualSalesTabPage.Name = "actualSalesTabPage"; + this.actualSalesTabPage.Size = new System.Drawing.Size(1805, 522); + this.actualSalesTabPage.TabIndex = 2; + this.actualSalesTabPage.Text = "Actual Sales"; + this.actualSalesTabPage.UseVisualStyleBackColor = true; + // + // actualSalesDataGridView + // + this.actualSalesDataGridView.AllowDrop = true; + this.actualSalesDataGridView.AllowUserToResizeRows = false; + this.actualSalesDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + 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(1805, 522); + this.actualSalesDataGridView.TabIndex = 1; + // + // invoicesTabPage + // + this.invoicesTabPage.Controls.Add(this.invoicesDataGridView); + this.invoicesTabPage.Location = new System.Drawing.Point(4, 33); + this.invoicesTabPage.Margin = new System.Windows.Forms.Padding(4); + this.invoicesTabPage.Name = "invoicesTabPage"; + this.invoicesTabPage.Size = new System.Drawing.Size(1805, 522); + this.invoicesTabPage.TabIndex = 3; + this.invoicesTabPage.Text = "Invoices"; + this.invoicesTabPage.UseVisualStyleBackColor = true; + // + // invoicesDataGridView + // + this.invoicesDataGridView.AllowDrop = true; + this.invoicesDataGridView.AllowUserToResizeRows = false; + this.invoicesDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + 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(1805, 522); + this.invoicesDataGridView.TabIndex = 1; + // + // debugTabPage + // + this.debugTabPage.Controls.Add(this.debugPanel); + this.debugTabPage.Location = new System.Drawing.Point(4, 33); + this.debugTabPage.Name = "debugTabPage"; + this.debugTabPage.Padding = new System.Windows.Forms.Padding(3); + this.debugTabPage.Size = new System.Drawing.Size(1805, 522); + this.debugTabPage.TabIndex = 4; + 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(1799, 516); + 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; + // + // 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; + // + // 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; + // + // 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; + // + // 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; + // + // costAnalysisGroupBox + // + this.costAnalysisGroupBox.Controls.Add(this.suppliesTextBox); + this.costAnalysisGroupBox.Controls.Add(this.salaryPercentageTextBox); + this.costAnalysisGroupBox.Controls.Add(this.salaryDollarsTextBox); + this.costAnalysisGroupBox.Controls.Add(this.salesPerManHourLabel); + this.costAnalysisGroupBox.Controls.Add(this.salaryPercentageLabel); + this.costAnalysisGroupBox.Controls.Add(this.salesPerManHourTextBox); + this.costAnalysisGroupBox.Controls.Add(this.salaryDollarsLabel); + this.costAnalysisGroupBox.Controls.Add(this.suppliesLabel); + this.costAnalysisGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.costAnalysisGroupBox.Location = new System.Drawing.Point(1368, 605); + this.costAnalysisGroupBox.Name = "costAnalysisGroupBox"; + this.costAnalysisGroupBox.Size = new System.Drawing.Size(450, 183); + this.costAnalysisGroupBox.TabIndex = 6; + this.costAnalysisGroupBox.TabStop = false; + this.costAnalysisGroupBox.Text = "Cost Analysis"; + // + // suppliesTextBox + // + this.suppliesTextBox.Location = new System.Drawing.Point(203, 139); + this.suppliesTextBox.Name = "suppliesTextBox"; + this.suppliesTextBox.Size = new System.Drawing.Size(199, 29); + this.suppliesTextBox.TabIndex = 25; + // + // salaryPercentageTextBox + // + this.salaryPercentageTextBox.Location = new System.Drawing.Point(203, 69); + this.salaryPercentageTextBox.Name = "salaryPercentageTextBox"; + this.salaryPercentageTextBox.Size = new System.Drawing.Size(199, 29); + this.salaryPercentageTextBox.TabIndex = 23; + // + // salaryDollarsTextBox + // + this.salaryDollarsTextBox.Location = new System.Drawing.Point(203, 104); + this.salaryDollarsTextBox.Name = "salaryDollarsTextBox"; + this.salaryDollarsTextBox.Size = new System.Drawing.Size(199, 29); + this.salaryDollarsTextBox.TabIndex = 24; + // + // salesPerManHourLabel + // + this.salesPerManHourLabel.AutoSize = true; + this.salesPerManHourLabel.Location = new System.Drawing.Point(3, 34); + this.salesPerManHourLabel.Name = "salesPerManHourLabel"; + this.salesPerManHourLabel.Size = new System.Drawing.Size(194, 25); + this.salesPerManHourLabel.TabIndex = 0; + this.salesPerManHourLabel.Text = "Sales Per Man Hour:"; + // + // salaryPercentageLabel + // + this.salaryPercentageLabel.AutoSize = true; + this.salaryPercentageLabel.Location = new System.Drawing.Point(18, 69); + this.salaryPercentageLabel.Name = "salaryPercentageLabel"; + this.salaryPercentageLabel.Size = new System.Drawing.Size(179, 25); + this.salaryPercentageLabel.TabIndex = 1; + this.salaryPercentageLabel.Text = "Salary Percentage:"; + // + // salesPerManHourTextBox + // + this.salesPerManHourTextBox.Location = new System.Drawing.Point(203, 34); + this.salesPerManHourTextBox.Name = "salesPerManHourTextBox"; + this.salesPerManHourTextBox.Size = new System.Drawing.Size(199, 29); + this.salesPerManHourTextBox.TabIndex = 22; + // + // salaryDollarsLabel + // + this.salaryDollarsLabel.AutoSize = true; + this.salaryDollarsLabel.Location = new System.Drawing.Point(58, 104); + this.salaryDollarsLabel.Name = "salaryDollarsLabel"; + this.salaryDollarsLabel.Size = new System.Drawing.Size(139, 25); + this.salaryDollarsLabel.TabIndex = 2; + this.salaryDollarsLabel.Text = "Salary Dollars:"; + // + // suppliesLabel + // + this.suppliesLabel.AutoSize = true; + this.suppliesLabel.Location = new System.Drawing.Point(103, 139); + this.suppliesLabel.Name = "suppliesLabel"; + this.suppliesLabel.Size = new System.Drawing.Size(94, 25); + this.suppliesLabel.TabIndex = 3; + this.suppliesLabel.Text = "Supplies:"; + // + // tabControl1 + // + this.tabControl1.Controls.Add(this.weeklySalesTabPage); + this.tabControl1.Controls.Add(this.taxableTabPage); + this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabControl1.Location = new System.Drawing.Point(910, 602); + this.tabControl1.Margin = new System.Windows.Forms.Padding(0); + this.tabControl1.Multiline = true; + this.tabControl1.Name = "tabControl1"; + this.tabControl1.Padding = new System.Drawing.Point(0, 0); + this.mainLayoutPanel.SetRowSpan(this.tabControl1, 2); + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(455, 378); + this.tabControl1.TabIndex = 5; + // + // weeklySalesTabPage + // + this.weeklySalesTabPage.BackColor = System.Drawing.SystemColors.ControlLight; + this.weeklySalesTabPage.Controls.Add(this.mondayWeeklySalesTextBox); + this.weeklySalesTabPage.Controls.Add(this.totalWeeklySalesTextBox); + this.weeklySalesTabPage.Controls.Add(this.saturdayWeeklySalesTextBox); + this.weeklySalesTabPage.Controls.Add(this.thursdayWeeklySalesTextBox); + this.weeklySalesTabPage.Controls.Add(this.tuesdayWeeklySalesTextBox); + this.weeklySalesTabPage.Controls.Add(this.mondayWeeklySalesLabel); + this.weeklySalesTabPage.Controls.Add(this.thursdayWeeklySalesLabel); + this.weeklySalesTabPage.Controls.Add(this.saturdayWeeklySalesLabel); + this.weeklySalesTabPage.Controls.Add(this.sundayWeeklySalesTextBox); + this.weeklySalesTabPage.Controls.Add(this.totalWeeklySalesLabel); + this.weeklySalesTabPage.Controls.Add(this.fridayWeeklySalesLabel); + this.weeklySalesTabPage.Controls.Add(this.wednesdayWeeklySalesLabel); + this.weeklySalesTabPage.Controls.Add(this.tuesdayWeeklySalesLabel); + this.weeklySalesTabPage.Controls.Add(this.fridayWeeklySalesTextBox); + this.weeklySalesTabPage.Controls.Add(this.sundayWeeklySalesLabel); + this.weeklySalesTabPage.Controls.Add(this.wednesdayWeeklySalesTextBox); + this.weeklySalesTabPage.Location = new System.Drawing.Point(4, 33); + this.weeklySalesTabPage.Name = "weeklySalesTabPage"; + this.weeklySalesTabPage.Padding = new System.Windows.Forms.Padding(3); + this.weeklySalesTabPage.Size = new System.Drawing.Size(447, 341); + this.weeklySalesTabPage.TabIndex = 0; + this.weeklySalesTabPage.Text = "Weekly Sales"; + // + // mondayWeeklySalesTextBox + // + this.mondayWeeklySalesTextBox.Location = new System.Drawing.Point(135, 46); + this.mondayWeeklySalesTextBox.Name = "mondayWeeklySalesTextBox"; + this.mondayWeeklySalesTextBox.Size = new System.Drawing.Size(274, 29); + this.mondayWeeklySalesTextBox.TabIndex = 7; + // + // totalWeeklySalesTextBox + // + this.totalWeeklySalesTextBox.Location = new System.Drawing.Point(134, 299); + this.totalWeeklySalesTextBox.Name = "totalWeeklySalesTextBox"; + this.totalWeeklySalesTextBox.Size = new System.Drawing.Size(274, 29); + this.totalWeeklySalesTextBox.TabIndex = 13; + // + // saturdayWeeklySalesTextBox + // + this.saturdayWeeklySalesTextBox.Location = new System.Drawing.Point(135, 256); + this.saturdayWeeklySalesTextBox.Name = "saturdayWeeklySalesTextBox"; + this.saturdayWeeklySalesTextBox.Size = new System.Drawing.Size(274, 29); + this.saturdayWeeklySalesTextBox.TabIndex = 12; + // + // thursdayWeeklySalesTextBox + // + this.thursdayWeeklySalesTextBox.Location = new System.Drawing.Point(135, 172); + this.thursdayWeeklySalesTextBox.Name = "thursdayWeeklySalesTextBox"; + this.thursdayWeeklySalesTextBox.Size = new System.Drawing.Size(274, 29); + this.thursdayWeeklySalesTextBox.TabIndex = 10; + // + // tuesdayWeeklySalesTextBox + // + this.tuesdayWeeklySalesTextBox.Location = new System.Drawing.Point(135, 88); + this.tuesdayWeeklySalesTextBox.Name = "tuesdayWeeklySalesTextBox"; + this.tuesdayWeeklySalesTextBox.Size = new System.Drawing.Size(274, 29); + this.tuesdayWeeklySalesTextBox.TabIndex = 8; + // + // mondayWeeklySalesLabel + // + this.mondayWeeklySalesLabel.AutoSize = true; + this.mondayWeeklySalesLabel.Location = new System.Drawing.Point(11, 49); + this.mondayWeeklySalesLabel.Name = "mondayWeeklySalesLabel"; + this.mondayWeeklySalesLabel.Size = new System.Drawing.Size(89, 25); + this.mondayWeeklySalesLabel.TabIndex = 1; + this.mondayWeeklySalesLabel.Text = "Monday:"; + // + // thursdayWeeklySalesLabel + // + this.thursdayWeeklySalesLabel.AutoSize = true; + this.thursdayWeeklySalesLabel.Location = new System.Drawing.Point(11, 175); + this.thursdayWeeklySalesLabel.Name = "thursdayWeeklySalesLabel"; + this.thursdayWeeklySalesLabel.Size = new System.Drawing.Size(101, 25); + this.thursdayWeeklySalesLabel.TabIndex = 4; + this.thursdayWeeklySalesLabel.Text = "Thursday:"; + // + // saturdayWeeklySalesLabel + // + this.saturdayWeeklySalesLabel.AutoSize = true; + this.saturdayWeeklySalesLabel.Location = new System.Drawing.Point(11, 259); + this.saturdayWeeklySalesLabel.Name = "saturdayWeeklySalesLabel"; + this.saturdayWeeklySalesLabel.Size = new System.Drawing.Size(97, 25); + this.saturdayWeeklySalesLabel.TabIndex = 6; + this.saturdayWeeklySalesLabel.Text = "Saturday:"; + // + // sundayWeeklySalesTextBox + // + this.sundayWeeklySalesTextBox.Location = new System.Drawing.Point(135, 4); + this.sundayWeeklySalesTextBox.Name = "sundayWeeklySalesTextBox"; + this.sundayWeeklySalesTextBox.Size = new System.Drawing.Size(274, 29); + this.sundayWeeklySalesTextBox.TabIndex = 6; + // + // totalWeeklySalesLabel + // + this.totalWeeklySalesLabel.AutoSize = true; + this.totalWeeklySalesLabel.Location = new System.Drawing.Point(11, 301); + this.totalWeeklySalesLabel.Name = "totalWeeklySalesLabel"; + this.totalWeeklySalesLabel.Size = new System.Drawing.Size(117, 25); + this.totalWeeklySalesLabel.TabIndex = 7; + this.totalWeeklySalesLabel.Text = "Total Sales:"; + // + // fridayWeeklySalesLabel + // + this.fridayWeeklySalesLabel.AutoSize = true; + this.fridayWeeklySalesLabel.Location = new System.Drawing.Point(11, 217); + this.fridayWeeklySalesLabel.Name = "fridayWeeklySalesLabel"; + this.fridayWeeklySalesLabel.Size = new System.Drawing.Size(72, 25); + this.fridayWeeklySalesLabel.TabIndex = 5; + this.fridayWeeklySalesLabel.Text = "Friday:"; + // + // wednesdayWeeklySalesLabel + // + this.wednesdayWeeklySalesLabel.AutoSize = true; + this.wednesdayWeeklySalesLabel.Location = new System.Drawing.Point(11, 133); + this.wednesdayWeeklySalesLabel.Name = "wednesdayWeeklySalesLabel"; + this.wednesdayWeeklySalesLabel.Size = new System.Drawing.Size(124, 25); + this.wednesdayWeeklySalesLabel.TabIndex = 3; + this.wednesdayWeeklySalesLabel.Text = "Wednesday:"; + // + // tuesdayWeeklySalesLabel + // + this.tuesdayWeeklySalesLabel.AutoSize = true; + this.tuesdayWeeklySalesLabel.Location = new System.Drawing.Point(11, 91); + this.tuesdayWeeklySalesLabel.Name = "tuesdayWeeklySalesLabel"; + this.tuesdayWeeklySalesLabel.Size = new System.Drawing.Size(95, 25); + this.tuesdayWeeklySalesLabel.TabIndex = 2; + this.tuesdayWeeklySalesLabel.Text = "Tuesday:"; + // + // fridayWeeklySalesTextBox + // + this.fridayWeeklySalesTextBox.Location = new System.Drawing.Point(135, 214); + this.fridayWeeklySalesTextBox.Name = "fridayWeeklySalesTextBox"; + this.fridayWeeklySalesTextBox.Size = new System.Drawing.Size(274, 29); + this.fridayWeeklySalesTextBox.TabIndex = 11; + // + // sundayWeeklySalesLabel + // + this.sundayWeeklySalesLabel.AutoSize = true; + this.sundayWeeklySalesLabel.Location = new System.Drawing.Point(11, 7); + this.sundayWeeklySalesLabel.Name = "sundayWeeklySalesLabel"; + this.sundayWeeklySalesLabel.Size = new System.Drawing.Size(86, 25); + this.sundayWeeklySalesLabel.TabIndex = 0; + this.sundayWeeklySalesLabel.Text = "Sunday:"; + // + // wednesdayWeeklySalesTextBox + // + this.wednesdayWeeklySalesTextBox.Location = new System.Drawing.Point(135, 130); + this.wednesdayWeeklySalesTextBox.Name = "wednesdayWeeklySalesTextBox"; + this.wednesdayWeeklySalesTextBox.Size = new System.Drawing.Size(274, 29); + this.wednesdayWeeklySalesTextBox.TabIndex = 9; + // + // taxableTabPage + // + this.taxableTabPage.BackColor = System.Drawing.SystemColors.ControlLight; + this.taxableTabPage.Controls.Add(this.totalTaxableTextBox); + this.taxableTabPage.Controls.Add(this.mondayTaxableTextBox); + this.taxableTabPage.Controls.Add(this.thursdayTaxableTextBox); + this.taxableTabPage.Controls.Add(this.tuesdayTaxableTextBox); + this.taxableTabPage.Controls.Add(this.fridayTaxableLabel); + this.taxableTabPage.Controls.Add(this.sundayTaxableLabel); + this.taxableTabPage.Controls.Add(this.thursdayTaxableLabel); + this.taxableTabPage.Controls.Add(this.wednesdayTaxableTextBox); + this.taxableTabPage.Controls.Add(this.fridayTaxableTextBox); + this.taxableTabPage.Controls.Add(this.mondayTaxableLabel); + this.taxableTabPage.Controls.Add(this.wednesdayTaxableLabel); + this.taxableTabPage.Controls.Add(this.totalTaxableLabel); + this.taxableTabPage.Controls.Add(this.saturdayTaxableLabel); + this.taxableTabPage.Controls.Add(this.sundayTaxableTextBox); + this.taxableTabPage.Controls.Add(this.tuesdayTaxableLabel); + this.taxableTabPage.Controls.Add(this.saturdayTaxableTextBox); + this.taxableTabPage.Location = new System.Drawing.Point(4, 33); + this.taxableTabPage.Name = "taxableTabPage"; + this.taxableTabPage.Padding = new System.Windows.Forms.Padding(3); + this.taxableTabPage.Size = new System.Drawing.Size(447, 341); + this.taxableTabPage.TabIndex = 1; + this.taxableTabPage.Text = "Taxable"; + // + // totalTaxableTextBox + // + this.totalTaxableTextBox.Location = new System.Drawing.Point(145, 299); + this.totalTaxableTextBox.Name = "totalTaxableTextBox"; + this.totalTaxableTextBox.Size = new System.Drawing.Size(263, 29); + this.totalTaxableTextBox.TabIndex = 21; + // + // mondayTaxableTextBox + // + this.mondayTaxableTextBox.Location = new System.Drawing.Point(145, 47); + this.mondayTaxableTextBox.Name = "mondayTaxableTextBox"; + this.mondayTaxableTextBox.Size = new System.Drawing.Size(263, 29); + this.mondayTaxableTextBox.TabIndex = 15; + // + // thursdayTaxableTextBox + // + this.thursdayTaxableTextBox.Location = new System.Drawing.Point(145, 173); + this.thursdayTaxableTextBox.Name = "thursdayTaxableTextBox"; + this.thursdayTaxableTextBox.Size = new System.Drawing.Size(263, 29); + this.thursdayTaxableTextBox.TabIndex = 18; + // + // tuesdayTaxableTextBox + // + this.tuesdayTaxableTextBox.Location = new System.Drawing.Point(145, 90); + this.tuesdayTaxableTextBox.Name = "tuesdayTaxableTextBox"; + this.tuesdayTaxableTextBox.Size = new System.Drawing.Size(263, 29); + this.tuesdayTaxableTextBox.TabIndex = 16; + // + // fridayTaxableLabel + // + this.fridayTaxableLabel.AutoSize = true; + this.fridayTaxableLabel.Location = new System.Drawing.Point(11, 219); + this.fridayTaxableLabel.Name = "fridayTaxableLabel"; + this.fridayTaxableLabel.Size = new System.Drawing.Size(72, 25); + this.fridayTaxableLabel.TabIndex = 13; + this.fridayTaxableLabel.Text = "Friday:"; + // + // sundayTaxableLabel + // + this.sundayTaxableLabel.AutoSize = true; + this.sundayTaxableLabel.Location = new System.Drawing.Point(11, 9); + this.sundayTaxableLabel.Name = "sundayTaxableLabel"; + this.sundayTaxableLabel.Size = new System.Drawing.Size(86, 25); + this.sundayTaxableLabel.TabIndex = 8; + this.sundayTaxableLabel.Text = "Sunday:"; + // + // thursdayTaxableLabel + // + this.thursdayTaxableLabel.AutoSize = true; + this.thursdayTaxableLabel.Location = new System.Drawing.Point(11, 177); + this.thursdayTaxableLabel.Name = "thursdayTaxableLabel"; + this.thursdayTaxableLabel.Size = new System.Drawing.Size(101, 25); + this.thursdayTaxableLabel.TabIndex = 12; + this.thursdayTaxableLabel.Text = "Thursday:"; + // + // wednesdayTaxableTextBox + // + this.wednesdayTaxableTextBox.Location = new System.Drawing.Point(145, 132); + this.wednesdayTaxableTextBox.Name = "wednesdayTaxableTextBox"; + this.wednesdayTaxableTextBox.Size = new System.Drawing.Size(263, 29); + this.wednesdayTaxableTextBox.TabIndex = 17; + // + // fridayTaxableTextBox + // + this.fridayTaxableTextBox.Location = new System.Drawing.Point(145, 216); + this.fridayTaxableTextBox.Name = "fridayTaxableTextBox"; + this.fridayTaxableTextBox.Size = new System.Drawing.Size(263, 29); + this.fridayTaxableTextBox.TabIndex = 19; + // + // mondayTaxableLabel + // + this.mondayTaxableLabel.AutoSize = true; + this.mondayTaxableLabel.Location = new System.Drawing.Point(11, 51); + this.mondayTaxableLabel.Name = "mondayTaxableLabel"; + this.mondayTaxableLabel.Size = new System.Drawing.Size(89, 25); + this.mondayTaxableLabel.TabIndex = 9; + this.mondayTaxableLabel.Text = "Monday:"; + // + // wednesdayTaxableLabel + // + this.wednesdayTaxableLabel.AutoSize = true; + this.wednesdayTaxableLabel.Location = new System.Drawing.Point(11, 135); + this.wednesdayTaxableLabel.Name = "wednesdayTaxableLabel"; + this.wednesdayTaxableLabel.Size = new System.Drawing.Size(124, 25); + this.wednesdayTaxableLabel.TabIndex = 11; + this.wednesdayTaxableLabel.Text = "Wednesday:"; + // + // totalTaxableLabel + // + this.totalTaxableLabel.AutoSize = true; + this.totalTaxableLabel.Location = new System.Drawing.Point(11, 303); + this.totalTaxableLabel.Name = "totalTaxableLabel"; + this.totalTaxableLabel.Size = new System.Drawing.Size(138, 25); + this.totalTaxableLabel.TabIndex = 15; + this.totalTaxableLabel.Text = "Total Taxable:"; + // + // saturdayTaxableLabel + // + this.saturdayTaxableLabel.AutoSize = true; + this.saturdayTaxableLabel.Location = new System.Drawing.Point(11, 261); + this.saturdayTaxableLabel.Name = "saturdayTaxableLabel"; + this.saturdayTaxableLabel.Size = new System.Drawing.Size(97, 25); + this.saturdayTaxableLabel.TabIndex = 14; + this.saturdayTaxableLabel.Text = "Saturday:"; + // + // sundayTaxableTextBox + // + this.sundayTaxableTextBox.Location = new System.Drawing.Point(145, 5); + this.sundayTaxableTextBox.Name = "sundayTaxableTextBox"; + this.sundayTaxableTextBox.Size = new System.Drawing.Size(263, 29); + this.sundayTaxableTextBox.TabIndex = 14; + // + // tuesdayTaxableLabel + // + this.tuesdayTaxableLabel.AutoSize = true; + this.tuesdayTaxableLabel.Location = new System.Drawing.Point(11, 93); + this.tuesdayTaxableLabel.Name = "tuesdayTaxableLabel"; + this.tuesdayTaxableLabel.Size = new System.Drawing.Size(95, 25); + this.tuesdayTaxableLabel.TabIndex = 10; + this.tuesdayTaxableLabel.Text = "Tuesday:"; + // + // saturdayTaxableTextBox + // + this.saturdayTaxableTextBox.Location = new System.Drawing.Point(145, 258); + this.saturdayTaxableTextBox.Name = "saturdayTaxableTextBox"; + this.saturdayTaxableTextBox.Size = new System.Drawing.Size(263, 29); + this.saturdayTaxableTextBox.TabIndex = 20; + // + // 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(459, 606); + this.commentsGroupBox.Margin = new System.Windows.Forms.Padding(4); + this.commentsGroupBox.Name = "commentsGroupBox"; + this.commentsGroupBox.Padding = new System.Windows.Forms.Padding(4); + this.commentsGroupBox.Size = new System.Drawing.Size(447, 181); + this.commentsGroupBox.TabIndex = 2; + this.commentsGroupBox.TabStop = false; + this.commentsGroupBox.Text = "Comments"; + // + // commentsTextBox + // + this.commentsTextBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.commentsTextBox.Location = new System.Drawing.Point(4, 26); + this.commentsTextBox.MaxLength = 256; + this.commentsTextBox.Multiline = true; + this.commentsTextBox.Name = "commentsTextBox"; + this.commentsTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.commentsTextBox.Size = new System.Drawing.Size(439, 151); + this.commentsTextBox.TabIndex = 4; + // + // dateGroupBox + // + this.dateGroupBox.Controls.Add(this.weekEndingCalendar); + this.dateGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.dateGroupBox.Location = new System.Drawing.Point(3, 605); + this.dateGroupBox.Name = "dateGroupBox"; + this.mainLayoutPanel.SetRowSpan(this.dateGroupBox, 2); + this.dateGroupBox.Size = new System.Drawing.Size(449, 372); + this.dateGroupBox.TabIndex = 24; + this.dateGroupBox.TabStop = false; + this.dateGroupBox.Text = "Week Ending Date"; + // + // weekEndingCalendar + // + this.weekEndingCalendar.BackColor = System.Drawing.SystemColors.ControlLight; + this.weekEndingCalendar.FirstDayOfWeek = System.Windows.Forms.Day.Sunday; + this.weekEndingCalendar.Location = new System.Drawing.Point(48, 34); + this.weekEndingCalendar.MaxSelectionCount = 1; + this.weekEndingCalendar.Name = "weekEndingCalendar"; + this.weekEndingCalendar.ShowTodayCircle = false; + this.weekEndingCalendar.TabIndex = 2; + this.weekEndingCalendar.TabStop = false; + // + // dateTimeMaskedTextBoxPanel + // + this.dateTimeMaskedTextBoxPanel.Controls.Add(this.informationLabel); + this.dateTimeMaskedTextBoxPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.dateTimeMaskedTextBoxPanel.Location = new System.Drawing.Point(458, 794); + this.dateTimeMaskedTextBoxPanel.Name = "dateTimeMaskedTextBoxPanel"; + this.dateTimeMaskedTextBoxPanel.Size = new System.Drawing.Size(449, 183); + this.dateTimeMaskedTextBoxPanel.TabIndex = 1; + // + // informationLabel + // + this.informationLabel.AutoSize = true; + this.informationLabel.Location = new System.Drawing.Point(0, 7); + this.informationLabel.Name = "informationLabel"; + this.informationLabel.Size = new System.Drawing.Size(0, 25); + this.informationLabel.TabIndex = 27; + // + // informationPanel + // + this.informationPanel.Controls.Add(this.errorLabel); + this.informationPanel.Controls.Add(this.addRecordButton); + this.informationPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.informationPanel.Location = new System.Drawing.Point(1368, 794); + this.informationPanel.Name = "informationPanel"; + this.informationPanel.Size = new System.Drawing.Size(450, 183); + this.informationPanel.TabIndex = 25; + // + // errorLabel + // + this.errorLabel.AutoSize = true; + this.errorLabel.ForeColor = System.Drawing.Color.Maroon; + this.errorLabel.Location = new System.Drawing.Point(-1, 7); + this.errorLabel.Name = "errorLabel"; + this.errorLabel.Size = new System.Drawing.Size(0, 25); + this.errorLabel.TabIndex = 28; + // + // addRecordButton + // + this.addRecordButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.addRecordButton.Location = new System.Drawing.Point(274, 133); + this.addRecordButton.Name = "addRecordButton"; + this.addRecordButton.Size = new System.Drawing.Size(167, 41); + this.addRecordButton.TabIndex = 26; + this.addRecordButton.Text = "Update Record"; + this.addRecordButton.UseVisualStyleBackColor = true; + // + // NewModifyRecord + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1821, 980); + this.Controls.Add(this.mainLayoutPanel); + this.MinimumSize = new System.Drawing.Size(1000, 1000); + this.Name = "NewModifyRecord"; + this.Text = "Modify Record"; + this.mainLayoutPanel.ResumeLayout(false); + this.mainLayoutPanel.PerformLayout(); + this.mainMenuStrip.ResumeLayout(false); + this.mainMenuStrip.PerformLayout(); + this.mainTabControl.ResumeLayout(false); + this.projectionTabPage.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.projectionsDataGridView)).EndInit(); + this.inventoryTabPage.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.inventoryDataGridView)).EndInit(); + this.actualSalesTabPage.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.actualSalesDataGridView)).EndInit(); + this.invoicesTabPage.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.invoicesDataGridView)).EndInit(); + this.debugTabPage.ResumeLayout(false); + this.debugPanel.ResumeLayout(false); + this.debugPanel.PerformLayout(); + this.costAnalysisGroupBox.ResumeLayout(false); + this.costAnalysisGroupBox.PerformLayout(); + this.tabControl1.ResumeLayout(false); + this.weeklySalesTabPage.ResumeLayout(false); + this.weeklySalesTabPage.PerformLayout(); + this.taxableTabPage.ResumeLayout(false); + this.taxableTabPage.PerformLayout(); + this.commentsGroupBox.ResumeLayout(false); + this.commentsGroupBox.PerformLayout(); + this.dateGroupBox.ResumeLayout(false); + this.dateTimeMaskedTextBoxPanel.ResumeLayout(false); + this.dateTimeMaskedTextBoxPanel.PerformLayout(); + this.informationPanel.ResumeLayout(false); + this.informationPanel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel mainLayoutPanel; + private System.Windows.Forms.MenuStrip mainMenuStrip; + private System.Windows.Forms.ToolStripMenuItem FileMainMenu; + private System.Windows.Forms.ToolStripMenuItem clearFormFileMainMenu; + private System.Windows.Forms.ToolStripMenuItem exitFileMainMenu; + private System.Windows.Forms.ToolStripMenuItem debugMainMenu; + private System.Windows.Forms.TabControl mainTabControl; + private System.Windows.Forms.TabPage projectionTabPage; + private System.Windows.Forms.DataGridView projectionsDataGridView; + private System.Windows.Forms.TabPage inventoryTabPage; + private System.Windows.Forms.DataGridView inventoryDataGridView; + private System.Windows.Forms.TabPage actualSalesTabPage; + private System.Windows.Forms.DataGridView actualSalesDataGridView; + private System.Windows.Forms.TabPage invoicesTabPage; + private System.Windows.Forms.DataGridView invoicesDataGridView; + private System.Windows.Forms.TabPage debugTabPage; + private System.Windows.Forms.Panel debugPanel; + private System.Windows.Forms.Button generateCostAnalysisIdButton; + private System.Windows.Forms.Button generateTaxableIdButton; + private System.Windows.Forms.Button generateWeeklySalesIdButton; + private System.Windows.Forms.Label reminderLabel; + private System.Windows.Forms.Button generateCommentIdButton; + private System.Windows.Forms.CheckBox isCostAnalysisDirtyCheckBox; + private System.Windows.Forms.CheckBox isTaxableDirtyCheckBox; + private System.Windows.Forms.CheckBox isWeeklySalesDirtyCheckBox; + private System.Windows.Forms.CheckBox isCommentDirtyCheckBox; + private System.Windows.Forms.GroupBox costAnalysisGroupBox; + private System.Windows.Forms.TextBox suppliesTextBox; + private System.Windows.Forms.TextBox salaryPercentageTextBox; + private System.Windows.Forms.TextBox salaryDollarsTextBox; + private System.Windows.Forms.Label salesPerManHourLabel; + private System.Windows.Forms.Label salaryPercentageLabel; + private System.Windows.Forms.TextBox salesPerManHourTextBox; + private System.Windows.Forms.Label salaryDollarsLabel; + private System.Windows.Forms.Label suppliesLabel; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage weeklySalesTabPage; + private System.Windows.Forms.TextBox mondayWeeklySalesTextBox; + private System.Windows.Forms.TextBox totalWeeklySalesTextBox; + private System.Windows.Forms.TextBox saturdayWeeklySalesTextBox; + private System.Windows.Forms.TextBox thursdayWeeklySalesTextBox; + private System.Windows.Forms.TextBox tuesdayWeeklySalesTextBox; + private System.Windows.Forms.Label mondayWeeklySalesLabel; + private System.Windows.Forms.Label thursdayWeeklySalesLabel; + private System.Windows.Forms.Label saturdayWeeklySalesLabel; + private System.Windows.Forms.TextBox sundayWeeklySalesTextBox; + private System.Windows.Forms.Label totalWeeklySalesLabel; + private System.Windows.Forms.Label fridayWeeklySalesLabel; + private System.Windows.Forms.Label wednesdayWeeklySalesLabel; + private System.Windows.Forms.Label tuesdayWeeklySalesLabel; + private System.Windows.Forms.TextBox fridayWeeklySalesTextBox; + private System.Windows.Forms.Label sundayWeeklySalesLabel; + private System.Windows.Forms.TextBox wednesdayWeeklySalesTextBox; + private System.Windows.Forms.TabPage taxableTabPage; + private System.Windows.Forms.TextBox totalTaxableTextBox; + private System.Windows.Forms.TextBox mondayTaxableTextBox; + private System.Windows.Forms.TextBox thursdayTaxableTextBox; + private System.Windows.Forms.TextBox tuesdayTaxableTextBox; + private System.Windows.Forms.Label fridayTaxableLabel; + private System.Windows.Forms.Label sundayTaxableLabel; + private System.Windows.Forms.Label thursdayTaxableLabel; + private System.Windows.Forms.TextBox wednesdayTaxableTextBox; + private System.Windows.Forms.TextBox fridayTaxableTextBox; + private System.Windows.Forms.Label mondayTaxableLabel; + private System.Windows.Forms.Label wednesdayTaxableLabel; + private System.Windows.Forms.Label totalTaxableLabel; + private System.Windows.Forms.Label saturdayTaxableLabel; + private System.Windows.Forms.TextBox sundayTaxableTextBox; + private System.Windows.Forms.Label tuesdayTaxableLabel; + private System.Windows.Forms.TextBox saturdayTaxableTextBox; + private System.Windows.Forms.GroupBox commentsGroupBox; + private System.Windows.Forms.TextBox commentsTextBox; + private System.Windows.Forms.GroupBox dateGroupBox; + private System.Windows.Forms.MonthCalendar weekEndingCalendar; + private System.Windows.Forms.Panel dateTimeMaskedTextBoxPanel; + private System.Windows.Forms.Label informationLabel; + private System.Windows.Forms.Panel informationPanel; + private System.Windows.Forms.Label errorLabel; + private System.Windows.Forms.Button addRecordButton; + } +} \ No newline at end of file diff --git a/AdvertsingProfitControl/NewModifyRecord.cs b/AdvertsingProfitControl/NewModifyRecord.cs new file mode 100644 index 0000000..938d54e --- /dev/null +++ b/AdvertsingProfitControl/NewModifyRecord.cs @@ -0,0 +1,2229 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Globalization; +using System.Linq; +using System.Text.RegularExpressions; +using System.Windows.Forms; + +namespace AdvertsingProfitControl +{ + public partial class NewModifyRecord : Form + { + private static readonly FrmLogConsole LogConsole = FrmLogConsole.GetStaticInstance; + //Create an array that contains all the ad items from the database. + private readonly List _adItemCollection; + //This object contains all the unused ad items. + private AutoCompleteStringCollection _trimmedAdItemCollection = new AutoCompleteStringCollection(); + //Contains all the ad specials that are in the database (i.e. "Daily Coupons"). + private readonly AutoCompleteStringCollection _adSpecialList; + //This object contains all the suppliers that were found in the database. + private readonly AutoCompleteStringCollection _supplierCollection; + //This array keeps track of the number of times an Ad Item is used, if used once then it may only be used AFTER an AdSpecialRow and only once after that. + //Once an item has been used twice, it will not appear again in the AutoCompleteSuggestions. + //The structure of the used ad item list is as follows: + //List(0) is section one and List(1) is section two. Section one is not ad special and section two is. + private readonly List[] _usedAdItems = new List[2]; + //This string keeps track of the last ad item used. This item can then be used to safely remove an ad item from the list of used items. + //Used in the OnCellValidating event to store the last ad item used in the event that the user changes a row that already exists. + private string _beginningCellValue = ""; + //Flag showing whether or not the AdSpecialRow has been made in this session. + private int _adSpecialIndex = -1; + private readonly AdvertisingProfitControlTableHelper _tableHelperFunctions = new AdvertisingProfitControlTableHelper(); + //Represents the date that is being modified, if this changes then the form needs to be cleared and refilled with the new date. + private DateTime _currentActiveDate; + // + private bool _isFormDirty; + + public NewModifyRecord(DateTime date) + { + InitializeComponent(); + //Start by grabbing all the AdItems and putting them into memory. + var databaseTracker = new DatabaseTracker(); + var databaseReader = new DatabaseReader(); + weekEndingCalendar.BoldedDates = databaseReader.RetrieveDates(databaseTracker.DatabaseConnectionString).ToArray(); + weekEndingCalendar.SelectionStart = date; + weekEndingCalendar.DateChanged += ValidateDateChanged; + _currentActiveDate = date; + Text = @"Modify Record (Current Record: " + date.ToString("d") + @")"; + //next pull all the ad items into memory. + _adItemCollection = databaseReader.GetAdItemsSuggestionList(databaseTracker.DatabaseConnectionString); + //Now pull all the suppliers and the ad special list into memory. + _supplierCollection = databaseReader.GetSupplierSuggestionList(databaseTracker.DatabaseConnectionString); + _adSpecialList = databaseReader.RetrieveAdSpecialList(databaseTracker.DatabaseConnectionString); + //Initialize the used ad item collection. + _usedAdItems[0] = new List(); + _usedAdItems[1] = new List(); + //Assign the events for the comments text box and display the remaining character count for the user. + commentsTextBox.TextChanged += DisplayRemainingCommentCharacterCount; + commentsGroupBox.Text = @"Comments (Characters Remaining: " + commentsTextBox.MaxLength + @")"; + //Setup the events for that the Projected and Actual Sales DataGridViews will share. + //Events are assigned with regard to which event gets triggered first and so on.. + //Hook the row add event so we can paint a row number in the header cell of the row. + projectionsDataGridView.RowsAdded += DisplayRowNumbers; + inventoryDataGridView.RowsAdded += DisplayRowNumbers; + actualSalesDataGridView.RowsAdded += DisplayRowNumbers; + //Assign all the tables to store the cell's contents on enter so changes (if any) can be detected and flagged (marked as dirty). + projectionsDataGridView.CellEnter += StoreBeginningCellValue; + inventoryDataGridView.CellEnter += StoreBeginningCellValue; + actualSalesDataGridView.CellEnter += StoreBeginningCellValue; + //Update the contents of the used as item list on row leave. + projectionsDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave; + inventoryDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave; + actualSalesDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave; + //Validate, clean and format the contents of the cell that fires the cell validating event. + projectionsDataGridView.CellValidating += ValidateSalesDataGridViewCellContents; + inventoryDataGridView.CellValidating += ValidateInventoryCellContents; + actualSalesDataGridView.CellValidating += ValidateSalesDataGridViewCellContents; + //Validate that the row the user is trying to leave is legal (has at least an ad item entered) and prevent the user from leaving the row is its not. + projectionsDataGridView.RowValidating += ValidateProjectedRow; + inventoryDataGridView.RowValidating += ValidateInventoryRow; + actualSalesDataGridView.RowValidating += ValidateActualSalesRow; + //Update the used ad item collection by removing the contents of the ad item column when a row is deleted. + projectionsDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving; + inventoryDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving; + actualSalesDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving; + //Once a row has been removed update the other tables keep them uniform. + projectionsDataGridView.RowsRemoved += ProjectionRowRemoved; + inventoryDataGridView.RowsRemoved += InventoryRowRemoved; + actualSalesDataGridView.RowsRemoved += ActualSalesRowRemoved; + //Grab the underlying text box object in the ad item cell, and build an auto complete list for the user. + projectionsDataGridView.EditingControlShowing += DisplayAutoCompleteOnEditingControlShowing; + inventoryDataGridView.EditingControlShowing += DisplayAutoCompleteOnEditingControlShowing; + actualSalesDataGridView.EditingControlShowing += DisplayAutoCompleteOnEditingControlShowing; + //After all events have been set, construct the DataGridVeiws for use. + ConstructApcDataGridViews(); + LoadDate(date); + //Set-up events for the Invoice table. + invoicesDataGridView.CellEnter += StoreBeginningCellValue; + //Validate that the row the user is trying to leave is legal (has at least an ad item entered) and prevent the user from leaving the row is its not. + invoicesDataGridView.RowValidating += ValidateInvoiceRow; + //Validate, clean and format the contents of the cell that fires the cell validating event. + invoicesDataGridView.CellValidating += ValidateInvoicesCellContents; + //Grab the underlying text box object in the ad item cell, and build an auto complete list for the user. + invoicesDataGridView.EditingControlShowing += DisplaySupplierAutoComleteOnEditingShadowControl; + //Subscribe the method to allow the user to delete saved rows from the Invoices table. + invoicesDataGridView.UserDeletingRow += UpdateInvoicesOnRowDeleting; + //Finally build the last DataGridView for the form. + 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; + sundayWeeklySalesTextBox.Validating += ValidateWeeklySales; + mondayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue; + mondayWeeklySalesTextBox.Validating += ValidateWeeklySales; + tuesdayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue; + tuesdayWeeklySalesTextBox.Validating += ValidateWeeklySales; + wednesdayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue; + wednesdayWeeklySalesTextBox.Validating += ValidateWeeklySales; + thursdayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue; + thursdayWeeklySalesTextBox.Validating += ValidateWeeklySales; + fridayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue; + fridayWeeklySalesTextBox.Validating += ValidateWeeklySales; + saturdayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue; + saturdayWeeklySalesTextBox.Validating += ValidateWeeklySales; + totalWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue; + totalWeeklySalesTextBox.Validating += ValidateWeeklySales; + //Subscribe the taxable text boxes to validation and update events. + sundayTaxableTextBox.Enter += StoreBeginningTextBoxValue; + sundayTaxableTextBox.Validating += ValidateTaxableFields; + mondayTaxableTextBox.Enter += StoreBeginningTextBoxValue; + mondayTaxableTextBox.Validating += ValidateTaxableFields; + tuesdayTaxableTextBox.Enter += StoreBeginningTextBoxValue; + tuesdayTaxableTextBox.Validating += ValidateTaxableFields; + wednesdayTaxableTextBox.Enter += StoreBeginningTextBoxValue; + wednesdayTaxableTextBox.Validating += ValidateTaxableFields; + thursdayTaxableTextBox.Enter += StoreBeginningTextBoxValue; + thursdayTaxableTextBox.Validating += ValidateTaxableFields; + fridayTaxableTextBox.Enter += StoreBeginningTextBoxValue; + fridayTaxableTextBox.Validating += ValidateTaxableFields; + saturdayTaxableTextBox.Enter += StoreBeginningTextBoxValue; + saturdayTaxableTextBox.Validating += ValidateTaxableFields; + totalTaxableTextBox.Enter += StoreBeginningTextBoxValue; + totalTaxableTextBox.Validating += ValidateTaxableFields; + //Subscribe the Cost Analysis text boxes to the validation and update events. + salesPerManHourTextBox.Enter += StoreBeginningTextBoxValue; + salesPerManHourTextBox.Validating += ValidateCostAnalysisValues; + salaryPercentageTextBox.Enter += StoreBeginningTextBoxValue; + salaryPercentageTextBox.Validating += ValidateCostAnalysisValues; + salaryDollarsTextBox.Enter += StoreBeginningTextBoxValue; + salaryDollarsTextBox.Validating += ValidateCostAnalysisValues; + suppliesTextBox.Enter += StoreBeginningTextBoxValue; + suppliesTextBox.Validating += ValidateCostAnalysisValues; + } + + public sealed override string Text + { + get { return base.Text; } + set { base.Text = value; } + } + + //private void RestoreActiveDate(object sender, EventArgs e) + //{ + // var calendar = (MonthCalendar) sender; + // if (calendar.SelectionStart == _currentActiveDate || calendar.BoldedDates.Contains(calendar.SelectionStart)) return; + // MessageBox.Show(@"This date doesn't appear to be in the database.", @"Date not Found"); + // weekEndingCalendar.DateChanged -= ValidateDateChanged; + // weekEndingCalendar.SelectionStart = _currentActiveDate; + // weekEndingCalendar.DateChanged += ValidateDateChanged; + //} + + #region Global Event Handlers + + /// + /// 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; + } + + #endregion + + #region Invoice Table Events + + /// + /// Event Used: RowValidating + /// Validates that the row has required information, namely an invoice date, number and supplier. + /// + /// + /// + private static void ValidateInvoiceRow(object sender, DataGridViewCellCancelEventArgs e) + { + var dataGridView = (DataGridView)sender; + if (dataGridView.Rows[e.RowIndex].IsNewRow) return; + DateTime dateTime; + //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]; + 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() == "") + { + 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; + } + } + + /// + /// Event Used: CellValidating + /// Verifies the contents of the invoice table's cells. Also applies formating where needed. + /// + /// + /// + private void ValidateInvoicesCellContents(object sender, DataGridViewCellValidatingEventArgs e) + { + //Grab the DataGirdView that fired the event and make it into a local variable. + var dataGridView = (DataGridView)sender; + var userInput = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue.ToString().Trim(); + var textInfo = new CultureInfo("en-US", false).TextInfo; + //Check for isNewRow if it is, return no need to check it for anything. + if (dataGridView.Rows[e.RowIndex].IsNewRow) + { + return; + } + //Mark the row as dirty assuming the user made changes + if (userInput != _beginningCellValue) + { + dataGridView.Rows[e.RowIndex].Cells[(int)InvoiceTableColumns.IsDirty].Value = true; + } + else + { + return; + } + //Check to see if we're in the invoice date column make sure the date is valid. + switch (e.ColumnIndex) + { + case (int)InvoiceTableColumns.InvoiceDate: + //Clear any error text a cell has for this column. + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = ""; + if (userInput != "") + { + DateTime date; + //Try parsing the date to make sure its valid, otherwise clear it from the cell and inform the user. + if (DateTime.TryParse(userInput, out date)) + { + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = date.ToString("d"); + dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit; + _isFormDirty = true; + } + else + { + MessageBox.Show(@"The date '" + userInput + @"' is not a valid date.", @"Invalid Date", MessageBoxButtons.OK, MessageBoxIcon.Error); + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "Invoice Date Must be in a Valid Format"; + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = ""; + } + } + else + { + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = ""; + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "An Invoice Date is Required"; + } + break; + case (int)InvoiceTableColumns.InvoiceNumber: + //Clear any error text a cell has for this column. + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = ""; + if (userInput != "") + { + long parsedNumber; + if (long.TryParse(userInput, out parsedNumber)) + { + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = parsedNumber; + dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit; + _isFormDirty = true; + } + else + { + MessageBox.Show(@"The invoice number must be a numeric value.", @"Non Numeric Invoice Number", MessageBoxButtons.OK, MessageBoxIcon.Error); + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = ""; + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "Invoice Number Must be Numeric"; + } + } + else + { + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = ""; + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "An Invoice Number is Required"; + } + break; + case (int)InvoiceTableColumns.Supplier: + //Clear any error text a cell has for this column. + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = ""; + if (userInput != "") + { + //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; + _isFormDirty = true; + } + else + { + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = ""; + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "A Supplier is Required"; + } + break; + case (int)InvoiceTableColumns.InvoiceNote: + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = userInput; + dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit; + _isFormDirty = true; + break; + default: + //Should only process the InvoiceNetAmountAtCost and InvoiceNetAmount columns. + if (e.ColumnIndex != (int)InvoiceTableColumns.Id && + e.ColumnIndex < (int)InvoiceTableColumns.InvoiceNote) + { + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = ""; + //Now check to make sure the user input isn't null + //Math.Round(parsedNumber, 2).ToString("N", new CultureInfo("en-US")); + if (userInput != "") + { + double parsedNumber; + if (double.TryParse(userInput, out parsedNumber)) + { + //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.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit; + _isFormDirty = true; + } + else + { + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = ""; + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "Only Numeric Values Allowed."; + } + } + } + break; + } + dataGridView.RefreshEdit(); + } + + /// + /// Event Used: EditingShadowControlShowing + /// Adds an auto-complete list of suppliers to the Suppliers cell. + /// + /// + /// + private void DisplaySupplierAutoComleteOnEditingShadowControl(object sender, DataGridViewEditingControlShowingEventArgs e) + { + var dataGridView = (DataGridView)sender; + var autoText = e.Control as TextBox; + if (autoText == null) return; + if (!(e.Control is DataGridViewTextBoxEditingControl) || dataGridView.CurrentCell.ColumnIndex != (int)InvoiceTableColumns.Supplier) return; + autoText.AutoCompleteMode = AutoCompleteMode.Suggest; + autoText.AutoCompleteSource = AutoCompleteSource.CustomSource; + autoText.AutoCompleteCustomSource = _supplierCollection; + } + + /// + /// Checks to see if the row that the user is attempting to delete has been saved to the database. + /// If so, this method will try to delete the record, failing that it will cancel the row deletion. + /// + /// Invoice table. + /// + private void UpdateInvoicesOnRowDeleting(object sender, DataGridViewRowCancelEventArgs e) + { + var rowIndex = e.Row.Index; + //See if there is an ID number in the ID column. + if (invoicesDataGridView.Rows[rowIndex].Cells[(int)InvoiceTableColumns.Id].EditedFormattedValue.ToString() == "") return; + //Ask the user to make damn sure they want to remove this record. + var result = MessageBox.Show(@"Deleting this row will remove it from the database permanently. Do you wish to continue?", @"Remove Invoice Number " + invoicesDataGridView.Rows[rowIndex].Cells[(int)InvoiceTableColumns.InvoiceNumber].EditedFormattedValue, MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (result == DialogResult.Yes) + { + //If so create the database interaction objects. + var dbTracker = new DatabaseTracker(); + var dbWriter = new DatabaseWriter(dbTracker.DatabaseConnectionString); + var id = + int.Parse( + invoicesDataGridView.Rows[rowIndex].Cells[(int)InvoiceTableColumns.Id].EditedFormattedValue + .ToString()); + if (dbWriter.DeleteInvoiceRow(id)) + { + informationLabel.Text = @"Successfully removed row " + (rowIndex + 1) + @" from the database."; + } + else + { + //The operation failed. + errorLabel.Text = @"Failed to delete row " + (rowIndex + 1) + @" from invoices."; + e.Cancel = true; + } + } + else + { + e.Cancel = true; + } + } + + #endregion + + #region APC DataGridView Events + + /// + /// Event Used: RowsAdded + /// Draws the row number in the row's cell header whenever a row is added. + /// + /// + /// + private static void DisplayRowNumbers(object sender, DataGridViewRowsAddedEventArgs e) + { + var table = ((DataGridView)sender); + table.Rows[e.RowIndex].HeaderCell.Value = (e.RowIndex + 1).ToString(); + } + + /// + /// Event Used: CellEnter + /// Stores the initial contents of the cell being entered to be compared later + /// to see if the user has made any changes (IsDirty). + /// + /// + /// + private void StoreBeginningCellValue(object sender, DataGridViewCellEventArgs e) + { + var dataGridView = (DataGridView)sender; + _beginningCellValue = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue.ToString(); + } + + /// + /// Event Used: OnRowLeave + /// Adds the ad items to the used ad item collection if they are not already in the collection. + /// + /// + /// + private void UpdateUsedAdItemCollectionOnRowLeave(object sender, DataGridViewCellEventArgs e) + { + var dataGridView = ((DataGridView)sender); + if (dataGridView.Rows[e.RowIndex].IsNewRow) { return; } //Return if the row is a new row as nothing needs to be done here. + int adItemIndex; + + switch (dataGridView.Name) + { + case "projectionsDataGridView": + adItemIndex = (int)SalesTableColumns.AdItem; + break; + case "actualSalesDataGridView": + adItemIndex = (int)SalesTableColumns.AdItem; + break; + default: + adItemIndex = (int)InventoryTableColumns.AdItem; + break; + } + var userInput = dataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString(); + //Paint the rows to identify what group they belong to. + _tableHelperFunctions.PaintRowGroupsFromIndex(e.RowIndex, dataGridView); + //Add in used Ad Items to the list. + if (userInput == "") return; + //Clear the old ad item out of the used ad item collection. + var parser = new RowParsing(); + if (parser.GetRowAttribute(dataGridView.Rows[e.RowIndex]) == RowAttribute.AdSpecialRow) + { + _adSpecialIndex = e.RowIndex; + return; + } + //Section one (1) detected. + if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex) + { + if (_usedAdItems[0].Contains(userInput)) return; + _usedAdItems[0].Add(userInput); + LogConsole.WriteToLog(FrmLogConsole.Level.Debug, "Adding \"" + userInput + "\" to section one (1)."); + } + //Section two (2) detected. + else + { + if (_usedAdItems[1].Contains(userInput)) return; + _usedAdItems[1].Add(userInput); + LogConsole.WriteToLog(FrmLogConsole.Level.Debug, "Adding \"" + userInput + "\" to section two (2)."); + } + } + + /// + /// Event Used: OnEditingControlShowing + /// Configures the auto complete collection and how it will be shown to the user. This method detects the section, + /// either one (1) or two (2), based on the gAdSpecialIndex and removes items from the auto complete accordingly. + /// Just a measure to help reduce redundancy in the tables. + /// + /// + /// + private void DisplayAutoCompleteOnEditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) + { + var dataGridView = ((DataGridView)sender); + var autoText = e.Control as TextBox; + //Get the index of the ad item column + const int adItemIndex = (int)SalesTableColumns.AdItem; + if (e.Control is DataGridViewTextBoxEditingControl && dataGridView.CurrentCell.ColumnIndex == adItemIndex) + { + //Create a copy of the main ad item list that can be freely manipulated. + var customAutoComplete = new AutoCompleteStringCollection(); + var customList = _adItemCollection.ToList(); + + //IF the current row is less than the AdSpecialRow, remove all used items with the section 1 attribute. + if (_adSpecialIndex == -1 || dataGridView.CurrentCell.RowIndex < _adSpecialIndex) + { + foreach (var adItem in _usedAdItems[0]) + { + customList.RemoveAll(w => w.Equals(adItem, StringComparison.OrdinalIgnoreCase)); + } + } + //Occurs AFTER the AdSpecial row. + else if (dataGridView.CurrentCell.RowIndex > _adSpecialIndex) + { + foreach (var adItem in _usedAdItems[1]) + { + customList.RemoveAll(w => w.Equals(adItem, StringComparison.OrdinalIgnoreCase)); + } + } + foreach (var item in customList) + { + customAutoComplete.Add(item); + } + autoText.KeyDown += ChangeAutoCompleteListOnKeyCombo; + _trimmedAdItemCollection = customAutoComplete; //Make a temporary copy of the list for use with the TextBox event handler. + autoText.AutoCompleteMode = AutoCompleteMode.Suggest; + autoText.AutoCompleteSource = AutoCompleteSource.CustomSource; + autoText.AutoCompleteCustomSource = customAutoComplete; + } + else if (e.Control is DataGridViewTextBoxEditingControl && dataGridView.CurrentCell.ColumnIndex != adItemIndex) + { + autoText.AutoCompleteMode = AutoCompleteMode.None; + } + } + + /// + /// Event Used: UserDeleteingRow + /// This function is responsible for removing ad Items from the gUsedAdItem array; this must be done during the row removing + /// event handler so the data in the row can be grabbed and used. + /// + /// The DataGridView that fired the event. + /// Parameters, mainly allowing for canceling the event. + private void UpdateUsedAdItemCollectionOnRowRemoving(object sender, CancelEventArgs e) + { + //Create an object that represents the DataGridView that fired the event. + var dataGridView = (DataGridView)sender; + if (dataGridView.CurrentRow == null) return; + //Create the database writer object so rows that are in the database can be deleted. + var dbTracker = new DatabaseTracker(); + var dbWriter = new DatabaseWriter(dbTracker.DatabaseConnectionString); + var currentRowIndex = dataGridView.CurrentRow.Index; + //Remove the ad item from the gUsedAdItem collection, if it exists. + if (_adSpecialIndex == -1) + { + //If the ID number is set, i.e. not equal to null then attempt to remove it from the database. + if (dataGridView.Rows[currentRowIndex].Cells[0].EditedFormattedValue.ToString() != "") + { + var result = MessageBox.Show(@"Removing this row will permanently delete this record from the database. Do you wish to continue?", @"Remove " + dataGridView.Rows[currentRowIndex].Cells[1].EditedFormattedValue, MessageBoxButtons.YesNo); + if (result == DialogResult.Yes) + { + //Attempt to delete the row from the database by its ID number. + var projectionsRowId = int.Parse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString()); + var inventoryRowId = int.Parse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString()); + var actualSalesRowId = int.Parse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString()); + if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId)) + { + informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) + @" from the database."; + } + else + { + //If the removing failed cancel the row deletion in the DataGridView. + e.Cancel = true; + MessageBox.Show(@"Failed to delete " + dataGridView.Rows[currentRowIndex].Cells[1].EditedFormattedValue + + @" from the database.", @"Failed to Update Database"); + return; + } + } + } + //If the ad item entered in the first cell is in the gUsedAdItems collection, then remove it from there. + _usedAdItems[0].Remove(dataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue.ToString()); + } + else if (currentRowIndex < _adSpecialIndex) + { + //If the ID number is set, i.e. not equal to null then attempt to remove it from the database. + if (dataGridView.Rows[currentRowIndex].Cells[0].EditedFormattedValue.ToString() != "") + { + var result = MessageBox.Show(@"Removing this row will permanently delete this record from the database. Do you wish to continue?", @"Remove " + dataGridView.Rows[currentRowIndex].Cells[1].EditedFormattedValue, MessageBoxButtons.YesNo); + if (result == DialogResult.Yes) + { + //Attempt to delete the row from the database by its ID number. + var projectionsRowId = int.Parse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString()); + var inventoryRowId = int.Parse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString()); + var actualSalesRowId = int.Parse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString()); + if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId)) + { + informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) + @" from the database."; + } + else + { + //If the removing failed cancel the row deletion in the DataGridView. + e.Cancel = true; + MessageBox.Show(@"Failed to delete " + dataGridView.Rows[currentRowIndex].Cells[1].EditedFormattedValue + + @" from the database.", @"Failed to Update Database"); + return; + } + } + } + //If the ad item entered in the first cell is in the gUsedAdItems collection, then remove it from there. + _usedAdItems[0].Remove(dataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue.ToString()); + //Also decrement the _adSpecialIndex so that it points to the correct row. + _adSpecialIndex--; + } + else if (currentRowIndex > _adSpecialIndex) + { + //If the ID number is set, i.e. not equal to null then attempt to remove it from the database. + if (dataGridView.Rows[currentRowIndex].Cells[0].EditedFormattedValue.ToString() != "") + { + var result = MessageBox.Show(@"Removing this row will permanently delete this record from the database. Do you wish to continue?", @"Remove " + dataGridView.Rows[currentRowIndex].Cells[1].EditedFormattedValue, MessageBoxButtons.YesNo); + if (result == DialogResult.Yes) + { + //Attempt to delete the row from the database by its ID number. + var projectionsRowId = int.Parse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString()); + var inventoryRowId = int.Parse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString()); + var actualSalesRowId = int.Parse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString()); + if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId)) + { + informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) + @" from the database."; + } + else + { + //If the removing failed cancel the row deletion in the DataGridView. + e.Cancel = true; + MessageBox.Show(@"Failed to delete " + dataGridView.Rows[currentRowIndex].Cells[1].EditedFormattedValue + + @" from the database.", @"Failed to Update Database"); + return; + } + } + } + //If the ad item entered in the first cell is in the gUsedAdItems collection, then remove it from there. + _usedAdItems[1].Remove(dataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue.ToString()); + } + else if (currentRowIndex == _adSpecialIndex) + { + //Handle removing the AdSpecial row. + var result = MessageBox.Show(@"Deleting the Ad Special row will remove all rows beneath it. Do you wish to continue?", @"Clear " + dataGridView.Rows[currentRowIndex].Cells[1].EditedFormattedValue, MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (result == DialogResult.Yes) + { + //Clear all events that handle row removal from both DataGridViews. + //Projections table + projectionsDataGridView.RowsRemoved -= ProjectionRowRemoved; + projectionsDataGridView.UserDeletingRow -= UpdateUsedAdItemCollectionOnRowRemoving; + //Inventory table + inventoryDataGridView.RowsRemoved -= InventoryRowRemoved; + inventoryDataGridView.UserDeletingRow -= UpdateUsedAdItemCollectionOnRowRemoving; + //Actual Sales table + actualSalesDataGridView.RowsRemoved -= ActualSalesRowRemoved; + actualSalesDataGridView.UserDeletingRow -= UpdateUsedAdItemCollectionOnRowRemoving; + //Now for-each through each row that is underneath the Ad Special row. + for (var rowIndex = dataGridView.RowCount; currentRowIndex != rowIndex; rowIndex--) + { + if (projectionsDataGridView.RowCount == inventoryDataGridView.RowCount && + projectionsDataGridView.RowCount == actualSalesDataGridView.RowCount) + { + if (dataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString() != "") + { + //Attempt to delete the row from the database by its ID number. + var projectionsRowId = int.Parse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString()); + var inventoryRowId = int.Parse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString()); + var actualSalesRowId = int.Parse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString()); + if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId)) + { + informationLabel.Text += @"Successfully removed row " + (currentRowIndex + 1) + @" from the database." + Environment.NewLine; + } + else + { + //If the removing failed cancel the row deletion in the DataGridView. + e.Cancel = true; + MessageBox.Show(@"Failed to delete " + dataGridView.Rows[currentRowIndex].Cells[1].EditedFormattedValue + + @" from the database.", @"Failed to Update Database"); + return; + } + } + } + if (projectionsDataGridView.Rows[currentRowIndex].IsNewRow != true) + { + projectionsDataGridView.Rows.RemoveAt(currentRowIndex); + } + if (inventoryDataGridView.Rows[currentRowIndex].IsNewRow != true) + { + inventoryDataGridView.Rows.RemoveAt(currentRowIndex); + } + if (actualSalesDataGridView.Rows[currentRowIndex].IsNewRow != true) + { + actualSalesDataGridView.Rows.RemoveAt(currentRowIndex); + } + //If the ad item entered in the first cell is in the gUsedAdItems collection, then remove it from there. + _usedAdItems[1].Remove(dataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue.ToString()); + } + //Re-enable all row removal events on both tables. + //Projections table + projectionsDataGridView.RowsRemoved += ProjectionRowRemoved; + projectionsDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving; + //Inventory table + inventoryDataGridView.RowsRemoved += InventoryRowRemoved; + inventoryDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving; + //Actual Sales table + actualSalesDataGridView.RowsRemoved += ActualSalesRowRemoved; + actualSalesDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving; + //Reset the gAdSpecialIndex to -1. + _adSpecialIndex = -1; + e.Cancel = true; //Prevent the new row from being removed. + } + else + { + e.Cancel = true; + } + } + } + + private void ChangeAutoCompleteListOnKeyCombo(object sender, KeyEventArgs e) + { + var textBox = (TextBox)sender; + informationLabel.Text = ""; + + if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.S) + { + if (_adSpecialIndex == -1) + { + textBox.AutoCompleteCustomSource = _adSpecialList; + informationLabel.Text = @"Auto complete mode changed to Ad Special."; + } + else + { + textBox.AutoCompleteCustomSource = _trimmedAdItemCollection; + informationLabel.Text = @"An Ad Special row already exists, auto complete mode\n can not be changed."; + } + } + else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.A) + { + textBox.AutoCompleteCustomSource = _trimmedAdItemCollection; + informationLabel.Text = @"Auto complete mode changed to Ad Items."; + } + e.Handled = false; + } + + #endregion + + #region Sales DataGridView Events + + /// + /// Event Used: CellValidating + /// Validates the contents of a cell, before leaving it. If the contents + /// are valid then the appropriate formatting is applied if needed. + /// + /// + /// + private void ValidateSalesDataGridViewCellContents(object sender, DataGridViewCellValidatingEventArgs e) + { + //Grab the DataGirdView that fired the event and make it into a local variable. + var dataGridView = (DataGridView)sender; + var userInput = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue.ToString(); + //TODO: Write a custom parsing engine for detecting when bins are entered. + var textInfo = new CultureInfo("en-US", false).TextInfo; + //Check for isNewRow if it is, return no need to check it for anything. + if (dataGridView.Rows[e.RowIndex].IsNewRow) + { + return; + } + + if (userInput == _beginningCellValue) + { + return; + } + //Check to make sure we're not in the boolean fields or the ID field. + if (e.ColumnIndex >= (int)SalesTableColumns.IsHeaderRow || e.ColumnIndex == (int)SalesTableColumns.Id) + { + return; + } + //Cell validating gets to handle updating the used ad item list since it handles cells on by one, instead by a whole row. + if (userInput != _beginningCellValue && e.ColumnIndex == (int)SalesTableColumns.AdItem) + { + //The user is trying to change the ad special text to something else. + if (e.RowIndex == _adSpecialIndex) + { + var parser = new RowParsing(); + if (parser.CheckForGroupKeyWord(userInput) == "NoGroupFound") + { + MessageBox.Show( + @"The Ad Special row's column one (1) cannot be changed. You must delete this row by clicking on the header cell and pressing 'Delete'.", + @"Invalid Operation on Ad Special Row", MessageBoxButtons.OK, MessageBoxIcon.Error); + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = _beginningCellValue; + dataGridView.RefreshEdit(); + return; + } + //Mark all ad special members as dirty since the user changed the ad special. + for (var index = _adSpecialIndex + 1; index < dataGridView.RowCount; index++) + { + //Add overflow protection + if (index < projectionsDataGridView.RowCount) + { + if (!projectionsDataGridView.Rows[index].IsNewRow) + { + projectionsDataGridView.Rows[index].Cells[(int)SalesTableColumns.IsDirty].Value = true; + } + } + if (index < actualSalesDataGridView.RowCount) + { + if (!actualSalesDataGridView.Rows[index].IsNewRow) + { + actualSalesDataGridView.Rows[index].Cells[(int)SalesTableColumns.IsDirty].Value = true; + } + } + if (index < inventoryDataGridView.RowCount) + { + if (!inventoryDataGridView.Rows[index].IsNewRow) + { + inventoryDataGridView.Rows[index].Cells[(int)InventoryTableColumns.IsDirty].Value = true; + } + } + } + } + _usedAdItems[_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex ? 0 : 1].Remove(_beginningCellValue); + dataGridView.Rows[e.RowIndex].Cells[(int)SalesTableColumns.IsDirty].Value = true; + } + 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; + _isFormDirty = true; + } + double parsedNumber; + //Check to see if the current column is the ad item column. + switch (e.ColumnIndex) + { + case (int)SalesTableColumns.AdItem: //Ad Item + //If there is text after all the whitespace has been cleared, clear the error text property regardless of whether or not it is set. + if (!string.IsNullOrEmpty(Regex.Replace(userInput, @"\s+", ""))) + { + //Clear the error text since there is in fact an item entered. + 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); + var parser = new RowParsing(); + if (parser.CheckForGroupKeyWord(userInput) == "NoGroupFound") + { + dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit; + _isFormDirty = true; + } + else + { + _adSpecialIndex = e.RowIndex; + //Since this is the ad special row don't give it any color coding. + dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = DefaultBackColor; + } + //Force a refresh so the cell's text updates and displays for the user. + dataGridView.RefreshEdit(); + return; + } + //Otherwise, show an error. + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "Ad Item needed"; + break; + case (int)SalesTableColumns.Sold: //Sold + //This Reg-ex pattern will match any number followed by the word bin(s), to allow specifying the number of bins of product were ordered. + var inventoryStringCheck = new Regex(@"^[0-9]{1,2} \bbin(s){0,1}\b", RegexOptions.IgnoreCase); + + if ( + inventoryStringCheck.IsMatch( + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue.ToString())) + { + //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; + _isFormDirty = true; + dataGridView.RefreshEdit(); + return; + } + //Try parsing the text entered as a number and if that fails then break out and clear the value entered. + if (double.TryParse(userInput, out parsedNumber)) + { + //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; + _isFormDirty = true; + } + else + { + if (userInput == "") + { + return; + } + 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; + return; + } + break; + case (int)SalesTableColumns.SalePrice: + //If the column is the "Sale Price" column try to parse the contents to a Double and apply number formatting to the contents. + //Check for the cost column to see if there are any strings formatted like such: + var regExpression = new Regex(@"^\d+( *)?/( *)?\${0,1}?\d+(\.\d+)?", RegexOptions.IgnoreCase); // [0-9]/($)?[0-9] + //IF the current cell is in the sale price column, check for the string format above, else move to the default method. + if (regExpression.IsMatch(dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue.ToString())) + { + //Grab the input and split it at the forward slash (/) for formatting. + var input = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue.ToString(); + input = input.Replace(" ", ""); + //Remove any dollar signs as these cause errors. + input = input.Replace("$", ""); + var stringArray = input.Split('/'); + //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; + _isFormDirty = true; + //Always refresh edit so the new value shows up to the user. + dataGridView.RefreshEdit(); + return; //And return, there is no need to go further. + } + //Try parsing the text entered as a number and if that fails then break out and clear the value entered. + 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; + _isFormDirty = true; + } + else + { + if (userInput == "") + { + return; + } + 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; + return; + } + break; + default: + //Purely here for protection against parsing the Boolean columns by mistake. + if (e.ColumnIndex == (int)SalesTableColumns.Id || e.ColumnIndex >= (int)SalesTableColumns.IsHeaderRow) { return; } + //If the column is any other then check to see if the entered value can be parsed to a double (is a number), if not then throw an error to the user. + 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; + _isFormDirty = true; + } + else + { + if (userInput == "") + { + return; + } + 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; + return; + } + break; + } + //Always refresh edit so the new value shows up to the user. + dataGridView.RefreshEdit(); + } + + #endregion + + #region Projected Sales DataGridView Events + + /// + /// Event Used: RowValidating + /// Checks to make sure the row is valid (has an ad item) and + /// then copies the contents where possible over to the inventory + /// and actual sales DataGridViews. + /// + /// + /// + private void ValidateProjectedRow(object sender, DataGridViewCellCancelEventArgs e) + { + //Grab the index of the ad item, assuming the Sales tables and the Inventory table stay in the same position. + const int adItemIndex = (int)SalesTableColumns.AdItem; + //Do not even attempt anything since this is a new row and nothing to worry about. + if (projectionsDataGridView.Rows[e.RowIndex].IsNewRow) + { + return; + } + //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; + } + //Check to see if the user left a row that already exists and doesn't require being copied over. + if (projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() == actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString()) + { + return; + } + //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) + { + 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() == "") + { + 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; + case (int)SalesTableColumns.IsHeaderRow: + rowContents[i] = false; + break; + case (int)SalesTableColumns.IsMemberRow: + rowContents[i] = false; + break; + default: + 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)InventoryTableColumns.IsDirty: + inventoryNewRow[(int)InventoryTableColumns.IsDirty] = true; + break; + case (int)InventoryTableColumns.IsHeaderRow: + inventoryNewRow[(int)InventoryTableColumns.IsHeaderRow] = false; + break; + case (int)InventoryTableColumns.IsMemberRow: + inventoryNewRow[(int)InventoryTableColumns.IsMemberRow] = false; + break; + default: + if (i > (int)InventoryTableColumns.IsHeaderRow) continue; + 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. + if (e.RowIndex != _adSpecialIndex) + { + inventoryDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit; + actualSalesDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit; + } + else + { + inventoryDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = DefaultBackColor; + actualSalesDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = DefaultBackColor; + } + } + + private void ProjectionRowRemoved(object sender, DataGridViewRowsRemovedEventArgs e) + { + var dataGridView = ((DataGridView)sender); + //Provide protection against overflows + if ((e.RowIndex + 1) > dataGridView.Rows.Count) + { + return; + } + //Disable all row removing events from the other two tables to prevent interference. + inventoryDataGridView.UserDeletingRow -= UpdateUsedAdItemCollectionOnRowRemoving; + inventoryDataGridView.RowsRemoved -= InventoryRowRemoved; + + actualSalesDataGridView.UserDeletingRow -= UpdateUsedAdItemCollectionOnRowRemoving; + actualSalesDataGridView.RowsRemoved -= ActualSalesRowRemoved; + + //IF the row count on the passed DataGridView is less then the other table's row count... + if (projectionsDataGridView.RowCount <= actualSalesDataGridView.RowCount && projectionsDataGridView.RowCount <= actualSalesDataGridView.RowCount) + { + //... it is lower so its safe to assume that both tables have the same row that can be removed. + if (!actualSalesDataGridView.Rows[e.RowIndex].IsNewRow) + { + actualSalesDataGridView.Rows.RemoveAt(e.RowIndex); + } + + if (!inventoryDataGridView.Rows[e.RowIndex].IsNewRow) + { + inventoryDataGridView.Rows.RemoveAt(e.RowIndex); + } + } + //ELSE IF the row count is larger then the other table's row count... + else + { + //... Log the error and then what? + //TODO: Figure out if this is an error condition. + LogConsole.WriteToLog(FrmLogConsole.Level.Error, "The Projections table has more rows then the Actual Sales table."); + LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Projections Row Count: " + projectionsDataGridView.RowCount); + LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Inventory Row Count: " + inventoryDataGridView.RowCount); + LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Actual Sales Row Count: " + actualSalesDataGridView.RowCount); + errorLabel.Text = @"Error removing rows from Actual Sales and Inventory."; + } + //... After all the row removal has been finished re-enable the row removal events. + inventoryDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving; + inventoryDataGridView.RowsRemoved += InventoryRowRemoved; + + actualSalesDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving; + actualSalesDataGridView.RowsRemoved += ActualSalesRowRemoved; + + //Reset the row numbers in the tables. + for (var i = e.RowIndex; i < (dataGridView.RowCount); i++) + { + projectionsDataGridView.Rows[i].HeaderCell.Value = (i + 1).ToString(); + inventoryDataGridView.Rows[i].HeaderCell.Value = (i + 1).ToString(); + actualSalesDataGridView.Rows[i].HeaderCell.Value = (i + 1).ToString(); + } + //Refresh the DataGridViews so the header cell's number get repainted properly and repaint the rows in case any groups get messed up during row removal. + projectionsDataGridView.RefreshEdit(); + inventoryDataGridView.RefreshEdit(); + actualSalesDataGridView.RefreshEdit(); + _tableHelperFunctions.PaintRowGroups(dataGridView); + } + + #endregion + + #region Inventory DataGridView Events + + /// + /// Event Used: CellValidating + /// Validates the contents of the cell that the user is attempting to leave. Applies formatting + /// to text as needed and prevents the user from leaving invalid cells. + /// + /// + /// + private void ValidateInventoryCellContents(object sender, DataGridViewCellValidatingEventArgs e) + { + //Grab the DataGirdView that fired the event and make it into a local variable. + var dataGridView = ((DataGridView)sender); + var userInput = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue.ToString(); + //TODO: Write a custom parsing engine for detecting when bins are entered. + var textInfo = new CultureInfo("en-US", false).TextInfo; + //Check for isNewRow if it is, return no need to check it for anything. + if (dataGridView.Rows[e.RowIndex].IsNewRow) + { + return; + } + + if (userInput == _beginningCellValue) + { + return; + } + //Check to make sure we're not in the boolean fields or the ID field. + if (e.ColumnIndex >= (int)InventoryTableColumns.IsHeaderRow || e.ColumnIndex == (int)InventoryTableColumns.Id) + { + return; + } + //Cell validating gets to handle updating the used ad item list since it handles cells on by one, instead by a whole row. + if (userInput != _beginningCellValue && e.ColumnIndex == (int)InventoryTableColumns.AdItem) + { + //The user is trying to change the ad special text to something else. + if (e.RowIndex == _adSpecialIndex) + { + var parser = new RowParsing(); + if (parser.CheckForGroupKeyWord(userInput) == "NoGroupFound") + { + MessageBox.Show(@"The Ad Special row's column one (1) cannot be changed. You must delete this row by clicking on the header cell and pressing 'Delete'.", @"Invalid Operation on Ad Special Row", MessageBoxButtons.OK, MessageBoxIcon.Error); + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = _beginningCellValue; + dataGridView.RefreshEdit(); + return; + } + //Mark all ad special members as dirty since the user changed the ad special. + for (var index = _adSpecialIndex + 1; index < dataGridView.RowCount; index++) + { + //Add overflow protection + if (index < projectionsDataGridView.RowCount) + { + if (!projectionsDataGridView.Rows[index].IsNewRow) + { + projectionsDataGridView.Rows[index].Cells[(int)SalesTableColumns.IsDirty].Value = true; + } + } + if (index < actualSalesDataGridView.RowCount) + { + if (!actualSalesDataGridView.Rows[index].IsNewRow) + { + actualSalesDataGridView.Rows[index].Cells[(int)SalesTableColumns.IsDirty].Value = true; + } + } + if (index < inventoryDataGridView.RowCount) + { + if (!inventoryDataGridView.Rows[index].IsNewRow) + { + inventoryDataGridView.Rows[index].Cells[(int)InventoryTableColumns.IsDirty].Value = true; + } + } + } + } + _usedAdItems[_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex ? 0 : 1].Remove(_beginningCellValue); + dataGridView.Rows[e.RowIndex].Cells[(int)InventoryTableColumns.IsDirty].Value = true; + } + else if (userInput != _beginningCellValue) + { + dataGridView.Rows[e.RowIndex].Cells[(int)InventoryTableColumns.IsDirty].Value = true; + } + //Check to see if the current column is the ad item column. + switch (e.ColumnIndex) + { + case (int)InventoryTableColumns.AdItem: + //If there is text after all the whitespace has been cleared, clear the error text property regardless of whether or not it is set. + if (!string.IsNullOrEmpty(Regex.Replace(userInput, @"\s+", ""))) + { + //Clear the error text since there is in fact an item entered. + 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); + var parser = new RowParsing(); + if (parser.CheckForGroupKeyWord(userInput) == "NoGroupFound") + { + dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit; + _isFormDirty = true; + } + else + { + _adSpecialIndex = e.RowIndex; + //Since this is the ad special row don't give it any color coding. + dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = DefaultBackColor; + } + //Force a refresh so the cell's text updates and displays for the user. + dataGridView.RefreshEdit(); + return; + } + //If column one (1) is blank then cancel cell validating. + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "Ad Item needed"; + break; + default: + //Purely here for protection against parsing the Boolean columns by mistake. + if (e.ColumnIndex == (int)InventoryTableColumns.Id || e.ColumnIndex >= (int)InventoryTableColumns.IsHeaderRow) { return; } + //This Reg-ex pattern will match any number followed by the word bin(s), to allow specifying the number of bins of product were ordered. + var inventoryStringCheck = new Regex(@"^[0-9]{1,2} \bbin(s){0,1}\b", RegexOptions.IgnoreCase); + + if ( + inventoryStringCheck.IsMatch( + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue.ToString())) + { + //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; + _isFormDirty = true; + 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)) + { + //Add the value to the cell. + dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = userInput; + dataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit; + _isFormDirty = true; + return; + } + //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. + dataGridView.RefreshEdit(); + } + + /// + /// Event Used: RowValidating + /// Checks to make sure the row is valid (has an ad item) and + /// then copies the contents where possible over to the projections + /// and actual sales DataGridViews. + /// + /// + /// + private void ValidateInventoryRow(object sender, DataGridViewCellCancelEventArgs e) + { + //Grab the index of the ad item, assuming the Sales tables and the Inventory table stay in the same position. + const int adItemIndex = (int)InventoryTableColumns.AdItem; + //Do not even attempt anything since this is a new row and nothing to worry about. + if (inventoryDataGridView.Rows[e.RowIndex].IsNewRow) + { + return; + } + //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; + } + //Check to see if the user left a row that already exists and doesn't require being copied over. + if (inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() == actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString()) + { + return; + } + //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) + { + 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)); + } + + 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; + case (int)SalesTableColumns.IsHeaderRow: + rowContents[i] = false; + break; + case (int)SalesTableColumns.IsMemberRow: + rowContents[i] = false; + break; + default: + rowContents[i] = ""; + break; + } + } + projectionsDataGridView.Rows.Add(rowContents); + actualSalesDataGridView.Rows.Add(rowContents); + if (e.RowIndex != _adSpecialIndex) + { + //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; + } + else + { + //Apply color coding to the respective row headers on the other tables. + projectionsDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = DefaultBackColor; + actualSalesDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = DefaultBackColor; + } + } + + private void InventoryRowRemoved(object sender, DataGridViewRowsRemovedEventArgs e) + { + var dataGridView = ((DataGridView)sender); + //Provide protection against overflows + if ((e.RowIndex + 1) > dataGridView.Rows.Count) + { + return; + } + //Disable all row removing events from the other two tables to prevent interference. + projectionsDataGridView.UserDeletingRow -= UpdateUsedAdItemCollectionOnRowRemoving; + projectionsDataGridView.RowsRemoved -= ProjectionRowRemoved; + + actualSalesDataGridView.UserDeletingRow -= UpdateUsedAdItemCollectionOnRowRemoving; + actualSalesDataGridView.RowsRemoved -= ActualSalesRowRemoved; + + //IF the row count on the passed DataGridView is less then the other table's row count... + if (inventoryDataGridView.RowCount <= projectionsDataGridView.RowCount && inventoryDataGridView.RowCount <= actualSalesDataGridView.RowCount) + { + //... it is lower so its safe to assume that both tables have the same row that can be removed. + if (!projectionsDataGridView.Rows[e.RowIndex].IsNewRow) + { + projectionsDataGridView.Rows.RemoveAt(e.RowIndex); + } + + if (!actualSalesDataGridView.Rows[e.RowIndex].IsNewRow) + { + actualSalesDataGridView.Rows.RemoveAt(e.RowIndex); + } + } + //ELSE IF the row count is larger then the other table's row count... + else + { + //... Log the error and then what? + //TODO: Figure out if this is an error condition. + LogConsole.WriteToLog(FrmLogConsole.Level.Error, "The Inventory table has more rows then the Actual Sales table."); + LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Projections Row Count: " + projectionsDataGridView.RowCount); + LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Inventory Row Count: " + inventoryDataGridView.RowCount); + LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Actual Sales Row Count: " + actualSalesDataGridView.RowCount); + errorLabel.Text = @"Error removing rows from Actual Sales and Inventory."; + } + //... After all the row removal has been finished re-enable the row removal events. + projectionsDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving; + projectionsDataGridView.RowsRemoved += ProjectionRowRemoved; + + actualSalesDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving; + actualSalesDataGridView.RowsRemoved += ActualSalesRowRemoved; + + //Reset the row numbers in each table. + for (var i = e.RowIndex; i < (dataGridView.RowCount); i++) + { + projectionsDataGridView.Rows[i].HeaderCell.Value = (i + 1).ToString(); + inventoryDataGridView.Rows[i].HeaderCell.Value = (i + 1).ToString(); + actualSalesDataGridView.Rows[i].HeaderCell.Value = (i + 1).ToString(); + } + //Refresh the DataGridViews so the header cell's number get repainted properly and repaint the rows in case any groups get messed up during row removal. + projectionsDataGridView.RefreshEdit(); + inventoryDataGridView.RefreshEdit(); + actualSalesDataGridView.RefreshEdit(); + _tableHelperFunctions.PaintRowGroups(dataGridView); + } + + #endregion + + #region Actual Sales DataGridView Events + + /// + /// Event Used: RowValidating + /// Checks to make sure the row is valid (has an ad item) and + /// then copies the contents where possible over to the inventory + /// and actual sales DataGridViews. + /// + /// + /// + private void ValidateActualSalesRow(object sender, DataGridViewCellCancelEventArgs e) + { + //Grab the index of the ad item, assuming the Sales tables and the Inventory table stay in the same position. + const int adItemIndex = (int)SalesTableColumns.AdItem; + //Do not even attempt anything since this is a new row and nothing to worry about. + if (actualSalesDataGridView.Rows[e.RowIndex].IsNewRow) + { + return; + } + //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; + } + //Check to see if the user left a row that already exists and doesn't require being copied over. + if (actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() == projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString()) + { + return; + } + //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) + { + 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)); + } + + 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; + case (int)SalesTableColumns.IsHeaderRow: + rowContents[i] = false; + break; + case (int)SalesTableColumns.IsMemberRow: + rowContents[i] = false; + break; + default: + 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; + case (int)InventoryTableColumns.IsHeaderRow: + inventoryNewRow[(int)InventoryTableColumns.IsHeaderRow] = false; + break; + case (int)InventoryTableColumns.IsMemberRow: + inventoryNewRow[(int)InventoryTableColumns.IsMemberRow] = false; + break; + default: + if (i > (int)InventoryTableColumns.IsHeaderRow) continue; + inventoryNewRow[i] = ""; + break; + } + } + inventoryDataGridView.Rows.Add(inventoryNewRow); + + if (e.RowIndex != _adSpecialIndex) + { + //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; + } + else + { + //Apply color coding to the respective row headers on the other tables. + projectionsDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = DefaultBackColor; + inventoryDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = DefaultBackColor; + } + } + + private void ActualSalesRowRemoved(object sender, DataGridViewRowsRemovedEventArgs e) + { + var dataGridView = ((DataGridView)sender); + //Provide protection against overflows + if ((e.RowIndex + 1) > dataGridView.Rows.Count) + { + return; + } + //Disable all row removing events from the other two tables to prevent interference. + projectionsDataGridView.UserDeletingRow -= UpdateUsedAdItemCollectionOnRowRemoving; + projectionsDataGridView.RowsRemoved -= ProjectionRowRemoved; + + inventoryDataGridView.UserDeletingRow -= UpdateUsedAdItemCollectionOnRowRemoving; + inventoryDataGridView.RowsRemoved -= InventoryRowRemoved; + + //IF the row count on the passed DataGridView is less then the other table's row count... + if (actualSalesDataGridView.RowCount <= projectionsDataGridView.RowCount && actualSalesDataGridView.RowCount <= inventoryDataGridView.RowCount) + { + //... it is lower so its safe to assume that both tables have the same row that can be removed. + if (!projectionsDataGridView.Rows[e.RowIndex].IsNewRow) + { + projectionsDataGridView.Rows.RemoveAt(e.RowIndex); + } + + if (!inventoryDataGridView.Rows[e.RowIndex].IsNewRow) + { + inventoryDataGridView.Rows.RemoveAt(e.RowIndex); + } + } + //ELSE IF the row count is larger then the other table's row count... + else + { + //... Log the error and then what? + //TODO: Figure out if this is an error condition. + LogConsole.WriteToLog(FrmLogConsole.Level.Error, "The Actual Sales table has more rows then the Projections table."); + LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Projections Row Count: " + projectionsDataGridView.RowCount); + LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Inventory Row Count: " + inventoryDataGridView.RowCount); + LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Actual Sales Row Count: " + actualSalesDataGridView.RowCount); + errorLabel.Text = @"Error removing rows from Actual Sales and Inventory."; + } + //... After all the row removal has been finished re-enable the row removal events. + projectionsDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving; + projectionsDataGridView.RowsRemoved += ProjectionRowRemoved; + + inventoryDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving; + inventoryDataGridView.RowsRemoved += InventoryRowRemoved; + + //Reset the row numbers in the tables. + for (var i = e.RowIndex; i < (dataGridView.RowCount); i++) + { + projectionsDataGridView.Rows[i].HeaderCell.Value = (i + 1).ToString(); + inventoryDataGridView.Rows[i].HeaderCell.Value = (i + 1).ToString(); + actualSalesDataGridView.Rows[i].HeaderCell.Value = (i + 1).ToString(); + } + //Refresh the DataGridViews so the header cell's number get repainted properly and repaint the rows in case any groups get messed up during row removal. + projectionsDataGridView.RefreshEdit(); + inventoryDataGridView.RefreshEdit(); + actualSalesDataGridView.RefreshEdit(); + _tableHelperFunctions.PaintRowGroups(dataGridView); + } + + #endregion + + #region DataGridView Construction Functions + + /// + /// Fills the APC DataGridViews with the appropriate columns and starting row for the user to start + /// entering data. + /// + private void ConstructApcDataGridViews() + { + //Construct a list of column names for the projections/actual sales DataGridViews and the inventory DataGirdView. + string[] saleColumnNames = + { + "ID", "AdItem", "Sold", "SalePrice", "TotalSales", "Cost", "ProfitReturn", + "TotalProfitReturn", "IsHeader", "IsMember", "IsDirty" + }; + string[] inventoryColumnNames = + { + "ID", "AdItem", "BeginningInventory", "Received", "Total", "EndingInventory", "IsHeader", "IsMember", "IsDirty" + }; + + foreach (var name in saleColumnNames) + { + if (!name.StartsWith("Is")) + { + var column = new DataGridViewTextBoxColumn + { + Name = name, + HeaderText = TextFormat.AddSpacesToSentence(name, false), + ValueType = typeof(string), + SortMode = DataGridViewColumnSortMode.NotSortable, + MaxInputLength = 20 + }; + if (name.Contains("ID")) + { + //column.Visible = false; + } + projectionsDataGridView.Columns.Add(column); + } + else + { + var column = new DataGridViewCheckBoxColumn + { + Name = name, + HeaderText = TextFormat.AddSpacesToSentence(name, false), + ValueType = typeof(bool), + //Visible = false, + SortMode = DataGridViewColumnSortMode.NotSortable + }; + projectionsDataGridView.Columns.Add(column); + } + } + //Add the columns into the inventory DataGridView after setting their types. + foreach (var name in inventoryColumnNames) + { + if (!name.StartsWith("Is")) + { + var column = new DataGridViewTextBoxColumn + { + Name = name, + HeaderText = TextFormat.AddSpacesToSentence(name, false), + ValueType = typeof(string), + SortMode = DataGridViewColumnSortMode.NotSortable, + MaxInputLength = 20 + }; + inventoryDataGridView.Columns.Add(column); + } + else + { + var column = new DataGridViewCheckBoxColumn + { + Name = name, + HeaderText = TextFormat.AddSpacesToSentence(name, false), + ValueType = typeof(bool), + //Visible = false, + SortMode = DataGridViewColumnSortMode.NotSortable + }; + inventoryDataGridView.Columns.Add(column); + } + } + // + foreach (var name in saleColumnNames) + { + if (!name.StartsWith("Is")) + { + var column = new DataGridViewTextBoxColumn + { + Name = name, + HeaderText = TextFormat.AddSpacesToSentence(name, false), + ValueType = typeof(string), + SortMode = DataGridViewColumnSortMode.NotSortable, + MaxInputLength = 20 + }; + actualSalesDataGridView.Columns.Add(column); + } + else + { + var column = new DataGridViewCheckBoxColumn + { + Name = name, + HeaderText = TextFormat.AddSpacesToSentence(name, false), + ValueType = typeof(bool), + //Visible = false, + SortMode = DataGridViewColumnSortMode.NotSortable + }; + actualSalesDataGridView.Columns.Add(column); + } + } + } + + /// + /// Constructs the invoices DataGridView. + /// + private void ConstructInvoicesDataGridView() + { + string[] invoicesColumnNames = { "ID", "InvoiceDate", "Supplier", "InvoiceNumber", "InvoiceNetAmountAtCost", "InvoiceNetAmount", "InvoiceNote", "IsDirty" }; + + foreach (var name in invoicesColumnNames) + { + if (!name.StartsWith("Is")) + { + var column = new DataGridViewTextBoxColumn + { + Name = name, + HeaderText = TextFormat.AddSpacesToSentence(name, false), + ValueType = typeof(string), + SortMode = DataGridViewColumnSortMode.NotSortable, + MaxInputLength = 20 + }; + if (name.Contains("ID")) + { + //column.Visible = false; + } + invoicesDataGridView.Columns.Add(column); + } + else + { + var column = new DataGridViewCheckBoxColumn + { + Name = name, + ValueType = typeof(bool), + //Visible = false, + SortMode = DataGridViewColumnSortMode.NotSortable + }; + invoicesDataGridView.Columns.Add(column); + } + } + } + + #endregion + + #region Comments TextBox Events + + /// + /// Allows the user to select all the text in the comments text box. + /// + /// + /// + private void CheckForKeyCommand(object sender, KeyEventArgs e) + { + if (!e.Control || e.KeyCode != Keys.A) return; + commentsTextBox.SelectionStart = 0; + commentsTextBox.SelectionLength = commentsTextBox.Text.Length; + e.Handled = true; + e.SuppressKeyPress = true; + } + + /// + /// Event Used: TextChanged + /// Calculates and displays the remaining number of characters available for the user to enter + /// and changes the color of the label displaying the character count to red when 20% or less characters remain. + /// + /// + /// + private void DisplayRemainingCommentCharacterCount(object sender, EventArgs e) + { + //If the amount of characters left is less then 20% (or 80% or more characters have been used) then color the label red, otherwise color it its default color. + commentsGroupBox.ForeColor = (double)commentsTextBox.TextLength / commentsTextBox.MaxLength < .8 ? default(Color) : Color.DarkRed; + commentsGroupBox.Text = @"Comments (Characters Remaining: " + (commentsTextBox.MaxLength - commentsTextBox.TextLength) + @")"; + } + + private void CheckForTextChangeOnLeave(object sender, EventArgs e) + { + if (commentsTextBox.Text == _beginningCellValue) return; + //Clear white spaces and check if the string is null. + if (commentsTextBox.Text.Trim() == "" && isCommentDirtyCheckBox.Tag == null) + { + //The user cleared the comment(s) they were making but the comments were never committed to the database. + //So the comments are no longer dirty. + isCommentDirtyCheckBox.Checked = false; + } + else + { + //Otherwise the comment(s) were committed to the database and will need updating. + //If its empty then the record will be cleared from the database. + isCommentDirtyCheckBox.Checked = true; + _isFormDirty = true; + } + } + + #endregion + + #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; + _isFormDirty = 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; + _isFormDirty = 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; + _isFormDirty = 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; + _isFormDirty = 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; + _isFormDirty = 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; + _isFormDirty = true; + } + } + } + + #endregion + + private void ValidateDateChanged(object sender, DateRangeEventArgs e) + { + if (e.Start == _currentActiveDate || !weekEndingCalendar.BoldedDates.Contains(e.Start)) return; + if (_isFormDirty) + { + var result = MessageBox.Show(@"Would you like to save the changes you have made to this record?", @"Changes Detected", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (result == DialogResult.Yes) + { + _currentActiveDate = e.Start; + _isFormDirty = false; + } + else + { + weekEndingCalendar.SelectionStart = _currentActiveDate; + return; + } + } + Text = @"Modify Record (Current Record: " + e.Start.ToString("d") + @")"; + //Load the specified date from the database. + + } + + private void LoadDate(DateTime date) + { + var databaseTracker = new DatabaseTracker(); + var databaseReader = new DatabaseReader(); + var dateId = databaseReader.RetrieveDateIdByDateString(date.ToString("d"), databaseTracker.DatabaseConnectionString); + var projections = databaseReader.ReturnProjectionsTable(dateId, databaseTracker.DatabaseConnectionString); + var inventory = databaseReader.ReturnInventoryTable(dateId, databaseTracker.DatabaseConnectionString); + var actualSales = databaseReader.ReturnActualSales(dateId, databaseTracker.DatabaseConnectionString); + LoadApcTables(projections, inventory, actualSales); + var invoices = databaseReader.ReturnInvoiceTable(dateId, databaseTracker.DatabaseConnectionString); + projectionsDataGridView.CellEnter += StoreBeginningCellValue; + projectionsDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave; + projectionsDataGridView.CellValidating += ValidateSalesDataGridViewCellContents; + projectionsDataGridView.RowValidating += ValidateProjectedRow; + } + + private void LoadApcTables(DataTable projections, DataTable inventory, DataTable actualSales) + { + //Assuming all the tables are correctly aligned. + //Disable the relevant events in the DataGridViews + projectionsDataGridView.CellEnter -= StoreBeginningCellValue; + projectionsDataGridView.RowLeave -= UpdateUsedAdItemCollectionOnRowLeave; + projectionsDataGridView.CellValidating -= ValidateSalesDataGridViewCellContents; + projectionsDataGridView.RowValidating -= ValidateProjectedRow; + + for(var i = 0; i < projections.Rows.Count; i++) + { + var newRow = new DataGridViewRow(); + for (var cellIndex = 0; cellIndex < projections.Rows[i].ItemArray.Length; cellIndex++) + { + //ID and Ad Item. + if (cellIndex <= 1) + { + var cell = new DataGridViewTextBoxCell + { + Value = projections.Rows[i].ItemArray[cellIndex].ToString() + }; + newRow.Cells.Add(cell); + continue; + } + //Everything in between the ad item cell and the row attribute cells. + if (cellIndex > 1 && cellIndex <= 7) + { + if (projections.Rows[i].ItemArray[cellIndex].ToString() == "0") + { + var cell = new DataGridViewTextBoxCell {Value = ""}; + newRow.Cells.Add(cell); + } + else + { + var cell = new DataGridViewTextBoxCell { Value = projections.Rows[i].ItemArray[cellIndex].ToString() }; + newRow.Cells.Add(cell); + } + continue; + } + //Check the attribute cell. + if (cellIndex == 8) + { + var isHeaderCell = new DataGridViewCheckBoxCell(false); + var isMemberCell = new DataGridViewCheckBoxCell(false); + var rowAttribute = int.Parse(projections.Rows[i].ItemArray[cellIndex].ToString()); + switch (rowAttribute) + { + case 1: + //Header row + isHeaderCell.Value = true; + newRow.DefaultCellStyle.BackColor = ApplicationColors.HeaderRow; + break; + case 2: + //Member Row + isMemberCell.Value = true; + newRow.DefaultCellStyle.BackColor = ApplicationColors.MemberRow; + break; + } + newRow.Cells.Add(isHeaderCell); + newRow.Cells.Add(isMemberCell); + continue; + } + //Check the group it is part of if any. + if (cellIndex == 9) + { + if (projections.Rows[i].ItemArray[cellIndex].ToString() != "0" && _adSpecialIndex == -1) + { + var databaseTracker = new DatabaseTracker(); + var databaseReader = new DatabaseReader(); + var groupName = + databaseReader.ReturnGroupNameFromGroupId( + projections.Rows[i].ItemArray[cellIndex].ToString(), + databaseTracker.DatabaseConnectionString); + var adSpecialRow = new DataGridViewRow(); + projectionsDataGridView.Rows.Add(adSpecialRow); + projectionsDataGridView.Rows[i].Cells[1].Value = groupName; + projectionsDataGridView.Rows[i].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial; + _adSpecialIndex = i; + } + } + } + projectionsDataGridView.Rows.Add(newRow); + } + //Re-enable the events + } + + private void NormalizeApcTables(DataTable projetions, DataTable inventory, DataTable actualSales, string dateId) + { + + } + } +} diff --git a/AdvertsingProfitControl/NewModifyRecord.resx b/AdvertsingProfitControl/NewModifyRecord.resx new file mode 100644 index 0000000..f80b0f3 --- /dev/null +++ b/AdvertsingProfitControl/NewModifyRecord.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application index f3e92cb..a398cd7 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application @@ -14,7 +14,7 @@ - VSIqTBM/2qcZ+QvdjsN5nrzGeyUkofXt8gkwA+ifCeM= + BL2VwteFPdU1C5eFgLcNJB6t71bYUCKbAJpayKyfE2c= diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest index 43c2b0a..0f96fbd 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest @@ -43,14 +43,14 @@ - + - Twcy9tLeC7tLOMd3Kt+tpcRMhnW/2zLmImwOYH8DbJw= + E5XDgx2BUQtUy2BTSxYDHOSv9/kMPusOEpgSdyhYHzk= @@ -93,7 +93,7 @@ - vIWbpHhaPK+/SPRL5GUWOfjJsfzpB/rCMLUdLPlUB+s= + UQFU3HlwUiJQK2YXuAkDK9mSdSFJnVT3pbRsOpcjnAg=