je suis sur le point de la finalisation de mon projet en fait il me reste juste la programmation de deux bouton (enregister et créer)
enregistrer c'est pour enregistrer une modification effectuées sur l'interface graphique d'intervention alors le bouton Creer c'est pour creer une nouvelle intervention
bon mon problème c'est que ni la requete de la modification ni la création d'une nouvelle intervention ne se s'exécute; je soupçonne les JCombobox puisque j'ai deux Jcombobx (Mpay:mode de paiement et Stat: Statut ) dans ces deux requete et j'ai d'autre requete sans JCombobox qui fonctionne super bien.
je vous laisse le code des deux classe (modification et création) au cas ou si vous reperez l'erreur
merci encore une fois
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Modification import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.text.ParseException; import javax.swing.JFormattedTextField; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JLabel; import javax.swing.text.MaskFormatter; public class Finterventionintermodify extends JFrame { private static final long serialVersionUID = 1L; public Finterventionintermodify(){ //Définit une taille pour celle-ci ; ici, 400 px de large et 500 px de haut this.setSize(1280, 770); //Nous allons maintenant dire à notre objet de se positionner au centre this.setLocationRelativeTo(null); //Instanciation d'un objet JPanel JPanel pan = new JPanel(); //Définition de sa couleur de fond pan.setBackground(Color.white); //On prévient notre JFrame que pan ça sera notre JPanel (contentPane) this.setContentPane(pan); setLayout(null); /* On crée un panal (conteneur) et on lui donne une couleur pourqu'il soit lisible On déclare de panel comme panel principal On Crée un label On ajoute ce label au panel On défini un layoutManager (FlowLayout) On attache le layoutManager au panel */ JLabel Titre=new JLabel(" Fiche d'Intervention Interne "); Titre.setFont(new Font("TimesRoman", Font.BOLD, 40)); Titre.setForeground(Color.red); Titre.setBounds(400,50,700,35); pan.add(Titre); JLabel Ninterinter = new JLabel("N° d'intervention : "); Ninterinter.setFont(new Font("TimesRoman", Font.BOLD, 25)); Ninterinter.setForeground(Color.red); Ninterinter.setBounds(100,150,300,25); pan.add(Ninterinter); final JLabel Ninter = new JLabel(Interventioninter.Nveninter); Ninter.setFont(new Font("TimesRoman", Font.BOLD, 20)); Ninter.setForeground(Color.red); Ninter.setBounds(360,155,200,20); pan.add(Ninter); JLabel Prob = new JLabel("Problématique : "); Prob.setFont(new Font("TimesRoman", Font.BOLD, 25)); Prob.setForeground(Color.red); Prob.setBounds(100,230,300,25); pan.add(Prob); final JTextField Pb = new JTextField(Interventioninter.Pveninter); Pb.setBounds(360,235,200,20); pan.add(Pb); JLabel cout = new JLabel("Coût : "); cout.setFont(new Font("TimesRoman", Font.BOLD, 25)); cout.setForeground(Color.red); cout.setBounds(100,310,300,25); pan.add(cout); final JTextField Ct = new JTextField(Interventioninter.Cveninter); Ct.setBounds(360,315,200,20); pan.add(Ct); JLabel date1 = new JLabel("Date d'entrée : "); date1.setFont(new Font("TimesRoman", Font.BOLD, 25)); date1.setForeground(Color.red); date1.setBounds(770,150,300,25); pan.add(date1); final JLabel Denter = new JLabel(Interventioninter.Dentreinter); Denter.setFont(new Font("TimesRoman", Font.BOLD, 20)); Denter.setForeground(Color.red); Denter.setBounds(1030,155,200,20); pan.add(Denter); /* try{ MaskFormatter Date1 = new MaskFormatter("##-##-####"); Date1.setValidCharacters("0123456789"); Date1.install(Denter); Denter.setBounds(1030,155,200,20); pan.add(Denter); } catch(ParseException e){ e.printStackTrace(); } */ JLabel Dinter = new JLabel("Date d'intervention : "); Dinter.setFont(new Font("TimesRoman", Font.BOLD, 25)); Dinter.setForeground(Color.red); Dinter.setBounds(770,230,300,25); pan.add(Dinter); final JFormattedTextField Dateinter = new JFormattedTextField(Interventioninter.Dinterveninter ); Dateinter.setBounds(1030,235,200,20); pan.add(Dateinter); /* try{ MaskFormatter Date2 = new MaskFormatter("##-##-####"); Date2.setValidCharacters("0123456789"); Date2.install(Dateinter); Dateinter.setBounds(1030,235,200,20); pan.add(Dateinter); } catch(ParseException e){ e.printStackTrace(); } */ JLabel Dfac = new JLabel("Date de facturation : "); Dfac.setFont(new Font("TimesRoman", Font.BOLD, 25)); Dfac.setForeground(Color.red); Dfac.setBounds(770,310,300,25); pan.add(Dfac); final JFormattedTextField Dfacture = new JFormattedTextField(Interventioninter.Dfacturinter); Dfacture.setBounds(1030,315,200,20); pan.add(Dfacture); /* try{ MaskFormatter Date3 = new MaskFormatter("##-##-####"); Date3.setValidCharacters("0123456789"); Date3.install(Dfacture); Dfacture.setBounds(1030,315,200,20); pan.add(Dfacture); } catch(ParseException e){ e.printStackTrace(); } */ JLabel Dsor = new JLabel("Date de sortie : "); Dsor.setFont(new Font("TimesRoman", Font.BOLD, 25)); Dsor.setForeground(Color.red); Dsor.setBounds(100,390,300,25); pan.add(Dsor); final JFormattedTextField Dsortie = new JFormattedTextField(Interventioninter.Dsorinter); Dsortie.setBounds(360,395,200,20); pan.add(Dsortie); /* try{ MaskFormatter Date4 = new MaskFormatter("##-##-####"); Date4.setValidCharacters("0123456789"); Date4.install(Dsortie); Dsortie.setBounds(360,395,200,20); pan.add(Dsortie); } catch(ParseException e){ e.printStackTrace(); } */ JLabel Description = new JLabel("Description : "); Description.setFont(new Font("TimesRoman", Font.BOLD, 25)); Description.setForeground(Color.red); Description.setBounds(100,470,250,25); pan.add(Description); final TextArea Descrip = new TextArea(Interventioninter.Descripinter); Descrip.setBounds(360,475,870,50); pan.add(Descrip); JLabel ModP = new JLabel("Mode de paiement : "); ModP.setFont(new Font("TimesRoman", Font.BOLD, 25)); ModP.setForeground(Color.red); ModP.setBounds(100,550,300,25); pan.add(ModP); final JComboBox Mpay = new JComboBox(); Mpay.addItem("Espèce"); Mpay.addItem("Carte Bancaire"); Mpay.addItem("Chèque"); Mpay.setBounds(360,555,200,23); pan.add(Mpay); JLabel Statut = new JLabel("Statut : "); Statut.setFont(new Font("TimesRoman", Font.BOLD, 25)); Statut.setForeground(Color.red); Statut.setBounds(770,550,300,25); pan.add(Statut); final JComboBox Stat = new JComboBox(); Stat.addItem("En cours"); Stat.addItem("En attente"); Stat.addItem("Invalide"); Stat.addItem("Closed"); Stat.setBounds(1030,555,200,23); pan.add(Stat); JButton Save = new JButton("Enregistrer"); Save.setBounds(583,620,170,25); pan.add(Save); Save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Cette méthode ne sera appelée que pour les évènements sur le bouton monBouton. // chaine de connexion final String url = "jdbc:odbc:dbrescue"; Connection con = null; Statement requete = null; ResultSet resultat1 = null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); con = DriverManager.getConnection(url,"",""); requete = con.createStatement(); int resultat = requete.executeUpdate("update Interventioninter set DATE_ENTREE='"+Denter.getText()+"', DATE_INTERINT='"+Dateinter.getText()+"', DATE_FACTURATION='"+Dfacture.getText()+"', DATE_SORTIE= '"+Dsortie.getText()+"', PROBLEMATIQUE='"+Pb.getText()+"', DESCRIPTION='"+Descrip.getText()+"', COUT='"+Ct.getText()+"', MODE_PAIEMENT= '"+Mpay.getSelectedItem()+"', INTSTATUT= '"+Stat.getSelectedItem()+"' from Interventioninter where N_INTERINT ="+Interventioninter.Nveninter+" "); JOptionPane.showMessageDialog(null,"Votre intervention a été bien modifiée" ); // Labeltest.setText(Numclient+ Nomclient + Ntelclient); Fclient Fclient = new Fclient(); Fclient.setVisible(true); dispose(); } catch (ClassNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SQLException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } catch (Exception e3) { e3.printStackTrace(); } finally { try {con.close(); requete.close(); resultat1.close(); } catch(final SQLException e1) {e1.printStackTrace(); } } } } ); JButton Anl = new JButton("Annuler"); Anl.setBounds(583,660,170,25); pan.add(Anl); Anl.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Finterventioninter Finterventioninter=new Finterventioninter(); dispose(); } } ); //Ferme-toi lorsqu'on clique sur "Fermer" ! this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // mettre la fenetre visible this.setVisible(true); } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Nouvelle import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.text.ParseException; import javax.swing.JFormattedTextField; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.text.MaskFormatter; public class Newfinterventioninter extends JFrame { private static final long serialVersionUID = 1L; JTextField Pb=null; JTextField Ct=null; JFormattedTextField Denter=null; JFormattedTextField Dateinter=null; JFormattedTextField Dfacture =null; JFormattedTextField Dsortie=null; TextArea Descrip=null; JComboBox Mpay=null; JComboBox Stat=null; public Newfinterventioninter(){ //Définit une taille pour celle-ci ; ici, 400 px de large et 500 px de haut this.setSize(1280, 770); //Nous allons maintenant dire à notre objet de se positionner au centre this.setLocationRelativeTo(null); //Instanciation d'un objet JPanel JPanel pan = new JPanel(); //Définition de sa couleur de fond pan.setBackground(Color.white); //On prévient notre JFrame que pan ça sera notre JPanel (contentPane) this.setContentPane(pan); setLayout(null); JLabel Titre=new JLabel(" Fiche d'Intervention Interne "); Titre.setFont(new Font("TimesRoman", Font.BOLD, 40)); Titre.setForeground(Color.red); Titre.setBounds(400,50,700,35); pan.add(Titre); JLabel Ninterinter = new JLabel("N° d'intervention : "); Ninterinter.setFont(new Font("TimesRoman", Font.BOLD, 25)); Ninterinter.setForeground(Color.red); Ninterinter.setBounds(100,150,300,25); pan.add(Ninterinter); JTextField Ninter = new JTextField(); Ninter.setBounds(360,155,200,20); pan.add(Ninter); JLabel Prob = new JLabel("Problématique : "); Prob.setFont(new Font("TimesRoman", Font.BOLD, 25)); Prob.setForeground(Color.red); Prob.setBounds(100,230,300,25); pan.add(Prob); JTextField Pb = new JTextField(); Pb.setBounds(360,235,200,20); pan.add(Pb); JLabel cout = new JLabel("Coût : "); cout.setFont(new Font("TimesRoman", Font.BOLD, 25)); cout.setForeground(Color.red); cout.setBounds(100,310,300,25); pan.add(cout); JTextField Ct = new JTextField(); Ct.setBounds(360,315,200,20); pan.add(Ct); JLabel date1 = new JLabel("Date d'entrée : "); date1.setFont(new Font("TimesRoman", Font.BOLD, 25)); date1.setForeground(Color.red); date1.setBounds(770,150,300,25); pan.add(date1); final JFormattedTextField Denter = new JFormattedTextField(); try{ MaskFormatter Date1 = new MaskFormatter("##-##-####"); Date1.setValidCharacters("0123456789"); Date1.install(Denter); Denter.setBounds(1030,155,200,20); pan.add(Denter); } catch(ParseException e){ e.printStackTrace(); } JLabel Dinter = new JLabel("Date d'intervention : "); Dinter.setFont(new Font("TimesRoman", Font.BOLD, 25)); Dinter.setForeground(Color.red); Dinter.setBounds(770,230,300,25); pan.add(Dinter); final JFormattedTextField Dateinter = new JFormattedTextField(); try{ MaskFormatter Date2 = new MaskFormatter("##-##-####"); Date2.setValidCharacters("0123456789"); Date2.install(Dateinter); Dateinter.setBounds(1030,235,200,20); pan.add(Dateinter); } catch(ParseException e){ e.printStackTrace(); } JLabel Dfac = new JLabel("Date de facturation : "); Dfac.setFont(new Font("TimesRoman", Font.BOLD, 25)); Dfac.setForeground(Color.red); Dfac.setBounds(770,310,300,25); pan.add(Dfac); final JFormattedTextField Dfacture = new JFormattedTextField(); try{ MaskFormatter Date3 = new MaskFormatter("##-##-####"); Date3.setValidCharacters("0123456789"); Date3.install(Dfacture); Dfacture.setBounds(1030,315,200,20); pan.add(Dfacture); } catch(ParseException e){ e.printStackTrace(); } JLabel Dsor = new JLabel("Date de sortie : "); Dsor.setFont(new Font("TimesRoman", Font.BOLD, 25)); Dsor.setForeground(Color.red); Dsor.setBounds(100,390,300,25); pan.add(Dsor); final JFormattedTextField Dsortie = new JFormattedTextField(); try{ MaskFormatter Date4 = new MaskFormatter("##-##-####"); Date4.setValidCharacters("0123456789"); Date4.install(Dsortie); Dsortie.setBounds(360,395,200,20); pan.add(Dsortie); } catch(ParseException e){ e.printStackTrace(); } JLabel Description = new JLabel("Description : "); Description.setFont(new Font("TimesRoman", Font.BOLD, 25)); Description.setForeground(Color.red); Description.setBounds(100,470,250,25); pan.add(Description); final TextArea Descrip = new TextArea(); Descrip.setBounds(360,475,870,50); pan.add(Descrip); JLabel ModP = new JLabel("Mode de paiement : "); ModP.setFont(new Font("TimesRoman", Font.BOLD, 25)); ModP.setForeground(Color.red); ModP.setBounds(100,550,300,25); pan.add(ModP); final JComboBox Mpay = new JComboBox(); Mpay.addItem("Espèce"); Mpay.addItem("Chèque"); Mpay.addItem("Carte Bancaire"); Mpay.setBounds(360,555,200,23); pan.add(Mpay); JLabel Statut = new JLabel("Statut : "); Statut.setFont(new Font("TimesRoman", Font.BOLD, 25)); Statut.setForeground(Color.red); Statut.setBounds(770,550,300,25); pan.add(Statut); final JComboBox Stat = new JComboBox(); Stat.addItem("En attente"); Stat.addItem("En cours"); Stat.addItem("Closed"); Stat.addItem("Invalide"); Stat.setBounds(1030,555,200,23); pan.add(Stat); JButton create = new JButton(" Créer "); create.setBounds(583,620,170,25); pan.add(create); create.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final String url = "jdbc:odbc:dbrescue"; Connection con = null; Statement requete = null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); con = DriverManager.getConnection(url,"",""); requete = con.createStatement(); int resultat = requete.executeUpdate("insert into Interventioninter (DATE_ENTREE, DATE_INTERINT, DATE_FACTURATION, DATE_SORTIE, PROBLEMATIQUE, DESCRIPTION, COUT, MODE_PAIEMENT, INTSTATUT, N_CLIENT) values ('"+Denter.getText()+"', '"+Dateinter.getText()+"', '"+Dfacture.getText()+"', "+Dsortie.getText()+", "+Descrip.getText()+", '"+Mpay.getSelectedItem()+"', '"+Stat.getSelectedItem()+"') where N_CLIENT="+Rclient.Nmclient+" "); JOptionPane.showMessageDialog(null,"Utilisateur crée avec succes" ); Rclient Rclient = new Rclient(); Rclient.setVisible(true); dispose(); } catch (ClassNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SQLException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } catch (Exception e3) { e3.printStackTrace(); } finally { try {con.close(); requete.close(); } catch(final SQLException e1) {e1.printStackTrace(); } } } } ); JButton Anl = new JButton(" Annuler "); Anl.setBounds(583,660,170,25); pan.add(Anl); Anl.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Interventioninter Interventioninter = new Interventioninter(); dispose(); } } ); //Ferme-toi lorsqu'on clique sur "Fermer" ! this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // mettre la fenetre visible this.setVisible(true); } }







Répondre avec citation





Partager