-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdialogaddbuy.cpp
More file actions
55 lines (45 loc) · 1.42 KB
/
Copy pathdialogaddbuy.cpp
File metadata and controls
55 lines (45 loc) · 1.42 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
#include "dialogaddbuy.h"
#include "ui_dialogaddbuy.h"
DialogAddBuy::DialogAddBuy(QSqlDatabase &db, QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogAddBuy)
{
ui->setupUi(this);
query = new QSqlQuery(db);
query->exec("SELECT First_name + ' ' + Middle_name + ' ' + Last_name, Phone_number FROM Client");
while(query->next())
{
ui->comboBox_client->addItem(query->value(0).toString(), query->value(1).toString());
}
query->clear();
query->exec("SELECT model + ' ' + Cast(Year_ as nvarchar(10)), ID FROM Car WHERE isSold is null");
while(query->next())
{
ui->comboBox_car->addItem(query->value(0).toString(), query->value(1).toInt());
}
}
DialogAddBuy::~DialogAddBuy()
{
delete ui;
delete query;
}
void DialogAddBuy::on_pushButton_add_clicked()
{
QString client = ui->comboBox_client->currentData().toString();
int car = ui->comboBox_car->currentData().toInt();
query->prepare("EXEC addBuy :c, :m");
query->bindValue(":c", client);
query->bindValue(":m", car);
if(query->exec())
{
qDebug() << "Покупка оформлена";
}
this->close();
ui->comboBox_car->clear();
query->clear();
query->exec("SELECT model + ' ' + Cast(Year_ as nvarchar(10)), ID FROM Car WHERE isSold is null");
while(query->next())
{
ui->comboBox_car->addItem(query->value(0).toString(), query->value(1).toInt());
}
}