From 7cf0febf2878eae51e1b95ce5706ef39a1387a76 Mon Sep 17 00:00:00 2001 From: fdai7207 Date: Sat, 4 Feb 2023 03:57:16 +0100 Subject: [PATCH] implement the getNewEmployeeCredentials() function in order for the user to sign up as an employee --- build-project.sh | 2 +- src/createEmployeeAccount.c | 19 +++++++++++++++++++ src/createEmployeeAccount.h | 2 ++ src/employeeList.txt | 3 --- src/mainMenu.c | 10 +++++++--- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/build-project.sh b/build-project.sh index aca0b67..9b064c8 100755 --- a/build-project.sh +++ b/build-project.sh @@ -22,7 +22,7 @@ for file in employeeLogin.c mainMenu.c createEmployeeAccount.c; do done # replace .c with .h in respective files -sed -i 's/employeeLogin.c/employeeLogin.h/g' mainMenu.c +sed -i 's/createEmployeeAccount.c/createEmployeeAccount.h/g' mainMenu.c sed -i 's/showGeneralInfoEmployee.c/showGeneralInfoEmployee.h/g' employeeLogin.c sed -i 's/mainMenu.c/mainMenu.h/g' employeeLogin.c sed -i 's/employeeLogin.c/employeeLogin.h/g' createEmployeeAccount.c diff --git a/src/createEmployeeAccount.c b/src/createEmployeeAccount.c index b2743ab..92f0f90 100644 --- a/src/createEmployeeAccount.c +++ b/src/createEmployeeAccount.c @@ -36,3 +36,22 @@ bool createNewEmployee(char* employeeId, char* employeePassword) return checkEmployeeCredentials(employeeId, employeePassword); } +void getNewEmployeeCredentials() +{ + char newEmployeeId[20]; + char newEmployeePassword[20]; + + printf("please enter your wished Id :"); + scanf("%s",newEmployeeId); + printf("please enter your wished Password :"); + scanf("%s",newEmployeePassword); + + if(createNewEmployee(newEmployeeId,newEmployeePassword)) + { + printf("\n\n Account created successfully !\n\n"); + } + else + { + printf("\n\n Could not create the Account please contact an employee of clearance 1 !\n\n"); + } +} diff --git a/src/createEmployeeAccount.h b/src/createEmployeeAccount.h index 4bb2df2..a5b272a 100644 --- a/src/createEmployeeAccount.h +++ b/src/createEmployeeAccount.h @@ -9,4 +9,6 @@ bool isValidEmployeeID(char* employee); bool createNewEmployee(char* employeeId, char* employeePassword); +void getNewEmployeeCredentials(); + #endif \ No newline at end of file diff --git a/src/employeeList.txt b/src/employeeList.txt index 1e66ce6..94986be 100644 --- a/src/employeeList.txt +++ b/src/employeeList.txt @@ -10,6 +10,3 @@ Mohamed MDfdai6618 Shivam Schivam007fdlt3781 - - - diff --git a/src/mainMenu.c b/src/mainMenu.c index e62e11d..b7a8594 100644 --- a/src/mainMenu.c +++ b/src/mainMenu.c @@ -1,6 +1,6 @@ #include "mainMenu.h" - -#include "employeeLogin.c" +#include "employeeLogin.h" +#include "createEmployeeAccount.c" @@ -112,7 +112,10 @@ void menuInput() case 3 : getEmployeeAccessCode(); break; - case 4 : printf("\e[1;1H\e[2J"); + case 4 : getNewEmployeeCredentials(); + break; + + case 5 : printf("\e[1;1H\e[2J"); printf("\nsee you next time !\n\n"); break; } @@ -127,6 +130,7 @@ void showMenu() printf("\n\n\n\n\t\t\t\t\t\t ->Login as an existing costumer."); printf("\n\n\t\t\t\t\t\t ->Register as a new costumer."); printf("\n\n\t\t\t\t\t\t ->Login as an Employee."); + printf("\n\n\t\t\t\t\t\t ->Register as an Employee."); printf("\n\n\t\t\t\t\t\t\t\t ->Exit.\n"); printf("\n\n\n\n\n Selection :\n");