diff --git a/out/production/FI_PRJ/Test/BDatabase.class b/out/production/FI_PRJ/Test/BDatabase.class
index b073693..3fe9b7a 100644
Binary files a/out/production/FI_PRJ/Test/BDatabase.class and b/out/production/FI_PRJ/Test/BDatabase.class differ
diff --git a/out/production/FI_PRJ/Test/ProfView$1.class b/out/production/FI_PRJ/Test/ProfView$1.class
index 4aaa0ec..ba2ad8a 100644
Binary files a/out/production/FI_PRJ/Test/ProfView$1.class and b/out/production/FI_PRJ/Test/ProfView$1.class differ
diff --git a/out/production/FI_PRJ/Test/ProfView$2.class b/out/production/FI_PRJ/Test/ProfView$2.class
index 09dc91f..ac2020c 100644
Binary files a/out/production/FI_PRJ/Test/ProfView$2.class and b/out/production/FI_PRJ/Test/ProfView$2.class differ
diff --git a/out/production/FI_PRJ/Test/ProfView$3.class b/out/production/FI_PRJ/Test/ProfView$3.class
index c1b11a0..0b86732 100644
Binary files a/out/production/FI_PRJ/Test/ProfView$3.class and b/out/production/FI_PRJ/Test/ProfView$3.class differ
diff --git a/out/production/FI_PRJ/Test/ProfView$4.class b/out/production/FI_PRJ/Test/ProfView$4.class
index f996b4f..5ab601c 100644
Binary files a/out/production/FI_PRJ/Test/ProfView$4.class and b/out/production/FI_PRJ/Test/ProfView$4.class differ
diff --git a/out/production/FI_PRJ/Test/ProfView.class b/out/production/FI_PRJ/Test/ProfView.class
index 3cc714e..e1af3c7 100644
Binary files a/out/production/FI_PRJ/Test/ProfView.class and b/out/production/FI_PRJ/Test/ProfView.class differ
diff --git a/src/Test/BDatabase.java b/src/Test/BDatabase.java
index 30cb75b..3bb6b0b 100644
--- a/src/Test/BDatabase.java
+++ b/src/Test/BDatabase.java
@@ -14,6 +14,8 @@ import java.util.Arrays;
import java.util.Iterator;
import org.mariadb.jdbc.*;
+import javax.crypto.spec.PSource;
+
/**
*
Methodes pour les interaction avec une base de donnees
*
diff --git a/src/Test/ProfView.java b/src/Test/ProfView.java
index 0fcec3f..3e0d1b5 100644
--- a/src/Test/ProfView.java
+++ b/src/Test/ProfView.java
@@ -7,6 +7,7 @@ import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTable;
+import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import java.awt.Dimension;
import java.awt.Insets;
@@ -15,6 +16,7 @@ import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
+import java.sql.SQLException;
import java.util.ArrayList;
public class ProfView extends BFrame implements ActionListener {
@@ -199,7 +201,6 @@ public class ProfView extends BFrame implements ActionListener {
data_final[x] = data[x];
}
-
JTable liste = new JTable(data_final, titre) {
public boolean editCellAt(int row, int column, java.util.EventObject e) {
return false;
@@ -214,66 +215,75 @@ public class ProfView extends BFrame implements ActionListener {
frame.openBFrame();
} else if(command == "fi::SearchStudentPer3Letters") {
- /**
- * Faire l'interface du filtrage.
- * */
- char[] beg = this.text.getText().toCharArray();
- ArrayList listFiltered = new ArrayList<>();
- char[] cur;
+ if(this.text.getText().length() < 3 || this.text.getText() == null) {
+ JOptionPane.showMessageDialog(
+ this,
+ "Veuillez ecrire au moins 3 lettres",
+ "Erreur.",
+ JOptionPane.ERROR_MESSAGE
+ );
+ } else {
+ char[] beg = this.text.getText().toCharArray();
- for(int i = 0; i <= this.e.size()-1; i++) {
- cur = this.e.get(i).getNom().toCharArray();
- if(cur[0] == beg[0] && cur[1] == beg[1] && cur[2] == beg[2]) {
- listFiltered.add(new EtudiantNP(
- this.e.get(i).getNom(),
- this.e.get(i).getPrenom(),
- this.e.get(i).getGroupe()
- ));
+ BFrame frame = new BFrame(
+ "Liste d'eleves d'ou les noms commence par " + beg[0] + beg[1] + beg[2],
+ 1,
+ 1,
+ 500,
+ 500,
+ "GridLayout",
+ 1,
+ 1,
+ 2
+ );
+
+ ArrayList filtreEleveNom = db.fetchAll("SELECT nom FROM fi_eleves WHERE nom LIKE '" + beg[0] + beg[1] + beg[2] + "%'");
+ ArrayList filtreElevePrenom = db.fetchAll("SELECT prenom FROM fi_eleves WHERE nom LIKE '" + beg[0] + beg[1] + beg[2] + "%'");
+ ArrayList filtreEleveGroupe = db.fetchAll("SELECT groupe FROM fi_eleves WHERE nom LIKE '" + beg[0] + beg[1] + beg[2] + "%'");
+
+ System.out.println(filtreEleveGroupe.size() + filtreElevePrenom.size() + filtreEleveGroupe.size());
+
+ if(filtreEleveGroupe.size() == 0 || filtreEleveNom.size() == 0 || filtreElevePrenom.size() == 0) {
+ JOptionPane.showMessageDialog(
+ this,
+ "Eleve introuvable !",
+ "Erreur.",
+ JOptionPane.ERROR_MESSAGE
+ );
+
+ frame.closeBFrame();
+ } else {
+ String[] titre = {
+ "Nom",
+ "Prenom",
+ "Groupe"
+ };
+
+ String[][] data = new String[filtreEleveNom.size()][2];
+
+ for(int i = 0; i <= filtreEleveNom.size()-1; i++){
+ data[i] = new String[]{
+ filtreEleveNom.get(i),
+ filtreElevePrenom.get(i),
+ String.valueOf(filtreEleveGroupe.get(i))
+ };
+ }
+
+ JTable liste = new JTable(data, titre) {
+ public boolean editCellAt(int row, int column, java.util.EventObject e) {
+ return false;
+ }
+ };
+
+ liste.getTableHeader().setReorderingAllowed(false);
+ liste.setFillsViewportHeight(true);
+
+ JScrollPane scroll = new JScrollPane(liste);
+ frame.getContentPane().add(scroll);
+
+ frame.openBFrame();
}
}
-
- BFrame frame = new BFrame(
- "Liste d'eleves d'ou les noms commence par " + beg[0] + beg[1] + beg[2],
- 1,
- 1,
- 500,
- 500,
- "GridLayout",
- 1,
- 1,
- 2
- );
-
- String[] titre = {
- "Nom",
- "Prenom",
- "Groupe"
- };
-
- String[][] data = new String[listFiltered.size()][2];
-
- for(int i = 0; i <= listFiltered.size()-1; i++){
- data[i] = new String[]{
- this.e.get(i).getNom(),
- this.e.get(i).getPrenom(),
- String.valueOf(this.e.get(i).getGroupe())
- };
- }
-
- JTable liste = new JTable(data, titre) {
- public boolean editCellAt(int row, int column, java.util.EventObject e) {
- return false;
- }
- };
-
- liste.getTableHeader().setReorderingAllowed(false);
- liste.setFillsViewportHeight(true);
-
- JScrollPane scroll = new JScrollPane(liste);
- frame.getContentPane().add(scroll);
-
- frame.openBFrame();
- frame.refreshBFrame();
}
}
}
diff --git a/src/Test/TestTexteMNP.java b/src/Test/TestTexteMNP.java
index 44b4f46..3a98028 100644
--- a/src/Test/TestTexteMNP.java
+++ b/src/Test/TestTexteMNP.java
@@ -28,8 +28,6 @@ public class TestTexteMNP {
Integer.parseInt(studGroupe.get(i), 10)
)
);
-
- //System.out.println(listEtu.get(i).monPrint());
} else {
System.out.println("[!] Erreur lors du chargement de la liste des etudiants.");
System.exit(-1);
@@ -65,6 +63,9 @@ public class TestTexteMNP {
System.out.println("[+] Liste des groupes chargees.");
+ /**
+ * Redirection vers ProfView (vue professeur)
+ * */
new ProfView(listEtu, listGroupe, bd);
}
}