Skip to content

Commit

Permalink
updated all previous output images, added function for unqiue number …
Browse files Browse the repository at this point in the history
…entry only, updatedContacts are revised to allow changes only to names and city name, added validation for display contacts to check if the file is empty
  • Loading branch information
Alkaison committed Jan 28, 2023
1 parent e389733 commit cbc78bd
Show file tree
Hide file tree
Showing 29 changed files with 114 additions and 78 deletions.
4 changes: 2 additions & 2 deletions Code Files/ContactList.txt
Original file line number Diff line number Diff line change
@@ -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
123 changes: 68 additions & 55 deletions Code Files/main.c
Original file line number Diff line number Diff line change
@@ -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<stdio.h> // almost everything
#include<stdlib.h> // system()
#include<string.h> // strcmp(), strlen()
#include<conio.h> // getch()
#include<windows.h> // Sleep()
#include<windows.h> // Sleep() => for windows OS
#include<unistd.h> // for linux or Mac OS
#include<ctype.h> // isdigit(), isaplha()

// define constants -> is used to define the constant or the micro substitution
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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, &copy.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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -490,53 +523,25 @@ void updateContact()
printf("Enter the city name: ");
gets(copy.cityName);

printf("Enter the gender [M/F]: ");
scanf(" %c",&copy.gender);
fflush(stdin);

printf("Enter the phone number [+91]: ");
gets(copy.findNum);

fflush(stdin);
printf("\n");
removeSpaces(copy.findNum);
if(isValidGender(&copy.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
Expand Down Expand Up @@ -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");
Expand Down
File renamed without changes
Binary file removed Images/PMS_01_Information_Page.png
Binary file not shown.
Binary file added Images/PMS_01_Introduction_Screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/PMS_02_Login_Page.png
Binary file not shown.
Binary file added Images/PMS_02_Login_Screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/PMS_03_Admin_Login_Secure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/PMS_03_Secure_Password.png
Binary file not shown.
Binary file modified Images/PMS_04_Admin_Panel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/PMS_05_User_Panel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/PMS_06_AddNewContact.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/PMS_06_Add_New_Contact.png
Binary file not shown.
Binary file added Images/PMS_07_UpdateContact.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/PMS_07_Update_Contact.png
Binary file not shown.
Binary file added Images/PMS_08_DisplayAllContacts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/PMS_08_Display_All_Contacts.png
Binary file not shown.
Binary file added Images/PMS_09_SeachByName.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/PMS_09_Search_By_Name.png
Binary file not shown.
Binary file added Images/PMS_10_SearchByNumber.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/PMS_10_Search_By_Number.png
Binary file not shown.
Binary file removed Images/PMS_11_Delete_Contact.png
Binary file not shown.
Binary file added Images/PMS_11_SearchByCityName.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/PMS_12_DeleteContact.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/PMS_12_Delete_All_Contact.png
Binary file not shown.
Binary file added Images/PMS_13_DeleteAllContacts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/PMS_14_NoContactError.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/PMS_15_ExitScreen.png
65 changes: 44 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ 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
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

Expand All @@ -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

Expand All @@ -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 📔

Expand Down

0 comments on commit cbc78bd

Please sign in to comment.