<% Option Explicit %>
<!--#include file="../../Inc/Const.asp" -->
<!--#include file="../../Inc/Cls_DB.asp" -->
<%
Dim DBC,Conn
Set DBC = New DataBaseClass
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
if Not JudgePopedomTF(Session("Name"),"P0702") then Call ReturnError1()
    Conn.Execute("Update Vote set State=2 where EndTime<>'0' and EndTime<='"&Now()&"'")
	Dim RsVoteObj
	Set RsVoteObj = Server.CreateObject("ADODB.recordset")
	RsVoteObj.open "Select * from Vote order by AddTime desc",conn,1,1
		%>
		<html>
		<head>
		<link href="../../CSS/css.css" rel="stylesheet" type="text/css">
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
		<title>投票列表</title>
		</head>
		<script src="../JS/PublicJS.js" language="JavaScript"></script>
		<body topmargin="0" leftmargin="0" oncontextmenu="SelectVote();showMenu(MouseRightMenu);return false;"  ondragstart="return false;" onselectstart="//return false;">
		<table id="MainTable" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
		  <tr>
			<td valign="top">
		<table width="100%" onclick="SelectVote();" border="0" cellspacing="0" cellpadding="0">
		  <tr> 
			<td width="41%" class="ButtonList"><div align="center">项目名称</div></td>
			<td width="14%" class="ButtonList"><div align="center">类型</div></td> 
			<td width="11%" class="ButtonList"><div align="center">选项</div></td> 
			<td width="11%" class="ButtonList"><div align="center">状态</div></td> 
			<td width="23%" class="ButtonList"><div align="center">添加时间</div></td> 
		  </tr>
		  <%if RsVoteObj.eof then
		  	page_size = 20
		   %>
		  <tr> 
			<td colspan="5" ><div align="center"><font color="#FF0000">暂时没有投票项目</font></div></td>
		  </tr>
		  <% else
		  Dim page_size,page_no,page_total,record_all,PageNums
		page_size=Request.QueryString("page_size")
		if page_size<=0 or page_size="" then page_size=10
		If isnumeric(Request.Form("PageNums")) then
			if Request.Form("PageNums")<>0 then
				page_size = Cint(Request.Form("PageNums"))
			end if
		End if
		page_no=request.querystring("page_no")
		if page_no<=1 or page_no="" then page_no=1
		If Request.QueryString("page_no")="" then
			page_no=1
		end if
		RsVoteObj.PageSize=page_size
		page_total=RsVoteObj.PageCount
		if (cint(page_no)>page_total) then page_no=page_total
		RsVoteObj.AbsolutePage=page_no
		record_all=RsVoteObj.RecordCount
		Dim i
		for i=1 to RsVoteObj.PageSize
			if RsVoteObj.eof then exit for
			Dim Types,States
			If RsVoteObj("Type") = "0" then
				Types = "单选"
			else
				Types = "多选"
			end if
			Select case RsVoteObj("State")
			  Case "0" States="关闭"
			  Case "1" States="开启"
			  Case "2" States="过期"
			 End Select
		%>
		  <tr height="20" VoteID="<%=RsVoteObj("VoteID")%>" State="<%=RsVoteObj("State")%>" style="background:white;cursor:default;"> 
			<td><div align="left">&nbsp;&nbsp;&nbsp;<%=RsVoteObj("Name")%></div></td>
			<td><div align="center"><%=Types%></div></td>
			<td><div align="center"><%=RsVoteObj("OptionNum")%></div></td>
			<td><div align="center"><%=States%></div></td>
			<td><div align="center"><%=RsVoteObj("AddTime")%></div></td>
		  </tr>
		  <%
				RsVoteObj.MoveNext
			Next
			end if
			RsVoteObj.close
			set RsVoteObj=nothing
		%>
		</table></td></tr>
		<tr>
		<td valign="middle" height="10">
		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="ButtonList">
              <tr height="1">
                  <tr height="1">
                  <td width="42%" height="18"><table width="99%" border="0" cellspacing="0" cellpadding="0">
                      <tr><form name="PGNum" method="post" action="">
                        <td width="46%" valign="middle">   
                        <div align="right">每页记录条数:						  </div></td>  
                        <td width="21%" valign="bottom"><input name="PageNums" type="text" id="PageNums" size="10" value="<%=page_size%>">                          </td>
						<td width="33%" valign="top"><div align="center">
						  <input name="imageField" type="image" src="../Images/Submit.gif" border="0">
					    </div></td>
                      </form>
                      </tr>
                   </table> </td>
                
                <td width="51%" height="25" valign="middle"> <div align="right">
                    <% =  "NO.<b>"& page_no &"</b>,&nbsp;&nbsp;" %>
                    <% = "Totel:<b>"& page_total &"</b>,&nbsp;RecordCounts:<b>" & record_all &"</b>&nbsp;&nbsp;&nbsp;"%>
                    <%
						if Page_Total=1 then
								response.Write "&nbsp;<img src=../images/First1.gif border=0 alt=首页></img>&nbsp;"
								response.Write "&nbsp;<img src=../images/prePage.gif border=0 alt=上一页></img>&nbsp;"
								response.Write "&nbsp;<img src=../images/nextPage.gif border=0 alt=下一页></img>&nbsp;"
								response.Write "&nbsp;<img src=../images/endPage.gif border=0 alt=尾页></img>&nbsp;"
						else
							if cint(Page_No)<>1 and cint(Page_No)<>Page_Total then
								response.Write "&nbsp;<a href=?page_no=1&page_size="& page_size &"&Keywords="&Request("Keywords")&"><img src=../images/First1.gif border=0 alt=首页></img></a>&nbsp;"
								response.Write "&nbsp;<a href=?page_no="&cstr(cint(Page_No)-1)&"&page_size="&page_size&"&Keywords="&Request("Keywords")&"><img src=../images/prePage.gif border=0 alt=上一页></img></a>&nbsp;"
								response.Write "&nbsp;<a href=?page_no="&cstr(cint(Page_No)+1)&"&page_size="&page_size&"&Keywords="&Request("Keywords")&"><img src=../images/nextPage.gif border=0 alt=下一页></img></a>&nbsp;"
								response.Write "&nbsp;<a href=?page_no="& Page_Total &"&page_size="& page_size &"&Keywords="&Request("Keywords")&"><img src=../images/endPage.gif border=0 alt=尾页></img></a>&nbsp;"
							elseif cint(Page_No)=1 then
								response.Write "&nbsp;<img src=../images/First1.gif border=0 alt=首页></img></a>&nbsp;"
								response.Write "&nbsp;<img src=../images/prePage.gif border=0 alt=上一页></img>&nbsp;"
								response.Write "&nbsp;<a href=?page_no="&cstr(cint(Page_No)+1)&"&page_size="& page_size &"&Keywords="&Request("Keywords")&"><img src=../images/nextPage.gif border=0 alt=下一页></img></a>&nbsp;"
								response.Write "&nbsp;<a href=?page_no="& Page_Total &"&page_size="& page_size &"&Keywords="&Request("Keywords")&"><img src=../images/endpage.gif border=0 alt=尾页></img></a>&nbsp;"
							else
								response.Write "&nbsp;<a href=?page_no=1&page_size="& page_size &"&Keywords="&Request("Keywords")&"><img src=../images/First1.gif border=0 alt=首页></img>&nbsp;"
								response.Write "&nbsp;<a href=?page_no="&cstr(cint(Page_No)-1)&"&page_size="& page_size &"&Keywords="&Request("Keywords")&"><img src=../images/prePage.gif border=0 alt=上一页></img></a>&nbsp;"
								response.Write "&nbsp;<img src=../images/nextPage.gif border=0 alt=下一页></img></a>&nbsp;"
								response.Write "&nbsp;<img src=../images/endpage.gif border=0 alt=尾页></img>&nbsp;"
							end if
						end if
						%>
                </div></td>
                <td width="7%" valign="middle"><select onChange="ChangePage(this.value);" style="width:50;" name="select">
                  <% for i=1 to Page_Total %>
                  <option <% if cint(Page_No) = i then Response.Write("selected")%> value="<% = i %>">
                  <% = i %>
                  </option>
                  <% next %>
                </select></td>
              </tr>
              
            </table>
			</td>
			</tr>
		</table>
		<!-- 鼠标右键菜单 -->
		<div id=MouseRightMenu onclick="ClickMenu(this);" onmouseover="MouseOverRightMenu();" onmouseout="MouseOverRightMenu();" class="menu"> 
		  <div class="MouseRightItem" id="CreVote" ExeFunction="OpenWindow('VoteTip.asp?FileName=VoteAdd.asp&Titles=添加投票',350,300,window);">新建</div>
		  <div class="MouseRightItem" id="Edit" ExeFunction="OpenWindow('VoteTip.asp?FileName=VoteModify.asp&Titles=修改投票项目&VoteID='+VoteID,350,300,window);">修改</div>
		  <div class="MouseRightItem" id="Del" ExeFunction="OpenWindow('VoteTip.asp?FileName=VoteDell.asp&Types=Dell&Titles=删除投票项目&VoteID='+VoteID,220,105,window);">删除</div>
		  <hr id="HR1">
		  <div class="MouseRightItem" id="Open" ExeFunction="OpenWindow('VoteTip.asp?FileName=VoteDell.asp&Types=Open&Titles=投票项目属性设置&VoteID='+VoteID,320,110,window);">开启</div>
		  <div class="MouseRightItem" id="Close" ExeFunction="OpenWindow('VoteTip.asp?FileName=VoteDell.asp&Types=Close&Titles=投票项目属性设置&VoteID='+VoteID,320,110,window);">关闭</div>
		  <hr id="HR3">
		  <div class="MouseRightItem" id="Result" ExeFunction="OpenWindow('VoteTip.asp?FileName=../../Vote/VoteResult.asp&Titles=查看投票结果&VoteID='+VoteID,420,200,window);">查看结果</div>
		  <div class="MouseRightItem" id="Code" ExeFunction="OpenWindow('VoteTip.asp?FileName=VoteCode.asp&Types=Code&Titles=调用代码&VoteID='+VoteID,500,130,window);">调用代码</div>
		  <hr id="HR5">
		  <div class="MouseRightItem" id="Refresh" ExeFunction="window.location.reload();">刷新</div>
		   <hr id="HR6">
		  <div class="MouseRightItem" id="Pros" ExeFunction="javascript:window.prompt('本页面路径属性' , '<%=Request.ServerVariables("SCRIPT_NAME")%>');">路径属性</div>
		</div>
		</body>
		</html>
		<%
		Set Conn = Nothing
		%>
		<script>
var DisableOrActiveMenuArrayNo=new Array();
DisableOrActiveMenuArrayNo[0]=Edit;
DisableOrActiveMenuArrayNo[1]=Del;
DisableOrActiveMenuArrayNo[2]=Open;
DisableOrActiveMenuArrayNo[3]=Close;
DisableOrActiveMenuArrayNo[4]=Result;
DisableOrActiveMenuArrayNo[5]=Code;

DisableMenu(DisableOrActiveMenuArrayNo);

function SelectVote()
{
	var i=0,j=0;
	var EventObj=event.srcElement;
	var TRObj;
	switch (EventObj.tagName.toLowerCase())
	{
		case 'div':
			TRObj=EventObj.parentElement.parentElement;
			break;
		case 'td':
			TRObj=EventObj.parentElement;
			break;
		case 'tr':
			TRObj=EventObj;
			break;
		default:
			return;
	}
	for (j=0;j<document.all.length;j++)
	{
		if (document.all(j).style.backgroundColor=='highlight')
		{
			document.all(j).style.backgroundColor='';
			for (i=0;i<document.all(j).children.length;i++) document.all(j).children(i).style.color='black';
		}
	}
	if (TRObj.VoteID!=null) VoteID=TRObj.VoteID;
	else VoteID='';
	if (VoteID!='')
	{
		TRObj.style.backgroundColor='highlight';
		if (TRObj.State=='1')
			{
			Open.className='MenuItemDisable';
			Close.className='MouseRightItem';
			}
		if (TRObj.State=='0')
			{
			Open.className='MouseRightItem';
			Close.className='MenuItemDisable';
			 }
		if (TRObj.State=='2')
			{
			Open.className='MenuItemDisable';
			Close.className='MenuItemDisable';
			 }
	    Edit.className='MouseRightItem';
		Del.className='MouseRightItem';
		Result.className='MouseRightItem';
		Code.className='MouseRightItem';
		for (i=0;i<TRObj.children.length;i++) TRObj.children(i).style.color='white';
	}
	else
	{
		VoteID='';
	    Edit.className='MenuItemDisable';
		Del.className='MenuItemDisable';
		Close.className='MenuItemDisable';
		Open.className='MenuItemDisable';
		Result.className='MenuItemDisable';
		Code.className='MenuItemDisable';
	}
}
function ChangePage(PageNum)
{
	var page_size;
	page_size=<% = page_size %>;
	window.location.href='?page_no='+PageNum+'&page_size='+page_size;
}
		</script>
