Professional Documents
Culture Documents
C PROGRAMMING
Term paper of
C PROGRAMMING..
CSE :202
ACKNOWLEDGEMENT
VINOD VERMA
PAGE:3
C PROGRAMMING
Employee Management Database System
#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;
PAGE:4
C PROGRAMMING
public:
group();
void addrec();
void listrec();
void modirec();
void delrec();
void recallrec();
void packrec();
void exit();
};
void main()
char choice,v;
group g;
do
clrscr();
struct dosdate_t d;
_dos_getdate(&d);
// p.day=d.day;
// p.month=d.month;
// p.year=d.year;
PAGE:5
C PROGRAMMING
// _dos_getdate(&d);
gotoxy(12,5);
textcolor(6);
cprintf("Todays date:");
printf("%d",d.day);
cout<<"/";
printf("%d",d.month);
cout<<"/";
cout<<d.year;
gotoxy(12,9);
cout<<"Srknec.corporation pvt.ltd";
gotoxy(12,12);
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<<"5.Recall record";
gotoxy(12,23);
cout<<"6.Pack record";
gotoxy(12,25);
cout<<"0.Exit";
gotoxy(12,28);
PAGE:6
C PROGRAMMING
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'5':
g.recallrec();
break;
case'6':
PAGE:7
C PROGRAMMING
g.packrec();
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)
exit();
void group::addrec()
{
PAGE:8
C PROGRAMMING
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;
do
:"<<endl<<endl;
cout<<"OR"<<endl<<endl;
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));
cin>>ch;
}
PAGE:9
C PROGRAMMING
while(ch=='y'||ch=='Y');
void group::listrec()
int j=0,a;
file.seekg(0L,ios::beg);
//Donot touch Above Line Any Way it is set to give Some Nice Look
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<<"
"<<p.day<<"/"<<p.month<<"/"<<p.year<<endl;
file.clear();
if(j==0)
gotoxy(10,10);
gotoxy(10,11);
PAGE:10
C PROGRAMMING
cout<<"Press any key...";
getch();
else
getch();
void group::modirec()
char code[5];
int count=0;
cin>>code;
file.seekg(0L,ios::beg);
while(file.read((char*)&p,sizeof(p)))
if(strcmp(p.empcode,code)==0)
cin>>p.name>>p.age>>p.sal;
struct dosdate_t d;
_dos_getdate(&d);
PAGE:11
C PROGRAMMING
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++;
getch();
file.clear();
void group::delrec()
char code[5];
int count=0;
cin>>code;
file.seekg(0L,ios::beg);
while(file.read((char*)&p,sizeof(p)))
if (strcmp(p.empcode,code)==0)
PAGE:12
C PROGRAMMING
{
p.flag='*';
pos=count*sizeof(p);
file.seekp(pos,ios::beg);
file.write((char*)&p,sizeof(p));
return;
count++;
getch();
file.clear();
void group::recallrec()
char code[5];
int count=0;
cin>>code;
file.seekg(0L,ios::beg);
while(file.read((char*)&p,sizeof(p)))
PAGE:13
C PROGRAMMING
{
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++;
getch();
file.clear();
void group::packrec()
ofstream outfile;
outfile.open("TEMP",ios::out);
file.seekg(0,ios::beg);
while(file.read((char*)&p,sizeof(p)))
if(p.flag!='*')
outfile.write((char*)&p,sizeof(p));
PAGE:14
C PROGRAMMING
}
outfile.close();
file.close();
remove("Emp.DAT");
rename("TEMP","EMP.DAT");
file.open("EMP.DAT",ios::binary|ios::in|ios::out|ios::nocreate);
gotoxy(10,10);
gotoxy(10,11);
getch();
void group::exit()
file.close();
References
E –Balagurusamy
Ashoke N Kamthane
PAGE:15
C PROGRAMMING
www.planet-source-code.com/
www.codeproject.com/