Section 16.10. WEB-INFclassescomcybertrailsadmin

   

16.10 WEB-INF/classes/com/cybertrails/admin

This folder contains the GetOrderBean , which allows the site merchant or administrator (in conjunction with the viewCompletedOrder JSP) to view all of the orders that have been placed but not yet processed . This allows the merchant to charge the card and fulfill the order.

16.10.1 GetOrderBean.java

 package com.cybertrails.admin;  import java.util.*; import java.sql.*; import javax.servlet.http.*; import javax.servlet.*; public class GetOrderBean {     //variables     private Connection con;     private String error;         // constructor     public GetOrderBean() {     }     public ResultSet getNewOrders() throws SQLException, Exception {                 ResultSet rs = null;                 String SQL;                 SQL = "SELECT o.orderid, o.customerid, o.shipinfoid, o.subtotal, " + "o.shipping, o.tax, o.grandtotal, o.orderdate, " + "op.ordersproductsid, op.productid, op.qty, op.price, " + "p.productid, p.name, " + "opt.optionname, opt.optionid, " + "c.billname, c.billaddress, c.billcity, c.billstate, " + "c.billzipcode, c.billcountry, c.billphone, c.billemail, " + "c.creditnumber, c.creditname, c.creditexpdate, " + "s.shipname, s.shipaddress, s.shipcity, s.shipstate, " + "s.shipzipcode, s.shipcountry, s.shipemail " + "FROM orders o " + "INNER JOIN customers c ON c.customerid = o.customerid " + "INNER JOIN shippinginfo s ON s.shipinfoid = o.shipinfoid " + "INNER JOIN products p ON p.productid = op.productid " + "INNER JOIN  ordersproducts op ON o.orderid = op.orderid " + "LEFT OUTER JOIN ordersproductoptionchoice opoc " + "ON opoc.ordersproductsid = op.ordersproductsid " + "LEFT OUTER  JOIN options opt ON opt.optionid = opoc.optionid" + "WHERE o.isprocessed = 0;";     try {       Statement getNewOrders;       getNewOrders = con.createStatement();       rs = getNewOrders.executeQuery(SQL);     }     catch (SQLException sqle) {       sqle.printStackTrace();         error = "SQL Error";            throw new SQLException(error);      }      catch (Exception e) {             e.printStackTrace();             error = "An unknown exception occured in                    getNewOrders";             throw new Exception(error);      }      return rs;     } //////// setIsProcessed()     public String setIsProcessed(String orderID) throws                                   SQLException, Exception {        String SQL;        String isProcessed = "The order has been processed.";        SQL = "Update orders SET isProcessed = 1                 WHERE orderid = " + orderID + ";";         try {             Statement getNewOrders;             getNewOrders = con.createStatement();             getNewOrders.executeQuery(SQL);             }             catch (SQLException sqle) {                 sqle.printStackTrace();                 error = "SQL Error";                 throw new SQLException(error);             }             catch (Exception e) {                 e.printStackTrace();                 error = "An unknown exception occured in                                  getNewOrders";                 throw new Exception(error);             }       return isProcessed;     } // ************ CONNECT     public void connect() throws SQLException, Exception {         try {             // load driver             Class.forName("org.gjt.mm.mysql.Driver");             // make connection con = DriverManager.getConnection("jdbc:mysql:///storecybertrailscomtest","","");         }         catch (SQLException sqle) {             error = sqle.getMessage();             throw new SQLException(error);         }         catch (Exception e) {             error = "Exception: unknown";             throw new Exception(error);         }     } //end connect  //********* DISCONNECT     public void disconnect() throws SQLException {         try {             if ( con != null )             {                 //close connection                 con.close();             }         }         catch (SQLException sqle) {             error = ("SQLException: can't close connection");             throw new SQLException(error);         }     } // end disconnect() } // eof 

   
Top


Java for ColdFusion Developers
Java for ColdFusion Developers
ISBN: 0130461806
EAN: 2147483647
Year: 2005
Pages: 206
Authors: Eben Hewitt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net