Fixed more bugs with the parsing engine, a crash bug in the update inventory method, and a crash bug in the trimming operations. Deleting a row now marks all rows under it as dirty.
This commit is contained in:
@@ -719,12 +719,25 @@ namespace AdvertsingProfitControl
|
||||
//Reset the gAdSpecialIndex to -1.
|
||||
_adSpecialIndex = -1;
|
||||
e.Cancel = true; //Prevent the new row from being removed.
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
//Mark all rows under the row that just got deleted as dirty.
|
||||
for (var index = currentRowIndex; index < dataGridView.Rows.Count; index++)
|
||||
{
|
||||
if (index == _adSpecialIndex + 1) continue;
|
||||
if (projectionsDataGridView.Rows[index].IsNewRow) continue;
|
||||
projectionsDataGridView.Rows[index].Cells[(int) SalesTableColumns.IsDirty].Value = true;
|
||||
projectionsDataGridView.Rows[index].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
|
||||
inventoryDataGridView.Rows[index].Cells[(int) InventoryTableColumns.IsDirty].Value = true;
|
||||
inventoryDataGridView.Rows[index].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
|
||||
actualSalesDataGridView.Rows[index].Cells[(int) SalesTableColumns.IsDirty].Value = true;
|
||||
actualSalesDataGridView.Rows[index].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeAutoCompleteListOnKeyCombo(object sender, KeyEventArgs e)
|
||||
@@ -2583,8 +2596,8 @@ namespace AdvertsingProfitControl
|
||||
//Check the attribute cell.
|
||||
if (cellIndex == 6)
|
||||
{
|
||||
var isHeaderCell = new DataGridViewCheckBoxCell(false);
|
||||
var isMemberCell = new DataGridViewCheckBoxCell(false);
|
||||
var isHeaderCell = new DataGridViewCheckBoxCell();
|
||||
var isMemberCell = new DataGridViewCheckBoxCell();
|
||||
var rowAttribute = int.Parse(inventoryTable.Rows[rowIndex].ItemArray[cellIndex].ToString());
|
||||
switch (rowAttribute)
|
||||
{
|
||||
@@ -2598,6 +2611,10 @@ namespace AdvertsingProfitControl
|
||||
isMemberCell.Value = true;
|
||||
newRow.DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
|
||||
break;
|
||||
default:
|
||||
isHeaderCell.Value = false;
|
||||
isMemberCell.Value = false;
|
||||
break;
|
||||
}
|
||||
newRow.Cells.Add(isHeaderCell);
|
||||
newRow.Cells.Add(isMemberCell);
|
||||
@@ -2683,8 +2700,8 @@ namespace AdvertsingProfitControl
|
||||
//Check the attribute cell.
|
||||
if (cellIndex == 8)
|
||||
{
|
||||
var isHeaderCell = new DataGridViewCheckBoxCell(false);
|
||||
var isMemberCell = new DataGridViewCheckBoxCell(false);
|
||||
var isHeaderCell = new DataGridViewCheckBoxCell();
|
||||
var isMemberCell = new DataGridViewCheckBoxCell();
|
||||
var rowAttribute = int.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString());
|
||||
switch (rowAttribute)
|
||||
{
|
||||
@@ -2698,6 +2715,10 @@ namespace AdvertsingProfitControl
|
||||
isMemberCell.Value = true;
|
||||
newRow.DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
|
||||
break;
|
||||
default:
|
||||
isHeaderCell.Value = false;
|
||||
isMemberCell.Value = false;
|
||||
break;
|
||||
}
|
||||
newRow.Cells.Add(isHeaderCell);
|
||||
newRow.Cells.Add(isMemberCell);
|
||||
@@ -3103,6 +3124,7 @@ namespace AdvertsingProfitControl
|
||||
MessageBox.Show(@"Failed to get the date ID number.", @"Invalid ID Number", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
if (displayInformation) informationLabel.Text = "";
|
||||
//Create the database interaction objects.
|
||||
var dbT = new DatabaseTracker();
|
||||
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
|
||||
@@ -3151,6 +3173,80 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
errorLabel.Text += @"Failed to process projections." + Environment.NewLine;
|
||||
}
|
||||
DataTable inventoryNewTable;
|
||||
DataTable inventoryUpdateTable;
|
||||
var inventoryTrimmingStatus = ConstructCleanedInventoryTable(dateId, out inventoryNewTable, out inventoryUpdateTable);
|
||||
if (inventoryTrimmingStatus != TrimmingOperationResult.NoChangesRequired && inventoryTrimmingStatus != TrimmingOperationResult.FailedToTrim)
|
||||
{
|
||||
if (inventoryNewTable.Rows.Count > 0)
|
||||
{
|
||||
var writerResult = dbW.InsertIntoInventoryTable(inventoryNewTable, dbT.DatabaseConnectionString);
|
||||
if (writerResult.GetWritingOperationStatus() != WritingOperationStatus.Failed)
|
||||
{
|
||||
//Spin through the collection and update the affected rows.
|
||||
foreach (var rowIndex in writerResult.GetRowCollection())
|
||||
{
|
||||
//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.IsDirty].Value = false;
|
||||
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Next check to see if the update table has anything.
|
||||
if (inventoryUpdateTable.Rows.Count > 0)
|
||||
{
|
||||
var writerResult = dbW.UpdateInventoryTable(inventoryUpdateTable, dbT.DatabaseConnectionString);
|
||||
if (writerResult.GetWritingOperationStatus() != WritingOperationStatus.Failed)
|
||||
{
|
||||
//Spin through the collection and update the affected rows.
|
||||
foreach (var rowIndex in writerResult.GetRowCollection())
|
||||
{
|
||||
//Only reset the IsDirty value to false since the updates when through.
|
||||
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int)InventoryTableColumns.IsDirty].Value = false;
|
||||
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (displayInformation) informationLabel.Text += @"Successfully saved inventory." + Environment.NewLine;
|
||||
}
|
||||
DataTable actualSalesNewTable;
|
||||
DataTable actualSalesUpdateTable;
|
||||
var actualSalesTrimmingStatus = ConstructCleanedSalesTable("ActualSales", dateId, out actualSalesNewTable, out actualSalesUpdateTable);
|
||||
if (actualSalesTrimmingStatus != TrimmingOperationResult.NoChangesRequired && actualSalesTrimmingStatus != TrimmingOperationResult.FailedToTrim)
|
||||
{
|
||||
//Check to see if the insert table has any items.
|
||||
if (actualSalesNewTable.Rows.Count > 0)
|
||||
{
|
||||
var writerResult = dbW.InsertIntoSalesTable(actualSalesNewTable, dbT.DatabaseConnectionString);
|
||||
if (writerResult.GetWritingOperationStatus() != WritingOperationStatus.Failed)
|
||||
{
|
||||
//Spin through the collection and update the affected rows.
|
||||
foreach (var rowIndex in writerResult.GetRowCollection())
|
||||
{
|
||||
actualSalesDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.Id].Value = rowIndex.Value;
|
||||
actualSalesDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false;
|
||||
actualSalesDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Next check to see if the update table has anything.
|
||||
if (actualSalesUpdateTable.Rows.Count > 0)
|
||||
{
|
||||
var writerResult = dbW.UpdateSalesTable(actualSalesUpdateTable, dbT.DatabaseConnectionString);
|
||||
if (writerResult.GetWritingOperationStatus() != WritingOperationStatus.Failed)
|
||||
{
|
||||
//Spin through the collection and update the affected rows.
|
||||
foreach (var rowIndex in writerResult.GetRowCollection())
|
||||
{
|
||||
//Only reset the IsDirty value to false since the updates when through.
|
||||
actualSalesDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false;
|
||||
actualSalesDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (displayInformation) informationLabel.Text += @"Successfully saved actual sales." + Environment.NewLine;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -3242,7 +3338,7 @@ namespace AdvertsingProfitControl
|
||||
continue;
|
||||
}
|
||||
//Check to see if the row is dirty.
|
||||
if (!(bool)row.Cells[(int)SalesTableColumns.IsDirty].Value)
|
||||
if (!(bool)row.Cells[(int)SalesTableColumns.IsDirty].EditedFormattedValue)
|
||||
{
|
||||
//If it is not then continue on to the next row.
|
||||
continue;
|
||||
@@ -3268,11 +3364,11 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
//Determine the row's attribute.
|
||||
var rowAttribute = 0; //Zero (0) means no grouping, its not a header nor a member.
|
||||
if ((bool)row.Cells[(int)SalesTableColumns.IsHeaderRow].Value && !(bool)row.Cells[(int)SalesTableColumns.IsMemberRow].Value)
|
||||
if ((bool)row.Cells[(int)SalesTableColumns.IsHeaderRow].EditedFormattedValue && !(bool)row.Cells[(int)SalesTableColumns.IsMemberRow].EditedFormattedValue)
|
||||
{
|
||||
rowAttribute = 1;
|
||||
}
|
||||
else if ((bool)row.Cells[(int)SalesTableColumns.IsMemberRow].Value && !(bool)row.Cells[(int)SalesTableColumns.IsHeaderRow].Value)
|
||||
else if ((bool)row.Cells[(int)SalesTableColumns.IsMemberRow].EditedFormattedValue && !(bool)row.Cells[(int)SalesTableColumns.IsHeaderRow].EditedFormattedValue)
|
||||
{
|
||||
rowAttribute = 2;
|
||||
}
|
||||
@@ -3399,7 +3495,7 @@ namespace AdvertsingProfitControl
|
||||
continue;
|
||||
}
|
||||
//Check to see if the row is dirty.
|
||||
if (!(bool)row.Cells[(int)InventoryTableColumns.IsDirty].Value)
|
||||
if (!(bool)row.Cells[(int)InventoryTableColumns.IsDirty].EditedFormattedValue)
|
||||
{
|
||||
//If it is not then continue on to the next row.
|
||||
continue;
|
||||
@@ -3424,11 +3520,11 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
//Determine the row's attribute.
|
||||
var rowAttribute = 0; //Zero (0) means no grouping, its not a header nor a member.
|
||||
if ((bool)row.Cells[(int)InventoryTableColumns.IsHeaderRow].Value && !(bool)row.Cells[(int)InventoryTableColumns.IsMemberRow].Value)
|
||||
if ((bool)row.Cells[(int)InventoryTableColumns.IsHeaderRow].EditedFormattedValue && !(bool)row.Cells[(int)InventoryTableColumns.IsMemberRow].EditedFormattedValue)
|
||||
{
|
||||
rowAttribute = 1;
|
||||
}
|
||||
else if ((bool)row.Cells[(int)InventoryTableColumns.IsMemberRow].Value && !(bool)row.Cells[(int)InventoryTableColumns.IsHeaderRow].Value)
|
||||
else if ((bool)row.Cells[(int)InventoryTableColumns.IsMemberRow].EditedFormattedValue && !(bool)row.Cells[(int)InventoryTableColumns.IsHeaderRow].EditedFormattedValue)
|
||||
{
|
||||
rowAttribute = 2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user