Finished the APC table saving code. Fixed a bug with the row parsing engine.

This commit is contained in:
2017-01-21 03:43:31 -06:00
parent 12239bce23
commit f9968942ea
5 changed files with 100 additions and 18 deletions
+59 -11
View File
@@ -465,7 +465,7 @@ namespace AdvertsingProfitControl
adItemIndex = (int)InventoryTableColumns.AdItem;
break;
}
var userInput = dataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
var userInput = dataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString().Trim();
//Paint the rows to identify what group they belong to.
_tableHelperFunctions.PaintRowGroupsFromIndex(e.RowIndex, dataGridView);
//Add in used Ad Items to the list.
@@ -3116,7 +3116,7 @@ namespace AdvertsingProfitControl
/// <returns>True on success otherwise, false.</returns>
private bool SaveRecords(bool displayInformation = true)
{
var success = false;
var success = true;
//Get the date ID for the current active date.
var dateId = GetDateId(_currentActiveDate.ToString("d"));
if (dateId == 0)
@@ -3142,11 +3142,18 @@ namespace AdvertsingProfitControl
//Spin through the collection and update the affected rows.
foreach (var rowIndex in writerResult.GetRowCollection())
{
projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.Id].Value = rowIndex.Value;
projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false;
projectionsDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.Id].Value =
rowIndex.Value;
projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.IsDirty].Value
= false;
projectionsDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor =
ApplicationColors.EditingSaved;
}
}
else
{
success = false;
}
}
//Next check to see if the update table has anything.
if (updateProjectionsTable.Rows.Count > 0)
@@ -3158,10 +3165,16 @@ namespace AdvertsingProfitControl
foreach (var rowIndex in writerResult.GetRowCollection())
{
//Only reset the IsDirty value to false since the updates when through.
projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false;
projectionsDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.IsDirty].Value
= false;
projectionsDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor =
ApplicationColors.EditingSaved;
}
}
else
{
success = false;
}
}
if (displayInformation) informationLabel.Text += @"Successfully saved projections." + Environment.NewLine;
}
@@ -3187,10 +3200,17 @@ namespace AdvertsingProfitControl
foreach (var rowIndex in writerResult.GetRowCollection())
{
//Only reset the IsDirty value to false since the updates when through.
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int)InventoryTableColumns.Id].Value = rowIndex.Value;
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int)InventoryTableColumns.IsDirty].Value = false;
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
}
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int) InventoryTableColumns.Id].Value =
rowIndex.Value;
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int) InventoryTableColumns.IsDirty]
.Value = false;
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor =
ApplicationColors.EditingSaved;
}
}
else
{
success = false;
}
}
//Next check to see if the update table has anything.
@@ -3207,9 +3227,21 @@ namespace AdvertsingProfitControl
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
}
}
else
{
success = false;
}
}
if (displayInformation) informationLabel.Text += @"Successfully saved inventory." + Environment.NewLine;
}
else if (projectionsTrimmingStatus == TrimmingOperationResult.NoChangesRequired)
{
if (displayInformation) informationLabel.Text += @"No changes to inventory detected." + Environment.NewLine;
}
else
{
errorLabel.Text += @"Failed to process inventory." + Environment.NewLine;
}
DataTable actualSalesNewTable;
DataTable actualSalesUpdateTable;
var actualSalesTrimmingStatus = ConstructCleanedSalesTable("ActualSales", dateId, out actualSalesNewTable, out actualSalesUpdateTable);
@@ -3229,6 +3261,10 @@ namespace AdvertsingProfitControl
actualSalesDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
}
}
else
{
success = false;
}
}
//Next check to see if the update table has anything.
if (actualSalesUpdateTable.Rows.Count > 0)
@@ -3244,9 +3280,21 @@ namespace AdvertsingProfitControl
actualSalesDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
}
}
else
{
success = false;
}
}
if (displayInformation) informationLabel.Text += @"Successfully saved actual sales." + Environment.NewLine;
}
else if (projectionsTrimmingStatus == TrimmingOperationResult.NoChangesRequired)
{
if (displayInformation) informationLabel.Text += @"No changes to actual sales detected." + Environment.NewLine;
}
else
{
errorLabel.Text += @"Failed to process actual sales." + Environment.NewLine;
}
return success;
}