-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFirstPage.java
More file actions
197 lines (149 loc) · 4.9 KB
/
FirstPage.java
File metadata and controls
197 lines (149 loc) · 4.9 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
package bootathonfinal;
import java.awt.Color;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.*;
import javax.swing.*;
import javax.swing.plaf.ColorUIResource;
import java.util.*;
public class FirstPage {
public static String tabelname;
static String hid="";
static String hname="";
static String hno="";
static String address="";
public static void main(String[] args) {
JFrame f1 = ObjectFile.getFrame("First Page");
JPanel panel = ObjectFile.getpanel();
f1.add(panel);
// care+ label
JLabel l1 = new JLabel("Care+ Community Hospital portal");
l1.setBounds(400, 30, 500, 50);
l1.setForeground(Color.decode("#5424BA"));
l1.setFont(new Font("Times New Roman",Font.PLAIN,34));
f1.add(l1);
// Sign in label
JLabel l2 = new JLabel("Sign in");
l2.setBounds(590, 120, 500, 50);
//l1.setForeground(Color.decode("#5424BA"));
l2.setFont(new Font("Times New Roman",Font.PLAIN,34));
f1.add(l2);
// uuid label
JLabel l3 = new JLabel("UUID");
l3.setBounds(400, 220, 500, 50);
//l1.setForeground(Color.decode("#5424BA"));
l3.setFont(new Font("Times New Roman",Font.PLAIN,24));
f1.add(l3);
//uuid TextField
JTextField t1 = new JTextField();
t1.setBounds(500, 230, 300, 40);
f1.add(t1);
// password label
JLabel l4 = new JLabel("Password");
l4.setBounds(400,300, 500, 50);
//l1.setForeground(Color.decode("#5424BA"));
l4.setFont(new Font("Times New Roman",Font.PLAIN,24));
f1.add(l4);
//password TextField
JPasswordField t2 = new JPasswordField();
t2.setBounds(500, 310, 300, 40);
f1.add(t2);
//Button
JButton login = ObjectFile.getButton("Login");
login.setBounds(650, 400, 150, 50);
f1.add(login);
//forget
JLabel forget = new JLabel("Forget Password ?");
forget.setBounds(450,400, 500, 50);
forget.setForeground(Color.decode("#5424BA"));
forget.setFont(new Font("Times New Roman",Font.PLAIN,24));
f1.add(forget);
forget.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
new ForgotPassword();
}
} );
//not register
JLabel not_register = new JLabel("Not Registered");
not_register.setBounds(480,500, 500, 50);
not_register.setFont(new Font("Times New Roman",Font.PLAIN,24));
f1.add(not_register);
//register Here
JLabel register_here = new JLabel("Register Here");
register_here.setForeground(Color.decode("#5424BA"));
register_here.setBounds(650,500, 500, 50);
register_here.setFont(new Font("Times New Roman",Font.PLAIN,24));
f1.add(register_here);
//Action listener
login.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//Login part
String s1=new String(t2.getPassword());
String s2=pass(t1.getText());
boolean status = ObjectFile.password_regex(s2);
System.out.println(s1+" "+s2);
if( !s1.isEmpty() && !t1.getText().isEmpty() &&s1.equals(s2))
{
Connection con=ObjectFile.getjdbc();
try {
Statement st=con.createStatement();
String query="select * from Hospital where Hospital_id='"+t1.getText()+"'";
ResultSet rs= st.executeQuery(query);
while(rs.next())
{
hid=rs.getString("Hospital_id");
hname=rs.getString("Hospital_name");
hno=rs.getString("Hospital_phonenumber");
address=rs.getString("Hospital_Address");
break;
}
new Hospital(hname);
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
else
{
JOptionPane.showMessageDialog(null, "Enter valid Hospital id and Password");
}
}
});
// register listener
register_here.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent e) {
UUID uuid=UUID.randomUUID();
String u =String.valueOf(uuid);
String unique = u.substring(9,13);
FirstPage.tabelname = unique;
System.out.println(unique);
System.out.println(tabelname);
Register r1 = new Register(unique);
}
});
}
private static String pass(String id)
{
String db="";
Connection con=ObjectFile.getjdbc();
try {
Statement st=con.createStatement();
String query="select Hospital_password from Hospital where Hospital_id='"+id+"'";
ResultSet rs= st.executeQuery(query);
while(rs.next())
{
db=rs.getString("Hospital_password");
break;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return Password.decrypt_password(db);
}
}