Employee and Customer Management System C++

Management System(Employee and Customer)

ctech&p

 


 #include<iostream>

#include<string>

using namespace std;

class Customer{

public:

	string custName, custAdress, custType,custPhone; int custCnic;

	Customer(){

		custName = custAdress = custType=custPhone = "0";

		custCnic = 0;

	}

	Customer(string a, string b, string c,string d, int e)

	{

		custName = a; custAdress = b;

		custType = c; custPhone = d; custCnic = e;

	}



};

class Employee{

public:

	string empName, empAdress, empType,empPhone; int empCnic;

	Employee(){

		empName = empAdress = empType,empPhone = "0";

		empCnic = 0;

	}

	Employee(string a, string b, string c,string d, int e)

	{

		empName = a; empAdress = b;

		empType = c; empPhone = d; empCnic = e;

	}



};

class DSA{

public:

		void Create(Employee *e, int size)

		{

			for (int i = 0; i < size; i++){

				cout << endl;

				cout << "Please enter the cnic number for Employee(in integer):";

				cin >> e[i].empCnic; cin.ignore();

				cout << "Please Enter the name of the Employee:";

				getline(cin, e[i].empName);

				cout << "Please enter the adress of the Employee:";

				getline(cin, e[i].empAdress);

				cout << "Enter the phone number of employee:";

				getline(cin, e[i].empPhone);

				cout << "Please enter the employee type:";

				getline(cin, e[i].empType);

				cout << endl << endl;



			}

		}

		void Retrieve(Employee *e, int size)

		{

			int a;

			cout << "Enter the cnic to search the Employee:"; cin >> a; cin.ignore();

			for (int i = 0; i < size; i++){

				if (a == e[i].empCnic)

				{

					cout << "Your name is:" << e[i].empName << endl;

					cout << "Your adress is:" << e[i].empAdress << endl;

					cout << "Your phone number is:" << e[i].empPhone << endl;

					cout << "Your type is:" << e[i].empType << endl;

				}

				else

				{

					cout << "This cnic is not found" << endl;

					cout << "Please enter the data again(Press enter to continoue)" << endl;

					cin.get();

				}

			}

		}

		void Update(Employee *e, int size)

		{

			int a;

			cout << "Enter the cnic to update the customer data:"; cin >> a; cin.ignore();

			for (int i = 0; i < size; i++){

				if (a == e[i].empCnic)

				{

					cout << "Please enter name to update:"; getline(cin, e[i].empName);

					cout << "Please enter Adress to update:"; getline(cin, e[i].empAdress);

					cout << "Please enter phone number to update:"; getline(cin, e[i].empPhone);

					cout << "Please enter Employee type to update:"; getline(cin, e[i].empType);

				}

				else

				{

					cout << "This cnic is not found" << endl;

					cout << "Please enter the data again(Press enter to continoue)" << endl;

					cin.get();

				}

			}

		}

		void SearchEmployee(Employee *e, int size)

		{

			int a;

			cout << "Enter the cnic for employee to search:"; cin >> a; cin.ignore();

			for (int i = 0; i < size; i++)

			{

				if (a == e[i].empCnic)

				{

					cout << "Your name is:" << e[i].empName << endl;

					cout << "Your adress is:" << e[i].empAdress << endl;

					cout << "Your phone number is:" << e[i].empPhone << endl;

					cout << "YOur type is:" << e[i].empType << endl;

				}

			}

		}

		void Delete(Employee *e, int size)

		{

			int a;

			cout << "Enter the cnic to delete the employee data:"; cin >> a; cin.ignore();

			for (int i = 0; i < size; i++){

				if (a == e[i].empCnic)

				{

					delete[i]e;

				}

				else

				{

					cout << "This cnic is not found" << endl;

					cout << "Please enter the data again(Press enter to continoue)" << endl;

					cin.get();

				}

			}

		}

		void Create(Customer *c, int size)

		{

			for (int i = 0; i < size; i++){

				cout << endl;

				cout << "Please enter the cnic number for customer(in integer):";

				cin >> c[i].custCnic; cin.ignore();

				cout << "Please Enter the name of the customer:";

				getline(cin, c[i].custName);

				cout << "Please enter the adress of the customer:";

				getline(cin, c[i].custAdress);

				cout << "Please enter the phone number of customer:";

				getline(cin, c[i].custPhone);

				cout << "Please enter the customer type:";

				getline(cin, c[i].custType);

				cout << endl << endl;



			}

		}

		void Retrieve(Customer *c, int size)

		{

			int a;

			cout << "Enter the cnic to search the customer:"; cin >> a; cin.ignore();

			for (int i = 0; i < size; i++){

				if (a == c[i].custCnic)

				{

					cout << "Your name is:" << c[i].custName << endl;

					cout << "Your adress is:" << c[i].custAdress << endl;

					cout << "Your pHone number is:" << c[i].custPhone << endl;

					cout << "Your type is:" << c[i].custType << endl;

				}

				else

				{

					cout << "This cnic is not found" << endl;

					cout << "Please enter the data again(Press enter to continoue)" << endl;

					cin.get();

				}

			}

		}

		void Update(Customer *c, int size)

		{

			int a;

			cout << "Enter the cnic to update the customer data:"; cin >> a; cin.ignore();

			for (int i = 0; i < size; i++){

				if (a == c[i].custCnic)

				{

					cout << "Please enter name to update:"; getline(cin, c[i].custName);

					cout << "Please enter Adress to update:"; getline(cin, c[i].custAdress);

					cout << "PLease enter the phone number to update:"; getline(cin, c[i].custPhone);

					cout << "Please enter Customer type to update:"; getline(cin, c[i].custType);

				}

				else

				{

					cout << "This cnic is not found" << endl;

					cout << "Please enter the data again(Press enter to continoue)" << endl;

					cin.get();

					Update(c, size);

				}

			}

		}

		void Delete(Customer *c, int size)

		{

			int a;

			cout << "Enter the cnic to delete the customer data:"; cin >> a; cin.ignore();

			for (int i = 0; i < size; i++){

				if (a == c[i].custCnic)

				{

					delete[i]c;

				}

				else

				{

					cout << "This cnic is not found" << endl;

					cout << "Please enter the data again(Press enter to continoue)" << endl;

					cin.get();

					Delete(c, size);

				}

			}

		}

		void SearchCustomer(Customer *c, int size)

		{

			int a;

			cout << "Enter the cnic for customer to search:"; cin >> a; cin.ignore();

			for (int i = 0; i < size; i++)

			{

				if (a == c[i].custCnic)

				{

					cout << "Your name is:" << c[i].custName << endl;

					cout << "Your adress is:" << c[i].custAdress << endl;

					cout << "Your phone number is:" << c[i].custPhone << endl;

					cout << "YOur type is:" << c[i].custType << endl;

				}

			}

		}



};

int main()

{

	int size, size1;

	DSA *dsa = new DSA;

	int a;

	cout << "Please enter 1 to go to employee section and 2 for customer section:";

	cin >> a; cin.ignore();

	cout << endl << endl << endl;

	try{

		if (a == 1)



		{

			int x = 0;

			cout << "Enter the number of employees for opration:"; cin >> size;

			Employee *emp = new Employee[size];

			dsa->Create(emp, size);

			while (x != 5){

				system("cls");

				cout << "***********************************" << endl;

				cout << "Enter the Manu" << endl;

				cout << "Enter 1 to retrieve the employee" << endl;

				cout << "Enter 2 to update the employee" << endl;

				cout << "Enter 3 to search the employee" << endl;

				cout << "Enter 4 to delete the employee" << endl;

				cout << "Enter 5 to cancel the manu" << endl;

				cin >> x; cin.ignore();

				switch (x)

				{

				case 1:

				{

						  dsa->Retrieve(emp, size);

						  break;

				}

				case 2:

				{

						  dsa->Update(emp, size);

						  break;

				}

				case 3:

				{

						  dsa->SearchEmployee(emp, size);

						  break;

				}

				case 4:

				{

						  dsa->Delete(emp, size);

						  break;

				}

				case 5:

				{

						  delete[]emp;

						  cout << "Thank you for our services and good luck" << endl;

						  cout << "Press enter to exit" << endl;

						  system("pause");

						  break;

				}

				default:

				{

						   delete[]emp;

						   cout << "This option is not available Sorry" << endl;

						   break;

				}

				}

			}

		}

		else if (a == 2)

		{

			int x = 0;

			cout << "Enter the numbers of customers to enter:"; cin >> size1;

			Customer *cust = new Customer[size1];

			dsa->Create(cust, size1);

			while (x != 5){

				system("cls");

				cout << "***********************************" << endl;

				cout << "Enter the Manu" << endl;

				cout << "Enter 1 to retrieve the customer" << endl;

				cout << "Enter 2 to update the customer" << endl;

				cout << "Enter 3 to search the customer" << endl;

				cout << "Enter 4 to delete the customer" << endl;

				cout << "Enter 5 to cancel the manu" << endl;

				cin >> x; cin.ignore();

				switch (x)

				{

				case 1:

				{

						  dsa->Retrieve(cust, size1);

						  break;

				}

				case 2:

				{

						  dsa->Update(cust, size1);

						  break;

				}

				case 3:

				{

						  dsa->SearchCustomer(cust, size1);

						  break;

				}

				case 4:

				{

						  dsa->Delete(cust, size1);

						  break;

				}

				case 5:

				{

						  delete[]cust;

						  cout << "Thank you for our services and good luck" << endl;

						  cout << "Press enter to exit" << endl;

						  system("pause");

						  break;

				}

				default:

				{

						   delete[]cust;

						   cout << "This option is not available Sorry" << endl;

						   break;

				}

				}

			}

		}

		else

		{

			cout << "This option is not available   Sorry!!!!" << endl;

			cout << "Thank you for our services" << endl;

			throw a;

		}

	}

	catch (...)

	{

		cout << "This was the program" << endl;

		cout << "Thank you so much" << 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++........