-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHind.java
More file actions
765 lines (683 loc) · 16.3 KB
/
Hind.java
File metadata and controls
765 lines (683 loc) · 16.3 KB
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
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
import java.io.*;
import java.util.*;
import java.util.Date;
//import java.sql.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JScrollPane;
import java.sql.*;
class Hind extends JFrame implements ActionListener
{
JButton b2,b1;
JLabel j1;
Font f,ff;
Panel p1=new Panel();
Panel p2=new Panel();
Hind()
{
super("Autonomous Deep Bench");
setVisible(true);
setSize(1500,1500);
setLayout(new FlowLayout(FlowLayout.CENTER,400,200));
p1.setLayout(new FlowLayout(FlowLayout.CENTER));
p2.setLayout(new FlowLayout(FlowLayout.CENTER));
b1=new JButton("Register");
b2=new JButton("Login");
f=new Font("Comic Sans MS",Font.PLAIN,15);
ff=new Font("Comic Sans MS",Font.BOLD,30);
j1=new JLabel("Welcome to P.D. HINDUJA HOSPITAL & MEDICAL RESEARCH CENTRE");
j1.setFont(ff);
b2.setFont(f);
b1.setFont(f);
p1.add(j1);
p2.add(b1);
p2.add(b2);
add(p1);
add(p2);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(b1.equals(ae.getSource()))
{
new Reg();
setVisible(false);
}
else
{
new Login();
setVisible(false);
}
}
public static void main(String...a)
{
new Hind();
}
}
class Reg extends JFrame implements ActionListener
{
JLabel l1,l2;
JTextField t1;
JPasswordField ap2;
JButton b1;
Font f;
Panel p1=new Panel();
Panel p2=new Panel();
Panel p3=new Panel();
Reg()
{
setVisible(true);
setSize(1000,1000);
setLayout(new FlowLayout(FlowLayout.LEFT,500,50));
p1.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
p2.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
p3.setLayout(new FlowLayout(FlowLayout.LEFT,50,0));
l1=new JLabel("username");
l2=new JLabel("password");
t1=new JTextField(20);
ap2=new JPasswordField(20);
b1=new JButton("Register");
f=new Font("Comic Sans MS",Font.PLAIN,15);
l1.setFont(f);
l2.setFont(f);
t1.setFont(f);
b1.setFont(f);
p1.add(l1);
p1.add(t1);
add(p1);
p2.add(l2);
p2.add(ap2);
add(p2);
p3.add(b1);
add(p3);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(b1.equals(ae.getSource()))
{ try{
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Connection c=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
PreparedStatement p=c.prepareStatement("insert into used values(?,?)");
p.setString(1,t1.getText());
p.setString(2,ap2.getText());
int mn=p.executeUpdate();
if(mn==1)
JOptionPane.showMessageDialog(null,"Registered Successfully");
c.close();
p.close();
}catch(Exception e){}
new Hind();
setVisible(false);
}
}
}
class Login extends JFrame implements ActionListener
{
JLabel l1,l2;
JTextField t1;
JPasswordField ap2;
JButton b1,b2;
Font f;
Panel p1=new Panel();
Panel p2=new Panel();
Panel p3=new Panel();
Login()
{
setVisible(true);
setSize(1000,1000);
setLayout(new FlowLayout(FlowLayout.LEFT,500,50));
p1.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
p2.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
p3.setLayout(new FlowLayout(FlowLayout.LEFT,50,0));
l1=new JLabel("username");
l2=new JLabel("password");
t1=new JTextField(20);
ap2=new JPasswordField(20);
b1=new JButton("Login");
b2=new JButton("go to main menu");
f=new Font("Comic Sans MS",Font.PLAIN,15);
l1.setFont(f);
l2.setFont(f);
t1.setFont(f);
b2.setFont(f);
b1.setFont(f);
p1.add(l1);
p1.add(t1);
add(p1);
p2.add(l2);
p2.add(ap2);
add(p2);
p3.add(b1);
p3.add(b2);
add(p3);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{int u=1;
if(b1.equals(ae.getSource()))
{
if(t1.getText()==""||ap2.getText()=="")
{
JOptionPane.showMessageDialog(null,"fill the fields properly");
}
else{
try{
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Connection c=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
Statement s=c.createStatement();
ResultSet rs=s.executeQuery("select * from used");
while(rs.next())
{
if(rs.getString(1).equals(t1.getText())&&rs.getString(2).equals(ap2.getText()))
{
JOptionPane.showMessageDialog(null,"Logged in successfully");
Date dt=new Date();
new Register();
setVisible(false);
u=0;
break;
}
}
if(u==1)
{
JOptionPane.showMessageDialog(null,"Invalid Credentials");
}
c.close();
}catch(Exception e){}
}
}
else
{
new Hind();
setVisible(false);
}
}
}
class Register extends JFrame implements ActionListener
{
JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10;
JButton b1,b2,b3,b4;
JTextField t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
JRadioButton r1,r2;
ButtonGroup bg=new ButtonGroup();
Font f;
Panel p2=new Panel();
Panel p3=new Panel();
Panel p4=new Panel();
Panel p5=new Panel();
Panel p6=new Panel();
Panel p7=new Panel();
Panel p8=new Panel();
public Register()
{
setVisible(true);
setLayout(new FlowLayout(FlowLayout.CENTER,500,50));
setSize(1000,1000);
p5.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
p2.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
p3.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
p4.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
p6.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
p7.setLayout(new FlowLayout(FlowLayout.CENTER,20,15));
p8.setLayout(new FlowLayout(FlowLayout.CENTER,20,20));
r1=new JRadioButton("and");
r2=new JRadioButton("or");
bg.add(r1);
bg.add(r2);
l1=new JLabel("Student");
l2=new JLabel("Mail id");
l3=new JLabel("Mobile Number");
l4=new JLabel("Research Faculty");
l5=new JLabel("mail id");
l6=new JLabel("Mobile Number");
l7=new JLabel("Guide/Doctor");
l8=new JLabel("Mail id");
l9=new JLabel("Mobile Number");
l10=new JLabel("enter Search KeyWords");
t1=new JTextField(30);
t2=new JTextField(30);
t3=new JTextField(30);
t4=new JTextField(30);
t5=new JTextField(30);
t6=new JTextField(30);
t7=new JTextField(30);
t8=new JTextField(30);
t9=new JTextField(30);
t10=new JTextField("Enter keywords seperated with Comma(,)",40);
f=new Font("Comic Sans MS",Font.PLAIN,15);
b1=new JButton("Upload Profile");
b2=new JButton("Add another Student");
b3=new JButton("Search");
b4=new JButton("goto home page");
p2.add(l1);
p2.add(t1);
p2.add(l2);
p2.add(t2);
p2.add(l3);
p2.add(t3);
//member 2
p3.add(l4);
p3.add(t4);
p3.add(l5);
p3.add(t5);
p3.add(l6);
p3.add(t6);
// member 3
p4.add(l7);
p4.add(t7);
p4.add(l8);
p4.add(t8);
p4.add(l9);
p4.add(t9);
//search elements text field
p6.add(l10);
p6.add(t10);
//buttons
p7.add(r1);
p7.add(r2);
p5.add(b1);
p5.add(b2);
p5.add(b3);
p5.add(b4);
//panels
//add(p1);
add(p2);
add(p3);
add(p4);
add(p6);
add(p7);
add(p5);
//font styles for labels
l1.setFont(f);
l2.setFont(f);
l3.setFont(f);
l4.setFont(f);
l5.setFont(f);
l6.setFont(f);
l7.setFont(f);
l8.setFont(f);
l9.setFont(f);
l10.setFont(f);
//font styles for textfields
t1.setFont(f);
t2.setFont(f);
t3.setFont(f);
t4.setFont(f);
t5.setFont(f);
t6.setFont(f);
t7.setFont(f);
t8.setFont(f);
t9.setFont(f);
t10.setFont(f);
r1.setFont(f);
r2.setFont(f);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
//hidden text
t10.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) {
if(t10.getText().equals("Enter keywords seperated with Comma(,)"))
t10.setText("");
}
});
//names validation
t1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
if(!(Character.isLetter(evt.getKeyChar()))){
evt.consume();
}
}
});
t4.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
if(!(Character.isLetter(evt.getKeyChar()))){
evt.consume();
}
}
});
t7.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
if(!(Character.isLetter(evt.getKeyChar()))){
evt.consume();
}
}
});
//mobiles numbers validation
t3.addKeyListener(new KeyAdapter(){
public void keyTyped(KeyEvent e)
{
char input=e.getKeyChar();
if((input<'0'||input>'9')&&input!='\b')
{
e.consume();
}
}});
t6.addKeyListener(new KeyAdapter(){
public void keyTyped(KeyEvent e)
{
char input=e.getKeyChar();
if((input<'0'||input>'9')&&input!='\b')
{
e.consume();
}
}});
t9.addKeyListener(new KeyAdapter(){
public void keyTyped(KeyEvent e)
{
char input=e.getKeyChar();
if((input<'0'||input>'9')&&input!='\b')
{
e.consume();
}
}});
}
public void actionPerformed(ActionEvent ae)
{
try
{
if(b1.equals(ae.getSource()))//uplooad
{
if((t1.getText().equals(""))||t2.getText().equals("")||t3.getText().equals("")||t4.getText().equals("")||t5.getText().equals("")||t6.getText().equals("")||t7.getText().equals("")||t8.getText().equals("")||t9.getText().equals("")||t10.getText().equals("Enter keywords seperated with Comma(,)"))
{
JOptionPane.showMessageDialog(null,"please fill all details properly");
}
else
{
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Connection c=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
PreparedStatement p=c.prepareStatement("insert into reg values(?,?,?,?,?,?,?,?,?,?)");
p.setString(1,t1.getText());// name
p.setString(2,t2.getText());// mail id
p.setString(3,t3.getText());// mobile no
p.setString(4,t4.getText());// name
p.setString(5,t5.getText());// mail id
p.setString(6,t6.getText());// mobile no
p.setString(7,t7.getText());//name
p.setString(8,t8.getText());//mail id
p.setString(9,t9.getText());//mobile no
//p.setString(10,t10.getText());// key word
int tt=p.executeUpdate();
if(tt==1)
JOptionPane.showMessageDialog(null,"Registered Successfully");
c.close();
p.close();
}
}//b1 end if
else if(b2.equals(ae.getSource()))
{
new Adduser(t4.getText(),t5.getText(),t6.getText(),t7.getText(),t8.getText(),t9.getText());
setVisible(false);
}
else if(b3.equals(ae.getSource()))
{
if(t10.getText().equals("")||t10.getText().equals("Enter keywords seperated with Comma(,)"))
{
JOptionPane.showMessageDialog(null,"enter keyword");
}
else{
if((r1.isSelected())||r2.isSelected()){
try{
if(r1.isSelected()){
String ser="";int c=0;
Date d=new Date();
String datar[]= t10.getText().split(",");
File file = new File("D:\\folder\\pdf");
if(file!=null && file.exists())
{
File[] listOfFiles = file.listFiles();
if(listOfFiles!=null)
{
for (int i=0;i<listOfFiles.length;i++)
{
if (listOfFiles[i].isFile())
{
FileInputStream fis = new FileInputStream(listOfFiles[i]);
byte[] data = new byte[(int) file.length()];
fis.read(data);
fis.close();
String str = new String(data, "UTF-8");c=0;
for(int ii=0;ii<datar.length;ii++)
{
if((str.contains(datar[ii])))
{ c++;
}
}
String sl=listOfFiles[i].toString();
int l=sl.length()-3;
if(c==datar.length)
{
ser=ser+sl.substring(14,l)+"pdf"+"\n";
}
}
}
}
}
if(ser.equals(""))
ser="given keywords doesn't exist in any file";
new Ans(ser);
setVisible(false);
}
else
{
String ser="";int c=0;
Date d=new Date();
String datar[]= t10.getText().split(",");
File file = new File("D:\\folder\\pdf");
if(file!=null && file.exists())
{
File[] listOfFiles = file.listFiles();
if(listOfFiles!=null)
{
for (int i=0;i<listOfFiles.length;i++)
{
if (listOfFiles[i].isFile())
{
FileInputStream fis = new FileInputStream(listOfFiles[i]);
byte[] data = new byte[(int) file.length()];
fis.read(data);
fis.close();
String str = new String(data, "UTF-8");c=0;
for(int ii=0;ii<datar.length;ii++)
{
if((str.contains(datar[ii])))
{ c++;break;
}
}
String sl=listOfFiles[i].toString();
int l=sl.length()-3;
if(c!=0)
{
ser=ser+sl.substring(14,l)+"pdf"+"\n";
}
}
}
}
}
if(ser.equals(""))
ser="given keywords doesn't exist in any file";
new Ans(ser);
setVisible(false);
}
}
catch(Exception e)
{
System.out.println(e);
}
}else{JOptionPane.showMessageDialog(null,"please select an option");}
}}
else
{
new Hind();
setVisible(false);
}
}catch(Exception e){System.out.println(e);}
}
}
class Adduser extends JFrame implements ActionListener
{
JLabel l1,l2,l3,l4;
JTextField t1,t2,t3,t4;
JButton b1;
Font f;
Panel p1=new Panel();
Panel p2=new Panel();
Panel p3=new Panel();
Panel p4=new Panel();
String mname,mmailid,mmobile,rgname,rgmailid,rgmobile;
public Adduser(String s1,String s2,String s3,String s4,String s5,String s6)
{
mname=s1;
mmailid=s2;
mmobile=s3;
rgname=s4;
rgmailid=s5;
rgmobile=s6;
setVisible(true);
setLayout(new FlowLayout(FlowLayout.CENTER,500,100));
setSize(1000,1000);
p1.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
p2.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
p3.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
p4.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
l1=new JLabel("student name");
l2=new JLabel("mail id");
l3=new JLabel("mobile no");
l4=new JLabel("enter Search keywords");
t1=new JTextField(30);
t2=new JTextField(30);
t3=new JTextField(30);
t4=new JTextField("Enter atleast 5 words seperated with Comma(,)",40);
b1=new JButton("Add Student");
f=new Font("Comic Sans MS",Font.PLAIN,15);
l1.setFont(f);
l2.setFont(f);
l3.setFont(f);
t1.setFont(f);
t2.setFont(f);
t3.setFont(f);
b1.setFont(f);
p1.add(l1);
p1.add(t1);
p1.add(l2);
p1.add(t2);
p1.add(l3);
p1.add(t3);
p2.add(l1);
p2.add(t1);
p2.add(l2);
p2.add(t2);
p2.add(l3);
p2.add(t3);
p3.add(l4);
p3.add(t4);
p4.add(b1);
add(p1);
add(p2);
add(p3);
add(p4);
t1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
if(!(Character.isLetter(evt.getKeyChar()))){
evt.consume();
}
}
});
//mobiles numbers validation
t3.addKeyListener(new KeyAdapter(){
public void keyTyped(KeyEvent e)
{
char input=e.getKeyChar();
if((input<'0'||input>'9')&&input!='\b')
{
e.consume();
}
}});
t4.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) {
if(t4.getText().equals("Enter atleast 5 words seperated with Comma(,)"))
t4.setText("");
}
});
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
try
{
if(b1.equals(ae.getSource()))
{
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Connection c=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
PreparedStatement p=c.prepareStatement("insert into reg values(?,?,?,?,?,?,?,?,?,?)");
p.setString(1,t1.getText());
p.setString(2,t2.getText());
p.setString(3,t3.getText());
p.setString(4,mname);
p.setString(5,mmailid);
p.setString(6,mmobile);
p.setString(7,rgname);
p.setString(8,rgmailid);
p.setString(9,rgmobile);
p.setString(10,t4.getText());
int tt=p.executeUpdate();
if(tt==1)
JOptionPane.showMessageDialog(null,"Registered Successfully");
c.close();
p.close();
new Hind();
setVisible(false);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
class Ans extends JFrame
{
TextArea a;
JButton b1,b2;
JCheckBox c1,c2;
Font f;
JScrollPane scroll;
Panel p1=new Panel();
Panel p2=new Panel();
Panel p3=new Panel();
String mnop;
public Ans(String rev)
{
mnop=rev;
setVisible(true);
setLayout(new FlowLayout(FlowLayout.LEFT));
setSize(1000,1000);
p1.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
p2.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
p3.setLayout(new FlowLayout(FlowLayout.LEFT,10,0));
a=new TextArea(50,100);
JScrollPane scrollableTextArea = new JScrollPane(a);
b1=new JButton("send E-mail");
b2=new JButton("Log Report");
c1=new JCheckBox("subscribe for mail");
c2=new JCheckBox("unsubscribe for mail");
scrollableTextArea.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollableTextArea.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
a.setText(mnop);
a.setEditable(true);
p1.add(scrollableTextArea);
p2.add(b1);
p2.add(b2);
p3.add(c1);
p3.add(c2);
add(p1);
add(p2);
add(p3);
add(scroll);
}
}