Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 21st, 2007, 04:03 AM
Registered User
 
Join Date: Nov 2006
Location: Newport Pagnell, Bucks, United Kingdom.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Appointment Booking Problem

Hi,

Could you please prevent me from going mad and re-assure me that it is actually possible to make a booking for the last hour of a given day using the Chapter 10 Appointment Booker.
When I try it, the wizard always says that the time is unavailable.
I have tried this using the code direct from the CD and the modified code from the download site.

Thanks,

Lawrence.
  #2 (permalink)  
Old February 21st, 2007, 01:42 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Lawrence,

I just tried it and I ran into the same problem. I then changed the settings to allow booking from 0:00 through 23:00 and then it worked.
Of course this is not ideal as it allows users to make an appointment starting at 0:00 as well.

However, it may give you an idea where to look for a fix. I'll look into it myself as well, but I am pretty occupied at the moment so I can't look now. Send me a reminder if you think I am taking too long and you can't fix it yourself easily....

Cheers,

Imar
  #3 (permalink)  
Old February 22nd, 2007, 03:51 AM
Registered User
 
Join Date: Nov 2006
Location: Newport Pagnell, Bucks, United Kingdom.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

Thanks for the re-assurance that its not just me on this one. I'll try & find the problem although I'm new to ASP so you or someone else on this forum may well find it first.

Cheers,

Lawrence.
  #4 (permalink)  
Old February 24th, 2007, 08:55 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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?
  #5 (permalink)  
Old February 26th, 2007, 04:39 AM
Registered User
 
Join Date: Nov 2006
Location: Newport Pagnell, Bucks, United Kingdom.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

Thanks for looking into this one, I had been looking myself and found that I couldn't book the last appointment of any given day, even if it wasn't the 23:00 slot, so I modified the CheckAvailability stored procedure as shown:

from:

     DATEPART(hh, @endDate) <= DATEPART(hh, BookingObject.EndTime)

to:

     DATEPART(hh, @endDate) <= (DATEPART(hh, BookingObject.EndTime)+1)

This seemed to work. I will try your fix also and see how I get on.

Thanks again,

Lawrence.
  #6 (permalink)  
Old February 26th, 2007, 07:00 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You're welcome....

Imar
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Appointment Booking KDSTECH BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 11 May 29th, 2008 12:46 AM
Appointment booking philblack1 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 January 25th, 2008 01:17 PM
Appointment Booking System newbie07 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 July 18th, 2007 08:32 AM
Appointment Booking problem outofwork BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 42 May 15th, 2007 04:56 PM
Modifications to Appointment Booking... mkumar BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 7 March 31st, 2007 01:51 AM



All times are GMT -4. The time now is 12:24 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.