<!--#include file="Inc/Conn.asp"-->
<!--#include file="Lock.asp"-->
<%Dim Action,S_Array,Scou_Array,selected
Dim Sql
Action = Trim(Request.QueryString("action"))
If Action="vote" and Session("MyUserName")<>"" and Session("MyPassWord")<>"" Then
If Request.Cookies("Vote")("UserName")=Session("MyUserName") Then
Response.Redirect "Vote.asp"
End if
Call VoteYes
Response.Cookies("Vote")("UserName") = Session("MyUserName")
Response.Redirect "Vote.asp"
Else
Set rs=Server.Createobject("Adodb.Recordset")
Sql = "Select top 1 * From [Vote]"
rs.Open Sql,Conn,1,1
%>
<html>
<title>调查结果</title>
<LINK href="ziyan/Style.css" type=text/css rel=stylesheet>
<body topmargin="0">
<table width="650" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#99CCFF">
  <tr> 
    <td height="25" colspan="2"> <div align="center"><strong><font color="#FFFFFF">调 
        查 结 果</font></strong></div></td>
  </tr>
  <tr> 
    <td width="100"><div align="center"><font color="#FFFFFF"><strong>调查内容：</strong></font></div></td>
    <td width="539"><font color="#FFFFFF"><%=rs("VoteTitel")%></font></td>
  </tr>
  <tr> 
    <td><div align="center"><strong><font color="#FFFFFF">总投票数：</font></strong></div></td>
    <td><font color="#FFFFFF"><%=rs("VoteCount")%></font></td>
  </tr>
  <tr> 
    <td colspan="2"><table width="85%" border="0" align="center" cellpadding="2" cellspacing="0">
        <tr> 
          <td width="32%"><font color="#FFFFFF">投票选项</font></td>
          <td width="13%"><div align="center"><font color="#FFFFFF">票数</font></div></td>
          <td width="55%"> <div align="center"><font color="#FFFFFF">百分比 </font></div></td>
        </tr>
<%Dim Vote_Array,Shu_Array
Dim cou,pesen
cou=rs("VoteCount")
Vote_Array=split(rs("Selectd"),"|")
Sel_Array=split(rs("SelCount"),"|")
For i=0 to Ubound(Vote_Array)-1
pesen = ( 100/cou )* Sel_Array(i)
%>
        <tr> 
          <td><font color="#FFFFFF"><%=Vote_Array(i)%></font></td>
          <td><div align="center"><font color="#333333"><%=Sel_Array(i)%></font></div></td>
          <td><div align="center"><img src="Image/topBar_bg.gif" width="<%=round(pesen*2)%>" height="10"><font color="#333333">
  <%Response.Write round(pesen) & "%"%>
	      </font></div></td>
        </tr>
<%Next%>
      </table></td>
  </tr>
  <tr> 
    <td colspan="2"><div align="center"><font color="#333333">
  <%If Session("MyUserName")="" or Session("MyPassWord")="" Then
Response.Write "您还没有登陆，请登陆后投下您宝贵的一票！"
Else
If Request.Cookies("Vote")("UserName")="" Then
Response.Write "您还没有投票，请投下您宝贵的一票！"
Else
If Response.Cookies("Vote")("UserName")=Session("MyUserName") Then
Response.Write "您已经投过票，请下次再投下您宝贵的一票！"
Else
Response.Write "多谢投下您宝贵的一票！"
End if
End if
End if
%>
    </font></div></td>
  </tr>
  <tr>
    <td height="25" colspan="2">
<div align="center"> 
        <input type="button" name="Submit" value="关闭窗口" onClick="javascript:window.close()">
      </div></td>
  </tr>
</table>
</body>
</html>
<%rs.Close
Set Conn=Nothing
Set rs=Nothing
End if
Sub VoteYes
Set rsv=Server.Createobject("Adodb.Recordset")
Sql = "Select * From [Vote] Where Vote_ID=1"
rsv.Open Sql,Conn,1,1
S_Array=split(rsv("Selectd"),"|")
Scou_Array=split(rsv("SelCount"),"|")
selected = ""
For i = 0 To Ubound(S_Array)-1
If Request.Form("sele") = S_Array(i) and InStr(rsv("Selectd"),Request.Form("sele")) > 0 Then
selected = selected & Scou_Array(i)+1 & "|"
Else
selected = selected & Scou_Array(i) & "|" 
End if
Next
Sql = "Update [Vote] Set [SelCount]='"&selected&"',[VoteCount] = VoteCount + 1"
Conn.Execute (Sql)
rsv.Close
Set Conn=Nothing
Set rsv=Nothing
End Sub
%>