<!-- #Include File="../Include/Skin.asp" -->
<%
'=======================================================
' 欢迎使用《阿赛大型门户网站系统V3.0》，简称“AsaiMHV3”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================

Dim vid
vid=Cls.Code_ID("vid")
tit="查看投票结果"
if action="ballot" then tit="投上一票"
call DoWebHead(0,2)
Cls.LoadTemplate(0)
Response.write Cls.ReHtml(ShowWebHead(1),1)
%>
  <table border=0 cellspacing=0 cellpadding=0 width='500px' height='100%'>
  <tr valign="top"><td align=center>
<%
if int(vid)<1 then
  Response.Write "<font class=red>投票（ID："&vid&"）不符合ID规则！</font>"
else
  select case action
  case "ballot"
    call AsaiMHVote_Ballot()
  case else
    call AsaiMHVote_View()
  end select
End If
%>
  </td></tr>
  <tr><td height=30 align=center><%call web_copy()%></td></tr>
  </table>
<%
'call web_copy()
Response.write Cls.ReHtml(ShowWebEnd(1),1)
Call DoWebEnd()
sub AsaiMHVote_Ballot()
  dim Vote_id,vtype,vdim,vtmp
  Vote_ID=trim(request.form("Vote_ID"))
  if Vote_ID="" or isnull(Vote_ID) then
    Response.Write "<br /><br /><br /><br /><font class=red>投票项不能为空！！！</font>"
    exit sub
  End If
  sql="select top 1 vtype From [AsaiMHVote] where vid="&vid&" and vtype<>1 order by id"
  set rs=Cls.exec(sql,1)
  vtype=rs(0)
  rs.close
  if int(vtype)<>2 then
    if not Cls.Is_Int(Vote_ID) then
      Response.Write "<br /><br /><br /><br /><font class=red>投票参数有错误！你是不是搞错了？！</font>"
      exit sub
    End If
  End If
  vtmp="<br /><br /><a href='?type=view&vid="&vid&"'>查看投票结果</a><br /><br /><font class=Gys>（系统将在 "&Format_Mid_Num(25)&" 秒钟后自动返回）</font><br /><meta http-equiv='refresh' content='"&Format_Mid_Num(25)&"; url=?type=view&vid="&vid&"'>"
  if trim(request.cookies(Cls.web_cookies)("[AsaiMHVote]_vid"))="v"&vid then
    Response.Write "<br /><br /><br /><br /><font class=red2>您已经投过一票！不可以重复多投……</font>"&vtmp
    exit sub
  End If
  response.cookies(Cls.web_cookies)("[AsaiMHVote]_vid")="v"&vid
  if int(vtype)<>2 then
    call Cls.exec("update [AsaiMHVote] set counter=counter+1 where vid="&vid&" and id="&Vote_ID,0)
    Response.Write "<br /><br /><br /><br /><font class=red>投票成功！谢谢你的支持和参与！</font>"&vtmp
    exit sub
  End If
  Vote_ID=replace(Vote_ID," ","")
  vdim=split(Vote_ID,",")
  for i=0 to ubound(vdim)
    if Cls.Is_Int(vdim(i)) then
      call Cls.exec("update [AsaiMHVote] set counter=counter+1 where vid="&vid&" and id="&vdim(i),0)
    End If
  next
  Response.Write "<font class=red>投票成功！谢谢你的支持和参与！</font>"&vtmp
End Sub
sub AsaiMHVote_View()
  dim vdim,vnum,vsum,nwid,nper
  sql="select vname,counter,tcolor From [AsaiMHVote] where vid="&vid&" order by id"
  set rs=Cls.exec(sql,1)
  if rs.eof then
    rs.close
    Response.Write "<font class=red>投票（ID："&vid&"）不存在！你是不是搞错了？！</font>"
    exit sub
  End If
  vdim=rs.getrows()
  rs.close
  vnum=ubound(vdim,2)
  vsum=0
  for i=0 to vnum
    vsum=vsum+vdim(1,i)
  next
%>
<table border=0 cellspacing=1 cellpadding=2 class=table>
<tr><td  class=td colspan=5 height=30 align=center><font class=blue size=3><b><%Response.Write vdim(0,0)%></b></font></td></tr>
<tr class=tre><td colspan=5 align=center>目前共有 <font class=red><%Response.Write vsum%></font> 人参与了投票</td></tr>
<tr>
<td class=trp width=10></td>
<td class=trp width=120></td>
<td class=trp width=*></td>
<td class=trp width=30></td>
<td class=trp width=40></td>
</tr>
<%
  for i=1 to vnum
    nwid=1
    nper="0%"
    if int(vdim(1,i))>0 then
      nwid=cint(replace(formatpercent(vdim(1,i)/vsum),"%",""))*1.5
      nper=formatpercent(vdim(1,i)/vsum,2)
    End If
%>
<tr height=24 class=tr>
<td class=tims align=center><%Response.Write i%></td>
<td><font color=<%Response.Write vdim(2,i)%>><%Response.Write vdim(0,i)%></font></td>
<td><img src='<%=Cls.Web_Dir%>images/Vote/vb<%Response.Write i%>.gif' border=0 height=10 width='<%Response.Write nwid%>'></td>
<td class=tims align=right><font class=blue><%Response.Write vdim(1,i)%></font>票</td>
<td class=tims><%Response.Write nper%></td>
</tr>
<%
  next
  erase vdim
%>
</table>
<%
End Sub
%>
