-
Notifications
You must be signed in to change notification settings - Fork 0
/
addhotelform.cpp
40 lines (36 loc) · 1.04 KB
/
addhotelform.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
#include "addhotelform.h"
#include "ui_addhotelform.h"
AddHotelForm::AddHotelForm(Queue<Hotel>*queue) :
queue(queue),
ui(new Ui::AddHotelForm)
{
ui->setupUi(this);
}
AddHotelForm::~AddHotelForm()
{
delete ui;
}
void AddHotelForm::on_pushButton_2_clicked()
{
string hotel = ui->lineEdit->text().toStdString();
for (int i = 0; i < queue->size(); i++) {
if (hotel == queue->operator[](i).getName()) {
QMessageBox::critical(nullptr, "Добавление отеля", "Такой отель уже существует!");
return;
}
}
Hotel newHotel(hotel, 0, 0);
hotel = hotel + ".txt";
ofstream on(hotel.c_str());
on.close();
queue->pushTail(newHotel);
Files::saveHotel(queue, "hotel.txt");
QMessageBox::information(nullptr, "Добавление отеля", "Отель успешно добавлен!");
this->close();
delete this;
}
void AddHotelForm::on_pushButton_clicked()
{
this->close();
delete this;
}