Skip to content

Hotfix/usertesting #53

Merged
merged 3 commits into from
Mar 17, 2026
Merged
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
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
package ntnu.systemutvikling.team6.DAO;

import ntnu.systemutvikling.team6.database.DatabaseConnection;
import ntnu.systemutvikling.team6.models.Charity;

import java.sql.*;
import java.util.Calendar;
import java.util.UUID;
import ntnu.systemutvikling.team6.database.DatabaseConnection;
import ntnu.systemutvikling.team6.models.Charity;

/**
* This class is responsible for sending concurrent information about the donation to the Donation Database.
* Usally called from the DonationPageController, where the user confirms their donation.
* This class is responsible for sending concurrent information about the donation to the Donation
* Database. Usally called from the DonationPageController, where the user confirms their donation.
*/

public class DonationDAO {
private static final DatabaseConnection connection = new DatabaseConnection();
private static final DatabaseConnection connection = new DatabaseConnection();

/**
* Gets the total ammount of donations for a given charity, and sends it to the database throught MySQL.
* @param charity
* @param amount
*/
public static void addDonation(Charity charity, double amount){
String sql_query =
"""
/**
* Gets the total ammount of donations for a given charity, and sends it to the database throught
* MySQL.
*
* @param charity
* @param amount
*/
public static void addDonation(Charity charity, double amount) {
String sql_query =
"""
INSERT INTO Donations (UUID_Donations, amount, date, Charities_UUID_charities)
VALUES (?, ?, ?, ?)
""";
try (Connection conn = connection.getMySqlConnection();
PreparedStatement ps = conn.prepareStatement(sql_query)){
conn.setAutoCommit(false);
try (Connection conn = connection.getMySqlConnection();
PreparedStatement ps = conn.prepareStatement(sql_query)) {
conn.setAutoCommit(false);

ps.setString(1, UUID.randomUUID().toString());
ps.setDouble(2, amount);
ps.setDate(3, new Date(System.currentTimeMillis()));
ps.setString(4, charity.getUUID().toString());
ps.setString(1, UUID.randomUUID().toString());
ps.setDouble(2, amount);
ps.setDate(3, new Date(System.currentTimeMillis()));
ps.setString(4, charity.getUUID().toString());

ps.executeUpdate();
conn.commit();
} catch (SQLException e) {
throw new RuntimeException(e);
}
ps.executeUpdate();
conn.commit();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import java.net.http.HttpClient;
import java.util.Objects;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
Expand All @@ -21,7 +20,10 @@ public void start(Stage stage) throws Exception {
FXMLLoader fxmlLoader =
new FXMLLoader(HmHApplication.class.getResource("/fxml/frontPage.fxml"));
Scene scene = new Scene(fxmlLoader.load());
Image icon = new Image(Objects.requireNonNull(HmHApplication.class.getResource("/images/Logo.png")).openStream());
Image icon =
new Image(
Objects.requireNonNull(HmHApplication.class.getResource("/images/Logo.png"))
.openStream());
stage.getIcons().add(icon);
stage.setTitle("Help Me Help");
stage.setScene(scene);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ntnu.systemutvikling.team6;


public class Main {
// Make sure you're connected to the NTNU network for this to work
public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,60 @@

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;
import ntnu.systemutvikling.team6.HmHApplication;
import ntnu.systemutvikling.team6.models.Charity;

import java.io.IOException;

/**
* This controller represents the charity page, where the user can read about the charity and choose to donate to it.
* It also has a button to return to the front page.
* This controller represents the charity page, where the user can read about the charity and choose
* to donate to it. It also has a button to return to the front page.
*/
public class CharityPageController {
@FXML private Label CharityDescription;

@FXML private Label CharityName;

@FXML public void initialize() {}
@FXML
public void initialize() {}

private Charity charity;

/**
* This method is used to set the charity that is being displayed on the page. It also updates the labels with the charity's name and description.
* It acts like an initializer for the charity page, since the charity is not known until the user clicks on a charity from the front page.
* Param charity is the charity that is being displayed on the page,
* AND is called on from the front page when the user clicks on a charity, to set the charity that is being displayed on the page.
* This method is used to set the charity that is being displayed on the page. It also updates the
* labels with the charity's name and description. It acts like an initializer for the charity
* page, since the charity is not known until the user clicks on a charity from the front page.
* Param charity is the charity that is being displayed on the page, AND is called on from the
* front page when the user clicks on a charity, to set the charity that is being displayed on the
* page.
*
* @param charity
*/
@FXML
public void setCharity(Charity charity){
public void setCharity(Charity charity) {
this.charity = charity;

CharityDescription.setText(charity.getDescription());
CharityName.setText(charity.getName());

}

/**
* This method is used to switch to the front page.
*
* @param event
*/
public void switchToFrontPage(ActionEvent event){
@FXML
public void switchToFrontPage(ActionEvent event) {
System.out.println("Click");
LoaderScene.LoadScene("FrontPage", event, charity);
}

/**
* This method is used to switch to the donation page.
*
* @param event
*/
public void switchToDonationPage(ActionEvent event){
@FXML
public void switchToDonationPage(ActionEvent event) {
System.out.println("Click");
LoaderScene.LoadScene("donationPage", event, charity);
}
}
Loading
Loading