Вы находитесь на странице: 1из 10

#include<stdio.h> #include<string.h> #include<graphics.h> #include<conio.

h> struct tt { char city_name[20]; int NOD; char city[20]; char code[7]; int members; char name[20]; char destination[20]; char from[20]; int from_date; int from_month; int from_year; int departure_time; int to_date; int to_month; int to_year; int arrival_time; char mode[10]; int charges; int capacity; int reserved; int vacant; char status[3]; }tt; struct mem { char mn[20]; int ma; char ms[10]; }mm; char tname[40]; void read(); void details(); void display(); void s(); void search(); void list(); void user(); void admin(); void reservation(); void update(); void del(); void main();void bg(); void pwd(); int password(); void bg() { int gd=DETECT,gm; initgraph(&gd,&gm,"c:\\Tc\\BGI"); settextstyle(1,0,3); setcolor(WHITE); setbkcolor(RED); outtextxy(100,50,"POORNIMA COLLEGE OF ENGINEERING");

outtextxy(200,100,"TOUR AND TRAVELS"); outtextxy(25,300,"SUBMITTED TO:"); outtextxy(25,340,"Mr. Sanjay Gupta"); outtextxy(25,360,"(;lecturer)"); outtextxy(400,300,"SUBMITTED BY:"); outtextxy(400,340,"Preksha Salecha "); outtextxy(400,360,"Nitesh Malav"); getch(); } void main() { int p,res,cho,choice,choice1; char ch; int gd=DETECT,gm; bg(); // initgraph(&gd,&gm,"c:\\Tc\\BGI"); settextstyle(1,0,3); setcolor(YELLOW) ; setbkcolor(GREEN); s(); } void s() { char ch; int p,res,cho,choice,choice1; //

cleardevice(); gotoxy(10,10); printf("\n 1.Administrator"); printf("\n\t 2.User"); printf("\n\t 3.Exit"); printf("\n select your choice: "); scanf("%d",&cho) ; switch(cho) {case 1: { admin(); getch();break; } case 2: {user(); getch(); break; } case 3: exit(1); default: { printf("Wrong Choice"); s();} } } void admin() { int res,choice1 ; cleardevice(); setbkcolor(5); setcolor(4); gotoxy(10,10);

res=password(); if(res==0) { while(1) { cleardevice(); gotoxy(10,10); settextstyle(4,0,4); printf("ADMINISTRATOR"); settextstyle(1,0,3); printf("\n 1.Read info"); printf("\n 2.Display info"); printf("\n 3.Search info"); printf("\n 4.Update"); printf("\n 5.Delete"); printf("\n 6.Exit"); printf("\n Enter your choice: "); scanf("%d",&choice1); switch(choice1) { case 1: read(); getch(); break; case 2: display(); getch(); break; case 3: search(); getch(); break; case 4: update(); getch(); break; case 5: del(); getch(); break; case 6: s(); getch(); break; default: printf("\n\toh!!!!!ITs a Wrong Choice \n\t\tTRY AGAIN"); } } } getch(); } void user() { int ch,choice; cleardevice(); setbkcolor(1); gotoxy(10,10); printf("\n 1.Search \n 2.List \n 3.Reservation \n 4.Details of reserved seats \n 5.Return to main menu");

printf("\n Enter your choice: "); scanf("%d",&choice); switch(choice) { case 1: {cleardevice(); gotoxy(10,10); search(); getch(); user(); break; } case 2: { cleardevice(); gotoxy(10,10); list(); getch(); user(); break; } case 3: {cleardevice(); gotoxy(10,10); reservation(); user(); getch(); break; } case 4: { cleardevice(); gotoxy(10,10); details(); getch(); break; } case 5: { s(); getch(); break; } default: { cleardevice(); gotoxy(10,10); printf("Wrong Choice"); user(); } } } //****************search*************** void search() { FILE *fp; char city[30]; fp=fopen("TT1.txt","r"); if(fp==NULL) { printf("file does not exist");

exit(1); } cleardevice(); gotoxy(10,10); printf("Enter the destination you want to search for: "); flushall(); gets(city); while((fread (&tt,sizeof(tt),1,fp))==1) { if(strcmpi(city,tt.destination)==0) { gotoxy(10,10); printf("\n Code of package:\t\t%s",tt.code); printf("\n No. of days:\t\t\t%d",tt.NOD); printf("\n city to start from:\t\t%s",tt.from); printf("\n Destination of the package:\t%s",tt.destination); printf("\n Date Of departure:\t\t%d",tt.from_date); printf("\n Month:\t\t\t\t%d",tt.from_month); printf("\n Year:\t\t\t\t%d",tt.from_year); printf("\n departure time of the trip:\t%d",tt.departure_time); printf("\n Arrival date:\t\t\t%d",tt.to_date); printf("\n month:\t\t\t\t%d",tt.to_month); printf("\n Year:\t\t\t\t%d",tt.to_year); printf("\n mode of transportation:\t%s",tt.mode); printf("\n charges of package:\t\t%d",tt.charges); printf("\n Capacity of the package:\t%d",tt.capacity); printf("\n Reserved seat:\t\t\t%d",tt.reserved); tt.vacant=tt.capacity-tt.reserved; printf("\n Vacant seats:\t\t\t%d",tt.vacant); getch(); } } fclose(fp); getch(); } void update() { del(); read(); } int password() { char pass[] ="POPJ"; char str[20]; int i=0,res; cleardevice(); gotoxy(10,10); printf("Enter Password: "); while( (str[i]=getch() )!= '\r') { printf("*"); i++; } str[i]='\0'; res= strcmp(pass,str); if(res==0) {

cleardevice(); gotoxy(20,20); printf("You have entered correct password"); } else { cleardevice(); gotoxy(20,10); printf("Access Denied..!!You have entered incorrect password"); gotoxy(27,10); printf("\n Re-enter password"); getch(); s(); } return res; } //*****************read***************** void read() { // FILE *fp,*fk; char tname[40]; fp=fopen("TT1.txt","a+"); if(fp==NULL) { printf("error"); exit(1); } cleardevice(); gotoxy(10,10); printf("\n Enter code: "); flushall(); scanf("%s",&tt.code); printf("\n Enter the city to start from: "); flushall(); gets(tt.from); printf("\n Enter your destination: "); flushall(); gets(tt.destination); printf("\n No. of days of the package: "); flushall(); scanf("%d",&tt.NOD); printf("\n Enter date of departure: "); flushall(); scanf("%d",&tt.from_date); printf("\n Enter month: "); flushall(); scanf("%d",&tt.from_month); printf("\n Enter year: "); flushall(); scanf("%d",&tt.from_year); printf("\n Enter deaparture time: "); flushall(); scanf("%d",&tt.departure_time);

printf("\n Enter date of arrival: "); flushall(); scanf("%d",&tt.to_date); printf("\n Enter month: "); flushall(); scanf("%d",&tt.to_month); printf("\n Enter Year: "); flushall(); scanf("%d",&tt.to_year); printf("\n Enter mode of transportation: "); flushall(); gets(tt.mode); printf("\n Enter charges: "); flushall(); scanf("%d",&tt.charges); printf("\n Enter capacity of the package: "); scanf("%d",&tt.capacity); // printf("\n Enter reserved seats: "); // scanf("%d",&tt.reserved); tt.reserved=0; strcpy(tname,tt.code); strcat(tname,".txt"); printf("%s",tname); fwrite(&tt,sizeof(tt),1,fp); fclose(fp); getch(); } //************************DISPLAY**************************** void display () { FILE *fp; fp=fopen("TT1.txt","r"); if(fp==NULL) { printf("error"); exit(1); } while((fread(&tt,sizeof(tt),1,fp))==1) { cleardevice(); gotoxy(10,10); printf("\n Code of package:\t\t%s",tt.code); printf("\n No. of days:\t\t\t%d",tt.NOD); printf("\n city to start from:\t\t%s",tt.from); printf("\n Destination of the package:\t%s",tt.destination); printf("\n Date Of departure:\t\t%d",tt.from_date); printf("\n Month:\t\t\t\t%d",tt.from_month); printf("\n Year:\t\t\t\t%d",tt.from_year); printf("\n departure time of the trip:\t%d",tt.departure_time); printf("\n Arrival date:\t\t\t%d",tt.to_date); printf("\n month:\t\t\t\t%d",tt.to_month); printf("\n Year:\t\t\t\t%d",tt.to_year); printf("\n mode of transportation:\t%s",tt.mode); printf("\n charges of package:\t\t%d",tt.charges); printf("\n Capacity of the package:\t%d",tt.capacity); printf("\n Reserved seat:\t\t\t%d",tt.reserved); tt.vacant=tt.capacity-tt.reserved; printf("\n Vacant seats:\t\t\t%d",tt.vacant);

getch(); } fclose(fp); } void del() { char destination1[20]; FILE *fp,*ft; fp=fopen("TT1.txt","r"); ft=fopen("temp.txt","w+"); if(fp==NULL) { printf("File does not exist"); exit(1); } cleardevice(); gotoxy(10,10); printf("Enter destination: "); flushall(); gets(destination1); while((fread(&tt,sizeof(tt),1,fp))==1) { if(strcmpi(destination1,tt.destination)!=0) fwrite(&tt,sizeof(tt),1,ft); } fcloseall(); remove("TT1.txt"); rename("temp.txt","TT1.txt"); } //***********************RESERVATION************************* void reservation() { int i,m; char c[7]; // char fname[7]; FILE *fp,*fk, *ft; fp=fopen("TT1.txt","r"); fk=fopen(tname,"a+"); ft=fopen("temp.txt","w+"); if(fp==NULL) { printf("File does not exist"); exit(1); } printf("Enter the code of the package you want to select"); flushall(); gets(c); printf("\n Enter number of members: "); flushall(); scanf("%d",&m); rewind(fp); if(tt.reserved<tt.capacity) { while((fread(&tt,sizeof(tt),1,fp))==1) { if(strcmpi(c,tt.code)!=0)

{ fwrite(&tt,sizeof(tt),1,ft); } else { tt.vacant=tt.capacity-m; tt.reserved=tt.reserved+m; fwrite(&tt,sizeof(tt),1,ft); cleardevice(); printf("Your seats have been reserved"); setbkcolor(0); gotoxy(10,10); printf("\n Code of package:\t\t%s",tt.code); printf("\n No. of days:\t\t\t%d",tt.NOD); printf("\n city to start from:\t\t%s",tt.from); printf("\n Destination of the package:\t%s",tt.destination); printf("\n Date Of departure:\t\t%d",tt.from_date); printf("\n Month:\t\t\t\t%d",tt.from_month); printf("\n Year:\t\t\t\t%d",tt.from_year); printf("\n departure time of the trip:\t%d",tt.departure_time); printf("\n Arrival date:\t\t\t%d",tt.to_date); printf("\n month:\t\t\t\t%d",tt.to_month); printf("\n Year:\t\t\t\t%d",tt.to_year); printf("\n mode of transportation:\t%s",tt.mode); printf("\n charges of package:\t\t%d",tt.charges); printf("\n Capacity of the package:\t%d",tt.capacity); printf("\n Reserved seat:\t\t\t%d",tt.reserved); tt.vacant=tt.capacity-tt.reserved; printf("\n Vacant seats:\t\t\t%d",tt.vacant); getch(); cleardevice(); gotoxy(10,10); printf("Enter details of members"); // while((fread(&tt,sizeof(tt),1,fp))==1) // { for(i=1;i<=m;i++) { printf("\n Member %d: ", i); printf("\n Enter Name: "); flushall(); gets(mm.mn); printf("\n Enter Age: "); flushall(); scanf("%d",&mm.ma); printf("\n Enter sex: "); flushall(); gets(mm.ms); fwrite(&mm,sizeof(mm),1,fk); getch(); } } } } else { cleardevice(); gotoxy(20,10);

printf("Sorry! No vacant seats available"); getch(); }

fcloseall(); remove("TT1.txt"); rename("temp.txt","TT1.txt"); getch(); } void list() { setbkcolor(0); display(); getch(); } void details() { FILE *fk; int i; char cd[7]; printf("Enter Code Of The Package"); flushall(); gets(cd); strcpy(tname,cd); strcat(tname,".txt"); fk=fopen(tname,"r"); while((fread(&mm,sizeof(mm),1,fk))==1) { printf("\n Member Details"); printf("\n Name: \t\t%s ",mm.mn); printf("\n Age:\t\t%d ",mm.ma); printf("\n Sex:\t\t%s ",mm.ms);

getch(); } user(); }

Вам также может понравиться