-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathk_EmergencyPage.java
483 lines (466 loc) · 21.4 KB
/
k_EmergencyPage.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
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
package finalproject;
import com.github.lgooddatepicker.components.DatePicker;
import com.github.lgooddatepicker.optionalusertools.DateChangeListener;
import com.github.lgooddatepicker.zinternaltools.DateChangeEvent;
import finalproject.z_Emailvalidator;
import static com.sun.org.apache.xalan.internal.lib.ExsltDatetime.date;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.time.LocalDate;
import java.util.Date;
import javax.swing.*;
public class k_EmergencyPage extends JFrame implements ActionListener{
private Container container = getContentPane();
private JPanel headerPanel = new JPanel();
private JLabel headerTitleLabel = new JLabel(" BOOTCAMP E-PASS");
private JPanel mainPanel = new JPanel();
private JPanel bodyPanel = new JPanel();
private JButton nextButton = new JButton("Continue");
private JButton backButton = new JButton("Back");
String states[]={"Tamil Nadu"};
String districts[]={"Ariyalur","Chengalpattu","Chennai","Coimbatore","Cuddalore","Dharmapuri","Dindigul","Erode",
"Kallakurichi","Kanchipuram","Kanyakumari","Karur","Krishnagiri","Madurai","Nagapattinam","Namakkal" ,
"Nilgiris","Perambalur","Pudukkottai","Ramanathapuram","Ranipet","Salem","Sivaganga","Tenkasi",
"Thanjavur","Theni","Thoothukudi","Tiruchirappalli","Tirunelveli","Tirupathur","Tiruppur","Tiruvallur",
"Tiruvannamalai","Tiruvarur","Vellore","Viluppuram","Virudhunagar"};
String vehicleType[] ={"Two Wheeler", "Four Wheeler", "Cab/Auto", "Truck/Lory/Goods","Railways","Without Vehicle"};
String purpose[]={"First Relative Death","Medical Emergency","Occasion/Wedding"};
private JScrollPane scrollable;
private JLabel passTitleLabel = new JLabel(" Emergency E-Pass Registration");
private JLabel subTitleLabel = new JLabel("Valid for 1 day");
private JLabel nativeLabel = new JLabel("State");
private JComboBox nativeComboBox =new JComboBox(states);
private JLabel nameLabel = new JLabel("Name");
private JTextField nameTextField = new JTextField();
private JLabel fromDateLabel = new JLabel("From date");
private JLabel toDateLabel = new JLabel("To date");
private JLabel purposeLabel = new JLabel("Purpose");
private JComboBox purposeComboBox = new JComboBox(purpose);
private JLabel startLocLabel = new JLabel("Travelling from");
private JComboBox startLocComboBox = new JComboBox(districts);
private JLabel endLocLabel = new JLabel("Travelling to");
private JComboBox endLocComboBox = new JComboBox(districts);
private JLabel vehicleTypeLabel = new JLabel("Vehicle type");
private JComboBox vehicleTypeComboBox = new JComboBox(vehicleType);
private JLabel vehicleNoLabel = new JLabel("Vehicle number");
private JTextField vehicleNoTextField= new JTextField();
private JLabel mobileNoLabel = new JLabel("Mobile number");
private JTextField mobileNoTextField= new JTextField();
private JLabel emailLabel = new JLabel("Email");
private JTextField emailTextField= new JTextField();
private JLabel addressLabel = new JLabel("Address");
private JTextField addressTextField= new JTextField();
private JLabel contaminatedLabel = new JLabel("Are you from contaminated zone?");
private JLabel routeLabel = new JLabel("Are you planning to return via same route?");
private JTextArea captureTextArea = new JTextArea("I allow the access to a webcam to capture a photograph");
private JTextArea agreementTextArea = new JTextArea("I assure that the above provided details are true to my knowledge");
private JCheckBox agreementCheckBox = new JCheckBox(" Accept");
private JLabel messageLabel=new JLabel();
private ButtonGroup bgSet1 = new ButtonGroup();
private ButtonGroup bgSet2 = new ButtonGroup();
private JRadioButton yesButton = new JRadioButton("Yes");
private JRadioButton noButton = new JRadioButton("No");
private JRadioButton yessButton = new JRadioButton("Yes");
private JRadioButton nooButton = new JRadioButton("No");
private DatePicker fromDatePicker=new DatePicker();
private DatePicker toDatePicker=new DatePicker();
k_EmergencyPage(){
setLayoutManager();
setHeaderPanel();
setMainPanel();
setBodyPanel();
setPassLabel();
setRadioButton();
setLocationAndSize();
setFontAndColor();
setBackButton();
setFrame();
setButtonAction();
}
private void setLayoutManager(){
container.setBackground(Color.WHITE);
container.setLayout(null);
}
private void setHeaderPanel(){
headerPanel.setBackground(new Color(251,5,37));
headerPanel.setLayout(new GridLayout(1,1,0,0));
ImageIcon iconLogo = new ImageIcon(new ImageIcon("C:\\Users\\Admin\\Desktop\\icon.png").getImage().getScaledInstance(75,75, Image.SCALE_SMOOTH));
headerTitleLabel.setIcon(iconLogo);
headerTitleLabel.setFont(new Font("Roboto", Font.BOLD,26));
headerTitleLabel.setForeground(Color.white);
headerPanel.add(headerTitleLabel);
}
private void setMainPanel(){
mainPanel.setBackground(Color.WHITE);
mainPanel.setLayout(null);
}
private void setPassLabel(){
passTitleLabel.setFont(new Font("Roboto", Font.BOLD,23));
passTitleLabel.setBounds(0,15,840,30);
passTitleLabel.setHorizontalAlignment(JLabel.CENTER);
subTitleLabel.setFont(new Font("Roboto", Font.BOLD,14));
subTitleLabel.setBounds(0,45,840,30);
subTitleLabel.setHorizontalAlignment(JLabel.CENTER);
subTitleLabel.setForeground(new Color(51, 69, 187));
mainPanel.add(subTitleLabel);
mainPanel.add(passTitleLabel);
}
private void setBodyPanel(){
nativeLabel.setBounds(58,20,250,40);
nativeComboBox.setBounds(58,61,250,40);
nameLabel.setBounds(350,20,250,40);
nameTextField.setBounds(350,61,250,40);
fromDateLabel.setBounds(58,111,250,40);
fromDatePicker.setBounds(58,154,250,40);
toDateLabel.setBounds(350,111,250,40);
toDatePicker.setBounds(350,154,250,40);
purposeLabel.setBounds(58,202,250,40);
purposeComboBox.setBounds(58,245,540,40);
startLocLabel.setBounds(58,295,250,40);
startLocComboBox.setBounds(58,338,250,40);
endLocLabel.setBounds(350,295,250,40);
endLocComboBox.setBounds(350,338,250,40);
vehicleTypeLabel.setBounds(58,388,250,40);
vehicleTypeComboBox.setBounds(58,431,250,40);
vehicleNoLabel.setBounds(350,388,250,40);
vehicleNoTextField.setBounds(350,431,250,40);
mobileNoLabel.setBounds(58,481,250,40);
mobileNoTextField.setBounds(58,524,250,40);
emailLabel.setBounds(350,481,250,40);
emailTextField.setBounds(350,524,250,40);
addressLabel.setBounds(58,574,250,40);
addressTextField.setBounds(58,617,540,40);
contaminatedLabel.setBounds(58, 670, 400, 40);
yesButton.setBounds(365, 670, 70, 40);
noButton.setBounds(440, 670, 70, 40);
routeLabel.setBounds(58, 707, 400, 40);
yessButton.setBounds(445, 707, 70, 40);
nooButton.setBounds(520, 707, 70, 40);
captureTextArea.setBounds(58, 787, 540,60);
agreementTextArea.setBounds(58, 827, 540,60);
agreementCheckBox.setBounds(284, 873, 540,40);
messageLabel.setBounds(0,920,650,40);
messageLabel.setHorizontalAlignment(JLabel.CENTER);
nextButton.setBounds(355,453,145, 42);
fromDatePicker.setDate( LocalDate.now());
bodyPanel.add(nativeLabel);
bodyPanel.add(nativeComboBox);
bodyPanel.add(nameLabel);
bodyPanel.add(nameTextField);
bodyPanel.add(fromDateLabel);
bodyPanel.add(fromDatePicker);
bodyPanel.add(toDateLabel);
bodyPanel.add(toDatePicker);
bodyPanel.add(purposeLabel);
bodyPanel.add(purposeComboBox);
bodyPanel.add(startLocLabel);
bodyPanel.add(startLocComboBox);
bodyPanel.add(endLocLabel);
bodyPanel.add(endLocComboBox);
bodyPanel.add(vehicleTypeLabel);
bodyPanel.add(vehicleTypeComboBox);
bodyPanel.add(vehicleNoLabel);
bodyPanel.add(vehicleNoTextField);
bodyPanel.add(mobileNoLabel);
bodyPanel.add(mobileNoTextField);
bodyPanel.add(emailLabel);
bodyPanel.add(emailTextField);
bodyPanel.add(addressLabel);
bodyPanel.add(addressTextField);
bodyPanel.add(contaminatedLabel);
bodyPanel.add(yesButton);
bodyPanel.add(noButton);
bodyPanel.add(routeLabel);
bodyPanel.add(yessButton);
bodyPanel.add(nooButton);
bodyPanel.add(captureTextArea);
bodyPanel.add(agreementTextArea);
bodyPanel.add(agreementCheckBox);
bodyPanel.add(messageLabel);
bodyPanel.setLayout(null);
scrollable= new JScrollPane(bodyPanel);
scrollable.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollable.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollable.setBounds(96,80,673,360);
bodyPanel.setPreferredSize(new Dimension(760,995));
mainPanel.add(nextButton);
mainPanel.add(scrollable);
toDatePicker.setEnabled(false);
vehicleTypeComboBox.addItemListener(new ItemListener(){
@Override
public void itemStateChanged(ItemEvent e) {
if(vehicleTypeComboBox.getSelectedIndex()==5 || vehicleTypeComboBox.getSelectedIndex()==4)
{
vehicleNoTextField.setEnabled(false);
}
else{
vehicleNoTextField.setEnabled(true);
}
}
});
fromDatePicker.addDateChangeListener((DateChangeEvent event) -> {
LocalDate date= fromDatePicker.getDate();
toDatePicker.setDate(date.plusDays((long)1));
});
}
public void setRadioButton(){
bgSet1.add(yesButton);
bgSet1.add(noButton);
bgSet2.add(yessButton);
bgSet2.add(nooButton);
}
private void setFontAndColor(){
nativeLabel.setFont(new Font("Roboto", Font.BOLD,18));
nativeComboBox.setFont(new Font("Roboto", Font.PLAIN,18));
nameLabel.setFont(new Font("Roboto", Font.BOLD,18));
nameTextField.setFont(new Font("Roboto", Font.PLAIN,18));
fromDateLabel.setFont(new Font("Roboto", Font.BOLD,18));
toDateLabel.setFont(new Font("Roboto", Font.BOLD,18));
//toDatePicker.setFont(new Font("Roboto", Font.PLAIN,18));
purposeLabel.setFont(new Font("Roboto", Font.BOLD,18));
purposeComboBox.setFont(new Font("Roboto", Font.PLAIN,18));
startLocLabel.setFont(new Font("Roboto", Font.BOLD,18));
startLocComboBox.setFont(new Font("Roboto", Font.PLAIN,18));
endLocLabel.setFont(new Font("Roboto", Font.BOLD,18));
endLocComboBox.setFont(new Font("Roboto", Font.PLAIN,18));
vehicleTypeLabel.setFont(new Font("Roboto", Font.BOLD,18));
vehicleTypeComboBox.setFont(new Font("Roboto", Font.PLAIN,18));
vehicleNoLabel.setFont(new Font("Roboto", Font.BOLD,18));
vehicleNoTextField.setFont(new Font("Roboto", Font.PLAIN,18));
mobileNoLabel.setFont(new Font("Roboto", Font.BOLD,18));
mobileNoTextField.setFont(new Font("Roboto", Font.PLAIN,18));
emailLabel.setFont(new Font("Roboto", Font.BOLD,18));
emailTextField.setFont(new Font("Roboto", Font.PLAIN,18));
addressLabel.setFont(new Font("Roboto", Font.BOLD,18));
addressTextField.setFont(new Font("Roboto", Font.PLAIN,18));
contaminatedLabel.setFont(new Font("Roboto", Font.BOLD,18));
yesButton.setFont(new Font("Roboto", Font.PLAIN,18));
noButton.setFont(new Font("Roboto", Font.PLAIN,18));
routeLabel.setFont(new Font("Roboto", Font.BOLD,18));
yessButton.setFont(new Font("Roboto", Font.PLAIN,18));
nooButton.setFont(new Font("Roboto", Font.PLAIN,18));
captureTextArea.setFont(new Font("Roboto", Font.BOLD,18));
agreementTextArea.setFont(new Font("Roboto", Font.BOLD,18));
agreementCheckBox.setFont(new Font("Roboto", Font.BOLD,18));
messageLabel.setFont(new Font("Roboto",Font.BOLD,18));
messageLabel.setForeground(new Color(51, 69, 187));
captureTextArea.setLineWrap(true);
captureTextArea.setEditable(false);
captureTextArea.setOpaque(false);
agreementTextArea.setLineWrap(true);
agreementTextArea.setEditable(false);
agreementTextArea.setOpaque(false);
purposeComboBox.setEditable(false);
nativeComboBox.setEditable(false);
startLocComboBox.setEditable(false);
endLocComboBox.setEditable(false);
vehicleTypeComboBox.setEditable(false);
purposeComboBox.setBackground(Color.WHITE);
nativeComboBox.setBackground(Color.WHITE);
startLocComboBox.setBackground(Color.WHITE);
endLocComboBox.setBackground(Color.WHITE);
vehicleTypeComboBox.setBackground(Color.WHITE);
captureTextArea.setForeground(new Color(251,5,37));
agreementTextArea.setForeground(new Color(251,5,37));
nextButton.setFont(new Font("Roboto", Font.BOLD,21));
nextButton.setBackground(new Color(113,113,113));
nextButton.setForeground(Color.white);
}
private void setLocationAndSize(){
headerPanel.setBounds(0, 0, 870, 70);
mainPanel.setBounds(0,70,847,510);
bodyPanel.setBounds(96,80,810,360);
}
private void setBackButton(){
backButton.setFont(new Font("Roboto", Font.BOLD,17));
backButton.setBounds(10,532,90,40);
backButton.setBackground(Color.BLACK);
backButton.setForeground(Color.WHITE);
container.add(backButton);
}
private void setButtonAction()
{
nextButton.addActionListener((e) ->
{ String state=(String) nativeComboBox.getItemAt(nativeComboBox.getSelectedIndex());
String name=nameTextField.getText();
LocalDate fromdate= fromDatePicker.getDate();
LocalDate todate= toDatePicker.getDate();
String purpose=(String)purposeComboBox.getItemAt(purposeComboBox.getSelectedIndex());
String travellingfrom=(String)startLocComboBox.getItemAt(startLocComboBox.getSelectedIndex());
String travellingto=(String)endLocComboBox.getItemAt(endLocComboBox.getSelectedIndex());
String vehicletype=(String)vehicleTypeComboBox.getItemAt(vehicleTypeComboBox.getSelectedIndex());
String vehiclenumber=vehicleNoTextField.getText();
String mobilenumber=mobileNoTextField.getText();
String email=emailTextField.getText();
String address=addressTextField.getText();
String zone="";
int f=0;
String d="";
if(name.equals(d))
{ messageLabel.setText("Enter the name");
f=1;
}
if(purpose.equals(d)&& f!=1)
{ messageLabel.setText("Enter the Purpose");
f=1;
}
if(vehiclenumber.equals(d)&& f!=1)
{ messageLabel.setText("Enter the vechiclenumber");
f=1;
}
if(mobilenumber.equals(d)&& f!=1)
{ messageLabel.setText("Enter the mobilenumber");
f=1;
}
if(!(mobilenumber.length()==10)&& f!=1)
{ messageLabel.setText("Enter the correct mobilenumber");
f=1;
}
if(email.equals(d)&& f!=1)
{ messageLabel.setText("Enter the email");
f=1;
}
z_Emailvalidator emailvalid=new z_Emailvalidator();
if(!emailvalid.validate(email)&&f!=1)
{ messageLabel.setText("Enter a valid Mail");
f=1;
}
if(address.equals(d)&& f!=1)
{ messageLabel.setText("Enter the address");
f=1;
}
int a=0;
if(yesButton.isSelected()&& f!=1)
{ zone="yes";
a=1;
}
if(noButton.isSelected()&& f!=1)
{ zone="no";
a=1;
}
String contaminatedzone = zone;
int b=0;
String route="";
if(yessButton.isSelected()&& f!=1)
{ route="yes";
b=1;
}
if(nooButton.isSelected()&& f!=1)
{ route="no";
b=1;
}
String returnviasameroute = route;
if(a==0&& f!=1)
{ messageLabel.setText("select the contaminatedzone");
f=1;
}
if(b==0&& f!=1)
{ messageLabel.setText("select the returnviasameroute");
f=1;
}
if(agreementCheckBox.isSelected() && f==0&& a==1 && b==1)
{
int id=1000;
try
{Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/project","root0","root");
//Connection con=DriverManager.getConnection("jdbc:sqlite:D:\\sqllitedb\\project.db");
Statement st=con.createStatement();
con.setAutoCommit(true);
String query1="select * from interstatepagetable";
ResultSet r1= st.executeQuery(query1);
while(r1.next())
{ String str=r1.getString("id");
int n=Integer.parseInt(str.substring(2,str.length()));
if(n>id)
{id=n;
}
}
String query2="select * from withinstatepagetable";
ResultSet r2= st.executeQuery(query2);
while(r2.next())
{ String str=r2.getString("id");
int n=Integer.parseInt(str.substring(2,str.length()));
if(n>id)
{id=n;
}
}
String query3="select * from emergencypagetable";
ResultSet r3 = st.executeQuery(query3);
while(r3.next())
{ String str=r3.getString("id");
int n=Integer.parseInt(str.substring(2,str.length()));
if(n>id)
{id=n;
}
}
String query4="select * from OrganisationalPage";
ResultSet r4= st.executeQuery(query4);
while(r4.next())
{ String str=r4.getString("id");
int n=Integer.parseInt(str.substring(2,str.length()));
if(n>id)
{id=n;
}
}
id++;
con.close();
new m_WebCam();
}
catch(Exception e3)
{System.out.print("ee"+e3);}
String status="pending";
String photopath="";
try
{ Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/project","root0","root");
//Connection con=DriverManager.getConnection("jdbc:sqlite:D:\\sqllitedb\\project.db");
Statement sta=con.createStatement();
String qu="insert into emergencypagetable values('"
+"EM"+id+"','"+state+"','"+name+"','"
+fromdate+"'"+ ",'"+todate+"',"
+ "'"+purpose+"','"+travellingfrom+"'"
+ ",'"+travellingto+"','"+vehicletype+"'"
+ ",'"+vehiclenumber+"','"+mobilenumber+"'"
+ ",'"+email+"','"+address+"',"
+ "'"+contaminatedzone+"','"+returnviasameroute+"','"
+status+"','"+photopath+"')";
sta.executeUpdate(qu);
con.close();
new m_WebCam();
}
catch (Exception ex)
{System.out.println("fail"+ex);
}
}
if(!(agreementCheckBox.isSelected()) && f==0&& a==1 && b==1)
{ messageLabel.setText("Please click the accept button to move to the next step");
}
});
backButton.addActionListener((e) -> {
this.toBack();
});
}
private void setFrame(){
Image icon = Toolkit.getDefaultToolkit().getImage("C:\\Users\\Admin\\Desktop\\icon.png");
container.add(headerPanel);
container.add(mainPanel);
setIconImage(icon);
setSize(870, 610);
setLocationRelativeTo(null);
setTitle("Emergency EPass");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}