Visualizzazione dei risultati da 1 a 7 su 7

Discussione: Errore calendario

  1. #1

    Errore calendario

    Salve, mi capita un erroer strano... ho messo on line questo script calendario e funziona perfettamente, l'ho messo sul mio sito e mi da uno strano errore, non mi visualizza tutti i giorni... non ho cambiato niente... come mai?

    Grazie

    Questo il codice:




    <%

    Function GetLastDay(intMonthNum, intYearNum)
    Dim dNextStart
    If CInt(intMonthNum) = 12 Then
    dNextStart = CDate( "1/1/" & intYearNum)
    Else
    dNextStart = CDate(intMonthNum + 1 & "/1/" & intYearNum)
    End If
    GetLastDay = Day(dNextStart - 1)
    End Function

    '-------------------------------------------------------------------------
    ' This routine prints the individual table divisions for days of the month
    '-------------------------------------------------------------------------
    Sub Write_TD(sValue, sClass)
    Response.Write " <TD ALIGN='RIGHT' WIDTH=20 HEIGHT=15 VALIGN='BOTTOM' CLASS='" & sClass & "'> " & sValue & "</TD>" & vbCrLf
    End Sub


    ' Constants for the days of the week
    Const cSUN = 1, cMON = 2, cTUE = 3, cWED = 4, cTHU = 5, cFRI = 6, cSAT = 7

    ' Get the name of this file
    sScript = Request.ServerVariables("SCRIPT_NAME")

    ' Check for valid month input
    If IsEmpty(Request("MONTH")) OR NOT IsNumeric(Request("MONTH")) Then
    datToday = Date()
    intThisMonth = Month(datToday)
    ElseIf CInt(Request("MONTH")) < 1 OR CInt(Request("MONTH")) > 12 Then
    datToday = Date()
    intThisMonth = Month(datToday)
    Else
    intThisMonth = CInt(Request("MONTH"))
    End If

    ' Check for valid year input
    If IsEmpty(Request("YEAR")) OR NOT IsNumeric(Request("YEAR")) Then
    datToday = Date()
    intThisYear = Year(datToday)
    Else
    intThisYear = CInt(Request("YEAR"))
    End If

    strMonthName = MonthName(intThisMonth)
    datFirstDay = DateSerial(intThisYear, intThisMonth, 1)
    intFirstWeekDay = WeekDay(datFirstDay, vbSunday)
    intLastDay = GetLastDay(intThisMonth, intThisYear)

    ' Get the previous month and year
    intPrevMonth = intThisMonth - 1
    If intPrevMonth = 0 Then
    intPrevMonth = 12
    intPrevYear = intThisYear - 1
    Else
    intPrevYear = intThisYear
    End If

    ' Get the next month and year
    intNextMonth = intThisMonth + 1
    If intNextMonth > 12 Then
    intNextMonth = 1
    intNextYear = intThisYear + 1
    Else
    intNextYear = intThisYear
    End If

    ' Get the last day of previous month. Using this, find the sunday of
    ' last week of last month
    LastMonthDate = GetLastDay(intLastMonth, intPrevYear) - intFirstWeekDay + 2
    NextMonthDate = 1

    ' Initialize the print day to 1
    intPrintDay = 1

    ' Open a record set of schedules
    Set Rs = Server.CreateObject("ADODB.RecordSet")

    ' These dates are used in the SQL
    dFirstDay = intThisMonth & "/1/" & intThisYear
    dLastDay = intThisMonth & "/" & intLastDay & "/" & intThisYear

    sSQL = "SELECT DISTINCT Start_Date, End_Date FROM tEvents WHERE " & _
    "(Start_Date >=#" & dFirstDay & "# AND Start_Date <= #" & dLastDay & "#) " & _
    "OR " & _
    "(End_Date >=#" & dFirstDay & "# AND End_Date <= #" & dLastDay & "#) " & _
    "OR " & _
    "(Start_Date < #" & dFirstDay & "# AND End_Date > #" & dLastDay & "# )" & _
    "ORDER BY Start_Date"
    'Response.Write sSQL

    ' Open the RecordSet with a static cursor. This cursor provides bi-directional navigation
    Rs.Open sSQL, sDSN, adOpenStatic, adLockReadOnly, adCmdText
    %>


    <table ALIGN="center" BORDER="0" CELLSPACING="1" CELLPADDING="2" BGCOLOR="#000000">
    <tr><td bgcolor="#FFFFFF">
    <table WIDTH="140" BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#FFFFFF">
    <tr HEIGHT="18" BGCOLOR="#E9E9E9">
    <td WIDTH="20" HEIGHT="18" ALIGN="LEFT" VALIGN="MIDDLE">[img]public/calendario/images/prev.gif[/img]</td>
    <td WIDTH="120" COLSPAN="5" ALIGN="CENTER" VALIGN="MIDDLE" CLASS="SOME"><% = strMonthName & " " & intThisYear %></td>
    <td WIDTH="20" HEIGHT="18" ALIGN="RIGHT" VALIGN="MIDDLE">[img]public/calendario/images/next.gif[/img]</td>
    </tr>
    <tr bgcolor="#FFFFFF">

    <td WIDTH="20" HEIGHT="15" ALIGN="RIGHT" VALIGN="BOTTOM" CLASS="SOME">D</td>

    <td WIDTH="20" HEIGHT="15" ALIGN="RIGHT" VALIGN="BOTTOM" CLASS="SOME">L</td>

    <td WIDTH="20" HEIGHT="15" ALIGN="RIGHT" VALIGN="BOTTOM" CLASS="SOME">M</td>

    <td WIDTH="20" HEIGHT="15" ALIGN="RIGHT" VALIGN="BOTTOM" CLASS="SOME">M</td>

    <td WIDTH="20" HEIGHT="15" ALIGN="RIGHT" VALIGN="BOTTOM" CLASS="SOME">G</td>

    <td WIDTH="20" HEIGHT="15" ALIGN="RIGHT" VALIGN="BOTTOM" CLASS="SOME">V</td>
    <td WIDTH="20" HEIGHT="15" ALIGN="RIGHT" VALIGN="BOTTOM" CLASS="SOME">S</td>
    </tr>
    <tr><td HEIGHT="1" ALIGN="MIDDLE" COLSPAN="7">[img]images/line.gif[/img]</td></tr>
    <%
    ' Initialize the end of rows flag to false
    EndRows = False
    Response.Write vbCrLf

    ' Loop until all the rows are exhausted
    Do While EndRows = False
    ' Start a table row
    Response.Write " <TR>" & vbCrLf
    ' This is the loop for the days in the week
    For intLoopDay = cSUN To cSAT
    ' If the first day is not sunday then print the last days of previous month in grayed font
    If intFirstWeekDay > cSUN Then
    Write_TD LastMonthDate, "NON"
    LastMonthDate = LastMonthDate + 1
    intFirstWeekDay = intFirstWeekDay - 1
    ' The month starts on a sunday
    Else
    ' If the dates for the month are exhausted, start printing next month's dates
    ' in grayed font
    If intPrintDay > intLastDay Then
    Write_TD NextMonthDate, "NON"
    NextMonthDate = NextMonthDate + 1
    EndRows = True
    Else
    ' If last day of the month, flag the end of the row
    If intPrintDay = intLastDay Then
    EndRows = True
    End If

    dToday = CDate(intThisMonth & "/" & intPrintDay & "/" & intThisYear)
    If NOT Rs.EOF Then
    ' Set events flag to false. This means the day has no event in it
    bEvents = False
    Do While NOT Rs.EOF AND bEvents = False
    ' If the date falls within the range of dates in the recordset, then
    ' the day has an event. Make the events flag True
    If dToday >= Rs("Start_Date") AND dToday <= Rs("End_Date") Then
    ' Print the date in a highlighted font
    Write_TD "<A HREF=public/calendario/events.asp?date="& Server.URLEncode(dToday) & " CLASS='EVENT' TARGET='blank'> " & intPrintDay & "</A>", "HL"
    bEvents = True
    ' If the Start date is greater than the date itself, there is no point
    ' checking other records. Exit the loop
    ElseIf dToday < Rs("Start_Date") Then
    Exit Do
    ' Move to the next record
    Else
    Rs.MoveNext
    End If
    Loop
    ' Checks for that day
    Rs.MoveFirst
    End If

    ' If the event flag is not raise for that day, print it in a plain font
    If bEvents = False Then
    Write_TD "<A HREF=public/calendario/events.asp?date="& Server.URLEncode(dToday) & " CLASS='NOEVENT' TARGET='blank'> " & intPrintDay & "</A>", "SOME"
    End If
    End If

    ' Increment the date. Done once in the loop.
    intPrintDay = intPrintDay + 1
    End If

    ' Move to the next day in the week
    Next
    Response.Write " </TR>" & vbCrLf

    Loop
    Rs.Close
    Set Rs = Nothing
    %>
    </table>
    </td></tr>
    </table>


    <div align=center>

    </div>
    La vita è come una scatola di cioccolatini...non sai mai quello che ti capita!

  2. #2
    Non avrai esagerato a postare tutto quel codice?

    Qualche consiglio:

    1. Cerca prima di identificare l'errore
    2. Posta soltanto la porzione realmente interessata all'errore
    3. usa il tag CODE per racchiudere il codice

    bye

  3. #3
    Originariamente inviato da j0tt0
    Non avrai esagerato a postare tutto quel codice?

    NO, c'è di peggio su altri post..kilometrici
    Se ti da fastidio basta nn leggere.. semplice no?

    bye
    La vita è come una scatola di cioccolatini...non sai mai quello che ti capita!

  4. #4
    Beh se andiamo per assoluto, nella vita c'e' sempre di peggio ma personalmente cerco di tendere al meglio.
    Per quanto riguarda i miei consigli, erano rivolti soltanto a darti qualche dritta su come usare il Forum, diversamente penso che non riceverai molte risposte.

    bye

  5. #5


    Ma vaaaaaaaaaa...

    La vita è come una scatola di cioccolatini...non sai mai quello che ti capita!

  6. #6
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Certo forrest che se avessi usato almeno il tag CODE non avresti fatto un soldo di danno...
    Detto questo, fatti stampare separatamente se riesci giorno, mese e anno per vedere se li interpreta bene.

    Roby

  7. #7
    Non l'avevo mai visto sto tag Code

    Thanks ora provo
    La vita è come una scatola di cioccolatini...non sai mai quello che ti capita!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.