Vous êtes sur la page 1sur 36

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

HEADER FILES USED

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

#include<iostream.h>

#include<conio.h>

#include<string.h>

#include<stdio.h>

#include<fstream.h>

#include<stdlib.h>

#include<ctype.h>
int c=1,r=8;

class employee //CLASS

{ char name[22];

long staffid;

char doj[20];

char desig[22];

char raddress[100];

char sal[11];

public:

void readdata();

void showdata();

void display();
long returnnumber()

return(staffid); }

}st;

void createfile();

void addfile();

void deletefile();

void displayfile();

void main()

clrscr();

int ch1;

do

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

THE MAIN MENU

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

clrscr();

cout<<"\n\t\t\t *** welcome to:-***";

cout<<"\n\t\t\t *** VS COMPANY ***\n";

cout<<"\n\t\t\t ****************\n\n";

cout<<"\n \t\t\t1.Add employee details";

cout<<"\n \t\t\t2.Append more details";

cout<<"\n \t\t\t3.Delete details";

cout<<"\n \t\t\t4.Display details";

cout<<"\n \t\t\t5.Exit";
cout<<"\nEnter your choice:\n";

cin>>ch1;

switch(ch1)

case 1:

createfile();

break;

case 2:

addfile();

break;

case 3:

deletefile();

break;

case 4:displayfile();

break;

case 5:

cout<<"\n Thank you for using the Program";

break;

default:

cout<<"\n Enter a Valid Option(1-5)";

} }

while(ch1!=5);

getch(); }
/******************************

TO DISPLAY THE RERCORDS

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

void employee::display()

gotoxy(3,r);

puts(name);

gotoxy(11,r);

cout<<staffid;

gotoxy(20,r);

puts(raddress);

gotoxy(35,r);

puts(doj);

gotoxy(60,r);

puts(desig);

gotoxy(74,r);

puts(sal);

r=r+1;

}
/*******************************

TO READ THE DETAILS

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

void employee::readdata()

clrscr();

cout<<"\n\t\t\t....Employee details....";

cout<<"\nEnter the Name Of The Employee:";

gets(name);

cout<<endl;

cout<<"\nEnter the Employee ID:";

cin>>staffid;

cout<<"\nEnter the Residential Address:";

gets(raddress);

cout<<"\nEnter the Date of Joining:";

gets(doj);

cout<<"\nEnter the Designation:";

gets(desig);

cout<<"\nEnter the Salary(per month):";

gets(sal);

cout<<"\n\t\tPersonnel added successfully!";

getch();

}
/*********************************

TO SHOW THE DETAILS

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

void employee::showdata()

clrscr();

cout<<"\n\t\t\tDETAILS OF THE EMPLOYEE ";

cout<<"\n\t\t\t***********************";

cout<<"\nName of the Employee:";cout<<name;

cout<<"\n";

cout<<"\nEmployee code:";cout<<staffid;

cout<<"\n";

cout<<"\nResedential Address:";cout<<raddress;

cout<<"\n\n";

cout<<"\Date of joining:";cout<<doj;

cout<<"\n";

cout<<"\nDesignation:";cout<<desig;

cout<<"\n";

cout<<"\nSalary:";cout<<sal;

getch();

clrscr();

}
/*******************************

TO ADD THE DETAILS

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

void addfile()

clrscr();

ofstream f1("empy.dat",ios::binary|ios::out|ios::app);

if(f1)

char a;

do

cout<<"\nEnter the range:";

cin>>c;

for(int i=0;i<c;i++)

st.readdata();

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

cout<<"\nDo you want to add more details:";

cout<<"\nPress(Y/N):\n";

cin>>a;

a=toupper(a);
}

while(a=='Y');

else

cout<<"File cannot be opened:";

f1.close();

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

TO CREATE THE RECORD

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

void createfile()

ofstream f("empy.dat",ios::binary|ios::out);

if(!f)

cout<<"File cannot be opened:";

else

st.readdata();

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

}
/**************************

TO DELETE A RECORD

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

void deletefile()

char q,ch;

do

ifstream fin;

fin.open("empy.dat",ios::binary|ios::in);

ofstream fout;

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

int sr,flag=0;

cout<<"\nEnter the Employee ID of employee to be deleted:";

cin>>sr;

fin.read((char*)&st,sizeof(st));

while(!fin.eof())

long c;

c=st.returnnumber();

if(sr==c)

cout<<"\nEmployee details present"<<endl;


cout<<"\nRecord to be deleted is :"<<endl;

st.showdata();

flag=1;

cout<<"\nEmployee details deleted successfully"<<endl;

else

fout.write((char*)&st,sizeof(st));

fin.read((char*)&st,sizeof(st));

if(flag==0)

cout<<"\nEmployee records not found"; }

fin.close();

fout.close();

remove("empy.dat");

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

cout<<"\n\n\nDo you want to deleted more records(Y/N):";

cin>>q; q=toupper(q);

}while(q!='N');

}
/**************************

TO DISPLAY THE RECORD

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

void displayfile()

db:

clrscr();

int ch,o;

ch=0;

o=0;

while(ch<4)

cout<<"\n\t\t\t *** VS COMPANY ***\n";

cout<<"\t\t\t ---------------\n\n";

cout<<"\n1.Employee Details";

cout<<"\n2.Display particular content:" <<"\n3.Edit a detail"

cout<<"\n4.Back to menu"

cout<<"\n\nEnter the choice:\n";

cin>>ch;

char s4;

switch(ch)

case 1:

{
ifstream f3("empy.dat",ios::binary|ios::in);

if(f3)

clrscr();

gotoxy(30,3);

cout<<"PERSONNEL DETAILS";

gotoxy(3,5);

cout<<"NAME";

gotoxy(11,5);

cout<<"CODE";

gotoxy(20,5);

cout<<"ADDRESS";

gotoxy(34,5);

cout<<"JOINING DATE";

gotoxy(59,5);

cout<<"DESIGNATION";

gotoxy(74,5);

cout<<"SALARY";

gotoxy(1,6);

cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"

<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^";

o=1;

while(!f3.eof())

f3.read((char*)&st,sizeof(st));
if(!f3.eof())

st.display();

getch();

clrscr();

if(o==0)

clrscr();

gotoxy(35,10);

cout<<"No records present"<<endl;

getch();

clrscr();

else

cout<<"\nFile cannot be opened:";

getch();

clrscr();

f3.close();

break;

case 2:

char s2;
do

int sno,n1;

ifstream f5("empy.dat",ios::binary|ios::in);

if(f5)

int a=0;

cout<<"\n\nEnter the Employee ID of"

cout<<"the employee whose details is "

cout<<"to be displayed"<<endl;

cin>>sno;

while(f5.read((char*)&st,sizeof(st)))

n1=st.returnnumber();

if(sno==n1)

a=1;

st.showdata();

cout<<endl;

if(a==0)

cout<<"Such an Employee does"


cout<<"not exists"<<endl<<endl; getch();

clrscr();

cout<<"\n\n\n Do you to display"

cout<<"any other data ?"<<"\nPress(Y/N):";

cin>>s2;

getch();

clrscr();

s2=toupper(s2);

f5.close();

else

cout<<"\nFile cannot be opened:";

while(s2=='Y');

break;

case 3:

int eno;

int flag=0;

cout<<"\n\n\tEnter Employee ID to Edited:";

cin>>eno;

ifstream fin("empy.dat",ios::binary|ios::in);
ofstream fout("temp.dat",ios::binary|ios::out);

if(!fin)

cout<<"\n\nFile Not Found...";

exit(0);}

fin.read((char*)&st,sizeof(st));

while(!fin.eof())

int x=st.returnnumber();

if(x==eno)

flag=1;

clrscr();

cout<<"\n\t\tCurrent Details are\n";

st.showdata();

cout<<"\n\n\t\tEnter New Details\n";

st.readdata();

fout.write((char*)&st,sizeof(st));

fin.read((char*)&st,sizeof(st));

cout<<"\n\n\t Personnel Details edited...";

fin.close();

fout.close();

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

if(flag==0)

cout<<"\n\t\tPersonnel does not exist...Please Retry!";

getch();

goto db;}

goto db;}

default:

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

getch();

break;

}
ENTERED VALUE:1

ENTERING THE EMPLOYMENT DETAILS:


--2-TO APPEND MORE DETAILS
ENTERING THE RANGE : 2
_NO ENTERED
--3-TO DELETE THE EMPLOYMENT DETAILS (ID-20 GIVEN)

:NO ENTERED
--4- TO DISPYAL THE DETAILS OF THE EMPLOYEMENT
--IF ENTERING : 1

--IF ENTERING : 2

--ID—24
INTRODUCTION

 This project is mainly aims for the


management of the employement in a
componay.
 This program is able to store the details of
the emoployements like employement
name,ID,address,
date of joining to the company,designation
and salary of the employement.
 In this program you can add many numbers of
the employement by taking range,you can see
the details,you can edit the details,you can
delete the details and you can search any
particular employements details by giving its
ID number,and many more things.
BIBLIOGRAPHY

 www.google.com

 www.slideshare.net

 www.icbse.com
WORKING

--This program consist of five option as

follows:-

1.To add a new employement details.

2.To append more employements details.

3.To display the employement details.

4.To delete the employement details.

5.To exit.

CONCLUSION
 In making of this program I learned the varios
aspects of C++ programming using the classes
,loops,array,etc.and their control over the source
code.

 The syntax errors was rectified by consulting by


computer teacher and referring various
books,searching on the internet and discussion with
friends.

 This program can be effectively used in factories


and company’s data system.
 Concluding it is acknowledgment that my c++
concepts were concretized and my programming skills
has been graded to higer level.

Thank you

Vous aimerez peut-être aussi