Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2004, 10:33 AM
Authorized User
 
Join Date: Jun 2003
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default booking system: first time using dates

Hi everybody

This is the code ive written for a simple appointment booking system. Its the first time ive used dates so if somebody could point out any mistakes ive made that would be appreciated.

Ive not tried running the script yet as the servers here haven't been configued propery yet. issues with permissions and all that :(

everyday is broken into 5 slots and it displays 1 month from the current date (hopefully).

The function isWeekDay is at the bottom of the code

Cheers, oh if anybody wants to use any of this stuff, by all means go ahead. Just dont blame me if your head explodes ;)

Cheers
Andy


<%

Dim dtToday, dtMonth, dtYear, objRS, objConn, sSQL, dtApptDay
' Get the current (start) date and 1 month in the future (finish date)
dtSDate = Date()
dtFDate = DateAdd("m", 1, dtSDate)

'find the number of days between these 2 dates for use later
numDays = DateDiff("d", dtSDate, dtFDate)

'make the RS
Set objConn = CreateObject("ADODB.Connection")
objConn.Open conn

'im using access, this query seems to work ok
Set objRS = CreateObject("ADODB.RecordSet")
sSQL = "SELECT Slot_id, Slot_Num, Slot_Date, Name, Email FROM Slots" & _
         "WHERE year(Slot_Date) = year(" & dtSDate & ") AND Month(Slot_Date) = Month(" & dtSDate & ") AND Month(Slot_Date) = Month(" & dtFDate & ")" & _
         "ORDER BY Slot_Date, Slot_Num;"
objRS.Open sSQL, objConn

%>

<html>
<head>
<style>

.appointments {
border: 1px solid #000000;
border-collapse: collapse;
}
.appointments td {
padding: 0.3em;
}

.even td {
border-bottom: 1px solid #cccccc;
background-color: #000000;
color: #ffffff;
}
.vertical {
writing-mode: tb-rl;
font-size: 2em;
background-color: #cccccc;
}
</style>
</head>
<body>


<h1>IT Officer Appointments</h1>

<p> To make an appointment more than 1 month in advance please Call Andrew on ext: 313.</p>


<table class="appointments">
<tr>
    <td>&nbsp;</td>
    <th>09:10 - 10:20</th>
     <td rowspan="6" class="vertical"> Break </td>
    <th>10:40 - 11:50</th>
    <th>11:50 - 13:00</th>
     <td rowspan="6" class="vertical"> Lunch </td>
    <th>14:00 - 15:10</th>
    <th>15:10 - 16:20</th>
</tr>


<%

dtApptDay = dtSDate

For x = 0 to numDays

blWeekDay = isWeekDay(dtApptDay)

If blWeekDay = False Then

    Response.Write "<tr><td> Weekend </td></tr>"

Else

    Response.Write "<tr>"
    Response.Write "<td>" & WeekDayName(WeekDay(dtApptDay)) & "</td>"

    For i = 1 to 5

     Response.Write "<td>"

     if objRS("Slot_Num") = i AND CDate(objRS("Slot_Date")) = dtApptDay Then

    ' write data from RS
    ' objRS.MoveNext

     Else

        Response.Write "<a href=""appt_make.asp?slotNum=" & i & "&apptDate=" & dtApptDay & chr(34) & ">available</a>" ' Note: chr(34) is the speach mark character

     End If

     Response.Write "</td>"

    Next

    Response.Write "</tr>"

End If

dtApptDay = DateAdd("d", 1, dtApptDay)

Next
%>

</table>
</body>
</html>






<%
' -------- functions go below here ----------

' Untested: pass a date into the the function and response.write the result to screen. True = mon-fri, False = sat/Sun

Function isWeekDay(dDay)

dDay = weekday(dDay)

Select Case dDay

Case 1, 7
    isWeekDay = False

Case else
    isWeekDay = True

End Select

End Function
%>
 
Old October 13th, 2004, 09:03 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

When you get it running and find 'specific problems' that would be the best time to use the very helpful peoples time on this forum

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
booking system newbie07 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 July 19th, 2007 04: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
What's the logic behind this Hotel Booking system? ivanhalen Classic ASP Professional 0 September 23rd, 2005 06:41 PM
Access 97 and a booking system narelleallen Access 2 June 24th, 2004 10:04 AM
Celendar Booking System acdsky Classic ASP Basics 0 March 31st, 2004 02:42 AM





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