From 09508aa16ceeaca911b14cd47b359373a4e19d3b Mon Sep 17 00:00:00 2001 From: Garritt McCune Date: Mon, 10 Apr 2017 16:42:21 -0500 Subject: [PATCH] Updated the table class files to allow a nullable ad special ID and changed the enum in the new modify record form to a boolean. Added a form to manage ad special keywords, still needs to handle removing them properly. --- .../APCDatabase Template Script.sql | 9 +- AdvertsingProfitControl/ActualSale.cs | 4 +- AdvertsingProfitControl/AdSpecial.cs | 17 ++ .../AdvertisingProfitControlModel.cs | 21 ++- .../AdvertsingProfitControl.csproj | 9 ++ AdvertsingProfitControl/App.config | 4 +- .../DebugDatabaseConverter.cs | 2 +- AdvertsingProfitControl/FrmMain.Designer.cs | 16 +- AdvertsingProfitControl/FrmMain.cs | 44 +++-- .../FrmRegisterAdSpecial.Designer.cs | 150 ++++++++++++++++++ .../FrmRegisterAdSpecial.cs | 149 +++++++++++++++++ .../FrmRegisterAdSpecial.resx | 120 ++++++++++++++ AdvertsingProfitControl/Inventory.cs | 4 +- AdvertsingProfitControl/Invoice.cs | 6 +- .../NewModifyRecord.Designer.cs | 45 +++--- AdvertsingProfitControl/NewModifyRecord.cs | 76 +++++---- AdvertsingProfitControl/Projection.cs | 4 +- 17 files changed, 594 insertions(+), 86 deletions(-) create mode 100644 AdvertsingProfitControl/FrmRegisterAdSpecial.Designer.cs create mode 100644 AdvertsingProfitControl/FrmRegisterAdSpecial.cs create mode 100644 AdvertsingProfitControl/FrmRegisterAdSpecial.resx diff --git a/AdvertsingProfitControl/APCDatabase Template Script.sql b/AdvertsingProfitControl/APCDatabase Template Script.sql index f953521..4cb4fe4 100644 --- a/AdvertsingProfitControl/APCDatabase Template Script.sql +++ b/AdvertsingProfitControl/APCDatabase Template Script.sql @@ -53,8 +53,7 @@ RowPosition INTEGER NOT NULL, RowAttribute INTEGER NOT NULL, --Rename to "HeaderId"? Point to the header group's ID number perhaps? --Now begin all the foreign keys. FkAdItemId INTEGER NOT NULL FOREIGN KEY REFERENCES AdItems(Id), -FkAdSpecialId INTEGER NOT NULL, ---FkAdSpecialId INTEGER NOT NULL FOREIGN KEY REFERENCES AdSpecials(Id), --Can be NULL +FkAdSpecialId INTEGER FOREIGN KEY REFERENCES AdSpecials(Id), --Can be NULL FkDateId INTEGER NOT NULL FOREIGN KEY REFERENCES WeekEndingDates(Id) ) @@ -73,8 +72,7 @@ RowPosition INTEGER NOT NULL, RowAttribute INTEGER NOT NULL, --Rename to "HeaderId"? Point to the header group's ID number perhaps? --Now begin all the foreign keys. FkAdItemId INTEGER NOT NULL FOREIGN KEY REFERENCES AdItems(Id), -FkAdSpecialId INTEGER NOT NULL, ---FkAdSpecialId INTEGER NOT NULL FOREIGN KEY REFERENCES AdSpecials(Id), --Can be NULL +FkAdSpecialId INTEGER FOREIGN KEY REFERENCES AdSpecials(Id), --Can be NULL FkDateId INTEGER NOT NULL FOREIGN KEY REFERENCES WeekEndingDates(Id) ) @@ -96,8 +94,7 @@ RowPosition INTEGER NOT NULL, RowAttribute INTEGER NOT NULL, --Rename to "HeaderId"? Point to the header group's ID number perhaps? --Now begin all the foreign keys. FkAdItemId INTEGER NOT NULL FOREIGN KEY REFERENCES AdItems(Id), -FkAdSpecialId INTEGER NOT NULL, ---FkAdSpecialId INTEGER NOT NULL FOREIGN KEY REFERENCES AdSpecials(Id), --Can be NULL +FkAdSpecialId INTEGER FOREIGN KEY REFERENCES AdSpecials(Id), --Can be NULL FkDateId INTEGER NOT NULL FOREIGN KEY REFERENCES WeekEndingDates(Id) ) diff --git a/AdvertsingProfitControl/ActualSale.cs b/AdvertsingProfitControl/ActualSale.cs index 14752e0..9d410f4 100644 --- a/AdvertsingProfitControl/ActualSale.cs +++ b/AdvertsingProfitControl/ActualSale.cs @@ -30,12 +30,14 @@ namespace AdvertsingProfitControl public int FkAdItemId { get; set; } - public int FkAdSpecialId { get; set; } + public int? FkAdSpecialId { get; set; } public int FkDateId { get; set; } public virtual AdItem AdItem { get; set; } + public virtual AdSpecial AdSpecial { get; set; } + public virtual WeekEndingDate WeekEndingDate { get; set; } } } diff --git a/AdvertsingProfitControl/AdSpecial.cs b/AdvertsingProfitControl/AdSpecial.cs index 0a3088a..ca04ff2 100644 --- a/AdvertsingProfitControl/AdSpecial.cs +++ b/AdvertsingProfitControl/AdSpecial.cs @@ -8,6 +8,14 @@ namespace AdvertsingProfitControl public partial class AdSpecial { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public AdSpecial() + { + ActualSales = new HashSet(); + Inventories = new HashSet(); + Projections = new HashSet(); + } + public int Id { get; set; } [Required] @@ -16,5 +24,14 @@ namespace AdvertsingProfitControl [StringLength(256)] public string Description { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection ActualSales { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection Inventories { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection Projections { get; set; } } } diff --git a/AdvertsingProfitControl/AdvertisingProfitControlModel.cs b/AdvertsingProfitControl/AdvertisingProfitControlModel.cs index 398dbee..1e911d1 100644 --- a/AdvertsingProfitControl/AdvertisingProfitControlModel.cs +++ b/AdvertsingProfitControl/AdvertisingProfitControlModel.cs @@ -8,7 +8,7 @@ namespace AdvertsingProfitControl public partial class AdvertisingProfitControlModel : DbContext { public AdvertisingProfitControlModel() - : base("name=AdvertisingProfitControlContext") + : base("name=AdvertisingProfitControlDbContext") { } @@ -86,6 +86,21 @@ namespace AdvertsingProfitControl .Property(e => e.Description) .IsUnicode(false); + modelBuilder.Entity() + .HasMany(e => e.ActualSales) + .WithOptional(e => e.AdSpecial) + .HasForeignKey(e => e.FkAdSpecialId); + + modelBuilder.Entity() + .HasMany(e => e.Inventories) + .WithOptional(e => e.AdSpecial) + .HasForeignKey(e => e.FkAdSpecialId); + + modelBuilder.Entity() + .HasMany(e => e.Projections) + .WithOptional(e => e.AdSpecial) + .HasForeignKey(e => e.FkAdSpecialId); + modelBuilder.Entity() .Property(e => e.SalesPerManHour) .HasPrecision(19, 2); @@ -118,6 +133,10 @@ namespace AdvertsingProfitControl .Property(e => e.EndingInventory) .IsUnicode(false); + modelBuilder.Entity() + .Property(e => e.InvoiceNumber) + .IsUnicode(false); + modelBuilder.Entity() .Property(e => e.InvoiceNetAmountAtCost) .HasPrecision(19, 2); diff --git a/AdvertsingProfitControl/AdvertsingProfitControl.csproj b/AdvertsingProfitControl/AdvertsingProfitControl.csproj index 2fa1095..4cb1db2 100644 --- a/AdvertsingProfitControl/AdvertsingProfitControl.csproj +++ b/AdvertsingProfitControl/AdvertsingProfitControl.csproj @@ -128,6 +128,12 @@ DebugDatabaseConverter.cs + + Form + + + FrmRegisterAdSpecial.cs + @@ -182,6 +188,9 @@ FrmLogConsole.cs + + FrmRegisterAdSpecial.cs + NewModifyRecord.cs diff --git a/AdvertsingProfitControl/App.config b/AdvertsingProfitControl/App.config index 6a626b3..9e830f2 100644 --- a/AdvertsingProfitControl/App.config +++ b/AdvertsingProfitControl/App.config @@ -15,5 +15,7 @@ - + + + \ No newline at end of file diff --git a/AdvertsingProfitControl/DebugDatabaseConverter.cs b/AdvertsingProfitControl/DebugDatabaseConverter.cs index 98a1e3d..92c7005 100644 --- a/AdvertsingProfitControl/DebugDatabaseConverter.cs +++ b/AdvertsingProfitControl/DebugDatabaseConverter.cs @@ -328,7 +328,7 @@ namespace AdvertsingProfitControl db.Suppliers.Add(supplier); } invoiceObject.InvoiceDate = DateTime.Parse(invoice.Rows[i][0].ToString()); - invoiceObject.InvoiceNumber = int.Parse(invoice.Rows[i][2].ToString()); + invoiceObject.InvoiceNumber = invoice.Rows[i][2].ToString(); invoiceObject.InvoiceNetAmountAtCost = decimal.Parse(invoice.Rows[i][3].ToString()); invoiceObject.InvoiceNetAmount = decimal.Parse(invoice.Rows[i][4].ToString()); invoiceObject.InvoiceNote = invoice.Rows[i][5].ToString(); diff --git a/AdvertsingProfitControl/FrmMain.Designer.cs b/AdvertsingProfitControl/FrmMain.Designer.cs index c17e833..65d58dc 100644 --- a/AdvertsingProfitControl/FrmMain.Designer.cs +++ b/AdvertsingProfitControl/FrmMain.Designer.cs @@ -104,6 +104,7 @@ this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel = new System.Windows.Forms.Label(); this.perfectGrossProfitLabel = new System.Windows.Forms.Label(); this.grossProfitDollarGrossProfitLabel = new System.Windows.Forms.Label(); + this.reportsMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.mainMenu.SuspendLayout(); this.mainTableLayoutPanel.SuspendLayout(); this.commentMainTableLayoutPanel.SuspendLayout(); @@ -146,6 +147,7 @@ this.mainMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileMainMenu, this.recordsToolStripMenuItem, + this.reportsMainMenu, this.toolsMainMenu, this.helpMainMenu, this.debugMainMenu}); @@ -196,9 +198,9 @@ // toolsMainMenu // this.toolsMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.adSpecialKeyWordsToolsMainMenu, + this.clearSelectedDateToolsMainMenu, this.manageItemsToolsMainMenu, - this.clearSelectedDateToolsMainMenu}); + this.adSpecialKeyWordsToolsMainMenu}); this.toolsMainMenu.Name = "toolsMainMenu"; this.toolsMainMenu.Size = new System.Drawing.Size(72, 34); this.toolsMainMenu.Text = "&Tools"; @@ -208,7 +210,7 @@ this.adSpecialKeyWordsToolsMainMenu.Name = "adSpecialKeyWordsToolsMainMenu"; this.adSpecialKeyWordsToolsMainMenu.Size = new System.Drawing.Size(286, 34); this.adSpecialKeyWordsToolsMainMenu.Text = "&Register Ad Special"; - this.adSpecialKeyWordsToolsMainMenu.Visible = false; + this.adSpecialKeyWordsToolsMainMenu.Click += new System.EventHandler(this.adSpecialKeyWordsToolsMainMenu_Click); // // manageItemsToolsMainMenu // @@ -944,6 +946,13 @@ this.grossProfitDollarGrossProfitLabel.TabIndex = 2; this.grossProfitDollarGrossProfitLabel.Text = "Dollar Gross Profit: "; // + // reportsMainMenu + // + this.reportsMainMenu.Name = "reportsMainMenu"; + this.reportsMainMenu.Size = new System.Drawing.Size(95, 34); + this.reportsMainMenu.Text = "R&eports"; + this.reportsMainMenu.Visible = false; + // // FrmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F); @@ -1067,6 +1076,7 @@ private System.Windows.Forms.ToolStripMenuItem clearSelectedDateToolsMainMenu; private System.Windows.Forms.ToolStripMenuItem addRecordToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem rawViewDebugMainMenu; + private System.Windows.Forms.ToolStripMenuItem reportsMainMenu; } } diff --git a/AdvertsingProfitControl/FrmMain.cs b/AdvertsingProfitControl/FrmMain.cs index d7e4ac9..346e1d6 100644 --- a/AdvertsingProfitControl/FrmMain.cs +++ b/AdvertsingProfitControl/FrmMain.cs @@ -29,7 +29,7 @@ namespace AdvertsingProfitControl private void frmMain_Load(object sender, EventArgs e) { var db = new AdvertisingProfitControlModel(); - monthCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray(); + RefreshDateListing(); ConstructApcDataGridViews(); ConstructInvoicesDataGridView(); RowParsing.AdSpecialGroups.AddRange(db.AdSpecials.Select(x => x.Name)); @@ -135,6 +135,7 @@ namespace AdvertsingProfitControl form.ShowDialog(); //One the user has closed the add record form, check to see if there is a newer date //available. If so, reload the form. + RefreshDateListing(); var date = db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault(); if (date == null) return; if (date.EndingDate == _currentActiveDate) return; @@ -157,6 +158,7 @@ namespace AdvertsingProfitControl { var form = new NewModifyRecord(_currentActiveDate); form.ShowDialog(); + RefreshDateListing(); //On return reload the date that was just modified by the modify record form. LoadDate(_currentActiveDate); } @@ -347,16 +349,6 @@ namespace AdvertsingProfitControl private void LoadDate(DateTime date) { var db = new AdvertisingProfitControlModel(); - if (monthCalendar.BoldedDates.Length == 0) - { - //The database is most likely empty so halt everything. - dateTimeGroupBox.Text = @"The database appears to be empty."; - modifyRecordMainMenu.Enabled = false; - modifyRecordMainMenu.ToolTipText = @"There are no records to modify."; - return; - } - modifyRecordMainMenu.Enabled = true; - modifyRecordMainMenu.ToolTipText = @""; var dateRecord = db.WeekEndingDates.SingleOrDefault(x => x.EndingDate == date); if (dateRecord == null) { @@ -413,7 +405,7 @@ namespace AdvertsingProfitControl projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.MemberRow; } - if (p.FkAdSpecialId != 0 && adSpecialIndex == -1) + if (p.FkAdSpecialId != null && adSpecialIndex == -1) { //TODO: Fix null reference when no object is found. adSpecialIndex = index; @@ -469,7 +461,7 @@ namespace AdvertsingProfitControl inventoryDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.MemberRow; } - if (i.FkAdSpecialId != 0 && adSpecialIndex == -1) + if (i.FkAdSpecialId != null && adSpecialIndex == -1) { adSpecialIndex = index; inventoryDataGridView.Rows.Insert(index, 1); @@ -509,7 +501,7 @@ namespace AdvertsingProfitControl actualSalesDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.MemberRow; } - if (a.FkAdSpecialId != 0 && adSpecialIndex == -1) + if (a.FkAdSpecialId != null && adSpecialIndex == -1) { adSpecialIndex = index; actualSalesDataGridView.Rows.Insert(index, 1); @@ -781,6 +773,17 @@ namespace AdvertsingProfitControl { var db = new AdvertisingProfitControlModel(); monthCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray(); + if (monthCalendar.BoldedDates.Length > 0) + { + modifyRecordMainMenu.Enabled = true; + modifyRecordMainMenu.ToolTipText = @""; + } + else + { + dateTimeGroupBox.Text = @"No records found in the database."; + modifyRecordMainMenu.Enabled = false; + modifyRecordMainMenu.ToolTipText = @"There are no records to modify."; + } } private void clearSelectedDateToolsMainMenu_Click(object sender, EventArgs e) @@ -845,6 +848,7 @@ namespace AdvertsingProfitControl db.WeekEndingDates.Remove(dateRecord); db.SaveChanges(); scope.Complete(); + ClearForm(); } catch (DbUpdateException ex) { @@ -854,7 +858,11 @@ namespace AdvertsingProfitControl } RefreshDateListing(); - LoadDate(db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault().EndingDate); + var mostRecentDate = db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault(); + if (mostRecentDate != null) + { + LoadDate(mostRecentDate.EndingDate); + } } private void addRecordToolStripMenuItem_Click_1(object sender, EventArgs e) @@ -867,6 +875,12 @@ namespace AdvertsingProfitControl { } + + private void adSpecialKeyWordsToolsMainMenu_Click(object sender, EventArgs e) + { + var form = new FrmRegisterAdSpecial(); + form.ShowDialog(); + } } } //http://stackoverflow.com/questions/487661/how-do-i-suspend-painting-for-a-control-and-its-children diff --git a/AdvertsingProfitControl/FrmRegisterAdSpecial.Designer.cs b/AdvertsingProfitControl/FrmRegisterAdSpecial.Designer.cs new file mode 100644 index 0000000..8fa0a00 --- /dev/null +++ b/AdvertsingProfitControl/FrmRegisterAdSpecial.Designer.cs @@ -0,0 +1,150 @@ +namespace AdvertsingProfitControl +{ + partial class FrmRegisterAdSpecial + { + /// + /// 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.registerAdSpecialButton = new System.Windows.Forms.Button(); + this.deleteAdSpecialButton = new System.Windows.Forms.Button(); + this.newAdSpecialLabel = new System.Windows.Forms.Label(); + this.newAdSpecialTextBox = new System.Windows.Forms.TextBox(); + this.informationLabel = new System.Windows.Forms.Label(); + this.adSpecialDescription = new System.Windows.Forms.Label(); + this.descriptionTextBox = new System.Windows.Forms.TextBox(); + this.adSpecialsListBox = new System.Windows.Forms.ListView(); + this.SuspendLayout(); + // + // registerAdSpecialButton + // + this.registerAdSpecialButton.Enabled = false; + this.registerAdSpecialButton.Location = new System.Drawing.Point(476, 428); + this.registerAdSpecialButton.Name = "registerAdSpecialButton"; + this.registerAdSpecialButton.Size = new System.Drawing.Size(200, 50); + this.registerAdSpecialButton.TabIndex = 0; + this.registerAdSpecialButton.Text = "Register Ad Special"; + this.registerAdSpecialButton.UseVisualStyleBackColor = true; + this.registerAdSpecialButton.Click += new System.EventHandler(this.RegisterNewAdSpecial); + // + // deleteAdSpecialButton + // + this.deleteAdSpecialButton.Enabled = false; + this.deleteAdSpecialButton.Location = new System.Drawing.Point(13, 428); + this.deleteAdSpecialButton.Name = "deleteAdSpecialButton"; + this.deleteAdSpecialButton.Size = new System.Drawing.Size(200, 50); + this.deleteAdSpecialButton.TabIndex = 2; + this.deleteAdSpecialButton.Text = "Remove Ad Special"; + this.deleteAdSpecialButton.UseVisualStyleBackColor = true; + this.deleteAdSpecialButton.Click += new System.EventHandler(this.deleteAdSpecialButton_Click); + // + // newAdSpecialLabel + // + this.newAdSpecialLabel.AutoSize = true; + this.newAdSpecialLabel.Location = new System.Drawing.Point(17, 21); + this.newAdSpecialLabel.Name = "newAdSpecialLabel"; + this.newAdSpecialLabel.Size = new System.Drawing.Size(233, 25); + this.newAdSpecialLabel.TabIndex = 3; + this.newAdSpecialLabel.Text = "Register New Ad Special:"; + // + // newAdSpecialTextBox + // + this.newAdSpecialTextBox.Location = new System.Drawing.Point(17, 54); + this.newAdSpecialTextBox.Name = "newAdSpecialTextBox"; + this.newAdSpecialTextBox.Size = new System.Drawing.Size(228, 29); + this.newAdSpecialTextBox.TabIndex = 4; + // + // informationLabel + // + this.informationLabel.AutoSize = true; + this.informationLabel.Location = new System.Drawing.Point(17, 171); + this.informationLabel.Name = "informationLabel"; + this.informationLabel.Size = new System.Drawing.Size(64, 25); + this.informationLabel.TabIndex = 5; + this.informationLabel.Text = "label1"; + // + // adSpecialDescription + // + this.adSpecialDescription.AutoSize = true; + this.adSpecialDescription.Location = new System.Drawing.Point(17, 91); + this.adSpecialDescription.Name = "adSpecialDescription"; + this.adSpecialDescription.Size = new System.Drawing.Size(207, 25); + this.adSpecialDescription.TabIndex = 6; + this.adSpecialDescription.Text = "Description (Optional):"; + // + // descriptionTextBox + // + this.descriptionTextBox.Location = new System.Drawing.Point(17, 124); + this.descriptionTextBox.Name = "descriptionTextBox"; + this.descriptionTextBox.Size = new System.Drawing.Size(228, 29); + this.descriptionTextBox.TabIndex = 7; + // + // adSpecialsListBox + // + this.adSpecialsListBox.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.adSpecialsListBox.Location = new System.Drawing.Point(256, 21); + this.adSpecialsListBox.Name = "adSpecialsListBox"; + this.adSpecialsListBox.Size = new System.Drawing.Size(420, 401); + this.adSpecialsListBox.TabIndex = 8; + this.adSpecialsListBox.UseCompatibleStateImageBehavior = false; + this.adSpecialsListBox.View = System.Windows.Forms.View.Details; + // + // FrmRegisterAdSpecial + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(686, 489); + this.Controls.Add(this.adSpecialsListBox); + this.Controls.Add(this.descriptionTextBox); + this.Controls.Add(this.adSpecialDescription); + this.Controls.Add(this.informationLabel); + this.Controls.Add(this.newAdSpecialTextBox); + this.Controls.Add(this.newAdSpecialLabel); + this.Controls.Add(this.deleteAdSpecialButton); + this.Controls.Add(this.registerAdSpecialButton); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FrmRegisterAdSpecial"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Register Ad Special"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button registerAdSpecialButton; + private System.Windows.Forms.Button deleteAdSpecialButton; + private System.Windows.Forms.Label newAdSpecialLabel; + private System.Windows.Forms.TextBox newAdSpecialTextBox; + private System.Windows.Forms.Label informationLabel; + private System.Windows.Forms.Label adSpecialDescription; + private System.Windows.Forms.TextBox descriptionTextBox; + private System.Windows.Forms.ListView adSpecialsListBox; + } +} \ No newline at end of file diff --git a/AdvertsingProfitControl/FrmRegisterAdSpecial.cs b/AdvertsingProfitControl/FrmRegisterAdSpecial.cs new file mode 100644 index 0000000..68c1f3d --- /dev/null +++ b/AdvertsingProfitControl/FrmRegisterAdSpecial.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Data.Entity.Infrastructure; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace AdvertsingProfitControl +{ + public partial class FrmRegisterAdSpecial : Form + { + private readonly ToolTip _tt = new ToolTip(); + private bool _isUpdating; + + public FrmRegisterAdSpecial() + { + InitializeComponent(); + newAdSpecialTextBox.TextChanged += NewAdSpecialTextChanged; + var columnHeader = new ColumnHeader + { + Name = "AdSpecialsHeaderColumn", + Text = @"Current Ad Special Grouping Keywords:", + Width = adSpecialsListBox.Width - 5 + }; + adSpecialsListBox.Columns.Add(columnHeader); + adSpecialsListBox.MouseMove += OnMouseMove; + adSpecialsListBox.ItemSelectionChanged += UpdateAdSpecialTextBoxes; + RefreshAdSpecialListing(); + } + + private void UpdateAdSpecialTextBoxes(object sender, ListViewItemSelectionChangedEventArgs e) + { + newAdSpecialTextBox.Text = ((AdSpecial) e.Item.Tag).Name; + descriptionTextBox.Text = ((AdSpecial) e.Item.Tag).Description; + _isUpdating = true; + deleteAdSpecialButton.Enabled = true; + registerAdSpecialButton.Text = @"Update Ad Special"; + } + + private void NewAdSpecialTextChanged(object sender, EventArgs e) + { + if (_isUpdating && newAdSpecialTextBox.Text.Length == 0) + { + _isUpdating = false; + descriptionTextBox.Text = string.Empty; + registerAdSpecialButton.Text = @"Register Ad Special"; + } + registerAdSpecialButton.Enabled = newAdSpecialTextBox.Text.Length > 0; + } + + private void RegisterNewAdSpecial(object sender, EventArgs e) + { + var db = new AdvertisingProfitControlModel(); + if (!_isUpdating) + { + if (!db.AdSpecials.Any(x => x.Name == newAdSpecialTextBox.Text)) + { + var adSpecial = new AdSpecial + { + Name = newAdSpecialTextBox.Text, + Description = descriptionTextBox.Text + }; + db.AdSpecials.Add(adSpecial); + try + { + db.SaveChanges(); + informationLabel.Text = @"Registered '" + Environment.NewLine + adSpecial.Name + Environment.NewLine + @"' successfully."; + } + catch (DbUpdateException ex) + { + informationLabel.Text = @"Failed to register '" + Environment.NewLine + adSpecial.Name + @"'." + Environment.NewLine + + ex.Message; + } + } + else + { + MessageBox.Show(@"Ad Special '" + newAdSpecialTextBox.Text + @"' already exists.", + @"Duplicate Entry", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + newAdSpecialTextBox.Text = string.Empty; + } + } + else + { + var item = adSpecialsListBox.SelectedItems[0]; + var index = ((AdSpecial) item.Tag).Id; + var adSpecial = db.AdSpecials.SingleOrDefault(x => x.Id == index); + if (adSpecial == null) + { + informationLabel.Text = @"Failed to retrieve " + Environment.NewLine + @"ad special keyword ID."; + return; + } + adSpecial.Name = newAdSpecialTextBox.Text; + adSpecial.Description = descriptionTextBox.Text; + db.SaveChanges(); + informationLabel.Text = @"Updated '" + Environment.NewLine + newAdSpecialTextBox.Text + Environment.NewLine + @"' successfully."; + } + RefreshAdSpecialListing(); + } + + private void OnMouseMove(object sender, MouseEventArgs e) + { + var box = sender as ListBox; + if (box == null) return; + var listBox = box; + var point = new Point(e.X, e.Y); + var hoverIndex = listBox.IndexFromPoint(point); + if (hoverIndex >= 0 && hoverIndex < listBox.Items.Count) + { + // _tt.SetToolTip(listBox, _descriptions[hoverIndex]); + } + } + + private void RefreshAdSpecialListing() + { + adSpecialsListBox.Items.Clear(); + var db = new AdvertisingProfitControlModel(); + var adSpecials = db.AdSpecials.Select(x => x); + foreach (var adSpecial in adSpecials) + { + var item = new ListViewItem + { + Text = adSpecial.Name, + Tag = adSpecial + }; + adSpecialsListBox.Items.Add(item); + } + deleteAdSpecialButton.Enabled = false; + newAdSpecialTextBox.Text = string.Empty; + descriptionTextBox.Text = string.Empty; + } + + private void deleteAdSpecialButton_Click(object sender, EventArgs e) + { + //TODO: Scan for Ad Specials that are in use by a table before removing. + var item = adSpecialsListBox.SelectedItems[0]; + var adSpecial = (AdSpecial) item.Tag; + var db = new AdvertisingProfitControlModel(); + var ad = db.AdSpecials.Single(x => x.Id == adSpecial.Id); + db.AdSpecials.Remove(ad); + db.SaveChanges(); + RefreshAdSpecialListing(); + informationLabel.Text = @"Removed '" + Environment.NewLine + adSpecial.Name + Environment.NewLine + @"' successfully."; + } + } +} diff --git a/AdvertsingProfitControl/FrmRegisterAdSpecial.resx b/AdvertsingProfitControl/FrmRegisterAdSpecial.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/AdvertsingProfitControl/FrmRegisterAdSpecial.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/AdvertsingProfitControl/Inventory.cs b/AdvertsingProfitControl/Inventory.cs index d76c8d8..42d1cc0 100644 --- a/AdvertsingProfitControl/Inventory.cs +++ b/AdvertsingProfitControl/Inventory.cs @@ -29,12 +29,14 @@ namespace AdvertsingProfitControl public int FkAdItemId { get; set; } - public int FkAdSpecialId { get; set; } + public int? FkAdSpecialId { get; set; } public int FkDateId { get; set; } public virtual AdItem AdItem { get; set; } + public virtual AdSpecial AdSpecial { get; set; } + public virtual WeekEndingDate WeekEndingDate { get; set; } } } diff --git a/AdvertsingProfitControl/Invoice.cs b/AdvertsingProfitControl/Invoice.cs index 96a4070..00c6d6a 100644 --- a/AdvertsingProfitControl/Invoice.cs +++ b/AdvertsingProfitControl/Invoice.cs @@ -13,7 +13,9 @@ namespace AdvertsingProfitControl [Column(TypeName = "date")] public DateTime InvoiceDate { get; set; } - public int InvoiceNumber { get; set; } + [Required] + [StringLength(256)] + public string InvoiceNumber { get; set; } public decimal? InvoiceNetAmountAtCost { get; set; } @@ -27,7 +29,7 @@ namespace AdvertsingProfitControl public int FkDateId { get; set; } public virtual WeekEndingDate WeekEndingDate { get; set; } - [Required] + public virtual Supplier Supplier { get; set; } } } diff --git a/AdvertsingProfitControl/NewModifyRecord.Designer.cs b/AdvertsingProfitControl/NewModifyRecord.Designer.cs index 084e025..c472ae6 100644 --- a/AdvertsingProfitControl/NewModifyRecord.Designer.cs +++ b/AdvertsingProfitControl/NewModifyRecord.Designer.cs @@ -31,8 +31,9 @@ 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.editMainMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.createNewRecordEditMainMenu = 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(); @@ -106,8 +107,6 @@ this.informationPanel = new System.Windows.Forms.Panel(); this.errorLabel = new System.Windows.Forms.Label(); this.addRecordButton = new System.Windows.Forms.Button(); - this.editMainMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.createNewRecordEditMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.mainLayoutPanel.SuspendLayout(); this.mainMenuStrip.SuspendLayout(); this.mainTabControl.SuspendLayout(); @@ -175,24 +174,32 @@ // 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.Size = new System.Drawing.Size(138, 34); this.exitFileMainMenu.Text = "E&xit"; // + // editMainMenu + // + this.editMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.createNewRecordEditMainMenu}); + this.editMainMenu.Name = "editMainMenu"; + this.editMainMenu.Size = new System.Drawing.Size(60, 31); + this.editMainMenu.Text = "&Edit"; + // + // createNewRecordEditMainMenu + // + this.createNewRecordEditMainMenu.Name = "createNewRecordEditMainMenu"; + this.createNewRecordEditMainMenu.Size = new System.Drawing.Size(283, 34); + this.createNewRecordEditMainMenu.Text = "&Create New Record"; + this.createNewRecordEditMainMenu.Click += new System.EventHandler(this.createNewRecordEditMainMenu_Click); + // // mainTabControl // this.mainLayoutPanel.SetColumnSpan(this.mainTabControl, 4); @@ -939,21 +946,6 @@ this.addRecordButton.UseVisualStyleBackColor = true; this.addRecordButton.Click += new System.EventHandler(this.addRecordButton_Click); // - // editMainMenu - // - this.editMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.createNewRecordEditMainMenu}); - this.editMainMenu.Name = "editMainMenu"; - this.editMainMenu.Size = new System.Drawing.Size(60, 31); - this.editMainMenu.Text = "&Edit"; - // - // createNewRecordEditMainMenu - // - this.createNewRecordEditMainMenu.Name = "createNewRecordEditMainMenu"; - this.createNewRecordEditMainMenu.Size = new System.Drawing.Size(283, 34); - this.createNewRecordEditMainMenu.Text = "&Create New Record"; - this.createNewRecordEditMainMenu.Click += new System.EventHandler(this.createNewRecordEditMainMenu_Click); - // // NewModifyRecord // this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F); @@ -1004,7 +996,6 @@ 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.TabControl mainTabControl; private System.Windows.Forms.TabPage projectionTabPage; diff --git a/AdvertsingProfitControl/NewModifyRecord.cs b/AdvertsingProfitControl/NewModifyRecord.cs index 1de06c7..a62ebe7 100644 --- a/AdvertsingProfitControl/NewModifyRecord.cs +++ b/AdvertsingProfitControl/NewModifyRecord.cs @@ -40,7 +40,7 @@ namespace AdvertsingProfitControl // private bool _isFormDirty; // - private FormRoll _formRoll; + private bool _isModifyingRecord; public NewModifyRecord(DateTime date) { InitializeComponent(); @@ -50,7 +50,7 @@ namespace AdvertsingProfitControl InitializeForm(); mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]); Text = @"Modify Record (Current Record: " + date.ToShortDateString() + @")"; - _formRoll = FormRoll.ModifyRecord; + _isModifyingRecord = true; LoadDate(date); } @@ -75,7 +75,7 @@ namespace AdvertsingProfitControl //_debugTabPage = mainTabControl.TabPages[4]; mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]); Text = @"Add New Record (Current Record: " + _currentActiveDate.ToShortDateString() + @")"; - _formRoll = FormRoll.AddRecord; + _isModifyingRecord = false; addRecordButton.Text = @"Add Record"; } @@ -2450,7 +2450,7 @@ namespace AdvertsingProfitControl if (e.Start == _currentActiveDate) return; if (!weekEndingCalendar.BoldedDates.Contains(e.Start)) { - if (_formRoll == FormRoll.AddRecord) + if (_isModifyingRecord == false) { _currentActiveDate = e.Start; Text = @"Add New Record (Current Record: " + e.Start.ToString("d") + @")"; @@ -2605,6 +2605,9 @@ namespace AdvertsingProfitControl //Clear the used ad items _usedAdItems[0].Clear(); //regular ad items (section 1) _usedAdItems[1].Clear(); //ad special items (section 2) + //Reset the error label + errorLabel.Text = string.Empty; + errorLabel.ForeColor = Color.Red; //Clear invoices invoicesDataGridView.Rows.Clear(); //Clear comments @@ -2734,7 +2737,7 @@ namespace AdvertsingProfitControl LoadWeeklySales(dateRecord); LoadTaxable(dateRecord); LoadCostAnalysis(dateRecord); - _formRoll = FormRoll.ModifyRecord; + _isModifyingRecord = true; } private void LoadProjectionsTable(WeekEndingDate dateRecord) @@ -2752,7 +2755,7 @@ namespace AdvertsingProfitControl var index = 0; foreach (var projection in projections) { - if (projection.FkAdSpecialId != 0 && adSpecialIndex == -1) + if (projection.FkAdSpecialId != null && adSpecialIndex == -1) { adSpecialIndex = index; projectionsDataGridView.Rows.Insert(index, 1); @@ -2816,7 +2819,7 @@ namespace AdvertsingProfitControl var index = 0; foreach (var inventory in inventories) { - if (inventory.FkAdSpecialId != 0 && adSpecialIndex == -1) + if (inventory.FkAdSpecialId != null && adSpecialIndex == -1) { adSpecialIndex = index; inventoryDataGridView.Rows.Insert(index, 1); @@ -2878,7 +2881,7 @@ namespace AdvertsingProfitControl var index = 0; foreach (var actualSale in actualSales) { - if (actualSale.FkAdSpecialId != 0 && adSpecialIndex == -1) + if (actualSale.FkAdSpecialId != null && adSpecialIndex == -1) { adSpecialIndex = index; actualSalesDataGridView.Rows.Insert(index, 1); @@ -3211,20 +3214,20 @@ namespace AdvertsingProfitControl //Prevent the ad special row from being marked in any way. if (i == _adSpecialIndex) continue; //Prevent rows pulled from that the database, that haven't been touched, from being marked as well. - if ((bool) projectionsDataGridView.Rows[i].Cells[(int) SalesTableColumns.IsDirty].EditedFormattedValue) + if ((bool) projectionsDataGridView.Rows[i].Cells[(int) SalesTableColumns.IsDirty].EditedFormattedValue && projectionsDataGridView.Rows[i].Cells[(int) SalesTableColumns.Id].EditedFormattedValue.ToString() != string.Empty) { projectionsDataGridView.Rows[i].Cells[(int) SalesTableColumns.IsDirty].Value = false; projectionsDataGridView.Rows[i].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved; } //Prevent rows pulled from that the database, that haven't been touched, from being marked as well. - if ((bool) inventoryDataGridView.Rows[i].Cells[(int)InventoryTableColumns.IsDirty].EditedFormattedValue) + if ((bool) inventoryDataGridView.Rows[i].Cells[(int)InventoryTableColumns.IsDirty].EditedFormattedValue && inventoryDataGridView.Rows[i].Cells[(int)InventoryTableColumns.Id].EditedFormattedValue.ToString() != string.Empty) { inventoryDataGridView.Rows[i].Cells[(int) InventoryTableColumns.IsDirty].Value = false; inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved; } //Prevent rows pulled from that the database, that haven't been touched, from being marked as well. if (!(bool) - actualSalesDataGridView.Rows[i].Cells[(int) SalesTableColumns.IsDirty].EditedFormattedValue) + actualSalesDataGridView.Rows[i].Cells[(int) SalesTableColumns.IsDirty].EditedFormattedValue && actualSalesDataGridView.Rows[i].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString() != string.Empty) continue; actualSalesDataGridView.Rows[i].Cells[(int) SalesTableColumns.IsDirty].Value = false; actualSalesDataGridView.Rows[i].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved; @@ -3275,7 +3278,7 @@ namespace AdvertsingProfitControl _isFormDirty = false; addRecordButton.Text = @"Update Record"; Text = @"Modify Record (Current Record: " + _currentActiveDate.ToShortDateString() + @")"; - _formRoll = FormRoll.ModifyRecord; + _isModifyingRecord = true; weekEndingCalendar.AddBoldedDate(_currentActiveDate); weekEndingCalendar.Invalidate(); return success; @@ -3307,6 +3310,15 @@ namespace AdvertsingProfitControl if (row.Index == _adSpecialIndex) { adSpecial = GetAdSpecial(adItemName); + //Check to see if the ad special return value exists. + if (adSpecial.Id == 0) + { + //Warn the user about the error and break out of the loop. + //We can simply ignore the ad special group and write the rest to the database. + errorLabel.Text = @"Warning: ad special group '" + adItemName + @"' failed to" + Environment.NewLine + @"write to the database." + Environment.NewLine + @"All rows starting from " + (_adSpecialIndex + 1) + @" to " + (projectionsDataGridView.RowCount - 1) + @" will not be saved."; + errorLabel.ForeColor = Color.Orange; + break; + } continue; } //Check to see if the ad item is in the database and if so grab the object for it, otherwise add it. @@ -3340,7 +3352,7 @@ namespace AdvertsingProfitControl } else { - projection.FkAdSpecialId = 0; + projection.FkAdSpecialId = null; } //Check for an ID number if (row.Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString() == string.Empty) @@ -3375,7 +3387,7 @@ namespace AdvertsingProfitControl ? 0 : decimal.Parse( row.Cells[(int) SalesTableColumns.TotalProfitReturn].EditedFormattedValue - .ToString()); + .ToString()); projection.FkAdItemId = adItem.Id; projection.RowAttribute = rowAttribute; projection.RowPosition = row.Index + 1; @@ -3470,6 +3482,15 @@ namespace AdvertsingProfitControl if (row.Index == _adSpecialIndex) { adSpecial = GetAdSpecial(adItemName); + //Check to see if the ad special return value exists. + if (adSpecial.Id == 0) + { + //Warn the user about the error and break out of the loop. + //We can simply ignore the ad special group and write the rest to the database. + errorLabel.Text = @"Warning: ad special group '" + adItemName + @"' failed to" + Environment.NewLine + @"write to the database." + Environment.NewLine + @"All rows starting from " + (_adSpecialIndex + 1) + @" to " + (projectionsDataGridView.RowCount - 1) + @" will not be saved."; + errorLabel.ForeColor = Color.Orange; + break; + } continue; } //Check to see if the ad item is in the database and if so grab the object for it, otherwise add it. @@ -3503,7 +3524,7 @@ namespace AdvertsingProfitControl } else { - inventory.FkAdSpecialId = 0; + inventory.FkAdSpecialId = null; } //Check for an ID number if (row.Cells[(int)InventoryTableColumns.Id].EditedFormattedValue.ToString() == string.Empty) @@ -3595,6 +3616,15 @@ namespace AdvertsingProfitControl if (row.Index == _adSpecialIndex) { adSpecial = GetAdSpecial(adItemName); + //Check to see if the ad special return value exists. + if (adSpecial.Id == 0) + { + //Warn the user about the error and break out of the loop. + //We can simply ignore the ad special group and write the rest to the database. + errorLabel.Text = @"Warning: ad special group '" + adItemName + @"' failed to" + Environment.NewLine + @"write to the database." + Environment.NewLine + @"All rows starting from " + (_adSpecialIndex + 1) + @" to " + (projectionsDataGridView.RowCount - 1) + @" will not be saved."; + errorLabel.ForeColor = Color.Orange; + break; + } continue; } //Check to see if the ad item is in the database and if so grab the object for it, otherwise add it. @@ -3628,7 +3658,7 @@ namespace AdvertsingProfitControl } else { - actualSale.FkAdSpecialId = 0; + actualSale.FkAdSpecialId = null; } //Check for an ID number if (row.Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString() == string.Empty) @@ -3772,7 +3802,7 @@ namespace AdvertsingProfitControl { //If there isn't one then create a new record and add it to the database. invoice.InvoiceDate = DateTime.Parse(row.Cells[(int)InvoiceTableColumns.InvoiceDate].EditedFormattedValue.ToString()); - invoice.InvoiceNumber = int.Parse(row.Cells[(int)InvoiceTableColumns.InvoiceNumber].EditedFormattedValue.ToString()); + invoice.InvoiceNumber = row.Cells[(int)InvoiceTableColumns.InvoiceNumber].EditedFormattedValue.ToString(); invoice.InvoiceNetAmountAtCost = string.IsNullOrWhiteSpace( row.Cells[(int)InvoiceTableColumns.InvoiceNetAmountAtCost].EditedFormattedValue.ToString()) @@ -3800,10 +3830,7 @@ namespace AdvertsingProfitControl invoice.InvoiceDate = DateTime.Parse( row.Cells[(int) InvoiceTableColumns.InvoiceDate].EditedFormattedValue.ToString()); - invoice.InvoiceNumber = - int.Parse( - row.Cells[(int) InvoiceTableColumns.InvoiceNumber].EditedFormattedValue.ToString - ()); + invoice.InvoiceNumber = row.Cells[(int) InvoiceTableColumns.InvoiceNumber].EditedFormattedValue.ToString(); invoice.InvoiceNetAmountAtCost = string.IsNullOrWhiteSpace( row.Cells[(int) InvoiceTableColumns.InvoiceNetAmountAtCost].EditedFormattedValue @@ -4250,7 +4277,7 @@ namespace AdvertsingProfitControl Text = @"Add New Record (Current Date: " + _currentActiveDate.ToShortDateString() + @")"; informationLabel.Text = string.Empty; errorLabel.Text = string.Empty; - _formRoll = FormRoll.AddRecord; + _isModifyingRecord = false; } private void NormalizeApcTables() @@ -4436,10 +4463,5 @@ namespace AdvertsingProfitControl } } - private enum FormRoll - { - AddRecord = 0, - ModifyRecord = 1 - } } } diff --git a/AdvertsingProfitControl/Projection.cs b/AdvertsingProfitControl/Projection.cs index 8fd6d18..96a5a11 100644 --- a/AdvertsingProfitControl/Projection.cs +++ b/AdvertsingProfitControl/Projection.cs @@ -30,12 +30,14 @@ namespace AdvertsingProfitControl public int FkAdItemId { get; set; } - public int FkAdSpecialId { get; set; } + public int? FkAdSpecialId { get; set; } public int FkDateId { get; set; } public virtual AdItem AdItem { get; set; } + public virtual AdSpecial AdSpecial { get; set; } + public virtual WeekEndingDate WeekEndingDate { get; set; } } }