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
| package medisoft;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.Font;
import javax.swing.SwingConstants;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JList;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import java.awt.Color;
import javax.swing.BorderFactory;
import java.awt.SystemColor;
import javax.swing.JOptionPane;
import java.awt.event.KeyEvent;
import java.awt.event.KeyAdapter;
public class Ajouter extends JFrame {
public Ajouter() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
this.getContentPane().setBackground(SystemColor.inactiveCaption);
this.setCursor(null);
this.setJMenuBar(null);
this.setResizable(false);
this.setTitle("Gestionaire MEDISOFT");
this.setVisible(true);
this.getContentPane().setLayout(null);
this.setBounds(200,100,630,520);
jLabel1.setFont(new java.awt.Font("Tahoma", Font.BOLD, 15));
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setText("Nouveau Patient");
jLabel1.setBounds(new Rectangle(0, 12, 630, 29));
jLabel2.setText("Nom & Prénom");
jLabel2.setBounds(new Rectangle(62, 72, 99, 14));
jLabel3.setText("CIN");
jLabel3.setBounds(new Rectangle(62, 108, 50, 14));
jLabel4.setText("Sexe");
jLabel4.setBounds(new Rectangle(62, 141, 64, 14));
jLabel5.setText("Adresse");
jLabel5.setBounds(new Rectangle(62, 179, 71, 14));
jLabel6.setText("Téléphone");
jLabel6.setBounds(new Rectangle(62, 211, 67, 14));
jLabel7.setText("Médecin Traitant");
jLabel7.setBounds(new Rectangle(62, 243, 100, 14));
jLabel8.setText("Mutualiste");
jLabel8.setBounds(new Rectangle(62, 277, 96, 14));
jLabel9.setText("Antécédants Médicaux");
jLabel9.setBounds(new Rectangle(62, 308, 131, 14));
jTextArea1.setBorder(BorderFactory.createEtchedBorder());
jTextArea1.setBounds(new Rectangle(197, 308, 205, 80));
jTextField2.setBounds(new Rectangle(197, 243, 205, 19));
jTextField3.setBounds(new Rectangle(197, 211, 205, 19));
jTextField4.setBounds(new Rectangle(197, 179, 205, 19));
jRadioButton1.setBackground(SystemColor.inactiveCaption);
jRadioButton1.setSelected(true);
jRadioButton1.setText("Masculin");
jRadioButton1.setBounds(new Rectangle(196, 139, 94, 21));
jRadioButton1.addActionListener(new Ajouter_jRadioButton1_actionAdapter(this));
jRadioButton2.setBackground(SystemColor.inactiveCaption);
jRadioButton2.setText("Féminin");
jRadioButton2.setBounds(new Rectangle(292, 138, 93, 23));
jLabel13.setFont(new java.awt.Font("Tahoma", Font.BOLD | Font.ITALIC,
11));
jLabel13.setForeground(Color.darkGray);
jLabel13.setText("Seules les Lettres sont Acceptées");
jLabel13.setBounds(new Rectangle(412, 243, 205, 19));
jLabel11.setFont(new java.awt.Font("Tahoma", Font.BOLD | Font.ITALIC,
11));
jLabel11.setForeground(Color.darkGray);
jLabel11.setText("Seules les Lettres sont Acceptées");
jLabel11.setBounds(new Rectangle(412, 72, 205, 19));
jRadioButton3.setBackground(SystemColor.inactiveCaption);
jRadioButton3.setSelected(true);
jRadioButton3.setText("Oui");
jRadioButton3.setBounds(new Rectangle(200, 277, 93, 23));
jRadioButton4.setBackground(SystemColor.inactiveCaption);
jRadioButton4.setText("Non");
jRadioButton4.setBounds(new Rectangle(292, 277, 93, 23));
jLabel12.setFont(new java.awt.Font("Tahoma", Font.BOLD | Font.ITALIC,
11));
jLabel12.setForeground(Color.darkGray);
jLabel12.setText("Seuls les Chiffres sont Acceptés");
jLabel12.setBounds(new Rectangle(412, 211, 205, 19));
radioGroup.add(jRadioButton1);
radioGroup.add(jRadioButton2);
radioGroup2.add(jRadioButton3);
radioGroup2.add(jRadioButton4);
jTextField5.setBounds(new Rectangle(197, 108, 205, 19));
jTextField6.setBounds(new Rectangle(197, 72, 205, 19));
jButton1.setBounds(new Rectangle(93, 423, 130, 23));
jButton1.setToolTipText("Retour au Menu Principal");
jButton1.setText("Menu Principal");
jButton1.addActionListener(new Ajouter_jButton1_actionAdapter(this));
jButton2.setBounds(new Rectangle(467, 423, 73, 23));
jButton2.setToolTipText("Retour à la Gestion des Patients");
jButton2.setText("Retour");
jButton2.addActionListener(new Ajouter_jButton2_actionAdapter(this));
jButton3.setBounds(new Rectangle(280, 423, 106, 23));
jButton3.setToolTipText("Enregistrer le Patient");
jButton3.setText("Enregistrer");
jButton3.addActionListener(new Ajouter_jButton3_actionAdapter(this));
this.getContentPane().add(jLabel1);
this.getContentPane().add(jLabel2);
this.getContentPane().add(jLabel3);
this.getContentPane().add(jLabel5);
this.getContentPane().add(jLabel6);
this.getContentPane().add(jLabel7);
this.getContentPane().add(jLabel8);
this.getContentPane().add(jLabel4);
this.getContentPane().add(jLabel9);
this.getContentPane().add(jTextArea1);
this.getContentPane().add(jTextField2);
this.getContentPane().add(jTextField3);
this.getContentPane().add(jTextField4);
this.getContentPane().add(jRadioButton2);
this.getContentPane().add(jTextField5);
this.getContentPane().add(jTextField6);
this.getContentPane().add(jLabel11);
this.getContentPane().add(jLabel13);
this.getContentPane().add(jRadioButton3);
this.getContentPane().add(jRadioButton4);
this.getContentPane().add(jLabel12);
this.getContentPane().add(jRadioButton1);
this.getContentPane().add(jButton3);
this.getContentPane().add(jButton1);
this.getContentPane().add(jButton2);
jTextField3.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(KeyEvent source) {
int k = source.getKeyChar();
if (k == 46)
source.setKeyChar((char) KeyEvent.VK_CLEAR);
else if ((k > 47 && k < 58) ||
(k == 8 || k == KeyEvent.VK_PERIOD)) {} else {
source.setKeyChar((char) KeyEvent.VK_CLEAR);
}
}
});
jTextField6.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent source) {
int k = source.getKeyChar();
if (k == 46)
source.setKeyChar((char) KeyEvent.VK_CLEAR);
else if ((k > 64 && k < 91) || (k > 96 && k < 123) ||
(k == 8 || k == KeyEvent.VK_PERIOD)) {} else {
source.setKeyChar((char) KeyEvent.VK_CLEAR);
}
}
});
jTextField2.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent source) {
int k = source.getKeyChar();
if (k == 46)
source.setKeyChar((char) KeyEvent.VK_CLEAR);
else if ((k > 64 && k < 91) || (k > 96 && k < 123) ||
(k == 8 || k == KeyEvent.VK_PERIOD)) {} else {
source.setKeyChar((char) KeyEvent.VK_CLEAR);
}
}
});
}
PatientDB sdb = new PatientDB();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
JLabel jLabel8 = new JLabel();
JLabel jLabel9 = new JLabel();
JTextArea jTextArea1 = new JTextArea();
JTextField jTextField2 = new JTextField();
JTextField jTextField3 = new JTextField();
JTextField jTextField4 = new JTextField();
JRadioButton jRadioButton1 = new JRadioButton();
JRadioButton jRadioButton2 = new JRadioButton();
ButtonGroup radioGroup = new ButtonGroup();
ButtonGroup radioGroup2 = new ButtonGroup();
JTextField jTextField5 = new JTextField();
JTextField jTextField6 = new JTextField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JLabel jLabel13 = new JLabel();
JLabel jLabel11 = new JLabel();
JRadioButton jRadioButton3 = new JRadioButton();
JRadioButton jRadioButton4 = new JRadioButton();
JLabel jLabel12 = new JLabel();
public void jRadioButton1_actionPerformed(ActionEvent actionEvent) {
}
public void jButton2_actionPerformed(ActionEvent actionEvent) {
this.setVisible(false);
General layout = new General();
layout.setVisible(true);
}
public void jButton3_actionPerformed(ActionEvent actionEvent) {
String gender, mutualiste;
gender = "Masculin";
mutualiste = "Non";
if (jTextArea1.getText().compareTo("") == 0 ||
jTextField2.getText().compareTo("") == 0 ||
jTextField3.getText().compareTo("") == 0 ||
jTextField4.getText().compareTo("") == 0 ||
jTextField5.getText().compareTo("") == 0 ||
jTextField6.getText().compareTo("") == 0) {
String ms = "Veuillez remplir tous les champs requis. SVP!!";
JOptionPane.showMessageDialog(null, ms);
}
else {
if(jRadioButton1.isSelected())
gender="Masculin";
else
gender="Féminin";
if(jRadioButton3.isSelected())
mutualiste = "Oui";
else
mutualiste = "Non";
sdb.AddPatient(jTextField6.getText().toString(), jTextField5.getText().toString(),
gender, jTextField4.getText().toString(), jTextField3.getText().toString(),
jTextField2.getText().toString(), mutualiste, jTextArea1.getText().toString());
String message = "Le produit a été ajouté à la base de données.";
JOptionPane.showMessageDialog(null, message);
sdb.CloseDB();
}
this.jTextArea1.setText(null);
this.jTextField3.setText(null);
this.jTextField4.setText(null);
this.jTextField6.setText(null);
this.jTextField5.setText(null);
this.jTextField2.setText(null);
}
public void jButton1_actionPerformed(ActionEvent actionEvent) {
this.setVisible(false);
Home layout2 = new Home();
layout2.setVisible(true);
}
}
class Ajouter_jButton1_actionAdapter implements ActionListener {
private Ajouter adaptee;
Ajouter_jButton1_actionAdapter(Ajouter adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jButton1_actionPerformed(actionEvent);
}
}
class Ajouter_jButton3_actionAdapter implements ActionListener {
private Ajouter adaptee;
Ajouter_jButton3_actionAdapter(Ajouter adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jButton3_actionPerformed(actionEvent);
}
}
class Ajouter_jButton2_actionAdapter implements ActionListener {
private Ajouter adaptee;
Ajouter_jButton2_actionAdapter(Ajouter adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jButton2_actionPerformed(actionEvent);
}
}
class Ajouter_jRadioButton1_actionAdapter implements ActionListener {
private Ajouter adaptee;
Ajouter_jRadioButton1_actionAdapter(Ajouter adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jRadioButton1_actionPerformed(actionEvent);
}
} |
Partager