use of tab.Lend in project Money-Manager by krHasan.
the class Undo method undoLend.
// /////////////////////// Lend Undo Action /////////////////////////////////
// ------------------------------------------------------------------------//
private boolean undoLend(int globalID) {
boolean feedback = false;
// sql queries for undo last Lend transaction
String undoLe = "SELECT * FROM Lend WHERE globalID = ?";
String deleteLe = "DELETE FROM Lend WHERE globalID = ?";
// variable to store the rollbacked transaction information temporarily
String leBalanceBefore = null;
String leType = "None";
String leMethod = "None";
String leWhom = null;
String leExactTk = null;
String leDate = null;
// if result set has a result then assign data to correspond variables
try (Connection conn = connector();
PreparedStatement pstmt = conn.prepareStatement(undoLe)) {
pstmt.setInt(1, globalID);
ResultSet leResult = pstmt.executeQuery();
if (leResult.next()) {
leBalanceBefore = leResult.getString("leBalanceBefore");
leType = leResult.getString("leType");
leMethod = leResult.getString("leMethod");
leWhom = leResult.getString("leWhom");
leExactTk = leResult.getString("leExactTk");
leDate = leResult.getString("leDate");
feedback = true;
}
} catch (Exception e) {
e.printStackTrace();
}
// if lend type is "Give Money"
if (leType.equals("Give Money")) {
// if lend type is "Give Money" and method is "bKash"
if (leMethod.equals("bKash")) {
// delete the last Lend transaction
try (Connection connle = connector();
PreparedStatement pstmtle = connle.prepareStatement(deleteLe)) {
pstmtle.setInt(1, globalID);
pstmtle.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
// sql queries for bKash transaction
String undoBk = "SELECT * FROM bKash WHERE globalID = ?";
String deleteBk = "DELETE FROM bKash WHERE globalID = ?";
// get the bKash balance before this transaction
String bkBalanceBefore = null;
try (Connection conn = connector();
PreparedStatement pstmt = conn.prepareStatement(undoBk)) {
pstmt.setInt(1, --globalID);
ResultSet bkResult = pstmt.executeQuery();
bkBalanceBefore = bkResult.getString("bkBalanceBefore");
} catch (Exception e) {
e.printStackTrace();
}
// then delete that transaction
try (Connection connbk = connector();
PreparedStatement pstmtbk = connbk.prepareStatement(deleteBk)) {
pstmtbk.setInt(1, globalID);
pstmtbk.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
// delete summary information from Lend_Summary table
String deleteLeSummary = "DELETE FROM Lend_Summary WHERE leWhom = ?";
try (Connection connbk = connector();
PreparedStatement pstmtbk = connbk.prepareStatement(deleteLeSummary)) {
pstmtbk.setString(1, leWhom);
pstmtbk.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
// roll back bKash balance
setCurrentbKashBalance(removeThousandSeparator(bkBalanceBefore));
// roll back Total Lend Tk
setTotalLendTk(removeThousandSeparator(leBalanceBefore));
// roll back globalID
GlobalId.setGlobalId(globalID);
// if lend type is "Give Money" and method is "Rocket"
} else if (leMethod.equals("Rocket")) {
// delete the last Lend transaction
try (Connection conngm = connector();
PreparedStatement pstmtgm = conngm.prepareStatement(deleteLe)) {
pstmtgm.setInt(1, globalID);
pstmtgm.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
// sql queries for Rocket transaction
String undoRoc = "SELECT * FROM Rocket WHERE globalID = ?";
String deleteRoc = "DELETE FROM Rocket WHERE globalID = ?";
// get the Rocket balance before this transaction
String rocBalanceBefore = null;
try (Connection conn = connector();
PreparedStatement pstmt = conn.prepareStatement(undoRoc)) {
pstmt.setInt(1, --globalID);
ResultSet rocResult = pstmt.executeQuery();
rocBalanceBefore = rocResult.getString("rocBalanceBefore");
} catch (Exception e) {
e.printStackTrace();
}
// then delete that transaction
try (Connection connroc = connector();
PreparedStatement pstmtroc = connroc.prepareStatement(deleteRoc)) {
pstmtroc.setInt(1, globalID);
pstmtroc.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
// delete summary information from Lend_Summary table
String deleteLeSummary = "DELETE FROM Lend_Summary WHERE leWhom = ?";
try (Connection connroc = connector();
PreparedStatement pstmtroc = connroc.prepareStatement(deleteLeSummary)) {
pstmtroc.setString(1, leWhom);
pstmtroc.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
// roll back Rocket balance
setCurrentRocketBalance(removeThousandSeparator(rocBalanceBefore));
// roll back Total Lend Tk
setTotalLendTk(removeThousandSeparator(leBalanceBefore));
// roll back globalID
GlobalId.setGlobalId(globalID);
// if lend type is "Give Money" and method is "Hand to Hand"
} else if (leMethod.equals("Hand to Hand")) {
// delete the last Lend transaction
try (Connection connHH = connector();
PreparedStatement pstmtHH = connHH.prepareStatement(deleteLe)) {
pstmtHH.setInt(1, globalID);
pstmtHH.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
// delete summary information from Lend_Summary table
String deleteLeSummary = "DELETE FROM Lend_Summary WHERE leWhom = ?";
try (Connection connHH = connector();
PreparedStatement pstmtHH = connHH.prepareStatement(deleteLeSummary)) {
pstmtHH.setString(1, leWhom);
pstmtHH.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
// roll back Wallet balance
setCurrentWalletBalance(longToString(currentWalletBalance() + stringToLong(removeThousandSeparator(leExactTk))));
// roll back Total Lend Tk
setTotalLendTk(removeThousandSeparator(leBalanceBefore));
// roll back globalID
GlobalId.setGlobalId(globalID);
}
// if lend type is "Give Money"
} else if (leType.equals("Take Back Lended Money")) {
// if lend type is "Take Back Lended Money" and method is "bKash"
if (leMethod.equals("bKash")) {
try (Connection connle = connector();
PreparedStatement pstmtle = connle.prepareStatement(deleteLe)) {
pstmtle.setInt(1, globalID);
pstmtle.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
String undoBk = "SELECT * FROM bKash WHERE globalID = ?";
String deleteBk = "DELETE FROM bKash WHERE globalID = ?";
String bkBalanceBefore = null;
try (Connection conn = connector();
PreparedStatement pstmt = conn.prepareStatement(undoBk)) {
pstmt.setInt(1, --globalID);
ResultSet bkResult = pstmt.executeQuery();
bkBalanceBefore = bkResult.getString("bkBalanceBefore");
} catch (Exception e) {
e.printStackTrace();
}
try (Connection connbk = connector();
PreparedStatement pstmtbk = connbk.prepareStatement(deleteBk)) {
pstmtbk.setInt(1, globalID);
pstmtbk.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
Map<String, String> boleData = new HashMap<>();
boleData.put("leDate", leDate);
boleData.put("leWhom", leWhom);
boleData.put("leExactTk", removeThousandSeparator(leExactTk));
if (!new Lend().leRepayPersonLendedAmount(leWhom).equals("0")) {
(new Lend()).updateLendSummaryDataForUndo(boleData);
} else {
(new Lend()).addLendSummaryData(boleData);
}
setCurrentbKashBalance(removeThousandSeparator(bkBalanceBefore));
setTotalLendTk(removeThousandSeparator(leBalanceBefore));
GlobalId.setGlobalId(globalID);
// if lend type is "Take Back Lended Money" and method is "Rocket"
} else if (leMethod.equals("Rocket")) {
try (Connection conngm = connector();
PreparedStatement pstmtgm = conngm.prepareStatement(deleteLe)) {
pstmtgm.setInt(1, globalID);
pstmtgm.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
String undoRoc = "SELECT * FROM Rocket WHERE globalID = ?";
String deleteRoc = "DELETE FROM Rocket WHERE globalID = ?";
String rocBalanceBefore = null;
try (Connection conn = connector();
PreparedStatement pstmt = conn.prepareStatement(undoRoc)) {
pstmt.setInt(1, --globalID);
ResultSet rocResult = pstmt.executeQuery();
rocBalanceBefore = rocResult.getString("rocBalanceBefore");
} catch (Exception e) {
e.printStackTrace();
}
try (Connection connroc = connector();
PreparedStatement pstmtroc = connroc.prepareStatement(deleteRoc)) {
pstmtroc.setInt(1, globalID);
pstmtroc.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
Map<String, String> boleData = new HashMap<>();
boleData.put("leDate", leDate);
boleData.put("leWhom", leWhom);
boleData.put("leExactTk", removeThousandSeparator(leExactTk));
if (!new Lend().leRepayPersonLendedAmount(leWhom).equals("0")) {
(new Lend()).updateLendSummaryDataForUndo(boleData);
} else {
(new Lend()).addLendSummaryData(boleData);
}
setCurrentRocketBalance(removeThousandSeparator(rocBalanceBefore));
setTotalLendTk(removeThousandSeparator(leBalanceBefore));
GlobalId.setGlobalId(globalID);
// if lend type is "Take Back Lended Money" and method is "Hand to Hand"
} else if (leMethod.equals("Hand to Hand")) {
// delete the last Lend transaction
try (Connection connHH = connector();
PreparedStatement pstmtHH = connHH.prepareStatement(deleteLe)) {
pstmtHH.setInt(1, globalID);
pstmtHH.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
Map<String, String> boleData = new HashMap<>();
boleData.put("leDate", leDate);
boleData.put("leWhom", leWhom);
boleData.put("leExactTk", removeThousandSeparator(leExactTk));
if (!new Lend().leRepayPersonLendedAmount(leWhom).equals("0")) {
(new Lend()).updateLendSummaryDataForUndo(boleData);
} else {
(new Lend()).addLendSummaryData(boleData);
}
setCurrentWalletBalance(longToString(currentWalletBalance() - stringToLong(removeThousandSeparator(leExactTk))));
setTotalLendTk(removeThousandSeparator(leBalanceBefore));
GlobalId.setGlobalId(globalID);
}
}
return feedback;
}
use of tab.Lend in project Money-Manager by krHasan.
the class MakeATransactionController method lendSaveBtn.
@FXML
private void lendSaveBtn(ActionEvent event) {
Map<String, String> boleData = new HashMap<>();
try {
if (selectedTabName.equals("Borrow")) {
if (bocmboType.getValue().equals("Money Take")) {
// Borrow, Money Take, bKash
if (bocmboMethod.getValue().equals("bKash")) {
if (amountIsZero(botxtAmountWithCharge.getText()) || letterCount(botxtFromWhom.getText()) == 100 || amountIsZero(botxtExactAmount.getText())) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Zero or Empty is not allowed");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
boleData.put("boTime", timeToSave());
boleData.put("boDate", (new DateFormatManager()).toString(lenddateDate.getValue()));
boleData.put("boMonth", monthToSave(lenddateDate.getValue()));
boleData.put("boType", bocmboType.getValue());
boleData.put("boMethod", bocmboMethod.getValue());
boleData.put("boWhom", botxtFromWhom.getText());
boleData.put("boTk", botxtAmountWithCharge.getText());
boleData.put("boNature", "None");
boleData.put("boBnkCharge", boBankChargeShow());
boleData.put("boBalanceBefore", longToString(totalBorrowTk()));
boleData.put("boBalanceAfter", updatedTotalBorrowTk(botxtExactAmount.getText(), "Money Take"));
boleData.put("boExactTk", botxtExactAmount.getText());
boleData.put("bkBalanceBefore", longToString(currentbKashBalance()));
boleData.put("bkBalanceAfter", updatedbKashBalance(botxtAmountWithCharge.getText(), "Cash In"));
(new Borrow()).addBorrowSummaryData(boleData);
(new Bkash()).saveBorrowBkashData(boleData);
(new Borrow()).saveBorrowData(boleData);
(new ComboboxList()).setAllMonth(monthToSave(lenddateDate.getValue()), yearToSave(lenddateDate.getValue()));
setCurrentbKashBalance(updatedbKashBalance(botxtAmountWithCharge.getText(), "Cash In"));
// setCurrentbKashBalance(boBkBalanceAfter(botxtAmountWithCharge.getText(), boBankChargeShow(), "Money Take"));
setTotalBorrowTk(updatedTotalBorrowTk(botxtExactAmount.getText(), "Money Take"));
boInitialize();
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Successfull Transaction");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Successful");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
confirmationMsg.setX(MakeATransactionStage.getX() + 200);
confirmationMsg.setY(MakeATransactionStage.getY() + 29);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
}
// Borrow, Money Take, Rocket
} else if (bocmboMethod.getValue().equals("Rocket")) {
if (amountIsZero(botxtAmountWithCharge.getText()) || letterCount(botxtFromWhom.getText()) == 100 || amountIsZero(botxtExactAmount.getText())) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Zero or Empty is not allowed");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
boleData.put("boTime", timeToSave());
boleData.put("boDate", (new DateFormatManager()).toString(lenddateDate.getValue()));
boleData.put("boMonth", monthToSave(lenddateDate.getValue()));
boleData.put("boType", bocmboType.getValue());
boleData.put("boMethod", bocmboMethod.getValue());
boleData.put("boWhom", botxtFromWhom.getText());
boleData.put("boTk", botxtAmountWithCharge.getText());
boleData.put("boNature", boGetSelectedrbtnName());
boleData.put("boBnkCharge", boBankChargeShow());
boleData.put("boBalanceBefore", longToString(totalBorrowTk()));
boleData.put("boBalanceAfter", updatedTotalBorrowTk(botxtExactAmount.getText(), "Money Take"));
boleData.put("boExactTk", botxtExactAmount.getText());
boleData.put("rocBalanceBefore", longToString(currentRocketBalance()));
boleData.put("rocBalanceAfter", updatedRocketBalance(botxtAmountWithCharge.getText(), "Cash In", boGetSelectedrbtnName()));
(new Borrow()).addBorrowSummaryData(boleData);
(new Rocket()).saveBorrowRocketData(boleData);
(new Borrow()).saveBorrowData(boleData);
(new ComboboxList()).setAllMonth(monthToSave(lenddateDate.getValue()), yearToSave(lenddateDate.getValue()));
setCurrentRocketBalance(updatedRocketBalance(botxtAmountWithCharge.getText(), "Cash In", boGetSelectedrbtnName()));
// setCurrentRocketBalance(boRocBalanceAfter(botxtAmountWithCharge.getText(), boBankChargeShow(), "Money Take"));
setTotalBorrowTk(updatedTotalBorrowTk(botxtExactAmount.getText(), "Money Take"));
boInitialize();
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Successfull Transaction");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Successful");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
confirmationMsg.setX(MakeATransactionStage.getX() + 200);
confirmationMsg.setY(MakeATransactionStage.getY() + 29);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
}
} else {
// Borrow, Money Take, Hand to Hand
if (amountIsZero(botxtAmountWithCharge.getText()) || letterCount(botxtFromWhom.getText()) == 100) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Zero or Empty is not allowed");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
boleData.put("boTime", timeToSave());
boleData.put("boDate", (new DateFormatManager()).toString(lenddateDate.getValue()));
boleData.put("boMonth", monthToSave(lenddateDate.getValue()));
boleData.put("boType", bocmboType.getValue());
boleData.put("boMethod", bocmboMethod.getValue());
boleData.put("boWhom", botxtFromWhom.getText());
boleData.put("boTk", botxtAmountWithCharge.getText());
boleData.put("boNature", "None");
boleData.put("boBnkCharge", "None");
boleData.put("boBalanceBefore", longToString(totalBorrowTk()));
boleData.put("boBalanceAfter", updatedTotalBorrowTk(botxtAmountWithCharge.getText(), "Money Take"));
boleData.put("boExactTk", botxtAmountWithCharge.getText());
boleData.put("gmWalletBalanceBefore", longToString(currentWalletBalance()));
boleData.put("gmWalletBalanceAfter", gmWalletBalanceAfter(botxtAmountWithCharge.getText()));
(new Borrow()).saveBorrowData(boleData);
(new Borrow()).addBorrowSummaryData(boleData);
// if it activate, then you have to change in Undo Class --> undoBorrow() method
// (new GetMoney()).saveBorrowGMData(boleData);
(new ComboboxList()).setAllMonth(monthToSave(lenddateDate.getValue()), yearToSave(lenddateDate.getValue()));
setCurrentWalletBalance(gmWalletBalanceAfter(botxtAmountWithCharge.getText()));
setTotalBorrowTk(updatedTotalBorrowTk(botxtAmountWithCharge.getText(), "Money Take"));
boInitialize();
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Successfull Transaction");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Successful");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
confirmationMsg.setX(MakeATransactionStage.getX() + 200);
confirmationMsg.setY(MakeATransactionStage.getY() + 29);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
}
}
} else {
// Borrow, Return Borrowed Money, bKash
if (bocmboMethod.getValue().equals("bKash")) {
if (amountIsZero(botxtAmountWithCharge.getText()) || amountIsZero(botxtExactAmount.getText())) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Zero or Empty is not allowed");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
if (boRepayValidation(botxtExactAmount.getText(), bocmboRepaidPerson.getValue())) {
boleData.put("boTime", timeToSave());
boleData.put("boDate", (new DateFormatManager()).toString(lenddateDate.getValue()));
boleData.put("boMonth", monthToSave(lenddateDate.getValue()));
boleData.put("boType", bocmboType.getValue());
boleData.put("boMethod", bocmboMethod.getValue());
boleData.put("boWhom", bocmboRepaidPerson.getValue());
boleData.put("boTk", botxtAmountWithCharge.getText());
boleData.put("boNature", boGetSelectedrbtnName());
boleData.put("boBnkCharge", boBankChargeShow());
boleData.put("boBalanceBefore", longToString(totalBorrowTk()));
boleData.put("boBalanceAfter", updatedTotalBorrowTk(botxtExactAmount.getText(), "Return Borrowed Money"));
boleData.put("boExactTk", botxtExactAmount.getText());
boleData.put("bkBalanceBefore", longToString(currentbKashBalance()));
boleData.put("bkBalanceAfter", updatedbKashBalance(botxtAmountWithCharge.getText(), boGetSelectedrbtnName()));
if (boisTypedAmountLessThanBorrowed(botxtExactAmount.getText(), bocmboRepaidPerson.getValue())) {
(new Borrow()).updateBorrowSummaryData(boleData);
} else {
(new Borrow()).deleteBorrowSummaryData(boleData);
}
(new Bkash()).saveBorrowBkashData(boleData);
(new Borrow()).saveBorrowData(boleData);
(new ComboboxList()).setAllMonth(monthToSave(lenddateDate.getValue()), yearToSave(lenddateDate.getValue()));
setCurrentbKashBalance(updatedbKashBalance(botxtAmountWithCharge.getText(), boGetSelectedrbtnName()));
// setCurrentbKashBalance(boBkBalanceAfter(botxtAmountWithCharge.getText(), boBankChargeShow(), "Return Borrowed Money"));
setTotalBorrowTk(updatedTotalBorrowTk(botxtExactAmount.getText(), "Return Borrowed Money"));
boInitialize();
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Successfull Transaction");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Successful");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
confirmationMsg.setX(MakeATransactionStage.getX() + 200);
confirmationMsg.setY(MakeATransactionStage.getY() + 29);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
} else {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Amount can't bigger than borrowed amount");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
}
}
// Borrow, Return Borrowed Money, Rocket
} else if (bocmboMethod.getValue().equals("Rocket")) {
if (amountIsZero(botxtAmountWithCharge.getText()) || amountIsZero(botxtExactAmount.getText())) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Zero or Empty is not allowed");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
if (boRepayValidation(botxtExactAmount.getText(), bocmboRepaidPerson.getValue())) {
boleData.put("boTime", timeToSave());
boleData.put("boDate", (new DateFormatManager()).toString(lenddateDate.getValue()));
boleData.put("boMonth", monthToSave(lenddateDate.getValue()));
boleData.put("boType", bocmboType.getValue());
boleData.put("boMethod", bocmboMethod.getValue());
boleData.put("boWhom", bocmboRepaidPerson.getValue());
boleData.put("boTk", botxtAmountWithCharge.getText());
boleData.put("boNature", boGetSelectedrbtnName());
boleData.put("boBnkCharge", boBankChargeShow());
boleData.put("boBalanceBefore", longToString(totalBorrowTk()));
boleData.put("boBalanceAfter", updatedTotalBorrowTk(botxtExactAmount.getText(), "Return Borrowed Money"));
boleData.put("boExactTk", botxtExactAmount.getText());
boleData.put("rocBalanceBefore", longToString(currentRocketBalance()));
boleData.put("rocBalanceAfter", updatedRocketBalance(botxtAmountWithCharge.getText(), "Cash Out", boGetSelectedrbtnName()));
if (boisTypedAmountLessThanBorrowed(botxtExactAmount.getText(), bocmboRepaidPerson.getValue())) {
(new Borrow()).updateBorrowSummaryData(boleData);
} else {
(new Borrow()).deleteBorrowSummaryData(boleData);
}
(new Rocket()).saveBorrowRocketData(boleData);
(new Borrow()).saveBorrowData(boleData);
(new ComboboxList()).setAllMonth(monthToSave(lenddateDate.getValue()), yearToSave(lenddateDate.getValue()));
setCurrentRocketBalance(updatedRocketBalance(botxtAmountWithCharge.getText(), "Cash Out", boGetSelectedrbtnName()));
// setCurrentRocketBalance(boRocBalanceAfter(botxtAmountWithCharge.getText(), boBankChargeShow(), "Return Borrowed Money"));
setTotalBorrowTk(updatedTotalBorrowTk(botxtExactAmount.getText(), "Return Borrowed Money"));
boInitialize();
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Successfull Transaction");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Successful");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
confirmationMsg.setX(MakeATransactionStage.getX() + 200);
confirmationMsg.setY(MakeATransactionStage.getY() + 29);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
} else {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Amount can't bigger than borrowed amount");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
}
}
} else {
// Borrow, Return Borrowed Money, Hand to Hand
if (amountIsZero(botxtAmountWithCharge.getText())) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Zero or Empty is not allowed");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
if (boRepayValidation(botxtAmountWithCharge.getText(), bocmboRepaidPerson.getValue())) {
boleData.put("boTime", timeToSave());
boleData.put("boDate", (new DateFormatManager()).toString(lenddateDate.getValue()));
boleData.put("boMonth", monthToSave(lenddateDate.getValue()));
boleData.put("boType", bocmboType.getValue());
boleData.put("boMethod", bocmboMethod.getValue());
boleData.put("boWhom", bocmboRepaidPerson.getValue());
boleData.put("boTk", botxtAmountWithCharge.getText());
boleData.put("boNature", "None");
boleData.put("boBnkCharge", "None");
boleData.put("boBalanceBefore", longToString(totalBorrowTk()));
boleData.put("boBalanceAfter", updatedTotalBorrowTk(botxtAmountWithCharge.getText(), "Return Borrowed Money"));
boleData.put("boExactTk", botxtAmountWithCharge.getText());
boleData.put("gmWalletBalanceBefore", longToString(currentWalletBalance()));
boleData.put("gmWalletBalanceAfter", exWalletBalanceAfter(botxtAmountWithCharge.getText()));
(new Borrow()).saveBorrowData(boleData);
if (boisTypedAmountLessThanBorrowed(botxtAmountWithCharge.getText(), bocmboRepaidPerson.getValue())) {
(new Borrow()).updateBorrowSummaryData(boleData);
} else {
(new Borrow()).deleteBorrowSummaryData(boleData);
}
// if it activate, then you have to change in Undo Class --> undoBorrow() method
// (new GetMoney()).saveBorrowGMData(boleData);
(new ComboboxList()).setAllMonth(monthToSave(lenddateDate.getValue()), yearToSave(lenddateDate.getValue()));
setCurrentWalletBalance(exWalletBalanceAfter(botxtAmountWithCharge.getText()));
setTotalBorrowTk(updatedTotalBorrowTk(botxtAmountWithCharge.getText(), "Return Borrowed Money"));
boInitialize();
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Successfull Transaction");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Successful");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
confirmationMsg.setX(MakeATransactionStage.getX() + 200);
confirmationMsg.setY(MakeATransactionStage.getY() + 29);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
} else {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Amount can't bigger than borrowed amount");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
}
}
}
}
} else {
if (lecmboType.getValue().equals("Give Money")) {
// Lend, Give Money, bKash
if (lecmboMethod.getValue().equals("bKash")) {
if (amountIsZero(letxtAmountWithCharge.getText()) || letterCount(letxtFromWhom.getText()) == 100 || amountIsZero(letxtExactAmount.getText())) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Zero or Empty is not allowed");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
boleData.put("leTime", timeToSave());
boleData.put("leDate", (new DateFormatManager()).toString(lenddateDate.getValue()));
boleData.put("leMonth", monthToSave(lenddateDate.getValue()));
boleData.put("leType", lecmboType.getValue());
boleData.put("leMethod", lecmboMethod.getValue());
boleData.put("leWhom", letxtFromWhom.getText());
boleData.put("leTk", letxtAmountWithCharge.getText());
boleData.put("leNature", leGetSelectedrbtnName());
boleData.put("leBnkCharge", leBankChargeShow());
boleData.put("leBalanceBefore", longToString(totalLendTk()));
boleData.put("leBalanceAfter", updatedTotalLendTk(letxtExactAmount.getText(), "Give Money"));
boleData.put("leExactTk", letxtExactAmount.getText());
boleData.put("bkBalanceBefore", longToString(currentbKashBalance()));
boleData.put("bkBalanceAfter", updatedbKashBalance(letxtAmountWithCharge.getText(), leGetSelectedrbtnName()));
(new Lend()).addLendSummaryData(boleData);
(new Bkash()).saveLendBkashData(boleData);
(new Lend()).saveLendData(boleData);
(new ComboboxList()).setAllMonth(monthToSave(lenddateDate.getValue()), yearToSave(lenddateDate.getValue()));
setCurrentbKashBalance(updatedbKashBalance(letxtAmountWithCharge.getText(), leGetSelectedrbtnName()));
// setCurrentbKashBalance(leBkBalanceAfter(letxtAmountWithCharge.getText(), leBankChargeShow(), "Give Money"));
setTotalLendTk(updatedTotalLendTk(letxtExactAmount.getText(), "Give Money"));
leInitialize();
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Successfull Transaction");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Successful");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
confirmationMsg.setX(MakeATransactionStage.getX() + 200);
confirmationMsg.setY(MakeATransactionStage.getY() + 29);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
}
// Lend, Give Money, Rocket
} else if (lecmboMethod.getValue().equals("Rocket")) {
if (amountIsZero(letxtAmountWithCharge.getText()) || letterCount(letxtFromWhom.getText()) == 100 || amountIsZero(letxtExactAmount.getText())) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Zero or Empty is not allowed");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
boleData.put("leTime", timeToSave());
boleData.put("leDate", (new DateFormatManager()).toString(lenddateDate.getValue()));
boleData.put("leMonth", monthToSave(lenddateDate.getValue()));
boleData.put("leType", lecmboType.getValue());
boleData.put("leMethod", lecmboMethod.getValue());
boleData.put("leWhom", letxtFromWhom.getText());
boleData.put("leTk", letxtAmountWithCharge.getText());
boleData.put("leNature", leGetSelectedrbtnName());
boleData.put("leBnkCharge", leBankChargeShow());
boleData.put("leBalanceBefore", longToString(totalLendTk()));
boleData.put("leBalanceAfter", updatedTotalLendTk(letxtExactAmount.getText(), "Give Money"));
boleData.put("leExactTk", letxtExactAmount.getText());
boleData.put("rocBalanceBefore", longToString(currentRocketBalance()));
boleData.put("rocBalanceAfter", updatedRocketBalance(letxtAmountWithCharge.getText(), "Cash Out", leGetSelectedrbtnName()));
(new Lend()).addLendSummaryData(boleData);
(new Rocket()).saveLendRocketData(boleData);
(new Lend()).saveLendData(boleData);
(new ComboboxList()).setAllMonth(monthToSave(lenddateDate.getValue()), yearToSave(lenddateDate.getValue()));
setCurrentRocketBalance(updatedRocketBalance(letxtAmountWithCharge.getText(), "Cash Out", leGetSelectedrbtnName()));
// setCurrentRocketBalance(leRocBalanceAfter(letxtAmountWithCharge.getText(), leBankChargeShow(), "Give Money"));
setTotalLendTk(updatedTotalLendTk(letxtExactAmount.getText(), "Give Money"));
leInitialize();
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Successfull Transaction");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Successful");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
confirmationMsg.setX(MakeATransactionStage.getX() + 200);
confirmationMsg.setY(MakeATransactionStage.getY() + 29);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
}
} else {
// Lend, Give Money, Hand to Hand
if (amountIsZero(letxtAmountWithCharge.getText()) || letterCount(letxtFromWhom.getText()) == 100) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Zero or Empty is not allowed");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
boleData.put("leTime", timeToSave());
boleData.put("leDate", (new DateFormatManager()).toString(lenddateDate.getValue()));
boleData.put("leMonth", monthToSave(lenddateDate.getValue()));
boleData.put("leType", lecmboType.getValue());
boleData.put("leMethod", lecmboMethod.getValue());
boleData.put("leWhom", letxtFromWhom.getText());
boleData.put("leTk", letxtAmountWithCharge.getText());
boleData.put("leNature", "None");
boleData.put("leBnkCharge", "None");
boleData.put("leBalanceBefore", longToString(totalLendTk()));
boleData.put("leBalanceAfter", updatedTotalLendTk(letxtAmountWithCharge.getText(), "Give Money"));
boleData.put("leExactTk", letxtAmountWithCharge.getText());
boleData.put("gmWalletBalanceBefore", longToString(currentWalletBalance()));
boleData.put("gmWalletBalanceAfter", exWalletBalanceAfter(letxtAmountWithCharge.getText()));
(new Lend()).saveLendData(boleData);
(new Lend()).addLendSummaryData(boleData);
// (new GetMoney()).saveLendGMData(boleData);
(new ComboboxList()).setAllMonth(monthToSave(lenddateDate.getValue()), yearToSave(lenddateDate.getValue()));
setCurrentWalletBalance(exWalletBalanceAfter(letxtAmountWithCharge.getText()));
setTotalLendTk(updatedTotalLendTk(letxtAmountWithCharge.getText(), "Give Money"));
leInitialize();
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Successfull Transaction");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Successful");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
confirmationMsg.setX(MakeATransactionStage.getX() + 200);
confirmationMsg.setY(MakeATransactionStage.getY() + 29);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
}
}
} else {
// Lend, Take Back Lended Money, bKash
if (lecmboMethod.getValue().equals("bKash")) {
if (amountIsZero(letxtAmountWithCharge.getText()) || amountIsZero(letxtExactAmount.getText())) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Zero or Empty is not allowed");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
if (leRepayValidation(letxtExactAmount.getText(), lecmboRepaidPerson.getValue())) {
boleData.put("leTime", timeToSave());
boleData.put("leDate", (new DateFormatManager()).toString(lenddateDate.getValue()));
boleData.put("leMonth", monthToSave(lenddateDate.getValue()));
boleData.put("leType", lecmboType.getValue());
boleData.put("leMethod", lecmboMethod.getValue());
boleData.put("leWhom", lecmboRepaidPerson.getValue());
boleData.put("leTk", letxtAmountWithCharge.getText());
boleData.put("leNature", leGetSelectedrbtnName());
boleData.put("leBnkCharge", leBankChargeShow());
boleData.put("leBalanceBefore", longToString(totalLendTk()));
boleData.put("leBalanceAfter", updatedTotalLendTk(letxtExactAmount.getText(), "Take Back Lended Money"));
boleData.put("leExactTk", letxtExactAmount.getText());
boleData.put("bkBalanceBefore", longToString(currentbKashBalance()));
boleData.put("bkBalanceAfter", updatedbKashBalance(letxtAmountWithCharge.getText(), "Cash In"));
if (leisTypedAmountLessThanLended(letxtExactAmount.getText(), lecmboRepaidPerson.getValue())) {
(new Lend()).updateLendSummaryData(boleData);
} else {
(new Lend()).deleteLendSummaryData(boleData);
}
(new Bkash()).saveLendBkashData(boleData);
(new Lend()).saveLendData(boleData);
(new ComboboxList()).setAllMonth(monthToSave(lenddateDate.getValue()), yearToSave(lenddateDate.getValue()));
setCurrentbKashBalance(updatedbKashBalance(letxtAmountWithCharge.getText(), "Cash In"));
// setCurrentbKashBalance(leBkBalanceAfter(letxtAmountWithCharge.getText(), leBankChargeShow(), "Take Back Lended Money"));
setTotalLendTk(updatedTotalLendTk(letxtExactAmount.getText(), "Take Back Lended Money"));
leInitialize();
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Successfull Transaction");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Successful");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
confirmationMsg.setX(MakeATransactionStage.getX() + 200);
confirmationMsg.setY(MakeATransactionStage.getY() + 29);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
} else {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Amount can't bigger than borrowed amount");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
}
}
// Lend, Take Back Lended Money, Rocket
} else if (lecmboMethod.getValue().equals("Rocket")) {
if (amountIsZero(letxtAmountWithCharge.getText()) || amountIsZero(letxtExactAmount.getText())) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Zero or Empty is not allowed");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
if (leRepayValidation(letxtExactAmount.getText(), lecmboRepaidPerson.getValue())) {
boleData.put("leTime", timeToSave());
boleData.put("leDate", (new DateFormatManager()).toString(lenddateDate.getValue()));
boleData.put("leMonth", monthToSave(lenddateDate.getValue()));
boleData.put("leType", lecmboType.getValue());
boleData.put("leMethod", lecmboMethod.getValue());
boleData.put("leWhom", lecmboRepaidPerson.getValue());
boleData.put("leTk", letxtAmountWithCharge.getText());
boleData.put("leNature", leGetSelectedrbtnName());
boleData.put("leBnkCharge", leBankChargeShow());
boleData.put("leBalanceBefore", longToString(totalLendTk()));
boleData.put("leBalanceAfter", updatedTotalLendTk(letxtExactAmount.getText(), "Take Back Lended Money"));
boleData.put("leExactTk", letxtExactAmount.getText());
boleData.put("rocBalanceBefore", longToString(currentRocketBalance()));
boleData.put("rocBalanceAfter", updatedRocketBalance(letxtAmountWithCharge.getText(), "Cash In", leGetSelectedrbtnName()));
if (leisTypedAmountLessThanLended(letxtExactAmount.getText(), lecmboRepaidPerson.getValue())) {
(new Lend()).updateLendSummaryData(boleData);
} else {
(new Lend()).deleteLendSummaryData(boleData);
}
(new Rocket()).saveLendRocketData(boleData);
(new Lend()).saveLendData(boleData);
(new ComboboxList()).setAllMonth(monthToSave(lenddateDate.getValue()), yearToSave(lenddateDate.getValue()));
setCurrentRocketBalance(updatedRocketBalance(letxtAmountWithCharge.getText(), "Cash In", leGetSelectedrbtnName()));
// setCurrentRocketBalance(leRocBalanceAfter(letxtAmountWithCharge.getText(), leBankChargeShow(), "Take Back Lended Money"));
setTotalLendTk(updatedTotalLendTk(letxtExactAmount.getText(), "Take Back Lended Money"));
leInitialize();
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Successfull Transaction");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Successful");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
confirmationMsg.setX(MakeATransactionStage.getX() + 200);
confirmationMsg.setY(MakeATransactionStage.getY() + 29);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
} else {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Amount can't bigger than borrowed amount");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
}
}
} else {
// Lend, Take Back Lended Money, Hand to Hand
if (amountIsZero(letxtAmountWithCharge.getText())) {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Zero or Empty is not allowed");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
} else {
if (leRepayValidation(letxtAmountWithCharge.getText(), lecmboRepaidPerson.getValue())) {
boleData.put("leTime", timeToSave());
boleData.put("leDate", (new DateFormatManager()).toString(lenddateDate.getValue()));
boleData.put("leMonth", monthToSave(lenddateDate.getValue()));
boleData.put("leType", lecmboType.getValue());
boleData.put("leMethod", lecmboMethod.getValue());
boleData.put("leWhom", lecmboRepaidPerson.getValue());
boleData.put("leTk", letxtAmountWithCharge.getText());
boleData.put("leNature", "None");
boleData.put("leBnkCharge", "None");
boleData.put("leBalanceBefore", longToString(totalLendTk()));
boleData.put("leBalanceAfter", updatedTotalLendTk(letxtAmountWithCharge.getText(), "Take Back Lended Money"));
boleData.put("leExactTk", letxtAmountWithCharge.getText());
boleData.put("gmWalletBalanceBefore", longToString(currentWalletBalance()));
boleData.put("gmWalletBalanceAfter", gmWalletBalanceAfter(letxtAmountWithCharge.getText()));
(new Lend()).saveLendData(boleData);
if (leisTypedAmountLessThanLended(letxtAmountWithCharge.getText(), lecmboRepaidPerson.getValue())) {
(new Lend()).updateLendSummaryData(boleData);
} else {
(new Lend()).deleteLendSummaryData(boleData);
}
// (new GetMoney()).saveLendGMData(boleData);
(new ComboboxList()).setAllMonth(monthToSave(lenddateDate.getValue()), yearToSave(lenddateDate.getValue()));
setCurrentWalletBalance(gmWalletBalanceAfter(letxtAmountWithCharge.getText()));
setTotalLendTk(updatedTotalLendTk(letxtAmountWithCharge.getText(), "Take Back Lended Money"));
leInitialize();
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Successfull Transaction");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Successful");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
confirmationMsg.setX(MakeATransactionStage.getX() + 200);
confirmationMsg.setY(MakeATransactionStage.getY() + 29);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
confirmationMsg.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
confirmationMsg.showAndWait();
} else {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Transaction Failed");
alert.setHeaderText(null);
alert.setContentText("Amount can't bigger than lended amount");
Stage MakeATransactionStage = (Stage) lendbtnSave.getScene().getWindow();
alert.setX(MakeATransactionStage.getX() + 200);
alert.setY(MakeATransactionStage.getY() + 170);
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
alert.hide();
}
}));
idlestage.setCycleCount(1);
idlestage.play();
alert.showAndWait();
}
}
}
}
}
} catch (Exception e) {
}
}
use of tab.Lend in project Money-Manager by krHasan.
the class MakeATransactionController method leRepayPersonCmboFunction.
private void leRepayPersonCmboFunction() {
lelblAmountValidationMsg.setText("");
lelblAmountValidationMsg2.setText("");
lelblWarningMsg.setText("");
String leRepayPersonLendedAmount = new Lend().leRepayPersonLendedAmount(lecmboRepaidPerson.getValue());
letxtExactAmount.setText(leRepayPersonLendedAmount);
letxtAmountWithCharge.setText(leRepayPersonLendedAmount);
}
Aggregations