-
Notifications
You must be signed in to change notification settings - Fork 1
/
rechargebalancewindow.cpp
87 lines (72 loc) · 2.52 KB
/
rechargebalancewindow.cpp
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
#include "rechargebalancewindow.h"
#include "ui_rechargebalancewindow.h"
rechargeBalanceWindow::rechargeBalanceWindow(QWidget *parent) : QDialog(parent),
ui(new Ui::rechargeBalanceWindow)
{
ui->setupUi(this);
this->p = new Patient;
}
rechargeBalanceWindow::~rechargeBalanceWindow()
{
delete ui;
}
void rechargeBalanceWindow::on_backButton_clicked()
{
this->close();
}
void rechargeBalanceWindow::on_depositButton_clicked()
{
if (ui->amountDisplay->text() == "")
{
ui->balanceStatusDisplay->setText("Balance Status: Please enter an amount.");
return;
}
QString abc = "abcdefghijklmnopqrstuvwxyz~!@#$%^&*()-_=+";
QString qs = ui->amountDisplay->text();
for (int i = 0; i < qs.length(); i++)
{
for (int j = 0; j < abc.length(); j++)
{
if (abc[j] == qs[i])
{
ui->balanceStatusDisplay->setText("Please enter only numbers.");
ui->amountDisplay->setText("");
return;
}
}
}
this->p->setBalance(this->p->getBalance() + ui->amountDisplay->text().toDouble());
ui->currentBalanceDisplay->setText("$" + QString::number(this->p->getBalance()));
ui->balanceStatusDisplay->setText("Balance Status: $" + ui->amountDisplay->text() + " deposited successfully!");
ui->amountDisplay->setText("");
}
void rechargeBalanceWindow::on_withdrawButton_clicked()
{
if (ui->amountDisplay->text() == "")
{
ui->balanceStatusDisplay->setText("Balance Status: Please enter an amount.");
return;
}
QString abc = "abcdefghijklmnopqrstuvwxyz~!@#$%^&*()-_=+";
QString qs = ui->amountDisplay->text();
for (int i = 0; i < qs.length(); i++)
{
for (int j = 0; j < abc.length(); j++)
{
if (abc[j] == qs[i])
{
ui->balanceStatusDisplay->setText("Please enter only numbers.");
ui->amountDisplay->setText("");
return;
}
}
}
this->p->setBalance(this->p->getBalance() - ui->amountDisplay->text().toDouble());
ui->currentBalanceDisplay->setText("$" + QString::number(this->p->getBalance()));
ui->balanceStatusDisplay->setText("Balance Status: $" + ui->amountDisplay->text() + " withdrawn successfully!");
ui->amountDisplay->setText("");
}
void rechargeBalanceWindow::on_showCurrentButton_clicked()
{
ui->currentBalanceDisplay->setText("$" + QString::number(this->p->getBalance()));
}