<%
if Request.Cookies("admindj")<>"1" then
   Response.Write "<BR><BR><BR><BR><center>权限不足，你没有此功能的管理权限"
   Response.end
end if
%>
<!--#include file = admin_chk.asp -->
<!--#include file = admin_conn.asp -->
<!--#include file = titleb.asp -->
<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<!--#include file = language.asp -->
<title></title>
<STYLE type="text/css">
<!--
a:link       {text-decoration: none; font-family: AdobeSm; color: #000000 }
a:visited    {text-decoration: none; color: #000000 }
A:hover      {COLOR: green; FONT-FAMILY: "宋体,MingLiU"; TEXT-DECORATION: underline}
body         {font-size: 9pt; font-family: 宋体,MingLiU, Arial;color: #000000}
TD           {FONT-SIZE: 9pt; FONT-FAMILY: "宋体,MingLiU, Arial";color: #000000;table-layout:fixed;word-break:break-all}
p            {FONT-SIZE: 9pt; FONT-FAMILY: "宋体,MingLiU, Arial";color: #000000}
input        {FONT-SIZE: 9pt; FONT-FAMILY: "宋体,MingLiU, Arial";color: #000000}
body         {margin-top: 0; margin-bottom: 0;margin-left:0;margin-right:0; color: #000000}
select       {FONT-SIZE: 9PT;}
option       {FONT-SIZE: 9pt;}
textarea     {FONT-SIZE: 9pt;}
-->
</STYLE>
</head>
<%
delid=trim(Request("delid"))
editid=trim(Request("editid"))
saveid=trim(Request("saveid"))
title=trim(Request("title"))
endtime=trim(Request("endtime"))
DD=trim(Request("DD"))
sj=date()
eendtime=date()

if delid<>"" then
	conn.Execute "delete from [tp] where ID="&CInt(delid)
	conn.Execute "delete from [tptitle] where tpID="&CInt(delid)
end if

if editid="" and saveid="" and title<>"" and DD<>"" then
	conn.Execute "insert into [tp] ([title],[dd],[addtime],[endtime]) values('"&title&"','"&dd&"','"&sj&"','"&endtime&"')"
elseif editid<>"" and saveid="" and title="" and dd="" then
	set rs = Server.CreateObject("ADODB.RecordSet")
	rs.Open "select * from [tp] where id="&editid&" order by id desc",conn,1,1
	if rs.recordcount<>0 then
		etitle=rs("title")
		eendtitle=rs("endtime")
		DD=rs("DD")
	end if
	rs.close:set rs=nothing
elseif saveid<>"" and title<>"" and DD<>"" then
	conn.Execute "update [tp] set [title]='"&title&"',[DD]='"&DD&"',endtime='"&endtime&"' where id="&clng(saveid)
end if
%>
<body>
<br><center>
<form method="POST" action="admin_tp.asp?saveid=<%=editid%>">
	标题：<input type="text" name="title" size="40" value='<%=etitle%>'> <select size="1"  name="DD">
	<option value="1">单项选择</option>
	<option value="2">多项选择</option>
	</select><br>结束时间：<input type="text" name="endtime" value='<%=eendtime+7%>' size="20"> <input type="submit" value="保存后再增加选项" name="B1">
</form>
</center>

<div align="center">
	<table border="1" cellpadding="2" width="700" id="table1" style="border-collapse: collapse" bordercolor="#C0C0C0">
		<tr>
			<td height="25" background="../images/bj3.jpg" align="center" width="467">投票标题</td>
			<td height="25" background="../images/bj3.jpg" align="center" width="76">投票数</td>
			<td height="25" background="../images/bj3.jpg" align="center" width="141">操作</td>
		</tr>
<%
set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open "select * from [tp] order by id asc",conn,1,1
while not rs.eof
%>
		<tr>
			<td width="467">
			<%
				DD=rs("DD")
				if DD=1 then 
					Response.Write "[单项选择]"
				else
					Response.Write "[多项选择]"
				end if
			%>
			<%=rs("title")%><br><font color=red>&lt;script </font>
			<font color="#FF0000">TYPE=&quot;text/javascript&quot;</font><font color=red> language=&quot;javascript&quot; 
			src=&quot;<%=finddir(request.servervariables("URL"))%>js-tp.asp?id=<%=rs("id")%>&quot;&gt;&lt;/script&gt;</font></td>
			<td width="76" align=center>
				<%	
					set rssum = Server.CreateObject("ADODB.RecordSet")
					rssum.Open "select sum(tps) as f_sum from [tptitle] where tpid="&rs("id")&" ",conn,1,1
					Response.Write rssum(0)
					rssum.close:set rssum=nothing
				%>
			</td>
			<td align=center width="141">
			<a href="admin_tp2.asp?tpid=<%=rs("id")%>">可选择项</a>　<a href="admin_tp.asp?editid=<%=rs("id")%>">修改</a>　<a onclick='{if(confirm("您确定删除吗?此操作将不能恢复!")){return true;}return false;}' href="admin_tp.asp?delid=<%=rs("id")%>">删除</a></td>
		</tr>
<%
rs.movenext
wend
rs.close:set rs=nothing
%>
	</table>
</div>

</body>

</html>
<%
conn.close:set conn=nothing
%>