Added a tool to remove an entire date and all records associated with it. Updated row deletion code to handle unbalanced tables or missing row IDs.

This commit is contained in:
2017-01-24 13:45:25 -06:00
parent d7229c9499
commit 2657523888
12 changed files with 277 additions and 242 deletions
+21 -9
View File
@@ -560,9 +560,13 @@ namespace AdvertsingProfitControl
if (result == DialogResult.Yes)
{
//Attempt to delete the row from the database by its ID number.
var projectionsRowId = int.Parse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var inventoryRowId = int.Parse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var actualSalesRowId = int.Parse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
int projectionsRowId;
int inventoryRowId;
int actualSalesRowId;
//Attempt to delete the row from the database by its ID number.
int.TryParse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out projectionsRowId);
int.TryParse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out inventoryRowId);
int.TryParse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out actualSalesRowId);
if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
{
informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) + @" from the database.";
@@ -589,9 +593,13 @@ namespace AdvertsingProfitControl
if (result == DialogResult.Yes)
{
//Attempt to delete the row from the database by its ID number.
var projectionsRowId = int.Parse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var inventoryRowId = int.Parse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var actualSalesRowId = int.Parse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
int projectionsRowId;
int inventoryRowId;
int actualSalesRowId;
//Attempt to delete the row from the database by its ID number.
int.TryParse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out projectionsRowId);
int.TryParse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out inventoryRowId);
int.TryParse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out actualSalesRowId);
if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
{
informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) + @" from the database.";
@@ -620,9 +628,13 @@ namespace AdvertsingProfitControl
if (result == DialogResult.Yes)
{
//Attempt to delete the row from the database by its ID number.
var projectionsRowId = int.Parse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int) SalesTableColumns.Id].EditedFormattedValue.ToString());
var inventoryRowId = int.Parse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var actualSalesRowId = int.Parse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
int projectionsRowId;
int inventoryRowId;
int actualSalesRowId;
//Attempt to delete the row from the database by its ID number.
int.TryParse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out projectionsRowId);
int.TryParse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out inventoryRowId);
int.TryParse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out actualSalesRowId);
if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
{
informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) + @" from the database.";