<% 'Database Variables dim conn dim rs dim ConStr dim sql dim sqlcount dim rsnum 'other variables dim bgcolor dim celltext dim curdate dim curdatetxt dim CurPage dim CurRec dim failed dim failmsg dim FinalNum dim NumPages dim RecCount dim thedate dim adate dim pdate dim ndate dim linktext 'constants const DaysInWeek = 7 const WeeksInMonth = 6 const MaxItems = 7 'initialise variables failmsg = "" CurPage = CInt(Request.QueryString("Page")) FinalNum = 0 CurRec = 0 RecCount = 0 NumPages = 0 adate = cdate(Request.QueryString("Date")) TheDate = CDate(DatePart("m",adate)&"/"&DatePart("d",adate)&"/"&DatePart("yyyy",adate)) linktext = "" ConStr = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&server.MapPath("items.mdb") set conn=Server.CreateObject("ADODB.Connection") conn.open ConStr if Request.QueryString("type") = "News" then sql = "SELECT * FROM Content WHERE Type = '"&Request.QueryString("type")&"' OR Type = 'Both' ORDER BY StartDate DESC" sqlcount = "SELECT COUNT(*) as RecCount FROM Content WHERE Type = '"&Request.QueryString("type")&"' OR Type = 'Both'" elseif Request.QueryString("type") = "Diary" then sql = "SELECT * FROM Content WHERE (Type = '"&Request.QueryString("type")&"' OR Type = 'Both') AND StartDate <= #"&TheDate&"# AND ExpiryDate >= #"&TheDate&"# ORDER BY StartDate DESC" sqlcount = "SELECT COUNT(*) as RecCount FROM Content WHERE (Type = '"&Request.QueryString("type")&"' OR Type = 'Both') AND StartDate <= #"&TheDate&"# AND ExpiryDate >= #"&TheDate&"#" end if set rsnum = Server.CreateObject("ADODB.RecordSet") rsnum.Open sqlcount, conn 'get number of records set rs = Server.CreateObject("ADODB.RecordSet") rs.Open sql, conn 'get records if not rs.BOF then 'check that there are records rsnum.MoveFirst rs.MoveFirst RecCount = cint(rsnum("RecCount")) rs.MoveFirst CurRec = MaxItems * (CurPage -1) + 1 NumPages = int(RecCount/MaxItems) + 1 FinalNum = RecCount mod MaxItems for i = 1 to CurRec-1 rs.MoveNext next else failed = true failmsg = "There are no items in this category" end if %> View <%= Request.QueryString("type") %> Items

<% if Request.QueryString("type") = "News" then %> News <% elseif Request.QueryString("type") = "Diary" then %> Diary <% end if %> Items

<% if Request.QueryString("type") = "Diary" then %> <% end if %> <% if failed then %> <% else 'show records, up to 7 at a time while ((not rs.EOF)and(CurRec <= MaxItems*CurPage)) response.Write(chr(9)&"") response.Write("") response.Write(""&chr(13)) response.Write(chr(9)&chr(9)&chr(9)&chr(9)&"") response.Write("") response.Write("") response.Write(""&chr(13)) response.Write(chr(9)&chr(9)&chr(9)&chr(9)) response.write("") response.Write(chr(13)) n = 0 for i = 1 to 3 if rs("FileName"&i) = "No Attachment" then n = n + 1 else response.Write(chr(9)&chr(9)&chr(9)&chr(9)) response.write("") response.Write(chr(13)) end if next if n = 3 then response.Write(chr(9)&chr(9)&chr(9)&chr(9)) response.Write("") response.Write(chr(13)) end if response.Write(chr(9)&chr(9)&chr(9)&chr(9)&"") response.Write("") response.Write(""&chr(13)&chr(13)&chr(9)&chr(9)&chr(9)) rs.MoveNext CurRec = CurRec + 1 wend end if %>
<% 'display a calendar, hilight the selected date curdate = cdate("1/"&DatePart("m",adate)&"/"&DatePart("yyyy",adate)) for x = 1 to WeeksInMonth if x > 1 then response.Write(chr(9)&chr(9)&chr(9)&chr(9)&chr(9)&chr(9))'formatting response.Write(chr(9)&chr(9))'formatting response.Write("") for y = 1 to DaysInWeek bgcolor="#ffffff" celltext = "" if ((Weekday(curdate) = y) and (DatePart("m",adate)=DatePart("m",curdate))) then if curdate = adate then bgcolor= "#ff0000" celltext = ""&DatePart("d",curdate)&"" curdate = DateAdd("d",1,curdate) end if response.Write(chr(13)&chr(9)&chr(9)&chr(9)&chr(9)&chr(9)&chr(9)&chr(9)&chr(9)&chr(9))'formatting response.Write("") next response.Write(chr(13)&chr(9)&chr(9)&chr(9)&chr(9)&chr(9)&chr(9)&chr(9)&chr(9))'formatting response.Write("") if x < WeeksInMonth then response.Write(chr(13))'formatting next %>
<% 'calculate next and previous dates pdate = DateAdd("m",-1,adate) ndate = DateAdd("m",1,adate) %> << <%= MonthName(DatePart("m",adate))&" "&DatePart("yyyy",adate) %> >>
Sun Mon Tue Wed Thu Fri Sat
"&celltext&"

 

<%= failmsg %>
Title: "&rs("Title")&"
Details: "&rs("Header")&"
Attachments
"&rs("FileName"&i)&"
No attached files.
 
Pages: <% 'split up the records shown into pages for i = 1 to NumPages if i > 1 then response.Write(", ") if i = CurPage then response.Write(cstr(i)) else linktext = ""&cstr(i)&"" if Request.QueryString("type") = "Diary" then linktext = linktext & "&Date="&adate end if response.Write(linktext) end if next 'clean up rs.Close set rs = nothing rsnum.Close set rsnum = nothing conn.Close set conn = nothing %>

Main Page

Add Item