%@ LANGUAGE="VBScript" %> <% Session.LCID = 2057 'Option Explicit set my_conn= Server.CreateObject("ADODB.Connection") my_Conn.Open DBCon Function FormatStr(String) on Error resume next String = Replace(String, CHR(13), "") String = Replace(String, CHR(10) & CHR(10), "
")
String = Replace(String, CHR(10), "
")
FormatStr = String
End Function
Dim dtToday
dtToday = Date()
Dim dtCurViewMonth ' First day of the currently viewed month
Dim dtCurViewDay ' Current day of the currently viewed month
Dim frmDate ' Date submitted by form
' if the GO button was used, build the date from the month and year
If InStr(1, Request.Form, "subGO", 1) > 0 then
if Request.Form("CURDATE_month") = "" then
tmpMonth = month(now())
else
tmpMonth = Request.Form("CURDATE_month")
End If
if Request.Form("CURDATE_year") = "" then
tmpyear = year(now())
else
tmpyear = Request.Form("CURDATE_year")
End If
tmpDate = "1 " & tmpMonth & " 1999"
mnth = Month(tmpDate)
frmDate = DateSerial(tmpyear, mnth, 1)
Else
frmDate = Request.Form("CURDATE")
end if
if Request("view_date") <> "" then
frmDate= DateSerial(year(Request("view_date")), month(Request("view_date")), 1)
end if
%>
<% REM This section defines functions to be used later on. %>
<% REM This sets the Previous Sunday and the Current Month %>
<%
'--------------------------------------------------
Function DtPrevSunday(ByVal dt)
Do While WeekDay(dt) > vbSunday
dt = DateAdd("d", -1, dt)
Loop
DtPrevSunday = dt
End Function
'--------------------------------------------------
%>
<%REM Set current view month from posted CURDATE, or
' the current date as appropriate.
' if posted from the form
' if prev button was hit on the form
If InStr(1, Request.Form, "subPrev", 1) > 0 Then
dtCurViewMonth = DateAdd("m", -1, frmDate)
' if next button was hit on the form
ElseIf InStr(1, Request.Form, "subNext", 1) > 0 Then
dtCurViewMonth = DateAdd("m", 1, frmDate)
' anyother time
Else
' date add in text box
If InStr(1, Request.Form, "subGO", 1) > 0 then
dtCurViewMonth = frmDate
Else
if Request("view_date") <> "" then
dtCurviewMonth = frmDate
else
dtCurViewMonth = DateSerial(Year(dtToday), Month(dtToday), 1)
End If
End If
End If
%>
<% REM --------BEGINNING OF DRAW CALENDAR SECTION-------- %>
<% REM This section executes the event query and draws a matching calendar. %>
<%
Dim iDay, iWeek, sFontColor, dictDte(31,2), intCount
strSql = "SELECT * FROM diary WHERE month(dte)= " & month(dtCurViewMonth) & " and year(dte) = " & year(dtCurViewMonth) & " order by dte"
set rs = my_conn.Execute (StrSql)
intCount= 0
' populate array with days of month
on Error resume next
do until rs.EOF
if intCount > 31 then exit do
if Day(rs("dte")) = intCount + 1 then
dictDte(intCount, 1) = rs("text_field")
rs.Movenext
Else
dictDte(intCount, 1) = " "
End If
dictDte(intCount, 2) = intCount + 1
intCount = intCount + 1
loop
%>