Turf Management System 1
Turf Management System 1
SYSTEM
Created By :
Rahul Ajgaonkar (BITS-ID : 2023MS15040)
Darren Talati (BITS-ID : 2023MS15042)
(Group-25)
CONTENTS
1|Page
Problem Statement
2|Page
Key Stakeholders
Key Stakeholders could include :
Customers/Users : Users are people who want to book turf slots for
their games or sessions. They are the primary users of this system
and together they make the vast majority of our key stakeholders.
3|Page
Key Operations
Key operations include :
1)Authentication : Users can log in from this screen using their IDs
and Passwords.
2)Enter details : Users can enter their details. Details include Name,
Phone number, Address, Email, etc.
3)View booking : Users can view bookings to their name.
4)Delete Booking : Users can delete their existing booking(s).
5)Edit Booking : Users can edit the bookings they’ve made.
4|Page
Source Code
// Function prototypes
void view1();
void update1();
void delete1();
void lookup1();
void add();
void loginProcess();
// Main function
int main() {
int i=0;
time_t t;
time(&t);
char bookingName;
char choice;
system("cls");
printf("\nCurrent date and time : %s",ctime(&t));
system("cls");
loginProcess(); // Call login function
5|Page
system("cls");
while (1) { // Infinite loop for the menu
system("cls");
printf("Use Numbers to Navigate the menu");
printf("\n\n");
printf(" \n1 -> Book Turf");
printf(" \n2 -> View Bookings");
printf(" \n3 -> Delete Booking");
printf(" \n4 -> Search Bookings");
printf(" \n5 -> Edit Booking");
printf(" \n6 -> Exit");
printf("\n");
printf("\n%s",ctime(&t)); // Display current time
choice=getche();
choice=toupper(choice);
switch(choice) { // Switch statement for menu options
case '1':
add(); // Call add function to book a turf
break;
case '2':
view1(); // Call view function to view bookings
break;
case '3':
delete1(); // Call delete function to delete a booking
break;
case '4':
lookup1(); // Call lookup function to search bookings
break;
case '5':
update1(); // Call update function to edit a booking
break;
case '6':
system("cls");
exit(0); // Exit the program
break;
default:
system("cls");
printf("Incorrect Input");
printf("\n Press any key to continue");
getch();
}
}
}
6|Page
f=fopen("add.txt","a+"); // Open file in append mode
if(f==0) {
f=fopen("add.txt","w+"); // If file doesn't exist, create a new
one
system("cls");
printf("\nAny key to continue");
getch();
}
while(1) {
system("cls");
printf("\n Enter Booking Details:");
printf("\n----------------------------");
printf("\n Enter Turf number:\n");
scanf("\n%s",s.turfnumber);
fflush(stdin);
printf("Enter Name:\n");
scanf("%s",s.name);
printf("Enter Address:\n");
scanf("%s",s.address);
printf("Enter Phone Number:\n");
scanf("%s",s.phonenumber);
printf("Enter number of people:\n");
scanf("%s",s.noOfPeople);
printf("Enter Email:\n");
scanf(" %s",s.email);
printf("Enter number of hours:\n");
scanf("%s",&s.noOfHours);
printf("Enter Booking Date(dd\\mm\\yyyy):\n");
scanf("%s",&s.bDate);
fwrite(&s,sizeof(s),1,f); // Write the booking details to file
fflush(stdin);
printf("\n\nTurf booked");
printf("\nEsc to exit, any key to add another booking");
test=getche();
if(test==27)
break;
}
fclose(f);
}
7|Page
printf("NAME\t ");
printf("\tADDRESS ");
printf("\tPHONE ");
printf("\t\tPEOPLE ");
printf("\t EMAIL ");
printf("\t\t \t HOURS ");
printf("\t \tDATE \n");
for(i=0;i<135;i++)
printf("-");
while(fread(&s,sizeof(s),1,f)==1) {
printf("\n%s \t %s \t\t%s \t%s \t%s \t %s \t \t%s \t
\t%s", s.turfnumber, s.name , s.address , s.phonenumber ,
s.noOfPeople , s.email, s.noOfHours, s.bDate);
}
printf("\n");
for(i=0;i<135;i++)
printf("-");
fclose(f);
getch();
}
8|Page
fclose(f);
fclose(t);
remove("add.txt");
rename("temp.txt","add.txt");
printf("\n\nAll bookings are removed");
fclose(f);
fclose(t);
getch();
}
9|Page
char turfnumber[20];
long int size=sizeof(s);
if((f=fopen("add.txt","r+"))==NULL)
exit(0);
system("cls");
printf("Enter Turf number:\n\n");
scanf("%[^\n]", turfnumber);
fflush(stdin);
while(fread(&s,sizeof(s),1,f)==1) {
if(strcmp(s.turfnumber, turfnumber) == 0) {
k=0;
printf("\nEnter Turf Number :");
gets(s.turfnumber);
printf("\nEnter Name :");
fflush(stdin);
scanf("%s",&s.name);
printf("\nEnter Address :");
scanf("%s",&s.address);
printf("\nEnter Phone number :");
scanf("%f",&s.phonenumber);
printf("\nEnter No of People :");
scanf("%s",&s.noOfPeople);
printf("\nEnter Email :");
scanf("%s",&s.email);
printf("\nEnter hours :");
scanf("%s",&s.noOfHours);
printf("\nEnter Date :");
scanf("%s",&s.bDate);
fseek(f,size,SEEK_CUR); //to go to desired position infile
fwrite(&s,sizeof(s),1,f);
break;
}
}
if(k==1) {
printf("\n\nNo Booking");
fclose(f);
getch();
} else {
fclose(f);
printf("\n\n\t\tBooking updated");
getch();
}
}
10 | P a g e
char pword[10],code[10];
char user[10]="admin";
char pass[10]="admin";
do {
system("cls");
printf(" \nUsername: ");
scanf("%s", &uname);
printf("Password: ");
while(i<10) {
pword[i]=getch();
c=pword[i];
if(c==13) break;
else printf("*");
i++;
}
pword[i]='\0';
i=0;
if(strcmp(uname,user)==0 && strcmp(pword,pass)==0) {
break;
} else {
printf("\n Login Unsuccessful");
a++;
getch();
}
} while(a<=2);
if (a>2) {
printf("\nYou have used all attempts");
getch();
}
system("cls");
}
11 | P a g e
Project Screenshots
Authentication Screen :
12 | P a g e
Navigation Menu :
13 | P a g e
Bookings View :
14 | P a g e
View Latest Booking Details :
15 | P a g e
Edit and Update Booking :
16 | P a g e