T'sWare スケジュール管理 フォームソースリスト [スケジュールの作成]フォーム
Function isPreviousRecs(lngResourceID As Long, dblCurrentDate As Date) As Boolean 'checks for previous recs and loads them into aTimeSlots array
Dim qdf As QueryDef
Dim rstTimes As Recordset
Dim intTimeSlot As Integer
Dim intBeginTime As Integer
Dim intEndTime As Integer
Set qdf = dbs.QueryDefs("S_スケジュール予約時間")
qdf![期間自] = dblCurrentDate - 1
qdf![期間至] = dblCurrentDate + 1
qdf![ScheduleIDParam] = lngResourceID
Set rstTimes = qdf.OpenRecordset
If rstTimes.RecordCount = 0 Then
isPreviousRecs = False
Exit Function
End If
'initialize atimeSlots
For intTimeSlot = 0 To 143
aTimeSlots(intTimeSlot) = TIMEFREE
Next intTimeSlot
Do While Not rstTimes.EOF
If rstTimes![予定日] < dblCurrentDate Then
intBeginTime = Hour(rstTimes![開始予定時刻]) * 2
ElseIf rstTimes![予定日] = dblCurrentDate Then
intBeginTime = (Hour(rstTimes![開始予定時刻]) * 2) + 48
Else
intBeginTime = (Hour(rstTimes![開始予定時刻]) * 2) + 96
End If
If Minute(rstTimes![開始予定時刻]) = 30 Then
intBeginTime = intBeginTime + 1
End If
If rstTimes![予定日] < dblCurrentDate Then
intEndTime = Hour(rstTimes![終了予定時刻]) * 2
ElseIf rstTimes![予定日] = dblCurrentDate Then
intEndTime = (Hour(rstTimes![終了予定時刻]) * 2) + 48
Else
intEndTime = (Hour(rstTimes![終了予定時刻]) * 2) + 96
End If
If Minute(rstTimes![終了予定時刻]) = 30 Then
intEndTime = intEndTime + 1
End If
If intEndTime <= intBeginTime Then 'endtime occurs the following day
intEndTime = intEndTime + 48
If intEndTime > 143 Then
intEndTime = 143
End If
End If
For intTimeSlot = intBeginTime To intEndTime - 1 'mark the times as booked
aTimeSlots(intTimeSlot) = TIMEALLOCATED
Next intTimeSlot
rstTimes.MoveNext
Loop
isPreviousRecs = True
rstTimes.Close
End Function