<%@ page language="java" contentType="text/html; charset=GB2312"
	pageEncoding="GB2312"%>
<%@ page import="java.util.Collection,java.util.Iterator"%>
<%@ page import="com.wxpn.tutorial.ec.bean.ECOrder"%>
<%@ page import="com.wxpn.tutorial.ec.bean.ECOrderItem"%>
<%@ include file="../include/header.jsp"%>
<%if (session.getAttribute("username") == null
					|| session.getAttribute("username") == "") {
				response.sendRedirect("../member/login.jsp?url="
						+ request.getRequestURI());
			}

			%>
<html>
<head>
<title>订单列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF">
<div align="center">
<table width="80%" border="0" bgcolor="#CCCCFF">
	<tr bgcolor="#9999FF">
		<td colspan="2">
		<div align="center"><b>订 单 列 表</b></div>
		</td>
	</tr>
</table>
<table width="80%" border="0" align="center">

	<%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="" 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()) {
						ECOrder order = (ECOrder) iterator.next();

						%>
	<tr>
		<td colspan=2 bgcolor="#FFCCCC">订单号:</td>
		<td colspan=2 bgcolor="#CCFFCC"><%=order.getId()%></td>		
	</tr>
	<tr>
		<td width="15%" bgcolor="#FFCCCC">姓名:</td>
		<td width="35%" bgcolor="#CCFFCC"><%=session.getAttribute("username")%></td>
		<td width="15%" bgcolor="#FFCCCC">身份证：</td>
		<td width="35%" bgcolor="#CCFFCC"><%=order.getUsercid()%></td>
	</tr>
	<tr>
		<td width="15%" bgcolor="#FFCCCC">住址：</td>
		<td width="35%" bgcolor="#CCFFCC"><%=order.getUseraddress()%></td>
		<td width="15%" bgcolor="#FFCCCC">电话:</td>
		<td width="35%" bgcolor="#CCFFCC"><%=order.getUserphone()%></td>
	</tr>
	<tr bgcolor="#FFCCCC">
		<td width="15%">
		<div align="center"><font color="#0000FF">购买数量</font></div>
		</td>
		<td width="35%">
		<div align="center"><font color="#0000FF">书名</font></div>
		</td>
		<td width="15%">
		<div align="center"><font color="#0000FF">单价</font></div>
		</td>
		<td width="35%">
		<div align="center"><font color="#0000FF">总价格</font></div>
		</td>
	</tr>
	<%Collection c2 = order.getItem();
						Iterator iterator2 = c2.iterator();
						double allprice = 0;
						while (iterator2.hasNext()) {
							ECOrderItem orderitem = (ECOrderItem) iterator2
									.next();

							%>
	<tr bgcolor="#CCFFCC">
		<td width="15%">
		<div align="center"><font color="#0000FF"> <%=orderitem.getBooknumber()%>
		</font></div>
		</td>
		<td width="35%">
		<div align="center"><font color="#0000FF"><%=orderitem.getBookname()%></font></div>
		</td>
		<td width="15%">
		<div align="center"><font color="#0000FF">&yen;<%=orderitem.getGoods_price()%></font></div>
		</td>

		<td width="35%">
		<div align="center"><font color="#0000FF">&yen;<%=(double) orderitem.getGoods_price()
									* orderitem.getBooknumber()%></font></div>
		</td>
	</tr>
	<%allprice = allprice
									+ (double) orderitem.getGoods_price()
									* orderitem.getBooknumber();
						}
%>
	<tr bgcolor="#CCCCFF">
		<td colspan="3">
		<div align="center"><font color="#0000FF">货物价格</font></div>
		</td>
		<td width="16%">
		<div align="center"><font color="#0000FF">&yen;<%=allprice%></font></div>
		</td>
	</tr>
	<tr>
		<td colspan="3" bgcolor="#CCCC99">
		<div align="center"><font color="#0000FF">运输费用</font></div>
		</td>
		<td width="16%" bgcolor="#CCCC99">
		<div align="center"><font color="#0000FF">&yen;5.00</font></div>
		</td>
	</tr>
	<tr bgcolor="#66FF66">
		<td colspan="3">
		<div align="center"><b><font color="#FF0000">总费用</font></b></div>
		</td>
		<td width="16%">
		<div align="center"><b><font color="#FF0000">&yen;<%=allprice + 5%></font></b></div>
		</td>
	</tr>

	<tr align="right">
		<td colspan="4"><b>状态:<%=order.getStrStatus()%> <%if ((order.getStatus() == 0)
								&& (session.getAttribute("username") != null)
								&& (session.getAttribute("username")
										.equals("wangxining"))) {

							%> [<a
			href="/ECommerce/OrderHandlerServlet?id=<%=order.getId() %>">处理订单</a>]
		<%}%> </b></td>
	</tr>
	<%}%>
	<tr align="center">
		<td colspan="4"><a href="javascript:close();">关闭窗口</a>|<a
			href="javascript:print();">打印订单</a></td>
	</tr>
	<%}
			}

		%>
</table>
</div>
</body>
</html>
