<%
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"
sql=sql & " where ChannelID=" & Channel
sql=sql & " order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%>
<%
rs.close
set rs=nothing
end sub
sub AddVote()
%>
<%
end sub
sub Modify()
dim ID
ID=Trim(Request("ID"))
if ID="" then
FoundErr=True
ErrMsg=ErrMsg & "
请指定调查IP
"
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 & "
找不到指定的调查!
"
rs.close
set rs=nothing
exit sub
end if
%>
<%
rs.close
set rs=nothing
end sub
%>
<%
sub SaveAdd()
dim Title,VoteTime,Action,IsSelected,ChannelID,i
Title=trim(request.form("Title"))
VoteTime=trim(request.form("VoteTime"))
if VoteTime="" then VoteTime=now()
IsSelected=trim(request("IsSelected"))
ChannelID=Clng(request("ChannelID"))
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 and ChannelID=" & ChannelID & ""
rs("IsSelected")=IsSelected
rs("ChannelID")=ChannelID
rs.update
rs.close
set rs=nothing
call CloseConn()
Response.Redirect "admin_Vote.asp?Channel="&ChannelID
end sub
sub SaveModify()
dim ID,Title,VoteTime,IsSelected,ChannelID
ID=Trim(Request("ID"))
if ID="" then
FoundErr=True
ErrMsg=ErrMsg & "
请指定调查IP
"
exit sub
else
ID=Clng(ID)
end if
Title=trim(request.form("Title"))
VoteTime=trim(request.form("VoteTime"))
if VoteTime="" then VoteTime=now()
ChannelID=Clng(request("ChannelID"))
IsSelected=trim(request("IsSelected"))
if IsSelected="True" then
conn.execute "Update Vote set IsSelected=False where IsSelected=True and ChannelID=" & ChannelID & ""
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 & "
找不到指定的调查!
"
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("ChannelID")=ChannelID
rs.update
rs.close
set rs=nothing
call CloseConn()
Response.Redirect "admin_Vote.asp?Channel="&ChannelID
end sub
sub SetNew()
dim ID
ID=Trim(Request("ID"))
if ID="" then
FoundErr=True
ErrMsg=ErrMsg & "
请指定调查IP
"
exit sub
else
ID=Clng(ID)
end if
conn.execute "Update Vote set IsSelected=False where IsSelected=True and ChannelID=" & Channel & ""
conn.execute "Update Vote set IsSelected=True Where ID=" & ID
response.Write ""
call main()
end sub
sub DelVote()
dim ID
ID=Trim(Request("ID"))
if ID="" then
FoundErr=True
ErrMsg=ErrMsg & "
请指定调查IP
"
exit sub
else
ID=Clng(ID)
end if
conn.Execute "delete from Vote where ID=" & ID
Response.Redirect strFileName
end sub
%>