-
Notifications
You must be signed in to change notification settings - Fork 0
/
darbaixa.cpp
67 lines (60 loc) · 1.7 KB
/
darbaixa.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
#include "darbaixa.h"
#include "ui_darbaixa.h"
darBaixa::darBaixa(QWidget *parent) :
QDialog(parent),
ui(new Ui::darBaixa)
{
ui->setupUi(this);
}
darBaixa::~darBaixa()
{
delete ui;
}
darBaixa::darBaixa(ImovelDB* db,QWidget *parent):
QDialog(parent),
ui(new Ui::darBaixa), db(db)
{
ui->setupUi(this);
QStringList list = db->getEnderecos();
QStringList list2 = (QStringList()<<"Aluguel"<<"IPTU");
ui->Imovel->addItems(list);
ui->typePayment->addItems(list2);
ui->mes->setRange(1,12);
}
void darBaixa::on_salvar_clicked()
{
QString endereco = ui->Imovel->currentText();
int n = db->search(endereco);
Imovel *im = db->busca(endereco);
QString caminho = db->getCaminho();
QString path = caminho + "/" + QString::number(n+1) + "/";
qDebug() << "path " << path;
QFile fileP(path + "payment.txt");
QFile fileI(path + "IPTU.txt");
if (!fileP.open(QIODevice::ReadOnly| QIODevice::WriteOnly | QIODevice::Text))
return;
if (!fileI.open(QIODevice::ReadOnly| QIODevice::WriteOnly | QIODevice::Text))
return;
QTextStream outP(&fileP);
QTextStream outI(&fileI);
if(ui->typePayment->currentText()=="Aluguel"){
vector<bool>pay(12);
while(!outP.atEnd())
pay.push_back((outP.readLine()=="true"?true:false));
int mes = ui->mes->value();
pay[mes-1] = true;
im->setPayment(pay);
outP.seek(0);
for(int i=0;i<12;i++)
outP << (pay[i]==true? "True": "False") << "\n";
}
else{
QString teste = outI.readLine();
outI.seek(0);
outI << "true" << "\n";
im->setIPTU(true);
}
fileP.close();
fileI.close();
close();
}