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
@@ -96,6 +96,29 @@ namespace AdvertsingProfitControl
dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false; dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = Color.White; dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = Color.White;
} }
//Then check to see if the next row is a member row
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
if (rowStatus == RowAttribute.MemberRow)
{
//Set the current row and check for changes.
if (!(bool)dataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue)
{
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
//Set the next row as a member row.
if (!(bool)dataGridView.Rows[i + 1].Cells[isMemberColumn].EditedFormattedValue)
{
dataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i + 1].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
dataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true;
dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = Color.LightBlue;
}
//IF previous row is Incomplete, then call the stable PaintRowGroups function. //IF previous row is Incomplete, then call the stable PaintRowGroups function.
else if (rowStatus == RowAttribute.IncompleteRow) else if (rowStatus == RowAttribute.IncompleteRow)
{ {
@@ -108,11 +131,21 @@ namespace AdvertsingProfitControl
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]); rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
if (rowStatus == RowAttribute.MemberRow) if (rowStatus == RowAttribute.MemberRow)
{ {
//Set the previous row as a header row. //Set the current row and check for changes.
if (!(bool)dataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue)
{
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
dataGridView.Rows[i].Cells[isHeaderColumn].Value = true; dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
dataGridView.Rows[i].Cells[isMemberColumn].Value = false; dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightGray; dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
//Set the next row as a member row. //Set the next row as a member row.
if (!(bool)dataGridView.Rows[i + 1].Cells[isMemberColumn].EditedFormattedValue)
{
dataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true;
dataGridView.Rows[i + 1].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
dataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false; dataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
dataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true; dataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true;
dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = Color.LightBlue; dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = Color.LightBlue;
+58 -10
View File
@@ -465,7 +465,7 @@ namespace AdvertsingProfitControl
adItemIndex = (int)InventoryTableColumns.AdItem; adItemIndex = (int)InventoryTableColumns.AdItem;
break; 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. //Paint the rows to identify what group they belong to.
_tableHelperFunctions.PaintRowGroupsFromIndex(e.RowIndex, dataGridView); _tableHelperFunctions.PaintRowGroupsFromIndex(e.RowIndex, dataGridView);
//Add in used Ad Items to the list. //Add in used Ad Items to the list.
@@ -3116,7 +3116,7 @@ namespace AdvertsingProfitControl
/// <returns>True on success otherwise, false.</returns> /// <returns>True on success otherwise, false.</returns>
private bool SaveRecords(bool displayInformation = true) private bool SaveRecords(bool displayInformation = true)
{ {
var success = false; var success = true;
//Get the date ID for the current active date. //Get the date ID for the current active date.
var dateId = GetDateId(_currentActiveDate.ToString("d")); var dateId = GetDateId(_currentActiveDate.ToString("d"));
if (dateId == 0) if (dateId == 0)
@@ -3142,11 +3142,18 @@ namespace AdvertsingProfitControl
//Spin through the collection and update the affected rows. //Spin through the collection and update the affected rows.
foreach (var rowIndex in writerResult.GetRowCollection()) 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.Id].Value =
projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false; rowIndex.Value;
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;
}
} }
//Next check to see if the update table has anything. //Next check to see if the update table has anything.
if (updateProjectionsTable.Rows.Count > 0) if (updateProjectionsTable.Rows.Count > 0)
@@ -3158,10 +3165,16 @@ namespace AdvertsingProfitControl
foreach (var rowIndex in writerResult.GetRowCollection()) foreach (var rowIndex in writerResult.GetRowCollection())
{ {
//Only reset the IsDirty value to false since the updates when through. //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].Cells[(int) SalesTableColumns.IsDirty].Value
projectionsDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved; = false;
projectionsDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor =
ApplicationColors.EditingSaved;
} }
} }
else
{
success = false;
}
} }
if (displayInformation) informationLabel.Text += @"Successfully saved projections." + Environment.NewLine; if (displayInformation) informationLabel.Text += @"Successfully saved projections." + Environment.NewLine;
} }
@@ -3187,11 +3200,18 @@ namespace AdvertsingProfitControl
foreach (var rowIndex in writerResult.GetRowCollection()) foreach (var rowIndex in writerResult.GetRowCollection())
{ {
//Only reset the IsDirty value to false since the updates when through. //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.Id].Value =
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int)InventoryTableColumns.IsDirty].Value = false; rowIndex.Value;
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved; 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. //Next check to see if the update table has anything.
if (inventoryUpdateTable.Rows.Count > 0) if (inventoryUpdateTable.Rows.Count > 0)
@@ -3207,9 +3227,21 @@ namespace AdvertsingProfitControl
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved; inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
} }
} }
else
{
success = false;
}
} }
if (displayInformation) informationLabel.Text += @"Successfully saved inventory." + Environment.NewLine; 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 actualSalesNewTable;
DataTable actualSalesUpdateTable; DataTable actualSalesUpdateTable;
var actualSalesTrimmingStatus = ConstructCleanedSalesTable("ActualSales", dateId, out actualSalesNewTable, out 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; actualSalesDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
} }
} }
else
{
success = false;
}
} }
//Next check to see if the update table has anything. //Next check to see if the update table has anything.
if (actualSalesUpdateTable.Rows.Count > 0) if (actualSalesUpdateTable.Rows.Count > 0)
@@ -3244,9 +3280,21 @@ namespace AdvertsingProfitControl
actualSalesDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved; actualSalesDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
} }
} }
else
{
success = false;
}
} }
if (displayInformation) informationLabel.Text += @"Successfully saved actual sales." + Environment.NewLine; 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; return success;
} }
+3 -2
View File
@@ -44,14 +44,15 @@ namespace AdvertsingProfitControl
{ {
return RowAttribute.NewRow; return RowAttribute.NewRow;
} }
//Determine the range to use during the looping process.
var headerCellIndex = row.Cells.Count == Enum.GetNames(typeof(SalesTableColumns)).Length ? (int)SalesTableColumns.IsHeaderRow : (int)InventoryTableColumns.IsHeaderRow;
var rowContents = new List<string>(); var rowContents = new List<string>();
var rowAttribute = RowAttribute.MemberRow; var rowAttribute = RowAttribute.MemberRow;
//Get the contents of the row that's being examined and add then to a List<string> array. //Get the contents of the row that's being examined and add then to a List<string> array.
var i = 0; var i = 0;
foreach (DataGridViewCell cell in row.Cells) foreach (DataGridViewCell cell in row.Cells)
{ {
if (cell.ColumnIndex >= (int) SalesTableColumns.IsHeaderRow || cell.ColumnIndex == 0) { i++; continue;} if (cell.ColumnIndex >= headerCellIndex || cell.ColumnIndex == 0) { i++; continue;}
//Strip all whitespace characters from the cell, this includes vertical tabs, newlines, and any number of spaces. //Strip all whitespace characters from the cell, this includes vertical tabs, newlines, and any number of spaces.
var cellContentsStripped = new string(cell.EditedFormattedValue.ToString().Where(c => !char.IsWhiteSpace(c)).ToArray()); var cellContentsStripped = new string(cell.EditedFormattedValue.ToString().Where(c => !char.IsWhiteSpace(c)).ToArray());
//Now remove all zeros, including any decimal points as these values are meaningless. //Now remove all zeros, including any decimal points as these values are meaningless.
@@ -14,7 +14,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>opU00zIbvKlwE9ETDbcBw3wn43DC9oTiG2Ds1yBbqBA=</dsig:DigestValue> <dsig:DigestValue>Btzwp78H3RT2AmoucaHpeRFbGzPf83asDL/GO1dGVPA=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
@@ -43,14 +43,14 @@
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
<dependency> <dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="3616256"> <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="3617280">
<assemblyIdentity name="AdvertsingProfitControl" version="0.9.5.2" language="neutral" processorArchitecture="amd64" /> <assemblyIdentity name="AdvertsingProfitControl" version="0.9.5.2" language="neutral" processorArchitecture="amd64" />
<hash> <hash>
<dsig:Transforms> <dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>T8dp3gOWrMgWFpeIbwYfpgMQxCEBFP64iXUiGpV4wto=</dsig:DigestValue> <dsig:DigestValue>xkEtzq+MLDnIJnChEMusRcJt0LD8/sPMW87LQ9g7ulE=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
@@ -93,7 +93,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>oAigmBR/53icZZvL5j6Qt5ZBgYe6Mu1htzSdYejMGRo=</dsig:DigestValue> <dsig:DigestValue>yZCLj+jy8vUBAeTKpwbwGxsDAc4IOfwKM+XGhtNBq5M=</dsig:DigestValue>
</hash> </hash>
</file> </file>
<file name="Stretched Logo Collection.ico" size="370070"> <file name="Stretched Logo Collection.ico" size="370070">