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
+37 -1
View File
@@ -157,7 +157,7 @@ namespace AdvertsingProfitControl
private void modifyRecordMainMenu_Click(object sender, EventArgs e)
{
var form = new NewModifyRecord(monthCalendar.SelectionStart);
var form = new NewModifyRecord(_currentActiveDate);
form.ShowDialog();
//On return reload the date that was just modified by the modify record form.
LoadDate(monthCalendar.SelectionStart);
@@ -1235,6 +1235,42 @@ namespace AdvertsingProfitControl
var databaseReader = new DatabaseReader();
monthCalendar.BoldedDates = databaseReader.RetrieveDates(databaseTracker.DatabaseConnectionString).ToArray();
}
public enum FormDefaultRoll
{
AddNewRecord = 0,
ModifyExistingRecord = 1
}
private void clearSelectedDateToolsMainMenu_Click(object sender, EventArgs e)
{
var result = MessageBox.Show(@"Are you sure you want to delete all records for the date " + _currentActiveDate.ToShortDateString() + @"?", @"Clear Date", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.No)
{
return;
}
var dbT = new DatabaseTracker();
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
var dbR = new DatabaseReader();
var dateId = dbR.RetrieveDateIdByDateString(_currentActiveDate.ToShortDateString(), dbT.DatabaseConnectionString);
if (dateId != 0)
{
if (dbW.ClearDateById(dateId))
{
RefreshDateListing();
var date = dbR.RetrieveMostRecentDate(dbT.DatabaseConnectionString);
LoadDate(date);
}
else
{
errorLabel.Text = @"Failed to clear the selected date.";
}
}
else
{
errorLabel.Text = @"Failed to get the date ID number.";
}
}
}
}
//http://stackoverflow.com/questions/487661/how-do-i-suspend-painting-for-a-control-and-its-children