반응형

Calendar.zip



<%

Function FixNull(v)
if isNull(v) then
 FixNull = ""
Else
 FixNull = v
End If
End Function

Function NameFromMonth(iMonth)
'There is an ASP function called
'NameFromMonth that does this,
'but it does not seem to
'work in all cases
select case cint(iMonth)
case 1
s = "January"
case 2
s = "February"
case 3
s = "March"
case 4
s = "April"
case 5
s = "May"
case 6
s = "June"
case 7
s = "July"
case 8
s = "August"
case 9
s = "September"
case 10
s = "October"
case 11
s = "November"
case 12
s = "December"
end select
NameFromMonth = s
End Function

Function LastDay(testYear, testMonth)

    LastDay = Day(DateSerial(testYear, testMonth + 1, 0))
End Function


Function GetPrevMonth(iThisMonth,iThisYear)
GetPrevMonth=month(dateserial(iThisYear,iThisMonth,1)-1)
End Function

Function GetPrevMonthYear(iThisMonth,iThisYear)
GetPrevMonthYear=Year(dateserial(iThisYear,iThisMonth,1)-1)
End Function

Function GetNextMonth(iThisMonth,iThisYear)
GetNextMonth=month(dateserial(iThisYear,iThisMonth+1,1))
End Function

Function GetNextMonthYear(iThisMonth,iThisYear)
GetNextMonthYear=year(dateserial(iThisYear,iThisMonth+1,1))
End Function

 

%>
<html>

<head>
<SCRIPT LANGUAGE='javascript'>
function showevent (ID)
{
window.open("ShowEventDetails.asp?ID=" + ID, "nw",'titlebar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=120,left=200,width=400,height=300')

}
</SCRIPT>
<title>Calendar</title>
</head>

<body>

 <%
iMonth=Request.QueryString ("Month")
iYear=Request.QueryString ("Year")
if  trim(iMonth)  = "" then iMonth = Month(Now)
sMonth=NameFromMonth(iMonth)
if trim(iYear) = "" then iYear = Year(Now)

  Response.Write ("<center><b><font size='3' FACE='Arial,Helvetica'> ")
  Response.Write ("<a href='default.asp?month=" & GetPrevMonth(iMonth,iYear) & "&year=" & GetPrevMonthYear(iMonth,iYear) & "'><<</a>" & "&nbsp;&nbsp;&nbsp;&nbsp;")
  Response.Write ( sMonth & ", " & iYear & "&nbsp;&nbsp;&nbsp;&nbsp;" )
  Response.Write ("<a href='default.asp?month=" & GetNextMonth(iMonth,iYear) & "&year=" & GetNextMonthYear(iMonth,iYear) & "'>>></a><br></b></font><br>")
      %>

        <table border="1">
          <tr>
            <td width="70" bgcolor="#FFFF99" height="16"><font color="#000000"><b>Sun</b></font></td>
            <td width="70" bgcolor="#FFFF99" height="16"><font color="#000000"><b>Mon</b></font></td>
            <td width="70" bgcolor="#FFFF99" height="16"><font color="#000000"><b>Tue</b></font></td>
            <td width="70" bgcolor="#FFFF99" height="16"><font color="#000000"><b>Wed</b></font></td>
            <td width="70" bgcolor="#FFFF99" height="16"><font color="#000000"><b>Thu</b></font></td>
            <td width="70" bgcolor="#FFFF99" height="16"><font color="#000000"><b>Fri</b></font></td>
            <td width="70" bgcolor="#FFFF99" height="16"><font color="#000000"><b>Sat</b></font></td>
          </tr>
<!--#include file = "database.inc"-->
          <%
           i = 0
          iLastDay = LastDay(iYear, iMonth)
          iFirstDay=  Weekday(CDate(imonth & "/01/" & iYear))
          iLastDay = iFirstDay + iLastDay - 1

          do while i<= iLastDay
   if i <> iLastDay then
   Response.Write ("<tr>")
   else
   exit do
   end if
   for j=1 to 7

    if (j < iFirstDay and i = 0) or (i + j > iLastDay)  then

     Response.Write ("<td width='90' height='75' valign='top' bgcolor='#D5D5D5' NOWRAP></td>")
    else
     k =  k + 1
     sDate = "#" & iMonth & "/" & k & "/" & iYear & "#"
     set rs = conn.execute("SELECT * FROM EVENTS WHERE DATE = " & sDate)
     if rs.eof then
      sHREF = "AddEvent.asp"
      sEvent = ""
     else
      sHREF = "EditEvent.asp"
      sEvent = "&nbsp;<P><FONT SIZE=-2 FACE='Arial,Helvetica'><A HREF = 'javascript:showevent(" & rs("ID") & ")'>" & rs("Description") & "</A><BR>"
      if FixNull(rs("Time")) <> "" then sEvent = sEvent & rs("Time") & "<BR>"
      if FixNull(rs("Location")) <> "" then sEvent = sEvent & rs("Location")
      sEvent = sEvent & "</FONT>"
     End If
     sHREF = sHREF & "?Month=" & iMonth & "&Day=" & k & "&Year=" & iYear
     
     If j=1 Then
      If Trim(iYear) = Trim(year(date)) and Trim(iMonth) = Trim(month(date)) And Trim(k) = Trim(day(date)) Then
      Response.Write ("<td width='90' height='75' valign='top' bgcolor='#FAED7D'>")
      else
      Response.Write ("<td width='90' height='75' valign='top' bgcolor='#FF7E7E'>")
      End If
     elseif  j=7 Then
      If Trim(iYear) = Trim(year(date)) and Trim(iMonth) = Trim(month(date)) And Trim(k) = Trim(day(date)) Then
      Response.Write ("<td width='90' height='75' valign='top' bgcolor='#FAED7D'>")
      else
      Response.Write ("<td width='90' height='75' valign='top' bgcolor='#9DCEFF'>")
      End If
     ElseIf Trim(iYear) = Trim(year(date)) and Trim(iMonth) = Trim(month(date)) And Trim(k) = Trim(day(date)) Then
     Response.Write ("<td width='90' height='75' valign='top' bgcolor='#FAED7D'>")
     else
     Response.Write ("<td width='90' height='75' valign='top'>")
     End If
     
     Response.Write "<B>"
     Response.Write "<A HREF = '" & sHREF & "'>"
     Response.write k & "</A></B>" & sEvent

     Response.Write ("</td>")
    end If
   

   next
   i=i+7

          loop
          Response.Write ("</tr>")
          %>
<!--#include file = "database_cleanup.inc"-->
</table>
</body>

</html>

반응형
Posted by ThinkPad War
,