Fixed a bug where ad specials wasn't being processed properly. Updated the main form to add up all data in the Invoice Net Amount at Cost column instead of the Extended Retail column. Minor behavior fixes.
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Data.Entity.Core;
|
|
||||||
using System.Data.Entity.Infrastructure;
|
using System.Data.Entity.Infrastructure;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Printing;
|
using System.Drawing.Printing;
|
||||||
@@ -651,11 +650,13 @@ namespace AdvertsingProfitControl
|
|||||||
invoicesDataGridView.Rows[index].Cells[1].Value = invoice.Supplier.Name;
|
invoicesDataGridView.Rows[index].Cells[1].Value = invoice.Supplier.Name;
|
||||||
invoicesDataGridView.Rows[index].Cells[2].Value = invoice.InvoiceNumber;
|
invoicesDataGridView.Rows[index].Cells[2].Value = invoice.InvoiceNumber;
|
||||||
invoicesDataGridView.Rows[index].Cells[3].Value = $@"{invoice.InvoiceNetAmountAtCost:N2}";
|
invoicesDataGridView.Rows[index].Cells[3].Value = $@"{invoice.InvoiceNetAmountAtCost:N2}";
|
||||||
|
//Net Amount Extended Retail is not the required field.
|
||||||
|
if (invoice.InvoiceNetAmountAtCost != null) _totalInvoicePurchases += (decimal)invoice.InvoiceNetAmountAtCost;
|
||||||
invoicesDataGridView.Rows[index].Cells[4].Value = $@"{invoice.InvoiceNetAmount:N2}";
|
invoicesDataGridView.Rows[index].Cells[4].Value = $@"{invoice.InvoiceNetAmount:N2}";
|
||||||
if (invoice.InvoiceNetAmount != null) _totalInvoicePurchases += (decimal) invoice.InvoiceNetAmount;
|
|
||||||
invoicesDataGridView.Rows[index].Cells[5].Value = invoice.InvoiceNote;
|
invoicesDataGridView.Rows[index].Cells[5].Value = invoice.InvoiceNote;
|
||||||
}
|
}
|
||||||
//Add the total purchases row to the invoice table.
|
//Add the total purchases row to the invoice table.
|
||||||
|
if(invoicesDataGridView.RowCount == 0) return;
|
||||||
var totalPurchaesRow = new DataGridViewRow();
|
var totalPurchaesRow = new DataGridViewRow();
|
||||||
invoicesDataGridView.Rows.Add(totalPurchaesRow);
|
invoicesDataGridView.Rows.Add(totalPurchaesRow);
|
||||||
invoicesDataGridView.Rows[invoicesDataGridView.Rows.Count - 1].Cells[0].Value = @"Total Purchases";
|
invoicesDataGridView.Rows[invoicesDataGridView.Rows.Count - 1].Cells[0].Value = @"Total Purchases";
|
||||||
@@ -933,6 +934,12 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DebugViewLogFiles(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var form = new FrmLogFileViewer();
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private void ClearActiveDateYearRecords(object sender, EventArgs e)
|
private void ClearActiveDateYearRecords(object sender, EventArgs e)
|
||||||
@@ -1100,10 +1107,5 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private void DebugViewLogFiles(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var form = new FrmLogFileViewer();
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,9 +10,13 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
public static void LogError(object sender, System.Threading.ThreadExceptionEventArgs e)
|
public static void LogError(object sender, System.Threading.ThreadExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (!Directory.Exists(LogFilePath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(LogFilePath);
|
||||||
|
}
|
||||||
using (
|
using (
|
||||||
var file =
|
var file =
|
||||||
new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("MM-dd-yyyy") + ".log", true))
|
new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("d") + ".log", true))
|
||||||
{
|
{
|
||||||
file.WriteLine(DateTime.Now + ": Unhandled Thread Exception:\n" + e.Exception.Message + Environment.NewLine);
|
file.WriteLine(DateTime.Now + ": Unhandled Thread Exception:\n" + e.Exception.Message + Environment.NewLine);
|
||||||
MessageBox.Show(@"An unhandled thread exception has occurred. Advertising Profit Control will be forced to exit.",
|
MessageBox.Show(@"An unhandled thread exception has occurred. Advertising Profit Control will be forced to exit.",
|
||||||
@@ -23,9 +27,11 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
public static void LogError(object sender, UnhandledExceptionEventArgs e)
|
public static void LogError(object sender, UnhandledExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
using (
|
if (!Directory.Exists(LogFilePath))
|
||||||
var file =
|
{
|
||||||
new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("MM-dd-yyyy") + ".log", true))
|
Directory.CreateDirectory(LogFilePath);
|
||||||
|
}
|
||||||
|
using (var file = new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("d") + ".log", true))
|
||||||
{
|
{
|
||||||
file.WriteLine(DateTime.Now + ": An unhandled exception occurred. \nException Object: " + e.ExceptionObject + Environment.NewLine);
|
file.WriteLine(DateTime.Now + ": An unhandled exception occurred. \nException Object: " + e.ExceptionObject + Environment.NewLine);
|
||||||
MessageBox.Show(@"And unknown error has occurred. Advertising Profit Control will be forced to exit.",
|
MessageBox.Show(@"And unknown error has occurred. Advertising Profit Control will be forced to exit.",
|
||||||
@@ -36,9 +42,12 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
public static void WriteToLog(string message)
|
public static void WriteToLog(string message)
|
||||||
{
|
{
|
||||||
|
if (!Directory.Exists(LogFilePath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(LogFilePath);
|
||||||
|
}
|
||||||
using (
|
using (
|
||||||
var file =
|
var file = new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\Information.log", true))
|
||||||
new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\Information.log", true))
|
|
||||||
{
|
{
|
||||||
file.WriteLine(message);
|
file.WriteLine(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,24 @@ namespace AdvertsingProfitControl
|
|||||||
}
|
}
|
||||||
return holiday;
|
return holiday;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Source: http://stackoverflow.com/questions/2510383/how-can-i-calculate-what-date-good-friday-falls-on-given-a-year
|
||||||
|
public static DateTime EasterSunday(int year)
|
||||||
|
{
|
||||||
|
var g = year % 19;
|
||||||
|
var c = year / 100;
|
||||||
|
var h = (c - c / 4 - (8 * c + 13) / 25 + 19 * g + 15) % 30;
|
||||||
|
var i = h - h / 28 * (1 - h / 28 * (29 / (h + 1)) * ((21 - g) / 11));
|
||||||
|
|
||||||
|
var day = i - ((year + year / 4 + i + 2 - c + c / 4) % 7) + 28;
|
||||||
|
var month = 3;
|
||||||
|
|
||||||
|
if (day <= 31) return new DateTime(year, month, day);
|
||||||
|
month++;
|
||||||
|
day -= 31;
|
||||||
|
|
||||||
|
return new DateTime(year, month, day);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public enum Holidays
|
public enum Holidays
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ namespace AdvertsingProfitControl
|
|||||||
private bool _isFormDirty;
|
private bool _isFormDirty;
|
||||||
//
|
//
|
||||||
private bool _isModifyingRecord;
|
private bool _isModifyingRecord;
|
||||||
|
|
||||||
|
private int _selectedRowIndex = -1;
|
||||||
|
|
||||||
public NewModifyRecord(DateTime date)
|
public NewModifyRecord(DateTime date)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -105,6 +108,10 @@ namespace AdvertsingProfitControl
|
|||||||
projectionsDataGridView.CellEnter += StoreBeginningCellValue;
|
projectionsDataGridView.CellEnter += StoreBeginningCellValue;
|
||||||
inventoryDataGridView.CellEnter += StoreBeginningCellValue;
|
inventoryDataGridView.CellEnter += StoreBeginningCellValue;
|
||||||
actualSalesDataGridView.CellEnter += StoreBeginningCellValue;
|
actualSalesDataGridView.CellEnter += StoreBeginningCellValue;
|
||||||
|
//Update the selected row index field.
|
||||||
|
projectionsDataGridView.RowEnter += UpdateSelectedRowIndexOnEnter;
|
||||||
|
inventoryDataGridView.RowEnter += UpdateSelectedRowIndexOnEnter;
|
||||||
|
actualSalesDataGridView.RowEnter += UpdateSelectedRowIndexOnEnter;
|
||||||
//Update the contents of the used as item list on row leave.
|
//Update the contents of the used as item list on row leave.
|
||||||
projectionsDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave;
|
projectionsDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave;
|
||||||
inventoryDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave;
|
inventoryDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave;
|
||||||
@@ -472,6 +479,18 @@ namespace AdvertsingProfitControl
|
|||||||
_beginningCellValue = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue.ToString();
|
_beginningCellValue = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Keeps track of the currently selected row index in the APC DataGridView that has focus.
|
||||||
|
/// This is used by the key down event handler in the cell's text box to determine what auto-complete
|
||||||
|
/// list to use.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void UpdateSelectedRowIndexOnEnter(object sender, DataGridViewCellEventArgs e)
|
||||||
|
{
|
||||||
|
_selectedRowIndex = e.RowIndex;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event Used: OnRowLeave
|
/// Event Used: OnRowLeave
|
||||||
/// Adds the ad items to the used ad item collection if they are not already in the collection.
|
/// Adds the ad items to the used ad item collection if they are not already in the collection.
|
||||||
@@ -816,7 +835,7 @@ namespace AdvertsingProfitControl
|
|||||||
|
|
||||||
if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.S)
|
if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.S)
|
||||||
{
|
{
|
||||||
if (_adSpecialIndex == -1)
|
if (_adSpecialIndex == -1 || _adSpecialIndex == _selectedRowIndex)
|
||||||
{
|
{
|
||||||
textBox.AutoCompleteCustomSource = _adSpecialList;
|
textBox.AutoCompleteCustomSource = _adSpecialList;
|
||||||
informationLabel.Text = @"Auto complete mode changed to Ad Special.";
|
informationLabel.Text = @"Auto complete mode changed to Ad Special.";
|
||||||
@@ -824,7 +843,7 @@ namespace AdvertsingProfitControl
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
textBox.AutoCompleteCustomSource = _trimmedAdItemCollection;
|
textBox.AutoCompleteCustomSource = _trimmedAdItemCollection;
|
||||||
informationLabel.Text = @"An Ad Special row already exists, auto complete mode\n can not be changed.";
|
informationLabel.Text = @"An Ad Special row already exists;" + Environment.NewLine + @"auto complete mode can not be changed.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.A)
|
else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.A)
|
||||||
@@ -2754,6 +2773,8 @@ namespace AdvertsingProfitControl
|
|||||||
if (projection.FkAdSpecialId != null && adSpecialIndex == -1)
|
if (projection.FkAdSpecialId != null && adSpecialIndex == -1)
|
||||||
{
|
{
|
||||||
adSpecialIndex = index;
|
adSpecialIndex = index;
|
||||||
|
//Set the form's ad special index field.
|
||||||
|
_adSpecialIndex = index;
|
||||||
projectionsDataGridView.Rows.Insert(index, 1);
|
projectionsDataGridView.Rows.Insert(index, 1);
|
||||||
//Apply the ad special text.
|
//Apply the ad special text.
|
||||||
projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
|
projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
|
||||||
@@ -3297,7 +3318,7 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
//If the row is a new row or is not dirty then continue to the next row if applicable.
|
//If the row is a new row or is not dirty then continue to the next row if applicable.
|
||||||
if (row.IsNewRow) continue;
|
if (row.IsNewRow) continue;
|
||||||
if (!(bool) row.Cells[(int) SalesTableColumns.IsDirty].EditedFormattedValue) continue;
|
if (!(bool) row.Cells[(int) SalesTableColumns.IsDirty].EditedFormattedValue && row.Index != _adSpecialIndex) continue;
|
||||||
//Obtain the ad item.
|
//Obtain the ad item.
|
||||||
var adItem = new AdItem();
|
var adItem = new AdItem();
|
||||||
//Sadly, LINQ doesn't like calls to the ToString method so we create a temp variable.
|
//Sadly, LINQ doesn't like calls to the ToString method so we create a temp variable.
|
||||||
@@ -3420,6 +3441,7 @@ namespace AdvertsingProfitControl
|
|||||||
: decimal.Parse(
|
: decimal.Parse(
|
||||||
row.Cells[(int) SalesTableColumns.TotalProfitReturn].EditedFormattedValue
|
row.Cells[(int) SalesTableColumns.TotalProfitReturn].EditedFormattedValue
|
||||||
.ToString());
|
.ToString());
|
||||||
|
projection.FkAdSpecialId = adSpecial.Id == 0 ? (int?) null : adSpecial.Id;
|
||||||
projection.FkAdItemId = adItem.Id;
|
projection.FkAdItemId = adItem.Id;
|
||||||
projection.RowAttribute = rowAttribute;
|
projection.RowAttribute = rowAttribute;
|
||||||
projection.RowPosition = row.Index + 1;
|
projection.RowPosition = row.Index + 1;
|
||||||
@@ -3469,7 +3491,7 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
//If the row is a new row or is not dirty then continue to the next row if applicable.
|
//If the row is a new row or is not dirty then continue to the next row if applicable.
|
||||||
if (row.IsNewRow) continue;
|
if (row.IsNewRow) continue;
|
||||||
if (!(bool)row.Cells[(int)InventoryTableColumns.IsDirty].EditedFormattedValue) continue;
|
if (!(bool)row.Cells[(int)InventoryTableColumns.IsDirty].EditedFormattedValue && row.Index != _adSpecialIndex) continue;
|
||||||
//Obtain the ad item.
|
//Obtain the ad item.
|
||||||
var adItem = new AdItem();
|
var adItem = new AdItem();
|
||||||
//Sadly, LINQ doesn't like calls to the ToString method so we create a temp variable.
|
//Sadly, LINQ doesn't like calls to the ToString method so we create a temp variable.
|
||||||
@@ -3554,6 +3576,7 @@ namespace AdvertsingProfitControl
|
|||||||
row.Cells[(int)InventoryTableColumns.Total].EditedFormattedValue.ToString();
|
row.Cells[(int)InventoryTableColumns.Total].EditedFormattedValue.ToString();
|
||||||
inventory.EndingInventory =
|
inventory.EndingInventory =
|
||||||
row.Cells[(int)InventoryTableColumns.EndingInventory].EditedFormattedValue.ToString();
|
row.Cells[(int)InventoryTableColumns.EndingInventory].EditedFormattedValue.ToString();
|
||||||
|
inventory.FkAdSpecialId = adSpecial.Id == 0 ? (int?)null : adSpecial.Id;
|
||||||
inventory.FkAdItemId = adItem.Id;
|
inventory.FkAdItemId = adItem.Id;
|
||||||
inventory.RowAttribute = rowAttribute;
|
inventory.RowAttribute = rowAttribute;
|
||||||
inventory.RowPosition = row.Index + 1;
|
inventory.RowPosition = row.Index + 1;
|
||||||
@@ -3603,7 +3626,7 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
//If the row is a new row or is not dirty then continue to the next row if applicable.
|
//If the row is a new row or is not dirty then continue to the next row if applicable.
|
||||||
if (row.IsNewRow) continue;
|
if (row.IsNewRow) continue;
|
||||||
if (!(bool)row.Cells[(int)SalesTableColumns.IsDirty].EditedFormattedValue) continue;
|
if (!(bool)row.Cells[(int)SalesTableColumns.IsDirty].EditedFormattedValue && row.Index != _adSpecialIndex) continue;
|
||||||
//Obtain the ad item.
|
//Obtain the ad item.
|
||||||
var adItem = new AdItem();
|
var adItem = new AdItem();
|
||||||
//Sadly, LINQ doesn't like calls to the ToString method so we create a temp variable.
|
//Sadly, LINQ doesn't like calls to the ToString method so we create a temp variable.
|
||||||
@@ -3726,6 +3749,7 @@ namespace AdvertsingProfitControl
|
|||||||
: decimal.Parse(
|
: decimal.Parse(
|
||||||
row.Cells[(int)SalesTableColumns.TotalProfitReturn].EditedFormattedValue
|
row.Cells[(int)SalesTableColumns.TotalProfitReturn].EditedFormattedValue
|
||||||
.ToString());
|
.ToString());
|
||||||
|
actualSale.FkAdSpecialId = adSpecial.Id == 0 ? (int?)null : adSpecial.Id;
|
||||||
actualSale.FkAdItemId = adItem.Id;
|
actualSale.FkAdItemId = adItem.Id;
|
||||||
actualSale.RowAttribute = rowAttribute;
|
actualSale.RowAttribute = rowAttribute;
|
||||||
actualSale.RowPosition = row.Index + 1;
|
actualSale.RowPosition = row.Index + 1;
|
||||||
@@ -4458,6 +4482,5 @@ namespace AdvertsingProfitControl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.10.0.0")]
|
[assembly: AssemblyVersion("2.0.1.16")]
|
||||||
[assembly: AssemblyFileVersion("1.10.0.0")]
|
[assembly: AssemblyFileVersion("2.0.1.16")]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||||
<Product Id="*" Name="Advertising Profit Control" Language="1033" Version="1.10.0.0" Manufacturer="Garritt McCune" UpgradeCode="a416a558-d7c0-4f24-8b1e-2d01761ad15f">
|
<Product Id="*" Name="Advertising Profit Control" Language="1033" Version="2.0.1.16" Manufacturer="Garritt McCune" UpgradeCode="a416a558-d7c0-4f24-8b1e-2d01761ad15f">
|
||||||
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="Custom Profit Control Recording Software" Comments="Profit Control Recording Software"/>
|
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="Custom Profit Control Recording Software" Comments="Profit Control Recording Software"/>
|
||||||
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
|
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
|
||||||
<!--Not set by default, EmbedCab="yes" embeds the cabinet file into the installer-->
|
<!--Not set by default, EmbedCab="yes" embeds the cabinet file into the installer-->
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<!--Detect .NET Framework 4.5-->
|
<!--Detect .NET Framework 4.5-->
|
||||||
<PropertyRef Id="NETFRAMEWORK45"/>
|
<PropertyRef Id="NETFRAMEWORK45"/>
|
||||||
|
|
||||||
<Condition Message="This application requires .NET Framework 4.5. Please install the .NET Framework then run this installer again.">
|
<Condition Message="[ProductName] requires .NET Framework 4.5. Please install the .NET Framework then run this installer again.">
|
||||||
<![CDATA[Installed OR NETFRAMEWORK45]]>
|
<![CDATA[Installed OR NETFRAMEWORK45]]>
|
||||||
</Condition>
|
</Condition>
|
||||||
<!--Define the icons used in the installer dialogs-->
|
<!--Define the icons used in the installer dialogs-->
|
||||||
|
|||||||
Reference in New Issue
Block a user