Skip to content
Snippets Groups Projects
Commit 9b209a8f authored by mik586's avatar mik586
Browse files

backup shiftype stuff

parent 7a53aca0
No related branches found
No related tags found
1 merge request!6Changed update implementation for employees so rather than sending the whole...
......@@ -25,7 +25,7 @@ public class RafisWeirdClass {
public static void main(String[] args) {
RafisWeirdClass rafisWeirdClass = new RafisWeirdClass();
rafisWeirdClass.schedule.addShift(3, "2022-03-10", 1200, 2100);
rafisWeirdClass.schedule.addShift(3, "2022-03-10", 1200, 2100, "shift");
/* Testing stuff that should be cleaned up for the alpha
String s = model.staff.getEmployees();
System.out.println();
......
......@@ -21,12 +21,12 @@ public class Schedule {
Return: none
*/
protected void addShift(int ID, String date, int start, int end){
protected void addShift(int ID, String date, int start, int end, String shiftType){
Date newDate = Date.valueOf(date);
try {
Statement myStatement = dbConnection.createStatement();
myStatement.executeUpdate("INSERT INTO shifts (employee_id, full_date, start_time, end_time) " +
"VALUES ('" + ID +"', '"+ newDate +"', '"+ start +"', '"+ end +"')");
myStatement.executeUpdate("INSERT INTO shifts (employee_id, full_date, start_time, end_time, shiftType) " +
"VALUES ('" + ID +"', '"+ newDate +"', '"+ start +"', '"+ end +"')'" + shiftType +"'");
} catch (SQLException e) {
e.printStackTrace();
}
......@@ -60,12 +60,13 @@ public class Schedule {
Description: Returns info for all shifts on a given date.
Return: String
*/
protected String getShifts(String date){
protected String getShifts(String date, String shiftType){
Date newDate = Date.valueOf(date);
String response = "getShifts";
try {
Statement myStatement = dbConnection.createStatement();
ResultSet myRs = myStatement.executeQuery("SELECT FROM shifts WHERE (full_date = " + newDate +")");
ResultSet myRs = myStatement.executeQuery("SELECT FROM shifts WHERE (full_date = " + newDate +")" +
"AND WHERE (shift_type = "+ shiftType +")");
while (myRs.next()) {
response = response + "/" + myRs.getString("full_date") + "." +
myRs.getString("employee_id") + "." + myRs.getString("start_time") +
......@@ -78,14 +79,14 @@ public class Schedule {
return response;
}
protected String getShiftsByWeek(String startDate, String endDate){
protected String getShiftsByWeek(String startDate, String endDate, String shiftType){
Date newStart = Date.valueOf(startDate);
Date newEnd = Date.valueOf(endDate);
String response = "getShiftsByWeek";
try {
Statement myStatement = dbConnection.createStatement();
ResultSet myRs = myStatement.executeQuery("SELECT FROM shifts WHERE (full_date >= " + newStart +")" +
"AND WHERE (full_date <= " + newEnd +")");
"AND WHERE (full_date <= " + newEnd +")" + "AND WHERE (shift_type = "+ shiftType +")");
while (myRs.next()) {
response = response + "/" + myRs.getString("full_date") + "." +
myRs.getString("employee_id") + "." + myRs.getString("start_time") +
......@@ -98,14 +99,15 @@ public class Schedule {
return response;
}
protected String getEmployeeShiftsByWeek(int ID, String startDate, String endDate){
protected String getEmployeeShiftsByWeek(int ID, String startDate, String endDate, String shiftType){
Date newStart = Date.valueOf(startDate);
Date newEnd = Date.valueOf(endDate);
String response = "getEmployeeShiftsByWeek";
try {
Statement myStatement = dbConnection.createStatement();
ResultSet myRs = myStatement.executeQuery("SELECT FROM shifts WHERE (full_date >= " + newStart +")" +
"AND WHERE (full_date <= " + newEnd +") AND WHERE (employee_id = "+ ID + ")");
"AND WHERE (full_date <= " + newEnd +") AND WHERE (employee_id = "+ ID + ")" +
"AND WHERE (shift_type = "+ shiftType +")");
while (myRs.next()) {
response = response + "/" + myRs.getString("full_date") + "." +
myRs.getString("employee_id") + "." + myRs.getString("start_time") +
......
......@@ -60,7 +60,7 @@ public class UserThread extends Thread {
break;
case "addShift":
try {
rafisWeirdClass.schedule.addShift(Integer.parseInt(args[1]), args[2], Integer.parseInt(args[3]), Integer.parseInt(args[4]));
rafisWeirdClass.schedule.addShift(Integer.parseInt(args[1]), args[2], Integer.parseInt(args[3]), Integer.parseInt(args[4]), args[5]);
serverMessage = rafisWeirdClass.schedule.allShifts();
server.broadcast(serverMessage);
} catch (NumberFormatException exception) {
......
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