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
- void mainmenu(void);
- void returnlect(void);
- void returnstud(void);
- void checkday(int , char*);
- void check_lectdates();
- void register_lecturer(void);
- void register_student(void);
- void view_lecturer(void);
- void view_student(void);
- void search_student(void);
- void search_lecturer(void);
- void delete_student(void);
- void delete_lecturer(void);
- void modify_student(void);
- void modify_lecturer(void);
- void attend(void);
- void modify_attendence(void);
- int t(void);
- //void closeapplication(void);
- void adminoption();
- void lectureroption();
- int studentoption();
- void Password();
- 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;
- char findstudent;
- char findlecturer;
- char password[10]={"codder"};
- struct date
- {
- int mm,dd,yy;
- };
- struct lecturer
- {
- char fname[25];
- char lname[25];
- char address[35];
- char faculty[20];
- int phoneno[15];
- int lid[10]; // lecturer id no.
- struct date attendance;
- };
- struct lecturer lect;
- struct student
- {
- char fname[25];
- char lname[25];
- char address[35];
- char faculty[20];
- int phoneno[15];
- int sid[10]; // student id no.
- struct date attendance;
- };
- struct student stud;
- int main()
- {
- Password();
- getch();
- return 0;
- }
- void mainmenu()
- {
- system("cls");
- // textbackground(13);
- int i;
- 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 7. 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;
- char username[25],password[15];
- printf("Enter your username:");
- scanf("%s",&username);
- printf("Enter 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 1. Register lecturer");
- gotoxy(20,7);
- printf("\xDB\xDB\xDB\xDB\xB2 2. Register student");
- gotoxy(20,9);
- printf("\xDB\xDB\xDB\xDB\xB2 3. View lecturer");
- gotoxy(20,11);
- printf("\xDB\xDB\xDB\xDB\xB2 4. View student");
- gotoxy(20,13);
- printf("\xDB\xDB\xDB\xDB\xB2 5. Delete lecturer");
- gotoxy(20,15);
- printf("\xDB\xDB\xDB\xDB\xB2 6. Delete student");
- gotoxy(20,17);
- printf("\xDB\xDB\xDB\xDB\xB2 7. Search lecturer");
- gotoxy(20,19);
- printf("\xDB\xDB\xDB\xDB\xB2 8. Search student");
- gotoxy(20,21);
- printf("\xDB\xDB\xDB\xDB\xB2 9. Modify lecturer");
- gotoxy(20,23);
- printf("\xDB\xDB\xDB\xDB\xB2 10. Modify student");
- gotoxy(20,25);
- printf("\xDB\xDB\xDB\xDB\xB2 11. Modify Attendance");
- gotoxy(20,27);
- printf("------------------------------------------");
- gotoxy(20,28);
- t();
- gotoxy(20,30);
- printf("Enter your choice:");
- switch(getch())
- {
- case '1':
- register_lecturer();
- break;
- case '2':
- register_student();
- case '3':
- view_lecturer();
- break;
- case'4':
- view_student();
- break;
- case '5':
- delete_lecturer();
- break;
- case '6':
- delete_student();
- break;
- case '7':
- search_lecturer();
- break;
- case '8':
- search_student();
- break;
- case '9':
- modify_lecturer();
- break;
- case'10':
- modify_student();
- break;
- case '11':
- modify_attendence();
- break;
- default:
- {
- gotoxy(10,23);
- printf("\aWrong Entry!!Please re-entered correct option");
- if(getch())
- adminoption();
- }
- }
- }
- void lectureroption()
- {
- int i;
- clrscr();
- 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':
- view_student();
- break;
- case '2':
- mark_attendance();
- break;
- case '3':
- modify_attendance();
- break;
- default:
- {
- gotoxy(10,23);
- printf("\aWrong Entry!!Please re-entered correct option");
- if(getch())
- lectureroption();
- }
- int studentoption()
- clrscr();
- 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 attendence");
- gotoxy(20,7);
- printf("\xDB\xDB\xDB\xDB\xB2 2. Update attendance");
- gotoxy(20,9);
- printf("------------------------------------------");
- gotoxy(20,10;
- t();
- gotoxy(20,11);
- printf("Enter your choice:");
- switch(getch())
- {
- case '1':
- view_attendance();
- break;
- case '2':
- update_attendance();
- break;
- default:
- {
- gotoxy(10,23);
- printf("\aWrong Entry!!Please re-entered correct option");
- if(getch())
- studentoption();
- }
- }
- void register_lecturer(){
- FILE *fp
- lect.id=t;
- gotoxy(21,7);
- printf("First name:");gotoxy(33,7);
- scanf("%s",lect.fname);
- gotoxy(21,8);
- printf("Last name:");gotoxy(30,8);
- scanf("%s",lect.lname);
- gotoxy(21,9);
- printf("Address:");gotoxy(31,9);
- scanf("%s",lect.address);
- gotoxy(21,10);
- printf("Faculty:");gotoxy(28,10);
- scanf("%s",lect.faculty);
- gotoxy(21,11);
- printf("Phone No.:");gotoxy(30,11);
- scanf("%d",&lect.phoneno);
- gotoxy(21,12);
- prinf("SID.:");
- scanf("%d",&lect.lid);
- fp=fopen("lecturer.dat","ab");
- fprintf(fp,"\n%s%s%s%s%d%d\n",fname,lname,address,faculty,phoneno,lid);
- gotoxy(21,14);
- printf("Lecturer registered sucessfully!!");
- fclose(fp);
- gotoxy(21,15);
- printf("Register any more?(Y / N):");
- if(getch()=='n')
- mainmenu();
- else
- system("cls");
- register_lecturer();
- }
- void register_student(){
- file *fs=fopen("student.dat","ab");
- stud.id=t;
- gotoxy(21,7);
- printf("First name:");gotoxy(33,7);
- scanf("%s",stud.fname);
- gotoxy(21,8);
- printf("Last name:");gotoxy(30,8);
- scanf("%s",stud.lname);
- gotoxy(21,9);
- printf("Address:");gotoxy(31,9);
- scanf("%s",stud.address);
- gotoxy(21,10);
- printf("Faculty:");gotoxy(28,10);
- scanf("%s",stud.faculty);
- gotoxy(21,11);
- printf("Phone No.:");
- scanf("%d",&stud.phoneno);
- gotoxy(21,12);
- prinf("SID.:");
- scanf("%d",&stud.sid);
- fprintf(fs,"\n%s%s%s%s%d%d\n",fname,lname,address,faculty,phoneno,sid);
- gotoxy(20,13);
- printf("Student registered sucessfully!!");
- fclose(fs);
- gotoxy(21,15);
- printf("Register any more?(Y / N):");
- if(getch()=='n')
- mainmenu();
- else
- system("cls");
- register_student();
- return;
- }
- void search_lecturer()
- {
- system("cls");
- int d;
- 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 Faculty****");
- gotoxy(20,5);
- printf("Enter The Teacher Faculty:");
- scanf("%d",&d);
- gotoxy(20,7);
- printf("Searching........");
- while(fread(&a,sizeof(a),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[15];
- system("cls");
- gotoxy(25,4);
- printf("****Search Lecturer By Name****");
- gotoxy(20,5);
- printf("Enter Lecturer Name:");
- scanf("%s",s);
- int d=0;
- while(fread(&a,sizeof(a),1,fp)==1)
- {
- if(strcmp(lect.name,(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(&a,sizeof(a),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 Name****");
- gotoxy(20,5);
- printf("Enter Student Name:");
- scanf("%s",s);
- int d=0;
- while(fread(&a,sizeof(a),1,fs)==1)
- {
- if(strcmp(stud.name,(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 delete_lecturer() // function that deletes lecturer record.
- {
- 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(&a,sizeof(a),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(&a,sizeof(a),1,fp)==1)
- {
- if(lect.lid!=d)
- {
- fseek(ft,0,SEEK_CUR);
- fwrite(&a,sizeof(a),1,ft); //write all in tempory file except that
- } //we want to delete
- }
- fclose(ft);
- fclose(fp);
- remove("lecturer.dat");
- rename("ldel.dat","Bibek.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() // function that deletes student record
- {
- 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(&a,sizeof(a),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(&a,sizeof(a),1,fs)==1)
- {
- if(stud.sid!=d)
- {
- fseek(ft,0,SEEK_CUR);
- fwrite(&a,sizeof(a),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 view_lecturer()
- {
- int i=0,j;
- system("cls");
- gotoxy(1,1);
- printf("*********************************Lecturer List*****************************");
- gotoxy(2,2);
- printf(" First Name Last Name Address Faculty Phone No. LID ");
- j=4;
- fp=fopen("lecturer.dat","rb");
- while(fread(&a,sizeof(a),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("%s",lect.faculty);
- gotoxy(50,j);
- printf("%d",lect.phoneno);
- gotoxy(57,j);
- printf("%d",lect.lid);
- printf("\n\n");
- j++;
- }
- fclose(fp);
- gotoxy(35,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(&a,sizeof(a),1,fs)==1)
- {
- gotoxy(3,j);
- printf("%s",stud.fname);
- gotoxy(16,j);
- printf("%s",stud.lname);
- gotoxy(22,j);
- printf("%s",stud.address);
- gotoxy(36,j);
- printf("%s",stud.faculty);
- gotoxy(50,j);
- printf("%d",stud.phoneno);
- gotoxy(57,j);
- printf("%d",stud.sid);
- printf("\n\n");
- j++;
- }
- fclose(fs);
- gotoxy(35,25);
- returnstud();
- }
- 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(&a,sizeof(a),1,fp)==1)
- {
- if(checkid(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(a),0);
- fwrite(&a,sizeof(a),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(&a,sizeof(a),1,fs)==1)
- {
- if(checkid(d)==0)
- {
- gotoxy(15,7);
- printf("The Student is availble");
- gotoxy(15,8);
- printf("The Student ID:%s",stud.lid);
- 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.lid);
- gotoxy(15,14);
- printf("The record is modified");
- fseek(fs,ftell(fs)-sizeof(a),0);
- fwrite(&a,sizeof(a),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 attendance()
- {
- }
- void modify_attendance(){
- return;
- }
- 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");
- 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(50);
- printf("*");
- }
- for(j=0;j<20;j++)
- {
- delay(50);
- printf("%c",d[j]);
- }
- for(j=0;j<20;j++)
- {
- delay(50);
- 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