-
Notifications
You must be signed in to change notification settings - Fork 0
/
leavewindow.cpp
80 lines (68 loc) · 2.16 KB
/
leavewindow.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
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "leavewindow.h"
#include "takewindow.h"
#include "parkwindow.h"
#include "mainwindow.h"
#include "ui_leavewindow.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
leaveWindow::leaveWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::leaveWindow)
{
ui->setupUi(this);
takeWindow *ptr = (takeWindow*)parentWidget();
//显示车位信息
ui->lcdfee->display(ptr->fee);
ui->lbcode->setText(ptr->code);
ui->lbnumer->setNum(ptr->number);
ui->lbintimehour->setNum(ptr->intimehour);
ui->lbintimemin->setNum(ptr->intimemin);
ui->lbouttimehour->setNum(ptr->outtimehour);
ui->lbouttimemin->setNum(ptr->outtimemin);
ui->lbtimelasthour->setNum(ptr->timelasthour);
ui->lbtimelastmin->setNum(ptr->timelastmin);
switch (ptr->bigsmall) {
case 0:ui->lbbigsmall->setText(QString::fromLocal8Bit("大型"));break;
default:ui->lbbigsmall->setText(QString::fromLocal8Bit("小型"));
}
}
leaveWindow::~leaveWindow()
{
delete ui;
}
void leaveWindow::on_pbtleave_clicked()
{
class spot carspot0[2000];
fstream inFile("spots.dat", ios::binary | ios::in); //以二进制读模式打开文件
if (!inFile) {
cout << "Source file open error." << endl;
}
else
{
while(inFile.read((char *)carspot0, sizeof(carspot0))); //一直读到文件结束
inFile.close();
}
takeWindow *ptr=(takeWindow*)parentWidget();
carspot0[ptr->number].status=0;//清空车位
fstream outFile("spots.dat", ios::out | ios::binary);
outFile.write((char*)carspot0, sizeof(carspot0));
outFile.close();
class parklot parklot0;
fstream inFile1("parklot.dat", ios::binary | ios::in); //以二进制读模式打开文件
if (!inFile1) {
cout << "Source file open error." << endl;
}
else
{
while(inFile1.read((char *)&parklot0, sizeof(parklot0))); //一直读到文件结束
inFile1.close();
}
parklot0.empty+=1;//空车位加一
fstream outFile1("parklot.dat", ios::out | ios::binary);
outFile1.write((char*)&parklot0, sizeof(parklot0));
outFile1.close();
emit sendData();
this->close();
}