diff --git a/Code Files/ContactList.txt b/Code Files/ContactList.txt index b88b387..127332e 100644 --- a/Code Files/ContactList.txt +++ b/Code Files/ContactList.txt @@ -1,11 +1,11 @@ suresh kumar m 8422882287 thane abrar shaikh m 8545525632 malegaon +roshni verma f 8422882286 majiwade aditya tiwari m 7594854565 thane rajesh sharma m 8924073774 panvel ganesh mourya m 9137141840 thane +karan kumar m 8422882284 thane gaurav manohar m 9021409095 kalyan mukesh patel m 8452458565 kurla asha vishwakarma f 7595455412 thane -karan kumar m 8422882286 thane -roshni verma f 8422882286 majiwade sahyog college m 8422882285 thane diff --git a/Code Files/main.c b/Code Files/main.c index 01ef4e8..4b14c03 100644 --- a/Code Files/main.c +++ b/Code Files/main.c @@ -1,13 +1,16 @@ /* Project Title: Phonebook Management System Language: C + GitHub Repository: https://github.com/Alkaison/Phonebook-Management-System + BSc IT Course => Project for Semester-1 Concepts: File Handling, Struct, Define, etc. */ #include // almost everything #include // system() #include // strcmp(), strlen() #include // getch() -#include // Sleep() +#include // Sleep() => for windows OS +#include // for linux or Mac OS #include // isdigit(), isaplha() // define constants -> is used to define the constant or the micro substitution @@ -51,6 +54,7 @@ void adminPanel(); int isValidGender(char *gender); // checks for the gender input int isValidNumeric(char num[]); // checks for the phone number input int isValidName(char *name); // checks string for searchByCity & searchByName +int checkNumberExistence(char *num); // checks for the input number if its exists in the database or not char *removeSpaces(char *str); // removes empty spaces from name inputs void invalidInput(int); // shows error on invalid inputs and returns them back to the panel void clearBuffer(); // clears the output screen & input buffer @@ -135,7 +139,11 @@ void endScreen() printf("\n\t\t\t\t------------------------------------------ \n"); printf("\t\t\t\t >>> Phonebook Management System <<< \n"); printf("\t\t\t\t------------------------------------------ \n\n"); - printf("\t\t\t\t\t\tThank You. \n\n"); + printf("\t\t\t\tGitHub: https://github.com/Alkaison \n"); + printf("\t\t\t\tTwitter: https://twitter.com/Alkaison \n"); + printf("\t\t\t\tLinkedIn: https://linkedin.com/in/Alkaison \n\n"); + printf("\t\t\t\t------------------------------------------ \n"); + printf("\t\t\t\t\t\tThank You. \n"); printf("\t\t\t\t------------------------------------------ \n\n"); Sleep(1500); // pause the screen for 3 seconds exit(0); // ends the program safely @@ -354,6 +362,22 @@ int isValidNumeric(char num[]) return 0; } +int checkNumberExistence(char *num) // checks for the input number if its exists in the database or not +{ + FILE *pT = fopen("ContactList.txt","r"); + + while(fscanf(pT, "%s %s %c %s %s\n",copy.firstName, copy.lastName, ©.gender, copy.findNum, copy.cityName) != EOF) + { + if(strcmp(num, copy.findNum) == 0) + { + fclose(pT); + return 0; + } + } + fclose(pT); + return 1; +} + void invalidInput(int entryCode) { printf("--------------------------------------------- \n"); @@ -419,13 +443,22 @@ void addNewContact() { if(isValidNumeric(contact.findNum) == 1) { - removeSpaces(contact.firstName); - removeSpaces(contact.lastName); - removeSpaces(contact.cityName); - fprintf(pF, "%s %s %c %s %s\n", contact.firstName, contact.lastName, contact.gender, contact.findNum, contact.cityName); - printf("---------------------------------------------- \n"); - printf("Success: Contact details added in the record. \n"); - printf("---------------------------------------------- \n"); + if(checkNumberExistence(contact.findNum)) + { + removeSpaces(contact.firstName); + removeSpaces(contact.lastName); + removeSpaces(contact.cityName); + fprintf(pF, "%s %s %c %s %s\n", contact.firstName, contact.lastName, contact.gender, contact.findNum, contact.cityName); + printf("---------------------------------------------- \n"); + printf("Success: Contact details added in the record. \n"); + printf("---------------------------------------------- \n"); + } + else + { + printf("---------------------------------------------------- \n"); + printf("ERROR: Phone number already exists in the database. \n"); + printf("---------------------------------------------------- \n"); + } } else flag = 1; @@ -490,53 +523,25 @@ void updateContact() printf("Enter the city name: "); gets(copy.cityName); - printf("Enter the gender [M/F]: "); - scanf(" %c",©.gender); - fflush(stdin); - - printf("Enter the phone number [+91]: "); - gets(copy.findNum); - fflush(stdin); printf("\n"); - removeSpaces(copy.findNum); - if(isValidGender(©.gender)) + + printf("Type `CONFIRM` to update this details: "); + gets(confirmDelete); + if(strcmp(confirmDelete, "CONFIRM") == 0) { - if(isValidNumeric(copy.findNum) == 1) - { - printf("Type `CONFIRM` to update this details: "); - gets(confirmDelete); - if(strcmp(confirmDelete, "CONFIRM") == 0) - { - // validates everything and fetchs into file - removeSpaces(copy.firstName); - removeSpaces(copy.lastName); - removeSpaces(copy.cityName); - printf("\nProcessing . . . \n\n"); - fprintf(pT, "%s %s %c %s %s\n",copy.firstName, copy.lastName, copy.gender, copy.findNum, copy.cityName); - flag = 2; - } - else - { - flag = 1; - fprintf(pT, "%s %s %c %s %s\n", contact.firstName, contact.lastName, contact.gender, contact.findNum, contact.cityName); - } - } - else - { - fprintf(pT, "%s %s %c %s %s\n", contact.firstName, contact.lastName, contact.gender, contact.findNum, contact.cityName); - if(len == 0) - { - printf("--------------------------------------------- \n"); - printf("ERROR: Invalid input please try again later. \n"); - printf("--------------------------------------------- \n"); - } - } + // validates everything and fetchs into file + removeSpaces(copy.firstName); + removeSpaces(copy.lastName); + removeSpaces(copy.cityName); + printf("\nProcessing . . . \n\n"); + fprintf(pT, "%s %s %c %s %s\n",copy.firstName, copy.lastName, contact.gender, contact.findNum, copy.cityName); + flag = 2; } else { + flag = 1; fprintf(pT, "%s %s %c %s %s\n", contact.firstName, contact.lastName, contact.gender, contact.findNum, contact.cityName); - flag = 3; } } else @@ -721,14 +726,22 @@ void displayContact(int entryCode) printf("\t\t\t\t---------------------------- \n\n"); pF = fopen("ContactList.txt", "r"); - printf("\t\t|===============================================================| \n"); - printf("\t\t|ID| \tName\t\t| Gender | Phone Number\t| City Name\t| \n"); - printf("\t\t|===============================================================| \n"); + if(fscanf(pF, "%s %s %c %s %s\n",contact.firstName, contact.lastName, &contact.gender, contact.findNum, contact.cityName) != EOF) + { + printf("\t\t|===============================================================| \n"); + printf("\t\t|ID| \tName\t\t| Gender | Phone Number\t| City Name\t| \n"); + printf("\t\t|===============================================================| \n"); - while(fscanf(pF, "%s %s %c %s %s\n",contact.firstName, contact.lastName, &contact.gender, contact.findNum, contact.cityName) != EOF) - printf("\t\t| %d| %s %s \t| %c |\t %s \t| %s \t| \n", counter++, contact.firstName, contact.lastName, contact.gender, contact.findNum, contact.cityName); + do + { + printf("\t\t| %d| %s %s \t| %c |\t %s \t| %s \t| \n", counter++, contact.firstName, contact.lastName, contact.gender, contact.findNum, contact.cityName); - printf("\t\t|===============================================================| \n\n"); + } while(fscanf(pF, "%s %s %c %s %s\n",contact.firstName, contact.lastName, &contact.gender, contact.findNum, contact.cityName) != EOF); + + printf("\t\t|===============================================================| \n\n"); + } + else + printf(" ERROR: Either we are unable to locate the ContactList.txt file or\n\t there are no contacts saved in the file. \n\n"); fclose(pF); system("pause"); diff --git a/Images/UseCaseDiagram.png b/Images/PMS_00_UseCaseDiagram.png similarity index 100% rename from Images/UseCaseDiagram.png rename to Images/PMS_00_UseCaseDiagram.png diff --git a/Images/PMS_01_Information_Page.png b/Images/PMS_01_Information_Page.png deleted file mode 100644 index ca1d01a..0000000 Binary files a/Images/PMS_01_Information_Page.png and /dev/null differ diff --git a/Images/PMS_01_Introduction_Screen.png b/Images/PMS_01_Introduction_Screen.png new file mode 100644 index 0000000..bf53823 Binary files /dev/null and b/Images/PMS_01_Introduction_Screen.png differ diff --git a/Images/PMS_02_Login_Page.png b/Images/PMS_02_Login_Page.png deleted file mode 100644 index 4ab6263..0000000 Binary files a/Images/PMS_02_Login_Page.png and /dev/null differ diff --git a/Images/PMS_02_Login_Screen.png b/Images/PMS_02_Login_Screen.png new file mode 100644 index 0000000..3cd52b5 Binary files /dev/null and b/Images/PMS_02_Login_Screen.png differ diff --git a/Images/PMS_03_Admin_Login_Secure.png b/Images/PMS_03_Admin_Login_Secure.png new file mode 100644 index 0000000..c400cca Binary files /dev/null and b/Images/PMS_03_Admin_Login_Secure.png differ diff --git a/Images/PMS_03_Secure_Password.png b/Images/PMS_03_Secure_Password.png deleted file mode 100644 index f047b74..0000000 Binary files a/Images/PMS_03_Secure_Password.png and /dev/null differ diff --git a/Images/PMS_04_Admin_Panel.png b/Images/PMS_04_Admin_Panel.png index 0061d27..1f6d6f3 100644 Binary files a/Images/PMS_04_Admin_Panel.png and b/Images/PMS_04_Admin_Panel.png differ diff --git a/Images/PMS_05_User_Panel.png b/Images/PMS_05_User_Panel.png index 34165cd..5cc1b03 100644 Binary files a/Images/PMS_05_User_Panel.png and b/Images/PMS_05_User_Panel.png differ diff --git a/Images/PMS_06_AddNewContact.png b/Images/PMS_06_AddNewContact.png new file mode 100644 index 0000000..126f08e Binary files /dev/null and b/Images/PMS_06_AddNewContact.png differ diff --git a/Images/PMS_06_Add_New_Contact.png b/Images/PMS_06_Add_New_Contact.png deleted file mode 100644 index 758c29a..0000000 Binary files a/Images/PMS_06_Add_New_Contact.png and /dev/null differ diff --git a/Images/PMS_07_UpdateContact.png b/Images/PMS_07_UpdateContact.png new file mode 100644 index 0000000..f6e1b10 Binary files /dev/null and b/Images/PMS_07_UpdateContact.png differ diff --git a/Images/PMS_07_Update_Contact.png b/Images/PMS_07_Update_Contact.png deleted file mode 100644 index 16d1e02..0000000 Binary files a/Images/PMS_07_Update_Contact.png and /dev/null differ diff --git a/Images/PMS_08_DisplayAllContacts.png b/Images/PMS_08_DisplayAllContacts.png new file mode 100644 index 0000000..0b306bc Binary files /dev/null and b/Images/PMS_08_DisplayAllContacts.png differ diff --git a/Images/PMS_08_Display_All_Contacts.png b/Images/PMS_08_Display_All_Contacts.png deleted file mode 100644 index 4cb60ef..0000000 Binary files a/Images/PMS_08_Display_All_Contacts.png and /dev/null differ diff --git a/Images/PMS_09_SeachByName.png b/Images/PMS_09_SeachByName.png new file mode 100644 index 0000000..76671b1 Binary files /dev/null and b/Images/PMS_09_SeachByName.png differ diff --git a/Images/PMS_09_Search_By_Name.png b/Images/PMS_09_Search_By_Name.png deleted file mode 100644 index 08eb0e6..0000000 Binary files a/Images/PMS_09_Search_By_Name.png and /dev/null differ diff --git a/Images/PMS_10_SearchByNumber.png b/Images/PMS_10_SearchByNumber.png new file mode 100644 index 0000000..882b9ab Binary files /dev/null and b/Images/PMS_10_SearchByNumber.png differ diff --git a/Images/PMS_10_Search_By_Number.png b/Images/PMS_10_Search_By_Number.png deleted file mode 100644 index 95018b8..0000000 Binary files a/Images/PMS_10_Search_By_Number.png and /dev/null differ diff --git a/Images/PMS_11_Delete_Contact.png b/Images/PMS_11_Delete_Contact.png deleted file mode 100644 index 7cbbab5..0000000 Binary files a/Images/PMS_11_Delete_Contact.png and /dev/null differ diff --git a/Images/PMS_11_SearchByCityName.png b/Images/PMS_11_SearchByCityName.png new file mode 100644 index 0000000..91c0898 Binary files /dev/null and b/Images/PMS_11_SearchByCityName.png differ diff --git a/Images/PMS_12_DeleteContact.png b/Images/PMS_12_DeleteContact.png new file mode 100644 index 0000000..ed0324c Binary files /dev/null and b/Images/PMS_12_DeleteContact.png differ diff --git a/Images/PMS_12_Delete_All_Contact.png b/Images/PMS_12_Delete_All_Contact.png deleted file mode 100644 index 40aecd3..0000000 Binary files a/Images/PMS_12_Delete_All_Contact.png and /dev/null differ diff --git a/Images/PMS_13_DeleteAllContacts.png b/Images/PMS_13_DeleteAllContacts.png new file mode 100644 index 0000000..afe04a6 Binary files /dev/null and b/Images/PMS_13_DeleteAllContacts.png differ diff --git a/Images/PMS_14_NoContactError.png b/Images/PMS_14_NoContactError.png new file mode 100644 index 0000000..dd4f2fb Binary files /dev/null and b/Images/PMS_14_NoContactError.png differ diff --git a/Images/PMS_15_ExitScreen.png b/Images/PMS_15_ExitScreen.png new file mode 100644 index 0000000..668e33d Binary files /dev/null and b/Images/PMS_15_ExitScreen.png differ diff --git a/README.md b/README.md index 4c721b2..f83efdf 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Phonebook Management System in the C programming language is a software applicat ## Description You can learn the fundamentals of functions, file handling, and data -structure by working on the Phonebook Management System mini-project. +structure by working on the Phonebook Management System. This system will show you how to add, list, change or edit, search for, and remove data from/to a file. The functions that make up this project's menu include adding new records, listing them, editing and updating them, looking @@ -14,11 +14,11 @@ for saved contacts, and deleting phonebook entries. ## Documents -- Synopsis report [here](/Documents/PhonebookManagementSystem_Synopsis.pdf) -- Use case diagram [here](/Documents/PhonebookManagementSystem_UseCaseDiagram.pdf) +- Synopsis report [here](/Documents/PhonebookManagementSystem_Synopsis.pdf "Synopsis Report") +- Use case diagram [here](/Documents/PhonebookManagementSystem_UseCaseDiagram.pdf "Use Case Diagram") - Output Images [here](/Images/) -**Note:** If the documents are not rendering on github please download the repository [here](https://github.com/Alkaison/Phonebook-Management-System/archive/refs/heads/main.zip). +**Note:** If the documents are not rendering on github please download the repository [here](https://github.com/Alkaison/Phonebook-Management-System/archive/refs/heads/main.zip "Latest Code"). ## Features @@ -28,11 +28,14 @@ We have used many functions in this project. These functions are very easy to un - Secure Password Login - Admin Panel - User Panel +- Unique phone numbers +- Advance validation function for user input - Add New Contact - Update Contact - Display All Contact - Search By Name - Search By Number +- Search By City - Delete Contact - Delete All Contact @@ -42,59 +45,79 @@ We have used many functions in this project. These functions are very easy to un - A software (IDE) for reviewing the code - C/C++ compiler (Recommended: GCC Compiler) -- Command Prompt or Windows Powershell +- Command Prompt or Windows Powershell **Note:** This program won't run on online compilers as they don't provide libraries for FILE Management & external storing. +## Contributing + +- If you wish to contribute a new function or want to improve the code quality, you are welcome for your contributions. + +- Fork the repository & make changes, after completion open pull request. + +- Thanks in advance 💛 + ## Screenshots 🖼️ -### 01. Information Page +### 01. Introduction Screen -![Information Page](https://i.ibb.co/T8thjdf/PMS-01-Information-Page.png) +![Information Page](https://i.ibb.co/rktHD2C/PMS-01-Introduction-Screen.png) -### 02. Login Page +### 02. Login Screen -![Login Page](https://i.ibb.co/BfqPzCL/PMS-02-Login-Page.png) +![Login Page](https://i.ibb.co/vYn8Fnm/PMS-02-Login-Screen.png) ### 03. Secure Password Login -![Secure Password Login](https://i.ibb.co/kJT6R4J/PMS-03-Secure-Password.png) +![Secure Password Login](https://i.ibb.co/KzPmpFF/PMS-03-Admin-Login-Secure.png) ### 04. Admin Panel -![Admin Panel](https://i.ibb.co/BNP4Rns/PMS-04-Admin-Panel.png) +![Admin Panel](https://i.ibb.co/Fb0gfXv/PMS-04-Admin-Panel.png) ### 05. User Panel -![User Panel](https://i.ibb.co/FqZ35cm/PMS-05-User-Panel.png) +![User Panel](https://i.ibb.co/743mZbx/PMS-05-User-Panel.png) ### 06. Add New Contact -![Add New Contact](https://i.ibb.co/nfR06x6/PMS-06-Add-New-Contact.png) +![Add New Contact](https://i.ibb.co/YtvXhJs/PMS-06-Add-New-Contact.png) ### 07. Update Contact -![Update Contact](https://i.ibb.co/vkh7bYF/PMS-07-Update-Contact.png) +![Update Contact](https://i.ibb.co/vvvXRhh/PMS-07-Update-Contact.png) ### 08. Display All Contact -![Display All Contact](https://i.ibb.co/vJCXBsw/PMS-08-Display-All-Contacts.png) +![Display All Contact](https://i.ibb.co/p2x9cvx/PMS-08-Display-All-Contacts.png) ### 09. Search By Name -![Search By Name](https://i.ibb.co/CtvLXSH/PMS-09-Search-By-Name.png) +![Search By Name](https://i.ibb.co/3MGKWmn/PMS-09-Seach-By-Name.png) ### 10. Search By Number -![Search By Number](https://i.ibb.co/WsRSZjK/PMS-10-Search-By-Number.png) +![Search By Number](https://i.ibb.co/0tL532S/PMS-10-Search-By-Number.png) + +### 11. Search By City Name + +![Search By City Name](https://i.ibb.co/hyXZMhd/PMS-11-Search-By-City-Name.png) + +### 12. Delete Contact + +![Delete Contact](https://i.ibb.co/6DYFThb/PMS-12-Delete-Contact.png) + +### 13. Delete All Contact + +![Delete All Contact](https://i.ibb.co/BP5CdYT/PMS-13-Delete-All-Contacts.png) -### 11. Delete Contact +### 14. No Contacts Error -![Delete Contact](https://i.ibb.co/1zzcpcQ/PMS-11-Delete-Contact.png) +![No Contacts Error](https://i.ibb.co/LSzLfZ8/PMS-14-No-Contact-Error.png) -### 12. Delete All Contact +### 15. Exit Screen -![Delete All Contact](https://i.ibb.co/Smbmhb9/PMS-12-Delete-All-Contact.png) +![Exit Screen](https://i.ibb.co/N3z5qqM/PMS-15-Exit-Screen.png) ## MIT LICENSE 📔