Repository navigation
Expand file tree
/
Copy pathEmployee.cpp
More file actions
128 lines (116 loc) · 5.26 KB
/
Copy pathEmployee.cpp
File metadata and controls
128 lines (116 loc) · 5.26 KB
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
#include <iostream>
#include "ScreenTheme.h"
#include "Screens.h"
#include "Employee.h"
#include "Validation.h"
#include <iomanip>
using namespace std;
Employee::Employee() {
this->salary = 0.0;
}
Employee::Employee(string id, string first_name, string second_name, string password, string phone_number, string national_id, double salary) :
Person(id,first_name,second_name,password,phone_number,national_id)
{
this->set_salary(salary);
}
bool Employee::set_salary(double salary) {
while (!Validation::isValidSalary(salary)){
string sal;
system("cls");
Screens::header_screen();
ScreenTheme::color_style(11);
cout << "\n\t\t\t\t\t\t\t\t\t $#$#$# ";
ScreenTheme::color_style(7);
cout << "Edite Invalid Salary";
ScreenTheme::color_style(11);
cout << " #$#$#$" << endl;
ScreenTheme::color_style(7);
cout << "\n\n";
cout << "\t\t\t\t\t\t\t\t\t\t To Cancel Press '";
ScreenTheme::color_style(12);
cout << "ESC";
ScreenTheme::color_style(7);
cout << "'" << endl;
ScreenTheme::color_style(7);
cout << "\n\n";
ScreenTheme::color_style(12);
cout << "\t\t\t\t\t\t\t\t\t Error! Invalid Salary :( " << endl;
cout << "\t\t\t\t\t\t\t\t\t Do you need to set Salary more than 5000." << endl;
ScreenTheme::color_style(7);
cout << "\t\t\t\t\t\t\t\t\t Please Enter Salary Again : ";
sal = ScreenTheme::take_num_input(7);
if (sal == "!x!"){
return false;
}
salary = stod(sal);
}
this->salary = salary;
return true;
}
double Employee::get_salary() {
return this->salary;
}
void Employee::display() {
cout << "\t\t\t\t\t\t*******************************************************************************************" <<endl;
cout << "\t\t\t\t\t\t*";
ScreenTheme::color_style(90);
cout << " ID Name Phone Number Salary ";
ScreenTheme::color_style(7);
cout << "*" << endl;
cout << "\t\t\t\t\t\t*******************************************************************************************" <<endl;
cout << "\t\t\t\t\t\t* " << left << setw(16) << this->get_id() << left << setw(25) << this->get_name() << left << setw(28) << this->get_phone_number() << left << setw(15) << this->get_salary() << "*" << endl;
cout << "\t\t\t\t\t\t*******************************************************************************************" <<endl;
}
void Employee::add_client(Client &client) {
f.add_client(client);
}
Client *Employee::search_client(int id) {
return f.search_client(id);
}
void Employee::list_client() {
vector<Client> c = f.get_all_clients();
cout << "\t\t\t\t\t\t\t\t\t*******************************************************************************************" <<endl;
cout << "\t\t\t\t\t\t\t\t\t*";
ScreenTheme::color_style(90);
cout << " ID Name Phone Number Balance ";
ScreenTheme::color_style(7);
cout << "*" << endl;
cout << "\t\t\t\t\t\t\t\t\t*******************************************************************************************" <<endl;
for(Client &C : c){
cout << "\t\t\t\t\t\t\t\t\t* " << left << setw(16) << C.get_id() << left << setw(25) << C.get_name() << left << setw(28) << C.get_phone_number() << left << setw(15) << C.get_balance() << "*" << endl;
}
cout << "\t\t\t\t\t\t\t\t\t*******************************************************************************************" <<endl;
}
void Employee::edit_client(int id, string first_name, string second_name, string password,string phone_number) {
vector<Client> c = f.get_all_clients();
f.remove_all_clients();
for(Client &C : c){
if (C.get_id() == to_string(id)){
C.set_name(first_name + " " + second_name);
C.set_password(password);
C.set_phone_number(phone_number);
}
f.add_client(C, false);
}
}
void Employee::display_with_national_id() {
cout << "\t\t\t\t\t ***********************************************************************************************************" <<endl;
cout << "\t\t\t\t\t *";
ScreenTheme::color_style(90);
cout << " ID Name Phone Number National ID Salary ";
ScreenTheme::color_style(7);
cout << "*" << endl;
cout << "\t\t\t\t\t ***********************************************************************************************************" <<endl;
cout << "\t\t\t\t\t * " << left << setw(16) << this->get_id() << left << setw(25) << this->get_name() << left << setw(21) << this->get_phone_number() << left << setw(24) << this->get_national_id() << left << setw(14) << this->get_salary() << "*" << endl;
cout << "\t\t\t\t\t ***********************************************************************************************************" <<endl;
}
void Employee::edit_password_in_file() {
vector<Employee> e = f.get_all_employees();
f.remove_all_employees();
for(Employee &E : e){
if (E.get_id() == this->id){
E.set_password(this->password);
}
f.add_employee(E, false);
}
}