$
This commit is contained in:
parent
8c76e54ea9
commit
d9b9b5e0fe
BIN
FI_PRJ.jar
BIN
FI_PRJ.jar
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.
@ -7,6 +7,8 @@ package Test;
|
|||||||
* 28/09/2022 at 20:35
|
* 28/09/2022 at 20:35
|
||||||
* */
|
* */
|
||||||
|
|
||||||
|
import API.*;
|
||||||
|
import MNP.*;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -14,8 +16,6 @@ import java.util.Arrays;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import org.mariadb.jdbc.*;
|
import org.mariadb.jdbc.*;
|
||||||
|
|
||||||
import javax.crypto.spec.PSource;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Methodes pour les interaction avec une base de donnees</p>
|
* <p>Methodes pour les interaction avec une base de donnees</p>
|
||||||
*
|
*
|
||||||
@ -145,6 +145,81 @@ public class BDatabase {
|
|||||||
return this.db_user;
|
return this.db_user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
try {
|
||||||
|
listEtu.add(
|
||||||
|
new EtudiantNP(
|
||||||
|
studNom.get(i),
|
||||||
|
studPrenom.get(i),
|
||||||
|
Integer.parseInt(studGroupe.get(i), 10)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} catch(NumberFormatException ignore) {
|
||||||
|
listEtu.add(
|
||||||
|
new EtudiantNP(
|
||||||
|
studNom.get(i),
|
||||||
|
studPrenom.get(i),
|
||||||
|
-1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("[!] Erreur lors du chargement de la liste des etudiants.");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("[+] Liste des etudiants chargee.");
|
||||||
|
|
||||||
|
return listEtu;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
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)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recuperer l'hote courant.
|
* Recuperer l'hote courant.
|
||||||
*
|
*
|
||||||
|
@ -20,22 +20,22 @@ public class Controller implements ActionListener, ListSelectionListener {
|
|||||||
|
|
||||||
private final ProfView pv;
|
private final ProfView pv;
|
||||||
private final AdminView av;
|
private final AdminView av;
|
||||||
|
|
||||||
private BFrame lastModal;
|
|
||||||
private BFrame currentModal;
|
private BFrame currentModal;
|
||||||
|
|
||||||
private final ArrayList<Etudiant> e;
|
private ArrayList<Etudiant> e;
|
||||||
private final ArrayList<Groupe> g;
|
private ArrayList<Groupe> g;
|
||||||
|
|
||||||
private JTable currentJTableUse;
|
private JTable currentJTableUse;
|
||||||
private JComboBox<String> list;
|
private JComboBox<String> list;
|
||||||
|
|
||||||
private String[] tmpStud;
|
private ArrayList<String> tmpStud;
|
||||||
|
|
||||||
public Controller(ArrayList<Etudiant> e, ArrayList<Groupe> g) {
|
public Controller(BDatabase db) {
|
||||||
this.e = e;
|
this.db = db;
|
||||||
this.g = g;
|
this.e = this.db.getEtuList();
|
||||||
this.db = new BDatabase();
|
this.g = this.db.getGroupeList();
|
||||||
|
|
||||||
|
// Les 3 fenetres s'ouvriront en meme temps (Pour le contexte du projet)
|
||||||
this.pv = new ProfView(e, g, this);
|
this.pv = new ProfView(e, g, this);
|
||||||
System.out.println("[+] Demarrage de la vue professeur -> " + pv);
|
System.out.println("[+] Demarrage de la vue professeur -> " + pv);
|
||||||
this.av = new AdminView(e, g, this);
|
this.av = new AdminView(e, g, this);
|
||||||
@ -129,6 +129,8 @@ public class Controller implements ActionListener, ListSelectionListener {
|
|||||||
int groupeIndex = this.pv.getComboSelectionIndex();
|
int groupeIndex = this.pv.getComboSelectionIndex();
|
||||||
String text = this.pv.getSearchStud();
|
String text = this.pv.getSearchStud();
|
||||||
|
|
||||||
|
this.e = this.db.getEtuList();
|
||||||
|
|
||||||
if(Objects.equals(command, "pv::GetStudList")) {
|
if(Objects.equals(command, "pv::GetStudList")) {
|
||||||
String[][] data = new String[this.e.size()][2];
|
String[][] data = new String[this.e.size()][2];
|
||||||
|
|
||||||
@ -284,15 +286,35 @@ public class Controller implements ActionListener, ListSelectionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if(Objects.equals(command, "crtll::ActionMoveGrup")) {
|
else if(Objects.equals(command, "crtll::ActionMoveGrup")) {
|
||||||
// TODO: CHANGE GROUPE
|
this.tmpStud.add(String.valueOf(this.list.getSelectedIndex()));
|
||||||
db.updateRow("UPDATE fi_eleves SET ");
|
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(
|
String query =
|
||||||
this.currentModal,
|
"UPDATE fi_eleves SET groupe=" + this.tmpStud.get(2) +
|
||||||
this.tmpStud[0] + " " + this.tmpStud[1] + " a bien ete deplace dans le " + this.list.getSelectedItem(),
|
" WHERE nom='" + this.tmpStud.get(0) +
|
||||||
"Deplacement effectue",
|
"' AND prenom='" + this.tmpStud.get(1) + "'"
|
||||||
JOptionPane.INFORMATION_MESSAGE
|
;
|
||||||
);
|
|
||||||
|
System.out.println(query);
|
||||||
|
|
||||||
|
if(db.updateRow(query)) {
|
||||||
|
JOptionPane.showMessageDialog(
|
||||||
|
this.currentModal,
|
||||||
|
this.tmpStud.get(0) + " " + this.tmpStud.get(1) + " a bien ete deplace dans le " + this.list.getSelectedItem(),
|
||||||
|
"Deplacement effectue",
|
||||||
|
JOptionPane.INFORMATION_MESSAGE
|
||||||
|
);
|
||||||
|
|
||||||
|
this.e = this.db.getEtuList();
|
||||||
|
|
||||||
|
System.out.println("[+] Modification de " + this.tmpStud.get(1) + " " + this.tmpStud.get(0) + " effectue");
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(
|
||||||
|
this.currentModal,
|
||||||
|
this.tmpStud.get(0) + " " + this.tmpStud.get(1) + " n'a pas pu etre deplace",
|
||||||
|
"Erreur lors du deplacement",
|
||||||
|
JOptionPane.ERROR_MESSAGE
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,7 +324,6 @@ public class Controller implements ActionListener, ListSelectionListener {
|
|||||||
int[] cell = this.currentJTableUse.getSelectedRows();
|
int[] cell = this.currentJTableUse.getSelectedRows();
|
||||||
int collumnCount = this.currentJTableUse.getColumnCount();
|
int collumnCount = this.currentJTableUse.getColumnCount();
|
||||||
Object value;
|
Object value;
|
||||||
System.out.println(e.getSource());
|
|
||||||
|
|
||||||
if(cell.length > 0) {
|
if(cell.length > 0) {
|
||||||
for(int i = 0; i < collumnCount; i++) {
|
for(int i = 0; i < collumnCount; i++) {
|
||||||
@ -312,10 +333,10 @@ public class Controller implements ActionListener, ListSelectionListener {
|
|||||||
if(Objects.equals(value, "[DEPLACER]")) {
|
if(Objects.equals(value, "[DEPLACER]")) {
|
||||||
JPanel forModal = new JPanel(new GridBagLayout());
|
JPanel forModal = new JPanel(new GridBagLayout());
|
||||||
BLayout settings = new BLayout();
|
BLayout settings = new BLayout();
|
||||||
this.tmpStud = new String[] {
|
|
||||||
(String) tm.getValueAt(cell[0], 0),
|
this.tmpStud = new ArrayList<>();
|
||||||
(String) tm.getValueAt(cell[0], 1)
|
this.tmpStud.add((String) tm.getValueAt(cell[0], 0));
|
||||||
};
|
this.tmpStud.add((String) tm.getValueAt(cell[0], 1));
|
||||||
|
|
||||||
settings.setPositionX(0);
|
settings.setPositionX(0);
|
||||||
settings.setPositionY(0);
|
settings.setPositionY(0);
|
||||||
@ -339,7 +360,7 @@ public class Controller implements ActionListener, ListSelectionListener {
|
|||||||
|
|
||||||
this.list = new JComboBox<>();
|
this.list = new JComboBox<>();
|
||||||
|
|
||||||
for (Groupe groupe : this.g) {
|
for(Groupe groupe : this.g) {
|
||||||
this.list.addItem(groupe.getName());
|
this.list.addItem(groupe.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package Test;
|
package Test;
|
||||||
|
|
||||||
import API.*;
|
import API.*;
|
||||||
import MNP.*;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class TestTexteMNP {
|
public class TestTexteMNP {
|
||||||
@ -9,73 +8,11 @@ public class TestTexteMNP {
|
|||||||
/**
|
/**
|
||||||
* Objet de la base de donnee contenant des methodes utile a notre developpement
|
* Objet de la base de donnee contenant des methodes utile a notre developpement
|
||||||
* */
|
* */
|
||||||
BDatabase bd = new BDatabase();
|
BDatabase db = new BDatabase();
|
||||||
|
|
||||||
/**
|
|
||||||
* Chargement des eleves
|
|
||||||
* */
|
|
||||||
ArrayList<Etudiant> listEtu = new ArrayList<>();
|
|
||||||
ArrayList<String> studPrenom = bd.fetchAll("SELECT prenom FROM fi_eleves");
|
|
||||||
ArrayList<String> studNom = bd.fetchAll("SELECT nom FROM fi_eleves");
|
|
||||||
ArrayList<String> studGroupe = bd.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) {
|
|
||||||
try {
|
|
||||||
listEtu.add(
|
|
||||||
new EtudiantNP(
|
|
||||||
studNom.get(i),
|
|
||||||
studPrenom.get(i),
|
|
||||||
Integer.parseInt(studGroupe.get(i), 10)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} catch(NumberFormatException ignore) {
|
|
||||||
listEtu.add(
|
|
||||||
new EtudiantNP(
|
|
||||||
studNom.get(i),
|
|
||||||
studPrenom.get(i),
|
|
||||||
-1
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
System.out.println("[!] Erreur lors du chargement de la liste des etudiants.");
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("[+] Liste des etudiants chargees.");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Chargement des groupes
|
|
||||||
* */
|
|
||||||
ArrayList<Groupe> listGroupe = new ArrayList<>();
|
|
||||||
ArrayList<String> groupeId = bd.fetchAll("SELECT id FROM fi_groupe");
|
|
||||||
ArrayList<String> groupeNom = bd.fetchAll("SELECT nom FROM fi_groupe");
|
|
||||||
ArrayList<String> groupeMin = bd.fetchAll("SELECT min FROM fi_groupe");
|
|
||||||
ArrayList<String> groupeMax = bd.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) {
|
|
||||||
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)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
System.out.println("[!] Erreur lors du chargement de la liste des groupes.");
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("[+] Liste des groupes chargees.");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Demarrage de l'appli
|
* Demarrage de l'appli
|
||||||
* */
|
* */
|
||||||
Controller listener = new Controller(listEtu, listGroupe);
|
Controller listener = new Controller(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user