diff --git a/AdvertsingProfitControl/FrmMain.Designer.cs b/AdvertsingProfitControl/FrmMain.Designer.cs index ebb2a00..04d51de 100644 --- a/AdvertsingProfitControl/FrmMain.Designer.cs +++ b/AdvertsingProfitControl/FrmMain.Designer.cs @@ -334,21 +334,21 @@ // rawViewDebugMainMenu // this.rawViewDebugMainMenu.Name = "rawViewDebugMainMenu"; - this.rawViewDebugMainMenu.Size = new System.Drawing.Size(240, 34); + this.rawViewDebugMainMenu.Size = new System.Drawing.Size(213, 34); this.rawViewDebugMainMenu.Text = "Ra&w View"; this.rawViewDebugMainMenu.Click += new System.EventHandler(this.DisplayRawDatabaseView); // // addRecordToolStripMenuItem // this.addRecordToolStripMenuItem.Name = "addRecordToolStripMenuItem"; - this.addRecordToolStripMenuItem.Size = new System.Drawing.Size(240, 34); + this.addRecordToolStripMenuItem.Size = new System.Drawing.Size(213, 34); this.addRecordToolStripMenuItem.Text = "Add Re&cord"; this.addRecordToolStripMenuItem.Click += new System.EventHandler(this.DisplayLegacyAddRecord); // // testToolStripMenuItem // this.testToolStripMenuItem.Name = "testToolStripMenuItem"; - this.testToolStripMenuItem.Size = new System.Drawing.Size(240, 34); + this.testToolStripMenuItem.Size = new System.Drawing.Size(213, 34); this.testToolStripMenuItem.Text = "Test"; this.testToolStripMenuItem.Click += new System.EventHandler(this.testToolStripMenuItem_Click); // @@ -945,7 +945,6 @@ // commentsTextBox // this.commentsTextBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.commentsTextBox.Enabled = false; this.commentsTextBox.Location = new System.Drawing.Point(5, 28); this.commentsTextBox.Multiline = true; this.commentsTextBox.Name = "commentsTextBox"; diff --git a/AdvertsingProfitControl/FrmManageAdItems.Designer.cs b/AdvertsingProfitControl/FrmManageAdItems.Designer.cs index acf3239..13969c9 100644 --- a/AdvertsingProfitControl/FrmManageAdItems.Designer.cs +++ b/AdvertsingProfitControl/FrmManageAdItems.Designer.cs @@ -39,15 +39,17 @@ this.informationLabel = new System.Windows.Forms.Label(); this.filterLabel = new System.Windows.Forms.Label(); this.filterComboBox = new System.Windows.Forms.ComboBox(); + this.replaceReferencesButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // // adItemsListView // - this.adItemsListView.Location = new System.Drawing.Point(141, 7); - this.adItemsListView.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.adItemsListView.Location = new System.Drawing.Point(259, 13); + this.adItemsListView.Margin = new System.Windows.Forms.Padding(4); this.adItemsListView.MultiSelect = false; this.adItemsListView.Name = "adItemsListView"; - this.adItemsListView.Size = new System.Drawing.Size(248, 235); + this.adItemsListView.Size = new System.Drawing.Size(451, 430); + this.adItemsListView.Sorting = System.Windows.Forms.SortOrder.Ascending; this.adItemsListView.TabIndex = 3; this.adItemsListView.TabStop = false; this.adItemsListView.UseCompatibleStateImageBehavior = false; @@ -56,10 +58,10 @@ // addUpdateItemButton // this.addUpdateItemButton.Enabled = false; - this.addUpdateItemButton.Location = new System.Drawing.Point(276, 243); - this.addUpdateItemButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.addUpdateItemButton.Location = new System.Drawing.Point(506, 449); + this.addUpdateItemButton.Margin = new System.Windows.Forms.Padding(4); this.addUpdateItemButton.Name = "addUpdateItemButton"; - this.addUpdateItemButton.Size = new System.Drawing.Size(109, 38); + this.addUpdateItemButton.Size = new System.Drawing.Size(200, 70); this.addUpdateItemButton.TabIndex = 3; this.addUpdateItemButton.Text = "Add New Item"; this.addUpdateItemButton.UseVisualStyleBackColor = true; @@ -68,10 +70,10 @@ // removeAdItemButton // this.removeAdItemButton.Enabled = false; - this.removeAdItemButton.Location = new System.Drawing.Point(7, 243); - this.removeAdItemButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.removeAdItemButton.Location = new System.Drawing.Point(13, 449); + this.removeAdItemButton.Margin = new System.Windows.Forms.Padding(4); this.removeAdItemButton.Name = "removeAdItemButton"; - this.removeAdItemButton.Size = new System.Drawing.Size(109, 38); + this.removeAdItemButton.Size = new System.Drawing.Size(200, 70); this.removeAdItemButton.TabIndex = 4; this.removeAdItemButton.Text = "Remove Selected Item"; this.removeAdItemButton.UseVisualStyleBackColor = true; @@ -79,58 +81,58 @@ // // newItemTextBox // - this.newItemTextBox.Location = new System.Drawing.Point(2, 22); - this.newItemTextBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.newItemTextBox.Location = new System.Drawing.Point(4, 41); + this.newItemTextBox.Margin = new System.Windows.Forms.Padding(4); this.newItemTextBox.MaxLength = 32; this.newItemTextBox.Name = "newItemTextBox"; - this.newItemTextBox.Size = new System.Drawing.Size(111, 20); + this.newItemTextBox.Size = new System.Drawing.Size(247, 29); this.newItemTextBox.TabIndex = 1; // // descriptionTextBox // - this.descriptionTextBox.Location = new System.Drawing.Point(2, 69); - this.descriptionTextBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.descriptionTextBox.Location = new System.Drawing.Point(4, 127); + this.descriptionTextBox.Margin = new System.Windows.Forms.Padding(4); this.descriptionTextBox.MaxLength = 128; this.descriptionTextBox.Name = "descriptionTextBox"; - this.descriptionTextBox.Size = new System.Drawing.Size(111, 20); + this.descriptionTextBox.Size = new System.Drawing.Size(247, 29); this.descriptionTextBox.TabIndex = 2; // // newItemLabel // this.newItemLabel.AutoSize = true; - this.newItemLabel.Location = new System.Drawing.Point(2, 7); - this.newItemLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.newItemLabel.Location = new System.Drawing.Point(4, 13); + this.newItemLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.newItemLabel.Name = "newItemLabel"; - this.newItemLabel.Size = new System.Drawing.Size(113, 13); + this.newItemLabel.Size = new System.Drawing.Size(205, 25); this.newItemLabel.TabIndex = 5; this.newItemLabel.Text = "Register New Ad Item:"; // // descriptionLabel // this.descriptionLabel.AutoSize = true; - this.descriptionLabel.Location = new System.Drawing.Point(2, 54); - this.descriptionLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.descriptionLabel.Location = new System.Drawing.Point(4, 100); + this.descriptionLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.descriptionLabel.Name = "descriptionLabel"; - this.descriptionLabel.Size = new System.Drawing.Size(111, 13); + this.descriptionLabel.Size = new System.Drawing.Size(207, 25); this.descriptionLabel.TabIndex = 6; this.descriptionLabel.Text = "Description (Optional):"; // // informationLabel // this.informationLabel.AutoSize = true; - this.informationLabel.Location = new System.Drawing.Point(4, 119); - this.informationLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.informationLabel.Location = new System.Drawing.Point(8, 271); + this.informationLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.informationLabel.Name = "informationLabel"; - this.informationLabel.Size = new System.Drawing.Size(0, 13); + this.informationLabel.Size = new System.Drawing.Size(0, 25); this.informationLabel.TabIndex = 7; // // filterLabel // this.filterLabel.AutoSize = true; - this.filterLabel.Location = new System.Drawing.Point(2, 103); - this.filterLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.filterLabel.Location = new System.Drawing.Point(4, 190); + this.filterLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.filterLabel.Name = "filterLabel"; - this.filterLabel.Size = new System.Drawing.Size(61, 13); + this.filterLabel.Size = new System.Drawing.Size(115, 25); this.filterLabel.TabIndex = 8; this.filterLabel.Text = "Apply Filter:"; // @@ -138,18 +140,31 @@ // this.filterComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.filterComboBox.FormattingEnabled = true; - this.filterComboBox.Location = new System.Drawing.Point(2, 118); - this.filterComboBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.filterComboBox.Location = new System.Drawing.Point(4, 219); + this.filterComboBox.Margin = new System.Windows.Forms.Padding(4); this.filterComboBox.Name = "filterComboBox"; - this.filterComboBox.Size = new System.Drawing.Size(111, 21); + this.filterComboBox.Size = new System.Drawing.Size(200, 32); this.filterComboBox.TabIndex = 9; this.filterComboBox.TabStop = false; // + // replaceReferencesButton + // + this.replaceReferencesButton.Enabled = false; + this.replaceReferencesButton.Location = new System.Drawing.Point(259, 449); + this.replaceReferencesButton.Margin = new System.Windows.Forms.Padding(4); + this.replaceReferencesButton.Name = "replaceReferencesButton"; + this.replaceReferencesButton.Size = new System.Drawing.Size(200, 70); + this.replaceReferencesButton.TabIndex = 10; + this.replaceReferencesButton.Text = "Replace References With..."; + this.replaceReferencesButton.UseVisualStyleBackColor = true; + this.replaceReferencesButton.Click += new System.EventHandler(this.FlagFormReplaceRefrence); + // // FrmManageAdItems // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(394, 288); + this.ClientSize = new System.Drawing.Size(722, 532); + this.Controls.Add(this.replaceReferencesButton); this.Controls.Add(this.filterComboBox); this.Controls.Add(this.filterLabel); this.Controls.Add(this.informationLabel); @@ -162,7 +177,7 @@ this.Controls.Add(this.adItemsListView); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.Margin = new System.Windows.Forms.Padding(4); this.Name = "FrmManageAdItems"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Manage Ad Items"; @@ -183,5 +198,6 @@ private System.Windows.Forms.Label informationLabel; private System.Windows.Forms.Label filterLabel; private System.Windows.Forms.ComboBox filterComboBox; + private System.Windows.Forms.Button replaceReferencesButton; } } \ No newline at end of file diff --git a/AdvertsingProfitControl/FrmManageAdItems.cs b/AdvertsingProfitControl/FrmManageAdItems.cs index 74be4e4..d33e925 100644 --- a/AdvertsingProfitControl/FrmManageAdItems.cs +++ b/AdvertsingProfitControl/FrmManageAdItems.cs @@ -1,4 +1,6 @@ using System; +using System.Data.Entity; +using System.Data.Entity.Core; using System.Data.Entity.Infrastructure; using System.Linq; using System.Transactions; @@ -10,6 +12,8 @@ namespace AdvertsingProfitControl public partial class FrmManageAdItems : Form { private bool _isUpdating; + private bool _replaceingReference; + private AdItem _replacee; public FrmManageAdItems() { @@ -28,12 +32,20 @@ namespace AdvertsingProfitControl private void FilterValueChanged(object sender, EventArgs e) { if(filterComboBox.Enabled == false) return; - adItemsListView.Columns[0].Text = @"Current Ad Items (" + (filterComboBox.SelectedItem.ToString() == "All" ? "No Filter" : @"Filter " + filterComboBox.SelectedItem) + @"):"; + if (!_replaceingReference) + { + adItemsListView.Columns[0].Text = @"Current Ad Items (" + (filterComboBox.SelectedItem.ToString() == "All" ? "No Filter" : @"Filter " + filterComboBox.SelectedItem) + @"):"; + } + else + { + adItemsListView.Columns[0].Text = @"Chose Replacement (" + (filterComboBox.SelectedItem.ToString() == "All" ? "No Filter" : @"Filter " + filterComboBox.SelectedItem) + @"):"; + } adItemsListView.Items.Clear(); var db = new AdvertisingProfitControlDbContext(); var adItems = db.AdItems.Select(x => x); foreach (var adItem in adItems) { + if(_replacee != null && _replacee.Name == adItem.Name) continue; var item = new ListViewItem { Text = adItem.Name, @@ -56,20 +68,32 @@ namespace AdvertsingProfitControl { adItemsListView.Items.Add(item);} } } - newItemTextBox.Text = string.Empty; - descriptionTextBox.Text = string.Empty; - removeAdItemButton.Enabled = false; + if (!_replaceingReference) + { + newItemTextBox.Text = string.Empty; + descriptionTextBox.Text = string.Empty; + removeAdItemButton.Enabled = false; + } } private void UpdateAdItemTextFields(object sender, ListViewItemSelectionChangedEventArgs e) { - newItemTextBox.Text = ((AdItem)e.Item.Tag).Name; - descriptionTextBox.Text = ((AdItem)e.Item.Tag).Description; _isUpdating = true; removeAdItemButton.Enabled = true; - addUpdateItemButton.Text = @"Update Ad Item"; - newItemLabel.Text = @"Update Ad Item:"; + if (!_replaceingReference) + { + newItemTextBox.Text = ((AdItem)e.Item.Tag).Name; + descriptionTextBox.Text = ((AdItem)e.Item.Tag).Description; + replaceReferencesButton.Enabled = true; + addUpdateItemButton.Text = @"Update Ad Item"; + newItemLabel.Text = @"Update Ad Item:"; + } + else + { + descriptionTextBox.Text = ((AdItem)e.Item.Tag).Name; + addUpdateItemButton.Enabled = true; + } } private void NewItemTextChanged(object sender, EventArgs e) @@ -78,8 +102,13 @@ namespace AdvertsingProfitControl { _isUpdating = false; descriptionTextBox.Text = string.Empty; - addUpdateItemButton.Text = @"Register Ad Item"; - newItemLabel.Text = @"Register New Ad Item:"; + if (!_replaceingReference) + { + addUpdateItemButton.Text = @"Register Ad Item"; + newItemLabel.Text = @"Register New Ad Item:"; + removeAdItemButton.Enabled = false; + replaceReferencesButton.Enabled = false; + } } addUpdateItemButton.Enabled = newItemTextBox.Text.Length > 0; } @@ -98,6 +127,7 @@ namespace AdvertsingProfitControl var numberFound = false; foreach (var adItem in adItems) { + if(_replacee != null && _replacee.Name == adItem.Name) continue; var item = new ListViewItem { Text = adItem.Name, @@ -107,7 +137,7 @@ namespace AdvertsingProfitControl { adItemsListView.Items.Add(item); } - else if (adItem.Name[0].ToString() == filter) + else if (string.Equals(adItem.Name[0].ToString(), filter, StringComparison.CurrentCultureIgnoreCase)) { adItemsListView.Items.Add(item); } @@ -143,20 +173,28 @@ namespace AdvertsingProfitControl filterComboBox.Enabled = false; filterComboBox.SelectedIndex = 0; } - removeAdItemButton.Enabled = false; - newItemTextBox.Text = string.Empty; - descriptionTextBox.Text = string.Empty; + if (!_replaceingReference) + { + removeAdItemButton.Enabled = false; + newItemTextBox.Text = string.Empty; + descriptionTextBox.Text = string.Empty; + } filterComboBox.SelectedIndexChanged += FilterValueChanged; } private void RemoveSelectedAdItem(object sender, EventArgs e) { + if (_replaceingReference) + { + SetFormStateAdNewItem(); + return; + } var item = adItemsListView.SelectedItems[0]; var oldAdItem = (AdItem)item.Tag; var db = new AdvertisingProfitControlDbContext(); var adItemEntry = db.AdItems.Single(x => x.Id == oldAdItem.Id); //Check to see if the ad special is used by other tables. - if (adItemEntry.ActualSales.Count > 0) + if (adItemEntry.ActualSales.Count > 0 && !_replaceingReference) { //If so, display a warning to the user about the potential data loss. var result = @@ -211,6 +249,7 @@ namespace AdvertsingProfitControl var db = new AdvertisingProfitControlDbContext(); if (!_isUpdating) { + newItemTextBox.Text = TextFormat.FormatAdItemText(newItemTextBox.Text); if (!db.AdItems.Any(x => x.Name == newItemTextBox.Text)) { var adItem = new AdItem @@ -235,10 +274,16 @@ namespace AdvertsingProfitControl MessageBox.Show(@"Ad item '" + newItemTextBox.Text + @"' already exists.", @"Duplicate Entry", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); newItemTextBox.Text = string.Empty; + return; } } + else if (_replaceingReference) + { + PerformReplacement(); + } else { + newItemTextBox.Text = TextFormat.FormatAdItemText(newItemTextBox.Text); var item = adItemsListView.SelectedItems[0]; var index = ((AdItem)item.Tag).Id; var adItem = db.AdItems.SingleOrDefault(x => x.Id == index); @@ -247,12 +292,141 @@ namespace AdvertsingProfitControl informationLabel.Text = @"Failed to retrieve " + Environment.NewLine + @"ad item ID."; return; } - adItem.Name = newItemTextBox.Text; - adItem.Description = descriptionTextBox.Text; - db.SaveChanges(); - informationLabel.Text = @"Updated '" + Environment.NewLine + newItemTextBox.Text + Environment.NewLine + @"' successfully."; + if (!db.AdItems.Any(x => x.Name == newItemTextBox.Text)) + { + adItem.Name = newItemTextBox.Text; + adItem.Description = descriptionTextBox.Text; + db.SaveChanges(); + informationLabel.Text = @"Updated '" + Environment.NewLine + newItemTextBox.Text + Environment.NewLine + @"' successfully."; + } + else + { + MessageBox.Show(@"Ad item '" + newItemTextBox.Text + @"' already exists.", + @"Duplicate Name Entered", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } } RefreshAdItemListing(filterComboBox.SelectedItem.ToString()); } + + private void FlagFormReplaceRefrence(object sender, EventArgs e) + { + SetFormStateReplacingReference(); + } + + private void PerformReplacement() + { + var newItem = (AdItem) adItemsListView.SelectedItems[0].Tag; + var db = new AdvertisingProfitControlDbContext(); + var replacementCount = 0; + var skipCount = 0; + + try + { + using (var scope = new TransactionScope()) + { + var projectionsToUpdate = db.Projections.Where(x => x.AdItem.Id == _replacee.Id); + + foreach (var record in projectionsToUpdate) + { + var table = db.Projections.Where(x => x.FkDateId == record.FkDateId); + if (table.Count(x => x.FkDateId == record.FkDateId) == 0) continue; + record.FkAdItemId = newItem.Id; + db.Projections.Attach(record); + db.Entry(record).State = EntityState.Modified; + replacementCount++; + } + + var inventoryToUpdate = db.Inventories.Where(x => x.AdItem.Id == _replacee.Id); + + foreach (var record in inventoryToUpdate) + { + var table = db.Inventories.Where(x => x.FkDateId == record.FkDateId); + if (table.Count(x => x.FkDateId == record.FkDateId) == 0) continue; + record.FkAdItemId = newItem.Id; + db.Inventories.Attach(record); + db.Entry(record).State = EntityState.Modified; + replacementCount++; + } + + var actualSalesToUpdate = db.ActualSales.Where(x => x.AdItem.Id == _replacee.Id); + + foreach (var record in actualSalesToUpdate) + { + var table = db.ActualSales.Where(x => x.FkDateId == record.FkDateId); + if (table.Count(x => x.FkDateId == record.FkDateId) == 0) continue; + record.FkAdItemId = newItem.Id; + db.ActualSales.Attach(record); + db.Entry(record).State = EntityState.Modified; + replacementCount++; + } + + db.SaveChanges(); + + scope.Complete(); + } + //All completed without error so give the user the option to delete the replace. + var result = MessageBox.Show(_replacee.Name + @" has been successfully replaced with " + newItem.Name + @". Would you like to delete " + _replacee.Name + @" from the database?", @"Replacement Completed Successfully on " + replacementCount + @" Item(s)", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (result == DialogResult.Yes) + { + _replacee = db.AdItems.Single(x => x.Id == _replacee.Id); + db.AdItems.Remove(_replacee); + db.SaveChanges(); + informationLabel.Text = @"Removed " + Environment.NewLine + _replacee.Name + Environment.NewLine + @" from the database."; + } + SetFormStateAdNewItem(); + RefreshAdItemListing(filterComboBox.SelectedItem.ToString()); + } + catch (EntitySqlException e) + { + MessageBox.Show(e.Message); + } + } + + private void SetFormStateReplacingReference() + { + newItemTextBox.TextChanged -= NewItemTextChanged; + adItemsListView.ItemSelectionChanged -= UpdateAdItemTextFields; + _replaceingReference = true; + _replacee = (AdItem)adItemsListView.SelectedItems[0].Tag; + addUpdateItemButton.Text = @"Replace References"; + addUpdateItemButton.Enabled = false; + newItemTextBox.Enabled = false; + newItemLabel.Text = @"Replace"; + descriptionTextBox.Enabled = false; + descriptionLabel.Text = @"With"; + removeAdItemButton.Text = @"Cancel"; + replaceReferencesButton.Text = @"Select Item to Replace With"; + replaceReferencesButton.Enabled = false; + //Prevent the user from selecting the same item again. + adItemsListView.Items.Remove(adItemsListView.SelectedItems[0]); + if (adItemsListView.Items.Count == 0) + { + RefreshAdItemListing(); + } + newItemTextBox.TextChanged += NewItemTextChanged; + adItemsListView.ItemSelectionChanged += UpdateAdItemTextFields; + } + + private void SetFormStateAdNewItem() + { + newItemTextBox.TextChanged -= NewItemTextChanged; + _replacee = null; + _replaceingReference = false; + _isUpdating = false; + newItemTextBox.Enabled = true; + newItemTextBox.Text = string.Empty; + descriptionTextBox.Enabled = true; + descriptionTextBox.Text = string.Empty; + descriptionLabel.Text = @"Description (Optional):"; + removeAdItemButton.Text = @"Remove Selected Item"; + replaceReferencesButton.Text = @"Replace References With..."; + addUpdateItemButton.Enabled = false; + addUpdateItemButton.Text = @"Ad New Item"; + newItemLabel.Text = @"Register New Ad Item:"; + removeAdItemButton.Enabled = false; + replaceReferencesButton.Enabled = false; + newItemTextBox.TextChanged += NewItemTextChanged; + } } } diff --git a/AdvertsingProfitControl/GlobalClasses.cs b/AdvertsingProfitControl/GlobalClasses.cs index 1a83371..7cc7d2f 100644 --- a/AdvertsingProfitControl/GlobalClasses.cs +++ b/AdvertsingProfitControl/GlobalClasses.cs @@ -16,7 +16,7 @@ namespace AdvertsingProfitControl } using ( var file = - new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("d") + ".log", true)) + new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("yy-MM-dd") + ".log", true)) { file.WriteLine(DateTime.Now + ": Unhandled Thread Exception:\n" + e.Exception.Message + Environment.NewLine); MessageBox.Show(@"An unhandled thread exception has occurred. Advertising Profit Control will be forced to exit.", @@ -31,7 +31,7 @@ namespace AdvertsingProfitControl { Directory.CreateDirectory(LogFilePath); } - using (var file = new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("d") + ".log", true)) + using (var file = new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("yy-MM-dd") + ".log", true)) { file.WriteLine(DateTime.Now + ": An unhandled exception occurred. \nException Object: " + e.ExceptionObject + Environment.NewLine); MessageBox.Show(@"And unknown error has occurred. Advertising Profit Control will be forced to exit.", diff --git a/SetupProject/Product.wxs b/SetupProject/Product.wxs index d444248..76e5b23 100644 --- a/SetupProject/Product.wxs +++ b/SetupProject/Product.wxs @@ -118,7 +118,6 @@ - @@ -138,6 +137,9 @@ + + +