Add to Favorites    Make Home Page 3331 Online  
 Language Categories  
 Our Services  

Home » C++ Home » Data Structures Home » Employee Management Database System

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Employee Management Database System
Author VIJEN M
Author Email vman [at] sify.com
Description It is basic program that deals with how to manage a database using C++ library functions.
Category C++ » Data Structures
Hits 392587
Code Select and Copy the Code
#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.day=d.day; // p.month=d.month; // p.year=d.year; // _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); 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': 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) { 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 shure that no employee has the same code"<<endl; do { cout<<endl<<"Enter employee code, name, age & salary :"<<endl<<endl; cout<<"OR"<<endl<<endl; cout<<"To return to the Main menu press'm' key else press'a':"; 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; //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); 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::recallrec() { char code[5]; long int pos; int count=0; cout<<"Enter employee code to be recalled :"; 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 the file with code="<<code; cout<<endl<<"Press any key..."; 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)); } 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); cout<<"Marked records to be deleted are all removed"; gotoxy(10,11); cout<<"press any key...."; getch(); } void group::exit() { file.close(); }

Related Source Codes

Script Name Author
Moving ball screen saver karlmarx
The Classic Game of Snake & Ladder Lakshmi Narayana .A
Railway seat reservation question which comes in sapient VyomWorld
To calculate percentile Ravi Mathur
Send to folder ANIMESH SAHU
Analog clock and calendar Nazia & Rida
HIGH/LOW GAME MOLLY ARORA
Data structure (stack Implimentation) Swapnil B Adsure
Memory Game AnirudhSanyal
Easy Calc Anirudh Sanyal
GK Quiz Anirudh Sanyal
Hangman Game Manish Jain
Snakeman Manish Jain
Full month Calendar Nigi
Cursor shapes nigi

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=742


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review