예제 #1
0
  public ArrayList<FIncomePO> findbyHall(String hall) throws RemoteException, IOException {
    ArrayList<FIncomePO> income = new ArrayList<FIncomePO>();
    ObjectInputStream os = null;
    System.out.println("start find!");
    try {
      FileInputStream fs = new FileInputStream(file);
      os = new ObjectInputStream(fs);
      FIncomePO po = (FIncomePO) os.readObject();

      while (fs.available() > 0) {
        byte[] buf = new byte[4];
        fs.read(buf);
        FIncomePO incomepo = (FIncomePO) os.readObject();

        if (incomepo.getShop().equals(hall)) {
          income.add(incomepo);
        }
      }

      return income;
    } catch (Exception e) {
      return null;
    } finally {
      os.close();
    }
  }
예제 #2
0
  public ArrayList<FIncomePO> findByTime(String time1, String time2)
      throws RemoteException, IOException {
    ArrayList<FIncomePO> income = new ArrayList<FIncomePO>();
    ObjectInputStream os = null;

    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
    try {
      Date date1 = formatter.parse(time1);
      Date date2 = formatter.parse(time2);

      FileInputStream fs = new FileInputStream(file);
      os = new ObjectInputStream(fs);
      FIncomePO po = (FIncomePO) os.readObject();

      while (fs.available() > 0) {
        byte[] buf = new byte[4];
        fs.read(buf);
        FIncomePO incomepo = (FIncomePO) os.readObject();

        if (formatter.parse(incomepo.getTime()).after(date1)
            && formatter.parse(incomepo.getTime()).before(date2)) {

          income.add(incomepo);
        }
      }

      return income;
    } catch (Exception e) {
      return null;
    } finally {
      os.close();
    }
  }
예제 #3
0
  public ArrayList<FIncomePO> findHallTime(String time1, String time2, String hall)
      throws RemoteException, IOException {
    ArrayList<FIncomePO> timeList = this.findByTime(time1, time2);
    ArrayList<FIncomePO> result = new ArrayList<FIncomePO>();

    if (timeList.isEmpty()) {
      return null;
    }

    for (int i = 0; i < timeList.size(); i++) {
      FIncomePO po = timeList.get(i);
      if (po.getShop().equals(hall)) result.add(po);
    }

    return result;
  }
예제 #4
0
  public void delete(FIncomePO po) throws RemoteException {
    FIncomePO PO = null;
    ObjectInputStream ois = null;
    ArrayList<FIncomePO> arr = new ArrayList<FIncomePO>();
    try {
      FileInputStream fs = new FileInputStream(file);
      ois = new ObjectInputStream(fs);
      PO = (FIncomePO) ois.readObject();

      while (true) {
        byte[] buf = new byte[4];
        fs.read(buf);
        PO = (FIncomePO) ois.readObject();
        System.out.println(PO.getID());
        arr.add(PO);
      }
    } catch (Exception e) {

    } finally {
      try {
        ois.close();
      } catch (IOException e) {
        e.printStackTrace();
      } finally {

        for (int i = 0; i < arr.size(); i++) {
          if (arr.get(i).getID().equals(po.getID())) {
            arr.remove(i);
          }
        }
        try {
          init();
          for (int i = 0; i < arr.size(); i++) {
            insert(arr.get(i));
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  }
예제 #5
0
  public FIncomePO find(String id) throws RemoteException, IOException {
    FIncomePO po = null;
    ObjectInputStream os = null;
    try {
      FileInputStream fs = new FileInputStream(file);
      os = new ObjectInputStream(fs);
      po = (FIncomePO) os.readObject();

      do {
        byte[] buf = new byte[4];
        fs.read(buf);
        po = (FIncomePO) os.readObject();
      } while (!(po.getID().equals(id)));

      return po;
    } catch (Exception e) {
      return null;
    } finally {
      os.close();
    }
  }