Search in sources :

Example 1 with CarriedOver

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

the class DashboardModel method getAmountBySource.

public String getAmountBySource(String monthName, String sourceName) {
    long totalAmountinLong = 0;
    if (monthName.equals("Total")) {
        if (sourceName.equals("All")) {
            String allGetMoneySql = "SELECT gmAmount FROM Get_Money";
            try (Connection conn = connector();
                Statement stmt = conn.createStatement();
                ResultSet result = stmt.executeQuery(allGetMoneySql)) {
                while (result.next()) {
                    totalAmountinLong += UnitConverter.stringToLong(removeThousandSeparator(result.getString("gmAmount")));
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (sourceName.equals("Carried Over Amount")) {
            totalAmountinLong = 0;
        } else {
            String sql = "SELECT gmAmount FROM Get_Money WHERE gmSource = ?";
            try (Connection conn = connector();
                PreparedStatement pstmt = conn.prepareStatement(sql)) {
                pstmt.setString(1, sourceName);
                ResultSet result = pstmt.executeQuery();
                while (result.next()) {
                    totalAmountinLong += UnitConverter.stringToLong(removeThousandSeparator(result.getString("gmAmount")));
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    } else {
        if (sourceName.equals("All")) {
            String[] sourceList = new ComboboxList().getSourceListForDashboard();
            for (String string : sourceList) {
                totalAmountinLong += new Source().getAmountBySourceFromGM(monthName, string);
            }
            totalAmountinLong += new CarriedOver().getCOAmount(monthName);
        } else if (sourceName.equals("Carried Over Amount")) {
            totalAmountinLong = new CarriedOver().getCOAmount(monthName);
        } else {
            totalAmountinLong = new Source().getAmountBySourceFromGM(monthName, sourceName);
        }
    }
    return addThousandSeparator(longToString(totalAmountinLong));
}
Also used : CarriedOver(operation.CarriedOver) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) ComboboxList(operation.ComboboxList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) Source(tab.Source)

Example 2 with CarriedOver

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

the class GetMoneyChart method getSourceData.

public static Series<String, Number> getSourceData(String monthName) {
    XYChart.Series<String, Number> source = new XYChart.Series<>();
    String[] allSource = new ComboboxList().getSourceListForDashboard();
    for (String sourceName : allSource) {
        if (!sourceName.equals("All")) {
            if (sourceName.equals("Carried Over Amount")) {
                String sourceShortName = getAbbreviateName(sourceName);
                double amount = longToDouble(new CarriedOver().getCOAmount(monthName));
                source.getData().add(new XYChart.Data<>(sourceShortName, amount));
            } else {
                String sourceShortName = getAbbreviateName(sourceName);
                double amount = longToDouble(new Source().getAmountBySourceFromGM(monthName, sourceName));
                source.getData().add(new XYChart.Data<>(sourceShortName, amount));
            }
        }
    }
    return source;
}
Also used : Series(javafx.scene.chart.XYChart.Series) CarriedOver(operation.CarriedOver) ComboboxList(operation.ComboboxList) XYChart(javafx.scene.chart.XYChart) Source(tab.Source)

Example 3 with CarriedOver

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

the class SignInController method logIn.

@FXML
private void logIn(ActionEvent event) {
    if (authentication(txtUsername.getText(), passPassword.getText())) {
        Stage SignInStage = (Stage) btnSignIn.getScene().getWindow();
        new ComboboxList().setAllMonth(getThisMonthName(), getYear());
        new ComboboxList().setAllGmMonth(getThisMonthName(), getYear());
        new ComboboxList().setAllExMonth(getThisMonthName(), getYear());
        new CarriedOver().addCarriedOver(getThisMonthName());
        if (userIsNew()) {
            goToDashboard(SignInStage.getX(), SignInStage.getY());
            SignInStage.close();
        } else {
            updateLastAccessDate();
            goToDashboard(SignInStage.getX(), SignInStage.getY());
            SignInStage.close();
        }
    } else {
        lblWrongAuthentication.setText("Username or Password is Wrong");
        passPassword.clear();
    }
}
Also used : CarriedOver(operation.CarriedOver) ComboboxList(operation.ComboboxList) Stage(javafx.stage.Stage) FXML(javafx.fxml.FXML)

Aggregations

CarriedOver (operation.CarriedOver)3 ComboboxList (operation.ComboboxList)3 Source (tab.Source)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 FXML (javafx.fxml.FXML)1 XYChart (javafx.scene.chart.XYChart)1 Series (javafx.scene.chart.XYChart.Series)1 Stage (javafx.stage.Stage)1