Friday, January 9, 2015

Employee Information System in C

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<iomanip.h>

int x=1;

class a
{
 public :

 char name[20];
 int des;
 int salary;
 int age;
 int experience;

void insert();
 };

 a d[100];        //Creating Object

 void a::insert()                       //To Insert A New Record
 {
 cout<<"Enter The Name Of The Employee :- ";
 cin>>name;
 cout<<"Enter The Age :- ";
 cin>>age;
 cout<<"Enter The Experience :- ";
 cin>>experience;
 cout<<"Enter The Desiganation Press 1:- Current 2:- Formal :- ";
 cin>>des;
 cout<<"Enter The Salary :- ";
 cin>>salary;
  };

  void delete1()                   //To Delete Record
  {
  int r,i,calc=0;
  char opt;
  cout<<"************************Delete A Record*************************"<<endl;
  cout<<"Enter The Serial Number Of The Employee :- ";
  cin>>r;
 cout<<endl;
 cout<<"Name             Age        Experience      Desiganation      Salary "<<endl;
 calc= strlen(d[i].name);
 if (d[r].des==1)
 {
 cout<<d[r].name<<setw(19-calc)<<d[r].age<<setw(15)<<d[r].experience<<setw(20)<<"Current"<<setw(11)<<d[r].salary<<endl<<endl;
  }
 else
 {
 cout<<d[r].name<<setw(19-calc)<<d[r].age<<setw(15)<<d[r].experience<<setw(20)<<"Formal"<<setw(11)<<d[r].salary<<endl<<endl;
  }

  cout<<"Do You Want To Delete Press y or n :- ";
  cin>>opt;

  switch(opt)
  {
  case 'y':
  {
  for(i=r;i<=x;i++)
  {
 // d[r].name=d[r+1].name;
  strcpy(d[r].name,d[r+1].name);
  d[r].age=d[r+1].age;
  d[r].des=d[r+1].des;
  d[r].experience=d[r+1].experience;
  d[r].salary=d[r+1].salary;
  }
  x=x-1;
  cout<<endl<<"Record Successfully Deleted "<<endl<<endl<<endl;

  break;
  }


  };

  }


 void viewall()
 {
 int i,calc;
 cout<<"****************************View All****************************"<<endl;
 cout<<"Name            Experience      Desiganation"<<endl;
 for(i=1;i<=x-1;i++)
 {
 calc= strlen(d[i].name);
 if (d[i].des==1)
 {
 cout<<d[i].name<<setw(19-calc)<<setw(20)<<d[i].experience<<setw(20)<<"Current"<<endl;
  }
 else
 {
 cout<<d[i].name<<setw(19-calc)<<setw(20)<<d[i].experience<<setw(20)<<"Formal"<<endl;
  }

 calc=0;

 }

 cout<<endl<<endl<<endl;

 }


 void viewemp()
 {
 int i,calc;
 cout<<"***********************View Employee Details************************"<<endl;
 cout<<"Name             Age        Experience      Desiganation      Salary "<<endl;
 for(i=1;i<=x-1;i++)
 {
 calc= strlen(d[i].name);
 if (d[i].des==1)
  {
  cout<<d[i].name<<setw(19-calc)<<d[i].age<<setw(15)<<d[i].experience<<setw(20)<<"Current"<<setw(11)<<d[i].salary<<endl<<endl;
  }
  calc=0;
  }

  cout<<endl;
 }



 void main()
 {
 clrscr();

 int val,i,valu,temp;
 s:
 cout<<"*********MENU**********"<<endl;
 cout<<"1 :- Insert A Employee "<<endl;
 cout<<"2 :- Delete A Employee "<<endl;
 cout<<"3 :- View All Employee "<<endl;
 cout<<"4 :- View Employee Details "<<endl<<endl;
 cout<<"Enter The Choice :- ";
 cin>>val;
 cout<<endl<<endl;
 valu=0;
 switch(val)
 {
 case 1:
 {
  cout<<"**************Insert A Employee***************"<<endl;
  cout<<"Enter The Number Of Employees Wants To Enter :- ";
  cin>>valu;
  temp=valu;
  valu=x+valu;
  cout<<endl;
for(i=x;i<=valu-1;i++)
  {
  d[i].insert();
  cout<<endl;
  }
  x=x+temp;  //updating the number of records
  cout<<"Employees Successfully Added"<<endl<<endl<<endl;
  break;

  }

  case 2:
  {
  delete1();
  break;
  }

  case 3:
  {
  viewall();
  break;
  }

  case 4:
  {
  viewemp();
  break;
  }

  };

  goto s;

 getch();
 }


for more codes you can Visit http://codesofprogramming.blogspot.in/

No comments:

Post a Comment