?? shopcar.jsp
字號:
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.util.*" %>
<%@ page session="true" %>
<%@ page import="bookshop.book.*"%>
<%@ page import="bookshop.run.op_book" %>
<%@ page import="bookshop.run.op_buy" %>
<jsp:useBean id="book_list" scope="page" class="bookshop.run.op_book" />
<jsp:useBean id="classlist" scope="page" class="bookshop.run.op_bookclass" />
<jsp:useBean id="shop" scope="page" class="bookshop.run.op_buy" />
<%
String userid = (String) session.getAttribute("userid");
if ( userid == null )
userid = "";
String modi = request.getParameter("modi");
String del = request.getParameter("del");
String payoutCar = request.getParameter("payout");
String clearCar = request.getParameter("clear");
String mesg = "";
if (modi!=null && !modi.equals("")) {
if ( !shop.modiShoper(request) ){
if (shop.getIsEmpty())
mesg = "你要的修改購買的圖書數量不足你的購買數量!";
else
mesg = "修改購買數量出錯!";
} else {
mesg = "修改成功";
}
}else if ( del != null && !del.equals("") ) {
if ( !shop.delShoper(request) ) {
mesg = "刪除清單中的圖書時出錯!" ;
}
}else if (payoutCar != null && !payoutCar.equals("") ) {
if (shop.payout(request) ) {
mesg = "你的購物車中的物品已提交給本店,你的訂單號為 "+ shop.getOrderId() + "<br>請及時付款,以便我們發貨!";
session.removeAttribute("shopcar");
} else {
if(!shop.getIsLogin())
mesg = "你還沒有登錄,請先<a href=login.jsp>登錄</a>后再提交";
else
mesg = "對不起,提交出錯,請稍后重試";
}
} else if (clearCar != null && ! clearCar.equals("") ) {
session.removeAttribute("shopcar");
mesg = "購物車中的物品清單已清空";
}
%>
<script language="javascript">
function openScript(url,name, width, height){
var Win = window.open(url,name,'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
}
function checklogin() {
if (document.payout.userid.value=="")
{
alert("你還沒有登錄,請登錄后再提交購物清單。");
return false;
}
return true;
}
function check()
{
if (document.change.amount.value<1){
alert("你的購買數量有問題");
document.change.amount.focus();
return false;
}
return true;
}
</script>
<%@include file="/bookshop/inc/head.inc"%>
<%@include file="/bookshop/inc/sub.inc"%>
<table width="778">
<tr>
<td width="150" align="center">
<%@include file="/bookshop/inc/left.inc"%>
</td>
<td width="600">
<p><b><font color="#0000FF">我的購物車物品清單</font></b></p>
<%
if (!mesg.equals("") )
out.println("<p ><font color=#ff0000>" + mesg + "</font></p>");
Vector shoplist = (Vector) session.getAttribute("shopcar");
if (shoplist==null || shoplist.size()<0 ){
if (mesg.equals(""))
out.println("<p><font color=#ff0000>你還沒有選擇購買圖書!請先購買</font></p>");
} else {
%>
<table width="100%" border="1" cellspacing="1" cellpadding="1" bordercolor="white">
<tr align="center" bgcolor="#DEF3CE">
<td>圖書名稱</td>
<td>作者</td>
<td>圖書類別</td>
<td>單價(元)</td>
<td>數量</td>
<td colspan =2>選擇</td>
</tr>
<%
float totalprice =0;
int totalamount = 0;
for (int i=0; i<shoplist.size();i++){
allorder iList = (allorder) shoplist.elementAt(i);
if (book_list.getOnebook((int)iList.getBookNo())) {
book bk = (book) book_list.getBooklist().elementAt(0);
totalprice = totalprice + bk.getPrince() * iList.getAmount();
totalamount = totalamount + iList.getAmount();
%>
<tr>
<td><%= bk.getBookName() %></td>
<td align="center"><%= bk.getAuthor() %></td>
<td align="center"><%= bk.getClassname() %></td>
<td align="center"><%= bk.getPrince() %></td>
<form name="change" method="post" action="shopcar.jsp">
<td align="center">
<input type="text" name="amount" maxlength="4" size="3" value="<%= iList.getAmount() %>" >
</td>
<td align="center" width=55 >
<input type="hidden" name="bookid" value="<%= iList.getBookNo() %>" >
<input type="submit" name="modi" value="修改" onclick="return(check());"></td>
<form name="del" method="post" action="shoperlist.jsp">
<input type="hidden" name="bookid" value="<%= iList.getBookNo() %>" >
<td align=center width=55> <input type="submit" name="del" value="刪除">
</td></form>
</tr>
<% }
} %> <tr><td colspan=7 align="right"><br>你選擇的圖書的總金額:<%= totalprice%>元 總數量:<%= totalamount%>本 </td></tr>
</table>
<p></p>
<table width="90%" border="0" cellspacing="1" cellpadding="1">
<tr> <form name="payout" method="post" action="shopcar.jsp">
<td align="right" valign="bottom"> <a href="booklist.jsp">繼續購書</a>
<input type="hidden" name="userid" value="<%= userid %>">
<input type="hidden" name="totalprice" value="<%= totalprice %>">
<TEXTAREA NAME="content" ROWS="3" COLS="20">附言:</TEXTAREA><br>
<input type="submit" name="payout" value="提交我的購物車" onclick="javascript:return(checklogin());"> </td></form>
<form name="form1" method="post" action="shopcar.jsp">
<td valign="bottom">
<input type="submit" name="clear" value="清空我的購物車">
</td></form>
</tr>
</table>
</form>
<% } %>
</td>
</tr>
</table>
<%@include file="/bookshop/inc/tail.inc"%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -