low1988 0 Light Poster
#include <iostream>
#include <conio.h>


using namespace std;

struct employeeInfo
{
       string name;
       int id;
       string department;
       employeeInfo *next;
};


class List {
	public:
		List(void) { head = NULL; } // constructor
		~List(void); // destructor
		bool IsEmpty() { return head == NULL; }

		employeeInfo* InsertEmployee(string ,int ,string );
		void DisplayList(void);
		void numEmployee();
		int DeleteNode(int x);
		int FindNode(int y);
		void ValNode(int,string);
        
  	 private:
		employeeInfo* head;
};

List::~List(void) {
	employeeInfo* currNode = head, *nextNode = NULL;
	while (currNode != NULL) {
		nextNode = currNode->next;
		// destroy the current node
		delete currNode;
		currNode = nextNode;
	}
}

employeeInfo* List::InsertEmployee(string nama,int number,string affiliate) {
	int currIndex = 0;
	employeeInfo* currNode = head;
	employeeInfo* prevNode = NULL;
	while (currNode) {
		prevNode = currNode;
      currNode = currNode->next;
		currIndex++;
	}

   employeeInfo* newNode = new employeeInfo;
	newNode->name = nama;
	newNode->id=number;
	newNode->department= affiliate;
	if (currIndex == 0) {
		newNode->next = head;
		head = newNode;
  	 } else {
		newNode->next = prevNode->next;
		prevNode->next = newNode;
   	}
 return newNode;
}
 
 void List::DisplayList()
{
	int num = 0;
	employeeInfo* currNode = head;
	while(currNode!=NULL)
	{
		cout << "Employee Name :"<<currNode->name <<endl;
		cout << "Employee ID   :"<<currNode->id<<endl;;
		cout << "Age           :"<<currNode->department<<endl;
		currNode = currNode->next;
		num++;
}   
}

int List::DeleteNode(int x) {
	employeeInfo* prevNode = NULL;
	employeeInfo* currNode = head;
	int currIndex = 1;
	while (currNode && currNode->id != x) {
		prevNode = currNode;
		currNode = currNode->next;
		currIndex++;
	}
	if (currNode) {
		if (prevNode) {
			prevNode->next = currNode->next;
			delete currNode;
		} else {
			head = currNode->next;
			delete currNode;
		}
		return currIndex;
   	}
	return 0;
}
void List::numEmployee()
{
    int numa=0;
    int totald = 0;
    int totalp = 0;
    int totalm = 0;
    string name ,department;
    int id;
    employeeInfo* currNode = head;
    while(currNode!=NULL)
    {
                         
    if(currNode->department =="design")
    {
     totald++;
     }
                            
    if(currNode->department =="production")
    {
     totalp++;
     }
      if(currNode->department =="management")
    {
     totalm++;
     }
      currNode = currNode->next;
      }
      cout <<"Total employee in design department is :"<<totald<<endl;
       cout <<"Total employee in production department is :"<<totalp<<endl;
        cout <<"Total employee in management department is :"<<totalm<<endl;
        cout <<"Total employees of all department is :"<<totald + totalp + totalm<<endl;
      
     }
     
     int List::FindNode(int y) {
	employeeInfo* currNode = head;
	int currIndex = 1;
	while (currNode && currNode->id!= y) {
		currNode = currNode->next;
		currIndex++;
	}
	if (currNode)
	{	cout << "Employee Name :"<<currNode->name <<endl;
		cout << "Employee ID   :"<<currNode->id<<endl;;
		cout << "Age           :"<<currNode->department<<endl;}
	else{
	    cout <<"Employee not found"<<endl;
		return 0;
}}

void List::ValNode(int z,string dep) {
	employeeInfo* currNode = head;
	int currIndex = 1;
	while (currNode && currNode->id!= z) {
		currNode = currNode->next;
		currIndex++;
	}
	if (currNode->department == dep)
	{
    cout <<"id incorrect";
    }
    else 
    {cout <<"Id correct";}
}
      
int main()
{
    int choice,logchc,id,dselect;
    int numemploy = 0;
    int select ;
    int count = 0;
    char name[20];
    int eid;
    string departmentl;
    
    string Bpassword = "1234";
    string Hpassword = "5678";
    string password,department,decide;
    
    List test;
    test.InsertEmployee("Michael",1213,"design");
    test.InsertEmployee("Steven",2345,"management");
    test.InsertEmployee("Fernando",3456,"design");
    test.InsertEmployee("Michelle",1213,"production");
    test.InsertEmployee("Fenelix",1213,"design");
    test.InsertEmployee("Michael",1213,"production");
    
    label: 
    cout <<" 1.Log in as Board Director"<<endl;
    cout <<" 2.Log in as Head of Department"<<endl;
    
    cout <<"\nWhich priviledges do you wish to log in:"<<endl;
    cin >>logchc;
    if (logchc == 1)
    {
               cout <<"You had choose to login as Board of Director"<<endl;
               cout <<"Please enter your password:";
               while(password != Bpassword){
               cin >> password;
               if(password != Bpassword)
               cout <<"Incorrect password ,please enter again :";
               }
                           system("cls");
                           cout <<"Log in successfully"<<endl;
                           test.numEmployee();
                           cout <<"How many employees do you wish to layoff :";
                           cin >> numemploy;
                           cout <<"From which department:";
                           cin >> departmentl;
                           cout <<"You had decide to sack "<<numemploy<<" people from "<<departmentl<<" department."<<endl;
                           cout <<"Information would further to Head of Department.In order to take action Head of department must be take action"<<endl;
                          
                           system("PAUSE");
                           system("cls");
                           goto label;
                          }
                           
     if(logchc == 2)
     {
               cout <<"You had choose to login as Head of Department"<<endl;
               cout <<"Please enter your password";
               cin >> password;
               while(password != Hpassword){
               cin >> password;
               if(password != Hpassword)
               cout <<"Incorrect password ,please enter again :";
               }
               system("cls");
               cout <<"Log in successfully"<<endl;
               cout <<"\n";
               labelb:
               cout <<"1.Employ new employee"<<endl;
               cout <<"2.Layoff employee"<<endl;
               cout <<"3.Find employee"<<endl;
               cout <<"4.View all Information of employee"<<endl;
               cout <<"5.Enter your selection :"<<endl;
               cin >> select; 
               
              if(select == 2)
                         {
                         cout <<"The Board of Director had decide to fire "<<numemploy<<" people from "<<departmentl<<" department"<<endl;
                        
                         
                         cout <<"Insert the employee ID you wish to layoff :";
                        
                         cin >> eid;
                        test.ValNode(eid,departmentl);
                        cout <<"id from another department,please insert employee from "<<departmentl<<"department."<<endl;
                        
                          }}

        
    getch(); 
    return 0;
}

The codes above shows a process of the employee management system.First the Board of Director decide how many employees to layoff then from which department(design,production,management).
After then log in the Head of department section and layoff the number of employee as the decision of the Board of Director .But if the employees from another department mistaken to be layoff by head of department the mesage error would prompt out and forbid the operation.So the test.ValNode(int ,string) function is the segment to validate the employees to be layoff is matching with the Board of Director decision,but it seems to cause error why ?