-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdminView.java
190 lines (154 loc) · 5.29 KB
/
AdminView.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
import java.util.ArrayList;
import Basic.Facility;
import Basic.Member;
import Basic.User;
import Common.CreateMemberException;
public class AdminView {
private User loginUser;
private AdminController controller;
private MainMenuView f1;
private CreateBookingView fCreateNewBookingView;
private CreateFacilityView fCreateFacilityView;
private UpdateFacilityView fUpdateFacility;
private BookingsView fBookingsView;
private DeleteMemberView fDelete;
private ResetMemberPasswordView fResetPlayer;
private SearchFacilityView fSearchFacility;
private ChangePasswordView fResetAdmin;
public AdminView(User a, AdminController controller) {
this.loginUser = a;
this.controller = controller;
f1 = new MainMenuView(this);
f1.pack();
f1.setLocationRelativeTo(null);
}
public static void main(String []args){
}
public boolean isAdmin(){
if (loginUser.getRole().equalsIgnoreCase("admin")) return true;
else return false;
}
public User getLoginUser(){
return loginUser;
}
public void show() {
f1.setLocationRelativeTo(null);
f1.setVisible(true);
controller.saveMemberData();
}
public void showMenuMember() {
}
public void run(){
f1.setLocationRelativeTo(null);
f1.setVisible(true);
}
public void frameCreateBooking(){
fCreateNewBookingView = new CreateBookingView(this, 0);
fCreateNewBookingView.setLocationRelativeTo(null);
fCreateNewBookingView.setVisible(true);
f1.setVisible(false);
}
public void frameDelete(){
fDelete = new DeleteMemberView(this);
fDelete.pack();
fDelete.setLocationRelativeTo(null);
fDelete.setVisible(true);
f1.setVisible(false);
}
public void frameResetPlayer(){
fResetPlayer = new ResetMemberPasswordView(this);
fResetPlayer.pack();
fResetPlayer.setLocationRelativeTo(null);
fResetPlayer.setVisible(true);
f1.setVisible(false);
}
public void frameChangeAdminPassword(){
fResetAdmin = new ChangePasswordView(this);
fResetAdmin.pack();
fResetAdmin.setLocationRelativeTo(null);
fResetAdmin.setVisible(true);
f1.setVisible(false);
}
//runAddTransactionSQLrunAddTransactionSQL(Member member, Facility facility, int timeSlot, int paxCount)
void createBooking(String date, int facility, int timeSlot, int paxCount, int price){
controller.createBooking(date, facility, timeSlot, paxCount, price);
}
public void deletePlayer(String name) throws InvalidMemberException {
controller.deleteMember(name);
controller.saveMemberData();
}
public void mainMenu() {
f1.setLocationRelativeTo(null);
f1.setVisible(true);
if (fDelete!= null) fDelete.setVisible(false);
if (fResetPlayer!= null) fResetPlayer.setVisible(false);
if (fCreateFacilityView!= null) fCreateFacilityView.setVisible(false);
if (fResetAdmin!= null) fResetAdmin.setVisible(false);
if (fCreateNewBookingView!= null) fCreateNewBookingView.setVisible(false);
if (fSearchFacility!= null) fSearchFacility.setVisible(false);
if (fBookingsView!= null) fBookingsView.setVisible(false);
}
public void resetPlayerPassword(String name, String password) throws CreateMemberException {
controller.resetMemberPassword(name, password);
controller.saveMemberData();
}
// public ArrayList<Player> getTopScorer() {
//
// return controller.getTopScorer();
// }
//
public void changeAdminPassword(String password1, String password2) throws InvalidPasswordException{
controller.changeAdminPassword(password1, password2);
}
public void logOut(){
f1.setVisible(false);
AdminModule newModule = new AdminModule();
newModule.run();
}
public void frameCreateFacility() {
// TODO Auto-generated method stub
fCreateFacilityView = new CreateFacilityView(this);
fCreateFacilityView.setLocationRelativeTo(null);
fCreateFacilityView.setVisible(true);
f1.setVisible(false);
}
public void frameUpdateFacility(int idToUpdate) {
// TODO Auto-generated method stub
fUpdateFacility = new UpdateFacilityView(this, idToUpdate);
fUpdateFacility.setLocationRelativeTo(null);
fUpdateFacility.setVisible(true);
fSearchFacility.setVisible(false);
f1.setVisible(false);
}
//UpdateFacilityView
public void createFacility(String name, String facility, int pricePeak, int priceNonPeak, int cap) {
// TODO Auto-generated method stub
controller.createFacility(name, facility, pricePeak, priceNonPeak, cap);
}
public void frameSearchFacility() {
// TODO Auto-generated method stub
fSearchFacility = new SearchFacilityView(this);
fSearchFacility.setLocationRelativeTo(null);
fSearchFacility.setVisible(true);
if (fUpdateFacility!= null) fUpdateFacility.setVisible(false);
f1.setVisible(false);
}
public void updateFacility(int idToUpdate, String name, String facility, int pricePeak, int priceNonPeak, int cap) {
// TODO Auto-generated method stub
controller.updateFacility(idToUpdate, name, facility, pricePeak, priceNonPeak, cap);
}
public void frameCreateBooking(int idToBook) {
// TODO Auto-generated method stub
fCreateNewBookingView = new CreateBookingView(this, idToBook);
fCreateNewBookingView.setLocationRelativeTo(null);
fCreateNewBookingView.setVisible(true);
f1.setVisible(false);
}
public void frameViewBooking() {
// TODO Auto-generated method stub
fBookingsView = new BookingsView(this);
fBookingsView.setLocationRelativeTo(null);
fBookingsView.setVisible(true);
f1.setVisible(false);
}
}