private void checkDaylight_CheckedChanged(object sender, EventArgs e) { bool bEnabled = checkDaylight.Checked; pickerDaylightStart.Enabled = bEnabled; pickerDaylightEnd.Enabled = bEnabled; if (gridSession.SelectedDataRows.Length > 0) { SessionObject cSession = gridSession.SelectedDataRows[0] as SessionObject; DaylightTime cDaylightTime = cSession.Daylight; if (bEnabled) { if (cDaylightTime == null) { cDaylightTime = new DaylightTime(); cDaylightTime.StartDate = DateTime.UtcNow; cDaylightTime.EndDate = DateTime.UtcNow; cSession.Daylight = cDaylightTime; } } else { if (cDaylightTime != null) { cSession.Daylight = null; } } } }