-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSourceCode.tex
More file actions
164 lines (139 loc) · 5.42 KB
/
SourceCode.tex
File metadata and controls
164 lines (139 loc) · 5.42 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
\fvset{frame=single}
\begin{pyglist}[language=java,style=borland,numbers=left,numbersep=5pt]
package kitordersystem;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Optional;
/**
* This is, as the name suggests, the main menu for my programme. WHere all the magic happens.
*/
public class MainMenu extends Application {
public static String token;
public static void main(String[] args) throws SQLException, IOException {
launch(args);
}
/**
*
*/
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Ordr");
Button remakeButton = new Button("Remake");
Button dbViewButton = new Button("Contents");
Button emailButton = new Button("Generate");
Button searchButton = new Button("Search");
TextField searchField = new TextField();
ComboBox orderComboBox = new ComboBox();
Label label = new Label();
searchField.setPromptText("Search");
orderComboBox.getItems().addAll("Name A-Z", "Name Z-A", "Item", "Order ID", )
remakeButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("Caution");
dialog.setContentText("Are you sure you want to do this? Enter remake to remake the database");
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
if (result.get() == "remake") {
DBCreate create = new DBCreate();
try {
create.SQLReader();
} catch (IOException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
try {
CSVReader reset = new CSVReader();
} catch (IOException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
} else {
}
} else {
}
}
});
dbViewButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
Platform.runLater(new Runnable() {
public void run() {
try {
new TableViewTest().start(new Stage());
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
});
emailButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
try {
DocWriter writer = new DocWriter();
} catch (Exception e) {
e.printStackTrace();
}
}
});
searchButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
token = searchField.getText();
try {
new DBSearch().start(new Stage());
} catch (Exception e) {
e.printStackTrace();
}
}
});
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(25, 25, 25, 25));
Scene scene = new Scene(grid, 300, 275);
primaryStage.setScene(scene);
grid.add(dbViewButton, 0, 0, 1, 1);
grid.add(remakeButton, 1, 0, 1, 1);
remakeButton.setTextFill(Color.RED);
grid.add(searchButton, 0, 1, 1, 1);
grid.add(emailButton, 1, 1, 1, 1);
grid.add(searchField, 0, 2, 3, 1);
grid.add(new Label("Order by: "), 0,3,1,1);
grid.add(orderComboBox, 1,3,2,1);
GridPane.setHalignment(remakeButton, HPos.CENTER);
GridPane.setHalignment(emailButton, HPos.CENTER);
GridPane.setHalignment(dbViewButton, HPos.CENTER);
GridPane.setHalignment(searchButton, HPos.CENTER);
GridPane.setHalignment(searchField, HPos.CENTER);
GridPane.setHalignment(orderComboBox, HPos.CENTER);
primaryStage.show();
}
}
\end{pyglist}