CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Nice Event Calendar

Print topic Send  topic

Author Message
Sean

Posts: 39
Posted: 04/02/2004, 7:12 AM

I found a pretty nice open source event calendar here: http://authors.aspalliance.com/mamanze/articles/?p=events

I set it up on my Intranet and it works pretty good as-is, but when I tried to put into CodeCharge Studio, I get an error due to the <% Option Explicit %> . When I take that out, the calendar really messes up.

I was wondering if someone could build it in CodeCharge Studio.

The .mdb

ID
EventDate
EventTitle
EventImage (255 char)

The Code - calendar.asp

<% Option Explicit %>
<html>
<head>
<style type="text/css">
<!--
table {border:2px solid #999999; border-collapse;collapse;}
td {border:1px solid #999999; border-collapse:collapse;}
-->
</style>
</head>
<body>
<%

dim objConn, objRS, objRSQuery
dim intCurrentDay, intDays, intWeekDay, intMonth, intYear, intEventCounter, i, intEventCount, intOffset, intEnd
dim dtmTemp
dim strSQL, strConn
dim arrEvents

' Simple oledb connection string to the database that's in the same directory.
strConn ="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("events.mdb")

' Which month do we want to look at?
intMonth = Request("Month")
' Which year do we want to look at?
intYear = Request("Year")

' If no value for the month was passed show the current month
If intMonth ="" Then
intMonth = Month(Date())
End If

' If no value for the year was passed show the current year.
If intYear ="" Then
intYear = Year(Date())
End If

' This SQL statement will grab all the pertinent information for the events this month.
strSQL ="Select id,DatePart(""d"",Eventdate) as EventDay, EventImage, EventTitle " & _
"From Events " & _
"Where DatePart(""yyyy"",EventDate) = " & CInt(intYear) & _
" AND DatePart(""m"",EventDate) = " & CInt(intMonth)

' Open up the connection and recordset, then grab all the events for this month.
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.RecordSet")

Call objConn.Open(strConn)

Call objRS.Open(strSQL, objConn)

If objRS.EOF Then
intEventCount = -1
Else
arrEvents = objRS.GetRows
intEventCount = UBound(arrEvents,2)
End If
Call objRS.Close()

Call objConn.Close()

Set objRS = Nothing
Set objConn = Nothing

' A temporary date value that holds the first day of the next month.
dtmTemp = CDate(intMonth mod 12 + 1 &"/1/" & intYear)

' Number of days in the month. We subtract one from the above temporary date and we arrive at the
' end of this month.
intDays = Day(DateAdd("d",-1,dtmTemp))

' Weekday at the start of the month.
' IE: It will be 1 for monday, 2 for tuesday...
intWeekDay = WeekDay(CDate(intMonth &"/1/" & intYear))

' Print out the links to the next months and the name of this month.
Call Response.Write("<table border=1 cellspacing=0 cellpadding=2 align=""center"">" & vbCrLf & _
" <tr>" & vbCrLf & _

" <td align=""center""><a href=""calendar.asp?month=" & (((intMonth + 10) mod 12) + 1) & _
"&year=" & Year(CDate(DateAdd("m",-1,intMonth &"/1/" & intYear))) & _
""">Previous</a></td>" & vbCrLf & _

" <td align=""center"" colspan=""5""><font size=""4""><b>Events for " & _
MonthName(intMonth) &" " & intYear &"</b></font></td>" & vbCrLf & _

" <td align=""center""><a href=""calendar.asp?month=" & ((intMonth mod 12) + 1) & _
"&year=" & Year(CDate(DateAdd("m",1,intMonth &"/1/" & intYear))) & _
""">Next</a></td>" & vbCrLf & _

" <tr>" & vbCrLf)
' Print out the names of the days (Monday, Tuesday...)
For i=1 to 7
Response.Write" <td align=""center""><font size=3><b>" & WeekDayName(i,True) &"</b></font></td>" & vbCrLf
Next'i'

Call Response.Write(" </tr>" & vbCrLf)

' Set the event counter to zero so it points to the first event in the array.
intEventCounter = 0

' This is the "Day of the Week" integer that corresponds to the beginning of the month.
intOffset = intWeekday - 1

' This corresponds to the end of the month. Basically divide it by 7 and if there is a remainder,
' add 1 to get the number of weeks we are printing.
intEnd = intWeekday + intDays

' Loop through. Maximum, each month can span 6 weeks, so we only need loop to 42.
For i=1 to 42
' Figure the day we will be writing out. If this is negative then we ignore it.
intCurrentDay = i - intOffset

' Are we at the beginning of a week? If so, i will divide evenly by 7.
If (i mod 7) = 1 Then
Call Response.Write(" <tr>" & vbCrLf)
End If

' If we are within the calendar month, then...
If i >= intWeekday AND i < intEnd Then

' If there are events still for this month. This just saves some processing time.
If intEventCounter <= intEventCount Then

' If the event currently at the head of the stack is on the day we are currently printing, then show it.
If intCurrentDay = arrEvents(1,intEventCounter) Then
' Print out the cell with the date number in it.
Call Response.Write(" <td height=""80"" width=""80"" bgcolor=""#FFEEDD"" valign=""top"" wrap>" & _
"<font size=""1"">" & intCurrentDay &"</font>")

' Loop through the events for that day and print them out. We know they are for that day
' because their "EventDay" is the same as the day we are printing.
Do While arrEvents(1,intEventCounter) = (i-intOffset)
Call Response.Write("<br><font size=""2""><font color=""#006699"">" & _
(arrEvents(2,intEventCounter)) & _
"</font> " & FormatHTML(arrEvents(3,intEventCounter)) &"</font>" & vbCrLf)
' If we have reached the end of the array then quit, this is to prevent an out of bound error.
If intEventCounter = intEventCount Then
Exit Do
End If

' Increment the event counter so that we go to the next event in the array.
intEventCounter = intEventCounter + 1
Loop
Call Response.Write("</td>" & vbCrLf)
Else
' If there are no events for this day, then print out an empty cell.
Call Response.Write(" <td height=""100"" width=""100"" bgcolor=""#FFFFFF"" valign=""top"">" & _
"<font size=""1"">" &" " & intCurrentDay &"</font></td>" & vbCrLf)
End If
Else
' If there are no events for this day, then print out an empty cell.
Call Response.Write(" <td height=""100"" width=""100"" bgcolor=""#FFFFFF"" valign=""top"">" & _
"<font size=""1"">" &" " & intCurrentDay &"</font></td>" & vbCrLf)
End If
Else
' Otherwise print out a grey cell. This happens when we are outside of the month.
Call Response.Write(" <td height=""100"" width=""100"" bgcolor=""#EEEEEE"" valign=""top"">" & _
" </td>" & vbCrLf)
End If
' If this is the end of a week then end the table row.
' Also, check to see if we need to print another row, if not then quit the for loop.
If (i mod 7) = 0 Then
Call Response.Write(" </tr>" & vbCrLf)
If i >= (intDays + intWeekDay)-1 Then
Exit For
End If
End If
Next'i'
Call Response.Write("</table>" & vbCrLf)

Function FormatHTML(byVal x)
dim strReturn
strReturn = Replace(x,"''","'")
strReturn = Replace(x,vbCrLf,"<br>")
FormatHTML = strReturn
End Function
%>
</body>
</html>
View profile  Send private message
ryan

Posts: 41
Posted: 04/04/2004, 10:59 PM

http://www13.brinkster.com/charmangel/testproject/event...sr_Calendar.asp

Yup it's possible... And CCS lets you expedite freely, and uniquely...

I didn't finish this design/development though, let your imagination and creativeness rule!
_________________
(\__/)
(='.'=)
(")_(")
View profile  Send private message
Theunis
Posted: 08/23/2005, 11:52 AM

Hi Ryan, I would really be interested in how you implemented the solution can you give me a shout on webmaster at samusic.co.za please?

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.