src/EditProductTab13.cpp

changeset 466
68ef2cc3e8d2
parent 465
8fc909360552
child 467
c5f6f3f1b714
equal deleted inserted replaced
465:8fc909360552 466:68ef2cc3e8d2
126 if (dialog->result() == QDialog::Rejected) { 126 if (dialog->result() == QDialog::Rejected) {
127 return; 127 return;
128 } 128 }
129 disconnect(buttonBox, nullptr, nullptr, nullptr); 129 disconnect(buttonBox, nullptr, nullptr, nullptr);
130 130
131 query.prepare("INSERT INTO products_pics SET uuid=:uuid, pic_type=:pic_type, pic_data=:pic_data, pic_comment=:pic_comment"); 131 QFileInfo fi(fileName);
132 query.prepare("INSERT INTO products_pics SET uuid=:uuid, pic_type=:pic_type, pic_data=:pic_data, "
133 "pic_comment=:pic_comment, filename=:filename, timestamp=:timestamp");
132 query.bindValue(":uuid", product->uuid); 134 query.bindValue(":uuid", product->uuid);
133 query.bindValue(":pic_type", g_prod_pic_types[typeEdit->currentIndex()]); 135 query.bindValue(":pic_type", g_prod_pic_types[typeEdit->currentIndex()]);
134 query.bindValue(":pic_data", imageByteArray); 136 query.bindValue(":pic_data", imageByteArray);
135 query.bindValue(":pic_comment", commentEdit->text()); 137 query.bindValue(":pic_comment", commentEdit->text());
138 query.bindValue(":filename", fi.fileName());
139 query.bindValue(":timestamp", fi.lastModified());
136 140
137 query.exec(); 141 query.exec();
138 if (query.lastError().isValid()) { 142 if (query.lastError().isValid()) {
139 qWarning() << "addImage_clicked()" << query.lastError(); 143 qWarning() << "addImage_clicked()" << query.lastError();
140 QMessageBox::warning(this, tr("Database error"), tr("MySQL error: %1\n%2\n%3") 144 QMessageBox::warning(this, tr("Database error"), tr("MySQL error: %1\n%2\n%3")

mercurial