1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
|
package Biblio;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Vector;
import javax.swing.*;
@SuppressWarnings("serial")
public class PanSearchAdh extends JPanel
{
static public JLabel lblNom = new JLabel("Nom :");
static public JLabel lblPren = new JLabel("Prénom :");
static public JLabel lblAdr = new JLabel("Adresse :");
static public JLabel lblCP = new JLabel("Code Postal :");
static public JLabel lblVille = new JLabel("Ville :");
static public JLabel lblDDN = new JLabel("Date de Naissance :");
static public JTextField txtNom = new JTextField();
static public JTextField txtPren = new JTextField();
static public JTextField txtAdr = new JTextField();
static public JTextField txtCP = new JTextField();
static public JTextField txtVille = new JTextField();
static public JTextField txtDDN = new JTextField();
private JLabel lblId = new JLabel("Id :");
private JLabel lblDDI = new JLabel("Date d'inscription :");
private JLabel lblDFC = new JLabel("Date de Fin de Cotisation :");
static JLabel txtId = new JLabel();
private static JLabel txtDDI = new JLabel();
private static JLabel txtDFC = new JLabel();
private static JLabel lblEmp1 = new JLabel("Emprunt en cours");
private static JLabel lblEmp2 = new JLabel("Emprunt en cours");
private static JLabel lblEmp3 = new JLabel("Emprunt en cours");
private static JLabel txtEmp1 = new JLabel();
private static JLabel txtEmp2 = new JLabel();
private static JLabel txtEmp3 = new JLabel();
private static JButton btnEmp1 = new JButton("Voir cet emprunt");
private static JButton btnEmp2 = new JButton("Voir cet emprunt");
private static JButton btnEmp3 = new JButton("Voir cet emprunt");
private JButton btnMod = new JButton("Modifier cet adhérent");
private JButton btnModOk = new JButton("Confirmer modifications");
private JButton btnSup = new JButton("Supprimer cet adhérent");
private static JLabel lblWarning = new JLabel("ATTENTION !!!!!!");
private static JLabel lblPerte = new JLabel("Amende en cours");
private static JLabel lblCotis = new JLabel("Cotisation expirée");
private static JButton btnPerte = new JButton("Payer cette amende");
private JLabel lblVide = new JLabel();
private static JButton btnCotis = new JButton("MAJ Cotisation");
private JPanel SESO = new JPanel(new GridLayout(3,1,5,5));
private JPanel SESE = new JPanel(new GridLayout(3,1,5,5));
private JPanel SES = new JPanel(new GridLayout(1,2,5,5));
private JPanel SEC = new JPanel(new FlowLayout(FlowLayout.CENTER));
private JPanel SENO = new JPanel(new BorderLayout(5,5));
private JPanel SENE = new JPanel(new BorderLayout(5,5));
private JPanel SEN = new JPanel(new GridLayout(1,2,5,5));
private JPanel SE = new JPanel(new GridLayout(3,1,5,5));
private static JPanel SO = new JPanel(new FlowLayout(FlowLayout.CENTER));
private JPanel NESS = new JPanel(new FlowLayout(FlowLayout.CENTER));
private JPanel NESC = new JPanel(new FlowLayout(FlowLayout.CENTER));
private JPanel NESN = new JPanel(new FlowLayout(FlowLayout.CENTER));
private JPanel NES = new JPanel(new GridLayout(3,1,5,5));
private JPanel NENO = new JPanel();
private JPanel NENE = new JPanel();
private JPanel NEN = new JPanel();
private JPanel NE = new JPanel(new GridLayout(2,1,5,5));
static public JPanel NOW = new JPanel(new GridLayout(6,1,5,5));
static public JPanel NOC = new JPanel(new GridLayout(6,1,5,5));
static public JPanel NO = new JPanel(new BorderLayout(5,5));
private JPanel panPrincipal = new JPanel(new GridLayout(2,2,5,5));
private static JScrollPane histo = null;
private static JTable tHisto;
private static Date dateJour = new Date();
private static DateFormat dateFormat = new SimpleDateFormat("dd/MM/YYYY");
private static Vector<Emprunt> vEmp = new Vector<Emprunt>();
private static Vector<Amende> vAmende = new Vector<Amende>();
private static Vector<String> vIdAmende = new Vector<String>();
private static JComboBox<String> texAmende = new JComboBox<String>();
private static Adherent toto;
GregorianCalendar calendar = new java.util.GregorianCalendar();
PaieCotis pc;
PanRendre pr;
public PanSearchAdh() throws ParseException
{
revalidate();
initControl();
}
public void initControl()
{
setLayout(new BorderLayout(5,5));
//Panneau Sud Est
SESO.add(lblPerte);
SESO.add(texAmende);
SESO.add(lblCotis);
SESE.add(btnPerte);
SESE.add(lblVide);
SESE.add(btnCotis);
SEC.add(lblWarning);
lblPerte.setVisible(false);
lblCotis.setVisible(false);
btnPerte.setVisible(false);
btnCotis.setVisible(false);
lblWarning.setVisible(false);
texAmende.setVisible(false);
lblWarning.setFont(new Font("Arial Black",Font.BOLD,25));
lblWarning.setForeground(Color.RED);
btnMod.addActionListener(new AppActionListener());
btnModOk.addActionListener(new AppActionListener());
btnSup.addActionListener(new AppActionListener());
btnCotis.addActionListener(new AppActionListener());
btnPerte.addActionListener(new AppActionListener());
SENO.add(btnMod,BorderLayout.CENTER);
SENE.add(btnSup,BorderLayout.CENTER);
SEN.add(SENO);
SEN.add(SENE);
SES.add(SESO);
SES.add(SESE);
SE.add(SEN);
SE.add(SEC);
SE.add(SES);
vEmp.removeAllElements();
SO.removeAll();
//Panneau Nord Est
NESS.add(lblEmp3);
NESS.add(txtEmp3);
NESS.add(btnEmp3);
NESC.add(lblEmp2);
NESC.add(txtEmp2);
NESC.add(btnEmp2);
NESN.add(lblEmp1);
NESN.add(txtEmp1);
NESN.add(btnEmp1);
btnEmp1.addActionListener(new AppActionListener());
btnEmp2.addActionListener(new AppActionListener());
btnEmp3.addActionListener(new AppActionListener());
btnEmp1.setVisible(false);
txtEmp1.setVisible(false);
lblEmp1.setVisible(false);
btnEmp2.setVisible(false);
txtEmp2.setVisible(false);
lblEmp2.setVisible(false);
btnEmp3.setVisible(false);
txtEmp3.setVisible(false);
lblEmp3.setVisible(false);
NES.add(NESN);
NES.add(NESC);
NES.add(NESS);
NENO.setLayout(new BoxLayout(NENO, BoxLayout.Y_AXIS));
lblId.setFont(new Font("Verdana",Font.ITALIC,15));
lblDDI.setFont(new Font("Verdana",Font.ITALIC,15));
lblDFC.setFont(new Font("Verdana",Font.ITALIC,15));
txtId.setFont(new Font("Verdana",Font.ITALIC,15));
txtDDI.setFont(new Font("Verdana",Font.ITALIC,15));
txtDFC.setFont(new Font("Verdana",Font.ITALIC,15));
txtDFC.setText("");
NENO.add(lblId);
NENO.add(lblDDI);
NENO.add(lblDFC);
NENE.setLayout(new BoxLayout(NENE, BoxLayout.Y_AXIS));
NENE.add(txtId);
txtId.setText(PanAdherent.texAdh.getText());
calendar.setTime(dateJour);
NENE.add(txtDDI);
NENE.add(txtDFC);
NEN.setLayout(new BoxLayout(NEN, BoxLayout.X_AXIS));
NEN.add(NENO);
NEN.add(NENE);
NE.add(NEN);
NE.add(NES);
//Panneau Nord Ouest
NOW.add(lblNom);
NOW.add(lblPren);
NOW.add(lblAdr);
NOW.add(lblCP);
NOW.add(lblVille);
NOW.add(lblDDN);
txtNom.setEditable(false);
NOC.add(txtNom);
txtPren.setEditable(false);
NOC.add(txtPren);
txtAdr.setEditable(false);
NOC.add(txtAdr);
txtCP.setEditable(false);
NOC.add(txtCP);
txtVille.setEditable(false);
NOC.add(txtVille);
lblNom.setFont(new Font("Verdana",Font.ITALIC,12));
lblPren.setFont(new Font("Verdana",Font.ITALIC,12));
lblAdr.setFont(new Font("Verdana",Font.ITALIC,12));
lblCP.setFont(new Font("Verdana",Font.ITALIC,12));
lblVille.setFont(new Font("Verdana",Font.ITALIC,12));
lblDDN.setFont(new Font("Verdana",Font.ITALIC,12));
txtNom.setFont(new Font("Verdana",Font.BOLD,12));
txtPren.setFont(new Font("Verdana",Font.BOLD,12));
txtAdr.setFont(new Font("Verdana",Font.BOLD,12));
txtCP.setFont(new Font("Verdana",Font.BOLD,12));
txtVille.setFont(new Font("Verdana",Font.BOLD,12));
txtDDN.setFont(new Font("Verdana",Font.BOLD,12));
txtDDN.setEditable(false);
NOC.add(txtDDN);
NO.add(NOW,BorderLayout.WEST);
NO.add(NOC,BorderLayout.CENTER);
panPrincipal.add(NO);
panPrincipal.add(NE);
panPrincipal.add(SO);
panPrincipal.add(SE);
add(panPrincipal,BorderLayout.CENTER);
}
public static JPanel panNO()
{
JPanel panno = new JPanel(new BorderLayout(5,5));
NOW.add(lblNom);
NOW.add(lblPren);
NOW.add(lblAdr);
NOW.add(lblCP);
NOW.add(lblVille);
NOW.add(lblDDN);
lblNom.setFont(new Font("Arial Black",Font.ITALIC,25));
lblPren.setFont(new Font("Arial Black",Font.ITALIC,25));
lblAdr.setFont(new Font("Arial Black",Font.ITALIC,25));
lblCP.setFont(new Font("Arial Black",Font.ITALIC,25));
lblVille.setFont(new Font("Arial Black",Font.ITALIC,25));
lblDDN.setFont(new Font("Arial Black",Font.ITALIC,25));
txtNom.setEditable(true);
NOC.add(txtNom);
txtPren.setEditable(true);
NOC.add(txtPren);
txtAdr.setEditable(true);
NOC.add(txtAdr);
txtCP.setEditable(true);
NOC.add(txtCP);
txtVille.setEditable(true);
NOC.add(txtVille);
txtDDN.setEditable(true);
NOC.add(txtDDN);
txtDDN.setText("JJ/MM/AAAA");
txtNom.setFont(new Font("Verdana",Font.BOLD,25));
txtPren.setFont(new Font("Verdana",Font.BOLD,25));
txtAdr.setFont(new Font("Verdana",Font.BOLD,25));
txtCP.setFont(new Font("Verdana",Font.BOLD,25));
txtVille.setFont(new Font("Verdana",Font.BOLD,25));
txtDDN.setFont(new Font("Verdana",Font.BOLD,25));
NO.add(NOW,BorderLayout.WEST);
NO.add(NOC,BorderLayout.CENTER);
panno = NO;
return panno;
}
//********************************************************LISTENERS******************************************************************
class AppActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == btnPerte)
{
EnConstruction.EnConstruction();
}
if (e.getSource() == PanSearchAdh.btnCotis)
{
System.out.println("déclencheur paie cotis");
pc = new PaieCotis();
pc.setVisible(true);
pc.setIdAdh(txtId.getText());
calendar.add(Calendar.MONTH,12);
toto.setAdhDFC(calendar.getTime());
txtDFC.setText(dateFormat.format(toto.getAdhDFC()));
}
if (e.getSource() == btnEmp1)
{
try
{
pr = new PanRendre();
removeAll();
add(pr, BorderLayout.CENTER);
PanRendre.txtNumEmp.setText(txtEmp1.getText());
PanRendre.SearchEmp();
}
catch (ClassNotFoundException e1) { e1.printStackTrace();}
catch (SQLException e1) {e1.printStackTrace();}
}
if (e.getSource() == btnEmp2)
{
try
{
pr = new PanRendre();
removeAll();
add(pr, BorderLayout.CENTER);
PanRendre.txtNumEmp.setText(txtEmp2.getText());
PanRendre.SearchEmp();
}
catch (ClassNotFoundException e1) { e1.printStackTrace();}
catch (SQLException e1) {e1.printStackTrace();}
}
if (e.getSource() == btnEmp3)
{
try
{
pr = new PanRendre();
removeAll();
add(pr, BorderLayout.CENTER);
PanRendre.txtNumEmp.setText(txtEmp3.getText());
PanRendre.SearchEmp();
}
catch (ClassNotFoundException e1) { e1.printStackTrace();}
catch (SQLException e1) {e1.printStackTrace();}
}
if (e.getSource() == btnMod)
{
SENO.remove(btnMod);
SENO.add(btnModOk,BorderLayout.CENTER);
txtNom.setEditable(true);
txtPren.setEditable(true);
txtAdr.setEditable(true);
txtCP.setEditable(true);
txtVille.setEditable(true);
txtDDN.setEditable(true);
validate();
repaint();
}
if (e.getSource() == btnModOk)
{
SENO.remove(btnModOk);
SENO.add(btnMod,BorderLayout.CENTER);
txtNom.setEditable(false);
txtPren.setEditable(false);
txtAdr.setEditable(false);
txtCP.setEditable(false);
txtVille.setEditable(false);
txtDDN.setEditable(false);
try
{
ValidModif();
}
catch (ClassNotFoundException e1) {e1.printStackTrace();}
catch (SQLException e1) {e1.printStackTrace();}
catch (ParseException e1) {e1.printStackTrace();}
validate();
repaint();
}
if (e.getSource() == btnSup)
try
{
GoSup();
}
catch (NumberFormatException e1) {e1.printStackTrace();}
catch (ClassNotFoundException e1) {e1.printStackTrace();}
catch (SQLException e1) {e1.printStackTrace(); }
}
}
public void GoSup() throws NumberFormatException, ClassNotFoundException, SQLException
{
if (vEmp.size() > 0)
JOptionPane.showMessageDialog(this,"SUPPRESSION IMPOSSIBLE DES EMPRUNTS SONT EN COURS" ,
"Cet adhérent ne va pas s'en tirer comme ça !",JOptionPane.ERROR_MESSAGE, new ImageIcon(("Images/oldbook.png")));
if (vAmende.size() > 0)
JOptionPane.showMessageDialog(this,"SUPPRESSION IMPOSSIBLE DES AMENDES SONT EN COURS" ,
"Cet adhérent nous doit de l'argent !",JOptionPane.ERROR_MESSAGE, new ImageIcon(("Images/1329582077_money.png")));
if (vEmp.size()==0 && vAmende.size() == 0) {
int rep = JOptionPane.showConfirmDialog(this,"ETES VOUS SUR DE VOULOIR SUPPRIMER CET ADHERENT ?","Eraser",JOptionPane.YES_NO_OPTION);
if (rep == JOptionPane.YES_OPTION){
int rep2 = JOptionPane.showConfirmDialog(this,"VOUS ETES VRAIMENT CERTAIN ?","Pas de regret ?",JOptionPane.YES_NO_OPTION);
if (rep2 == JOptionPane.YES_OPTION){
AdherentManager.deleteAdh(AdherentManager.getAdherent(Integer.parseInt(txtId.getText())));
JOptionPane.showMessageDialog(this,"SUPPRESSION EFFECTUÉE" ,
"Cet adhérent n'existe plus",JOptionPane.ERROR_MESSAGE, new ImageIcon(("Images/terminator.png")));}
if (rep2 == JOptionPane.NO_OPTION)
JOptionPane.showMessageDialog(this,"SUPPRESSION CORRECTEMENT ANNULE" ,
"Cet adhérent a eu chaud",JOptionPane.ERROR_MESSAGE, new ImageIcon(("Images/Wall.E.png")));
}
}
}
public static void vaChercher(String num) throws ClassNotFoundException, SQLException, ParseException
{
System.out.println("PanSearchAdh vaChercher()");
int id = Integer.parseInt(num);
toto = AdherentManager.getAdherent(id);
txtNom.setText(toto.getAdhNom());
txtPren.setText(toto.getAdhPren());
// INSERTION DES INFORMATIONS RELATIVES A L'ADHERENT
try {
try{txtAdr.setText(toto.getAdhAdr());}
catch (Exception e) { e.printStackTrace();}
try{txtCP.setText(String.valueOf(toto.getAdhCP()));}
catch (Exception e) { e.printStackTrace();}
try{txtVille.setText(toto.getAdhVille());}
catch (Exception e) { e.printStackTrace();}
try{txtDDN.setText(dateFormat.format(toto.getDDN()));}
catch (Exception e) { e.printStackTrace();}
try{txtId.setText(toto.getAdhId());}
catch (Exception e) { e.printStackTrace();}
try{txtDDI.setText(dateFormat.format(toto.getAdhDDI()));}
catch (Exception e) { e.printStackTrace();}
//GESTION DE LA DATE DE FIN DE COTISATION
try{
toto = AdherentManager.getDFC(toto);
if (toto.getAdhDFC() != null)
txtDFC.setText(dateFormat.format(toto.getAdhDFC()));
else{
JOptionPane.showMessageDialog(new JWindow(), "Cet adhérent n'a pas encore payé sa cotisation","Erreur",JOptionPane.ERROR_MESSAGE,new ImageIcon("Images/1329224175_Warning.png"));
lblWarning.setVisible(true);
lblCotis.setVisible(true);
btnCotis.setVisible(true);}
}
catch (Exception e) { e.printStackTrace();}}
catch (Exception e) { e.printStackTrace();}
String sdateJour = dateFormat.format(dateJour);
if (toto.getAdhDFC() != null)
{
if (PanRendre.stringToDate(txtDFC.getText()).before(PanRendre.stringToDate(sdateJour)))
{
lblWarning.setVisible(true);
lblCotis.setVisible(true);
btnCotis.setVisible(true);
JOptionPane.showMessageDialog(new JWindow(),"VOTRE COTISATION N'EST PLUS A JOUR !!" ,
"La prochaine fois, on vous purge",JOptionPane.ERROR_MESSAGE, new ImageIcon(("Images/bouh.png")));
}
}
//GESTION DES EMPRUNTS EN COURS
vEmp = EmpruntManager.getEmprunt(toto);
if (vEmp.size() > 0)
{
btnEmp1.setVisible(true);
txtEmp1.setVisible(true);
lblEmp1.setVisible(true);
txtEmp1.setText(vEmp.elementAt(0).getIdemprunt());
if (vEmp.elementAt(0).getDateRetourMax().before(PanRendre.stringToDate(sdateJour)))
{
JOptionPane.showMessageDialog(new JWindow(),"L'emprunt "+vEmp.elementAt(0).getIdemprunt()+" a dépassé la date de retour prévue" ,
"Vous vous prenez pour qui ?",JOptionPane.ERROR_MESSAGE, new ImageIcon(("Images/bouh.png")));
}
}
if (vEmp.size() > 1)
{
btnEmp2.setVisible(true);
txtEmp2.setVisible(true);
lblEmp2.setVisible(true);
txtEmp2.setText(vEmp.elementAt(1).getIdemprunt());
if (vEmp.elementAt(1).getDateRetourMax().before(PanRendre.stringToDate(sdateJour)))
{
JOptionPane.showMessageDialog(new JWindow(),"L'emprunt "+vEmp.elementAt(1).getIdemprunt()+" a dépassé la date de retour prévue" ,
"Vous vous prenez pour qui ?",JOptionPane.ERROR_MESSAGE, new ImageIcon(("Images/bouh.png")));
}
}
if (vEmp.size() > 2)
{
btnEmp3.setVisible(true);
txtEmp3.setVisible(true);
lblEmp3.setVisible(true);
txtEmp3.setText(vEmp.elementAt(2).getIdemprunt());
if (vEmp.elementAt(2).getDateRetourMax().before(PanRendre.stringToDate(sdateJour)))
{
JOptionPane.showMessageDialog(new JWindow(),"L'emprunt "+vEmp.elementAt(2).getIdemprunt()+" a dépassé la date de retour prévue" ,
"Vous vous prenez pour qui ?",JOptionPane.ERROR_MESSAGE, new ImageIcon(("Images/bouh.png")));
}
}
//GESTION DES AMENDES EN COURS
try {
vAmende = AmendeManager.getAmende(toto);
if (vAmende.size()>0)
{
for (int i=0 ; i<vAmende.size(); i++)
vIdAmende.add(i,vAmende.elementAt(i).getIdAmende());
for (int i=0 ; i<vIdAmende.size(); i++)
texAmende.addItem(vIdAmende.elementAt(i));
texAmende.setVisible(true);
lblWarning.setVisible(true);
lblPerte.setVisible(true);
btnPerte.setVisible(true);
JOptionPane.showMessageDialog(new JWindow(),"Cet adhérent a des amendes en cours" ,
"Par ici la monnaie !!",JOptionPane.ERROR_MESSAGE, new ImageIcon(("Images/bouh.png")));
}
}
catch(Exception e){e.printStackTrace();}
//GESTION DE L'HISTORIQUE
tHisto = new JTable(new HistoriqueTable(toto));
tHisto.setAutoCreateRowSorter(true);
histo = new JScrollPane(tHisto);
tHisto.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS );
SO.add(histo);
}
public void ValidModif() throws ClassNotFoundException, SQLException, ParseException
{
int id = Integer.parseInt(txtId.getText());
toto = AdherentManager.getAdherent(id);
AdherentManager.upadteAdh(toto);
}
} |
Partager