-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLog.java
306 lines (249 loc) · 9.19 KB
/
Log.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
package summm;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Color;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.UIManager;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Cursor;
import java.awt.SystemColor;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.BevelBorder;
import javax.swing.SwingConstants;
import java.awt.event.MouseMotionAdapter;
public class Log extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
public static JTextField name;
public static JTextField id;
int xmouse;
int ymouse;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Log frame = new Log();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Log() {
this.setLocationRelativeTo(null);
setUndecorated(true);
setBounds(100, 100, 553, 366);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
setLocationRelativeTo(null);
JPanel panel = new JPanel();
panel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
xmouse=arg0.getXOnScreen();
ymouse=arg0.getYOnScreen();
}
});
panel.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(MouseEvent evt) {
int x=evt.getXOnScreen();
int y=evt.getYOnScreen();
setLocation(x-xmouse,y-ymouse);
}
});
panel.setBorder(new CompoundBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null), null));
panel.setForeground(UIManager.getColor("Button.disabledShadow"));
panel.setBackground(SystemColor.controlShadow);
panel.setBounds(0, 0, 553, 61);
contentPane.add(panel);
panel.setLayout(null);
JLabel lblclose = new JLabel("X");
lblclose.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
lblclose.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
int a=JOptionPane.showConfirmDialog(null, "Are you sure to quit?");
if(a==JOptionPane.YES_OPTION){
dispose();
}
}
});
lblclose.setForeground(Color.WHITE);
lblclose.setFont(new Font("Tahoma", Font.BOLD, 18));
lblclose.setBounds(485, 19, 46, 19);
panel.add(lblclose);
JLabel lblmin = new JLabel("-");
lblmin.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
lblmin.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
setState(JFrame.ICONIFIED);
}
// TODO Auto-generated method stub
});
lblmin.setForeground(Color.WHITE);
lblmin.setFont(new Font("Tahoma", Font.BOLD, 20));
lblmin.setBounds(451, 6, 24, 44);
panel.add(lblmin);
JLabel lblBreakReminder = new JLabel("Break Reminder");
lblBreakReminder.setBackground(SystemColor.activeCaptionBorder);
lblBreakReminder.setForeground(SystemColor.inactiveCaptionBorder);
lblBreakReminder.setFont(new Font("Tahoma", Font.BOLD, 21));
lblBreakReminder.setBounds(25, 11, 183, 44);
panel.add(lblBreakReminder);
JPanel panel_1 = new JPanel();
panel_1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
panel_1.setBackground(new Color(0, 102, 153));
panel_1.setBounds(0, 60, 553, 325);
contentPane.add(panel_1);
panel_1.setLayout(null);
name = new JTextField();
name.setBounds(279, 97, 165, 32);
name.setFont(new Font("Tahoma",Font.PLAIN,14));
panel_1.add(name);
name.setColumns(10);
JLabel lblUsername = new JLabel(" Name :\r\n\r\n");
lblUsername.setFont(new Font("Tahoma", Font.BOLD, 18));
lblUsername.setForeground(Color.WHITE);
lblUsername.setBounds(156, 91, 154, 40);
panel_1.add(lblUsername);
id = new JTextField();
id.setBounds(279, 160, 165, 32);
id.setFont(new Font("Tahoma",Font.PLAIN,14));
panel_1.add(id);
id.setColumns(10);
JLabel lblEmplloyeeid = new JLabel("Email-id :");
lblEmplloyeeid.setForeground(Color.WHITE);
lblEmplloyeeid.setFont(new Font("Tahoma", Font.BOLD, 18));
lblEmplloyeeid.setBounds(177, 154, 142, 40);
panel_1.add(lblEmplloyeeid);
JButton btnSubmit = new JButton("Login");
btnSubmit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String Name = name.getText();
String Email = id.getText();
try {
Connection connection = (Connection) DriverManager.getConnection("jdbc:mysql://127.0.0.1:3307/login?serverTimezone=UTC", "root", "");
PreparedStatement st = (PreparedStatement) connection
.prepareStatement("Select Name, Email from register where Name=? and Email=?");
st.setString(1, Name);
st.setString(2, Email);
ResultSet rs = st.executeQuery();
if (rs.next()) {
dispose();
UserHom obj=new UserHom();
obj.setVisible(true);
obj.setLocationRelativeTo(null);
UserHom.namee.setText(Log.name.getText());
UserHom.idd.setText(Log.id.getText());
JOptionPane.showMessageDialog(btnSubmit, "You have successfully logged in");
String sql="insert into userlogin values (?, ?,?,?)";
PreparedStatement pst=connection.prepareStatement(sql);
java.util.Date date=new java.util.Date();
java.sql.Date sqlDate=new java.sql.Date(date.getTime());
java.sql.Timestamp sqlTime=new java.sql.Timestamp(date.getTime());
pst.setString(1,name.getText());
pst.setString(2, id.getText());
pst.setDate(3,sqlDate);
pst.setTimestamp(4,sqlTime);
pst.executeUpdate();
}
else if(name.getText().trim().isEmpty()||
id.getText().trim().isEmpty()){
JOptionPane.showMessageDialog(btnSubmit, "All fields are required");
}
else
{
JOptionPane.showMessageDialog(btnSubmit, "invalid Name or Email-id");
}
} catch (SQLException sqlException) {
sqlException.printStackTrace();
}
}
});
btnSubmit.setForeground(Color.WHITE);
btnSubmit.setBackground(SystemColor.textHighlight);
btnSubmit.setFont(new Font("Tahoma", Font.BOLD, 15));
btnSubmit.setBounds(283, 226, 89, 23);
panel_1.add(btnSubmit);
JButton btnReset = new JButton("Reset");
btnReset.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
name.setText("");
id.setText("");
}
});
btnReset.setBackground(Color.RED);
btnReset.setForeground(Color.WHITE);
btnReset.setFont(new Font("Tahoma", Font.BOLD, 15));
btnReset.setBounds(401, 226, 89, 23);
panel_1.add(btnReset);
JLabel lblNewLabel = new JLabel(" User Login \r\n");
lblNewLabel.setBounds(279, 30, 297, 44);
panel_1.add(lblNewLabel);
lblNewLabel.setForeground(Color.WHITE);
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 24));
JLabel lblNewLabel_2 = new JLabel("New User?\r\n Register");
lblNewLabel_2.addMouseListener(new MouseAdapter() {
@SuppressWarnings("unused")
@Override
public void mouseClicked(MouseEvent arg0) {
dispose();
Register reg=new Register();
reg.setVisible(true);
reg.setLocationRelativeTo(null);
}
});
lblNewLabel_2.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
lblNewLabel_2.setFont(new Font("Tahoma", Font.BOLD, 16));
lblNewLabel_2.setForeground(new Color(240, 248, 255));
lblNewLabel_2.setBounds(353, 265, 165, 37);
panel_1.add(lblNewLabel_2);
JLabel lblNewLabel_1 = new JLabel("Click here to Admin login");
lblNewLabel_1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
dispose();
Admin am=new Admin();
am.setVisible(true);
am.setLocationRelativeTo(null);
}
});
lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 16));
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_1.setForeground(Color.WHITE);
lblNewLabel_1.setBackground(Color.WHITE);
lblNewLabel_1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
lblNewLabel_1.setBounds(10, 272, 267, 23);
panel_1.add(lblNewLabel_1);
}
}