You are on page 1of 33

#include<iostream.

h>

#include<stdio.h>

#include<fstream.h>

#include<dos.h>

#include<conio.h>

#include<string.h>

class employee

int eid;

int pid;

char en[30];

char dob[30];

long pn;

char cy[25];

char add[40];

char pc [10];

char g[8];

char ms[15];

public:

void get_data()

{cout<<"enter employee id number";

cin>>eid;

cout<<"enter employee personal id number";

cin>>pid;

cout<<"enter employee name";


gets(en);

cout<<"enter employee date of birth[;dd_mm_yyyy]";

gets(dob);

cout<<"enter employee phone number";

cin>>pn;

cout<<"enter city of employee";

gets(cy);

cout<<"enter address of employee";

gets(add);

cout<<"enter employee's area postal code";

gets(pc);

cout<<"enter employee's gender";

gets(g);

cout<<"enter employee's marital status";

gets(ms);

void show_data()

cout<<"name:"<<en<<endl;

cout<<"employee id number:"<<eid<<endl;

cout<<"personal id number:"<<pid<<endl;

cout<<"date of birth:"<<dob<<endl;

cout<<"employee's address:"<<add<<endl;

cout<<"city:"<<cy<<endl;

cout<<"area postal code:"<<pc<<endl;


cout<<"contact number:"<<pn<<endl;

cout<<"gender:"<<g<<endl;

cout<<"employee's marital status:"<<ms<<endl;

int get_eid()

{return eid;

int get_pid()

{return pid;

};

//***********************************************************************************
****

// FUNCTION TO ADD THE INFORMATION OF NEW EMPLOYEE

//***********************************************************************************
****

void new_ed()

fstream f;

f.open("employee.dat",ios::app|ios::binary);

employee e;

e.get_data();

f.write((char*)&e,sizeof(e));

f.close();

//**********************************************************************************
//FUNCTION TO DISPLAY THE INFORMATION OF ALL EMPLOYEES

//**********************************************************************************

void display_ed()

{fstream f;

f.open("employee.dat",ios::in|ios::binary);

employee e;

while(f.read((char*)&e,sizeof(e)))

e.show_data();

f.close();

//*********************************************************************************

//FUNCTION TO FIND A EMPLOYEE INFORMATION THROUGH EID

//********************************************************************************

void find_ed()

fstream f;

f.open("employee.dat",ios::in|ios::binary);

employee e;

int eid;

int a=0;

cout<<"enter the employee id number";

cin>>eid;

while(f.read((char*)&e,sizeof(e)))
{if (e.get_eid()==eid)

e.show_data();

a=1;

break;

if (a==0)

cout<<"employee id is not valid";

//***************************************************************************

//FUNCTION TO DELETE THE EMPLOYEE INFORMATION THROUGH EID

//***************************************************************************

void delete_ed()

fstream f;

fstream f1;

f.open("employee.dat",ios::in|ios::binary);

f1.open("temp.dat",ios::in|ios::binary);

employee e;

int eid;

cout<<"enter the employee id number to be detected";

cin>>eid;
while(f.read((char*)&e,sizeof(e)))

{if (e.get_eid()!=eid)

f1.write((char*)&e,sizeof(e));

remove("employee.dat");

rename("temp.dat","employee.dat");

//***************************************************************************

//FUNCTION TO MODIFY THE EMPLOYEE THROUGH EID

//***************************************************************************

void modify_ed()

fstream f;

f.open("employee.dat",ios::app|ios::binary);

employee e;

int eid;

cout<<"enters employee id number to be modified";

cin>>eid;

while (f.read((char*)&e,sizeof(e)))

if(e.get_eid()==eid)

f.seekp(-1*sizeof(e),ios::cur);
e.get_data();

f.write((char*)&e,sizeof(e));

class workhistory

int eid;

char cn[50];

char en[30];

char cea[50];

int eol;

char ea[50];

public:

void get_data()

{cout<<"enter employee id number";

cin>>eid;

cout<<"enter company name";

gets(cn);

cout<<"enter employee name";

gets(en);

cout<<"enter company employee address i.e floor&desk no.";

gets(cea);

cout<<"enter eployee office landline number";

cin>>eol;
cout<<"enter employee address";

gets(ea);

void show_data()

cout<<cn<<endl;

cout<<"name:"<<en<<endl;

cout<<"company employee address:"<<cea<<endl;

cout<<"employee office phone:"<<eol<<endl;

cout<<"employee address:"<<ea<<endl;

int get_eid()

{return eid;

};

//***************************************************************

//FUNCTION TO ADD A WORKING HISTORY OF EMPLOYEE

//***************************************************************

void new_wh()

{fstream f;

f.open("workhistory.dat",ios::app|ios::binary);

workhistory w;

w.get_data();

f.write((char*)&w,sizeof(w));

f.close();
}

//**************************************************************

//FUNCTION TO DISPLAY ALL THE RECORDS

//**************************************************************

void display_wh()

{fstream f;

f.open("workhistory.dat",ios::in|ios::binary);

workhistory w;

while(f.read((char*)&w,sizeof(w)))

w.show_data();

f.close();

//**************************************************************

//FUNCTION TO FIND THE WORKING HISTORY OF EMPLOYEE

//***************************************************************

void find_wh()

fstream f;

f.open("workhistory.dat",ios::in|ios::binary);

workhistory w;

int eid;

int a=0;

cout<<"enter the employee id number to be search";


cin>>eid;

while (f.read((char*)&w,sizeof(w)))

if(w.get_eid()==eid)

w.show_data();

a=1;

break;

if(a==0)

cout<<"not a valid eid";

//************************************************************************

//FUNCTION TO DELETE THE WORKING HISTORY RECORD OF EMPLOYEE

//************************************************************************

void delete_wh()

fstream f,f1;

f.open("workhistory.dat",ios::in|ios::binary);

f1.open("temp.dat",ios::out|ios::binary);

workhistory w;

int eid;
cout<<"enter the employee id number ehose record you want to delete";

cin>>eid;

while(f.read((char*)&w,sizeof(w)))

if(w.get_eid()!=eid)

f1.write((char*)&w,sizeof(w));

remove("workhistory.dat");

rename("temp.dat","workhistory.dat");

//*************************************************************************

//FUNCTION TO MODIFY THE WORKING HISTORY RECORD

//*************************************************************************

void modify_wh()

fstream f;

f.open("workhistory.dat",ios::in|ios::app|ios::binary);

workhistory w;

int eid;

cout<<"enter the employee id number whose record is to be modified";

cin>>eid;

while (f.read((char*)&w,sizeof(w)))

{
if(w.get_eid()==eid)

f.seekp(-1*sizeof(w),ios::cur);

w.get_data();

f.write ((char*)&w,sizeof(w));

class salary

{int eid;

int bms;

float md;

long ns;

public:

void get_data()

{cout<<"enter employee id number";

cin>>eid;

cout<<"monthly basic salary";

cin>>bms;

//monthly deduction=8%incometax of basic salary+2%pe of basic salary

//net salary=32%hpf of bs+20%ha of bs +bs-monthly deduction

md=((8/100)*bms)+((2/100)*bms);

ns=((40/100)*bms)+((12/100)*bms)+bms-md;

void show_data()
{cout<<"employee id number:"<<eid<<endl;

cout<<"employee basic monthly salary:"<<bms<<endl;

cout<<"net salary:"<<md<<endl;

cout<<"net salary:"<<ns<<endl;

int geteid()

return eid;

};

//*************************************************

//function to add a salary detail of employee

//*************************************************

void new_s()

fstream f;

f.open("salary.dat",ios::app|ios::binary);

salary s;

s.get_data();

f.write((char*)&s,sizeof(s));

f.close();

//*************************************************

//function to display all the records

//*************************************************
void display_s()

fstream f;

f.open("salary.dat",ios::in|ios::binary);

salary s;

while(f.read((char*)&s,sizeof(s)))

s.show_data();

f.close();

//*************************************************

//function to find the salay detail of a employee

//************************************************

void find_s()

fstream f;

f.open("salary.dat",ios::in|ios::binary);

salary s;

int eid;

int a=0;

cout<<"enter employee id number to be search";

cin>>eid;

while(f.read((char*)&s,sizeof(s)))

{
if(s.geteid()==eid)

s.show_data();

a=1;

break;

if(a==0)

cout<<"not a valid employee id";

//****************************************

// function to delete the salary detail of employee

//****************************************

void delete_s()

fstream f,f1;

f.open("salary.dat",ios::in|ios::binary);

f1.open("temp.dat",ios::out|ios::binary);

salary s;

int eid;

cout<<"enter employee id number to be deleted";

cin>>eid;

while(f.read((char*)&s,sizeof(s)))
{

if(s.geteid()!=eid)

f1.write((char*)&s,sizeof(s));

remove("salary.dat");

rename("temp.dat","salary .dat");

//********************************************

//function to modify the salary detail of employee

//********************************************

void modify_s()

{fstream f;

f.open("salary.dat",ios::in|ios::app|ios ::binary);

salary s;

int eid;

cout<<"enter the employee id to be modified";

cin>>eid;

while(f.read((char*)&s,sizeof(s)))

if(s.geteid()==eid)

f.seekp(-1*sizeof(s),ios::cur);

s.get_data();
f.write((char*)& s,sizeof(s));

class timeinfo

{int eid;

int wh;

int owh;

int oh;

public:

void get_data()

cout<<"enter employee id nuber";

cin>>eid;

cout<<"enter the number of worked hour";

cin>>wh;

cout<<"enter the number of overtime worked hours";

cin>>owh;

cout<<"enter the number of off hours";

cin>>oh;

void show_data()

cout<<"enter employee id no. :"<<eid<<endl;

cout<<"worked hours:"<<wh<<endl;
cout<<"overtime worked hours :"<<owh<<endl;

cout<<"off hours:"<<oh<<endl;

int geteid()

{return eid;

};

//*********************************************

//function to add timr information of a employee

//*********************************************

void new_ti()

{fstream f;

f.open("timeinfo.dat",ios::app|ios::binary);

timeinfo t;

t.get_data();

f.write((char*)&t,sizeof(t));

f.close();

//*********************************************

//function to display the time information of a employee

//*********************************************

void display_ti()

{fstream f;

f.open("timeinfo.dat",ios::binary);

timeinfo t;
while (f.read((char*)&t,sizeof(t)))

t.show_data();

f.close();

//*********************************************

//function to find the time information of a employee

//**********************************************

void find_ti()

{fstream f;

f.open("timeinfo,dat",ios::in|ios::binary);

timeinfo t;

int eid;

int a=0;

cout<<"enter employee id no. to be search";

cin>>eid;

while(f.read((char*)&t,sizeof(t)))

if (t.geteid()==eid)

t.show_data();

a=1;

break;

}
}

if (a==0)

cout<<"employee id not valid";

//***************************************

//function to delete the time information of a employee

//***************************************

void delete_ti()

{fstream f,f1;

f.open("timeinfo.dat",ios::in|ios::binary);

f1.open("temp.dat",ios::app|ios::binary);

timeinfo t;

int eid;

cout<<"enter the eployee id no. to be deleted";

cin>>eid;

while(f.read((char*)&t,sizeof(t)))

if(t.geteid()!=eid)

f1.write((char*)&t,sizeof(t));

remove("timeinfo.dat");
rename("temp.dat","timeinfo.dat");

//****************************************

//function to modify the time information of employee

//****************************************

void modify_ti()

{fstream f;

f.open("timeinfo.dat",ios::in|ios::app|ios::binary);

timeinfo t;

int eid;

cout<<"enter the employee id no. to be deleted",

cin>>eid;

while(f.read((char*)&t,sizeof(t)))

if(t.geteid()==eid)

f.seekp(-1*sizeof(t),ios::cur);

t.get_data();

f.write ((char*)&t,sizeof(t));

void main()

clrscr();
char pwd[6];

int i=0;

while(i<6)

pwd[i]=getch();

cout<<"*";

i++;

if(strcmp(pwd,"141523")==0)

gotoxy(27,1);

cout<<"emplouee management system "<<endl;

cout<<"submitted by:"<<endl;

cout<<"shailendra kumar prajapati"<<endl;

cout<<"abhay anand"<<endl;

cout<<"rahul"<<endl;

gotoxy(35,6);

cout<<"welcome to main menu"<<endl;

gotoxy(35,7);

cout<<"1.employee detail"<<endl;

gotoxy(35,8);

cout<<"2.work history detail"<<endl;

gotoxy(35,9);

cout<<"3.salary detail"<<endl;

gotoxy(35,10);
cout<<"4.time information"<<endl;

int ch;

cout<<"enter your choice";

cin>>ch;

if(ch==1)

cout<<"employee detail"<<endl;

cout<<"1.addnew employee detail"<<endl;

cout<<"2.display detail of all employee"<<endl;

cout<<"3.find employee detail"<<endl;

cout<<"4.delete employee detail"<<endl;

cout<<"5.modify employee detail"<<endl;

int n;

cout<<"enter your choice";

cin>>n;

if(n==1)

new_ed();

else if(n==2)

display_ed();

else if(n==3)

{find_ed();
}

else if(n==4)

delete_ed();

else if(n==5)

modify_ed();

else

cout<<"not a valid choice"<<endl;

else if(ch==2)

cout<<"work history detail"<<endl;

cout<<"1.Add"<<endl;

cout<<"2.Display"<<endl;

cout<<"3.Find"<<endl;

cout<<"4.Delete"<<endl;

cout<<"5.Modify"<<endl;

int b;

cout<<"enter your choice";

cin>>b;
if(b==1)

new_wh();

else if(b==2)

display_wh();

else if(b==3)

find_wh();

else if(b==4)

delete_wh();

else if(b==5)

modify_wh();

else

cout<<"not a valicd choice"<<endl;

}
else if(ch==3)

cout<<"salary detail"<<endl;

cout<<"1.Add"<<endl;

cout<<"2.Display"<<endl;

cout<<"3.Find"<<endl;

cout<<"4.Delete"<<endl;

cout<<"5.Modify"<<endl;

int c;

cout<<"enter your choice";

cin>>c;

if(c==1)

new_s();

else if(c==2)

display_s();

else if(c==3)

find_s();

else if(c==4)

{
delete_s();

else if(c==5)

modify_s();

else

cout<<"not a valid choice"<<endl;

else if(ch==4)

cout<<"Time Information"<<endl;

cout<<"1.Add"<<endl;

cout<<"2.Display"<<endl;

cout<<"3.Find"<<endl;

cout<<"4.Delete"<<endl;

cout<<"5.Find"<<endl;

int d;

cout<<"enter your choice";

cin>>d;

if(d==1)

new_ti();
}

else if(d==2)

display_ti();

else if(d==3)

find_ti();

else if(d==4)

delete_ti();

else if(d==5)

modify_ti();

else

cout<<"not a valid choice"<<endl;

else

cout<<"ENTER A VALID CHOICE"<<endl;


}

cout<<"THANK YOU"<<endl;

cout<<"HAVE A NICE DAY"<<endl;

else

{ cout<<"INCORRECT PASSWORD"<<endl;

getch();

}
OUTPUTS
MAIN MENU

ADDING EMPLOYEE DETAIL


FIND EMPLOYEE

WORK HISTORY MENU


SALARY DETAIL MENU

TIME INFORMATION MENU


Mr. Brijmohan Sir
There’s no one quite
Like a special teacher ,
And no teacher quite
As special as you.

Thank you!

You might also like