<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.Collection,java.util.Iterator"%>
<%@ page import="com.wxpn.tutorial.servlet.Question"%>
<%@ page import="com.wxpn.tutorial.servlet.Item"%>
<%if (session.getAttribute("userName") == null) {
				response.sendRedirect("/Vote/admin/login.jsp");
			}%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>浏览投票项目</title>
<script type="text/javascript">
function confirmDelete(id){
	if(window.confirm("您真的要彻底删除吗?")){
		window.location="DeleteVoteServlet?id="+id;
	}
}
</script>
</head>

<body>
<center>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
	<tr>
		<td width="50%" bgcolor="#0000FF" height="35" align=center><b><font
			color="#FFFFFF">浏览投票项目 </font></b></td>
		<td width="50%" bgcolor="#0000FF" height="35" align=center>[<a
			href="admin/addVote.jsp"><b><font
			color="#FF6600">添加投票项目</font></b></a>]|[<a href=/Vote/index.jsp><b><font
			color="#FF6600">投票界面首页</font></b></a>]</td>
	</tr>
</table>
<table border="1" width="100%" bordercolorlight="#C0C0C0"
	bordercolordark="#FFFFFF" cellspacing="0" cellpadding="0">
	<tr>
		<td width="5%" bgcolor="#FCCCCC">编号</td>
		<td width="40%" bgcolor="#FCCCCC">主题</td>
		<td width="10%" bgcolor="#FCCCCC">投票总数</td>
		<td width="12%" bgcolor="#FCCCCC">开始时间</td>
		<td width="12%" bgcolor="#FCCCCC">结束时间</td>
		<td width="10%" bgcolor="#FCCCCC">状态</td>
		<td width="10%" bgcolor="#FCCCCC">&nbsp;</td>
	</tr>
	<%if (request.getAttribute("c") == null) {

			%>
	<tr>
		<td width="75%" colspan=5 bgcolor="#FCFCFC" align=center>还没有任何投票项目。</td>
	</tr>
	<%} else {
				Collection c = (Collection) request.getAttribute("c");
				if (c == null) {

				%>
	<tr>
		<td width="75%" colspan=5 bgcolor="#FCFCFC" align=center>还没有任何投票项目。</td>
	</tr>
	<%} else {
					int totalPageNum = ((Integer) (request
							.getAttribute("totalPageNum"))).intValue();
					int currentPage = 1;
					if (request.getParameter("page") != null) {
						currentPage = Integer.parseInt(request
								.getParameter("page"));
					}
					Iterator iterator = c.iterator();
					while (iterator.hasNext()) {
						Question question = (Question) iterator.next();

						%>
	<tr>
		<td width="5%" bgcolor="#FCFCFC"><a
			href="ShowVoteServlet?page=showvote.jsp&id=<%=question.getId()%>"><%=question.getId()%></a></td>
		<td width="40%" bgcolor="#FCFCFC"><a
			href="ShowVoteServlet?page=showvote.jsp&id=<%=question.getId()%>"><%=question.getTitle()%></a></td>
		<td width="10%" bgcolor="#FCFCFC"><%=question.getVotecount()%></td>
		<td width="12%" bgcolor="#FCFCFC"><%=question.getStrStartime()%></td>
		<td width="12%" bgcolor="#FCFCFC"><%=question.getStrEndtime()%></td>
		<td width="10%" bgcolor="#FCFCFC"><%=question.getActive() == 0 ? "已关闭"
										: "正常"%></td>
		<td width="10%" bgcolor="#FCFCFC"><a
			href="EditVoteServlet?id=<%=question.getId()%>">修改</a>|<a
			href="javascript:confirmDelete(<%=question.getId()%>)">删除</a></td>
	</tr>
	<%}%>
	<tr>
		<td width="75%" colspan=8 align=right height="50" bgcolor="#EFEFEF"><%if (totalPageNum > 1) {%>
		<a href="BrowseVoteServlet?type=admin&page=1">首页</a>|<a
			href="BrowseVoteServlet?type=admin&page=<%=currentPage>1?currentPage-1:1 %>">上一页</a>|<a
			href="BrowseVoteServlet?type=admin&page=<%=currentPage<totalPageNum?currentPage+1:totalPageNum %>">下一页</a>|<a
			href="BrowseVoteServlet?type=admin&page=<%=totalPageNum%>">末页</a> <%}

				%>
	</tr>
	<%}
			}

		%>
	<tr>
		<td width="75%" colspan=8 align=center height="50" bgcolor="#EFEFEF">
		[<a href="admin/addVote.jsp">添加投票项目</a>]
	</tr>
</table>
</center>
</body>
</html>
