diff --git a/AdvertsingProfitControl/FrmMain.Designer.cs b/AdvertsingProfitControl/FrmMain.Designer.cs index 8ad4488..5a3b83e 100644 --- a/AdvertsingProfitControl/FrmMain.Designer.cs +++ b/AdvertsingProfitControl/FrmMain.Designer.cs @@ -38,6 +38,7 @@ this.modifyRecordMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.deleteRecordsMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.newFormTestToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.newModifyRecordToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolsMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.adSpecialKeyWordsToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.manageItemsToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem(); @@ -85,7 +86,6 @@ this.taxableDataGridView = new System.Windows.Forms.DataGridView(); this.debugTabPage = new System.Windows.Forms.TabPage(); this.monthCalendar = new System.Windows.Forms.MonthCalendar(); - this.newModifyRecordToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mainTableLayoutPanel.SuspendLayout(); this.mainMenu.SuspendLayout(); this.commentMainTableLayoutPanel.SuspendLayout(); @@ -187,9 +187,11 @@ // // deleteRecordsMainMenu // + this.deleteRecordsMainMenu.Enabled = false; this.deleteRecordsMainMenu.Name = "deleteRecordsMainMenu"; this.deleteRecordsMainMenu.Size = new System.Drawing.Size(323, 34); this.deleteRecordsMainMenu.Text = "&Delete Existing record"; + this.deleteRecordsMainMenu.ToolTipText = "Currently Unavailable in this Version."; this.deleteRecordsMainMenu.Click += new System.EventHandler(this.deleteRecordsMainMenu_Click); // // newFormTestToolStripMenuItem @@ -199,6 +201,13 @@ this.newFormTestToolStripMenuItem.Text = "&New Form Test"; this.newFormTestToolStripMenuItem.Click += new System.EventHandler(this.newFormTestToolStripMenuItem_Click); // + // newModifyRecordToolStripMenuItem + // + this.newModifyRecordToolStripMenuItem.Name = "newModifyRecordToolStripMenuItem"; + this.newModifyRecordToolStripMenuItem.Size = new System.Drawing.Size(323, 34); + this.newModifyRecordToolStripMenuItem.Text = "New Modify Record"; + this.newModifyRecordToolStripMenuItem.Click += new System.EventHandler(this.newModifyRecordToolStripMenuItem_Click); + // // toolsMainMenu // this.toolsMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -762,13 +771,6 @@ this.monthCalendar.TabIndex = 0; this.monthCalendar.TabStop = false; // - // newModifyRecordToolStripMenuItem - // - this.newModifyRecordToolStripMenuItem.Name = "newModifyRecordToolStripMenuItem"; - this.newModifyRecordToolStripMenuItem.Size = new System.Drawing.Size(323, 34); - this.newModifyRecordToolStripMenuItem.Text = "New Modify Record"; - this.newModifyRecordToolStripMenuItem.Click += new System.EventHandler(this.newModifyRecordToolStripMenuItem_Click); - // // FrmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F); diff --git a/AdvertsingProfitControl/NewModifyRecord.cs b/AdvertsingProfitControl/NewModifyRecord.cs index 5a61e59..7812b53 100644 --- a/AdvertsingProfitControl/NewModifyRecord.cs +++ b/AdvertsingProfitControl/NewModifyRecord.cs @@ -163,7 +163,7 @@ namespace AdvertsingProfitControl set { base.Text = value; } } - #region Global Event Handlers + #region Global Text Box Events /// /// Stores the beginning value in a text box into the _beginningCellValue field. @@ -2110,6 +2110,8 @@ namespace AdvertsingProfitControl #endregion + #region Date Time Events + private void ValidateDateChanged(object sender, DateRangeEventArgs e) { if (e.Start == _currentActiveDate || !weekEndingCalendar.BoldedDates.Contains(e.Start)) return; @@ -2118,7 +2120,8 @@ namespace AdvertsingProfitControl 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; + //_currentActiveDate = e.Start; + //Save the changes made to the database then clear and load the date picked by the user. } else { @@ -2126,6 +2129,7 @@ namespace AdvertsingProfitControl return; } } + _currentActiveDate = e.Start; Text = @"Modify Record (Current Record: " + e.Start.ToString("d") + @")"; //Clear the form state. ClearFormState(); @@ -2133,60 +2137,7 @@ namespace AdvertsingProfitControl LoadDate(e.Start); } - 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); - LoadProjectionsTable(projections); - LoadInventory(inventory); - LoadActualSales(actualSales); - var invoices = databaseReader.ReturnInvoiceTable(dateId, databaseTracker.DatabaseConnectionString); - var comments = databaseReader.RetrieveComments(int.Parse(dateId), databaseTracker.DatabaseConnectionString); - if (comments.Count == 2) - { - LoadComments(int.Parse(comments[0]), comments[1]); - } - else - { - LogConsole.WriteToLog(FrmLogConsole.Level.Info, "No comments to display for the date of " + _currentActiveDate.ToString("d") + "."); - informationLabel.Text += @"No comments to display." + Environment.NewLine; - } - var weeklySales = databaseReader.ReturnWeeklySalesFromDateId(dateId, - databaseTracker.DatabaseConnectionString); - if (weeklySales.Rows.Count == 1) - { - LoadWeeklySales(weeklySales); - } - else - { - informationLabel.Text += @"No weekly sales to display." + Environment.NewLine; - } - - var taxable = databaseReader.ReturnTaxableFromDateId(dateId, databaseTracker.DatabaseConnectionString); - if (taxable.Rows.Count == 1) - { - LoadTaxable(taxable); - } - else - { - informationLabel.Text += @"No taxable data to display." + Environment.NewLine; - } - LoadInvoices(invoices); - var costAnalysis = databaseReader.ReturnCostAnalysis(int.Parse(dateId), - databaseTracker.DatabaseConnectionString); - if (costAnalysis.Rows.Count == 1) - { - LoadCostAnalysis(costAnalysis); - } - else - { - informationLabel.Text += @"No cost analysis data to display." + Environment.NewLine; - } - } + #endregion private void ClearFormState() { @@ -2377,6 +2328,60 @@ namespace AdvertsingProfitControl #region Data Loading Methods + 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); + LoadProjectionsTable(projections); + LoadInventory(inventory); + LoadActualSales(actualSales); + var invoices = databaseReader.ReturnInvoiceTable(dateId, databaseTracker.DatabaseConnectionString); + var comments = databaseReader.RetrieveComments(int.Parse(dateId), databaseTracker.DatabaseConnectionString); + if (comments.Count == 2) + { + LoadComments(int.Parse(comments[0]), comments[1]); + } + else + { + informationLabel.Text += @"No comments to display." + Environment.NewLine; + } + var weeklySales = databaseReader.ReturnWeeklySalesFromDateId(dateId, + databaseTracker.DatabaseConnectionString); + if (weeklySales.Rows.Count == 1) + { + LoadWeeklySales(weeklySales); + } + else + { + informationLabel.Text += @"No sales to display." + Environment.NewLine; + } + + var taxable = databaseReader.ReturnTaxableFromDateId(dateId, databaseTracker.DatabaseConnectionString); + if (taxable.Rows.Count == 1) + { + LoadTaxable(taxable); + } + else + { + informationLabel.Text += @"No taxable data to display." + Environment.NewLine; + } + LoadInvoices(invoices); + var costAnalysis = databaseReader.ReturnCostAnalysis(int.Parse(dateId), + databaseTracker.DatabaseConnectionString); + if (costAnalysis.Rows.Count == 1) + { + LoadCostAnalysis(costAnalysis); + } + else + { + informationLabel.Text += @"No cost analysis data to display." + Environment.NewLine; + } + } + private void LoadProjectionsTable(DataTable projections) { //Assuming all the tables are correctly aligned. @@ -2658,34 +2663,29 @@ namespace AdvertsingProfitControl var row = new DataGridViewRow(); for (var cellIndex = 0; cellIndex < invoices.Rows[rowIndex].ItemArray.Length; cellIndex++) { - //Get the + var cell = new DataGridViewTextBoxCell(); //Format the invoice date. if (cellIndex == 1) { var date = DateTime.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString()); - var cell = new DataGridViewTextBoxCell - { - Value = date.ToString("d") - }; + cell.Value = date.ToString("d"); row.Cells.Add(cell); continue; } - if (invoices.Rows[rowIndex].ItemArray[cellIndex].ToString() != "0") + //Apply formatting to the only cells that will have currency values in them. + if (cellIndex == 4 || cellIndex == 5) { - var cell = new DataGridViewTextBoxCell + var formattedNumber = Math.Round(double.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") { - Value = invoices.Rows[rowIndex].ItemArray[cellIndex].ToString() - }; + cell.Value = formattedNumber; + } row.Cells.Add(cell); - } - else - { - var cell = new DataGridViewTextBoxCell - { - Value = "" - }; - row.Cells.Add(cell); - } + continue; + } + //No special formatting rules here so just put the value in and move on. + cell.Value = invoices.Rows[rowIndex].ItemArray[cellIndex].ToString(); + row.Cells.Add(cell); } invoicesDataGridView.Rows.Add(row); } @@ -2995,11 +2995,17 @@ namespace AdvertsingProfitControl suppliesTextBox.Validating += ValidateCostAnalysisValues; } + #endregion + + #region Database Update/Insertion Methods + + + #endregion //private void NormalizeApcTables(DataTable projections, DataTable inventory, DataTable actualSales, string dateId) //{ - + //} } } diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application index e2cc48b..330240f 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application @@ -14,7 +14,7 @@ - v/vV1JQ1KwJ475DzlF/9pMJ1BiE2M9/K5exyQW56JdA= + zpbkgJk14ECDIZQitxLLt8pDxjsgaGNLCsn6A15FHiw= diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest index c56988c..1f27c83 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest @@ -43,14 +43,14 @@ - + - X9LoHKI4Q8rmL073oAPMcfETygEZnYWzLirYaKYjcvQ= + RfwzuWZMEhfrUq7aBd3p9sX+V5RWL5yDo9XNd2Uj/JM=