void writetickets()
{
string park1 = "Sign Sammoric/Tickets/";
park1 += to_string(dat.year()) + "/" + to_string(dat.month()) + "/" + to_string(dat.day());
if (!is_directory(park1.c_str()))
{
if (create_directories(park1.c_str()))
{
park1.append("/Tickets.dat");
ofstream file(park1.c_str(), ios::out | ios::app | ios::binary);
materials t1;
if (file.is_open())
{
auto r = material.begin();
for (r = material.begin();r != material.end();r++)
{
file.write(reinterpret_cast<char *>(&(*r).name1), sizeof((*r).name1));
file.write(reinterpret_cast<char *>(&(*r).ticketid), sizeof((*r).ticketid));
file.write(reinterpret_cast<char *>(&(*r).serial), sizeof((*r).serial));
file.write(reinterpret_cast<char *>(&(*r).date), sizeof((*r).date));
file.write(reinterpret_cast<char *>(&(*r).y), sizeof((*r).y));
file.write(reinterpret_cast<char *>(&(*r).check), sizeof((*r).check));
}
file.close();
}
}
}
else
{
park1 += "/Tickets.dat";
materials t1;
ofstream file(park1.c_str(), ios::out | ios::app | ios::binary);
if (file.is_open())
{
auto r = material.begin();
for (r = material.begin();r != material.end();r++)
{
file.write((char *)&r, sizeof(r));
}
file.close();
}
}
}
void addcache()
{
materials t1;
dat = QDate::currentDate();
strncpy(t1.name1, pickapark->currentText().toStdString().c_str(), 30);
strncpy(t1.ticketid, edit2->displayText().toStdString().c_str(), 10);
strncpy(t1.serial, edit1->displayText().toStdString().c_str(), 10);
l = dat.toString().toStdString();
strncpy(t1.date, l.c_str(), 15);
t1.y = day1->currentText().toInt();
t1.check = 1;
material.push_back(t1);
}
void viewtickets()
{
string par = "Sign Sammoric/Tickets/" + to_string(boyear->currentText().toInt()) + "/" + to_string(setmonth1(bomonth->currentText())) + "/" + to_string(boday->currentText().toInt());
if (is_directory(par.c_str()))
{
materials t1;
par.append("/Tickets.dat");
ifstream file;
if (!material.empty());
material.erase(material.begin(), material.end());
file.open(par.c_str(), ios::in | ios::binary);
if (file.is_open())
{
while (!file.fail())
{
file.read(reinterpret_cast<char *>(&t1.name1), sizeof(t1.name1));
file.read(reinterpret_cast<char *>(&t1.ticketid), sizeof(t1.ticketid));
file.read(reinterpret_cast<char *>(&t1.serial), sizeof(t1.serial));
file.read(reinterpret_cast<char *>(&t1.date), sizeof(t1.date));
file.read(reinterpret_cast<char *>(&t1.y), sizeof(t1.y));
file.read(reinterpret_cast<char *>(&t1.check), sizeof(t1.check));
material.push_back(t1);
}
}
file.close();
}
}