-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoverdueFilter.java
More file actions
57 lines (42 loc) · 1.53 KB
/
Copy pathoverdueFilter.java
File metadata and controls
57 lines (42 loc) · 1.53 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
package lms;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
public class overdueFilter extends FilterSearchGUI implements ActionListener {
/**
* Default Keyword Option
*/
private static String selectedOption = "patron_ID"; // default value
/**
* Array of Keyword Options
*/
private static final String[] options = {"patron_ID", "author"};
/**
* Constructor. Calls Superclass constructor and passes in new array of keywords
*/
public overdueFilter() {
super(options);
}
/**
* Overriding the abstract actionPerformed method. Handles the connection to database and keyword recognition
*/
@Override
public void actionPerformed(ActionEvent e) {
Connection connection = DatabaseConnection.openDatabase();
// if the action is a dropDown switch, switch our selectedOption. Otherwise, show a table.
if ("keyword".equals(e.getActionCommand())) {
selectedOption = String.valueOf(keywordDropDown.getSelectedItem());
}else if ("go".equals(e.getActionCommand())) {
switch (selectedOption) {
case "patron_ID":
System.out.println(super.criterion.getText());
Librarian.getOverdueList(connection, "checkoutsview", "patron_ID", super.criterion.getText());
break;
case "author":
Librarian.getOverdueList(connection, "checkoutsview", "author", super.criterion.getText());
break;
}
}
DatabaseConnection.closeDatabase(connection);
}
}