I did not change seletedDate on runTime and I did not write code. when I want to change SelectedDate by using SelectedDateCalendar it selects different Time, showed Date in Pop SelectedDateCalendar is different with selected Date.
public
partial
class
Patient_PatientScheduler : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!Page.IsPostBack)
{
//PatientScheduler.SelectedDate = DateTime.Now.AddDays(1);
PatientScheduler.MinutesPerRow =Convert.ToInt32(ConfigurationManager.AppSettings[
"Interval"
]);
}
}
protected
void
PatientScheduler_AppointmentInsert(
object
sender, AppointmentInsertEventArgs e)
{
if
(e.Appointment.Start < DateTime.Now)
{
e.Cancel =
true
;
throw
new
Exception(
"time must be after today"
);
}
if
(e.Appointment.Start.TimeOfDay > e.Appointment.End.TimeOfDay)
{
e.Cancel =
true
;
throw
new
Exception(
"start time must be before end time"
);
}
if
(e.Appointment.End.TimeOfDay.Subtract(e.Appointment.Start.TimeOfDay) >
new
TimeSpan(0,15,0))
{
e.Cancel =
true
;
throw
new
Exception(
"differece of start time and end time should be less than interval"
);
}
}
protected
void
PatientScheduler_AppointmentUpdate(
object
sender, AppointmentUpdateEventArgs e)
{
TimeSpan endTime = e.ModifiedAppointment.End.TimeOfDay;
e.ModifiedAppointment.End = e.Appointment.End;
e.ModifiedAppointment.End = e.ModifiedAppointment.End.Add(endTime - e.ModifiedAppointment.End.TimeOfDay);
TimeSpan startTime = e.ModifiedAppointment.Start.TimeOfDay;
e.ModifiedAppointment.Start = e.Appointment.Start;
e.ModifiedAppointment.Start = e.ModifiedAppointment.Start.Add(startTime - e.ModifiedAppointment.Start.TimeOfDay);
if
(e.ModifiedAppointment.Start.TimeOfDay > e.ModifiedAppointment.End.TimeOfDay)
{
e.Cancel =
true
;
throw
new
Exception(
"start time must be before end time"
);
}
}
protected
void
PatientScheduler_FormCreated(
object
sender, SchedulerFormCreatedEventArgs e)
{
RadScheduler scheduler = (RadScheduler)sender;
RadComboBox patientsComboBox = (RadComboBox)e.Container.FindControl(
"PatientsComboBox"
);
if
(patientsComboBox !=
null
&& Profile.PatientId != 0)
{
patientsComboBox.SelectedIndex = patientsComboBox.FindItemIndexByValue(Profile.PatientId.ToString());
patientsComboBox.Enabled =
false
;
}
RadComboBox appointmentStatesComboBox = (RadComboBox)e.Container.FindControl(
"AppointmentStatesComboBox"
);
if
(appointmentStatesComboBox !=
null
)
{
appointmentStatesComboBox.SelectedIndex = 0;
appointmentStatesComboBox.Enabled =
false
;
}
RadComboBox doctorAppointmentComboBox = (RadComboBox)e.Container.FindControl(
"DoctorAppointmentComboBox"
);
if
(doctorAppointmentComboBox !=
null
)
{
if
(doctorAppointmentComboBox.Items.Count <= 0)
throw
new
Exception(
"time must be exist"
);
}
RadTimePicker startTime = (RadTimePicker)e.Container.FindControl(
"StartTime"
);
startTime.TimeView.StartTime = PatientScheduler.DayStartTime;
startTime.TimeView.EndTime = PatientScheduler.DayEndTime;
startTime.SelectedTime = e.Appointment.Start.TimeOfDay;
RadTimePicker endTime = (RadTimePicker)e.Container.FindControl(
"EndTime"
);
endTime.TimeView.StartTime = PatientScheduler.DayStartTime;
endTime.TimeView.EndTime = PatientScheduler.DayEndTime;
endTime.SelectedTime = e.Appointment.End.TimeOfDay;
startTime.ClientEvents.OnDateSelected =
"OnDateSelected"
;
EndTimeHiddenField.Value = endTime.ClientID;
DoctorsComboBox.Enabled =
false
;
}
protected
void
DateCalendar_SelectionChanged(
object
sender, EventArgs e)
{
PatientScheduler.SelectedDate = DateCalendar.SelectedDate.Date;
PatientScheduler.Rebind();
}
protected
void
PatientScheduler_PreRender(
object
sender, EventArgs e)
{
if
(((RadCalendar)PatientScheduler.FindControl(
"SelectedDateCalendar"
)) !=
null
)
((RadCalendar)PatientScheduler.FindControl(
"SelectedDateCalendar"
)).Visible =
false
;
}
}