Split the database objects out into a seperate project. Needs renaming in some areas and updates in the installer. Otherwise first version of a proper data DLL file.
This commit is contained in:
@@ -1,12 +1,8 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
public partial class ActualSale
|
||||
namespace AdvertisingProfitControlData
|
||||
{
|
||||
public class ActualSale
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
public partial class AdItem
|
||||
namespace AdvertisingProfitControlData
|
||||
{
|
||||
public class AdItem
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public AdItem()
|
||||
@@ -1,12 +1,9 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
public partial class AdSpecial
|
||||
namespace AdvertisingProfitControlData
|
||||
{
|
||||
public class AdSpecial
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public AdSpecial()
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{E30F8B0E-DFF3-4AB7-8D0C-47BD11164E51}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>AdvertisingProfitControlData</RootNamespace>
|
||||
<AssemblyName>AdvertisingProfitControlData</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ActualSale.cs" />
|
||||
<Compile Include="AdItem.cs" />
|
||||
<Compile Include="AdSpecial.cs" />
|
||||
<Compile Include="AdvertisingProfitControlModel.cs" />
|
||||
<Compile Include="CostAnaylsi.cs" />
|
||||
<Compile Include="Inventory.cs" />
|
||||
<Compile Include="Invoice.cs" />
|
||||
<Compile Include="Note.cs" />
|
||||
<Compile Include="Projection.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Supplier.cs" />
|
||||
<Compile Include="Taxable.cs" />
|
||||
<Compile Include="Version.cs" />
|
||||
<Compile Include="WeekEndingDate.cs" />
|
||||
<Compile Include="WeeklySales.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
+36
-7
@@ -1,14 +1,43 @@
|
||||
using AdvertsingProfitControl.Properties;
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
namespace AdvertisingProfitControlData
|
||||
{
|
||||
using System.Data.Entity;
|
||||
|
||||
public partial class AdvertisingProfitControlModel : DbContext
|
||||
public class AdvertisingProfitControlModel : DbContext
|
||||
{
|
||||
public AdvertisingProfitControlModel()
|
||||
: base(Settings.Default.ConnectionString)
|
||||
private static string _connectionString = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes and stores the supplied connection string. This allows calls to
|
||||
/// an overloaded constructor to take no parameters.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">The connection string for the database.</param>
|
||||
public AdvertisingProfitControlModel(string connectionString) : base(connectionString)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the database context using a previously initialized connection string.
|
||||
/// </summary>
|
||||
public AdvertisingProfitControlModel()
|
||||
: base(ValidateConnectionString())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to make sure a connection string has been initialized.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static string ValidateConnectionString()
|
||||
{
|
||||
if (_connectionString == string.Empty)
|
||||
{
|
||||
throw new OperationCanceledException("A connection string must be specified.");
|
||||
}
|
||||
|
||||
return _connectionString;
|
||||
}
|
||||
|
||||
public virtual DbSet<ActualSale> ActualSales { get; set; }
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
|
||||
</configSections>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
|
||||
</providers>
|
||||
</entityFramework>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
|
||||
+2
-8
@@ -1,12 +1,6 @@
|
||||
namespace AdvertsingProfitControl
|
||||
namespace AdvertisingProfitControlData
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
|
||||
public partial class CostAnalysi
|
||||
public class CostAnalysi
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace AdvertisingProfitControlData
|
||||
{
|
||||
[Table("Inventory")]
|
||||
public partial class Inventory
|
||||
public class Inventory
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
public partial class Invoice
|
||||
namespace AdvertisingProfitControlData
|
||||
{
|
||||
public class Invoice
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace AdvertisingProfitControlData
|
||||
{
|
||||
public class Note
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(256)]
|
||||
public string Remark { get; set; }
|
||||
|
||||
public int FkDateId { get; set; }
|
||||
|
||||
public virtual WeekEndingDate WeekEndingDate { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,8 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
public partial class Projection
|
||||
namespace AdvertisingProfitControlData
|
||||
{
|
||||
public class Projection
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("AdvertisingProfitControlData")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("AdvertisingProfitControlData")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("e30f8b0e-dff3-4ab7-8d0c-47bd11164e51")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -1,12 +1,9 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
public partial class Supplier
|
||||
namespace AdvertisingProfitControlData
|
||||
{
|
||||
public class Supplier
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public Supplier()
|
||||
@@ -1,13 +1,9 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace AdvertisingProfitControlData
|
||||
{
|
||||
[Table("Taxable")]
|
||||
public partial class Taxable
|
||||
public class Taxable
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace AdvertisingProfitControlData
|
||||
{
|
||||
[Table("Version")]
|
||||
public class Version
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[StringLength(32)]
|
||||
public string VersionNumber { get; set; }
|
||||
}
|
||||
}
|
||||
+6
-8
@@ -1,12 +1,10 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
public partial class WeekEndingDate
|
||||
namespace AdvertisingProfitControlData
|
||||
{
|
||||
public class WeekEndingDate
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public WeekEndingDate()
|
||||
@@ -1,12 +1,6 @@
|
||||
namespace AdvertsingProfitControl
|
||||
namespace AdvertisingProfitControlData
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
|
||||
public partial class WeeklySale
|
||||
public class WeeklySale
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="EntityFramework" version="6.1.3" targetFramework="net452" />
|
||||
</packages>
|
||||
@@ -1,12 +1,14 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26403.3
|
||||
VisualStudioVersion = 15.0.26228.4
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvertsingProfitControl", "AdvertsingProfitControl\AdvertsingProfitControl.csproj", "{4A45C665-5D02-4724-9CC5-C0C50CA44760}"
|
||||
EndProject
|
||||
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "SetupProject", "SetupProject\SetupProject.wixproj", "{EB640D80-1A1E-4835-90B3-83A688419321}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvertisingProfitControlData", "AdvertisingProfitControlData\AdvertisingProfitControlData.csproj", "{E30F8B0E-DFF3-4AB7-8D0C-47BD11164E51}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -29,6 +31,14 @@ Global
|
||||
{EB640D80-1A1E-4835-90B3-83A688419321}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{EB640D80-1A1E-4835-90B3-83A688419321}.Release|x86.ActiveCfg = Release|x86
|
||||
{EB640D80-1A1E-4835-90B3-83A688419321}.Release|x86.Build.0 = Release|x86
|
||||
{E30F8B0E-DFF3-4AB7-8D0C-47BD11164E51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E30F8B0E-DFF3-4AB7-8D0C-47BD11164E51}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E30F8B0E-DFF3-4AB7-8D0C-47BD11164E51}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{E30F8B0E-DFF3-4AB7-8D0C-47BD11164E51}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{E30F8B0E-DFF3-4AB7-8D0C-47BD11164E51}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E30F8B0E-DFF3-4AB7-8D0C-47BD11164E51}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E30F8B0E-DFF3-4AB7-8D0C-47BD11164E51}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{E30F8B0E-DFF3-4AB7-8D0C-47BD11164E51}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Generated
+22
-24
@@ -1,6 +1,6 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
partial class AboutBox1
|
||||
partial class AboutBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -39,10 +39,9 @@
|
||||
//
|
||||
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.okButton.Location = new System.Drawing.Point(620, 442);
|
||||
this.okButton.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.okButton.Location = new System.Drawing.Point(339, 240);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(138, 40);
|
||||
this.okButton.Size = new System.Drawing.Size(75, 22);
|
||||
this.okButton.TabIndex = 24;
|
||||
this.okButton.Text = "&OK";
|
||||
//
|
||||
@@ -50,11 +49,11 @@
|
||||
//
|
||||
this.databaseVersionLabel.BackColor = System.Drawing.Color.Transparent;
|
||||
this.databaseVersionLabel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.databaseVersionLabel.Location = new System.Drawing.Point(11, 48);
|
||||
this.databaseVersionLabel.Margin = new System.Windows.Forms.Padding(11, 0, 6, 0);
|
||||
this.databaseVersionLabel.MaximumSize = new System.Drawing.Size(0, 31);
|
||||
this.databaseVersionLabel.Location = new System.Drawing.Point(6, 26);
|
||||
this.databaseVersionLabel.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);
|
||||
this.databaseVersionLabel.MaximumSize = new System.Drawing.Size(0, 17);
|
||||
this.databaseVersionLabel.Name = "databaseVersionLabel";
|
||||
this.databaseVersionLabel.Size = new System.Drawing.Size(747, 31);
|
||||
this.databaseVersionLabel.Size = new System.Drawing.Size(408, 17);
|
||||
this.databaseVersionLabel.TabIndex = 0;
|
||||
this.databaseVersionLabel.Text = "Database Version:";
|
||||
this.databaseVersionLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
@@ -63,11 +62,11 @@
|
||||
//
|
||||
this.labelProductVerion.BackColor = System.Drawing.Color.Transparent;
|
||||
this.labelProductVerion.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.labelProductVerion.Location = new System.Drawing.Point(11, 0);
|
||||
this.labelProductVerion.Margin = new System.Windows.Forms.Padding(11, 0, 6, 0);
|
||||
this.labelProductVerion.MaximumSize = new System.Drawing.Size(0, 31);
|
||||
this.labelProductVerion.Location = new System.Drawing.Point(6, 0);
|
||||
this.labelProductVerion.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0);
|
||||
this.labelProductVerion.MaximumSize = new System.Drawing.Size(0, 17);
|
||||
this.labelProductVerion.Name = "labelProductVerion";
|
||||
this.labelProductVerion.Size = new System.Drawing.Size(747, 31);
|
||||
this.labelProductVerion.Size = new System.Drawing.Size(408, 17);
|
||||
this.labelProductVerion.TabIndex = 19;
|
||||
this.labelProductVerion.Text = "Advertising Prodift Control Version:";
|
||||
this.labelProductVerion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
@@ -82,8 +81,7 @@
|
||||
this.tableLayoutPanel.Controls.Add(this.okButton, 0, 6);
|
||||
this.tableLayoutPanel.Controls.Add(this.reportGeneratingVersionLabel, 0, 5);
|
||||
this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel.Location = new System.Drawing.Point(17, 17);
|
||||
this.tableLayoutPanel.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.tableLayoutPanel.Location = new System.Drawing.Point(9, 9);
|
||||
this.tableLayoutPanel.Name = "tableLayoutPanel";
|
||||
this.tableLayoutPanel.RowCount = 7;
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
@@ -93,35 +91,35 @@
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tableLayoutPanel.Size = new System.Drawing.Size(764, 488);
|
||||
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 11F));
|
||||
this.tableLayoutPanel.Size = new System.Drawing.Size(417, 265);
|
||||
this.tableLayoutPanel.TabIndex = 0;
|
||||
//
|
||||
// reportGeneratingVersionLabel
|
||||
//
|
||||
this.reportGeneratingVersionLabel.AutoSize = true;
|
||||
this.reportGeneratingVersionLabel.Location = new System.Drawing.Point(3, 387);
|
||||
this.reportGeneratingVersionLabel.Location = new System.Drawing.Point(2, 210);
|
||||
this.reportGeneratingVersionLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.reportGeneratingVersionLabel.Name = "reportGeneratingVersionLabel";
|
||||
this.reportGeneratingVersionLabel.Size = new System.Drawing.Size(314, 25);
|
||||
this.reportGeneratingVersionLabel.Size = new System.Drawing.Size(171, 13);
|
||||
this.reportGeneratingVersionLabel.TabIndex = 25;
|
||||
this.reportGeneratingVersionLabel.Text = "Report Generating Engine Version:";
|
||||
//
|
||||
// AboutBox1
|
||||
// AboutBox
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackgroundImage = global::AdvertsingProfitControl.Properties.Resources.Large_Allens_Icon_Template___Copy;
|
||||
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.ClientSize = new System.Drawing.Size(798, 522);
|
||||
this.ClientSize = new System.Drawing.Size(435, 283);
|
||||
this.Controls.Add(this.tableLayoutPanel);
|
||||
this.DoubleBuffered = true;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "AboutBox1";
|
||||
this.Padding = new System.Windows.Forms.Padding(17);
|
||||
this.Name = "AboutBox";
|
||||
this.Padding = new System.Windows.Forms.Padding(9, 9, 9, 9);
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
@@ -1,12 +1,13 @@
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using AdvertisingProfitControlData;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
internal partial class AboutBox1 : Form
|
||||
internal partial class AboutBox : Form
|
||||
{
|
||||
public AboutBox1()
|
||||
public AboutBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
labelProductVerion.Text = $@"Advertising Profit Control Version: {Assembly.GetEntryAssembly().GetName().Version}";
|
||||
@@ -109,7 +109,6 @@
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
@@ -120,25 +119,14 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AboutBox1.cs">
|
||||
<Compile Include="AboutBox.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="AboutBox1.Designer.cs">
|
||||
<DependentUpon>AboutBox1.cs</DependentUpon>
|
||||
<Compile Include="AboutBox.Designer.cs">
|
||||
<DependentUpon>AboutBox.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ActualSale.cs" />
|
||||
<Compile Include="AdItem.cs" />
|
||||
<Compile Include="AdSpecial.cs" />
|
||||
<Compile Include="AdvertisingProfitControlModel.cs" />
|
||||
<Compile Include="AdvertisingProfitControlTableHelper.cs" />
|
||||
<Compile Include="ApplicationColors.cs" />
|
||||
<Compile Include="CostAnalysi.cs" />
|
||||
<Compile Include="DebugDatabaseConverter.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DebugDatabaseConverter.Designer.cs">
|
||||
<DependentUpon>DebugDatabaseConverter.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FrmChangeShrink.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -182,24 +170,18 @@
|
||||
<DependentUpon>FrmReportSettings.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Holiday.cs" />
|
||||
<Compile Include="Inventory.cs" />
|
||||
<Compile Include="Invoice.cs" />
|
||||
<Compile Include="NewModifyRecord.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NewModifyRecord.Designer.cs">
|
||||
<DependentUpon>NewModifyRecord.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Note.cs" />
|
||||
<Compile Include="Projection.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ReportGenerator.cs" />
|
||||
<Compile Include="Supplier.cs" />
|
||||
<Compile Include="Taxable.cs" />
|
||||
<Compile Include="TextFormat.cs" />
|
||||
<Compile Include="BackPageGenerator.cs" />
|
||||
<Compile Include="FrmAddRecord.cs">
|
||||
@@ -225,14 +207,8 @@
|
||||
<Compile Include="RowParsing.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Version.cs" />
|
||||
<Compile Include="WeekEndingDate.cs" />
|
||||
<Compile Include="WeeklySale.cs" />
|
||||
<EmbeddedResource Include="AboutBox1.resx">
|
||||
<DependentUpon>AboutBox1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="DebugDatabaseConverter.resx">
|
||||
<DependentUpon>DebugDatabaseConverter.cs</DependentUpon>
|
||||
<EmbeddedResource Include="AboutBox.resx">
|
||||
<DependentUpon>AboutBox.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="FrmAddRecord.resx">
|
||||
<DependentUpon>FrmAddRecord.cs</DependentUpon>
|
||||
@@ -326,7 +302,12 @@
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AdvertisingProfitControlData\AdvertisingProfitControlData.csproj">
|
||||
<Project>{e30f8b0e-dff3-4ab7-8d0c-47bd11164e51}</Project>
|
||||
<Name>AdvertisingProfitControlData</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.UI;
|
||||
using Pechkin;
|
||||
using AdvertisingProfitControlData;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
partial class DebugDatabaseConverter
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.existingDatesListBox = new System.Windows.Forms.ListBox();
|
||||
this.datesToConvertListBox = new System.Windows.Forms.ListBox();
|
||||
this.moveOverButton = new System.Windows.Forms.Button();
|
||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||
this.convertButton = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.webBrowser1 = new System.Windows.Forms.WebBrowser();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// existingDatesListBox
|
||||
//
|
||||
this.existingDatesListBox.FormattingEnabled = true;
|
||||
this.existingDatesListBox.ItemHeight = 24;
|
||||
this.existingDatesListBox.Location = new System.Drawing.Point(23, 12);
|
||||
this.existingDatesListBox.Name = "existingDatesListBox";
|
||||
this.existingDatesListBox.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
|
||||
this.existingDatesListBox.Size = new System.Drawing.Size(353, 364);
|
||||
this.existingDatesListBox.TabIndex = 0;
|
||||
//
|
||||
// datesToConvertListBox
|
||||
//
|
||||
this.datesToConvertListBox.FormattingEnabled = true;
|
||||
this.datesToConvertListBox.ItemHeight = 24;
|
||||
this.datesToConvertListBox.Location = new System.Drawing.Point(556, 29);
|
||||
this.datesToConvertListBox.Name = "datesToConvertListBox";
|
||||
this.datesToConvertListBox.Size = new System.Drawing.Size(97, 52);
|
||||
this.datesToConvertListBox.TabIndex = 1;
|
||||
//
|
||||
// moveOverButton
|
||||
//
|
||||
this.moveOverButton.Enabled = false;
|
||||
this.moveOverButton.Location = new System.Drawing.Point(381, 417);
|
||||
this.moveOverButton.Name = "moveOverButton";
|
||||
this.moveOverButton.Size = new System.Drawing.Size(160, 56);
|
||||
this.moveOverButton.TabIndex = 2;
|
||||
this.moveOverButton.Text = "Move Selected";
|
||||
this.moveOverButton.UseVisualStyleBackColor = true;
|
||||
this.moveOverButton.Click += new System.EventHandler(this.MoveOverButton_Click);
|
||||
//
|
||||
// openFileDialog1
|
||||
//
|
||||
this.openFileDialog1.FileName = "openFileDialog1";
|
||||
//
|
||||
// convertButton
|
||||
//
|
||||
this.convertButton.Location = new System.Drawing.Point(556, 530);
|
||||
this.convertButton.Name = "convertButton";
|
||||
this.convertButton.Size = new System.Drawing.Size(133, 50);
|
||||
this.convertButton.TabIndex = 3;
|
||||
this.convertButton.Text = "Convert";
|
||||
this.convertButton.UseVisualStyleBackColor = true;
|
||||
this.convertButton.Click += new System.EventHandler(this.convertButton_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 515);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(64, 25);
|
||||
this.label1.TabIndex = 4;
|
||||
this.label1.Text = "label1";
|
||||
//
|
||||
// webBrowser1
|
||||
//
|
||||
this.webBrowser1.AllowNavigation = false;
|
||||
this.webBrowser1.AllowWebBrowserDrop = false;
|
||||
this.webBrowser1.Location = new System.Drawing.Point(776, 53);
|
||||
this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20);
|
||||
this.webBrowser1.Name = "webBrowser1";
|
||||
this.webBrowser1.Size = new System.Drawing.Size(1524, 940);
|
||||
this.webBrowser1.TabIndex = 6;
|
||||
this.webBrowser1.Url = new System.Uri("file:///C:/Users/Crypto/Desktop/FrontPage.html", System.UriKind.Absolute);
|
||||
//
|
||||
// DebugDatabaseConverter
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(2374, 1114);
|
||||
this.Controls.Add(this.webBrowser1);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.convertButton);
|
||||
this.Controls.Add(this.moveOverButton);
|
||||
this.Controls.Add(this.datesToConvertListBox);
|
||||
this.Controls.Add(this.existingDatesListBox);
|
||||
this.Name = "DebugDatabaseConverter";
|
||||
this.Text = "DebugDatabaseConverter";
|
||||
this.Load += new System.EventHandler(this.DebugDatabaseConverter_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ListBox existingDatesListBox;
|
||||
private System.Windows.Forms.ListBox datesToConvertListBox;
|
||||
private System.Windows.Forms.Button moveOverButton;
|
||||
private System.Windows.Forms.OpenFileDialog openFileDialog1;
|
||||
private System.Windows.Forms.Button convertButton;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.WebBrowser webBrowser1;
|
||||
}
|
||||
}
|
||||
@@ -1,799 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Transactions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
public partial class DebugDatabaseConverter : Form
|
||||
{
|
||||
private string _filePath;
|
||||
private string _connectionString;
|
||||
public DebugDatabaseConverter()
|
||||
{
|
||||
InitializeComponent();
|
||||
existingDatesListBox.SelectedIndexChanged += EnableButton;
|
||||
}
|
||||
|
||||
private void EnableButton(object sender, EventArgs e)
|
||||
{
|
||||
moveOverButton.Enabled = true;
|
||||
}
|
||||
|
||||
private void DebugDatabaseConverter_Load(object sender, EventArgs e)
|
||||
{
|
||||
openFileDialog1.DefaultExt = "accdb";
|
||||
openFileDialog1.Filter = @"Access Files (*.accdb) | *.accdb";
|
||||
|
||||
if (openFileDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var filePath = openFileDialog1.FileName;
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
_filePath = filePath;
|
||||
//Get the list of dates.
|
||||
var connectionString =
|
||||
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Persist Security Info=False";
|
||||
_connectionString = connectionString;
|
||||
var dates = new List<DateTime>();
|
||||
var oleDbCommand = new OleDbCommand
|
||||
{
|
||||
CommandText = "SELECT EndOfWeekDate FROM WeekEnding"
|
||||
};
|
||||
var connection = new OleDbConnection(connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
using (var reader = oleDbCommand.ExecuteReader())
|
||||
{
|
||||
while (reader != null && reader.Read())
|
||||
{
|
||||
dates.Add(DateTime.Parse(reader[0].ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
connection.Close();
|
||||
}
|
||||
|
||||
foreach (var date in dates)
|
||||
{
|
||||
existingDatesListBox.Items.Add(date.ToShortDateString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void MoveOverButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (existingDatesListBox.SelectedIndex == -1) return;
|
||||
foreach (var index in existingDatesListBox.SelectedItems)
|
||||
{
|
||||
datesToConvertListBox.Items.Add(index);
|
||||
//existingDatesListBox.Items.Remove(index);
|
||||
}
|
||||
moveOverButton.Enabled = false;
|
||||
}
|
||||
|
||||
private void convertButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (datesToConvertListBox.Items.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//Start by bringing in all the ad items then the suppliers.
|
||||
var adItems = GetAdItems();
|
||||
foreach (var adItem in adItems)
|
||||
{
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
if (db.AdItems.Any(x => x.Name == adItem)) continue;
|
||||
var temp = new AdItem { Name = TextFormat.FormatAdItemText(adItem) };
|
||||
db.AdItems.Add(temp);
|
||||
db.SaveChanges();
|
||||
}
|
||||
var suppliers = GetSuppliers();
|
||||
foreach (var supplier in suppliers)
|
||||
{
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
if (db.Suppliers.Any(x => x.Name == supplier)) continue;
|
||||
var temp = new Supplier { Name = supplier };
|
||||
db.Suppliers.Add(temp);
|
||||
db.SaveChanges();
|
||||
}
|
||||
var adSpecials = GetAdSpecials();
|
||||
foreach (var adSpecial in adSpecials)
|
||||
{
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
if(db.AdSpecials.Any(x => x.Name == adSpecial)) continue;
|
||||
var tempAd = new AdSpecial
|
||||
{
|
||||
Name = adSpecial
|
||||
};
|
||||
db.AdSpecials.Add(tempAd);
|
||||
db.SaveChanges();
|
||||
}
|
||||
foreach (var date in datesToConvertListBox.Items)
|
||||
{
|
||||
var oldDateId = GetDateIdByDateString(date.ToString());
|
||||
//Get the tables.
|
||||
var projectionsTable = ReturnProjections(oldDateId);
|
||||
var inventoryTable = ReturnInventory(oldDateId);
|
||||
var actualSales = ReturnActualSales(oldDateId);
|
||||
var invoices = ReturnInvoiceTable(oldDateId);
|
||||
var weeklySales = ReturnWeeklySalesFromDateId(oldDateId);
|
||||
var taxable = ReturnTaxableFromDateId(oldDateId, _connectionString);
|
||||
var comment = GetComments(oldDateId);
|
||||
var costs = ReturnCostAnalysis(oldDateId, _connectionString);
|
||||
MassiveWriteFunction(date.ToString(), projectionsTable, inventoryTable, actualSales, invoices, weeklySales, taxable, costs, comment);
|
||||
}
|
||||
}
|
||||
|
||||
private void MassiveWriteFunction(string dateString, DataTable projections, DataTable inventory, DataTable actualSales, DataTable invoice, DataTable weeklySales, DataTable taxableTable, DataTable costOfSales, string comments)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var transaction = new TransactionScope())
|
||||
{
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var date = new WeekEndingDate {EndingDate = DateTime.Parse(dateString)};
|
||||
if (db.WeekEndingDates.Any(x => x.EndingDate == date.EndingDate))
|
||||
{
|
||||
date = db.WeekEndingDates.First(x => x.EndingDate == date.EndingDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
db.WeekEndingDates.Add(date);
|
||||
}
|
||||
var adSpecialId = -1;
|
||||
for (var rowIndex = 0; rowIndex < projections.Rows.Count; rowIndex++)
|
||||
{
|
||||
var projectionedSale = new Projection();
|
||||
var adItem = new AdItem();
|
||||
var adItemId = 0;
|
||||
//var id = int.Parse(projections.Rows[rowIndex][0].ToString());
|
||||
var spam = TextFormat.FormatAdItemText(projections.Rows[rowIndex][0].ToString());
|
||||
if (db.AdItems.Any(x => x.Name == spam))
|
||||
{
|
||||
//Exists
|
||||
adItem = db.AdItems.First(x => x.Name == spam);
|
||||
adItemId = adItem.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Doesn't
|
||||
adItem.Name = projections.Rows[rowIndex][0].ToString();
|
||||
db.AdItems.Add(adItem);
|
||||
adItemId = adItem.Id;
|
||||
}
|
||||
projectionedSale.Sold = projections.Rows[rowIndex][1].ToString();
|
||||
projectionedSale.SalePrice = projections.Rows[rowIndex][2].ToString();
|
||||
projectionedSale.TotalSales = decimal.Parse(projections.Rows[rowIndex][3].ToString());
|
||||
projectionedSale.Cost = decimal.Parse(projections.Rows[rowIndex][4].ToString());
|
||||
projectionedSale.ProfitReturn = decimal.Parse(projections.Rows[rowIndex][5].ToString());
|
||||
projectionedSale.TotalProfitReturn = decimal.Parse(projections.Rows[rowIndex][6].ToString());
|
||||
projectionedSale.FkAdItemId = db.AdItems.First(x => x.Id == adItemId).Id;
|
||||
projectionedSale.RowAttribute = int.Parse(projections.Rows[rowIndex][7].ToString());
|
||||
|
||||
if ((int) projections.Rows[rowIndex][8] == 0 && adSpecialId == -1)
|
||||
{
|
||||
projectionedSale.FkAdSpecialId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((int) (projections.Rows[rowIndex][8]) == 0)
|
||||
{
|
||||
projectionedSale.FkAdSpecialId = adSpecialId;
|
||||
}
|
||||
else
|
||||
{
|
||||
adSpecialId = (int) projections.Rows[rowIndex][8];
|
||||
projectionedSale.FkAdSpecialId = (int) projections.Rows[rowIndex][8];
|
||||
}
|
||||
}
|
||||
projectionedSale.RowPosition = rowIndex + 1;
|
||||
projectionedSale.FkDateId = date.Id;
|
||||
db.Projections.Add(projectionedSale);
|
||||
}
|
||||
//inventory
|
||||
adSpecialId = -1;
|
||||
for (var i = 0; i < inventory.Rows.Count; i++)
|
||||
{
|
||||
var inventoryObject = new Inventory();
|
||||
AdItem adItem;
|
||||
var adItemId = 0;
|
||||
var spam = TextFormat.FormatAdItemText(inventory.Rows[i][0].ToString());
|
||||
if (db.AdItems.Any(x => x.Name == spam))
|
||||
{
|
||||
//Exists
|
||||
adItem = db.AdItems.First(x => x.Name == spam);
|
||||
adItemId = adItem.Id;
|
||||
}
|
||||
inventoryObject.BeginningInventory = inventory.Rows[i][1].ToString();
|
||||
inventoryObject.Recieved = inventory.Rows[i][2].ToString();
|
||||
inventoryObject.TotalInventory = inventory.Rows[i][3].ToString();
|
||||
inventoryObject.EndingInventory = inventory.Rows[i][4].ToString();
|
||||
inventoryObject.FkAdItemId = adItemId;
|
||||
inventoryObject.RowAttribute = int.Parse(inventory.Rows[i][5].ToString());
|
||||
if ((int)inventory.Rows[i][6] == 0 && adSpecialId == -1)
|
||||
{
|
||||
inventoryObject.FkAdSpecialId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((int)(inventory.Rows[i][6]) == 0)
|
||||
{
|
||||
inventoryObject.FkAdSpecialId = adSpecialId;
|
||||
}
|
||||
else
|
||||
{
|
||||
adSpecialId = (int)inventory.Rows[i][6];
|
||||
inventoryObject.FkAdSpecialId = (int)inventory.Rows[i][6];
|
||||
}
|
||||
}
|
||||
inventoryObject.RowPosition = i + 1;
|
||||
inventoryObject.FkDateId = date.Id;
|
||||
db.Inventories.Add(inventoryObject);
|
||||
}
|
||||
|
||||
//actual sales
|
||||
adSpecialId = -1;
|
||||
for (var rowIndex = 0; rowIndex < actualSales.Rows.Count; rowIndex++)
|
||||
{
|
||||
var actualSale = new ActualSale();
|
||||
//Get the ID number of the ad item.
|
||||
var adItemId = 0;
|
||||
var spam = TextFormat.FormatAdItemText(actualSales.Rows[rowIndex][0].ToString());
|
||||
if (db.AdItems.Any(x => x.Name == spam))
|
||||
{
|
||||
//Exists
|
||||
var adItem = db.AdItems.First(x => x.Name == spam);
|
||||
adItemId = adItem.Id;
|
||||
}
|
||||
//adspecialId = GetAdSpecialId(int.Parse(actualSales.Rows[rowIndex][8].ToString()));
|
||||
//oleDbCommand.CommandText =
|
||||
// "INSERT INTO ActualSales (Sold, SalePrice, TotalSales, Cost, ProfitReturn, TotalProfitReturn, FK_AdItemID, RowAttribute, FK_AdSpecialGroupName, RowPosition, FK_DateID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
//SELECT AdItem.AdItem, APC.ProjectionSold, APC.ProjectionSalePrice, APC.ProjectionTotalSales, APC.ProjectionCost, APC.ProjectionProfitReturn, APC.ProjectionTotalProfitReturn, APC.RowAttribute, APC.FK_GroupID FROM (AdItem INNER JOIN APC ON AdItem.ID = APC.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC
|
||||
|
||||
//SELECT Projections.ID, AdItem.AdItem, Projections.Sold, Projections.SalePrice, Projections.TotalSales, Projections.Cost, Projections.ProfitReturn, Projections.TotalProfitReturn, Projections.RowAttribute, Projections.FK_AdSpecialGroupName FROM (AdItem INNER JOIN Projections ON AdItem.ID = Projections.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC
|
||||
actualSale.Sold = actualSales.Rows[rowIndex][1].ToString();
|
||||
actualSale.SalePrice = actualSales.Rows[rowIndex][2].ToString();
|
||||
actualSale.TotalSales = decimal.Parse(actualSales.Rows[rowIndex][3].ToString());
|
||||
actualSale.Cost = decimal.Parse(actualSales.Rows[rowIndex][4].ToString());
|
||||
actualSale.ProfitReturn = decimal.Parse(actualSales.Rows[rowIndex][5].ToString());
|
||||
actualSale.TotalProfitReturn = decimal.Parse(actualSales.Rows[rowIndex][6].ToString());
|
||||
actualSale.FkAdItemId = adItemId;
|
||||
actualSale.RowAttribute = int.Parse(actualSales.Rows[rowIndex][7].ToString());
|
||||
if ((int)actualSales.Rows[rowIndex][8] == 0 && adSpecialId == -1)
|
||||
{
|
||||
actualSale.FkAdSpecialId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((int)(projections.Rows[rowIndex][8]) == 0)
|
||||
{
|
||||
actualSale.FkAdSpecialId = adSpecialId;
|
||||
}
|
||||
else
|
||||
{
|
||||
adSpecialId = (int)actualSales.Rows[rowIndex][8];
|
||||
actualSale.FkAdSpecialId = (int)actualSales.Rows[rowIndex][8];
|
||||
}
|
||||
}
|
||||
actualSale.RowPosition = rowIndex + 1;
|
||||
actualSale.FkDateId = date.Id; //db.WeekEndingDates.First(x => x.Id == dateId);
|
||||
//oleDbCommand.Parameters.AddWithValue("Sold", actualSales.Rows[rowIndex][1]);
|
||||
//oleDbCommand.Parameters.AddWithValue("SalesPrice", actualSales.Rows[rowIndex][2]);
|
||||
//oleDbCommand.Parameters.AddWithValue("TotalSales", actualSales.Rows[rowIndex][3]);
|
||||
//oleDbCommand.Parameters.AddWithValue("Cost", actualSales.Rows[rowIndex][4]);
|
||||
//oleDbCommand.Parameters.AddWithValue("ProfitReturn", actualSales.Rows[rowIndex][5]);
|
||||
//oleDbCommand.Parameters.AddWithValue("TotalProfitReturn", actualSales.Rows[rowIndex][6]);
|
||||
//oleDbCommand.Parameters.AddWithValue("adItemID", adItemId);
|
||||
//oleDbCommand.Parameters.AddWithValue("RowAttribute",
|
||||
// int.Parse(projections.Rows[rowIndex][7].ToString()));
|
||||
//oleDbCommand.Parameters.AddWithValue("adSpecialID", adspecialId);
|
||||
//oleDbCommand.Parameters.AddWithValue("RowPosition", (rowIndex + 1));
|
||||
//oleDbCommand.Parameters.AddWithValue("dateID", dateId);
|
||||
//oleDbCommand.ExecuteNonQuery();
|
||||
//oleDbCommand.Parameters.Clear();
|
||||
db.ActualSales.Add(actualSale);
|
||||
}
|
||||
|
||||
for (var i = 0; i < invoice.Rows.Count; i++)
|
||||
{
|
||||
var invoiceObject = new Invoice();
|
||||
var supplier = new Supplier();
|
||||
var spam = invoice.Rows[i][1].ToString();
|
||||
if (db.Suppliers.Any(x => x.Name == spam))
|
||||
{
|
||||
supplier = db.Suppliers.First(x => x.Name == spam);
|
||||
}
|
||||
else
|
||||
{
|
||||
supplier.Name = invoice.Rows[i][1].ToString();
|
||||
db.Suppliers.Add(supplier);
|
||||
}
|
||||
invoiceObject.InvoiceDate = DateTime.Parse(invoice.Rows[i][0].ToString());
|
||||
invoiceObject.InvoiceNumber = invoice.Rows[i][2].ToString();
|
||||
invoiceObject.InvoiceNetAmountAtCost = decimal.Parse(invoice.Rows[i][3].ToString());
|
||||
invoiceObject.InvoiceNetAmount = decimal.Parse(invoice.Rows[i][4].ToString());
|
||||
invoiceObject.InvoiceNote = invoice.Rows[i][5].ToString();
|
||||
invoiceObject.FkSupplierId = supplier.Id;
|
||||
invoiceObject.FkDateId = date.Id;
|
||||
db.Invoices.Add(invoiceObject);
|
||||
// //SELECT Invoice.InvoiceDate, Supplier.SupplierName, Invoice.InvoiceNumber, Invoice.InvoiceNetAmountAtCost, Invoice.InvoiceNetAmount, Invoice.InvoiceNote FROM (Supplier INNER JOIN Invoice ON Supplier.ID = Invoice.FK_Supplier) WHERE FK_DateID = ?
|
||||
// oleDbCommand.CommandText =
|
||||
// "INSERT INTO Invoice (InvoiceDate, InvoiceNumber, InvoiceNetAmountAtCost, InvoiceNetAmount, InvoiceNote, FK_Supplier, FK_DateID) VALUES(?,?,?,?,?,?,?)";
|
||||
// oleDbCommand.Parameters.AddWithValue("InvoiceDate", invoice.Rows[i][0].ToString());
|
||||
// oleDbCommand.Parameters.AddWithValue("InvoiceNumber", invoice.Rows[i][2].ToString());
|
||||
// oleDbCommand.Parameters.AddWithValue("InvoiceNetAmountAtCost",
|
||||
// invoice.Rows[i][3].ToString() == "" ? 0 : double.Parse(invoice.Rows[i][3].ToString()));
|
||||
// oleDbCommand.Parameters.AddWithValue("InvoiceNetAmount",
|
||||
// invoice.Rows[i][4].ToString() == "" ? 0 : double.Parse(invoice.Rows[i][4].ToString()));
|
||||
// oleDbCommand.Parameters.AddWithValue("InvoiceNote", invoice.Rows[i][5].ToString());
|
||||
// oleDbCommand.Parameters.AddWithValue("FK_Supplier", supplier.Id);
|
||||
// oleDbCommand.Parameters.AddWithValue("FK_DateID", dateId);
|
||||
// oleDbCommand.ExecuteNonQuery();
|
||||
// oleDbCommand.Parameters.Clear();
|
||||
}
|
||||
if (weeklySales.Rows.Count == 1)
|
||||
{
|
||||
var weeklySale = new WeeklySale
|
||||
{
|
||||
Sunday = decimal.Parse(weeklySales.Rows[0][0].ToString()),
|
||||
Monday = decimal.Parse(weeklySales.Rows[0][1].ToString()),
|
||||
Tuesday = decimal.Parse(weeklySales.Rows[0][2].ToString()),
|
||||
Wednesday = decimal.Parse(weeklySales.Rows[0][3].ToString()),
|
||||
Thursday = decimal.Parse(weeklySales.Rows[0][4].ToString()),
|
||||
Friday = decimal.Parse(weeklySales.Rows[0][5].ToString()),
|
||||
Saturday = decimal.Parse(weeklySales.Rows[0][6].ToString()),
|
||||
TotalSales = decimal.Parse(weeklySales.Rows[0][7].ToString()),
|
||||
FkDateId = date.Id
|
||||
};
|
||||
db.WeeklySales.Add(weeklySale);
|
||||
}
|
||||
|
||||
if (taxableTable.Rows.Count == 1)
|
||||
{
|
||||
//Comes from DatabaseReader class, so offset by one because zero is the ID number.
|
||||
var taxable = new Taxable
|
||||
{
|
||||
Sunday = decimal.Parse(taxableTable.Rows[0][1].ToString()),
|
||||
Monday = decimal.Parse(taxableTable.Rows[0][2].ToString()),
|
||||
Tuesday = decimal.Parse(taxableTable.Rows[0][3].ToString()),
|
||||
Wednesday = decimal.Parse(taxableTable.Rows[0][4].ToString()),
|
||||
Thursday = decimal.Parse(taxableTable.Rows[0][5].ToString()),
|
||||
Friday = decimal.Parse(taxableTable.Rows[0][6].ToString()),
|
||||
Saturday = decimal.Parse(taxableTable.Rows[0][7].ToString()),
|
||||
Total = decimal.Parse(taxableTable.Rows[0][8].ToString()),
|
||||
FkDateId = date.Id
|
||||
};
|
||||
db.Taxables.Add(taxable);
|
||||
}
|
||||
//SELECT CostOfSalesAnalysis.ID, CostOfSalesAnalysis.SalesPerManHour, CostOfSalesAnalysis.SalaryPercentage, CostOfSalesAnalysis.SalaryDollars, CostOfSalesAnalysis.Supplies FROM CostOfSalesAnalysis WHERE FK_DateID = ?
|
||||
if (costOfSales.Rows.Count == 1)
|
||||
{
|
||||
var cost = new CostAnalysi
|
||||
{
|
||||
SalesPerManHour = decimal.Parse(costOfSales.Rows[0][1].ToString()),
|
||||
SalaryPercentage = decimal.Parse(costOfSales.Rows[0][2].ToString()),
|
||||
SalaryDollar = decimal.Parse(costOfSales.Rows[0][3].ToString()),
|
||||
Supplies = decimal.Parse(costOfSales.Rows[0][4].ToString()),
|
||||
FkDateId = date.Id
|
||||
};
|
||||
db.CostAnalysis.Add(cost);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(comments))
|
||||
{
|
||||
var comment = new Note
|
||||
{
|
||||
Remark = comments,
|
||||
FkDateId = date.Id
|
||||
};
|
||||
db.Notes.Add(comment);
|
||||
}
|
||||
//oleDbCommand.Parameters.Clear();
|
||||
//oleDbCommand.CommandText = "INSERT INTO Comment (Comment, FK_DateID) VALUES (?, ?)";
|
||||
//oleDbCommand.Parameters.AddWithValue("Com", comments);
|
||||
//oleDbCommand.Parameters.AddWithValue("FK", dateId);
|
||||
//oleDbCommand.ExecuteNonQuery();
|
||||
//oleDbTransaction.Commit();
|
||||
db.SaveChanges();
|
||||
transaction.Complete();
|
||||
}
|
||||
}
|
||||
catch (OleDbException e)
|
||||
{
|
||||
MessageBox.Show(e.Message);
|
||||
//oleDbTransaction?.Rollback();
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> GetAdItems()
|
||||
{
|
||||
var adItems = new List<string>();
|
||||
var oleDbCommand = new OleDbCommand
|
||||
{
|
||||
CommandText = "SELECT AdItem.AdItem FROM AdItem ORDER BY AdItem.AdItem ASC"
|
||||
};
|
||||
var connection = new OleDbConnection(_connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
var reader = oleDbCommand.ExecuteReader();
|
||||
while (reader != null && reader.Read())
|
||||
{
|
||||
adItems.Add(reader[0].ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return adItems;
|
||||
}
|
||||
|
||||
public List<string> GetSuppliers()
|
||||
{
|
||||
var adItems = new List<string>();
|
||||
var oleDbCommand = new OleDbCommand
|
||||
{
|
||||
CommandText = "SELECT Supplier.SupplierName FROM Supplier ORDER BY Supplier.SupplierName ASC"
|
||||
};
|
||||
var connection = new OleDbConnection(_connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
var reader = oleDbCommand.ExecuteReader();
|
||||
while (reader != null && reader.Read())
|
||||
{
|
||||
adItems.Add(reader[0].ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return adItems;
|
||||
}
|
||||
|
||||
public List<string> GetAdSpecials()
|
||||
{
|
||||
var adItems = new List<string>();
|
||||
var oleDbCommand = new OleDbCommand
|
||||
{
|
||||
CommandText = "SELECT AdSpecialName.AdSpecialName FROM AdSpecialName"
|
||||
};
|
||||
var connection = new OleDbConnection(_connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
var reader = oleDbCommand.ExecuteReader();
|
||||
while (reader != null && reader.Read())
|
||||
{
|
||||
adItems.Add(reader[0].ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return adItems;
|
||||
}
|
||||
|
||||
public int GetSupplierId(string supplierName)
|
||||
{
|
||||
var supplier = new Supplier();
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
try
|
||||
{
|
||||
if (db.Suppliers.Any(x => x.Name == supplierName))
|
||||
{
|
||||
return db.Suppliers.First(x => x.Name == supplierName).Id;
|
||||
}
|
||||
//No match
|
||||
supplier.Name = supplierName;
|
||||
db.Suppliers.Add(supplier);
|
||||
db.SaveChanges();
|
||||
return supplier.Id;
|
||||
}
|
||||
catch (OleDbException e)
|
||||
{
|
||||
MessageBox.Show(e.Message);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private string GetComments(int dateId)
|
||||
{
|
||||
var comments = "";
|
||||
var oleDbCommand = new OleDbCommand
|
||||
{
|
||||
CommandText = "SELECT Comment.Comment FROM Comment WHERE Comment.FK_DateID = ?"
|
||||
};
|
||||
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
|
||||
var connection = new OleDbConnection(_connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
var reader = oleDbCommand.ExecuteReader();
|
||||
while (reader != null && reader.Read())
|
||||
{
|
||||
comments = reader[0].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return comments;
|
||||
}
|
||||
|
||||
public string RetrieveAdItemName(int id)
|
||||
{
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
{
|
||||
CommandText = "SELECT AdItem.AdItem FROM AdItem WHERE AdItem.ID = ?"
|
||||
};
|
||||
oleDbCommand.Parameters.AddWithValue("ding", id);
|
||||
var connection = new OleDbConnection(_connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
var adItemName = "";
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
using (var reader = oleDbCommand.ExecuteReader())
|
||||
{
|
||||
while (reader != null && reader.Read())
|
||||
{
|
||||
adItemName = reader[0].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
connection.Close();
|
||||
}
|
||||
|
||||
return adItemName;
|
||||
}
|
||||
|
||||
private int GetDateIdByDateString(string dateString)
|
||||
{
|
||||
var dateId = 0;
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
{
|
||||
CommandText = "SELECT WeekEnding.ID FROM WeekEnding WHERE WeekEnding.EndOfWeekDate = ?"
|
||||
};
|
||||
oleDbCommand.Parameters.AddWithValue("DateString", dateString);
|
||||
var connection = new OleDbConnection(_connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
using (var reader = oleDbCommand.ExecuteReader())
|
||||
{
|
||||
while (reader != null && reader.Read())
|
||||
{
|
||||
dateId = int.Parse(reader[0].ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
connection.Close();
|
||||
}
|
||||
|
||||
return dateId;
|
||||
}
|
||||
|
||||
private DataTable ReturnProjections(int dateId)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand
|
||||
{
|
||||
CommandText = "SELECT AdItem.AdItem, Projections.Sold, Projections.SalePrice, Projections.TotalSales, Projections.Cost, Projections.ProfitReturn, Projections.TotalProfitReturn, Projections.RowAttribute, Projections.FK_AdSpecialGroupName FROM (AdItem INNER JOIN Projections ON AdItem.ID = Projections.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC"
|
||||
};
|
||||
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
|
||||
var connection = new OleDbConnection(_connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
using (var dataAdapter = new OleDbDataAdapter(oleDbCommand))
|
||||
{
|
||||
dataAdapter.Fill(dataTable);
|
||||
}
|
||||
}
|
||||
connection.Close();
|
||||
}
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTable ReturnInventory(int dateId)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
{
|
||||
CommandText = "SELECT AdItem.AdItem, Inventory.BeginningInventory, Inventory.Received, Inventory.TotalInventory, Inventory.EndingInventory, Inventory.RowAttribute, Inventory.FK_AdSpecialGroupName FROM (AdItem INNER JOIN Inventory ON AdItem.ID = Inventory.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC"
|
||||
};
|
||||
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
|
||||
var connection = new OleDbConnection(_connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
using (var dataAdapter = new OleDbDataAdapter(oleDbCommand))
|
||||
{
|
||||
dataAdapter.Fill(dataTable);
|
||||
}
|
||||
}
|
||||
connection.Close();
|
||||
}
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTable ReturnActualSales(int dateId)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
{
|
||||
CommandText = "SELECT AdItem.AdItem, ActualSales.Sold, ActualSales.SalePrice, ActualSales.TotalSales, ActualSales.Cost, ActualSales.ProfitReturn, ActualSales.TotalProfitReturn, ActualSales.RowAttribute, ActualSales.FK_AdSpecialGroupName FROM (AdItem INNER JOIN ActualSales ON AdItem.ID = ActualSales.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC"
|
||||
};
|
||||
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
|
||||
var connection = new OleDbConnection(_connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
using (var dataAdapter = new OleDbDataAdapter(oleDbCommand))
|
||||
{
|
||||
dataAdapter.Fill(dataTable);
|
||||
}
|
||||
}
|
||||
connection.Close();
|
||||
}
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTable ReturnInvoiceTable(int dateId)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
{
|
||||
CommandText = "SELECT Invoice.InvoiceDate, Supplier.SupplierName, Invoice.InvoiceNumber, Invoice.InvoiceNetAmountAtCost, Invoice.InvoiceNetAmount, Invoice.InvoiceNote FROM (Supplier INNER JOIN Invoice ON Supplier.ID = Invoice.FK_Supplier) WHERE FK_DateID = ?"
|
||||
};
|
||||
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
|
||||
var connection = new OleDbConnection(_connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
using (var adapter = new OleDbDataAdapter(oleDbCommand))
|
||||
{
|
||||
adapter.Fill(dataTable);
|
||||
}
|
||||
}
|
||||
connection.Close();
|
||||
}
|
||||
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTable ReturnWeeklySalesFromDateId(int dateId)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
{
|
||||
CommandText = "SELECT WeeklySales.Sunday, WeeklySales.Monday, WeeklySales.Tuesday, WeeklySales.Wednesday, WeeklySales.Thursday, WeeklySales.Friday, WeeklySales.Saturday, WeeklySales.TotalSales FROM WeeklySales WHERE FK_DateID = ?"
|
||||
};
|
||||
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
|
||||
var connection = new OleDbConnection(_connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
using (var dataAdapter = new OleDbDataAdapter(oleDbCommand))
|
||||
{
|
||||
dataAdapter.Fill(dataTable);
|
||||
}
|
||||
}
|
||||
connection.Close();
|
||||
}
|
||||
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTable ReturnTaxableFromDateId(int dateId, string connectionString)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand
|
||||
{
|
||||
CommandText = "SELECT Taxable.ID, Taxable.Sunday, Taxable.Monday, Taxable.Tuesday, Taxable.Wednesday, Taxable.Thursday, Taxable.Friday, Taxable.Saturday, Taxable.Total FROM Taxable WHERE FK_DateID = ?"
|
||||
};
|
||||
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
|
||||
var connection = new OleDbConnection(connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
using (var dataAdapter = new OleDbDataAdapter(oleDbCommand))
|
||||
{
|
||||
dataAdapter.Fill(dataTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTable ReturnCostAnalysis(int dateId, string connectionString)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand
|
||||
{
|
||||
CommandText = "SELECT CostOfSalesAnalysis.ID, CostOfSalesAnalysis.SalesPerManHour, CostOfSalesAnalysis.SalaryPercentage, CostOfSalesAnalysis.SalaryDollars, CostOfSalesAnalysis.Supplies FROM CostOfSalesAnalysis WHERE FK_DateID = ?"
|
||||
};
|
||||
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
|
||||
var connection = new OleDbConnection(connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
using (var dataAdapter = new OleDbDataAdapter(oleDbCommand))
|
||||
{
|
||||
dataAdapter.Fill(dataTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
using (var scope = new TransactionScope())
|
||||
{
|
||||
var invoices = db.Invoices.Select(x => x);
|
||||
foreach (var invoice in invoices)
|
||||
{
|
||||
invoice.InvoiceNetAmountAtCost = invoice.InvoiceNetAmount;
|
||||
invoice.InvoiceNetAmount = null;
|
||||
|
||||
}
|
||||
db.SaveChanges();
|
||||
scope.Complete();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.Windows.Forms;
|
||||
using AdvertisingProfitControlData;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
@@ -56,7 +57,7 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
ConnectionSuccessful = true;
|
||||
//Try to initialize the database.
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
var db = new AdvertisingProfitControlModel(connectionString);
|
||||
//Force the UI thread to draw the label's text so the user can see it.
|
||||
informationLabel.Text = @"Connection successful! Preparing main form...";
|
||||
informationLabel.Invalidate();
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Drawing.Printing;
|
||||
using System.Linq;
|
||||
using System.Transactions;
|
||||
using System.Windows.Forms;
|
||||
using AdvertisingProfitControlData;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
@@ -268,7 +269,7 @@ namespace AdvertsingProfitControl
|
||||
|
||||
private void DisplayProductVersionNumbers(object sender, EventArgs e)
|
||||
{
|
||||
var form = new AboutBox1();
|
||||
var form = new AboutBox();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
@@ -900,9 +901,7 @@ namespace AdvertsingProfitControl
|
||||
|
||||
private void DisplayDebugTool(object sender, EventArgs e)
|
||||
{
|
||||
var form = new DebugDatabaseConverter();
|
||||
form.ShowDialog();
|
||||
RefreshDateListing();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Data.Entity.Infrastructure;
|
||||
using System.Linq;
|
||||
using System.Transactions;
|
||||
using System.Windows.Forms;
|
||||
using AdvertisingProfitControlData;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Transactions;
|
||||
using System.Windows.Forms;
|
||||
using AdvertisingProfitControlData;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Data.Entity.Infrastructure;
|
||||
using System.Linq;
|
||||
using System.Transactions;
|
||||
using System.Windows.Forms;
|
||||
using AdvertisingProfitControlData;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.IO;
|
||||
using System.Web.UI;
|
||||
using System.Linq;
|
||||
using Pechkin;
|
||||
using AdvertisingProfitControlData;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Transactions;
|
||||
using System.Windows.Forms;
|
||||
using AdvertisingProfitControlData;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
|
||||
public partial class Note
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(256)]
|
||||
public string Remark { get; set; }
|
||||
|
||||
public int FkDateId { get; set; }
|
||||
|
||||
public virtual WeekEndingDate WeekEndingDate { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
|
||||
[Table("Version")]
|
||||
public partial class Version
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[StringLength(32)]
|
||||
public string VersionNumber { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user