Add user insertion
parent
410555c8ae
commit
89d4aec6e0
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
# Chronos admin
|
# Chronos admin
|
||||||
|
|
||||||
A good 'ol JavaFX wrapper to administer [chronos](https://github.com/serverwentdown/chronos) schools.
|
A good 'ol JavaFX wrapper to administer [Chronos](https://github.com/serverwentdown/chronos) schools.
|
||||||
|
|
||||||
Probably gonna be forever WIP.
|
Probably gonna be forever WIP.
|
|
@ -39,6 +39,11 @@ public class Controller {
|
||||||
public TextField modify_user_role;
|
public TextField modify_user_role;
|
||||||
public Button modify_user_go;
|
public Button modify_user_go;
|
||||||
public TextField connect_database;
|
public TextField connect_database;
|
||||||
|
public TextField add_user_school;
|
||||||
|
public TextField add_user_name;
|
||||||
|
public TextField add_user_role;
|
||||||
|
public TextField add_user_email;
|
||||||
|
public Button add_user_go;
|
||||||
|
|
||||||
private Connection c;
|
private Connection c;
|
||||||
|
|
||||||
|
@ -145,6 +150,24 @@ public class Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addUser(ActionEvent actionEvent) {
|
||||||
|
try {
|
||||||
|
PreparedStatement ps = c.prepareStatement("INSERT INTO user (name, email, role, school) VALUES (?, ?, ?, ?)");
|
||||||
|
ps.setString(1, add_user_name.getText());
|
||||||
|
ps.setString(2, add_user_email.getText());
|
||||||
|
ps.setString(3, add_user_role.getText());
|
||||||
|
ps.setInt(4, Integer.parseInt(add_user_school.getText()));
|
||||||
|
ps.execute();
|
||||||
|
|
||||||
|
alertInsertDone();
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
alertBadInput();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
alertBadInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void querySchools(ActionEvent actionEvent) {
|
public void querySchools(ActionEvent actionEvent) {
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = c.prepareStatement("SELECT * FROM school WHERE school.name LIKE ?");
|
PreparedStatement ps = c.prepareStatement("SELECT * FROM school WHERE school.name LIKE ?");
|
||||||
|
|
|
@ -91,25 +91,42 @@
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</content>
|
</content>
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab text="modify user">
|
<Tab text="add user">
|
||||||
<content>
|
<content>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
<children>
|
<children>
|
||||||
<ToolBar layoutX="17.0" layoutY="3.0" prefHeight="40.0" prefWidth="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<ToolBar layoutX="17.0" layoutY="3.0" prefHeight="40.0" prefWidth="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<items>
|
<items>
|
||||||
<TextField fx:id="modify_user_school" prefHeight="27.0" prefWidth="83.0" promptText="school id" />
|
<TextField fx:id="add_user_school" prefHeight="27.0" prefWidth="83.0" promptText="school id" />
|
||||||
<TextField fx:id="modify_user_id" layoutX="10.0" layoutY="11.0" prefHeight="27.0" prefWidth="74.0" promptText="user id" />
|
<TextField fx:id="add_user_name" layoutX="10.0" layoutY="11.0" prefHeight="27.0" prefWidth="132.0" promptText="name" />
|
||||||
<Button fx:id="modify_user_load" mnemonicParsing="false" onAction="#modifyUserLoad" text="load" />
|
<TextField fx:id="add_user_email" layoutX="100.0" layoutY="11.0" prefHeight="27.0" prefWidth="112.0" promptText="email" />
|
||||||
<TextField fx:id="modify_user_name" layoutX="10.0" layoutY="11.0" prefHeight="27.0" prefWidth="132.0" promptText="name" />
|
<TextField fx:id="add_user_role" prefHeight="27.0" prefWidth="65.0" promptText="role" />
|
||||||
<TextField fx:id="modify_user_email" layoutX="100.0" layoutY="11.0" prefHeight="27.0" prefWidth="112.0" promptText="email" />
|
<Button fx:id="add_user_go" mnemonicParsing="false" onAction="#addUser" text="go" />
|
||||||
<TextField fx:id="modify_user_role" prefHeight="27.0" prefWidth="65.0" promptText="role" />
|
|
||||||
<Button fx:id="modify_user_go" mnemonicParsing="false" onAction="#modifyUser" text="go" />
|
|
||||||
</items>
|
</items>
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</content>
|
</content>
|
||||||
</Tab>
|
</Tab>
|
||||||
|
<Tab text="modify user">
|
||||||
|
<content>
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<ToolBar layoutX="17.0" layoutY="3.0" prefHeight="40.0" prefWidth="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<items>
|
||||||
|
<TextField fx:id="modify_user_school" prefHeight="27.0" prefWidth="83.0" promptText="school id" />
|
||||||
|
<TextField fx:id="modify_user_id" layoutX="10.0" layoutY="11.0" prefHeight="27.0" prefWidth="74.0" promptText="user id" />
|
||||||
|
<Button fx:id="modify_user_load" mnemonicParsing="false" onAction="#modifyUserLoad" text="load" />
|
||||||
|
<TextField fx:id="modify_user_name" layoutX="10.0" layoutY="11.0" prefHeight="27.0" prefWidth="132.0" promptText="name" />
|
||||||
|
<TextField fx:id="modify_user_email" layoutX="100.0" layoutY="11.0" prefHeight="27.0" prefWidth="112.0" promptText="email" />
|
||||||
|
<TextField fx:id="modify_user_role" prefHeight="27.0" prefWidth="65.0" promptText="role" />
|
||||||
|
<Button fx:id="modify_user_go" mnemonicParsing="false" onAction="#modifyUser" text="go" />
|
||||||
|
</items>
|
||||||
|
</ToolBar>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</content>
|
||||||
|
</Tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
</TabPane>
|
</TabPane>
|
||||||
</children>
|
</children>
|
||||||
|
|
Loading…
Reference in New Issue