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
+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)
{