📄 cart_order.jsp
字号:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.Vector"%>
<%@ page import="goodselement"%>
<%@ page import="chStr"%>
<%
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();
%>
<%
String username=(String)session.getAttribute("username");
chStr chStr=new chStr();
String pay=chStr.chStr(request.getParameter("pay"));
String carry=chStr.chStr(request.getParameter("carry"));
String bz=chStr.chStr(request.getParameter("bz"));
String orderID="";
String now=(String)((new java.util.Date()).toLocaleString());
orderID=orderID+now;
orderID=orderID.replace('-','1');
orderID=orderID.replace(' ','2');
orderID=orderID.replace(':','3');
orderID=chStr.chStr(orderID);
Vector cart=(Vector)session.getAttribute("cart");
int number=0;
int price=0;
int ID=0;
String str="";
String leg="";
leg="insert into order2(bz,pay,carry,orderID,username) values ('"+bz+"','"+pay+"','"+carry+"','"+orderID+"','"+username+"')";
stmt.executeUpdate(leg);
for(int i=0;i<cart.size();i++){
goodselement mygoodselement=(goodselement)cart.elementAt(i);
ID=mygoodselement.ID;
price=mygoodselement.price;
number=mygoodselement.number;
str="insert into order1(orderID,goodsID,price,num,username) values ('"+orderID+"',"+ID+","+price+","+number+",'"+username+"')";
stmt.executeUpdate(str);
}
session.removeAttribute("cart");
out.println("<script language='javascript'>alert('订单生成,请记住您的订单号["+orderID+"]');window.location.href='zhanshi.jsp';</script>");
stmt.close();
conn.close();
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -