$
This commit is contained in:
parent
50bd82b762
commit
eed97394b5
BIN
3B_SCHOOL_UML.pdf
Normal file
BIN
3B_SCHOOL_UML.pdf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10811
build/Test/Untitled.mdj
10811
build/Test/Untitled.mdj
File diff suppressed because it is too large
Load Diff
@ -66,6 +66,24 @@ public class AdminView extends JPanel {
|
||||
createGrup.setActionCommand("av::CreateGrup");
|
||||
this.add(createGrup, settings);
|
||||
|
||||
settings.setPositionY(8);
|
||||
this.add(new JLabel(" "), settings);
|
||||
|
||||
settings.setPositionY(9);
|
||||
CustomJButton renGrup = new CustomJButton("Renommer un groupe");
|
||||
renGrup.addActionListener(this.listener);
|
||||
renGrup.setActionCommand("av::renameGrup");
|
||||
this.add(renGrup, settings);
|
||||
|
||||
settings.setPositionY(10);
|
||||
this.add(new JLabel(" "), settings);
|
||||
|
||||
settings.setPositionY(11);
|
||||
CustomJButton delGrup = new CustomJButton("Supprimer un groupe");
|
||||
delGrup.addActionListener(this.listener);
|
||||
delGrup.setActionCommand("av::delGrup");
|
||||
this.add(delGrup, settings);
|
||||
|
||||
this.repaint();
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,9 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
private JTextField l2;
|
||||
private JTextField l3;
|
||||
|
||||
private String r1;
|
||||
private JTextField r2;
|
||||
|
||||
public Controller(BDatabase db) {
|
||||
this.db = db;
|
||||
this.e = this.db.getEtuList();
|
||||
@ -264,7 +267,7 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
Object[] info = {
|
||||
this.e.get(i).getNom(),
|
||||
this.e.get(i).getPrenom(),
|
||||
String.valueOf(this.e.get(i).getGroupe()),
|
||||
this.getGroupeById(this.e.get(i).getGroupe()),
|
||||
"[DEPLACER]"
|
||||
};
|
||||
|
||||
@ -291,7 +294,7 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
ArrayList<String> info = new ArrayList<>();
|
||||
info.add(this.e.get(i).getNom());
|
||||
info.add(this.e.get(i).getPrenom());
|
||||
info.add(String.valueOf(this.e.get(i).getGroupe()));
|
||||
info.add(this.getGroupeById(this.e.get(i).getGroupe()));
|
||||
info.add("[AJOUTER]");
|
||||
|
||||
data.add(info);
|
||||
@ -534,7 +537,7 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
String max = this.l2.getText();
|
||||
String min = this.l3.getText();
|
||||
|
||||
if(this.db.insertRow("fi_groupes", new String[]{"nom", "min", "max"}, new String[]{nom, min, max})) {
|
||||
if(this.db.insertRow("fi_groupe", new String[]{"nom", "min", "max"}, new String[]{nom, min, max})) {
|
||||
JOptionPane.showMessageDialog(
|
||||
this.parent,
|
||||
"Groupe" + nom + "creer !",
|
||||
@ -552,6 +555,69 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
else if(Objects.equals(command, "av::renameGrup")) {
|
||||
Object[][] data = new Object[this.g.size()][2];
|
||||
|
||||
String[] titre = {
|
||||
"Groupes",
|
||||
" "
|
||||
};
|
||||
|
||||
for(int i = 0; i <= this.g.size()-1; i++) {
|
||||
Object[] info = {
|
||||
this.g.get(i).getName(),
|
||||
"[RENOMMER]"
|
||||
};
|
||||
|
||||
data[i] = info;
|
||||
}
|
||||
|
||||
DisplayWithListner(this.createJTable(data, titre));
|
||||
}
|
||||
|
||||
else if(Objects.equals(command, "crtll::RenameGrup")) {
|
||||
String grupToChange = this.r1;
|
||||
String newName = this.r2.getText();
|
||||
|
||||
if(this.db.updateRow("UPDATE fi_groupe SET nom='" + newName + "' WHERE nom = '" + grupToChange + "'")) {
|
||||
JOptionPane.showMessageDialog(
|
||||
this.parent,
|
||||
"Le groupe : " + grupToChange + " a bien ete renommé par : " + newName,
|
||||
"Succes",
|
||||
JOptionPane.INFORMATION_MESSAGE
|
||||
);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(
|
||||
this.parent,
|
||||
"Echec du changement de nom du groupe : " + grupToChange,
|
||||
"Erreur",
|
||||
JOptionPane.ERROR_MESSAGE
|
||||
);
|
||||
}
|
||||
|
||||
this.g = this.db.getGroupeList();
|
||||
}
|
||||
|
||||
else if(Objects.equals(command, "av::delGrup")) {
|
||||
Object[][] data = new Object[this.g.size()][2];
|
||||
|
||||
String[] titre = {
|
||||
"Groupes",
|
||||
" "
|
||||
};
|
||||
|
||||
for(int i = 0; i <= this.g.size()-1; i++) {
|
||||
Object[] info = {
|
||||
this.g.get(i).getName(),
|
||||
"[SUPPRIMER]"
|
||||
};
|
||||
|
||||
data[i] = info;
|
||||
}
|
||||
|
||||
DisplayWithListner(this.createJTable(data, titre));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -570,14 +636,90 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
addMoveStudent(tm, cell, "[DEPLACER]");
|
||||
}
|
||||
|
||||
if(Objects.equals(value, "[AJOUTER]")) {
|
||||
else if(Objects.equals(value, "[AJOUTER]")) {
|
||||
addMoveStudent(tm, cell, "[AJOUTER]");
|
||||
}
|
||||
|
||||
else if(Objects.equals(value, "[RENOMMER]")) {
|
||||
renameGrup(tm, cell);
|
||||
}
|
||||
|
||||
else if(Objects.equals(value, "[SUPPRIMER]")) {
|
||||
deleteGrup(tm, cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteGrup(TableModel tm, int[] cell) {
|
||||
int choice = JOptionPane.showConfirmDialog(this.parent, "Etes-vous sur ?");
|
||||
|
||||
if(choice == 0) {
|
||||
String grupDelName = (String) tm.getValueAt(cell[0], 0);
|
||||
|
||||
if(this.db.updateRow("DELETE FROM fi_groupe WHERE nom = '" + grupDelName + "'")) {
|
||||
if(this.db.updateRow("UPDATE fi_eleves SET groupe = -1 WHERE groupe = " + this.getIDGroupeByName(grupDelName))) {
|
||||
this.e = this.db.getEtuList();
|
||||
this.g = this.db.getGroupeList();
|
||||
|
||||
JOptionPane.showMessageDialog(
|
||||
this.parent,
|
||||
"Le groupe : " + grupDelName + " a bien ete supprime",
|
||||
"Succes",
|
||||
JOptionPane.INFORMATION_MESSAGE
|
||||
);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(
|
||||
this.parent,
|
||||
"Echec de la suppression du groupe : " + grupDelName,
|
||||
"Erreur",
|
||||
JOptionPane.ERROR_MESSAGE
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renameGrup(TableModel tm, int[] cell) {
|
||||
this.r1 = (String) tm.getValueAt(cell[0], 0);
|
||||
|
||||
JPanel forModal = new JPanel(new GridBagLayout());
|
||||
BLayout settings = new BLayout();
|
||||
settings.setPositionX(0);
|
||||
|
||||
settings.setPositionY(0);
|
||||
forModal.add(new JLabel("Nouveau nom"), settings);
|
||||
|
||||
settings.setPositionY(1);
|
||||
forModal.add(new JLabel(" "), settings);
|
||||
|
||||
settings.setPositionY(2);
|
||||
this.r2 = new JTextField();
|
||||
this.r2.setPreferredSize(new Dimension(130, 30));
|
||||
forModal.add(this.r2, settings);
|
||||
|
||||
settings.setPositionY(3);
|
||||
forModal.add(new JLabel(" "), settings);
|
||||
|
||||
|
||||
settings.setPositionY(4);
|
||||
forModal.add(new JLabel(" "), settings);
|
||||
|
||||
JButton confirmRename = new JButton("Renommer");
|
||||
confirmRename.addActionListener(this);
|
||||
confirmRename.setActionCommand("crtll::RenameGrup");
|
||||
forModal.add(confirmRename, settings);
|
||||
|
||||
DisplayModal(
|
||||
"Renommer le groupe",
|
||||
600,
|
||||
300,
|
||||
this.parent.getLocation().x + (this.parent.getSize().width - 600) / 2,
|
||||
this.parent.getLocation().y + (this.parent.getSize().height - 300) / 2,
|
||||
forModal
|
||||
);
|
||||
}
|
||||
|
||||
private void addMoveStudent(TableModel tm, int[] cell, String action){
|
||||
String[] stringSetAdd = {
|
||||
@ -585,11 +727,13 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
"Ajouter",
|
||||
"Nouveau groupe de l'élève : "
|
||||
};
|
||||
|
||||
String[] stringSetMove = {
|
||||
"Déplacer ",
|
||||
"Déplacer",
|
||||
"Déplacer l'élève : "
|
||||
};
|
||||
|
||||
String[] stringSet;
|
||||
|
||||
if (action == "[AJOUTER]"){
|
||||
@ -657,6 +801,8 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
this.parent.getLocation().y + (this.parent.getSize().height - 250) / 2,
|
||||
forModal
|
||||
);
|
||||
|
||||
this.g = this.db.getGroupeList();
|
||||
this.parent.updateTable(this.initTable());
|
||||
}
|
||||
|
||||
@ -679,7 +825,21 @@ public class Controller implements ActionListener, ListSelectionListener {
|
||||
}
|
||||
|
||||
public String getGroupeById(int id) {
|
||||
return this.db.fetchAll("SELECT nom FROM fi_groupe WHERE id = " + id).get(0);
|
||||
if(id != -1) {
|
||||
return this.db.fetchAll("SELECT nom FROM fi_groupe WHERE id = " + id).get(0);
|
||||
} else {
|
||||
return "PAS DE GROUPE";
|
||||
}
|
||||
}
|
||||
|
||||
public int getIDGroupeByName(String label) {
|
||||
for(int i = 0; i <= this.g.size()-1; i++) {
|
||||
if(this.g.get(i).getName() == label) {
|
||||
return this.g.get(i).getId();
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public ProfView getProfView() {
|
||||
|
10811
src/Test/Untitled.mdj
10811
src/Test/Untitled.mdj
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user