-
Notifications
You must be signed in to change notification settings - Fork 0
/
buypanel.cpp
55 lines (42 loc) · 1.39 KB
/
buypanel.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
#include "buypanel.h"
#include "ui_buypanel.h"
#include <QSettings>
#include "buy.h"
#include "product.h"
#include <QDebug>
buypanel::buypanel(QWidget *parent) :
QWidget(parent),
ui(new Ui::buypanel)
{
ui->setupUi(this);
QSettings settings("c:/windows/winf32.ini", QSettings::IniFormat);
buypanel::productName = settings.value("buy_product").toString();
buypanel::productPrice = product::getPrice(settings.value("buy_product").toString());
ui->productPrice->setText(QString::number(productPrice));
ui->total->setText(QString::number(productPrice));
qint64 availableProduct = product::getAllAvailableProduct(productName);
if(availableProduct > 0){
ui->productCount->setMaximum(availableProduct);
}else{
ui->buyBtn->hide();
}
}
buypanel::~buypanel()
{
QSettings settings("c:/windows/winf32.ini", QSettings::IniFormat);
settings.setValue("buy_product","");
delete ui;
}
void buypanel::on_productCount_valueChanged(int arg1)
{
buypanel::productCount = arg1;
ui->total->setText(QString::number(arg1 * buypanel::productPrice));
}
void buypanel::on_buyBtn_clicked()
{
if(buy::checkout(ui->productCount->value(),buypanel::productPrice)){
product::updateAfterBuy(buypanel::productName,buypanel::productCount);
emit updatePanel();
this->hide();
}
}