Repository navigation
Expand file tree
/
Copy pathPerson.java
More file actions
80 lines (63 loc) · 1.66 KB
/
Copy pathPerson.java
File metadata and controls
80 lines (63 loc) · 1.66 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
package Model;
import DAO.UserDAO;
import javafx.collections.ObservableList;
public class Person {
String userName,password;
int identity;
public Person(){}
public Person(String userName, String password, int identity) {
this.userName = userName;
this.password = password;
this.identity = identity;
}
public ObservableList<Person> getData(){
try {
return new UserDAO().getData();
} catch (NullPointerException e){
return null;
}catch (Exception e) {
e.printStackTrace();
}
return null;
}
public boolean update(){
return new UserDAO().update(this);
}
public boolean add(){
return new UserDAO().addUser(this);
}
public boolean Delete(){
return new UserDAO().Delete(this.userName);
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getIdentity() {
return identity;
}
public void setIdentity(int identity) {
this.identity = identity;
}
public int Login() {
UserDAO ud=new UserDAO();
try {
if(ud.getPassword(this.userName).equals(this.password)){
return ud.getIdentity(this.userName);
}
} catch (NullPointerException e){
return -2;
} catch (Exception e) {
e.printStackTrace();
}
return -1;
}
}