Advertisement
Guest User

Untitled

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