-
Notifications
You must be signed in to change notification settings - Fork 0
/
summarylogbybrand.cpp
57 lines (51 loc) · 1.75 KB
/
summarylogbybrand.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
#include "summarylogbybrand.h"
#include "ui_summarylogbybrand.h"
#include <QLineEdit>
#include <QSqlQuery>
SummaryLogByBrand::SummaryLogByBrand(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::SummaryLogByBrand)
{
ui->setupUi(this);
}
SummaryLogByBrand::~SummaryLogByBrand()
{
delete ui;
}
void SummaryLogByBrand::addTableWidgetRows(int counter, QString *arrayData)
{
ui->tableWidget->setRowCount(counter + 1);
for (int i = counter; i == counter; i++)
{
for (int j = 0; j < 6; j++)
{
QTableWidgetItem *pItem = new QTableWidgetItem();
pItem->setText(QString(arrayData[j]).arg(i).arg(j));
ui->tableWidget->setItem(i, j, pItem);
}
}
}
void SummaryLogByBrand::showSearchResult()
{
QSqlQuery queryGetDataTravelSheets;
queryGetDataTravelSheets.prepare("SELECT idMotorTransport, date, idRoute, "
"workedTime, mileage, spendFuel "
"FROM TravelSheet "
"WHERE date >= :dateFrom AND date <= :dateTo");
queryGetDataTravelSheets.bindValue(":dateFrom", ui->dateFrom->date());
queryGetDataTravelSheets.bindValue(":dateTo", ui->dateTo->date());
queryGetDataTravelSheets.exec();
QString arrayDataRegisterTravelSheets[6];
int counter = 0;
bool dateNoExist = true;
while(queryGetDataTravelSheets.next())
{
for (int i = 0; i < 6; i++)
arrayDataRegisterTravelSheets[i] = queryGetDataTravelSheets.value(i).toString();
this->addTableWidgetRows(counter, arrayDataRegisterTravelSheets);
counter++;
dateNoExist = false;
}
if (dateNoExist)
this->addTableWidgetRows(-1, arrayDataRegisterTravelSheets);
}