1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
|
#include "employee.h"
void readRecord(Employee *theEmployee , int &size){
ifstream inFile;
inFile.open( "employee.txt" );
if( inFile.is_open() ){
inFile >> size;
inFile.ignore(1, ':');
cin.get();
for (int i = 0 ; i < size ; ++i)
{
getline( inFile , theEmployee[i].EmployeeID );
getline( inFile , theEmployee[i].EmployeeName );
getline( inFile , theEmployee[i].EmployeeDepartment );
getline( inFile , theEmployee[i].EmployeeDOB );
getline( inFile , theEmployee[i].EmployeeAddress );
inFile >> theEmployee[i].EmployeeWorkHours;
inFile >> theEmployee[i].PayRate;
inFile >> theEmployee[i].totalSalary;
inFile.ignore(1,':');
}
}
}
void addRecord(Employee *theEmployee , int &size){
ofstream outFile;
cout<<"Size: "<< size;
cout << "\nEnter Employee ID [Mix of Char & Integer] : ";
cin.ignore();
getline( cin,theEmployee[size].EmployeeID );
cout << "Enter Name : ";
getline( cin,theEmployee[size].EmployeeName );
cout << "Enter Employee Department : ";
getline( cin,theEmployee[size].EmployeeDepartment );
cout << "Date of birthday [dd/mm/yy] : ";
//cin.ignore();
getline( cin,theEmployee[size].EmployeeDOB );
cout << "Enter Address : ";
getline( cin,theEmployee[size].EmployeeAddress );
do{
cout << "Enter Work Hour : ";
cin >> theEmployee[size].EmployeeWorkHours;
if( theEmployee[size].EmployeeWorkHours < 1 ){
cout << "\nInvalid Input for Work Hours !" << endl;
}
}while( theEmployee[size].EmployeeWorkHours < 1 );
do{
cout << "Enter Pay Rate : ";
cin >> theEmployee[size].PayRate;
if( theEmployee[size].PayRate < 1 )
cout << "\nInvalid Input for Pay Rate !" << endl;
}while( theEmployee[size].PayRate < 1 );
theEmployee[size].totalSalary = theEmployee[size].EmployeeWorkHours * theEmployee[size].PayRate ;
outFile.open( "employee.txt" , ios:: out );
size++;
outFile << size << "\n" ;
for( int i = 0 ; i < size ; i++ ){
outFile << theEmployee[i].EmployeeID << endl << theEmployee[i].EmployeeName << endl
<< theEmployee[i].EmployeeDepartment << endl
<< theEmployee[i].EmployeeDOB << endl << theEmployee[i].EmployeeAddress
<< endl << theEmployee[i].EmployeeWorkHours << endl << theEmployee[i].PayRate
<< endl << theEmployee[i].totalSalary << endl;
}
outFile.close();
}
void displaySpecificEmployee(Employee *theEmployee , int &size){
string SpecificEmployeeID = "";
int foundIndex = 0;
bool found = 0;
system( "cls" );
cin.ignore();
cout << "\tSearch a particular employee's payroll " << endl
<< "-------------------------------------------------------" << endl << endl
<< "Enter Employee ID : ";
getline(cin,SpecificEmployeeID);
for( int i = 0 ; i < size ; i++ ){
if( theEmployee[i].EmployeeID==SpecificEmployeeID ){
found = true;
foundIndex = i;
}
}
if( found == true ){
cout << "\nEmployee ID : " << theEmployee[foundIndex].EmployeeID << endl
<< "Employee Name : " << theEmployee[foundIndex].EmployeeName << endl
<< "Employee Department : " << theEmployee[foundIndex].EmployeeDepartment << endl
<< "Employee Date Of Birth : " << theEmployee[foundIndex].EmployeeDOB << endl
<< "Employee Address : " << theEmployee[foundIndex].EmployeeAddress << endl
<< "Employee Work Hours : " << theEmployee[foundIndex].EmployeeWorkHours << endl
<< "Employee Pay Rate : " << theEmployee[foundIndex].PayRate << endl
<< "Employee Salary : " << theEmployee[foundIndex].totalSalary << endl;
}
else
cout << "No Any Record found ! " << endl;
}
void displayParticularDepartment(Employee *theEmployee , int &size){
bool match = 0;
int foundIndex = 0;
string theDepartment;
cin.ignore();
cout << "Enter Department : ";
getline( cin , theDepartment );
cout << "Department : " << theDepartment << endl << endl;
for( int i = 0 ; i < size ; i++ ){
if( theEmployee[i].EmployeeDepartment == theDepartment ){
match = true;
foundIndex = i;
}
if( match == true ){
cout << "\nRecord " << ( i + 1 ) << "\n-----------------------";
cout << "\nEmployee ID : " << theEmployee[foundIndex].EmployeeID << endl
<< "Employee Name : " << theEmployee[foundIndex].EmployeeName << endl
<< "Employee Department : " << theEmployee[foundIndex].EmployeeDepartment << endl
<< "Employee Date Of Birth : " << theEmployee[foundIndex].EmployeeDOB << endl
<< "Employee Address : " << theEmployee[foundIndex].EmployeeAddress << endl
<< "Employee Work Hours : " << theEmployee[foundIndex].EmployeeWorkHours << endl
<< "Employee Pay Rate : " << theEmployee[foundIndex].PayRate << endl
<< "Employee Salary : " << theEmployee[foundIndex].totalSalary << endl ;
}
}
}
void ModifySpecificEmployee(Employee *theEmployee , int &size){
string SpecificEmployeeID = "";
bool found = 0;
int foundIndex = 0;
cin.ignore();
cout << "\tModify Employee\n---------------------------------" << endl << endl
<< "Enter Employee ID : " ;
getline( cin , SpecificEmployeeID );
for( int i = 0 ; i < size ; i++ ){
if( theEmployee[i].EmployeeID == SpecificEmployeeID ){
found = true;
foundIndex = i;
}
}
if( found == true ){
cout << "\n\tRecord :\n---------------------" << endl
<< "Employee ID : " << theEmployee[foundIndex].EmployeeID << endl
<< "Employee Name : " << theEmployee[foundIndex].EmployeeName << endl
<< "Employee Department : " << theEmployee[foundIndex].EmployeeDepartment << endl
<< "Employee Date Of Birth : " << theEmployee[foundIndex].EmployeeDOB << endl
<< "Employee Address : " << theEmployee[foundIndex].EmployeeAddress << endl
<< "Employee Work Hours : " << theEmployee[foundIndex].EmployeeWorkHours << endl
<< "Employee Pay Rate : " << theEmployee[foundIndex].PayRate << endl
<< "Employee Salary : " << theEmployee[foundIndex].totalSalary << endl << endl
<< "1. Change EmployeeID" << endl
<< "2. Change EmployeeName " << endl
<< "3. Change Department " << endl
<< "4. Change Date Of Birth" << endl
<< "5. Change Address " << endl
<< "6. Change Work Hours " << endl
<< "7. Change Pay Rate " << endl;
}
}
void deleteSpecificEmployeeRecord(Employee *theEmployee , int &size){
int choice = 0;
string SpecificEmployeeID = "";
bool found = 0;
int foundIndex = 0;
cin.ignore();
cout << "\tDelete Employee Record\n---------------------------------" << endl << endl
<< "Enter Employee ID : " ;
getline( cin , SpecificEmployeeID );
for( int i = 0 ; i < size ; i++ ){
if( theEmployee[i].EmployeeID == SpecificEmployeeID ){
found = true;
foundIndex = i;
}
}
if( found == true ){
cout << "\n\tRecord :\n---------------------" << endl
<< "Employee ID : " << theEmployee[foundIndex].EmployeeID << endl
<< "Employee Name : " << theEmployee[foundIndex].EmployeeName << endl
<< "Employee Department : " << theEmployee[foundIndex].EmployeeDepartment << endl
<< "Employee Date Of Birth : " << theEmployee[foundIndex].EmployeeDOB << endl
<< "Employee Address : " << theEmployee[foundIndex].EmployeeAddress << endl
<< "Employee Work Hours : " << theEmployee[foundIndex].EmployeeWorkHours << endl
<< "Employee Pay Rate : " << theEmployee[foundIndex].PayRate << endl
<< "Employee Salary : " << theEmployee[foundIndex].totalSalary << endl << endl;
}
cout << "1. Delete Record " << endl
<< "2. Cancel " << endl;
cin >> choice;
if( choice == 1){
}
else if( choice == 2 ){
}
}
|