00001 package ProdDatabase;
00002 import java.sql.*;
00003 import java.util.*;
00004
00005 public class ShipmentInfo {
00006 Statement statement;
00007 ResultSet resultSet;
00008 StringBuffer sqlStat;
00009 Vector shipmentList;
00010 SCTDBInterface db;
00011
00012 public ShipmentInfo() {
00013 db = SCTDBInterface.getInstance();
00014 shipmentList=new Vector();
00015 }
00016
00017
00018 public Vector getShipmentVector() {
00019 return shipmentList;
00020 }
00021
00022 public String getitemsinShipment(String locn,String sn1,String sn2,boolean onlyBarCodes) throws Exception {
00023
00024
00025 if(onlyBarCodes) shipmentList = new Vector();
00026
00027 sqlStat = new StringBuffer("SELECT ");
00028 sqlStat.append("ser_no,ctype,assembled FROM items");
00029 sqlStat.append(" WHERE locn_name LIKE '"+locn+"' AND ser_no >= "+sn1+" AND ser_no <= "+sn2);
00030 sqlStat.append(" ORDER BY ser_no");
00031
00032 statement = db.connection.createStatement();
00033 System.out.println("Checking your ownership of items from "+sn1+" to "+sn2+" ...");
00034 resultSet = statement.executeQuery(sqlStat.toString());
00035 int recordCount=0;
00036 int itemcount=0;
00037 String ctype=null;
00038 for(boolean n = resultSet.next() ; n==true ; n=resultSet.next() ){
00039 recordCount++;
00040
00041 String serno = resultSet.getString(1);
00042 if(ctype==null) ctype = resultSet.getString(2);
00043 String assembledFlag = resultSet.getString(3);
00044
00045 if(ctype.equals("bmHASIC") && onlyBarCodes) {
00046 System.out.println(serno+" is invalid. Please use the barcode number!!!");
00047 break;
00048 }
00049 if(ctype.equals("bmHPC") && onlyBarCodes) {
00050 System.out.println(serno+" is invalid. Please use the barcode number!!!");
00051 break;
00052 }
00053 if(ctype.equals("bmBB") && onlyBarCodes) {
00054 System.out.println(serno+" is invalid. Please use the barcode number!!!");
00055 break;
00056 }
00057
00058 if(ctype.equals("bmHASIC") && assembledFlag.equals("YES")) continue;
00059 if(ctype.equals("bmHPC") && assembledFlag.equals("YES")) continue;
00060 if(ctype.equals("bmBB") && assembledFlag.equals("YES")) continue;
00061
00062 Vector theLine = new Vector();
00063 theLine.addElement(serno);
00064 theLine.addElement(ctype);
00065 theLine.addElement(assembledFlag);
00066 if(!shipmentList.contains((Vector)theLine)) shipmentList.addElement(theLine);
00067 itemcount++;
00068 }
00069 System.out.println("Retrieved "+recordCount+" records in total, and validated your ownership of "+itemcount);
00070 statement.close();
00071 return ctype;
00072 }
00073 }
00074