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

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 strId = (String)request.getSession(true).getAttribute("LoginSuccess");
  7.   String productList = (String)request.getSession(true).getAttribute("productList");
  8.   if (productList == null || productList.equals("")){
  9. %>
  10.   <jsp:forward page="nothing.jsp" />
  11. <%
  12.   return;
  13.   }
  14.   //数据库连接
  15.   Class.forName("oracle.jdbc.driver.OracleDriver");
  16.   String strUrl = "jdbc:oracle:thin:@slight:1521:LOCAL";
  17.   String strUser = "eshop";
  18.   String strPassword = "eshop";
  19.   Connection con = DriverManager.getConnection(strUrl, strUser, strPassword);
  20.   Statement st = con.createStatement();
  21.   String sql = "select * from product where product_id in (" + productList + ")";
  22.   ResultSet rs = st.executeQuery(sql);
  23. %>
  24. <html>
  25. <head>
  26. <title>
  27. 商品结算
  28. </title>
  29. <link rel="stylesheet" type="text/css" href="style.css">
  30. </head>
  31. <BODY>
  32. <div align="center">
  33. <TABLE cellSpacing=0 cellPadding=0 width=600>
  34.  <TR>
  35.   <TD height=62 width="100%">
  36.    <BR><BR>
  37. <%
  38.   String strAddress = request.getParameter("Address");
  39.   strAddress = new String(strAddress.getBytes("iso8859-1"),"gb2312");
  40. %>
  41.    <FORM name=FORM1 action=ment3.jsp method=post>
  42.     <input type=hidden Name="UserId" Value="<%=request.getParameter("UserId")%>">
  43.     <input type=hidden Name="Name" Value="<%=request.getParameter("Name")%>" >
  44.     <input type=hidden Name="Address" Value="<%=strAddress%>" >
  45.     <input type=hidden Name="Zip" Value="<%=request.getParameter("Zip")%>" >
  46.     <input type=hidden Name="Phone" Value="<%=request.getParameter("Phone")%>" >
  47.     <input type=hidden Name="Email" Value="<%=request.getParameter("Email")%>" >
  48.     <TABLE cellSpacing=0 cellPadding=0 width=100%>
  49.      <TR>
  50.      <TD align=middle width="100%">
  51.         <div align="center">
  52.          <TABLE cellSpacing=1 width=100% bgColor=#000000 >
  53.           <TR vAlign=top bgColor=#eeeeee>
  54.            <TD  colSpan=2 width="574" bgcolor="#EEEEEE">
  55.             <p align="center">购物结算--(第二步)购物信息及付款方式</p>
  56.            </TD>
  57.            </TR>
  58.            <tr>
  59.            <TD  width=100% bgcolor=#EEEEEE height=7 align="right" colspan="2">
  60.             <div align="center">
  61.             <table border="0" cellspacing="1" width="580"  height="61" bgcolor="#000000" bordercolorlight="#000000" bordercolordark="#FFFFFF">
  62.               <tr bgcolor="#006699">
  63.                 <td align="center" width="85"  height="20" bgcolor="#006699"><font color="#FFFFFF">商品编号</font></td>
  64.                 <td align="center" width="205"  height="20" bgcolor="#006699"><font color="#FFFFFF">商品名称</font></td>
  65.                 <td align="center" width="87" height="20" bgcolor="#006699"><font color="#FFFFFF">商品价格</font></td>
  66.                 <td align="center" width="76"  height="20" bgcolor="#006699"><font color="#FFFFFF">商品数量</font></td>
  67.                 <td align="center" width="95"  height="20" bgcolor="#006699"><font color="#FFFFFF">总价</font></td>
  68.               </tr>
  69. <%
  70.    double Sum = 0;
  71.    DecimalFormat df = new DecimalFormat("0.00");
  72.    int Quatity = 0;
  73.    while(rs.next()){
  74.       String strQuatity = (String)request.getSession(true).getAttribute(rs.getString("Product_Id"));
  75.       if (strQuatity == null  || strQuatity.equals("")){
  76.         Quatity = 1;
  77.       }else{
  78.         Quatity = Integer.parseInt(strQuatity);
  79.         if (Quatity <=0){
  80.           Quatity = 1;
  81.         }
  82.       }
  83.       request.getSession(true).setAttribute(rs.getString("Product_Id"), String.valueOf(Quatity));
  84.      Sum = Sum + rs.getDouble("P_NewPrice") * Quatity;
  85. %>
  86.               <tr>
  87.                 <td align="center" width="85" height="23" bgcolor="#EEEEEE"><%=rs.getString("Product_ID")%></td>
  88.                 <td align="center" width="205" height="23" bgcolor="#EEEEEE"><%=rs.getString("Product_Name")%></td>
  89.                 <td align="center" width="87" height="23" bgcolor="#EEEEEE"><%=df.format(rs.getDouble("P_NewPrice"))%></td>
  90.                 <td align="center" width="76" height="23" bgcolor="#EEEEEE"><%=String.valueOf(Quatity)%></td>
  91.                 <td Align="center" width="95" height="23" bgcolor="#EEEEEE"><%=df.format(rs.getDouble("P_NewPrice") * Quatity)%>元</td>
  92.               </tr>
  93. <%
  94.    }
  95. %>
  96.               <tr>
  97.                 <td Align="Right" ColSpan="6" width="572" height="12" bgcolor="#EEEEEE"><font Color="Red">总价格=人民币 <%=df.format(Sum)%>元</font></td>
  98.               </tr>
  99.             </table>
  100.           </div>
  101.         </TD>
  102.       </tr>
  103.       <tr>
  104.        <TD  width=124 bgcolor=#EEEEEE height=7>付款方式</TD>
  105.        <TD  width=438 height=7 bgcolor="#EEEEEE">
  106.           <select size="1" name="Pays" style="font-size: 14px">
  107.             <option>邮局汇款,款到发货</option>
  108.             <option>现金支付,上门提货</option>
  109.             <option>银行转帐,见票发货</option>
  110.           </select>
  111.         </TD>
  112.       </tr>
  113.       <tr>
  114.         <TD  width=124 bgcolor=#EEEEEE height=7>请给我们订单处理员留言</TD>
  115.         <TD  width=438 height=7 bgcolor="#EEEEEE"><textarea rows="6" name="Remark" cols="45" style="font-size: 10pt"></textarea> </TD>
  116.       </tr>
  117.       <TR vAlign=top bgColor=#eeeeee>
  118.         <TD  colSpan=2 width="574" bgcolor="#EEEEEE"></TD>
  119.       </TR>
  120.       <TR bgColor=#eeeeee>
  121.         <TD  colSpan=2 width="574" bgcolor="#EEEEEE">
  122.           <DIV align=center>&nbsp;
  123.             <INPUT class=main type=submit size=3 value=下一步 name=Submit2>
  124.           </DIV>
  125.         </TD>
  126.       </TR>
  127.     </TABLE>
  128.   </div>
  129. </TD>
  130. </TR>
  131. </TABLE>
  132. <BR>
  133.   </FORM>
  134. </TD>
  135. </TR>
  136. </TABLE>
  137. </div>
  138. </BODY>
  139. </html>
  140. <%
  141.   }catch(Exception e){
  142.     throw (e);
  143.   }
  144. %>