Skip to content
Snippets Groups Projects
Commit 1d4356f2 authored by eyan_'s avatar eyan_
Browse files

Merge branch 'combo' into main

parents ecebcd46 6468bdc0
No related branches found
No related tags found
1 merge request!3Added 'mysql-connector-java-8.0.28.jar.' This is the connector/j driver that...
Showing
with 811 additions and 14 deletions
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
<project version="4"> <project version="4">
<component name="Encoding"> <component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -6,6 +6,16 @@ ...@@ -6,6 +6,16 @@
<option name="name" value="Central Repository" /> <option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" /> <option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository> </remote-repository>
<remote-repository>
<option name="id" value="in-project" />
<option name="name" value="In Project Repo" />
<option name="url" value="file://C:\cmpt370\cmpt-370-group-project\SchedulerApp/lib" />
</remote-repository>
<remote-repository>
<option name="id" value="in-project" />
<option name="name" value="In Project Repo" />
<option name="url" value="file://$PROJECT_DIR$/lib" />
</remote-repository>
<remote-repository> <remote-repository>
<option name="id" value="central" /> <option name="id" value="central" />
<option name="name" value="Maven Central repository" /> <option name="name" value="Maven Central repository" />
......
<component name="libraryTable">
<library name="Maven: com.google.protobuf:protobuf-java:3.11.4">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/google/protobuf/protobuf-java/3.11.4/protobuf-java-3.11.4.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/google/protobuf/protobuf-java/3.11.4/protobuf-java-3.11.4-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/google/protobuf/protobuf-java/3.11.4/protobuf-java-3.11.4-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: mysql:mysql-connector-java:8.0.28">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/mysql/mysql-connector-java/8.0.28/mysql-connector-java-8.0.28.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/mysql/mysql-connector-java/8.0.28/mysql-connector-java-8.0.28-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/mysql/mysql-connector-java/8.0.28/mysql-connector-java-8.0.28-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
...@@ -24,5 +24,7 @@ ...@@ -24,5 +24,7 @@
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.7.1" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.7.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.7.1" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.7.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.7.1" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.7.1" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.28" level="project" />
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.11.4" level="project" />
</component> </component>
</module> </module>
\ No newline at end of file
...@@ -14,6 +14,14 @@ ...@@ -14,6 +14,14 @@
<junit.version>5.7.1</junit.version> <junit.version>5.7.1</junit.version>
</properties> </properties>
<repositories>
<repository>
<id>in-project</id>
<name>In Project Repo</name>
<url>file://${project.basedir}/lib</url>
</repository>
</repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.openjfx</groupId> <groupId>org.openjfx</groupId>
...@@ -38,6 +46,12 @@ ...@@ -38,6 +46,12 @@
<version>${junit.version}</version> <version>${junit.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.example.schedulerapp; package com.example.schedulerapp;
<<<<<<< HEAD
import javafx.event.Event; import javafx.event.Event;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
...@@ -23,6 +24,25 @@ public class Controller { ...@@ -23,6 +24,25 @@ public class Controller {
Calendar test; Calendar test;
public void scheduleButtonClicked() throws Exception { public void scheduleButtonClicked() throws Exception {
=======
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import java.io.IOException;
public class Controller {
Model model = new Model();
public void scheduleButtonClicked(){
>>>>>>> combo
System.out.println("schedule button clicked"); System.out.println("schedule button clicked");
dailyScheduleButtonClicked(); dailyScheduleButtonClicked();
leftSideButtons.setVisible(true); leftSideButtons.setVisible(true);
...@@ -76,6 +96,7 @@ public class Controller { ...@@ -76,6 +96,7 @@ public class Controller {
public void nextButtonClicked(){ public void nextButtonClicked(){
System.out.println("next button clicked"); System.out.println("next button clicked");
} }
<<<<<<< HEAD
public void managementButtonClicked() throws IOException { public void managementButtonClicked() throws IOException {
System.out.println("management button clicked"); System.out.println("management button clicked");
FXMLLoader fxmlLoader = new FXMLLoader(ScheduleApp.class.getResource("managementView.fxml")); FXMLLoader fxmlLoader = new FXMLLoader(ScheduleApp.class.getResource("managementView.fxml"));
...@@ -106,5 +127,165 @@ public class Controller { ...@@ -106,5 +127,165 @@ public class Controller {
System.out.println("employer test clicked"); System.out.println("employer test clicked");
FXMLLoader fxmlLoader = new FXMLLoader(ScheduleApp.class.getResource("employerMainView.fxml")); FXMLLoader fxmlLoader = new FXMLLoader(ScheduleApp.class.getResource("employerMainView.fxml"));
rootBorderPane.setCenter(fxmlLoader.load()); rootBorderPane.setCenter(fxmlLoader.load());
=======
// Login Page
public void managerLoginClicked(MouseEvent mouseEvent) throws IOException {
BorderPane root = new BorderPane();
FXMLLoader gridLoader = new FXMLLoader(this.getClass().getResource("dailySchedManager.fxml"));
Parent grid = gridLoader.load();
FXMLLoader headerLoader = new FXMLLoader(this.getClass().getResource("headerManager.fxml"));
Parent header = headerLoader.load();
FXMLLoader sideLoader = new FXMLLoader(this.getClass().getResource("schedSidePanel.fxml"));
Parent sidePanel = sideLoader.load();
FXMLLoader bottomLoader = new FXMLLoader(this.getClass().getResource("schedBottomPanelManager.fxml"));
Parent bottomPanel = bottomLoader.load();
root.setTop(header);
root.setLeft(sidePanel);
root.setBottom(bottomPanel);
root.setCenter(grid);
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App");
stage.setScene(scene);
stage.show();
}
public void employeeLoginClicked(MouseEvent mouseEvent) throws IOException {
FXMLLoader employeeLoader = new FXMLLoader(this.getClass().getResource("mainView.fxml"));
Parent root = employeeLoader.load();
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App");
stage.setScene(scene);
stage.show();
}
// Header
public void mangerLogoutClicked(MouseEvent mouseEvent) throws IOException {
FXMLLoader loginLoader = new FXMLLoader(this.getClass().getResource("login.fxml"));
Parent root = loginLoader.load();
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App");
stage.setScene(scene);
stage.show();
}
// Manager Page
// Staff Section
// Switch to Staff Page
public void staffManagerClicked(MouseEvent mouseEvent) throws IOException {
BorderPane root = new BorderPane();
FXMLLoader gridLoader = new FXMLLoader(this.getClass().getResource("addEmployee.fxml"));
Parent grid = gridLoader.load();
FXMLLoader headerLoader = new FXMLLoader(this.getClass().getResource("headerManager.fxml"));
Parent header = headerLoader.load();
FXMLLoader sideLoader = new FXMLLoader(this.getClass().getResource("staffManagerSidePanel.fxml"));
Parent sidePanel = sideLoader.load();
root.setTop(header);
root.setLeft(sidePanel);
root.setCenter(grid);
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App");
stage.setScene(scene);
stage.show();
}
// Side Panel
// Switch to Edit Employee
public void editStaffSidePanelClicked(MouseEvent mouseEvent) throws IOException {
BorderPane root = new BorderPane();
FXMLLoader gridLoader = new FXMLLoader(this.getClass().getResource("editEmployee.fxml"));
Parent grid = gridLoader.load();
FXMLLoader headerLoader = new FXMLLoader(this.getClass().getResource("headerManager.fxml"));
Parent header = headerLoader.load();
FXMLLoader sideLoader = new FXMLLoader(this.getClass().getResource("staffManagerSidePanel.fxml"));
Parent sidePanel = sideLoader.load();
root.setTop(header);
root.setLeft(sidePanel);
root.setCenter(grid);
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App");
stage.setScene(scene);
stage.show();
>>>>>>> combo
} }
// Switch to Remove Employee
public void removeStaffSidePanelClicked(MouseEvent mouseEvent) throws IOException {
BorderPane root = new BorderPane();
FXMLLoader gridLoader = new FXMLLoader(this.getClass().getResource("removeEmployee.fxml"));
Parent grid = gridLoader.load();
FXMLLoader headerLoader = new FXMLLoader(this.getClass().getResource("headerManager.fxml"));
Parent header = headerLoader.load();
FXMLLoader sideLoader = new FXMLLoader(this.getClass().getResource("staffManagerSidePanel.fxml"));
Parent sidePanel = sideLoader.load();
root.setTop(header);
root.setLeft(sidePanel);
root.setCenter(grid);
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App");
stage.setScene(scene);
stage.show();
}
// Switch to View Employees
@FXML
TextArea employees = new TextArea();
public void viewStaffSidePanelClicked(MouseEvent mouseEvent) throws IOException {
BorderPane root = new BorderPane();
FXMLLoader gridLoader = new FXMLLoader(this.getClass().getResource("viewEmployees.fxml"));
Parent grid = gridLoader.load();
FXMLLoader headerLoader = new FXMLLoader(this.getClass().getResource("headerManager.fxml"));
Parent header = headerLoader.load();
FXMLLoader sideLoader = new FXMLLoader(this.getClass().getResource("staffManagerSidePanel.fxml"));
Parent sidePanel = sideLoader.load();
root.setTop(header);
root.setLeft(sidePanel);
root.setCenter(grid);
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App");
stage.setScene(scene);
stage.show();
}
// Add, Edit, Remove Functions
// Add Employee
@FXML
private TextField addFirstName;
@FXML
private TextField addLastName;
@FXML
private TextField removeID;
public void addEmployeeClicked(MouseEvent mouseEvent) {
String firstName = addFirstName.getText();
String lastName = addLastName.getText();
model.staff.addEmployee(firstName, lastName);
System.out.println("Employee " + firstName + " " + lastName + " added to Staff. Welcome "
+ firstName + "!");
}
// Edit employee
public void editEmployeeClicked(MouseEvent mouseEvent) {
//edit employee
}
// Remove Employee
public void removeEmployeeClicked(MouseEvent mouseEvent) {
int id = Integer.parseInt(removeID.getText());
model.staff.removeEmployee(id);
}
// View Employees
} }
package com.example.schedulerapp; package com.example.schedulerapp;
public class Employee { public class Employee {
} }
package com.example.schedulerapp; package com.example.schedulerapp;
public class Model { public class Model {
Staff staff = new Staff();
} }
package com.example.schedulerapp; package com.example.schedulerapp;
import java.sql.*;
public class Schedule { public class Schedule {
private Connection dbConnection;
protected Schedule() {
connectDataBase();
}
protected String connectDataBase(){
try {
dbConnection = DriverManager.getConnection("jdbc:mysql://localhost:3306/ScheduleApp", "root", "password");
} catch (Exception e) {
System.out.println(e.fillInStackTrace());
return "Couldn't connect to database.";
}
return "Successfully connected to database.";
}
} }
...@@ -16,9 +16,15 @@ public class ScheduleApp extends Application { ...@@ -16,9 +16,15 @@ public class ScheduleApp extends Application {
Label hello = new Label("Testing again :)"); Label hello = new Label("Testing again :)");
root.setCenter(hello); root.setCenter(hello);
<<<<<<< HEAD
FXMLLoader fxmlLoader = new FXMLLoader(ScheduleApp.class.getResource("employeeMainView.fxml")); FXMLLoader fxmlLoader = new FXMLLoader(ScheduleApp.class.getResource("employeeMainView.fxml"));
Scene scene = new Scene(fxmlLoader.load(),500,500); Scene scene = new Scene(fxmlLoader.load(),500,500);
stage.setTitle("Schedule App"); stage.setTitle("Schedule App");
=======
FXMLLoader fxmlLoader = new FXMLLoader(ScheduleApp.class.getResource("login.fxml"));
Scene scene = new Scene(fxmlLoader.load(),800,600);
stage.setTitle("Scheduler App");
>>>>>>> combo
stage.setScene(scene); stage.setScene(scene);
stage.show(); stage.show();
} }
......
package com.example.schedulerapp;
public class Shift {
}
/*
This class facilitates the communication between the model and the mysql database, for staff purposes.
*/
package com.example.schedulerapp; package com.example.schedulerapp;
import java.sql.*;
public class Staff { public class Staff {
// Object that facilitates the connection to the database
private Connection dbConnection;
/*
Name: Staff Constructor
Parameters: None
Description: Establishes connections to the local database. If running on a different computer
make sure that the port number (replace '3306'), database name (replace 'ScheduleApp'), user, and password are
set correctly.
Return: Staff Object
*/
protected Staff() {
connectDataBase();
}
protected String connectDataBase(){
try {
dbConnection = DriverManager.getConnection("jdbc:mysql://localhost:3306/ScheduleApp", "root", "password");
} catch (Exception e) {
System.out.println(e.fillInStackTrace());
return "Couldn't connect to database.";
}
return "Successfully connected to database.";
}
/*
Name: addEmployee
Parameters:
String firstName: First name of the employee,
String lastName: Last name of the employee .
Description: Adds an employee by querying the database. Also, assigns a unique ID.
Return: none
*/
protected void addEmployee(String firstName, String lastName){
try {
Statement myStatement = dbConnection.createStatement();
myStatement.executeUpdate("insert into Employees (first_name,last_name) values ('" + firstName + "', '" + lastName + "')");
} catch (Exception e) {
System.out.println(e.fillInStackTrace());
}
System.out.println("Employee Added");
}
/*
Name: removeEmployee
Parameters:
int ID: The employees unique ID.
Description: Removes the employee with the same ID by querying the database.
Return: none
*/
protected void removeEmployee(int ID){
try {
Statement myStatement = dbConnection.createStatement();
myStatement.executeUpdate("delete from Employees where employee_id = " + ID);
} catch (Exception e) {
System.out.println(e.fillInStackTrace());
}
System.out.println("Employee Removed");
}
/*
Name: printEmployees
Parameters: none
Description: prints the id, and names of each employee
Return: none
*/
protected String printEmployees(){
try {
Statement myStatement = dbConnection.createStatement();
ResultSet myRs = myStatement.executeQuery("select * from Employees");
while (myRs.next()) {
System.out.println("id: " + myRs.getString("employee_ID") + ", " + myRs.getString("last_name") + ", " + myRs.getString("first_name"));
}
} catch (Exception e) {
System.out.println(e.fillInStackTrace());
return "fail";
}
return "success";
}
} }
module com.example.schedulerapp { module com.example.schedulerapp {
requires javafx.controls; requires javafx.controls;
requires javafx.fxml; requires javafx.fxml;
requires java.sql;
opens com.example.schedulerapp to javafx.fxml; opens com.example.schedulerapp to javafx.fxml;
......
File added
File added
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.schedulerapp.login">
<children>
<VBox alignment="CENTER" layoutX="250.0" layoutY="133.0" prefHeight="134.0" prefWidth="100.0" AnchorPane.bottomAnchor="133.0" AnchorPane.leftAnchor="250.0" AnchorPane.rightAnchor="250.0" AnchorPane.topAnchor="133.0">
<children>
<Button alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false" text="Manager">
<VBox.margin>
<Insets bottom="10.0" />
</VBox.margin>
</Button>
<Button alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false" text="Employee">
<VBox.margin>
<Insets top="10.0" />
</VBox.margin>
</Button>
</children>
<opaqueInsets>
<Insets />
</opaqueInsets>
</VBox>
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="187.0" layoutY="52.0" prefHeight="38.0" prefWidth="212.0" text="Scheduler App">
<font>
<Font name="System Bold" size="28.0" />
</font>
</Label>
<Label layoutX="218.0" layoutY="90.0" text="Scheduling made easy">
<font>
<Font name="System Bold Italic" size="14.0" />
</font>
</Label>
</children>
</AnchorPane>
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="540.0" prefWidth="700.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.schedulerapp.Controller">
<children>
<Label alignment="CENTER" minHeight="-Infinity" minWidth="-Infinity" prefHeight="150.0" prefWidth="700.0" text="Add Employee" textAlignment="CENTER">
<font>
<Font name="System Bold" size="28.0" />
</font>
<VBox.margin>
<Insets />
</VBox.margin>
<padding>
<Insets top="50.0" />
</padding>
</Label>
<HBox alignment="CENTER" minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="600.0">
<children>
<Label text="First Name: ">
<font>
<Font size="20.0" />
</font>
</Label>
<TextField fx:id="addFirstName" prefWidth="300.0">
<font>
<Font size="18.0" />
</font>
</TextField>
</children>
</HBox>
<HBox alignment="CENTER" minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="600.0">
<children>
<Label text="Last Name: ">
<font>
<Font size="20.0" />
</font>
</Label>
<TextField fx:id="addLastName" prefWidth="300.0">
<font>
<Font size="18.0" />
</font>
</TextField>
</children>
</HBox>
<HBox alignment="TOP_CENTER" prefHeight="150.0" prefWidth="600.0">
<children>
<Button alignment="CENTER" mnemonicParsing="false" text="Add Employee" onMouseClicked="#addEmployeeClicked">
<font>
<Font size="16.0" />
</font>
<HBox.margin>
<Insets top="25.0" />
</HBox.margin>
</Button>
</children>
</HBox>
</children>
</VBox>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment