studentview + modif BDatabase.java
This commit is contained in:
parent
14ebaedeeb
commit
b4cd384ece
@ -251,16 +251,15 @@ public class BDatabase {
|
||||
public String toString() {
|
||||
return this.db_host + "\n" + this.db_name + "\n" + this.db_user + "\n";
|
||||
}
|
||||
/***
|
||||
* Recupere le nombre d'etudiant par groupe
|
||||
* @return
|
||||
*/
|
||||
public ArrayList<NBGroupe> getNbrEtuGroupes() {
|
||||
ArrayList<NBGroupe> NGroupe = new ArrayList<>();
|
||||
ArrayList<String> groupeNB = this.fetchAll("SELECT COUNT(DISTINCT groupe) FROM fi_eleves;");
|
||||
for(int i = 0; i <= NGroupe.Goupe(groupeNB); i++) {
|
||||
ArrayList<String> grpnb = this.fetchAll("Select count(id) from fi_eleves where groupe="+i+";");
|
||||
|
||||
}
|
||||
/**
|
||||
* Recuperer le nombre de membre d'un groupe
|
||||
*
|
||||
* @param groupe_id le groupes
|
||||
* @return le nombre de membre
|
||||
* */
|
||||
public int getMemberCount(int groupe_id) {
|
||||
ArrayList<String> forCount = this.fetchAll(
|
||||
"SELECT nom FROM fi_eleves WHERE groupe=" + groupe_id);
|
||||
return forCount.size();
|
||||
}
|
||||
}
|
116
src/Test/StudentView.java
Normal file
116
src/Test/StudentView.java
Normal file
@ -0,0 +1,116 @@
|
||||
package Test;
|
||||
|
||||
import API.Etudiant;
|
||||
import API.Groupe;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class StudentView extends JPanel {
|
||||
private final ArrayList<Etudiant> e;
|
||||
private final ArrayList<Groupe> g;
|
||||
private final Controller listener;
|
||||
private JComboBox<String> groupeOption;
|
||||
private JTextField text;
|
||||
|
||||
public StudentView(ArrayList<Etudiant> e, ArrayList<Groupe> g, Controller listener) {
|
||||
super();
|
||||
|
||||
this.listener = listener;
|
||||
this.e = e;
|
||||
this.g = g;
|
||||
|
||||
this.Display();
|
||||
}
|
||||
|
||||
public String getComboSelection() {
|
||||
return (String) this.groupeOption.getSelectedItem();
|
||||
}
|
||||
|
||||
public String getSearchStud() {
|
||||
return this.text.getText();
|
||||
}
|
||||
|
||||
public int getComboSelectionIndex() {
|
||||
return this.groupeOption.getSelectedIndex();
|
||||
}
|
||||
|
||||
public void Display() {
|
||||
BLayout settings = new BLayout();
|
||||
settings.setPositionX(0);
|
||||
settings.setPositionY(6);
|
||||
|
||||
settings.setPositionY(0);
|
||||
JButton studList = new JButton("Voir la liste des etudiants");
|
||||
studList.setActionCommand("pv::GetStudList");
|
||||
studList.addActionListener(this.listener);
|
||||
this.add(studList, settings);
|
||||
|
||||
settings.setPositionY(1);
|
||||
this.add(new JLabel(" "), settings);
|
||||
|
||||
settings.setPositionY(2);
|
||||
JLabel gs = new JLabel("Afficher les etudiants se trouvant dans le groupe :");
|
||||
this.add(gs, settings);
|
||||
|
||||
settings.setPositionY(3);
|
||||
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++) {
|
||||
groupeList[i] = this.g.get(i).getName();
|
||||
}
|
||||
|
||||
this.groupeOption = new JComboBox<>(groupeList);
|
||||
this.groupeOption.setPreferredSize(new Dimension(110, 30));
|
||||
this.add(groupeOption, settings);
|
||||
|
||||
settings.setPositionY(3);
|
||||
settings.setPadding(new Insets(0, 0, 0, 0));
|
||||
settings.setAnchor(GridBagConstraints.EAST);
|
||||
JButton confirm = new JButton("Rechercher");
|
||||
confirm.setActionCommand("pv::GetListFiltered");
|
||||
confirm.addActionListener(this.listener);
|
||||
this.add(confirm, settings);
|
||||
|
||||
settings.setAnchor(GridBagConstraints.CENTER);
|
||||
|
||||
settings.setPositionY(4);
|
||||
this.add(new JLabel(" "), settings);
|
||||
|
||||
settings.setPositionY(5);
|
||||
JLabel pf = new JLabel("Rechercher un etudiant : ");
|
||||
this.add(pf, settings);
|
||||
|
||||
settings.setPositionY(6);
|
||||
settings.setPadding(new Insets(0, 0, 0, 50));
|
||||
this.text = new JTextField();
|
||||
this.text.setPreferredSize(new Dimension(110, 30));
|
||||
text.addKeyListener(new KeyAdapter() {
|
||||
public void keyTyped(KeyEvent e) {
|
||||
if (text.getText().length() >= 3 )
|
||||
e.consume();
|
||||
}
|
||||
});
|
||||
this.add(this.text, settings);
|
||||
|
||||
settings.setPositionY(6);
|
||||
settings.setPadding(new Insets(0, 0, 0, 0));
|
||||
settings.setAnchor(GridBagConstraints.EAST);
|
||||
JButton searchTLetters = new JButton("Rechercher");
|
||||
searchTLetters.addActionListener(this.listener);
|
||||
searchTLetters.setActionCommand("pv::SearchStudentPer3Letters");
|
||||
this.add(searchTLetters, settings);
|
||||
|
||||
this.repaint();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user