employment database system - ritika n kunal - copy (2)
TRANSCRIPT
Employee Management Data Base System By: Aman Gupta Roll No 1 Class 12 C
CertificateThis is to certificate that the project entitled “Employee Management Database System”, which deals with the data record of all the employees in a company is being submitted by AMAN GUPTA. This project is a bonafide piece of work carried with the consultation of the supervisor.
AcknowledgementIt is with great pleasure that I find myself penning down these lines to express my sincere thanks to various people who helped me a long way in completing this project. It was a privilege to have been guided by Mrs. Rita Joseph.
/*Employee Management Database System made by Aman Gupta Roll No. - 1 */
#include<fstream.h>#include<dos.h>#include<conio.h>#include<stdlib.h>#include<stdio.h>#include<string.h>#include<iomanip.h>#include<graphics.h>
class group{
private:struct person{ char flag; char empcode[5];
char name[40]; int age; float sal; int day;
int month;int year;
}p;fstream file;public:
group();
void addrec();void listrec();void modirec();void delrec();void exit();
};
void main()
{ char choice,v; group g; do {
clrscr();struct dosdate_t d;_dos_getdate(&d);
cout<<"Made by Aman Gupta"<<endl;gotoxy(12,5);textcolor(6);cprintf("Todays date:");printf("%d",d.day);cout<<"/";
printf("%d",d.month);cout<<"/";cout<<d.year;gotoxy(12,9);gotoxy(12,13);
cout<<"1.Add record";gotoxy(12,15);cout<<"2.List Record";gotoxy(12,17);cout<<"3.Modify record";gotoxy(12,19);cout<<"4.Delete record";gotoxy(12,21);
cout<<"0.Exit"<<endl;gotoxy(12,28);cout<<"Your choice"<<" ";
cin>>choice;clrscr();
switch(choice) { case '1': g.addrec();
break; case'2': g.listrec();
break;
case'3': g.modirec(); break;
case'4': g.delrec(); break;
case'0': g.exit(); exit(1);
}}while(choice!=0);
}
void group::group(){
file.open("Emp.dat",ios::binary|ios::in|ios::out);p.flag=' ';if(!file){
cout<<endl<<"Unable to open file";exit();
}
}
void group::addrec(){
char ch;file.seekp(0L,ios::end);struct dosdate_t d;_dos_getdate(&d);p.day=d.day;p.month=d.month;p.year=d.year;
cout<<"Make sure that no employee has the same code"<<endl;do{
cout<<endl<<"To return to the Main menu press'm' key else press'a' followed by employee details";
cout<<" as shown:"<<endl<<endl; cout<<endl<<endl;
cout<<"Enter a code, name, age & salary"; cin>>ch; if(ch=='m'||ch=='M') {
main();}
cin>>p.empcode>>p.name>>p.age>>p.sal;p.flag=' ';
file.write((char*)&p,sizeof(p)); cout<<"Add another record ?(y/n) :"; cin>>ch; }while(ch=='y'||ch=='Y');
}
void group::listrec(){
int j=0,a;file.seekg(0L,ios::beg);
cout<<"List of records present are as under>>>"<<endl<<endl;cout<<" "<<"|CODE|"<<" "<<"|NAME|"<<""<<"|
AGE|"<<" "<<"|SALARY|"<<" "<<"|DATED|"<<endl;while(file.read((char*)&p,sizeof(p))){
if(p.flag!='*')
cout<<endl<<"Record#"<<""<<j++<<setw(6)<<p.empcode<<setw(20)<<p.name<<setw(4)<<p.age<<setw(9)<<p.sal;
cout<<" "<<p.day<<"/"<<p.month<<"/"<<p.year<<endl;}file.clear();
if(j==0){
gotoxy(10,10); cout<<"No record exit"; gotoxy(10,11); cout<<"Press any key..."; getch();
}else{
cout<<endl<<"Press any key..."; getch();
}}
void group::modirec(){
char code[5];int count=0;long int pos;cout<<"Enter employee code whose record is to be modified :";cin>>code;file.seekg(0L,ios::beg);while(file.read((char*)&p,sizeof(p))){ if(strcmp(p.empcode,code)==0)
{ cout<<endl<<"Enter new record "<<endl; cout<<endl<<"Enter employee name,age &
salary :"<<endl; cin>>p.name>>p.age>>p.sal; struct dosdate_t d; _dos_getdate(&d); p.day=d.day; p.month=d.month; p.year=d.year; p.flag=' ';
pos=count*sizeof(p); file.seekp(pos,ios::beg); file.write((char*)&p,sizeof(p)); return;
} count++;
}cout<<endl<<"No employee in file with code= "<<code;getch();file.clear();
}
void group::delrec(){
char code[5];long int pos;int count=0;cout<<"Enter employee code to be deleted :";cin>>code;file.seekg(0L,ios::beg);while(file.read((char*)&p,sizeof(p))){ if (strcmp(p.empcode,code)==0) {
p.flag='*'; pos=count*sizeof(p); file.seekp(pos,ios::beg); file.write((char*)&p,sizeof(p)); return;
} count++;
} cout<<endl<<"No employee in file with code="<<code; cout<<endl<<"Press any key..."; getch(); file.clear();
}
void group::exit(){ file.close();}
OUTPUT