First version of the Main form that is able to pull all the required data from the SQL database. Holiday detection is disabled for this build. Fixed some bugs with the debug database conversion code. Still missing Ad Special data in the conversion code.

This commit is contained in:
2017-03-27 14:39:42 -05:00
parent 36fe75d761
commit 9da9540969
39 changed files with 104913 additions and 871 deletions
Binary file not shown.
Binary file not shown.
+41
View File
@@ -0,0 +1,41 @@
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 ActualSale
{
public int Id { get; set; }
[StringLength(128)]
public string Sold { get; set; }
[StringLength(128)]
public string SalePrice { get; set; }
public decimal? TotalSales { get; set; }
public decimal? Cost { get; set; }
public decimal? ProfitReturn { get; set; }
public decimal? TotalProfitReturn { get; set; }
public int RowPosition { get; set; }
public int RowAttribute { get; set; }
public int FkAdItemId { get; set; }
public int FkAdSpecialId { get; set; }
public int FkDateId { get; set; }
public virtual AdItem AdItem { get; set; }
public virtual WeekEndingDate WeekEndingDate { get; set; }
}
}
+37
View File
@@ -0,0 +1,37 @@
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 AdItem
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public AdItem()
{
ActualSales = new HashSet<ActualSale>();
Inventories = new HashSet<Inventory>();
Projections = new HashSet<Projection>();
}
public int Id { get; set; }
[Required]
[StringLength(256)]
public string Name { get; set; }
[StringLength(256)]
public string Description { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<ActualSale> ActualSales { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Inventory> Inventories { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Projection> Projections { get; set; }
}
}
+20
View File
@@ -0,0 +1,20 @@
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 AdSpecial
{
public int Id { get; set; }
[Required]
[StringLength(256)]
public string Name { get; set; }
[StringLength(256)]
public string Description { get; set; }
}
}
@@ -0,0 +1,292 @@
namespace AdvertsingProfitControl
{
using System;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
public partial class AdvertisingProfitControlModel : DbContext
{
public AdvertisingProfitControlModel()
: base("name=AdvertisingProfitControlContext")
{
}
public virtual DbSet<ActualSale> ActualSales { get; set; }
public virtual DbSet<AdItem> AdItems { get; set; }
public virtual DbSet<AdSpecial> AdSpecials { get; set; }
public virtual DbSet<CostAnalysi> CostAnalysis { get; set; }
public virtual DbSet<Inventory> Inventories { get; set; }
public virtual DbSet<Invoice> Invoices { get; set; }
public virtual DbSet<Note> Notes { get; set; }
public virtual DbSet<Projection> Projections { get; set; }
public virtual DbSet<Supplier> Suppliers { get; set; }
public virtual DbSet<Taxable> Taxables { get; set; }
public virtual DbSet<Version> Versions { get; set; }
public virtual DbSet<WeekEndingDate> WeekEndingDates { get; set; }
public virtual DbSet<WeeklySale> WeeklySales { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<ActualSale>()
.Property(e => e.Sold)
.IsUnicode(false);
modelBuilder.Entity<ActualSale>()
.Property(e => e.SalePrice)
.IsUnicode(false);
modelBuilder.Entity<ActualSale>()
.Property(e => e.TotalSales)
.HasPrecision(19, 2);
modelBuilder.Entity<ActualSale>()
.Property(e => e.Cost)
.HasPrecision(19, 2);
modelBuilder.Entity<ActualSale>()
.Property(e => e.ProfitReturn)
.HasPrecision(19, 2);
modelBuilder.Entity<ActualSale>()
.Property(e => e.TotalProfitReturn)
.HasPrecision(19, 2);
modelBuilder.Entity<AdItem>()
.Property(e => e.Name)
.IsUnicode(false);
modelBuilder.Entity<AdItem>()
.Property(e => e.Description)
.IsUnicode(false);
modelBuilder.Entity<AdItem>()
.HasMany(e => e.ActualSales)
.WithRequired(e => e.AdItem)
.HasForeignKey(e => e.FkAdItemId)
.WillCascadeOnDelete(false);
modelBuilder.Entity<AdItem>()
.HasMany(e => e.Inventories)
.WithRequired(e => e.AdItem)
.HasForeignKey(e => e.FkAdItemId)
.WillCascadeOnDelete(false);
modelBuilder.Entity<AdItem>()
.HasMany(e => e.Projections)
.WithRequired(e => e.AdItem)
.HasForeignKey(e => e.FkAdItemId)
.WillCascadeOnDelete(false);
modelBuilder.Entity<AdSpecial>()
.Property(e => e.Name)
.IsUnicode(false);
modelBuilder.Entity<AdSpecial>()
.Property(e => e.Description)
.IsUnicode(false);
modelBuilder.Entity<CostAnalysi>()
.Property(e => e.SalesPerManHour)
.HasPrecision(19, 2);
modelBuilder.Entity<CostAnalysi>()
.Property(e => e.SalaryPercentage)
.HasPrecision(19, 2);
modelBuilder.Entity<CostAnalysi>()
.Property(e => e.SalaryDollar)
.HasPrecision(19, 2);
modelBuilder.Entity<CostAnalysi>()
.Property(e => e.Supplies)
.HasPrecision(19, 2);
modelBuilder.Entity<Inventory>()
.Property(e => e.BeginningInventory)
.IsUnicode(false);
modelBuilder.Entity<Inventory>()
.Property(e => e.Recieved)
.IsUnicode(false);
modelBuilder.Entity<Inventory>()
.Property(e => e.TotalInventory)
.IsUnicode(false);
modelBuilder.Entity<Inventory>()
.Property(e => e.EndingInventory)
.IsUnicode(false);
modelBuilder.Entity<Invoice>()
.Property(e => e.InvoiceNetAmountAtCost)
.HasPrecision(19, 2);
modelBuilder.Entity<Invoice>()
.Property(e => e.InvoiceNetAmount)
.HasPrecision(19, 2);
modelBuilder.Entity<Invoice>()
.Property(e => e.InvoiceNote)
.IsUnicode(false);
modelBuilder.Entity<Note>()
.Property(e => e.Remark)
.IsUnicode(false);
modelBuilder.Entity<Projection>()
.Property(e => e.Sold)
.IsUnicode(false);
modelBuilder.Entity<Projection>()
.Property(e => e.SalePrice)
.IsUnicode(false);
modelBuilder.Entity<Projection>()
.Property(e => e.TotalSales)
.HasPrecision(19, 2);
modelBuilder.Entity<Projection>()
.Property(e => e.Cost)
.HasPrecision(19, 2);
modelBuilder.Entity<Projection>()
.Property(e => e.ProfitReturn)
.HasPrecision(19, 2);
modelBuilder.Entity<Projection>()
.Property(e => e.TotalProfitReturn)
.HasPrecision(19, 2);
modelBuilder.Entity<Supplier>()
.Property(e => e.Name)
.IsUnicode(false);
modelBuilder.Entity<Supplier>()
.Property(e => e.Description)
.IsUnicode(false);
modelBuilder.Entity<Supplier>()
.HasMany(e => e.Invoices)
.WithRequired(e => e.Supplier)
.HasForeignKey(e => e.FkSupplierId)
.WillCascadeOnDelete(false);
modelBuilder.Entity<Taxable>()
.Property(e => e.Sunday)
.HasPrecision(19, 2);
modelBuilder.Entity<Taxable>()
.Property(e => e.Monday)
.HasPrecision(19, 2);
modelBuilder.Entity<Taxable>()
.Property(e => e.Tuesday)
.HasPrecision(19, 2);
modelBuilder.Entity<Taxable>()
.Property(e => e.Wednesday)
.HasPrecision(19, 2);
modelBuilder.Entity<Taxable>()
.Property(e => e.Thursday)
.HasPrecision(19, 2);
modelBuilder.Entity<Taxable>()
.Property(e => e.Friday)
.HasPrecision(19, 2);
modelBuilder.Entity<Taxable>()
.Property(e => e.Saturday)
.HasPrecision(19, 2);
modelBuilder.Entity<Taxable>()
.Property(e => e.Total)
.HasPrecision(19, 2);
modelBuilder.Entity<Version>()
.Property(e => e.VersionNumber)
.IsUnicode(false);
modelBuilder.Entity<WeekEndingDate>()
.HasMany(e => e.ActualSales)
.WithRequired(e => e.WeekEndingDate)
.HasForeignKey(e => e.FkDateId)
.WillCascadeOnDelete(false);
modelBuilder.Entity<WeekEndingDate>()
.HasMany(e => e.CostAnalysis)
.WithRequired(e => e.WeekEndingDate)
.HasForeignKey(e => e.FkDateId)
.WillCascadeOnDelete(false);
modelBuilder.Entity<WeekEndingDate>()
.HasMany(e => e.Inventories)
.WithRequired(e => e.WeekEndingDate)
.HasForeignKey(e => e.FkDateId)
.WillCascadeOnDelete(false);
modelBuilder.Entity<WeekEndingDate>()
.HasMany(e => e.Invoices)
.WithRequired(e => e.WeekEndingDate)
.HasForeignKey(e => e.FkDateId)
.WillCascadeOnDelete(false);
modelBuilder.Entity<WeekEndingDate>()
.HasMany(e => e.Notes)
.WithRequired(e => e.WeekEndingDate)
.HasForeignKey(e => e.FkDateId)
.WillCascadeOnDelete(false);
modelBuilder.Entity<WeekEndingDate>()
.HasMany(e => e.Projections)
.WithRequired(e => e.WeekEndingDate)
.HasForeignKey(e => e.FkDateId)
.WillCascadeOnDelete(false);
modelBuilder.Entity<WeekEndingDate>()
.HasMany(e => e.Taxables)
.WithRequired(e => e.WeekEndingDate)
.HasForeignKey(e => e.FkDateId)
.WillCascadeOnDelete(false);
modelBuilder.Entity<WeekEndingDate>()
.HasMany(e => e.WeeklySales)
.WithRequired(e => e.WeekEndingDate)
.HasForeignKey(e => e.FkDateId)
.WillCascadeOnDelete(false);
modelBuilder.Entity<WeeklySale>()
.Property(e => e.Sunday)
.HasPrecision(19, 2);
modelBuilder.Entity<WeeklySale>()
.Property(e => e.Monday)
.HasPrecision(19, 2);
modelBuilder.Entity<WeeklySale>()
.Property(e => e.Tuesday)
.HasPrecision(19, 2);
modelBuilder.Entity<WeeklySale>()
.Property(e => e.Wednesday)
.HasPrecision(19, 2);
modelBuilder.Entity<WeeklySale>()
.Property(e => e.Thursday)
.HasPrecision(19, 2);
modelBuilder.Entity<WeeklySale>()
.Property(e => e.Friday)
.HasPrecision(19, 2);
modelBuilder.Entity<WeeklySale>()
.Property(e => e.Saturday)
.HasPrecision(19, 2);
modelBuilder.Entity<WeeklySale>()
.Property(e => e.TotalSales)
.HasPrecision(19, 2);
}
}
}
@@ -54,7 +54,7 @@
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
<GenerateManifests>false</GenerateManifests>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup>
@@ -82,6 +82,14 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</Reference>
<Reference Include="HtmlRenderer, Version=1.5.0.6, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlRenderer.Core.1.5.0.6\lib\net45\HtmlRenderer.dll</HintPath>
<Private>True</Private>
@@ -92,11 +100,14 @@
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<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" />
<Reference Include="System.Security" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
@@ -104,9 +115,13 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="AdItemCollectionModel.cs" />
<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="DbTableWriterStatus.cs" />
<Compile Include="DbWriterStatus.cs" />
<Compile Include="DebugDatabaseConverter.cs">
@@ -116,12 +131,18 @@
<DependentUpon>DebugDatabaseConverter.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="Supplier.cs" />
<Compile Include="Taxable.cs" />
<Compile Include="TextFormat.cs" />
<Compile Include="BackPageGenerator.cs" />
<Compile Include="DatabaseReader.cs" />
@@ -163,6 +184,9 @@
<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="DebugDatabaseConverter.resx">
<DependentUpon>DebugDatabaseConverter.cs</DependentUpon>
</EmbeddedResource>
@@ -195,6 +219,7 @@
<DesignTime>True</DesignTime>
</Compile>
<None Include="AdvertsingProfitControl_TemporaryKey.pfx" />
<None Include="App.config" />
<None Include="app.manifest" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
+19
View File
@@ -0,0 +1,19 @@
<?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.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="AdvertisingProfitControlContext" connectionString="data source=(LocalDb)\MSSQLLocalDB;initial catalog=AdvertisingProfitControl;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" /></connectionStrings>
</configuration>
+25
View File
@@ -0,0 +1,25 @@
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 CostAnalysi
{
public int Id { get; set; }
public decimal? SalesPerManHour { get; set; }
public decimal? SalaryPercentage { get; set; }
public decimal? SalaryDollar { get; set; }
public decimal? Supplies { get; set; }
public int FkDateId { get; set; }
public virtual WeekEndingDate WeekEndingDate { get; set; }
}
}
+2 -1
View File
@@ -41,6 +41,7 @@
this.existingDatesListBox.ItemHeight = 24;
this.existingDatesListBox.Location = new System.Drawing.Point(59, 84);
this.existingDatesListBox.Name = "existingDatesListBox";
this.existingDatesListBox.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
this.existingDatesListBox.Size = new System.Drawing.Size(254, 316);
this.existingDatesListBox.TabIndex = 0;
//
@@ -62,7 +63,7 @@
this.moveOverButton.TabIndex = 2;
this.moveOverButton.Text = "Move Selected";
this.moveOverButton.UseVisualStyleBackColor = true;
this.moveOverButton.Click += new System.EventHandler(this.moveOverButton_Click);
this.moveOverButton.Click += new System.EventHandler(this.MoveOverButton_Click);
//
// openFileDialog1
//
+119 -52
View File
@@ -77,14 +77,15 @@ namespace AdvertsingProfitControl
}
}
private void moveOverButton_Click(object sender, EventArgs e)
private void MoveOverButton_Click(object sender, EventArgs e)
{
if (existingDatesListBox.SelectedIndex != -1)
if (existingDatesListBox.SelectedIndex == -1) return;
foreach (var index in existingDatesListBox.SelectedItems)
{
datesToConvertListBox.Items.Add(existingDatesListBox.SelectedItem);
existingDatesListBox.Items.Remove(existingDatesListBox.SelectedItem);
moveOverButton.Enabled = false;
datesToConvertListBox.Items.Add(index);
//existingDatesListBox.Items.Remove(index);
}
moveOverButton.Enabled = false;
}
private void convertButton_Click(object sender, EventArgs e)
@@ -93,6 +94,25 @@ namespace AdvertsingProfitControl
{
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();
}
foreach (var date in datesToConvertListBox.Items)
{
var oldDateId = GetDateIdByDateString(date.ToString());
@@ -112,15 +132,8 @@ namespace AdvertsingProfitControl
private void MassiveWriteFunction(string dateString, DataTable projections, DataTable inventory, DataTable actualSales, DataTable invoice, DataTable weeklySales, DataTable taxableTable, DataTable costOfSales, string comments)
{
//var dbT = new DatabaseTracker();
////Get a new ID number for the date supplied.
//var oleDbConnection = new OleDbConnection(dbT.DatabaseConnectionString);
//var oleDbCommand = new OleDbCommand
//{
// Connection = oleDbConnection
//};
try
{
{
using (var transaction = new TransactionScope())
{
var db = new AdvertisingProfitControlModel();
@@ -163,7 +176,7 @@ namespace AdvertsingProfitControl
var adItem = new AdItem();
var adItemId = 0;
//var id = int.Parse(projections.Rows[rowIndex][0].ToString());
var spam = projections.Rows[rowIndex][0].ToString();
var spam = TextFormat.FormatAdItemText(projections.Rows[rowIndex][0].ToString());
if (db.AdItems.Any(x => x.Name == spam))
{
//Exists
@@ -176,7 +189,6 @@ namespace AdvertsingProfitControl
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();
@@ -219,7 +231,7 @@ namespace AdvertsingProfitControl
var inventoryObject = new Inventory();
AdItem adItem;
var adItemId = 0;
var spam = actualSales.Rows[i][0].ToString();
var spam = TextFormat.FormatAdItemText(inventory.Rows[i][0].ToString());
if (db.AdItems.Any(x => x.Name == spam))
{
//Exists
@@ -261,7 +273,7 @@ namespace AdvertsingProfitControl
//Get the ID number of the ad item.
AdItem adItem;
var adItemId = 0;
var spam = actualSales.Rows[rowIndex][0].ToString();
var spam = TextFormat.FormatAdItemText(actualSales.Rows[rowIndex][0].ToString());
if (db.AdItems.Any(x => x.Name == spam))
{
//Exists
@@ -339,43 +351,54 @@ namespace AdvertsingProfitControl
// oleDbCommand.ExecuteNonQuery();
// oleDbCommand.Parameters.Clear();
}
var weeklySale = new WeeklySale
if (weeklySales.Rows.Count == 1)
{
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);
//Comes from DatabaseReader class, so offset by one because zero is the ID number.
var taxable = new Taxable
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)
{
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);
//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 = ?
var cost = new CostAnalysi
if (costOfSales.Rows.Count == 1)
{
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);
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
@@ -400,10 +423,54 @@ namespace AdvertsingProfitControl
MessageBox.Show(e.Message);
//oleDbTransaction?.Rollback();
}
finally
}
public List<string> GetAdItems()
{
var adItems = new List<string>();
var oleDbCommand = new OleDbCommand
{
//oleDbConnection.Close();
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 int GetSupplierId(string supplierName)
+192 -679
View File
@@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
@@ -18,27 +21,41 @@ namespace AdvertsingProfitControl
private DateTime _currentActiveDate;
private readonly FrmLogConsole _console = FrmLogConsole.GetStaticInstance;
private int _LazyPageCounter;
private bool isDebug;
public FrmMain()
public FrmMain(bool isDebug)
{
InitializeComponent();
this.isDebug = isDebug;
isDebug = true;
debugToolStripMenuItem.Visible = isDebug;
var db = new AdvertisingProfitControlModel();
db.Versions.Count();
}
private void frmMain_Load(object sender, EventArgs e)
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
monthCalendar.BoldedDates = databaseReader.RetrieveDates(databaseTracker.DatabaseConnectionString).ToArray();
var db = new AdvertisingProfitControlModel();
monthCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray();
ConstructApcDataGridViews();
ConstructInvoicesDataGridView();
RowParsing.AdSpecialGroups.AddRange(databaseReader.ReturnGroupNameList(databaseTracker.DatabaseConnectionString));
var date = databaseReader.RetrieveMostRecentDate(databaseTracker.DatabaseConnectionString);
_currentActiveDate = date;
LoadDate(date);
//RowParsing.AdSpecialGroups.AddRange(databaseReader.ReturnGroupNameList(databaseTracker.DatabaseConnectionString));
//Select the most recent date from the database.
var recentDate = db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault();
if (recentDate != null)
{
_currentActiveDate = recentDate.EndingDate;
LoadDate(recentDate.EndingDate);
}
monthCalendar.DateChanged += ValidateDateChanged;
//projectionsDataGridView.KeyDown += FrmMain_KeyDown;
//var margin = new Margins(50, 50, 0, 0);
//_printDoc.DefaultPageSettings.Margins = margin;
//var adItem = new AdItem {Name = "Celery"};
//var db = new AdvertisingProfitControlContext();
//db.AdItems.Add(adItem);
//db.SaveChanges();
}
private void CalculateProfitAnalysis(double shrink = 0.30)
@@ -337,8 +354,7 @@ namespace AdvertsingProfitControl
private void LoadDate(DateTime date)
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var db = new AdvertisingProfitControlModel();
if (monthCalendar.BoldedDates.Length == 0)
{
//The database is most likely empty so halt everything.
@@ -349,210 +365,62 @@ namespace AdvertsingProfitControl
}
modifyRecordMainMenu.Enabled = true;
modifyRecordMainMenu.ToolTipText = @"";
var dateId = databaseReader.RetrieveDateIdByDateString(date.ToString("d"),
databaseTracker.DatabaseConnectionString);
if (dateId == 0)
{
errorLabel.Text = @"Failed to get the date ID number, aborting load operation." + Environment.NewLine;
return;
}
var dateRecord = db.WeekEndingDates.Single(x => x.EndingDate == date);
ClearForm();
var projections = databaseReader.ReturnProjectionsTable(dateId, databaseTracker.DatabaseConnectionString);
var inventory = databaseReader.ReturnInventoryTable(dateId, databaseTracker.DatabaseConnectionString);
var actualSales = databaseReader.ReturnActualSales(dateId, databaseTracker.DatabaseConnectionString);
LoadProjectionsTable(projections);
LoadInventoryTable(inventory);
LoadActualSalesTable(actualSales);
var invoices = databaseReader.ReturnInvoiceTable(dateId, databaseTracker.DatabaseConnectionString);
LoadInvoices(invoices);
var comments = databaseReader.RetrieveComments(int.Parse(dateId.ToString()),
databaseTracker.DatabaseConnectionString);
if (comments.Count == 2)
{
commentsTextBox.Text = comments[1];
}
else
{
commentMainGroupBox.Text = @"Comments (None to Display)";
}
var weeklySales = databaseReader.ReturnWeeklySalesFromDateId(dateId,
databaseTracker.DatabaseConnectionString);
if (weeklySales.Rows.Count == 1)
{
LoadWeeklySales(weeklySales);
}
else
{
weeklySalesGroupBox.Text = @"Weekly Sales (Nothing to Display)";
}
var taxable = databaseReader.ReturnTaxableFromDateId(dateId, databaseTracker.DatabaseConnectionString);
if (taxable.Rows.Count == 1)
{
LoadTaxable(taxable);
}
else
{
taxableGroupBox.Text = @"Taxable (Nothing to Display)";
}
var costAnalysis = databaseReader.ReturnCostAnalysis(dateId,
databaseTracker.DatabaseConnectionString);
if (costAnalysis.Rows.Count == 1)
{
LoadCostAnalysis(costAnalysis);
}
else
{
costAnalysisGroupBox.Text = @"Cost Analysis (Nothing to Display)";
}
LoadProjectionsTable(dateRecord);
LoadInventoryTable(dateRecord);
LoadActualSalesTable(dateRecord);
LoadInvoices(dateRecord);
var note = db.Notes.Single(x => x.FkDateId == dateRecord.Id);
commentsTextBox.Text = note.Remark;
LoadWeeklySales(dateRecord);
LoadTaxable(dateRecord);
LoadCostAnalysis(dateRecord);
CalculateProfitAnalysis();
CalculateGrossProfit();
monthCalendar.BoldedDates = databaseReader.RetrieveDates(databaseTracker.DatabaseConnectionString).ToArray();
monthCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray();
monthCalendar.SelectionStart = date;
dateTimeGroupBox.Text = @"Loaded " + date.ToString("d");
}
private void LoadProjectionsTable(DataTable projections)
private void LoadProjectionsTable(WeekEndingDate dateRecord)
{
if (projections.Rows.Count == 0) return;
var db = new AdvertisingProfitControlModel();
var adSpecialIndex = -1;
double totalSales = 0;
double totalProfitReturn = 0;
for (var rowIndex = 0; rowIndex < projections.Rows.Count; rowIndex++)
decimal totalSales = 0;
decimal totalProfitReturn = 0;
var projections = db.Projections.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
foreach (var p in projections)
{
var newRow = new DataGridViewRow();
for (var cellIndex = 1; cellIndex < projections.Rows[rowIndex].ItemArray.Length; cellIndex++)
projectionsDataGridView.Rows.Add();
var index = projectionsDataGridView.RowCount - 1;
projectionsDataGridView.Rows[index].Cells[0].Value = p.AdItem.Name;
projectionsDataGridView.Rows[index].Cells[1].Value = p.Sold;
projectionsDataGridView.Rows[index].Cells[2].Value = p.SalePrice;
projectionsDataGridView.Rows[index].Cells[3].Value = $@"{p.TotalSales:N2}";
if (p.TotalSales != null) totalSales += (decimal)p.TotalSales;
projectionsDataGridView.Rows[index].Cells[4].Value = $@"{p.Cost:N2}";
projectionsDataGridView.Rows[index].Cells[5].Value = $@"{p.ProfitReturn:N2}";
projectionsDataGridView.Rows[index].Cells[6].Value = $@"{p.TotalProfitReturn:N2}";
if (p.TotalProfitReturn != null) totalProfitReturn += (decimal)p.TotalProfitReturn;
if (p.RowAttribute == 1)
{
//ID and Ad Item.
if (cellIndex == 1)
{
var cell = new DataGridViewTextBoxCell
{
Value = projections.Rows[rowIndex].ItemArray[cellIndex].ToString()
};
newRow.Cells.Add(cell);
continue;
}
//String allowed columns
if (cellIndex > 1 && cellIndex <= 3)
{
if (projections.Rows[rowIndex].ItemArray[cellIndex].ToString() != string.Empty)
{
var cell = new DataGridViewTextBoxCell
{
Value = projections.Rows[rowIndex].ItemArray[cellIndex].ToString()
};
newRow.Cells.Add(cell);
}
else
{
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
newRow.Cells.Add(cell);
}
continue;
}
//If the cell is meant to be summed into a totals roll add its contents to the total.
//If the cell is the total sales cell..
if (cellIndex == 4)
{
if (projections.Rows[rowIndex].ItemArray[cellIndex].ToString() != string.Empty &&
Math.Abs(double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString())) > 0)
{
totalSales += double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString());
var cell = new DataGridViewTextBoxCell
{
Value =
double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString())
.ToString("N2")
};
newRow.Cells.Add(cell);
}
else
{
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
newRow.Cells.Add(cell);
}
continue;
}
//or the total profit return cell.
if (cellIndex == 7)
{
if (projections.Rows[rowIndex].ItemArray[cellIndex].ToString() != string.Empty &&
Math.Abs(double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString())) > 0)
{
totalProfitReturn += double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString());
var cell = new DataGridViewTextBoxCell
{
Value =
double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString())
.ToString("N2")
};
newRow.Cells.Add(cell);
}
else
{
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
newRow.Cells.Add(cell);
}
continue;
}
//Everything in between the ad item cell and the row attribute cells.
if (cellIndex > 3 && cellIndex < 8)
{
if (Math.Abs(double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString())) > 0)
{
var cell = new DataGridViewTextBoxCell
{
Value =
double.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString())
.ToString("N2")
};
newRow.Cells.Add(cell);
}
else
{
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
newRow.Cells.Add(cell);
}
continue;
}
//Check the attribute cell.
if (cellIndex == 8)
{
var rowAttribute = int.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString());
switch (rowAttribute)
{
case 1:
//Header row
newRow.DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
break;
case 2:
//Member Row
newRow.DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
break;
}
continue;
}
//Check the group it is part of if any.
if (cellIndex != 9) continue;
//Check to see if this row belongs to an ad special group.
if (projections.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0") continue;
//If the ad special index is not set, then create the ad special row with the human friendly group name.
if (adSpecialIndex != -1) continue;
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var groupName =
databaseReader.ReturnGroupNameFromGroupId(
projections.Rows[rowIndex].ItemArray[cellIndex].ToString(),
databaseTracker.DatabaseConnectionString);
var adSpecialRow = new DataGridViewRow();
projectionsDataGridView.Rows.Add(adSpecialRow);
projectionsDataGridView.Rows[rowIndex].Cells[3].Value = groupName;
projectionsDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor =
ApplicationColors.AdSpecial;
adSpecialIndex = rowIndex;
projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
}
else if (p.RowAttribute == 2)
{
projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
}
if (p.FkAdSpecialId != 0 && adSpecialIndex == -1)
{
//TODO: Fix null reference when no object is found.
adSpecialIndex = index;
projectionsDataGridView.Rows.Insert(index, 1);
projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
projectionsDataGridView.Rows[index].Cells[3].Value = db.AdSpecials.Single(x => x.Id == p.FkAdSpecialId).Name;
}
projectionsDataGridView.Rows.Add(newRow);
}
//Now add the totals row.
var totalsRow = new DataGridViewRow();
@@ -576,215 +444,78 @@ namespace AdvertsingProfitControl
}
}
private void LoadInventoryTable(DataTable inventory)
private void LoadInventoryTable(WeekEndingDate dateRecord)
{
if (inventory.Rows.Count == 0) return;
var db = new AdvertisingProfitControlModel();
var adSpecialIndex = -1;
for (var rowIndex = 0; rowIndex < inventory.Rows.Count; rowIndex++)
var inventories = db.Inventories.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
foreach (var i in inventories)
{
var newRow = new DataGridViewRow();
for (var cellIndex = 1; cellIndex < inventory.Rows[rowIndex].ItemArray.Length; cellIndex++)
inventoryDataGridView.Rows.Add();
var index = inventoryDataGridView.RowCount - 1;
inventoryDataGridView.Rows[index].Cells[0].Value = i.AdItem.Name;
inventoryDataGridView.Rows[index].Cells[1].Value = i.BeginningInventory;
inventoryDataGridView.Rows[index].Cells[2].Value = i.Recieved;
inventoryDataGridView.Rows[index].Cells[3].Value = i.TotalInventory;
inventoryDataGridView.Rows[index].Cells[4].Value = i.EndingInventory;
if (i.RowAttribute == 1)
{
//String allowed columns
if (cellIndex < 6)
{
if (inventory.Rows[rowIndex].ItemArray[cellIndex].ToString() != string.Empty)
{
var cell = new DataGridViewTextBoxCell
{
Value = inventory.Rows[rowIndex].ItemArray[cellIndex].ToString()
};
newRow.Cells.Add(cell);
}
else
{
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
newRow.Cells.Add(cell);
}
continue;
}
//Check the attribute cell.
if (cellIndex == 6)
{
var rowAttribute = int.Parse(inventory.Rows[rowIndex].ItemArray[cellIndex].ToString());
switch (rowAttribute)
{
case 1:
//Header row
newRow.DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
break;
case 2:
//Member Row
newRow.DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
break;
}
continue;
}
//Check the group it is part of if any.
if (cellIndex != 7) continue;
//Check to see if this row belongs to an ad special group.
if (inventory.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0") continue;
//If the ad special index is not set, then create the ad special row with the human friendly group name.
if (adSpecialIndex != -1) continue;
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var groupName =
databaseReader.ReturnGroupNameFromGroupId(
inventory.Rows[rowIndex].ItemArray[cellIndex].ToString(),
databaseTracker.DatabaseConnectionString);
var adSpecialRow = new DataGridViewRow();
inventoryDataGridView.Rows.Add(adSpecialRow);
inventoryDataGridView.Rows[rowIndex].Cells[2].Value = groupName;
inventoryDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor =
ApplicationColors.AdSpecial;
adSpecialIndex = rowIndex;
inventoryDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
}
else if (i.RowAttribute == 2)
{
inventoryDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
}
if (i.FkAdSpecialId != 0 && adSpecialIndex == -1)
{
adSpecialIndex = index;
inventoryDataGridView.Rows.Insert(index, 1);
inventoryDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
inventoryDataGridView.Rows[index].Cells[2].Value = db.AdSpecials.Single(x => x.Id == i.FkAdSpecialId).Name;
}
inventoryDataGridView.Rows.Add(newRow);
}
}
private void LoadActualSalesTable(DataTable actualSales)
private void LoadActualSalesTable(WeekEndingDate dateRecord)
{
if (actualSales.Rows.Count == 0) return;
var db = new AdvertisingProfitControlModel();
var adSpecialIndex = -1;
double totalSales = 0;
double totalProfitReturn = 0;
for (var rowIndex = 0; rowIndex < actualSales.Rows.Count; rowIndex++)
decimal totalSales = 0;
decimal totalProfitReturn = 0;
var actualSales = db.ActualSales.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
foreach (var a in actualSales)
{
var newRow = new DataGridViewRow();
for (var cellIndex = 1; cellIndex < actualSales.Rows[rowIndex].ItemArray.Length; cellIndex++)
actualSalesDataGridView.Rows.Add();
var index = actualSalesDataGridView.RowCount - 1;
actualSalesDataGridView.Rows[index].Cells[0].Value = a.AdItem.Name;
actualSalesDataGridView.Rows[index].Cells[1].Value = a.Sold;
actualSalesDataGridView.Rows[index].Cells[2].Value = a.SalePrice;
actualSalesDataGridView.Rows[index].Cells[3].Value = $@"{a.TotalSales:N2}";
if (a.TotalSales != null) totalSales += (decimal)a.TotalSales;
actualSalesDataGridView.Rows[index].Cells[4].Value = $@"{a.Cost:N2}";
actualSalesDataGridView.Rows[index].Cells[5].Value = $@"{a.ProfitReturn:N2}";
actualSalesDataGridView.Rows[index].Cells[6].Value = $@"{a.TotalProfitReturn:N2}";
if (a.TotalProfitReturn != null) totalProfitReturn += (decimal)a.TotalProfitReturn;
if (a.RowAttribute == 1)
{
//ID and Ad Item.
if (cellIndex == 1)
{
var cell = new DataGridViewTextBoxCell
{
Value = actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString()
};
newRow.Cells.Add(cell);
continue;
}
//String allowed columns
if (cellIndex > 1 && cellIndex <= 3)
{
if (actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString() != string.Empty)
{
var cell = new DataGridViewTextBoxCell
{
Value = actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString()
};
newRow.Cells.Add(cell);
}
else
{
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
newRow.Cells.Add(cell);
}
continue;
}
//If the cell is meant to be summed into a totals roll add its contents to the total.
//If the cell is the total sales cell..
if (cellIndex == 4)
{
if (actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString() != string.Empty &&
Math.Abs(double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString())) > 0)
{
totalSales += double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString());
var cell = new DataGridViewTextBoxCell
{
Value =
double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString())
.ToString("N2")
};
newRow.Cells.Add(cell);
}
else
{
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
newRow.Cells.Add(cell);
}
continue;
}
//or the total profit return cell.
if (cellIndex == 7)
{
if (actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString() != string.Empty &&
Math.Abs(double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString())) > 0)
{
totalProfitReturn += double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString());
var cell = new DataGridViewTextBoxCell
{
Value =
double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString())
.ToString("N2")
};
newRow.Cells.Add(cell);
}
else
{
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
newRow.Cells.Add(cell);
}
continue;
}
//Everything in between the ad item cell and the row attribute cells.
if (cellIndex > 3 && cellIndex < 8)
{
if (Math.Abs(double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString())) > 0)
{
var cell = new DataGridViewTextBoxCell
{
Value =
double.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString())
.ToString("N2")
};
newRow.Cells.Add(cell);
}
else
{
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
newRow.Cells.Add(cell);
}
continue;
}
//Check the attribute cell.
if (cellIndex == 8)
{
var rowAttribute = int.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString());
switch (rowAttribute)
{
case 1:
//Header row
newRow.DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
break;
case 2:
//Member Row
newRow.DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
break;
}
continue;
}
//Check the group it is part of if any.
if (cellIndex != 9) continue;
//Check to see if this row belongs to an ad special group.
if (actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0") continue;
//If the ad special index is not set, then create the ad special row with the human friendly group name.
if (adSpecialIndex != -1) continue;
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var groupName =
databaseReader.ReturnGroupNameFromGroupId(
actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString(),
databaseTracker.DatabaseConnectionString);
var adSpecialRow = new DataGridViewRow();
actualSalesDataGridView.Rows.Add(adSpecialRow);
actualSalesDataGridView.Rows[rowIndex].Cells[3].Value = groupName;
actualSalesDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor =
ApplicationColors.AdSpecial;
adSpecialIndex = rowIndex;
actualSalesDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
}
actualSalesDataGridView.Rows.Add(newRow);
}
else if (a.RowAttribute == 2)
{
actualSalesDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
}
if (a.FkAdSpecialId != 0 && adSpecialIndex == -1)
{
adSpecialIndex = index;
actualSalesDataGridView.Rows.Insert(index, 1);
actualSalesDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
actualSalesDataGridView.Rows[index].Cells[3].Value = db.AdSpecials.Single(x => x.Id == a.FkAdSpecialId).Name;
}
}
//Now add the totals row.
var totalsRow = new DataGridViewRow();
actualSalesDataGridView.Rows.Add(totalsRow);
@@ -807,50 +538,23 @@ namespace AdvertsingProfitControl
}
}
private void LoadInvoices(DataTable invoices)
private void LoadInvoices(WeekEndingDate dateRecord)
{
if (invoices.Rows.Count == 0) return;
_totalInvoicePurchases = 0;
for (var rowIndex = 0; rowIndex < invoices.Rows.Count; rowIndex++)
var db = new AdvertisingProfitControlModel();
var invoices = db.Invoices.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
foreach (var invoice in invoices)
{
var row = new DataGridViewRow();
for (var cellIndex = 1; cellIndex < invoices.Rows[rowIndex].ItemArray.Length; cellIndex++)
{
var cell = new DataGridViewTextBoxCell();
switch (cellIndex)
{
//Apply formatting to the invoice date to trim the 12:00:00 time stamp.
case 1:
var date = DateTime.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString());
cell.Value = date.ToString("d");
row.Cells.Add(cell);
continue;
//Apply formatting to the only cells that will have currency values in them.
case 4:
var netAmountAtCost = double.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString());
if (netAmountAtCost.ToString("N2") != "0.00")
{
cell.Value = netAmountAtCost.ToString("N2");
}
row.Cells.Add(cell);
break;
case 5:
var netAmoundExtendedRetail = double.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString());
if (netAmoundExtendedRetail.ToString("N2") != "0.00")
{
_totalInvoicePurchases += netAmoundExtendedRetail;
cell.Value = netAmoundExtendedRetail.ToString("N2");
}
row.Cells.Add(cell);
break;
default:
//No special formatting rules here so just put the value in and move on.
cell.Value = invoices.Rows[rowIndex].ItemArray[cellIndex].ToString();
row.Cells.Add(cell);
break;
}
}
invoicesDataGridView.Rows.Add(row);
invoicesDataGridView.Rows.Add();
var index = invoicesDataGridView.RowCount - 1;
invoicesDataGridView.Rows[index].Cells[0].Value = invoice.InvoiceDate.ToString("d");
invoicesDataGridView.Rows[index].Cells[1].Value = invoice.Supplier.Name;
invoicesDataGridView.Rows[index].Cells[2].Value = invoice.InvoiceNumber;
invoicesDataGridView.Rows[index].Cells[3].Value = $@"{invoice.InvoiceNetAmountAtCost:N2}";
invoicesDataGridView.Rows[index].Cells[4].Value = $@"{invoice.InvoiceNetAmount:N2}";
if (invoice.InvoiceNetAmount != null) _totalInvoicePurchases += (double)invoice.InvoiceNetAmount;
invoicesDataGridView.Rows[index].Cells[5].Value = invoice.InvoiceNote;
}
//Add the total purchases row to the invoice table.
var totalPurchaesRow = new DataGridViewRow();
@@ -862,252 +566,61 @@ namespace AdvertsingProfitControl
}
}
private void LoadWeeklySales(DataTable weeklySales)
private void LoadWeeklySales(WeekEndingDate dateRecord)
{
//Clear the department sales and prepare to add up a total.
_departmentSales = 0;
//Spin through the only row in the weekly sales table. Item in item
//array index zero (0) is the ID number of the weekly sales.
for (var cellIndex = 1; cellIndex < weeklySales.Rows[0].ItemArray.Length; cellIndex++)
var db = new AdvertisingProfitControlModel();
var weeklySales = db.WeeklySales.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
foreach (var sale in weeklySales)
{
double dollarAmount;
switch (cellIndex)
{
case 1: //Sunday
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
if (dollarAmount.ToString("N2") != "0.00")
{
_departmentSales += dollarAmount;
sundayWeeklySalesLabel.Text = @"Sunday: $" + dollarAmount.ToString("N2");
}
else
{
sundayWeeklySalesLabel.Text = @"Sunday: " + CheckForHoliday(DayOfWeek.Sunday);
}
break;
case 2: //Monday
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
if (dollarAmount.ToString("N2") != "0.00")
{
_departmentSales += dollarAmount;
mondayWeeklySalesLabel.Text = @"Monday: $" + dollarAmount.ToString("N2");
}
else
{
mondayWeeklySalesLabel.Text = @"Monday: " + CheckForHoliday(DayOfWeek.Monday);
}
break;
case 3: //Tuesday
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
if (dollarAmount.ToString("N2") != "0.00")
{
_departmentSales += dollarAmount;
tuesadayWeeklySalesLabel.Text = @"Tuesday: $" + dollarAmount.ToString("N2");
}
else
{
tuesadayWeeklySalesLabel.Text = @"Tuesday: " + CheckForHoliday(DayOfWeek.Tuesday);
}
break;
case 4: //Wednesday
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
if (dollarAmount.ToString("N2") != "0.00")
{
_departmentSales += dollarAmount;
wednesdayWeeklySalesLabel.Text = @"Wednesday: $" + dollarAmount.ToString("N2");
}
else
{
wednesdayWeeklySalesLabel.Text = @"Wednesday: " + CheckForHoliday(DayOfWeek.Wednesday);
}
break;
case 5: //Thursday
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
if (dollarAmount.ToString("N2") != "0.00")
{
_departmentSales += dollarAmount;
thursdayWeeklySalesLabel.Text = @"Thursday: $" + dollarAmount.ToString("N2");
}
else
{
thursdayWeeklySalesLabel.Text = @"Thursday: " + CheckForHoliday(DayOfWeek.Thursday);
}
break;
case 6: //Friday
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
if (dollarAmount.ToString("N2") != "0.00")
{
_departmentSales += dollarAmount;
fridayWeeklySalesLabel.Text = @"Friday: $" + dollarAmount.ToString("N2");
}
else
{
fridayWeeklySalesLabel.Text = @"Friday: " + CheckForHoliday(DayOfWeek.Friday);
}
break;
case 7: //Saturday
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
if (dollarAmount.ToString("N2") != "0.00")
{
_departmentSales += dollarAmount;
saturdayWeeklySalesLabel.Text = @"Saturday: $" + dollarAmount.ToString("N2");
}
else
{
saturdayWeeklySalesLabel.Text = @"Saturday: " + CheckForHoliday(DayOfWeek.Saturday);
}
break;
case 8: //Total Sales
dollarAmount = double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString());
if (dollarAmount.ToString("N2") != "0.00")
{
totalWeeklySalesLabel.Text = @"Total Sales: $" + dollarAmount.ToString("N2");
}
else
{
totalWeeklySalesLabel.Text = @"Total Sales: ";
}
break;
}
if (sale.Sunday != null) _departmentSales += (double)sale.Sunday;
sundayWeeklySalesLabel.Text = @"Sunday: " + $@"{sale.Sunday:c}";
if (sale.Monday != null) _departmentSales += (double)sale.Monday;
mondayWeeklySalesLabel.Text = @"Monday: " + $@"{sale.Monday:c}";
if (sale.Tuesday != null) _departmentSales += (double)sale.Tuesday;
tuesadayWeeklySalesLabel.Text = @"Tuesday: " + $@"{sale.Tuesday:c}";
if (sale.Wednesday != null) _departmentSales += (double)sale.Wednesday;
wednesdayWeeklySalesLabel.Text = @"Wednesday: " + $@"{sale.Wednesday:c}";
if (sale.Thursday != null) _departmentSales += (double)sale.Thursday;
thursdayWeeklySalesLabel.Text = @"Thursday: " + $@"{sale.Thursday:c}";
if (sale.Friday != null) _departmentSales += (double)sale.Friday;
fridayWeeklySalesLabel.Text = @"Friday: " + $@"{sale.Friday:c}";
if (sale.Saturday != null) _departmentSales += (double)sale.Saturday;
saturdayWeeklySalesLabel.Text = @"Saturday: " + $@"{sale.Saturday:c}";
totalWeeklySalesLabel.Text = @"Total Sales: " + $@"{sale.TotalSales:c}";
}
}
private void LoadTaxable(WeekEndingDate dateRecord)
{
//TODO: Check for holidays
var db = new AdvertisingProfitControlModel();
var taxables = db.Taxables.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
foreach (var taxable in taxables)
{
sundayTaxableLabel.Text = @"Sunday: " + $@"{taxable.Sunday:c}";
mondayTaxableLabel.Text = @"Monday: " + $@"{taxable.Monday:c}";
tuesdayTaxableLabel.Text = @"Tuesday: " + $@"{taxable.Tuesday:c}";
wednesdayTaxableLabel.Text = @"Wednesday: " + $@"{taxable.Wednesday:c}";
thursdayTaxableLabel.Text = @"Thursday: " + $@"{taxable.Thursday:c}";
fridayTaxableLabel.Text = @"Friday: " + $@"{taxable.Friday:c}";
saturdayTaxableLabel.Text = @"Saturday: " + $@"{taxable.Saturday:c}";
totalTaxableLabel.Text = @"Total: " + $@"{taxable.Total:c}";
}
}
private void LoadTaxable(DataTable taxable)
private void LoadCostAnalysis(WeekEndingDate dateRecord)
{
//Spin through the only row in the taxable table. Item in item
//array index zero (0) is the ID number of the weekly sales.
for (var cellIndex = 1; cellIndex < taxable.Rows[0].ItemArray.Length; cellIndex++)
var db = new AdvertisingProfitControlModel();
var analysis = db.CostAnalysis.Where(x => x.WeekEndingDate.Id == dateRecord.Id).Select(x => x);
foreach (var a in analysis)
{
string formattedNumber;
switch (cellIndex)
{
case 1: //Sunday
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
if (formattedNumber != "0.00")
{
sundayTaxableLabel.Text = @"Sunday: $" + formattedNumber;
}
else
{
sundayTaxableLabel.Text = @"Sunday: " + CheckForHoliday(DayOfWeek.Sunday);
}
break;
case 2: //Monday
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
if (formattedNumber != "0.00")
{
mondayTaxableLabel.Text = @"Monday: $" + formattedNumber;
}
else
{
mondayTaxableLabel.Text = @"Monday: " + CheckForHoliday(DayOfWeek.Monday);
}
break;
case 3: //Tuesday
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
if (formattedNumber != "0.00")
{
tuesdayTaxableLabel.Text = @"Tuesday: $" + formattedNumber;
}
else
{
tuesdayTaxableLabel.Text = @"Tuesday: " + CheckForHoliday(DayOfWeek.Tuesday);
}
break;
case 4: //Wednesday
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
if (formattedNumber != "0.00")
{
wednesdayTaxableLabel.Text = @"Wednesday: $" + formattedNumber;
}
else
{
wednesdayTaxableLabel.Text = @"Wednesday: " + CheckForHoliday(DayOfWeek.Wednesday);
}
break;
case 5: //Thursday
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
if (formattedNumber != "0.00")
{
thursdayTaxableLabel.Text = @"Thursday: $" + formattedNumber;
}
else
{
thursdayTaxableLabel.Text = @"Thursday: " + CheckForHoliday(DayOfWeek.Thursday);
}
break;
case 6: //Friday
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
if (formattedNumber != "0.00")
{
fridayTaxableLabel.Text = @"Friday: $" + formattedNumber;
}
else
{
fridayTaxableLabel.Text = @"Friday: " + CheckForHoliday(DayOfWeek.Friday);
}
break;
case 7: //Saturday
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
if (formattedNumber != "0.00")
{
saturdayTaxableLabel.Text = @"Saturday: $" + formattedNumber;
}
else
{
saturdayTaxableLabel.Text = @"Saturday: " + CheckForHoliday(DayOfWeek.Saturday);
}
break;
case 8: //Total Taxable
formattedNumber = double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
if (formattedNumber != "0.00")
{
totalTaxableLabel.Text = @"Total Taxable: $" + formattedNumber;
}
break;
}
}
}
private void LoadCostAnalysis(DataTable costAnalysis)
{
//Spin through the only row in the taxable table. Item in item
//array index zero (0) is the ID number of the weekly sales.
for (var cellIndex = 1; cellIndex < costAnalysis.Rows[0].ItemArray.Length; cellIndex++)
{
string formattedNumber;
switch (cellIndex)
{
case 1: //Sales per man hour
formattedNumber = double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
if (formattedNumber != "0.00")
{
salesPerManHourLabel.Text = @"Sales Per Man Hour: $" + formattedNumber;
}
break;
case 2: //Salary Percentage
formattedNumber = double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()).ToString("P2");
if (formattedNumber != "0.00")
{
salaryPercentageLabel.Text = @"Salary Percentage: " + formattedNumber;
}
break;
case 3: //Salary Dollars
formattedNumber = double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
if (formattedNumber != "0.00")
{
salaryDollarsLabel.Text = @"Salary Dollars: $" + formattedNumber;
}
break;
case 4: //Supplies
formattedNumber = double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()).ToString("N2");
if (formattedNumber != "0.00")
{
suppliesLabel.Text = @"Supplies: $" + formattedNumber;
}
break;
}
}
salesPerManHourLabel.Text = @"Sales Per Man Hour: " + $@"{a.SalesPerManHour:c}";
salaryPercentageLabel.Text = @"Salary Percentage: " + $@"{a.SalaryPercentage:p}";
salaryDollarsLabel.Text = @"Salary Dollars: " + $@"{a.SalaryDollar:c}";
suppliesLabel.Text = @"Supplies: " + $@"{a.Supplies}";
}
}
private string CheckForHoliday(DayOfWeek day)
@@ -1197,14 +710,14 @@ namespace AdvertsingProfitControl
departmentSalesLabel.Text = @"Department Sales: ";
salesProducedLabel.Text = @"Sales Produced By Ad Items (A):";
remainingSalesLabel.Text = @"Remaining Sales:";
totalProfitFromAdItemsLabel.Text = @"Total Profit Return" + Environment.NewLine + @" From Ad Items (B): ";
totalProfitReturnFromRemaingLabel.Text = @"Total Profit Return" + Environment.NewLine + @" From Remaining Sales: ";
totalProfitFromAdItemsLabel.Text = @"Total Profit Return" + Environment.NewLine + @"From Ad Items (B): ";
totalProfitReturnFromRemaingLabel.Text = @"Total Profit Return" + Environment.NewLine + @"From Remaining Sales: ";
totalProfitReturnLabel.Text = @"Total Profit Return: ";
grossProfitTotalSales.Text = @"Total Sales:";
grossProfitLessCostOfSales.Text = @"Less Cost of Sales: ";
grossProfitDollarGrossProfitLabel.Text = @"Dollar Gross Profit: ";
perfectGrossProfitLabel.Text = @"Percent Gross Profit: ";
grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Text = @"Estimated Weekly" + Environment.NewLine + @" Department Expense: ";
grossProfitEstimatedWeeklyDeptmartmentExpenseLabel.Text = @"Estimated Weekly" + Environment.NewLine + @"Department Expense: ";
}
private void debugToolStripMenuItem1_Click(object sender, EventArgs e)
+40
View File
@@ -0,0 +1,40 @@
namespace AdvertsingProfitControl
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;
[Table("Inventory")]
public partial class Inventory
{
public int Id { get; set; }
[StringLength(256)]
public string BeginningInventory { get; set; }
[StringLength(256)]
public string Recieved { get; set; }
[StringLength(256)]
public string TotalInventory { get; set; }
[StringLength(256)]
public string EndingInventory { get; set; }
public int RowPosition { get; set; }
public int RowAttribute { get; set; }
public int FkAdItemId { get; set; }
public int FkAdSpecialId { get; set; }
public int FkDateId { get; set; }
public virtual AdItem AdItem { get; set; }
public virtual WeekEndingDate WeekEndingDate { get; set; }
}
}
+33
View File
@@ -0,0 +1,33 @@
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 Invoice
{
public int Id { get; set; }
[Column(TypeName = "date")]
public DateTime InvoiceDate { get; set; }
public int InvoiceNumber { get; set; }
public decimal? InvoiceNetAmountAtCost { get; set; }
public decimal? InvoiceNetAmount { get; set; }
[StringLength(256)]
public string InvoiceNote { get; set; }
public int FkSupplierId { get; set; }
public int FkDateId { get; set; }
public virtual WeekEndingDate WeekEndingDate { get; set; }
[Required]
public virtual Supplier Supplier { get; set; }
}
}
+21
View File
@@ -0,0 +1,21 @@
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; }
}
}
+11 -4
View File
@@ -9,9 +9,9 @@ namespace AdvertsingProfitControl
/// The main entry point for the application.
/// </summary>
[STAThread]
private static void Main()
{
Application.EnableVisualStyles();
private static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ThreadException += GlobalClasses.LogError;
AppDomain.CurrentDomain.UnhandledException += GlobalClasses.LogError;
@@ -19,7 +19,14 @@ namespace AdvertsingProfitControl
//var errorConsoleThread = new Thread(console.Show);
//errorConsoleThread.IsBackground = true;
//errorConsoleThread.Start();
Application.Run(new FrmMain());
if (args.Length == 1 && args[0] == "/debug")
{
Application.Run(new FrmMain(true));
}
else
{
Application.Run(new FrmMain(false));
}
}
}
}
+41
View File
@@ -0,0 +1,41 @@
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 Projection
{
public int Id { get; set; }
[StringLength(128)]
public string Sold { get; set; }
[StringLength(128)]
public string SalePrice { get; set; }
public decimal? TotalSales { get; set; }
public decimal? Cost { get; set; }
public decimal? ProfitReturn { get; set; }
public decimal? TotalProfitReturn { get; set; }
public int RowPosition { get; set; }
public int RowAttribute { get; set; }
public int FkAdItemId { get; set; }
public int FkAdSpecialId { get; set; }
public int FkDateId { get; set; }
public virtual AdItem AdItem { get; set; }
public virtual WeekEndingDate WeekEndingDate { get; set; }
}
}
+28
View File
@@ -0,0 +1,28 @@
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 Supplier
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Supplier()
{
Invoices = new HashSet<Invoice>();
}
public int Id { get; set; }
[StringLength(256)]
public string Name { get; set; }
[StringLength(256)]
public string Description { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Invoice> Invoices { get; set; }
}
}
+34
View File
@@ -0,0 +1,34 @@
namespace AdvertsingProfitControl
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;
[Table("Taxable")]
public partial class Taxable
{
public int Id { get; set; }
public decimal? Sunday { get; set; }
public decimal? Monday { get; set; }
public decimal? Tuesday { get; set; }
public decimal? Wednesday { get; set; }
public decimal? Thursday { get; set; }
public decimal? Friday { get; set; }
public decimal? Saturday { get; set; }
public decimal? Total { get; set; }
public int FkDateId { get; set; }
public virtual WeekEndingDate WeekEndingDate { get; set; }
}
}
+17
View File
@@ -0,0 +1,17 @@
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; }
}
}
+53
View File
@@ -0,0 +1,53 @@
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 WeekEndingDate
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public WeekEndingDate()
{
ActualSales = new HashSet<ActualSale>();
CostAnalysis = new HashSet<CostAnalysi>();
Inventories = new HashSet<Inventory>();
Invoices = new HashSet<Invoice>();
Notes = new HashSet<Note>();
Projections = new HashSet<Projection>();
Taxables = new HashSet<Taxable>();
WeeklySales = new HashSet<WeeklySale>();
}
public int Id { get; set; }
[Column(TypeName = "date")]
public DateTime EndingDate { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<ActualSale> ActualSales { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<CostAnalysi> CostAnalysis { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Inventory> Inventories { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Invoice> Invoices { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Note> Notes { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Projection> Projections { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Taxable> Taxables { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<WeeklySale> WeeklySales { get; set; }
}
}
+33
View File
@@ -0,0 +1,33 @@
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 WeeklySale
{
public int Id { get; set; }
public decimal? Sunday { get; set; }
public decimal? Monday { get; set; }
public decimal? Tuesday { get; set; }
public decimal? Wednesday { get; set; }
public decimal? Thursday { get; set; }
public decimal? Friday { get; set; }
public decimal? Saturday { get; set; }
public decimal? TotalSales { get; set; }
public int FkDateId { get; set; }
public virtual WeekEndingDate WeekEndingDate { get; set; }
}
}
+6 -14
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
@@ -18,45 +18,38 @@
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<PermissionSet Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
</windowsSettings>
</application>
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
@@ -72,5 +65,4 @@
</dependentAssembly>
</dependency>
-->
</assembly>
</assembly>
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xrml="urn:mpeg:mpeg21:2003:01-REL-R-NS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
<assemblyIdentity name="AdvertsingProfitControl.application" version="1.0.0.1" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" xmlns="urn:schemas-microsoft-com:asm.v1" />
<description asmv2:publisher="AdvertsingProfitControl" asmv2:product="AdvertsingProfitControl" xmlns="urn:schemas-microsoft-com:asm.v1" />
<deployment install="true" mapFileExtensions="true" />
<compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2">
<framework targetVersion="4.5" profile="Full" supportedRuntime="4.0.30319" />
</compatibleFrameworks>
<dependency>
<dependentAssembly dependencyType="install" codebase="AdvertsingProfitControl.exe.manifest" size="7492">
<assemblyIdentity name="AdvertsingProfitControl.exe" version="1.0.0.1" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" type="win32" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>3ChUsEqNUMAjVaBGqxbdYDY0WFTlgEm8k8f2eCP9a18=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
</asmv1:assembly>
@@ -1,18 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
<asmv1:assemblyIdentity name="AdvertsingProfitControl.exe" version="1.0.0.1" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" type="win32" />
<description asmv2:iconFile="Stretched Logo Collection.ico" xmlns="urn:schemas-microsoft-com:asm.v1" />
<application />
<entryPoint>
<assemblyIdentity name="AdvertsingProfitControl" version="1.9.3.0" language="neutral" processorArchitecture="amd64" />
<commandLine file="AdvertsingProfitControl.exe" parameters="" />
</entryPoint>
<trustInfo>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<applicationRequestMinimum>
<PermissionSet version="1" class="System.Security.NamedPermissionSet" Name="LocalIntranet" Description="Default rights given to applications on the local intranet" Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
@@ -28,92 +18,12 @@
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<PermissionSet Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
</security>
</trustInfo>
<dependency>
<dependentOS>
<osVersionInfo>
<os majorVersion="5" minorVersion="1" buildNumber="2600" servicePackMajor="0" />
</osVersionInfo>
</dependentOS>
</dependency>
<dependency>
<dependentAssembly dependencyType="preRequisite" allowDelayedBinding="true">
<assemblyIdentity name="Microsoft.Windows.CommonLanguageRuntime" version="4.0.30319.0" />
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="2435072">
<assemblyIdentity name="AdvertsingProfitControl" version="1.9.3.0" language="neutral" processorArchitecture="amd64" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>mupCCLiyPu/EYkKY9Sc0jm2Z0deNl6wThi2EYMz/tAI=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="HtmlRenderer.dll" size="222208">
<assemblyIdentity name="HtmlRenderer" version="1.5.0.6" language="neutral" processorArchitecture="msil" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>VGr+ZzYUr4vMefSbFien3axjDZd7ylgpjfrMKI12ink=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="HtmlRenderer.WinForms.dll" size="60416">
<assemblyIdentity name="HtmlRenderer.WinForms" version="1.5.0.6" language="neutral" processorArchitecture="msil" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>WF/zxFwKgeKM8FANZnlU0EY/IhL18w1Px1iKE75KJWM=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
<file name="APCDatabase Template Script.sql" size="6200">
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>hrCGS0Sn5+IzPQDdJqcLf/Le8W/IzTyGRSduCe/L7Yo=</dsig:DigestValue>
</hash>
</file>
<file name="APCDatabase.accdb" size="864256">
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>u8KjFRismEEKveuk50umuN3UTCd1w3Uh6n8Nk4q8yoo=</dsig:DigestValue>
</hash>
</file>
<file name="APCTemplate.accdb" size="819200">
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>HWMXjUaEQtZd0vBm2k4ValXtZwmVzcqV0rERViSzOOc=</dsig:DigestValue>
</hash>
</file>
<file name="Stretched Logo Collection.ico" size="370070">
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>EhpcVkhatavmpmzYIlqLL5P0WB1QFP8mU66foV/5u+c=</dsig:DigestValue>
</hash>
</file>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
@@ -131,9 +41,28 @@
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
</windowsSettings>
</application>
</asmv1:assembly>
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>
+1
View File
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.3" targetFramework="net45" />
<package id="HtmlRenderer.Core" version="1.5.0.6" targetFramework="net45" />
<package id="HtmlRenderer.WinForms" version="1.5.0.6" targetFramework="net45" />
</packages>