Hi Lawrence,
I looked into the code and found the problem. The stored procedure sprocAppointmentCheckAvailability looks at the start and end date to determine whether a specific booking object is available or not. It also looks at the end and start date of the appointment, and when both have different dates, the appointment is assumed to cross midnight. (Look in the comments in the procedure and you'll see what I mean). However, when you start an appointment at 23:00 hour which lasts and hour, the end date is *at the next day*. E.g.:
Start: 3/11/2007 11:00:00 PM
End: 3/12/2007 12:00:00 AM
This in turn causes all kinds of problems in the procedure.
One way to fix it is to subtract one second from the end date, bringing it back on the current day. This is the revised code for the wizAppointment_FinishButtonClick method in CreateAppointment.aspx:
Code:
If ValidateAllSteps() Then
' All steps valid. Create a new Appointment, check if it can be made and then finalize it.
wizAppointment.Visible = False
Dim myAppointment As New Appointment()
myAppointment.StartDate = _
calStartDate.SelectedDate.AddHours(hpTime.SelectedHour)
myAppointment.EndDate = _
myAppointment.StartDate.AddHours(Convert.ToInt32( _
lstDuration.SelectedValue)).AddSeconds(-1)
myAppointment.BookingObjectId = _
Convert.ToInt32(lstBookingObject.SelectedValue)
myAppointment.Comments = _
Server.HtmlEncode(txtComments.Text)
I haven't tested this extensively, so you may run into problems where other appointments appear not to overlap where in reality they do. If you experience problems like that, you may be able to do the same trick in the stored procedure, but only temporarily to a temp variable.
Hope this helps,
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of
ASP.NET 2.0 Instant Results and
Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to:
Praise You by
Fatboy Slim (From the album:
You've Come a Long Way, Baby)
What's This?