Fixed a bug in the row parsing engine related to ad special rows. Move all data from the old format to the new format. Updated the main form's UI.

This commit is contained in:
2017-01-23 00:26:46 -06:00
parent 9f045175ed
commit 739c4c179d
11 changed files with 228 additions and 158 deletions
+22 -14
View File
@@ -477,27 +477,35 @@ namespace AdvertsingProfitControl
oleDbCommand.Parameters.AddWithValue("ID", int.Parse(table.Rows[i].Cells[(int)InvoiceTableColumns.Id].EditedFormattedValue.ToString()));
oleDbCommand.ExecuteNonQuery();
oleDbCommand.Parameters.Clear();
rowsAdded.Add(i);
}
//Row index is only used to keep track of what row failed to update.
lastRowProcessed = i + 1;
}
oleDbTransaction.Commit();
foreach (DataGridViewRow row in table.Rows)
//Spin through the collection and update the affected rows.
foreach (var rowIndex in rowsAdded)
{
if(row.IsNewRow) continue;
if (!rowsAdded.Contains(row.Index)) continue;
var supplierId = RetrieveSupplierId(row.Cells[(int)InvoiceTableColumns.Supplier].EditedFormattedValue.ToString());
var invoiceIdNumber =
RetrieveInvoiceId(
row.Cells[(int)InvoiceTableColumns.InvoiceDate].EditedFormattedValue
.ToString(),
long.Parse(
row.Cells[(int)InvoiceTableColumns.InvoiceNumber].EditedFormattedValue
.ToString()), supplierId, dateId);
row.Cells[(int)InvoiceTableColumns.Id].Value = invoiceIdNumber;
row.Cells[(int)InvoiceTableColumns.IsDirty].Value = false;
row.HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
//Only reset the IsDirty value to false since the updates when through.
table.Rows[rowIndex].Cells[(int)InvoiceTableColumns.IsDirty].Value = false;
table.Rows[rowIndex].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
}
//foreach (DataGridViewRow row in table.Rows)
//{
// if(row.IsNewRow) continue;
// if (!rowsAdded.Contains(row.Index)) continue;
// var supplierId = RetrieveSupplierId(row.Cells[(int)InvoiceTableColumns.Supplier].EditedFormattedValue.ToString());
// var invoiceIdNumber =
// RetrieveInvoiceId(
// row.Cells[(int)InvoiceTableColumns.InvoiceDate].EditedFormattedValue
// .ToString(),
// long.Parse(
// row.Cells[(int)InvoiceTableColumns.InvoiceNumber].EditedFormattedValue
// .ToString()), supplierId, dateId);
// row.Cells[(int)InvoiceTableColumns.Id].Value = invoiceIdNumber;
// row.Cells[(int)InvoiceTableColumns.IsDirty].Value = false;
// row.HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
//}
table.RefreshEdit();
//Set the status.
status.SetStatus(WritingOperationStatus.InsertionSuccessful);