Updated the ad item manager form to allow the user to replace one item with another item. Fixed a crash bug in the Global Class logger functions.
This commit is contained in:
+3
-4
@@ -334,21 +334,21 @@
|
|||||||
// rawViewDebugMainMenu
|
// rawViewDebugMainMenu
|
||||||
//
|
//
|
||||||
this.rawViewDebugMainMenu.Name = "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.Text = "Ra&w View";
|
||||||
this.rawViewDebugMainMenu.Click += new System.EventHandler(this.DisplayRawDatabaseView);
|
this.rawViewDebugMainMenu.Click += new System.EventHandler(this.DisplayRawDatabaseView);
|
||||||
//
|
//
|
||||||
// addRecordToolStripMenuItem
|
// addRecordToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.addRecordToolStripMenuItem.Name = "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.Text = "Add Re&cord";
|
||||||
this.addRecordToolStripMenuItem.Click += new System.EventHandler(this.DisplayLegacyAddRecord);
|
this.addRecordToolStripMenuItem.Click += new System.EventHandler(this.DisplayLegacyAddRecord);
|
||||||
//
|
//
|
||||||
// testToolStripMenuItem
|
// testToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.testToolStripMenuItem.Name = "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.Text = "Test";
|
||||||
this.testToolStripMenuItem.Click += new System.EventHandler(this.testToolStripMenuItem_Click);
|
this.testToolStripMenuItem.Click += new System.EventHandler(this.testToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
@@ -945,7 +945,6 @@
|
|||||||
// commentsTextBox
|
// commentsTextBox
|
||||||
//
|
//
|
||||||
this.commentsTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.commentsTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.commentsTextBox.Enabled = false;
|
|
||||||
this.commentsTextBox.Location = new System.Drawing.Point(5, 28);
|
this.commentsTextBox.Location = new System.Drawing.Point(5, 28);
|
||||||
this.commentsTextBox.Multiline = true;
|
this.commentsTextBox.Multiline = true;
|
||||||
this.commentsTextBox.Name = "commentsTextBox";
|
this.commentsTextBox.Name = "commentsTextBox";
|
||||||
|
|||||||
+49
-33
@@ -39,15 +39,17 @@
|
|||||||
this.informationLabel = new System.Windows.Forms.Label();
|
this.informationLabel = new System.Windows.Forms.Label();
|
||||||
this.filterLabel = new System.Windows.Forms.Label();
|
this.filterLabel = new System.Windows.Forms.Label();
|
||||||
this.filterComboBox = new System.Windows.Forms.ComboBox();
|
this.filterComboBox = new System.Windows.Forms.ComboBox();
|
||||||
|
this.replaceReferencesButton = new System.Windows.Forms.Button();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// adItemsListView
|
// adItemsListView
|
||||||
//
|
//
|
||||||
this.adItemsListView.Location = new System.Drawing.Point(141, 7);
|
this.adItemsListView.Location = new System.Drawing.Point(259, 13);
|
||||||
this.adItemsListView.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
this.adItemsListView.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.adItemsListView.MultiSelect = false;
|
this.adItemsListView.MultiSelect = false;
|
||||||
this.adItemsListView.Name = "adItemsListView";
|
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.TabIndex = 3;
|
||||||
this.adItemsListView.TabStop = false;
|
this.adItemsListView.TabStop = false;
|
||||||
this.adItemsListView.UseCompatibleStateImageBehavior = false;
|
this.adItemsListView.UseCompatibleStateImageBehavior = false;
|
||||||
@@ -56,10 +58,10 @@
|
|||||||
// addUpdateItemButton
|
// addUpdateItemButton
|
||||||
//
|
//
|
||||||
this.addUpdateItemButton.Enabled = false;
|
this.addUpdateItemButton.Enabled = false;
|
||||||
this.addUpdateItemButton.Location = new System.Drawing.Point(276, 243);
|
this.addUpdateItemButton.Location = new System.Drawing.Point(506, 449);
|
||||||
this.addUpdateItemButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
this.addUpdateItemButton.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.addUpdateItemButton.Name = "addUpdateItemButton";
|
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.TabIndex = 3;
|
||||||
this.addUpdateItemButton.Text = "Add New Item";
|
this.addUpdateItemButton.Text = "Add New Item";
|
||||||
this.addUpdateItemButton.UseVisualStyleBackColor = true;
|
this.addUpdateItemButton.UseVisualStyleBackColor = true;
|
||||||
@@ -68,10 +70,10 @@
|
|||||||
// removeAdItemButton
|
// removeAdItemButton
|
||||||
//
|
//
|
||||||
this.removeAdItemButton.Enabled = false;
|
this.removeAdItemButton.Enabled = false;
|
||||||
this.removeAdItemButton.Location = new System.Drawing.Point(7, 243);
|
this.removeAdItemButton.Location = new System.Drawing.Point(13, 449);
|
||||||
this.removeAdItemButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
this.removeAdItemButton.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.removeAdItemButton.Name = "removeAdItemButton";
|
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.TabIndex = 4;
|
||||||
this.removeAdItemButton.Text = "Remove Selected Item";
|
this.removeAdItemButton.Text = "Remove Selected Item";
|
||||||
this.removeAdItemButton.UseVisualStyleBackColor = true;
|
this.removeAdItemButton.UseVisualStyleBackColor = true;
|
||||||
@@ -79,58 +81,58 @@
|
|||||||
//
|
//
|
||||||
// newItemTextBox
|
// newItemTextBox
|
||||||
//
|
//
|
||||||
this.newItemTextBox.Location = new System.Drawing.Point(2, 22);
|
this.newItemTextBox.Location = new System.Drawing.Point(4, 41);
|
||||||
this.newItemTextBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
this.newItemTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.newItemTextBox.MaxLength = 32;
|
this.newItemTextBox.MaxLength = 32;
|
||||||
this.newItemTextBox.Name = "newItemTextBox";
|
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;
|
this.newItemTextBox.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// descriptionTextBox
|
// descriptionTextBox
|
||||||
//
|
//
|
||||||
this.descriptionTextBox.Location = new System.Drawing.Point(2, 69);
|
this.descriptionTextBox.Location = new System.Drawing.Point(4, 127);
|
||||||
this.descriptionTextBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
this.descriptionTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.descriptionTextBox.MaxLength = 128;
|
this.descriptionTextBox.MaxLength = 128;
|
||||||
this.descriptionTextBox.Name = "descriptionTextBox";
|
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;
|
this.descriptionTextBox.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// newItemLabel
|
// newItemLabel
|
||||||
//
|
//
|
||||||
this.newItemLabel.AutoSize = true;
|
this.newItemLabel.AutoSize = true;
|
||||||
this.newItemLabel.Location = new System.Drawing.Point(2, 7);
|
this.newItemLabel.Location = new System.Drawing.Point(4, 13);
|
||||||
this.newItemLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
this.newItemLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
this.newItemLabel.Name = "newItemLabel";
|
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.TabIndex = 5;
|
||||||
this.newItemLabel.Text = "Register New Ad Item:";
|
this.newItemLabel.Text = "Register New Ad Item:";
|
||||||
//
|
//
|
||||||
// descriptionLabel
|
// descriptionLabel
|
||||||
//
|
//
|
||||||
this.descriptionLabel.AutoSize = true;
|
this.descriptionLabel.AutoSize = true;
|
||||||
this.descriptionLabel.Location = new System.Drawing.Point(2, 54);
|
this.descriptionLabel.Location = new System.Drawing.Point(4, 100);
|
||||||
this.descriptionLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
this.descriptionLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
this.descriptionLabel.Name = "descriptionLabel";
|
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.TabIndex = 6;
|
||||||
this.descriptionLabel.Text = "Description (Optional):";
|
this.descriptionLabel.Text = "Description (Optional):";
|
||||||
//
|
//
|
||||||
// informationLabel
|
// informationLabel
|
||||||
//
|
//
|
||||||
this.informationLabel.AutoSize = true;
|
this.informationLabel.AutoSize = true;
|
||||||
this.informationLabel.Location = new System.Drawing.Point(4, 119);
|
this.informationLabel.Location = new System.Drawing.Point(8, 271);
|
||||||
this.informationLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
this.informationLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
this.informationLabel.Name = "informationLabel";
|
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;
|
this.informationLabel.TabIndex = 7;
|
||||||
//
|
//
|
||||||
// filterLabel
|
// filterLabel
|
||||||
//
|
//
|
||||||
this.filterLabel.AutoSize = true;
|
this.filterLabel.AutoSize = true;
|
||||||
this.filterLabel.Location = new System.Drawing.Point(2, 103);
|
this.filterLabel.Location = new System.Drawing.Point(4, 190);
|
||||||
this.filterLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
this.filterLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
this.filterLabel.Name = "filterLabel";
|
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.TabIndex = 8;
|
||||||
this.filterLabel.Text = "Apply Filter:";
|
this.filterLabel.Text = "Apply Filter:";
|
||||||
//
|
//
|
||||||
@@ -138,18 +140,31 @@
|
|||||||
//
|
//
|
||||||
this.filterComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
this.filterComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
this.filterComboBox.FormattingEnabled = true;
|
this.filterComboBox.FormattingEnabled = true;
|
||||||
this.filterComboBox.Location = new System.Drawing.Point(2, 118);
|
this.filterComboBox.Location = new System.Drawing.Point(4, 219);
|
||||||
this.filterComboBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
this.filterComboBox.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.filterComboBox.Name = "filterComboBox";
|
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.TabIndex = 9;
|
||||||
this.filterComboBox.TabStop = false;
|
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
|
// 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.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.filterComboBox);
|
||||||
this.Controls.Add(this.filterLabel);
|
this.Controls.Add(this.filterLabel);
|
||||||
this.Controls.Add(this.informationLabel);
|
this.Controls.Add(this.informationLabel);
|
||||||
@@ -162,7 +177,7 @@
|
|||||||
this.Controls.Add(this.adItemsListView);
|
this.Controls.Add(this.adItemsListView);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
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.Name = "FrmManageAdItems";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "Manage Ad Items";
|
this.Text = "Manage Ad Items";
|
||||||
@@ -183,5 +198,6 @@
|
|||||||
private System.Windows.Forms.Label informationLabel;
|
private System.Windows.Forms.Label informationLabel;
|
||||||
private System.Windows.Forms.Label filterLabel;
|
private System.Windows.Forms.Label filterLabel;
|
||||||
private System.Windows.Forms.ComboBox filterComboBox;
|
private System.Windows.Forms.ComboBox filterComboBox;
|
||||||
|
private System.Windows.Forms.Button replaceReferencesButton;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Data.Entity;
|
||||||
|
using System.Data.Entity.Core;
|
||||||
using System.Data.Entity.Infrastructure;
|
using System.Data.Entity.Infrastructure;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Transactions;
|
using System.Transactions;
|
||||||
@@ -10,6 +12,8 @@ namespace AdvertsingProfitControl
|
|||||||
public partial class FrmManageAdItems : Form
|
public partial class FrmManageAdItems : Form
|
||||||
{
|
{
|
||||||
private bool _isUpdating;
|
private bool _isUpdating;
|
||||||
|
private bool _replaceingReference;
|
||||||
|
private AdItem _replacee;
|
||||||
|
|
||||||
public FrmManageAdItems()
|
public FrmManageAdItems()
|
||||||
{
|
{
|
||||||
@@ -28,12 +32,20 @@ namespace AdvertsingProfitControl
|
|||||||
private void FilterValueChanged(object sender, EventArgs e)
|
private void FilterValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if(filterComboBox.Enabled == false) return;
|
if(filterComboBox.Enabled == false) return;
|
||||||
|
if (!_replaceingReference)
|
||||||
|
{
|
||||||
adItemsListView.Columns[0].Text = @"Current Ad Items (" + (filterComboBox.SelectedItem.ToString() == "All" ? "No Filter" : @"Filter " + filterComboBox.SelectedItem) + @"):";
|
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();
|
adItemsListView.Items.Clear();
|
||||||
var db = new AdvertisingProfitControlDbContext();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var adItems = db.AdItems.Select(x => x);
|
var adItems = db.AdItems.Select(x => x);
|
||||||
foreach (var adItem in adItems)
|
foreach (var adItem in adItems)
|
||||||
{
|
{
|
||||||
|
if(_replacee != null && _replacee.Name == adItem.Name) continue;
|
||||||
var item = new ListViewItem
|
var item = new ListViewItem
|
||||||
{
|
{
|
||||||
Text = adItem.Name,
|
Text = adItem.Name,
|
||||||
@@ -56,21 +68,33 @@ namespace AdvertsingProfitControl
|
|||||||
{ adItemsListView.Items.Add(item);}
|
{ adItemsListView.Items.Add(item);}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!_replaceingReference)
|
||||||
|
{
|
||||||
newItemTextBox.Text = string.Empty;
|
newItemTextBox.Text = string.Empty;
|
||||||
descriptionTextBox.Text = string.Empty;
|
descriptionTextBox.Text = string.Empty;
|
||||||
removeAdItemButton.Enabled = false;
|
removeAdItemButton.Enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateAdItemTextFields(object sender, ListViewItemSelectionChangedEventArgs e)
|
private void UpdateAdItemTextFields(object sender, ListViewItemSelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
newItemTextBox.Text = ((AdItem)e.Item.Tag).Name;
|
|
||||||
descriptionTextBox.Text = ((AdItem)e.Item.Tag).Description;
|
|
||||||
_isUpdating = true;
|
_isUpdating = true;
|
||||||
removeAdItemButton.Enabled = true;
|
removeAdItemButton.Enabled = true;
|
||||||
|
if (!_replaceingReference)
|
||||||
|
{
|
||||||
|
newItemTextBox.Text = ((AdItem)e.Item.Tag).Name;
|
||||||
|
descriptionTextBox.Text = ((AdItem)e.Item.Tag).Description;
|
||||||
|
replaceReferencesButton.Enabled = true;
|
||||||
addUpdateItemButton.Text = @"Update Ad Item";
|
addUpdateItemButton.Text = @"Update Ad Item";
|
||||||
newItemLabel.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)
|
private void NewItemTextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@@ -78,8 +102,13 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
_isUpdating = false;
|
_isUpdating = false;
|
||||||
descriptionTextBox.Text = string.Empty;
|
descriptionTextBox.Text = string.Empty;
|
||||||
|
if (!_replaceingReference)
|
||||||
|
{
|
||||||
addUpdateItemButton.Text = @"Register Ad Item";
|
addUpdateItemButton.Text = @"Register Ad Item";
|
||||||
newItemLabel.Text = @"Register New Ad Item:";
|
newItemLabel.Text = @"Register New Ad Item:";
|
||||||
|
removeAdItemButton.Enabled = false;
|
||||||
|
replaceReferencesButton.Enabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
addUpdateItemButton.Enabled = newItemTextBox.Text.Length > 0;
|
addUpdateItemButton.Enabled = newItemTextBox.Text.Length > 0;
|
||||||
}
|
}
|
||||||
@@ -98,6 +127,7 @@ namespace AdvertsingProfitControl
|
|||||||
var numberFound = false;
|
var numberFound = false;
|
||||||
foreach (var adItem in adItems)
|
foreach (var adItem in adItems)
|
||||||
{
|
{
|
||||||
|
if(_replacee != null && _replacee.Name == adItem.Name) continue;
|
||||||
var item = new ListViewItem
|
var item = new ListViewItem
|
||||||
{
|
{
|
||||||
Text = adItem.Name,
|
Text = adItem.Name,
|
||||||
@@ -107,7 +137,7 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
adItemsListView.Items.Add(item);
|
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);
|
adItemsListView.Items.Add(item);
|
||||||
}
|
}
|
||||||
@@ -143,20 +173,28 @@ namespace AdvertsingProfitControl
|
|||||||
filterComboBox.Enabled = false;
|
filterComboBox.Enabled = false;
|
||||||
filterComboBox.SelectedIndex = 0;
|
filterComboBox.SelectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
if (!_replaceingReference)
|
||||||
|
{
|
||||||
removeAdItemButton.Enabled = false;
|
removeAdItemButton.Enabled = false;
|
||||||
newItemTextBox.Text = string.Empty;
|
newItemTextBox.Text = string.Empty;
|
||||||
descriptionTextBox.Text = string.Empty;
|
descriptionTextBox.Text = string.Empty;
|
||||||
|
}
|
||||||
filterComboBox.SelectedIndexChanged += FilterValueChanged;
|
filterComboBox.SelectedIndexChanged += FilterValueChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveSelectedAdItem(object sender, EventArgs e)
|
private void RemoveSelectedAdItem(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (_replaceingReference)
|
||||||
|
{
|
||||||
|
SetFormStateAdNewItem();
|
||||||
|
return;
|
||||||
|
}
|
||||||
var item = adItemsListView.SelectedItems[0];
|
var item = adItemsListView.SelectedItems[0];
|
||||||
var oldAdItem = (AdItem)item.Tag;
|
var oldAdItem = (AdItem)item.Tag;
|
||||||
var db = new AdvertisingProfitControlDbContext();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var adItemEntry = db.AdItems.Single(x => x.Id == oldAdItem.Id);
|
var adItemEntry = db.AdItems.Single(x => x.Id == oldAdItem.Id);
|
||||||
//Check to see if the ad special is used by other tables.
|
//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.
|
//If so, display a warning to the user about the potential data loss.
|
||||||
var result =
|
var result =
|
||||||
@@ -211,6 +249,7 @@ namespace AdvertsingProfitControl
|
|||||||
var db = new AdvertisingProfitControlDbContext();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
if (!_isUpdating)
|
if (!_isUpdating)
|
||||||
{
|
{
|
||||||
|
newItemTextBox.Text = TextFormat.FormatAdItemText(newItemTextBox.Text);
|
||||||
if (!db.AdItems.Any(x => x.Name == newItemTextBox.Text))
|
if (!db.AdItems.Any(x => x.Name == newItemTextBox.Text))
|
||||||
{
|
{
|
||||||
var adItem = new AdItem
|
var adItem = new AdItem
|
||||||
@@ -235,10 +274,16 @@ namespace AdvertsingProfitControl
|
|||||||
MessageBox.Show(@"Ad item '" + newItemTextBox.Text + @"' already exists.",
|
MessageBox.Show(@"Ad item '" + newItemTextBox.Text + @"' already exists.",
|
||||||
@"Duplicate Entry", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
@"Duplicate Entry", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||||
newItemTextBox.Text = string.Empty;
|
newItemTextBox.Text = string.Empty;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (_replaceingReference)
|
||||||
|
{
|
||||||
|
PerformReplacement();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
newItemTextBox.Text = TextFormat.FormatAdItemText(newItemTextBox.Text);
|
||||||
var item = adItemsListView.SelectedItems[0];
|
var item = adItemsListView.SelectedItems[0];
|
||||||
var index = ((AdItem)item.Tag).Id;
|
var index = ((AdItem)item.Tag).Id;
|
||||||
var adItem = db.AdItems.SingleOrDefault(x => x.Id == index);
|
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.";
|
informationLabel.Text = @"Failed to retrieve " + Environment.NewLine + @"ad item ID.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!db.AdItems.Any(x => x.Name == newItemTextBox.Text))
|
||||||
|
{
|
||||||
adItem.Name = newItemTextBox.Text;
|
adItem.Name = newItemTextBox.Text;
|
||||||
adItem.Description = descriptionTextBox.Text;
|
adItem.Description = descriptionTextBox.Text;
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
informationLabel.Text = @"Updated '" + Environment.NewLine + newItemTextBox.Text + Environment.NewLine + @"' successfully.";
|
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());
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace AdvertsingProfitControl
|
|||||||
}
|
}
|
||||||
using (
|
using (
|
||||||
var file =
|
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);
|
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.",
|
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);
|
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);
|
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.",
|
MessageBox.Show(@"And unknown error has occurred. Advertising Profit Control will be forced to exit.",
|
||||||
|
|||||||
@@ -118,7 +118,6 @@
|
|||||||
<Component Id="wkhtmltox0">
|
<Component Id="wkhtmltox0">
|
||||||
<File Source="$(var.SolutionDir)AdvertsingProfitControl\wkhtmltox0.dll"/>
|
<File Source="$(var.SolutionDir)AdvertsingProfitControl\wkhtmltox0.dll"/>
|
||||||
</Component>
|
</Component>
|
||||||
|
|
||||||
<Component Id="Spire">
|
<Component Id="Spire">
|
||||||
<File Source="$(var.SolutionDir)\packages\FreeSpire.PDF.3.2\lib\net40\Spire.License.dll"/>
|
<File Source="$(var.SolutionDir)\packages\FreeSpire.PDF.3.2\lib\net40\Spire.License.dll"/>
|
||||||
</Component>
|
</Component>
|
||||||
@@ -138,6 +137,9 @@
|
|||||||
</Component>
|
</Component>
|
||||||
<Component Id="ApcData">
|
<Component Id="ApcData">
|
||||||
<File Source="$(var.SolutionDir)\AdvertisingProfitControlData\bin\Debug\AdvertisingProfitControlData.dll"/>
|
<File Source="$(var.SolutionDir)\AdvertisingProfitControlData\bin\Debug\AdvertisingProfitControlData.dll"/>
|
||||||
|
</Component>
|
||||||
|
<Component Id="TableParsingEngine">
|
||||||
|
<File Source="$(var.SolutionDir)\DataTableParsingEngine\bin\Debug\DataTableParsingEngine.dll"/>
|
||||||
</Component>
|
</Component>
|
||||||
</ComponentGroup>
|
</ComponentGroup>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
|||||||
Reference in New Issue
Block a user