'宣言 Public Overloads Function DoesDateRangeHaveActivity( _ ByVal startDateTime As Date, _ ByVal endDateTime As Date, _ ByVal useTime As Boolean _ ) As Boolean
public bool DoesDateRangeHaveActivity( DateTime startDateTime, DateTime endDateTime, bool useTime )
Note、Appointment、および Holiday は、集合的に「アクティビティ」として参照されます。
Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Imports System.IO Imports System.Globalization Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click ' 'useTime' パラメーターを False に設定すると、メソッドは ' 00:00:00 から 23:59:59 の間でアクティビティを検索します Dim todayHasAnyActivity As Boolean = Me.ultraCalendarInfo1.DoesDateRangeHaveActivity(DateTime.Today.Date.AddHours(9.0F), DateTime.Today.Date.AddHours(9.5F), False) ' 'useTime' パラメーターを True に設定すると、メソッドは ' 開始時間から終了時間 (09:00 ~ 09:30 など) までのアクティビティのみを検索します Dim todayHasWorkingHourActivity As Boolean = Me.ultraCalendarInfo1.DoesDateRangeHaveActivity(DateTime.Today.Date.AddHours(9.0F), DateTime.Today.Date.AddHours(9.5F), True) ' 現在の日のアクティビティ状態を表示します Dim info As String = String.Empty If (Not todayHasAnyActivity And Not todayHasWorkingHourActivity) Then info += "There is no activity for " + DateTime.Today.ToLongDateString() + "." + vbCrLf Else If (todayHasAnyActivity) Then info += "There is activity for " + DateTime.Today.ToLongDateString() + "." + vbCrLf If (todayHasWorkingHourActivity) Then info += "There is activity between the hours of 9AM and 9:30AM for " + DateTime.Today.ToLongDateString() + "." + vbCrLf End If End If End If MessageBox.Show(info, "DoesDateRangeHaveActivity", MessageBoxButtons.OK) End Sub
using System.Diagnostics; using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; using System.IO; using System.Globalization; private void button1_Click(object sender, System.EventArgs e) { // 'useTime' パラメーターを False に設定すると、メソッドは // 00:00:00 から 23:59:59 の間でアクティビティを検索します bool todayHasAnyActivity = this.ultraCalendarInfo1.DoesDateRangeHaveActivity( DateTime.Today.Date.AddHours( 9.0F ), DateTime.Today.Date.AddHours( 9.5F ), false ); // 'useTime' パラメーターを True に設定すると、メソッドは // 開始時間から終了時間 (09:00 ~ 09:30 など) の間のアクティビティのみを検索します bool todayHasWorkingHourActivity = this.ultraCalendarInfo1.DoesDateRangeHaveActivity( DateTime.Today.Date.AddHours( 9.0F ), DateTime.Today.Date.AddHours( 9.5F ), true ); // 現在の日のアクティビティ状態を表示します string info = string.Empty; if ( ! todayHasAnyActivity && ! todayHasWorkingHourActivity ) info += "There is no activity for " + DateTime.Today.ToLongDateString() + "." + "\n"; else { if ( todayHasAnyActivity ) info += "There is activity for " + DateTime.Today.ToLongDateString() + "." + "\n"; if ( todayHasWorkingHourActivity ) info += "There is activity between the hours of 9AM and 9:30AM for " + DateTime.Today.ToLongDateString() + "." + "\n"; } MessageBox.Show( info, "DoesDateRangeHaveActivity", MessageBoxButtons.OK ); }