Skip to content

Commit

Permalink
Merge pull request #12 from paulhfisher/Paul3
Browse files Browse the repository at this point in the history
Paul3
  • Loading branch information
MageTomcatF14 authored Jul 25, 2021
2 parents 5be4241 + 93fb7ad commit 5c1138a
Show file tree
Hide file tree
Showing 37 changed files with 1,156 additions and 367 deletions.
4 changes: 4 additions & 0 deletions src/Controleur/CarListAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
*/
public class CarListAccess {

/**
* connection with the database
* @return null
*/
public static Connection getConnection(){
Connection conn;
try {
Expand Down
24 changes: 12 additions & 12 deletions src/Controleur/CustomerDBQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@
*/
public class CustomerDBQuery {

// Database URL Constant
// Database URL Constant
public final String url = "jdbc:mysql://localhost:3306/project"; //DB_URL is the database url to connect to. projet is the name of our project
public final String user = "root"; //user is your username to connect to the database
public final String password = ""; //password is your password to connect to the database
private Connection conn;

public CustomerDBQuery() {

}

/*
* Execute the query.
*/
public CustomerDBQuery() {}

/**
* Execute the query
* @param query
*/
public void run (String query){
getDatabaseConnection(); // assure connection to the database
try
Expand All @@ -47,10 +46,11 @@ public void run (String query){
}
}

/*
* Connection to the database
*/
private void getDatabaseConnection() //Create the connection to the database.

/**
* Connection to the database
*/
public void getDatabaseConnection() //Create the connection to the database.
{
try
{
Expand Down
99 changes: 78 additions & 21 deletions src/Controleur/DBGetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import java.sql.*;

/**
*
* savig
* this class has various methods to get values from a table
* by havig in input a table data
* author : Savinien Godineau
*/
public class DBGetter {

Expand All @@ -20,14 +21,20 @@ public class DBGetter {
private Connection conn;

public DBGetter(){}

//The role of this method is to retrieve data from the vehicule table. It is necessary to define several parameters :
//the name of the table in which the data to be acquired is located, we could do without this parameter but it allows a better readability
//the number of the line we are interested in (the number of the line corresponds to the ID of the vehicle, we can know it by looking at the database for example)
//the name of the column which is finally the name of the data we are trying to obtain.
//For example, if we want to know the name of the vehicle with ID 5, we can use the following command: GetString("vehicles", 5, "vehicle_name")+ " car")
//The method will return the name of the vehicle as a String.


/**
*The role of this method is to retrieve data from the vehicule table It is necessary to define several parameters :
*the name of the table in which the data to be acquired is located, we could do without this parameter but it allows a better readability
*the number of the line we are interested in (the number of the line corresponds to the ID of the vehicle, we can know it by looking at the database for example)
*the name of the column which is finally the name of the data we are trying to obtain
*For example, if we want to know the name of the vehicle with ID 5, we can use the following command: GetString("vehicles", 5, "vehicle_name")+ " car")
*The method will return the name of the vehicle as a String
* @param table_name
* @param line_number
* @param column_name
* @return vehicule name
*/
public String GetString (String table_name, int line_number, String column_name){
getDatabaseConnection();
String data = "xxx";
Expand All @@ -52,10 +59,51 @@ public String GetString (String table_name, int line_number, String column_name)
ex.printStackTrace();
}
return data;
}
}

/**
* This method will get the value of the
* primary key, in this example the primary
* key is the vehicule id (int)
* @param table_name
* @param carname
* @param column_name
* @return
*/
public int GetPrimaryID (String table_name, String carname, String column_name){
getDatabaseConnection();
String data = "xxx";
try
{
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
String query = "SELECT * FROM "+table_name+" WHERE vehicule_name LIKE '"+carname+"'";
ResultSet results = stmt.executeQuery(query);
while (results.next()) {
// Get the data from the current row using the column index
data = results.getString(1);
// Get the data from the current row using the column name
data = results.getString(column_name);
}
stmt.close();
conn.close();
}catch (SQLException ex){
ex.printStackTrace();
}
return Integer.parseInt(data);
}

//

//This method has exactly the same role and use as the previous one except that it will return an int and not a string, which is more convenient for processing.
public int GetInt (String table_name, int line_number, String column_name){
/**
* this method has exactly the same role and use as the previous
* one except that it will return an int and not a string,
* which is more convenient for processing.
* @param table_name
* @param line_number
* @param column_name
* @return
*/
public int GetInt (String table_name, int line_number, String column_name){
getDatabaseConnection();
String data = "xxx";
try
Expand Down Expand Up @@ -83,13 +131,19 @@ public int GetInt (String table_name, int line_number, String column_name){
return Integer.parseInt(data);
}

//The role of this method is to retrieve data from the person table. It is necessary to define several parameters :
//the name of the table in which the data to be acquired is located, we could do without this parameter but it allows a better readability
//the Username value of the user we are interested in
//the name of the column which is finally the name of the data we are trying to obtain.
//For example, if we want to know the firstname of the User called Sav, we can use the following command : GetStringUser("person", "Sav", "firstname")
//The method will return the firstname of the User called Sav as a String.
public String GetStringUser (String table_name, String username, String column_name){
/**
*The role of this method is to retrieve data from the person table It is necessary to define several parameters :
*the name of the table in which the data to be acquired is located, we could do without this parameter but it allows a better readability
*the Username value of the user we are interested in
*the name of the column which is finally the name of the data we are trying to obtain
*For example, if we want to know the firstname of the User called Sav, we can use the following command : GetStringUser("person", "Sav", "firstname")
*The method will return the firstname of the User called Sav as a String
*@param table_name
* @param username
* @param column_name
* @return primary key value
*/
public String GetStringUser (String table_name, String username, String column_name){
getDatabaseConnection();
String data = "xxx";
try
Expand All @@ -115,7 +169,10 @@ public String GetStringUser (String table_name, String username, String column_n
return data;
}

public void getDatabaseConnection() //Create the connection to the database.
/**
*Create the connection to the database.
*/
public void getDatabaseConnection()
{
try
{
Expand All @@ -129,7 +186,7 @@ public void getDatabaseConnection() //Create the connection to the database.
}

//This method is not important, it just allows a better readability.
private int mineone(int a){
private int mineone(int a){
return a-1;
}
}
2 changes: 1 addition & 1 deletion src/Controleur/ExceptionAcceptConditions.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import javax.swing.JOptionPane;

/**
This personalized exception will be excecuted if
*This personalized exception will be excecuted if
* the customer has not accepted the general conditions
* of the application
* author Paul Fisher
Expand Down
5 changes: 3 additions & 2 deletions src/Controleur/ExceptionCarNameWrong.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import javax.swing.JOptionPane;

/**
*
* @author fishe
* this personalized exception will be excecuted
* if the car name entered by the customer is wrong
* author Paul fisher
*/
public class ExceptionCarNameWrong extends Exception {

Expand Down
7 changes: 4 additions & 3 deletions src/Controleur/ExceptionCarNotChoosen.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
import javax.swing.JOptionPane;

/**
*
* @author fishe
* this personalized exception will be excecuted
* if no car has been entered
* Paul fisher
*/
public class ExceptionCarNotChoosen extends Exception {

public ExceptionCarNotChoosen() {
JOptionPane.showMessageDialog(null, "You need to enter a car number identification before passing to paiment","error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, "You need to enter an available car","error", JOptionPane.ERROR_MESSAGE);
}

}
14 changes: 9 additions & 5 deletions src/Controleur/FXMLAccountCheckCustomerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@


/**
*
* @author fishe
*/
* This class will manege the page where the customer
* needs to choose if he will login or go to the sinup page
* to create a account
* author : Paul Fisher
*/
public class FXMLAccountCheckCustomerController {

@FXML
Expand All @@ -31,6 +33,8 @@ public class FXMLAccountCheckCustomerController {
@FXML
private Button m_closeAccountCheck;



@FXML
void onClickedChoice(ActionEvent event) throws IOException {
if(event.getSource() == m_buttonYes){ // if the customer has already a account
Expand All @@ -47,14 +51,14 @@ void onClickedChoice(ActionEvent event) throws IOException {
window.setScene(tableViewScene);
window.centerOnScreen();
window.show();
} else if(event.getSource() == m_backAccountCheck){
} else if(event.getSource() == m_backAccountCheck){ // go back to person selection
Parent tableViewParent = FXMLLoader.load(getClass().getResource("/View/FXMLSelectionPersonType.fxml"));
Scene tableViewScene = new Scene(tableViewParent);
Stage window = (Stage) ((Node)event.getSource()).getScene().getWindow();
window.setScene(tableViewScene);
window.centerOnScreen();
window.show();
} else if(event.getSource() == m_closeAccountCheck){
} else if(event.getSource() == m_closeAccountCheck){ // close app
JOptionPane.showMessageDialog(null, "The application is about to close","information", JOptionPane.INFORMATION_MESSAGE);
exit();
}
Expand Down
Loading

0 comments on commit 5c1138a

Please sign in to comment.