# HG changeset patch # User Michiel Broek # Date 1674572233 -3600 # Node ID 0d7441b39d41e9cd306e00f2d40aac44e29a4e2d # Parent db8ad1c2112b8275affd220dfc12cbd7f3941319 Delete images from a producti first[C when a product is deleted. diff -r db8ad1c2112b -r 0d7441b39d41 src/EditProduct.cpp --- a/src/EditProduct.cpp Mon Jan 23 17:23:10 2023 +0100 +++ b/src/EditProduct.cpp Tue Jan 24 15:57:13 2023 +0100 @@ -912,6 +912,19 @@ if (rc == QMessageBox::No) return; + /* + * First delete any pictures for this product. + */ + QSqlQuery query; + query.prepare("DELETE FROM products_pics WHERE uuid=:uuid"); + query.bindValue(":uuid", product->uuid); + query.exec(); + if (query.lastError().isValid()) { + qWarning() << "on_deleteButton_clicked()" << query.lastError(); + QMessageBox::warning(this, tr("Database error"), tr("MySQL error: %1\n%2\n%3") + .arg(query.lastError().nativeErrorCode()).arg(query.lastError().driverText()).arg(query.lastError().databaseText())); + } + DB_product::dele(this, this->recno); this->close(); diff -r db8ad1c2112b -r 0d7441b39d41 translations/bmsapp_en.ts --- a/translations/bmsapp_en.ts Mon Jan 23 17:23:10 2023 +0100 +++ b/translations/bmsapp_en.ts Tue Jan 24 15:57:13 2023 +0100 @@ -4202,12 +4202,12 @@ - + Product changed - + The product has been modified. Save changes? @@ -4332,7 +4332,7 @@ - + Delete %1 @@ -4980,6 +4980,9 @@ + + + @@ -5254,52 +5257,73 @@ - + Open File - + Cannot load %1: %2 - + Image here - + Image type: - + Image comment: - + The comment for this image. - + Delete image + + Files (*.png) + + + + + No PNG file selected. + + + + + Saved %1 + + + - - + + + + + Database error - - + + + + + MySQL error: %1 %2 %3 diff -r db8ad1c2112b -r 0d7441b39d41 translations/bmsapp_nl.ts --- a/translations/bmsapp_nl.ts Mon Jan 23 17:23:10 2023 +0100 +++ b/translations/bmsapp_nl.ts Tue Jan 24 15:57:13 2023 +0100 @@ -4640,8 +4640,11 @@ - - + + + + + Database error Database fout @@ -4685,8 +4688,11 @@ - - + + + + + MySQL error: %1 %2 %3 @@ -4700,12 +4706,12 @@ Verwijder product - + Product changed Product gewijzigd - + The product has been modified. Save changes? Het product is gewijzigd. Wijzigingen opslaan? @@ -4842,7 +4848,7 @@ - + Delete %1 Verwijder %1 @@ -5483,6 +5489,9 @@ + + + @@ -5860,41 +5869,56 @@ Bevestig dat het proeven gedaan is en opmerkingen ingevuld zijn. - + Open File Open bestand - + Cannot load %1: %2 Kan niet laden %1: %2 - + Image here Plaatje hier - + Image type: Soort plaatje: - + Image comment: Bijschrift: - + The comment for this image. Het bijschrift of commentaar bij dit plaatje. - + Delete image Wis plaatje + + + Files (*.png) + + + + + No PNG file selected. + + + + + Saved %1 + + EditProfileFerment