Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions Projects/Project 0/src/main/java/DAOs/AccDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,24 +285,25 @@ public boolean depositFunds(int amount, int accID) throws SQLException {
*/
public boolean transferFunds(int amount, int accID, int otherAccID){
boolean success = false;
withdrawFunds(amount, accID);
NumberFormat formatter = NumberFormat.getCurrencyInstance(Locale.US);
try {
sql = "UPDATE ACCOUNTS " +
"SET BALANCE = (BALANCE + ?) " +
"WHERE ACCOUNT_ID = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, amount);
pstmt.setInt(2, otherAccID);

if (pstmt.executeUpdate() != 0) {
System.out.println(formatter.format(amount) + " has been deposited to Account: " + otherAccID);
success = true;
if(withdrawFunds(amount, accID)){
NumberFormat formatter = NumberFormat.getCurrencyInstance(Locale.US);
try {
sql = "UPDATE ACCOUNTS " +
"SET BALANCE = (BALANCE + ?) " +
"WHERE ACCOUNT_ID = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, amount);
pstmt.setInt(2, otherAccID);

if (pstmt.executeUpdate() != 0) {
System.out.println(formatter.format(amount) + " has been deposited to Account: " + otherAccID);
success = true;
}
} catch (SQLException e) {
System.out.println(NullAccount(otherAccID));
e.printStackTrace();
success = false;
}
} catch (SQLException e) {
System.out.println(NullAccount(otherAccID));
e.printStackTrace();
success = false;
}

return success;
Expand Down
5 changes: 4 additions & 1 deletion Projects/Project 0/src/main/java/Menu/TransferFunds.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ public void printMenu() throws SQLException {
pm.navigate("class Menu.LoggedIn");
isTransferring = false;
}
else{
pm.navigate("class Menu.LoggedIn");
isTransferring = false;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
pm.navigate("class Menu.LoggedIn");
}
}