<!--#include file="const.asp"-->
<!--#include file="conn.asp"-->
<%'on error resume next
if isnull(request.cookies("cardnumber")) or request.cookies("cardnumber")=empty then
response.cookies("cardnumber")="|"
response.cookies("cardnumber").Expires=Date+365
end if
set rs=server.createobject("adodb.recordset")
'*********************************判断投票项目是否已经关闭
sql="select kg,overtime from class where id="&request("classid")
rs.open sql,conn,3,1
if rs("kg")=1 then
response.write "<script>alert('这次活动已经结束。');</script>"
rs.close
call show()
end if
'*****************************************判断投票项目是否已经过期
if left(rs("overtime"),2)<>"0-"then
if datediff("s",now,formatdatetime(rs("overtime")))<0 then
response.write "<script>alert('这次投票活动已经截止。');</script>"
rs.close
call show()
end if
end if
rs.close
'****************************************判断是否已经投票过了
if instr(request.cookies("cardnumber"),"|"&request("classid")&"|")<>0 then
response.write "<script>alert('您已经投过票了,请勿重复投票,谢谢!。');</script>"
call show()
response.end
end if
'*********************************************进行数据库操作
if request("style")="radio" then
if isnull(request("voted")) or request("voted")=empty then
response.write "<script>alert('请选择投票主题。');window.close()</script>"
call rsclose
call connclose
response.end
end if
sql="select * from vote where id="&request("voted")
rs.open sql,conn,3,2
rs("count")=rs("count")+1
rs.update
rs.close
elseif request("style")="checkbox" then
if request("voted").count=0 then
response.write "<script>alert('请选择投票主题。');window.close()</script>"
call rsclose
call connclose
response.end
end if
for i=1 to request("voted").count
sql="select * from vote where id="&request("voted")(i)
rs.open sql,conn,3,2
rs("count")=rs("count")+1
rs.update
rs.close
next
end if
response.cookies("cardnumber")=request.cookies("cardnumber")&request("classid")&"|"
response.cookies("cardnumber").Expires=Date+365
'*************************************显示投票结果
call show()
function show
response.write "<script>location.href='showvote.asp?classid="&request("classid")&"';</script>"
call rsclose()
call connclose()
response.end
end function
'Response.Write Err.description%>