Advertisement
Guest User

Untitled

a guest
Feb 26th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.55 KB | None | 0 0
  1. #include<windows.h>
  2. #include<stdio.h>
  3. #include<conio.h> //contains delay(),getch(),gotoxy(),etc.
  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.  
  10. #define RETURNTIME 15
  11.  
  12. //list of function prototype
  13. //char catagories[][25]={"Register Lecturer","Register Student","View Lecturer","View Student","Delete Lecturer","Delete Student","Search Lecturer","Search student","Modify Lecture","Modify Student","View Attendance","Modify Attendance"};
  14. void mainmenu(void);
  15. void returnlect(void);
  16. void returnstud(void);
  17. void checkday(int , char*);
  18. void check_lectdates();
  19. void register_lecturer();
  20. void register_student(void);
  21. void view_lecturer(void);
  22. void view_student(void);
  23. void search_student(void);
  24. void search_lecturer(void);
  25. void delete_lecturer(void);
  26. void delete_student(void);
  27. void modify_student(void);
  28. void modify_lecturer(void);
  29. void closeapplication(void);
  30. void attend(void);
  31. void modify_attendance(void);
  32. int t(void);
  33. int checklid(int);
  34. int checksid(int);
  35. //void closeapplication(void);
  36. void adminoption();
  37. void lectureroption();
  38. void studentoption();
  39. void Password();
  40. //char *cat;
  41. COORD coord = {0, 0}; // sets coordinates to 0,0
  42. //COORD max_buffer_size = GetLargestConsoleWindowSize(hOut);
  43. COORD max_res,cursor_size;
  44. void gotoxy (int x, int y)
  45. {
  46. coord.X = x; coord.Y = y; // X and Y coordinates
  47. SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
  48. }
  49. void delay(unsigned int mseconds)
  50. {
  51. clock_t goal = mseconds + clock();
  52. while (goal > clock());
  53. }
  54.  
  55. //list of global files that can be acceed form anywhere in program
  56. FILE *fp,*ft,*fs;
  57.  
  58. //list of global variable
  59. int s;
  60. char findstudent;
  61. char findlecturer;
  62. char password[10]={"codder"};
  63.  
  64. struct merodate
  65. {
  66. int mm,dd,yy;
  67. };
  68.  
  69. struct lecturer
  70. {
  71. char fname[25];
  72. char lname[25];
  73. char address[35];
  74. char faculty[20];
  75. int phoneno;
  76. int lid; // lecturer id no.
  77.  
  78. };
  79. struct lecturer lect;
  80.  
  81. struct student
  82. {
  83. char fname[25];
  84. char lname[25];
  85. char address[35];
  86. char faculty[20];
  87. int phoneno;
  88. int sid; // student id no.
  89.  
  90. };
  91. struct student stud;
  92.  
  93. int main()
  94.  
  95. {
  96.  
  97. Password();
  98. getch();
  99. return 0;
  100.  
  101. }
  102.  
  103.  
  104. void mainmenu()
  105.  
  106. {
  107. int i;
  108. system("cls");
  109. // textbackground(13);
  110.  
  111. gotoxy(20,3);
  112. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2 MAIN MENU");
  113. printf(" \xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  114. gotoxy(20,5);
  115. printf("\xDB\xDB\xDB\xDB\xB2 1. Admin ");
  116. gotoxy(20,7);
  117. printf("\xDB\xDB\xDB\xDB\xB2 2. lecturer");
  118. gotoxy(20,9);
  119. printf("\xDB\xDB\xDB\xDB\xB2 3. student");
  120. gotoxy(20,11);
  121. printf("\xDB\xDB\xDB\xDB\xB2 4. Exit");
  122. gotoxy(20,13);
  123. printf("------------------------------------------");
  124. gotoxy(20,14);
  125. t();
  126. gotoxy(20,15);
  127. printf("Enter your choice:");
  128. switch(getch())
  129.  
  130. {
  131.  
  132. case '1':
  133. adminoption();
  134. break;
  135.  
  136. case '2':
  137. //lectureroption();
  138. break;
  139.  
  140. case '3':
  141. //studentoption();
  142. break;
  143.  
  144. case '4':
  145. {
  146. system("cls");
  147. gotoxy(16,3);
  148. printf("Thanks for using the Program..");
  149. gotoxy(10,7);
  150. printf("Exiting in 5 second...........>");
  151. //flushall();
  152. delay(5000);
  153. exit(0);
  154. }
  155. default:
  156. {
  157. gotoxy(10,23);
  158. printf("\aWrong Entry!!Please re-entered correct option");
  159. if(getch())
  160. mainmenu();
  161. }
  162.  
  163.  
  164. }
  165. }
  166.  
  167.  
  168.  
  169. void adminoption()
  170.  
  171. {
  172. int i,s;
  173. /*char username[25],password[15];
  174. printf("\nEnter your username:");
  175. scanf("%s",&username);
  176. printf("\nEnter Password:");
  177. scanf("%s",&password);
  178. if(strcmp(username,"admin")==0 && strcmp(password,"password")==0)
  179. {*/
  180. system("cls");
  181. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2 ADMIN PANEL");
  182. printf(" \xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  183. gotoxy(20,5);
  184. printf("\xDB\xDB\xDB\xDB\xB2 a. Register lecturer");
  185. gotoxy(20,7);
  186. printf("\xDB\xDB\xDB\xDB\xB2 b. Register student");
  187. gotoxy(20,9);
  188. printf("\xDB\xDB\xDB\xDB\xB2 c. View lecturer");
  189. gotoxy(20,11);
  190. printf("\xDB\xDB\xDB\xDB\xB2 d. View student");
  191. gotoxy(20,13);
  192. printf("\xDB\xDB\xDB\xDB\xB2 e. Delete lecturer");
  193. gotoxy(20,15);
  194. printf("\xDB\xDB\xDB\xDB\xB2 f. Delete student");
  195. gotoxy(20,17);
  196. printf("\xDB\xDB\xDB\xDB\xB2 g. Search lecturer");
  197. gotoxy(20,19);
  198. printf("\xDB\xDB\xDB\xDB\xB2 h. Search student");
  199. gotoxy(20,21);
  200. printf("\xDB\xDB\xDB\xDB\xB2 i. Modify lecturer");
  201. gotoxy(20,23);
  202. printf("\xDB\xDB\xDB\xDB\xB2 j. Modify student");
  203. gotoxy(20,25);
  204. printf("\xDB\xDB\xDB\xDB\xB2 k. View attendance");
  205. gotoxy(20,27);
  206. printf("\xDB\xDB\xDB\xDB\xB2 l. Modify Attendance");
  207. gotoxy(20,29);
  208. printf("------------------------------------------");
  209. gotoxy(20,30);
  210. t();
  211. gotoxy(20,31);
  212. printf("Enter your choice:");
  213. switch(getch())
  214. {
  215. case 'a':
  216. register_lecturer();
  217. break;
  218.  
  219. case 'b':
  220. register_student();
  221. break;
  222.  
  223. case 'c':
  224. view_lecturer();
  225. break;
  226.  
  227. case 'd':
  228. view_student();
  229. break;
  230.  
  231. case 'e':
  232. delete_lecturer();
  233. break;
  234.  
  235. case 'f':
  236. delete_student();
  237. break;
  238.  
  239. case 'g':
  240. search_lecturer();
  241. break;
  242.  
  243. case'h':
  244. search_student();
  245. break;
  246.  
  247. case 'i':
  248. modify_lecturer();
  249. break;
  250.  
  251. case 'j':
  252. //modify_student
  253. break;
  254.  
  255. case 'k':
  256. //view_attendance
  257. break;
  258.  
  259. case'l':
  260. //modify_attendance
  261. break;
  262.  
  263. default:
  264.  
  265. gotoxy(10,23);
  266. printf("\aWrong Entry!!Please re-entered correct option");
  267. if(getch())
  268. adminoption();
  269.  
  270. }
  271. //}
  272. }
  273.  
  274. void register_lecturer()
  275. {
  276. struct lecturer lect;
  277. system("cls");
  278. int i;
  279. FILE *fp=NULL;
  280. fp=fopen("lecturer.dat","a");
  281.  
  282. gotoxy(20,3);
  283. printf("Enter the Information Below");
  284. gotoxy(20,4);
  285. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  286. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  287. gotoxy(20,5);
  288. printf("\xB2");gotoxy(46,5);printf("\xB2");
  289. gotoxy(20,6);
  290. printf("\xB2");gotoxy(46,6);printf("\xB2");
  291. gotoxy(20,7);
  292. printf("\xB2");gotoxy(46,7);printf("\xB2");
  293. gotoxy(20,8);
  294. printf("\xB2");gotoxy(46,8);printf("\xB2");
  295. gotoxy(20,9);
  296. printf("\xB2");gotoxy(46,9);printf("\xB2");
  297. gotoxy(20,10);
  298. printf("\xB2");gotoxy(46,10);printf("\xB2");
  299. gotoxy(20,11);
  300. printf("\xB2");gotoxy(46,11);printf("\xB2");
  301. gotoxy(20,12);
  302. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  303. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  304. gotoxy(21,5);
  305. printf("Lecturer Information:");
  306. gotoxy(21,6);
  307. printf("First Name :");
  308. scanf("%s",lect.fname);
  309. gotoxy(21,7);
  310. printf("Last Name :");
  311. scanf("%s",lect.lname);
  312. gotoxy(21,8);
  313. printf("Address :");
  314. scanf("%s",lect.address);
  315. gotoxy(21,9);
  316. printf("Phone No. :");
  317. scanf("%d",&lect.phoneno);
  318. gotoxy(21,10);
  319. printf("LID :");
  320. scanf("%d",&lect.lid);
  321. gotoxy(21,13);
  322. fprintf(fp, "\n%s %s %s %s %d %d\n",lect.fname,lect.lname,lect.address,lect.faculty,lect.phoneno,lect.lid);
  323. printf("Lecturer registered sucessfully!!");
  324. fclose(fp);
  325. gotoxy(21,15);
  326. printf("Register any more?(Y / N):");
  327. if(getch()=='n')
  328. mainmenu();
  329. else
  330. system("cls");
  331. register_lecturer();
  332.  
  333. }
  334.  
  335.  
  336. void register_student()
  337.  
  338. {
  339. system("cls");
  340. int i;
  341. FILE *fs;
  342. fs=fopen("student.dat","a");
  343. gotoxy(20,3);
  344. printf("Enter the Information Below");
  345. gotoxy(20,4);
  346. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  347. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  348. gotoxy(20,5);
  349. printf("\xB2");gotoxy(46,5);printf("\xB2");
  350. gotoxy(20,6);
  351. printf("\xB2");gotoxy(46,6);printf("\xB2");
  352. gotoxy(20,7);
  353. printf("\xB2");gotoxy(46,7);printf("\xB2");
  354. gotoxy(20,8);
  355. printf("\xB2");gotoxy(46,8);printf("\xB2");
  356. gotoxy(20,9);
  357. printf("\xB2");gotoxy(46,9);printf("\xB2");
  358. gotoxy(20,10);
  359. printf("\xB2");gotoxy(46,10);printf("\xB2");
  360. gotoxy(20,11);
  361. printf("\xB2");gotoxy(46,11);printf("\xB2");
  362. gotoxy(20,12);
  363. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  364. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  365. gotoxy(21,5);
  366. printf("Student Information:");
  367. gotoxy(21,6);
  368. printf("First name :");
  369. scanf("%s",stud.fname);
  370. gotoxy(21,7);
  371. printf("Last name :");
  372. scanf("%s",stud.lname);
  373. gotoxy(21,8);
  374. printf("Address :");
  375. scanf("%s",stud.address);
  376. gotoxy(21,9);
  377. printf("Faculty :");
  378. scanf("%s",stud.faculty);
  379. gotoxy(21,10);
  380. printf("Phone No. :");
  381. scanf("%d",&stud.phoneno);
  382. gotoxy(21,11);
  383. printf("SID. :");
  384. scanf("%d",&stud.sid);
  385. fprintf(fs,"\n%s\t\t%s\t\t%s\t\t%s\t\t%d\t\t%d\n",stud.fname,stud.lname,stud.address,stud.faculty,stud.phoneno,stud.sid);
  386. gotoxy(21,14);
  387. printf("Student registered sucessfully!!");
  388. fclose(fs);
  389. gotoxy(21,15);
  390. printf("Register any more?(Y / N):");
  391. if(getch()=='n')
  392. mainmenu();
  393. else
  394. system("cls");
  395. register_student();
  396.  
  397. }
  398. void view_lecturer(void)
  399.  
  400. {
  401. int i=0,j;
  402. system("cls");
  403. gotoxy(1,1);
  404. printf("*********************************Lecturer List*****************************");
  405. gotoxy(2,2);
  406. printf(" First Name Last Name Address Faculty Phone No. LID ");
  407. j=4;
  408. fp=fopen("lecturer.dat","r");
  409. while(fread(&lect,sizeof(lect),1,fp)==1)
  410. {
  411. gotoxy(3,j);
  412. printf("%s",lect.fname);
  413. gotoxy(16,j);
  414. printf("%s",lect.lname);
  415. gotoxy(22,j);
  416. printf("%s",lect.address);
  417. gotoxy(36,j);
  418. printf("%s",lect.faculty);
  419. gotoxy(50,j);
  420. printf("%d",lect.phoneno);
  421. gotoxy(57,j);
  422. printf("%d\t\t",lect.lid);
  423. printf("\n\n");
  424. j++;
  425.  
  426. }
  427.  
  428. fclose(fp);
  429. gotoxy(70,25);
  430. returnlect();
  431. }
  432. void view_student()
  433. {
  434. int i=0,j;
  435. system("cls");
  436. gotoxy(1,1);
  437. printf("*********************************Student List*****************************");
  438. gotoxy(2,2);
  439. printf(" First Name Last Name Address Faculty Phone No. SID ");
  440. j=4;
  441. fs=fopen("student.dat","rb");
  442. while(fread(&stud,sizeof(stud),1,fs)==1)
  443. {
  444. gotoxy(3,j);
  445. printf("%s\t",stud.fname);
  446. gotoxy(16,j);
  447. printf("%s\t",stud.lname);
  448. gotoxy(22,j);
  449. printf("%s\t",stud.address);
  450. gotoxy(36,j);
  451. printf("%s\t",stud.faculty);
  452. gotoxy(50,j);
  453. printf("%d\t",stud.phoneno);
  454. gotoxy(57,j);
  455. printf("%d\t",stud.sid);
  456. printf("\n\n");
  457. j++;
  458. fclose(fs);
  459. }
  460.  
  461. gotoxy(35,25);
  462. returnstud();
  463. }
  464.  
  465. void delete_lecturer()
  466. {
  467. system("cls");
  468. int d;
  469. char another='y';
  470. while(another=='y') //infinite loop
  471. {
  472. system("cls");
  473. gotoxy(10,5);
  474. printf("Enter the Lecturer ID to delete:");
  475. scanf("%d",&d);
  476. fp=fopen("lecturer.dat","rb+");
  477. rewind(fp);
  478. while(fread(&lect,sizeof(lect),1,fp)==1)
  479. {
  480. if(lect.lid==d)
  481. {
  482.  
  483. gotoxy(10,7);
  484. printf("The lecturer is available");
  485. gotoxy(10,8);
  486. printf("lecturer name is %s",lect.fname);
  487. gotoxy(10,9);
  488. printf("Lecturer Faculty. is %s",lect.faculty);
  489. findlecturer='t';
  490. }
  491. }
  492. if(findlecturer!='t')
  493. {
  494. gotoxy(10,10);
  495. printf("No record is found modify the search");
  496. if(getch())
  497. mainmenu();
  498. }
  499. if(findlecturer=='t' )
  500. {
  501. gotoxy(10,9);
  502. printf("Do you want to delete it?(Y/N):");
  503. if(getch()=='y')
  504. {
  505. ft=fopen("ldel.dat.","wb+"); //temporary file for delete
  506. rewind(fp);
  507. while(fread(&lect,sizeof(lect),1,fp)==1)
  508. {
  509. if(lect.lid!=d)
  510. {
  511. fseek(ft,0,SEEK_CUR);
  512. fwrite(&lect,sizeof(lect),1,ft); //write all in tempory file except that
  513. } //we want to delete
  514. }
  515. fclose(ft);
  516. fclose(fp);
  517. remove("lecturer.dat");
  518. rename("ldel.dat","lecturer.dat"); //copy all item frtemporary file to fp except that
  519. fp=fopen("lecturer.dat","rb+"); //we want to delete
  520. if(findlecturer=='t')
  521. {
  522. gotoxy(10,10);
  523. printf("The record is sucessfully deleted");
  524. gotoxy(10,11);
  525. printf("Delete another record?(Y/N)");
  526. }
  527. }
  528. else
  529. mainmenu();
  530. fflush(stdin);
  531. another=getch();
  532. }
  533. gotoxy(10,15);
  534. mainmenu();
  535. }
  536. }
  537. void delete_student(void)
  538.  
  539. {
  540.  
  541. system("cls");
  542. int d;
  543. char another='y';
  544. while(another=='y') //infinite loop
  545. {
  546. system("cls");
  547. gotoxy(10,5);
  548. printf("Enter the Student ID to delete:");
  549. scanf("%d",&d);
  550. fs=fopen("student.dat","rb+");
  551. rewind(fs);
  552. while(fread(&stud,sizeof(stud),1,fs)==1)
  553. {
  554. if(stud.sid==d)
  555. {
  556.  
  557. gotoxy(10,7);
  558. printf("The student is available");
  559. gotoxy(10,8);
  560. printf("Student name is %s",stud.fname);
  561. gotoxy(10,9);
  562. printf("Student Faculty. is %s",stud.faculty);
  563. findlecturer='t';
  564. }
  565. }
  566. if(findstudent!='t')
  567. {
  568. gotoxy(10,10);
  569. printf("No record is found modify the search");
  570. if(getch())
  571. mainmenu();
  572. }
  573. if(findstudent=='t' )
  574. {
  575. gotoxy(10,9);
  576. printf("Do you want to delete it?(Y/N):");
  577. if(getch()=='y')
  578. {
  579. ft=fopen("sdel.dat.","wb+"); //temporary file for delete
  580. rewind(fs);
  581. while(fread(&stud,sizeof(stud),1,fs)==1)
  582. {
  583. if(stud.sid!=d)
  584. {
  585. fseek(ft,0,SEEK_CUR);
  586. fwrite(&stud,sizeof(stud),1,ft); //write all in tempory file except that
  587. } //we want to delete
  588. }
  589. fclose(ft);
  590. fclose(fs);
  591. remove("student.dat");
  592. rename("sdel.dat","Bibek.dat"); //copy all item frtemporary file to fp except that
  593. fp=fopen("student.dat","rb+"); //we want to delete
  594. if(findstudent=='t')
  595. {
  596. gotoxy(10,10);
  597. printf("The record is sucessfully deleted");
  598. gotoxy(10,11);
  599. printf("Delete another record?(Y/N)");
  600. }
  601. }
  602. else
  603. mainmenu();
  604. fflush(stdin);
  605. another=getch();
  606. }
  607. }
  608. gotoxy(10,15);
  609. mainmenu();
  610. }
  611.  
  612.  
  613.  
  614. void search_lecturer(void)
  615.  
  616. {
  617.  
  618. system("cls");
  619. int d=0,i;
  620. printf("*****************************Search Teacher*********************************");
  621. gotoxy(20,10);
  622. printf("\xDB\xDB\xDB\xB2 1. Search By LID");
  623. gotoxy(20,14);
  624. printf("\xDB\xDB\xDB\xB2 2. Search By Name");
  625. gotoxy( 15,20);
  626. printf("Enter Your Choice");
  627. fp=fopen("lecturer.dat","rb+"); //open file for reading propose
  628. rewind(fp); //move pointer at the begining of file
  629. switch(getch())
  630. {
  631. case '1':
  632. {
  633. system("cls");
  634. gotoxy(25,4);
  635. printf("****Search Teacher By ID****");
  636. gotoxy(20,5);
  637. printf("Enter The Lecturer ID:");
  638. scanf("%d",&d);
  639. gotoxy(20,7);
  640. printf("Searching........");
  641. while(fread(&lect,sizeof(lect),1,fp)==1)
  642. {
  643. if(lect.lid==d) //checks whether a.id is equal to d or not
  644. {
  645. delay(2);
  646. gotoxy(20,7);
  647. printf("The lecturer found");
  648. gotoxy(20,8);
  649. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  650. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  651. gotoxy(20,9);
  652. printf("\xB2 First Name:%s",lect.fname);gotoxy(47,9);printf("\xB2");
  653. gotoxy(20,10);
  654. printf("\xB2 Last Name:%s",lect.lname);gotoxy(47,10);printf("\xB2");
  655. gotoxy(20,11);
  656. printf("\xB2 Address:%s ",lect.address);gotoxy(47,11);printf("\xB2");
  657. gotoxy(20,12);
  658. printf("\xB2 Faculty:%s ",lect.faculty);gotoxy(47,12);printf("\xB2"); gotoxy(47,11);printf("\xB2");
  659. gotoxy(20,13);
  660. printf("\xB2 Phone No.:%d",lect.phoneno);gotoxy(47,13);printf("\xB2");
  661. gotoxy(20,14);
  662. printf("\xB2 LID:%d ",lect.lid);gotoxy(47,14);printf("\xB2");
  663. gotoxy(20,15);
  664. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  665. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  666. findlecturer='t';
  667. }
  668.  
  669. }
  670. if(findlecturer!='t') //checks whether conditiion enters inside loop or not
  671. {
  672. gotoxy(20,8);
  673. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  674. gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2");
  675. gotoxy(20,10);
  676. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  677. gotoxy(22,9);printf("\aNo Record Found");
  678. }
  679. gotoxy(20,17);
  680. printf("Try another search?(Y/N)");
  681. if(getch()=='y')
  682. search_lecturer();
  683. else
  684. mainmenu();
  685. break;
  686. }
  687. case '2':
  688. {
  689. char s[25];
  690. system("cls");
  691. gotoxy(25,4);
  692. printf("****Search Lecturer By Name****");
  693. gotoxy(20,5);
  694. printf("Enter Lecturer First Name:");
  695. scanf("%s",s);
  696. int d=0;
  697. while(fread(&lect,sizeof(lect),1,fp)==1)
  698. {
  699. if(strcmp(lect.fname,(s))==0) //checks whether a.name is equal to s or not
  700. {
  701. gotoxy(20,7);
  702. printf("The Lecturer found");
  703. gotoxy(20,8);
  704. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  705. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  706. gotoxy(20,9);
  707. printf("\xB2 First Name:%s",lect.fname);gotoxy(47,9);printf("\xB2");
  708. gotoxy(20,10);
  709. printf("\xB2 Last Name:%s",lect.lname);gotoxy(47,10);printf("\xB2");
  710. gotoxy(20,11);
  711. printf("\xB2 Address:%s ",lect.address);gotoxy(47,11);printf("\xB2");
  712. gotoxy(20,12);
  713. printf("\xB2 Faculty:%s ",lect.faculty);gotoxy(47,12);printf("\xB2"); gotoxy(47,11);printf("\xB2");
  714. gotoxy(20,13);
  715. printf("\xB2 Phone No.:%d",lect.phoneno);gotoxy(47,13);printf("\xB2");
  716. gotoxy(20,14);
  717. printf("\xB2 LID:%d ",lect.lid);gotoxy(47,14);printf("\xB2");
  718. gotoxy(20,15);
  719. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  720. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  721. d++;
  722. }
  723.  
  724. }
  725. if(d==0)
  726. {
  727. gotoxy(20,8);
  728. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  729. gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2");
  730. gotoxy(20,10);
  731. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  732. gotoxy(22,9);printf("\aNo Lecturer Found");
  733. }
  734. gotoxy(20,17);
  735. printf("Try another search?(Y/N)");
  736. if(getch()=='y')
  737. search_lecturer();
  738. else
  739. mainmenu();
  740. break;
  741. }
  742.  
  743. default :
  744. getch();
  745. search_lecturer();
  746. fclose(fp);
  747. }
  748. }
  749.  
  750. void search_student()
  751. {
  752. system("cls");
  753. int d;
  754. printf("*****************************Search Students*********************************");
  755. gotoxy(20,10);
  756. printf("\xDB\xDB\xDB\xB2 1. Search By SID");
  757. gotoxy(20,14);
  758. printf("\xDB\xDB\xDB\xB2 2. Search By Name");
  759. gotoxy( 15,20);
  760. printf("Enter Your Choice");
  761. fs=fopen("student.dat","rb+"); //open file for reading propose
  762. rewind(fs); //move pointer at the begining of file
  763. switch(getch())
  764. {
  765. case '1':
  766. {
  767. system("cls");
  768. gotoxy(25,4);
  769. printf("****Search Student By SID****");
  770. gotoxy(20,5);
  771. printf("Enter the student id:");
  772. scanf("%d",&d);
  773. gotoxy(20,7);
  774. printf("Searching........");
  775. while(fread(&stud,sizeof(stud),1,fs)==1)
  776. {
  777. if(stud.sid==d)
  778. {
  779. delay(2);
  780. gotoxy(20,7);
  781. printf("The student found");
  782. gotoxy(20,8);
  783. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  784. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  785. gotoxy(20,9);
  786. printf("\xB2 First Name:%s",stud.fname);gotoxy(47,9);printf("\xB2");
  787. gotoxy(20,10);
  788. printf("\xB2 Last Name:%s",stud.lname);gotoxy(47,10);printf("\xB2");
  789. gotoxy(20,11);
  790. printf("\xB2 Address:%s ",stud.address);gotoxy(47,11);printf("\xB2");
  791. gotoxy(20,12);
  792. printf("\xB2 Faculty:%s ",stud.faculty);gotoxy(47,12);printf("\xB2"); gotoxy(47,11);printf("\xB2");
  793. gotoxy(20,13);
  794. printf("\xB2 Phone No.:%d",stud.phoneno);gotoxy(47,13);printf("\xB2");
  795. gotoxy(20,14);
  796. printf("\xB2 SID:%d ",stud.sid);gotoxy(47,14);printf("\xB2");
  797. gotoxy(20,15);
  798. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  799. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  800. findstudent='t';
  801. }
  802.  
  803. }
  804. if(findstudent!='t') //checks whether conditiion enters inside loop or not
  805. {
  806. gotoxy(20,8);
  807. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  808. gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2");
  809. gotoxy(20,10);
  810. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  811. gotoxy(22,9);printf("\aNo Record Found");
  812. }
  813. gotoxy(20,17);
  814. printf("Try another search?(Y/N)");
  815. if(getch()=='y')
  816. search_student();
  817. else
  818. mainmenu();
  819. break;
  820. }
  821.  
  822. case '2':
  823. {
  824. char s[15];
  825. system("cls");
  826. gotoxy(25,4);
  827. printf("****Search Student By First Name****");
  828. gotoxy(20,5);
  829. printf("Enter Student Name:");
  830. scanf("%s",s);
  831. int d=0;
  832. while(fread(&stud,sizeof(stud),1,fs)==1)
  833. {
  834. if(strcmp(stud.fname,(s))==0) //checks whether a.name is equal to s or not
  835. {
  836. gotoxy(20,7);
  837. printf("The Student found");
  838. gotoxy(20,8);
  839. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  840. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  841. gotoxy(20,9);
  842. printf("\xB2 First Name:%s",stud.fname);gotoxy(47,9);printf("\xB2");
  843. gotoxy(20,10);
  844. printf("\xB2 Last Name:%s",stud.lname);gotoxy(47,10);printf("\xB2");
  845. gotoxy(20,11);
  846. printf("\xB2 Address:%s ",stud.address);gotoxy(47,11);printf("\xB2");
  847. gotoxy(20,12);
  848. printf("\xB2 Faculty:%s ",stud.faculty);gotoxy(47,12);printf("\xB2"); gotoxy(47,11);printf("\xB2");
  849. gotoxy(20,13);
  850. printf("\xB2 Phone No.:%d",stud.phoneno);gotoxy(47,13);printf("\xB2");
  851. gotoxy(20,14);
  852. printf("\xB2 SID:%d ",stud.sid);gotoxy(47,14);printf("\xB2");
  853. gotoxy(20,15);
  854. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  855. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  856. d++;
  857. }
  858.  
  859. }
  860. if(d==0)
  861. {
  862. gotoxy(20,8);
  863. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  864. gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2");
  865. gotoxy(20,10);
  866. printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  867. gotoxy(22,9);printf("\aNo Student Found");
  868. }
  869. gotoxy(20,17);
  870. printf("Try another search?(Y/N)");
  871. if(getch()=='y')
  872. search_student();
  873. else
  874. mainmenu();
  875. break;
  876. }
  877. default :
  878. getch();
  879. search_student();
  880.  
  881. fclose(fs);
  882. }
  883. }
  884. void modify_lecturer(void) //edit information about book
  885. {
  886. system("cls");
  887. int c=0;
  888. int d,e;
  889. gotoxy(20,4);
  890. printf("****Modify Lecturer Section****");
  891. char another='y';
  892. while(another=='y')
  893. {
  894. system("cls");
  895. gotoxy(15,6);
  896. printf("Enter Lecturer Id to be edited:");
  897. scanf("%d",&d);
  898. fp=fopen("lecturer.dat","rb+");
  899. while(fread(&lect,sizeof(lect),1,fp)==1)
  900. {
  901. if(checklid(d)==0)
  902. {
  903. gotoxy(15,7);
  904. printf("The Lecturer is availble");
  905. gotoxy(15,8);
  906. printf("The Lecturer ID:%s",lect.lid);
  907. gotoxy(15,9);
  908. printf("Enter new first name:");scanf("%s",lect.fname);
  909. gotoxy(15,10);
  910. printf("Enter new last name:");scanf("%s",lect.lname);
  911. gotoxy(15,11);
  912. printf("Enter new Address:");scanf("%s",lect.address);
  913. gotoxy(15,12);
  914. printf("Enter new phone no.:");scanf("%d",&lect.phoneno);
  915. gotoxy(15,13);
  916. printf("Enter new LID:");scanf("%d",&lect.lid);
  917. gotoxy(15,14);
  918. printf("The record is modified");
  919. fseek(fp,ftell(fp)-sizeof(lect),0);
  920. fwrite(&lect,sizeof(lect),1,fp);
  921. fclose(fp);
  922. c=1;
  923. }
  924. if(c==0)
  925. {
  926. gotoxy(15,9);
  927. printf("No record found");
  928. }
  929. }
  930. gotoxy(15,16);
  931. printf("Modify another Record?(Y/N)");
  932. fflush(stdin);
  933. another=getch() ;
  934. }
  935. returnlect();
  936. }
  937.  
  938. int checklid(int t) //check whether the lecturer exist in or not
  939. {
  940. rewind(fp);
  941. while(fread(&lect,sizeof(lect),1,fp)==1)
  942. if(lect.lid==t)
  943. return 0; //returns 0 if lecturer exits
  944. return 1; //return 1 if doesnot exxist
  945. }
  946.  
  947. void returnlect(void)
  948. {
  949. printf(" Press ENTER to return to main menu");
  950. lect:
  951. if(getch()==13) //allow only use of enter
  952. mainmenu();
  953. else
  954. goto lect;
  955. }
  956.  
  957. void returnstud(void)
  958. {
  959.  
  960. printf(" Press ENTER to return to main menu");
  961. stud:
  962. if(getch()==13) //allow only use of enter
  963. mainmenu();
  964. else
  965. goto stud;
  966. }
  967. int t(void) //for time
  968. {
  969. time_t t;
  970. time(&t);
  971. printf("Date and time:%s\n",ctime(&t));
  972.  
  973. return 0 ;
  974. }
  975.  
  976.  
  977. void Password(void) //for password option
  978. {
  979.  
  980. system("cls");
  981. printf("\n\n=================WELCOME TO THE ATTENDANCE MANAGEMENT SYSTEM=================\n\n\n");
  982. char d[25]="Password Protected";
  983. char ch,pass[10];
  984. int i=0,j;
  985. //textbackground(WHITE);
  986. //textcolor(RED);
  987. gotoxy(10,4);
  988. for(j=0;j<20;j++)
  989.  
  990. {
  991. delay(5);
  992. printf("*");
  993. }
  994.  
  995. for(j=0;j<20;j++)
  996.  
  997. {
  998. delay(5);
  999. printf("%c",d[j]);
  1000. }
  1001.  
  1002. for(j=0;j<20;j++)
  1003. {
  1004. delay(5);
  1005. printf("*");
  1006. }
  1007.  
  1008. gotoxy(10,10);
  1009. gotoxy(15,7);
  1010. printf("Enter Password:");
  1011.  
  1012. while(ch!=13)
  1013. {
  1014. ch=getch();
  1015.  
  1016. if(ch!=13 && ch!=8)
  1017. {
  1018. putch('*');
  1019. pass[i] = ch;
  1020. i++;
  1021. }
  1022. }
  1023. pass[i] = '\0';
  1024. if(strcmp(pass,password)==0)
  1025.  
  1026. {
  1027. gotoxy(15,9);
  1028. //textcolor(BLINK);
  1029. printf("Password match");
  1030. gotoxy(17,10);
  1031. printf("Press any key to countinue.....");
  1032. getch();
  1033. mainmenu();
  1034. }
  1035. else
  1036.  
  1037. {
  1038. gotoxy(15,16);
  1039. printf("\aWarning!! Incorrect Password");
  1040. getch();
  1041. Password();
  1042. }
  1043. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement