📄 admin_vote.asp
字号:
<%@language=vbscript codepage=936 %>
<%
option explicit
response.buffer=true
Const PurviewLevel=2 '操作权限
%>
<%
if vartype(Session("admin"))=9 or vartype(Session("admin"))=0 then
Response.Write("<script>")
Response.Write("parent.location.href='admin/admin_login.asp'")
Response.Write("</script>")
end if
%>
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/function.asp"-->
<%
dim sql,rs,i
dim Action,FoundErr,ErrMsg
Action=Trim(Request("Action"))
%>
<html>
<head>
<title>调查管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="Style.css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="760" border="0" align="center" cellpadding="2" cellspacing="1" Class="border">
<tr class="topbg">
<td height="22" colspan=2 align=center><b>网 站 调 查 管 理</b></td>
</tr>
<tr class="tdbg">
<td width="70" height="30" bgcolor="#BCD2E7"><strong>管理导航:</strong></td>
<td height="30" bgcolor="#BCD2E7"><a href="Admin_Vote.asp">网站调查管理首页</a> | <a href="Admin_Vote.asp?Action=Add">添加新调查</a></td>
</tr>
</table>
<%
if Action="Add" then
call AddVote()
elseif Action="SaveAdd" then
call SaveAdd()
elseif Action="Modify" then
call Modify()
elseif Action="SaveModify" then
call SaveModify()
elseif Action="Set" then
call SetNew()
elseif Action="Del" then
call DelVote()
else
call main()
end if
if FoundErr=True then
call WriteErrMsg()
end if
call CloseConn()
sub main()
sql="select * from Vote order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%>
<form method="POST" action="Admin_Vote.asp">
<table width="760" border="0" align="center" cellpadding="2" cellspacing="1" Class="border">
<tr class="title">
<td width="30" height="22" align="center" bgcolor="#BCD2E7">选择</td>
<td width="30" height="22" align="center" bgcolor="#BCD2E7">ID</td>
<td height="22" align="center" bgcolor="#BCD2E7">主题</td>
<td width="60" height="22" align="center" bgcolor="#BCD2E7">操作</td>
</tr>
<%
if not (rs.bof and rs.eof) then
do while not rs.eof
%>
<tr class="tdbg">
<td width="30" align="center" bgcolor="#E8EFF7"><input type="radio" value=<%=rs("ID")%><%if rs("IsSelected")=true then%> checked<%end if%> name="ID"></td>
<td width="30" align="center" bgcolor="#E8EFF7"><%=rs("ID")%></td>
<td bgcolor="#E8EFF7"><%=rs("Title")%></td>
<td width="60" align="center" bgcolor="#E8EFF7"><%
response.write "<a href='Admin_Vote.asp?Action=Modify&ID=" & rs("ID") & "'>修改</a> "
response.write "<a href='Admin_Vote.asp?Action=Del&ID=" & rs("ID") & "'>删除</a>"
%></td>
</tr>
<%
rs.movenext
loop
%>
<tr class="tdbg">
<td colspan=4 align=center bgcolor="#E8EFF7"><input name="Action" type="hidden" id="Action" value="Set">
<input type="submit" value="将选定的调查设为最新调查" name="submit">
</td>
</tr>
<%
end if
%>
</table>
</form>
<%
rs.close
set rs=nothing
end sub
sub AddVote()
%>
<form method="POST" action="Admin_Vote.asp">
<table width="760" border="0" align="center" cellpadding="2" cellspacing="1" Class="border">
<tr class="title">
<td height="22" class="title" colspan=4 align=center><b>添 加 调 查</b></td>
</tr>
<tr bgcolor="#BCD2E7" class="tdbg">
<td width="15%" align="right" bgcolor="#E8EFF7">主题:</td>
<td width="85%" colspan="3" bgcolor="#E8EFF7"><textarea name="Title" cols="50" rows="4"></textarea></td>
</tr>
<%
for i=1 to 8%>
<tr bgcolor="#BCD2E7" class="tdbg">
<td align="right" bgcolor="#E8EFF7">选项<%=i%>:</td>
<td bgcolor="#E8EFF7"><input type="text" name="select<%=i%>" size="36">
</td>
<td align="right" bgcolor="#E8EFF7">票数:</td>
<td width="80" bgcolor="#E8EFF7"><input type="text" name="answer<%=i%>" size="5"></td>
</tr>
<%next%>
<tr bgcolor="#BCD2E7" class="tdbg">
<td align="right" bgcolor="#E8EFF7">调查类型:</td>
<td colspan="3" bgcolor="#E8EFF7"><select name="VoteType" id="VoteType">
<option value="Single" selected>单选</option>
<option value="Multi">多选</option>
</select></td>
</tr>
<tr bgcolor="#BCD2E7" class="tdbg">
<td align="right" bgcolor="#E8EFF7"> </td>
<td colspan="3" bgcolor="#E8EFF7"><input name="IsSelected" type="checkbox" id="IsSelected" value="True" checked>
设为最新调查</td>
</tr>
<tr bgcolor="#BCD2E7" class="tdbg">
<td colspan=4 align=center bgcolor="#E8EFF7"><input name="Action" type="hidden" id="Action" value="SaveAdd">
<input name="Submit" type="submit" id="Submit" value=" 添 加 ">
<input name="Reset2" type="reset" id="Reset2" value=" 清 除 "> </td>
</tr>
</table>
</form>
<%
end sub
sub Modify()
dim ID
ID=Trim(Request("ID"))
if ID="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>请指定调查IP</li>"
exit sub
else
ID=Clng(ID)
end if
sql="select * from Vote where ID="& ID
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
if rs.bof and rs.eof then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>找不到指定的调查!</li>"
rs.close
set rs=nothing
exit sub
end if
%>
<form method="POST" action="Admin_Vote.asp">
<table width="760" border="0" align="center" cellpadding="2" cellspacing="1" Class="border">
<tr class="title">
<td height="22" class="title" colspan=4 align=center><b>修 改 调 查</b></td>
</tr>
<tr class="tdbg">
<td width="15%" align="right" bgcolor="#E8EFF7">主题:</td>
<td width="85%" colspan="3" bgcolor="#E8EFF7"><textarea name="Title" cols="50" rows="4"><%=rs("Title")%></textarea></td>
</tr>
<%
for i=1 to 8%>
<tr class="tdbg">
<td align="right" bgcolor="#E8EFF7">选项<%=i%>:</td>
<td bgcolor="#E8EFF7"><input name="select<%=i%>" type="text" value="<%=rs("select"& i)%>" size="36">
</td>
<td align="right" bgcolor="#E8EFF7">票数:</td>
<td width="80" bgcolor="#E8EFF7"><input name="answer<%=i%>" type="text" value="<%=rs("answer"&i)%>" size="5"></td>
</tr>
<%next%>
<tr class="tdbg">
<td align="right" bgcolor="#E8EFF7">调查类型:</td>
<td colspan="3" bgcolor="#E8EFF7"><select name="VoteType" id="VoteType">
<option value="Single" <% if rs("VoteType")="Single" then %> selected <% end if%>>单选</option>
<option value="Multi" <% if rs("VoteType")="Multi" then %> selected <% end if%>>多选</option>
</select></td>
</tr>
<tr class="tdbg">
<td align="right" bgcolor="#E8EFF7"> </td>
<td colspan="3" bgcolor="#E8EFF7"><input name="IsSelected" type="checkbox" id="IsSelected" value="True" <% if rs("IsSelected")=true then response.write "checked"%>>
设为最新调查</td>
</tr>
<tr class="tdbg">
<td colspan=4 align=center bgcolor="#E8EFF7"><input name="Action" type="hidden" id="Action" value="SaveModify">
<input name="ID" type="hidden" id="ID" value="<%=rs("ID")%>">
<input name="Submit" type="submit" id="Submit" value="保存修改结果"> </td>
</tr>
</table>
</form>
<%
rs.close
set rs=nothing
end sub
%>
</body>
</html>
<%
sub SaveAdd()
dim Title,VoteTime,Action,IsSelected,i
Title=trim(request.form("Title"))
VoteTime=trim(request.form("VoteTime"))
if VoteTime="" then VoteTime=now()
IsSelected=trim(request("IsSelected"))
sql="select top 1 * from Vote"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
rs.addnew
rs("Title")=Title
for i=1 to 8
if trim(request("select"&i))<>"" then
rs("select"&i)=trim(request("select"&i))
if request("answer"&i)="" then
rs("answer"&i)=0
else
rs("answer"&i)=clng(request("answer"&i))
end if
end if
next
rs("VoteTime")=VoteTime
rs("VoteType")=request("VoteType")
if IsSelected="" then IsSelected=false
if IsSelected="True" then conn.execute "Update Vote set IsSelected=False where IsSelected=True"
rs("IsSelected")=IsSelected
rs.update
rs.close
set rs=nothing
call CloseConn()
Response.Redirect "Admin_Vote.asp"
end sub
sub SaveModify()
dim ID,Title,VoteTime,IsSelected
ID=Trim(Request("ID"))
if ID="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>请指定调查IP</li>"
exit sub
else
ID=Clng(ID)
end if
Title=trim(request.form("Title"))
VoteTime=trim(request.form("VoteTime"))
if VoteTime="" then VoteTime=now()
IsSelected=trim(request("IsSelected"))
if IsSelected="True" then
conn.execute "Update Vote set IsSelected=False where IsSelected=True"
end if
sql="select * from Vote where ID="& ID
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
if rs.bof and rs.eof then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>找不到指定的调查!</li>"
rs.close
set rs=nothing
exit sub
end if
rs("Title")=Title
for i=1 to 8
if trim(request("select"&i))<>"" then
rs("select"&i)=trim(request("select"&i))
if request("answer"&i)="" then
rs("answer"&i)=0
else
rs("answer"&i)=clng(request("answer"&i))
end if
else
rs("select"&i)=""
rs("answer"&i)=0
end if
next
rs("VoteTime")=VoteTime
rs("VoteType")=request("VoteType")
if IsSelected="" then IsSelected=false
rs("IsSelected")=IsSelected
rs.update
rs.close
set rs=nothing
call CloseConn()
Response.Redirect "Admin_Vote.asp"
end sub
sub SetNew()
dim ID
ID=Trim(Request("ID"))
if ID="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>请指定调查IP</li>"
exit sub
else
ID=Clng(ID)
end if
conn.execute "Update Vote set IsSelected=False where IsSelected=True"
conn.execute "Update Vote set IsSelected=True Where ID=" & ID
response.Write "<script language='JavaScript' type='text/JavaScript'>alert('设置成功!');</script>"
call main()
end sub
sub DelVote()
dim ID
ID=Trim(Request("ID"))
if ID="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>请指定调查IP</li>"
exit sub
else
ID=Clng(ID)
end if
conn.Execute "delete from Vote where ID=" & ID
Response.Redirect "Admin_Vote.asp"
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -