Mise a jour des 3 boutons(ajout,modifier,supprimer)
This commit is contained in:
@@ -1,30 +1,33 @@
|
|||||||
// package fr.iutfbleau.papillon;
|
// package fr.iutfbleau.papillon;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
|
|
||||||
public class BtnAjouter extends JButton implements ActionListener{
|
public class BtnAjouter extends JButton implements ActionListener{
|
||||||
private GestionRappel ges;
|
|
||||||
private Main main;
|
private Main main;
|
||||||
|
|
||||||
|
|
||||||
public BtnAjouter(Main main){
|
public BtnAjouter(Main main){
|
||||||
super("Ajouter");
|
super("Ajouter");
|
||||||
this.main = main;
|
this.main = main;
|
||||||
setPreferredSize(new Dimension(120,25));
|
setPreferredSize(new Dimension(120,25));
|
||||||
|
|
||||||
|
setFocusPainted(false);
|
||||||
addActionListener(this);
|
addActionListener(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e){
|
public void actionPerformed(ActionEvent e){
|
||||||
if(e.getSource()==this){
|
if(e.getSource()==this){
|
||||||
|
|
||||||
FenetreAjout f = new FenetreAjout(main);
|
FenetreAjout f = new FenetreAjout(main);
|
||||||
// cacher la fenetre actuelle et montrer celle d ajout
|
f.setLocation(main.getLocation());
|
||||||
f.setLocation(main.getLocation()); // récupère la position actuelle de Main,place FenetreAjout au même endroit
|
|
||||||
f.setVisible(true);
|
f.setVisible(true);
|
||||||
main.setVisible(false);
|
main.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,28 +1,29 @@
|
|||||||
// package fr.iutfbleau.papillon;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class BtnModifier extends JButton implements ActionListener{
|
public class BtnModifier extends JButton implements ActionListener {
|
||||||
|
|
||||||
private GestionRappel ges;
|
|
||||||
private Rappel rappel;
|
private Rappel rappel;
|
||||||
private Main main;
|
private final Main main;
|
||||||
|
|
||||||
public BtnModifier(Main main){
|
public BtnModifier(Main main) {
|
||||||
super("Modifier");
|
super("Modifier");
|
||||||
this.main = main;
|
this.main = main;
|
||||||
setPreferredSize(new Dimension(120,25));
|
setPreferredSize(new Dimension(120, 25));
|
||||||
addActionListener(this);
|
addActionListener(this);
|
||||||
|
|
||||||
|
setFocusPainted(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public void actionPerformed(ActionEvent e){
|
public void actionPerformed(ActionEvent e){
|
||||||
|
|
||||||
if (e.getSource() == this) {
|
if (e.getSource() == this) {
|
||||||
ges = new GestionRappel();
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
List<PanelRappel> listRpl = new ArrayList<>();
|
List<PanelRappel> listRpl = new ArrayList<>();
|
||||||
PanelRappel pr;
|
PanelRappel pr;
|
||||||
@@ -41,10 +42,9 @@ public class BtnModifier extends JButton implements ActionListener{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(count==1){
|
if(count==1){
|
||||||
|
FenetreModif f = new FenetreModif(main,rappel);
|
||||||
FenetreModif f = new FenetreModif(main,rappel,rappel.getTitre(),rappel.getContenu());
|
|
||||||
f.setVisible(true);
|
f.setVisible(true);
|
||||||
main.setVisible(false);
|
main.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count>1){
|
if(count>1){
|
||||||
@@ -54,4 +54,8 @@ public class BtnModifier extends JButton implements ActionListener{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ import java.awt.*;
|
|||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
|
|
||||||
public class BtnSupprimer extends JButton implements ActionListener{
|
public class BtnSupprimer extends JButton implements ActionListener{
|
||||||
|
|
||||||
private GestionRappel ges;
|
private GestionRappel ges;
|
||||||
private Main main;
|
private Main main;
|
||||||
|
|
||||||
@@ -15,6 +16,8 @@ public class BtnSupprimer extends JButton implements ActionListener{
|
|||||||
this.main = main;
|
this.main = main;
|
||||||
setPreferredSize(new Dimension(120,25));
|
setPreferredSize(new Dimension(120,25));
|
||||||
addActionListener(this);
|
addActionListener(this);
|
||||||
|
|
||||||
|
setFocusPainted(false);
|
||||||
}
|
}
|
||||||
public void actionPerformed(ActionEvent e){
|
public void actionPerformed(ActionEvent e){
|
||||||
|
|
||||||
@@ -30,6 +33,23 @@ public class BtnSupprimer extends JButton implements ActionListener{
|
|||||||
pr = listRpl.get(i);
|
pr = listRpl.get(i);
|
||||||
if(pr.getSelection()==true){
|
if(pr.getSelection()==true){
|
||||||
count++;
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(count==0){
|
||||||
|
JOptionPane.showMessageDialog(main, "Sélectionnez les rappels que vous souhaiter supprimer !");
|
||||||
|
}else{
|
||||||
|
int choix = JOptionPane.showConfirmDialog(
|
||||||
|
main,
|
||||||
|
"Êtes-vous sûr de vouloir supprimer ce(s) rappel(s) ?",
|
||||||
|
"Confirmation",
|
||||||
|
JOptionPane.YES_NO_OPTION,
|
||||||
|
JOptionPane.WARNING_MESSAGE
|
||||||
|
);
|
||||||
|
|
||||||
|
if (choix == JOptionPane.YES_OPTION) {
|
||||||
|
for(int i = 0; i<listRpl.size();i++){
|
||||||
|
pr = listRpl.get(i);
|
||||||
|
if(pr.getSelection()==true){
|
||||||
try{
|
try{
|
||||||
ges.supprimerParId(pr.getId());
|
ges.supprimerParId(pr.getId());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@@ -37,12 +57,11 @@ public class BtnSupprimer extends JButton implements ActionListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(count==0){
|
|
||||||
JOptionPane.showMessageDialog(main, "Sélectionnez les rappels que vous souhaiter supprimer !");
|
|
||||||
}else{
|
|
||||||
JOptionPane.showMessageDialog(main, "Les rappels on bien étaient supprimé.");
|
JOptionPane.showMessageDialog(main, "Les rappels on bien étaient supprimé.");
|
||||||
new Main().setVisible(true);
|
new Main().setVisible(true);
|
||||||
main.dispose();
|
main.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user