Back to Devexpress

AppointmentOperationEventArgs Class

corelibraries-devexpress-dot-xtrascheduler-cc3f7a52.md

latest7.3 KB
Original Source

AppointmentOperationEventArgs Class

Provides data for the AllowAppointment events of the SchedulerControl.

Namespace : DevExpress.XtraScheduler

Assembly : DevExpress.XtraScheduler.v25.2.Core.Desktop.dll

NuGet Package : DevExpress.Scheduler.CoreDesktop

Declaration

csharp
public class AppointmentOperationEventArgs :
    AppointmentEventArgs
vb
Public Class AppointmentOperationEventArgs
    Inherits AppointmentEventArgs

AppointmentOperationEventArgs is the data class for the following events:

Show 16 events

LibraryRelated API Members
WinForms ControlsSchedulerControl.AllowAppointmentCopy
SchedulerControl.AllowAppointmentCreate
SchedulerControl.AllowAppointmentDelete
SchedulerControl.AllowAppointmentDrag
SchedulerControl.AllowAppointmentDragBetweenResources
SchedulerControl.AllowAppointmentEdit
SchedulerControl.AllowAppointmentResize
SchedulerControl.AllowInplaceEditor
ASP.NET Web Forms ControlsASPxScheduler.AllowAppointmentCopy
ASPxScheduler.AllowAppointmentCreate
ASPxScheduler.AllowAppointmentDelete
ASPxScheduler.AllowAppointmentDrag
ASPxScheduler.AllowAppointmentDragBetweenResources
ASPxScheduler.AllowAppointmentEdit
ASPxScheduler.AllowAppointmentResize
ASPxScheduler.AllowInplaceEditor

Remarks

The AllowAppointment events occur when an end-user tries to perform a particular action, which is defined by this AllowAppointment event, and the corresponding AllowAppointment property of the SchedulerControl.OptionsCustomization object is set to Custom. The AppointmentOperationEventArgs class introduces the AppointmentOperationEventArgs.Allow property that specifies whether the particular action is allowed to be performed by an end-user or not. The processed appointment is identified by the AppointmentEventArgs.Appointment property.

An instance of the AppointmentOperationEventArgs class with appropriate settings is automatically created and passed to the corresponding event’s handler.

Example

This example demonstrates how to implement custom rules for editing and deleting appointments. The code below allows an appointment to be edited only by its owner (the end-user who created it). To do this it’s necessary to set the SchedulerOptionsCustomization.AllowAppointmentEdit and SchedulerOptionsCustomization.AllowAppointmentDelete properties to UsedAppointmentType.Custom, and handle the SchedulerControl.AllowAppointmentEdit and SchedulerControl.AllowAppointmentDelete events to implement custom logic for editing appointments.

csharp
using DevExpress.XtraScheduler;
// ...

private void schedulerControl1_AllowAppointmentDelete(object sender, 
    AppointmentOperationEventArgs e) {
   // Allow only the user who created this appontment to delete it.
   e.Allow = CanUserModifyThisAppointment(e.Appointment);
}
private void schedulerControl1_AllowAppointmentEdit(object sender, 
    AppointmentOperationEventArgs e) {
   // Allow only the user who created this appontment to modify it.
   e.Allow = CanUserModifyThisAppointment(e.Appointment);
}
// Determine if the current user is the same 
// as the one who created the specified appointment 
bool CanUserModifyThisAppointment(Appointment apt) {
   object obj = apt.CustomFields["Owner"];
   if (obj == null)
      return true;
   string appointmentOwner = obj.ToString();
   if (appointmentOwner == String.Empty)
      return true;
   return (String.Compare(appointmentOwner, tbUserName.Text, true) == 0);
}
vb
Imports DevExpress.XtraScheduler
' ...

Private Sub schedulerControl1_AllowAppointmentDelete(ByVal sender As Object, _
ByVal e As AppointmentOperationEventArgs)
   ' Allow only the user who created this appontment to delete it.
   e.Allow = CanUserModifyThisAppointment(e.Appointment)
End Sub
Private Sub schedulerControl1_AllowAppointmentEdit(ByVal sender As Object, _
ByVal e As AppointmentOperationEventArgs)
   ' Allow only the user who created this appontment to modify it.
   e.Allow = CanUserModifyThisAppointment(e.Appointment)
End Sub
' Determine if the current user is the same 
' as the one who created the specified appointment 
Private Function CanUserModifyThisAppointment(ByVal apt As Appointment) As Boolean
   Dim obj As Object = apt.CustomFields("Owner")
   If obj Is Nothing Then
      Return True
   End If
   Dim appointmentOwner As String = obj.ToString()
   If appointmentOwner = String.Empty Then
      Return True
   End If
   Return (String.Compare(appointmentOwner, tbUserName.Text, True) = 0)
End Function

Inheritance

Object EventArgs AppointmentEventArgs AppointmentOperationEventArgs

See Also

AppointmentOperationEventArgs Members

DevExpress.XtraScheduler Namespace