This is a migrated thread and some comments may be shown as answers.

Appointment validation

3 Answers 160 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
ryan
Top achievements
Rank 1
ryan asked on 10 May 2011, 10:46 PM
I'm having trouble validating a custom appointment.  In appointmentSaving i added this

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?

3 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 13 May 2011, 02:23 PM
Hello ryan,

I've attached a simple example to show you how to implement validation in EditAppointmentDialog. You can add your custom validation logic in RadButton_Click event handler. Please download the attachment and examine it. 

Kind regards,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ryan
Top achievements
Rank 1
answered on 16 May 2011, 03:25 PM
so in order to do any validation on appointments I have to use a custom edit template? 
0
Yana
Telerik team
answered on 17 May 2011, 08:07 AM
Hi ryan,

Currently this is the only way to validate the appointments.  We are working on some built-in validation, most probably this feature will be available in Q2.

All the best,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ScheduleView
Asked by
ryan
Top achievements
Rank 1
Answers by
Yana
Telerik team
ryan
Top achievements
Rank 1
Share this question
or