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:
@@ -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.";
|
||||
|
||||
Reference in New Issue
Block a user