This commit is contained in:
Romain BESSON 2022-12-08 12:06:39 +01:00
parent 7de078d0cc
commit af7d5ce7c7
31 changed files with 58 additions and 10 deletions

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.

Binary file not shown.

View File

@ -634,17 +634,21 @@ public class Controller implements ActionListener, ListSelectionListener {
}; };
for (int i = 0; i <= this.r.size() - 1; i++) { for (int i = 0; i <= this.r.size() - 1; i++) {
Object[] info = { if (this.r.get(i).getStatut().equals("Pas encore de reponse")) {
this.getEtuNameById(this.r.get(i).getEtuId()), Object[] info = {
this.getGroupeById(this.r.get(i).getWitchGroupe()), this.getEtuNameById(this.r.get(i).getEtuId()),
this.r.get(i).getMessage(), this.getGroupeById(this.r.get(i).getWitchGroupe()),
this.r.get(i).getType(), this.r.get(i).getMessage(),
"[DECISION]" this.r.get(i).getType(),
}; "[DECISION]"
};
data[i] = info; data[i] = info;
}
} }
DisplayWithListner(this.createJTable(data, titre)); DisplayWithListner(this.createJTable(data, titre));
} }
} }
@ -676,6 +680,10 @@ public class Controller implements ActionListener, ListSelectionListener {
else if (Objects.equals(value, "[SUPPRIMER]")) { else if (Objects.equals(value, "[SUPPRIMER]")) {
deleteGrup(tm, cell); deleteGrup(tm, cell);
} }
else if (Objects.equals(value, "[DECISION]")) {
makeDecision(tm, cell);
}
} }
} }
} }
@ -688,6 +696,46 @@ public class Controller implements ActionListener, ListSelectionListener {
return nom + " " + prenom; return nom + " " + prenom;
} }
private void makeDecision(TableModel tm, int[] cell) {
int choice = JOptionPane.showConfirmDialog(this.parent, "Accepter la demande ?");
int id = getIDGroupeByName((String) tm.getValueAt(cell[0], 1));
System.out.println((String) tm.getValueAt(cell[0], 1) + ",");
if (choice == 0) {
if (this.db.updateRow("UPDATE fi_demandes SET statut = 'Acceptée' WHERE id = " + id)) {
if (this.db.updateRow("UPDATE fi_demandes SET statut = 'Acceptée' WHERE id = " + id)) {
JOptionPane.showMessageDialog(this.parent, "La demande a bien été acceptée", "Succès",JOptionPane.INFORMATION_MESSAGE);
} else {
}
} else {
JOptionPane.showMessageDialog(
this.parent,
"Impossible d'accepter la demande",
"Echec",
JOptionPane.INFORMATION_MESSAGE);
}
} else {
if (this.db.updateRow("UPDATE fi_demandes SET statut = 'Refusée' WHERE id = " + id)) {
JOptionPane.showMessageDialog(
this.parent,
"La demande a bien été refusée",
"Succes",
JOptionPane.INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(
this.parent,
"Impossible de refuser la demande",
"Echec",
JOptionPane.INFORMATION_MESSAGE);
}
}
}
private void deleteGrup(TableModel tm, int[] cell) { private void deleteGrup(TableModel tm, int[] cell) {
int choice = JOptionPane.showConfirmDialog(this.parent, "Etes-vous sur ?"); int choice = JOptionPane.showConfirmDialog(this.parent, "Etes-vous sur ?");
@ -874,7 +922,7 @@ public class Controller implements ActionListener, ListSelectionListener {
public int getIDGroupeByName(String label) { public int getIDGroupeByName(String label) {
for (int i = 0; i <= this.g.size() - 1; i++) { for (int i = 0; i <= this.g.size() - 1; i++) {
if (this.g.get(i).getName() == label) { if (this.g.get(i).getName().equals(label)) {
return this.g.get(i).getId(); return this.g.get(i).getId();
} }
} }
@ -921,4 +969,4 @@ public class Controller implements ActionListener, ListSelectionListener {
public void setMainMenu(MainMenu m) { public void setMainMenu(MainMenu m) {
this.parent = m; this.parent = m;
} }
} }