-
Notifications
You must be signed in to change notification settings - Fork 0
/
Registration.java
335 lines (287 loc) · 14.3 KB
/
Registration.java
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package hospital.management.system;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import javax.swing.JOptionPane;
/**
*
* @author Mukuria
*/
public class Registration extends javax.swing.JFrame {
/**
* Creates new form Registration
*/
public Registration() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
REpassword = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
firstname = new javax.swing.JTextField();
IDNo = new javax.swing.JTextField();
Back = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
Password = new javax.swing.JLabel();
REpassword1 = new javax.swing.JLabel();
email = new javax.swing.JTextField();
phone = new javax.swing.JTextField();
surname = new javax.swing.JTextField();
jPanel4 = new javax.swing.JPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setAutoRequestFocus(false);
setBackground(new java.awt.Color(51, 0, 102));
setForeground(new java.awt.Color(51, 0, 102));
setMinimumSize(new java.awt.Dimension(1380, 800));
setPreferredSize(new java.awt.Dimension(1360, 800));
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jPanel1.setBackground(new java.awt.Color(51, 204, 0));
jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
jPanel1.setForeground(new java.awt.Color(51, 204, 0));
jPanel1.setPreferredSize(new java.awt.Dimension(1360, 700));
jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel1.setBackground(new java.awt.Color(242, 38, 19));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 153, 0));
jLabel1.setText("First name");
jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 70, -1, -1));
REpassword.setBackground(new java.awt.Color(242, 38, 19));
REpassword.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
REpassword.setForeground(new java.awt.Color(255, 153, 0));
REpassword.setText("Phone no");
jPanel1.add(REpassword, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 460, -1, -1));
jLabel4.setBackground(new java.awt.Color(242, 38, 19));
jLabel4.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
jLabel4.setForeground(new java.awt.Color(255, 153, 0));
jLabel4.setText("Surname");
jPanel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 170, -1, 40));
firstname.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
firstname.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
firstnameActionPerformed(evt);
}
});
jPanel1.add(firstname, new org.netbeans.lib.awtextra.AbsoluteConstraints(740, 70, 192, -1));
IDNo.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
IDNo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
IDNoActionPerformed(evt);
}
});
jPanel1.add(IDNo, new org.netbeans.lib.awtextra.AbsoluteConstraints(740, 250, 192, -1));
Back.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
Back.setForeground(new java.awt.Color(51, 0, 255));
Back.setText("Back");
Back.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
BackActionPerformed(evt);
}
});
jPanel1.add(Back, new org.netbeans.lib.awtextra.AbsoluteConstraints(860, 550, -1, 50));
jButton2.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jButton2.setForeground(new java.awt.Color(51, 0, 255));
jButton2.setText("Register");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jPanel1.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 550, -1, 50));
jButton3.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jButton3.setForeground(new java.awt.Color(51, 0, 255));
jButton3.setText("Cancel");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jPanel1.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(620, 550, -1, 50));
Password.setBackground(new java.awt.Color(242, 38, 19));
Password.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
Password.setForeground(new java.awt.Color(255, 153, 0));
Password.setText("IDNo");
jPanel1.add(Password, new org.netbeans.lib.awtextra.AbsoluteConstraints(490, 260, -1, -1));
REpassword1.setBackground(new java.awt.Color(242, 38, 19));
REpassword1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
REpassword1.setForeground(new java.awt.Color(255, 153, 0));
REpassword1.setText("Email");
jPanel1.add(REpassword1, new org.netbeans.lib.awtextra.AbsoluteConstraints(490, 350, -1, -1));
email.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
email.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
emailActionPerformed(evt);
}
});
jPanel1.add(email, new org.netbeans.lib.awtextra.AbsoluteConstraints(740, 350, 192, -1));
phone.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
phone.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
phoneActionPerformed(evt);
}
});
jPanel1.add(phone, new org.netbeans.lib.awtextra.AbsoluteConstraints(740, 450, 192, -1));
surname.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
surname.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
surnameActionPerformed(evt);
}
});
jPanel1.add(surname, new org.netbeans.lib.awtextra.AbsoluteConstraints(740, 170, 192, -1));
getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 60, 1380, 710));
jPanel4.setBackground(new java.awt.Color(255, 204, 102));
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "KIM'S HEALTH CENTER", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Tahoma", 1, 48), new java.awt.Color(102, 102, 0))); // NOI18N
jPanel4.setPreferredSize(new java.awt.Dimension(1360, 100));
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 1348, Short.MAX_VALUE)
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
getContentPane().add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, 60));
pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
private void firstnameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_firstnameActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_firstnameActionPerformed
private void BackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BackActionPerformed
// TODO add your handling code here:
setVisible(false);
Home ob=new Home();
ob.setVisible(true);
}//GEN-LAST:event_BackActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
String Firstname=firstname.getText();
String Surname=surname.getText();
String IDNO=IDNo.getText();
String Email=email.getText();
String Phone=phone.getText();
if(Firstname.equals(""))
{
JOptionPane.showMessageDialog(null,"Enter Firstname!");
}
else if(Surname.equals(""))
{
JOptionPane.showMessageDialog(null,"Enter a Surname!");
}
else if(IDNO.equals(""))
{
JOptionPane.showMessageDialog(null,"Enter Your Id number!");
}
else if(Phone.equals(""))
{
JOptionPane.showMessageDialog(null," Enter Your Phone number!");
}
else
{
try
{
Class.forName("com.mysql.jdbc.Driver");
String path= "jdbc:mysql://localhost/Hospital";
String user="root";
String pass="";
Connection conn=DriverManager.getConnection(path,user,pass);
Statement St=conn.createStatement();
String query = "INSERT INTO `patient` (`Firstname`, `Surname`, `IDNo`, `email`, `Phone_No`) VALUES ('"+Firstname+"','"+Surname+"','"+IDNO+"','"+Email+"','"+Phone+"')";
St.executeUpdate(query);
JOptionPane.showMessageDialog(null,"Record saved successfully");
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"Error In Connection!");
}
}
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
// setVisible(false);
//Registration ob=new Registration();
//ob.setVisible(true);
firstname.setText(null);
IDNo.setText(null);
IDNo.setText(null);
phone.setText(null);
}//GEN-LAST:event_jButton3ActionPerformed
private void IDNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IDNoActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_IDNoActionPerformed
private void emailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emailActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_emailActionPerformed
private void phoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_phoneActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_phoneActionPerformed
private void surnameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_surnameActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_surnameActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Registration.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Registration.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Registration.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Registration.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Registration().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton Back;
private javax.swing.JTextField IDNo;
private javax.swing.JLabel Password;
private javax.swing.JLabel REpassword;
private javax.swing.JLabel REpassword1;
private javax.swing.JTextField email;
private javax.swing.JTextField firstname;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel4;
private javax.swing.JTextField phone;
private javax.swing.JTextField surname;
// End of variables declaration//GEN-END:variables
}