📄 cart_see.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.util.Vector"%>
<%@ page import="goodselement"%>
<html >
<head>
<title>无标题文档</title>
</head>
<%
String username=(String)session.getAttribute("username");
if(username=="" || username==null)
{
out.println("<script language='javascript'>alert('请先登录!');window.location.href='../index.jsp';</script>");
}
else
{
String spath="wangye/ec.mdb";
String dbpath = application.getRealPath(spath);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+dbpath;
Connection conn= DriverManager.getConnection(url,"","");
Statement stmt=conn.createStatement();
Vector cart=(Vector)session.getAttribute("cart");
if(cart==null || cart.size()==0)
{
response.sendRedirect("cart_null.jsp");
}else
{
%>
<body>
<table width="770" border="1" align="center">
<tr>
<th colspan="7" scope="col"><img src="../image/1.jpg" width="760" height="200" /></th>
</tr>
<tr>
<th width="104" height="40" background="../image/t1.jpg" scope="row"><table width="100" border="0">
<tr>
<th scope="col"><a href="../index.jsp">首页</a></th>
</tr>
</table></th>
<td width="104" background="../image/t1.jpg"><table width="100" border="0">
<tr>
<th scope="col"><a href="zhanshi.jsp">数码</a></th>
</tr>
</table></td>
<td width="104" background="../image/t1.jpg"><table width="100" border="0">
<tr>
<th scope="col">服装</th>
</tr>
</table></td>
<td width="104" background="../image/t1.jpg"><table width="100" border="0">
<tr>
<th scope="col">饰品</th>
</tr>
</table></td>
<td width="104" background="../image/t1.jpg"><table width="100" border="0">
<tr>
<th scope="col">家电</th>
</tr>
</table></td>
<td width="104" background="../image/t1.jpg"><table width="100" border="0">
<tr>
<th scope="col">食品</th>
</tr>
</table></td>
<td width="100" background="../image/t1.jpg"><table width="100" border="0">
<tr>
<th scope="col">日用</th>
</tr>
</table></td>
</tr>
</table>
<table width="770" border="1" align="center">
<tr>
<th width="754" bgcolor="#A6BBFC" scope="col" ><marquee direction="left" scrollamount="1" scrolldelay="1" onMouseOver="this.stop();" onMouseOut="this.start();">
<%if(username==null || username==""){%>
<font color="#330000">顾客您好!购买商品请先登录</font> <a href="../zhuce.jsp" >[新用户注册]</a>
<%}else{%><%=username%> <font color="#330000">您好! 电子商务交易平台欢迎您!</font>
<%}%>
</marquee></th>
</tr>
</table>
<table width="770" border="1" align="center">
<tr>
<th width="200" bgcolor="#FFF8B0" scope="col">
<% if (username==null || username==""){%>
<form name="form1" method="post" action="wangye/Login_U.jsp">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr> </tr>
<tr>
<td width="94%" height="24"> <div align="center">会员名
<input name="username" type="text" id="username" size="16">
</div></td>
</tr>
<tr>
<td height="24"><div align="center">密 码
<input name="PWD" type="password" id="PWD" size="16" >
</div></td>
</tr>
<tr>
<td height="31">
<input name="Button" type="button" value="注册" onClick="window.location.href='wangye/zhuce.htm'">
<input name="Submit2" type="submit" value="登录" >
<input name="Submit3" type="reset" value="重置"></td>
</tr>
</table>
<%}else{%>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="94%" height="31" align="center" >[<%=username%>]您好!<br>
您现在可以购物了!</td>
</tr>
<tr>
<td height="24" align="center">
<input name="Submit22" type="button" value="修改资料" onClick="window.location.href='modifyMember.jsp';">
<input name="Submit33" type="button" value="购 物 车" onClick="window.location.href='cart_see.jsp';">
<input name="Submit32" type="button" value="订单管理" onClick="window.location.href='ordermanage.jsp';"></td>
</tr>
<tr> </tr>
</table>
<%}%>
</form>
</th>
<th width="554" rowspan="2" bgcolor="#FFFACE">
<%
int sum=0;
int ID=-1;
String goodsname="";
for(int i=0;i<cart.size();i++)
{
goodselement goodsitem=(goodselement)cart.elementAt(i);
sum=sum+goodsitem.number*goodsitem.price;
ID=goodsitem.ID;
if (ID>0)
{
ResultSet rs_goods=stmt.executeQuery("select * from goods where key="+ID);
if (rs_goods.next())
{
goodsname=rs_goods.getString("goodsname");
%>
<form method="post" action="cart_modify.jsp" name="form1">
<table width="92%" height="48" border="1" align="center" cellpadding="0" cellspacing="0">
<tr align="center" valign="middle">
<td height="27" >编号</td>
<td height="27" >商品编号</td>
<td >商品名称</td>
<td height="27" >单价</td>
<td height="27" >数量</td>
<td height="27" >金额</td>
<td >删除</td>
</tr>
<tr align="center" valign="middle">
<td width="32" height="27"><%=i+1%></td>
<td width="109" height="27"><%=ID%></td>
<td width="199" height="27"><%=goodsname%></td>
<td width="59" height="27">¥<%=goodsitem.price%></td>
<td width="51" height="27">
<input name="num<%=i%>" size="7" type="text" value="<%=goodsitem.number%>" onBlur="check(this.form)"></td>
<td width="65" height="27">¥<%=(goodsitem.price*goodsitem.number)%></td>
<td width="34"><a href="cart_move.jsp?ID=<%=i%>"><img src="../image/del.gif" width="16" height="16"></a></td>
</tr>
</table>
<%
}
}
}
%>
</form>
<table width="100%" height="52" border="0" align="center" cellpadding="0" cellspacing="0">
<tr align="center" valign="middle">
<td height="10"> </td>
<td width="24%" height="10" colspan="-3" align="left"> </td>
</tr>
<tr align="center" valign="middle">
<td height="21" class="tableBorder_B1"> </td>
<td height="21" colspan="-3" align="left" class="tableBorder_B1">合计总金额:¥<%=sum%></td>
</tr>
<tr align="center" valign="middle">
<td height="21" colspan="2"> <a href="../index.jsp">继续购物</a> | <a href="cart_checkout.jsp">去收银台结账</a> | <a href="cart_clear.jsp">清空购物车</a> | <a href="#">修改数量</a></td>
</tr>
</table></th>
</tr>
</table>
<table width="770" border="1" align="center">
<tr>
<th background="../image/2.jpg" scope="col"><br>
<p><a href="#"><font size="2">关于我们</font></a>
<font size="2"> |
<a href=# onclick="">加入收藏</a> | <a href=# onClick="">设为首页</a> | <a href="#">请您留言</a><br><br>
电子商务交易平台 版权所有</font></p><br>
</th>
</tr>
</table>
</body>
</html>
<%}
stmt.close();
conn.close();
}%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -