📄 checkorder.jsp
字号:
<%--
***************文件名 : orderView.jsp
***************功能 : 订单查看页
***************作者 : 马俊
***************接口参数: bookID(要查看图书ID号)-1表示纯粹的订单查询
***************实现过程: 先要判断用户是否登录
--%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<HTML><HEAD><TITLE>订单</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT language=JavaScript type=text/JavaScript>
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</SCRIPT>
<SCRIPT src="images/alt.js"></SCRIPT>
<LINK href="images/default.css" type=text/css
rel=stylesheet>
<META content="Microsoft FrontPage 4.0" name=GENERATOR></HEAD>
<BODY background=images/crossbig.gif
onmouseover="window.status='【欢迎你光临我们的网站】如果您喜欢本站,别忘了把本站介绍给您的好友哦!:)';return true"
leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<SCRIPT language=JavaScript>
<!--
function checkss()
{
if(checkspace(document.searchform.searchkey.value !='请输入关键字')) {
document.searchform.searchkey.focus();
alert("请输入查询关键字!");
return false;
}
if(checkspace(document.searchform.searchkey.value)) {
document.searchform.searchkey.focus();
alert("请输入查询关键字!");
return false;
}
document.searchform.submit();
}
function checkspace(checkstr) {
var str = '';
for(i = 0; i < checkstr.length; i++) {
str = str + ' ';
}
return (str == checkstr);
}
//-->
</SCRIPT>
<%
//获得登录名,若为空则表示未登录
String logName=(String) session.getValue("logName");
%>
<TABLE cellSpacing=0 cellPadding=0 width=776 align=center border=0>
<TBODY>
<TR>
<TD width=771 height=14>
<p><font color="#FF0000">
插入图片</font></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=776 align=center
background="images/INDEX_r2_c1.jpg" border=0>
<TBODY>
<TR>
<TD width=160 height=25>
<SCRIPT language=JavaScript type=text/JavaScript>
today=new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i] }
var d=new initArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
document.write(
"<font color=#ffffff>"+
today.getYear()+"年"+
(today.getMonth()+1)+"月"+
today.getDate()+"日 "+
d[today.getDay()+1]+
"</font>");
</SCRIPT>
</TD>
<% if(logName==null)
{
%>
<TD width=616><IMG height=10 src="images/b.gif"
width=10 align=absMiddle><FONT color=#333333><font color="#FFFFFF"> </font> <A
class=a1 href="index.jsp" target=_top>
<% }
else
{
%>
<TD width=616><IMG height=10 src="images/b.gif"
width=10 align=absMiddle><FONT color=#333333><font color="#FFFFFF"> </font> <A
class=a1 href="main.jsp" target=_top>
<% }
%>
<font color="#FFFFFF">首 页</font></A></FONT><FONT color=#333333><font color="#FFFFFF"> | </font>
<A class=a1 href="userPannel.jsp" target=_top>
<font color="#FFFFFF">个人信息面板</font></FONT><FONT color=#333333><font color="#FFFFFF"> | </font></FONT></a>
<A class=a1 href="newList.jsp?pubDate=2001/2/4&ToPage=1" target=_top>
<font color="#FFFFFF">新品上架</font></A><FONT color=#FFFFFF> | </FONT>
<A class=a1 href="sortList.jsp?sort=计算机硬件&ToPage=1" target=_top>
<font color="#FFFFFF">图书分类</font></A><FONT color=#FFFFFF> |</FONT>
<A class=a1 href="commendList.jsp?limitNum=10&ToPage=1" target=_top>
<font color="#FFFFFF">精品推荐</font></A><FONT color=#FFFFFF> | </FONT>
<A class=a1 href="topList.jsp?limitNum=10&ToPage=1" target=_top>
<font color="#FFFFFF">排行榜</font></A><FONT color=#FFFFFF> | </FONT>
<a class="a1" target="_top" href="help.jsp">
<font color="#FFFFFF">在线帮助</font></a><FONT color=#FFFFFF>|</FONT>
<FONT color=#ffffff> </FONT>
<% if(logName==null)
{
%>
<FONT color=#FF0000>您还没有登录!!!</FONT>
<% }
else
{
%>
<FONT color=#FF0000>当前登录用户:<%=logName%></FONT>
<%
}
%>
<DIV></DIV></TD></TR></TBODY></TABLE>
<TABLE id=Table1 cellSpacing=0 cellPadding=0 width=776 align=center border=0>
<TBODY>
<TR>
<FORM id=Search name=searchform
action=searchResult.jsp?ToPage=1 method=post>
<TD bgColor=#cce3e7 height=26>
<DIV align=center> </DIV>
<DIV align=center><IMG height=16
src="images/search.gif" width=64 align=absMiddle>
<INPUT onfocus="this.value=''" value=请输入关键字 name=searchkey size="20">
<SELECT id=action name=condition>
<OPTION value=1 selected>书 名</OPTION>
<OPTION value=2>作 者</OPTION>
<OPTION value=3>出版社</OPTION>
<OPTION value=4>ISBN</OPTION>
</SELECT>
<INPUT id=Submit1 style="BORDER-RIGHT: #333333 1px solid; BACKGROUND-POSITION: 0% 50%; BORDER-TOP: #333333 1px solid; FONT-WEIGHT: normal; FONT-SIZE: 12px; BACKGROUND-ATTACHMENT: scroll; BORDER-LEFT: #333333 1px solid; COLOR: #333333; LINE-HEIGHT: normal; BORDER-BOTTOM: #333333 1px solid; BACKGROUND-REPEAT: repeat; FONT-STYLE: normal; HEIGHT: 18px; BACKGROUND-COLOR: #cee7ef; FONT-VARIANT: normal" onclick="return checkss();" type=submit value=立即查询 name=Submit>
</DIV></TD></FORM></TR></TBODY></TABLE>
<%@ page import="java.sql.*"%>
<%@ page import="page.buyList"%>
<%@ page import="java.util.*"%>
<%
////获得购物车信息
Vector shop=new Vector(); //(Vector)session.getValue("shop");
////获得新购图书信息
String pid=request.getParameter("bookID");
String sql=new String();
// String logName=(String)session.getValue("logName");
int grade=0; //用户级别
double rate=0.0; //享受的折扣1-2 0.9 3-4 0.8 5-6 0.75
if(logName==null) //没有登录
{
%>
<p>
<p align=center><font color=red size=5>你还没有登录,请先登录!!!</font>
<p>
<%
}
else //已经登录
{
////
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{
out.println(e.toString());
}
////
double price; //价格
String bookName=new String(); //图书名
String bookAuthor=new String(); //作者
String publisher=new String(); //出版社
try
{
////查询用户信息
sql="SELECT * FROM client WHERE logName='"+logName+"'";
Connection con = DriverManager.getConnection("jdbc:odbc:bookStore");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next())
{
grade=rs.getInt("grade");
if(grade>=1 && grade<=2)
rate=0.9;
else if(grade>=3 && grade<=4)
rate=0.8;
else if(grade>=5 && grade<=6)
rate=0.75;
}
rs.close();
if(pid.compareTo("-1")==0) //订单查询
{
shop=(Vector)session.getValue("shop"); //获得session中的shop信息
}
else //向购物车中添加新书
{
shop=(Vector)session.getValue("shop"); //获得session中的shop信息
sql="SELECT * FROM book WHERE bookID='";
sql=sql+pid;
sql=sql+"'";
// byte[] tempBytes=pid.getBytes("ISO8859-1");
// pid=new String(tempBytes);
////获得新购图书信息
rs = stmt.executeQuery(sql);
while(rs.next())
{
bookName=rs.getString("bookName");
bookAuthor=rs.getString("bookAuthor");
price=rs.getDouble("bookPrice");
publisher=rs.getString("publisher");
buyList myList=new buyList();
boolean flag=false; //是否已经定购过该书
myList.bookName=bookName;
myList.bookID=pid;
myList.bookNum=1;
myList.bookPrice=price;
myList.publisher=publisher;
if(shop!=null)
{
for(int i=0;i<shop.size();i++)
{
buyList tempList=(buyList)shop.elementAt(i);
int index=shop.indexOf(tempList);
if(tempList.bookID.equals(myList.bookID))
{
tempList.bookNum++;
shop.setElementAt(tempList,index);
flag=true;
break;
}
}
}
else
shop=new Vector();
if(!flag)
{
shop.addElement(myList);
}
session.setAttribute("shop",shop);
}
rs.close();
}
if(shop.size()==0) //购物车为空
{
%>
<p align=center><font size=5 color=red>您的购物车为空,请先购物!!!</font>
<% }
%>
<% }
catch(Exception e)
{
out.println(e.toString());
}
%>
<TABLE cellSpacing=0 cellPadding=0 width=776 align=center border=0>
<TBODY>
<TR>
<TD vAlign=top>
</TD>
</TR></TBODY></TABLE>
<TABLE height=1 cellSpacing=0 cellPadding=0 width=769 align=center border=3 bordercolor="#FFFFFF">
<TBODY>
<TR>
<TD height=1 width="373" align=left colspan="2">
用户名:<font color=red size=4> <%=logName%></font></TD>
<TD height=1 width="343" colspan="3">级别: <%=grade%>
可享受折扣: <%=rate%></TD></TR>
<TR>
<TD height=1 width="716" colspan="5">您本次已定购图书:(若想删除图书,可以将数量置零后单击修改)
<hr>
</TD>
</TR>
<TR>
<TD height=1 width="129" align="center" bordercolor="#3333CC" bgcolor="#FFFFFF">书名</TD>
<TD height=1 width="258" align="center" bordercolor="#3333CC" bgcolor="#FFFFFF">出版社</TD>
<TD height=1 width="129" align="center" bordercolor="#3333CC" bgcolor="#FFFFFF">原价</TD>
<TD height=1 width="165" align="center" bordercolor="#3333CC" bgcolor="#FFFFFF">实际价格</TD>
<TD height=1 width="84" align="center" bordercolor="#3333CC" bgcolor="#FFFFFF">所购册数</TD>
</TR>
<form name="form1" method="post" action="modify.jsp?type=<%=1%>">
<% for(int i=0;i<shop.size();i++)
{
buyList myList=(buyList)shop.elementAt(i);
%>
<TR>
<TD height=1 width="129" align="center" bordercolor="#3333CC" bgcolor="#FFFFFF"><%=myList.bookName%></TD>
<TD height=1 width="258" align="center" bordercolor="#3333CC" bgcolor="#FFFFFF"><%=myList.publisher%></TD>
<TD height=1 width="129" align="center" bordercolor="#3333CC" bgcolor="#FFFFFF">¥ <%=myList.bookPrice%></TD>
<TD height=1 width="165" align="center" bordercolor="#3333CC" bgcolor="#FFFFFF"><%=myList.bookPrice*rate%></TD>
<TD height=1 width="84" align="center" bordercolor="#3333CC" bgcolor="#FFFFFF"><input type=text name="num<%=i%>" size="9" value=<%=myList.bookNum%>></TD>
</TR>
<% }
%>
<TR>
<TD height=1 width="383" align="center" bordercolor="#3333CC" bgcolor="#FFFFFF" colspan="2">
<input type=submit name=Submit value=" 修改" onclick="checkform(this)"> </a>
</TD>
<TD height=1 width="376" align="center" bordercolor="#3333CC" bgcolor="#FFFFFF" colspan="3">
<a href="modify.jsp?type=<%=2%>"><font color=blue>清空购物车</font></a> | <a href="main.jsp"><font color=blue> 继续购物</font> </a> | <a href="submitOrder.jsp" type=submit><font color=blue> 提交订单</font> </a>
</TD>
</TR>
</TBODY></TABLE>
<SCRIPT language=JavaScript src="JSLib.js" type=text/javascript>
//确保输入的数字有效
function checkform(Frm)
{
alert("dfasdfasd");
var flag=true;
String err="输入错误!!!";
byte[] tempBytes=err.getBytes("ISO8859-1");
err=new String(tempBytes);
<% for(int num=0;num<shop.size();num++)
{
out.print("if(!isInt(Frm.num"+num+".value))"+"\r\n");
out.print("{"+"\r\n");
out.print("alert("+"图书数目输入有误!!!)"+"\r\n");
out.print("Frm.num"+num+".focus();"+"\r\n");
out.print("flag=false;"+"\r\n");
out.print("}"+"\r\n");
}
%>
return flag;
}
</SCRIPT>
<%
}
%>
<TABLE cellSpacing=0 cellPadding=0 width=776 align=center border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=1 cellPadding=0 width="100%" align=center
bgColor=#89bec6 border=0>
<TBODY>
<TR bgColor=#aacfd5>
<TD style="PADDING-LEFT: 10px"> </TD>
<TD style="PADDING-LEFT: 10px"> </TD>
<TD style="PADDING-LEFT: 10px"> </TD>
<TD style="PADDING-LEFT: 10px"> </TD>
<TD style="PADDING-LEFT: 26px"> </TD></TR>
</TBODY></TABLE>
<DIV align=center></DIV></TD></TR>
<TR>
<TD height=6></TD></TR>
</TBODY></TABLE>
<HR align=center width=776 color=#339999 SIZE=1>
<TABLE cellSpacing=0 cellPadding=0 width=776 align=center border=0>
<TBODY>
<TR>
<TD align=middle>版权所有 2003-2004 © All rights MagicTeam reseverd</TD></TR></TBODY></TABLE>
<DIV align=center></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -