Beispiel #1
0
  public String delete() {
    try {
      List<Payment> listPayment = paymentBO.getAll();
      List<Usebus> listUse = useBO.getAll();
      List<BusDetail> listBusdetail = busDetailBO.getAll();
      List<Logging> listLog = loggingBO.getAll();

      user = userBO.getById(accountID);
      if (user.getAccount().compareTo(ACCOUNT_USER) == 0) {
        for (Payment p : listPayment) {
          if (p.getCustomerNumber().compareTo(accountID) == 0) {
            paymentBO.delete(p);
          }
        }
        for (Usebus u : listUse) {
          if (u.getCustomerNumber().compareTo(accountID) == 0) {
            useBO.delete(u);
          }
        }

        for (Logging l : listLog) {
          if (l.getCustomerNumber().compareTo(accountID) == 0) {
            loggingBO.delete(l);
          }
        }

        customer = customerBO.getById(accountID);
        customerBO.delete(customer);

      } else if (user.getAccount().compareTo(ACCOUNT_EMPLOYEE) == 0) {
        for (Payment p : listPayment) {
          if (p.getUserNumber().compareTo(accountID) == 0) {
            paymentBO.delete(p);
          }
        }
        for (BusDetail b : listBusdetail) {
          if (b.getEmployeeNumber().compareTo(accountID) == 0) {
            busDetailBO.delete(b);
          }
        }
        for (Logging l : listLog) {
          if (l.getUserNumber().compareTo(accountID) == 0) {
            loggingBO.delete(l);
          }
        }
        employee = employeeBO.getById(accountID);
        employeeBO.delete(employee);
      }
      userBO.delete(user);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    list();
    return "delete";
  }