Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Protected Sub btnCheck_Click(sender As Object, e As System.EventArgs) Handles btnCheck.Click
- ' Variables
- Dim arrRunning(0)
- ReDim arrRemoveDates(0)
- ReDim arrFinalDates(0)
- Dim arrTRID
- Dim arrVDClosed(0)
- Dim arrDOW(7)
- Dim oGlobals As New oGlobals
- Dim arrConflict(0)
- Dim bBlock As Boolean = False
- Dim bConflict As Boolean = False
- Dim bConflictExists As Boolean = False
- Dim bConflictOverride As Boolean = False
- Dim bRace As Boolean = False
- Dim bAdHoc As Boolean = False
- Dim bMeeting As Boolean = False
- Dim bOverride As Boolean = False
- Dim bRFOverride As Boolean = False
- Dim bParticipentAdded As Boolean = False
- Dim bRepeat As Boolean = False
- Dim bSiteClosed As Boolean = False
- Dim bSameEvent As Boolean = False
- Dim dstData As DataSet
- Dim dstDataClone As New DataSet
- Dim dstTable As DataTable
- Dim dstRow As DataRow
- Dim dstCol As DataColumn
- Dim dstRForm As New DataSet
- Dim dtmDate As DateTime
- Dim dtmEndTime As Date
- Dim dtmStartTime As Date
- Dim dtmSQLCheck As Date
- Dim dtmSQLAdjust As Date
- Dim dtmStart As Date
- Dim dtmEnd As Date
- Dim dtmVDDate As Date
- Dim dMinute As Double
- Dim dDuration As Double = 0
- Dim intTR_NoOfKarts As Integer = 0
- Dim intRF_MaxDrivers As Integer = 0
- Dim intRF_MaxDrivers_Alt As Integer = 0
- Dim intSQLDOW As Integer = 0
- Dim intACnt As Integer = 0
- Dim intCnt As Integer = 0
- Dim intCCnt As Integer = 0
- Dim intConCount As Integer = 0
- Dim intDaysClosed As Integer = 0
- Dim intDayOfWeek As Integer = 0
- Dim intErr As Integer = 0
- Dim intId As Integer = 0
- Dim intNoOfApps As Integer = 0
- Dim intNoOfAppsToRemove As Integer = 0
- Dim intNoOfDriver As Integer = 0
- Dim sAltSQL As String = "(AD_ATID IN (7)) AND "
- Dim sTempNotice As String = ""
- Dim sLabel As String = "people"
- Dim sDtmDisplay As String = ""
- Dim sTempInternalNotice As String = ""
- Dim sId As String = ""
- Dim dstAdHoc As New DataSet
- Dim sAdHocSQL As String = ""
- Dim sTempDateString As String = ""
- Dim sTimeConflict As String = ""
- Dim intInCCnt As Integer = 0
- Dim bExists As Boolean = False
- Dim dtmCheck As DateTime
- Dim dtmCheckII As DateTime
- Dim intACount As Integer = 0
- Dim bIgnore As Boolean = False
- Dim bFinished As Boolean = False
- Dim dtmRunning As Date
- Dim dtmFStart As Date
- Dim dInt As Double
- Dim dtmEndRun As DateTime
- sqlConn = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("sqlConn"))
- Using sqlConn
- ' Collect the connection using the protected method
- sqlConn = oGlobals.returnSQLConn(sqlConn)
- ' Setup default parameters
- Select Case ddlAT_ATID.SelectedValue
- Case -4 ' Block Booking
- bAdHoc = False
- bBlock = True
- bMeeting = False
- bRace = False
- Case -3 ' Meeting
- bAdHoc = False
- bBlock = False
- bMeeting = True
- bRace = False
- sLabel = "People"
- Case -2 ' Adhoc
- bAdHoc = True
- bBlock = False
- bMeeting = False
- bRace = False
- sLabel = "Participants"
- Case -1 ' Race
- bAdHoc = False
- bBlock = False
- bMeeting = False
- bRace = True
- sLabel = "drivers"
- End Select
- If chkAP_Repeat.Checked Then bRepeat = True
- ' Validate
- If returnValid(bAdHoc, bRace, bRepeat, sLabel, bMeeting, bBlock) Then
- Dim intRF_RFID_Chk As Integer = 0
- If ddlRF_RFID.SelectedValue & "" <> "" Then intRF_RFID_Chk = ddlRF_RFID.SelectedValue
- If Not fnc_ScheduledFormat(intRF_RFID_Chk) Then
- ' Sortout the number of drivers
- intNoOfDriver = Session("AP_AD_Drivers") + Session("AP_ALT_Drivers")
- ' Check availability
- lbl_Message.Text = ""
- ' Collect the connection using the protected method
- sqlConn = oGlobals.returnSQLConn(sqlConn)
- ' Collect race format information
- If (Not bAdHoc) And (Not bMeeting) And (Not bBlock) Then dstRForm = returnProducts(ddlRF_RFID.SelectedValue)
- If ddlAT_ATID.SelectedValue = -3 Then
- sAltSQL = "(AD_ATID IN (12)) AND "
- Else
- sAltSQL = "(AD_ATID IN (6,8,10,11,13)) AND "
- End If
- ' Collect any linked Id's - will always return at least one (the selected activity center)
- arrTRID = returnACLinks(ddlTR_TRID.SelectedValue)
- For intCnt = 0 To UBound(arrTRID, 1)
- If intCnt < UBound(arrTRID, 1) Then
- sId = sId & arrTRID(intCnt) & ","
- Else
- sId = sId & arrTRID(intCnt)
- End If
- Next
- ' remove the final comma if needed
- If UBound(arrTRID, 1) > 1 Then sId = Mid(sId, 1, (Len(sId) - 1))
- ' Depending on the repeat option
- ' We have to check different options
- Select Case bRepeat
- Case True
- ' Setup the date parameter
- Dim intDaysToAdd As Integer = 0
- dtmSQLCheck = FormatDateTime(calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString)
- ' Sort out the day of the week filter if it's a weekly
- ' or hourly type of repeat, if it's a monthly repeat
- ' then setup the end date based on the number of months
- Select Case ddlAP_Frequency.SelectedValue
- Case 0, 2 'Hourly/Weekly
- dtmSQLAdjust = calAP_dtmAppointmentEnd.SelectedDate.Value.ToShortDateString
- ' Set/all to false
- For intCnt = 1 To 7
- arrDOW(intCnt) = False
- Next
- ' Update the selected days
- If chkSun.Checked Then arrDOW(1) = True
- If chkMon.Checked Then arrDOW(2) = True
- If chkTue.Checked Then arrDOW(3) = True
- If chkWed.Checked Then arrDOW(4) = True
- If chkThu.Checked Then arrDOW(5) = True
- If chkFri.Checked Then arrDOW(6) = True
- If chkSat.Checked Then arrDOW(7) = True
- Case 1 'Daily
- dtmSQLAdjust = calAP_dtmAppointmentEnd.SelectedDate.Value.ToShortDateString
- Case 3 ' Monthly
- dtmSQLAdjust = DateAdd(DateInterval.Month, CInt(ddlRF_Months.SelectedValue), CDate(dtmSQLCheck))
- Case 4 ' Ad Hoc
- If Not IsNothing(Session("dstAdHocDate")) Then
- dstAdHoc = Session("dstAdHocDate")
- For intCnt = 0 To dstAdHoc.Tables(0).Rows.Count - 1
- dtmDate = FormatDateTime(dstAdHoc.Tables(0).Rows(intCnt).Item("AH_dtmEvent"), DateFormat.ShortDate)
- sTempDateString = Right(dtmDate, 4) & Mid(dtmDate, 4, 2) & Left(dtmDate, 2)
- sAdHocSQL = sAdHocSQL & "(AP_dtmAppointmentStart = '" & sTempDateString & "')"
- If intCnt <> dstAdHoc.Tables(0).Rows.Count - 1 Then sAdHocSQL = sAdHocSQL & " OR "
- Next
- End If
- End Select
- calAP_dtmAppointmentEnd.SelectedDate = dtmSQLAdjust
- sSQL = "SELECT DISTINCT AP_ACID, RF_RFID, RF_Duration, RF_Name, RF_MaxDrivers, RF_MinAge, RF_MaxAge, AC_Name, AS_Name, AP_APID, AP_dtmAppointmentStart, CONVERT(VARCHAR(8),AP_StartTime,108) AS AP_StartTime, AP_EndTime, RF_PTID, RF_TRID, " &
- "(RF_MaxDrivers - COALESCE((SELECT SUM(AD_NoParticipents) FROM tbl_AD_AppointmentDetails WHERE AD_APID = AP_APID AND AD_ASID <= 280 AND AD_CLID > -1), 0) - @AP_NoOfDrivers) AS AP_Avail, AP_NoParticipents, RF_ETID, TR_MaxKarts, AD_NoParticipents " &
- "FROM tbl_AP_Appointment LEFT OUTER JOIN " &
- "tbl_AD_AppointmentDetails ON AP_APID = AD_APID LEFT OUTER JOIN " &
- "tbl_RF_RaceFormat ON AD_RFID = RF_RFID LEFT OUTER JOIN " &
- "tbl_TR_Track ON RF_TRID = TR_TRID LEFT OUTER JOIN " &
- "tbl_AS_AppointmentStatus ON AP_ASID = AS_ASID LEFT OUTER JOIN " &
- "tbl_AC_AppointmentClass ON AP_ACID = AC_ACID " &
- "WHERE (AP_dtmAppointmentStart >= @AP_dtmAppointmentStart) AND "
- ' Add filter depending on type of repeat
- Dim dtmAP_Start As DateTime
- Select Case ddlAP_Frequency.SelectedValue
- Case 0, 2 ' Hourly/Weekly
- sSQL &= "("
- For intCnt = 1 To 7
- If arrDOW(intCnt) Then
- If intACnt > 0 Then sSQL &= " OR "
- sSQL &= "(DATEPART(Dw,AP_dtmAppointmentStart) = " & intCnt & ")"
- intACnt = intACnt + 1
- End If
- Next
- If intACnt > 0 Then sSQL &= ") AND "
- intACnt = 0
- dtmAP_Start = calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString
- Case 1, 3
- dtmAP_Start = calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString
- Case 4
- sSQL &= "(" & sAdHocSQL & ") AND "
- dstAdHoc = Session("dstAdHocDate")
- dtmAP_Start = FormatDateTime(dstAdHoc.Tables(0).Rows(0).Item("AH_dtmEvent"), DateFormat.ShortDate)
- End Select
- ' Add filter for race/meeting
- sSQL &= sAltSQL &
- "(AP_VEID = @AP_VEID) AND " &
- "(AD_TRID IN (" & sId & ")) AND " &
- "AP_ASID NOT IN (300,400,500,600) AND " &
- "AD_ASID NOT IN (300,400,500,600) AND " &
- "AD_Deleted = 0 AND " &
- "(AD_CLID > -1) AND " &
- "RF_NonSchedule = 0 " &
- "ORDER BY CONVERT(VARCHAR(8),AP_StartTime,108), RF_Name ASC"
- ' SQL Parameters
- sqlCmd = New SqlCommand(sSQL, sqlConn)
- sqlCmd.Parameters.Add("@AP_NoOfDrivers", SqlDbType.Int, 4).Value = intNoOfDriver
- sqlCmd.Parameters.Add("@AP_dtmAppointmentStart", SqlDbType.DateTime, 8).Value = FormatDateTime(dtmAP_Start, DateFormat.ShortDate)
- sqlCmd.Parameters.Add("@AP_VEID", SqlDbType.Int, 4).Value = ddlVE_VEID.SelectedValue
- sqlAdap = New SqlDataAdapter(sqlCmd)
- Case False
- sSQL = "SELECT DISTINCT AP_ACID, RF_RFID, RF_Duration, RF_Name, RF_MaxDrivers, RF_MinAge, RF_MaxAge, AC_Name, AS_Name, AP_APID, AP_dtmAppointmentStart, CONVERT(VARCHAR(8),AP_StartTime,108) AS AP_StartTime, AP_EndTime, RF_PTID, RF_TRID, " &
- "(RF_MaxDrivers - COALESCE((SELECT SUM(AD_NoParticipents) FROM tbl_AD_AppointmentDetails WHERE AD_APID = AP_APID AND AD_ASID <= 280 AND AD_CLID > -1), 0) - @AP_NoOfDrivers) AS AP_Avail, AP_NoParticipents, RF_ETID, TR_MaxKarts, AD_NoParticipents " &
- "FROM tbl_AP_Appointment LEFT OUTER JOIN " &
- "tbl_AD_AppointmentDetails ON AP_APID = AD_APID LEFT OUTER JOIN " &
- "tbl_RF_RaceFormat ON AD_RFID = RF_RFID LEFT OUTER JOIN " &
- "tbl_TR_Track ON RF_TRID = TR_TRID LEFT OUTER JOIN " &
- "tbl_AS_AppointmentStatus ON AP_ASID = AS_ASID LEFT OUTER JOIN " &
- "tbl_AC_AppointmentClass ON AP_ACID = AC_ACID " &
- "WHERE (AP_dtmAppointmentStart = @AP_dtmAppointmentStart) AND "
- ' Filter for modifying events
- If hidAP_APID.Value <> "" Then
- sSQL &= sAltSQL &
- " (AP_APID <> " & hidAP_APID.Value & ") AND "
- End If
- ' Add filter for race/meeting
- sSQL &= sAltSQL &
- "(AP_VEID = @AP_VEID) AND " &
- "(AD_TRID IN (" & sId & ")) AND " &
- "AP_ASID NOT IN (300,400,500,600) AND " &
- "AD_ASID NOT IN (300,400,500,600) AND " &
- "AD_Deleted = 0 AND " &
- "(AD_CLID > -1) AND " &
- "RF_NonSchedule = 0 " &
- "ORDER BY CONVERT(VARCHAR(8),AP_StartTime,108), RF_Name ASC"
- ' SQL Parameters
- sqlCmd = New SqlCommand(sSQL, sqlConn)
- sqlCmd.Parameters.Add("@AP_NoOfDrivers", SqlDbType.Int, 4).Value = intNoOfDriver
- sqlCmd.Parameters.Add("@AP_dtmAppointmentStart", SqlDbType.DateTime, 8).Value = calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString
- sqlCmd.Parameters.Add("@AP_VEID", SqlDbType.Int, 4).Value = ddlVE_VEID.SelectedValue
- sqlAdap = New SqlDataAdapter(sqlCmd)
- End Select
- dstData = New DataSet
- sqlAdap.Fill(dstData, "AllTables")
- ReDim Preserve arrConflict(dstData.Tables("AllTables").Rows.Count)
- For intCnt = 0 To dstData.Tables("AllTables").Rows.Count - 1
- arrConflict(intCnt) = -1
- Next
- ' Setup date/time and duration variables
- ' Remember to set the duration manually if it's an adhoc thing
- Dim intAFCnt As Integer = 0
- Dim intAFCCnt As Integer = 0
- If bAdHoc Or bMeeting Or bBlock Then
- dDuration = txt_AH_Duration.Text
- Else
- dDuration = oGlobals.returnDuration(ddlRF_RFID.SelectedValue, intNoOfDriver)
- End If
- dtmStartTime = FormatDateTime(ddlAP_StartTime.SelectedValue, DateFormat.ShortTime)
- dtmEndTime = DateAdd(DateInterval.Minute, CDbl(dDuration), CDate(FormatDateTime(ddlAP_StartTime.SelectedValue, DateFormat.ShortTime)))
- ' Establish the counts for potential entries
- ' Add an additional day on the Daily/Hourly basis to include the final day
- If bRepeat Then
- Select Case ddlAP_Frequency.SelectedValue
- Case 0 ' Hourly
- Dim intNoOfActualApps As Integer = 0
- intNoOfApps = DateDiff(DateInterval.DayOfYear, CDate(calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString), CDate(calAP_dtmAppointmentEnd.SelectedDate.Value.ToShortDateString)) + 1
- dtmEndTime = ddlRF_EndTime.SelectedValue
- dtmFStart = FormatDateTime(dtmStartTime, DateFormat.ShortTime)
- ReDim arrRunning(0)
- intCnt = 0
- Do
- If intCnt = 0 Then
- dtmRunning = FormatDateTime(dtmStartTime, DateFormat.ShortTime)
- Else
- dInt = intCnt * dDuration
- dtmRunning = DateAdd(DateInterval.Minute, dInt, dtmFStart)
- End If
- If FormatDateTime(dtmRunning, DateFormat.ShortTime) >= FormatDateTime(dtmEndTime, DateFormat.ShortTime) Then bFinished = True
- If Not bFinished Then
- arrRunning(intCnt) = dtmRunning
- intCnt = intCnt + 1
- ReDim Preserve arrRunning(intCnt)
- End If
- Loop Until bFinished
- ' Are things open
- If intNoOfApps >= 1 Then
- arrVDClosed = returnSiteClosedStatus()
- If arrVDClosed(0) = -1 Then
- For intCnt = 0 To intNoOfApps
- ' Get the date
- dtmVDDate = DateAdd(DateInterval.DayOfYear, intCnt, CDate(calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString))
- ' Get the day of the week
- intDayOfWeek = DatePart(DateInterval.Weekday, dtmVDDate)
- For intACnt = 1 To 7
- ' If the day of the week matches and that day has been
- ' Specified as a day to run, then check against closures
- If intDayOfWeek = intACnt Then
- If arrDOW(intACnt) Then
- intNoOfActualApps = intNoOfActualApps + 1
- For intCCnt = 0 To UBound(arrVDClosed, 1) - 1
- If DatePart(DateInterval.Weekday, dtmVDDate) = arrVDClosed(intCCnt) Then
- arrConflictDates(intNoOfAppsToRemove) = dtmVDDate
- intNoOfAppsToRemove = intNoOfAppsToRemove + 1
- ReDim Preserve arrConflictDates(intNoOfAppsToRemove)
- Else
- For intAFCCnt = 0 To UBound(arrRunning, 1) - 1
- arrFinalDates(intAFCnt) = FormatDateTime(dtmVDDate, DateFormat.ShortDate) & " " & arrRunning(intAFCCnt)
- intAFCnt = intAFCnt + 1
- ReDim Preserve arrFinalDates(intAFCnt)
- Next
- End If
- Next
- End If
- End If
- Next
- Next
- Else
- For intCnt = 0 To intNoOfApps
- ' Get the date
- dtmVDDate = DateAdd(DateInterval.DayOfYear, intCnt, CDate(calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString))
- ' Get the day of the week
- intDayOfWeek = DatePart(DateInterval.Weekday, dtmVDDate)
- For intACnt = 1 To 7
- ' If the day of the week matches and that day has been
- ' Specified as a day to run
- If intDayOfWeek = intACnt Then
- If arrDOW(intACnt) Then
- intNoOfActualApps = intNoOfActualApps + 1
- arrFinalDates(intAFCnt) = FormatDateTime(dtmVDDate, DateFormat.ShortDate) & " " & ddlAP_StartTime.SelectedValue
- intAFCnt = intAFCnt + 1
- ReDim Preserve arrFinalDates(intAFCnt)
- End If
- End If
- Next
- Next
- End If
- End If
- ' Update the final date array to include the timings
- ' Set the new totals up
- intDaysClosed = intNoOfAppsToRemove
- intNoOfApps = UBound(arrFinalDates, 1)
- Case 2 ' Weekly
- Dim intNoOfActualApps As Integer = 0
- intNoOfApps = DateDiff(DateInterval.DayOfYear, CDate(calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString), CDate(calAP_dtmAppointmentEnd.SelectedDate.Value.ToShortDateString))
- ' Collect the days the venue is closed
- ' Then remove those dates from the possible creations
- ' This applies to Hourly/Weekly repeats
- ' Add the dates to the conflict date array
- If intNoOfApps >= 1 Then
- arrVDClosed = returnSiteClosedStatus()
- If arrVDClosed(0) = -1 Then
- For intCnt = 0 To intNoOfApps
- ' Get the date
- dtmVDDate = DateAdd(DateInterval.DayOfYear, intCnt, CDate(calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString))
- ' Get the day of the week
- intDayOfWeek = DatePart(DateInterval.Weekday, dtmVDDate)
- For intACnt = 1 To 7
- ' If the day of the week matches and that day has been
- ' Specified as a day to run, then check against closures
- If intDayOfWeek = intACnt Then
- If arrDOW(intACnt) Then
- intNoOfActualApps = intNoOfActualApps + 1
- For intCCnt = 0 To UBound(arrVDClosed, 1) - 1
- If DatePart(DateInterval.Weekday, dtmVDDate) = arrVDClosed(intCCnt) Then
- arrConflictDates(intNoOfAppsToRemove) = dtmVDDate
- intNoOfAppsToRemove = intNoOfAppsToRemove + 1
- ReDim Preserve arrConflictDates(intNoOfAppsToRemove)
- Else
- arrFinalDates(intAFCnt) = FormatDateTime(dtmVDDate, DateFormat.ShortDate) & " " & ddlAP_StartTime.SelectedValue
- intAFCnt = intAFCnt + 1
- ReDim Preserve arrFinalDates(intAFCnt)
- End If
- Next
- ' It's open so add the day
- If intCCnt = 0 Then
- arrFinalDates(intAFCnt) = FormatDateTime(dtmVDDate, DateFormat.ShortDate) & " " & ddlAP_StartTime.SelectedValue
- intAFCnt = intAFCnt + 1
- ReDim Preserve arrFinalDates(intAFCnt)
- End If
- End If
- End If
- Next
- Next
- Else
- For intCnt = 0 To intNoOfApps
- ' Get the date
- dtmVDDate = DateAdd(DateInterval.DayOfYear, intCnt, CDate(calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString))
- ' Get the day of the week
- intDayOfWeek = DatePart(DateInterval.Weekday, dtmVDDate)
- For intACnt = 1 To 7
- ' If the day of the week matches and that day has been
- ' Specified as a day to run
- If intDayOfWeek = intACnt Then
- If arrDOW(intACnt) Then
- intNoOfActualApps = intNoOfActualApps + 1
- arrFinalDates(intAFCnt) = FormatDateTime(dtmVDDate, DateFormat.ShortDate) & " " & ddlAP_StartTime.SelectedValue
- intAFCnt = intAFCnt + 1
- ReDim Preserve arrFinalDates(intAFCnt)
- End If
- End If
- Next
- Next
- End If
- End If
- ' Set the new totals up
- intDaysClosed = intNoOfAppsToRemove
- intNoOfApps = intNoOfActualApps - intNoOfAppsToRemove
- Case 1 ' Daily
- intNoOfApps = DateDiff(DateInterval.DayOfYear, CDate(calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString), CDate(calAP_dtmAppointmentEnd.SelectedDate.Value.ToShortDateString))
- ' Collect the days the venue is closed
- ' Then remove those dates from the possible creations
- ' This only applies to Daily repeats
- ' Add the dates to the conflict date array
- If intNoOfApps >= 1 Then
- arrVDClosed = returnSiteClosedStatus()
- If arrVDClosed(0) = -1 Then
- For intCnt = 0 To intNoOfApps
- dtmVDDate = DateAdd(DateInterval.DayOfYear, intCnt, CDate(calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString))
- For intCCnt = 0 To UBound(arrVDClosed, 1) - 1
- If DatePart(DateInterval.Weekday, dtmVDDate) = arrVDClosed(intCCnt) Then
- arrConflictDates(intNoOfAppsToRemove) = dtmVDDate
- intNoOfAppsToRemove = intNoOfAppsToRemove + 1
- ReDim Preserve arrConflictDates(intNoOfAppsToRemove)
- Else
- arrFinalDates(intAFCnt) = FormatDateTime(dtmVDDate, DateFormat.ShortDate) & " " & ddlAP_StartTime.SelectedValue
- intAFCnt = intAFCnt + 1
- ReDim Preserve arrFinalDates(intAFCnt)
- End If
- Next
- ' It's open so add the day
- If intCCnt = 0 Then
- arrFinalDates(intAFCnt) = FormatDateTime(dtmVDDate, DateFormat.ShortDate) & " " & ddlAP_StartTime.SelectedValue
- intAFCnt = intAFCnt + 1
- ReDim Preserve arrFinalDates(intAFCnt)
- End If
- Next
- End If
- End If
- ' Set the new totals up
- intDaysClosed = intNoOfAppsToRemove
- intNoOfApps = intNoOfApps - intNoOfAppsToRemove + 1
- Case 3 ' Monthly
- intNoOfApps = DateDiff(DateInterval.Month, CDate(calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString), CDate(dtmSQLAdjust))
- For intCnt = 0 To intNoOfApps - 1
- arrFinalDates(intAFCnt) = DateAdd(DateInterval.Month, intCnt, CDate(calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString)) & " " & ddlAP_StartTime.SelectedValue
- intAFCnt = intAFCnt + 1
- ReDim Preserve arrFinalDates(intAFCnt)
- Next
- Case 4 ' Ad Hoc Dates
- dstAdHoc = Session("dstAdHocDate")
- intNoOfApps = dstAdHoc.Tables(0).Rows.Count
- For intCnt = 0 To intNoOfApps - 1
- arrFinalDates(intAFCnt) = dstAdHoc.Tables(0).Rows(intCnt).Item("AH_dtmEvent") & " " & ddlAP_StartTime.SelectedValue
- intAFCnt = intAFCnt + 1
- ReDim Preserve arrFinalDates(intAFCnt)
- Next
- End Select
- Else
- arrFinalDates(intAFCnt) = FormatDateTime(calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString, DateFormat.ShortDate) & " " & ddlAP_StartTime.SelectedValue
- intAFCnt = intAFCnt + 1
- ReDim Preserve arrFinalDates(intAFCnt)
- End If
- intAFCCnt = 0
- ' Set the initial count to include those now driving
- intTR_NoOfKarts = intNoOfDriver
- With dstData.Tables("AllTables")
- If .Rows.Count >= 1 Then
- ' Clear the message out and setup the counters
- sTempNotice = ""
- If ddlRF_RFID.Visible Then
- bRFOverride = True
- 'TS 16032016
- If bRepeat Then bRFOverride = False
- Else
- bRFOverride = False
- End If
- ' Loop through all potential matches
- For intCnt = 0 To .Rows.Count - 1
- intRF_MaxDrivers = .Rows(intCnt).Item("RF_MaxDrivers")
- If bRFOverride Then
- bOverride = fnc_OverrideSelectedRace(ddlRF_RFID.SelectedValue, .Rows(intCnt).Item("RF_TRID"), .Rows(intCnt).Item("RF_RFID"))
- Else
- bOverride = False
- End If
- bExists = False
- For intACount = 0 To UBound(arrFinalDates, 1) - 1
- bIgnore = False
- ' Only check it if it's a direct date match
- If FormatDateTime(.Rows(intCnt).Item("AP_dtmAppointmentStart"), DateFormat.ShortDate) = FormatDateTime(arrFinalDates(intACount), DateFormat.ShortDate) Then
- If FormatDateTime(.Rows(intCnt).Item("AP_StartTime"), DateFormat.ShortTime) = FormatDateTime(dtmStartTime, DateFormat.ShortTime) Then
- If Not bParticipentAdded Then
- intTR_NoOfKarts = intTR_NoOfKarts + .Rows(intCnt).Item("AD_NoParticipents")
- bParticipentAdded = True
- Else
- intTR_NoOfKarts = intTR_NoOfKarts + .Rows(intCnt).Item("AD_NoParticipents")
- bParticipentAdded = False
- End If
- Else
- ' This checks for events that have already started before the proposed event starts
- ' We need to check that to see if they end before the proposed event either ends whilst
- ' We are racing, or in the event of an hour event, ends after the event is running
- ' IF the duration is greater than 60 minutes then do this check
- dDuration = oGlobals.returnDuration(.Rows(intCnt).Item("RF_RFID"), .Rows(intCnt).Item("AD_NoParticipents"))
- If dDuration > 30 Then
- If FormatDateTime(.Rows(intCnt).Item("AP_StartTime"), DateFormat.ShortTime) < FormatDateTime(dtmStartTime, DateFormat.ShortTime) Then
- If FormatDateTime(.Rows(intCnt).Item("AP_EndTime"), DateFormat.ShortTime) > FormatDateTime(dtmStartTime, DateFormat.ShortTime) Then
- If Not bParticipentAdded Then
- intTR_NoOfKarts = intTR_NoOfKarts + .Rows(intCnt).Item("AD_NoParticipents")
- bParticipentAdded = True
- Else
- intTR_NoOfKarts = intTR_NoOfKarts + .Rows(intCnt).Item("AD_NoParticipents")
- bParticipentAdded = False
- End If
- End If
- End If
- If FormatDateTime(.Rows(intCnt).Item("AP_StartTime"), DateFormat.ShortTime) < FormatDateTime(dtmEndTime, DateFormat.ShortTime) Then
- If FormatDateTime(.Rows(intCnt).Item("AP_StartTime"), DateFormat.ShortTime) > FormatDateTime(dtmStartTime, DateFormat.ShortTime) Then
- If Not bParticipentAdded Then
- intTR_NoOfKarts = intTR_NoOfKarts + .Rows(intCnt).Item("AD_NoParticipents")
- bParticipentAdded = True
- Else
- intTR_NoOfKarts = intTR_NoOfKarts + .Rows(intCnt).Item("AD_NoParticipents")
- bParticipentAdded = False
- End If
- End If
- End If
- End If
- ' This checks for events that will be running after the proposed event starts
- ' We just need to check to see if they end before the poposed event ends
- ' If the duration is only 30 minutes we need to check different options
- If dDuration <= 30 Then
- If FormatDateTime(.Rows(intCnt).Item("AP_StartTime"), DateFormat.ShortTime) < FormatDateTime(dtmStartTime, DateFormat.ShortTime) Then
- If FormatDateTime(.Rows(intCnt).Item("AP_EndTime"), DateFormat.ShortTime) > FormatDateTime(dtmStartTime, DateFormat.ShortTime) Then
- bIgnore = True
- If Not bParticipentAdded Then
- intTR_NoOfKarts = intTR_NoOfKarts + .Rows(intCnt).Item("AD_NoParticipents")
- bParticipentAdded = True
- Else
- intTR_NoOfKarts = intTR_NoOfKarts + .Rows(intCnt).Item("AD_NoParticipents")
- bParticipentAdded = False
- End If
- End If
- End If
- If FormatDateTime(.Rows(intCnt).Item("AP_StartTime"), DateFormat.ShortTime) > FormatDateTime(dtmStartTime, DateFormat.ShortTime) Then
- If FormatDateTime(.Rows(intCnt).Item("AP_StartTime"), DateFormat.ShortTime) < FormatDateTime(dtmEndTime, DateFormat.ShortTime) Then
- If Not bIgnore Then
- bIgnore = True
- If Not bParticipentAdded Then
- intTR_NoOfKarts = intTR_NoOfKarts + .Rows(intCnt).Item("AD_NoParticipents")
- bParticipentAdded = True
- Else
- intTR_NoOfKarts = intTR_NoOfKarts + .Rows(intCnt).Item("AD_NoParticipents")
- bParticipentAdded = False
- End If
- End If
- End If
- End If
- End If
- End If
- ' Clear the conflict flag for this loop
- bConflictExists = False
- ' Same start time
- sTempInternalNotice = fnc_SameStartTime(FormatDateTime(.Rows(intCnt).Item("AP_StartTime"), DateFormat.ShortTime), FormatDateTime(dtmStartTime, DateFormat.ShortTime), bRace, bOverride, intTR_NoOfKarts, .Rows(intCnt).Item("TR_MaxKarts"), intRF_MaxDrivers, .Rows(intCnt).Item("AP_ACID"), .Rows(intCnt).Item("RF_RFID"))
- ' Mark it as a conflict and exit or continue
- If sTempInternalNotice <> "" Then
- sTempNotice = sTempNotice & sTempInternalNotice
- bConflictExists = True
- bConflict = True
- arrConflict(intCnt) = intCnt
- ' Store the date to remove it later
- ' So long as we haven't already got it in there
- bExists = False
- For intInCCnt = 0 To intAFCCnt - 1
- dtmCheck = .Rows(intCnt).Item("AP_dtmAppointmentStart") & " " & ddlAP_StartTime.SelectedValue
- dtmCheckII = arrRemoveDates(intInCCnt)
- If FormatDateTime(dtmCheckII, DateFormat.GeneralDate) = FormatDateTime(dtmCheck, DateFormat.GeneralDate) Then
- bExists = True
- Exit For
- End If
- Next
- If Not bExists Then
- arrRemoveDates(intAFCCnt) = FormatDateTime(.Rows(intCnt).Item("AP_dtmAppointmentStart"), DateFormat.ShortDate) & " " & ddlAP_StartTime.SelectedValue
- intAFCCnt = intAFCCnt + 1
- ReDim Preserve arrRemoveDates(intAFCCnt)
- End If
- End If
- ' Ends whilst i'm racing
- ' Only check if the bConflictExists hasn't been
- ' For this particular date in the loop, there's no
- ' Point in checking if there's already a conflict
- If Not bConflictExists Then
- sTempInternalNotice = fnc_EndsWhilstRacing(FormatDateTime(.Rows(intCnt).Item("AP_EndTime"), DateFormat.ShortTime), FormatDateTime(.Rows(intCnt).Item("AP_StartTime"), DateFormat.ShortTime), FormatDateTime(dtmStartTime, DateFormat.ShortTime), bRace, bOverride, intTR_NoOfKarts, .Rows(intCnt).Item("TR_MaxKarts"), intRF_MaxDrivers, .Rows(intCnt).Item("AP_ACID"), .Rows(intCnt).Item("RF_RFID"))
- ' Mark it as a conflict and exit or continue
- If sTempInternalNotice <> "" Then
- sTempNotice = sTempNotice & sTempInternalNotice
- bConflictExists = True
- bConflict = True
- arrConflict(intCnt) = intCnt
- ' Store the date to remove it later
- ' So long as we haven't already got it in there
- bExists = False
- For intInCCnt = 0 To intAFCCnt - 1
- dtmCheck = FormatDateTime(.Rows(intCnt).Item("AP_dtmAppointmentStart"), DateFormat.ShortDate) & " " & ddlAP_StartTime.SelectedValue
- dtmCheckII = FormatDateTime(arrRemoveDates(intInCCnt), DateFormat.GeneralDate)
- If FormatDateTime(dtmCheckII, DateFormat.GeneralDate) = FormatDateTime(dtmCheck, DateFormat.GeneralDate) Then
- bExists = True
- Exit For
- End If
- Next
- If Not bExists Then
- arrRemoveDates(intAFCCnt) = FormatDateTime(.Rows(intCnt).Item("AP_dtmAppointmentStart"), DateFormat.ShortDate) & " " & ddlAP_StartTime.SelectedValue
- intAFCCnt = intAFCCnt + 1
- ReDim Preserve arrRemoveDates(intAFCCnt)
- End If
- End If
- End If
- ' Starts whilst i'm racing
- ' Only check if the bConflictExists hasn't been
- ' For this particular date in the loop, there's no
- ' Point in checking if there's already a conflict
- If Not bConflictExists Then
- sTempInternalNotice = fnc_StartsWhilstRacing(FormatDateTime(.Rows(intCnt).Item("AP_StartTime"), DateFormat.ShortTime), FormatDateTime(.Rows(intCnt).Item("AP_EndTime"), DateFormat.ShortTime), FormatDateTime(dtmStartTime, DateFormat.ShortTime), FormatDateTime(dtmEndTime, DateFormat.ShortTime), bRace, bOverride, intTR_NoOfKarts, .Rows(intCnt).Item("TR_MaxKarts"), intRF_MaxDrivers, .Rows(intCnt).Item("AP_ACID"), .Rows(intCnt).Item("RF_RFID"))
- If sTempInternalNotice <> "" Then
- sTempNotice = sTempNotice & sTempInternalNotice
- bConflictExists = True
- bConflict = True
- arrConflict(intCnt) = intCnt
- bExists = False
- For intInCCnt = 0 To intAFCCnt - 1
- dtmCheck = FormatDateTime(.Rows(intCnt).Item("AP_dtmAppointmentStart"), DateFormat.ShortDate) & " " & ddlAP_StartTime.SelectedValue
- dtmCheckII = FormatDateTime(arrRemoveDates(intInCCnt), DateFormat.GeneralDate)
- If FormatDateTime(dtmCheckII, DateFormat.GeneralDate) = FormatDateTime(dtmCheck, DateFormat.GeneralDate) Then
- bExists = True
- Exit For
- End If
- Next
- If Not bExists Then
- arrRemoveDates(intAFCCnt) = FormatDateTime(.Rows(intCnt).Item("AP_dtmAppointmentStart"), DateFormat.ShortDate) & " " & ddlAP_StartTime.SelectedValue
- intAFCCnt = intAFCCnt + 1
- ReDim Preserve arrRemoveDates(intAFCCnt)
- End If
- End If
- End If
- Else
- intTR_NoOfKarts = 0
- bParticipentAdded = False
- End If
- Next
- If InStr(sTempNotice, "exceeds the activity center limit") Then
- .Rows(intCnt).Item("AP_Avail") = -1
- dstData.Tables("AllTables").AcceptChanges()
- End If
- If InStr(sTempNotice, "exceeds the events limit of") Then
- .Rows(intCnt).Item("AP_Avail") = -1
- dstData.Tables("AllTables").AcceptChanges()
- End If
- If InStr(sTempNotice, " are not comaptible") Then
- .Rows(intCnt).Item("AP_Avail") = -1
- dstData.Tables("AllTables").AcceptChanges()
- End If
- If InStr(sTempNotice, " that is exclusive") Then
- .Rows(intCnt).Item("AP_Avail") = -1
- dstData.Tables("AllTables").AcceptChanges()
- End If
- Next
- Session("arrRemoveDates") = arrRemoveDates
- Session("arrFinalDates") = arrFinalDates
- If bRace Then
- hidSRF_MinAge.Value = returnEventAge_Min(ddlRF_RFID.SelectedValue)
- hidSRF_MaxAge.Value = returnEventAge_Max(ddlRF_RFID.SelectedValue)
- Else
- hidSRF_MinAge.Value = 1
- hidSRF_MaxAge.Value = 100
- End If
- ' Final check to make sure the venue will still be open
- If Not bConflict Then
- sTempInternalNotice = returnEndsAfterSiteCloses(FormatDateTime(dtmEndTime, DateFormat.ShortTime), FormatDateTime(returnVenueClosingTime, DateFormat.ShortTime), bRace)
- If sTempInternalNotice <> "" Then
- sTempNotice = sTempNotice & sTempInternalNotice
- bSiteClosed = True
- End If
- End If
- ' Build the final dataset
- ' To show those that conflict
- pnlAvailability.Visible = True
- intACnt = 0
- If bRepeat Then
- If bConflict Then
- ' Loop through and grab the days that
- ' Won't get included and update the array
- ' Rebase the counter to include all closed days
- intConCount = UBound(arrConflictDates, 1)
- With dstData.Tables("AllTables")
- ' Add the closed message if it applies
- Select Case ddlAP_Frequency.SelectedValue
- Case 0, 1, 2, 3
- dtmEndRun = calAP_dtmAppointmentEnd.SelectedDate.Value.ToShortDateString
- Case 4
- dstAdHoc = Session("dstAdHocDate")
- dtmEndRun = dstAdHoc.Tables(0).Rows(dstAdHoc.Tables(0).Rows.Count - 1).Item("AH_dtmEvent")
- End Select
- If intDaysClosed > 0 Then
- sDtmDisplay = "<li>Conflicts were detected in the scheduling system.<br/><br/>If you proceed you will create a total of <b>|FINAL|</b> repeat booking(s) which will occur on a <b>" & ddlAP_Frequency.Items(ddlAP_Frequency.SelectedIndex).Text & "</b> basis until <b>" & FormatDateTime(dtmEndRun, DateFormat.ShortDate) & "</b>.<br/><br/>No entries will be created on the <b>" & intDaysClosed & "</b> day(s) that the venue is closed during the timeframe specified.<br/><br/>Entries will not be created on the following dates due to any existing bookings:<br/><b>"
- Else
- sDtmDisplay = "<li>Conflicts were detected in the scheduling system.<br/><br/>If you proceed you will create a total of <b>|FINAL|</b> repeat booking(s) which will occur on a <b>" & ddlAP_Frequency.Items(ddlAP_Frequency.SelectedIndex).Text & "</b> basis until <b>" & FormatDateTime(dtmEndRun, DateFormat.ShortDate) & "</b>.<br/><br/>Entries will not be created on the following dates due to any existing bookings:<br/><b>"
- End If
- Dim tmpDates As New List(Of Date)
- For intCnt = 0 To UBound(arrRemoveDates, 1) - 1
- tmpDates.Add(FormatDateTime(arrRemoveDates(intCnt), DateFormat.GeneralDate))
- Next
- tmpDates.Sort()
- ' Sort out the dates to display
- For intCnt = 0 To tmpDates.Count - 1
- sDtmDisplay = sDtmDisplay & " | " & FormatDateTime(tmpDates(intCnt), DateFormat.GeneralDate)
- intNoOfApps = intNoOfApps - 1
- intACnt = intACnt + 1
- If intACnt = 4 Then
- sDtmDisplay = sDtmDisplay & "<br/>"
- intACnt = 0
- End If
- Next
- ' Tidy up the string and replace the |FINAL|
- ' Variables with the actual number left to be created
- sDtmDisplay = Replace(sDtmDisplay, "|FINAL|", intNoOfApps) & "</b>"
- ' Final catch to make sure 0's are caught
- If intNoOfApps <= 0 Then
- sDtmDisplay = "<li>Conflicts were detected in the scheduling system against <b>ALL</b> of the dates you have selected, therefore you cannot create the bookings."
- btnAddClients.Enabled = False
- Else
- sDtmDisplay = Replace(sDtmDisplay, "|FINAL|", intNoOfApps) & "</b>"
- btnAddClients.Enabled = True
- End If
- End With
- lbl_AVTitle.Text = "<b><a name='avail'>Availability</a></b>"
- lbl_Availability.Text = sDtmDisplay
- lbl_Availability.Text = lbl_Availability.Text & "<br/><br/>Click <a href='DailyCalendar.aspx?CO_COID=" & ddlCO_COID.SelectedValue & "&VE_VEID=" & ddlVE_VEID.SelectedValue & "&TR_TRID=" & ddlTR_TRID.SelectedValue & "&ap_lapid=" & hidAP_APID_Primary.Value & "&ap_lclid=" & hidAP_CLID_Primary.Value & "&dtmDate=" & FormatDateTime(calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString, DateFormat.ShortDate) & "'>HERE</a> to view the calendar."
- trRepeater.Visible = False
- trProceed.Visible = True
- txt_AP_NoDrivers.Text = "0"
- txt_AP_NoDrivers_Alt.Text = "0"
- Else
- lbl_AVTitle.Text = "<b><a name='avail'>Availability</a></b>"
- ' Added to prevent silly messages getting returned,
- ' If someone has selected a monthly/weekly schedule
- ' But not put enough time into make a difference
- If intNoOfApps = 0 Then
- If intDaysClosed > 0 Then
- sDtmDisplay = "<li>There were no conflicts found.<br/>If you proceed you will only create <b>1</b> booking because the end date specified occurs before the next <b>" & ddlAP_Frequency.Items(ddlAP_Frequency.SelectedIndex).Text & "</b> occurrence would be met.<br/>No entries will be created on the <b>" & intDaysClosed & "</b> day(s) that the venue is closed during the timeframe specified."
- Else
- sDtmDisplay = "<li>There were no conflicts found.<br/>If you proceed you will only create <b>1</b> booking because the end date specified occurs before the next <b>" & ddlAP_Frequency.Items(ddlAP_Frequency.SelectedIndex).Text & "</b> occurrence would be met."
- End If
- Else
- Select Case ddlAP_Frequency.SelectedValue
- Case 0, 1, 2, 3
- dtmEndRun = calAP_dtmAppointmentEnd.SelectedDate.Value.ToShortDateString
- Case 4
- dstAdHoc = Session("dstAdHocDate")
- dtmEndRun = dstAdHoc.Tables(0).Rows(dstAdHoc.Tables(0).Rows.Count - 1).Item("AH_dtmEvent")
- End Select
- If intDaysClosed > 0 Then
- sDtmDisplay = "<li>There were no conflicts found.<br/>If you proceed you will create a total of <b>" & intNoOfApps & "</b> repeat booking(s) which will occur on a <b>" & ddlAP_Frequency.Items(ddlAP_Frequency.SelectedIndex).Text & "</b> basis until <b>" & FormatDateTime(dtmEndRun, DateFormat.ShortDate) & "</b>.<br/>No entries will be created on the <b>" & intDaysClosed & "</b> day(s) that the venue is closed during the timeframe specified."
- Else
- sDtmDisplay = "<li>There were no conflicts found.<br/>If you proceed you will create a total of <b>" & intNoOfApps & "</b> repeat booking(s) which will occur on a <b>" & ddlAP_Frequency.Items(ddlAP_Frequency.SelectedIndex).Text & "</b> basis until <b>" & FormatDateTime(dtmEndRun, DateFormat.ShortDate) & "</b>."
- End If
- End If
- lbl_Availability.Text = sDtmDisplay
- trRepeater.Visible = False
- trProceed.Visible = True
- txt_AP_NoDrivers.Text = "0"
- txt_AP_NoDrivers_Alt.Text = "0"
- btnAddClients.Enabled = True
- End If
- Else
- ' New check to see if we have an identical match or not
- bSameEvent = False
- Dim bConflictMatched As Boolean = False
- ' Loop through all potential matches
- For intCnt = 0 To .Rows.Count - 1
- intRF_MaxDrivers = .Rows(intCnt).Item("RF_MaxDrivers")
- For intACount = 0 To UBound(arrFinalDates, 1) - 1
- bIgnore = False
- ' Only check it if it's a direct date and format match
- If FormatDateTime(.Rows(intCnt).Item("AP_dtmAppointmentStart"), DateFormat.ShortDate) = FormatDateTime(arrFinalDates(intACount), DateFormat.ShortDate) Then
- ' Same start time
- sTempInternalNotice = fnc_SameStartTime_AddToEvent(FormatDateTime(.Rows(intCnt).Item("AP_StartTime"), DateFormat.ShortTime), FormatDateTime(dtmStartTime, DateFormat.ShortTime), .Rows(intCnt).Item("AP_ACID"), .Rows(intCnt).Item("RF_RFID"))
- ' Mark it as a conflict and exit or continue
- If sTempInternalNotice <> "" Then
- If Not bConflictMatched Then
- sTempNotice = sTempNotice & sTempInternalNotice
- bConflict = True
- arrConflict(intCnt) = intCnt
- bConflictMatched = True
- End If
- ' Store the date to remove it later
- ' So long as we haven't already got it in there
- bExists = False
- For intInCCnt = 0 To intAFCCnt - 1
- dtmCheck = .Rows(intCnt).Item("AP_dtmAppointmentStart") & " " & ddlAP_StartTime.SelectedValue
- dtmCheckII = arrRemoveDates(intInCCnt)
- If FormatDateTime(dtmCheckII, DateFormat.GeneralDate) = FormatDateTime(dtmCheck, DateFormat.GeneralDate) Then
- bExists = True
- Exit For
- End If
- Next
- If Not bExists Then
- arrRemoveDates(intAFCCnt) = FormatDateTime(.Rows(intCnt).Item("AP_dtmAppointmentStart"), DateFormat.ShortDate) & " " & ddlAP_StartTime.SelectedValue
- intAFCCnt = intAFCCnt + 1
- ReDim Preserve arrRemoveDates(intAFCCnt)
- End If
- End If
- Else
- intTR_NoOfKarts = 0
- bParticipentAdded = False
- End If
- Next
- Next
- Session("arrRemoveDates") = arrRemoveDates
- Session("arrFinalDates") = arrFinalDates
- dstDataClone = New DataSet
- If bConflict Then
- dstTable = New DataTable
- With dstData.Tables("AllTables")
- ' Add the columns
- For intCnt = 0 To .Columns.Count - 1
- dstCol = New DataColumn(.Columns(intCnt).ColumnName, .Columns(intCnt).DataType)
- dstTable.Columns.Add(dstCol)
- Next
- ' Add the rows
- For intCnt = 0 To .Rows.Count - 1
- If arrConflict(intCnt) = intCnt Then
- dstRow = dstTable.NewRow
- For intCCnt = 0 To .Columns.Count - 1
- dstRow(intCCnt) = .Rows(intCnt).Item(intCCnt)
- Next
- dstTable.Rows.Add(dstRow)
- End If
- Next
- ' Add the table
- dstDataClone.Tables.Add(dstTable)
- End With
- End If
- ' Final update to sort out empty references for meetings
- If bConflict Then
- If Not bRace Then
- For intCnt = 0 To dstDataClone.Tables(0).Rows.Count - 1
- With dstDataClone.Tables(0)
- dtmStart = FormatDateTime(.Rows(intCnt).Item("AP_StartTime"), DateFormat.ShortTime)
- dtmEnd = FormatDateTime(.Rows(intCnt).Item("AP_EndTime"), DateFormat.ShortTime)
- dMinute = DateDiff(DateInterval.Minute, dtmStart, dtmEnd)
- If .Rows(intCnt).Item("RF_Name") & "" = "" Then .Rows(intCnt).Item("RF_Name") = "Room Hire"
- dDuration = oGlobals.returnDuration(.Rows(0).Item("RF_RFID"), .Rows(0).Item("AD_NoParticipents"))
- If dDuration & "" = "" Then .Rows(intCnt).Item("RF_Duration") = dMinute
- If .Rows(intCnt).Item("AP_Avail") & "" = "" Then .Rows(intCnt).Item("AP_Avail") = 0
- .Rows(intCnt).Item("RF_Duration") = dDuration
- dstDataClone.AcceptChanges()
- End With
- Next
- End If
- End If
- ' Sort out the duration as we've got the new method
- If dstDataClone.Tables.Count >= 1 Then
- For intCnt = 0 To dstDataClone.Tables(0).Rows.Count - 1
- With dstDataClone.Tables(0)
- dDuration = oGlobals.returnDuration(.Rows(0).Item("RF_RFID"), .Rows(0).Item("AD_NoParticipents"))
- If dDuration & "" = "" Then .Rows(intCnt).Item("RF_Duration") = dMinute
- .Rows(intCnt).Item("RF_Duration") = dDuration
- dstDataClone.AcceptChanges()
- End With
- Next
- End If
- ' Either show the conflicting events
- ' Or hide and display the continue panels
- ' And remove any people count!
- pnlAvailability.Visible = True
- If bConflict Then
- lbl_AVTitle.Text = "<b><a name='avail'>Availability</a></b>"
- lbl_Details.Text = "<b>Please Note:</b> The number shown in 'Spaces Left' refers to the number of spaces that will be left <b>AFTER</b> the booking you are currently placing.<br/><br/>"
- lbl_Availability.Text = sTempNotice
- rptAvailability.DataSource = dstDataClone
- rptAvailability.DataBind()
- trRepeater.Visible = True
- trProceed.Visible = False
- lbl_Availability.Text = lbl_Availability.Text & "<br/><br/>Click <a href='DailyCalendar.aspx?CO_COID=" & ddlCO_COID.SelectedValue & "&VE_VEID=" & ddlVE_VEID.SelectedValue & "&TR_TRID=" & ddlTR_TRID.SelectedValue & "&AP_LAPID=" & hidAP_APID_Primary.Value & "&AP_LCLID=" & hidAP_CLID_Primary.Value & "&dtmDate=" & FormatDateTime(calAP_dtmAppointmentStart.SelectedDate.Value.ToShortDateString, DateFormat.ShortDate) & "'>HERE</a> to view the calendar."
- btnAddClients.Enabled = True
- Else
- lbl_AVTitle.Text = "<b><a name='avail'>Availability</a></b>"
- lbl_Availability.Text = "<li>There were no conflicts found.</li>"
- trRepeater.Visible = False
- trProceed.Visible = True
- btnAddClients.Enabled = True
- End If
- End If
- ' Final check for venue closed situation
- If bSiteClosed Then
- lbl_AVTitle.Text = "<b><a name='avail'>Availability</a></b>"
- lbl_Availability.Text = "<li>There were no conflicts found, however the event is scheduled to finish <b>after the venue has closed.</b> You may proceed if you wish, but it's at your discretion.</li>"
- trRepeater.Visible = False
- trProceed.Visible = True
- btnAddClients.Enabled = True
- End If
- Else
- ' Collect info for checking against
- ' Minimum/maximum age requirements
- ' Default adhocs to untouchable levelts as we don't
- ' Care what they are because the organiser is assuming
- ' Responsibility for all that when they create the event
- If bAdHoc Or bMeeting Or bBlock Then
- hidSRF_MinAge.Value = 1
- hidSRF_MaxAge.Value = 100
- Else
- hidSRF_MinAge.Value = returnEventAge_Min(ddlRF_RFID.SelectedValue)
- hidSRF_MaxAge.Value = returnEventAge_Max(ddlRF_RFID.SelectedValue)
- End If
- Session("arrFinalDates") = arrFinalDates
- ' Final check to make sure the venue will still be open
- If Not bConflict Then
- sTempInternalNotice = returnEndsAfterSiteCloses(FormatDateTime(dtmEndTime, DateFormat.ShortTime), FormatDateTime(returnVenueClosingTime, DateFormat.ShortTime), bRace)
- ' Mark it as a conflict and exit or continue
- If sTempInternalNotice <> "" Then
- sTempNotice = sTempNotice & sTempInternalNotice
- bSiteClosed = True
- End If
- End If
- ' Display the panel
- pnlAvailability.Visible = True
- ' Sort out the message dending on the repeat status
- If bRepeat Then
- lbl_AVTitle.Text = "<b><a name='avail'>Availability</a></b>"
- ' Added to prevent silly messages getting returned,
- ' If someone has selected a monthly/weekly schedule
- ' But not put enough time into make a difference
- If intNoOfApps = 0 Then
- If intDaysClosed > 0 Then
- sDtmDisplay = "<li>There were no conflicts found.<br/>If you proceed you will only create <b>1</b> booking because the end date specified occurs before the next <b>" & ddlAP_Frequency.Items(ddlAP_Frequency.SelectedIndex).Text & "</b> occurrence would be met.<br/>No entries will be created on the <b>" & intDaysClosed & "</b> day(s) that the venue is closed during the timeframe specified."
- Else
- sDtmDisplay = "<li>There were no conflicts found.<br/>If you proceed you will only create <b>1</b> booking because the end date specified occurs before the next <b>" & ddlAP_Frequency.Items(ddlAP_Frequency.SelectedIndex).Text & "</b> occurrence would be met."
- End If
- Else
- If intDaysClosed > 0 Then
- sDtmDisplay = "<li>There were no conflicts found.<br/>If you proceed you will create a total of <b>" & intNoOfApps & "</b> repeat booking(s) which will occur on a <b>" & ddlAP_Frequency.Items(ddlAP_Frequency.SelectedIndex).Text & "</b> basis until <b>" & FormatDateTime(calAP_dtmAppointmentEnd.SelectedDate.Value.ToShortDateString, DateFormat.ShortDate) & "</b>.<br/>No entries will be created on the <b>" & intDaysClosed & "</b> day(s) that the venue is closed during the timeframe specified."
- Else
- sDtmDisplay = "<li>There were no conflicts found.<br/>If you proceed you will create a total of <b>" & intNoOfApps & "</b> repeat booking(s) which will occur on a <b>" & ddlAP_Frequency.Items(ddlAP_Frequency.SelectedIndex).Text & "</b> basis until <b>" & FormatDateTime(calAP_dtmAppointmentEnd.SelectedDate.Value.ToShortDateString, DateFormat.ShortDate) & "</b>."
- End If
- End If
- lbl_Availability.Text = sDtmDisplay
- trRepeater.Visible = False
- trProceed.Visible = True
- txt_AP_NoDrivers.Text = "0"
- btnAddClients.Enabled = True
- Else
- lbl_AVTitle.Text = "<b><a name='avail'>Availability</a></b>"
- lbl_Availability.Text = "<li>There were no conflicts found.</li>"
- trRepeater.Visible = False
- trProceed.Visible = True
- btnAddClients.Enabled = True
- End If
- ' Final check for venue closed situation
- If bSiteClosed Then
- lbl_AVTitle.Text = "<b><a name='avail'>Availability</a></b>"
- lbl_Availability.Text = "<li>There were no conflicts found, however the event is scheduled to finish <b>after the venue has closed.</b> You may proceed if you wish, but it's at your discretion.</li>"
- trRepeater.Visible = False
- trProceed.Visible = True
- btnAddClients.Enabled = True
- End If
- End If
- End With
- Else
- lbl_AVTitle.Text = "<b><a name='avail'>Availability</a></b>"
- lbl_Availability.Text = "<li>There were no conflicts found.</li>"
- trAvailability.Visible = True
- pnlAvailability.Visible = True
- trRepeater.Visible = False
- trProceed.Visible = True
- btnAddClients.Enabled = True
- End If
- ' Final catch to clean up messages
- If InStr(sTempNotice, "There is an identical event") Then
- lbl_Details.Visible = True
- Else
- lbl_Details.Visible = False
- End If
- ' Save the array
- If Not IsNothing(arrConflictDates) Then Session("arrConflictDates") = arrConflictDates
- ' Kill the connection if it's still open
- If sqlConn.State <> ConnectionState.Closed Then sqlConn.Close()
- End If
- End Using
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement