Notification texts go here Contact Us Click here

Library Management using C ( C Projects )

Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated






     






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


Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.