Updated the main form's tools to include an option to delete the entire active year. Tweaked the ListViews in the three tool forms to disallow multi-select and made a slight change to the behavior of the filter combo box.

This commit is contained in:
2017-04-12 03:36:05 -05:00
parent 932ee01bf3
commit 3567727caa
8 changed files with 189 additions and 20 deletions
-1
View File
@@ -15,7 +15,6 @@
</providers> </providers>
</entityFramework> </entityFramework>
<connectionStrings> <connectionStrings>
<add name="AdvertisingProfitControlContext" connectionString="data source=(LocalDb)\MSSQLLocalDB;initial catalog=AdvertisingProfitControl;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
<add name="AdvertisingProfitControlDbContext" connectionString="data source=(LocalDb)\MSSQLLocalDB;initial catalog=AdvertisingProfitControl;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" /> <add name="AdvertisingProfitControlDbContext" connectionString="data source=(LocalDb)\MSSQLLocalDB;initial catalog=AdvertisingProfitControl;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
</connectionStrings> </connectionStrings>
</configuration> </configuration>
+10 -10
View File
@@ -40,7 +40,7 @@
this.toolsMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.toolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.clearRecordToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.clearRecordToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.clearCurrentRecordSelectedDateToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.clearCurrentRecordSelectedDateToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.selectRangeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.clearCurrentActiveYearTools = new System.Windows.Forms.ToolStripMenuItem();
this.manageItemsToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.manageItemsToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.manageSuppliersToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.manageSuppliersToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.adSpecialKeyWordsToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.adSpecialKeyWordsToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
@@ -220,7 +220,7 @@
// //
this.clearRecordToolsMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.clearRecordToolsMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.clearCurrentRecordSelectedDateToolsMainMenu, this.clearCurrentRecordSelectedDateToolsMainMenu,
this.selectRangeToolStripMenuItem}); this.clearCurrentActiveYearTools});
this.clearRecordToolsMainMenu.Name = "clearRecordToolsMainMenu"; this.clearRecordToolsMainMenu.Name = "clearRecordToolsMainMenu";
this.clearRecordToolsMainMenu.Size = new System.Drawing.Size(282, 34); this.clearRecordToolsMainMenu.Size = new System.Drawing.Size(282, 34);
this.clearRecordToolsMainMenu.Text = "&Clear Record(s)"; this.clearRecordToolsMainMenu.Text = "&Clear Record(s)";
@@ -228,16 +228,16 @@
// clearCurrentRecordSelectedDateToolsMainMenu // clearCurrentRecordSelectedDateToolsMainMenu
// //
this.clearCurrentRecordSelectedDateToolsMainMenu.Name = "clearCurrentRecordSelectedDateToolsMainMenu"; this.clearCurrentRecordSelectedDateToolsMainMenu.Name = "clearCurrentRecordSelectedDateToolsMainMenu";
this.clearCurrentRecordSelectedDateToolsMainMenu.Size = new System.Drawing.Size(244, 34); this.clearCurrentRecordSelectedDateToolsMainMenu.Size = new System.Drawing.Size(272, 34);
this.clearCurrentRecordSelectedDateToolsMainMenu.Text = "C&urrent Record"; this.clearCurrentRecordSelectedDateToolsMainMenu.Text = "C&urrent Record";
this.clearCurrentRecordSelectedDateToolsMainMenu.Click += new System.EventHandler(this.ClearCurrentRecord); this.clearCurrentRecordSelectedDateToolsMainMenu.Click += new System.EventHandler(this.ClearCurrentRecord);
// //
// selectRangeToolStripMenuItem // clearCurrentActiveYearTools
// //
this.selectRangeToolStripMenuItem.Name = "selectRangeToolStripMenuItem"; this.clearCurrentActiveYearTools.Name = "clearCurrentActiveYearTools";
this.selectRangeToolStripMenuItem.Size = new System.Drawing.Size(244, 34); this.clearCurrentActiveYearTools.Size = new System.Drawing.Size(272, 34);
this.selectRangeToolStripMenuItem.Text = "Select Ran&ge..."; this.clearCurrentActiveYearTools.Text = "Clear Current &Year";
this.selectRangeToolStripMenuItem.Click += new System.EventHandler(this.DisplayRecordDeletionRangeForm); this.clearCurrentActiveYearTools.Click += new System.EventHandler(this.ClearActiveDateYearRecords);
// //
// manageItemsToolsMainMenu // manageItemsToolsMainMenu
// //
@@ -249,7 +249,7 @@
// manageSuppliersToolsMainMenu // manageSuppliersToolsMainMenu
// //
this.manageSuppliersToolsMainMenu.Name = "manageSuppliersToolsMainMenu"; this.manageSuppliersToolsMainMenu.Name = "manageSuppliersToolsMainMenu";
this.manageSuppliersToolsMainMenu.Size = new System.Drawing.Size(286, 34); this.manageSuppliersToolsMainMenu.Size = new System.Drawing.Size(282, 34);
this.manageSuppliersToolsMainMenu.Text = "Manage &Suppliers"; this.manageSuppliersToolsMainMenu.Text = "Manage &Suppliers";
this.manageSuppliersToolsMainMenu.Click += new System.EventHandler(this.manageSuppliersToolsMainMenu_Click); this.manageSuppliersToolsMainMenu.Click += new System.EventHandler(this.manageSuppliersToolsMainMenu_Click);
// //
@@ -1105,7 +1105,7 @@
private System.Windows.Forms.ToolStripMenuItem reportsMainMenu; private System.Windows.Forms.ToolStripMenuItem reportsMainMenu;
private System.Windows.Forms.ToolStripMenuItem manageSuppliersToolsMainMenu; private System.Windows.Forms.ToolStripMenuItem manageSuppliersToolsMainMenu;
private System.Windows.Forms.ToolStripMenuItem clearCurrentRecordSelectedDateToolsMainMenu; private System.Windows.Forms.ToolStripMenuItem clearCurrentRecordSelectedDateToolsMainMenu;
private System.Windows.Forms.ToolStripMenuItem selectRangeToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem clearCurrentActiveYearTools;
} }
} }
+170 -5
View File
@@ -1,4 +1,5 @@
using System; using System;
using System.Data.Entity.Core;
using System.Data.Entity.Infrastructure; using System.Data.Entity.Infrastructure;
using System.Drawing; using System.Drawing;
using System.Drawing.Printing; using System.Drawing.Printing;
@@ -231,11 +232,6 @@ namespace AdvertsingProfitControl
} }
} }
private void DisplayRecordDeletionRangeForm(object sender, EventArgs e)
{
//TODO: Create a form to allow the user to delete a range of dates.
}
private void DisplayAdItemManager(object sender, EventArgs e) private void DisplayAdItemManager(object sender, EventArgs e)
{ {
var adItemManager = new FrmManageAdItems(); var adItemManager = new FrmManageAdItems();
@@ -884,6 +880,8 @@ namespace AdvertsingProfitControl
modifyRecordMainMenu.ToolTipText = string.Empty; modifyRecordMainMenu.ToolTipText = string.Empty;
clearCurrentRecordSelectedDateToolsMainMenu.Enabled = true; clearCurrentRecordSelectedDateToolsMainMenu.Enabled = true;
clearCurrentRecordSelectedDateToolsMainMenu.ToolTipText = string.Empty; clearCurrentRecordSelectedDateToolsMainMenu.ToolTipText = string.Empty;
clearCurrentActiveYearTools.Enabled = true;
clearCurrentActiveYearTools.ToolTipText = string.Empty;
} }
else else
{ {
@@ -892,6 +890,8 @@ namespace AdvertsingProfitControl
modifyRecordMainMenu.ToolTipText = @"There are no records to modify."; modifyRecordMainMenu.ToolTipText = @"There are no records to modify.";
clearCurrentRecordSelectedDateToolsMainMenu.Enabled = false; clearCurrentRecordSelectedDateToolsMainMenu.Enabled = false;
clearCurrentRecordSelectedDateToolsMainMenu.ToolTipText = @"There is no date to clear."; clearCurrentRecordSelectedDateToolsMainMenu.ToolTipText = @"There is no date to clear.";
clearCurrentActiveYearTools.Enabled = false;
clearCurrentActiveYearTools.ToolTipText = @"There are no records to clear.";
} }
} }
@@ -928,5 +928,170 @@ namespace AdvertsingProfitControl
} }
#endregion #endregion
private void ClearActiveDateYearRecords(object sender, EventArgs e)
{
var result = MessageBox.Show(@"Are you sure you want to remove all records for the year of " + _currentActiveDate.Year + @"? This cannot be undone!", @"Clear " + _currentActiveDate.Year + @"'s Records", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
if (result != DialogResult.Yes) return;
var db = new AdvertisingProfitControlModel();
var distinctYears = db.WeekEndingDates.Select(x => x.EndingDate.Year).Distinct().ToArray();
if (distinctYears.Length == 1)
{
result = MessageBox.Show(_currentActiveDate.Year + @" appears to be the only year, clearing it will wipe all data in the database. Are you sure you wish to continue?", @"Clear " + _currentActiveDate.Year + @"'s Records", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
if (result != DialogResult.Yes) return;
}
if (ClearSelectedDate(_currentActiveDate.Year))
{
RefreshDateListing();
}
else
{
MessageBox.Show(@"Failed to clear the records for " + _currentActiveDate.Year + @".", @"Update Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#region Writing Operations
private bool ClearSelectedDate(int year)
{
var db = new AdvertisingProfitControlModel();
var status = true;
using (var scope = new TransactionScope())
{
try
{
var dateRecords = db.WeekEndingDates.Select(x => x).Where(x => x.EndingDate.Year == year).ToArray();
foreach (var dateRecord in dateRecords)
{
ClearProjectionRecords(dateRecord);
ClearInventoyRecords(dateRecord);
ClearActualSalesRecords(dateRecord);
ClearInvoices(dateRecord);
ClearWeeklySales(dateRecord);
ClearTaxableRecords(dateRecord);
ClearCostAnalysisRecords(dateRecord);
ClearCommentsRecords(dateRecord);
db.WeekEndingDates.Remove(dateRecord);
}
db.SaveChanges();
scope.Complete();
}
catch (DbUpdateException e)
{
_console.WriteToLog(FrmLogConsole.Level.Error, e.Message);
status = false;
}
}
return status;
}
private void ClearProjectionRecords(WeekEndingDate dateRecord)
{
var db = new AdvertisingProfitControlModel();
using (var scope = new TransactionScope())
{
var projections = db.Projections.Select(x => x).Where(x => x.FkDateId == dateRecord.Id);
db.Projections.RemoveRange(projections);
db.SaveChanges();
scope.Complete();
}
}
private void ClearInventoyRecords(WeekEndingDate dateRecord)
{
var db = new AdvertisingProfitControlModel();
using (var scope = new TransactionScope())
{
var inventories = db.Inventories.Select(x => x).Where(x => x.FkDateId == dateRecord.Id);
db.Inventories.RemoveRange(inventories);
db.SaveChanges();
scope.Complete();
}
}
private void ClearActualSalesRecords(WeekEndingDate dateRecord)
{
var db = new AdvertisingProfitControlModel();
using (var scope = new TransactionScope())
{
var actualSales = db.ActualSales.Select(x => x).Where(x => x.FkDateId == dateRecord.Id);
db.ActualSales.RemoveRange(actualSales);
db.SaveChanges();
scope.Complete();
}
}
private void ClearInvoices(WeekEndingDate dateRecord)
{
var db = new AdvertisingProfitControlModel();
using (var scope = new TransactionScope())
{
var invoices = db.Invoices.Select(x => x).Where(x => x.FkDateId == dateRecord.Id);
db.Invoices.RemoveRange(invoices);
db.SaveChanges();
scope.Complete();
}
}
private void ClearWeeklySales(WeekEndingDate dateRecord)
{
var db = new AdvertisingProfitControlModel();
using (var scope = new TransactionScope())
{
var weeklySales = db.WeeklySales.Select(x => x).Where(x => x.FkDateId == dateRecord.Id);
db.WeeklySales.RemoveRange(weeklySales);
db.SaveChanges();
scope.Complete();
}
}
private void ClearTaxableRecords(WeekEndingDate dateRecord)
{
var db = new AdvertisingProfitControlModel();
using (var scope = new TransactionScope())
{
var taxables = db.Taxables.Select(x => x).Where(x => x.FkDateId == dateRecord.Id);
db.Taxables.RemoveRange(taxables);
db.SaveChanges();
scope.Complete();
}
}
private void ClearCostAnalysisRecords(WeekEndingDate dateRecord)
{
var db = new AdvertisingProfitControlModel();
using (var scope = new TransactionScope())
{
var costAnalysis = db.CostAnalysis.Select(x => x).Where(x => x.FkDateId == dateRecord.Id);
db.CostAnalysis.RemoveRange(costAnalysis);
db.SaveChanges();
scope.Complete();
}
}
private void ClearCommentsRecords(WeekEndingDate dateRecord)
{
var db = new AdvertisingProfitControlModel();
using (var scope = new TransactionScope())
{
var comments = db.Notes.Select(x => x).Where(x => x.FkDateId == dateRecord.Id);
db.Notes.RemoveRange(comments);
db.SaveChanges();
scope.Complete();
}
}
#endregion
} }
} }
+1
View File
@@ -44,6 +44,7 @@
// adItemsListView // adItemsListView
// //
this.adItemsListView.Location = new System.Drawing.Point(258, 12); this.adItemsListView.Location = new System.Drawing.Point(258, 12);
this.adItemsListView.MultiSelect = false;
this.adItemsListView.Name = "adItemsListView"; this.adItemsListView.Name = "adItemsListView";
this.adItemsListView.Size = new System.Drawing.Size(452, 431); this.adItemsListView.Size = new System.Drawing.Size(452, 431);
this.adItemsListView.TabIndex = 3; this.adItemsListView.TabIndex = 3;
@@ -139,6 +139,7 @@ namespace AdvertsingProfitControl
else else
{ {
adItemsListView.Columns[0].Text = @"No Ad Items to Display."; adItemsListView.Columns[0].Text = @"No Ad Items to Display.";
filterComboBox.Enabled = false;
filterComboBox.SelectedIndex = 0; filterComboBox.SelectedIndex = 0;
} }
removeAdItemButton.Enabled = false; removeAdItemButton.Enabled = false;
+1
View File
@@ -43,6 +43,7 @@
// //
this.suppliersListBox.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; this.suppliersListBox.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.suppliersListBox.Location = new System.Drawing.Point(257, 12); this.suppliersListBox.Location = new System.Drawing.Point(257, 12);
this.suppliersListBox.MultiSelect = false;
this.suppliersListBox.Name = "suppliersListBox"; this.suppliersListBox.Name = "suppliersListBox";
this.suppliersListBox.Size = new System.Drawing.Size(423, 412); this.suppliersListBox.Size = new System.Drawing.Size(423, 412);
this.suppliersListBox.TabIndex = 16; this.suppliersListBox.TabIndex = 16;
@@ -107,6 +107,7 @@
// //
this.adSpecialsListBox.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; this.adSpecialsListBox.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.adSpecialsListBox.Location = new System.Drawing.Point(260, 21); this.adSpecialsListBox.Location = new System.Drawing.Point(260, 21);
this.adSpecialsListBox.MultiSelect = false;
this.adSpecialsListBox.Name = "adSpecialsListBox"; this.adSpecialsListBox.Name = "adSpecialsListBox";
this.adSpecialsListBox.Size = new System.Drawing.Size(420, 401); this.adSpecialsListBox.Size = new System.Drawing.Size(420, 401);
this.adSpecialsListBox.TabIndex = 8; this.adSpecialsListBox.TabIndex = 8;
+2 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Advertising Profit Control" Language="1033" Version="0.1.0.0" Manufacturer="Garritt McCune" UpgradeCode="a416a558-d7c0-4f24-8b1e-2d01761ad15f"> <Product Id="*" Name="Advertising Profit Control" Language="1033" Version="0.1.0.0" Manufacturer="Garritt McCune" UpgradeCode="a416a558-d7c0-4f24-8b1e-2d01761ad15f">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="Custom Profit Control Recording Software" Comments="Profit Control Recording Software"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<!--Not set by default, EmbedCab="yes" embeds the cabinet file into the installer--> <!--Not set by default, EmbedCab="yes" embeds the cabinet file into the installer-->
<MediaTemplate EmbedCab="yes"/> <MediaTemplate EmbedCab="yes"/>
@@ -12,6 +12,7 @@
<!--There are no select features options with this install dialog.--> <!--There are no select features options with this install dialog.-->
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" /> <Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<UIRef Id="WixUI_InstallDir" /> <UIRef Id="WixUI_InstallDir" />
<!--Define the icons used in the installer dialogs-->
<WixVariable Id="WixUILicenseRtf" Value="License.rtf" /> <WixVariable Id="WixUILicenseRtf" Value="License.rtf" />
<WixVariable Id="WixUIBannerBmp" Value="Banner.bmp" /> <WixVariable Id="WixUIBannerBmp" Value="Banner.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="Dialog.bmp" /> <WixVariable Id="WixUIDialogBmp" Value="Dialog.bmp" />