FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Grade-Management-System/src/SystemUI/LaunchView.java at zw · LeoAxilion/Grade-Management-System · GitHub
LeoAxilion
/
Grade-Management-System
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Issues
0
Pull requests
2
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Grade-Management-System
/
src
/
SystemUI
/
LaunchView.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
140 lines (119 loc) · 4.82 KB
Breadcrumbs
Grade-Management-System
/
src
/
SystemUI
/
LaunchView.java
Copy path
File metadata and controls
140 lines (119 loc) · 4.82 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package
SystemUI
;
import
DbOperation
.
DbUtil
;
import
java
.
sql
.*;
import
javafx
.
application
.
Application
;
import
javafx
.
beans
.
value
.
ChangeListener
;
import
javafx
.
beans
.
value
.
ObservableValue
;
import
javafx
.
event
.
ActionEvent
;
import
javafx
.
event
.
EventHandler
;
import
javafx
.
fxml
.
FXMLLoader
;
import
javafx
.
geometry
.
Insets
;
import
javafx
.
scene
.
Parent
;
import
javafx
.
scene
.
Scene
;
import
javafx
.
scene
.
chart
.
StackedBarChart
;
import
javafx
.
scene
.
control
.*;
import
javafx
.
scene
.
layout
.
FlowPane
;
import
javafx
.
stage
.
Stage
;
public
class
LaunchView
extends
Application
{
String
id
;
String
password
;
Stage
primaryStage
;
public
static
void
main
(
String
[]
args
) {
launch
(
args
);
}
@
Override
public
void
start
(
Stage
primaryStage
)
throws
Exception
{
//Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
this
.
primaryStage
=
primaryStage
;
primaryStage
.
setTitle
(
"Please Login"
);
FlowPane
pane
=
new
FlowPane
();
pane
.
setPadding
(
new
Insets
(
11
,
12
,
13
,
14
));
pane
.
setVgap
(
15
);
pane
.
setHgap
(
15
);
Label
l_id
=
new
Label
(
"Please input your id:"
);
TextField
tf_id
=
new
TextField
();
tf_id
.
textProperty
().
addListener
(
new
ChangeListener
<
String
>() {
//设置只能输入数字
@
Override
public
void
changed
(
ObservableValue
<?
extends
String
>
observableValue
,
String
oldValue
,
String
newValue
) {
if
(!
newValue
.
matches
(
"
\\
d*"
)) {
tf_id
.
setText
(
newValue
.
replaceAll
(
"[^
\\
d]"
,
""
));
}
}
});
Label
l_password
=
new
Label
(
"Please input your password:"
);
PasswordField
pw_password
=
new
PasswordField
();
Button
bt_sub
=
new
Button
(
"Submit"
);
bt_sub
.
setOnAction
(
new
EventHandler
<
ActionEvent
>() {
@
Override
public
void
handle
(
ActionEvent
actionEvent
) {
//提交前非空检查
if
(
tf_id
.
getText
() ==
null
||
tf_id
.
getText
().
equals
(
""
)) {
Alert
alert
=
new
Alert
(
Alert
.
AlertType
.
ERROR
,
"Id can not be null"
);
alert
.
showAndWait
()
.
filter
(
response
->
response
==
ButtonType
.
OK
);
System
.
out
.
println
(
"id is null"
);
return
;
}
else
if
(
pw_password
.
getText
() ==
null
||
pw_password
.
getText
().
equals
(
""
)) {
System
.
out
.
println
(
"password is null"
);
Alert
alert
=
new
Alert
(
Alert
.
AlertType
.
ERROR
,
"Password can not be null"
);
alert
.
showAndWait
()
.
filter
(
response
->
response
==
ButtonType
.
OK
);
return
;
}
/*****************************
* 判断身份并查表
* ****************************
*/
password
=
pw_password
.
getText
();
id
=
tf_id
.
getText
();
try
{
Login
(
id
,
password
);
}
catch
(
SQLException
e
) {
e
.
printStackTrace
();
}
}
});
pane
.
getChildren
().
addAll
(
l_id
,
tf_id
,
l_password
,
pw_password
,
bt_sub
);
Scene
scene
=
new
Scene
(
pane
);
primaryStage
.
setScene
(
scene
);
primaryStage
.
show
();
}
private
void
Login
(
String
id
,
String
password
)
throws
SQLException
{
String
sql
=
"select * from user where id = ? and password = ?"
;
Connection
cnn
=
DbUtil
.
getConnection
();
PreparedStatement
ps
=
null
;
try
{
ps
=
cnn
.
prepareStatement
(
sql
);
}
catch
(
SQLException
e
) {
e
.
printStackTrace
();
}
ps
.
setString
(
1
,
id
);
ps
.
setString
(
2
,
password
);
System
.
out
.
println
(
sql
);
ResultSet
rs
=
ps
.
executeQuery
();
if
(!
rs
.
next
())
{
System
.
out
.
println
(
"Your id or password is wrong"
);
Alert
alert
=
new
Alert
(
Alert
.
AlertType
.
ERROR
,
"Your id or password is wrong"
);
alert
.
showAndWait
()
.
filter
(
response
->
response
==
ButtonType
.
OK
);
}
else
{
if
(
rs
.
getString
(
"userType"
).
equals
(
"teacher"
)) {
TeacherCourseSelectView
tv
=
new
TeacherCourseSelectView
(
id
);
primaryStage
.
close
();
}
else
if
(
rs
.
getString
(
"userType"
).
equals
(
"student"
)) {
StudentView
sv
=
new
StudentView
(
id
);
primaryStage
.
close
();
}
else
if
(
rs
.
getString
(
"userType"
).
equals
(
"admin"
)) {
AdminView
av
=
new
AdminView
();
primaryStage
.
close
();
}
else
{
Alert
alert
=
new
Alert
(
Alert
.
AlertType
.
ERROR
,
"Please contact administrater"
);
alert
.
showAndWait
()
.
filter
(
response
->
response
==
ButtonType
.
OK
);
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL