Updated the behavior of the Inventory data table to reflect the row attributes of the Actual Sales table. Minor tweaks to the Manage Ad Items form.
This commit is contained in:
@@ -149,6 +149,7 @@
|
||||
//
|
||||
// replaceReferencesButton
|
||||
//
|
||||
this.replaceReferencesButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
|
||||
this.replaceReferencesButton.Enabled = false;
|
||||
this.replaceReferencesButton.Location = new System.Drawing.Point(259, 449);
|
||||
this.replaceReferencesButton.Margin = new System.Windows.Forms.Padding(4);
|
||||
|
||||
@@ -319,7 +319,6 @@ namespace AdvertsingProfitControl
|
||||
var newItem = (AdItem) adItemsListView.SelectedItems[0].Tag;
|
||||
var db = new AdvertisingProfitControlDbContext();
|
||||
var replacementCount = 0;
|
||||
var skipCount = 0;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -329,8 +328,6 @@ namespace AdvertsingProfitControl
|
||||
|
||||
foreach (var record in projectionsToUpdate)
|
||||
{
|
||||
var table = db.Projections.Where(x => x.FkDateId == record.FkDateId);
|
||||
if (table.Count(x => x.FkDateId == record.FkDateId) == 0) continue;
|
||||
record.FkAdItemId = newItem.Id;
|
||||
db.Projections.Attach(record);
|
||||
db.Entry(record).State = EntityState.Modified;
|
||||
@@ -341,8 +338,6 @@ namespace AdvertsingProfitControl
|
||||
|
||||
foreach (var record in inventoryToUpdate)
|
||||
{
|
||||
var table = db.Inventories.Where(x => x.FkDateId == record.FkDateId);
|
||||
if (table.Count(x => x.FkDateId == record.FkDateId) == 0) continue;
|
||||
record.FkAdItemId = newItem.Id;
|
||||
db.Inventories.Attach(record);
|
||||
db.Entry(record).State = EntityState.Modified;
|
||||
@@ -353,8 +348,6 @@ namespace AdvertsingProfitControl
|
||||
|
||||
foreach (var record in actualSalesToUpdate)
|
||||
{
|
||||
var table = db.ActualSales.Where(x => x.FkDateId == record.FkDateId);
|
||||
if (table.Count(x => x.FkDateId == record.FkDateId) == 0) continue;
|
||||
record.FkAdItemId = newItem.Id;
|
||||
db.ActualSales.Attach(record);
|
||||
db.Entry(record).State = EntityState.Modified;
|
||||
@@ -366,13 +359,19 @@ namespace AdvertsingProfitControl
|
||||
scope.Complete();
|
||||
}
|
||||
//All completed without error so give the user the option to delete the replace.
|
||||
var result = MessageBox.Show(_replacee.Name + @" has been successfully replaced with " + newItem.Name + @". Would you like to delete " + _replacee.Name + @" from the database?", @"Replacement Completed Successfully on " + replacementCount + @" Item(s)", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
var result =
|
||||
MessageBox.Show(
|
||||
_replacee.Name + @" has been successfully replaced with " + newItem.Name +
|
||||
@". Would you like to delete " + _replacee.Name + @" from the database?",
|
||||
@"Replacement Completed Successfully on " + replacementCount + @" Item(s)",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
_replacee = db.AdItems.Single(x => x.Id == _replacee.Id);
|
||||
db.AdItems.Remove(_replacee);
|
||||
db.SaveChanges();
|
||||
informationLabel.Text = @"Removed " + Environment.NewLine + _replacee.Name + Environment.NewLine + @" from the database.";
|
||||
informationLabel.Text = @"Removed " + Environment.NewLine + _replacee.Name + Environment.NewLine +
|
||||
@" from the database.";
|
||||
}
|
||||
SetFormStateAdNewItem();
|
||||
RefreshAdItemListing(filterComboBox.SelectedItem.ToString());
|
||||
|
||||
@@ -518,7 +518,14 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
var userInput = dataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString().Trim();
|
||||
//Paint the rows to identify what group they belong to.
|
||||
TableGroupParser.PaintRowGroupsFromIndex(e.RowIndex, dataGridView);
|
||||
if (dataGridView != inventoryDataGridView)
|
||||
{
|
||||
TableGroupParser.PaintRowGroupsFromIndex(e.RowIndex, dataGridView);
|
||||
}
|
||||
else
|
||||
{
|
||||
TableGroupParser.PaintInventoryRowGroups(e.RowIndex, inventoryDataGridView, actualSalesDataGridView);
|
||||
}
|
||||
//Add in used Ad Items to the list.
|
||||
if (userInput == string.Empty) return;
|
||||
//Clear the old ad item out of the used ad item collection.
|
||||
@@ -1012,7 +1019,7 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
inventoryDataGridView.Rows[e.RowIndex].Cells[(int) TableGroupParser.InventoryTableColumns.AdItem].Value = userInput;
|
||||
}
|
||||
TableGroupParser.PaintRowGroupsFromIndex(e.RowIndex - 1, inventoryDataGridView);
|
||||
TableGroupParser.PaintInventoryRowGroups(e.RowIndex - 1, inventoryDataGridView, actualSalesDataGridView); //TODO:CHANGED .PaintRowGroupsFromIndex(e.RowIndex - 1, inventoryDataGridView);
|
||||
if (actualSalesDataGridView.RowCount > e.RowIndex)
|
||||
{
|
||||
actualSalesDataGridView.Rows[e.RowIndex].Cells[(int) TableGroupParser.SalesTableColumns.AdItem].Value = userInput;
|
||||
@@ -1530,7 +1537,7 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
inventoryDataGridView.Rows[e.RowIndex].Cells[(int)TableGroupParser.InventoryTableColumns.AdItem].Value = userInput;
|
||||
}
|
||||
TableGroupParser.PaintRowGroupsFromIndex(e.RowIndex - 1, inventoryDataGridView);
|
||||
TableGroupParser.PaintInventoryRowGroups(e.RowIndex - 1, inventoryDataGridView, actualSalesDataGridView); //TODO:CHANGE .PaintRowGroupsFromIndex(e.RowIndex - 1, inventoryDataGridView);
|
||||
if (actualSalesDataGridView.RowCount > e.RowIndex)
|
||||
{
|
||||
actualSalesDataGridView.Rows[e.RowIndex].Cells[(int)TableGroupParser.SalesTableColumns.AdItem].Value = userInput;
|
||||
@@ -1856,7 +1863,7 @@ out double beginningBinCount, out string newBinText))
|
||||
projectionsDataGridView.RefreshEdit();
|
||||
inventoryDataGridView.RefreshEdit();
|
||||
actualSalesDataGridView.RefreshEdit();
|
||||
TableGroupParser.PaintRowGroups(dataGridView);
|
||||
TableGroupParser.PaintInventoryRowGroups(0, inventoryDataGridView, actualSalesDataGridView); //TODO: CHANEG.PaintRowGroups(dataGridView);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -3274,6 +3281,10 @@ out double beginningBinCount, out string newBinText))
|
||||
|
||||
try
|
||||
{
|
||||
//Force update all the data tables.
|
||||
//TableGroupParser.PaintRowGroupsFromIndex(0, projectionsDataGridView);
|
||||
//TableGroupParser.PaintRowGroupsFromIndex(0, inventoryDataGridView);
|
||||
//TableGroupParser.PaintRowGroupsFromIndex(0, actualSalesDataGridView);
|
||||
using (var scope = new TransactionScope())
|
||||
{
|
||||
SaveProjections(date);
|
||||
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("3.0.1.0")]
|
||||
[assembly: AssemblyFileVersion("3.0.1.0")]
|
||||
[assembly: AssemblyVersion("3.1.2.0")]
|
||||
[assembly: AssemblyFileVersion("3.1.2.0")]
|
||||
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("1.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||
|
||||
@@ -21,17 +21,12 @@ namespace DataTableParsingEngine
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var parser = new RowParser();
|
||||
int isHeaderColumn;
|
||||
int isMemberColumn;
|
||||
int isDirtyColumn;
|
||||
if (dataGridView.Columns.Count == Enum.GetNames(typeof(SalesTableColumns)).Length)
|
||||
{
|
||||
isHeaderColumn = (int)SalesTableColumns.IsHeaderRow;
|
||||
isMemberColumn = (int)SalesTableColumns.IsMemberRow;
|
||||
isDirtyColumn = (int)SalesTableColumns.IsDirty;
|
||||
}
|
||||
else
|
||||
var isHeaderColumn = (int)SalesTableColumns.IsHeaderRow;
|
||||
var isMemberColumn = (int)SalesTableColumns.IsMemberRow;
|
||||
var isDirtyColumn = (int)SalesTableColumns.IsDirty;
|
||||
if (dataGridView.ColumnCount < Enum.GetNames(typeof(SalesTableColumns)).Length)
|
||||
{
|
||||
isHeaderColumn = (int)InventoryTableColumns.IsHeaderRow;
|
||||
isMemberColumn = (int)InventoryTableColumns.IsMemberRow;
|
||||
@@ -90,6 +85,12 @@ namespace DataTableParsingEngine
|
||||
//IF the previous row is a header row OR if the previous row is index zero AND a member row, clear its coloring.
|
||||
if (rowStatus == RowParser.RowAttribute.HeaderRow || rowStatus == RowParser.RowAttribute.MemberRow && (i - 1) == 0)
|
||||
{
|
||||
//Set the current row and check for changes.
|
||||
if ((bool)dataGridView.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
//Clear the previous row of its attributes.
|
||||
dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
|
||||
@@ -128,27 +129,25 @@ namespace DataTableParsingEngine
|
||||
{
|
||||
//Then check to see if the next row is a member row
|
||||
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
|
||||
if (rowStatus == RowParser.RowAttribute.MemberRow)
|
||||
if (rowStatus != RowParser.RowAttribute.MemberRow) continue;
|
||||
//Set the current row and check for changes.
|
||||
if (!(bool)dataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue)
|
||||
{
|
||||
//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 = TableColors.PendingEdit;
|
||||
}
|
||||
dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
|
||||
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
//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 = TableColors.PendingEdit;
|
||||
}
|
||||
dataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true;
|
||||
dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
|
||||
dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
//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 = TableColors.PendingEdit;
|
||||
}
|
||||
dataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true;
|
||||
dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
}
|
||||
else if (rowStatus == RowParser.RowAttribute.MemberRow)
|
||||
@@ -161,6 +160,12 @@ namespace DataTableParsingEngine
|
||||
if (rowStatus == RowParser.RowAttribute.MemberRow && (i - 1) == 0)
|
||||
{
|
||||
//Clear the previous row of its attributes.
|
||||
if ((bool)dataGridView.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
//And mark it as dirty if those attributes have been set for whatever reason.
|
||||
dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
|
||||
@@ -252,6 +257,12 @@ namespace DataTableParsingEngine
|
||||
else
|
||||
{
|
||||
//Clear the current row of its attributes.
|
||||
if (!(bool)dataGridView.Rows[0].Cells[isMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
//If the row thinks that it's a member row then set it to dirty so the changes can be shown.
|
||||
dataGridView.Rows[0].Cells[isDirtyColumn].Value = true;
|
||||
dataGridView.Rows[0].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
dataGridView.Rows[0].Cells[isHeaderColumn].Value = false;
|
||||
dataGridView.Rows[0].Cells[isMemberColumn].Value = false;
|
||||
dataGridView.Rows[0].DefaultCellStyle.BackColor = default(Color);
|
||||
@@ -297,13 +308,292 @@ namespace DataTableParsingEngine
|
||||
|
||||
public static void PaintRowGroups(DataGridView table)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void PaintInventoryRowGroups(int startingIndex, DataGridView inventoryDataGridView,
|
||||
DataGridView companionDataGridView = null)
|
||||
DataGridView masterDataGridView)
|
||||
{
|
||||
|
||||
var isHeaderColumn = (int)InventoryTableColumns.IsHeaderRow;
|
||||
var isMemberColumn = (int)InventoryTableColumns.IsMemberRow;
|
||||
var isDirtyColumn = (int)InventoryTableColumns.IsDirty;
|
||||
var masterHeaderColumn = (int)SalesTableColumns.IsHeaderRow;
|
||||
var masterMemberColumn = (int)SalesTableColumns.IsMemberRow;
|
||||
|
||||
var parser = new RowParser();
|
||||
//Spin through the dataGridView rows starting at the row that fired the event.
|
||||
for (var i = startingIndex; i < (inventoryDataGridView.RowCount - 1); i++)
|
||||
{
|
||||
//Get the status of the current row.
|
||||
var rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i]);
|
||||
//IF the current row is a header row...
|
||||
if (rowStatus == RowParser.RowAttribute.HeaderRow)
|
||||
{
|
||||
//Then check to see if the next row is a row header.
|
||||
rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i + 1]);
|
||||
//IF so, color code this row as White, since it is not a true group header.
|
||||
if (rowStatus == RowParser.RowAttribute.HeaderRow)
|
||||
{
|
||||
//Clear the current row of its attributes.
|
||||
inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
return;
|
||||
}
|
||||
//IF the current row is not the first row in the data grid (index zero)...
|
||||
if (i > 0)
|
||||
{
|
||||
//The start by checking the previous row's status.
|
||||
rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i - 1]);
|
||||
//IF the previous row is a header row AND has color coding saying it is a group header, then clear the previous row's color and apply it to this row (i).
|
||||
if (rowStatus == RowParser.RowAttribute.HeaderRow && (bool)masterDataGridView.Rows[i - 1].Cells[masterHeaderColumn].EditedFormattedValue)
|
||||
{
|
||||
//Clear the previous row of its attributes.
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
|
||||
//This condition means the user changed the members of a group, so the old header row needs to be updated in the database.
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
inventoryDataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
|
||||
//Check the next row to see if its a member row before declaring the current row a header row.
|
||||
rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i + 1]);
|
||||
if (rowStatus != RowParser.RowAttribute.MemberRow)
|
||||
{
|
||||
//Clear the coloring from the current row.
|
||||
inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
return;
|
||||
}
|
||||
//Set the current row as a header row.
|
||||
inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.HeaderRow;
|
||||
return;
|
||||
}
|
||||
//IF the previous row is a header row OR if the previous row is index zero AND a member row, clear its coloring.
|
||||
if (rowStatus == RowParser.RowAttribute.HeaderRow || rowStatus == RowParser.RowAttribute.MemberRow && (i - 1) == 0)
|
||||
{
|
||||
//Set the current row and check for changes.
|
||||
if ((bool)masterDataGridView.Rows[i - 1].Cells[masterMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
//Clear the previous row of its attributes.
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
//Then check to see if the next row is a member row
|
||||
rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i + 1]);
|
||||
if (rowStatus == RowParser.RowAttribute.MemberRow)
|
||||
{
|
||||
//Set the current row and check for changes.
|
||||
if (!(bool)masterDataGridView.Rows[i].Cells[masterHeaderColumn].EditedFormattedValue)
|
||||
{
|
||||
inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.HeaderRow;
|
||||
//Set the next row as a member row.
|
||||
if (!(bool)masterDataGridView.Rows[i + 1].Cells[masterMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
inventoryDataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
inventoryDataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
//IF previous row is Incomplete, then call the stable PaintRowGroups function.
|
||||
else if (rowStatus == RowParser.RowAttribute.IncompleteRow)
|
||||
{
|
||||
//PaintRowGroups(dataGridView);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Then check to see if the next row is a member row
|
||||
rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i + 1]);
|
||||
if (rowStatus != RowParser.RowAttribute.MemberRow) continue;
|
||||
//Set the current row and check for changes.
|
||||
if (!(bool)masterDataGridView.Rows[i].Cells[masterHeaderColumn].EditedFormattedValue)
|
||||
{
|
||||
inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
//Set the next row as a member row.
|
||||
if (!(bool)masterDataGridView.Rows[i + 1].Cells[masterMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
inventoryDataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
inventoryDataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
}
|
||||
else if (rowStatus == RowParser.RowAttribute.MemberRow)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
//Check the previous row.
|
||||
rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i - 1]);
|
||||
//IF the previous row is a member row AND is the first row in the data grid, then remove the coloring from it and the current row (i).
|
||||
if (rowStatus == RowParser.RowAttribute.MemberRow && (i - 1) == 0)
|
||||
{
|
||||
//Clear the previous row of its attributes.
|
||||
if ((bool)masterDataGridView.Rows[i - 1].Cells[masterMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
//And mark it as dirty if those attributes have been set for whatever reason.
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
|
||||
//Check for changes in the current row.
|
||||
if ((bool)masterDataGridView.Rows[i].Cells[masterMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
//Clear the current row of its attributes.
|
||||
inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
//IF the previous row is a member row AND it also has color coding suggesting that it is a member of a group, then add the current row (i) as well.
|
||||
else if (rowStatus == RowParser.RowAttribute.MemberRow && (bool)masterDataGridView.Rows[i - 1].Cells[masterMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
//Check for changes in the current row.
|
||||
if (!(bool)masterDataGridView.Rows[i].Cells[masterMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
//Set the current row as a member row.
|
||||
inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
//IF the previous row is simply a member row with no coloring at all, then remove the coloring from the current row (i).
|
||||
else if (rowStatus == RowParser.RowAttribute.MemberRow || rowStatus == RowParser.RowAttribute.AdSpecialRow)
|
||||
{
|
||||
//Check for changes in the current row.
|
||||
if ((bool)masterDataGridView.Rows[i].Cells[masterMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
//Clear the current row of its attributes.
|
||||
inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
//IF the previous row is a header row, then color it as a group header and color the current row as a member of said group.
|
||||
else if (rowStatus == RowParser.RowAttribute.HeaderRow && !(bool)masterDataGridView.Rows[i - 1].Cells[masterHeaderColumn].EditedFormattedValue)
|
||||
{
|
||||
//Set the previous row as a header row.
|
||||
if (!(bool)masterDataGridView.Rows[i - 1].Cells[masterMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i - 1].DefaultCellStyle.BackColor = TableColors.HeaderRow;
|
||||
//This condition means the user created a group so the newly made header row will need to be updated in the database as well.
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
//Check for changes in the current row.
|
||||
if (!(bool)masterDataGridView.Rows[i].Cells[masterMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
//Set the current row as a member row.
|
||||
inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
else if (rowStatus == RowParser.RowAttribute.HeaderRow)
|
||||
{
|
||||
//Check for changes in the current row.
|
||||
if (!(bool)masterDataGridView.Rows[i].Cells[masterMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
inventoryDataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
//Set the current row as a member row.
|
||||
inventoryDataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i].Cells[isMemberColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
|
||||
}
|
||||
//IF the previous row is incomplete, then call the stable PaintRowGroups function.
|
||||
else if (rowStatus == RowParser.RowAttribute.IncompleteRow)
|
||||
{
|
||||
//PaintRowGroups(dataGridView);
|
||||
}
|
||||
}
|
||||
//ELSE the current row is the first row in the data grid, therefore it can't be a member row so remove all coloring.
|
||||
else
|
||||
{
|
||||
//Clear the current row of its attributes.
|
||||
if (!(bool)masterDataGridView.Rows[0].Cells[masterMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
//If the row thinks that it's a member row then set it to dirty so the changes can be shown.
|
||||
inventoryDataGridView.Rows[0].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[0].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
inventoryDataGridView.Rows[0].Cells[isHeaderColumn].Value = false;
|
||||
inventoryDataGridView.Rows[0].Cells[isMemberColumn].Value = false;
|
||||
inventoryDataGridView.Rows[0].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
}
|
||||
else if (rowStatus == RowParser.RowAttribute.AdSpecialRow)
|
||||
{
|
||||
if (i == 0) return;
|
||||
inventoryDataGridView.Rows[startingIndex].DefaultCellStyle.BackColor = TableColors.AdSpecial;
|
||||
//Get the previous row's attribute.
|
||||
rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i - 1]);
|
||||
if (rowStatus == RowParser.RowAttribute.HeaderRow)
|
||||
{
|
||||
//Check to see if the previous row sees itself as a header row, if so mark it dirty.
|
||||
if ((bool)masterDataGridView.Rows[i - 1].Cells[masterHeaderColumn].EditedFormattedValue)
|
||||
{
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
//Clear its color coding.
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
//Next get the status of the next row.
|
||||
rowStatus = parser.GetRowAttribute(masterDataGridView.Rows[i + 1]);
|
||||
if (rowStatus == RowParser.RowAttribute.MemberRow)
|
||||
{
|
||||
//Check to see if the next row thinks it is a member row.
|
||||
if (!(bool)masterDataGridView.Rows[i + 1].Cells[masterMemberColumn].EditedFormattedValue)
|
||||
{
|
||||
inventoryDataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true;
|
||||
inventoryDataGridView.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
||||
}
|
||||
//Clear its color coding.
|
||||
inventoryDataGridView.Rows[i + 1].Cells[isMemberColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
|
||||
inventoryDataGridView.Rows[i + 1].DefaultCellStyle.BackColor = default(Color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum SalesTableColumns
|
||||
|
||||
Reference in New Issue
Block a user