0% found this document useful (0 votes)
15 views14 pages

Faisal

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views14 pages

Faisal

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

1 //list of header files

2 #include <windows.h>
3 #include<stdio.h> //contains printf,scanf etc
4 #include<conio.h> //contains delay(),getch(),gotoxy(),etc.
5 #include <stdlib.h>
6 #include<string.h> //contains strcmp(),strcpy(),strlen(),etc
7 #include<ctype.h> //contains toupper(), tolower(),etc
8 #include<dos.h> //contains _dos_getdate
9 #include<time.h>
10
11 #define RETURNTIME 15
12
13 //list of function prototype
14 char catagories[][15]={"Computer","Electronics","Electrical","Civil","Mechnnical","Architecture"};
15 void returnfunc(void);
16 void mainmenu(void);
17 void addbooks(void);
18 void deletebooks(void);
19 void editbooks(void);
20 void searchbooks(void);
21 void issuebooks(void);
22 void viewbooks(void);
23 void closeapplication(void);
24 int getdata();
25 int checkid(int);
26 int t(void);
27 //void show_mouse(void);
28 void Password();
29 void issuerecord();
30 void loaderanim();
31
32 COORD coord = {0, 0}; // sets coordinates to 0,0
33 //COORD max_buffer_size = GetLargestConsoleWindowSize(hOut);
34 COORD max_res,cursor_size;
35 void gotoxy (int x, int y)
36 {
37 coord.X = x; coord.Y = y; // X and Y coordinates
38 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
39 }
40 void delay(unsigned int mseconds)
41 {
42 clock_t goal = mseconds + clock();
43 while (goal > clock());
44 }
45 //list of global files that can be acceed form anywhere in program
46 FILE *fp,*ft,*fs;
47
48 //list of global variable
49 int s;
50 char findbook;
51 char password[10]={"yemen"};
52
53
54 struct meroDate
55 {
56 int mm,dd,yy;
57 };
58 struct books
59 {
60 int id;
61 char stname[20];
62 char name[20];
63 char Author[20];
64 int quantity;
65 float Price;
66 int count;
67 int rackno;
68 char *cat;
69 struct meroDate issued;
70 struct meroDate duedate;
71 };
72 struct books a;
73 int main()
74
75 {
76 Password();
77 getch();
78 return 0;
79
80 }
81 void mainmenu()
82 {
83 //loaderanim();
84 system("cls");
85 // textbackground(13);
86 int i;
87 gotoxy(20,3);
88 printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2 MAIN MENU
\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
89 //show_mouse();
90 gotoxy(20,5);
91 printf("\xDB\xDB\xDB\xDB\xB2 1. Add Books ");
92 gotoxy(20,7);
93 printf("\xDB\xDB\xDB\xDB\xB2 2. Delete books");
94 gotoxy(20,9);
95 printf("\xDB\xDB\xDB\xDB\xB2 3. Search Books");
96 gotoxy(20,11);
97 printf("\xDB\xDB\xDB\xDB\xB2 4. Issue Books");
98 gotoxy(20,13);
99 printf("\xDB\xDB\xDB\xDB\xB2 5. View Book list");
100 gotoxy(20,15);
101 printf("\xDB\xDB\xDB\xDB\xB2 6. Edit Book's Record");
102 gotoxy(20,17);
103 printf("\xDB\xDB\xDB\xDB\xB2 7. Close Application");
104 gotoxy(20,19);
105 printf(
"\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB
2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
106 gotoxy(20,20);
107 t();
108 gotoxy(20,21);
109 printf("Enter your choice:");
110 switch(getch())
111 {
112 case '1':
113 addbooks();
114 break;
115 case '2':
116 deletebooks();
117 break;
118 case '3':
119 searchbooks();
120 break;
121 case '4':
122 issuebooks();
123 break;
124 case '5':
125 viewbooks();
126 break;
127 case '6':
128 editbooks();
129 break;
130 case '7':
131 {
132 system("cls");
133 gotoxy(16,3);
134 printf("Programmers....");
135 gotoxy(16,4);
136 printf("1. Faisal Gahlan ");
137 gotoxy(16,5);
138 printf(" Ac.No:202270242");
139 gotoxy(16,7);
140 printf("2. Maan Manea ");
141 gotoxy(16,8);
142 printf(" Ac.No:202270095 ");
143 gotoxy(16,10);
144 printf("3. Talal AL-Degry ");
145 gotoxy(16,11);
146 printf(" Ac.No:202270020 ");
147 gotoxy(16,13);
148 printf("4. Ramiz Al-Qabaty ");
149 gotoxy(16,14);
150 printf(" Ac.No:202270171 ");
151 gotoxy(16,16);
152 printf("With the Unexplainable Help of eng.Ryan");
153 gotoxy(10,19);
154 printf("Exiting in 3 second...........>");
155 //flushall();
156 delay(3000);
157 exit(0);
158 }
159 default:
160 {
161 gotoxy(10,23);
162 printf("\aWrong Entry!!Please re-entered correct option");
163 if(getch())
164 mainmenu();
165 }
166
167 }
168 }
169 void addbooks(void) //funtion that add books
170 {
171 system("cls");
172 int i;
173 gotoxy(20,5);
174 printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2SELECT
CATEGOIES\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
175 gotoxy(20,7);
176 printf("\xDB\xDB\xDB\xDB\xB2 1. Computer");
177 gotoxy(20,9);
178 printf("\xDB\xDB\xDB\xDB\xB2 2. Electronics");
179 gotoxy(20,11);
180 printf("\xDB\xDB\xDB\xDB\xB2 3. Electrical");
181 gotoxy(20,13);
182 printf("\xDB\xDB\xDB\xDB\xB2 4. Civil");
183 gotoxy(20,15);
184 printf("\xDB\xDB\xDB\xDB\xB2 5. Mechanical");
185 gotoxy(20,17);
186 printf("\xDB\xDB\xDB\xDB\xB2 6. Architecture");
187 gotoxy(20,19);
188 printf("\xDB\xDB\xDB\xDB\xB2 7. Back to main menu");
189 gotoxy(20,21);
190 printf(
"\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB
2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
191 gotoxy(20,22);
192 printf("Enter your choice:");
193 scanf("%d",&s);
194 if(s==7)
195
196 mainmenu() ;
197 system("cls");
198 fp=fopen("Bibek.dat","ab+");
199 if(getdata()==1)
200 {
201 a.cat=catagories[s-1];
202 fseek(fp,0,SEEK_END);
203 fwrite(&a,sizeof(a),1,fp);
204 fclose(fp);
205 gotoxy(21,14);
206 printf("The record is sucessfully saved");
207 gotoxy(21,15);
208 printf("Save any more?(Y / N):");
209 if(getch()=='n')
210 mainmenu();
211 else
212 system("cls");
213 addbooks();
214 }
215 }
216 void deletebooks() //function that delete items from file fp
217 {
218 system("cls");
219 int d;
220 char another='y';
221 while(another=='y') //infinite loop
222 {
223 system("cls");
224 gotoxy(10,5);
225 printf("Enter the Book ID to delete:");
226 scanf("%d",&d);
227 fp=fopen("Bibek.dat","rb+");
228 rewind(fp);
229 while(fread(&a,sizeof(a),1,fp)==1)
230 {
231 if(a.id==d)
232 {
233
234 gotoxy(10,7);
235 printf("The book record is available");
236 gotoxy(10,8);
237 printf("Book name is %s",a.name);
238 gotoxy(10,9);
239 printf("Rack No. is %d",a.rackno);
240 findbook='t';
241 }
242 }
243 if(findbook!='t')
244 {
245 gotoxy(10,10);
246 printf("No record is found modify the search");
247 if(getch())
248 mainmenu();
249 }
250 if(findbook=='t' )
251 {
252 gotoxy(10,9);
253 printf("Do you want to delete it?(Y/N):");
254 if(getch()=='y')
255 {
256 ft=fopen("test.dat","wb+"); //temporary file for delete
257 rewind(fp);
258 while(fread(&a,sizeof(a),1,fp)==1)
259 {
260 if(a.id!=d)
261 {
262 fseek(ft,0,SEEK_CUR);
263 fwrite(&a,sizeof(a),1,ft); //write all in tempory file except that
264 } //we want to delete
265 }
266 fclose(ft);
267 fclose(fp);
268 remove("Bibek.dat");
269 rename("test.dat","Bibek.dat"); //copy all item from temporary file to fp except that
270 fp=fopen("Bibek.dat","rb+"); //we want to delete
271 if(findbook=='t')
272 {
273 gotoxy(10,10);
274 printf("The record is sucessfully deleted");
275 gotoxy(10,11);
276 printf("Delete another record?(Y/N)");
277 }
278 }
279 else
280 mainmenu();
281 fflush(stdin);
282 another=getch();
283 }
284 }
285 gotoxy(10,15);
286 mainmenu();
287 }
288 void searchbooks()
289 {
290 system("cls");
291 int d;
292 printf("*****************************Search Books*********************************");
293 gotoxy(20,10);
294 printf("\xDB\xDB\xDB\xB2 1. Search By ID");
295 gotoxy(20,14);
296 printf("\xDB\xDB\xDB\xB2 2. Search By Name");
297 gotoxy( 15,20);
298 printf("Enter Your Choice");
299 fp=fopen("Bibek.dat","rb+"); //open file for reading propose
300 rewind(fp); //move pointer at the begining of file
301 switch(getch())
302 {
303 case '1':
304 {
305 system("cls");
306 gotoxy(25,4);
307 printf("****Search Books By Id****");
308 gotoxy(20,5);
309 printf("Enter the book id:");
310 scanf("%d",&d);
311 gotoxy(20,7);
312 printf("Searching........");
313 while(fread(&a,sizeof(a),1,fp)==1)
314 {
315 if(a.id==d)
316 {
317 delay(2);
318 gotoxy(20,7);
319 printf("The Book is available");
320 gotoxy(20,8);
321 printf(
"\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB
2");
322 gotoxy(20,9);
323 printf("\xB2 ID:%d",a.id);gotoxy(47,9);printf("\xB2");
324 gotoxy(20,10);
325 printf("\xB2 Name:%s",a.name);gotoxy(47,10);printf("\xB2");
326 gotoxy(20,11);
327 printf("\xB2 Author:%s ",a.Author);gotoxy(47,11);printf("\xB2");
328 gotoxy(20,12);
329 printf("\xB2 Qantity:%d ",a.quantity);gotoxy(47,12);printf("\xB2"); gotoxy(47,11);printf("\xB2"
);
330 gotoxy(20,13);
331 printf("\xB2 Price:Rs.%.2f",a.Price);gotoxy(47,13);printf("\xB2");
332 gotoxy(20,14);
333 printf("\xB2 Rack No:%d ",a.rackno);gotoxy(47,14);printf("\xB2");
334 gotoxy(20,15);
335 printf(
"\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB
2");
336 findbook='t';
337 }
338
339 }
340 if(findbook!='t') //checks whether conditiion enters inside loop or not
341 {
342 gotoxy(20,8);
343 printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
344 gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2");
345 gotoxy(20,10);
346 printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
347 gotoxy(22,9);printf("\aNo Record Found");
348 }
349 gotoxy(20,17);
350 printf("Try another search?(Y/N)");
351 if(getch()=='y')
352 searchbooks();
353 else
354 mainmenu();
355 break;
356 }
357 case '2':
358 {
359 char s[15];
360 system("cls");
361 gotoxy(25,4);
362 printf("****Search Books By Name****");
363 gotoxy(20,5);
364 printf("Enter Book Name:");
365 scanf("%s",s);
366 int d=0;
367 while(fread(&a,sizeof(a),1,fp)==1)
368 {
369 if(strcmp(a.name,(s))==0) //checks whether a.name is equal to s or not
370 {
371 gotoxy(20,7);
372 printf("The Book is available");
373 gotoxy(20,8);
374 printf(
"\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB
2");
375 gotoxy(20,9);
376 printf("\xB2 ID:%d",a.id);gotoxy(47,9);printf("\xB2");
377 gotoxy(20,10);
378 printf("\xB2 Name:%s",a.name);gotoxy(47,10);printf("\xB2");
379 gotoxy(20,11);
380 printf("\xB2 Author:%s",a.Author);gotoxy(47,11);printf("\xB2");
381 gotoxy(20,12);
382 printf("\xB2 Qantity:%d",a.quantity);gotoxy(47,12);printf("\xB2");
383 gotoxy(20,13);
384 printf("\xB2 Price:Rs.%.2f",a.Price);gotoxy(47,13);printf("\xB2");
385 gotoxy(20,14);
386 printf("\xB2 Rack No:%d ",a.rackno);gotoxy(47,14);printf("\xB2");
387 gotoxy(20,15);
388 printf(
"\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB
2");
389 d++;
390 }
391
392 }
393 if(d==0)
394 {
395 gotoxy(20,8);
396 printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
397 gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2");
398 gotoxy(20,10);
399 printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
400 gotoxy(22,9);printf("\aNo Record Found");
401 }
402 gotoxy(20,17);
403 printf("Try another search?(Y/N)");
404 if(getch()=='y')
405 searchbooks();
406 else
407 mainmenu();
408 break;
409 }
410 default :
411 getch();
412 searchbooks();
413 }
414 fclose(fp);
415 }
416 void issuebooks(void) //function that issue books from library
417 {
418 int t;
419
420 system("cls");
421 printf("********************************ISSUE SECTION**************************");
422 gotoxy(10,5);
423 printf("\xDB\xDB\xDB\xDb\xB2 1. Issue a Book");
424 gotoxy(10,7);
425 printf("\xDB\xDB\xDB\xDb\xB2 2. View Issued Book");
426 gotoxy(10,9);
427 printf("\xDB\xDB\xDB\xDb\xB2 3. Search Issued Book");
428 gotoxy(10,11);
429 printf("\xDB\xDB\xDB\xDb\xB2 4. Remove Issued Book");
430 gotoxy(10,14);
431 printf("Enter a Choice:");
432 switch(getch())
433 {
434 case '1': //issue book
435 {
436 system("cls");
437 int c=0;
438 char another='y';
439 while(another=='y')
440 {
441 system("cls");
442 gotoxy(15,4);
443 printf("***Issue Book section***");
444 gotoxy(10,6);
445 printf("Enter the Book Id:");
446 scanf("%d",&t);
447 fp=fopen("Bibek.dat","rb");
448 fs=fopen("Issue.dat","ab+");
449 if(checkid(t)==0) //issues those which are present in library
450 {
451 gotoxy(10,8);
452 printf("The book record is available");
453 gotoxy(10,9);
454 printf("There are %d unissued books in library ",a.quantity);
455 gotoxy(10,10);
456 printf("The name of book is %s",a.name);
457 gotoxy(10,11);
458 printf("Enter student name:");
459 scanf("%s",a.stname);
460 // struct dosdate_t d; //for current date
461 // _dos_getdate(&d);
462 // a.issued.dd=d.day;
463 // a.issued.mm=d.month;
464 //a.issued.yy=d.year;
465 gotoxy(10,12);
466 printf("Issued date=%d-%d-%d",a.issued.dd,a.issued.mm,a.issued.yy);
467 gotoxy(10,13);
468 printf("The BOOK of ID %d is issued",a.id);
469 a.duedate.dd=a.issued.dd+RETURNTIME; //for return date
470 a.duedate.mm=a.issued.mm;
471 a.duedate.yy=a.issued.yy;
472 if(a.duedate.dd>30)
473 {
474 a.duedate.mm+=a.duedate.dd/30;
475 a.duedate.dd-=30;
476
477 }
478 if(a.duedate.mm>12)
479 {
480 a.duedate.yy+=a.duedate.mm/12;
481 a.duedate.mm-=12;
482
483 }
484 gotoxy(10,14);
485 printf("To be return:%d-%d-%d",a.duedate.dd,a.duedate.mm,a.duedate.yy);
486 fseek(fs,sizeof(a),SEEK_END);
487 fwrite(&a,sizeof(a),1,fs);
488 fclose(fs);
489 c=1;
490 }
491 if(c==0)
492 {
493 gotoxy(10,11);
494 printf("No record found");
495 }
496 gotoxy(10,15);
497 printf("Issue any more(Y/N):");
498 fflush(stdin);
499 another=getche();
500 fclose(fp);
501 }
502
503 break;
504 }
505 case '2': //show issued book list
506 {
507 system("cls");
508 int j=4;
509 printf("*******************************Issued book list*******************************\n");
510 gotoxy(2,2);
511 printf("STUDENT NAME CATEGORY ID BOOK NAME ISSUED DATE RETURN DATE");
512 fs=fopen("Issue.dat","rb");
513 while(fread(&a,sizeof(a),1,fs)==1)
514 {
515
516 gotoxy(2,j);
517 printf("%s",a.stname);
518 gotoxy(18,j);
519 printf("%s",a.cat);
520 gotoxy(30,j);
521 printf("%d",a.id);
522 gotoxy(36,j);
523 printf("%s",a.name);
524 gotoxy(51,j);
525 printf("%d-%d-%d",a.issued.dd,a.issued.mm,a.issued.yy );
526 gotoxy(65,j);
527 printf("%d-%d-%d",a.duedate.dd,a.duedate.mm,a.duedate.yy);
528 //struct dosdate_t d;
529 //_dos_getdate(&d);
530 gotoxy(50,25);
531 // printf("Current date=%d-%d-%d",d.day,d.month,d.year);
532 j++;
533
534 }
535 fclose(fs);
536 gotoxy(1,25);
537 returnfunc();
538 }
539 break;
540 case '3': //search issued books by id
541 {
542 system("cls");
543 gotoxy(10,6);
544 printf("Enter Book ID:");
545 int p,c=0;
546 char another='y';
547 while(another=='y')
548 {
549
550 scanf("%d",&p);
551 fs=fopen("Issue.dat","rb");
552 while(fread(&a,sizeof(a),1,fs)==1)
553 {
554 if(a.id==p)
555 {
556 issuerecord();
557 gotoxy(10,12);
558 printf("Press any key.......");
559 getch();
560 issuerecord();
561 c=1;
562 }
563
564 }
565 fflush(stdin);
566 fclose(fs);
567 if(c==0)
568 {
569 gotoxy(10,8);
570 printf("No Record Found");
571 }
572 gotoxy(10,13);
573 printf("Try Another Search?(Y/N)");
574 another=getch();
575 }
576 }
577 break;
578 case '4': //remove issued books from list
579 {
580 system("cls");
581 int b;
582 FILE *fg; //declaration of temporary file for delete
583 char another='y';
584 while(another=='y')
585 {
586 gotoxy(10,5);
587 printf("Enter book id to remove:");
588 scanf("%d",&b);
589 fs=fopen("Issue.dat","rb+");
590 while(fread(&a,sizeof(a),1,fs)==1)
591 {
592 if(a.id==b)
593 {
594 issuerecord();
595 findbook='t';
596 }
597 if(findbook=='t')
598 {
599 gotoxy(10,12);
600 printf("Do You Want to Remove it?(Y/N)");
601 if(getch()=='y')
602 {
603 fg=fopen("record.dat","wb+");
604 rewind(fs);
605 while(fread(&a,sizeof(a),1,fs)==1)
606 {
607 if(a.id!=b)
608 {
609 fseek(fs,0,SEEK_CUR);
610 fwrite(&a,sizeof(a),1,fg);
611 }
612 }
613 fclose(fs);
614 fclose(fg);
615 remove("Issue.dat");
616 rename("record.dat","Issue.dat");
617 gotoxy(10,14);
618 printf("The issued book is removed from list");
619
620 }
621
622 }
623 if(findbook!='t')
624 {
625 gotoxy(10,15);
626 printf("No Record Found");
627 }
628 }
629 gotoxy(10,16);
630 printf("Delete any more?(Y/N)");
631 another=getch();
632 }
633 }
634 default:
635 gotoxy(10,18);
636 printf("\aWrong Entry!!");
637 getch();
638 issuebooks();
639 break;
640 }
641 gotoxy(1,30);
642 returnfunc();
643 }
644 void viewbooks(void) //show the list of book persists in library
645 {
646 int i=0,j;
647 system("cls");
648 gotoxy(1,1);
649 printf("*********************************Book List*****************************");
650 gotoxy(2,2);
651 printf(" CATEGORY ID BOOK NAME AUTHOR QTY PRICE RackNo ");
652 j=4;
653 fp=fopen("Bibek.dat","rb");
654 while(fread(&a,sizeof(a),1,fp)==1)
655 {
656 gotoxy(3,j);
657 printf("%s",a.cat);
658 gotoxy(16,j);
659 printf("%d",a.id);
660 gotoxy(22,j);
661 printf("%s",a.name);
662 gotoxy(36,j);
663 printf("%s",a.Author);
664 gotoxy(50,j);
665 printf("%d",a.quantity);
666 gotoxy(57,j);
667 printf("%.2f",a.Price);
668 gotoxy(69,j);
669 printf("%d",a.rackno);
670 printf("\n\n");
671 j++;
672 i=i+a.quantity;
673 }
674 gotoxy(3,25);
675 printf("Total Books =%d",i);
676 fclose(fp);
677 gotoxy(35,25);
678 returnfunc();
679 }
680 void editbooks(void) //edit information about book
681 {
682 system("cls");
683 int c=0;
684 int d,e;
685 gotoxy(20,4);
686 printf("****Edit Books Section****");
687 char another='y';
688 while(another=='y')
689 {
690 system("cls");
691 gotoxy(15,6);
692 printf("Enter Book Id to be edited:");
693 scanf("%d",&d);
694 fp=fopen("Bibek.dat","rb+");
695 while(fread(&a,sizeof(a),1,fp)==1)
696 {
697 if(checkid(d)==0)
698 {
699 gotoxy(15,7);
700 printf("The book is availble");
701 gotoxy(15,8);
702 printf("The Book ID:%d",a.id);
703 gotoxy(15,9);
704 printf("Enter new name:");scanf("%s",a.name);
705 gotoxy(15,10);
706 printf("Enter new Author:");scanf("%s",a.Author);
707 gotoxy(15,11);
708 printf("Enter new quantity:");scanf("%d",&a.quantity);
709 gotoxy(15,12);
710 printf("Enter new price:");scanf("%f",&a.Price);
711 gotoxy(15,13);
712 printf("Enter new rackno:");scanf("%d",&a.rackno);
713 gotoxy(15,14);
714 printf("The record is modified");
715 fseek(fp,ftell(fp)-sizeof(a),0);
716 fwrite(&a,sizeof(a),1,fp);
717 fclose(fp);
718 c=1;
719 }
720 if(c==0)
721 {
722 gotoxy(15,9);
723 printf("No record found");
724 }
725 }
726 gotoxy(15,16);
727 printf("Modify another Record?(Y/N)");
728 fflush(stdin);
729 another=getch() ;
730 }
731 returnfunc();
732 }
733 void returnfunc(void)
734 {
735 {
736 printf(" Press ENTER to return to main menu");
737 }
738 a:
739 if(getch()==13) //allow only use of enter
740 mainmenu();
741 else
742 goto a;
743 }
744 int getdata()
745 {
746 int t;
747 gotoxy(20,3);printf("Enter the Information Below");
748 gotoxy(20,4);printf(
"\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
749 gotoxy(20,5);
750 printf("\xB2");gotoxy(46,5);printf("\xB2");
751 gotoxy(20,6);
752 printf("\xB2");gotoxy(46,6);printf("\xB2");
753 gotoxy(20,7);
754 printf("\xB2");gotoxy(46,7);printf("\xB2");
755 gotoxy(20,8);
756 printf("\xB2");gotoxy(46,8);printf("\xB2");
757 gotoxy(20,9);
758 printf("\xB2");gotoxy(46,9);printf("\xB2");
759 gotoxy(20,10);
760 printf("\xB2");gotoxy(46,10);printf("\xB2");
761 gotoxy(20,11);
762 printf("\xB2");gotoxy(46,11);printf("\xB2");
763 gotoxy(20,12);
764 printf(
"\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
765 gotoxy(21,5);
766 printf("Category:");
767 gotoxy(31,5);
768 printf("%s",catagories[s-1]);
769 gotoxy(21,6);
770 printf("Book ID:\t");
771 gotoxy(30,6);
772 scanf("%d",&t);
773 if(checkid(t) == 0)
774 {
775 gotoxy(21,13);
776 printf("\aThe book id already exists\a");
777 getch();
778 mainmenu();
779 return 0;
780 }
781 a.id=t;
782 gotoxy(21,7);
783 printf("Book Name:");gotoxy(33,7);
784 scanf("%s",a.name);
785 gotoxy(21,8);
786 printf("Author:");gotoxy(30,8);
787 scanf("%s",a.Author);
788 gotoxy(21,9);
789 printf("Quantity:");gotoxy(31,9);
790 scanf("%d",&a.quantity);
791 gotoxy(21,10);
792 printf("Price:");gotoxy(28,10);
793 scanf("%f",&a.Price);
794 gotoxy(21,11);
795 printf("Rack No:");gotoxy(30,11);
796 scanf("%d",&a.rackno);
797 return 1;
798 }
799 int checkid(int t) //check whether the book is exist in library or not
800 {
801 rewind(fp);
802 while(fread(&a,sizeof(a),1,fp)==1)
803 if(a.id==t)
804 return 0; //returns 0 if book exits
805 return 1; //return 1 if it not
806 }
807 int t(void) //for time
808 {
809 time_t t;
810 time(&t);
811 printf("Date and time:%s\n",ctime(&t));
812
813 return 0 ;
814 }
815 //void show_mouse(void) //show inactive mouse pointer in programme
816 //{
817 //union REGS in,out;
818 //
819 // in.x.ax = 0x1;
820 // int86(0x33,&in,&out);
821 //}
822 void Password(void) //for password option
823 {
824
825 system("cls");
826 char d[25]="Password Protected";
827 char ch,pass[10];
828 int i=0,j;
829 //textbackground(WHITE);
830 //textcolor(RED);
831 gotoxy(10,4);
832 for(j=0;j<20;j++)
833 {
834 delay(10);
835 printf("*");
836 }
837 for(j=0;j<20;j++)
838 {
839 delay(10);
840 printf("%c",d[j]);
841 }
842 for(j=0;j<20;j++)
843 {
844 delay(10);
845 printf("*");
846 }
847 gotoxy(10,10);
848 gotoxy(15,7);
849 printf("Enter Password:");
850
851 while(ch!=13)
852 {
853 ch=getch();
854
855 if(ch!=13 && ch!=8){
856 putch('*');
857 pass[i] = ch;
858 i++;
859 }
860 }
861 pass[i] = '\0';
862 if(strcmp(pass,password)==0)
863 {
864
865 gotoxy(15,9);
866 //textcolor(BLINK);
867 printf("Password match");
868 gotoxy(17,10);
869 printf("Press any key to countinue.....");
870 getch();
871 mainmenu();
872 }
873 else
874 {
875 gotoxy(15,16);
876 printf("\aWarning!! Incorrect Password");
877 getch();
878 Password();
879 }
880 }
881 void issuerecord() //display issued book's information
882 {
883 system("cls");
884 gotoxy(10,8);
885 printf("The Book has taken by Mr. %s",a.stname);
886 gotoxy(10,9);
887 printf("Issued Date:%d-%d-%d",a.issued.dd,a.issued.mm,a.issued.yy);
888 gotoxy(10,10);
889 printf("Returning Date:%d-%d-%d",a.duedate.dd,a.duedate.mm,a.duedate.yy);
890 }
891 void loaderanim()
892 {
893 int loader;
894 system("cls");
895 gotoxy(20,10);
896 printf("LOADING........");
897 printf("\n\n");
898 gotoxy(22,11);
899 for(loader=1;loader<20;loader++)
900 {
901 delay(100);printf("%c",219);}
902 }
903 //End of program
904

You might also like