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));
}
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;
}
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();
}
}
Aggregations