-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEmployee Management System.cpp
More file actions
358 lines (333 loc) · 7.1 KB
/
Copy pathEmployee Management System.cpp
File metadata and controls
358 lines (333 loc) · 7.1 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
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
#include <iostream>
using namespace std;
class Employee
{
private:
string Full_Name ;
string Email ;
string Phone;
string Position ;
double Salary ;
public:
Employee()
{
}
//// constructor take all variable as parameters
Employee(string fn, string e , string ph , string p , double s)
{
Full_Name = fn;
Email=e;
Phone=ph;
Position=p;
Salary=s;
}
//// set Full_Name
void setFullname(string n)
{
Full_Name=n;
}
//// get Full_Name
string getFullname()
{
return Full_Name;
}
//// set Email
void setEmail(string e)
{
Email=e;
}
//// get Email
string getEmail()
{
return Email;
}
//// set phone
void setphone(string ph)
{
Phone=ph;
}
//// get Phone
string getPhone()
{
return Phone;
}
//// set Position
void setPosition(string p)
{
Position=p;
}
//// get Position
string getPosition()
{
return Position;
}
//// set salary
void setsalary(double s)
{
Salary=s;
}
//// get salary
double getSalary()
{
return Salary;
}
};
//////////////////////////////////////
template <class T>
class Node{
public:
T data;
Node<T>* next;
Node(T e){
data = e;
next = NULL;
}
};
///////////////////////////////////////
template <class T>
class EmployeeList{
Node<T>* head;
public:
EmployeeList()
{
head = NULL;
}
//// insert function
bool insert_employee(T e){
Node<T>* newNode = new Node<T>(e);
Node<T>* temp=head;
if (head==NULL)
{
head=newNode;
return true ;
}
while(temp!=NULL)
{
if (temp->data.getEmail()==e.getEmail())
{
return false;
}
temp=temp->next;
}
temp=head;
while(temp->next!=NULL)
{
temp=temp->next;
}
temp->next=new Node<T>(e);
return true ;
}
//// display function
int display_employee_info()
{
Node<T>* temp=head;
while(temp!=NULL)
{
cout << "Full name: " << temp->data.getFullname() << endl;
cout << "Email: " << temp->data.getEmail() << endl;
cout << "Phone: " << temp->data.getPhone() << endl;
cout << "Position: " << temp->data.getPosition() << endl;
cout << "Salary: " << temp->data.getSalary() << endl;
temp=temp->next;
}
char click;
cout<<" to get back to menu click 0 : \n" ;
getchar();
click=getchar();
switch(click)
{
case '0':
{
return 1;
}
return 1 ;
}
}
//// edit salary function
bool edit_salary( string email,double new_salary )
{
if (head == NULL)
{
cout<<"list is empty"<<endl;
return false;
}
else{
Node<T>* temp = head;
while(temp != NULL)
{
if (temp->data.getEmail() == email)
{
temp->data.setsalary(new_salary) ;
return true;
}
temp = temp->next;
}
return false;
}
}
//// delete function
bool delet_Employy(string email)
{
Node<T>* temp = head;
Node<T>* temp2 = head;
while(temp!=NULL)
{
if(temp->data.getEmail()== email)
{
if(temp=head)
{
head=head->next;
delete temp;
}
else
{
temp2->next=temp->next;
}
cout<< "Employee with email "<<email<<" has ramoved"<<endl;
break;
}
temp2=temp;
temp=temp->next;
}
cout<<"your email dose not exist";
cout<<"\n";
return true;
}
};
////////////////////////////////////////////////s
int main();
EmployeeList<Employee> L;
//// edit function 2
void edit_salary2(){
double s2;
string email2;
cout<<"enter employee email : ";
cin>>email2;
cout<<"enter new salary : ";
cin>>s2;
L.edit_salary(email2 , s2);
char click;
cout<<" to print new info click 1 to get back to menu click 2 : \n" ;
getchar();
click=getchar();
switch(click)
{
case '1':
{
if( L.display_employee_info())
{
main();
}
break;
}
case '2':
{
main();
}
}
}
//// insert function 2
int main();
void insert2(){
string Full_Name2 ;
string Email3 ;
string Phone2;
string Position2 ;
double Salary2 ;
cout<<"enter the employee name : ";
cin>>Full_Name2;
cout<<"enter the employee mail : ";
cin>>Email3;
cout<<"enter the employee Number : ";
cin>>Phone2;
cout<<"enter the employee Position : ";
cin>>Position2;
cout<<"enter the employee salary : ";
cin>>Salary2;
Employee E1(Full_Name2,Email3,Phone2,Position2,Salary2);
L.insert_employee(E1);
char click;
cout<<" to enter the another employee click 1 to get back to menu click 2 : \n" ;
getchar();
click=getchar();
switch(click)
{
case '1':
{
insert2();
break;
}
case '2':
{
main();
break;
}
}
}
////delete function 2
void delete2(){
string del_email;
cout<<"enter your email want to delete : ";
cin>>del_email ;
L.delet_Employy(del_email);
char click;
cout<<" to enter the another employee click 1 to get back to menu click 2 : \n" ;
getchar();
click=getchar();
switch(click)
{
case '1':
{
insert2();
break;
}
case '2':
{
main();
break;
}
}
}
int main() {
fflush(stdin);
cout<<"Welcome to the Employee Management System"<<endl;
cout<<"Choose of the following to use the system features"<<endl;
cout<<"1. Insert a new Employee"<<endl;
cout<<"2. Edit employee's salary"<<endl;
cout<<"3. Delete an employee"<<endl;
cout<<"4. Print all employees"<<endl;
cout<<"5. Close the program"<<endl;
char click;
click=getchar();
switch(click)
{
case '1':
{
insert2();
break;
}
case '2':
{
edit_salary2();
break;
}
case '3':
{
delete2();
break;
}
case '4':
{
if(L.display_employee_info())
{
main();
}
break;
}
case '5':
{
break;
}
}
return 0;
}