You are on page 1of 5

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; 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.month=d.month; // p.year=d.year; // _dos_getdate(&d); gotoxy(12,5); textcolor(6); cprintf("Todays date:"); printf("%d",; cout<<"/"; printf("%d",d.month); cout<<"/"; cout<<d.year; gotoxy(12,9); cout<<"Srknec.corporation"; gotoxy(12,12);

gotoxy(12.23).21).Recall record". gotoxy(12.delrec().ios::binary|ios::in|ios::out). cout<<"5. cout<<"2. p.addrec(). gotoxy(12. cout<<"0. case'6': g.19).packrec(). } } . clrscr(). cout<<"Your choice"<<" ". switch(choice) { case '1': g. break. break. cout<<"6. break.listrec(). break. exit(1). case'2': g.modirec(). case'0': g.exit(). } void group::group() { file. cin>>choice.cout<<"1.25).recallrec().dat".17). gotoxy(12. if(!file) { cout<<endl<<"Unable to open file". gotoxy(12.Modify record". case'3': g.Delete record".Add record". case'4': g. break.flag=' '.List Record". cout<<"3. cout<<"4. } } while(choice!=0).15).Pack record". gotoxy("Emp. case'5': g. break.Exit". gotoxy(12. exit().28).

} else { cout<<endl<<"Press any>>p. cin>>ch.sizeof(p))) { if(p. //Donot touch Above Line Any Way it is set to give Some Nice Look while(file..void group::addrec() { char ch.flag!='*') cout<<endl<<"Record#"<<" "<<j++<<setw(6)<<p. struct dosdate_t d. cout<<"To return to the Main menu press'm' key else press'a':".day=d.. cout<<"OR"<<endl<<endl.ios::beg).. cout<<"Press any key.11). name.sal<<" "<<p.seekg(0L.a.10)<<setw(4)<<p. if(j==0) { gotoxy(10. age & salary :"<<endl<<endl. p. p.month<<"/"<<p.write((char*)&p. } void group::listrec() { int j=0..sal.". file. cout<<"List of records present are as under>>>"<<endl<<endl. _dos_getdate(&d). if(ch=='m'||ch=='M') { main().name>>p. } } void group::modirec() . getch().sizeof(p)).ios::end). gotoxy(10.age<<setw(9)<<p.year.year<<endl. cout<<"Add another record ?(y/n) :". cin>>ch. p. cout<<"No record exit". file.month=d. } cin>>p.empcode<<setw(20)<<p. file. cout<<"Make shure that no employee has the same code"<<endl.flag=' '.read((char*)&p.".clear().age>>p.month. p. do { cout<<endl<<"Enter employee code.seekp(0L. } file. } while(ch=='y'||ch=='Y'). getch(). cout<<" "<<"|CODE|"<<" "<<"|NAME|"<<" "<<"|AGE|"<<" "<<"|SALARY|"<<" "<<"|DATED|"<<<<"/"<<p.

name>>p.ios::beg). struct dosdate_t d.month=d.flag=' '.empcode.write((char*)&p.clear().ios::beg).day=d.*)&p.{ char code[5]. } count++. cin>>code.sizeof(p)). long int pos. cout<<"Enter employee code to be deleted :". while(file. getch().ios::beg). file. pos=count*sizeof(p).sal. p. int count=0.month.write((char*)&p. cin>>p.ios::beg).sizeof(p)). int count=0. _dos_getdate(&d). cout<<endl<<"Press any key. } count++. while(file.sizeof(p))) { if(strcmp(p. file.flag='*'.clear().code)==0) { cout<<endl<<"Enter new record "<< cout<<endl<<"Enter employee name.".age & salary :"<<endl. p. file.seekp(pos. file. cout<<"Enter employee code to be recalled :".read((char*)&p. long int pos. } void group::recallrec() { char code[5]. file.year=d. } void group::delrec() { char code[5].code)==0) { p.sizeof(p))) { if (strcmp(p. cout<<"Enter employee code whose record is to be modified :". return. cin>>code.seekp(pos. file. } cout<<endl<<"No employee in file with code= "<<code. file.age>>p. cin>>code. return.seekg(0L. pos=count*sizeof(p). file. . long int pos... p. int count=0. } cout<<endl<<"No employee in file with code="<<code. getch().seekg(0L.empcode.year.

write((char*)&p.ios::out). cout<<"Marked records to be deleted are all removed". getch()."EMP. while(file. } cout<<endl<<"No employee in the file with code="<<code.DAT").code)==0) { p.11).seekg(0L.DAT".. gotoxy(10. } .sizeof(p))) { if(strcmp(p. rename("TEMP".open("TEMP". remove("Emp.. file. } void group::packrec() { ofstream outfile. outfile.ios::beg).seekg(0. file. } void group::exit() { file.10).write((char*)&p. }*)&p.sizeof(p))..empcode.DAT").sizeof(p))) { if(p.flag=' '*)&p. cout<<"press any key.". file.close(). } outfile. file. while(file.ios::beg). file.seekp(pos.flag!='*') outfile.close(). getch(). cout<<endl<<"Press any key. return.clear()..close(). gotoxy(10..ios::binary|ios::in|ios::out|ios::nocreate). file. pos=count*sizeof(p).sizeof(p)).open("EMP.".ios::beg).