<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../../Include/Const.asp" -->
<!--#include file="../../Include/Conn1.asp" -->
<!--#include file="../CheckAdmin.asp"-->
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../Images/CssAdmin.css">
<script language="javascript" src="../inc/Admin.js"></script>
<script>
function show(id)
{
    if(document.all(id).style.display=='none')
    {
    document.all(id).style.display='block';
    }
else
    {
    document.all(id).style.display='none';
    }
}
</script>
<BODY>
<br />
<%
If Trim(Request.QueryString("Action"))="Modify" then
sql="select * from Angel_SetPicVote where Angel_Voteid="&Trim(Request("id"))
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
id=Trim(Request("id"))
Angel_VoteTitle=rs("Angel_VoteTitle")
Angel_VoteStart=rs("Angel_VoteStart")
Angel_VoteEnd=rs("Angel_VoteEnd")
Angel_VoteStyle=rs("Angel_VoteStyle")
Angel_VoteColor=rs("Angel_VoteColor")
Angel_Voteing=rs("Angel_Voteing")
rs.close
set rs=nothing
end If

If Trim(Request.QueryString("Action"))="SaveData" then
If Trim(Request("Angel_VoteStart"))>Trim(Request("Angel_VoteEnd")) then 
		Response.Write "<script language=""JavaScript"">alert('你的开始时间和结束时间不正确');" & "history.back()" & "</script>"
End If 
set rs=server.createobject("adodb.recordset")
if Trim(Request("id"))<>"" then
sql="select * from Angel_SetPicVote where Angel_Voteid="&Trim(Request("id"))
rs.open sql,conn,1,3
rs("Angel_VoteTitle")=Request("Angel_VoteTitle")
rs("Angel_VoteStart")=Request("Angel_VoteStart")
rs("Angel_VoteEnd")=Request("Angel_VoteEnd")
rs("Angel_VoteStyle")=Request("Angel_VoteStyle")
rs("Angel_Voteing")=Request("Angel_Voteing")
rs.update
rs.close
if Request("votecountss")<>"" then
for i=1 to Request("votecountss")
Angel_Voteid=Request("Angel_Voteid"&i&"")
sql="select * from Angel_SetPicVote where Angel_Voteid="&Angel_Voteid
rs.open sql,conn,1,3
rs("Angel_Voteing")=Request("Angel_Voteing")
rs("Angel_VoteTitle")=Request("Angel_VoteTitle"&i&"")
rs("Angel_VoteColor")=Request("Angel_VoteColor"&i&"")
rs.update
rs.close
next
end if
'新增投票选项
if Request("votecount")>0 then
for i=1 to Request("votecount")
sql="select * from Angel_SetPicVote"
rs.open sql,conn,1,3
rs.addnew
rs("Angel_VoteClass")=Request("id")
rs("Angel_VoteCount")=0
rs("Angel_Voteing")=Request("Angel_Voteing")
rs("Angel_VoteTitle")=Request("Angel_VoteTitless"&i&"")
rs("Angel_VoteColor")=Request("Angel_VoteColorss"&i&"")
rs.update
rs.close
next
end if
'修改结束
else
sql="select * from Angel_SetPicVote"
rs.open sql,conn,1,3
rs.addnew
rs("Angel_VoteTitle")=Request("Angel_VoteTitle")
rs("Angel_VoteStart")=Request("Angel_VoteStart")
rs("Angel_VoteEnd")=Request("Angel_VoteEnd")
rs("Angel_VoteStyle")=Request("Angel_VoteStyle")
rs("Angel_Voteing")=Request("Angel_Voteing")
rs("Angel_VoteClass")=0
rs.update
id=rs("Angel_Voteid")
'新增投票选项
if Request("votecount")>0 then
for i=1 to Request("votecount")
rs.addnew
rs("Angel_VoteClass")=id
rs("Angel_VoteCount")=0
rs("Angel_Voteing")=Request("Angel_Voteing")
rs("Angel_VoteTitle")=Request("Angel_VoteTitle"&i&"")
rs("Angel_VoteColor")=Request("Angel_VoteColor"&i&"")
rs.update
next
end if
end if
end if

'删除投票选项
If Trim(Request.QueryString("Action"))="Del" then
conn.execute "delete from Angel_SetPicVote where Angel_Voteid="&Request("id")
conn.execute "delete from Angel_SetPicVote where Angel_VoteClass="&Request("id")
response.redirect "Admin_SetPicVote.asp"
end if

If Trim(Request.QueryString("Action"))="VoteDel" then
conn.execute "delete from Angel_SetPicVote where Angel_Voteid="&Request("Voteid")
response.redirect "Admin_SetPicVote.asp"
end if
%>

<%
if Request("id")="" then
paget="添加新"
else
paget="修改照片投票"
end if
If Trim(Request.QueryString("Action"))="Add" or Trim(Request.QueryString("Action"))="Modify" then %>
<table class="border" width="95%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#628AE1">
  <form name="form1" action="Admin_SetPicVote.asp?action=SaveData&id=<%=Trim(Request("id"))%>" method="post">
    <input name="key" type="hidden" value="0">
    <tr>
      <td colspan="2" height="25"  nowrap bgcolor="#8DB4E9"><font color="#FFFFFF"><strong><%= paget %>项目</strong></font></td>
    </tr>
    <tr>
      <td width="200" height="25" align="right" bgcolor="#ffffff"  >项目标题：</td>
      <td bgcolor="#ffffff" ><input name="Angel_VoteTitle" type="text" size="40" value="<%= Angel_VoteTitle %>"></td>
    </tr>
    <tr>
      <td height="25" align="right" bgcolor="#ffffff" >投票方式：</td>
      <td bgcolor="#ffffff" >
        <input name="Angel_VoteStyle" type="checkbox" value="checkbox" checked />
        多选</td>
    </tr>
    <tr>
      <td height="25" align="right" bgcolor="#ffffff"  >投票状态：</td>
      <td bgcolor="#ffffff" ><input name="Angel_Voteing" type="radio" value="1" <% If Angel_Voteing=1 then %>checked<% End If %>>
        开
        <input name="Angel_Voteing" type="radio" value="0" <% If Angel_Voteing=0 then %>checked<% End If %>>
        关</td>
    </tr>
    <tr>
      <td height="25" align="right" bgcolor="#ffffff" >投票时间：</td>
      <td bgcolor="#ffffff" >开始于
  <script language=javascript> 
          var myDate=new dateSelector(); 
          myDate.year--; 
		  myDate.date; 
          myDate.inputName='Angel_VoteStart';  //注意这里设置输入框的name，同一页中日期输入框，不能出现重复的name。
		  myDate.showvalue='<%=Angel_VoteStart%>';
          myDate.display(); 
          </script>
        结束于
 <script language=javascript> 
		  myDate.year++; 
          myDate.year++;
          myDate.inputName='Angel_VoteEnd';  //注意这里设置输入框的name，同一页中的日期输入框，不能出现重复的name。 
		  myDate.showvalue='<%=Angel_VoteEnd%>';
          myDate.display(); 
          </script>
		</td>
    </tr>

    </tr>
    <tr align="center" valign="middle">
      <td bgcolor="#ffffff" ></td>
      <td align="left" bgcolor="#ffffff" ><input name="Submit" type="submit" value="<%= paget %>设置"></td>

    </tr>
  </form>
</table>

<% else %>
<table bgcolor="#628AE1" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
  <tr align="center">
    <td height="25" align="left" nowrap bgcolor="#8DB4E9" ><strong>投票主题</strong></td>
    <td nowrap bgcolor="#8DB4E9"><strong>开始时间</strong></td>
    <td nowrap bgcolor="#8DB4E9"><strong>结束时间</strong></td>
    <td nowrap bgcolor="#8DB4E9"><strong>投票方式</strong></td>
    <td nowrap bgcolor="#8DB4E9"><strong>投票状态</strong></td>
    <td nowrap bgcolor="#8DB4E9"><strong>编辑</strong></td>
  </tr>
<%
sql="select * from Angel_SetPicVote where Angel_VoteClass=0"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof then
Response.Write("")
else
while(not rs.eof)
%>
  <tr height="25">
    <td bgcolor="#ffffff" ><%= rs("Angel_VoteTitle") %></td>
    <td bgcolor="#ffffff" ><%= rs("Angel_VoteStart") %> 0:00:00</td>
    <td bgcolor="#ffffff" ><%= rs("Angel_VoteEnd") %> 0:00:00</td>
    <td bgcolor="#ffffff">多选投票</td>
    <td bgcolor="#ffffff"  >
<% If rs("Angel_Voteing")=1 then %>
<font color="blue">投票进行中</font>
<% Else %>
<font color="red">投票结束</font>
<% End If %>
</td>
    <td bgcolor="#ffffff" ><a href="Admin_SetPicVote.asp?action=Modify&id=<%= rs("Angel_Voteid") %>">修改</a>
<%
If rs("Angel_Voteing")=1 Then response.write "<font color=""blue"">投票已开启</font>" Else response.write "<font color=""red"">投票已关闭</font>" End If 
%>
	</td>
  </tr>
  <tr style="display: none;" id="<%= rs("Angel_Voteid") %>">
    <td height="25" colspan="8" bgcolor="#ffffff"  ></td>
  </tr>
  <tr id="daima<%= rs("Angel_Voteid") %>" style="display: none">
    <td colspan="8" bgcolor="#ffffff"  ><input type="text" value="<script language='javascript' src='ShowVote.Asp?Angel_Voteid=<%= rs("Angel_Voteid") %>'></script>" style="width: 60%">
      <br />
     </td>
  </tr>
<%
rs.movenext
wend
end if
rs.close
set rs=nothing
%>

</table>
<% End If %>
