vote.asp

来自「1.支持文章」· ASP 代码 · 共 189 行

ASP
189
字号
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="Conn.asp"-->
<!--#include file="SysCls/KS_CommonCls.asp"-->
<%
'===================================================================================================================
'软件名称:科汛网站管理系统
'当前版本:科汛网站管理系统 V2.2 0628 Free
'Copyright (C) 2006-2008 Kesion.Com  All rights reserved.
'产品咨询QQ:9537636,41904294
'技术支持QQ:111394,54004407 
'程序版权:科汛网络
'程序开发:科汛网络开发组(总策划:林文仲)
'E-Mail  :kesioncms@hotmail.com webmaster@kesion.com
'官方网站:http://www.kesion.com  
'演示站点:http://test.kesion.com 
'郑重声明:
'    ①、免费版本请在程序首页保留版权信息,并做上本站LOGO友情连接,商业版本无此要求;
'    ②、任何个人或组织不得在授权允许的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息;
'    ③、科汛网络保留此软件的法律追究权利
'===================================================================================================================
Dim KSCls
Set KSCls = New Vote
KSCls.Execute()
Set KSCls = Nothing

Class Vote
        Private KSCMS
		Private Sub Class_Initialize()
		  Set KSCMS=New CommonCls
		End Sub
        Private Sub Class_Terminate()
		 Call KSCMS.CloseConn()
		 Set KSCMS=Nothing
		End Sub
		Sub Execute()
			dim Action,ID,VoteType,VoteOption,sqlVote,rsVote
			Action=trim(KSCMS.G("Action"))
			ID=Trim(KSCMS.G("ID"))
			VoteType=Trim(KSCMS.G("VoteType"))
			VoteOption=trim(KSCMS.G("VoteOption"))
			If Action = "Vote" And Id<> "" And VoteOption<>"" And Session("Voted") = "" Then
				if VoteType="Single" then
					conn.execute "Update KS_Vote set answer" & VoteOption  & "= answer" & VoteOption & "+1 where ID=" & ID
				else
					dim arrOptions
					if instr(VoteOption,",")>0 then
						arrOptions=split(VoteOption,",")
						dim i
						for i=0 to ubound(arrOptions)
							conn.execute "Update KS_Vote set answer" & cint(trim(arrOptions(i)))  & "= answer" & cint(trim(arrOptions(i))) & "+1 where ID=" & Clng(ID)
						next
					else
						conn.execute "Update KS_Vote set answer" & VoteOption  & "= answer" & VoteOption & "+1 where ID=" & Clng(ID)
					end if
				end if
				session("Voted")="True"
			End If
			if ID<>"" then
				sqlVote="Select * From KS_Vote Where ID=" & Clng(ID)
			else
				sqlVote="select top 1 * From KS_Vote order by NewestTF desc"
			end if
			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="skin/style.css" rel=stylesheet>
			</HEAD>
			<BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
            <table width="700" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
				<tr> 
					<td valign="top">
			<%
			if Action="Vote" and session("voted")<>"" then
				Response.Write "<font color='#FF0000' size='4'>"
				if Request.Cookies(KSCMS.SiteSn)("UserName")<>"" then Response.Write Request.Cookies(KSCMS.SiteSn)("UserName") & ","
				Response.Write "<br><br>&nbsp;&nbsp;非常感谢您的投票!</font><br>"
			end if
			%>
						<table width="600" border="0" align="center" cellpadding="2" cellspacing="0" class="border">
							<tr align="center" class="title"> 
								<td height="35" colspan="3"><strong>调 查 结 果</strong></td>
							</tr>
							<tr class="tdbg">
								<td>
									<table width="600" border="0" align="center" cellpadding="0" cellspacing="2">
										<tr> 
											<td width="140" align="right"><div align="center"><strong>调查内容:</strong></div></td>
											<td colspan="2"><%=rsVote("Title")%></td>
										</tr>
										<tr> 
											<td width="140" align="right"><div align="center"><strong>总投票数:</strong></div></td>
											<td colspan="2"
			> 
			<%
			  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
			%>
			</td>
										</tr>
										<tr> 
											<td colspan="3" align="center">&nbsp;</td>
										</tr>
										<tr> 
											<td width="140" align="center"><strong>投票选项</strong></td>
											<td width="64" align="right"><div align="center"><strong>票数</strong></div></td>
											<td width="388" align="center"><strong>百分比</strong></td>
										</tr>
			<%
			  for i=1 to 8
				if trim(rsVote("Select" & i) & "")="" then exit for
			%>
										<tr> 
											<td width="140" align="right"><div align="center"><font color="#ff6600"><%=rsVote("Select"& i)%></font> </div></td>
											<td align="right"> 
			<div align="center"><%
			Response.Write rsVote("answer"& i)
			%>
			</div></td>
											<td> 
			<%
			dim perVote
			perVote=round(rsVote("answer"& i)/totalVote,4)
			Response.Write "<img src='Skin/Default/bar.gif' width='" & round(360*perVote) & "' height='15' align='absmiddle'>"
			perVote=perVote*100
			if perVote<1 and perVote<>0 then
				Response.Write "&nbsp;0" & perVote & "%"
			else
				Response.Write "&nbsp;" & perVote & "%"
			end if
			%>
											</td>
										</tr>
			<% next %>
									</table>
								</td>
							</tr>
						</table>
			<%
			if session("voted")="" then 
					if Request.Cookies(KSCMS.SiteSn)("UserName")<>"" then
						Response.Write Request.Cookies(KSCMS.SiteSn)("UserName") & ","
					end if 
					Response.Write "<br><br>&nbsp;&nbsp;&nbsp;&nbsp;您还没有投票,请您在此投下您宝贵的一票!"
					Response.Write "<form name='VoteForm' method='post' action='vote.asp'>"
					Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;" & rsVote("Title") & "<br>"
					if rsVote("VoteType")="Single" then
						for i=1 to 8
							if trim(rsVote("Select" & i) & "")="" then exit for
							Response.Write "<input type='radio' name='VoteOption' value='" & i & "'>" & rsVote("Select" & i) & "<br>"
						next
					else
						for i=1 to 8
							if trim(rsVote("Select" & i) & "")="" then exit for
							Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;<input type='checkbox' name='VoteOption' value='" & i & "'>&nbsp;" & rsVote("Select" & i) & "<br>"
						next
					end if
					Response.Write "<br><input name='VoteType' type='hidden'value='" & rsVote("VoteType") & "'>"
					Response.Write "<input name='Action' type='hidden' value='Vote'>"
					Response.Write "<input name='ID' type='hidden' value='" & rsVote("ID") & "'>"
					Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:VoteForm.submit();'><img src='Skin/Default/voteSubmit.gif' width='52' height='18' border='0'></a>&nbsp;&nbsp;"
					Response.Write "<a href='Vote.asp?ID=" & rsVote("ID") & "&Action=Show' target='_blank'><img src='Skin/Default/voteSubmit.gif' width='52' height='18' border='0'></a>"
					Response.Write "</form>"
			end if
			%>
			<p align="center">【<a href="javascript:window.close();">关闭窗口</a>】<br>
			<br></p>
					</td>
				</tr>
			</table>
			</BODY></HTML>
			<%
			rsVote.Close()
			Set rsVote = Nothing
    End Sub
End Class
			%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?