You are on page 1of 19

package gestioncomptes;

import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class Fenetre extends JFrame implements ActionListener
{
private JButton monBouton1,
monBouton2,monBouton3,monBouton4,monBouton5,monBouton6,monBouton7,monBouton77,monBo
uton777,monBouton8,monBouton10,monBouton11,monBouton12,monBouton13,monBouton14,monB
outon15,monBouton16 ;
private JPanel pan1,mous;
private JButton monBouton111,monBouton100,monBouton150;
private JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,
l16,l17,l18,l19;JButton monBouton9,monBouton99;
private JTextField
k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k12,k13,k14,ch1,ch2,ch3,ch4,ch5;
private JTextArea k11;
private Container contenu = getContentPane() ;
private JButton monBouton999;
private JButton monBouton1000;
private JButton monBouton144;
private JButton monBouton1500;
private JLabel l01;
private JLabel l02;
private JLabel l00;
private JLabel l001;
private JLabel l002;
private JLabel l010;
private Component l020;
public Fenetre ()
{ setTitle ("frame title") ;
setSize (3000, 2000) ;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
l1 =new JLabel("GUICHET");
l2 =new JLabel("CLIENT");
l3 =new JLabel("NUMERO:");
l4 =new JLabel("NOM:");
l5 =new JLabel("PRENOM:");
l6 =new JLabel("ADRESSE:");
l7 =new JLabel("TELEPHONE:");
l8 =new JLabel("PAYS:");
l9 =new JLabel("COMPTE");
l10 =new JLabel("COMPTE BANCAIRE");
l11 =new JLabel("SOLDE");
l12 =new JLabel("N CLIENT");
l13 =new JLabel("MONTANT(depot/retrait)");
l14 =new JLabel("COMPTE CHEQUE");
l15 =new JLabel("DECOUVERT");
l16 =new JLabel("GUICHET AUTOMATIQUE");
l17 =new JLabel("N CARTE");
l18 =new JLabel("N Compte");
l19 =new JLabel("MONTANT");
l00=new JLabel("CONTACT"); Font police = new Font("Times New Roman", Font.BOLD,
30);
l00.setFont(police);
l00.setForeground(Color.black);
l00.setHorizontalAlignment(JLabel.CENTER);l001=new JLabel("Copyright ");
l001.setFont(new Font("Arial",Font.ITALIC,15));
l001.setBounds(180,175,100,30);

k1 =new JTextField("",10); ch1 =new JTextField("",10);


k2 =new JTextField("",10);ch2 =new JTextField("",10);
k3 =new JTextField("",10);ch3 =new JTextField("",10);
k4 =new JTextField("",10);ch4 =new JTextField("",10);
k5 =new JTextField("",10);ch5 =new JTextField("",10);
k6 =new JTextField("",10);
k7 =new JTextField("",10);k8 =new JTextField("",10);k9 =new
JTextField("",10);k10 =new JTextField("",10);
k11 =new JTextArea("INSERER VOTRE CARTE...",10,10);
k12 =new JTextField("",10); k13 =new JTextField("",10); k14 =new
JTextField("",10);
monBouton1 = new JButton ("guichet") ;
monBouton1.setPreferredSize (new Dimension (300, 25)) ; // largeur 200,
hauteur 50
monBouton2 = new JButton ("guichet auto") ;
monBouton2.setPreferredSize (new Dimension (300, 25)) ;
monBouton3 = new JButton ("contacts") ;
monBouton3.setPreferredSize (new Dimension (300, 25)) ;
monBouton4 = new JButton ("quitter") ;
monBouton4.setPreferredSize (new Dimension (300, 25)) ;
monBouton5 = new JButton ("COMPTE") ;
monBouton5.setPreferredSize (new Dimension (400, 50)) ;
monBouton6 = new JButton ("CLIENT") ;
monBouton6.setPreferredSize (new Dimension (400, 50)) ;
monBouton7 = new JButton ("SELECTIONNER") ;monBouton7.setPreferredSize (new
Dimension (150, 20)) ;
monBouton77 = new JButton ("SELECTIONNER") ;monBouton777 = new JButton
("SELECTIONNER") ;monBouton777.setPreferredSize (new Dimension (150, 50)) ;
monBouton8 = new JButton ("COMPTE(S)") ; monBouton8.setPreferredSize (new
Dimension (150, 20)) ;
monBouton9 = new JButton ("ENREGISTRER") ;monBouton9.setPreferredSize (new
Dimension (150, 20)) ;
monBouton99 = new JButton ("ENREGISTRER") ;monBouton999 = new JButton
("ENREGISTRER") ;monBouton999.setPreferredSize (new Dimension (150, 50)) ;
monBouton10 = new JButton ("SUPPRIMER") ;monBouton10.setPreferredSize (new
Dimension (150, 20)) ;
monBouton100 = new JButton ("SUPPRIMER") ;monBouton1000 = new JButton
("SUPPRIMER") ;
monBouton11 = new JButton ("ANNULER") ; monBouton111 = new JButton ("ANNULER")
; monBouton11.setPreferredSize (new Dimension (150, 20)) ;
monBouton12 = new JButton ("BANCAIRE") ;
monBouton12.setPreferredSize (new Dimension (300, 50)) ;
monBouton13 = new JButton ("CHEQUE") ;
monBouton13.setPreferredSize (new Dimension (300, 50)) ;
monBouton14 = new JButton ("DEPOSER") ; monBouton144 = new JButton
("DEPOSER") ;monBouton144.setPreferredSize (new Dimension (150, 50)) ;
monBouton14.setPreferredSize (new Dimension (300, 50)) ;
monBouton15 = new JButton ("RETIRER") ; monBouton150 = new JButton
("RETIRER") ; monBouton1500 = new JButton ("RETIRER") ;
monBouton15.setPreferredSize (new Dimension (300, 50)) ;
monBouton16 = new JButton ("RETOUR") ;
monBouton16.setPreferredSize (new Dimension (300, 50)) ;
pan1 = new JPanel() ;
mous=new JPanel() ;
mous.setPreferredSize(new Dimension (1200,500));
mous.setVisible(false);
mous.setBackground(Color.orange) ;
pan1.setBackground(Color.orange) ;
pan1.setPreferredSize(new Dimension (1200,500));
pan1.setVisible(false);
Font police1 = new Font("Times New Roman", Font.BOLD, 30);
l1.setFont(police1);
l1.setForeground(Color.black);
l1.setHorizontalAlignment(JLabel.CENTER);
pan1.add(l1);

contenu.setBackground(Color.green);
FlowLayout g = new FlowLayout() ;
FlowLayout h = new FlowLayout() ;

contenu.setLayout(g) ;
g.setHgap (0) ; // intervalle horizontal entre composants de 15 pixels
g.setVgap (5) ;
pan1.setLayout(h);
h.setHgap (1000) ; // intervalle horizontal entre composants de 15 pixels
h.setVgap (50) ;
contenu.add(monBouton1) ;
contenu.add(monBouton2) ;
contenu.add(monBouton3) ;
contenu.add(monBouton4) ;
contenu.add(pan1) ;
contenu.add(mous) ;
pan1.add(monBouton5) ;
pan1.add(monBouton6) ;
monBouton1.addActionListener(this);
monBouton2.addActionListener(this);
monBouton3.addActionListener(this);
monBouton4.addActionListener(this);
monBouton6.addActionListener(this);
monBouton5.addActionListener(this);
monBouton12.addActionListener(this);
monBouton11.addActionListener(this); monBouton111.addActionListener(this);
monBouton13.addActionListener(this);
monBouton14.addActionListener(this);monBouton144.addActionListener(this);

monBouton15.addActionListener(this);monBouton150.addActionListener(this);monBouton1
500.addActionListener(this);
monBouton16.addActionListener(this);
monBouton8.addActionListener(this);
monBouton9.addActionListener(this);
monBouton99.addActionListener(this);monBouton999.addActionListener(this);

monBouton10.addActionListener(this);monBouton100.addActionListener(this);monBouton1
000.addActionListener(this);
monBouton7.addActionListener(this);
monBouton77.addActionListener(this);monBouton777.addActionListener(this);
}
public void actionPerformed (ActionEvent ev)
{ if (ev.getSource() == monBouton1)
{System.out.println ("action sur bouton numero 1") ;
pan1.setVisible(true);

}
if (ev.getSource() == monBouton2){
System.out.println ("action sur bouton numero 2") ;
pan1.setVisible(true);
monBouton6.setVisible(false);
monBouton12.setVisible(false);
monBouton13.setVisible(false);
monBouton5.setVisible(false);
Box vBox21=Box.createHorizontalBox();
vBox21.add(k11);

l1.setVisible(false);
l9.setVisible(false);
Font policy = new Font("Times New Roman", Font.BOLD, 30);
l16.setFont(policy);
l16.setForeground(Color.black);
l16.setHorizontalAlignment(JLabel.CENTER);
pan1.add(l16);
Box vBox14=Box.createVerticalBox();
// vBox14.setSize(100, 100);
vBox14.add(l17);vBox14.add(Box.createVerticalStrut(10));
vBox14.add(l18);vBox14.add(Box.createVerticalStrut(10));
vBox14.add(l19);vBox14.add(Box.createVerticalStrut(10));

// pan1.add(vBox7);

Box vBox15=Box.createVerticalBox();
//vBox15.setSize(100, 100);
vBox15.add(Box.createVerticalStrut(3));
vBox15.add(k12); vBox15.add(Box.createVerticalStrut(5));
vBox15.add(k13);vBox15.add(Box.createVerticalStrut(5));
vBox15.add(k14);vBox15.add(Box.createVerticalStrut(5));

//pan1.add(vBox8);

Box vBox16=Box.createHorizontalBox();
//vBox2.setSize(400, 200);
vBox16.add(vBox14);vBox16.add(Box.createHorizontalStrut(20));
vBox16.add(vBox15);
//pan1.add(vBox16);
Box vBox18=Box.createVerticalBox();

vBox18.add(monBouton150);vBox18.add(Box.createVerticalStrut(5));
vBox18.add(monBouton11);vBox18.add(Box.createVerticalStrut(5));
Box vBox19=Box.createVerticalBox();

vBox19.add(monBouton8);
Box vBox22=Box.createHorizontalBox();
vBox22.add(vBox19);vBox22.add(Box.createHorizontalStrut(300));
vBox22.add(vBox18);

//pan1.add(vBox19);

Box vBox20=Box.createVerticalBox();
vBox20.add(vBox21);vBox20.add(Box.createVerticalStrut(10));
vBox20.add(vBox16);vBox20.add(Box.createVerticalStrut(10));

vBox20.add(vBox22);

pan1.add(vBox20);
}
if (ev.getSource() == monBouton6){
System.out.println ("action sur bouton numero 6") ;
monBouton6.setVisible(false);
monBouton5.setVisible(false);
l1.setVisible(false);
Font polices = new Font("Times New Roman", Font.BOLD, 30);
l2.setFont(polices);
l2.setForeground(Color.black);
l2.setHorizontalAlignment(JLabel.CENTER);
pan1.add(l2);

Box vBox=Box.createVerticalBox();
vBox.setSize(200, 200);
//pan1.add(vBox);
vBox.add(l3); vBox.add(Box.createVerticalStrut(10));
vBox.add(l4);vBox.add(Box.createVerticalStrut(10));
vBox.add(l5);vBox.add(Box.createVerticalStrut(10));
vBox.add(l6);vBox.add(Box.createVerticalStrut(10));
vBox.add(l7);vBox.add(Box.createVerticalStrut(10));
vBox.add(l8);

Box vBox1=Box.createVerticalBox();
vBox1.setSize(200, 200);
// pan1.add(vBox1);
vBox1.add(Box.createVerticalStrut(3));
vBox1.add(k1); vBox1.add(Box.createVerticalStrut(5));
vBox1.add(k2);vBox1.add(Box.createVerticalStrut(5));
vBox1.add(k3);vBox1.add(Box.createVerticalStrut(5));
vBox1.add(k4);vBox1.add(Box.createVerticalStrut(5));
vBox1.add(k5);vBox1.add(Box.createVerticalStrut(5));
vBox1.add(k6);
Box vBox2=Box.createHorizontalBox();
//vBox2.setSize(400, 200);
vBox2.add(vBox);vBox2.add(Box.createHorizontalStrut(50));
vBox2.add(vBox1);

Box vBox3=Box.createVerticalBox();
vBox3.add(Box.createVerticalStrut(5));
vBox3.add(monBouton7); vBox3.add(Box.createVerticalStrut(5));
vBox3.add(monBouton9); vBox3.add(Box.createVerticalStrut(5));
vBox3.add(monBouton11);
Box vBox4=Box.createVerticalBox();
//vBox4.setSize(200, 200);
vBox4.add(monBouton8); vBox4.add(Box.createVerticalStrut(5));
vBox4.add(monBouton10); vBox4.add(Box.createVerticalStrut(5));
vBox4.add(Box.createVerticalStrut(5));
Box vBox5=Box.createHorizontalBox();
vBox5.add(vBox3);vBox5.add(Box.createHorizontalStrut(50));
vBox5.add(vBox4);
// pan1.add(vBox5);
Box vBox6=Box.createVerticalBox();
vBox6.add(vBox2);vBox6.add(Box.createVerticalStrut(10));
vBox6.add(vBox5);
pan1.add(vBox6);

if (ev.getSource() == monBouton5){
System.out.println ("action sur bouton numero 5") ;
monBouton6.setVisible(false);
monBouton5.setVisible(false);
FlowLayout i = new FlowLayout() ;
pan1.setLayout(i);
i.setHgap (1000) ; // intervalle horizontal entre composants de 15 pixels
i.setVgap (40) ;
Font policy = new Font("Times New Roman", Font.BOLD, 30);
l9.setFont(policy);
l9.setForeground(Color.black);
l9.setHorizontalAlignment(JLabel.CENTER);
pan1.add(l9);
pan1.add(monBouton12);
pan1.add(monBouton13);
l1.setVisible(false);
// mous.equals(pan1);

}
if (ev.getSource() == monBouton12){
System.out.println ("action sur bouton numero 12") ;
mous.setVisible(false);pan1.setVisible(true);
monBouton6.setVisible(false);
monBouton12.setVisible(false);
monBouton13.setVisible(false);
monBouton5.setVisible(false);
l1.setVisible(false);
l9.setVisible(false);
Font policy = new Font("Times New Roman", Font.BOLD, 30);
l10.setFont(policy);
l10.setForeground(Color.black);
l10.setHorizontalAlignment(JLabel.CENTER);
pan1.add(l10);

Box vBox7=Box.createVerticalBox();
vBox7.add(l3); vBox7.add(Box.createVerticalStrut(10));
vBox7.add(l11);vBox7.add(Box.createVerticalStrut(10));
vBox7.add(l12);vBox7.add(Box.createVerticalStrut(10));
vBox7.add(l13);vBox7.add(Box.createVerticalStrut(10));

Box vBox8=Box.createVerticalBox();
vBox8.setSize(100, 100);
vBox8.add(Box.createVerticalStrut(3));
vBox8.add(k7); vBox8.add(Box.createVerticalStrut(5));
vBox8.add(k8);vBox8.add(Box.createVerticalStrut(5));
vBox8.add(k9);vBox8.add(Box.createVerticalStrut(5));
vBox8.add(k10);vBox8.add(Box.createVerticalStrut(5));

Box vBox9=Box.createHorizontalBox();
vBox9.add(vBox7);vBox9.add(Box.createHorizontalStrut(50));
vBox9.add(vBox8);

Box vBox10=Box.createVerticalBox();
vBox10.add(Box.createVerticalStrut(5));
vBox10.add(monBouton77); vBox10.add(Box.createVerticalStrut(5));
vBox10.add(monBouton99); vBox10.add(Box.createVerticalStrut(5));
vBox10.add(monBouton14); vBox10.add(Box.createVerticalStrut(5));

Box vBox11=Box.createVerticalBox();
vBox11.add(monBouton111);vBox11.add(Box.createVerticalStrut(5));
vBox11.add(monBouton100);vBox11.add(Box.createVerticalStrut(5));
vBox11.add(monBouton15);vBox11.add(Box.createVerticalStrut(5));
vBox11.add(monBouton16);vBox11.add(Box.createVerticalStrut(5));

Box vBox12=Box.createHorizontalBox();
vBox12.add(vBox10);vBox12.add(Box.createHorizontalStrut(50));
vBox12.add(vBox11);

Box vBox13=Box.createVerticalBox();
vBox13.add(vBox9);vBox12.add(Box.createVerticalStrut(5));
vBox13.add(vBox12);
pan1.add(vBox13);

}
if (ev.getSource() == monBouton16){
pan1.setVisible(false);

mous.add(l9);
mous.add(monBouton12);
mous.add(monBouton13);
mous.setVisible(true);
System.out.println ("action sur bouton numero 16") ;

}
if (ev.getSource() == monBouton13){
System.out.println ("action sur bouton numero 13") ;
monBouton6.setVisible(false);
monBouton12.setVisible(false);
monBouton13.setVisible(false);
monBouton5.setVisible(false);
l1.setVisible(false);
l9.setVisible(false);
Font policy = new Font("Times New Roman", Font.BOLD, 30);
l14.setFont(policy);
l14.setForeground(Color.black);
l14.setHorizontalAlignment(JLabel.CENTER);
pan1.add(l14);
Box vBox7=Box.createVerticalBox();
vBox7.setSize(100, 100);
vBox7.add(l3); vBox7.add(Box.createVerticalStrut(10));
vBox7.add(l11);vBox7.add(Box.createVerticalStrut(10));
vBox7.add(l15);vBox7.add(Box.createVerticalStrut(10));
vBox7.add(l12);vBox7.add(Box.createVerticalStrut(10));
vBox7.add(l13);vBox7.add(Box.createVerticalStrut(10));

Box vBox8=Box.createVerticalBox();
vBox8.setSize(100, 100);
vBox8.add(Box.createVerticalStrut(3));
vBox8.add(ch1); vBox8.add(Box.createVerticalStrut(5));
vBox8.add(ch2);vBox8.add(Box.createVerticalStrut(5));
vBox8.add(ch3);vBox8.add(Box.createVerticalStrut(5));
vBox8.add(ch4);vBox8.add(Box.createVerticalStrut(5));
vBox8.add(ch5);vBox8.add(Box.createVerticalStrut(5));

Box vBox9=Box.createHorizontalBox();
//vBox2.setSize(400, 200);
vBox9.add(vBox7);vBox9.add(Box.createHorizontalStrut(10));
vBox9.add(vBox8);
pan1.add(vBox9);

Box vBox10=Box.createVerticalBox();
vBox10.setSize(100, 100);vBox10.add(Box.createVerticalStrut(5));
vBox10.add(monBouton777); vBox10.add(Box.createVerticalStrut(5));
vBox10.add(monBouton999); vBox10.add(Box.createVerticalStrut(5));
vBox10.add(monBouton144); vBox10.add(Box.createVerticalStrut(5));

Box vBox11=Box.createVerticalBox();
vBox11.setSize(100, 100);

vBox11.add(monBouton111);vBox10.add(Box.createVerticalStrut(5));
vBox11.add(monBouton1000);vBox10.add(Box.createVerticalStrut(5));
vBox11.add(monBouton1500);vBox10.add(Box.createVerticalStrut(5));
vBox11.add(monBouton16);vBox10.add(Box.createVerticalStrut(5));
Box vBox12=Box.createHorizontalBox();
vBox12.add(vBox10);vBox12.add(Box.createHorizontalStrut(10));
vBox12.add(vBox11);
pan1.add(vBox12);

Box vBox13=Box.createVerticalBox();
vBox13.add(vBox9);vBox12.add(Box.createVerticalStrut(5));
vBox13.add(vBox12);
pan1.add(vBox13);

}
if (ev.getSource() == monBouton4) {
System.out.println ("action sur bouton numero 4") ;
int r=JOptionPane.showConfirmDialog(null, "Voulez vous quitter l application",
"quitter", JOptionPane.YES_NO_OPTION);
if (r==0){
System.exit(0); }
}
if (ev.getSource() == monBouton3) {
System.out.println ("action sur bouton numero 3");
pan1.add(l00);
l1.setVisible(false);
monBouton6.setVisible(false);
monBouton5.setVisible(false);
l010 =new JLabel("Yaya");Font font=new Font("Arial",Font.BOLD,20);
l010.setFont(font);
l010.setBounds(100,100,300,50); l002 =new JLabel("Moustapha");Font
font1=new Font("Arial",Font.BOLD,20);
l002.setFont(font1);
l002.setBounds(100,100,300,50);l020=new JLabel("Etudiants en Licence
professionnelle R�seaux et Services ");
l020.setFont(new Font("Arial",Font.ITALIC,15));
l020.setBounds(160,190,200,30);
l01=new JLabel("Email: bayaya459@yahoo.com / gorele24@gmail.com ");
l01.setFont(new Font("Arial",Font.ITALIC,15));
l01.setBounds(110,170,300,30);l02=new JLabel("Email:
moustaphadiagne500@hotmail.com ");
l02.setFont(new Font("Arial",Font.ITALIC,15));
l02.setBounds(110,170,300,30);

pan1.add(l010);
pan1.add(l01);

pan1.add(l002);
pan1.add(l02);
pan1.add(l020);
pan1.add(l001);
pan1.setVisible(true);

if (ev.getSource() == monBouton11) {
pan1.setVisible(false);

if (ev.getSource() == monBouton9){
try {
enregistrerEnbase();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
if (ev.getSource() == monBouton99){
try {
registerEnbase();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (ev.getSource() == monBouton999){
try {
saveEnbase();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (ev.getSource() == monBouton10){
try {
supprimerEnbase();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
if (ev.getSource() == monBouton100 ){
try {
deleteEnbase();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
if (ev.getSource() == monBouton1000 ){
try {
clrEnbase();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
if (ev.getSource() == monBouton7){
try {
selectionnerEnbase();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
if (ev.getSource() == monBouton77){
try {
selectionEnbase();
} catch (SQLException e) {
e.printStackTrace();
}

}
if (ev.getSource() == monBouton777){
try {
selectEnbase();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (ev.getSource() == monBouton14){
try {
deposerEnbase();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (ev.getSource() == monBouton144){
try {
depotEnbase();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (ev.getSource() == monBouton15){
try {
retirerEnbase();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (ev.getSource() == monBouton111){

k7.setText("");k8.setText("");k9.setText("");k10.setText("");
ch1.setText(""); ch2.setText(""); ch3.setText("");
ch4.setText(""); ch5.setText("");

}
if (ev.getSource() == monBouton16){

System.out.println ("action sur bouton numero 5") ;


pan1.setVisible(false);
FlowLayout i = new FlowLayout() ;
mous.setLayout(i);
i.setHgap (1000) ; // intervalle horizontal entre composants de 15 pixels
i.setVgap (40) ;
Font policy = new Font("Times New Roman", Font.BOLD, 30);
l9.setFont(policy);
l9.setForeground(Color.black);

l9.setHorizontalAlignment(JLabel.CENTER);monBouton12.setVisible(true);monBouton13.s
etVisible(true);l9.setVisible(true);
mous.add(l9);
mous.add(monBouton12);
mous.add(monBouton13);
mous.setVisible(true);
}
if (ev.getSource() == monBouton8){
try {
comptesEnbase();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (ev.getSource() == monBouton150){
try {
soustraireEnbase();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (ev.getSource() == monBouton1500){
try {
retirchEnbase();
} catch (SQLException e) {
e.printStackTrace();
}
}
}

public void enregistrerEnbase() throws SQLException{


Connection c = null;
PreparedStatement pstmt = null;
int num= Integer.parseInt(k1.getText()); String nom=k2.getText();
String prenom=k3.getText();
String addr=k4.getText(); int tel=Integer.parseInt(k5.getText()); String
pays=k6.getText();
try {
Class.forName("com.mysql.jdbc.Driver");
}catch(Exception e){
e.printStackTrace();
}
try{

c = DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
+ "user=root&password=");

String sql="insert into FEEDBACK.CLIENTS values (?, ?, ?, ? , ?, ?)";


pstmt = c.prepareStatement(sql);

pstmt.setInt(1,num);
pstmt.setString(2,nom );
pstmt.setString(3, prenom);
pstmt.setString(4, addr);
pstmt.setInt(5, tel);
pstmt.setString(6, pays);
pstmt.execute();
}
catch (Exception e){
e.printStackTrace();
}finally{
c.close();
pstmt.close();
}
k1.setText(""); k2.setText(""); k3.setText(""); k3.setText("");
k4.setText(""); k5.setText(""); k6.setText("");
JOptionPane jop = new JOptionPane();
jop.showMessageDialog(null, "client enregistre avec succes !!",
"Confirmation", 0);

}
public void registerEnbase() throws SQLException{
Integer numc=new Integer(k7.getText());
Integer num=new Integer(k9.getText());
Integer x=new Integer(k8.getText());
float dec=0;
Statement stmt;
try {
Class.forName("com.mysql.jdbc.Driver");
Connection c =
DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
+ "user=root&password=");;
stmt=c.createStatement();
stmt.executeUpdate("INSERT INTO compte
(id_compte,type, solde,decouvert,numero) values ("+numc+",'Banquaire',
"+x+","+dec+","+num+")",
Statement.RETURN_GENERATED_KEYS);
JOptionPane.showMessageDialog(null, "Compte enr�gist�");
stmt.close();
c.close();

k7.setText("");k8.setText("");k9.setText("");k10.setText("");
} catch (Exception e1) {
e1.printStackTrace();
}

}
public void selectionEnbase() throws SQLException{
Integer x = new Integer (k7.getText());
Statement stmt;
ResultSet res=null;
try {
Class.forName("com.mysql.jdbc.Driver");
Connection c =
DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
+ "user=root&password=");;
stmt=c.createStatement();res=stmt.executeQuery("Select
solde, numero From compte Where id_compte="+x);
if (res.next())
{k8.setText(res.getString(1));
k9.setText(res.getString(2));
}
else
JOptionPane.showMessageDialog(null, "Il n�y a
personne avec ce numero !");
res.close();
stmt.close();
c.close();}
catch (Exception e1) {
e1.printStackTrace();
}

public void supprimerEnbase() throws SQLException{

try {
Class.forName("com.mysql.jdbc.Driver");
Connection c =
DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
+ "user=root&password=");;
Statement stmt = c.createStatement();
Integer num=new Integer(k1.getText());
int rr=JOptionPane.showConfirmDialog(null, "Voulez vous supprimer ce
client", "supprimer", JOptionPane.YES_NO_OPTION);
if (rr==0){
stmt.executeUpdate("DELETE FROM FEEDBACK.CLIENTS WHERE
numero="+num+"");

k1.setText("");k2.setText("");k3.setText("");k4.setText("");k5.setText("");k6.setTe
xt("");
}catch(Exception e){
e.printStackTrace();
}}
public void selectionnerEnbase() throws SQLException{
ResultSet res=null;

try {
Class.forName("com.mysql.jdbc.Driver");
Connection c =
DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
+ "user=root&password=");;
Statement stmt = c.createStatement();
Integer num=new Integer(k1.getText());

res=stmt.executeQuery("SELECT * FROM FEEDBACK.CLIENTS WHERE


numero="+num+"");
if(res.next()){
k2.setText(res.getString(2));
k3.setText(res.getString(3));k5.setText(res.getString(5));
k4.setText(res.getString(4));k6.setText(res.getString(6));
}else JOptionPane.showMessageDialog(null, "Pas de client avec ce
numero");
}catch(Exception e){
e.printStackTrace();
}}
public void deposerEnbase() throws SQLException{
Integer x=new Integer(k7.getText());
int solde= Integer.parseInt(k8.getText());
int montant= Integer.parseInt(k10.getText());
solde+=montant;
Statement stmt;
try {
Class.forName("com.mysql.jdbc.Driver");
Connection c =
DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
+ "user=root&password=");;
stmt = c.createStatement();
stmt.executeUpdate("UPDATE compte Set solde="+solde+" Where
id_compte="+x+"");
JOptionPane.showMessageDialog(null, "Operation
reussie");
stmt.close();
c.close();

k7.setText("");k8.setText("");k9.setText("");k10.setText("");
} catch (Exception e1) {
e1.printStackTrace();
}}
public void depotEnbase() throws SQLException{
Integer x=new Integer(ch1.getText());
int solde= Integer.parseInt(ch2.getText());
int montant= Integer.parseInt(ch5.getText());
solde+=montant;
Statement stmt;
try {
Class.forName("com.mysql.jdbc.Driver");
Connection c =
DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
+ "user=root&password=");;
stmt = c.createStatement();
stmt.executeUpdate("UPDATE compte Set solde="+solde+" Where
id_compte="+x+"");
JOptionPane.showMessageDialog(null, "Operation
reussie");
stmt.close();
c.close();

ch1.setText("");ch2.setText("");ch5.setText("");ch4.setText("");ch3.setText("");
} catch (Exception e1) {
e1.printStackTrace();
}}
public void retirerEnbase() throws SQLException{
Integer x=new Integer(k7.getText());
int solde= Integer.parseInt(k8.getText());
int montant= Integer.parseInt(k10.getText());
if (solde>montant){
solde-=montant;
Statement stmt;
try {
Class.forName("com.mysql.jdbc.Driver");
Connection c =
DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
+ "user=root&password=");;
stmt = c.createStatement();
stmt.executeUpdate("UPDATE compte Set
solde="+solde+" Where id_compte="+x+"");
JOptionPane.showMessageDialog(null,
"Operation reussie");
stmt.close();
c.close();

k7.setText("");k8.setText("");k9.setText("");k10.setText("");
} catch (Exception e1) {
e1.printStackTrace();
}}
else
JOptionPane.showMessageDialog(null,
"Operation r�fus�e");

}
public void retirchEnbase() throws SQLException{
Integer x=new Integer(ch1.getText());
int solde= Integer.parseInt(ch2.getText());
int decouvert= Integer.parseInt(ch3.getText());
int montant= Integer.parseInt(ch5.getText());
if (solde-decouvert>montant){
solde-=montant;
Statement stmt;
try {
Class.forName("com.mysql.jdbc.Driver");
Connection c =
DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
+ "user=root&password=");;
stmt = c.createStatement();
stmt.executeUpdate("UPDATE compte Set solde="+solde+" Where
id_compte="+x+"");
JOptionPane.showMessageDialog(null, "Operation
reussie");
stmt.close();
c.close();

ch1.setText("");ch2.setText("");ch3.setText("");ch4.setText("");ch5.setText("");
} catch (Exception e1) {
e1.printStackTrace();
}}
else
JOptionPane.showMessageDialog(null, "Operation
r�fus�e");

}
public void deleteEnbase() throws SQLException{

Statement stmt;
Integer numc=new Integer(k7.getText());
Integer num=new Integer(k9.getText());

try {
Class.forName("com.mysql.jdbc.Driver");
Connection c =
DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
+ "user=root&password=");;
stmt = c.createStatement();
stmt.executeUpdate("Delete From compte Where numero="+num+" and
id_compte="+numc+"");
JOptionPane.showMessageDialog(null, "Compte
Banquaire supprim�");
stmt.close();
c.close();

k7.setText("");k8.setText("");k9.setText("");k10.setText("");
} catch (Exception e2) {
e2.printStackTrace();
}
}
public void clrEnbase() throws SQLException{

Statement stmt;
Integer numc=new Integer(ch1.getText());
Integer num=new Integer(ch4.getText());

try {
Class.forName("com.mysql.jdbc.Driver");
Connection c =
DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
+ "user=root&password=");;
stmt = c.createStatement();
stmt.executeUpdate("Delete From compte Where numero="+num+" and
id_compte="+numc+"");
JOptionPane.showMessageDialog(null, "Compte Cheque
supprim�");
stmt.close();
c.close();

ch1.setText("");ch2.setText("");ch3.setText("");ch4.setText("");
} catch (Exception e2) {
e2.printStackTrace();
}
}
public void comptesEnbase() throws SQLException{ResultSet res=null;
Statement stmt;
Integer x= new Integer(k13.getText());
Integer y=new Integer(k12.getText());
try {
Class.forName("com.mysql.jdbc.Driver");
Connection c = DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
+ "user=root&password=");;
stmt = c.createStatement();
res=stmt.executeQuery("Select type,solde,decouvert From compte,carte Where
carte.id_carte="+y+" AND carte.id_compte=compte.id_compte AND
compte.id_compte="+x);
if (res.next())
{k11.setText("Compte "+res.getString(1)+"\n Solde=
"+res.getString(2)+"\n Decouvert= "+res.getString(3));
}
else
JOptionPane.showMessageDialog(null, "le numero de compte ou de la
carte n'existe pas !");
k12.setText("");k13.setText("");k14.setText("");
res.close();
stmt.close();
c.close();
}catch (Exception e1)
{ e1.printStackTrace(); }

}
public void soustraireEnbase() throws SQLException{
Integer x=new Integer(k12.getText());Integer y=new Integer(k13.getText());
int solde= 0;
int montant= Integer.parseInt(k14.getText());
int rep=0;
Statement stmt;
ResultSet res =null;
try {
Class.forName("com.mysql.jdbc.Driver");
Connection c =
DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
+ "user=root&password=");;
stmt = c.createStatement();
res=stmt.executeQuery("Select solde, decouvert From carte,compte
Where carte.id_carte="+x+" AND compte.id_compte=carte.id_compte AND
compte.id_compte="+y
);
if (res.next())
{
rep=res.getInt(1)-res.getInt(2);
solde=res.getInt(1);
if(rep>montant){
solde-=montant;

stmt.executeUpdate("UPDATE compte Set solde="+solde+" Where


id_compte="+y+"");
JOptionPane.showMessageDialog(null, "Operation reussie"); }
else JOptionPane.showMessageDialog(null, "Operation
r�fus�e");
}
else
JOptionPane.showMessageDialog(null, "Operation
r�fus�e");
stmt.close();
c.close();

k11.setText("");k12.setText("");k13.setText("");k14.setText("");
} catch (Exception e1) {
e1.printStackTrace();
}}
public void selectEnbase() throws SQLException{
Integer x = new Integer (ch1.getText());
Statement stmt;
ResultSet res=null;
try {
Class.forName("com.mysql.jdbc.Driver");
Connection c =
DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
+ "user=root&password=");;
stmt=c.createStatement();res=stmt.executeQuery("Select
solde,decouvert,numero From compte Where id_compte="+x);
if (res.next())
{ch2.setText(res.getString(1));
ch3.setText(res.getString(2));ch4.setText(res.getString(3));
}
else
JOptionPane.showMessageDialog(null, "Il n�y a
personne avec ce numero !");
res.close();
stmt.close();
c.close();}
catch (Exception e1) {
e1.printStackTrace();
}

}
public void saveEnbase() throws SQLException{
Integer numc=new Integer(ch1.getText());
Integer num=new Integer(ch4.getText());
Integer x=new Integer(ch2.getText());
Integer y=new Integer(ch3.getText());
Statement stmt;
try {
Class.forName("com.mysql.jdbc.Driver");
Connection c =
DriverManager.getConnection("jdbc:mysql://localhost/feedback?"
+ "user=root&password=");;
stmt=c.createStatement();
stmt.executeUpdate("INSERT INTO compte
(id_compte,type, solde,decouvert,numero) values ("+numc+",'Cheque',
"+x+","+y+","+num+")",
Statement.RETURN_GENERATED_KEYS);
JOptionPane.showMessageDialog(null, "Compte cheque
enr�gist�");
stmt.close();
c.close();

ch1.setText("");ch2.setText("");ch3.setText("");ch4.setText("");
} catch (Exception e1) {
e1.printStackTrace();
}

public static void main(String[] args) {


//TODO Auto-generated method stub
Fenetre fen = new Fenetre() ;
fen.setVisible(true) ;

}}

You might also like