<!--#include file="inc/conn.asp" -->

<!--#include file="inc/function.asp" -->
<%
dim Action,ID,VoteType,VoteOption,arrOptions,sqlVote,rsVote
dim Voted,VotedID,arrVotedID,i
dim FoundErr,ErrMsg
Action=trim(Request("Action"))
ID=Trim(request("ID"))
VoteType=Trim(request("VoteType"))
VoteOption=trim(request("VoteOption"))
Voted=False
VotedID=session("VotedID")

if Id="" then
	founderr=true
	errmsg=errmsg+"<br><li>不能确定调查ID</li>"
	call WriteErrMsg()
	response.end
else
	ID=CLng(ID)
	if instr(VotedID,",")>0 then
		arrVotedID=split(VotedID,",")
		for i=0 to ubound(arrVotedID)
			if Clng(arrVotedID(i))=ID then
				Voted=True
				exit for
			end if
		next
	else
		if VotedID=ID then
			Voted=True
		end if
	end if
end if
if Action="" or VoteOption="" then
	Action="Show"
end if
If Action = "Vote" And VoteOption<>"" and Voted=False Then
	if VoteType="Single" then
		conn.execute "Update Vote set answer" & VoteOption  & "= answer" & VoteOption & "+1 where ID=" & ID
	else
		if instr(VoteOption,",")>0 then
			arrOptions=split(VoteOption,",")
			for i=0 to ubound(arrOptions)
				conn.execute "Update Vote set answer" & cint(trim(arrOptions(i)))  & "= answer" & cint(trim(arrOptions(i))) & "+1 where ID=" & Clng(ID)
			next
		else
			conn.execute "Update Vote set answer" & VoteOption  & "= answer" & VoteOption & "+1 where ID=" & Clng(ID)
		end if 
	end if
	if VotedID="" then
		session("VotedID")=ID
	else
		session("VotedID")=VotedID & "," & ID
	end if
End If
sqlVote="Select * from Vote Where ID=" & ID
Set rsVote = Server.CreateObject("ADODB.Recordset")
rsVote.open sqlVote,conn,1,1
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>调查结果</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<link href="style.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY bgcolor="#ffffff">
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td valign="top" align="center"><table width="760" border="0" align="center"  cellpadding="0" cellspacing="0">
        <tr> 
          <td height="20" background="imge/atopa.gif"> </td>
        </tr>
      </table>
      
      <table width="710" border="0" align="center" cellpadding="0" cellspacing="0">
         <tr>
          <td width="1" height="1"><img src="img0415/space.gif" width="1" height="1"></td>
          <td bgcolor="#CCCCCC"></td>
          <td width="1"></td>
        </tr><tr>
          <td width="1" bgcolor="#CCCCCC"><img src="img0415/space.gif" width="1" height="1"></td>
          <td height="28" bgcolor="f2f2f2"><div align="center"><strong><img src="Images/p1.GIF" width="16" height="16" align="absmiddle"> 
          网站关于<font color="#FF0000">“</font><font color="#FF0000"><%=rsVote("Title")%>”</font>的调查结果</strong></div></td>
          <td width="1" bgcolor="#CCCCCC"><img src="img0415/space.gif" width="1" height="1"></td>
        </tr>
       
      </table>
      <table width="710" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF" class="border">
        
        <tr> 
          <td align="left" bgcolor="#FFFFFF"><table width="100%" border="0" align="center"  cellpadding="10" cellspacing="0">
              <tr> 
                <td height="11" align="center"><strong>
                  <%
if Action="Vote" And VoteOption<>"" then
	response.write "<font color='#FF0000' size='3'>"
	if Session("UserName")<>"" then response.write Session("UserName") & "，"
	if Voted=True then
		response.write "==　你已经投过票了，请勿重复投票！　=="
    else	
		response.write "==　非常感谢您的投票！　=="
	end if
	response.write "</font><br>"
end if
		%>
                </strong></td>
              </tr>
            </table>
            <strong> </strong> 
            <table width="700" border="0" align="center" cellpadding="3" cellspacing="0" bordercolorlight="#000000" bordercolordark="#CCCCCC">
              <tr> 
                <td height="40"> <strong>　&middot;目前网友的总投票数为：</strong><font color="#FF0000"> 
                  <%
  dim totalVote
  totalVote=0
  for i=1 to 8
  	if rsVote("Select" & i)="" then exit for
	totalVote=totalVote+rsVote("answer"& i)
  next
  response.Write(totalVote & "票")
  if totalVote=0 then totalVote=1
  %>
                </font> </td>
              </tr>
              <%
  for i=1 to 8
  	if trim(rsVote("Select" & i) & "")="" then exit for
  %>
              <% next %>
            </table>
            <table width="700" border="0" align="center" cellpadding="3" cellspacing="0" bordercolorlight="#000000" bordercolordark="#CCCCCC">
              <%
  for i=1 to 8
  	if trim(rsVote("Select" & i) & "")="" then exit for
  %>
              <tr> 
                <td align="right"> <div align="left"><font color="#cc0000"></font> 
                    <table width="539" border="0" cellpadding="0" cellspacing="0">
                      <tr> 
                        <td height="23"><font color="#cc0000">&nbsp;</font>&nbsp;&nbsp;选项<%=i%>：<strong><%=rsVote("Select"& i)%></strong></td>
                      </tr>
                    </table>
                  </div></td>
              </tr>
              <tr> 
                <td><table border=0 cellspacing="0" cellpadding="0" height="30">
                    <tr> 
                      <td height="11" valign="top">&nbsp;&nbsp; 得票率：<img src="Images/dc/left.gif" width="4" height="21" border="0" align="top"><img src="Images/dc/greenbar.gif" width="1" height="21" align="top"><%dim perVote
	perVote=round(rsVote("answer"& i)/totalVote,4)
	response.write "<img src='Images/dc/greenbar.gif' width='" & int(360*pervote) & "' height='21' align='absmiddle'>"
	perVote=perVote*100%></td><td valign="top"><img src="Images/dc/mid.gif" width="6" height="21" align="top"><%dim perVote2
	perVote2=round(rsVote("answer"& i)/totalVote,4)
	response.write "<img src='Images/dc/whitebar.gif' width='" & 325-int(360*pervote2) & "' height='21' align='absmiddle'>"
	perVote2=perVote2*100%><img src="Images/dc/right.gif" width="6" height="21" border="0" align="top"></td></tr>
                    <tr><td></td>
                      <td height="19">占：<%	if perVote<1 and perVote<>0 then
		response.write "&nbsp;0" & perVote & "%"
	else
		response.write "&nbsp;" & perVote & "%"
	end if
%>
                        [得：<font color="#ff0000"><%response.write rsVote("answer"& i)%></font>票]</td></tr></table>
                </td>
              </tr>
              <% next %>
            </table>
            <table width="100%" border="0" align="center"  cellpadding="0" cellspacing="0">
              <tr> 
                <td height="11"></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      
      <table width="710" border="0" align="center" cellpadding="0" cellspacing="0">
        
        <tr>
          <td width="1" bgcolor="#CCCCCC"><img src="img0415/space.gif" width="1" height="1"></td>
          <td height="26" bgcolor="f2f2f2"><div align="center">【<a href="javascript:window.close();">关闭窗口</a>】</div></td>
          <td width="1" bgcolor="#CCCCCC"><img src="img0415/space.gif" width="1" height="1"></td>
        </tr>
		<tr>
          <td width="1" height="1"><img src="img0415/space.gif" width="1" height="1"></td>
          <td bgcolor="#CCCCCC"></td>
          <td width="1"></td>
        </tr>
      </table></td>
  </tr>
  

</table>
</BODY>
</HTML>
<%
rsVote.Close()
Set rsVote = Nothing
call CloseConn()
%>
