Advertisement
afrinahoque

HUGGGEEEE

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