diff --git a/AdvertsingProfitControl/APCDatabase.accdb b/AdvertsingProfitControl/APCDatabase.accdb index b12af87..c7a14ac 100644 Binary files a/AdvertsingProfitControl/APCDatabase.accdb and b/AdvertsingProfitControl/APCDatabase.accdb differ diff --git a/AdvertsingProfitControl/NewAddRecord.cs b/AdvertsingProfitControl/NewAddRecord.cs index 0705c7e..0a2cde5 100644 --- a/AdvertsingProfitControl/NewAddRecord.cs +++ b/AdvertsingProfitControl/NewAddRecord.cs @@ -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) { diff --git a/AdvertsingProfitControl/NewModifyRecord.cs b/AdvertsingProfitControl/NewModifyRecord.cs index 7812b53..8e4779f 100644 --- a/AdvertsingProfitControl/NewModifyRecord.cs +++ b/AdvertsingProfitControl/NewModifyRecord.cs @@ -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()); } } } diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application index 330240f..2f951b4 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application @@ -14,7 +14,7 @@ - zpbkgJk14ECDIZQitxLLt8pDxjsgaGNLCsn6A15FHiw= + ib1gNsn2WoDzAPiOU+0/4RFlwIEfmJtvgCPloir4KFA= diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest index 1f27c83..edd7034 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest @@ -43,14 +43,14 @@ - + - RfwzuWZMEhfrUq7aBd3p9sX+V5RWL5yDo9XNd2Uj/JM= + cTFWoKFn2+4/0r/55ub0w4SG/Rc39J/A3gn6JBlTdZU= @@ -93,7 +93,7 @@ - dJHxM6HPIKo4c5VqxwCZb6aI2vGij+MP5mUPlilWJ/A= + oAigmBR/53icZZvL5j6Qt5ZBgYe6Mu1htzSdYejMGRo=