From 7e475648ed23b7060e7a35a6b2c9ad02410baa9a Mon Sep 17 00:00:00 2001 From: "pro.boooooo" Date: Tue, 15 Nov 2022 18:28:51 +0100 Subject: [PATCH] $ --- out/production/FI_PRJ/Test/BDatabase.class | Bin 5166 -> 5166 bytes out/production/FI_PRJ/Test/ProfView$1.class | Bin 871 -> 871 bytes out/production/FI_PRJ/Test/ProfView$2.class | Bin 840 -> 840 bytes out/production/FI_PRJ/Test/ProfView$3.class | Bin 840 -> 840 bytes out/production/FI_PRJ/Test/ProfView$4.class | Bin 840 -> 840 bytes out/production/FI_PRJ/Test/ProfView.class | Bin 6986 -> 7555 bytes src/Test/BDatabase.java | 2 + src/Test/ProfView.java | 126 +++++++++++--------- src/Test/TestTexteMNP.java | 5 +- 9 files changed, 73 insertions(+), 60 deletions(-) diff --git a/out/production/FI_PRJ/Test/BDatabase.class b/out/production/FI_PRJ/Test/BDatabase.class index b073693e4e5c3e41f3cf296a51e7e4eac37e0c2d..3fe9b7a5e8d9d68cd2d8f3a8cbded9ab468c149e 100644 GIT binary patch delta 253 zcmWNLO-lk{6osD`T4aGXGaxQXnbMdNDy@w%hC&$@6iF7@2PIiSY1^Q$wcB~2MS&}6 z=McK8Wq+ZiEh73MT@IXkxt!;6e8+d*j9|uQfN_SHV1zhf5{%-=B`Mn!lT3?dC@{-9 zX*QT+lN7tm>$Tv!on??EBIJb4vmkSkWn5Os3R7gY7Y{wDt!)C7G1*~EP=`HvQ<3OC zB@Q_fopDTq6K<&T%qg$b@Hyv$3qHBziz|Mp^DC)8u6x5qLK(Nx`A+)Y6Xk&zk2-H2 esHSe2uJUwW{6$ABSG9FnyrVs&l}nyQ3KUuE#)ltO$;C$*lL}#~QdyI#9f|JZ zQfH3_ZQ(ilTyVfMhrH3mqs6CudK~e^F?~+><&;0pxne#tji}^@`b0 eclyP2)V=-|KIx$4s8?MTzUv38s5<(`a{mFXUNOi3 diff --git a/out/production/FI_PRJ/Test/ProfView$1.class b/out/production/FI_PRJ/Test/ProfView$1.class index 4aaa0ec9d36d16b40b47e1384e47e22ada7aed48..ba2ad8aeffbbbdb90943d9222e534b033fb0163a 100644 GIT binary patch delta 27 jcmaFP_MC0QRwl;8$=jI1Ig=R#8B!QT8B!;UF$V$wf!qh4 delta 27 jcmaFP_MC0QRwl-<$=jI1IU^VZ86p`(8KNeOF$V$wf8qyn diff --git a/out/production/FI_PRJ/Test/ProfView$2.class b/out/production/FI_PRJ/Test/ProfView$2.class index 09dc91ff32b1ced3cd94718e330eb722d4ee093b..ac2020c2d6fc918789f57505e74e1c2b49239b25 100644 GIT binary patch delta 19 bcmX@Xc7kogWG2QLlcz9+GtQd)hA9RBOX3G} delta 19 bcmX@Xc7kogWG2Sm$y1oZ8T%){VTu6&OEL#t diff --git a/out/production/FI_PRJ/Test/ProfView$3.class b/out/production/FI_PRJ/Test/ProfView$3.class index c1b11a0b707d565df9deed1e1b482c0cfccc90ae..0b8673243ac942590f838655abb6a2e325539bb4 100644 GIT binary patch delta 19 bcmX@Xc7kogWG2Qllcz9+GoG9LhA9RBPa+4~ delta 19 bcmX@Xc7kogWG2Q#lcz9+Gai}zhA9RBPJ#!= diff --git a/out/production/FI_PRJ/Test/ProfView$4.class b/out/production/FI_PRJ/Test/ProfView$4.class index f996b4f25faf92de6b4df0b8eb79f3ab27c26027..5ab601c93e1f808c08cd63e76f61c9560062a3c6 100644 GIT binary patch delta 20 ccmX@Xc7kogBqkpF delta 20 ccmX@Xc7kogBqkcq3f$g70 z*5~t`@4UX>_dCZqUB9DIKYi_$F#roWyk9TS(_MrsYQ~0A!*2YIm^@&PM50l1TgY6O zh$PIAF%sGskHnIpxuK|;N+rys8}AcZIFT?%5_f6%fGF8uY&IUQNp6Y6hHBcoH>D!+ zSdS4ib^HS#`tT7h68XvD_?AvHnKXvX)`$^}4-pG0JFMBB0;^UDEb7R_sEHa9p)Zw? zK#grx13J2K*@r9mC*e)STZWB9QzBt(B^;GiD_a5}#(nq${%w6nFAWEvU|h#FT-OL6 zNrlM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5; z4wW`6z!D}TvpGzzieY4h5w_vjD6%oi#zdRLMfZ8JM_$2zXdt``d3s>38<)XP=2pfl zx8mJ?SgE-8^su9RY-VFYh!AJA@F+0_VPm-2dA5Mg&h-NU$ zYJCCg{dFRo!L7f$PHO_RhCwB-B75mDx}qP*XqZosmm-c z3DP-VFB6v}Il<3}K75wJzZPu@b6d98k6R$}F1Pzc6D+Hcr}d9NZdsu|Y)OX0uc0wz z#-C|US@GwZQ=#|^%}Lv}6n*F*o-&dVvp$-L1_J*$x4Mx;G@UaFz;({APbMGVlqo{F z{H9Dn?!}Jg=1ozB_)skNxWU=bR$ZrAQIiyvr@82lW19=^w=jV;@c#M{wGBA7_k{IBTTOW5A5zoLPqR zW-ZQ`6L7(7pk+2PWGE@Q;JgO0g|d1em>`Blbi)Q_G}ITWd6Y|K<$`t=qTQ?K${ zELK6);O8vC(<-PL*vt{y7ZN|^ypmUG-%-R^s@k`?F%2hh6H#fqyjpIeBI@rsH=^rU z&W%Vrlyk$eIGBTDrFa=B3tMd6#!-Tch^HJ#R4nB{9C6ah(P}dxBZeR5Y>f}FI9R2l zhM_i4F12aoakbpXV2P&wAcU~U+8O}cqHIeLOvG$Jb#RiXxeSTmB#vL^7kiCX7{m(o znvi)H$0l`6@PZnOMYsj(S~K?sY~r-=>R5V)p#S9>%CpY zW$CP%(f`>}pMu$b`_JN@%j7nzq&bIB7B~ByOaA~cXXN8@xS)eJmdfG=m|yQvq?U57 zuNbRYquKxP4&cO0?7`iFeZ6}WED#J-J1R1p4@~J7w3W8%*mX}X>k7w D2AQUa 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); } }