From 8dcc290aefa5775139feda504331cbf5220c2db2 Mon Sep 17 00:00:00 2001 From: Garritt McCune Date: Fri, 2 Dec 2016 18:45:31 -0600 Subject: [PATCH] Added dirty flags to the comments, cost analysis, weekly sales and taxable, as well as formatting, validation and auto summing for the latter two. The Tag properties of the check boxes for the dirty flags will contain the IDs. --- AdvertsingProfitControl/APCDatabase.accdb | Bin 2932736 -> 2932736 bytes .../FrmAdSpecialRegister.Designer.cs | 68 +++--- .../FrmAddRecord.Designer.cs | 10 +- AdvertsingProfitControl/FrmMain.Designer.cs | 69 ++++-- AdvertsingProfitControl/FrmMain.cs | 4 - AdvertsingProfitControl/FrmManageAdItems.cs | 2 - .../NewAddRecord.Designer.cs | 105 ++++++++- AdvertsingProfitControl/NewAddRecord.cs | 200 +++++++++++++++++- ...AdvertsingProfitControl.vshost.application | 2 +- ...dvertsingProfitControl.vshost.exe.manifest | 6 +- .../frmManageAdItems.Designer.cs | 134 ++++++------ 11 files changed, 473 insertions(+), 127 deletions(-) diff --git a/AdvertsingProfitControl/APCDatabase.accdb b/AdvertsingProfitControl/APCDatabase.accdb index d2e11d6269de6addb748ddc90073e7623aee0978..6ee917a0670d3b46a6d720c6a38efa32b6d1e3ae 100644 GIT binary patch delta 303 zcmZo@*vtsR8<_Yw+2wXJF)=bSGHw>+d(SvofsbvIz+Qf)fUBGL%fI$vY?yv9o>OzW z!#+0U$@25Lc$gX37#x^b7#uhnI3_E8ke=?4&&s>mG#w-Yedkeol^2lJWBN zyZIc-?cDN=?cDNA+qvbLH(p>AY2W*vxqa_@miE2xS=;x%XKUa4p1pnVdye+K?>XD| zzUSJ$_dU1shiwPgnFO{oec;g++_+&5*K~sdX_oD0PqUk{Y-bYS{l^cMU(WP^M_@Zs z1Lr^fwgBF?0KT>W{9zow zwgB0-0J*jR`L+OswgAPp0HwA7<+cEowgA<(0JXLN^|k+d(SvofsbvIz+QePfxDac%fI$vJTP&g=5&XB zY|4}6=W}s0Gq5o@FtIQ=a2%N4IA2O;x 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; + } + totalTaxableTextBox.Text = ""; + } + } + + private void StoreBeginningTextBoxValue(object sender, EventArgs e) + { + var textBox = (TextBox) sender; + _beginningCellValue = textBox.Text; + } + + private void ValidateWeeklySales(object sender, CancelEventArgs e) + { + var textBox = (TextBox) sender; + if (_beginningCellValue == textBox.Text) return; + //There was a change to the starting value of the text box if we've made it this far. + if (textBox.Text != "") + { + double dollarValue; + if (double.TryParse(textBox.Text.Trim(), out dollarValue)) + { + //Input is valid so mark the section as dirty. + isWeeklySalesDirtyCheckBox.Checked = true; + //And apply formatting. + textBox.Text = Math.Round(dollarValue, 2).ToString("N", new CultureInfo("en-US")); + //Check to see if the number is equal to zero (0) i.e. "0.00". + if (textBox.Text == @"0.00") textBox.Text = ""; + //Check to see if this is not the total weekly sales text box. + if (textBox.Name == totalWeeklySalesTextBox.Name) return; + } + 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; + } + totalWeeklySalesTextBox.Text = ""; + } } #region Invoice Table Events @@ -288,7 +431,7 @@ namespace AdvertsingProfitControl /// /// /// - private void DisplayRowNumbers(object sender, DataGridViewRowsAddedEventArgs e) + private static void DisplayRowNumbers(object sender, DataGridViewRowsAddedEventArgs e) { var table = ((DataGridView)sender); table.Rows[e.RowIndex].HeaderCell.Value = (e.RowIndex + 1).ToString(); @@ -1547,6 +1690,46 @@ namespace AdvertsingProfitControl 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; + } + } + + private void StoreBeginningTextValue(object sender, EventArgs e) + { + //Reduce and reuse. + _beginningCellValue = commentsTextBox.Text; + } + + #endregion + + #region Weekly Sales Events + + + #endregion + + #region Taxable Events + + + #endregion + + #region Cost Analysis Events + + #endregion #region DateTime Events @@ -2385,5 +2568,20 @@ namespace AdvertsingProfitControl } #endregion + + private void idButton_Click(object sender, EventArgs e) + { + if (isCommentDirtyCheckBox.Tag == null) + { + var ran = new Random(); + isCommentDirtyCheckBox.Tag = ran.Next(); + MessageBox.Show(@"Comment ID is now " + isCommentDirtyCheckBox.Tag, @"Debug ID Test"); + } + else + { + isCommentDirtyCheckBox.Tag = null; + MessageBox.Show(@"ID cleared from comments.", @"Clear ID Debug"); + } + } } } diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application index 2833bbd..9784eb4 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application @@ -14,7 +14,7 @@ - uNpKtKGgY3WdCqpTJARuduXQEnYHDum4naMxK2seAZY= + sGFYIVV7/W3lYCXVUKinGP8+HnzRtuBko/4mLniApzs= diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest index 2b25e19..3e8a29c 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest @@ -43,14 +43,14 @@ - + - miQ8SvKSYPgPCR7wkH2br43baRyA6z3qxRB6jWLSEB4= + usHPTgWtHUZgtHEvPN4oe9BDB+EUrs2IjXXHTcpDJnI= @@ -84,7 +84,7 @@ - L1S1NQ/iZ4fotWtEDbVeoia76lgWuMUfQqouemtj2z0= + EXv832xgnrJTLbEvUhk+7ekkWAMvfBMCvVv0Y6BILg0= diff --git a/AdvertsingProfitControl/frmManageAdItems.Designer.cs b/AdvertsingProfitControl/frmManageAdItems.Designer.cs index 4144301..f9f94bf 100644 --- a/AdvertsingProfitControl/frmManageAdItems.Designer.cs +++ b/AdvertsingProfitControl/frmManageAdItems.Designer.cs @@ -32,16 +32,16 @@ this.mainLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); this.adItemListView = new System.Windows.Forms.ListView(); this.columnOnePanel = new System.Windows.Forms.Panel(); + this.addItemLabel = new System.Windows.Forms.Label(); + this.adItemTextBox = new System.Windows.Forms.TextBox(); + this.addItemButton = new System.Windows.Forms.Button(); + this.notificationLabel = new System.Windows.Forms.Label(); this.deleteSelectedItem = new System.Windows.Forms.Button(); this.adItemFilterComboBox = new System.Windows.Forms.ComboBox(); this.letterSelectionLabel = new System.Windows.Forms.Label(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.fileMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.closeFormFileMainMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.notificationLabel = new System.Windows.Forms.Label(); - this.addItemButton = new System.Windows.Forms.Button(); - this.adItemTextBox = new System.Windows.Forms.TextBox(); - this.addItemLabel = new System.Windows.Forms.Label(); this.mainLayoutPanel.SuspendLayout(); this.columnOnePanel.SuspendLayout(); this.menuStrip1.SuspendLayout(); @@ -57,23 +57,23 @@ this.mainLayoutPanel.Controls.Add(this.menuStrip1, 0, 0); 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(2); + this.mainLayoutPanel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.mainLayoutPanel.Name = "mainLayoutPanel"; this.mainLayoutPanel.RowCount = 3; - this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 19F)); + 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, 50F)); this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.mainLayoutPanel.Size = new System.Drawing.Size(496, 445); + this.mainLayoutPanel.Size = new System.Drawing.Size(909, 822); this.mainLayoutPanel.TabIndex = 0; // // adItemListView // this.adItemListView.Dock = System.Windows.Forms.DockStyle.Fill; - this.adItemListView.Location = new System.Drawing.Point(225, 21); - this.adItemListView.Margin = new System.Windows.Forms.Padding(2); + this.adItemListView.Location = new System.Drawing.Point(413, 39); + this.adItemListView.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.adItemListView.Name = "adItemListView"; this.mainLayoutPanel.SetRowSpan(this.adItemListView, 2); - this.adItemListView.Size = new System.Drawing.Size(269, 422); + this.adItemListView.Size = new System.Drawing.Size(492, 779); this.adItemListView.Sorting = System.Windows.Forms.SortOrder.Ascending; this.adItemListView.TabIndex = 5; this.adItemListView.UseCompatibleStateImageBehavior = false; @@ -89,20 +89,59 @@ this.columnOnePanel.Controls.Add(this.adItemFilterComboBox); this.columnOnePanel.Controls.Add(this.letterSelectionLabel); this.columnOnePanel.Dock = System.Windows.Forms.DockStyle.Fill; - this.columnOnePanel.Location = new System.Drawing.Point(2, 21); - this.columnOnePanel.Margin = new System.Windows.Forms.Padding(2); + this.columnOnePanel.Location = new System.Drawing.Point(4, 39); + this.columnOnePanel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.columnOnePanel.Name = "columnOnePanel"; this.mainLayoutPanel.SetRowSpan(this.columnOnePanel, 2); - this.columnOnePanel.Size = new System.Drawing.Size(219, 422); + this.columnOnePanel.Size = new System.Drawing.Size(401, 779); this.columnOnePanel.TabIndex = 1; // + // addItemLabel + // + this.addItemLabel.AutoSize = true; + this.addItemLabel.Location = new System.Drawing.Point(35, 378); + this.addItemLabel.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); + this.addItemLabel.Name = "addItemLabel"; + this.addItemLabel.Size = new System.Drawing.Size(140, 25); + this.addItemLabel.TabIndex = 6; + this.addItemLabel.Text = "Add New Item:"; + // + // adItemTextBox + // + this.adItemTextBox.Location = new System.Drawing.Point(213, 373); + this.adItemTextBox.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); + this.adItemTextBox.Name = "adItemTextBox"; + this.adItemTextBox.Size = new System.Drawing.Size(180, 29); + this.adItemTextBox.TabIndex = 2; + // + // addItemButton + // + this.addItemButton.Enabled = false; + this.addItemButton.Location = new System.Drawing.Point(213, 421); + this.addItemButton.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); + this.addItemButton.Name = "addItemButton"; + this.addItemButton.Size = new System.Drawing.Size(183, 59); + this.addItemButton.TabIndex = 3; + this.addItemButton.Text = "Add Item"; + this.addItemButton.UseVisualStyleBackColor = true; + this.addItemButton.Click += new System.EventHandler(this.addItemButton_Click); + // + // notificationLabel + // + this.notificationLabel.AutoSize = true; + this.notificationLabel.Location = new System.Drawing.Point(17, 78); + this.notificationLabel.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); + this.notificationLabel.Name = "notificationLabel"; + this.notificationLabel.Size = new System.Drawing.Size(0, 25); + this.notificationLabel.TabIndex = 3; + // // deleteSelectedItem // this.deleteSelectedItem.Enabled = false; - this.deleteSelectedItem.Location = new System.Drawing.Point(9, 380); - this.deleteSelectedItem.Margin = new System.Windows.Forms.Padding(2); + this.deleteSelectedItem.Location = new System.Drawing.Point(17, 702); + this.deleteSelectedItem.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.deleteSelectedItem.Name = "deleteSelectedItem"; - this.deleteSelectedItem.Size = new System.Drawing.Size(120, 33); + this.deleteSelectedItem.Size = new System.Drawing.Size(220, 61); this.deleteSelectedItem.TabIndex = 4; this.deleteSelectedItem.Text = "Delete Selected Item"; this.deleteSelectedItem.UseVisualStyleBackColor = true; @@ -112,19 +151,19 @@ // this.adItemFilterComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.adItemFilterComboBox.FormattingEnabled = true; - this.adItemFilterComboBox.Location = new System.Drawing.Point(81, 2); - this.adItemFilterComboBox.Margin = new System.Windows.Forms.Padding(2); + this.adItemFilterComboBox.Location = new System.Drawing.Point(149, 4); + this.adItemFilterComboBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.adItemFilterComboBox.Name = "adItemFilterComboBox"; - this.adItemFilterComboBox.Size = new System.Drawing.Size(136, 21); + this.adItemFilterComboBox.Size = new System.Drawing.Size(246, 32); this.adItemFilterComboBox.TabIndex = 1; // // letterSelectionLabel // this.letterSelectionLabel.AutoSize = true; - this.letterSelectionLabel.Location = new System.Drawing.Point(6, 2); - this.letterSelectionLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.letterSelectionLabel.Location = new System.Drawing.Point(11, 4); + this.letterSelectionLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.letterSelectionLabel.Name = "letterSelectionLabel"; - this.letterSelectionLabel.Size = new System.Drawing.Size(71, 13); + this.letterSelectionLabel.Size = new System.Drawing.Size(129, 25); this.letterSelectionLabel.TabIndex = 0; this.letterSelectionLabel.Text = "Select a filter:"; // @@ -136,8 +175,8 @@ this.fileMainMenu}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Padding = new System.Windows.Forms.Padding(4, 1, 0, 1); - this.menuStrip1.Size = new System.Drawing.Size(496, 19); + this.menuStrip1.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2); + this.menuStrip1.Size = new System.Drawing.Size(909, 35); this.menuStrip1.TabIndex = 2; this.menuStrip1.Text = "menuStrip1"; // @@ -146,60 +185,25 @@ this.fileMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.closeFormFileMainMenu}); this.fileMainMenu.Name = "fileMainMenu"; - this.fileMainMenu.Size = new System.Drawing.Size(37, 17); + this.fileMainMenu.Size = new System.Drawing.Size(56, 31); this.fileMainMenu.Text = "&File"; // // closeFormFileMainMenu // this.closeFormFileMainMenu.Name = "closeFormFileMainMenu"; - this.closeFormFileMainMenu.Size = new System.Drawing.Size(152, 22); + this.closeFormFileMainMenu.Size = new System.Drawing.Size(208, 34); this.closeFormFileMainMenu.Text = "&Close Form"; this.closeFormFileMainMenu.Click += new System.EventHandler(this.closeFormFileMainMenu_Click); // - // notificationLabel - // - this.notificationLabel.AutoSize = true; - this.notificationLabel.Location = new System.Drawing.Point(9, 42); - this.notificationLabel.Name = "notificationLabel"; - this.notificationLabel.Size = new System.Drawing.Size(0, 13); - this.notificationLabel.TabIndex = 3; - // - // addItemButton - // - this.addItemButton.Enabled = false; - this.addItemButton.Location = new System.Drawing.Point(116, 228); - this.addItemButton.Name = "addItemButton"; - this.addItemButton.Size = new System.Drawing.Size(100, 32); - this.addItemButton.TabIndex = 3; - this.addItemButton.Text = "Add Item"; - this.addItemButton.UseVisualStyleBackColor = true; - this.addItemButton.Click += new System.EventHandler(this.addItemButton_Click); - // - // adItemTextBox - // - this.adItemTextBox.Location = new System.Drawing.Point(116, 202); - this.adItemTextBox.Name = "adItemTextBox"; - this.adItemTextBox.Size = new System.Drawing.Size(100, 20); - this.adItemTextBox.TabIndex = 2; - // - // addItemLabel - // - this.addItemLabel.AutoSize = true; - this.addItemLabel.Location = new System.Drawing.Point(19, 205); - this.addItemLabel.Name = "addItemLabel"; - this.addItemLabel.Size = new System.Drawing.Size(77, 13); - this.addItemLabel.TabIndex = 6; - this.addItemLabel.Text = "Add New Item:"; - // // FrmManageAdItems // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(496, 445); + this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.ClientSize = new System.Drawing.Size(909, 822); this.Controls.Add(this.mainLayoutPanel); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MainMenuStrip = this.menuStrip1; - this.Margin = new System.Windows.Forms.Padding(2); + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "FrmManageAdItems";