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"; }
public String addUser() { try { userBO.addNew(user); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return list(); }
public AccountAction() { super(); // TODO Auto-generated constructor stub try { int total = userBO.getAll().size(); int div = total / STATIC_ROW_MAX; if (div * STATIC_ROW_MAX == total) { totalPage = div; } else { totalPage = div + 1; } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public String list() { try { list = userBO.getAll(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } int index = 0, begin = 0; begin = (pageIndex - 1) * STATIC_ROW_MAX; if (pageIndex < totalPage) { index = pageIndex * STATIC_ROW_MAX; } else { index = list.size(); } for (int i = begin; i < index; i++) { listUser.add(list.get(i)); } return "list"; }