-
Notifications
You must be signed in to change notification settings - Fork 1
/
invoiceviewer.cpp
45 lines (35 loc) · 949 Bytes
/
invoiceviewer.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
#include "invoiceviewer.h"
#include "ui_invoiceviewer.h"
#include "mainwindow.h"
#include <iostream>
int orderID;
QWidget *pic;
invoiceViewer::invoiceViewer(QWidget *parent) :
QDialog(parent),
ui(new Ui::invoiceViewer)
{
ui->setupUi(this);
pic = new QWidget(this);
}
invoiceViewer::~invoiceViewer()
{
delete ui;
}
void invoiceViewer::setOrderID(int id){
orderID = id;
viewInvoice();
}
void invoiceViewer::viewInvoice(){
QSqlQuery qry(QSqlDatabase::database("MyConnect"));
qry.prepare("SELECT invoice FROM Orders WHERE orderid = :orderid");
qry.bindValue(":orderid", orderID);
if(!qry.exec()){
qDebug()<<"Error getting invoice from database!";
}
qry.first();
QByteArray outByteArray = qry.value(0).toByteArray();
QPixmap outPixmap = QPixmap();
outPixmap.loadFromData(outByteArray);
ui->invoiceImageLabel->setPixmap(outPixmap);
ui->invoiceImageLabel->show();
}