Fixed a bug that caused the ModifyRecord form to crash on load if the cursor was over the top left hand header cell. Set a timeout for the restore SQL statement to hopefully prevent a timeout exception from being thrown. Minor code clean up.

This commit is contained in:
2018-04-04 01:47:02 -05:00
parent 65dd82cd31
commit f2fe8c592f
10 changed files with 45 additions and 62 deletions
+9 -2
View File
@@ -77,14 +77,13 @@ namespace AdvertsingProfitControl
public NewModifyRecord(DateTime date)
{
InitializeComponent();
InitializeComponent();
//
weekEndingCalendar.SelectionStart = date;
_currentActiveDate = date;
InitializeForm();
mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]);
Text = @"Modify Record (Current Record: " + date.ToShortDateString() + @")";
_isModifyingRecord = true;
LoadDate(date);
}
@@ -2728,6 +2727,14 @@ out double beginningBinCount, out string _))
public void InitializeForm()
{
//Apply a little nonsense fix for a but that occurs with the DataGridView control where if a cursor
//is placed over the top left hand header cell, it causes an InvalidOperationException. This mainly
//effects this form when its overloaded constructor is called since the mouse cursor is right on top
//of the aforementioned cell after clicking the "Modify Existing Record" menu option on the main form.
//More info one the bug here https://stackoverflow.com/questions/34344499/invalidoperationexception-this-operation-cannot-be-performed-while-an-auto-fill
//The following fix is applied to the projections DataGridView since its the first grid displayed to the user.
//The fix is simple however, force the form to create the cell as follows:
var projectionsLeftHeaderCell = projectionsDataGridView.TopLeftHeaderCell;
var db = new AdvertisingProfitControlDbContext();
weekEndingCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray();
weekEndingCalendar.DateChanged += ValidateDateChanged;