📄 orderlist.jsp
字号:
<%-- 这个JSP脚本是用来显示临时购物蓝的 --%>
<%@ page language="java"%>
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page errorPage="errorpage.jsp" %>
<%@ page import="java.sql.*" %>
<jsp:useBean id="DBexecuteBean" scope="page" class="bookSearchOrderBean.DBexecuteBean"/> <%-- 调用JavaBean --%>
<html>
<head>
<title>网上图书信息检索和订购</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.TableLine { border: #6666FF; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
-->
</style>
</head>
<%
String islogin = null;
Cookie[] bookcookie = request.getCookies();
/* 首先验证访问者是否已经登录 */
if(bookcookie != null)
{
for(int j = 0;j < bookcookie.length;j++)
{
if(bookcookie[j].getName().equals("hadlogin"))
{
islogin = bookcookie[j].getValue();
}
}
}
if((islogin == null) || (!(islogin.equals("1"))))
{
throw new Exception("你还没有登录,请先登录!");
}
%>
<body bgcolor="#FFFFFF" link="#6666FF" vlink="#6666FF" alink="#6666FF">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="TableLine">
<tr>
<td height="150">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td height="2">
<div align="center"><font color="#6666FF" size="5" face="华文新魏"><font size="+3"><b><font size="6">定单信息确认</font></b></font></font></div>
</td>
</tr>
<tr>
<td height="2"> </td>
</tr>
<tr>
<td height="2"> <font face="幼圆" size="4"><b><font color="#6666FF">
<%=(String)session.getValue("LoginName")%>
<font size="3">用户:您的图书定单如下:</font></font></b></font>
</td>
</tr>
<tr>
<td height="2"> </td>
</tr>
<tr>
<td height="4">
<form method="post" action="http://127.0.0.1/chapter5/book/Finish.jsp">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="44%">
<div align="center"><b>书 名</b></div>
</td>
<td width="20%">
<div align="center"><b>数 量(本)</b></div>
</td>
<td width="18%">
<div align="center"><b>单 价(元)</b></div>
</td>
<td width="18%">
<div align="center"><b>总 价(元)</b></div>
</td>
</tr>
<tr>
<td colspan="4">
<div align="center"><font face="Times New Roman, Times, serif">-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - </font></div>
</td>
</tr>
<%
String bookID = null;
String UserID = null;
String BookName = null;
int BuyNumber = 1;
double prePrice = 0;
double totalPrice = 0;
String sSQLCmd1 = null;
String sSQLCmd2 = null;
ResultSet rset1 = null;
ResultSet rset2 = null;
UserID = (String)session.getValue("UserID"); // 获得用户编号
if(UserID == null || UserID.length() < 7)
{
throw new Exception("用户的ID号出错!");
}
else
{
UserID = UserID.trim();
sSQLCmd1 = " select BookList.BookName,orderlist.buynumber,BookList.Price,orderlist.totalprice from orderlist inner join Booklist on orderlist.bookid = BookList.ID where orderlist.UserID='" + UserID + "'";
rset1 = DBexecuteBean.getTableRecords(sSQLCmd1);
while(rset1.next())
{
/* 显示详细的购物清单 */
BookName = rset1.getString(1);
BuyNumber = rset1.getInt(2);
prePrice = rset1.getDouble(3);
totalPrice = rset1.getDouble(4);
out.println("<tr><td width=\"44%\"><div align=\"center\">" + BookName.trim() + "</div></td>");
out.println("<td width=\"20%\"><div align=\"center\">" + BuyNumber + "</div></td>");
out.println("<td width=\"18%\"><div align=\"center\">" + (double)((int)(prePrice * 100) / 100.0) + "</div></td>");
out.println("<td width=\"18%\"><div align=\"center\">" + (double)((int)(totalPrice * 100) / 100.0) + "</div></td></tr>");
}
sSQLCmd2 = " select sum(BuyNumber),sum(TotalPrice) from orderlist where UserID='" + UserID + "'";
rset2 = DBexecuteBean.getTableRecords(sSQLCmd2);
while(rset2.next())
{
/* 显示总的数量 */
BuyNumber = rset2.getInt(1);
totalPrice = rset2.getDouble(2);
}
}
%>
<tr>
<td colspan="4"> </td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
<tr>
<td colspan="4"> <b>图书总数为:<%=BuyNumber%> 本,价格为:<%=(double)((int)(totalPrice * 100) / 100.0)%> 元。</b></td>
</tr>
<tr>
<td colspan="4" height="2">
<div align="left"> </div>
</td>
</tr>
<tr>
<td colspan="4">
<div align="center">
<input type="submit" name="SubmitOK" value="确 认" class="TableLine">
</div>
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -