<!--#include file="Inc/conn.asp"-->
<!--#include file="Inc.asp"--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><%=SiteTitle%></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="<%=Sitekeywords%>" />
<meta name="description" content="<%=Sitedescription%>" />
<link href="<% =SitePath %>images/angel_asp.css" type=text/css rel=stylesheet>
<link href="<% =SitePath %>images/Css_angel_asp.css" ID="skin" type=text/css rel=stylesheet>
<link rel="shortcut icon" href="<%=SitePath%>images/myfav.ico" type="image/x-icon" />
<style>
.votesee{width:600px;margin:30px auto;overflow:hidden;border:1px solid #3A98D1;background:#D5E5F7;}
.votesee .title {text-align:center;font:bold 16px "Microsoft Yahei",sans-serif;padding:10px 0;}
.votesee td {height:30px;text-align:left;padding-left:5px;border-top:1px solid #3A98D1;}
.votesee .bfb {font-weight:bold;text-align:center;border-left:1px solid #3A98D1;border-right:1px solid #3A98D1;}
</style>
<script type="text/javascript" src="<%=SitePath%>inc/main.asp"></script>
</head>
<body>
<div class="mwall">
<%=Head%>
<%=Menu%><div class="mw" style="margin-bottom:5px;">
<div class="dh">
<%=search%>您现在的位置：<a href="<%=SitePath%>">首页</a> >> 投票
</div>
<div class="mw borderall" style="margin-top:5px;">
<%
ID=Angel_aspRequest(request("id"))
	if request("action") = "add" then
		call add_vote()
	elseif request("action")="edit" then
		call edit()
	elseif request("action")="savenew" then
		call savenew()
	elseif request("action")="savedit" then
		call savedit()
	elseif request("action")="delAll" then
		call delAll()
	elseif request("action")="see" then
		call see_vote()
	else
		call List()
	end if
%>
</div>
</div>
<%=Copy%>
</body>
</html>
<%	
Sub add_vote

set rs=server.CreateObject("adodb.recordset")
sql="select result,StartTime,EndTime from "&tbname&"_Vote where id="&id&""
Rs.Open sql,Conn,1,3

If  rs.eof then
	Call Alert ("没有此投票！","Close")
Else
	If Request.Form("vote")="" then
	Call Alert ("请选择投票项目！","Close")
	End if
	If Datediff("s",Rs(1),Now())<0 Then Call Alert ("该投票还没开始！","Vote.asp?action=see&id="&id&"")
	If Datediff("s",Rs(2),Now())>0 Then Call Alert ("该投票已过期！","Vote.asp?action=see&id="&id&"")
	If Request.Cookies("Angel_aspvote_"&id&"")="" then
	   	for each ho in Request.Form("vote")
			pollresult=split(Rs(0),"|")
			for i = 0 to (ubound(pollresult)-1)
				if not pollresult(i)="" then
				
					if int(ho)=i then
						pollresult(i)=pollresult(i)+1
					end if
					allpollresult=""&allpollresult&""&pollresult(i)&"|"
				end if
			next
			Rs(0)=allpollresult
			Rs.update
			allpollresult=""
		next
		Response.Cookies("Angel_aspvote_"&id&"")=id
		Response.Cookies("Angel_aspvote_"&id&"").Expires=Date+30
		Call Alert ("恭喜您，投票成功！","Vote.asp?action=see&id="&id&"")
	Else
		Call Alert ("您已经投过票了,请勿重复投票！","Vote.asp?action=see&id="&id&"")
	end if
End if
rs.close
set rs=nothing
End sub

sub see_vote()
sql="select title,vote,result,stype,StartTime,EndTime from "&tbname&"_Vote where id="&ID&""
set rs=conn.execute(sql)
if rs.eof then
	Call Alert ("没有此投票！",-1)
else
	vote=rs(1)
	result=rs(2)
	total_vote=0
	vote=split(vote,"|")
	result=split(result,"|")
	for i=0 to ubound(result)
	if not result(i)="" then total_vote=result(i)+total_vote
	next
	Response.Write "<table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" class=""votesee"">"& VbCrLf
	Response.Write "	<tr>"
	Response.Write "		<td colspan=""3"" class=""title"">"&rs(0)&"</td>"
	Response.Write "	</tr>"
	for i=0 to (ubound(vote)-1)
	if result(i)=0 then
	bl="0"
	else
	bl=Formatpercent(result(i)/total_vote,0)
	end if
	Response.Write "	<tr>"
	Response.Write "		<td width=""40%"">"&i+1&"."&vote(i)&"</td>"
	Response.Write "		<td width=""10%"" class=""bfb"">"&bl&"</td>"
	Response.Write "		<td width=""50%""><img src="""&SitePath&"images/vote/"&RndNumber(0,4)&".gif"" style=""width:"&bl&";height:9px;margin-right:5px;"" title="""&bl&""">"&result(i)&"票</td>"
	Response.Write "	</tr>"
	next
	Response.Write "	<tr>"
	Response.Write "		<td colspan=""3"" style=""text-align:center;"">总得票：<font style=""color:#ff0000;"">"&total_vote&"</font>　投票时间："&FormatDate(rs(4),11)&"至"&FormatDate(rs(5),11)&"</td>"
	Response.Write "	</tr>"
	Response.Write "</table>"& VbCrLf
end if
rs.close
set rs=nothing
end sub
%>