-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateFacilityView.java
149 lines (109 loc) · 3.95 KB
/
CreateFacilityView.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
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import Basic.Facility;
import Basic.Member;
import Basic.TimeSlot;
public class CreateFacilityView extends JFrame{
private Admin admin;
//private AdminController controller;
private JPanel panel;
private JButton submitButton, cancelButton;
private JLabel label0, label1;
private JTextField input0, input1;
private AdminView controller;
private DataPool dp;
private JTextField facilityName;
private JTextField priceAtNonPeak;
JComboBox facilityType;
private JTextField priceAtPeak;
private JTextField capacity;
public CreateFacilityView(AdminView controller){
//
dp = new DataPool();
ArrayList<String> listOfType = new ArrayList<String>();
listOfType.add("Restaurant");
listOfType.add("Ktv");
listOfType.add("Billiard");
listOfType.add("Bbq pit");
setBounds(100, 100, 450, 300);
this.controller=controller;
panel = new JPanel();
panel.setBorder(new EmptyBorder(5, 5, 5, 5));
panel.setLayout(null);
//panel.setLayout(null);
JLabel lblFacilityName = new JLabel("Facility Name");
lblFacilityName.setBounds(6, 31, 142, 16);
panel.add(lblFacilityName);
facilityName = new JTextField();
facilityName.setBounds(193, 26, 151, 26);
panel.add(facilityName);
facilityName.setColumns(10);
JLabel lblFacility = new JLabel("Facility Type");
lblFacility.setBounds(6, 56, 117, 16);
panel.add(lblFacility);
facilityType = new JComboBox();
for(String f: listOfType){
facilityType.addItem(f);
}
facilityType.setBounds(193, 52, 151, 27);
panel.add(facilityType);
JLabel lblSlot = new JLabel("Price at Peak");
lblSlot.setBounds(6, 84, 130, 16);
panel.add(lblSlot);
JLabel lblNumberOfPax = new JLabel("Price At Non Peak");
lblNumberOfPax.setBounds(6, 124, 142, 16);
panel.add(lblNumberOfPax);
priceAtNonPeak = new JTextField();
priceAtNonPeak.setBounds(193, 119, 151, 26);
panel.add(priceAtNonPeak);
priceAtNonPeak.setColumns(10);
JButton btnSubmit = new JButton("Submit");
btnSubmit.setBounds(193, 191, 117, 29);
btnSubmit.addActionListener(new SubmitButtonListener());
panel.add(btnSubmit);
//panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));
panel.setBorder(BorderFactory.createTitledBorder("Create new booking"));
//panel.setLayout(new GridLayout(3,2));
panel.setBackground(Color.white);
JButton btnCancel = new JButton("Cancel");
btnCancel.setBounds(81, 192, 100, 26);
btnCancel.addActionListener(new ButtonListener());
panel.add(btnCancel);
getContentPane().add(panel);
priceAtPeak = new JTextField();
priceAtPeak.setBounds(193, 79, 151, 26);
panel.add(priceAtPeak);
priceAtPeak.setColumns(10);
JLabel lblCapacity = new JLabel("Capacity");
lblCapacity.setBounds(6, 161, 117, 16);
panel.add(lblCapacity);
capacity = new JTextField();
capacity.setBounds(193, 153, 151, 26);
panel.add(capacity);
capacity.setColumns(10);
}
private class ButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
controller.mainMenu();
}
}
private class SubmitButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
// try {
//runAddTransactionSQL(int member, int facility, int timeSlot, int paxCount)
String name = facilityName.getText();
String facility = (String) facilityType.getSelectedItem();
int pricePeak = Integer.parseInt(priceAtPeak.getText());
int priceNonPeak = Integer.parseInt(priceAtNonPeak.getText());
int cap = Integer.parseInt(capacity.getText());
controller.createFacility(name, facility, pricePeak, priceNonPeak, cap);
JOptionPane.showMessageDialog(panel, "Player Created","Information", JOptionPane.PLAIN_MESSAGE);
// } catch (CreateMemberException e1) {
// JOptionPane.showMessageDialog(panel, e1.getMessage(),"Information", JOptionPane.PLAIN_MESSAGE);
// }
}
}
}