Employee and Customer Management System using single link list

Customer and Employee Management System using link list 


 #include<iostream>
#include<string>
using namespace std;
class Customer{
public:
	int custCnic;
	string custName, custAdress,custPhone,custType;
	Customer *custNext;
	Customer()
	{
		custCnic = 0;
		custName = custAdress = custPhone = custType = " ";
	}
	Customer(int cnic, string name, string adress, string phone, string type)
	{
		custCnic = cnic;
		custName = name; custAdress = adress; custPhone = phone; custType = type;
	}
};
class Employee{
public:
	int empCnic;
	string empName, empAdress, empPhone, empType;
	Employee *empNext;
	Employee()
	{
		empCnic = 0;
		empName = empAdress = empPhone = empType = " ";
	}
	Employee(int cnic, string name, string adress, string phone, string type)
	{
		empCnic = cnic;
		empName = name; empAdress = adress; empPhone = phone; empType = type;
	}
};
class DSA{
public:
	Customer *custHead = NULL;
	Employee *empHead = NULL;
	void insertCust()
	{
		Customer *temp = new Customer;
		cout << "Enter the cnic of customer:"; cin >> temp->custCnic; cin.ignore();
		cout << "Enter the name of customer:"; getline(cin, temp->custName);
		cout << "Enter the address of customer:"; getline(cin, temp->custAdress);
		cout << "Enter the the phone number of customer:"; getline(cin, temp->custPhone);
		cout << "Enter the customer type of customer:"; getline(cin, temp->custType);
		if (custHead == NULL)
		{
			temp->custNext = NULL;
			custHead = temp;
		}
		else
		{
			temp->custNext = custHead;
			custHead = temp;
		}
	}
	void insertEmp()
	{
		Employee *temp = new Employee;
		cout << "Enter the cnic of Employee:"; cin >> temp->empCnic; cin.ignore();
		cout << "Enter the name of Employee:"; getline(cin, temp->empName);
		cout << "Enter the address of Employee:"; getline(cin, temp->empAdress);
		cout << "Enter the the phone number of Employee:"; getline(cin, temp->empPhone);
		cout << "Enter the customer type of Employee:"; getline(cin, temp->empType);
		if (empHead == NULL)
		{
			temp->empNext = NULL;
			empHead = temp;
		}
		else
		{
			temp->empNext = empHead;
			empHead = temp;
		}
	}
	void custUpdate()
	{
		Customer *temp = new Customer;
		temp = custHead; int a, count = 0;
		cout << "PLease enter the cnic of the customer to update:"; cin >> a;
		while (temp != NULL)
		{
			if (a == temp->custCnic)
			{
				cout << "Enter the name of customer to update:"; getline(cin, temp->custName);
				cout << "Enter the address of customer to update:"; getline(cin, temp->custAdress);
				cout << "Enter the the phone number of customer to update:"; getline(cin, temp->custPhone);
				cout << "Enter the customer type of customer to update:"; getline(cin, temp->custType);
				cout << "Please press enter to continue" << endl;
				system("pause");
				count++;
			}
			temp = temp->custNext;
		}
		if (count==0)
		{
			cout << "This cnic is not found" << endl;
		}

	}
	void empUpdate()
	{
		Employee *temp = new Employee;
		temp = empHead; int a, count = 0;
		cout << "PLease enter the cnic of the customer:"; cin >> a;
		while (temp != NULL)
		{
			if (a == temp->empCnic)
			{
				cout << "Enter the name of Employee to update:"; getline(cin, temp->empName);
				cout << "Enter the address of Employee to update:"; getline(cin, temp->empAdress);
				cout << "Enter the the phone number of Employee to update:"; getline(cin, temp->empPhone);
				cout << "Enter the customer type of Employee to update:"; getline(cin, temp->empType);
				cout << "Please press enter to contineue" << endl;
				system("pause");
				count++;
			}
			temp = temp->empNext;
		}
		if (count==0)
		{
			cout << "This cnic is not found" << endl;
		}
	}
	void custRetrieve()
	{
		Customer *temp = new Customer;
		temp = custHead; int count = 0;
		while (temp != NULL)
		{
				cout << "Your name is(Customer Name):" << temp->custName << endl;
				cout << "Your address is(Customer Adress):" << temp->custAdress << endl;
				cout << "Your cnic is(Customer CNIC):" << temp->custCnic << endl;
				cout << "Your phone number is(Customer Phone):" << temp->custPhone << endl;
				cout << "Your type is(Customer Type):" << temp->custType << endl;
				cout << "Please press enter to contineue" << endl;
				system("pause");
				count++;
			temp = temp->custNext;
		}
		if (count == 0)
		{
			cout << "There is no Data" << endl;
		}
	}
	void empRetrieve()
	{
		Employee *temp = new Employee;
		temp = empHead; int count = 0;
		while (temp != NULL)
		{
				cout << "Your name is(Employee Name):" << temp->empName << endl;
				cout << "Your address is(Employee Adress):" << temp->empAdress << endl;
				cout << "Your cnic is(Employee CNIC):" << temp->empCnic << endl;
				cout << "Your phone number is(Employee Phone):" << temp->empPhone << endl;
				cout << "Your type is(Employee Type):" << temp->empType << endl;
				cout << "Please press enter to contineue" << endl;
				system("pause");
				count++;
			temp = temp->empNext;
		}
		if (count==0)
		{
			cout << "This cnic is not found" << endl;
		}
	}
	void searchCust()
	{
		Customer *temp = new Customer;
		temp = custHead; int a,count=0;
		cout << "PLease enter the cnic of the customer:"; cin >> a;
			while (temp != NULL)
			{
				if (a == temp->custCnic)
				{
					cout << "Your name is(Customer Name):" << temp->custName << endl;
					cout << "Your address is(Customer Adress):" << temp->custAdress << endl;
					cout << "Your cnic is(Customer CNIC):" << temp->custCnic << endl;
					cout << "Your phone number is(Customer Phone):" << temp->custPhone << endl;
					cout << "Your type is(Customer Type):" << temp->custType << endl;
					cout << "Please press enter to contineue" << endl;
					system("pause");
					count++;
				}
				temp = temp->custNext;
			}
		if(count==0)
		{
			cout << "This cnic is not found" << endl;
		}
	}
	void searchEmp()
	{
		Employee *temp = new Employee;
		temp = empHead; int a, count = 0;
		cout << "PLease enter the cnic of the customer:"; cin >> a;
		while (temp != NULL)
		{
			if (a == temp->empCnic)
			{
				cout << "Your name is(Employee Name):" << temp->empName << endl;
				cout << "Your address is(Employee Adress):" << temp->empAdress << endl;
				cout << "Your cnic is(Employee CNIC):" << temp->empCnic << endl;
				cout << "Your phone number is(Employee Phone):" << temp->empPhone << endl;
				cout << "Your type is(Employee Type):" << temp->empType << endl;
				cout << "Please press enter to contineue" << endl;
				system("pause");
				count++;
			}
			temp = temp->empNext;
		}
		if (count==0)
		{
			cout << "This cnic is not found" << endl;
		}
	}
};
int main()
{
	DSA *d1 = new DSA;
	int a = 0;

	while (a != 3){
		system("cls");
		cout << "**********Unlimited Customers And Employee Management System*************" << endl;
		cout << "Enter 1 to work for customers" << endl;
		cout << "Enter 2 to work in Employee" << endl;
		cout << "Enter 3 to cancel" << endl;
		cout << "**************************************************************************" << endl;
		cin >> a;
		if (a == 1)
		{
			d1->insertCust();
			
			int c = 0;
			while (c != 4)
			{
				system("cls");
			cout << "Enter 1 to retrieve the customer data" << endl;
			cout << "Enter 2 to search the customer" << endl;
			cout << "Enter 3 to update the customer data" << endl;
			cout << "Enter 4 to cancel" << endl;
			cin >> c;
			
				switch (c)
				{
				case 1:
				{
						  d1->custRetrieve();
						  cout << endl << endl;
						  break;
				}
				case 2:
				{
						  d1->searchCust();
						  cout << endl << endl;
						  break;
				}
				case 3:
				{
						  d1->custUpdate();
						  cout << endl << endl;
						  break;
				}
				case 4:
				{
						  cout << "Thank You For Our services" << endl;
						  cout << "Press Enter to cancel" << endl;
						  system("pause");
						  break;
				}
				default:
				{
						   cout << "This option is not available" << endl;
						   break;
				}
				}
			}
		}
		else if (a == 2)
		{
			
			d1->insertEmp();
			int c = 0;
			while (c != 4)
			{
				system("cls");
			cout << "Enter 1 to retrieve the Employee data" << endl;
			cout << "Enter 2 to search the Employee" << endl;
			cout << "Enter 3 to update the Employee data" << endl;
			cout << "Enter 4 to cancel" << endl;
			cin >> c;
			
				switch (c)
				{
				case 1:
				{
						  d1->empRetrieve();
						  cout << endl << endl;
						  break;
				}
				case 2:
				{
						  d1->searchEmp();
						  cout << endl << endl;
						  break;
				}
				case 3:
				{
						  d1->empUpdate();
						  cout << endl << endl;
						  break;
				}
				case 4:
				{
						  cout << endl << endl;
						  cout << "Thank You For Our services" << endl;
						  cout << "Press Enter to cancel" << endl;
						  system("pause");
						  break;
				}
				default:
				{
						   cout << endl << endl;
						   cout << "This option is not available" << endl;
						   break;
				}
				}
			}
		}
		else
		{
			try{
				if (a == 3)
				{
					throw a;
				}
				else{
					cout << endl << endl << endl;
					cout << "Sorry This option is not available" << endl;
					cout << "WE are working to expand our project so stay tuned" << endl;
					cout << "Press Enter to continue" << endl;
					system("pause");
				}
			}

			catch (...)
			{
				cout << "Thank You so much FOR our services" << endl;
			}
		}
	}
		getchar();
		getchar();
		return 0;
	}      

          

       
 

Comments

Popular posts from this blog

Multiple inheritance,friend function and multiple file in oop(object oriented programming)

Concepts of OOP (object oriented programming)

Concepts in c++........