Modify record now fills in used ad items on data load. Fixed a bug where changing the ad special group name would mark the other table's ad special row as pending edit. Removed marking the ad special row as dirty, only its members are marked as such; this goes for color coding the heard cells too.

This commit is contained in:
2017-01-20 16:21:06 -06:00
parent 22b9ba4334
commit 84f43538d1
5 changed files with 159 additions and 55 deletions
Binary file not shown.
+63 -15
View File
@@ -769,27 +769,37 @@ namespace AdvertsingProfitControl
{
if (!projectionsDataGridView.Rows[index].IsNewRow)
{
projectionsDataGridView.Rows[index].Cells[(int) SalesTableColumns.IsDirty].Value = true;
}
projectionsDataGridView.Rows[index].Cells[(int)SalesTableColumns.IsDirty].Value = true;
projectionsDataGridView.Rows[index].HeaderCell.Style.BackColor =
ApplicationColors.PendingEdit;
}
}
if (index < actualSalesDataGridView.RowCount)
{
if (!actualSalesDataGridView.Rows[index].IsNewRow)
{
actualSalesDataGridView.Rows[index].Cells[(int)SalesTableColumns.IsDirty].Value = true;
}
actualSalesDataGridView.Rows[index].HeaderCell.Style.BackColor =
ApplicationColors.PendingEdit;
}
}
if (index < inventoryDataGridView.RowCount)
{
if (!inventoryDataGridView.Rows[index].IsNewRow)
{
inventoryDataGridView.Rows[index].Cells[(int)InventoryTableColumns.IsDirty].Value = true;
inventoryDataGridView.Rows[index].Cells[(int)InventoryTableColumns.IsDirty].Value =
true;
inventoryDataGridView.Rows[index].HeaderCell.Style.BackColor =
ApplicationColors.PendingEdit;
}
}
}
}
}
_usedAdItems[_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex ? 0 : 1].Remove(_beginningCellValue);
dataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsDirty].Value = true;
else
{
_usedAdItems[_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex ? 0 : 1].Remove(_beginningCellValue);
dataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsDirty].Value = true;
}
}
else if (userInput != _beginningCellValue)
{
@@ -969,8 +979,17 @@ namespace AdvertsingProfitControl
{
var adItemText = projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
if (e.RowIndex != _adSpecialIndex)
{
actualSalesDataGridView.Rows[e.RowIndex].Cells[(int)SalesTableColumns.IsDirty].Value = true;
actualSalesDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
projectionsDataGridView.RefreshEdit();
if (e.RowIndex != _adSpecialIndex)
{
inventoryDataGridView.Rows[e.RowIndex].Cells[(int)InventoryTableColumns.IsDirty].Value = true;
inventoryDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
//Remove the last ad item from the UsedAdItem array, the new one will be added in the OnRowLeave event handler.
if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex)
{
@@ -1175,7 +1194,9 @@ namespace AdvertsingProfitControl
var parser = new RowParsing();
if (parser.CheckForGroupKeyWord(userInput) == "NoGroupFound")
{
MessageBox.Show(@"The Ad Special row's column one (1) cannot be changed. You must delete this row by clicking on the header cell and pressing 'Delete'.", @"Invalid Operation on Ad Special Row", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(
@"The Ad Special row's column one (1) cannot be changed. You must delete this row by clicking on the header cell and pressing 'Delete'.",
@"Invalid Operation on Ad Special Row", MessageBoxButtons.OK, MessageBoxIcon.Error);
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = _beginningCellValue;
dataGridView.RefreshEdit();
return;
@@ -1189,6 +1210,8 @@ namespace AdvertsingProfitControl
if (!projectionsDataGridView.Rows[index].IsNewRow)
{
projectionsDataGridView.Rows[index].Cells[(int)SalesTableColumns.IsDirty].Value = true;
projectionsDataGridView.Rows[index].HeaderCell.Style.BackColor =
ApplicationColors.PendingEdit;
}
}
if (index < actualSalesDataGridView.RowCount)
@@ -1196,19 +1219,27 @@ namespace AdvertsingProfitControl
if (!actualSalesDataGridView.Rows[index].IsNewRow)
{
actualSalesDataGridView.Rows[index].Cells[(int)SalesTableColumns.IsDirty].Value = true;
actualSalesDataGridView.Rows[index].HeaderCell.Style.BackColor =
ApplicationColors.PendingEdit;
}
}
if (index < inventoryDataGridView.RowCount)
{
if (!inventoryDataGridView.Rows[index].IsNewRow)
{
inventoryDataGridView.Rows[index].Cells[(int)InventoryTableColumns.IsDirty].Value = true;
inventoryDataGridView.Rows[index].Cells[(int)InventoryTableColumns.IsDirty].Value =
true;
inventoryDataGridView.Rows[index].HeaderCell.Style.BackColor =
ApplicationColors.PendingEdit;
}
}
}
}
_usedAdItems[_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex ? 0 : 1].Remove(_beginningCellValue);
dataGridView.Rows[e.RowIndex].Cells[(int) InventoryTableColumns.IsDirty].Value = true;
else
{
_usedAdItems[_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex ? 0 : 1].Remove(_beginningCellValue);
dataGridView.Rows[e.RowIndex].Cells[(int) InventoryTableColumns.IsDirty].Value = true;
}
}
else if (userInput != _beginningCellValue)
{
@@ -1319,8 +1350,17 @@ namespace AdvertsingProfitControl
{
var adItemText = inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
if (e.RowIndex != _adSpecialIndex)
{
projectionsDataGridView.Rows[e.RowIndex].Cells[(int)SalesTableColumns.IsDirty].Value = true;
projectionsDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
//inventoryDataGridView.RefreshEdit();
if (e.RowIndex != _adSpecialIndex)
{
actualSalesDataGridView.Rows[e.RowIndex].Cells[(int)SalesTableColumns.IsDirty].Value = true;
actualSalesDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
//Remove the last ad item from the UsedAdItem array, the new one will be added in the OnRowLeave event handler.
if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex)
{
@@ -1330,7 +1370,6 @@ namespace AdvertsingProfitControl
{
_usedAdItems[1].RemoveAll(I => I.Equals(_beginningCellValue, StringComparison.OrdinalIgnoreCase));
}
return;
}
}
@@ -1476,8 +1515,17 @@ namespace AdvertsingProfitControl
{
var adItemText = actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
if (e.RowIndex != _adSpecialIndex)
{
projectionsDataGridView.Rows[e.RowIndex].Cells[(int)SalesTableColumns.IsDirty].Value = true;
projectionsDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
//projectionsDataGridView.RefreshEdit();
if (e.RowIndex != _adSpecialIndex)
{
inventoryDataGridView.Rows[e.RowIndex].Cells[(int)InventoryTableColumns.IsDirty].Value = true;
inventoryDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
//Remove the last ad item from the UsedAdItem array, the new one will be added in the OnRowLeave event handler.
if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex)
{
+92 -36
View File
@@ -810,27 +810,37 @@ namespace AdvertsingProfitControl
{
if (!projectionsDataGridView.Rows[index].IsNewRow)
{
projectionsDataGridView.Rows[index].Cells[(int)SalesTableColumns.IsDirty].Value = true;
projectionsDataGridView.Rows[index].Cells[(int) SalesTableColumns.IsDirty].Value = true;
projectionsDataGridView.Rows[index].HeaderCell.Style.BackColor =
ApplicationColors.PendingEdit;
}
}
if (index < actualSalesDataGridView.RowCount)
{
if (!actualSalesDataGridView.Rows[index].IsNewRow)
{
actualSalesDataGridView.Rows[index].Cells[(int)SalesTableColumns.IsDirty].Value = true;
actualSalesDataGridView.Rows[index].Cells[(int) SalesTableColumns.IsDirty].Value = true;
actualSalesDataGridView.Rows[index].HeaderCell.Style.BackColor =
ApplicationColors.PendingEdit;
}
}
if (index < inventoryDataGridView.RowCount)
{
if (!inventoryDataGridView.Rows[index].IsNewRow)
{
inventoryDataGridView.Rows[index].Cells[(int)InventoryTableColumns.IsDirty].Value = true;
inventoryDataGridView.Rows[index].Cells[(int) InventoryTableColumns.IsDirty].Value =
true;
inventoryDataGridView.Rows[index].HeaderCell.Style.BackColor =
ApplicationColors.PendingEdit;
}
}
}
}
_usedAdItems[_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex ? 0 : 1].Remove(_beginningCellValue);
dataGridView.Rows[e.RowIndex].Cells[(int)SalesTableColumns.IsDirty].Value = true;
else
{
_usedAdItems[_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex ? 0 : 1].Remove(_beginningCellValue);
dataGridView.Rows[e.RowIndex].Cells[(int)SalesTableColumns.IsDirty].Value = true;
}
}
else if (userInput != _beginningCellValue)
{
@@ -1017,11 +1027,17 @@ namespace AdvertsingProfitControl
{
var adItemText = projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
actualSalesDataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsDirty].Value = true;
actualSalesDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
if (e.RowIndex != _adSpecialIndex)
{
actualSalesDataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsDirty].Value = true;
actualSalesDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
inventoryDataGridView.Rows[e.RowIndex].Cells[(int) InventoryTableColumns.IsDirty].Value = true;
inventoryDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
if (e.RowIndex != _adSpecialIndex)
{
inventoryDataGridView.Rows[e.RowIndex].Cells[(int) InventoryTableColumns.IsDirty].Value = true;
inventoryDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
projectionsDataGridView.RefreshEdit();
//Remove the last ad item from the UsedAdItem array, the new one will be added in the OnRowLeave event handler.
if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex)
@@ -1232,7 +1248,9 @@ namespace AdvertsingProfitControl
var parser = new RowParsing();
if (parser.CheckForGroupKeyWord(userInput) == "NoGroupFound")
{
MessageBox.Show(@"The Ad Special row's column one (1) cannot be changed. You must delete this row by clicking on the header cell and pressing 'Delete'.", @"Invalid Operation on Ad Special Row", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(
@"The Ad Special row's column one (1) cannot be changed. You must delete this row by clicking on the header cell and pressing 'Delete'.",
@"Invalid Operation on Ad Special Row", MessageBoxButtons.OK, MessageBoxIcon.Error);
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = _beginningCellValue;
dataGridView.RefreshEdit();
return;
@@ -1245,27 +1263,37 @@ namespace AdvertsingProfitControl
{
if (!projectionsDataGridView.Rows[index].IsNewRow)
{
projectionsDataGridView.Rows[index].Cells[(int)SalesTableColumns.IsDirty].Value = true;
projectionsDataGridView.Rows[index].Cells[(int) SalesTableColumns.IsDirty].Value = true;
projectionsDataGridView.Rows[index].HeaderCell.Style.BackColor =
ApplicationColors.PendingEdit;
}
}
if (index < actualSalesDataGridView.RowCount)
{
if (!actualSalesDataGridView.Rows[index].IsNewRow)
{
actualSalesDataGridView.Rows[index].Cells[(int)SalesTableColumns.IsDirty].Value = true;
actualSalesDataGridView.Rows[index].Cells[(int) SalesTableColumns.IsDirty].Value = true;
actualSalesDataGridView.Rows[index].HeaderCell.Style.BackColor =
ApplicationColors.PendingEdit;
}
}
if (index < inventoryDataGridView.RowCount)
{
if (!inventoryDataGridView.Rows[index].IsNewRow)
{
inventoryDataGridView.Rows[index].Cells[(int)InventoryTableColumns.IsDirty].Value = true;
inventoryDataGridView.Rows[index].Cells[(int) InventoryTableColumns.IsDirty].Value =
true;
inventoryDataGridView.Rows[index].HeaderCell.Style.BackColor =
ApplicationColors.PendingEdit;
}
}
}
}
_usedAdItems[_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex ? 0 : 1].Remove(_beginningCellValue);
dataGridView.Rows[e.RowIndex].Cells[(int)InventoryTableColumns.IsDirty].Value = true;
else
{
_usedAdItems[_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex ? 0 : 1].Remove(_beginningCellValue);
dataGridView.Rows[e.RowIndex].Cells[(int)InventoryTableColumns.IsDirty].Value = true;
}
}
else if (userInput != _beginningCellValue)
{
@@ -1379,12 +1407,17 @@ namespace AdvertsingProfitControl
{
var adItemText = inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
projectionsDataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsDirty].Value = true;
projectionsDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
if (e.RowIndex != _adSpecialIndex)
{
projectionsDataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsDirty].Value = true;
projectionsDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
actualSalesDataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsDirty].Value = true;
actualSalesDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
//inventoryDataGridView.RefreshEdit();
if (e.RowIndex != _adSpecialIndex)
{
actualSalesDataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsDirty].Value = true;
actualSalesDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
//Remove the last ad item from the UsedAdItem array, the new one will be added in the OnRowLeave event handler.
if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex)
{
@@ -1540,11 +1573,17 @@ namespace AdvertsingProfitControl
{
var adItemText = actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
projectionsDataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsDirty].Value = true;
projectionsDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
if (e.RowIndex != _adSpecialIndex)
{
projectionsDataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsDirty].Value = true;
projectionsDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
inventoryDataGridView.Rows[e.RowIndex].Cells[(int) InventoryTableColumns.IsDirty].Value = true;
inventoryDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
if (e.RowIndex != _adSpecialIndex)
{
inventoryDataGridView.Rows[e.RowIndex].Cells[(int) InventoryTableColumns.IsDirty].Value = true;
inventoryDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
}
//projectionsDataGridView.RefreshEdit();
//Remove the last ad item from the UsedAdItem array, the new one will be added in the OnRowLeave event handler.
if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex)
@@ -2217,6 +2256,9 @@ namespace AdvertsingProfitControl
_beginningCellValue = "";
//Reset the form's dirty flag
_isFormDirty = false;
//Clear the used ad items
_usedAdItems[0].Clear(); //regular ad items (section 1)
_usedAdItems[1].Clear(); //ad special items (section 2)
//Clear invoices
invoicesDataGridView.Rows.Clear();
//Clear comments
@@ -2447,19 +2489,33 @@ namespace AdvertsingProfitControl
//Check the group it is part of if any.
if (cellIndex == 9)
{
if (projections.Rows[rowIndex].ItemArray[cellIndex].ToString() != "0" && _adSpecialIndex == -1)
//Check to see if this row belongs to an ad special group.
if (projections.Rows[rowIndex].ItemArray[cellIndex].ToString() != "0")
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var groupName =
databaseReader.ReturnGroupNameFromGroupId(
projections.Rows[rowIndex].ItemArray[cellIndex].ToString(),
databaseTracker.DatabaseConnectionString);
var adSpecialRow = new DataGridViewRow();
projectionsDataGridView.Rows.Add(adSpecialRow);
projectionsDataGridView.Rows[rowIndex].Cells[1].Value = groupName;
projectionsDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
_adSpecialIndex = rowIndex;
//If so add the ad item in it to section two (2) of the used ad item array.
_usedAdItems[1].Add(projections.Rows[rowIndex].ItemArray[1].ToString());
//If the ad special index is not set, then create the ad special row with the human friendly group name.
if (_adSpecialIndex == -1)
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var groupName =
databaseReader.ReturnGroupNameFromGroupId(
projections.Rows[rowIndex].ItemArray[cellIndex].ToString(),
databaseTracker.DatabaseConnectionString);
var adSpecialRow = new DataGridViewRow();
projectionsDataGridView.Rows.Add(adSpecialRow);
projectionsDataGridView.Rows[rowIndex].Cells[1].Value = groupName;
projectionsDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor =
ApplicationColors.AdSpecial;
_adSpecialIndex = rowIndex;
}
}
else
{
//The ad item belongs in section one (1) of the used ad item array.
_usedAdItems[0].Add(projections.Rows[rowIndex].ItemArray[1].ToString());
}
}
}
@@ -14,7 +14,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>zpbkgJk14ECDIZQitxLLt8pDxjsgaGNLCsn6A15FHiw=</dsig:DigestValue>
<dsig:DigestValue>ib1gNsn2WoDzAPiOU+0/4RFlwIEfmJtvgCPloir4KFA=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
@@ -43,14 +43,14 @@
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="3606528">
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="3607040">
<assemblyIdentity name="AdvertsingProfitControl" version="0.9.5.2" language="neutral" processorArchitecture="amd64" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>RfwzuWZMEhfrUq7aBd3p9sX+V5RWL5yDo9XNd2Uj/JM=</dsig:DigestValue>
<dsig:DigestValue>cTFWoKFn2+4/0r/55ub0w4SG/Rc39J/A3gn6JBlTdZU=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
@@ -93,7 +93,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>dJHxM6HPIKo4c5VqxwCZb6aI2vGij+MP5mUPlilWJ/A=</dsig:DigestValue>
<dsig:DigestValue>oAigmBR/53icZZvL5j6Qt5ZBgYe6Mu1htzSdYejMGRo=</dsig:DigestValue>
</hash>
</file>
<file name="Stretched Logo Collection.ico" size="370070">