Search in sources :

Example 1 with ComboboxList

use of operation.ComboboxList in project Money-Manager by krHasan.

the class MakeATransactionController method gmbtnSaveAdd.

@FXML
private void gmbtnSaveAdd(ActionEvent event) {
    if (amountIsZero(gmtxtAmount.getText())) {
        gmlblWarningMsg.setText("Empty or Zero is not approved.");
    } else {
        try {
            Map<String, String> stringData = new HashMap<>();
            stringData.put("gmTime", timeToSave());
            stringData.put("gmDate", (new DateFormatManager()).toString(gmdateDate.getValue()));
            stringData.put("gmMonth", monthToSave(gmdateDate.getValue()));
            stringData.put("gmAmount", gmtxtAmount.getText());
            if ((gmcmboMethod.getValue()).equals("bKash")) {
                stringData.put("gmBankCharge", bkashBnkCharge(gmtxtAmount.getText(), "Cash In"));
            } else if ((gmcmboMethod.getValue()).equals("Rocket")) {
                stringData.put("gmBankCharge", rocketBnkCharge(gmtxtAmount.getText(), "Cash In", gmGetSelectedrbtnName()));
            } else {
                stringData.put("gmBankCharge", "0.00");
            }
            if ((gmcmboMethod.getValue()).equals("bKash")) {
                stringData.put("gmAmountNature", "Cash In from Agent");
            } else if ((gmcmboMethod.getValue()).equals("Rocket")) {
                stringData.put("gmAmountNature", gmGetSelectedrbtnName());
            } else {
                stringData.put("gmAmountNature", "None");
            }
            if ((gmcmboMethod.getValue()).equals("bKash")) {
                stringData.put("bkBalanceAfter", updatedbKashBalance(gmtxtAmount.getText(), "Cash In"));
                (new Bkash()).saveGmBkashData(stringData);
            } else if ((gmcmboMethod.getValue()).equals("Rocket")) {
                stringData.put("rocBalanceAfter", updatedRocketBalance(gmtxtAmount.getText(), "Cash In", gmGetSelectedrbtnName()));
                (new Rocket()).saveGmRocketData(stringData);
            }
            stringData.put("gmSource", gmcmboSource.getValue());
            if (gmIsDescripionEmpty()) {
                stringData.put("gmDescription", "None");
            } else {
                stringData.put("gmDescription", gmtxtDescription.getText());
            }
            stringData.put("gmMethod", gmcmboMethod.getValue());
            stringData.put("gmWalletBalanceBefore", getWalletBalance());
            if ((gmcmboMethod.getValue()).equals("Hand to Hand")) {
                stringData.put("gmWalletBalanceAfter", gmWalletBalanceAfter(gmtxtAmount.getText()));
                setCurrentWalletBalance(gmWalletBalanceAfter(gmtxtAmount.getText()));
            } else {
                stringData.put("gmWalletBalanceAfter", getWalletBalance());
            }
            (new GetMoney()).saveGetMoneyData(stringData);
            (new ComboboxList()).setAllMonth(monthToSave(gmdateDate.getValue()), yearToSave(gmdateDate.getValue()));
            (new ComboboxList()).setAllGmMonth(monthToSave(gmdateDate.getValue()), yearToSave(gmdateDate.getValue()));
            gmInitialize();
            gmtxtAmount.clear();
            gmtxtDescription.clear();
            Alert confirmationMsg = new Alert(AlertType.INFORMATION);
            confirmationMsg.setTitle("Successfull Transaction");
            confirmationMsg.setHeaderText(null);
            confirmationMsg.setContentText("Successful");
            Stage MakeATransactionStage = (Stage) gmbtnSave.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();
        } catch (Exception e) {
            Alert alert = new Alert(AlertType.WARNING);
            alert.setTitle("Transaction Failed");
            alert.setHeaderText(null);
            alert.setContentText("There something is wrong.");
            Stage MakeATransactionStage = (Stage) gmbtnSave.getScene().getWindow();
            alert.setX(MakeATransactionStage.getX() + 200);
            alert.setY(MakeATransactionStage.getY() + 170);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    alert.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            alert.showAndWait();
        }
    }
    cancelbtnPressed = true;
}
Also used : HashMap(java.util.HashMap) GetMoney(tab.GetMoney) ActionEvent(javafx.event.ActionEvent) DateFormatManager(system.DateFormatManager) EventHandler(javafx.event.EventHandler) Rocket(tab.Rocket) Timeline(javafx.animation.Timeline) ComboboxList(operation.ComboboxList) Bkash(tab.Bkash) Stage(javafx.stage.Stage) KeyFrame(javafx.animation.KeyFrame) Alert(javafx.scene.control.Alert) FXML(javafx.fxml.FXML)

Example 2 with ComboboxList

use of operation.ComboboxList in project Money-Manager by krHasan.

the class MakeATransactionController method loadAdvancedExpenseSector.

private void loadAdvancedExpenseSector() {
    TextField[] AdvancedExtxt = { extxtAdvSector1, extxtAdvSector2, extxtAdvSector3, extxtAdvSector4, extxtAdvSector5, extxtAdvSector6, extxtAdvSector7 };
    Label[] AdvancedExlbl = { exlblAdvSector1, exlblAdvSector2, exlblAdvSector3, exlblAdvSector4, exlblAdvSector5, exlblAdvSector6, exlblAdvSector7 };
    String[] sectorName = new ComboboxList().getAdvancedSectorListActive();
    for (TextField textField : AdvancedExtxt) {
        textField.clear();
        textField.setVisible(false);
    }
    for (Label label : AdvancedExlbl) {
        label.setText("");
    }
    int indexLimit = new ComboboxList().getAdvancedSectorActiveArraySize();
    int index = 0;
    for (String string : sectorName) {
        if ((indexLimit > 0) && (index < indexLimit)) {
            AdvancedExtxt[index].setVisible(true);
            AdvancedExlbl[index].setText(string);
            ++index;
        }
    }
}
Also used : ComboboxList(operation.ComboboxList) Label(javafx.scene.control.Label) TextField(javafx.scene.control.TextField)

Example 3 with ComboboxList

use of operation.ComboboxList in project Money-Manager by krHasan.

the class MakeATransactionController method exbtnAdvancedAdjustBalance.

@FXML
private void exbtnAdvancedAdjustBalance(ActionEvent event) {
    TextInputDialog dialog = new TextInputDialog();
    dialog.setTitle("Adjust Wallet Balance");
    dialog.setHeaderText("Provide Balance Status at Your Hand Now.");
    dialog.setContentText("Please enter the amount:");
    Stage MakeATransactionStage = (Stage) exbtnAdjustBalance.getScene().getWindow();
    dialog.setX(MakeATransactionStage.getX() + 200);
    dialog.setY(MakeATransactionStage.getY() + 170);
    Optional<String> result = dialog.showAndWait();
    if (result.isPresent()) {
        String typedAmount = result.get();
        if (!validAmount(typedAmount)) {
            Alert alert = new Alert(AlertType.WARNING);
            alert.setTitle("Transaction Failed");
            alert.setHeaderText(null);
            alert.setContentText(InvalidInput);
            alert.setX(MakeATransactionStage.getX() + 200);
            alert.setY(MakeATransactionStage.getY() + 170);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    alert.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            alert.showAndWait();
        } else if (amountIsZero(typedAmount)) {
            Alert alert = new Alert(AlertType.WARNING);
            alert.setTitle("Transaction Failed");
            alert.setHeaderText(null);
            alert.setContentText("Zero is not approved.");
            alert.setX(MakeATransactionStage.getX() + 200);
            alert.setY(MakeATransactionStage.getY() + 170);
            Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent event) {
                    alert.hide();
                }
            }));
            idlestage.setCycleCount(1);
            idlestage.play();
            alert.showAndWait();
        } else {
            long dbWalletBalance = currentWalletBalance();
            long typedBalance = stringToLong(typedAmount);
            String exAdvAdjustBalAfter = typedAmount;
            String exAdvAdjustAmount;
            if (dbWalletBalance < typedBalance) {
                exAdvAdjustAmount = "added " + longToString(typedBalance - dbWalletBalance) + " to Wallet";
            } else if (dbWalletBalance > typedBalance) {
                exAdvAdjustAmount = exWalletBalanceAfter(typedAmount);
            } else {
                exAdvAdjustAmount = "0.0";
            }
            try {
                Map<String, String> expenseData = new HashMap<>();
                expenseData.put("exTime", timeToSave());
                expenseData.put("exDate", (new DateFormatManager()).toString(exdateAdvancedDate.getValue()));
                expenseData.put("exMonth", monthToSave(exdateAdvancedDate.getValue()));
                expenseData.put("exAmount", exAdvAdjustAmount);
                if (exIsAdvDescripionEmpty()) {
                    expenseData.put("exDescription", "You have adjusted your Wallet Balance");
                } else {
                    expenseData.put("exDescription", extxtAdvancedDescription.getText());
                }
                expenseData.put("exSector", "Adjusted Balance");
                expenseData.put("exWalletBalanceBefore", getWalletBalance());
                expenseData.put("exWalletBalanceAfter", exAdvAdjustBalAfter);
                setCurrentWalletBalance(exAdvAdjustBalAfter);
                (new Expense()).saveExpenseData(expenseData);
                (new ComboboxList()).setAllMonth(monthToSave(exdateAdvancedDate.getValue()), yearToSave(exdateAdvancedDate.getValue()));
                (new ComboboxList()).setAllExMonth(monthToSave(exdateAdvancedDate.getValue()), yearToSave(exdateAdvancedDate.getValue()));
                exInitialize();
                extxtAdvancedDescription.clear();
                Alert confirmationMsg = new Alert(AlertType.INFORMATION);
                confirmationMsg.setTitle("Successfull Transaction");
                confirmationMsg.setHeaderText(null);
                confirmationMsg.setContentText("Successful");
                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();
            } catch (Exception e) {
                Alert alert = new Alert(AlertType.WARNING);
                alert.setTitle("Transaction Failed");
                alert.setHeaderText(null);
                alert.setContentText("There something is wrong.");
                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();
            }
        }
    }
}
Also used : ActionEvent(javafx.event.ActionEvent) DateFormatManager(system.DateFormatManager) EventHandler(javafx.event.EventHandler) Timeline(javafx.animation.Timeline) Expense(tab.Expense) ComboboxList(operation.ComboboxList) Stage(javafx.stage.Stage) KeyFrame(javafx.animation.KeyFrame) Alert(javafx.scene.control.Alert) Map(java.util.Map) HashMap(java.util.HashMap) TextInputDialog(javafx.scene.control.TextInputDialog) FXML(javafx.fxml.FXML)

Example 4 with ComboboxList

use of operation.ComboboxList in project Money-Manager by krHasan.

the class MakeATransactionController method exAdvSaveFunction.

private void exAdvSaveFunction(String amount, String sectorName) {
    try {
        Map<String, String> expenseData = new HashMap<>();
        expenseData.put("exTime", timeToSave());
        expenseData.put("exDate", (new DateFormatManager()).toString(exdateAdvancedDate.getValue()));
        expenseData.put("exMonth", monthToSave(exdateAdvancedDate.getValue()));
        expenseData.put("exAmount", amount);
        if (exIsAdvDescripionEmpty()) {
            expenseData.put("exDescription", "None");
        } else {
            expenseData.put("exDescription", extxtAdvancedDescription.getText());
        }
        expenseData.put("exSector", sectorName);
        expenseData.put("exWalletBalanceBefore", getWalletBalance());
        expenseData.put("exWalletBalanceAfter", exWalletBalanceAfter(amount));
        setCurrentWalletBalance(exWalletBalanceAfter(amount));
        (new Expense()).saveExpenseData(expenseData);
        (new ComboboxList()).setAllMonth(monthToSave(exdateAdvancedDate.getValue()), yearToSave(exdateAdvancedDate.getValue()));
        (new ComboboxList()).setAllExMonth(monthToSave(exdateAdvancedDate.getValue()), yearToSave(exdateAdvancedDate.getValue()));
    } catch (Exception e) {
    }
}
Also used : HashMap(java.util.HashMap) Expense(tab.Expense) ComboboxList(operation.ComboboxList) DateFormatManager(system.DateFormatManager)

Example 5 with ComboboxList

use of operation.ComboboxList in project Money-Manager by krHasan.

the class SettingsController method loadSectorInList.

private void loadSectorInList() {
    Label[] lbl = { advancedlblSectorName1, advancedlblSectorName2, advancedlblSectorName3, advancedlblSectorName4, advancedlblSectorName5, advancedlblSectorName6, advancedlblSectorName7 };
    String[] sectorNameInList = new ComboboxList().getAdvancedSectorListActive();
    int indexSize = new ComboboxList().getAdvancedSectorActiveArraySize();
    int index = 0;
    for (Label label : lbl) {
        label.setText("");
    }
    for (Label label : lbl) {
        if ((indexSize > 0) && (index < indexSize)) {
            label.setText(sectorNameInList[index]);
            ++index;
        }
    }
}
Also used : ComboboxList(operation.ComboboxList) Label(javafx.scene.control.Label)

Aggregations

ComboboxList (operation.ComboboxList)16 Stage (javafx.stage.Stage)8 HashMap (java.util.HashMap)7 KeyFrame (javafx.animation.KeyFrame)7 Timeline (javafx.animation.Timeline)7 ActionEvent (javafx.event.ActionEvent)7 EventHandler (javafx.event.EventHandler)7 Alert (javafx.scene.control.Alert)7 DateFormatManager (system.DateFormatManager)7 FXML (javafx.fxml.FXML)6 Bkash (tab.Bkash)4 Rocket (tab.Rocket)4 Connection (java.sql.Connection)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 CarriedOver (operation.CarriedOver)3 Expense (tab.Expense)3 GetMoney (tab.GetMoney)3 Statement (java.sql.Statement)2 XYChart (javafx.scene.chart.XYChart)2