vlw aee
<title>Confirma Placar</title>
<body>
<!--#include file= "estilo.asp" -->
<%
Set objConexao = Server.CreateObject("adodb.connection")
objConexao.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath(".\db7frvirtual.mdb")
nicklogado = session("nick")
sql = "Select * from jogos where time2 = '" & nicklogado & "' and confirmado = false"
'jogos que o seu adversario enviou
sql2 = "Select * from jogos where time1 = '" & nicklogado & "' and confirmado = false"
'jogos que você enviou
Set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorType = 3
rs.open sql, objConexao
Set rs2 = Server.CreateObject("ADODB.Recordset")
rs2.CursorType = 3
rs2.open sql2, objConexao
if rs.eof = true and rs2.eof = true then
response.write("Nenhum Resultado a Confirmar")
end if
if rs2.eof = false then
response.write("Jogos enviados por você, ainda não confirmados:<P>")
do while not rs2.eof
response.write (rs2("data") & " - " & rs2("time1") & " " & rs2("resultado1") & " x " & rs2("resultado2") & " " & rs2("time2"))
response.write (" <a href='excluir.asp?cmd=" & rs2("id") & "'>Excluir</a><br>")
rs2.movenext
loop
Response.Write("<P>")
end if
If rs.EOF = false Then
response.write ("Jogos para você confirmar:<P>")
rs.movelast
lastid = rs("id")
rs.movefirst
Do While Not rs.EOF
id = rs("id")
response.write (rs("data") & " - " & rs("time1") & " " & rs("resultado1") & " x " & rs("resultado2") & " " & rs("time2"))
response.write (" <a href='confirma.asp?cmd=" & id & "'>Confirmar</a> <a href='excluir.asp?cmd=" & id & "'>Excluir</a><br>")
rs.movenext
Loop
response.write("<P>")
gsCommand = (Request.QueryString("CMD"))
gsCommand = CInt(gsCommand)
For i = 1 To lastid
If i = gsCommand Then
sql1 = "Select * from jogos where id = " & gsCommand
Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.CursorType = 3
rs1.open sql1, objConexao
if rs1.eof then
response.write("Resultado Inexistente")
reponse.end
end if
frmTime1 = rs1("time1")
frmTime2 = rs1("time2")
frmResultado1 = rs1("resultado1")
frmResultado2 = rs1("resultado2")
sqltime1 = "Select * from cadastro where nick = '" & frmTime1 & "'"
'pega os dados (pontos) do nicklogado
Set rstime1 = Server.CreateObject("ADODB.Recordset")
rstime1.CursorType = 3
rstime1.open sqltime1, objConexao
sqltime2 = "Select * from cadastro where nick = '" & frmTime2 & "'"
'pontos do time adversário
Set rstime2 = Server.CreateObject("ADODB.Recordset")
rstime2.CursorType = 3
rstime2.open sqltime2, objConexao
If frmResultado1 = frmResultado2 Then
Time1pts = rstime1("pontos") + 3
Time2pts = rstime2("pontos") + 3
Time1jogos = rstime1("jogos") + 1
Time2jogos = rstime2("jogos") + 1
Time1vitoria = rstime1("vitoria") + 0
Time2vitoria = rstime2("vitoria") + 0
Time1empate = rstime1("empate") + 1
Time2empate = rstime2("empate") + 1
Time1derrota = rstime1("derrota") + 0
Time2derrota = rstime2("derrota") + 0
Time1gp = rstime1("gp") + frmResultado1
Time2gp = rstime2("gp") + frmResultado2
Time1gc = rstime1("gc") + frmResultado2
Time2gc = rstime2("gc") + frmResultado1
ElseIf frmResultado1 > frmResultado2 Then
Time1pts = rstime1("pontos") + 10
Time2pts = rstime2("pontos") - 7
Time1jogos = rstime1("jogos") + 1
Time2jogos = rstime2("jogos") + 1
Time1vitoria = rstime1("vitoria") + 1
Time2vitoria = rstime2("vitoria") + 0
Time1empate = rstime1("empate") + 0
Time2empate = rstime2("empate") + 0
Time1derrota = rstime1("derrota") + 0
Time2derrota = rstime2("derrota") + 1
Time1gp = rstime1("gp") + frmResultado1
Time2gp = rstime2("gp") + frmResultado2
Time1gc = rstime1("gc") + frmResultado2
Time2gc = rstime2("gc") + frmResultado1
ElseIf frmResultado1 < frmResultado2 Then
Time1pts = rstime1("pontos") - 7
Time2pts = rstime2("pontos") + 10
Time1jogos = rstime1("jogos") + 1
Time2jogos = rstime2("jogos") + 1
Time1vitoria = rstime1("vitoria") + 0
Time2vitoria = rstime2("vitoria") + 1
Time1empate = rstime1("empate") + 0
Time2empate = rstime2("empate") + 0
Time1derrota = rstime1("derrota") + 1
Time2derrota = rstime2("derrota") + 0
Time1gp = rstime1("gp") + frmResultado1
Time2gp = rstime2("gp") + frmResultado2
Time1gc = rstime1("gc") + frmResultado2
Time2gc = rstime2("gc") + frmResultado1
End If
if rs1("confirmado") = false then
sqlupdate = "update jogos set confirmado = true where id = " & gsCommand
sqlupdatetime1 = "update cadastro set pontos = " & Time1pts & _
", jogos = " & Time1jogos & _
", vitoria = " & Time1vitoria & _
", empate = " & Time1empate & _
", derrota = " & Time1derrota & _
", gp = " & Time1gp & _
", gc = " & Time1gc & " where nick = '" & frmTime1 & "'"
sqlupdatetime2 = "update cadastro set pontos = " & Time2pts & _
", jogos = " & Time2jogos & _
", vitoria = " & Time2vitoria & _
", empate = " & Time2empate & _
", derrota = " & Time2derrota & _
", gp = " & Time2gp & _
", gc = " & Time2gc & " where nick = '" & frmTime2 & "'"
objConexao.Execute (sqlupdate)
objConexao.Execute (sqlupdatetime1)
objConexao.Execute (sqlupdatetime2)
response.redirect ("mensagem.asp?msg=confirmado")
End If
End If
Next
End If
objConexao.Close
Set objConexao = Nothing
%>










