I have a problem, where if DataStartFiend and Dataendfield is null in db will throw an exception. Please advise thank you
aspx
<telerik:RadScheduler ID="RadScheduler1" runat="server"
HoursPanelTimeFormat="htt" ValidationGroup="RadScheduler1" Width="100%" Height="600px"
MinutesPerRow="5" Skin="Office2007" DayStartTime="08:00:00" DayEndTime="15:00:00" ColumnWidth="200px"
DataKeyField="ID" DataStartField="Start" DataEndField="End" DataSubjectField="Subject"
DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentID"
AllowDelete="false" AllowEdit="false" AllowInsert="false" FirstDayOfWeek="Monday" LastDayOfWeek="Sunday"
DayHeaderDateFormat="d MMMM yyyy" WeekHeaderDateFormat="d MMMM yyyy" TimelineView-HeaderDateFormat="d MMMM yyyy"
TimelineView-ColumnHeaderDateFormat="d MMMM yyyy" MonthHeaderDateFormat="MMMM yyyy" SelectedView="WeekView">
</telerik:RadScheduler>
aspx.cs
public List<TimetablePeriod> TimetableCollection
{
set
{
RadScheduler1.DataSource = value;
}
}
TimetablePeriod.cs
public TimetablePeriod(long studentId, string startDate, string endDate,
string weekDay, string startTime, string endTime, string teacherTitle, string roomCode)
{
this.studentId = studentId;
this.startDate = startDate;
this.endDate = endDate;
this.weekDay = weekDay;
this.startTime = startTime;
this.endTime = endTime;
this.roomCode = roomCode;
this.recurParentID = null;
}
public DateTime Start
{
get { return GetDate(startDate, startTime); }
}
public DateTime End
{
get { return GetDate(startDate, endTime); }
}
private DateTime GetDate(string date, string time)
{
int year, month, day, hour, minute, second;
string[] dateParts = date.Split(new char[] { '-' });
year = Convert.ToInt32(dateParts[0]);
month = Convert.ToInt32(dateParts[1]);
day = Convert.ToInt32(dateParts[2]);
string[] timeParts = time.Split(new char[] { ':' });
hour = Convert.ToInt32(timeParts[0]);
minute = Convert.ToInt32(timeParts[1]);
second = Convert.ToInt32(timeParts[2]);
DateTime dt = new DateTime(year, month, day, hour, minute, second);
dt = dt.AddDays(this.GetDayOffset());
return dt;
}