Jump to content
Fórum Script Brasil
  • 0

Ajuda para Calendário asp


Paulo de Jesus Nunes

Question

Olá pessoal estou precisando de uma ajuda aqui tenho esse calendário esta funcionando com os dados do meu banco só que quando coloco While ele cria 3 formulários porque eu quero de mostre 3 datas cadastradas no banco. 

Gostaria de uma ajuda para mostrar essa 3 datas em um único formulário.

Att

<!--#include file="conexao.asp" -->
<%

   
      
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
Set rs = Server.CreateObject("ADODB.Recordset")
     sql = "SELECT * FROM ticket'"
       rs.open sql, conexao, 3, 3

while not rs.EOF

If IsDate(rs("data_vencimento")) Then


    dDate = CDate(rs("data_vencimento"))

Else

    
 If IsDate(rs("mes_vencimento") & "-" & rs("dia_vencimento") & "-" & rs("ano_vencimento")) Then

    dDate = CDate(rs("mes_vencimento") & "-" & rs("dia_vencimento") & "-" & rs("ano_vencimento"))


Else
    

    dDate = Date()
    
        If Len(rs("mes_vencimento")) <> 0 Or Len(rs("dia_vencimento")) <> 0 Or Len(rs("ano_vencimento")) <> 0 Or Len(rs("data_vencimento")) <> 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


        ' The elegant solution for those of you running IIS4
        'If IsDate.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


iDIM = GetDaysInMonth(Month(dDate), Year(dDate))
iDOW = GetWeekdayMonthStartsOn(dDate)

%>

<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 align=center>
<TR>
<TD ALIGN="center">

<TABLE BORDER=2 CELLSPACING=0 CELLPADDING=1 BGCOLOR=#FFFFFF align=center>
    <TR>
        <TD BGCOLOR=#000099 ALIGN="center" COLSPAN=7>

            <TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0>
                <TR>
                    <TD ALIGN="right"></br><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"></br><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><FONT COLOR=#FFFF00><B>D</B></FONT><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD>
        <TD ALIGN="center" BGCOLOR=#0000CC><FONT COLOR=#FFFF00><B>S</B></FONT><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD>
        <TD ALIGN="center" BGCOLOR=#0000CC><FONT COLOR=#FFFF00><B>T</B></FONT><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD>
        <TD ALIGN="center" BGCOLOR=#0000CC><FONT COLOR=#FFFF00><B>Q</B></FONT><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD>
        <TD ALIGN="center" BGCOLOR=#0000CC><FONT COLOR=#FFFF00><B>Q</B></FONT><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD>
        <TD ALIGN="center" BGCOLOR=#0000CC><FONT COLOR=#FFFF00><B>S</B></FONT><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD>
        <TD ALIGN="center" BGCOLOR=#0000CC><FONT COLOR=#FFFF00><B>S</B></FONT><BR><IMG SRC="./images/spacer.gif" WIDTH=60 HEIGHT=1 BORDER=0></TD>
    </TR>
<%
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


iCurrent = 1
iPosition = iDOW
    
Do While iCurrent <= iDIM
    
    If iPosition = 1 Then
        Response.Write vbTab & "<TR>" & vbCrLf
    End If
    
    If iCurrent = Day(dDate) Then


        Response.Write vbTab & vbTab & "<TD BGCOLOR=#DF0101 align=center><FONT SIZE=""-1""><a href='alterar.asp?data="&iCurrent&"'><B>"& iCurrent &"</a></B></FONT><BR><BR></TD>"

Else
        Response.Write vbTab & vbTab & "<TD align=center><A HREF=""./calendar.asp?date=" & Month(dDate) & "-" & iCurrent & "-" & Year(dDate) & """><FONT SIZE=""-1"" color=000000>" & iCurrent & "</FONT></A><BR><BR></TD>"


End If

   
    If iPosition = 7 Then
        Response.Write vbTab & "</TR>" & vbCrLf
        iPosition = 0
    End If
    
    
    ' Increment variables
        iCurrent = iCurrent + 1
    iPosition = iPosition + 1
Loop
rs.Movenext

If iPosition <> 1 Then
    Do While iPosition <= 7
        Response.Write vbTab & vbTab & "<TD>&nbsp;</TD>" & vbCrLf
        iPosition = iPosition + 1
    Loop
    Response.Write vbTab & "</TR></br>" & vbCrLf
End If
wend

%>
</td></tr>
</TABLE>
<BR>

print.png

Edited by Paulo de Jesus Nunes
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.1k
    • Total Posts
      651.8k
×
×
  • Create New...