Sei sulla pagina 1di 54

HOLIDAY HOME WORK : CLASS 12

SUBJECT : COMPUTER SCIENCE


Based on the points mentioned below all are the complete term end project.
a. Select a real life problem such as
i. Railway reservation system
ii. Working of retailer shop
iii. Working of gas agency
iv. Allotment of government quarters
v. Gate security system
vi. Result preparation system
vii. School time table system
viii. Any other project with reallife relevance and with
considerabale complexity.
b. Project should be well planned and should include following
i. Multiple classes for handling user data
ii. Data file with functionality of read, write, update, delete and
search.
iii. Menu based programming.
iv. Maximum code should be in functions
v. Size of each function should be manageable.
vi. Code should self documenting
c. Create project report as per demo specification given below.
d. Submit the project which include
i. Word file in soft copy
ii. C++ source file
iii. Readme file
e. After approval by subject teacher take print out of write up and
create a CD with above three files
f. The final report should inclue CD and final report in spiral binding.
g. Due dates
i. Submission for approval : 13 Jan 2016
ii. Final print out and submission: 15 Jan 2016

A Project Report on
Software Project(C++)

AISSCE
2016

School Database Management &


ID Based Entry Recording System

Submitted By:
PQR Paul
Roll no: 3625712

Under the Guidance of:


Shri Sanwar Mal (PGT Comp.Sci)

Submitted to:
Department of Computer Science
Kendriya Vidyalaya No. 2, Shift-1, Delhi Cantt

Department of Computer Science


Kendriya Vidyalaya No. 2, Shift-1, Delhi Cantt

CERTIFICATE

This is to certify that PQR Paul, Roll no. :-3625712 of


Class XII A has prepared the report on the Project entitled
School Database Management & ID Based Entry Recording System
.
The report is the result of his efforts and endeavors. The
report is found worthy of acceptance as final project report for
the subject computer science of Class XII A. He has prepared
the report under my guidance.

(Mr. Sanwar Mal)


PGT (Comp. Sci.)
Department of Computer Science
Kendriya Vidyalaya No. 2, Shift-1, Delhi Cantt

Department of Computer Science


Kendriya Vidyalaya No. 2, Shift-1, Delhi Cantt

CERTIFICATE

The project report entitled School Database Management & ID


Based Entry Recording System , submitted by PQR Paul, Roll no:
3625712 of Class XII A for All India Senior Secondary Certificate
Examination (AISSCE) -2016 of subject Computer Science at
Kendriya Vidyalaya Khatkhati(Assam) has been examined.

Examiner
Date:

February, 2016

Place :- New Delhi

DECLARATION

I hereby declare that the project work entitled School


Database Management & ID Based Entry Recording System,
submitted to Department of Computer Science Kendriya
Vidyalaya Khatkhati (Assam) is prepared by me. All the coding
are result of my personal efforts.

PQR Paul
Class XII A
Roll No:3625712

ACKNOWLEDGEMENTS

I would like to express a deep sense of thanks and gratitude to my


project guide Sh. Sanwar Mal Sir for guiding me immensely through the
course of the project. He always evinced keen interest in my work. His
constructive advice and constant motivation have been responsible for the
successful completion of this project.
My sincere thanks goes to Ms. Bharathi Kukkal, principal madam, for
her co-ordination in extending every possible support for the completion of
this project.
I also thanks to my parents for their motivation and support. I must
thanks to my classmates for their timely help and support for compilation of
this project.
Last but not the least; I would like to thank all those who had helped
directly or indirectly towards the completion of this project.

PQR Paul
Class XII A

CONTENTS

1.

Introduction

2.

Description of program with screenshots

3.

Testing

4.

Bibliography

INTRODUCTION
Schools of KVS are one of the renouned Institutions of
India , students and as well as teacher of it are indulged not only
in academic but also many co-curicular activities. Since it is a
Govt. of India undertaken Institution there fore it has a lot of
paper works to be done , usually they are done by maintaining
huge registers, from the entry of a person in vidyalaya to the lists
of TC issued students, all are manually recorded. It increases a lot
of data redundancy and personal errors done by the staffs.So by
maintaining a digital record the effort is reduced a lot and
secondly a large amount of energy and resourses is saved.
Since a school has a lot of elements that is to be
recorded manually therefore combining all of them in one
programe will be a very tough job. So I have designed my program
in C++ to cover some of its aspects. My programe is associated
with basic database of all teachers and student containing the bio
data of them , it allows to add , delete ,edit biodata of
students.And it also contains a ID no based entry system thats
records the entry of a particular person.

Description of program with screenshots

Header file used


Iostream.h
2. conio.h
3. Ffstream.h
4. String.h
5. Stdio.h
6. Stdlib.h
7. Iomanip.h
8. Time.h
9. Ctype.h
10. Process.h
11. Dos.h
1.

Global file streams used


//file stream
ofstream fout;
ifstream fin;

Global variables used


//global variable
int flag,r,p,g;
Various function prortotypes used in the program
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.

void welcome_screen(void);
int administrator_menu(void);
void search_teacher(void);
void search_student(void);
void show_all_teacher(void);
void show_all_student(void);
void delete_teacher(void);
void delete_student(void);
void edit_teacher(void);
void edit_student(void);
void show_all_entry(void);
void show_part_entry(void);
void add_entry();
void char main_screen(void)

Class Declaration and its objects


1)
class teacher
{
public:
int qtr_no;
float basic_pay;
char name[20];
char email_id[20];
char post[15];
int id_no;
void add_tech();
int getid(){return id_no;}
void disp_tech();
} t1;
Here t1 is global object of class teacher used for various purpose
2)
class student
{
public:
int id_no;
int rollno;
char name[20];
char email_id[20];
char clas[3];
void add_stu();
int getid(){return id_no;}
void disp_stu();
} s1 ;
Here s1 is global object of class student used for various purpose
3)
class entry
{
public:
int idno,year,month,day,hr,min,sec;
void add_entry();
void show_entry();
int get_id(){return idno;}
} e1 ;
Here e1 is global object of class entry used for various purpose

The welcome screen and its function

//Welcome function
void welcome_screen()
{
clrscr();
for(int i=2;i<78;i++)
{
gotoxy(i,2);
textcolor(RED+BLINK);
cputs("-");
}
for(i=3;i<24;i++)
{
gotoxy(2,i);
textcolor(RED+BLINK);
cputs("|");
gotoxy(77,i);
textcolor(RED+BLINK);
cputs("|");
}
for(i=2;i<78;i++)
{
gotoxy(i,24);
textcolor(RED+BLINK);

cputs("-");
}
for(i=4;i<23;i++)
{
gotoxy(8,i);
textcolor(LIGHTRED+BLINK);
cputs("*");
}
for(i=4;i<23;i++)
{
gotoxy(70,i);
textcolor(LIGHTRED+BLINK);
cputs("*");
}
for(i=4;i<76;i++)
{
gotoxy(i,6);
textcolor(LIGHTBLUE+BLINK);
cputs("=");
}
for(i=4;i<76;i++)
{
gotoxy(i,20);
textcolor(LIGHTBLUE+BLINK);
cputs("=");
}
gotoxy(20,8);
textcolor(YELLOW);
cputs(" +++++++");
gotoxy(32,8);
textcolor(LIGHTRED+BLINK);
cputs(" W E L C O M E ");
gotoxy(48,8);
textcolor(YELLOW);
cputs(" ++++++++");
gotoxy(30,10);
textcolor(WHITE+RED);
cputs("KENDTIYA VIDYALAYA");
gotoxy(25,11);
textcolor(WHITE+RED);
cputs("G.C. C.R.P.F. Khatkhati,ASSAM");
gotoxy(14,14);
textcolor(LIGHTRED);
cputs("Database Management AND Entry Record Keeping
Program");
gotoxy(27,16);
textcolor(WHITE);

cputs("Loading Files Please Wait");


gotoxy(14,17);
cout<<"--------------------------------------------------";
gotoxy(14,18);
cout<<"|";
gotoxy(64,18);
cout<<"|";
gotoxy(14,19);
cout<<"--------------------------------------------------";
gotoxy(15,18);
for(i=0;i<49;i++)
{
textcolor(YELLOW+BLINK);
cputs(" ");
delay(50);
}
delay(300);
return;
}
The main screen and its function

//Main menu function


char main_screen()

{
clrscr();
for(int i=10;i<68;i++)
{
gotoxy(i,5);
textcolor(YELLOW+BLINK);
cputs("-");
}
for(i=6;i<21;i++)
{
gotoxy(10,i);
textcolor(RED+BLINK);
cputs("|");
gotoxy(67,i);
textcolor(RED+BLINK);
cputs("|");
}
for(i=10;i<68;i++)
{
gotoxy(i,21);
textcolor(YELLOW+BLINK);
cputs("-");
}
for(i=6;i<21;i++)
{
gotoxy(16,i);
textcolor(LIGHTRED+BLINK);
cputs("+");
}
for(i=16;i<67;i++)
{
gotoxy(i,8);
textcolor(LIGHTBLUE+BLINK);
cputs("=");
}
gotoxy(23,8);
textcolor(YELLOW);
cputs(" +++++++ ");
gotoxy(35,8);
textcolor(LIGHTRED+BLINK);
cputs("
MAIN MENU
");
gotoxy(51,8);
textcolor(YELLOW);
cputs(" ++++++++ ");
gotoxy(30,13);
textcolor(WHITE+RED);
cputs("1. ADMINISTRATOR MENU ");
gotoxy(30,15);

textcolor(WHITE+RED);
cputs("2. Add Entry ");
gotoxy(30,17);
textcolor(WHITE+RED);
cputs("3. Exit ");
char ch;
cin>>ch;
return(ch);
//getch();
}
The Administrator menu and its function

//Administrator menu function


int administrator_menu()
{
int ch;
clrscr();
for(int i=2;i<78;i++)
{
gotoxy(i,2);
textcolor(LIGHTRED+BLINK);
cputs("=");
}
for(i=2;i<78;i++)
{
gotoxy(i,24);

textcolor(LIGHTBLUE+BLINK);
cputs("_");
}
for(i=3;i<25;i++)
{
gotoxy(2,i);
textcolor(YELLOW+BLINK);
cputs("|");
gotoxy(77,i);
textcolor(YELLOW+BLINK);
cputs("|");
}
for(i=2;i<78;i++)
{
gotoxy(i,6);
textcolor(LIGHTBLUE+BLINK);
cputs("_");
}
gotoxy(14,4);
textcolor(RED);
cputs("||
A D M I N S T R A T I V E
||");
gotoxy(23,9);
textcolor(MAGENTA);
cputs("1.
Add New Teacher");
gotoxy(23,10);
textcolor(MAGENTA);
cputs("2.
Add New Student");
gotoxy(23,11);
textcolor(MAGENTA);
cputs("3.
Search Teacher");
gotoxy(23,12);
textcolor(MAGENTA);
cputs("4.
Search Student");
gotoxy(23,13);
textcolor(MAGENTA);
cputs("5.
Show All Teacher");
gotoxy(23,14);
textcolor(MAGENTA);
cputs("6.
Show All Student");
gotoxy(23,15);
textcolor(MAGENTA);
cputs("7.
Delete Teacher");
gotoxy(23,16);
textcolor(MAGENTA);
cputs("8.
Delete Student");
gotoxy(23,17);
textcolor(MAGENTA);

M E N U

cputs("9.
Edit Teacher");
gotoxy(23,18);
textcolor(MAGENTA);
cputs("10.
Edit Student");
gotoxy(23,19);
textcolor(MAGENTA);
cputs("11.
Show All Entry");
gotoxy(23,20);
textcolor(MAGENTA);
cputs("12.
Show Particular Entry");
gotoxy(23,22);
textcolor(LIGHTGREEN);
cputs("ENTER YOUR CHOICE...");
cin>>ch;
return(ch);
}
The adding new teacher window and its function
It takes ID no of new teacher as input and check its availability

If the Id no is already availability then it displays to input a new no but if it


is not available then it displays

Then it displays a message that teacher is added successfully


//teacher adding menu
void teacher::add_tech()
{
//delete teacher::t1;
clrscr();
for(int i=5;i<74;i++)
{
gotoxy(i,2);
textcolor(YELLOW+BLINK);
cputs("-");
}
for(i=3;i<24;i++)
{
gotoxy(5,i);
textcolor(RED+BLINK);
cputs("|");
gotoxy(73,i);
textcolor(RED+BLINK);
cputs("|");
}
for(i=5;i<74;i++)
{
gotoxy(i,24);
textcolor(YELLOW+BLINK);
cputs("-");
}
gotoxy(27,4);
textcolor(LIGHTRED);
cputs("Adding Teacher Details");
gotoxy(10,5);
textcolor(WHITE);
cputs("*******************************************************
****");
gotoxy(38,6);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,7);
textcolor(WHITE);
cputs("ID number
:
|
| ");
gotoxy(38,8);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,9);
textcolor(WHITE);

cputs("--------------------------------");
gotoxy(10,10);
textcolor(WHITE);
cputs("Quater number
:
|
");
gotoxy(38,11);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,12);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,13);
textcolor(WHITE);
cputs("Basic Pay (Rs)
:
|
");
gotoxy(38,14);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,15);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,16);
textcolor(WHITE);
cputs("Name
:
|
");
gotoxy(38,17);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,18);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,19);
textcolor(WHITE);
cputs("E-main Id
:
|
");
gotoxy(38,20);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,21);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,22);
textcolor(WHITE);
cputs("Post
:
|
");
gotoxy(38,23);
textcolor(WHITE);
cputs("--------------------------------");

gotoxy(39,7);
cin>>id_no;
gotoxy(39,10);
cin>>qtr_no;
gotoxy(39,13);
cin>>basic_pay;
gotoxy(39,16);
gets(name);
gotoxy(39,19);
gets(email_id);
gotoxy(39,22);
gets(post);
fout.open("Teacher.dat",ios::binary|ios::app);
fout.write((char *)&t1,sizeof(t1));
fout.close();
clrscr();
for(i=0;i<3;i++)
{
clrscr();
delay(500);
gotoxy(25,11);
cputs("*** Teacher Added Sucessfully ***");
delay(500);
}
return;
}

The adding new student window and its function


It takes ID no of new student as input and check its availability

If the Id no is already availability then it displays to input a new no but if it


is not available then it displays

//student adding menu


void student::add_stu()
{
clrscr();
for(int i=5;i<74;i++)
{
gotoxy(i,2);
textcolor(YELLOW+BLINK);
cputs("-");
}
for(i=3;i<24;i++)
{
gotoxy(5,i);
textcolor(RED+BLINK);
cputs("|");
gotoxy(73,i);
textcolor(RED+BLINK);
cputs("|");
}
for(i=5;i<74;i++)
{
gotoxy(i,24);
textcolor(YELLOW+BLINK);
cputs("-");
}
gotoxy(27,5);
textcolor(LIGHTRED);
cputs("Adding Student Details");

gotoxy(10,7);
textcolor(WHITE);
cputs("*******************************************************
****");
gotoxy(38,8);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,9);
textcolor(WHITE);
cputs("ID number
:
|
| ");
gotoxy(38,10);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,11);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,12);
textcolor(WHITE);
cputs("Rollno
:
|
| ");
gotoxy(38,13);;
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,14);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,15);
textcolor(WHITE);
cputs("Name
:
|
| ");
gotoxy(38,16);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,17);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,18);
textcolor(WHITE);
cputs("E-mail Id
:
|
| ");
gotoxy(38,19);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,20);
textcolor(WHITE);
cputs("--------------------------------");

gotoxy(10,21);
textcolor(WHITE);
cputs("Class
:
|
| ");
gotoxy(38,22);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(39,9);
cin>>id_no;
int t=id_no;
fin.open("Student.dat",ios::binary|ios::in);
fin.seekg(0);
int p=1;
while(fin.read((char *)&s1,sizeof(s1))&&(p!=0))
{
int x=s1.getid();
if(t==x)
{
clrscr();
cout<<"\n\n\n\t\t Student already Exist !!! ENTER NEW ID
NUMBER ";
delay(1000);
add_stu();
return;
}
}
gotoxy(39,12);
cin>>rollno;
gotoxy(39,15);
gets(name);
gotoxy(39,18);
gets(email_id);
gotoxy(39,21);
gets(clas);
fout.open("Student.dat",ios::binary|ios::app);
fout.write((char *)&s1,sizeof(s1));
fout.close();
clrscr();
for(i=0;i<3;i++)
{
clrscr();
delay(250);
gotoxy(25,11);
cputs("*** Student Added Sucessfully ***");
delay(250);
}
return;
}

The Searching teacher window and its code


First it takes the Id no and then if available then displays it

//funC for searching teacher


void search_teacher(void)
{
clrscr();
flag=0;
int eno;
cout<<"\n\tEnter Id number of teacher : ";
cin>>eno;
fin.open("Teacher.dat",ios::binary);
if(!fin)
{
cout<<"\n\nFile Not Found...";
return;
}
fin.seekg(0);
while(fin.read((char*)&t1, sizeof(t1)))
{
int x=t1.getid();//teacher::getid();
if(x==eno)
{
flag=1;
cout<<"\n\n\t\tTeacher Details are \n";
cout<<"\t\t====================\n";
t1.disp_tech();
}

}
fin.close();
if(flag==0) cout<<"\n\t\tTeaher does not exist....Please
Retry!";
getch();
}
The Disp_tech() funC
void teacher::disp_tech()
{
clrscr();
for(int i=5;i<74;i++)
{
gotoxy(i,2);
textcolor(YELLOW+BLINK);
cputs("-");
}
for(i=3;i<24;i++)
{
gotoxy(5,i);
textcolor(RED+BLINK);
cputs("|");
gotoxy(73,i);
textcolor(RED+BLINK);
cputs("|");
}
for(i=5;i<74;i++)
{
gotoxy(i,24);
textcolor(YELLOW+BLINK);
cputs("-");
}
gotoxy(27,4);
textcolor(LIGHTRED);
cputs("Displaying Teacher Details");
gotoxy(10,5);
textcolor(WHITE);
cputs("*******************************************************
****");
gotoxy(10,6);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,7);
textcolor(WHITE);
cputs("|| ID number
:
||");
gotoxy(10,8);

textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,9);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,10);
textcolor(WHITE);
cputs("|| Quater number :
||");
gotoxy(10,11);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,12);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,13);
textcolor(WHITE);
cputs("|| Basic Pay (Rs) :
||");
gotoxy(10,14);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,15);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,16);
textcolor(WHITE);
cputs("|| Name
:
||");
gotoxy(10,17);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,18);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,19);
textcolor(WHITE);
:
cputs("|| E-main Id
||");
gotoxy(10,20);

textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,21);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,22);
textcolor(WHITE);
cputs("|| Post
:
||");
gotoxy(10,23);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(39,7);
cout<<id_no;
gotoxy(39,10);
cout<<qtr_no;
gotoxy(39,13);
cout<<basic_pay;
gotoxy(39,16);
cputs(name);
gotoxy(39,19);
cputs(email_id);
gotoxy(39,22);
cputs(post);
}
The Searching teacher window and its code
First it takes the Id no and then if available then displays it

//funC for searching student


void search_student(void)
{
clrscr();
flag=0;
int eno;
cout<<"\n\tEnter Id number of Student : ";
cin>>eno;
fin.open("Student.dat",ios::binary);
if(!fin)
{
cout<<"\n\nFile Not Found...";
return;
}
fin.seekg(0);
while(fin.read((char*)&s1, sizeof(s1)))
{
int x=s1.getid();//student::getid();
if(x==eno)
{
flag=1;
cout<<"\n\n\t\tStudent Details are \n";
cout<<"\t\t====================\n";
s1.disp_stu();
}
}
fin.close();
if(flag==0) cout<<"\n\t\tStudent does not exist....Please
Retry!";
getch();
}
The disp_stud() funC
void student::disp_stu()
{
clrscr();
for(int i=5;i<74;i++)
{
gotoxy(i,2);
textcolor(YELLOW+BLINK);
cputs("-");
}
for(i=3;i<24;i++)
{
gotoxy(5,i);
textcolor(RED+BLINK);
cputs("|");

gotoxy(73,i);
textcolor(RED+BLINK);
cputs("|");
}
for(i=5;i<74;i++)
{
gotoxy(i,24);
textcolor(YELLOW+BLINK);
cputs("-");
}
gotoxy(27,5);
textcolor(LIGHTRED);
cputs("Displaying Student Details");
gotoxy(10,7);
textcolor(WHITE);
cputs("*******************************************************
****");
gotoxy(10,8);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,9);
textcolor(WHITE);
cputs("|| ID number
:
||");
gotoxy(10,10);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,11);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,12);
textcolor(WHITE);
cputs("|| Rollno
:
||");
gotoxy(10,13);;
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,14);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,15);
textcolor(WHITE);

cputs("|| Name
:
||");
gotoxy(10,16);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,17);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,18);
textcolor(WHITE);
cputs("|| E-mail Id
:
||");
gotoxy(10,19);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,20);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(10,21);
textcolor(WHITE);
cputs("|| Class
:
||");
gotoxy(10,22);
textcolor(WHITE);
cputs("------------------------------------------------------------");
gotoxy(39,9);
cout<<id_no;
gotoxy(39,12);
cout<<rollno;
gotoxy(39,15);
cputs(name);
gotoxy(39,18);
cputs(email_id);
gotoxy(39,21);
cputs(clas);
}

The Show all the teacher window and its code

If the page is full the press enter to continue


//funC to show all teachers
void show_all_teacher(void)
{
clrscr();
textcolor(LIGHTGREEN);
gotoxy(1,2);
cputs("=======================================================
=======================");
gotoxy(1,3);
cputs("|| Id no ||Qtr no||Basic Pay||
Name
||
Email_id
||Post||");
gotoxy(1,4);
cputs("=======================================================
=======================");
fin.open("Teacher.dat",ios::binary);
fin.seekg(0);
int i=5;
while(fin.read((char*)&t1, sizeof(t1))&&i<25)
{
if(fin.eof())
{
getch();
return;

}
textcolor(WHITE);
{
gotoxy(4,i);cout<<t1.id_no;
gotoxy(13,i);cout<<t1.qtr_no;
gotoxy(21,i);cout<<t1.basic_pay;
gotoxy(32,i);cputs(t1.name);
gotoxy(48,i);cputs(t1.email_id);
gotoxy(73,i);cputs(t1.post);
}
i++;
if(i==23)
{
getch();
clrscr();
textcolor(LIGHTGREEN);
gotoxy(1,2);
cputs("=======================================================
=======================");
gotoxy(1,3);
cputs("|| Id no ||Qtr no||Basic Pay||
Name
||
Email_id
||Post||");
gotoxy(1,4);
cputs("=======================================================
=======================");
i=5;
}
}
fin.close();
getch();
return;
}
The Show all the student window and its code
//funC to show all student
void show_all_student(void)
{
clrscr();
textcolor(LIGHTGREEN);
gotoxy(1,2);
cputs("=======================================================
=======================");
gotoxy(1,3);
cputs("|| Id no ||Rollno||Name
||Email_id
||Class||");

gotoxy(1,4);
cputs("=======================================================
=======================");
fin.open("Student.dat",ios::binary|ios::in);
fin.seekg(0);
int i=5;
while(fin.read((char*)&s1, sizeof(s1))&&i<25)
{
if(fin.eof())
{
getch();
return;
}
textcolor(WHITE);
{
gotoxy(4,i);cout<<s1.id_no;
gotoxy(13,i);cout<<s1.rollno;
gotoxy(21,i);cputs(s1.name);
gotoxy(43,i);cputs(s1.email_id);
gotoxy(71,i);cputs(s1.clas);
}
i++;
if(i==24)
{
getch();
clrscr();
textcolor(LIGHTGREEN);
gotoxy(1,2);
cputs("=======================================================
=======================");
gotoxy(1,3);
cputs("|| Id no ||Rollno||Name
||Email_id
||Class||");
gotoxy(1,4);
cputs("=======================================================
=======================");
i=5;
}
}
fin.close();
getch();
return;
}

The delete teacher window and its code

//function for deleting teacher


void delete_teacher(void)
{
flag=0;
cout<<"\n\n\tEnter Teacher ID_no to be deleted :";
int eno;
cin>>eno;
fin.open("Teacher.dat",ios::binary);
if(!fin)
{
cout<<"\n\nFile Not Found...";
return;
}
fstream tmp("temp_tech.dat",ios::binary|ios::out);
fin.seekg(0);
while(fin.read((char*)&t1, sizeof(t1)))
{
int x=t1.getid();//t1.teacher::getid();
if(x!=eno)
tmp.write((char*)&t1,sizeof(t1));
else
{
flag=1;
}
}
fin.close();
tmp.close();
fout.open("Teacher.dat",ios::trunc|ios::binary);
fout.seekp(0);
tmp.open("temp_tech.dat",ios::binary|ios::in);
if(!tmp)
{
cout<<"Error in File";
return;
}
while(tmp.read((char*)&t1,sizeof(t1)))
fout.write((char*)&t1,sizeof(t1));
tmp.close();
fout.close();
if(flag==1)

cout<<"\n\t\tTeacher Succesfully Deleted";


else if (flag==0)
cout<<"\n\t\tTeacher does not Exist! Please Retry";
getch();
}
The delete student funC and its code
//function for deleting student
void delete_student(void)
{
flag=0;
cout<<"\n\n\tEnter Student ID_no to be deleted :";
int eno;
cin>>eno;
fin.open("Student.dat",ios::binary);
if(!fin)
{
cout<<"\n\nFile Not Found...";
return;
}
fstream tmp("temp_stud.dat",ios::binary|ios::out);
fin.seekg(0);
while(fin.read((char*)&s1, sizeof(s1)))
{
int x=s1.getid();//t1.teacher::getid();
if(x!=eno)
tmp.write((char*)&s1,sizeof(s1));
else
{
flag=1;
}
}
fin.close();
tmp.close();
fout.open("Student.dat",ios::trunc|ios::binary);
fout.seekp(0);
tmp.open("temp_stud.dat",ios::binary|ios::in);
if(!tmp)
{
cout<<"Error in File";
return;
}
while(tmp.read((char*)&s1,sizeof(s1)))
fout.write((char*)&s1,sizeof(s1));
tmp.close();
fout.close();
if(flag==1)
cout<<"\n\t\tStudent Succesfully Deleted";

else if (flag==0)
cout<<"\n\t\tStudent does not Exist! Please Retry";
getch();
}
The Edit teacher funC and its code
//funC to edit teacher
void edit_teacher(void)
{
clrscr();
flag=0;
cout<<"\n\n\tEnter Teacher ID_no to be edited :";
int eno;
cin>>eno;
fin.open("Teacher.dat",ios::binary);
if(!fin)
{
cout<<"\n\nFile Not Found...";
return;
}
fstream tmp("temp_tech.dat",ios::binary|ios::out);
fin.seekg(0);
while(fin.read((char*)&t1, sizeof(t1)))
{
int x=t1.getid();//t1.teacher::getid();
if(x!=eno)
tmp.write((char*)&t1,sizeof(t1));
else
{
clrscr();
for(int i=5;i<74;i++)
{
gotoxy(i,2);
textcolor(YELLOW+BLINK);
cputs("-");
}
for(i=3;i<24;i++)
{
gotoxy(5,i);
textcolor(RED+BLINK);
cputs("|");
gotoxy(73,i);
textcolor(RED+BLINK);
cputs("|");
}
for(i=5;i<74;i++)
{

gotoxy(i,24);
textcolor(YELLOW+BLINK);
cputs("-");
}
gotoxy(27,4);
textcolor(LIGHTRED);
cputs("Editing Teacher Details");
gotoxy(10,5);
textcolor(WHITE);
cputs("*******************************************************
****");
gotoxy(38,6);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,7);
textcolor(WHITE);
|
cputs("ID number
:
| ");
gotoxy(38,8);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,9);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,10);
textcolor(WHITE);
cputs("Quater number
:
|
| ");
gotoxy(38,11);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,12);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,13);
textcolor(WHITE);
cputs("Basic Pay (Rs)
:
|
| ");
gotoxy(38,14);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,15);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,16);
textcolor(WHITE);

cputs("Name
:
|
| ");
gotoxy(38,17);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,18);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,19);
textcolor(WHITE);
cputs("E-main Id
:
|
| ");
gotoxy(38,20);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,21);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,22);
textcolor(WHITE);
cputs("Post
:
|
| ");
gotoxy(38,23);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(39,7);
cin>>t1.id_no;
gotoxy(39,10);
cin>>t1.qtr_no;
gotoxy(39,13);
cin>>t1.basic_pay;
gotoxy(39,16);
gets(t1.name);
gotoxy(39,19);
gets(t1.email_id);
gotoxy(39,22);
gets(t1.post);
tmp.write((char*)&t1,sizeof(t1));
flag=1;
}
}
fin.close();
tmp.close();
fout.open("Teacher.dat",ios::trunc|ios::binary);
fout.seekp(0);
tmp.open("temp_tech.dat",ios::binary|ios::in);
if(!tmp)
{

cout<<"Error in File";
return;
}
while(tmp.read((char*)&t1,sizeof(t1)))
fout.write((char*)&t1,sizeof(t1));
tmp.close();
fout.close();
if(flag==1)
{
cout<<"\n\t\tTeacher Succesfully Edited";
getch();
}
else if(flag==0)
{
cout<<"\n\t\tTeacher does not Exist! Please Retry";
getch();
}
return;
}
The Edit Student funC and its code
//funC to edit student
void edit_student(void)
{
clrscr();
flag=0;
cout<<"\n\n\tEnter Student ID_no to be edited :";
int eno;
cin>>eno;
fin.open("Student.dat",ios::binary);
if(!fin)
{
cout<<"\n\nFile Not Found...";
return;
}
fstream tmp("temp_stud.dat",ios::binary|ios::out);
fin.seekg(0);
while(fin.read((char*)&s1, sizeof(s1)))
{
int x=s1.getid();//t1.teacher::getid();
if(x!=eno)
tmp.write((char*)&s1,sizeof(s1));
else
{
clrscr();
for(int i=5;i<74;i++)
{

gotoxy(i,2);
textcolor(YELLOW+BLINK);
cputs("-");
}
for(i=3;i<24;i++)
{
gotoxy(5,i);
textcolor(RED+BLINK);
cputs("|");
gotoxy(73,i);
textcolor(RED+BLINK);
cputs("|");
}
for(i=5;i<74;i++)
{
gotoxy(i,24);
textcolor(YELLOW+BLINK);
cputs("-");
}
gotoxy(27,5);
textcolor(LIGHTRED);
cputs("Adding Student Details");
gotoxy(10,7);
textcolor(WHITE);
cputs("*******************************************************
****");
gotoxy(38,8);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,9);
textcolor(WHITE);
cputs("ID number
:
|
| ");
gotoxy(38,10);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,11);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,12);
textcolor(WHITE);
cputs("Rollno
:
|
| ");
gotoxy(38,13);;
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,14);

textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,15);
textcolor(WHITE);
cputs("Name
:
|
| ");
gotoxy(38,16);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,17);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,18);
textcolor(WHITE);
cputs("E-mail Id
:
|
| ");
gotoxy(38,19);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(38,20);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(10,21);
textcolor(WHITE);
cputs("Class
:
|
| ");
gotoxy(38,22);
textcolor(WHITE);
cputs("--------------------------------");
gotoxy(39,9);
cin>>s1.id_no;
gotoxy(39,12);
cin>>s1.rollno;
gotoxy(39,15);
gets(s1.name);
gotoxy(39,18);
gets(s1.email_id);
gotoxy(39,21);
gets(s1.clas);
tmp.write((char*)&s1,sizeof(s1));
flag=1;
}
}
fin.close();
tmp.close();
fout.open("Student.dat",ios::trunc|ios::binary);
fout.seekp(0);
tmp.open("temp_stud.dat",ios::binary|ios::in);

if(!tmp)
{
cout<<"Error in File";
return;
}
while(tmp.read((char*)&s1,sizeof(s1)))
fout.write((char*)&s1,sizeof(s1));
tmp.close();
fout.close();
if(flag==1)
{
cout<<"\n\t\tStudent Succesfully Edited ";
getch();
}
else if(flag==0)
{
cout<<"\n\t\tStudent does not Exist! Please Retry";
getch();
}
getch();
return;
}
The show all entry funC and its code

//funC to show all entry


void show_all_entry(void)
{
clrscr();
fin.open("Entry.dat",ios::binary);

fin.seekg(0);
int i=4;
while(fin.read((char*)&e1, sizeof(e1))&&i<25)
{
flag=1;
cout<<"Id no : "<<e1.idno<<" ";
e1.show_entry();
i++;
if(i==24)
{
getch();
i=4;
clrscr();
}
}
fin.close();
getch();
return;
}
void entry::show_entry(void)
{
cout<<"Year : "<<year<<" Month : "<<month<<" Day :
"<<day<<" Hour : "<<hr<<" Min : "<<min<<" Sec :
"<<sec<<endl;
}
The show particular entry window and its code

//funC to show particular entry of a given Id no


void show_part_entry(void)
{
clrscr();
int idno;
cout<<"\n\tEnter id no to search entry : ";
cin>>idno;
p=1;
flag=0;
while(p)
{
fin.open("Teacher.dat",ios::binary);
if(!fin)
{
cout<<"\n\nFile Not Found...";
return;
}
fin.seekg(0);
while(fin.read((char*)&t1, sizeof(t1)))
{
int x=t1.getid();
if(x==idno)
{
flag=1;
cout<<"\n\t Entries of : "<<t1.name<<endl;
p=0;
}
}
fin.close();
fin.open("Student.dat",ios::binary);
if(!fin)
{
cout<<"\n\nFile Not Found...";
return;
}
fin.seekg(0);
while(fin.read((char*)&s1, sizeof(s1)))
{
int x=s1.getid();
if(x==idno)
{
flag=1;
cout<<"\n\tEntries of : "<<s1.name<<endl;
p=0;
}
}
fin.close();
if(flag==0)

{
cout<<"\n\tEntry doesnot exist !!!";
p=0;
return;
}
}
int i=4;
fin.open("Entry.dat",ios::binary);
if(!fin)
{
cout<<"\n\nFile Not Found...";
return;
}
fin.seekg(0);
while(fin.read((char*)&e1, sizeof(e1))&&i<25)
{
int x=e1.get_id();
if(x==idno&&!fin.eof())
{
flag=1;
e1.show_entry();
i++;
if(i==24)
{
getch();
i=4;
clrscr();
gotoxy(1,2);
}
}
}
fin.close();
if(flag==0)
cout<<"\n\tRechecked !!!!!!!
Entry not found ";
getch();
return;
}

The add entry funC and its code


If the Id no exists then it adds entry other wise it gives a warning to register
the user

//funC for adding entry


void entry::add_entry(void)
{
clrscr();
cout<<"\n\n\n\n\t Add your Entry by inputing ur ID NO :";
cin>>idno;
//current date/time based on current system
time_t now = time(0);
// cout << "Number of sec since January 1,1970:" << now <<
endl;
tm *ltm = localtime(&now);
// print various components of tm structure.
cout << "\n\tYear: "<< 1900 + ltm->tm_year <<" ";
cout << "Month: "<< 1 + ltm->tm_mon<<" ";
cout << "Day: "<< ltm->tm_mday <<" ";
cout << "Time: "<< ltm->tm_hour << ":";
cout << ltm->tm_min << ":";
cout << ltm->tm_sec << endl;
getch();
flag=0;
p=1;
do

{
fin.open("Teacher.dat",ios::binary|ios::in);
if(!fin)
{
cout<<"\n\nFile Not Found...";
return;
}
fin.seekg(0);
while(fin.read((char*)&t1, sizeof(t1)))
{
int x=t1.teacher::getid();
if(x==idno)
{
flag=1;
cout<<"\n\t Welcome : "<<t1.name;
p=0;
}
}
fin.close();
fin.open("Student.dat",ios::binary);
if(!fin)
{
cout<<"\n\nFile Not Found...";
return;
}
fin.seekg(0);
while(fin.read((char*)&s1, sizeof(s1)))
{
int x=s1.getid();
if(x==idno)
{
cout<<"\n\tWelcome : "<<s1.name;
flag=1;
p=0;
}
}
fin.close();
if(flag==0)
{
cout<<"\n\tUnknown member !!!!!! Warning !!!!! Register
yourself !!!!";
cout<<"\n\n\tEnter 'T/t' if teacher or 'S/s' if student
";
char ch;
cin>>ch;
if(ch=='T'||ch=='t')
{
t1.add_tech();

getch();
}
else if(ch=='S'||ch=='s')
{
s1.add_stu();
getch();
}
p=0;
e1.add_entry();
g=0;
}
}while(p==1);
year=1900 + ltm->tm_year;
month=1 + ltm->tm_mon;
day= ltm->tm_mday;
hr=ltm->tm_hour;
min=ltm->tm_min;
sec=ltm->tm_sec;
fout.open("Entry.dat",ios::binary|ios::app);
fout.write((char *)&e1,sizeof(e1));
fout.close();
cout<<"\n\tEntry Recorded";
getch();
return;
}
void entry::show_entry(void)
{
cout<<"Year : "<<year<<" Month : "<<month<<" Day :
"<<day<<" Hour : "<<hr<<" Min : "<<min<<" Sec :
"<<sec<<endl;
}
The main funCs code
//main function
void main()
{
clrscr();
int y=0;
if(y==0)
{
welcome_screen();
y=1;
}
while(1)
{
char ch;
int ch2;

ch=main_screen();
switch(ch)
{
case'1':ch2=administrator_menu();
//ch2=getch();
switch(ch2)
{
case 1:{
clrscr();
cout<<"\n\n\n\t\tEnter Id no to check its
avaiability : ";
int i;
cin>>i;
int t=i;
fin.open("Teacher.dat",ios::binary|ios::in);
fin.seekg(0);
int p=1;
while(fin.read((char
*)&t1,sizeof(t1))&&(p!=0))
{
int x=t1.getid();
if(t==x)
{
clrscr();
cout<<"\n\n\n\t\t Teacher already Exist !!!"
<<"ENTER NEW ID NUMBER ";
delay(1000);
p=0;
}
}
fin.close();
if(p==1)
{
t1.add_tech();
break;
}
else if(p==0)
break;
}
case 2:{
clrscr();
cout<<"\n\n\n\t\tEnter Id no to check its
avaiability : ";
int i;
cin>>i;
int t=i;
fin.open("Student.dat",ios::binary|ios::in);
fin.seekg(0);

int p=1;
while(fin.read((char
*)&s1,sizeof(s1))&&(p!=0))
{
int x=s1.getid();
if(t==x)
{
clrscr();
cout<<"\n\n\n\t\t Student already Exist !!!"
<<"ENTER NEW ID NUMBER ";
delay(1000);
p=0;
}
}
fin.close();
if(p==1)
{
s1.add_stu();
break;
}
else if(p==0)
break;
}
case 3:search_teacher();
break;
case 4:search_student();
break;
case 5:show_all_teacher();
break;
case 6:show_all_student();
break;
case 7:delete_teacher();
break;
case 8:delete_student();
break;
case 9:edit_teacher();
break;
case 10:edit_student();
break;
case 11:show_all_entry();
break;
case 12:show_part_entry();
break;
default:clrscr();
cout<<"\n\n\t\tEnter correct choice";
continue;
}
break;

case'2': e1.add_entry();
break;
case'3': exit(0);
default:clrscr();
cout<<"\n\n\t\tEnter correct choice";
continue;
}
}
}

Testing

This program is made by me after lots of troubles


and errors. Firstly, I checked the program and finds
some errors and then myself corrected them . After
that I asked my computer science sir to verify it but
he finds small errors in my program and asked me to
correct them. Then with the given suggestion of my
sir I corrected them.

Lastly, I asked my computer science sir to give a last


look in it and with his blessings I completed my
project.

CONCLUSION OF PROJECT

My project is on School database management and Id based entry system.


I have successfully completed it. I take this opportunity to express my
sense of indebtedness and gratitude to all those people who helped us in
completing this project.

I am immensely grateful to Mr. Sanwar Mal(PGT comp. sc) for his


supervision and guidance without which this work would not have been
possible..This project has contributed a lot to my knowledge that has
proved to be a value addition for me.

BIBLIOGRAPHY

Internet
Computer science book of
class 12th

Potrebbero piacerti anche