'宣言 Public ReadOnly Property OriginalAppointment As Appointment
public Appointment OriginalAppointment {get;}
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Imports System.Diagnostics Private Sub ultraCalendarInfo1_ValidateAppointment(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinSchedule.ValidateAppointmentEventArgs) Handles ultraCalendarInfo1.ValidateAppointment '---------------------------------------------------------------------------------------------------- ' 説明 ' ValidateAppointment ' ' Appointment オブジェクトが Appointment ダイアログで変更されたときに発生します ' '---------------------------------------------------------------------------------------------------- ' SaveChanges プロパティは、条件付きの変更を ' 予定で許可するために使用できます If (Not e.Appointment.Tag Is Nothing) Then Dim userID As String = e.Appointment.Tag ' ユーザーが管理者ではない場合、変更は保存されません If (userID.ToLower() <> "admin") Then MessageBox.Show("You must have administrator rights to modify this Appointment.", "ValidateAppointment", MessageBoxButtons.OK, MessageBoxIcon.Error) e.SaveChanges = False Return End If End If ' CloseDialog プロパティを使用すると、Appointment オブジェクトの ' 状態が特定の条件を満たすまでダイアログは ' 開かれたままです If (e.Appointment.Description Is Nothing Or e.Appointment.Description.Length = 0) Then MessageBox.Show("You must enter a Description for this Appointment.", "ValidateAppointment", MessageBoxButtons.OK, MessageBoxIcon.Error) e.CloseDialog = False Return End If ' OriginalAppointment プロパティを使用すると、予定オブジェクトに ' 加えられた変更を決定します Dim info As String = String.Empty If (e.OriginalAppointment.StartDateTime <> e.Appointment.StartDateTime) Then info += "The appointment's StartDateTime has changed." + vbCrLf End If If (e.OriginalAppointment.EndDateTime <> e.Appointment.EndDateTime) Then info += "The appointment's EndDateTime has changed." + vbCrLf End If If (e.OriginalAppointment.Subject <> e.Appointment.Subject) Then info += "The appointment's Subject has changed." + vbCrLf End If If (e.OriginalAppointment.Location <> e.Appointment.Location) Then info += "The appointment's Location has changed." + vbCrLf End If If (e.OriginalAppointment.Description <> e.Appointment.Description) Then info += "The appointment's Description has changed." + vbCrLf End If ' 重要なプロパティが変更された場合、エンド ユーザーに通知します If (info.Length > 0) Then MessageBox.Show(info, "ValidateAppointment", MessageBoxButtons.OK) End If End Sub
using System.Diagnostics; using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; private void ultraCalendarInfo1_ValidateAppointment(object sender, Infragistics.Win.UltraWinSchedule.ValidateAppointmentEventArgs e) { //---------------------------------------------------------------------------------------------------- // 説明 // ValidateAppointment // // Appointment オブジェクトが Appointment ダイアログで変更されたときに発生します // //---------------------------------------------------------------------------------------------------- // SaveChanges プロパティは、条件付きの変更を // 予定で許可するために使用できます if ( e.Appointment.Tag is string ) { string userID = e.Appointment.Tag as string; // ユーザーが管理者ではない場合、変更は保存されません if ( userID.ToLower() != "admin" ) { MessageBox.Show( "You must have administrator rights to modify this Appointment.", "ValidateAppointment", MessageBoxButtons.OK, MessageBoxIcon.Error ); e.SaveChanges = false; return; } } // CloseDialog プロパティを使用すると、Appointment オブジェクトの // 状態が特定の条件を満たすまでダイアログは // 開かれたままです if ( e.Appointment.Description == null || e.Appointment.Description.Length == 0 ) { MessageBox.Show( "You must enter a Description for this Appointment.", "ValidateAppointment", MessageBoxButtons.OK, MessageBoxIcon.Error ); e.CloseDialog = false; return; } // OriginalAppointment プロパティを使用すると、予定オブジェクトに // 加えられた変更を決定します string info = string.Empty; if ( e.OriginalAppointment.StartDateTime != e.Appointment.StartDateTime) info += "The appointment's StartDateTime has changed." + "\n"; if ( e.OriginalAppointment.EndDateTime != e.Appointment.EndDateTime) info += "The appointment's EndDateTime has changed." + "\n"; if ( e.OriginalAppointment.Subject != e.Appointment.Subject ) info += "The appointment's Subject has changed." + "\n"; if ( e.OriginalAppointment.Location != e.Appointment.Location ) info += "The appointment's Location has changed." + "\n"; if ( e.OriginalAppointment.Description != e.Appointment.Description ) info += "The appointment's Description has changed." + "\n"; // 重要なプロパティが変更された場合、エンド ユーザーに通知します if ( info.Length > 0 ) MessageBox.Show( info, "ValidateAppointment", MessageBoxButtons.OK ); }