Updated the behavior of the Inventory data table to reflect the row attributes of the Actual Sales table. Minor tweaks to the Manage Ad Items form.

This commit is contained in:
2017-07-14 18:23:00 -05:00
parent 3b36476a6c
commit ac9f464cf3
6 changed files with 350 additions and 49 deletions
+1
View File
@@ -149,6 +149,7 @@
//
// replaceReferencesButton
//
this.replaceReferencesButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.replaceReferencesButton.Enabled = false;
this.replaceReferencesButton.Location = new System.Drawing.Point(259, 449);
this.replaceReferencesButton.Margin = new System.Windows.Forms.Padding(4);
+8 -9
View File
@@ -319,7 +319,6 @@ namespace AdvertsingProfitControl
var newItem = (AdItem) adItemsListView.SelectedItems[0].Tag;
var db = new AdvertisingProfitControlDbContext();
var replacementCount = 0;
var skipCount = 0;
try
{
@@ -329,8 +328,6 @@ namespace AdvertsingProfitControl
foreach (var record in projectionsToUpdate)
{
var table = db.Projections.Where(x => x.FkDateId == record.FkDateId);
if (table.Count(x => x.FkDateId == record.FkDateId) == 0) continue;
record.FkAdItemId = newItem.Id;
db.Projections.Attach(record);
db.Entry(record).State = EntityState.Modified;
@@ -341,8 +338,6 @@ namespace AdvertsingProfitControl
foreach (var record in inventoryToUpdate)
{
var table = db.Inventories.Where(x => x.FkDateId == record.FkDateId);
if (table.Count(x => x.FkDateId == record.FkDateId) == 0) continue;
record.FkAdItemId = newItem.Id;
db.Inventories.Attach(record);
db.Entry(record).State = EntityState.Modified;
@@ -353,8 +348,6 @@ namespace AdvertsingProfitControl
foreach (var record in actualSalesToUpdate)
{
var table = db.ActualSales.Where(x => x.FkDateId == record.FkDateId);
if (table.Count(x => x.FkDateId == record.FkDateId) == 0) continue;
record.FkAdItemId = newItem.Id;
db.ActualSales.Attach(record);
db.Entry(record).State = EntityState.Modified;
@@ -366,13 +359,19 @@ namespace AdvertsingProfitControl
scope.Complete();
}
//All completed without error so give the user the option to delete the replace.
var result = MessageBox.Show(_replacee.Name + @" has been successfully replaced with " + newItem.Name + @". Would you like to delete " + _replacee.Name + @" from the database?", @"Replacement Completed Successfully on " + replacementCount + @" Item(s)", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
var result =
MessageBox.Show(
_replacee.Name + @" has been successfully replaced with " + newItem.Name +
@". Would you like to delete " + _replacee.Name + @" from the database?",
@"Replacement Completed Successfully on " + replacementCount + @" Item(s)",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
_replacee = db.AdItems.Single(x => x.Id == _replacee.Id);
db.AdItems.Remove(_replacee);
db.SaveChanges();
informationLabel.Text = @"Removed " + Environment.NewLine + _replacee.Name + Environment.NewLine + @" from the database.";
informationLabel.Text = @"Removed " + Environment.NewLine + _replacee.Name + Environment.NewLine +
@" from the database.";
}
SetFormStateAdNewItem();
RefreshAdItemListing(filterComboBox.SelectedItem.ToString());
+15 -4
View File
@@ -518,7 +518,14 @@ namespace AdvertsingProfitControl
}
var userInput = dataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString().Trim();
//Paint the rows to identify what group they belong to.
TableGroupParser.PaintRowGroupsFromIndex(e.RowIndex, dataGridView);
if (dataGridView != inventoryDataGridView)
{
TableGroupParser.PaintRowGroupsFromIndex(e.RowIndex, dataGridView);
}
else
{
TableGroupParser.PaintInventoryRowGroups(e.RowIndex, inventoryDataGridView, actualSalesDataGridView);
}
//Add in used Ad Items to the list.
if (userInput == string.Empty) return;
//Clear the old ad item out of the used ad item collection.
@@ -1012,7 +1019,7 @@ namespace AdvertsingProfitControl
{
inventoryDataGridView.Rows[e.RowIndex].Cells[(int) TableGroupParser.InventoryTableColumns.AdItem].Value = userInput;
}
TableGroupParser.PaintRowGroupsFromIndex(e.RowIndex - 1, inventoryDataGridView);
TableGroupParser.PaintInventoryRowGroups(e.RowIndex - 1, inventoryDataGridView, actualSalesDataGridView); //TODO:CHANGED .PaintRowGroupsFromIndex(e.RowIndex - 1, inventoryDataGridView);
if (actualSalesDataGridView.RowCount > e.RowIndex)
{
actualSalesDataGridView.Rows[e.RowIndex].Cells[(int) TableGroupParser.SalesTableColumns.AdItem].Value = userInput;
@@ -1530,7 +1537,7 @@ namespace AdvertsingProfitControl
{
inventoryDataGridView.Rows[e.RowIndex].Cells[(int)TableGroupParser.InventoryTableColumns.AdItem].Value = userInput;
}
TableGroupParser.PaintRowGroupsFromIndex(e.RowIndex - 1, inventoryDataGridView);
TableGroupParser.PaintInventoryRowGroups(e.RowIndex - 1, inventoryDataGridView, actualSalesDataGridView); //TODO:CHANGE .PaintRowGroupsFromIndex(e.RowIndex - 1, inventoryDataGridView);
if (actualSalesDataGridView.RowCount > e.RowIndex)
{
actualSalesDataGridView.Rows[e.RowIndex].Cells[(int)TableGroupParser.SalesTableColumns.AdItem].Value = userInput;
@@ -1856,7 +1863,7 @@ out double beginningBinCount, out string newBinText))
projectionsDataGridView.RefreshEdit();
inventoryDataGridView.RefreshEdit();
actualSalesDataGridView.RefreshEdit();
TableGroupParser.PaintRowGroups(dataGridView);
TableGroupParser.PaintInventoryRowGroups(0, inventoryDataGridView, actualSalesDataGridView); //TODO: CHANEG.PaintRowGroups(dataGridView);
}
#endregion
@@ -3274,6 +3281,10 @@ out double beginningBinCount, out string newBinText))
try
{
//Force update all the data tables.
//TableGroupParser.PaintRowGroupsFromIndex(0, projectionsDataGridView);
//TableGroupParser.PaintRowGroupsFromIndex(0, inventoryDataGridView);
//TableGroupParser.PaintRowGroupsFromIndex(0, actualSalesDataGridView);
using (var scope = new TransactionScope())
{
SaveProjections(date);
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.0.1.0")]
[assembly: AssemblyFileVersion("3.0.1.0")]
[assembly: AssemblyVersion("3.1.2.0")]
[assembly: AssemblyFileVersion("3.1.2.0")]