-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSystemManagerGUI.java
More file actions
144 lines (137 loc) · 5.08 KB
/
SystemManagerGUI.java
File metadata and controls
144 lines (137 loc) · 5.08 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
package KYUTES;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.Scanner;
import java.io.*;
import java.sql.*;
public class SystemManagerGUI extends JFrame implements ActionListener {
static String SystemAccount, SystemPassword;
CardLayout Cards = new CardLayout();
JPanel MenuPanel, FunctionPanel, MainPanel;
SystemManager_GroupPanel GroupPanel;
SystemManager_StudentPanel InformationPanel;
SystemManager_SubjectPanel SubjectPanel;
SystemManager_PersonalPanel EditPanel;
SystemManager_RegisterUserPanel RegisterPanel;
String SystemAccountthis, SystemPasswordthis;
SystemManagerGUI(String SystemAccount, String SystemPassword) {
SystemAccountthis = SystemAccount;
SystemPasswordthis = SystemPassword;
MenuPanel = new JPanel();
FunctionPanel = new JPanel();
EditPanel = new SystemManager_PersonalPanel(SystemAccount);
RegisterPanel = new SystemManager_RegisterUserPanel();
GroupPanel = new SystemManager_GroupPanel();
InformationPanel = new SystemManager_StudentPanel();
SubjectPanel = new SystemManager_SubjectPanel();
MainPanel = new JPanel();
// Welcome
JLabel Welcome = new JLabel("Welcome " + SystemAccount + "!" + " ");
// Menu Button
JButton Leave = new JButton("離開");
Leave.setSize(80, 25);
JButton Edit = new JButton("管理個人帳號");
Edit.setSize(80, 25);
JButton Register = new JButton("管理使用者帳號");
Register.setSize(80, 25);
JButton Information = new JButton("管理學生資訊");
Information.setSize(80, 25);
JButton Group = new JButton("管理測驗群組");
Group.setSize(80, 25);
JButton Subject = new JButton("管理科目");
Subject.setSize(80, 25);
JButton Main = new JButton("回主頁");
Subject.setSize(80, 25);
// 監聽
Leave.addActionListener(this);
Edit.addActionListener(this);
Register.addActionListener(this);
Information.addActionListener(this);
Group.addActionListener(this);
Subject.addActionListener(this);
Main.addActionListener(this);
// LeavePanel
MainPanel.setBackground(Color.white);
JLabel MainLabel = new JLabel("<html><body><br><br>親愛的系統管理者<br>歡迎使用KYUTES!<body></html>");
MainLabel.setFont(new Font(null, Font.BOLD, 50));
MainLabel.setSize(800, 800);
MainPanel.add(MainLabel, BorderLayout.CENTER);
// RegisterPanel
// FuntionPanel
FunctionPanel.setBackground(Color.pink);
FunctionPanel.setLayout(Cards);
FunctionPanel.add("MainCardPanel", MainPanel);
FunctionPanel.add("EditCardPanel", EditPanel);
FunctionPanel.add("RegisterCardPanel", RegisterPanel);
FunctionPanel.add("InformationCardPanel", InformationPanel);
FunctionPanel.add("GroupCardPanel", GroupPanel);
FunctionPanel.add("SubjectCardPanel", SubjectPanel);
// MenuPanel
MenuPanel.add(Welcome);
MenuPanel.add(Leave);
MenuPanel.add(Edit);
MenuPanel.add(Register);
MenuPanel.add(Information);
MenuPanel.add(Group);
MenuPanel.add(Subject);
MenuPanel.add(Main);
// container
Container Con = getContentPane();
Con.add(MenuPanel, BorderLayout.NORTH);
Con.add(FunctionPanel, BorderLayout.SOUTH);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
add(FunctionPanel);
setTitle("Welcome H3");
setSize(1000, 800);
setVisible(true);
setLocationRelativeTo(null);
}
public static void main(String[] args) {
new SystemManagerGUI(SystemAccount, SystemPassword);
}
@Override
public void actionPerformed(ActionEvent e) {
try {
String buttonName = e.getActionCommand();
if (buttonName.equals("離開")) {
Cards.show(FunctionPanel, "MainCardPanel");
int Confirm = JOptionPane.showConfirmDialog(this, "Continue Leaving?", "Continue?",
JOptionPane.YES_NO_OPTION);
if (Confirm == JOptionPane.YES_OPTION) {
leaveMethod();
}
} else if (buttonName.equals("回主頁")) {
Cards.show(FunctionPanel, "MainCardPanel");
} else if (buttonName.equals("管理使用者帳號")) {
Cards.show(FunctionPanel, "RegisterCardPanel");
} else if (buttonName.equals("管理學生資訊")) {
Cards.show(FunctionPanel, "InformationCardPanel");
} else if (buttonName.equals("管理個人帳號")) {
Cards.show(FunctionPanel, "EditCardPanel");
} else if (buttonName.equals("管理測驗群組")) {
Cards.show(FunctionPanel, "GroupCardPanel");
} else if (buttonName.equals("管理科目")) {
Cards.show(FunctionPanel, "SubjectCardPanel");
}
} catch (Exception e10) {
e10.printStackTrace();
}
}
public void leaveMethod() throws IOException {
try {
Connection conn = UseDatabase.getConnection();
Statement stat = conn.createStatement();
LoginGUI l1 = new LoginGUI();
String sql2 = "Update useraccount SET isLogin='false' where iduser_account =" + "'" + SystemAccountthis + "'";
stat.executeUpdate(sql2);
l1.setVisible(true);
dispose();
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "Wrong");
e.printStackTrace();
}
}
}