public void ChangeData() { model.Customer c = customerdao.get(user.getCustomer().getCustomerid()); c.setCustomerfirstname(firstname); c.setCustomerlastname(lastname); c.setCustomeraddress(address); c.setCustomerphone(phone); customerdao.update(c); user.setCustomer(c); }
public String perform(HttpServletRequest request) { HttpSession session = request.getSession(); List<String> errors = new ArrayList<String>(); // authority judge if ((EmployeeBean) session.getAttribute("employee") == null) { return "employeelogin.do"; } request.setAttribute("errors", errors); EmployeeBean employee = (EmployeeBean) session.getAttribute("employee"); if (employee == null) { return "employeelogin.do"; } /* * Check the deposit form. */ DepositCheckForm depositcheckform = new DepositCheckForm(request); request.setAttribute("depositcheckform", depositcheckform); if (!depositcheckform.isPresent()) { return "employee_deposit_check.jsp"; } errors.addAll(depositcheckform.getValidationErrors()); if (errors.size() != 0) { return "employee_deposit_check.jsp"; } CustomerBean customer = (CustomerBean) session.getAttribute("modifyCustomer"); int id = customer.getCustomerId(); try { customer = customerDAO.read(id); } catch (RollbackException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } double amount = depositcheckform.getAmount(); ////////////////////// // Transaction START // ////////////////////// try { Transaction.begin(); TransactionBean transaction = new TransactionBean(); // what kind of transaction transaction.setTransactionType(TransactionType.DEPOSIT.toString()); // who request the deposit transaction.setCustomerId(customer.getCustomerId()); // how much money(in long) transaction.writeAmount(amount); // Create transaction transactionDAO.create(transaction); // update balance&available immediately. customer.writeCashBalance(amount); customerDAO.update(customer); Transaction.commit(); } catch (RollbackException e) { e.printStackTrace(); } //////////////////// // Transaction END// //////////////////// session.setAttribute("modifyCustomer", customer); // session.setAttribute("customer", customer); session.setAttribute( "message", "Thank you! You have successfully sent your deposit check request!"); return "success_employee.jsp"; }