This commit is contained in:
Bilou 2022-12-08 03:58:56 +01:00
parent 37eec841b8
commit dd088c00a2
38 changed files with 53533 additions and 53544 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -17,7 +17,9 @@ import java.util.Iterator;
import org.mariadb.jdbc.*;
/**
* <p>Methodes pour les interaction avec une base de donnees</p>
* <p>
* Methodes pour les interaction avec une base de donnees
* </p>
*
* @author <a href="https://github.com/lalBi94">Bilal Boudjemline</a>
*/
@ -38,12 +40,13 @@ public class BDatabase {
try {
Class.forName("org.mariadb.jdbc.Driver");
} catch(ClassNotFoundException e) {
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
try {
this.sharedObject = DriverManager.getConnection(this.db_host + this.db_name, this.db_user, this.db_password);
this.sharedObject = DriverManager.getConnection(this.db_host + this.db_name, this.db_user,
this.db_password);
this.status = true;
} catch (SQLException e) {
System.out.println("Erreur de liaison avec la base de donnees.");
@ -61,12 +64,12 @@ public class BDatabase {
ArrayList<String> toReturn = new ArrayList<String>();
ResultSet rs = this.sharedObject.prepareStatement(request).executeQuery();
for(int i = 0; rs.next(); i++) {
for (int i = 0; rs.next(); i++) {
toReturn.add(i, String.valueOf(rs.getString(1)));
}
return toReturn;
} catch(SQLException e) {
} catch (SQLException e) {
System.out.println("Erreur de la requete : " + e);
return null;
}
@ -87,17 +90,17 @@ public class BDatabase {
Iterator<String> iteVal = Arrays.stream(value).iterator();
collumns.append("(");
while(iteCol.hasNext()) {
while (iteCol.hasNext()) {
collumns.append(iteCol.next()).append(", ");
}
collumns.setLength(collumns.length()-2);
collumns.setLength(collumns.length() - 2);
collumns.append(")");
values.append("(");
while(iteVal.hasNext()) {
while (iteVal.hasNext()) {
values.append("\"").append(iteVal.next()).append("\"").append(", ");
}
values.setLength(values.length()-2);
values.setLength(values.length() - 2);
values.append(")");
String request = "INSERT INTO " + table + collumns + " VALUES" + values + ";";
@ -107,13 +110,14 @@ public class BDatabase {
this.sharedObject.prepareStatement(request).executeQuery();
System.out.println("Succes: " + request);
return true;
} catch(SQLException e) {
} catch (SQLException e) {
return false;
}
}
/**
* Faire des requetes de type UPDATE SET (il y aura plus d'argument prochainement).
* Faire des requetes de type UPDATE SET (il y aura plus d'argument
* prochainement).
*
* @param request La requete
* @return Si oui ou non ca a fonctionne
@ -121,8 +125,9 @@ public class BDatabase {
public boolean updateRow(String request) {
try {
this.sharedObject.prepareStatement(request).executeQuery();
System.out.println("Succes:" + request);
return true;
} catch(SQLException e) {
} catch (SQLException e) {
return false;
}
}
@ -149,31 +154,27 @@ public class BDatabase {
* Recuperer la liste des etudiants (FIProjet Contexte)
*
* @return La liste des etudiants
* */
*/
public ArrayList<Etudiant> getEtuList() {
ArrayList<Etudiant> listEtu = new ArrayList<>();
ArrayList<String> studPrenom = this.fetchAll("SELECT prenom FROM fi_eleves");
ArrayList<String> studNom = this.fetchAll("SELECT nom FROM fi_eleves");
ArrayList<String> studGroupe = this.fetchAll("SELECT groupe FROM fi_eleves");
for(int i = 0; i <= studPrenom.size()-1; i++) {
if(studPrenom.get(i) != null && studNom.get(i) != null && studGroupe.get(i) != null) {
for (int i = 0; i <= studPrenom.size() - 1; i++) {
if (studPrenom.get(i) != null && studNom.get(i) != null && studGroupe.get(i) != null) {
try {
listEtu.add(
new EtudiantNP(
studNom.get(i),
studPrenom.get(i),
Integer.parseInt(studGroupe.get(i), 10)
)
);
} catch(NumberFormatException ignore) {
Integer.parseInt(studGroupe.get(i), 10)));
} catch (NumberFormatException ignore) {
listEtu.add(
new EtudiantNP(
studNom.get(i),
studPrenom.get(i),
-1
)
);
-1));
}
} else {
System.out.println("[!] Erreur lors du chargement de la liste des etudiants.");
@ -190,32 +191,28 @@ public class BDatabase {
* Recuperer la liste des groupes (FIProjet contexte)
*
* @return La liste des groupes
* */
*/
public ArrayList<Groupe> getGroupeList() {
ArrayList<Groupe> listGroupe = new ArrayList<>();
ArrayList<String> groupeId = this.fetchAll("SELECT id FROM fi_groupe");
ArrayList<String> groupeNom = this.fetchAll("SELECT nom FROM fi_groupe");
ArrayList<String> groupeMin = this.fetchAll("SELECT min FROM fi_groupe");
ArrayList<String> groupeMax = this.fetchAll("SELECT max FROM fi_groupe");
for(int i = 0; i <= groupeNom.size()-1; i++) {
if(groupeId.get(i) != null && groupeNom.get(i) != null && groupeMin.get(i) != null && groupeMax.get(i) != null) {
for (int i = 0; i <= groupeNom.size() - 1; i++) {
if (groupeId.get(i) != null && groupeNom.get(i) != null && groupeMin.get(i) != null
&& groupeMax.get(i) != null) {
listGroupe.add(
new GroupeNP(
Integer.parseInt(groupeId.get(i), 10),
groupeNom.get(i),
Integer.parseInt(groupeMin.get(i), 10),
Integer.parseInt(groupeMax.get(i), 10)
)
);
Integer.parseInt(groupeMax.get(i), 10)));
} else {
System.out.println("[!] Erreur lors du chargement de la liste des groupes.");
System.exit(-1);
}
}
System.out.println("[+] Liste des groupes chargees.");
return listGroupe;
}
@ -223,7 +220,7 @@ public class BDatabase {
* Recuperer les requetes
*
* @return la liste des requetes
* */
*/
public ArrayList<Requete> getRequestList() {
ArrayList<Requete> toReturn = new ArrayList<>();
ArrayList<String> requestId = this.fetchAll("SELECT id FROM fi_demandes");
@ -233,7 +230,7 @@ public class BDatabase {
ArrayList<String> requestType = this.fetchAll("SELECT type FROM fi_demandes");
ArrayList<String> requestStatut = this.fetchAll("SELECT statut FROM fi_demandes");
for(int i = 0; i <= requestId.size()-1; i++) {
for (int i = 0; i <= requestId.size() - 1; i++) {
toReturn.add(
new RequeteNP(
Integer.parseInt(requestId.get(i)),
@ -241,9 +238,7 @@ public class BDatabase {
Integer.parseInt(requestEtu.get(i)),
Integer.parseInt(requestType.get(i)),
Integer.parseInt(requestWitchGrup.get(i)),
requestStatut.get(i)
)
);
requestStatut.get(i)));
}
return toReturn;

File diff suppressed because it is too large Load Diff

View File

@ -66,7 +66,7 @@ public class ProfView extends JPanel {
settings.setPadding(new Insets(0, 0, 0, 50));
String[] groupeList = new String[this.g.size()];
for(int i = 0; i <= this.g.size()-1; i++) {
for (int i = 0; i <= this.g.size() - 1; i++) {
groupeList[i] = this.g.get(i).getName();
}
@ -97,7 +97,7 @@ public class ProfView extends JPanel {
this.text.setPreferredSize(new Dimension(110, 30));
text.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) {
if (text.getText().length() >= 3 )
if (text.getText().length() >= 3)
e.consume();
}
});

View File

@ -61,7 +61,7 @@ public class StudentView extends JPanel {
settings.setPadding(new Insets(0, 0, 0, 50));
String[] groupeList = new String[this.g.size()];
for(int i = 0; i <= this.g.size()-1; i++) {
for (int i = 0; i <= this.g.size() - 1; i++) {
groupeList[i] = this.g.get(i).getName();
}