69% found this document useful (13 votes)
10K views

C++ Coding Employee Management System

This document contains C++ code for classes and functions related to employee record management. It includes classes for updating employee information, employee data, and file handling. Functions defined include showing the main menu, searching for employees by name or designation, listing all employees, and adding/updating employee details that will be stored in a data file.

Uploaded by

eternities
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
69% found this document useful (13 votes)
10K views

C++ Coding Employee Management System

This document contains C++ code for classes and functions related to employee record management. It includes classes for updating employee information, employee data, and file handling. Functions defined include showing the main menu, searching for employees by name or designation, listing all employees, and adding/updating employee details that will be stored in a data file.

Uploaded by

eternities
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 58

6.

Coding Section
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<dos.h>
#include<iostream.h>
#include<ctype.h>
#include<string.h>
#include<process.h>
#include<iomanip.h>

/* class containing functions, variables regarding update in emp info */

class upddate
{
public:
void edata();
void empl();
void wdata();
void udate();
void anewemp();
void uname();
void ufname();
void ulname();
void utel();
void udesi();
void uotel();
void urtel();
void uadd();
void uoadd();
void uradd();
char f1name[],f2name[],l1name[],l2name[],desii[],off1add[],res1add[];
float off1tel,off2tel,res1tel;
char fme[15],lme[15],ds[20],ofad[50],l3name[],read[50];
long v,lo;
int na,dd,mm,yy,rec;
};
/* class containing functions,variables regarding employee info,date */
class emp :public upddate
{
public:

void l();
void l1();
void l2();
void l3();
void sfname();
void slname();
void sdesi();
void exitt();
void showmain();
void exiit();
char f1name[],l3name[],off3add[],res3add[],desii[];
float off3tel,res3tel;
};
/* class containing all the data related to file handling*/
class fl :public upddate
{
public:

void list2();
void list();
void list1();
void addetail(char[], char [],char[],
char[],char[],long,int,long,int,int,int);
};
/*function to show the main screen of the project */
void emp::showmain(void)
{
int j;
char choice;
clrscr();
while(1)
{
for(j=8;j<45;j++)
{ gotoxy(6,j);
cout<<"*\n";}
for(j=7;j<70;j++)
{ gotoxy(j,44);
cout<<"*\n";}
for(j=8;j<45;j++)
{ gotoxy(70,j);
cout<<"*\n";}
for(j=6;j<70;j++)
{ gotoxy(j,8);
cout<<"*\n";}
gotoxy(15,15);
cout<<" ---WELCOME TO SPEAKER OFFICE
RECORDS--- \n";
gotoxy(12,18);

cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n";
gotoxy(20,25);
cout<<" 1.EMPLOYEE INFO \
gotoxy(20,28);
cout<<" 2.UPDATE \n";
gotoxy(20,31);
cout<<" 3.EXIT \n";
gotoxy(18,35);
cout<<" please enter your choice:- \n";
gotoxy(47,35);
choice=getche();
upddate a;
if(choice=='1')
{
a.empl();
}
else
if(choice=='2')
{ a.udate();
}
else if(choice=='3')
{
emp e;
e.exiit();
}}}
/*function to exit from the application*/
void emp::exiit()
{
clrscr();
gotoxy(22,25);
cout<<"** HAVE A NICE TIME GOOD DAY **\n";
getch();
exit(4000);
}
/*function to come to main menu*/
void emp::exitt()
{ clrscr();
emp a;
a.showmain();
}

/*function to show the employee info screen*/

void upddate::empl()
{
int j;
char ch;
clrscr();
upddate k;
while(1)
{ for(j=8;j<49;j++)
{ gotoxy(6,j);
cout<<"*\n";}
for(j=7;j<70;j++)
{ gotoxy(j,48);
cout<<"*\n";}
for(j=8;j<49;j++)
{ gotoxy(70,j);
cout<<"*\n";}
for(j=6;j<70;j++)
{ gotoxy(j,8);
cout<<"*\n";}
gotoxy(19,15);
cout<<" -- WELCOME TO EMPLOYEE INFORMATION
-- \n";\\
gotoxy(16,19);
cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n";
gotoxy(17,22);
cout<<" 1.search employee by last name \n";
gotoxy(17,25);
cout<<" 2.search employee by first name \n";
gotoxy(17,28);
cout<<" 3.search by employee designation \n";
gotoxy(17,31);
cout<<" 4.list of all the employee \n";
gotoxy(17,34);
cout<<" 5.exit to main menu \n";
gotoxy(17,37);
cout<<" 6.exit from application \n";
gotoxy(15,40);
cout<<" please enter your choice:- ";
gotoxy(44,40);
emp z;
ch=getche();
if(ch=='1')
{ clrscr();
z.slname();
k.empl();
}
else
if(ch=='2')
{ clrscr();
z.sfname();
k.empl();
}
Else
if(ch=='3')
{ clrscr();
z.sdesi();
k.empl(); }
else
if(ch=='4')
{
fl a;
a.list();
k.empl();}
else
if(ch=='5')
{ z.exitt();}
else
if(ch=='6')
{
z.exiit();
}}}

/*function to search employee by last name*/


void emp::slname()
{
emp r;
r.l();
gotoxy(22,22);
cout<<"! enter name: ";
cin>>l3name;
fstream p;
p.open("C:\TC\TC\Bin\pp.dat",ios::in);
p.seekg(0,ios::beg);
int count=0;
while(p.read((char*)this,sizeof(fl)))
{int h=strncmp(l3name,lme,15);
if(h==0)
{ gotoxy(22,25);
cout<<"! name present";
r.l3();
count=1;
gotoxy(19,8);
cout<<" THE DETAILS OF THE EMPLOYEE";
gotoxy(15,10);
cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^";
gotoxy(10,15);
cout<<"first name:-";
gotoxy(30,15);
cout<<fme;
gotoxy(10,18);
cout<<"last name:-";
gotoxy(30,18);
cout<<lme;;
gotoxy(10,21);
cout<<"designation:-";
gotoxy(30,21);
cout<<ds;;
gotoxy(10,24);
cout<<"office address:-";
gotoxy(30,24);
cout<<ofad;
gotoxy(10,27);
cout<<"residence address:-";
gotoxy(30,27);
cout<<read;
gotoxy(10,30);
cout<<"office telephone:-";
gotoxy(30,30);
cout<<v;
gotoxy(10,33);
cout<<"std code of resi:-";
gotoxy(30,33);
cout<<"0";
gotoxy(31,33);
cout<<na;;
gotoxy(10,36);
cout<<"residence telephone:-";
gotoxy(32,36);
cout<<lo;
gotoxy(10,39);
cout<<"date of joining:-";
gotoxy(30,39);
cout<<dd;;
gotoxy(32,39);
cout<<".";
gotoxy(33,39);
cout<<mm;;
gotoxy(35,39);
cout<<".";
gotoxy(36,39);
cout<<yy;
getch();
clrscr();
continue;
}}
p.close();
g: if(count==0)
{ clrscr();
r.l();
gotoxy(22,20);
cout<<"! Data not present";
gotoxy(22,22);
cout<<"! Name entered : "<<l3name;
int k;
gotoxy(22,24);
cout<<"! Press 1 to enter again";
gotoxy(22,26);
cout<<"! Press 2 to exit";
gotoxy(22,28);
cout<<"Select your choice ";
cin>>k;
if(k==1){ clrscr();
slname(); }
else if(k==2){
else{ gotoxy(22,30);
cout<<"wrong option selected reselect";
delay(2000);
goto g;
}}}
/*functions to searh employee by first name*/
void emp::sfname()
{ emp r;
r.l();
gotoxy(22,22);
cout<<"! enter name :";
cin>>f1name;
fstream p;
p.open("C:\TC\TC\Bin\pp.dat",ios::in);
p.seekg(0,ios::beg);
int count=0;
while(p.read((char*)this,sizeof(fl)))
{
int h=strncmp(f1name,fme,15);
if(h==0)
{ gotoxy(22,25);
cout<<"! name present";
r.l3();
count=1;
gotoxy(19,8);
cout<<" THE DETAILS OF THE EMPLOYEE";
gotoxy(15,10);
cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^";
gotoxy(10,15);
cout<<"first name:-";
gotoxy(30,15);
cout<<fme;
gotoxy(10,18);
cout<<"last name:-";
gotoxy(30,18);
cout<<lme;;
gotoxy(10,21);
cout<<"designation:-";
gotoxy(30,21);
cout<<ds;;
gotoxy(10,24);
cout<<"office address:-";
gotoxy(30,24);
cout<<ofad;
gotoxy(10,27);
cout<<"residence address:-";
gotoxy(30,27);
cout<<read;
gotoxy(10,30);
cout<<"office telephone:-";
gotoxy(30,30);
cout<<v;
gotoxy(10,33);
cout<<"std code of resi:-";
gotoxy(30,33);
cout<<"0";
gotoxy(31,33);
cout<<na;;
gotoxy(10,36);
cout<<"residence telephone:-";
gotoxy(32,36);
cout<<lo;
gotoxy(10,39);
cout<<"date of joining:-";
gotoxy(30,39);
cout<<dd;;
gotoxy(32,39);
cout<<".";
gotoxy(33,39);
cout<<mm;;
gotoxy(35,39);
cout<<".";
gotoxy(36,39);
cout<<yy;
getch();
clrscr();
continue;
} }
p.close();
g: if(count==0)
{ clrscr();
r.l();
gotoxy(22,20);
cout<<"! Data not present";
gotoxy(22,22);
cout<<"! Name entered : "<<f1name;
int k;
gotoxy(22,24);
cout<<"! Press 1 to enter again";
gotoxy(22,26);
cout<<"! Press 2 to exit";
gotoxy(22,28);
cout<<"Select your choice ";
cin>>k;

if(k==1){
clrscr();
sfname(); }
else if(k==2){
}
else{ gotoxy(22,30);
cout<<"wrong option selected reselect";
delay(2000);
goto g;
}}
/*functions to search employee by designation*/
void emp::sdesi()

{ clrscr();
emp r;
r.l();
gotoxy(22,22);
cout<<"! enter designation: ";
cin>>desii;
fstream p;
p.open("C:\TC\TC\Bin\pp.dat",ios::in);
p.seekg(0,ios::beg);
int count=0;
while(p.read((char*)this,sizeof(fl)))
{
int h=strncmp(desii,ds,15);
if(h==0)
{
gotoxy(22,25);
cout<<"! designation present";
r.l3();
count=1;
gotoxy(19,8);
cout<<" THE DETAILS OF THE EMPLOYEE";
gotoxy(15,10);
cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^";
gotoxy(10,15);
cout<<"first name:-";
gotoxy(30,15);
cout<<fme;
gotoxy(10,18);
cout<<"last name:-";
gotoxy(30,18);
cout<<lme;;
gotoxy(10,21);
cout<<"designation:-";
gotoxy(30,21);
cout<<ds;;
gotoxy(10,24);
cout<<"office address:-";
gotoxy(30,24);
cout<<ofad;
gotoxy(10,27);
cout<<"residence address:-";
gotoxy(30,27);
cout<<read;
gotoxy(10,30);
cout<<"office telephone:-";
gotoxy(30,30);
cout<<v;
gotoxy(10,33);
cout<<"std code of resi:-";
gotoxy(30,33);
cout<<"0";
gotoxy(31,33);
cout<<na;;
gotoxy(10,36);
cout<<"residence telephone:-";
gotoxy(32,36);
cout<<lo;
gotoxy(10,39);
cout<<"date of joining:-";
gotoxy(30,39);
cout<<dd;;
gotoxy(32,39);
cout<<".";
gotoxy(33,39);
cout<<mm;;
gotoxy(35,39);
cout<<".";
gotoxy(36,39);
cout<<yy;
getch();
clrscr();
continue;
}}
p.close();
g: if(count==0)
{ clrscr();
r.l();
gotoxy(22,20);
cout<<"! Data not present";
gotoxy(22,22);
cout<<"! Designation entered :"<<desii;
int k;
gotoxy(22,24);
cout<<"! Press 1 to enter again";
gotoxy(22,26);
cout<<"! Press 2 to exit";
gotoxy(22,28);
cout<<"Select your choice ";
cin>>k;
if(k==1){
sdesi(); }
else if(k==2){
}
else{ gotoxy(22,30);
cout<<"wrong option selected reselect";
delay(2000);
goto g;
}} }

/*function to show list of working employees*/


void fl::list()
{
char ch5;
int j;
while(1)
{ clrscr();
for(j=8;j<45;j++)
{ gotoxy(6,j);
cout<<"*\n";}
for(j=7;j<70;j++)
{ gotoxy(j,44);
cout<<"*\n";}
for(j=8;j<45;j++)
{ gotoxy(70,j);
cout<<"*\n";}
for(j=6;j<70;j++)
{ gotoxy(j,8);
cout<<"*\n";}
gotoxy(20,12);
cout<<"-- WELCOME TO EMPLOYEE INFORMATION --\n";
gotoxy(17,16);
cout<<" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n";
gotoxy(17,19);
cout<<" 1.office information \n";
gotoxy(17,22);
cout<<" 2.residence information \n";
gotoxy(17,25);
cout<<" 3.go to previous screen \n";
gotoxy(17,28);
cout<<" 4.go to main menu \n";
gotoxy(17,31);
cout<<" 5.exit from application \n";
gotoxy(15,35);
cout<<" please enter your choice:- ";
gotoxy(42,35);
ch5=getche();
if(ch5=='1')
{ fl r;
r.list2();
r.list();
}
else
if(ch5=='2')
{
fl p;
p.list1();
p.list();
}
if(ch5=='3')
{ upddate r;
r.empl();
}
else
if(ch5=='4')
{ emp c;
c.exitt();}
else
if(ch5=='5')
{
emp d;
d.exiit();} getch();
}}

/*function to show update screen*/

void upddate::udate()
{
char ch1;
int j;
while(1)
{ clrscr();
for(j=8;j<45;j++)
{ gotoxy(6,j);
cout<<"*\n";}
for(j=7;j<70;j++)
{ gotoxy(j,44);
cout<<"*\n";}
for(j=8;j<45;j++)
{ gotoxy(70,j);
cout<<"*\n";}
for(j=6;j<70;j++)
{ gotoxy(j,8);
cout<<"*\n";}
gotoxy(23,12);
cout<<"-- WELCOME TO UPDATE RECORD --\n";
gotoxy(17,16);
cout<<" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n";
gotoxy(17,19);
cout<<" 1.add new employee \n";
gotoxy(17,22);
cout<<" 2.update name \n";
gotoxy(17,25);
cout<<" 3.update designation \n";
gotoxy(17,28);
cout<<" 4.update address \n";
gotoxy(17,31);
cout<<" 5.update telephone no. \n";
gotoxy(17,34);
cout<<" 6.exit to main menu \n";
gotoxy(17,37);
cout<<" 7.exit from application \n";
gotoxy(15,40);
cout<<" please enter your choice:- ";
gotoxy(44,40);
ch1=getche();
if(ch1=='1')
{ upddate r;
r.anewemp();
}
else
if(ch1=='2')
{
upddate p;
p.uname();
}
else
if(ch1=='3')
{ upddate v;
v.udesi();
}
else
if(ch1=='4')
{ upddate v;
v.uadd();
}
else
if(ch1=='5')
{ upddate s;
s.utel();}
else
if(ch1=='6')
{ emp c;
c.exitt();}
else
if(ch1=='7')
{
emp d;
d.exiit();
}}}

/*function to add new employee details*/

void upddate::anewemp()
{
int dday,mmonth,yyear;
char fname[15],lname[15],desi[20],offadd[50],resadd[50];
long ot,rt;
int co,rec;
int j;
fl q;
clrscr();
for(j=6;j<45;j++)
{ gotoxy(6,j);
cout<<"*\n";}
for(j=7;j<75;j++)
{ gotoxy(j,44);
cout<<"*\n";}
for(j=6;j<45;j++)
{ gotoxy(75,j);
cout<<"*\n";}
for(j=6;j<75;j++)
{ gotoxy(j,6);
cout<<"*\n";}
gotoxy(19,8);
cout<<"ENTER THE DETAILS OF THE EMPLOYEE";
gotoxy(15,10);
cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^";
gotoxy(10,15);
cout<<"enter first name of the employee:-";
gotoxy(45,15);
gets(fname);
getch();
gotoxy(10,18);
cout<<"enter the last name of the employee:-";
gotoxy(48,18);
gets(lname);
getch();
gotoxy(10,21);
cout<<"enter the designation of the employee:-";
gotoxy(50,21);
gets(desi);
getch();
gotoxy(10,24);
cout<<"enter the office address:-";
gotoxy(37,24);
gets(offadd);
getch();
gotoxy(10,27);
cout<<"enter the residence address:-";
gotoxy(40,27);
gets(resadd);
getch();
gotoxy(10,30);
cout<<"enter the office telephone:-";
gotoxy(39,30);
cin>>ot;
getch();
gotoxy(10,33);
cout<<"enter the std code of resi:-";
gotoxy(39,33);
cout<<"0";
gotoxy(40,33);
cin>>co;
getch();
gotoxy(10,36);
cout<<"enter the residence telephone:-";
gotoxy(42,36);
cin>>rt;
getch();
gotoxy(10,39);
cout<<"date of joining(dy,mn,yr):-";
gotoxy(37,39);
cin>>dday;
getch();
gotoxy(39,39);
cout<<".";
gotoxy(40,39);
cin>>mmonth;
getch();
gotoxy(42,39);
cout<<".";
gotoxy(43,39);
cin>>yyear;
getch();
o: char k;
gotoxy(50,41);
cout<<"Save record y/n";
gotoxy(66,41);
cin>>k;
if(k=='y'|k=='Y')
{q.addetail(fname,lname,desi,offadd,resadd,ot,co,rt,dday,mmonth,yyear);
upddate i;
i.udate();}
else if(k=='n'|k=='N')
{ upddate i;
i.udate();
}
else
{ gotoxy(50,43);
cout<<"Press either yes/no";
goto o;
}}
/*function to show update name */

void upddate::uname()
{ char desi[20];
int j;
char ch2;
while(1)
{ clrscr();
for(j=8;j<45;j++)
{ gotoxy(6,j);
cout<<"*\n";}
for(j=7;j<70;j++)
{ gotoxy(j,44);
cout<<"*\n";}
for(j=8;j<45;j++)
{ gotoxy(70,j);
cout<<"*\n";}
for(j=6;j<70;j++)
{ gotoxy(j,8);
cout<<"*\n";}
gotoxy(25,10);
cout<<" --UPDATE NAME-- \n";
gotoxy(20,13);
cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^";
gotoxy(20,15);
cout<<" 1.update last name \n";
gotoxy(20,19);
cout<<" 2.update first name \n";
gotoxy(20,23);
cout<<" 3.go to previous screen \n";
gotoxy(20,27);
cout<<" 4.go to main menu \n";
gotoxy(20,31);
cout<<" 5.exit from application \n";
gotoxy(20,35);
cout<<" please enter your choice:- \n";
gotoxy(50,35);
ch2=getche();
if(ch2=='1')
{ clrscr();
upddate r;
r.ulname();
r.udate();
}
else
if(ch2=='2')
{
clrscr();
upddate p;
p.ufname();
p.udate();
}
else
if(ch2=='3')
{ upddate c;
c.udate();}

else
if(ch2=='4')
{ emp c;
c.exitt();}
else
if(ch2=='5')
{
emp d;
d.exiit();
}}}

/*function for loop*/


void emp::l()
{ int j;
for(j=18;j<33;j++)
{ gotoxy(20,j);
cout<<"*\n";}
for(j=20;j<55;j++)
{ gotoxy(j,32);
cout<<"*\n";}
for(j=18;j<33;j++)
{ gotoxy(55,j);
cout<<"*\n";}
for(j=20;j<55;j++)
{ gotoxy(j,18);
cout<<"*\n";}
}
void emp::l1()
{ int j;
for(j=16;j<33;j++)
{ gotoxy(8,j);
cout<<"*\n";}
for(j=8;j<69;j++)
{ gotoxy(j,32);
cout<<"*\n";}
for(j=16;j<33;j++)
{ gotoxy(69,j);
cout<<"*\n";}
for(j=8;j<69;j++)
{ gotoxy(j,16);
cout<<"*\n";}
}
void emp::l2()
{
int j;
for(j=18;j<33;j++)
{ gotoxy(20,j);
cout<<"*\n";}
for(j=20;j<55;j++)
{ gotoxy(j,32);
cout<<"*\n";}
for(j=18;j<33;j++)
{ gotoxy(55,j);
cout<<"*\n";}
for(j=20;j<55;j++)
{ gotoxy(j,18);
cout<<"*\n";}

}
void emp::l3()
{ gotoxy(22,28);
cout<<"! wait for few seconds ";
delay(3000);
clrscr();
int j;
for(j=6;j<45;j++)
{ gotoxy(6,j);
cout<<"*\n";}
for(j=7;j<75;j++)
{ gotoxy(j,44);
cout<<"*\n";}
for(j=6;j<45;j++)
{ gotoxy(75,j);
cout<<"*\n";}
for(j=6;j<75;j++)
{ gotoxy(j,6);
cout<<"*\n";}
}

/*function to show updated last name*/


void upddate::ulname()
{
int count=0;
emp e;
clrscr();
fl y;

char u[25],l[25],l1[25];
FILE *pfile;
pfile=fopen("C:\TC\TC\Bin\pp.dat","r");
if(pfile== NULL)
{ cout<<"no such file exist";
getch();
return; }
else{ e.l();
gotoxy(22,20);
cout<<"! enter fname ";
gets(l1);
gotoxy(22,22);
cout<<"! enter lname ";
gets(l);
fstream p;
fstream g;
p.open("C:\TC\TC\Bin\pp.dat",ios::in);
g.open("temp.dat",ios::out|ios::ate);
while(p.read((char*)this,sizeof(fl)))
{ int k=strncmp(l1,fme,15);
int h=strncmp(l,lme,15);
if(h==0&k==0)
{ count=1;
gotoxy(22,25);
cout<<"! name present";
gotoxy(22,28);
cout<<"! updated name ";
gets(u);;
strcpy(lme,u);
}
g.write((char*)this,sizeof(fl));
}
p.close();
g.close();
remove("C:\TC\TC\Bin\pp.dat");
rename("temp.dat","C:\TC\TC\Bin\pp.dat");}
g: if(count==0)
{ clrscr();
e.l();
int j;
gotoxy(22,20);
cout<<"! Data not present";
gotoxy(22,22);
cout<<"! Name entered :"<<l;
int k;
gotoxy(22,24);
cout<<"! Press 1 to enter again";
gotoxy(22,26);
cout<<"! Press 2 to exit";
gotoxy(22,28);
cout<<"Select your choice ";
cin>>k;

if(k==1){
ulname(); }
else if(k==2){
else{ gotoxy(22,30);
cout<<"wrong option selected reselect";
delay(2000);
goto g;
}} }

/*function to show updated first name*/


void upddate::ufname()

{
int count=0;
emp e;
clrscr();
\ fl y;
char u[25],l[25],l1[25];
FILE *pfile;
pfile=fopen("C:\TC\TC\Bin\pp.dat","r");
if(pfile== NULL)
{ cout<<"no such file exist";
getch();
return; }
else{ e.l();
gotoxy(22,20);
cout<<"! enter fname ";
gets(l1);
gotoxy(22,22);
cout<<"! enter lname ";
gets(l);
fstream p;
fstream g;
p.open("C:\TC\TC\Bin\pp.dat",ios::in);
g.open("temp.dat",ios::out|ios::ate);
while(p.read((char*)this,sizeof(fl)))
{ int h=strncmp(l1,fme,15);
int q=strncmp(l,lme,15);
if(h==0&q==0)
{ count =1;
gotoxy(22,25);
cout<<"! name present";
gotoxy(22,28);
cout<<"! updated name ";
gets(u);
strcpy(fme,u);
}
g.write((char*)this,sizeof(fl));
}
p.close();
g.close();
remove("C:\TC\TC\Bin\pp.dat");
rename("temp.dat","C:\TC\TC\Bin\pp.dat");
}
g: if(count==0)
{ clrscr();
e.l();
gotoxy(22,20);
cout<<"! Data not present";
gotoxy(22,22);
cout<<"! Name entered :"<<l;
int k;
gotoxy(22,24);
cout<<"! Press 1 to enter again";
gotoxy(22,26);
cout<<"! Press 2 to exit";
gotoxy(22,28);
cout<<"Select your choice ";
cin>>k;
if(k==1){
ufname(); }
else if(k==2){
}
else{ gotoxy(22,30);
cout<<"wrong option selected reselect";
delay(2000);
goto g;
}
}}
/*function to update designation*/
void upddate ::udesi()
{ emp e;
clrscr();
fl y;
int count=0;
char u[25],l[25],l1[25];
FILE *pfile;
pfile=fopen("C:\TC\TC\Bin\pp.dat","r");
if(pfile== NULL)
{ cout<<"no such file exist";
getch();
return; }
else
{ e.l();
gotoxy(22,20);
cout<<"! enter fname ";
gets(l1);
gotoxy(22,22);
cout<<"! enter designation ";
gets(l);
fstream p;
fstream g;
p.open("C:\TC\TC\Bin\pp.dat",ios::in);
g.open("temp.dat",ios::out|ios::ate);
while(p.read((char*)this,sizeof(fl)))
{ int h=strncmp(l,ds,15);
int q=strncmp(l,ds,15);
if(h==0&q==0)
{ count=1;
gotoxy(22,25);
cout<<"! designation present";
gotoxy(22,28);
cout<<"! updated designation ";
gets(u);
strcpy(ds,u);
}
g.write((char*)this,sizeof(fl));
}
p.close();
g.close();
remove("C:\TC\TC\Bin\pp.dat");
rename("temp.dat","C:\TC\TC\Bin\pp.dat");
}
g: if(count==0)
{ clrscr();
e.l();
gotoxy(22,20);
cout<<"! Data not present";
gotoxy(22,22);
cout<<"! Designation entered :"<<l;
int k;
gotoxy(22,24);
cout<<"! Press 1 to enter again";
gotoxy(22,26);
cout<<"! Press 2 to exit";
gotoxy(22,28);
cout<<"Select your choice ";
cin>>k;
if(k==1){
udesi(); }
else if(k==2){
}
else{ gotoxy(22,30);
cout<<"wrong option selected reselect";
delay(2000);
goto g;
}}}

/*function to update address */

void upddate::uadd()
{
int j;
char ch3,desi[20];
while(1)
{ clrscr();
for(j=8;j<45;j++)
{ gotoxy(6,j);
cout<<"*\n";}
for(j=7;j<70;j++)
{ gotoxy(j,44);
cout<<"*\n";}
for(j=8;j<45;j++)
{ gotoxy(70,j);
cout<<"*\n";}
for(j=6;j<70;j++)
{ gotoxy(j,8);
cout<<"*\n";}
gotoxy(25,10);
cout<<" --UPDATE ADDRESS-- \n";
gotoxy(20,13);
cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^";
gotoxy(20,15);
cout<<" 1.update office addresss \n";
gotoxy(20,19);
cout<<" 2.update residence address \n";
gotoxy(20,23);
cout<<" 3.go to previous screen \n";
gotoxy(20,27);
cout<<" 4.go to main menu \n";
gotoxy(20,31);
cout<<" 5.exit from application \n";
gotoxy(20,35);
cout<<" please enter your choice:- \n";
gotoxy(50,35);
ch3=getche();
if(ch3=='1')
{ clrscr();
upddate r;
r.uoadd();
r.udate();
getch();
}
else

if(ch3=='2')
{ clrscr();
upddate p;
p.uradd();
p.udate();
getch();
}
else
if(ch3=='3')
{ upddate c;
c.udate();}
else
if(ch3=='4')
{ emp c;
c.exitt();}
else
if(ch3=='5')
{
emp d;
d.exiit();
}}}

/*function to show updated off address*/

void upddate::uoadd()

{
int count=0;
emp e;
clrscr();
fl y;
char u[25],l[25];
FILE *pfile;
pfile=fopen("C:\TC\TC\Bin\pp.dat","r");
if(pfile== NULL)
{ cout<<"no such file exist";
getch();
return; }

else{ e.l1();
gotoxy(10,20);
cout<<"! enter address ";
gets(l);

fstream p;
fstream g;
p.open("C:\TC\TC\Bin\pp.dat",ios::in);
g.open("temp.dat",ios::out|ios::ate);
while(p.read((char*)this,sizeof(fl)))
{ int h=strncmp(l,ofad,15);
if(h==0)
{ count=1;
gotoxy(10,23);
cout<<"! address is present";
gotoxy(10,26);
cout<<"! updated address ";
gets(u);;
strcpy(ofad,u);
}
g.write((char*)this,sizeof(fl));
}
p.close();
g.close();
remove("C:\TC\TC\Bin\pp.dat");
rename("temp.dat","C:\TC\TC\Bin\pp.dat");
}
g: if(count==0)
{ clrscr();
e.l1();
gotoxy(10,20);
cout<<"! Data not present";
gotoxy(10,22);
cout<<"! address entered :"<<l;
int k;
gotoxy(10,24);
cout<<"! press 1 to enter again";
gotoxy(10,26);
cout<<"! press 2 to exit";
gotoxy(10,28);
cout<<"Select your choice";
gotoxy(29,28);
cin>>k;
if(k==1){
uoadd(); }
else if(k==2){
}
else{ gotoxy(10,30);
cout<<"wrong option selected reselect";
delay(2000);
goto g;
}}}

/*function to show updated res address*/

void upddate::uradd()

{
emp e;
clrscr();
fl y;
int count=0;
char u[25],l[25];
FILE *pfile;
pfile=fopen("C:\TC\TC\Bin\pp.dat","r");
if(pfile== NULL)
{ cout<<"no such file exist";
getch();
return; }

else{ e.l1();
gotoxy(10,20);
cout<<"! enter address ";
gets(l);

fstream p;
fstream g;
p.open("C:\TC\TC\Bin\pp.dat",ios::in);
g.open("temp.dat",ios::out|ios::ate);
while(p.read((char*)this,sizeof(fl)))
{ int h=strncmp(l,read,15);
if(h==0)
{ count=1;
gotoxy(10,23);
cout<<"! address is present";
gotoxy(10,26);
cout<<"! updated address ";
gets(u);;
strcpy(read,u);
}
g.write((char*)this,sizeof(fl));}
p.close();
g.close();
remove("C:\TC\TC\Bin\pp.dat");
rename("temp.dat","C:\TC\TC\Bin\pp.dat");
}
g: if(count==0)
{ clrscr();
e.l1();
gotoxy(10,20);
cout<<"! Data not present";
gotoxy(10,22);
cout<<"! address entered :"<<l;
int k;
gotoxy(10,24);
cout<<"! press 1 to enter again";
gotoxy(10,26);
cout<<"! press 2 to exit";
gotoxy(10,28);
cout<<"Select your choice";
gotoxy(29,28);
cin>>k;
if(k==1){
uradd(); }
else if(k==2){
}
else{ gotoxy(10,30);
cout<<"wrong option selected reselect";
delay(2000);
goto g;
}}}
/*function to update telephone no.*/
void upddate::utel()
{ int j;

char ch4;
while(1)
{ clrscr();
for(j=8;j<45;j++)
{ gotoxy(6,j);
cout<<"*\n";}
for(j=7;j<70;j++)
{ gotoxy(j,44);
cout<<"*\n";}
for(j=8;j<45;j++)
{ gotoxy(70,j);
cout<<"*\n";}
for(j=6;j<70;j++)
{ gotoxy(j,8);
cout<<"*\n";}
gotoxy(25,10);
cout<<" --UPDATE TELEPHONE-- \n";
gotoxy(20,13);
cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^";
gotoxy(20,15);
cout<<" 1.update office telephone \n";
gotoxy(20,19);
cout<<" 2.update residence telephone \n";
gotoxy(20,23);
cout<<" 3.go to previous screen \n";
gotoxy(20,27);
cout<<" 4.go to main menu \n";
gotoxy(20,31);
cout<<" 5.exit from application \n";
gotoxy(20,35);
cout<<" please enter your choice:- \n";
gotoxy(50,35);

ch4=getche();
if(ch4=='1')
{ clrscr();
upddate r;
r.uotel();
r.udate();
getch();
}
else
if(ch4=='2')
{ clrscr();
upddate p;
p.urtel();
p.udate();
getch();
}
else if(ch4=='3')
{ upddate c;
c.udate();}
else
if(ch4=='4')
{ emp c;
c.exitt();}
else
if(ch4=='5')
{ emp d;
d.exiit();
}}}

/*function to update res tel*/

void upddate::urtel()

{
emp e;
clrscr();
fl y;
int count=0;
long u,l;
FILE *pfile;
pfile=fopen("C:\TC\TC\Bin\pp.dat","r");
if(pfile== NULL)
{ cout<<"no such file exist";
getch();
return; }
else{ e.l2();
gotoxy(22,22);
cout<<"! enter no. ";
cin>>l;

fstream p;
fstream g;
p.open("C:\TC\TC\Bin\pp.dat",ios::in);
g.open("temp.dat",ios::out|ios::ate);
while(p.read((char*)this,sizeof(fl)))
{
if(l==lo)
{ count =1;
gotoxy(22,25);
cout<<"! no present";
gotoxy(22,28);
cout<<"! updated no ";
cin>>u;
lo=u;
}
g.write((char*)this,sizeof(fl));

}
p.close();
g.close();
remove("C:\TC\TC\Bin\pp.dat");
rename("temp.dat","C:\TC\TC\Bin\pp.dat");
}
g: if(count==0)
{ clrscr();
e.l2();
gotoxy(22,20);
cout<<"! Data not present";
gotoxy(22,22);
cout<<"! no entered by you "<<l;
int k;
gotoxy(22,24);
cout<<"! press 1 to enter again";
gotoxy(22,26);
cout<<"! press 2 to exit";
gotoxy(22,28);
cout<<"Select your choice";
gotoxy(41,28);
cin>>k;
if(k==1){
urtel(); }
else if(k==2){
}
else{ gotoxy(22,30);
cout<<"wrong option selected reselect";
delay(2000);
goto g;
}}}

/*function to update office tel*/


void upddate::uotel()

{ emp e;
clrscr();
fl y;
int count=0;
long u,l;
FILE *pfile;
pfile=fopen("C:\TC\TC\Bin\pp.dat","r");
if(pfile== NULL)
{ cout<<"no such file exist";
getch();
return; }

else{
e.l2();
gotoxy(22,22);
cout<<"! enter no. ";
cin>>l;
fstream p;
fstream g;

p.open("C:\TC\TC\Bin\pp.dat",ios::in);
g.open("temp.dat",ios::out|ios::ate);
while(p.read((char*)this,sizeof(fl)))
{
if(l==v)
{ count=1;
gotoxy(22,25);
cout<<"! no present";
gotoxy(22,28);
cout<<"! updated no ";
cin>>u;
v=u;
}
g.write((char*)this,sizeof(fl));

}
p.close();
g.close();
remove("C:\TC\TC\Bin\pp.dat");
rename("temp.dat","C:\TC\TC\Bin\pp.dat");
}
g: if(count==0)
{ clrscr();
e.l2();
gotoxy(22,20);
cout<<"! Data not present";
gotoxy(22,22);
cout<<"! no entered by you "<<l;
int k;
gotoxy(22,24);
cout<<"! press 1 to enter again";
gotoxy(22,26);
cout<<"! press 2 to exit";
gotoxy(22,28);
cout<<"Select your choice";
gotoxy(41,28);
cin>>k;
if(k==1){
uotel(); }
else if(k==2){
}
else{ gotoxy(22,30);
cout<<"wrong option selected reselect";
delay(2000);
goto g;
}}}

/*function to manage list */

void upddate::wdata()
{ clrscr();
int j;
fl k;
for(j=3;j<47;j++)
{ gotoxy(5,j);
cout<<"|\n";}
for(j=3;j<47;j++)
{ gotoxy(21,j);
cout<<"|\n";}
for(j=3;j<47;j++)
{ gotoxy(30,j);
cout<<"|\n";}
for(j=3;j<47;j++)
{ gotoxy(65,j);
cout<<"|\n";}
for(j=3;j<47;j++)
{ gotoxy(1,j);
cout<<"|\n";}
for(j=3;j<47;j++)
{ gotoxy(79,j);
cout<<"|\n";}
for(j=2;j<79;j++)
{ gotoxy(j,46);
cout<<"_";}
for(j=2;j<79;j++)
{ gotoxy(j,6);
cout<<"-";}

gotoxy(22,2);
cout<<" THE DETAILS OF THE EMPLOYEE";
gotoxy(1,3);

cout<<"______________________________________________________________________
_________";
gotoxy(2,5);
cout<<"SNO";
gotoxy(10,5);
cout<<"NAME ";
gotoxy(23,5);
cout<<"DESI. ";
gotoxy(40,5);
cout<<"RES.ADDRESS";
gotoxy(69,5);
cout<<"RS.TEL";

}
/*function to manage list */

void upddate::edata()
{ clrscr();
int j;
fl k;
for(j=3;j<47;j++)
{ gotoxy(5,j);
cout<<"|\n";}
for(j=3;j<47;j++)
{ gotoxy(21,j);
cout<<"|\n";}
for(j=3;j<47;j++)
{ gotoxy(30,j);
cout<<"|\n";}
for(j=3;j<47;j++)
{ gotoxy(65,j);
cout<<"|\n";}
for(j=3;j<47;j++)
{ gotoxy(1,j);
cout<<"|\n";}
for(j=3;j<47;j++)
{ gotoxy(79,j);
cout<<"|\n";}
for(j=2;j<79;j++)
{ gotoxy(j,46);
cout<<"_";}
for(j=2;j<79;j++)
{ gotoxy(j,6);
cout<<"-";}

gotoxy(22,2);
cout<<" THE DETAILS OF THE EMPLOYEE";
gotoxy(1,3);

cout<<"______________________________________________________________________
_________";
gotoxy(2,5);
cout<<"SNO";
gotoxy(10,5);
cout<<"NAME ";
gotoxy(23,5);
cout<<"DESI. ";
gotoxy(40,5);
cout<<"OFF.ADDRESS";
gotoxy(69,5);
cout<<"OFF.TEL";

/*function to manage new emp detail into file*/

void fl::addetail(char fname[], char lname[],char desi[],


char offadd[],char resadd[],long ot,
int co,long rt,int dday,int mmonth,int yyear)
{ fl s[10];

dd=dday;
mm=mmonth;
yy=yyear;
v=ot;
na=co;
lo=rt;
strcpy(fme,fname);
strcpy(lme,lname);
strcpy(ds,desi);
strcpy(ofad,offadd);
strcpy(read,resadd);

fstream re;
re.open("C:\TC\TC\Bin\pp.dat",ios::out|ios::app);
re.write((char*)this,sizeof(fl));
re.close();
}
/*function to show the list of employee*/
void fl::list1()
{
upddate e;
clrscr();
fl y;
fstream g;

FILE *pfile;
pfile=fopen("C:\TC\TC\Bin\pp.dat","r");
if(pfile== NULL)
{ cout<<"no such file exist";
getch();
return; }

else{ clrscr();
e.wdata();
g.open("C:\TC\TC\Bin\pp.dat",ios::in);
g.seekg(0,ios::beg);
int s;
int sno=1;
int i=8;
while(g.read((char*)this,sizeof(fl)))
{
s=i+1;
for(i;i<s;i++)
{gotoxy(3,i);
cout<<sno;
gotoxy(6,i);
cout<<fme;
gotoxy(6,i+2);
cout<<lme;
gotoxy(22,i);
cout<<ds;
gotoxy(32,i);
cout<<read;
gotoxy(66,i);
cout<<"0"<<na<<"-"<<lo;}
sno++;
i=i+3;
if(i==44)
{ i=8;
gotoxy(10,48);
cout<<"press enter to continue application";
getch();
clrscr();
e.wdata();
}
}}
g.close();
getch();}

/*function to show the list of employee*/


void fl::list2()
{
upddate e;
clrscr();
fl y;
fstream g;

FILE *pfile;
pfile=fopen("C:\TC\TC\Bin\pp.dat","r");
if(pfile== NULL)
{ cout<<"no such file exist";
getch();
return; }
else{ clrscr();
e.edata();
g.open("C:\TC\TC\Bin\pp.dat",ios::in);
g.seekg(0,ios::beg);
int s;
int sno=1;
int i=8;
while(g.read((char*)this,sizeof(fl)))
{ s=i+1;

for(i;i<s;i++)
{gotoxy(3,i);
cout<<sno;
gotoxy(6,i);
cout<<fme;
gotoxy(6,i+2);
cout<<lme;
gotoxy(22,i);
cout<<ds;
gotoxy(32,i);
cout<<ofad;
gotoxy(66,i);
cout<<"011-"<<v;}
sno++;
i=i+3;
if(i==44)
{ i=8;
gotoxy(10,48);
cout<<"press enter to continue application";
getch();
clrscr();
e.edata();
}
}}
g.close();
getch();}
void main()
{ textbackground(BLACK);
textcolor(RED);
clrscr();
emp k;
k.showmain();

getch();
}

You might also like