I'm having trouble validating a custom appointment. In appointmentSaving i added this
but if any of the tests fail the edit dialog closes. then when I try and open another new appointment the appointmentSaved event is called again.
here is my custom CopyFrom.
Anyone have any ideas?
private void scheduler_AppointmentSaving(object sender, AppointmentSavingEventArgs e)
{
ShiftData shift = new ShiftData();
shift.CopyFrom(e.Appointment);
if (shift.Start >= shift.End)
{
RadWindow.Alert("Start Time must be after end time.");
e.Cancel = true;
}
if (shift.RadID == 0)
{
RadWindow.Alert("Radiologist is required.");
e.Cancel = true;
}
if (shift.ShiftSubTypeID == 0)
{
RadWindow.Alert("Shift Type is required.");
e.Cancel = true;
}
if (shift.FacilityID == 0)
{
RadWindow.Alert("Facility is required.");
e.Cancel = true;
}
}
but if any of the tests fail the edit dialog closes. then when I try and open another new appointment the appointmentSaved event is called again.
here is my custom CopyFrom.
public override void CopyFrom(IAppointment other)
{
if (other != null)
{
this.StartTimeUtc = other.Start.ToUniversalTime();
this.EndTimeUtc = other.End.ToUniversalTime();
this.Remarks = other.Subject;
Resource AllianceGroup = other.Resources.Cast<
Resource
>().Where(r => r.ResourceType == "AllianceGroup").FirstOrDefault();
if (AllianceGroup != null)
this.FacilityGroupID = Convert.ToInt32(AllianceGroup.ResourceName);
Resource facility = other.Resources.Cast<
Resource
>().Where(r => r.ResourceType == "Facility").FirstOrDefault();
if(facility != null)
this.FacilityID = Convert.ToInt32(facility.ResourceName);
Resource rad = other.Resources.Cast<
Resource
>().Where(r => r.ResourceType == "Rad").FirstOrDefault();
if (rad != null)
this.RadID = Convert.ToInt32(rad.ResourceName);
if (other.Resources.Cast<
Resource
>().Where(r => r.ResourceType == "ShiftAssignemnt").Count() > 0)
{
foreach (Resource sa in other.Resources.Cast<
Resource
>().Where(r => r.ResourceType == "ShiftAssignemnt"))
{
this.Assignments.Add(new ShiftAssignmentData { ShiftAssignmentID = Convert.ToInt32(sa.ResourceName) });
}
}
if((other as AppointmentBase).Category != null)
this.ShiftSubTypeID = Convert.ToInt16((other as AppointmentBase).Category.CategoryName);
}
base.CopyFrom(other);
}
Anyone have any ideas?