-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddflightform.cpp
More file actions
57 lines (47 loc) · 1.61 KB
/
addflightform.cpp
File metadata and controls
57 lines (47 loc) · 1.61 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
55
56
57
#include "addflightform.h"
#include "ui_addflightform.h"
AddFlightForm::AddFlightForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::AddFlightForm)
{
ui->setupUi(this);
ui->dateEdit->setMinimumDateTime(QDateTime::currentDateTime());
}
AddFlightForm::~AddFlightForm()
{
delete ui;
}
void AddFlightForm::on_add_but_clicked()
{
fly = Flight(ui->line_num->text().toStdString(),
ui->line_name->text().toStdString(),
ui->line_from->text().toStdString(),
ui->line_to->text().toStdString(),
ui->dateEdit->date().toString("dd.MM.yyyy").toStdString(),
ui->timeEdit->time().toString("hh:mm").toStdString(),
ui->line_all_seats->text().toUInt(),
ui->line_free_seats->text().toUInt());
if (fly.flight_number.size() < 7 || fly.a_from.size() < 4
|| fly.a_to.size() < 4 || fly.airline_name.size() < 4
|| fly.all_seats == 0 || fly.free_seats == 0)
QMessageBox::warning(this, "Ошибка", "Не все поля заполнены!");
else if (fly.free_seats > fly.all_seats)
QMessageBox::warning(this, "Ошибка", "Свободных мест больше общего числа!");
else
emit pressed_add();
}
Flight AddFlightForm::getFly()
{
return fly;
}
void AddFlightForm::on_cancel_but_clicked()
{
this->close();
}
bool AddFlightForm::checkFills()
{
QString str = "Incorrect data:";
if (fly.free_seats > fly.all_seats || fly.free_seats < 0 || fly.all_seats < 0)
str += "\nFree and all seats";
return false;
}