@Override
 public ArrayList<DriverPO> findAll() {
   // TODO Auto-generated method stub
   ArrayList<DriverPO> drivers = new ArrayList<DriverPO>();
   DriverPO driver = null;
   ResultSet result = null;
   String sql = "SELECT*FROM driverpo;";
   try {
     result = Helper.find(sql);
     while (result.next()) {
       driver =
           new DriverPO(
               result.getString("name"),
               Work.valueOf(result.getString("work")),
               result.getString("workNumber"),
               result.getString("workPlaceNumber"),
               result.getString("birthDate"),
               result.getString("idNumber"),
               result.getString("phoneNumber"),
               result.getString("address"),
               Sex.valueOf(result.getString("sex")),
               result.getInt("driverYear"),
               result.getInt("page"));
       drivers.add(driver);
     }
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return drivers;
 }
 @Override
 public ResultMessage insert(DriverPO po) {
   // TODO Auto-generated method stub
   String sql =
       "insert into driverpo(name,work,workNumber,workPlaceNumber,birthdate,idNumber,phoneNumber,address,sex,driverYear,page) values('"
           + po.getName()
           + "','"
           + po.getWork()
           + "','"
           + po.getWorkNumber()
           + "','"
           + po.getWorkPlaceNumber()
           + "','"
           + po.getBirthDate()
           + "','"
           + po.getIdNumber()
           + "','"
           + po.getPhoneNumber()
           + "','"
           + po.getAddress()
           + "','"
           + po.getSex()
           + "',"
           + po.getDriverYear()
           + ","
           + po.getPage()
           + ");";
   return Helper.insert(sql);
 }
 @Override
 public ResultMessage delete(String id) {
   // TODO Auto-generated method stub
   String sql = "DELETE FROM driverpo WHERE workNumber='" + id + "';";
   ResultMessage result = Helper.delete(sql);
   return result;
 }
  @Override
  public DriverPO find(String id) {
    // TODO Auto-generated method stub
    ResultSet result = null;
    String sql = "SELECT*FROM driverpo WHERE workNumber= '" + id + "';";

    DriverPO driver = null;

    try {
      result = Helper.find(sql);
      if (result.next())
        driver =
            new DriverPO(
                result.getString("name"),
                Work.valueOf(result.getString("work")),
                result.getString("workNumber"),
                result.getString("workPlaceNumber"),
                result.getString("birthDate"),
                result.getString("idNumber"),
                result.getString("phoneNumber"),
                result.getString("address"),
                Sex.valueOf(result.getString("sex")),
                result.getInt("driverYear"),
                result.getInt("page"));
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return driver;
  }
  @Override
  public ReceiptsPO findReceipt(String date, String courier) throws RemoteException {
    // TODO Auto-generated method stub
    String sql = "select*from receiptspo where data='" + date + "' and courier='" + courier + "';";
    ReceiptsPO receiptsPO = null;
    ResultSet resultSet = null;

    try {
      resultSet = Helper.find(sql);
      while (resultSet.next()) {
        ArrayList<String> orderNumber =
            (ArrayList<String>) IOObject.getArray(resultSet.getBytes("orderNumber"));
        receiptsPO =
            new ReceiptsPO(
                resultSet.getString(1),
                resultSet.getDouble(2),
                resultSet.getString(3),
                orderNumber,
                resultSet.getString(5),
                DocumentCondition.valueOf(resultSet.getString(6)));
      }

    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    // TODO Auto-generated method stub
    return receiptsPO;
  }
 @Override
 public ResultMessage delete(DriverPO po) {
   // TODO Auto-generated method stub
   String sql = "DELETE FROM driverpo WHERE idNumber='" + po.getIdNumber() + "';";
   ResultMessage result = Helper.delete(sql);
   return result;
 }
  @Override
  public ResultMessage deleteReceiptsPO(String date, String courier) throws RemoteException {
    // TODO Auto-generated method stub

    String sql = "delete from receiptspo where data='" + date + "' and courier='" + courier + "';";
    return Helper.delete(sql);
  }
  @Override
  public ArrayList<ReceiptsPO> findReceipts(String date, String office) throws RemoteException {
    String sql = "select*from receiptspo where data='" + date + "' and office='" + office + "';";
    ArrayList<ReceiptsPO> receiptsPOs = new ArrayList<ReceiptsPO>();
    ResultSet resultSet = null;

    try {
      resultSet = Helper.find(sql);
      while (resultSet.next()) {
        ArrayList<String> orderNumber =
            (ArrayList<String>) IOObject.getArray(resultSet.getBytes("ordernumbers"));
        ReceiptsPO po =
            new ReceiptsPO(
                resultSet.getString(1),
                resultSet.getDouble(2),
                resultSet.getString(3),
                orderNumber,
                resultSet.getString(5),
                DocumentCondition.valueOf(resultSet.getString(6)));
        receiptsPOs.add(po);
      }

    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    // TODO Auto-generated method stub
    return receiptsPOs;
  }
  @Override
  public ArrayList<OrderPO> findWithdCondition(String nameOfCourier, DocumentCondition dCondition)
      throws RemoteException {
    // TODO Auto-generated method stub
    String sql =
        "select* from orderpo where documentcondition='"
            + dCondition
            + "' and nameofcourier='"
            + nameOfCourier
            + "';";
    ResultSet result = null;
    OrderPO po = null;
    ArrayList<OrderPO> pos = new ArrayList<OrderPO>();
    ReceiverPO receiver = null;
    SenderPO sender = null;
    BillPO bill = null;
    GoodsPO goods = null;

    try {
      result = Helper.find(sql);
      while (result.next()) {

        try {
          // ObjectInputStream oips = new ObjectInputStream(result.getBinaryStream("receiver"));
          receiver = (ReceiverPO) IOObject.getArray(result.getBytes("receiver"));
          // oips = new ObjectInputStream(result.getBinaryStream("sender"));
          sender = (SenderPO) IOObject.getArray(result.getBytes("sender"));
          // oips = new ObjectInputStream(result.getBinaryStream("bill"));
          bill = (BillPO) IOObject.getArray(result.getBytes("bill"));
          // oips = new ObjectInputStream(result.getBinaryStream("goods"));
          goods = (GoodsPO) IOObject.getArray(result.getBytes("goods"));
        } catch (Exception e) {
          // TODO: handle exception
          e.printStackTrace();
        }

        po =
            new OrderPO(
                receiver,
                sender,
                bill,
                goods,
                result.getString(5),
                result.getString(6),
                result.getString(7),
                result.getString(8),
                result.getString(9),
                DocumentCondition.valueOf(result.getString(10)));
        pos.add(po);
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
    return pos;
  }
Ejemplo n.º 10
0
  @Override
  public ArrayList<OrderPO> findReceived() throws RemoteException {
    // TODO Auto-generated method stub
    String sql = "select*from orderpo where receivetime != 'null';";
    ArrayList<OrderPO> orderPOs = new ArrayList<OrderPO>();
    ResultSet result = null;
    ReceiverPO receiver = null;
    SenderPO sender = null;
    BillPO bill = null;
    GoodsPO goods = null;

    try {
      result = Helper.find(sql);
      while (result.next()) {
        receiver = (ReceiverPO) IOObject.getArray(result.getBytes("receiver"));
        // oips = new ObjectInputStream(result.getBinaryStream("sender"));
        sender = (SenderPO) IOObject.getArray(result.getBytes("sender"));
        // oips = new ObjectInputStream(result.getBinaryStream("bill"));
        bill = (BillPO) IOObject.getArray(result.getBytes("bill"));
        // oips = new ObjectInputStream(result.getBinaryStream("goods"));
        goods = (GoodsPO) IOObject.getArray(result.getBytes("goods"));
        OrderPO po =
            new OrderPO(
                receiver,
                sender,
                bill,
                goods,
                result.getString(5),
                result.getString(6),
                result.getString(7),
                result.getString(8),
                result.getString(9),
                DocumentCondition.valueOf(result.getString(10)));
        orderPOs.add(po);
      }
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return orderPOs;
  }
Ejemplo n.º 11
0
  @Override
  public OrderPO findLatest() throws RemoteException {
    // TODO Auto-generated method stub

    String sql = "select * from orderpo order by ordernumber desc;";
    OrderPO po = null;
    ResultSet result = null;
    ReceiverPO receiver = null;
    SenderPO sender = null;
    BillPO bill = null;
    GoodsPO goods = null;

    try {
      result = Helper.find(sql);
      if (result.next()) {
        receiver = (ReceiverPO) IOObject.getArray(result.getBytes("receiver"));
        // oips = new ObjectInputStream(result.getBinaryStream("sender"));
        sender = (SenderPO) IOObject.getArray(result.getBytes("sender"));
        // oips = new ObjectInputStream(result.getBinaryStream("bill"));
        bill = (BillPO) IOObject.getArray(result.getBytes("bill"));
        // oips = new ObjectInputStream(result.getBinaryStream("goods"));
        goods = (GoodsPO) IOObject.getArray(result.getBytes("goods"));
        po =
            new OrderPO(
                receiver,
                sender,
                bill,
                goods,
                result.getString(5),
                result.getString(6),
                result.getString(7),
                result.getString(8),
                result.getString(9),
                DocumentCondition.valueOf(result.getString(10)));
      }
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return po;
  }