ciao a tutti.
ho un problema con un calendario eventi.
in sostanza io inserisco gli eventi nel db riferiti ad un tale giorno, e fin qua tutto ok.
il problema è che se li inserisco dal giorno 10 in su... poi sul calendario i giorni risultano avere un evento dal giorno 1 al giorno 9 anche se l'evento esiste nel calendario non vengono segnalati.
credo che il problema stia nel fatto che nel db vengono memorizzati come 01 02 eccetera mentre nel calendario come 1 2 eccetera... posto il codice, che ovviamente non è mio ed è un po lungo...
pagina delle funzioni: e nella riga in rosso cè il punto dove legge i giorni con evento:
questa è dove inserisco gli eventi:codice:<% TableWidth = 160 BgColor = "#cccccc" CellColor = "#E2E2E2" dbName = "/mdb-database/calendar.mdb" Conn= "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & Server.MapPath(dbName) EditImage = "<font face=WingDings>" & chr(50) & "</font>" DeleteImage = "<font face=WingDings>" & chr(251) & "</font>" ToTopImage = "<font face=WingDings>" & chr(241) & "</font>" '*ToTopimage = "<img border=0 src=up.gif>" Session.LCID = 1040 '************************************************ '***** FUNCTIONS ********* '************************************************ Sub DisplayCalendar(mMonth, yYear) dDay = DateSerial(yYear,mMonth,1) mMonth = Month(dDay) yYear = Year(dDay) FirstDayOfMonth = Weekday(dDay) '## Display the Top of Calendar ## CALL DisplayCalendarTop(dDay) '## Start Displaying the Actual Calendar ## Response.Write "<Table Align=center width=" & TableWidth & " CellPadding=1 CellSpacing=1 Border=0 BgColor=" & BgColor & ">" & vbCrlf Response.Write "<TR Valign=Top Align=Center BgColor=" & bgcolor & ">" & vbCrlf For i = vbSunday To vbSaturday Response.Write "<TD><Font Size='-2'>" & left(WeekDayName(i), 1) & "</Font></TD>" & vbCrlf Next Response.Write "</TR>" & vbCrlf '## Set dDay to the First day of the month ## dDay = DateSerial(yYear,mMonth,1) FOR j=1 to 6 Response.Write "<TR>" & vbCrlf FOR i=vbSunday to vbSaturday CellStr="<Font size=-3></Font>" Color=cellcolor If WeekDay(dDay) = i and Month(dDay) = mMonth then '## Set Color to Yellow if Current Day if (Day(dDay) = Day(now)) and (Month(dDay) = Month(now)) and (Year(dDay) = Year(now)) then Color="Yellow" CellStr = "<Font size=-2>" & Day(dDay) & "</Font> " '## Get the Memo Field out of Database for current Date Memo = GetCellData(dDay) IF Memo <> "" then '## Format Cell String if there is a Memo ## CellStr ="<a href=eventi.asp?id=" & dDay & "><Font size=-2 color=#ff0000>" & Day(dDay) & "</Font>" & "</a>" '## End Calendar Details ## End If '## Get the Next Day dDay = DateAdd("d",1,dDay) End If Response.Write "<TD vAlign=top align=center BgColor='" & Color & "'>" & CellStr & "</TD>" & vbCrlf NEXT '## FOR i=vbSunday to vbSaturday ## Response.Write "</TR>" & vbCrlf NEXT '## For j=1 to 6 ## Response.Write "</Table>" & vbCrlf End Sub '************************************************ '************************************************ Sub DisplayCalendarTop(dDay) Title = MonthName(month(dDay)) & " " & year(dDay) pPREVIOUS = dateadd("m",-1, dDay) nNEXT = dateadd("m",1,dDay) Response.Write "<a name=top><TABLE Align=center CELLPADDING=0 CELLSPACING=0 WIDTH=" & TableWidth & " BORDER=0>" & vbCrlf Response.Write "<TR VALIGN=MIDDLE ALIGN=CENTER>" & vbCrlf Response.Write "<TD BgColor='" & BgColor & "' ALIGN=center>" & vbCrlf Response.Write "<font FACE=WingDings>" & chr(239) & "</font>" & vbCrlf Response.Write "</TD>" & vbCrlf Response.Write "<TD BgColor='" & BgColor & "' ALIGN=center>" & vbCrlf Response.Write "" & Title & "" & vbCrlf Response.Write "</TD>" & vbCrlf Response.Write "<TD BgColor='" & BgColor & "' ALIGN=center>" & vbCrlf Response.Write "<font FACE=WingDings>" & chr(240) & "</font>" & vbCrlf Response.Write "</TD>" & vbCrlf Response.Write "</TR>" & vbCrlf Response.Write "</TABLE>" & vbCrlf End Sub '************************************************ '************************************************ Function GetCellData(dDay) Set rs = Server.CreateObject("ADODB.Recordset") sSQL = "Select [date],[memo] from CalendarInfo where Date=#" & dDay & "#" rs.open sSQL, Conn,3,3 GetCellData = "" if rs.recordcount > 0 then GetCellData=rs("memo") rs.close Set rs = nothing End Function '************************************************ '************************************************ Sub DisplaySmallCalendar(mMonth, yYear) Title = "<a href=calendar.asp?month=" & mMonth & "&year=" & yYear & ">" & MonthName(mMonth) & " " & yYear & "</a>" dDay = DateSerial(yYear,mMonth,1) mMonth = Month(dDay) yYear = Year(dDay) FirstDayOfMonth = Weekday(dDay) Response.Write "<TABLE Align=center width=150 CELLPADDING=0 CELLSPACING=0 BORDER=1>" & vbCrlf Response.Write "<TR VALIGN=MIDDLE ALIGN=CENTER>" & vbCrlf Response.Write "<TD BgColor='" & BgColor & "' ALIGN=center>" & vbCrlf Response.Write "<font size=-2>" & Title & "</font>" & vbCrlf Response.Write "</TD>" & vbCrlf Response.Write "</TR>" & vbCrlf Response.Write "</TABLE>" & vbCrlf '## Start Displaying the Actual Calendar ## Response.Write "<Table width=150 Align=center CellPadding=3 CellSpacing=1 Border=1 BgColor='" & BgColor & "'>" & vbCrlf Response.Write "<TR Valign=Top Align=Center BgColor='" & bgcolor & "'>" & vbCrlf For i = vbSunday To vbSaturday Response.Write "<TD><Font Size='-3'>" & left(WeekDayName(i), 1) & "</Font></TD>" & vbCrlf Next Response.Write "</TR>" & vbCrlf '## Set dDay to the First day of the month ## dDay = DateSerial(yYear,mMonth,1) FOR j=1 to 6 Response.Write "<TR>" & vbCrlf FOR i=vbSunday to vbSaturday CellStr="<Font size=-3></Font>" Color=cellcolor If WeekDay(dDay) = i and Month(dDay) = mMonth then '## Set Color to Yellow if Current Day if (Day(dDay) = Day(now)) and (Month(dDay) = Month(now)) and (Year(dDay) = Year(now)) then Color="Yellow" CellStr = "<Font size=-3>" & Day(dDay) & "</Font>" '## Get the Next Day dDay = DateAdd("d",1,dDay) End If Response.Write "<TD vAlign=top align=left BgColor='" & Color & "'>" & CellStr & "</TD>" & vbCrlf NEXT '## FOR i=vbSunday to vbSaturday ## Response.Write "</TR>" & vbCrlf NEXT '## For j=1 to 6 ## Response.Write "</Table>" & vbCrlf End Sub %>
se qualcuno ha qualche suggerimeto!codice:<% dim dDay,mMonth,yYear,memo,LeapYear,DaysInFeb,dDate,rs,sql dDay = request.form("dDay") mMonth = request.form("mMonth") yYear = request.form("yYear") memo = request.form("memo") memo = replace(memo, vbcrlf, " ") memo = replace(memo, "'","´") yYear= int(yYear) dDay = int(dday) mMonty = int(mMonth) Select Case mMonth case 4,6,9,11: if dDay > 30 then response.write " <Center><font size=-1>" response.write "There are only 30 days in the month of " & MonthName(mMOnth) & " " response.write "Click <font color=red>back</font> on your browser and try again" response.write "</font></Center>" 'response.end end if case 2: LeapYear = False if ((yYear Mod 4 = 0) And (yYear Mod 100 <> 0) Or (yYear Mod 400 = 0)) then LeapYear=True DaysInFeb = 28 if LeapYear then DaysInFeb = 29 if dDay > DaysInFeb then response.write " <Center><font size=-1>" response.write "There are only " & DaysinFeb & " days in the month of " & MonthName(mMOnth) & " " response.write "Click <font color=red>back</font> on your browser and try again" response.write "</font></Center>" 'response.end end if End Select dDate = dateserial(yyear,mmonth,dday) Set rs = Server.CreateObject("ADODB.Recordset") sSQL = "Select [memo],[date],[dateadded] from CalendarInfo" rs.open sSQL, Conn, 3, 3 rs.addnew rs("date") = dDate rs("DateAdded") = now() rs("memo") = memo rs.update rs.close Set rs = nothing Response.Redirect "addnewcal.asp" %>![]()

Rispondi quotando
