Updated the backup and restore functions to be more verbose and stable. Changed the version number slightly for appearance reasons. Fixed a bug on the Main Form that prevented it from refreshing the controls properly after all years have been wiped and after a database restore.
This commit is contained in:
@@ -170,6 +170,7 @@ namespace AdvertsingProfitControl
|
||||
form.ShowDialog();
|
||||
if (!form.RestoredDatabase) return;
|
||||
//If a database restore operation occurred then load the most recent date.
|
||||
RefreshDateListing();
|
||||
var db = new AdvertisingProfitControlDbContext();
|
||||
var recentDate = db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault();
|
||||
if (recentDate == null) return;
|
||||
@@ -892,6 +893,7 @@ namespace AdvertsingProfitControl
|
||||
private void RefreshDateListing()
|
||||
{
|
||||
var db = new AdvertisingProfitControlDbContext();
|
||||
monthCalendar.RemoveAllBoldedDates();
|
||||
monthCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray();
|
||||
if (monthCalendar.BoldedDates.Length > 0)
|
||||
{
|
||||
@@ -902,6 +904,8 @@ namespace AdvertsingProfitControl
|
||||
clearCurrentActiveYearTools.Enabled = true;
|
||||
clearCurrentActiveYearTools.ToolTipText = string.Empty;
|
||||
printPreviewButton.Enabled = true;
|
||||
generateReportMenuItem.ToolTipText = string.Empty;
|
||||
generateReportMenuItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -913,6 +917,8 @@ namespace AdvertsingProfitControl
|
||||
clearCurrentActiveYearTools.Enabled = false;
|
||||
clearCurrentActiveYearTools.ToolTipText = @"There are no records to clear.";
|
||||
printPreviewButton.Enabled = false;
|
||||
generateReportMenuItem.ToolTipText = @"There are no records to display.";
|
||||
generateReportMenuItem.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -956,7 +962,12 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
if (ClearSelectedDate(_currentActiveDate.Year))
|
||||
{
|
||||
ClearForm();
|
||||
RefreshDateListing();
|
||||
var date = db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault();
|
||||
if (date == null) return;
|
||||
if (date.EndingDate == _currentActiveDate) return;
|
||||
LoadDate(date.EndingDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user