Browse Source

Fixes #7. Add nag to Delete button

Neal Wilson 6 years ago
parent
commit
b72918c0cf
Signed by: neal <neal@typica.us> GPG Key ID: D6F25C90DD5819DF
1 changed files with 14 additions and 11 deletions
  1. 14
    11
      config/Windows/editinventorytransaction.xml

+ 14
- 11
config/Windows/editinventorytransaction.xml View File

@@ -54,17 +54,20 @@
54 54
 				window.close();
55 55
 			});
56 56
 			deleteButton.clicked.connect(function() {
57
-				var query = new QSqlQuery();
58
-				query.prepare("DELETE FROM inventory WHERE item = :item AND time = :timestamp");
59
-				query.bind(":item", Number(itemField.text));
60
-				query.bind(":timestamp", timeField.text);
61
-				query.exec();
62
-				query.prepare("UPDATE items SET quantity = (SELECT balance FROM item_history(:item) ORDER BY time DESC LIMIT 1) WHERE id = :item2");
63
-				query.bind(":item", Number(itemField.text));
64
-				query.bind(":item2", Number(itemField.text));
65
-				query.exec();
66
-				query = query.invalidate();
67
-				window.close();
57
+				var proceed = displayWarning(TTR("editinventorytransaction", "Are you sure?"), TTR("editinventorytransaction", "Deleting this transaction can not be undone. Continue?"));
58
+				if(proceed) {
59
+					var query = new QSqlQuery();
60
+					query.prepare("DELETE FROM inventory WHERE item = :item AND time = :timestamp");
61
+					query.bind(":item", Number(itemField.text));
62
+					query.bind(":timestamp", timeField.text);
63
+					query.exec();
64
+					query.prepare("UPDATE items SET quantity = (SELECT balance FROM item_history(:item) ORDER BY time DESC LIMIT 1) WHERE id = :item2");
65
+					query.bind(":item", Number(itemField.text));
66
+					query.bind(":item2", Number(itemField.text));
67
+					query.exec();
68
+					query = query.invalidate();
69
+					window.close();
70
+				}
68 71
 			});
69 72
 		]]>
70 73
 	</program>

Loading…
Cancel
Save