Jump to content


Photo

Calendario Em Asp


  • Faça o login para participar
8 replies to this topic

#1 SpiT

SpiT

    Novato no fórum

  • Usuários
  • 5 posts
  • Sexo:Não informado

Posted 16/01/2007, 18:55

Eu peguei um script de calendario e tentei adicionar um banco de dados para colocar eventos, só que eu adiciono evento e o evento nao aparece no calendario.
Outro problema tambem é que se eu digitar o endereço com as strings e tudo mais, nao carrega da erro: "ADODB.Field error '80020009'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. "
São duas paginas os codigos estao abaixo:

## calendar.asp

<%
cnpath="DBQ=" & Server.MapPath("calendario.mdb")
DataSource = "Driver={Microsoft Access Driver (*.mdb)}; " & cnpath

Set Conn = Server.CreateObject("ADODB.Connection")

Conn.Open DataSource


'*******************************************************
'* ASP 101 Sample Code - http://www.asp101.com *
'* *
'* This code is made available as a service to our *
'* visitors and is provided strictly for the *
'* purpose of illustration. *
'* *
'* Please direct all inquiries to webmaster@asp101.com *
'*******************************************************
' ***Begin Function Declaration***
' New and improved GetDaysInMonth implementation.
' Thanks to Florent Renucci for pointing out that I
' could easily use the same method I used for the
' revised GetWeekdayMonthStartsOn function.
Function GetDaysInMonth(iMonth, iYear)
Dim dTemp
dTemp = DateAdd("d", -1, DateSerial(iYear, iMonth + 1, 1))
GetDaysInMonth = Day(dTemp)
End Function

' Previous implementation on GetDaysInMonth
'Function GetDaysInMonth(iMonth, iYear)
' Select Case iMonth
' Case 1, 3, 5, 7, 8, 10, 12
' GetDaysInMonth = 31
' Case 4, 6, 9, 11
' GetDaysInMonth = 30
' Case 2
' If IsDate("February 29, " & iYear) Then
' GetDaysInMonth = 29
' Else
' GetDaysInMonth = 28
' End If
' End Select
'End Function

Function GetWeekdayMonthStartsOn(dAnyDayInTheMonth)
Dim dTemp
dTemp = DateAdd("d", -(Day(dAnyDayInTheMonth) - 1), dAnyDayInTheMonth)
GetWeekdayMonthStartsOn = WeekDay(dTemp)
End Function

Function SubtractOneMonth(dDate)
SubtractOneMonth = DateAdd("m", -1, dDate)
End Function

Function AddOneMonth(dDate)
AddOneMonth = DateAdd("m", 1, dDate)
End Function
' ***End Function Declaration***


Dim dDate ' Date we're displaying calendar for
Dim iDIM ' Days In Month
Dim iDOW ' Day Of Week that month starts on
Dim iCurrent ' Variable we use to hold current day of month as we write table
Dim iPosition ' Variable we use to hold current position in table


' Get selected date. There are two ways to do this.
' First check if we were passed a full date in RQS("date").
' If so use it, if not look for seperate variables, putting them togeter into a date.
' Lastly check if the date is valid...if not use today
If IsDate(Request.QueryString("date")) Then
dDate = CDate(Request.QueryString("date"))
Else
If IsDate(Request.QueryString("month") & "-" & Request.QueryString("day") & "-" & Request.QueryString("year")) Then
dDate = CDate(Request.QueryString("month") & "-" & Request.QueryString("day") & "-" & Request.QueryString("year"))
Else
dDate = Date()
' The annoyingly bad solution for those of you running IIS3
If Len(Request.QueryString("month")) <> 0 Or Len(Request.QueryString("day")) <> 0 Or Len(Request.QueryString("year")) <> 0 Or Len(Request.QueryString("date")) <> 0 Then
Response.Write "A data que você escolheu não é valida..<BR><BR>"
End If
' The elegant solution for those of you running IIS4
'If Request.QueryString.Count <> 0 Then Response.Write "The date you picked was not a valid date. The calendar was set to today's date.<BR><BR>"
End If
End If

'Now we've got the date. Now get Days in the choosen month and the day of the week it starts on.
iDIM = GetDaysInMonth(Month(dDate), Year(dDate))
iDOW = GetWeekdayMonthStartsOn(dDate)

%>
<!-- Outer Table is simply to get the pretty border--><body background="fundo.jpg">
<TABLE BORDER=6 align="center" CELLPADDING=0 CELLSPACING=0>
<TR>
<TD>
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1 BGCOLOR=#99CCFF>
<TR>
<TD BGCOLOR=#000099 ALIGN="center" COLSPAN=7>
<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD ALIGN="right"><A HREF="./calendar.asp?date=<%= SubtractOneMonth(dDate) %>"><FONT COLOR=#FFFF00 SIZE="-1">&lt;&lt;</FONT></A></TD>
<TD ALIGN="center"><FONT COLOR=#FFFF00><B><%= MonthName(Month(dDate)) & " " & Year(dDate) %></B></FONT></TD>
<TD ALIGN="left"><A HREF="./calendar.asp?date=<%= AddOneMonth(dDate) %>"><FONT COLOR=#FFFF00 SIZE="-1">&gt;&gt;</FONT></A></TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD ALIGN="center" BGCOLOR=#0000CC><b><font color="#FFFF00">Dom</font></b><BR>
<IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD>
<TD ALIGN="center" BGCOLOR=#0000CC><FONT COLOR=#FFFF00><B>Seg</B></FONT><BR>
<IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD>
<TD ALIGN="center" BGCOLOR=#0000CC><FONT COLOR=#FFFF00><B>Ter</B></FONT><BR>
<IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD>
<TD ALIGN="center" BGCOLOR=#0000CC><FONT COLOR=#FFFF00><B>Qua</B></FONT><BR>
<IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD>
<TD ALIGN="center" BGCOLOR=#0000CC><b><font color="#FFFF00">Qui</font></b><BR>
<IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD>
<TD ALIGN="center" BGCOLOR=#0000CC><b><font color="#FFFF00">Sex</font></b><BR>
<IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD>
<TD ALIGN="center" BGCOLOR=#0000CC><FONT COLOR=#FFFF00><B>Sab</B></FONT><BR>
<IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD>
</TR>
<%
' Write spacer cells at beginning of first row if month doesn't start on a Sunday.
If iDOW <> 1 Then
Response.Write vbTab & "<TR>" & vbCrLf
iPosition = 1
Do While iPosition < iDOW
Response.Write vbTab & vbTab & "<TD>&nbsp;</TD>" & vbCrLf
iPosition = iPosition + 1
Loop
End If

' Write days of month in proper day slots
iCurrent = 1
iPosition = iDOW
Do While iCurrent <= iDIM
' If we're at the begginning of a row then write TR
If iPosition = 1 Then
Response.Write vbTab & "<TR>" & vbCrLf
End If

' If the day we're writing is the selected day then highlight it somehow.
If iCurrent = Day(dDate) Then
edate = iCurrent & "-" & Month(dDate) & "-" & Year(dDate)
set rs=conn.execute("select * from calendario where data=" & edate & " ")
Response.Write vbTab & vbTab & "<TD BGCOLOR=#00FFFF><FONT SIZE=""-1""><B>" & iCurrent & "</B></FONT><BR>"
If rs.EOF Then
Response.Write " "
Else
Response.Write "<A HREF=""cal.asp?id=" & rs("id") & "&data=" & edate & """>" & rs("abrev") & "</a>"
End If
Response.Write "<BR></TD>" & vbCrLf
Else
edate = iCurrent & "-" & Month(dDate) & "-" & Year(dDate)
set rs=conn.execute("select * from calendario where data=" & edate & " ")
Response.Write vbTab & vbTab & "<TD><FONT SIZE=""-1"">" & iCurrent & "</FONT><BR>"
If rs.EOF Then
Response.Write " "
Else
Response.Write "<A HREF=""cal.asp?id=" & rs("id") & "&data=" & edate &""">" & rs("abrev") & "</a>"
End If
Response.Write "<BR></TD>" & vbCrLf
End If

' If we're at the endof a row then write /TR
If iPosition = 7 Then
Response.Write vbTab & "</TR>" & vbCrLf
iPosition = 0
End If

' Increment variables
iCurrent = iCurrent + 1
iPosition = iPosition + 1
Loop

' Write spacer cells at end of last row if month doesn't end on a Saturday.
If iPosition <> 1 Then
Do While iPosition <= 7
Response.Write vbTab & vbTab & "<TD>&nbsp;</TD>" & vbCrLf
iPosition = iPosition + 1
Loop
Response.Write vbTab & "</TR>" & vbCrLf
End If
%>
</TABLE>
</TD>
</TR>
</TABLE>

<BR>

<TABLE BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0>
<TR><TD ALIGN="center">
<FORM ACTION="./calendar.asp" METHOD=GET>
<SELECT NAME="month">
<OPTION VALUE=1>Janeiro</OPTION>
<OPTION VALUE=2>Fevereiro</OPTION>
<OPTION VALUE=3>Março</OPTION>
<OPTION VALUE=4>Abril</OPTION>
<OPTION VALUE=5>Maio</OPTION>
<OPTION VALUE=6>Junho</OPTION>
<OPTION VALUE=7>Julho</OPTION>
<OPTION VALUE=8>Agosto</OPTION>
<OPTION VALUE=9>Setembro</OPTION>
<OPTION VALUE=10>Outubro</OPTION>
<OPTION VALUE=11>Novembro</OPTION>
<OPTION VALUE=12>Dezembro</OPTION>
</SELECT>
<SELECT NAME="day">
<OPTION VALUE=1>1</OPTION>
<OPTION VALUE=2>2</OPTION>
<OPTION VALUE=3>3</OPTION>
<OPTION VALUE=4>4</OPTION>
<OPTION VALUE=5>5</OPTION>
<OPTION VALUE=6>6</OPTION>
<OPTION VALUE=7>7</OPTION>
<OPTION VALUE=8>8</OPTION>
<OPTION VALUE=9>9</OPTION>
<OPTION VALUE=10>10</OPTION>
<OPTION VALUE=11>11</OPTION>
<OPTION VALUE=12>12</OPTION>
<OPTION VALUE=13>13</OPTION>
<OPTION VALUE=14>14</OPTION>
<OPTION VALUE=15>15</OPTION>
<OPTION VALUE=16>16</OPTION>
<OPTION VALUE=17>17</OPTION>
<OPTION VALUE=18>18</OPTION>
<OPTION VALUE=19>19</OPTION>
<OPTION VALUE=20>20</OPTION>
<OPTION VALUE=21>21</OPTION>
<OPTION VALUE=22>22</OPTION>
<OPTION VALUE=23>23</OPTION>
<OPTION VALUE=24>24</OPTION>
<OPTION VALUE=25>25</OPTION>
<OPTION VALUE=26>26</OPTION>
<OPTION VALUE=27>27</OPTION>
<OPTION VALUE=28>28</OPTION>
<OPTION VALUE=29>29</OPTION>
<OPTION VALUE=30>30</OPTION>
<OPTION VALUE=31>31</OPTION>
</SELECT>
<SELECT NAME="year">
<OPTION VALUE=2006>2006</OPTION>
<OPTION VALUE=2007 selected>2007</OPTION>
<OPTION VALUE=2008>2008</OPTION>
<OPTION VALUE=2009>2009</OPTION>
<OPTION VALUE=2010>2010</OPTION>
<OPTION VALUE=2011>2011</OPTION>
<OPTION VALUE=2012>2012</OPTION>
<OPTION VALUE=2013>2013</OPTION>
<OPTION VALUE=2014>2014</OPTION>
</SELECT>
<BR>
<INPUT TYPE="submit" VALUE="Mostrar essa data no calendario!">
</FORM>
</TD></TR></TABLE>





## cal.asp

<%
cnpath="DBQ=" & Server.MapPath("calendario.mdb")
DataSource = "Driver={Microsoft Access Driver (*.mdb)}; " & cnpath

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open DataSource
set rs=conn.execute("select * from calendario where data=" & Request.QueryString("data") & " ")


%>
<!-- Outer Table is simply to get the pretty border--><style type="text/css">
<!--
body {
background-image: url(fundo.jpg);
}
.style2 {font-size: 18px}
-->
</style>
<table width="354" height="171" border="0" align="center" cellspacing="0">
<tr bgcolor="#000066">
<td height="37" colspan="2" align="center"><span class="style2"><font color="#FFFFFF"><strong><%=rs("evento")%><strong></font></span></td>
</tr>
<tr bgcolor="#6699FF">
<td height="29" colspan="2" align="center"><strong>Dia <%=rs("data")%></strong></td>
</tr>
<tr bgcolor="#FFFF99">
<td width="85" height="27"><div align="right"><strong>Local:</strong></div></td>
<td width="262"><%=rs("local")%></td>
</tr>
<tr bgcolor="#FFFF99">
<td height="27"><div align="right"><strong>Hor&aacute;rio:</strong></div></td>
<td><%=rs("hora")%></td>
</tr>
<tr bgcolor="#FFFF99">
<td colspan="2"><%=rs("descricao")%></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>


Link para download:
Download

Edição feita por: SpiT, 16/01/2007, 19:03.


#2 replay

replay

    Agora a vida começa...

  • Usuários
  • 421 posts
  • Sexo:Não informado

Posted 17/01/2007, 00:30

Olha eu nem olhei o teu codigo (é muito grande e vc nem informou em que linha ocorre o erro) mas esse erro normalmente se resolve fazendo um if do eof apos o select no banco

If rs.eof then
'não há eventos
else
'ha enventos
end if


Valeu :P
Não me adicione no MSN pq eu não vo te ajuda... se insistir eu vo ser grosso!!!
Ta com dúvida pergunta aqui no fórum...
Grato

#3 SpiT

SpiT

    Novato no fórum

  • Usuários
  • 5 posts
  • Sexo:Não informado

Posted 17/01/2007, 01:40

entao eu fiz isso no calendario, e nao deu certo pq nao apareceu os eventos gravados, eu soh nao fiz isso pra pagina q abre o evento diretamente, mas pq ela soh vai ser carregada se existir o evento, e o erro se passa na linha 0, eh isso que diz o problema. Obrigado!

#4 Dehu

Dehu

    Novato no fórum

  • Usuários
  • 12 posts
  • Sexo:Não informado

Posted 17/01/2007, 13:35

Eu tenho um calendário de eventos que comecei mas não terminei ... ele tá quase 100% pronto, até funciona ... quem quiser, me pede que eu mando...

Ele cadastra, exibe o evento a única coisa que não consegui foi fazer com que os dias só estejam linkados quando houver evento e até mesmo mudar a célula da tabela de outra cor indicando que há evento marcado naquele dia. Atualmente só mostra a célula amarela no dia atual.

Vejam: http://www.aberje.co...ndario_dehu.asp

CLIQUEM NO DIA 28/01/2007 eu cadastrei um evento la[b]


Valew!

#5 SpiT

SpiT

    Novato no fórum

  • Usuários
  • 5 posts
  • Sexo:Não informado

Posted 18/01/2007, 03:41

po eu aceito sim se tiver como voce me mandar..

nm.ricardo@gmail.com

Valeu!

#6 Dehu

Dehu

    Novato no fórum

  • Usuários
  • 12 posts
  • Sexo:Não informado

Posted 18/01/2007, 11:50

enviei no seu email ..
qualquer dúvida, me fale

abraço

#7 Avanço

Avanço

    Novato no fórum

  • Usuários
  • 20 posts
  • Sexo:Não informado

Posted 26/01/2007, 00:21

pô me manda ai que vou ver se consigo colocar os links apenas nos dias que tiverem os eventos e se conseguir posto aqui pra galera.

email: ebfconsultoria@firme.com.br

#8 Dehu

Dehu

    Novato no fórum

  • Usuários
  • 12 posts
  • Sexo:Não informado

Posted 02/02/2007, 17:30

Attached File  calendario.zip   30.49KB   54 downloadsTO COLOCANDO EM ANEXO AÍ PRA VOCÊS BAIXAREM...


eu testei ele, ta funcionando certinho, só não sei pq alguns dias nao aparecem que tem eventos (nao fica com link) e no BD o dia ta com evento.

Ve se arrumem isso e coloca aqui pra galera baixar

#9 acooper

acooper

    Ativo

  • Usuários
  • 368 posts
  • Sexo:Masculino
  • Localidade:Recreio dos Bandeirantes

Posted 12/02/2007, 09:14

Caro, também não estou conseguindo arrumar essa questão de não verificar os outros dias cadastrados.

Attached File  calendario.zip   30.49KB   54 downloadsTO COLOCANDO EM ANEXO AÍ PRA VOCÊS BAIXAREM...


eu testei ele, ta funcionando certinho, só não sei pq alguns dias nao aparecem que tem eventos (nao fica com link) e no BD o dia ta com evento.

Ve se arrumem isso e coloca aqui pra galera baixar


Andre Figueiredo
Analista de Sistema Senior
Tel.: + 55 - (21) 3824-4698- Cel: + 55 - (21) 9127-2772
E-Mail: andre.figueiredo@veirano.com.br
Skype: andre.figueiredo.veirano.com.br




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq