ment3.jsp
上传用户:xjrzjk
上传日期:2022-07-31
资源大小:1585k
文件大小:7k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=GBK" %>
  2. <%@ page import="java.sql.*"%>
  3. <%@ page import="java.text.DecimalFormat"%>
  4. <%
  5.   try{
  6. String Id = (String)request.getSession(true).getAttribute("LoginSuccess");
  7. String productList = (String)request.getSession(true).getAttribute("productList");
  8. if (productList == null || productList.equals("")){
  9.   response.sendRedirect("nothing.jsp");
  10.   return;
  11. }
  12. //数据库连接
  13. Class.forName("oracle.jdbc.driver.OracleDriver");
  14. String strUrl = "jdbc:oracle:thin:@slight:1521:LOCAL";
  15. String strUser = "eshop";
  16. String strPassword = "eshop";
  17. Connection con = DriverManager.getConnection(strUrl, strUser, strPassword);
  18. Statement st = con.createStatement();
  19. String sql = "select * from product where product_id in (" + productList + ")";
  20. ResultSet rs = st.executeQuery(sql);
  21. %>
  22. <html>
  23. <head>
  24. <title>
  25. 商品结算
  26. </title>
  27. <link rel="stylesheet" type="text/css" href="style.css">
  28. </head>
  29. <BODY>
  30.     <BR><BR>
  31.       <FORM name=FORM1 action=ment4.jsp method=post>
  32. <%
  33.   String strUserId = request.getParameter("UserId");
  34.   strUserId = new String(strUserId.getBytes("iso8859-1"),"gb2312");
  35.   String strName = request.getParameter("Name");
  36.   strName = new String(strName.getBytes("iso8859-1"),"gb2312");
  37.   String strAddress = request.getParameter("Address");
  38.   strAddress = new String(strAddress.getBytes("iso8859-1"),"gb2312");
  39.   String strZip = request.getParameter("Zip");
  40.   strZip = new String(strZip.getBytes("iso8859-1"),"gb2312");
  41.   String strPhone = request.getParameter("Phone");
  42.   strPhone = new String(strPhone.getBytes("iso8859-1"),"gb2312");
  43.   String strEmail = request.getParameter("Email");
  44.   strEmail = new String(strEmail.getBytes("iso8859-1"),"gb2312");
  45.   String strPays = request.getParameter("Pays");
  46.   strPays = new String(strPays.getBytes("iso8859-1"),"gb2312");
  47.   String strRemark = request.getParameter("Remark");
  48.   strRemark = new String(strRemark.getBytes("iso8859-1"),"gb2312");
  49. %>
  50. <input type=hidden Name="UserId" Value="<%=strUserId%>" >
  51. <input type=hidden Name="Name" Value="<%=strName%>" >
  52. <input type=hidden Name="Address" Value="<%=strAddress%>" >
  53. <input type=hidden Name="Zip" Value="<%=strZip%>" >
  54. <input type=hidden Name="Phone" Value="<%=strPhone%>" >
  55. <input type=hidden Name="Email" Value="<%=strEmail%>" >
  56. <input type=hidden Name="Pays" Value="<%=strPays%>" >
  57. <input type=hidden Name="Remark" Value="<%=strRemark%>" >
  58. <div align="center">
  59.   <center>
  60.       <TABLE cellSpacing=0 cellPadding=0 width=362>
  61.         <TBODY>
  62.         <TR>
  63.           <TD align=middle width="372">
  64.             <TABLE cellSpacing=1 cellPadding=4 width=508 bgColor=#000000 class=main1>
  65.               <TBODY>
  66.               <TR vAlign=top bgColor=#eeeeee>
  67.                 <TD colSpan=4 width="494" bgcolor="#EEEEEE">购物结算--(第三步)信息确认</TD></TR>
  68.               <tr>
  69.                 <TD width=482 bgcolor=#EEEEEE height=7 align="right" colspan="4">
  70.   <div align="center"><center>
  71. <table border="1" cellpadding="0" cellspacing="0" width="524" bordercolor="#000000" height="61">
  72.         <tr bgcolor="#006699">
  73.           <td align="center" width="80"  height="20" bgcolor="#006699"><font color="#FFFFFF">商品编号</font></td>
  74.           <td align="center" width="170"  height="20" bgcolor="#006699"><font color="#FFFFFF">商品名称</font></td>
  75.           <td align="center" width="76" height="20" bgcolor="#006699"><font color="#FFFFFF">商品价格</font></td>
  76.           <td align="center" width="67"  height="20" bgcolor="#006699"><font color="#FFFFFF">商品数量</font></td>
  77.           <td align="center" width="83"  height="20" bgcolor="#006699"><font color="#FFFFFF">总价</font></td>
  78.         </tr>
  79. <%
  80.    double Sum = 0;
  81.    int Quatity = 0;
  82.    DecimalFormat df = new DecimalFormat("0.00");
  83.    while(rs.next()){
  84.       String strQuatity = (String)request.getSession(true).getAttribute(rs.getString("Product_Id"));
  85.       if (strQuatity == null  || strQuatity.equals("")){
  86.         Quatity = 1;
  87.       }else{
  88.         Quatity = Integer.parseInt(strQuatity);
  89.         if (Quatity <=0){
  90.           Quatity = 1;
  91.         }
  92.       }
  93.       request.getSession(true).setAttribute(rs.getString("Product_Id"), String.valueOf(Quatity));
  94.      Sum = Sum + rs.getDouble("P_NewPrice") * Quatity;
  95. %>
  96.         <tr>
  97.           <td align="center" width="80" height="23"><%=rs.getString("Product_ID")%>
  98. </td>
  99.           <td align="center" width="170" height="23"><%=rs.getString("Product_Name")%>
  100. </td>
  101.           <td align="center" width="76" height="23"><%=df.format(rs.getDouble("P_NewPrice"))%>
  102. </td>
  103.           <td align="center" width="67" height="23"><%=Quatity%></td>
  104.           <td Align="center" width="83" height="23"><%=df.format(rs.getDouble("P_NewPrice") * Quatity)%>元
  105. </td>
  106.         </tr>
  107. <%
  108.    }
  109. %>
  110.         <tr>
  111.       <td Align="Right" ColSpan="6" width="520" height="12"><font Color="Red">总价格=人民币 <%=Sum%>元</font></td>
  112.         </tr>
  113.       </table>
  114.       </center></div><blockquote>
  115.   </blockquote>
  116. </TD>
  117.               </tr>
  118.               <tr>
  119.                 <TD width=103 bgcolor=#EEEEEE height=7 align="right">收货人姓名:</TD>
  120.                 <TD width=379 height=7 bgcolor="#EEEEEE" colspan="3"><%=strName%></TD>
  121.               </tr>
  122.               <tr>
  123.                 <TD width=103 bgcolor=#EEEEEE height=7 align="right">收货人地址:</TD>
  124.                 <TD width=379 height=7 bgcolor="#EEEEEE" colspan="3"><%=strAddress%></TD>
  125.               </tr>
  126.               <tr>
  127.                 <TD width=103 bgcolor=#EEEEEE height=7 align="right">邮政编码:</TD>
  128.                 <TD width=127 height=7 bgcolor="#EEEEEE"><%=strZip%></TD>
  129.                 <TD width=106 height=7 bgcolor="#006699">
  130.                   <p align="center"><font color="#FFFFFF">联系电话:</font> </TD>
  131.                 <TD width=146 height=7 bgcolor="#EEEEEE"><%=strPhone%></TD>
  132.               </tr>
  133.               <tr>
  134.                 <TD width=103 bgcolor=#EEEEEE height=7 align="right">电子信箱:</TD>
  135.                 <TD width=379 height=7 bgcolor="#EEEEEE" colspan="3"><%=strEmail%></TD>
  136.               </tr>
  137.               <tr>
  138.                 <TD width=103 bgcolor=#EEEEEE height=7 align="right">付款方式:</TD>
  139.                 <TD width=379 height=7 bgcolor="#EEEEEE" colspan="3"><%=strPays%></TD>
  140.               </tr>
  141.               <tr>
  142.                 <TD width=103 bgcolor=#EEEEEE height=7 align="right">订单备注:</TD>
  143.                 <TD width=379 height=7 bgcolor="#EEEEEE" colspan="3"><%=strRemark%></TD>
  144.               </tr>
  145.               <TR vAlign=top bgColor=#eeeeee>
  146.                 <TD colSpan=4 width="494" bgcolor="#EEEEEE"></TD></TR>
  147.               <TR bgColor=#eeeeee>
  148.                 <TD colSpan=4 width="494" bgcolor="#EEEEEE">
  149.                   <DIV align=center><input type="button" value="上一步" name="B4" onclick="javascript:window.history.go(-1)">
  150.                     <INPUT class=main type=submit size=3 value=提交定单 name=Submit2>
  151.                   </DIV></TD></TR></TBODY></TABLE>
  152.           </TD></TR></TBODY></TABLE></center>
  153. </div>
  154. <BR></FORM>
  155. </BODY>
  156. </html>
  157. <%
  158.   }catch(Exception e){
  159.     throw (e);
  160.   }
  161. %>