Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<windows.h>
- #include<stdio.h>
- #include<conio.h> //contains delay(),getch(),gotoxy(),etc.
- #include <stdlib.h>
- #include<string.h> //contains strcmp(),strcpy(),strlen(),etc
- #include<ctype.h> //contains toupper(), tolower(),etc
- #include<dos.h> //contains _dos_getdate
- #include<time.h>
- #define RETURNTIME 15
- //list of function prototype
- //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"};
- void mainmenu(void);
- void returnlect(void);
- void returnstud(void);
- void checkday(int , char*);
- void check_lectdates();
- void register_lecturer();
- void register_student(void);
- void view_lecturer(void);
- void view_student(void);
- void search_student(void);
- void search_lecturer(void);
- void delete_lecturer(void);
- void delete_student(void);
- void modify_student(void);
- void modify_lecturer(void);
- void closeapplication(void);
- void view_attendance(void);
- void take_attendance(void);
- void modify_attendance(void);
- int t(void);
- int checklid(int);
- int checksid(int);
- //void closeapplication(void);
- void adminoption();
- void lectureroption();
- void studentoption();
- void Password();
- //char *cat;
- COORD coord = {0, 0}; // sets coordinates to 0,0
- //COORD max_buffer_size = GetLargestConsoleWindowSize(hOut);
- COORD max_res,cursor_size;
- void gotoxy (int x, int y)
- {
- coord.X = x; coord.Y = y; // X and Y coordinates
- SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
- }
- void delay(unsigned int mseconds)
- {
- clock_t goal = mseconds + clock();
- while (goal > clock());
- }
- //list of global files that can be acceed form anywhere in program
- FILE *fp,*ft,*fs;
- //list of global variable
- int s;
- int temp;
- char findstudent;
- char findlecturer;
- char password[10]={"codder"};
- struct merodate
- {
- int mm,dd,yy;
- };
- struct Attendance{
- int id;
- int student_id;
- char lectured_date[25];
- char start_time[50];
- char end_time[50];
- char module_name[50];
- char intake_code[50];
- char status[25];
- };
- struct lecturer
- {
- char fname[25];
- char lname[25];
- char address[35];
- char faculty[20];
- int phoneno;
- int lid; // lecturer id no.
- };
- struct lecturer lect;
- struct student
- {
- char fname[25];
- char lname[25];
- char address[35];
- char faculty[20];
- int phoneno;
- int sid; // student id no.
- };
- struct student stud;
- int main()
- {
- Password();
- getch();
- return 0;
- }
- void mainmenu()
- {
- int i;
- system("cls");
- // textbackground(13);
- gotoxy(20,3);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2 MAIN MENU");
- printf(" \xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(20,5);
- printf("\xDB\xDB\xDB\xDB\xB2 1. Admin ");
- gotoxy(20,7);
- printf("\xDB\xDB\xDB\xDB\xB2 2. lecturer");
- gotoxy(20,9);
- printf("\xDB\xDB\xDB\xDB\xB2 3. student");
- gotoxy(20,11);
- printf("\xDB\xDB\xDB\xDB\xB2 4. Exit");
- gotoxy(20,13);
- printf("------------------------------------------");
- gotoxy(20,14);
- t();
- gotoxy(20,15);
- printf("Enter your choice:");
- switch(getch())
- {
- case '1':
- adminoption();
- break;
- case '2':
- lectureroption();
- break;
- case '3':
- //studentoption();
- break;
- case '4':
- {
- system("cls");
- gotoxy(16,3);
- printf("Thanks for using the Program..");
- gotoxy(10,7);
- printf("Exiting in 5 second...........>");
- //flushall();
- delay(5000);
- exit(0);
- }
- default:
- {
- gotoxy(10,23);
- printf("\aWrong Entry!!Please re-entered correct option");
- if(getch())
- mainmenu();
- }
- }
- }
- void adminoption()
- {
- int i,s;
- /*char username[25],password[15];
- printf("\nEnter your username:");
- scanf("%s",&username);
- printf("\nEnter Password:");
- scanf("%s",&password);
- if(strcmp(username,"admin")==0 && strcmp(password,"password")==0)
- {*/
- system("cls");
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2 ADMIN PANEL");
- printf(" \xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(20,5);
- printf("\xDB\xDB\xDB\xDB\xB2 a. Register lecturer");
- gotoxy(20,7);
- printf("\xDB\xDB\xDB\xDB\xB2 b. Register student");
- gotoxy(20,9);
- printf("\xDB\xDB\xDB\xDB\xB2 c. View lecturer");
- gotoxy(20,11);
- printf("\xDB\xDB\xDB\xDB\xB2 d. View student");
- gotoxy(20,13);
- printf("\xDB\xDB\xDB\xDB\xB2 e. Delete lecturer");
- gotoxy(20,15);
- printf("\xDB\xDB\xDB\xDB\xB2 f. Delete student");
- gotoxy(20,17);
- printf("\xDB\xDB\xDB\xDB\xB2 g. Search lecturer");
- gotoxy(20,19);
- printf("\xDB\xDB\xDB\xDB\xB2 h. Search student");
- gotoxy(20,21);
- printf("\xDB\xDB\xDB\xDB\xB2 i. Modify lecturer");
- gotoxy(20,23);
- printf("\xDB\xDB\xDB\xDB\xB2 j. Modify student");
- gotoxy(20,25);
- printf("\xDB\xDB\xDB\xDB\xB2 k. View attendance");
- gotoxy(20,27);
- printf("\xDB\xDB\xDB\xDB\xB2 l. Modify Attendance");
- gotoxy(20,29);
- printf("------------------------------------------");
- gotoxy(20,30);
- t();
- gotoxy(20,31);
- printf("Enter your choice:");
- switch(getch())
- {
- case 'a':
- register_lecturer();
- break;
- case 'b':
- register_student();
- break;
- case 'c':
- view_lecturer();
- break;
- case 'd':
- view_student();
- break;
- case 'e':
- delete_lecturer();
- break;
- case 'f':
- delete_student();
- break;
- case 'g':
- search_lecturer();
- break;
- case'h':
- search_student();
- break;
- case 'i':
- modify_lecturer();
- break;
- case 'j':
- modify_student();
- break;
- case 'k':
- //view_attendance
- break;
- case'l':
- //modify_attendance
- break;
- default:
- gotoxy(10,23);
- printf("\aWrong Entry!!Please re-entered correct option");
- if(getch())
- adminoption();
- }
- //}
- }
- void register_lecturer()
- {
- struct lecturer lect;
- system("cls");
- int i;
- FILE *fp=NULL;
- fp=fopen("lecturer.dat","a");
- gotoxy(20,3);
- printf("Enter the Information Below");
- gotoxy(20,4);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(20,5);
- printf("\xB2");gotoxy(46,5);printf("\xB2");
- gotoxy(20,6);
- printf("\xB2");gotoxy(46,6);printf("\xB2");
- gotoxy(20,7);
- printf("\xB2");gotoxy(46,7);printf("\xB2");
- gotoxy(20,8);
- printf("\xB2");gotoxy(46,8);printf("\xB2");
- gotoxy(20,9);
- printf("\xB2");gotoxy(46,9);printf("\xB2");
- gotoxy(20,10);
- printf("\xB2");gotoxy(46,10);printf("\xB2");
- gotoxy(20,11);
- printf("\xB2");gotoxy(46,11);printf("\xB2");
- gotoxy(20,12);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(21,5);
- printf("Lecturer Information:");
- gotoxy(21,6);
- printf("First Name :");
- scanf("%s",lect.fname);
- gotoxy(21,7);
- printf("Last Name :");
- scanf("%s",lect.lname);
- gotoxy(21,8);
- printf("Address :");
- scanf("%s",lect.address);
- gotoxy(21,9);
- printf("Phone No. :");
- scanf("%d",&lect.phoneno);
- gotoxy(21,10);
- printf("LID :");
- scanf("%d",&lect.lid);
- gotoxy(21,13);
- fprintf(fp, "\n%s %s %s %d %d\n",lect.fname,lect.lname,lect.address,lect.phoneno,lect.lid);
- printf("Lecturer registered sucessfully!!");
- fclose(fp);
- fflush(stdin);
- gotoxy(21,15);
- printf("Register any more?(Y / N):");
- if(getch()=='n')
- mainmenu();
- else
- system("cls");
- register_lecturer();
- }
- void register_student()
- {
- system("cls");
- int i;
- FILE *fs;
- fs=fopen("student.dat","a");
- gotoxy(20,3);
- printf("Enter the Information Below");
- gotoxy(20,4);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(20,5);
- printf("\xB2");gotoxy(46,5);printf("\xB2");
- gotoxy(20,6);
- printf("\xB2");gotoxy(46,6);printf("\xB2");
- gotoxy(20,7);
- printf("\xB2");gotoxy(46,7);printf("\xB2");
- gotoxy(20,8);
- printf("\xB2");gotoxy(46,8);printf("\xB2");
- gotoxy(20,9);
- printf("\xB2");gotoxy(46,9);printf("\xB2");
- gotoxy(20,10);
- printf("\xB2");gotoxy(46,10);printf("\xB2");
- gotoxy(20,11);
- printf("\xB2");gotoxy(46,11);printf("\xB2");
- gotoxy(20,12);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(21,5);
- printf("Student Information:");
- gotoxy(21,6);
- printf("First name :");
- scanf("%s",stud.fname);
- gotoxy(21,7);
- printf("Last name :");
- scanf("%s",stud.lname);
- gotoxy(21,8);
- printf("Address :");
- scanf("%s",stud.address);
- gotoxy(21,9);
- printf("Faculty :");
- scanf("%s",stud.faculty);
- gotoxy(21,10);
- printf("Phone No. :");
- scanf("%d",&stud.phoneno);
- gotoxy(21,11);
- printf("SID. :");
- scanf("%d",&stud.sid);
- 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);
- gotoxy(21,14);
- printf("Student registered successfully!!");
- fclose(fs);
- gotoxy(21,15);
- printf("Register any more?(Y / N):");
- if(getch()=='n')
- mainmenu();
- else
- system("cls");
- register_student();
- }
- void view_lecturer(void)
- {
- struct lecturer lect;
- int i=0,j;
- system("cls");
- gotoxy(1,1);
- printf("*********************************Lecturer List*****************************");
- gotoxy(2,2);
- printf("First Name Last Name Address Phone No. LID ");
- j=4;
- fp=fopen("lecturer.dat","rb");
- while(fread(&lect,sizeof(lect),1,fp)==1)
- {
- gotoxy(3,j);
- printf("%s",lect.fname);
- gotoxy(16,j);
- printf("%s",lect.lname);
- gotoxy(22,j);
- printf("%s",lect.address);
- gotoxy(36,j);
- printf("%d",lect.phoneno);
- gotoxy(57,j);
- printf("%d\t\t",lect.lid);
- printf("\n\n");
- j++;
- }
- fflush(stdin);
- fclose(fp);
- gotoxy(70,25);
- returnlect();
- }
- void view_student()
- {
- int i=0,j;
- system("cls");
- gotoxy(1,1);
- printf("*********************************Student List*****************************");
- gotoxy(2,2);
- printf(" First Name Last Name Address Faculty Phone No. SID ");
- j=4;
- fs=fopen("student.dat","rb");
- while(fread(&stud,sizeof(stud),1,fs)==1)
- {
- gotoxy(3,j);
- printf("%s\t",stud.fname);
- gotoxy(16,j);
- printf("%s\t",stud.lname);
- gotoxy(22,j);
- printf("%s\t",stud.address);
- gotoxy(36,j);
- printf("%s\t",stud.faculty);
- gotoxy(50,j);
- printf("%d\t",stud.phoneno);
- gotoxy(57,j);
- printf("%d\t",stud.sid);
- printf("\n\n");
- j++;
- fclose(fs);
- }
- gotoxy(35,25);
- returnstud();
- }
- void delete_lecturer()
- {
- system("cls");
- int d;
- char another='y';
- while(another=='y') //infinite loop
- {
- system("cls");
- gotoxy(10,5);
- printf("Enter the Lecturer ID to delete:");
- scanf("%d",&d);
- fp=fopen("lecturer.dat","rb+");
- rewind(fp);
- while(fread(&lect,sizeof(lect),1,fp)==1)
- {
- if(lect.lid==d)
- {
- gotoxy(10,7);
- printf("The lecturer is available");
- gotoxy(10,8);
- printf("lecturer name is %s",lect.fname);
- gotoxy(10,9);
- printf("Lecturer Faculty. is %s",lect.faculty);
- findlecturer='t';
- }
- }
- if(findlecturer!='t')
- {
- gotoxy(10,10);
- printf("No record is found modify the search");
- if(getch())
- mainmenu();
- }
- if(findlecturer=='t' )
- {
- gotoxy(10,9);
- printf("Do you want to delete it?(Y/N):");
- if(getch()=='y')
- {
- ft=fopen("ldel.dat.","wb+"); //temporary file for delete
- rewind(fp);
- while(fread(&lect,sizeof(lect),1,fp)==1)
- {
- if(lect.lid!=d)
- {
- fseek(ft,0,SEEK_CUR);
- fwrite(&lect,sizeof(lect),1,ft); //write all in tempory file except that
- } //we want to delete
- }
- fclose(ft);
- fclose(fp);
- remove("lecturer.dat");
- rename("ldel.dat","lecturer.dat"); //copy all item frtemporary file to fp except that
- fp=fopen("lecturer.dat","rb+"); //we want to delete
- if(findlecturer=='t')
- {
- gotoxy(10,10);
- printf("The record is sucessfully deleted");
- gotoxy(10,11);
- printf("Delete another record?(Y/N)");
- }
- }
- else
- mainmenu();
- fflush(stdin);
- another=getch();
- }
- gotoxy(10,15);
- mainmenu();
- }
- }
- void delete_student(void)
- {
- system("cls");
- int d;
- char another='y';
- while(another=='y') //infinite loop
- {
- system("cls");
- gotoxy(10,5);
- printf("Enter the Student ID to delete:");
- scanf("%d",&d);
- fs=fopen("student.dat","rb+");
- rewind(fs);
- while(fread(&stud,sizeof(stud),1,fs)==1)
- {
- if(stud.sid==d)
- {
- gotoxy(10,7);
- printf("The student is available");
- gotoxy(10,8);
- printf("Student name is %s",stud.fname);
- gotoxy(10,9);
- printf("Student Faculty. is %s",stud.faculty);
- findlecturer='t';
- }
- }
- if(findstudent!='t')
- {
- gotoxy(10,10);
- printf("No record is found modify the search");
- if(getch())
- mainmenu();
- }
- if(findstudent=='t' )
- {
- gotoxy(10,9);
- printf("Do you want to delete it?(Y/N):");
- if(getch()=='y')
- {
- ft=fopen("sdel.dat.","wb+"); //temporary file for delete
- rewind(fs);
- while(fread(&stud,sizeof(stud),1,fs)==1)
- {
- if(stud.sid!=d)
- {
- fseek(ft,0,SEEK_CUR);
- fwrite(&stud,sizeof(stud),1,ft); //write all in tempory file except that
- } //we want to delete
- }
- fclose(ft);
- fclose(fs);
- remove("student.dat");
- rename("sdel.dat","Bibek.dat"); //copy all item frtemporary file to fp except that
- fp=fopen("student.dat","rb+"); //we want to delete
- if(findstudent=='t')
- {
- gotoxy(10,10);
- printf("The record is sucessfully deleted");
- gotoxy(10,11);
- printf("Delete another record?(Y/N)");
- }
- }
- else
- mainmenu();
- fflush(stdin);
- another=getch();
- }
- }
- gotoxy(10,15);
- mainmenu();
- }
- void search_lecturer(void)
- {
- system("cls");
- int d=0,i;
- printf("*****************************Search Teacher*********************************");
- gotoxy(20,10);
- printf("\xDB\xDB\xDB\xB2 1. Search By LID");
- gotoxy(20,14);
- printf("\xDB\xDB\xDB\xB2 2. Search By Name");
- gotoxy( 15,20);
- printf("Enter Your Choice");
- fp=fopen("lecturer.dat","rb+"); //open file for reading propose
- rewind(fp); //move pointer at the begining of file
- switch(getch())
- {
- case '1':
- {
- system("cls");
- gotoxy(25,4);
- printf("****Search Teacher By ID****");
- gotoxy(20,5);
- printf("Enter The Lecturer ID:");
- scanf("%d",&d);
- gotoxy(20,7);
- printf("Searching........");
- while(fread(&lect,sizeof(lect),1,fp)==1)
- {
- if(lect.lid==d) //checks whether a.id is equal to d or not
- {
- delay(2);
- gotoxy(20,7);
- printf("The lecturer found");
- gotoxy(20,8);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(20,9);
- printf("\xB2 First Name:%s",lect.fname);gotoxy(47,9);printf("\xB2");
- gotoxy(20,10);
- printf("\xB2 Last Name:%s",lect.lname);gotoxy(47,10);printf("\xB2");
- gotoxy(20,11);
- printf("\xB2 Address:%s ",lect.address);gotoxy(47,11);printf("\xB2");
- gotoxy(20,12);
- printf("\xB2 Faculty:%s ",lect.faculty);gotoxy(47,12);printf("\xB2"); gotoxy(47,11);printf("\xB2");
- gotoxy(20,13);
- printf("\xB2 Phone No.:%d",lect.phoneno);gotoxy(47,13);printf("\xB2");
- gotoxy(20,14);
- printf("\xB2 LID:%d ",lect.lid);gotoxy(47,14);printf("\xB2");
- gotoxy(20,15);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- findlecturer='t';
- }
- }
- if(findlecturer!='t') //checks whether conditiion enters inside loop or not
- {
- gotoxy(20,8);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2");
- gotoxy(20,10);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(22,9);printf("\aNo Record Found");
- }
- gotoxy(20,17);
- printf("Try another search?(Y/N)");
- if(getch()=='y')
- search_lecturer();
- else
- mainmenu();
- break;
- }
- case '2':
- {
- char s[25];
- system("cls");
- gotoxy(25,4);
- printf("****Search Lecturer By Name****");
- gotoxy(20,5);
- printf("Enter Lecturer First Name:");
- scanf("%s",s);
- int d=0;
- while(fread(&lect,sizeof(lect),1,fp)==1)
- {
- if(strcmp(lect.fname,(s))==0) //checks whether a.name is equal to s or not
- {
- gotoxy(20,7);
- printf("The Lecturer found");
- gotoxy(20,8);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(20,9);
- printf("\xB2 First Name:%s",lect.fname);gotoxy(47,9);printf("\xB2");
- gotoxy(20,10);
- printf("\xB2 Last Name:%s",lect.lname);gotoxy(47,10);printf("\xB2");
- gotoxy(20,11);
- printf("\xB2 Address:%s ",lect.address);gotoxy(47,11);printf("\xB2");
- gotoxy(20,12);
- printf("\xB2 Faculty:%s ",lect.faculty);gotoxy(47,12);printf("\xB2"); gotoxy(47,11);printf("\xB2");
- gotoxy(20,13);
- printf("\xB2 Phone No.:%d",lect.phoneno);gotoxy(47,13);printf("\xB2");
- gotoxy(20,14);
- printf("\xB2 LID:%d ",lect.lid);gotoxy(47,14);printf("\xB2");
- gotoxy(20,15);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- d++;
- }
- }
- if(d==0)
- {
- gotoxy(20,8);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2");
- gotoxy(20,10);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(22,9);printf("\aNo Lecturer Found");
- }
- gotoxy(20,17);
- printf("Try another search?(Y/N)");
- if(getch()=='y')
- search_lecturer();
- else
- mainmenu();
- break;
- }
- default :
- getch();
- search_lecturer();
- fclose(fp);
- }
- }
- void search_student()
- {
- system("cls");
- int d;
- printf("*****************************Search Students*********************************");
- gotoxy(20,10);
- printf("\xDB\xDB\xDB\xB2 1. Search By SID");
- gotoxy(20,14);
- printf("\xDB\xDB\xDB\xB2 2. Search By Name");
- gotoxy( 15,20);
- printf("Enter Your Choice");
- fs=fopen("student.dat","rb+"); //open file for reading propose
- rewind(fs); //move pointer at the begining of file
- switch(getch())
- {
- case '1':
- {
- system("cls");
- gotoxy(25,4);
- printf("****Search Student By SID****");
- gotoxy(20,5);
- printf("Enter the student id:");
- scanf("%d",&d);
- gotoxy(20,7);
- printf("Searching........");
- while(fread(&stud,sizeof(stud),1,fs)==1)
- {
- if(stud.sid==d)
- {
- delay(2);
- gotoxy(20,7);
- printf("The student found");
- gotoxy(20,8);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(20,9);
- printf("\xB2 First Name:%s",stud.fname);gotoxy(47,9);printf("\xB2");
- gotoxy(20,10);
- printf("\xB2 Last Name:%s",stud.lname);gotoxy(47,10);printf("\xB2");
- gotoxy(20,11);
- printf("\xB2 Address:%s ",stud.address);gotoxy(47,11);printf("\xB2");
- gotoxy(20,12);
- printf("\xB2 Faculty:%s ",stud.faculty);gotoxy(47,12);printf("\xB2"); gotoxy(47,11);printf("\xB2");
- gotoxy(20,13);
- printf("\xB2 Phone No.:%d",stud.phoneno);gotoxy(47,13);printf("\xB2");
- gotoxy(20,14);
- printf("\xB2 SID:%d ",stud.sid);gotoxy(47,14);printf("\xB2");
- gotoxy(20,15);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- findstudent='t';
- }
- }
- if(findstudent!='t') //checks whether conditiion enters inside loop or not
- {
- gotoxy(20,8);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2");
- gotoxy(20,10);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(22,9);printf("\aNo Record Found");
- }
- gotoxy(20,17);
- printf("Try another search?(Y/N)");
- if(getch()=='y')
- search_student();
- else
- mainmenu();
- break;
- }
- case '2':
- {
- char s[15];
- system("cls");
- gotoxy(25,4);
- printf("****Search Student By First Name****");
- gotoxy(20,5);
- printf("Enter Student Name:");
- scanf("%s",s);
- int d=0;
- while(fread(&stud,sizeof(stud),1,fs)==1)
- {
- if(strcmp(stud.fname,(s))==0) //checks whether a.name is equal to s or not
- {
- gotoxy(20,7);
- printf("The Student found");
- gotoxy(20,8);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(20,9);
- printf("\xB2 First Name:%s",stud.fname);gotoxy(47,9);printf("\xB2");
- gotoxy(20,10);
- printf("\xB2 Last Name:%s",stud.lname);gotoxy(47,10);printf("\xB2");
- gotoxy(20,11);
- printf("\xB2 Address:%s ",stud.address);gotoxy(47,11);printf("\xB2");
- gotoxy(20,12);
- printf("\xB2 Faculty:%s ",stud.faculty);gotoxy(47,12);printf("\xB2"); gotoxy(47,11);printf("\xB2");
- gotoxy(20,13);
- printf("\xB2 Phone No.:%d",stud.phoneno);gotoxy(47,13);printf("\xB2");
- gotoxy(20,14);
- printf("\xB2 SID:%d ",stud.sid);gotoxy(47,14);printf("\xB2");
- gotoxy(20,15);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- d++;
- }
- }
- if(d==0)
- {
- gotoxy(20,8);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2");
- gotoxy(20,10);
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(22,9);printf("\aNo Student Found");
- }
- gotoxy(20,17);
- printf("Try another search?(Y/N)");
- if(getch()=='y')
- search_student();
- else
- mainmenu();
- break;
- }
- default :
- getch();
- search_student();
- fclose(fs);
- }
- }
- void modify_lecturer(void) //edit information about book
- {
- system("cls");
- int c=0;
- int d,e;
- gotoxy(20,4);
- printf("****Modify Lecturer Section****");
- char another='y';
- while(another=='y')
- {
- system("cls");
- gotoxy(15,6);
- printf("Enter Lecturer Id to be edited:");
- scanf("%d",&d);
- fp=fopen("lecturer.dat","rb+");
- while(fread(&lect,sizeof(lect),1,fp)==1)
- {
- if(checklid(d)==0)
- {
- gotoxy(15,7);
- printf("The Lecturer is availble");
- gotoxy(15,8);
- printf("The Lecturer ID:%s",lect.lid);
- gotoxy(15,9);
- printf("Enter new first name:");scanf("%s",lect.fname);
- gotoxy(15,10);
- printf("Enter new last name:");scanf("%s",lect.lname);
- gotoxy(15,11);
- printf("Enter new Address:");scanf("%s",lect.address);
- gotoxy(15,12);
- printf("Enter new phone no.:");scanf("%d",&lect.phoneno);
- gotoxy(15,13);
- printf("Enter new LID:");scanf("%d",&lect.lid);
- gotoxy(15,14);
- printf("The record is modified");
- fseek(fp,ftell(fp)-sizeof(lect),0);
- fwrite(&lect,sizeof(lect),1,fp);
- fclose(fp);
- c=1;
- }
- if(c==0)
- {
- gotoxy(15,9);
- printf("No record found");
- }
- }
- gotoxy(15,16);
- printf("Modify another Record?(Y/N)");
- fflush(stdin);
- another=getch() ;
- }
- returnlect();
- }
- void modify_student(void) //edit information about book
- {
- system("cls");
- int c=0;
- int d,e;
- gotoxy(20,4);
- printf("****Modify Student Section****");
- char another='y';
- while(another=='y')
- {
- system("cls");
- gotoxy(15,6);
- printf("Enter Student Id to be edited:");
- scanf("%d",&d);
- fs=fopen("student.dat","rb+");
- while(fread(&stud,sizeof(stud),1,fs)==1)
- {
- if(checksid(d)==0)
- {
- gotoxy(15,7);
- printf("The Student is availble");
- gotoxy(15,8);
- printf("The Student ID:%s",stud.sid);
- gotoxy(15,9);
- printf("Enter new first name:");scanf("%s",stud.fname);
- gotoxy(15,10);
- printf("Enter new last name:");scanf("%s",stud.lname);
- gotoxy(15,11);
- printf("Enter new Address:");scanf("%s",stud.address);
- gotoxy(15,12);
- printf("Enter new phone no.:");scanf("%d",&stud.phoneno);
- gotoxy(15,13);
- printf("Enter new SID:");scanf("%d",&stud.sid);
- gotoxy(15,14);
- printf("The record is modified");
- fseek(fs,ftell(fs)-sizeof(stud),0);
- fwrite(&stud,sizeof(stud),1,fs);
- fclose(fs);
- c=1;
- }
- if(c==0)
- {
- gotoxy(15,9);
- printf("No record found");
- }
- }
- gotoxy(15,16);
- printf("Modify another Record?(Y/N)");
- fflush(stdin);
- another=getch() ;
- }
- returnstud();
- }
- void lectureroption()
- {
- system("cls");
- int i;
- printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2 LECTURER PANEL");
- printf(" \xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2");
- gotoxy(20,5);
- printf("\xDB\xDB\xDB\xDB\xB2 1. View student");
- gotoxy(20,7);
- printf("\xDB\xDB\xDB\xDB\xB2 2. Mark attendance");
- gotoxy(20,9);
- printf("\xDB\xDB\xDB\xDB\xB2 3. Modify attendance");
- gotoxy(20,11);
- printf("------------------------------------------");
- gotoxy(20,12);
- t();
- gotoxy(20,13);
- printf("Enter your choice:");
- switch(getch())
- {
- case '1':
- take_attendance();
- break;
- case '2':
- view_attendance();
- break;
- case '3':
- modify_attendance();
- break;
- default:
- {
- gotoxy(10,23);
- printf("\aWrong Entry!!Please re-entered correct option");
- if(getch())
- lectureroption();
- }
- }
- }
- void view_attendance(){
- FILE *f = NULL;
- char ch[10000];
- printf("\n\n=================ATTENDANCE LIST=================\n\n");
- printf("ATTENDANCE ID, STUDENT ID, DATE, START TIME, END TIME, MODULE, INTAKE CODE, ATTENDANCE STATUS\n");
- printf("------------------------------------------------------------------------------------\n");
- f = fopen("attendance.dat", "r");
- if (f == NULL){
- printf("Could not open file %s","attendance.dat");
- }else{
- while (EOF != fscanf(f, "%10000[^\n]\n", ch))
- {
- printf("> %s\n", ch);
- }
- fclose(f);
- }
- }
- void take_attendance() {
- struct Attendance attendance;
- int noOfStudents = 0;
- int index = 0, loop, attendance_status;
- FILE *f = NULL;
- attendance.id = rand();
- view_student();
- printf("Enter Number of Students:");
- scanf("%d", &noOfStudents);
- while (noOfStudents > index){
- printf("Enter Student Id:\n");
- scanf("%d", &attendance.student_id);
- printf("Enter Lecture Date (Ex. 2018-01-14):\n");
- scanf("%s", attendance.lectured_date);
- printf("Enter Start Time(Ex. 6:30):\n");
- scanf("%s", attendance.start_time);
- printf("Enter End Time(Ex. 7:30):\n");
- scanf("%s", attendance.end_time);
- printf("Enter Module Name:\n");
- scanf("%c",&temp);
- scanf("%[^\n]", attendance.module_name);
- printf("Enter Intake Code:\n");
- scanf("%s", attendance.intake_code);
- loop = 0;
- while (loop == 0){
- printf("Choose Attendance Status:\n");
- printf("1. Present\n");
- printf("2. Absent\n");
- printf("3. Late\n");
- scanf("%d", &attendance_status);
- switch (attendance_status){
- case 1:
- strcpy(attendance.status, "Present");
- loop = 1;
- break;
- case 2:
- strcpy(attendance.status, "Absent");
- loop = 1;
- break;
- case 3:
- strcpy(attendance.status, "Late");
- loop = 1;
- break;
- default:
- continue;
- }
- }
- f = fopen("attendance.dat", "a");
- fprintf(f, "%d,%d,%s,%s,%s,%s,%s,%s\n", attendance.id, attendance.student_id, attendance.lectured_date, attendance.start_time,
- attendance.end_time, attendance.module_name, attendance.intake_code, attendance.status);
- printf("Attendance Recorded Successfully.\n");
- fclose(f);
- index++;
- }
- }
- void modify_attendance(){
- FILE *f = NULL, *ftemp = NULL;
- char ch[10000], ch_copy[10000], *pt, c, temp_file[] = "temp_attendance.txt";
- int index = 0, found = 0;
- struct Attendance attendance;
- int loop, attendance_status;
- printf("Enter Attendance Id:\n");
- scanf("%d", &attendance.id);
- printf("Please Enter New Attendance Details:\n");
- printf("Enter Student Id:\n");
- scanf("%d", &attendance.student_id);
- printf("Enter Lecture Date (Ex. 2018-01-14):\n");
- scanf("%s", attendance.lectured_date);
- printf("Enter Start Time(Ex. 6:30):\n");
- scanf("%s", attendance.start_time);
- printf("Enter End Time(Ex. 7:30):\n");
- scanf("%s", attendance.end_time);
- printf("Enter Module Name:\n");
- scanf("%c",&temp);
- scanf("%[^\n]", attendance.module_name);
- printf("Enter Intake Code:\n");
- scanf("%s", attendance.intake_code);
- loop = 0;
- while (loop == 0){
- printf("Choose Attendance Status:\n");
- printf("1. Present\n");
- printf("2. Absent\n");
- printf("3. Late\n");
- scanf("%d", &attendance_status);
- switch (attendance_status){
- case 1:
- strcpy(attendance.status, "Present");
- loop = 1;
- break;
- case 2:
- strcpy(attendance.status, "Absent");
- loop = 1;
- break;
- case 3:
- strcpy(attendance.status, "Late");
- loop = 1;
- break;
- default:
- continue;
- }
- }
- f = fopen("attendance.dat", "r");
- ftemp = fopen(temp_file, "w");
- if (f == NULL) {
- printf("Could not open file %s", "attendance.dat");
- } else {
- while (EOF != fscanf(f, "%10000[^\n]\n", ch)) {
- index = 0, found = 0;
- strcpy(ch_copy, ch);
- pt = strtok(ch_copy, ",");
- while (pt != NULL) {
- if (index == 0) {
- int attendance_id = atoi(pt);
- if (attendance_id == attendance.id) {
- found = 1;
- break;
- }
- }
- pt = strtok(NULL, ",");
- index++;
- }
- if (found == 0) {
- fprintf(ftemp, "%s\n", ch);
- } else {
- fprintf(ftemp, "%d,%d,%s,%s,%s,%s,%s,%s\n", attendance.id, attendance.student_id, attendance.lectured_date, attendance.start_time,
- attendance.end_time, attendance.module_name, attendance.intake_code, attendance.status);
- }
- }
- fclose(f);
- fclose(ftemp);
- remove("attendance.dat");
- f = fopen("attendance", "a");
- ftemp = fopen(temp_file, "r");
- c = fgetc(ftemp);
- while (c != EOF) {
- fputc(c, f);
- c = fgetc(ftemp);
- }
- fclose(f);
- fclose(ftemp);
- remove(temp_file);
- }
- }
- int checklid(int t) //check whether the lecturer exist in or not
- {
- rewind(fp);
- while(fread(&lect,sizeof(lect),1,fp)==1)
- if(lect.lid==t)
- return 0; //returns 0 if lecturer exits
- return 1; //return 1 if doesnot exxist
- }
- int checksid(int t) //check whether the student exist or not
- {
- rewind(fs);
- while(fread(&stud,sizeof(stud),1,fs)==1)
- if(stud.sid==t)
- return 0; //returns 0 if student exits
- return 1; //return 1 if doesnot exist
- }
- void returnlect(void)
- {
- printf(" Press ENTER to return to main menu");
- lect:
- if(getch()==13) //allow only use of enter
- mainmenu();
- else
- goto lect;
- }
- void returnstud(void)
- {
- printf(" Press ENTER to return to main menu");
- stud:
- if(getch()==13) //allow only use of enter
- mainmenu();
- else
- goto stud;
- }
- int t(void) //for time
- {
- time_t t;
- time(&t);
- printf("Date and time:%s\n",ctime(&t));
- return 0 ;
- }
- void Password(void) //for password option
- {
- system("cls");
- printf("\n\n=================WELCOME TO THE ATTENDANCE MANAGEMENT SYSTEM=================\n\n\n");
- char d[25]="Password Protected";
- char ch,pass[10];
- int i=0,j;
- //textbackground(WHITE);
- //textcolor(RED);
- gotoxy(10,4);
- for(j=0;j<20;j++)
- {
- delay(5);
- printf("*");
- }
- for(j=0;j<20;j++)
- {
- delay(5);
- printf("%c",d[j]);
- }
- for(j=0;j<20;j++)
- {
- delay(5);
- printf("*");
- }
- gotoxy(10,10);
- gotoxy(15,7);
- printf("Enter Password:");
- while(ch!=13)
- {
- ch=getch();
- if(ch!=13 && ch!=8)
- {
- putch('*');
- pass[i] = ch;
- i++;
- }
- }
- pass[i] = '\0';
- if(strcmp(pass,password)==0)
- {
- gotoxy(15,9);
- //textcolor(BLINK);
- printf("Password match");
- gotoxy(17,10);
- printf("Press any key to countinue.....");
- getch();
- mainmenu();
- }
- else
- {
- gotoxy(15,16);
- printf("\aWarning!! Incorrect Password");
- getch();
- Password();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement