-
Notifications
You must be signed in to change notification settings - Fork 0
/
clsUpdateClientScreen.h
115 lines (83 loc) · 3.1 KB
/
clsUpdateClientScreen.h
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
#pragma once
#include <iostream>
#include "clsScreen.h"
#include "clsPerson.h"
#include "clsBankClient.h"
#include "clsInputValidate.h"
class clsUpdateClientScreen :protected clsScreen
{
private:
static void _PrintClient(clsBankClient Client)
{
cout << "\nClient Card:";
cout << "\n___________________";
cout << "\nFirstName : " << Client.FirstName;
cout << "\nLastName : " << Client.LastName;
cout << "\nFull Name : " << Client.FullName();
cout << "\nEmail : " << Client.Email;
cout << "\nPhone : " << Client.Phone;
cout << "\nAcc. Number : " << Client.GetAccountNumber();
cout << "\nPassword : " << Client.PinCode;
cout << "\nBalance : " << Client.AccountBalance;
cout << "\n___________________\n";
}
static void ReadClientInfo(clsBankClient& Client)
{
cout << "\nEnter FirstName: ";
Client.FirstName = clsInputValidate::ReadString();
cout << "\nEnter LastName: ";
Client.LastName = clsInputValidate::ReadString();
cout << "\nEnter Email: ";
Client.Email = clsInputValidate::ReadString();
cout << "\nEnter Phone: ";
Client.Phone = clsInputValidate::ReadString();
cout << "\nEnter PinCode: ";
Client.PinCode = clsInputValidate::ReadString();
cout << "\nEnter Account Balance: ";
Client.AccountBalance = clsInputValidate::ReadFloatNumber("Error number , enter number again");
}
public:
static void ShowUpdateClientScreen()
{
if (!CheckAccessRights(clsUser::enPermissions::pUpdateClients))
{
return;// this will exit the function and it will not continue
}
_DrawScreenHeader("\tUpdate Client Screen");
string AccountNumber = "";
cout << "\nPlease Enter client Account Number: ";
AccountNumber = clsInputValidate::ReadString();
while (!clsBankClient::IsClientExist(AccountNumber))
{
cout << "\nAccount number is not found, choose another one: ";
AccountNumber = clsInputValidate::ReadString();
}
clsBankClient Client1 = clsBankClient::Find(AccountNumber);
_PrintClient(Client1);
cout << "\nAre you sure you want to update this client y/n? ";
char Answer = 'n';
cin >> Answer;
if (Answer == 'y' || Answer == 'Y')
{
cout << "\n\nUpdate Client Info:";
cout << "\n____________________\n";
ReadClientInfo(Client1);
clsBankClient::enSaveResults SaveResult;
SaveResult = Client1.Save();
switch (SaveResult)
{
case clsBankClient::enSaveResults::svSucceeded:
{
cout << "\nAccount Updated Successfully :-)\n";
_PrintClient(Client1);
break;
}
case clsBankClient::enSaveResults::svFaildEmptyObject:
{
cout << "\nError account was not saved because it's Empty";
break;
}
}
}
}
};