This commit is contained in:
Bilal
2022-10-06 11:29:53 +02:00
commit af4b827eba
33 changed files with 7670 additions and 0 deletions

110
src/ManageStudent.java Normal file
View File

@@ -0,0 +1,110 @@
import javax.swing.JFrame;
import javax.swing.JList;
import java.awt.GridBagConstraints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.Array;
import java.util.ArrayList;
public class ManageStudent extends BFrame implements ActionListener {
protected BInput inSearch;
protected BButton btnSearch;
protected JList<String> student;
protected BButton moveTo;
protected BButton addTo;
protected BButton seeReq;
protected BDatabase sharedObject;
protected ArrayList<String> tmp;
protected ArrayList<String> tmp2;
protected String[] data;
protected BLayout settings;
public ManageStudent(BDatabase so) {
super("Manageur d'Eleve", 800, 400, JFrame.DISPOSE_ON_CLOSE);
this.settings = new BLayout();
this.sharedObject = so;
this.settings.setAnchor(GridBagConstraints.NORTHWEST);
this.inSearch = new BInput(150, 30);
this.settings.setPositionX(0);
this.settings.setPositionY(0);
this.add(inSearch, this.settings);
this.btnSearch = new BButton("Rechercher");
this.settings.setPositionX(1);
this.settings.setPositionY(0);
this.btnSearch.setActionCommand("search");
this.btnSearch.addActionListener(this);
this.add(btnSearch, this.settings);
this.student = refreshList("");
this.settings.setFill(GridBagConstraints.BOTH);
this.settings.setPositionX(0);
this.settings.setPositionY(1);
this.settings.setSizeX(1.0f);
this.settings.setSizeY(1.0f);
this.settings.setTakeCaseOnY(2);
this.settings.setTakeCaseOnX(2);
this.add(this.student, this.settings);
this.settings.setSizeX(1.0f);
this.settings.setSizeY(1.0f);
this.settings.setTakeCaseOnY(1);
this.settings.setTakeCaseOnX(1);
this.settings.setFill(GridBagConstraints.NONE);
this.settings.setAnchor(GridBagConstraints.CENTER);
this.moveTo = new BButton("Deplacer");
this.settings.setPositionX(2);
this.settings.setPositionY(1);
this.add(moveTo, this.settings);
this.addTo = new BButton("Ajouter");
this.settings.setPositionX(3);
this.settings.setPositionY(1);
this.add(addTo, this.settings);
this.seeReq = new BButton("Voir ses demandes");
this.settings.setPositionX(4);
this.settings.setPositionY(1);
this.add(seeReq, this.settings);
this.openBFrame();
this.refreshBFrame();
}
protected JList<String> refreshList(String student) {
this.tmp = new ArrayList<>();
this.tmp2 = new ArrayList<>();
this.tmp = this.sharedObject.fetchAll(
"SELECT nom FROM Membres WHERE nom LIKE '%" + student + "%'"
);
this.tmp2 = this.sharedObject.fetchAll(
"SELECT prenom FROM Membres WHERE nom LIKE '%" + student + "%'"
);
this.data = new String[tmp.size()];
for(int i = 0; i <= tmp.size()-1; i++) {
this.data[i] = tmp.get(i) + " " + tmp2.get(i);
System.out.println(this.data[i] + " | " + i);
}
JList<String> list = new JList<>(this.data);
this.refreshBFrame();
return list;
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand() == "search") {
refreshList(this.inSearch.getText());
} else {
System.out.println("ok");
}
}
}