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:
@@ -41,6 +41,9 @@ namespace AdvertsingProfitControl
|
||||
private bool _isFormDirty;
|
||||
//
|
||||
private bool _isModifyingRecord;
|
||||
|
||||
private int _selectedRowIndex = -1;
|
||||
|
||||
public NewModifyRecord(DateTime date)
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -105,6 +108,10 @@ namespace AdvertsingProfitControl
|
||||
projectionsDataGridView.CellEnter += StoreBeginningCellValue;
|
||||
inventoryDataGridView.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.
|
||||
projectionsDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave;
|
||||
inventoryDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave;
|
||||
@@ -472,6 +479,18 @@ namespace AdvertsingProfitControl
|
||||
_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>
|
||||
/// Event Used: OnRowLeave
|
||||
/// 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 (_adSpecialIndex == -1)
|
||||
if (_adSpecialIndex == -1 || _adSpecialIndex == _selectedRowIndex)
|
||||
{
|
||||
textBox.AutoCompleteCustomSource = _adSpecialList;
|
||||
informationLabel.Text = @"Auto complete mode changed to Ad Special.";
|
||||
@@ -824,7 +843,7 @@ namespace AdvertsingProfitControl
|
||||
else
|
||||
{
|
||||
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)
|
||||
@@ -2754,6 +2773,8 @@ namespace AdvertsingProfitControl
|
||||
if (projection.FkAdSpecialId != null && adSpecialIndex == -1)
|
||||
{
|
||||
adSpecialIndex = index;
|
||||
//Set the form's ad special index field.
|
||||
_adSpecialIndex = index;
|
||||
projectionsDataGridView.Rows.Insert(index, 1);
|
||||
//Apply the ad special text.
|
||||
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 (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.
|
||||
var adItem = new AdItem();
|
||||
//Sadly, LINQ doesn't like calls to the ToString method so we create a temp variable.
|
||||
@@ -3420,6 +3441,7 @@ namespace AdvertsingProfitControl
|
||||
: decimal.Parse(
|
||||
row.Cells[(int) SalesTableColumns.TotalProfitReturn].EditedFormattedValue
|
||||
.ToString());
|
||||
projection.FkAdSpecialId = adSpecial.Id == 0 ? (int?) null : adSpecial.Id;
|
||||
projection.FkAdItemId = adItem.Id;
|
||||
projection.RowAttribute = rowAttribute;
|
||||
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 (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.
|
||||
var adItem = new AdItem();
|
||||
//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();
|
||||
inventory.EndingInventory =
|
||||
row.Cells[(int)InventoryTableColumns.EndingInventory].EditedFormattedValue.ToString();
|
||||
inventory.FkAdSpecialId = adSpecial.Id == 0 ? (int?)null : adSpecial.Id;
|
||||
inventory.FkAdItemId = adItem.Id;
|
||||
inventory.RowAttribute = rowAttribute;
|
||||
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 (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.
|
||||
var adItem = new AdItem();
|
||||
//Sadly, LINQ doesn't like calls to the ToString method so we create a temp variable.
|
||||
@@ -3726,6 +3749,7 @@ namespace AdvertsingProfitControl
|
||||
: decimal.Parse(
|
||||
row.Cells[(int)SalesTableColumns.TotalProfitReturn].EditedFormattedValue
|
||||
.ToString());
|
||||
actualSale.FkAdSpecialId = adSpecial.Id == 0 ? (int?)null : adSpecial.Id;
|
||||
actualSale.FkAdItemId = adItem.Id;
|
||||
actualSale.RowAttribute = rowAttribute;
|
||||
actualSale.RowPosition = row.Index + 1;
|
||||
@@ -4458,6 +4482,5 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user