-
Notifications
You must be signed in to change notification settings - Fork 1
/
dobloodtestwindow.cpp
69 lines (60 loc) · 1.81 KB
/
dobloodtestwindow.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
#include "dobloodtestwindow.h"
#include "ui_dobloodtestwindow.h"
doBloodTestWindow::doBloodTestWindow(QWidget *parent) : QDialog(parent),
ui(new Ui::doBloodTestWindow)
{
ui->setupUi(this);
this->p = new Patient;
}
doBloodTestWindow::~doBloodTestWindow()
{
delete ui;
}
void doBloodTestWindow::on_submitSampleButton_clicked()
{
if (this->p->getLoggedIn() == false)
{
QMessageBox::about(this, "Error", "Please log in first");
}
else
{
if (this->p->getBalance() < 200)
{
ui->resultDisplay->setText("Result: Failed! Insufficient balance.");
return;
}
srand(time(NULL));
int x = rand() % 30 + 70;
this->p->setBalance(this->p->getBalance() - 200 + this->p->getPoints()); // Accumulative non-decreasing points system
this->p->setPoints(this->p->getPoints() + 5);
ui->resultDisplay->setText("Result: %" + QString::number(x) + " Healthy.");
ui->discountDisplay->setText("$" + QString::number(this->p->getPoints()));
ui->currentBalanceDisplay->setText("$" + QString::number(this->p->getBalance()));
}
}
void doBloodTestWindow::on_checkDiscountButton_clicked()
{
if (this->p->getLoggedIn() == false)
{
QMessageBox::about(this, "Error", "Please log in first");
}
else
{
ui->discountDisplay->setText("$" + QString::number(this->p->getPoints()));
}
}
void doBloodTestWindow::on_showCurrentButton_clicked()
{
if (this->p->getLoggedIn() == false)
{
QMessageBox::about(this, "Error", "Please log in first");
}
else
{
ui->currentBalanceDisplay->setText("$" + QString::number(this->p->getBalance()));
}
}
void doBloodTestWindow::on_backButton_clicked()
{
this->close();
}