-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserMan.java
More file actions
108 lines (93 loc) · 3.07 KB
/
Copy pathUserMan.java
File metadata and controls
108 lines (93 loc) · 3.07 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
package PDBMS;
import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import java.sql.ResultSet;
import java.sql.SQLException;
public class UserMan {
@FXML private TextField tf0;
@FXML private TextField tf1;
@FXML private TextField tf2;
@FXML private TextField tf3;
private TextField tf01;
LoginManager lm;
public void initStatus(final LoginManager l,TextField a,TextField b,TextField c,TextField d,TextField e) {
lm = l;
tf0=a;
tf1=b;
tf2=c;
tf3=d;
tf01=e;
tf3.setText("User Management");
}
@FXML
public void create(){
ResultSet r;
r=LoginManager.sql("select * from users where UserName='"+tf0.getText()+"'");
try {
if(r.next())
{
tf3.setText("User Already Exists! Try Update User if you want to change Password or User Name");
}
else
{
if(tf1.getText().equals(tf2.getText()))
{
r=LoginManager.sql("Insert into users values('"+tf0.getText()+"','"+tf1.getText()+"','officer',"+tf01.getText()+");");
tf3.setText("Created Successfully!");
}
else
tf3.setText("Error! Passwords Don't match");
}
} catch (SQLException e) {
e.printStackTrace();
}
}
@FXML
public void update(){
ResultSet r;
r=LoginManager.sql("select * from users where UserName='"+tf0.getText()+"'");
try {
if(r.next())
{
if(tf1.getText().equals(tf2.getText())){
r=LoginManager.sql("update users set Password='"+tf1.getText()+"' where UserName='"+tf0.getText()+"';");
tf3.setText("Updated Successfully!");
}
else
tf3.setText("Error! Passwords Don't match");
}
else
{
tf3.setText("User Does not Exist! Try Create User if you want to Create new User");
}
} catch (SQLException e) {
e.printStackTrace();
}
}
@FXML
public void delete(){
ResultSet r;
r=LoginManager.sql("select * from users where UserName='"+tf0.getText()+"'");
try {
if(r.next())
{
if(tf1.getText().equals(tf2.getText())){
r=LoginManager.sql("delete from users where UserName='"+tf0.getText()+"';");
tf3.setText("Deleted Successfully!");
}
else
tf3.setText("Error! Passwords Don't match");
}
else
{
tf3.setText("User Does not Exist! Try Create User if you want to Create new User");
}
} catch (SQLException e) {
e.printStackTrace();
}
}
@FXML
private void back(){
lm.showMainView();
}
}