Implemented database backups and restores into the AdvertisingProfitControlData DLL and added a form, DatabaseRecovery, to manage the backups and restores. Updated the installer to include the data DLL file into the install bundle.
This commit is contained in:
@@ -49,13 +49,15 @@
|
|||||||
<Compile Include="ActualSale.cs" />
|
<Compile Include="ActualSale.cs" />
|
||||||
<Compile Include="AdItem.cs" />
|
<Compile Include="AdItem.cs" />
|
||||||
<Compile Include="AdSpecial.cs" />
|
<Compile Include="AdSpecial.cs" />
|
||||||
<Compile Include="AdvertisingProfitControlModel.cs" />
|
<Compile Include="AdvertisingProfitControlDbContext.cs" />
|
||||||
|
<Compile Include="Backup.cs" />
|
||||||
<Compile Include="CostAnaylsi.cs" />
|
<Compile Include="CostAnaylsi.cs" />
|
||||||
<Compile Include="Inventory.cs" />
|
<Compile Include="Inventory.cs" />
|
||||||
<Compile Include="Invoice.cs" />
|
<Compile Include="Invoice.cs" />
|
||||||
<Compile Include="Note.cs" />
|
<Compile Include="Note.cs" />
|
||||||
<Compile Include="Projection.cs" />
|
<Compile Include="Projection.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Restore.cs" />
|
||||||
<Compile Include="Supplier.cs" />
|
<Compile Include="Supplier.cs" />
|
||||||
<Compile Include="Taxable.cs" />
|
<Compile Include="Taxable.cs" />
|
||||||
<Compile Include="Version.cs" />
|
<Compile Include="Version.cs" />
|
||||||
|
|||||||
+7
-7
@@ -3,24 +3,24 @@ using System.Data.Entity;
|
|||||||
|
|
||||||
namespace AdvertisingProfitControlData
|
namespace AdvertisingProfitControlData
|
||||||
{
|
{
|
||||||
public class AdvertisingProfitControlModel : DbContext
|
public class AdvertisingProfitControlDbContext : DbContext
|
||||||
{
|
{
|
||||||
private static string _connectionString = string.Empty;
|
internal static string ConnectionString = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes and stores the supplied connection string. This allows calls to
|
/// Initializes and stores the supplied connection string. This allows calls to
|
||||||
/// an overloaded constructor to take no parameters.
|
/// an overloaded constructor to take no parameters.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="connectionString">The connection string for the database.</param>
|
/// <param name="connectionString">The connection string for the database.</param>
|
||||||
public AdvertisingProfitControlModel(string connectionString) : base(connectionString)
|
public AdvertisingProfitControlDbContext(string connectionString) : base(connectionString)
|
||||||
{
|
{
|
||||||
_connectionString = connectionString;
|
ConnectionString = connectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the database context using a previously initialized connection string.
|
/// Creates the database context using a previously initialized connection string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AdvertisingProfitControlModel()
|
public AdvertisingProfitControlDbContext()
|
||||||
: base(ValidateConnectionString())
|
: base(ValidateConnectionString())
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -32,12 +32,12 @@ namespace AdvertisingProfitControlData
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static string ValidateConnectionString()
|
private static string ValidateConnectionString()
|
||||||
{
|
{
|
||||||
if (_connectionString == string.Empty)
|
if (ConnectionString == string.Empty)
|
||||||
{
|
{
|
||||||
throw new OperationCanceledException("A connection string must be specified.");
|
throw new OperationCanceledException("A connection string must be specified.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return _connectionString;
|
return ConnectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual DbSet<ActualSale> ActualSales { get; set; }
|
public virtual DbSet<ActualSale> ActualSales { get; set; }
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace AdvertisingProfitControlData
|
||||||
|
{
|
||||||
|
public class Backup
|
||||||
|
{
|
||||||
|
public static readonly string DefaultBackupLocation = Path.GetPathRoot(Environment.SystemDirectory) + @"Users\" + Environment.UserName + @"\AppData\Local\APC\Backups\";
|
||||||
|
public static readonly string DefaultBackupExtension = "apcdbbak";
|
||||||
|
public string ErrorMessage = string.Empty;
|
||||||
|
|
||||||
|
public bool SingleFileBackup(string optionalBackupFilePath = "")
|
||||||
|
{
|
||||||
|
var defaultBackupFile = DefaultBackupLocation + DateTime.Now.ToString("yy-MM-dd") + "." + DefaultBackupExtension;
|
||||||
|
var sqlConStrBuilder = new SqlConnectionStringBuilder(AdvertisingProfitControlDbContext.ConnectionString);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var s = new SqlConnection(sqlConStrBuilder.ConnectionString))
|
||||||
|
{
|
||||||
|
var query = $"BACKUP DATABASE {sqlConStrBuilder.InitialCatalog} TO DISK='{defaultBackupFile}'";
|
||||||
|
|
||||||
|
using (var command = new SqlCommand(query, s))
|
||||||
|
{
|
||||||
|
s.Open();
|
||||||
|
command.ExecuteNonQuery();
|
||||||
|
if (optionalBackupFilePath == string.Empty) return true;
|
||||||
|
command.CommandText =
|
||||||
|
$"BACKUP DATABASE {sqlConStrBuilder.InitialCatalog} TO DISK='{optionalBackupFilePath + DateTime.Now.ToString("yy-MM-dd") + "." + DefaultBackupExtension}'";
|
||||||
|
command.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (SqlException e)
|
||||||
|
{
|
||||||
|
ErrorMessage = e.Message;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FileInfo> GetSingleFileBackupFilesList()
|
||||||
|
{
|
||||||
|
var directoryInfo = new DirectoryInfo(DefaultBackupLocation);
|
||||||
|
var files = directoryInfo.GetFiles("*." + DefaultBackupExtension);
|
||||||
|
return files.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
using System.Data.SqlClient;
|
||||||
|
|
||||||
|
namespace AdvertisingProfitControlData
|
||||||
|
{
|
||||||
|
public class Restore
|
||||||
|
{
|
||||||
|
public string ErrorMessage = string.Empty;
|
||||||
|
|
||||||
|
public bool SingleFileRestore(string databaseFilePath)
|
||||||
|
{
|
||||||
|
var sqlConStrBuilder = new SqlConnectionStringBuilder(AdvertisingProfitControlDbContext.ConnectionString);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var conn = new SqlConnection(sqlConStrBuilder.ConnectionString))
|
||||||
|
{
|
||||||
|
var query = $"RESTORE DATABASE {sqlConStrBuilder.InitialCatalog} FROM DISK='{databaseFilePath}'";
|
||||||
|
|
||||||
|
conn.Open();
|
||||||
|
var useMasterCommand = new SqlCommand("USE master", conn);
|
||||||
|
useMasterCommand.ExecuteNonQuery();
|
||||||
|
|
||||||
|
var alter1Cmd = new SqlCommand($"ALTER DATABASE {sqlConStrBuilder.InitialCatalog} SET Single_User WITH Rollback Immediate", conn);
|
||||||
|
alter1Cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
var restoreCmd = new SqlCommand(query, conn);
|
||||||
|
restoreCmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
var alter2Cmd = new SqlCommand($"ALTER DATABASE {sqlConStrBuilder.InitialCatalog} SET Multi_User", conn);
|
||||||
|
alter2Cmd.ExecuteNonQuery();
|
||||||
|
conn.Close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SqlException e)
|
||||||
|
{
|
||||||
|
ErrorMessage = e.Message;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
labelProductVerion.Text = $@"Advertising Profit Control Version: {Assembly.GetEntryAssembly().GetName().Version}";
|
labelProductVerion.Text = $@"Advertising Profit Control Version: {Assembly.GetEntryAssembly().GetName().Version}";
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var version = db.Versions.SingleOrDefault(x => x.Id == 1);
|
var version = db.Versions.SingleOrDefault(x => x.Id == 1);
|
||||||
databaseVersionLabel.Text = version == null ? @"Database Version: N/A" : $@"Database Version: {version.VersionNumber}";
|
databaseVersionLabel.Text = version == null ? @"Database Version: N/A" : $@"Database Version: {version.VersionNumber}";
|
||||||
reportGeneratingVersionLabel.Text = @"Report Generating Engine Version: " + ReportGenerator.Version;
|
reportGeneratingVersionLabel.Text = @"Report Generating Engine Version: " + ReportGenerator.Version;
|
||||||
|
|||||||
@@ -127,6 +127,12 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="AdvertisingProfitControlTableHelper.cs" />
|
<Compile Include="AdvertisingProfitControlTableHelper.cs" />
|
||||||
<Compile Include="ApplicationColors.cs" />
|
<Compile Include="ApplicationColors.cs" />
|
||||||
|
<Compile Include="DatabaseRecovery.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="DatabaseRecovery.Designer.cs">
|
||||||
|
<DependentUpon>DatabaseRecovery.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="FrmChangeShrink.cs">
|
<Compile Include="FrmChangeShrink.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -210,6 +216,9 @@
|
|||||||
<EmbeddedResource Include="AboutBox.resx">
|
<EmbeddedResource Include="AboutBox.resx">
|
||||||
<DependentUpon>AboutBox.cs</DependentUpon>
|
<DependentUpon>AboutBox.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="DatabaseRecovery.resx">
|
||||||
|
<DependentUpon>DatabaseRecovery.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="FrmAddRecord.resx">
|
<EmbeddedResource Include="FrmAddRecord.resx">
|
||||||
<DependentUpon>FrmAddRecord.cs</DependentUpon>
|
<DependentUpon>FrmAddRecord.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace AdvertsingProfitControl
|
|||||||
/// <param name="writer"></param>
|
/// <param name="writer"></param>
|
||||||
private void BuildReportBackPage(DateTime date, ref HtmlTextWriter writer)
|
private void BuildReportBackPage(DateTime date, ref HtmlTextWriter writer)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var dateRecord = db.WeekEndingDates.SingleOrDefault(x => x.EndingDate == date);
|
var dateRecord = db.WeekEndingDates.SingleOrDefault(x => x.EndingDate == date);
|
||||||
var invoices = db.Invoices.Where(x => x.FkDateId == dateRecord.Id).ToList();
|
var invoices = db.Invoices.Where(x => x.FkDateId == dateRecord.Id).ToList();
|
||||||
var weeklySale = db.WeeklySales.SingleOrDefault(x => x.FkDateId == dateRecord.Id);
|
var weeklySale = db.WeeklySales.SingleOrDefault(x => x.FkDateId == dateRecord.Id);
|
||||||
|
|||||||
+338
@@ -0,0 +1,338 @@
|
|||||||
|
namespace AdvertsingProfitControl
|
||||||
|
{
|
||||||
|
partial class DatabaseRecovery
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DatabaseRecovery));
|
||||||
|
this.mainLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
this.backupGroupBox = new System.Windows.Forms.GroupBox();
|
||||||
|
this.backupOptionsPanel = new System.Windows.Forms.Panel();
|
||||||
|
this.backupResultLabel = new System.Windows.Forms.Label();
|
||||||
|
this.backupInformationLabel = new System.Windows.Forms.Label();
|
||||||
|
this.customBackupLocationSelectionButton = new System.Windows.Forms.Button();
|
||||||
|
this.customBackupLocationLabel = new System.Windows.Forms.Label();
|
||||||
|
this.customBackupLocationTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.createBackupButton = new System.Windows.Forms.Button();
|
||||||
|
this.restoreGroupBox = new System.Windows.Forms.GroupBox();
|
||||||
|
this.restoreOptionsPanel = new System.Windows.Forms.Panel();
|
||||||
|
this.restoreResultLabel = new System.Windows.Forms.Label();
|
||||||
|
this.customRestoreLocationSelectionButton = new System.Windows.Forms.Button();
|
||||||
|
this.customRestoreLocationLabel = new System.Windows.Forms.Label();
|
||||||
|
this.restoreLocationTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.restoreInfoLabel = new System.Windows.Forms.Label();
|
||||||
|
this.restoreBackupButton = new System.Windows.Forms.Button();
|
||||||
|
this.existingBackupsGroupBox = new System.Windows.Forms.GroupBox();
|
||||||
|
this.exisitingBackupsListView = new System.Windows.Forms.ListView();
|
||||||
|
this.listViewItemOptionsPanel = new System.Windows.Forms.Panel();
|
||||||
|
this.deleteBackupFileButton = new System.Windows.Forms.Button();
|
||||||
|
this.mainLayoutPanel.SuspendLayout();
|
||||||
|
this.backupGroupBox.SuspendLayout();
|
||||||
|
this.backupOptionsPanel.SuspendLayout();
|
||||||
|
this.restoreGroupBox.SuspendLayout();
|
||||||
|
this.restoreOptionsPanel.SuspendLayout();
|
||||||
|
this.existingBackupsGroupBox.SuspendLayout();
|
||||||
|
this.listViewItemOptionsPanel.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// mainLayoutPanel
|
||||||
|
//
|
||||||
|
this.mainLayoutPanel.ColumnCount = 2;
|
||||||
|
this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||||
|
this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||||
|
this.mainLayoutPanel.Controls.Add(this.backupGroupBox, 0, 0);
|
||||||
|
this.mainLayoutPanel.Controls.Add(this.restoreGroupBox, 0, 2);
|
||||||
|
this.mainLayoutPanel.Controls.Add(this.existingBackupsGroupBox, 1, 0);
|
||||||
|
this.mainLayoutPanel.Controls.Add(this.listViewItemOptionsPanel, 1, 3);
|
||||||
|
this.mainLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.mainLayoutPanel.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.mainLayoutPanel.Name = "mainLayoutPanel";
|
||||||
|
this.mainLayoutPanel.RowCount = 4;
|
||||||
|
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||||
|
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F));
|
||||||
|
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||||
|
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F));
|
||||||
|
this.mainLayoutPanel.Size = new System.Drawing.Size(1048, 598);
|
||||||
|
this.mainLayoutPanel.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// backupGroupBox
|
||||||
|
//
|
||||||
|
this.backupGroupBox.Controls.Add(this.backupOptionsPanel);
|
||||||
|
this.backupGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.backupGroupBox.Location = new System.Drawing.Point(3, 3);
|
||||||
|
this.backupGroupBox.Name = "backupGroupBox";
|
||||||
|
this.mainLayoutPanel.SetRowSpan(this.backupGroupBox, 2);
|
||||||
|
this.backupGroupBox.Size = new System.Drawing.Size(518, 293);
|
||||||
|
this.backupGroupBox.TabIndex = 0;
|
||||||
|
this.backupGroupBox.TabStop = false;
|
||||||
|
this.backupGroupBox.Text = "Backup Options";
|
||||||
|
//
|
||||||
|
// backupOptionsPanel
|
||||||
|
//
|
||||||
|
this.backupOptionsPanel.Controls.Add(this.backupResultLabel);
|
||||||
|
this.backupOptionsPanel.Controls.Add(this.backupInformationLabel);
|
||||||
|
this.backupOptionsPanel.Controls.Add(this.customBackupLocationSelectionButton);
|
||||||
|
this.backupOptionsPanel.Controls.Add(this.customBackupLocationLabel);
|
||||||
|
this.backupOptionsPanel.Controls.Add(this.customBackupLocationTextBox);
|
||||||
|
this.backupOptionsPanel.Controls.Add(this.createBackupButton);
|
||||||
|
this.backupOptionsPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.backupOptionsPanel.Location = new System.Drawing.Point(3, 25);
|
||||||
|
this.backupOptionsPanel.Name = "backupOptionsPanel";
|
||||||
|
this.backupOptionsPanel.Size = new System.Drawing.Size(512, 265);
|
||||||
|
this.backupOptionsPanel.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// backupResultLabel
|
||||||
|
//
|
||||||
|
this.backupResultLabel.AutoSize = true;
|
||||||
|
this.backupResultLabel.Location = new System.Drawing.Point(10, 222);
|
||||||
|
this.backupResultLabel.Name = "backupResultLabel";
|
||||||
|
this.backupResultLabel.Size = new System.Drawing.Size(0, 25);
|
||||||
|
this.backupResultLabel.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// backupInformationLabel
|
||||||
|
//
|
||||||
|
this.backupInformationLabel.AutoSize = true;
|
||||||
|
this.backupInformationLabel.Location = new System.Drawing.Point(10, 10);
|
||||||
|
this.backupInformationLabel.Name = "backupInformationLabel";
|
||||||
|
this.backupInformationLabel.Size = new System.Drawing.Size(499, 100);
|
||||||
|
this.backupInformationLabel.TabIndex = 4;
|
||||||
|
this.backupInformationLabel.Text = resources.GetString("backupInformationLabel.Text");
|
||||||
|
//
|
||||||
|
// customBackupLocationSelectionButton
|
||||||
|
//
|
||||||
|
this.customBackupLocationSelectionButton.Location = new System.Drawing.Point(470, 159);
|
||||||
|
this.customBackupLocationSelectionButton.Name = "customBackupLocationSelectionButton";
|
||||||
|
this.customBackupLocationSelectionButton.Size = new System.Drawing.Size(39, 29);
|
||||||
|
this.customBackupLocationSelectionButton.TabIndex = 3;
|
||||||
|
this.customBackupLocationSelectionButton.Text = "...";
|
||||||
|
this.customBackupLocationSelectionButton.UseVisualStyleBackColor = true;
|
||||||
|
this.customBackupLocationSelectionButton.Click += new System.EventHandler(this.UpdateCustomBackupLocationOnBackupLocationButtonClick);
|
||||||
|
//
|
||||||
|
// customBackupLocationLabel
|
||||||
|
//
|
||||||
|
this.customBackupLocationLabel.AutoSize = true;
|
||||||
|
this.customBackupLocationLabel.Location = new System.Drawing.Point(10, 131);
|
||||||
|
this.customBackupLocationLabel.Name = "customBackupLocationLabel";
|
||||||
|
this.customBackupLocationLabel.Size = new System.Drawing.Size(325, 25);
|
||||||
|
this.customBackupLocationLabel.TabIndex = 2;
|
||||||
|
this.customBackupLocationLabel.Text = "(Optional) Specify Backup Location:";
|
||||||
|
//
|
||||||
|
// customBackupLocationTextBox
|
||||||
|
//
|
||||||
|
this.customBackupLocationTextBox.Location = new System.Drawing.Point(15, 159);
|
||||||
|
this.customBackupLocationTextBox.Name = "customBackupLocationTextBox";
|
||||||
|
this.customBackupLocationTextBox.Size = new System.Drawing.Size(452, 29);
|
||||||
|
this.customBackupLocationTextBox.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// createBackupButton
|
||||||
|
//
|
||||||
|
this.createBackupButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.createBackupButton.Location = new System.Drawing.Point(335, 215);
|
||||||
|
this.createBackupButton.Name = "createBackupButton";
|
||||||
|
this.createBackupButton.Size = new System.Drawing.Size(171, 39);
|
||||||
|
this.createBackupButton.TabIndex = 0;
|
||||||
|
this.createBackupButton.Text = "Create Backup";
|
||||||
|
this.createBackupButton.UseVisualStyleBackColor = true;
|
||||||
|
this.createBackupButton.Click += new System.EventHandler(this.CreateBackupOnButtonClick);
|
||||||
|
//
|
||||||
|
// restoreGroupBox
|
||||||
|
//
|
||||||
|
this.restoreGroupBox.Controls.Add(this.restoreOptionsPanel);
|
||||||
|
this.restoreGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.restoreGroupBox.Location = new System.Drawing.Point(3, 302);
|
||||||
|
this.restoreGroupBox.Name = "restoreGroupBox";
|
||||||
|
this.mainLayoutPanel.SetRowSpan(this.restoreGroupBox, 2);
|
||||||
|
this.restoreGroupBox.Size = new System.Drawing.Size(518, 293);
|
||||||
|
this.restoreGroupBox.TabIndex = 1;
|
||||||
|
this.restoreGroupBox.TabStop = false;
|
||||||
|
this.restoreGroupBox.Text = "Restore Options";
|
||||||
|
//
|
||||||
|
// restoreOptionsPanel
|
||||||
|
//
|
||||||
|
this.restoreOptionsPanel.Controls.Add(this.restoreResultLabel);
|
||||||
|
this.restoreOptionsPanel.Controls.Add(this.customRestoreLocationSelectionButton);
|
||||||
|
this.restoreOptionsPanel.Controls.Add(this.customRestoreLocationLabel);
|
||||||
|
this.restoreOptionsPanel.Controls.Add(this.restoreLocationTextBox);
|
||||||
|
this.restoreOptionsPanel.Controls.Add(this.restoreInfoLabel);
|
||||||
|
this.restoreOptionsPanel.Controls.Add(this.restoreBackupButton);
|
||||||
|
this.restoreOptionsPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.restoreOptionsPanel.Location = new System.Drawing.Point(3, 25);
|
||||||
|
this.restoreOptionsPanel.Name = "restoreOptionsPanel";
|
||||||
|
this.restoreOptionsPanel.Size = new System.Drawing.Size(512, 265);
|
||||||
|
this.restoreOptionsPanel.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// restoreResultLabel
|
||||||
|
//
|
||||||
|
this.restoreResultLabel.AutoSize = true;
|
||||||
|
this.restoreResultLabel.Location = new System.Drawing.Point(10, 225);
|
||||||
|
this.restoreResultLabel.Name = "restoreResultLabel";
|
||||||
|
this.restoreResultLabel.Size = new System.Drawing.Size(0, 25);
|
||||||
|
this.restoreResultLabel.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// customRestoreLocationSelectionButton
|
||||||
|
//
|
||||||
|
this.customRestoreLocationSelectionButton.Location = new System.Drawing.Point(465, 159);
|
||||||
|
this.customRestoreLocationSelectionButton.Name = "customRestoreLocationSelectionButton";
|
||||||
|
this.customRestoreLocationSelectionButton.Size = new System.Drawing.Size(39, 29);
|
||||||
|
this.customRestoreLocationSelectionButton.TabIndex = 6;
|
||||||
|
this.customRestoreLocationSelectionButton.Text = "...";
|
||||||
|
this.customRestoreLocationSelectionButton.UseVisualStyleBackColor = true;
|
||||||
|
this.customRestoreLocationSelectionButton.Click += new System.EventHandler(this.UpdateRestoreLocationOnCustomBackupLocationButtonClick);
|
||||||
|
//
|
||||||
|
// customRestoreLocationLabel
|
||||||
|
//
|
||||||
|
this.customRestoreLocationLabel.AutoSize = true;
|
||||||
|
this.customRestoreLocationLabel.Location = new System.Drawing.Point(10, 131);
|
||||||
|
this.customRestoreLocationLabel.Name = "customRestoreLocationLabel";
|
||||||
|
this.customRestoreLocationLabel.Size = new System.Drawing.Size(163, 25);
|
||||||
|
this.customRestoreLocationLabel.TabIndex = 5;
|
||||||
|
this.customRestoreLocationLabel.Text = "Backup Location:";
|
||||||
|
//
|
||||||
|
// restoreLocationTextBox
|
||||||
|
//
|
||||||
|
this.restoreLocationTextBox.Location = new System.Drawing.Point(15, 159);
|
||||||
|
this.restoreLocationTextBox.Name = "restoreLocationTextBox";
|
||||||
|
this.restoreLocationTextBox.Size = new System.Drawing.Size(447, 29);
|
||||||
|
this.restoreLocationTextBox.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// restoreInfoLabel
|
||||||
|
//
|
||||||
|
this.restoreInfoLabel.AutoSize = true;
|
||||||
|
this.restoreInfoLabel.Location = new System.Drawing.Point(15, 4);
|
||||||
|
this.restoreInfoLabel.Name = "restoreInfoLabel";
|
||||||
|
this.restoreInfoLabel.Size = new System.Drawing.Size(426, 100);
|
||||||
|
this.restoreInfoLabel.TabIndex = 1;
|
||||||
|
this.restoreInfoLabel.Text = "To restore the database from a previous backup\r\neither select one from the list t" +
|
||||||
|
"o the right or\r\nspecify a location below if the database backup \r\nis not in a de" +
|
||||||
|
"fault location (like a flashdrive).";
|
||||||
|
//
|
||||||
|
// restoreBackupButton
|
||||||
|
//
|
||||||
|
this.restoreBackupButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.restoreBackupButton.Enabled = false;
|
||||||
|
this.restoreBackupButton.Location = new System.Drawing.Point(338, 220);
|
||||||
|
this.restoreBackupButton.Name = "restoreBackupButton";
|
||||||
|
this.restoreBackupButton.Size = new System.Drawing.Size(168, 35);
|
||||||
|
this.restoreBackupButton.TabIndex = 0;
|
||||||
|
this.restoreBackupButton.Text = "Restore Backup";
|
||||||
|
this.restoreBackupButton.UseVisualStyleBackColor = true;
|
||||||
|
this.restoreBackupButton.Click += new System.EventHandler(this.RestoreSelectedBackupOnBackupRestoreButtonClick);
|
||||||
|
//
|
||||||
|
// existingBackupsGroupBox
|
||||||
|
//
|
||||||
|
this.existingBackupsGroupBox.Controls.Add(this.exisitingBackupsListView);
|
||||||
|
this.existingBackupsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.existingBackupsGroupBox.Location = new System.Drawing.Point(527, 3);
|
||||||
|
this.existingBackupsGroupBox.Name = "existingBackupsGroupBox";
|
||||||
|
this.mainLayoutPanel.SetRowSpan(this.existingBackupsGroupBox, 3);
|
||||||
|
this.existingBackupsGroupBox.Size = new System.Drawing.Size(518, 542);
|
||||||
|
this.existingBackupsGroupBox.TabIndex = 2;
|
||||||
|
this.existingBackupsGroupBox.TabStop = false;
|
||||||
|
this.existingBackupsGroupBox.Text = "Existing Backups";
|
||||||
|
//
|
||||||
|
// exisitingBackupsListView
|
||||||
|
//
|
||||||
|
this.exisitingBackupsListView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.exisitingBackupsListView.Location = new System.Drawing.Point(3, 25);
|
||||||
|
this.exisitingBackupsListView.MultiSelect = false;
|
||||||
|
this.exisitingBackupsListView.Name = "exisitingBackupsListView";
|
||||||
|
this.exisitingBackupsListView.Size = new System.Drawing.Size(512, 514);
|
||||||
|
this.exisitingBackupsListView.TabIndex = 0;
|
||||||
|
this.exisitingBackupsListView.UseCompatibleStateImageBehavior = false;
|
||||||
|
this.exisitingBackupsListView.View = System.Windows.Forms.View.Details;
|
||||||
|
//
|
||||||
|
// listViewItemOptionsPanel
|
||||||
|
//
|
||||||
|
this.listViewItemOptionsPanel.Controls.Add(this.deleteBackupFileButton);
|
||||||
|
this.listViewItemOptionsPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.listViewItemOptionsPanel.Location = new System.Drawing.Point(527, 551);
|
||||||
|
this.listViewItemOptionsPanel.Name = "listViewItemOptionsPanel";
|
||||||
|
this.listViewItemOptionsPanel.Size = new System.Drawing.Size(518, 44);
|
||||||
|
this.listViewItemOptionsPanel.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// deleteBackupFileButton
|
||||||
|
//
|
||||||
|
this.deleteBackupFileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.deleteBackupFileButton.Enabled = false;
|
||||||
|
this.deleteBackupFileButton.Location = new System.Drawing.Point(276, 3);
|
||||||
|
this.deleteBackupFileButton.Name = "deleteBackupFileButton";
|
||||||
|
this.deleteBackupFileButton.Size = new System.Drawing.Size(239, 38);
|
||||||
|
this.deleteBackupFileButton.TabIndex = 0;
|
||||||
|
this.deleteBackupFileButton.Text = "Delete Selected Backup";
|
||||||
|
this.deleteBackupFileButton.UseVisualStyleBackColor = true;
|
||||||
|
this.deleteBackupFileButton.Click += new System.EventHandler(this.deleteBackupFileButton_Click);
|
||||||
|
//
|
||||||
|
// DatabaseRecovery
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(1048, 598);
|
||||||
|
this.Controls.Add(this.mainLayoutPanel);
|
||||||
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
|
||||||
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.Name = "DatabaseRecovery";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "Database Backup and Recovery";
|
||||||
|
this.mainLayoutPanel.ResumeLayout(false);
|
||||||
|
this.backupGroupBox.ResumeLayout(false);
|
||||||
|
this.backupOptionsPanel.ResumeLayout(false);
|
||||||
|
this.backupOptionsPanel.PerformLayout();
|
||||||
|
this.restoreGroupBox.ResumeLayout(false);
|
||||||
|
this.restoreOptionsPanel.ResumeLayout(false);
|
||||||
|
this.restoreOptionsPanel.PerformLayout();
|
||||||
|
this.existingBackupsGroupBox.ResumeLayout(false);
|
||||||
|
this.listViewItemOptionsPanel.ResumeLayout(false);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.TableLayoutPanel mainLayoutPanel;
|
||||||
|
private System.Windows.Forms.GroupBox backupGroupBox;
|
||||||
|
private System.Windows.Forms.GroupBox restoreGroupBox;
|
||||||
|
private System.Windows.Forms.GroupBox existingBackupsGroupBox;
|
||||||
|
private System.Windows.Forms.Panel backupOptionsPanel;
|
||||||
|
private System.Windows.Forms.Button createBackupButton;
|
||||||
|
private System.Windows.Forms.Panel restoreOptionsPanel;
|
||||||
|
private System.Windows.Forms.Button restoreBackupButton;
|
||||||
|
private System.Windows.Forms.Button customBackupLocationSelectionButton;
|
||||||
|
private System.Windows.Forms.Label customBackupLocationLabel;
|
||||||
|
private System.Windows.Forms.TextBox customBackupLocationTextBox;
|
||||||
|
private System.Windows.Forms.Label backupInformationLabel;
|
||||||
|
private System.Windows.Forms.Label backupResultLabel;
|
||||||
|
private System.Windows.Forms.Label restoreInfoLabel;
|
||||||
|
private System.Windows.Forms.Button customRestoreLocationSelectionButton;
|
||||||
|
private System.Windows.Forms.Label customRestoreLocationLabel;
|
||||||
|
private System.Windows.Forms.TextBox restoreLocationTextBox;
|
||||||
|
private System.Windows.Forms.Label restoreResultLabel;
|
||||||
|
private System.Windows.Forms.ListView exisitingBackupsListView;
|
||||||
|
private System.Windows.Forms.Panel listViewItemOptionsPanel;
|
||||||
|
private System.Windows.Forms.Button deleteBackupFileButton;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,176 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using AdvertisingProfitControlData;
|
||||||
|
|
||||||
|
namespace AdvertsingProfitControl
|
||||||
|
{
|
||||||
|
public partial class DatabaseRecovery : Form
|
||||||
|
{
|
||||||
|
public bool RestoredDatabase;
|
||||||
|
|
||||||
|
public DatabaseRecovery()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
exisitingBackupsListView.ItemSelectionChanged += UpdateRestoreLocationTextBoxOnItemSelectionChange;
|
||||||
|
restoreLocationTextBox.TextChanged += UpdateRestoreButtonOnRestoreLocationTextChange;
|
||||||
|
//Grab the list of backups and fill the list box.
|
||||||
|
var headerColumn = new ColumnHeader
|
||||||
|
{
|
||||||
|
Width = exisitingBackupsListView.Width - 10,
|
||||||
|
TextAlign = HorizontalAlignment.Center
|
||||||
|
};
|
||||||
|
exisitingBackupsListView.Columns.Add(headerColumn);
|
||||||
|
UpdateBackupList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateRestoreButtonOnRestoreLocationTextChange(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
restoreBackupButton.Enabled = restoreLocationTextBox.Text.Length != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateRestoreLocationTextBoxOnItemSelectionChange(object sender, ListViewItemSelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
//Update the restore location text box when an item is selected.
|
||||||
|
restoreLocationTextBox.Text = ((FileInfo) e.Item.Tag).FullName;
|
||||||
|
deleteBackupFileButton.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateBackupList()
|
||||||
|
{
|
||||||
|
var backup = new Backup();
|
||||||
|
var fileList = backup.GetSingleFileBackupFilesList();
|
||||||
|
exisitingBackupsListView.Items.Clear();
|
||||||
|
|
||||||
|
if (fileList.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var file in fileList)
|
||||||
|
{
|
||||||
|
var item = new ListViewItem
|
||||||
|
{
|
||||||
|
Text = file.Name,
|
||||||
|
Tag = file
|
||||||
|
};
|
||||||
|
exisitingBackupsListView.Items.Add(item);
|
||||||
|
}
|
||||||
|
exisitingBackupsListView.Columns[0].Text = @"Current Backups";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exisitingBackupsListView.Columns[0].Text = @"No Backups Exist";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateBackupOnButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var backup = new Backup();
|
||||||
|
var customBackupLocation = string.Empty;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(customBackupLocationTextBox.Text))
|
||||||
|
{
|
||||||
|
//Check to see if the folder selected or typed exists.
|
||||||
|
var folder = new DirectoryInfo(customBackupLocationTextBox.Text);
|
||||||
|
|
||||||
|
if (folder.Exists)
|
||||||
|
{
|
||||||
|
customBackupLocation = customBackupLocationTextBox.Text;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
@"The selected backup folder doesn't exist. Please choose a different folder to store the backup.",
|
||||||
|
@"Backup Folder Location Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
backupResultLabel.Text = @"Custom backup location invalid.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (backup.SingleFileBackup(customBackupLocation))
|
||||||
|
{
|
||||||
|
backupResultLabel.Text = @"Successfully created backup(s).";
|
||||||
|
customBackupLocationTextBox.Text = string.Empty;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show(backup.ErrorMessage, @"Failed to Create Backup", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
backupResultLabel.Text = @"Failed to create backup(s).";
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateBackupList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateCustomBackupLocationOnBackupLocationButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var dialog = new FolderBrowserDialog {Description = @"Select a folder to place the backup file into."};
|
||||||
|
dialog.ShowDialog();
|
||||||
|
|
||||||
|
if (dialog.SelectedPath != string.Empty)
|
||||||
|
{
|
||||||
|
customBackupLocationTextBox.Text = dialog.SelectedPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateRestoreLocationOnCustomBackupLocationButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var dialog = new OpenFileDialog
|
||||||
|
{
|
||||||
|
Multiselect = false,
|
||||||
|
Filter = @"Backup Files | *." + Backup.DefaultBackupExtension,
|
||||||
|
Title = @"Select your backup file to restore from."
|
||||||
|
};
|
||||||
|
|
||||||
|
dialog.ShowDialog();
|
||||||
|
|
||||||
|
restoreLocationTextBox.Text = dialog.FileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RestoreSelectedBackupOnBackupRestoreButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var restore = new Restore();
|
||||||
|
//Check for the file's existence before proceeding.
|
||||||
|
if (!File.Exists(restoreLocationTextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show(@"Database backup file could not be found at the location" + Environment.NewLine + @"'" + restoreLocationTextBox.Text + @"'.", @"Database Backup File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
restoreInfoLabel.Text = @"Restore file location invalid.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (restore.SingleFileRestore(restoreLocationTextBox.Text))
|
||||||
|
{
|
||||||
|
restoreResultLabel.Text = @"Successfully restored the database.";
|
||||||
|
restoreLocationTextBox.Text = string.Empty;
|
||||||
|
RestoredDatabase = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show(restore.ErrorMessage, @"Failed to Restore Backup", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
restoreInfoLabel.Text = @"Failed to restore the database.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteBackupFileButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (exisitingBackupsListView.SelectedItems.Count == 0)
|
||||||
|
{
|
||||||
|
deleteBackupFileButton.Enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var selectedItem = exisitingBackupsListView.SelectedItems[0];
|
||||||
|
var fileInfo = (FileInfo) selectedItem.Tag;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(fileInfo.FullName);
|
||||||
|
restoreLocationTextBox.Text = string.Empty;
|
||||||
|
deleteBackupFileButton.Enabled = false;
|
||||||
|
}
|
||||||
|
catch (IOException exception)
|
||||||
|
{
|
||||||
|
MessageBox.Show(exception.Message, @"Failed to Delete File " + fileInfo.Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateBackupList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
|
using System.IO;
|
||||||
|
using System.Security.AccessControl;
|
||||||
|
using System.Security.Principal;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using AdvertisingProfitControlData;
|
using AdvertisingProfitControlData;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
@@ -13,6 +16,19 @@ namespace AdvertsingProfitControl
|
|||||||
public FrmLoginForm()
|
public FrmLoginForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
//Check to see if the backup folder exists.
|
||||||
|
if (!Directory.Exists(Backup.DefaultBackupLocation))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(Backup.DefaultBackupLocation);
|
||||||
|
//Create it and set its permissions so SQL can write to it.
|
||||||
|
//Reference: https://stackoverflow.com/questions/5298905/add-everyone-privilege-to-folder-using-c-net
|
||||||
|
var sec = Directory.GetAccessControl(Backup.DefaultBackupLocation);
|
||||||
|
// Using this instead of the "Everyone" string means we work on non-English systems.
|
||||||
|
var everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
|
||||||
|
sec.AddAccessRule(new FileSystemAccessRule(everyone, FileSystemRights.Modify | FileSystemRights.Synchronize, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
|
||||||
|
Directory.SetAccessControl(Backup.DefaultBackupLocation, sec);
|
||||||
|
}
|
||||||
|
//Scan the registry for SQL server instances (not the recommended way).
|
||||||
var registryView = Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32;
|
var registryView = Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32;
|
||||||
using (var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, registryView))
|
using (var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, registryView))
|
||||||
{
|
{
|
||||||
@@ -57,7 +73,7 @@ namespace AdvertsingProfitControl
|
|||||||
}
|
}
|
||||||
ConnectionSuccessful = true;
|
ConnectionSuccessful = true;
|
||||||
//Try to initialize the database.
|
//Try to initialize the database.
|
||||||
var db = new AdvertisingProfitControlModel(connectionString);
|
var db = new AdvertisingProfitControlDbContext(connectionString);
|
||||||
//Force the UI thread to draw the label's text so the user can see it.
|
//Force the UI thread to draw the label's text so the user can see it.
|
||||||
informationLabel.Text = @"Connection successful! Preparing main form...";
|
informationLabel.Text = @"Connection successful! Preparing main form...";
|
||||||
informationLabel.Invalidate();
|
informationLabel.Invalidate();
|
||||||
|
|||||||
+17
-7
@@ -37,6 +37,7 @@
|
|||||||
this.addRecordsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.addRecordsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.modifyRecordMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
this.modifyRecordMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.reportsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
this.reportsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.generateReportMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
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();
|
||||||
@@ -111,7 +112,7 @@
|
|||||||
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel = new System.Windows.Forms.Label();
|
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel = new System.Windows.Forms.Label();
|
||||||
this.perfectGrossProfitLabel = new System.Windows.Forms.Label();
|
this.perfectGrossProfitLabel = new System.Windows.Forms.Label();
|
||||||
this.grossProfitDollarGrossProfitLabel = new System.Windows.Forms.Label();
|
this.grossProfitDollarGrossProfitLabel = new System.Windows.Forms.Label();
|
||||||
this.generateReportMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.backupRestoreToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.mainMenu.SuspendLayout();
|
this.mainMenu.SuspendLayout();
|
||||||
this.mainTableLayoutPanel.SuspendLayout();
|
this.mainTableLayoutPanel.SuspendLayout();
|
||||||
this.commentMainTableLayoutPanel.SuspendLayout();
|
this.commentMainTableLayoutPanel.SuspendLayout();
|
||||||
@@ -176,7 +177,7 @@
|
|||||||
// exitFileMainMenu
|
// exitFileMainMenu
|
||||||
//
|
//
|
||||||
this.exitFileMainMenu.Name = "exitFileMainMenu";
|
this.exitFileMainMenu.Name = "exitFileMainMenu";
|
||||||
this.exitFileMainMenu.Size = new System.Drawing.Size(138, 34);
|
this.exitFileMainMenu.Size = new System.Drawing.Size(240, 34);
|
||||||
this.exitFileMainMenu.Text = "E&xit";
|
this.exitFileMainMenu.Text = "E&xit";
|
||||||
this.exitFileMainMenu.Click += new System.EventHandler(this.ExitProgram);
|
this.exitFileMainMenu.Click += new System.EventHandler(this.ExitProgram);
|
||||||
//
|
//
|
||||||
@@ -212,6 +213,13 @@
|
|||||||
this.reportsMainMenu.Size = new System.Drawing.Size(95, 34);
|
this.reportsMainMenu.Size = new System.Drawing.Size(95, 34);
|
||||||
this.reportsMainMenu.Text = "R&eports";
|
this.reportsMainMenu.Text = "R&eports";
|
||||||
//
|
//
|
||||||
|
// generateReportMenuItem
|
||||||
|
//
|
||||||
|
this.generateReportMenuItem.Name = "generateReportMenuItem";
|
||||||
|
this.generateReportMenuItem.Size = new System.Drawing.Size(256, 34);
|
||||||
|
this.generateReportMenuItem.Text = "&Generate Report";
|
||||||
|
this.generateReportMenuItem.Click += new System.EventHandler(this.GenerateReportMenuItemClick);
|
||||||
|
//
|
||||||
// settingsToolStripMenuItem
|
// settingsToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
|
this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
|
||||||
@@ -222,6 +230,7 @@
|
|||||||
// toolsMainMenu
|
// toolsMainMenu
|
||||||
//
|
//
|
||||||
this.toolsMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.toolsMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.backupRestoreToolsMainMenu,
|
||||||
this.clearRecordToolsMainMenu,
|
this.clearRecordToolsMainMenu,
|
||||||
this.manageItemsToolsMainMenu,
|
this.manageItemsToolsMainMenu,
|
||||||
this.manageSuppliersToolsMainMenu,
|
this.manageSuppliersToolsMainMenu,
|
||||||
@@ -1008,12 +1017,12 @@
|
|||||||
this.grossProfitDollarGrossProfitLabel.TabIndex = 2;
|
this.grossProfitDollarGrossProfitLabel.TabIndex = 2;
|
||||||
this.grossProfitDollarGrossProfitLabel.Text = "Dollar Gross Profit: ";
|
this.grossProfitDollarGrossProfitLabel.Text = "Dollar Gross Profit: ";
|
||||||
//
|
//
|
||||||
// generateReportMenuItem
|
// backupRestoreToolsMainMenu
|
||||||
//
|
//
|
||||||
this.generateReportMenuItem.Name = "generateReportMenuItem";
|
this.backupRestoreToolsMainMenu.Name = "backupRestoreToolsMainMenu";
|
||||||
this.generateReportMenuItem.Size = new System.Drawing.Size(256, 34);
|
this.backupRestoreToolsMainMenu.Size = new System.Drawing.Size(282, 34);
|
||||||
this.generateReportMenuItem.Text = "&Generate Report";
|
this.backupRestoreToolsMainMenu.Text = "&Database Backup";
|
||||||
this.generateReportMenuItem.Click += new System.EventHandler(this.GenerateReportMenuItemClick);
|
this.backupRestoreToolsMainMenu.Click += new System.EventHandler(this.DisplayDatabaseRecoveryFormOnBackupRestoreClick);
|
||||||
//
|
//
|
||||||
// FrmMain
|
// FrmMain
|
||||||
//
|
//
|
||||||
@@ -1146,6 +1155,7 @@
|
|||||||
private System.Windows.Forms.ToolStripMenuItem testToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem testToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem generateReportMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem generateReportMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem backupRestoreToolsMainMenu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void frmMain_Load(object sender, EventArgs e)
|
private void frmMain_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
RefreshDateListing();
|
RefreshDateListing();
|
||||||
ConstructApcDataGridViews();
|
ConstructApcDataGridViews();
|
||||||
ConstructInvoicesDataGridView();
|
ConstructInvoicesDataGridView();
|
||||||
@@ -136,7 +136,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void DisplayNewRecordForm(object sender, EventArgs e)
|
private void DisplayNewRecordForm(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var form = new NewModifyRecord();
|
var form = new NewModifyRecord();
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
//One the user has closed the add record form, check to see if there is a newer date
|
//One the user has closed the add record form, check to see if there is a newer date
|
||||||
@@ -157,6 +157,19 @@ namespace AdvertsingProfitControl
|
|||||||
LoadDate(_currentActiveDate);
|
LoadDate(_currentActiveDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DisplayDatabaseRecoveryFormOnBackupRestoreClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var form = new DatabaseRecovery();
|
||||||
|
form.ShowDialog();
|
||||||
|
if (!form.RestoredDatabase) return;
|
||||||
|
//If a database restore operation occurred then load the most recent date.
|
||||||
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
|
var recentDate = db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault();
|
||||||
|
if (recentDate == null) return;
|
||||||
|
_currentActiveDate = recentDate.EndingDate;
|
||||||
|
LoadDate(recentDate.EndingDate);
|
||||||
|
}
|
||||||
|
|
||||||
private void ClearCurrentRecord(object sender, EventArgs e)
|
private void ClearCurrentRecord(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var result = MessageBox.Show(@"Are you sure you want to delete all records for the date " + _currentActiveDate.ToShortDateString() + @"?", @"Clear Date", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
var result = MessageBox.Show(@"Are you sure you want to delete all records for the date " + _currentActiveDate.ToShortDateString() + @"?", @"Clear Date", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||||
@@ -165,7 +178,7 @@ namespace AdvertsingProfitControl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var dateRecord = db.WeekEndingDates.Single(x => x.EndingDate == _currentActiveDate);
|
var dateRecord = db.WeekEndingDates.Single(x => x.EndingDate == _currentActiveDate);
|
||||||
var projections = db.Projections.Where(x => x.WeekEndingDate.EndingDate == dateRecord.EndingDate);
|
var projections = db.Projections.Where(x => x.WeekEndingDate.EndingDate == dateRecord.EndingDate);
|
||||||
var inventories = db.Inventories.Where(x => x.WeekEndingDate.EndingDate == dateRecord.EndingDate);
|
var inventories = db.Inventories.Where(x => x.WeekEndingDate.EndingDate == dateRecord.EndingDate);
|
||||||
@@ -242,7 +255,6 @@ namespace AdvertsingProfitControl
|
|||||||
adItemManager.ShowDialog();
|
adItemManager.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void manageSuppliersToolsMainMenu_Click(object sender, EventArgs e)
|
private void manageSuppliersToolsMainMenu_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var form = new FrmManageSuppliers();
|
var form = new FrmManageSuppliers();
|
||||||
@@ -447,7 +459,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void LoadDate(DateTime date)
|
private void LoadDate(DateTime date)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
//Check to see if that date record can be found before clearing the form.
|
//Check to see if that date record can be found before clearing the form.
|
||||||
var dateRecord = db.WeekEndingDates.SingleOrDefault(x => x.EndingDate == date);
|
var dateRecord = db.WeekEndingDates.SingleOrDefault(x => x.EndingDate == date);
|
||||||
if (dateRecord == null)
|
if (dateRecord == null)
|
||||||
@@ -478,7 +490,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void LoadProjectionsTable(WeekEndingDate dateRecord)
|
private void LoadProjectionsTable(WeekEndingDate dateRecord)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var adSpecialIndex = -1;
|
var adSpecialIndex = -1;
|
||||||
decimal totalSales = 0;
|
decimal totalSales = 0;
|
||||||
decimal totalProfitReturn = 0;
|
decimal totalProfitReturn = 0;
|
||||||
@@ -538,7 +550,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void LoadInventoryTable(WeekEndingDate dateRecord)
|
private void LoadInventoryTable(WeekEndingDate dateRecord)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var adSpecialIndex = -1;
|
var adSpecialIndex = -1;
|
||||||
var inventories = db.Inventories.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x).OrderBy(x => x.RowPosition);
|
var inventories = db.Inventories.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x).OrderBy(x => x.RowPosition);
|
||||||
|
|
||||||
@@ -570,7 +582,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void LoadActualSalesTable(WeekEndingDate dateRecord)
|
private void LoadActualSalesTable(WeekEndingDate dateRecord)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var adSpecialIndex = -1;
|
var adSpecialIndex = -1;
|
||||||
decimal totalSales = 0;
|
decimal totalSales = 0;
|
||||||
decimal totalProfitReturn = 0;
|
decimal totalProfitReturn = 0;
|
||||||
@@ -630,7 +642,7 @@ namespace AdvertsingProfitControl
|
|||||||
private void LoadInvoices(WeekEndingDate dateRecord)
|
private void LoadInvoices(WeekEndingDate dateRecord)
|
||||||
{
|
{
|
||||||
_totalInvoicePurchases = 0;
|
_totalInvoicePurchases = 0;
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var invoices = db.Invoices.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
var invoices = db.Invoices.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
||||||
|
|
||||||
foreach (var invoice in invoices)
|
foreach (var invoice in invoices)
|
||||||
@@ -660,7 +672,7 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
//Clear the department sales and prepare to add up a total.
|
//Clear the department sales and prepare to add up a total.
|
||||||
_departmentSales = 0;
|
_departmentSales = 0;
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var weeklySales = db.WeeklySales.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
var weeklySales = db.WeeklySales.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
||||||
foreach (var sale in weeklySales)
|
foreach (var sale in weeklySales)
|
||||||
{
|
{
|
||||||
@@ -719,7 +731,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void LoadTaxable(WeekEndingDate dateRecord)
|
private void LoadTaxable(WeekEndingDate dateRecord)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var taxables = db.Taxables.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
var taxables = db.Taxables.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
||||||
foreach (var taxable in taxables)
|
foreach (var taxable in taxables)
|
||||||
{
|
{
|
||||||
@@ -750,7 +762,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void LoadCostAnalysis(WeekEndingDate dateRecord)
|
private void LoadCostAnalysis(WeekEndingDate dateRecord)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var analysis = db.CostAnalysis.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
var analysis = db.CostAnalysis.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
||||||
foreach (var a in analysis)
|
foreach (var a in analysis)
|
||||||
{
|
{
|
||||||
@@ -870,7 +882,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void RefreshDateListing()
|
private void RefreshDateListing()
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
monthCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray();
|
monthCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray();
|
||||||
if (monthCalendar.BoldedDates.Length > 0)
|
if (monthCalendar.BoldedDates.Length > 0)
|
||||||
{
|
{
|
||||||
@@ -931,7 +943,7 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
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);
|
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;
|
if (result != DialogResult.Yes) return;
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var distinctYears = db.WeekEndingDates.Select(x => x.EndingDate.Year).Distinct().ToArray();
|
var distinctYears = db.WeekEndingDates.Select(x => x.EndingDate.Year).Distinct().ToArray();
|
||||||
if (distinctYears.Length == 1)
|
if (distinctYears.Length == 1)
|
||||||
{
|
{
|
||||||
@@ -953,7 +965,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private bool ClearSelectedDate(int year)
|
private bool ClearSelectedDate(int year)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var status = true;
|
var status = true;
|
||||||
|
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
@@ -988,7 +1000,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void ClearProjectionRecords(WeekEndingDate dateRecord)
|
private void ClearProjectionRecords(WeekEndingDate dateRecord)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
|
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
@@ -1001,7 +1013,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void ClearInventoyRecords(WeekEndingDate dateRecord)
|
private void ClearInventoyRecords(WeekEndingDate dateRecord)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
|
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
@@ -1014,7 +1026,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void ClearActualSalesRecords(WeekEndingDate dateRecord)
|
private void ClearActualSalesRecords(WeekEndingDate dateRecord)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
|
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
@@ -1027,7 +1039,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void ClearInvoices(WeekEndingDate dateRecord)
|
private void ClearInvoices(WeekEndingDate dateRecord)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
|
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
@@ -1040,7 +1052,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void ClearWeeklySales(WeekEndingDate dateRecord)
|
private void ClearWeeklySales(WeekEndingDate dateRecord)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
|
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
@@ -1053,7 +1065,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void ClearTaxableRecords(WeekEndingDate dateRecord)
|
private void ClearTaxableRecords(WeekEndingDate dateRecord)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
|
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
@@ -1066,7 +1078,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void ClearCostAnalysisRecords(WeekEndingDate dateRecord)
|
private void ClearCostAnalysisRecords(WeekEndingDate dateRecord)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
|
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
@@ -1079,7 +1091,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void ClearCommentsRecords(WeekEndingDate dateRecord)
|
private void ClearCommentsRecords(WeekEndingDate dateRecord)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
|
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
@@ -1109,7 +1121,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void testToolStripMenuItem_Click(object sender, EventArgs e)
|
private void testToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
MessageBox.Show(@"Nothing to debug here!", @"Debug Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ namespace AdvertsingProfitControl
|
|||||||
if(filterComboBox.Enabled == false) return;
|
if(filterComboBox.Enabled == false) return;
|
||||||
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) + @"):";
|
||||||
adItemsListView.Items.Clear();
|
adItemsListView.Items.Clear();
|
||||||
var db = new AdvertisingProfitControlModel();
|
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)
|
||||||
{
|
{
|
||||||
@@ -92,7 +92,7 @@ namespace AdvertsingProfitControl
|
|||||||
adItemsListView.Items.Clear();
|
adItemsListView.Items.Clear();
|
||||||
filterComboBox.Items.Clear();
|
filterComboBox.Items.Clear();
|
||||||
filterComboBox.Items.Add("All");
|
filterComboBox.Items.Add("All");
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var adItems = db.AdItems.Select(x => x).OrderBy(x => x.Name);
|
var adItems = db.AdItems.Select(x => x).OrderBy(x => x.Name);
|
||||||
var adItemCount = 0;
|
var adItemCount = 0;
|
||||||
var numberFound = false;
|
var numberFound = false;
|
||||||
@@ -153,7 +153,7 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
var item = adItemsListView.SelectedItems[0];
|
var item = adItemsListView.SelectedItems[0];
|
||||||
var oldAdItem = (AdItem)item.Tag;
|
var oldAdItem = (AdItem)item.Tag;
|
||||||
var db = new AdvertisingProfitControlModel();
|
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)
|
||||||
@@ -208,7 +208,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void AddUpdateItem(object sender, EventArgs e)
|
private void AddUpdateItem(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
if (!_isUpdating)
|
if (!_isUpdating)
|
||||||
{
|
{
|
||||||
if (!db.AdItems.Any(x => x.Name == newItemTextBox.Text))
|
if (!db.AdItems.Any(x => x.Name == newItemTextBox.Text))
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace AdvertsingProfitControl
|
|||||||
private void RefreshSupplierListing()
|
private void RefreshSupplierListing()
|
||||||
{
|
{
|
||||||
suppliersListBox.Items.Clear();
|
suppliersListBox.Items.Clear();
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var suppliers = db.Suppliers.Select(x => x).OrderBy(x => x.Name);
|
var suppliers = db.Suppliers.Select(x => x).OrderBy(x => x.Name);
|
||||||
var supplierCount = 0;
|
var supplierCount = 0;
|
||||||
foreach (var supplier in suppliers)
|
foreach (var supplier in suppliers)
|
||||||
@@ -72,7 +72,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void registerSupplierButton_Click(object sender, EventArgs e)
|
private void registerSupplierButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
if (!_isUpdating)
|
if (!_isUpdating)
|
||||||
{
|
{
|
||||||
if (!db.Suppliers.Any(x => x.Name == newSupplierTextBox.Text))
|
if (!db.Suppliers.Any(x => x.Name == newSupplierTextBox.Text))
|
||||||
@@ -123,7 +123,7 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
var item = suppliersListBox.SelectedItems[0];
|
var item = suppliersListBox.SelectedItems[0];
|
||||||
var oldSupplier = (Supplier)item.Tag;
|
var oldSupplier = (Supplier)item.Tag;
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var supplier = db.Suppliers.Single(x => x.Id == oldSupplier.Id);
|
var supplier = db.Suppliers.Single(x => x.Id == oldSupplier.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 (supplier.Invoices.Count > 0)
|
if (supplier.Invoices.Count > 0)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void RegisterNewAdSpecial(object sender, EventArgs e)
|
private void RegisterNewAdSpecial(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
if (!_isUpdating)
|
if (!_isUpdating)
|
||||||
{
|
{
|
||||||
if (!db.AdSpecials.Any(x => x.Name == newAdSpecialTextBox.Text))
|
if (!db.AdSpecials.Any(x => x.Name == newAdSpecialTextBox.Text))
|
||||||
@@ -100,7 +100,7 @@ namespace AdvertsingProfitControl
|
|||||||
private void RefreshAdSpecialListing()
|
private void RefreshAdSpecialListing()
|
||||||
{
|
{
|
||||||
adSpecialsListBox.Items.Clear();
|
adSpecialsListBox.Items.Clear();
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var adSpecials = db.AdSpecials.Select(x => x).OrderBy(x => x.Name);
|
var adSpecials = db.AdSpecials.Select(x => x).OrderBy(x => x.Name);
|
||||||
foreach (var adSpecial in adSpecials)
|
foreach (var adSpecial in adSpecials)
|
||||||
{
|
{
|
||||||
@@ -120,7 +120,7 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
var item = adSpecialsListBox.SelectedItems[0];
|
var item = adSpecialsListBox.SelectedItems[0];
|
||||||
var adSpecial = (AdSpecial) item.Tag;
|
var adSpecial = (AdSpecial) item.Tag;
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var ad = db.AdSpecials.Single(x => x.Id == adSpecial.Id);
|
var ad = db.AdSpecials.Single(x => x.Id == adSpecial.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 (ad.ActualSales.Count > 0)
|
if (ad.ActualSales.Count > 0)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace AdvertsingProfitControl
|
|||||||
/// <param name="writer"></param>
|
/// <param name="writer"></param>
|
||||||
private void BuildReportFrontPage(DateTime date, ref HtmlTextWriter writer)
|
private void BuildReportFrontPage(DateTime date, ref HtmlTextWriter writer)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var dateRecord = db.WeekEndingDates.SingleOrDefault(x => x.EndingDate == date);
|
var dateRecord = db.WeekEndingDates.SingleOrDefault(x => x.EndingDate == date);
|
||||||
if (dateRecord == null)
|
if (dateRecord == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace AdvertsingProfitControl
|
|||||||
public NewModifyRecord()
|
public NewModifyRecord()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
//Check to see if there are dates in the database.
|
//Check to see if there are dates in the database.
|
||||||
if (db.WeekEndingDates.Any())
|
if (db.WeekEndingDates.Any())
|
||||||
{
|
{
|
||||||
@@ -85,7 +85,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
public void InitializeForm()
|
public void InitializeForm()
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
weekEndingCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray();
|
weekEndingCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray();
|
||||||
weekEndingCalendar.DateChanged += ValidateDateChanged;
|
weekEndingCalendar.DateChanged += ValidateDateChanged;
|
||||||
//next pull all the ad items into memory.
|
//next pull all the ad items into memory.
|
||||||
@@ -2737,7 +2737,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void LoadDate(DateTime date)
|
private void LoadDate(DateTime date)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var dateRecord = db.WeekEndingDates.SingleOrDefault(x => x.EndingDate == date);
|
var dateRecord = db.WeekEndingDates.SingleOrDefault(x => x.EndingDate == date);
|
||||||
if (dateRecord == null)
|
if (dateRecord == null)
|
||||||
{
|
{
|
||||||
@@ -2765,7 +2765,7 @@ namespace AdvertsingProfitControl
|
|||||||
projectionsDataGridView.CellValidating -= ValidateSalesDataGridViewCellContents;
|
projectionsDataGridView.CellValidating -= ValidateSalesDataGridViewCellContents;
|
||||||
projectionsDataGridView.RowValidating -= ValidateProjectedRow;
|
projectionsDataGridView.RowValidating -= ValidateProjectedRow;
|
||||||
|
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var adSpecialIndex = -1;
|
var adSpecialIndex = -1;
|
||||||
var projections = db.Projections.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x).OrderBy(x => x.RowPosition);
|
var projections = db.Projections.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x).OrderBy(x => x.RowPosition);
|
||||||
var index = 0;
|
var index = 0;
|
||||||
@@ -2831,7 +2831,7 @@ namespace AdvertsingProfitControl
|
|||||||
inventoryDataGridView.CellValidating -= ValidateInventoryCellContents;
|
inventoryDataGridView.CellValidating -= ValidateInventoryCellContents;
|
||||||
inventoryDataGridView.RowValidating -= ValidateInventoryRow;
|
inventoryDataGridView.RowValidating -= ValidateInventoryRow;
|
||||||
//Create a local ad special index since Projections should have filled the ad special index in for the class.
|
//Create a local ad special index since Projections should have filled the ad special index in for the class.
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var adSpecialIndex = -1;
|
var adSpecialIndex = -1;
|
||||||
var inventories = db.Inventories.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x).OrderBy(x => x.RowPosition);
|
var inventories = db.Inventories.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x).OrderBy(x => x.RowPosition);
|
||||||
var index = 0;
|
var index = 0;
|
||||||
@@ -2893,7 +2893,7 @@ namespace AdvertsingProfitControl
|
|||||||
actualSalesDataGridView.CellValidating -= ValidateSalesDataGridViewCellContents;
|
actualSalesDataGridView.CellValidating -= ValidateSalesDataGridViewCellContents;
|
||||||
actualSalesDataGridView.RowValidating -= ValidateActualSalesRow;
|
actualSalesDataGridView.RowValidating -= ValidateActualSalesRow;
|
||||||
//Create a local ad special index since Projections should have filled the ad special index in for the class.
|
//Create a local ad special index since Projections should have filled the ad special index in for the class.
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var adSpecialIndex = -1;
|
var adSpecialIndex = -1;
|
||||||
var actualSales = db.ActualSales.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x).OrderBy(x => x.RowPosition);
|
var actualSales = db.ActualSales.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x).OrderBy(x => x.RowPosition);
|
||||||
var index = 0;
|
var index = 0;
|
||||||
@@ -2950,7 +2950,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void LoadInvoices(WeekEndingDate dateRecord)
|
private void LoadInvoices(WeekEndingDate dateRecord)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var invoices = db.Invoices.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
var invoices = db.Invoices.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
|
||||||
var index = 0;
|
var index = 0;
|
||||||
foreach (var invoice in invoices)
|
foreach (var invoice in invoices)
|
||||||
@@ -2973,7 +2973,7 @@ namespace AdvertsingProfitControl
|
|||||||
commentsTextBox.Enter -= StoreBeginningTextBoxValue;
|
commentsTextBox.Enter -= StoreBeginningTextBoxValue;
|
||||||
commentsTextBox.KeyDown -= CheckForKeyCommand;
|
commentsTextBox.KeyDown -= CheckForKeyCommand;
|
||||||
commentsTextBox.Leave -= CheckForTextChangeOnLeave;
|
commentsTextBox.Leave -= CheckForTextChangeOnLeave;
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var comments = db.Notes.SingleOrDefault(x => x.FkDateId == dateRecord.Id);
|
var comments = db.Notes.SingleOrDefault(x => x.FkDateId == dateRecord.Id);
|
||||||
if (comments != null)
|
if (comments != null)
|
||||||
{
|
{
|
||||||
@@ -3011,7 +3011,7 @@ namespace AdvertsingProfitControl
|
|||||||
totalWeeklySalesTextBox.Enter -= StoreBeginningTextBoxValue;
|
totalWeeklySalesTextBox.Enter -= StoreBeginningTextBoxValue;
|
||||||
totalWeeklySalesTextBox.Validating -= ValidateWeeklySales;
|
totalWeeklySalesTextBox.Validating -= ValidateWeeklySales;
|
||||||
|
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var weeklySale = db.WeeklySales.SingleOrDefault(x => x.FkDateId == dateRecord.Id);
|
var weeklySale = db.WeeklySales.SingleOrDefault(x => x.FkDateId == dateRecord.Id);
|
||||||
if (weeklySale == null)
|
if (weeklySale == null)
|
||||||
{
|
{
|
||||||
@@ -3068,7 +3068,7 @@ namespace AdvertsingProfitControl
|
|||||||
saturdayTaxableTextBox.Validating -= ValidateTaxableFields;
|
saturdayTaxableTextBox.Validating -= ValidateTaxableFields;
|
||||||
totalTaxableTextBox.Enter -= StoreBeginningTextBoxValue;
|
totalTaxableTextBox.Enter -= StoreBeginningTextBoxValue;
|
||||||
totalTaxableTextBox.Validating -= ValidateTaxableFields;
|
totalTaxableTextBox.Validating -= ValidateTaxableFields;
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var taxable = db.Taxables.SingleOrDefault(x => x.FkDateId == dateRecord.Id);
|
var taxable = db.Taxables.SingleOrDefault(x => x.FkDateId == dateRecord.Id);
|
||||||
if (taxable == null)
|
if (taxable == null)
|
||||||
{
|
{
|
||||||
@@ -3117,7 +3117,7 @@ namespace AdvertsingProfitControl
|
|||||||
suppliesTextBox.Enter -= StoreBeginningTextBoxValue;
|
suppliesTextBox.Enter -= StoreBeginningTextBoxValue;
|
||||||
suppliesTextBox.Validating -= ValidateCostAnalysisValues;
|
suppliesTextBox.Validating -= ValidateCostAnalysisValues;
|
||||||
|
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var costAnalysis = db.CostAnalysis.SingleOrDefault(x => x.FkDateId == dateRecord.Id);
|
var costAnalysis = db.CostAnalysis.SingleOrDefault(x => x.FkDateId == dateRecord.Id);
|
||||||
if (costAnalysis == null)
|
if (costAnalysis == null)
|
||||||
{
|
{
|
||||||
@@ -3154,7 +3154,7 @@ namespace AdvertsingProfitControl
|
|||||||
private bool SaveRecords()
|
private bool SaveRecords()
|
||||||
{
|
{
|
||||||
var success = true;
|
var success = true;
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
//Get the date ID for the current active date.
|
//Get the date ID for the current active date.
|
||||||
if (_currentActiveDate.DayOfWeek != DayOfWeek.Saturday)
|
if (_currentActiveDate.DayOfWeek != DayOfWeek.Saturday)
|
||||||
{
|
{
|
||||||
@@ -3303,7 +3303,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void SaveProjections(WeekEndingDate date)
|
private void SaveProjections(WeekEndingDate date)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var lastRow = -1;
|
var lastRow = -1;
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
@@ -3482,7 +3482,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void SaveInventory(WeekEndingDate date)
|
private void SaveInventory(WeekEndingDate date)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var lastRow = -1;
|
var lastRow = -1;
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
@@ -3623,7 +3623,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void SaveActualSales(WeekEndingDate date)
|
private void SaveActualSales(WeekEndingDate date)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var lastRow = -1;
|
var lastRow = -1;
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
@@ -3804,7 +3804,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private void SaveInvoices(WeekEndingDate date)
|
private void SaveInvoices(WeekEndingDate date)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var lastRow = -1;
|
var lastRow = -1;
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
@@ -3936,7 +3936,7 @@ namespace AdvertsingProfitControl
|
|||||||
informationLabel.Text += @"No changes detected to Weekly Sales." + Environment.NewLine;
|
informationLabel.Text += @"No changes detected to Weekly Sales." + Environment.NewLine;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -4011,7 +4011,7 @@ namespace AdvertsingProfitControl
|
|||||||
informationLabel.Text += @"No changes detected to Taxable." + Environment.NewLine;
|
informationLabel.Text += @"No changes detected to Taxable." + Environment.NewLine;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -4086,7 +4086,7 @@ namespace AdvertsingProfitControl
|
|||||||
informationLabel.Text += @"No changes detected to Cost Analysis." + Environment.NewLine;
|
informationLabel.Text += @"No changes detected to Cost Analysis." + Environment.NewLine;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -4153,7 +4153,7 @@ namespace AdvertsingProfitControl
|
|||||||
informationLabel.Text += @"No changes detected for Comments." + Environment.NewLine;
|
informationLabel.Text += @"No changes detected for Comments." + Environment.NewLine;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -4209,7 +4209,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
private static AdSpecial GetAdSpecial(string adSpecialText)
|
private static AdSpecial GetAdSpecial(string adSpecialText)
|
||||||
{
|
{
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var adSpecial = new AdSpecial();
|
var adSpecial = new AdSpecial();
|
||||||
//An ad special does exist so grab its ID from the database.
|
//An ad special does exist so grab its ID from the database.
|
||||||
if (db.AdSpecials.Any(x => x.Name == adSpecialText))
|
if (db.AdSpecials.Any(x => x.Name == adSpecialText))
|
||||||
@@ -4227,7 +4227,7 @@ namespace AdvertsingProfitControl
|
|||||||
private static bool DeleteApcRow(int projectionId, int inventoryId, int actualSalesId)
|
private static bool DeleteApcRow(int projectionId, int inventoryId, int actualSalesId)
|
||||||
{
|
{
|
||||||
var result = true;
|
var result = true;
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -4263,7 +4263,7 @@ namespace AdvertsingProfitControl
|
|||||||
private static bool DeleteInvoiceRow(int invoiceId)
|
private static bool DeleteInvoiceRow(int invoiceId)
|
||||||
{
|
{
|
||||||
var result = true;
|
var result = true;
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
using (var scope = new TransactionScope())
|
using (var scope = new TransactionScope())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -4325,7 +4325,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
ClearFormState();
|
ClearFormState();
|
||||||
addRecordButton.Text = @"Add Record";
|
addRecordButton.Text = @"Add Record";
|
||||||
var db = new AdvertisingProfitControlModel();
|
var db = new AdvertisingProfitControlDbContext();
|
||||||
var recentDate = db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault(x => x.EndingDate.Year == _currentActiveDate.Year);
|
var recentDate = db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault(x => x.EndingDate.Year == _currentActiveDate.Year);
|
||||||
if (recentDate == null)
|
if (recentDate == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.5.1.1")]
|
[assembly: AssemblyVersion("3.0.0.0")]
|
||||||
[assembly: AssemblyFileVersion("2.5.1.1")]
|
[assembly: AssemblyFileVersion("3.0.0.0")]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?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="2.5.1.1" Manufacturer="Garritt McCune" UpgradeCode="a416a558-d7c0-4f24-8b1e-2d01761ad15f">
|
<Product Id="*" Name="Advertising Profit Control" Language="1033" Version="3.0.0.0" Manufacturer="Garritt McCune" UpgradeCode="a416a558-d7c0-4f24-8b1e-2d01761ad15f">
|
||||||
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="Custom Profit Control Recording Software" Comments="Profit Control Recording Software"/>
|
<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-->
|
||||||
@@ -135,6 +135,9 @@
|
|||||||
</Component>
|
</Component>
|
||||||
<Component Id="Logging">
|
<Component Id="Logging">
|
||||||
<File Source="$(var.SolutionDir)\packages\Common.Logging.3.3.1\lib\net40\Common.Logging.dll"/>
|
<File Source="$(var.SolutionDir)\packages\Common.Logging.3.3.1\lib\net40\Common.Logging.dll"/>
|
||||||
|
</Component>
|
||||||
|
<Component Id="ApcData">
|
||||||
|
<File Source="$(var.SolutionDir)\AdvertisingProfitControlData\bin\Debug\AdvertisingProfitControlData.dll"/>
|
||||||
</Component>
|
</Component>
|
||||||
</ComponentGroup>
|
</ComponentGroup>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
|||||||
Reference in New Issue
Block a user