-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprojectdaiko.cpp
558 lines (512 loc) · 12.6 KB
/
projectdaiko.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
struct book
{
char code[20];
char name[100];
int date;
int cost;
};
struct old
{
char nam[100];
char mob[100];
char moviename[100];
int total;
int seats;
int booked[20];
};
struct login
{
char fname[30];
char lname[30];
char username[30];
char password[20];
};
int seat = 60 ;
void login (void);
void registration (void);
void loginre();
void insert_details();//for inserting movie details
void viewAll(); // for view all data
void find(); // for finding data
void book_ticket(); //for booking tickets
void old_record(); //for view old recorrds of users,booked tickets
void support();
int main(void)
{
system("color 2");
int ch,z;
do{
printf("\n");
printf("\n\t\t\t====================================================================\n");
printf("\n");
printf("\t\t\t\t\t\tMOVIE TICKET BOOKING SYSTEM ");
printf("\n");
printf("\n\t\t\t====================================================================");
printf("\n\t\t\t\t\tPress <1> LOGIN AS ADMIN\n");
printf("\n\t\t\t\t\tPress <2> SIGN IN OR REGISTER\n");
printf("\n\t\t\t\t\tPress <3> SUPPORT\n");
printf("\n\t\t\t\t\tPress <0> EXIT\n");
printf("\n\t\t\tEnter your Choice ::");
scanf("%d",&ch);
switch (ch)
{
case 1 :
printf("ENTER <1> TO INSERT DETAILS\n");
printf("ENTER <2> TO VIEW ALL TRANSACTIONS\n");
printf("ENTER <0> TO EXIT\n");
scanf("%d",&z);
if (z==1)
{
insert_details();
}
else if (z==2)
{
old_record();
}
else if (z==0)
{
return 0;
}
else
{
printf("invalid entery");
}
break;
case 2:
loginre();
break;
case 3:
support();
break;
case 4:
return 0;
break;
default:
printf("Wrong choice !");
break;
}
}while(ch!=0);
}
void loginre()
{
int option;
printf("Press '1' to Register\nPress '2' to Login\n\n");
scanf("%d",&option);
getchar();
if(option == 1)
{
system("CLS");
registration();
}
else if(option == 2)
{
system("CLS");
login();
}
}
void login (void)
{
struct login l;
char username[30],password[20];
FILE *log;
log = fopen("login.txt","r+b");
if (log == NULL)
{
printf("Error opening file!");
exit(1);
}
else{
printf("\nPlease Enter your login credentials below\n\n");
printf("PLEASE ENTER YOUR USERNAME: ");
gets(username);
printf("\nPLEASE ENTER PASSWORD: ");
gets(password);
while(fread(&l,sizeof(struct login),1,log))
{
if(strcmp(username,l.username)==0 && strcmp(password,l.password)==0)
{
printf("\nSuccessful Login\n");
int main();
}
else
{
printf("\nIncorrect Login Details\nPlease enter the correct credentials\n");
printf("\nPlease TRY AGAIN or REGISTER FIRST if you haven't yet\n");
login();
}
}
fclose(log);
}
printf("ENTER <1> TO VIEW ALL MOVIES\n");
printf("ENTER <2> TO FIND MOVIES\n");
printf("ENTER <3> TO BOOK A TICKET\n");
printf("ENTER <4> FOR SUPPORT\n");
printf("ENTER <0> TO EXIT\n");
int v;
scanf("%d",&v);
switch (v)
{
case 1:
viewAll();
case 2:
find();
case 3:
book_ticket();
case 4:
support();
case 5:
exit(1);
default:
printf(" invalid entry");
}
return;
}
void support()
{
printf("IF YOU HAVE ANY QUERIES YO CAN CONTACT US\n +977-9862262314\n +977-9841097032\n 01-6630491\nAlso you can email us at: attidamiproject23@cmail.com");
}
void insert_details()
{
FILE *fp;
struct book b;
printf("Enter movie code :- ");
scanf("%s",b.code);
printf("Enter name :- ");
gets(b.name);
gets(b.name);
printf("Enter Release Year:- ");
scanf("%d",&b.date);
printf("Enter Ticket Price:- ");
scanf("%d",&b.cost);
fp=fopen("data.txt","a+b");
if(fp == NULL)
{
printf("File not Found");
}
else
{
fwrite(&b,sizeof(struct book),1,fp);
printf("Record insert Successful");
}
printf("\n");
fclose(fp);
}
void registration(void)
{
char firstname[15];
FILE *log;
log=fopen("login.txt","w+b");
if (log == NULL)
{
printf("Error opening File");
exit(1);
}
struct login l;
printf("\nWelcome to Theatre C. We need to enter some details for registration.\n\n");
printf("\nEnter First Name:");
gets(l.fname);
printf("\nEnter Surname:");
gets(l.lname);
printf("\nNow please choose a USERNAME and PASSWORD as credentials for system login.\n\n");
printf("Ensure the username is no more than 30 characters long\n\n");
printf("Ensure your PASSWORD is at least 8 characters long and contains lowercase, uppercase, numerical and special character values.\n\n");
printf("\nEnter Username:");
gets(l.username);
printf("\nEnter Password:");
gets(l.password);
fwrite(&l,sizeof(struct login),1,log);
fclose(log);
printf("\n\t\t\t\tREGISTRATION COMPLETE\n");
printf("Press any key to continue...");
getchar();
system("CLS");
printf("Enter <1> FOR LOGIN");
printf("ENTER ANY KEY fOR EXIT");
int v;
scanf("%d",&v);
if (v==1)
{
login();
}
else{
exit(1);
}
}
void find() //find details
{
struct book b;
FILE *fp;
int tempprice;
char ch[20];
printf("Enter movie code :");
scanf("%s",ch);
//system("clear");
fp = fopen("data.txt","r+b");
if(fp == NULL)
{
printf("file not found !");
exit(1);
}
else
{
system("cls");
while(fread(&b, sizeof(struct book), 1, fp))
{
if(strcmp(ch,b.code)==0)
{
printf("%Movie Code:%s\t",b.code);
printf("Movie Name: %s\t",b.name);
printf("Movie Release Date: %d\t",b.date);
printf("Ticket Price:NRs %d\t",b.cost);
printf("\n");
printf("\n");
}
}
}
fclose(fp);
}
void viewAll()
{
struct book b;
char ch;
FILE *fp;
fp = fopen("data.txt","r+b");
if(fp == NULL)
{
printf("file does not found !");
exit(1);
}
else
{
system("cls");
while(fread(&b, sizeof(struct book), 1, fp))
{
printf("%Movie Code:%s\t",b.code);
printf("Movie Name: %s\t",b.name);
printf("Movie Release Date: %d\t",b.date);
printf("Per Ticket Price:NRs %d\t",b.cost);
printf("\n");
printf("\n");
}
}
fclose(fp);
}
//for ticket booking
void book_ticket()
{
system("cls");
struct book b;
struct old o;
int c=0,d=0;
FILE *fp;
FILE *ufp;
int total_seat,total_amount;
char mobile[50];
int m,i,j,k,seat[20],tempprice;
int store[100];
char name[50],tempname[50];
char ch; //used in display all movies
char movie_code[20]; //for searching
// disply all moives by default for movie code
fp = fopen("data.txt","r+b");
ufp=fopen("oldTransaction.txt","r+b");
printf("\n");
while(fread(&b, sizeof(struct book), 1, fp))
{
printf("%Movie Code:%s\t",b.code);
printf("Movie Name: %s\t",b.name);
printf("Movie Release Date: %d\t",b.date);
printf("Per Ticket Price:NRs %d\t",b.cost);
printf("\n");
printf("\n");
}
//display ends
printf("\n For booking Ticket choose Movie.\n");
printf("\n Enter movie code :");
scanf("%s",movie_code);
//system("clear");
fp = fopen("data.txt","r");
if(fp == NULL)
{
printf("file does not found !");
exit(1);
}
else
{
system("cls");
while(fread(&b, sizeof(struct book), 1, fp))
{
if(strcmp(movie_code,b.code)==0)
{
printf("%Movie Code:%s\t",b.code);
printf("Movie Name: %s\t",b.name);
strcpy(tempname,b.name);
printf("Movie Release Date: %d\t",b.date);
printf("Per Ticket Price:NRs %d\t",b.cost);
tempprice=b.cost;
printf("\n");
printf("\n");
}
}
}
printf("\n* Fill Details *");
printf("\n Please Enter Your name :");
gets(name);
gets(name);
printf("\n Mobile number :");
gets(mobile);
printf("\n Total number of tickets :");
scanf("%d",&total_seat);
system("cls");
printf("\n");
while(fread(&b, sizeof(struct book), 1, fp))
{
if(strcmp(movie_code,b.code)==0)
{
printf("%Movie Code:%s\t",b.code);
printf("Movie Name: %s\t",b.name);
strcpy(tempname,b.name);
printf("Movie Release Date: %d\t",b.date);
printf("Ticket Price:NRs %d\t",b.cost);
tempprice=b.cost;
printf("\n");
printf("\n");
}
}
fp = fopen("data.txt","r");
if(fp == NULL)
{
printf("file does not found !");
exit(1);
}
else
{
while(fread(&b, sizeof(struct book), 1, fp))
{
if(strcmp(movie_code,b.code)==0)
{
printf("%Movie Code:%s\t",b.code);
printf("Movie Name: %s\t",b.name);
strcpy(tempname,b.name);
printf("Movie Release Date: %d\t",b.date);
printf("Ticket Price:NRs %d\t",b.cost);
tempprice=b.cost;
printf("\n");
printf("\n");
}
}
}
printf("\t\t\t\t\t||SCREEN||\n\n");
fclose(ufp);
fclose(fp);
ufp=fopen("oldTransaction.txt","r+b");
while(fread(&o, sizeof(struct old), 1, ufp))
{
if(strcmp(o.moviename,tempname)==0)
{
for(i=0; i<o.seats; i++)
{
store[c]=o.booked[i];
c=c+1;
}
}
}
for(i=0; i<100; i=i+10)
{
for(j=i; j<i+10; j++)
{
for(k=0; k<c; k++)
{
if(store[k]==j+1)
{
printf("\t*");
d=d+1;
}
}
if(d!=1)
{
printf("\t%d",j+1);
}
d=0;
}
printf("\n");
printf("\n");
}
fclose(ufp);
printf("\n\n\t\t\t\t *-->NOT AVILABLE\n\n\n");
printf("\n Please Choose the Seat Number:\n");
for(i=0; i<total_seat; i++)
{
printf("Seat %d:",i+1);
scanf("%d",&seat[i]);
}
total_amount = tempprice * total_seat;
system("cls");
printf("\n\t\t\t\t\t\t ***** ENJOY THE MOVIE ****\n");
printf("\n\t\t\t\t\t\t-------Costumer Details:-------\n");
printf("\n\t\t\t\t\t\tName : %s\n",name);
printf("\n\t\t\t\t\t\tMobile Number:");
puts(mobile);
printf("\n\t\t\t\t\t\tMovie Name:");
puts(tempname);
printf("\n\t\t\t\t\t\tTotal Seats : %d\n",total_seat);
printf("\n\t\t\t\t\t\tCost per ticket : %d\n",tempprice);
printf("\n\t\t\t\t\t\tTotal Amount : %d\n",total_amount);
printf("\n\t\t\t\t\t\tSeats Chosen:\n");
printf("\t\t\t\t\t\t\t");
for(i=0; i<total_seat; i++)
{
printf("\t%d",seat[i]);
o.booked[i]=seat[i];
}
strcpy(o.nam,name);
strcpy(o.mob,mobile);
strcpy(o.moviename,tempname);
o.seats=total_seat;
o.total=total_amount;
ufp=fopen("oldTransaction.txt","a+b");
if(ufp == NULL)
{
printf("File not Found");
}
else
{
fwrite(&o,sizeof(struct old),1,ufp);
printf("\nSUCCESSFULLY RECORDED");
}
printf("\n");
fclose(ufp);
fclose(fp);
}
//for view all user transactions
void old_record()
{
struct old o;
char ch;
int i;
FILE *fp;
fp=fopen("oldTransaction.txt","r+b");
system("cls");
while(fread(&o, sizeof(struct old), 1, fp))
{
printf("_________________________________");
printf("\nName : %s\n",o.nam);
printf("\nMobile Number:");
printf("%s",o.mob);
printf("\n\nMovie Name:");
puts(o.moviename);
printf("\nTotal Seats : %d\n",o.seats);
printf("\nTotal Amount : %d\n",o.total);
printf("\nSelected Seats:\n");
for(i=0; i<o.seats; i++)
{
printf("\t%d",o.booked[i]);
}
printf("\n");
printf("__________________________________");
}
fclose(fp);
}