// This would be better implemented if weeknumber wasn't an argument, but // rather it loaded according to currentWeekNumber. I can't imagine a // scenario in which you'd want to load something different from // currentWeekNumber. This was what was causing the previous bug with // edits in one week showing up in another. ?? Did I write this C.G? // Cause I'm thinking selecting another week number in the Combobox means that // you can jump around week numbers private void LoadWeek(int weeknumber) { isInitialising = true; //Clear the current rows dgScheduleView.Rows.Clear(); try { IList <ScheduleRecord> list = scheduleModel.GetWeek(weeknumber); foreach (ScheduleRecord record in list) { //match the fields in record with those to go in the datagrid dgScheduleView.Rows.Add(CreateDataGridRow(record)); } lblTitle.Text = ScheduleRecord.WeekName(weeknumber - 1); } catch (Exception e) { MessageBox.Show("Exception occured loading week " + weeknumber + "\r\n" + e.ToString(), "Exception Loading Week", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { isInitialising = false; } }
public void InitialiseUI() { for (int i = 1; i <= ScheduleEditingModel.NUMBER_OF_WEEKS; i++) { cbWeekSelector.Items.Add(ScheduleRecord.WeekName(i - 1)); } cbWeekSelector.SelectedIndex = 0; }