-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstructorMenu.java
More file actions
executable file
·132 lines (123 loc) · 4.28 KB
/
Copy pathInstructorMenu.java
File metadata and controls
executable file
·132 lines (123 loc) · 4.28 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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class InstructorMenu extends JDialog implements ActionListener {
private static final long serialVersionUID = 1L;
Container container = getContentPane();
JButton view, update, create, remove, add, exitInsMenu;
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel();
public InstructorMenu(JFrame parent, String title) {
super(parent, title, true);
setSize(500, 250);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setResizable(true);
container.setLayout(new GridLayout(3, 3));
// panel.setLayout(new FlowLayout());
setFont(new Font("Arial", Font.BOLD, 25));
setLocation(300, 300);
create = new JButton("Create Instructor");
remove = new JButton("Remove Office Hours");
update = new JButton("Update Instructor");
view = new JButton("View Instructor");
add = new JButton("Add Office Hours");
exitInsMenu = new JButton("Exit Instructor Menu");
panel1.add(create);
panel1.add(remove);
panel1.add(add);
panel1.setLayout(new FlowLayout(FlowLayout.LEFT, 20, 20));
panel2.add(update);
panel2.add(view);
panel2.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 20));
panel3.add(exitInsMenu);
panel3.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 20));
container.add(panel1);
container.add(panel2);
container.add(panel3);
add.addActionListener(this);
create.addActionListener(this);
update.addActionListener(this);
remove.addActionListener(this);
view.addActionListener(this);
exitInsMenu.addActionListener(this);
addWindowListener(new WindowAdapterURS());
this.setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == create) {
CreateInstructor cs = new CreateInstructor((JFrame) this
.getParent(), "Create Instructor");
}
if (ae.getSource() == view) {
String option[] = { "Department", "First_Name", "Last_Name",
"Address", "City", "State", "Zip", "Office_Hours",
"Courses" };
String r = (String) JOptionPane.showInputDialog(this,
"Select Option to View", "Instructor",
JOptionPane.QUESTION_MESSAGE, null, option, option[1]);
if (r != null) {
String id = JOptionPane.showInputDialog(this,
"Enter Instructor ID");
if (id != null) {
String req = "Get_" + r + "\n" + RequestID.getNextID()
+ "\n1\n" + id;
String res = JMSSender.send(req);
Response.displayResponse(res, (JFrame) this.getParent());
}
}
}
if (ae.getSource() == update) {
String option[] = { "Courses", "Department", "First_Name",
"Last_Name", "Address", "City", "State", "Zip", "ID" };
String r = (String) JOptionPane.showInputDialog(this,
"Select Option to Update", "Instructor",
JOptionPane.QUESTION_MESSAGE, null, option, option[1]);
if (r != null) {
String id = JOptionPane.showInputDialog(this,
"Enter Instructor ID");
if (id != null) {
String newValue = JOptionPane.showInputDialog(this,
"Enter " + r);
String req = "Set_" + r + "\n" + RequestID.getNextID()
+ "\n2\n" + newValue + "\n" + id;
String res = JMSSender.send(req);
Response.displayResponse(res, (JFrame) this.getParent());
}
}
}
if (ae.getSource() == add) {
String req;
String id = JOptionPane
.showInputDialog(this, "Enter Instructor ID");
if (id != null) {
String location = JOptionPane.showInputDialog(this,
"Enter Location");
if (location != null) {
req = "Add_Office_Hours\n" + RequestID.getNextID()
+ "\n2\n" + id + "\n" + location;
String res = JMSSender.send(req);
Response.displayResponse(res, (JFrame) this.getParent());
}
}
}
if (ae.getSource() == remove) {
String req;
String id = JOptionPane
.showInputDialog(this, "Enter Instructor ID");
if (id != null) {
String location = JOptionPane.showInputDialog(this,
"Enter Location");
if (location != null) {
req = "Remove_Office_Hours\n" + RequestID.getNextID()
+ "\n2\n" + id + "\n" + location;
String res = JMSSender.send(req);
Response.displayResponse(res, (JFrame) this.getParent());
}
}
}
if (ae.getSource() == exitInsMenu) {
dispose();
}
}
}