Employer Mangment System using C++

Employer Mangment System using C++ is semester based project for Introduction to computer programming. This project is using file handling. It would be helpful for newbies. This is project is not based on OOP.

The code has following parts.

1) Show Employers Database
2) Add a new Record
3) Delete a record
4) Search a Record
5) Show all Records
6) Delete all Records

Header Files

#include <iostream>#include <string>#include <fstream>#include <windows.h>using namespace std;

Function Initialization

I tried to make whole project with function to understand it more clearly and easily. Then we do each work in its relevent function.

void input_biodata();void show_record();void search_record();void delete_record();void loop();void delete_all();void about_project();void menu();

Global Variable

int ct=0;int p,s,u=0; //loop function variables

Defining Structure

struct bio_data{int id;char fname[8];char lname[8];char category[8];char joinig_date[10];char qualification[8];};

Structure Object

bio_data d1;

Main Function

void main(){system("color 1F");char h='1';while(h == '1'){menu();cout<<"nn1. Continuet Any key for Exitn";cin>>h;}}

Menu

void menu(){int z;cout<<"tttEMPLOYER MANGMENT SYSTEMnn";cout<<"ttt 1. Show Employers Databasen";cout<<"ttt 2. Enter A Employer Recordn";cout<<"ttt 3. medical translation services . Delete a recordn";cout<<"ttt 4. Searchn";cout<<"ttt 5. viveros mayoristas . sell tickets online . Total Recordsn";cout<<"ttt 6. Delete Alln";cout<<"ttt 7. Exitnnnn";cout<<"ttt 0. About Project!nnnn";cout<<"Enter Your Choicen";cin>>z;switch(z){case 1:{show_record();}break;case 2:{input_biodata();}break;case 3:{delete_record();}break;case 4:{search_record();}break;case 5:{loop();cout<<"nnTotal Records In the Database are : " << u;}case 6:{delete_all();}break;case 7:{exit(0);}case 0:{about_project();}}//end switch}//end menu

Input Function

void input_biodata(){int n=0;int x=1;while(x == 1){cout<<"nID : ";cin>>d1.id;cout<<"n";cout<<"Enter the employer First Name : ";cin>>d1.fname;cout<<"Enter the employer Last Name : ";cin>>d1.lname;cout<<"Enter the category : ";cin>>d1.category;cout<<"Enter the Employer Joining Date e.g(dd.mm.yyyy): ";cin>>d1.joinig_date;cout<<"Enter the Employer Qualification : ";cin>>d1.qualification;fstream file ("record.txt",ios::binary|ios::app|ios::out );file.write( reinterpret_cast (&d1),sizeof(d1));file.close();ct++;cout<<"nn-----------------n";cout<<"ttt1. Enter An Other Recordn";cout<<"ttt2. Main Menun";cin>>x;}menu();}

Show All Records Function

void show_record(){loop();int i=0;cout<<"IDtF.NmaetL.NametCategorytJoining DatetQualification" ;cout<<"nn----------------------------";while(i< u){fstream file ("record.txt",ios::binary|ios::app|ios::in|ios::out);file.seekg(i*sizeof(d1),ios::beg);file.read( reinterpret_cast (&d1),sizeof(d1));cout<< d1.id <<"t"<< d1.fname<<" "<< d1.lname<<"t"<< d1.category<<"tt"<< d1.joinig_date<< "t"<< d1.qualification<<"n";i++;}}

Search Records

void search_record(){loop();char f_name [8];int l=0;int i=0;cout<<"Entert the First Name : ";cin>>f_name;fstream file("record.txt",ios::binary|ios::in|ios::out);file.seekg(0);while(i(&d1),sizeof(d1));if ((strcmp(f_name,d1.fname))==0){cout<<"n********************************************************************************n";cout<<d1.fname<</d1.fname<

<d1.fname<</d1.fname<

Calculate Total Records

void loop(){fstream file ("record.txt",ios::binary|ios::in);file.seekg(0,ios::end);p=file.tellg();s=sizeof(d1);u=p/s; //totalreocrd=position/sizeof(d1)}

Delete All Records

void delete_all(){fstream file("record.txt",ios::out|ios::trunc);file.close();}

 

Let's Discuss

  • http://stokedskateboards.com/decks/landyachtz-decks.html Landyachtz deck

    It’s been quite some time since an article such as yours has caught my interest. What a joy to find something so well written and impressive. This article is bookmark-worthy.