Browse Source

Add column names to database INSERTs

Neal Wilson 10 years ago
parent
commit
d352f33c3f

+ 4
- 4
config/Windows/newbatch.xml View File

324
 				checkQuery.exec("SELECT 1 FROM machine WHERE id = " + selectedRoasterID);
324
 				checkQuery.exec("SELECT 1 FROM machine WHERE id = " + selectedRoasterID);
325
 				if(!checkQuery.next())
325
 				if(!checkQuery.next())
326
 				{
326
 				{
327
-					checkQuery.prepare("INSERT INTO machine VALUES(:id, :name)");
327
+					checkQuery.prepare("INSERT INTO machine (id, name) VALUES(:id, :name)");
328
 					checkQuery.bind(":id", selectedRoasterID);
328
 					checkQuery.bind(":id", selectedRoasterID);
329
 					checkQuery.bind(":name", selectedRoasterName);
329
 					checkQuery.bind(":name", selectedRoasterName);
330
 					checkQuery.exec();
330
 					checkQuery.exec();
331
 				}
331
 				}
332
 				checkQuery = checkQuery.invalidate();
332
 				checkQuery = checkQuery.invalidate();
333
-				var q = "INSERT INTO files VALUES(default, :name, 'profile', NULL, :data) RETURNING id";
333
+				var q = "INSERT INTO files (id, name, type, note, file) VALUES(default, :name, 'profile', NULL, :data) RETURNING id";
334
 				query = new QSqlQuery();
334
 				query = new QSqlQuery();
335
 				query.prepare(q);
335
 				query.prepare(q);
336
 				query.bind(":name", timefield.text + " " + roasted.currentText);
336
 				query.bind(":name", timefield.text + " " + roasted.currentText);
340
 				var fileno = query.value(0);
340
 				var fileno = query.value(0);
341
 				var file = new QFile(batch.tempData);
341
 				var file = new QFile(batch.tempData);
342
 				file.remove();
342
 				file.remove();
343
-				var q2 = "INSERT INTO roasting_log VALUES(:time, ";
343
+				var q2 = "INSERT INTO roasting_log (time, unroasted_id, unroasted_quantity, unroasted_total_quantity, roasted_id, roasted_quantity, transaction_type, annotation, machine, duration, approval, humidity, barometric, indoor_air, outdoor_air, files) VALUES(:time, ";
344
 				q2 = q2 + table.columnArray(0, 32);
344
 				q2 = q2 + table.columnArray(0, 32);
345
 				q2 = q2 + ", ";
345
 				q2 = q2 + ", ";
346
 				for(var i = 0; table.data(i, 1, 0).value != ""; i++)
346
 				for(var i = 0; table.data(i, 1, 0).value != ""; i++)
368
 				query2.exec();
368
 				query2.exec();
369
                 query2 = query2.invalidate();
369
                 query2 = query2.invalidate();
370
 				if(target.checked) {
370
 				if(target.checked) {
371
-					var q3 = "INSERT INTO item_files VALUES(:time, :item, '{";
371
+					var q3 = "INSERT INTO item_files (time, item, files) VALUES(:time, :item, '{";
372
 					q3 = q3 + fileno;
372
 					q3 = q3 + fileno;
373
 					q3 = q3 + "}')";
373
 					q3 = q3 + "}')";
374
 					query.prepare(q3);
374
 					query.prepare(q3);

+ 1
- 1
config/Windows/newroaster.xml View File

17
 			var rnumber = findChildObject(this, 'id');
17
 			var rnumber = findChildObject(this, 'id');
18
 			var nrwindow = this;
18
 			var nrwindow = this;
19
 			button.clicked.connect(function() {
19
 			button.clicked.connect(function() {
20
-				var q = "INSERT INTO machine VALUES (";
20
+				var q = "INSERT INTO machine (id, name) VALUES (";
21
 				q = q + rnumber.text;
21
 				q = q + rnumber.text;
22
 				q = q + ", :name)";
22
 				q = q + ", :name)";
23
 				query = new QSqlQuery();
23
 				query = new QSqlQuery();

+ 6
- 6
config/Windows/newsamplebatch.xml View File

252
 			var target = findChildObject(this, 'target');
252
 			var target = findChildObject(this, 'target');
253
 			submit.clicked.connect(function() {
253
 			submit.clicked.connect(function() {
254
 				query = new QSqlQuery();
254
 				query = new QSqlQuery();
255
-				query.prepare("INSERT INTO files VALUES(DEFAULT, :name, 'profile', NULL, :data) RETURNING id");
255
+				query.prepare("INSERT INTO files (id, name, type, note, file) VALUES(DEFAULT, :name, 'profile', NULL, :data) RETURNING id");
256
 				query.bind(":name", timefield.text + " " + name.text + " " + profileName.currentText);
256
 				query.bind(":name", timefield.text + " " + name.text + " " + profileName.currentText);
257
 				query.bindFileData(":data", batch.tempData);
257
 				query.bindFileData(":data", batch.tempData);
258
 				query.exec();
258
 				query.exec();
262
 				file.remove();
262
 				file.remove();
263
 				if(target.checked)
263
 				if(target.checked)
264
 				{
264
 				{
265
-					query.prepare("INSERT INTO sample_roast_profiles VALUES(:time, :name, :file)");
265
+					query.prepare("INSERT INTO sample_roast_profiles (time, profile_name, file) VALUES(:time, :name, :file)");
266
 					query.bind(":time", timefield.text);
266
 					query.bind(":time", timefield.text);
267
 					query.bind(":name", profileName.currentText);
267
 					query.bind(":name", profileName.currentText);
268
 					query.bind(":file", Number(fileno));
268
 					query.bind(":file", Number(fileno));
293
 					}
293
 					}
294
 					else
294
 					else
295
 					{
295
 					{
296
-						query.prepare("INSERT INTO item_attributes VALUES(DEFAULT, :name) RETURNING id");
296
+						query.prepare("INSERT INTO item_attributes (id, name) VALUES(DEFAULT, :name) RETURNING id");
297
 						query.bind(":name", attname);
297
 						query.bind(":name", attname);
298
 						query.exec();
298
 						query.exec();
299
 						query.next();
299
 						query.next();
300
 						attributes.setData(i, 0, query.value(0), 32);
300
 						attributes.setData(i, 0, query.value(0), 32);
301
 					}
301
 					}
302
 				}
302
 				}
303
-				query.prepare("INSERT INTO coffee_sample_items VALUES(DEFAULT, :name, NULL, 'lb', 0, 'Coffee: Green Sample', :arrival, :vendor, :attrids, :attrvals, NULL) RETURNING id");
303
+				query.prepare("INSERT INTO coffee_sample_items (id, name, reference, unit, quantity, category, arrival, vendor, attribute_ids, attribute_values) VALUES(DEFAULT, :name, NULL, 'lb', 0, 'Coffee: Green Sample', :arrival, :vendor, :attrids, :attrvals) RETURNING id");
304
 				query.bind(":name", name.text);
304
 				query.bind(":name", name.text);
305
 				query.bind(":arrival", arrival.date);
305
 				query.bind(":arrival", arrival.date);
306
 				query.bind(":vendor", vendor.text);
306
 				query.bind(":vendor", vendor.text);
309
 				query.exec();
309
 				query.exec();
310
 				query.next();
310
 				query.next();
311
 				var greenId = query.value(0);
311
 				var greenId = query.value(0);
312
-				query.prepare("INSERT INTO items VALUES(DEFAULT, :name, NULL, 'lb', 0, 'Coffee: Roasted Sample') RETURNING id");
312
+				query.prepare("INSERT INTO items (id, name, reference, unit, quantity, category) VALUES(DEFAULT, :name, NULL, 'lb', 0, 'Coffee: Roasted Sample') RETURNING id");
313
 				query.bind(":name", name.text + " " + profileName.currentText);
313
 				query.bind(":name", name.text + " " + profileName.currentText);
314
 				query.exec();
314
 				query.exec();
315
 				query.next();
315
 				query.next();
316
 				var roastedId = query.value(0);
316
 				var roastedId = query.value(0);
317
-				query.prepare("INSERT INTO roasting_log VALUES(:time, :unroastedids, NULL, :green, :roastedid, :roasted, 'SAMPLEROAST', :note, :machine, :duration, TRUE, NULL, NULL, NULL, NULL, :files)");
317
+				query.prepare("INSERT INTO roasting_log (time, unroasted_id, unroasted_quantity, unroasted_total_quantity, roasted_id, roasted_quantity, transaction_type, annotation, machine, duration, approval, humidity, barometric, indoor_air, outdoor_air, files) VALUES(:time, :unroastedids, NULL, :green, :roastedid, :roasted, 'SAMPLEROAST', :note, :machine, :duration, TRUE, NULL, NULL, NULL, NULL, :files)");
318
 				query.bind(":time", timefield.text);
318
 				query.bind(":time", timefield.text);
319
 				query.bind(":unroastedids", "{" + greenId + "}");
319
 				query.bind(":unroastedids", "{" + greenId + "}");
320
 				query.bind(":green", convertToPounds(parseFloat(green.text), GunitBox.currentText));
320
 				query.bind(":green", convertToPounds(parseFloat(green.text), GunitBox.currentText));

+ 1
- 1
config/Windows/optime.xml View File

63
 			});
63
 			});
64
 			submitbutton.clicked.connect(function() {
64
 			submitbutton.clicked.connect(function() {
65
 				query = new QSqlQuery();
65
 				query = new QSqlQuery();
66
-				var q = "INSERT INTO operational_time VALUES (:machine, :start, :stop, :duration)";
66
+				var q = "INSERT INTO operational_time (machine, start_time, end_time, duration) VALUES (:machine, :start, :stop, :duration)";
67
 				query.prepare(q);
67
 				query.prepare(q);
68
 				query.bind(":machine", machine.currentData());
68
 				query.bind(":machine", machine.currentData());
69
 				query.bind(":start", startline.text);
69
 				query.bind(":start", startline.text);

+ 1
- 1
config/Windows/profilehistory.xml View File

51
 		var currentProfileID;
51
 		var currentProfileID;
52
 		setCurrent.clicked.connect(function() {
52
 		setCurrent.clicked.connect(function() {
53
 			var query = new QSqlQuery();
53
 			var query = new QSqlQuery();
54
-			query.prepare("INSERT INTO item_files VALUES('now', :coffee, :profile)");
54
+			query.prepare("INSERT INTO item_files (time, item, files) VALUES('now', :coffee, :profile)");
55
 			query.bind(":coffee", coffeelist.currentData());
55
 			query.bind(":coffee", coffeelist.currentData());
56
 			query.bind(":profile", "{" + currentProfileID + "}");
56
 			query.bind(":profile", "{" + currentProfileID + "}");
57
 			query.exec();
57
 			query.exec();

+ 8
- 8
config/Windows/purchase.xml View File

203
             var dateField = findChildObject(this, 'date');
203
             var dateField = findChildObject(this, 'date');
204
             submitButton.clicked.connect(function() {
204
             submitButton.clicked.connect(function() {
205
                 var query = new QSqlQuery;
205
                 var query = new QSqlQuery;
206
-                var q = "INSERT INTO invoices VALUES (default, :invoice, :vendor, :date) RETURNING id";
206
+                var q = "INSERT INTO invoices (id, invoice, vendor, time) VALUES (default, :invoice, :vendor, :date) RETURNING id";
207
                 query.prepare(q);
207
                 query.prepare(q);
208
                 query.bind(":invoice", invoiceField.text);
208
                 query.bind(":invoice", invoiceField.text);
209
                 query.bind(":vendor", vendorField.currentText);
209
                 query.bind(":vendor", vendorField.currentText);
246
                     }
246
                     }
247
                     if(decafSelection.checked)
247
                     if(decafSelection.checked)
248
                     {
248
                     {
249
-                        q = "INSERT INTO decaf_coffees VALUES (default, :name, :reference, :unit, 0, 'Coffee: Unroasted', :origin, :region, :producer, :grade, :milling, :drying, :decafMethod) RETURNING id";
249
+                        q = "INSERT INTO decaf_coffees (id, name, reference, unit, quantity, category, origin, region, producer, grade, milling, drying, decaf_method) VALUES (default, :name, :reference, :unit, 0, 'Coffee: Unroasted', :origin, :region, :producer, :grade, :milling, :drying, :decafMethod) RETURNING id";
250
                     }
250
                     }
251
                     else
251
                     else
252
                     {
252
                     {
253
-                        q = "INSERT INTO coffees VALUES (default, :name, :reference, :unit, 0, 'Coffee: Unroasted', :origin, :region, :producer, :grade, :milling, :drying) RETURNING id";
253
+                        q = "INSERT INTO coffees (id, name, reference, unit, quantity, category, origin, region, producer, grade, milling, drying) VALUES (default, :name, :reference, :unit, 0, 'Coffee: Unroasted', :origin, :region, :producer, :grade, :milling, :drying) RETURNING id";
254
                     }
254
                     }
255
                     query.prepare(q);
255
                     query.prepare(q);
256
                     query.bind(":name", nameEntry.currentText);
256
                     query.bind(":name", nameEntry.currentText);
317
                     query.exec();
317
                     query.exec();
318
                     query.next();
318
                     query.next();
319
                     var item_id = query.value(0);
319
                     var item_id = query.value(0);
320
-                    q = "INSERT INTO purchase VALUES(:time, :item, :quantity, :cost, :vendor)";
320
+                    q = "INSERT INTO purchase (time, item, quantity, cost, vendor) VALUES(:time, :item, :quantity, :cost, :vendor)";
321
                     query.prepare(q);
321
                     query.prepare(q);
322
                     query.bind(":time", dateField.date);
322
                     query.bind(":time", dateField.date);
323
                     query.bind(":item", item_id);
323
                     query.bind(":item", item_id);
333
                     }
333
                     }
334
                     query.bind(":vendor", vendorField.currentText);
334
                     query.bind(":vendor", vendorField.currentText);
335
                     query.exec();
335
                     query.exec();
336
-                    q = "INSERT INTO lb_bag_conversion VALUES(:item, :conversion)";
336
+                    q = "INSERT INTO lb_bag_conversion (item, conversion) VALUES(:item, :conversion)";
337
                     query.prepare(q);
337
                     query.prepare(q);
338
                     query.bind(":item", item_id);
338
                     query.bind(":item", item_id);
339
                     var bagsEntry = findChildObject(current, 'bags');
339
                     var bagsEntry = findChildObject(current, 'bags');
340
                     var conversion = convertToPounds(parseFloat(quantityEntry.text), unitEntry.currentText) / Number(bagsEntry.text);
340
                     var conversion = convertToPounds(parseFloat(quantityEntry.text), unitEntry.currentText) / Number(bagsEntry.text);
341
                     query.bind(":conversion", conversion);
341
                     query.bind(":conversion", conversion);
342
                     query.exec();
342
                     query.exec();
343
-                    q = "INSERT INTO invoice_items VALUES(:id, 'PURCHASE', :item, :description, :cost)";
343
+                    q = "INSERT INTO invoice_items (invoice_id, record_type, item_id, description, cost) VALUES(:id, 'PURCHASE', :item, :description, :cost)";
344
                     query.prepare(q);
344
                     query.prepare(q);
345
                     query.bind(":id", invoiceNumber);
345
                     query.bind(":id", invoiceNumber);
346
                     query.bind(":item", item_id);
346
                     query.bind(":item", item_id);
356
                     query.exec();
356
                     query.exec();
357
                     var certifications = findChildObject(current, 'certdisplay');
357
                     var certifications = findChildObject(current, 'certdisplay');
358
                     var certlist = certifications.text.split(",");
358
                     var certlist = certifications.text.split(",");
359
-                    q = "INSERT INTO certifications VALUES (:item, :certification)";
359
+                    q = "INSERT INTO certifications (item, certification) VALUES (:item, :certification)";
360
                     query.prepare(q);
360
                     query.prepare(q);
361
                     query.bind(":item", item_id);
361
                     query.bind(":item", item_id);
362
                     for(var j = 0; j < certlist.length; j++)
362
                     for(var j = 0; j < certlist.length; j++)
366
                     }
366
                     }
367
                 }
367
                 }
368
                 var descriptionArray = sqlToArray(feesTable.columnArray(0, 0));
368
                 var descriptionArray = sqlToArray(feesTable.columnArray(0, 0));
369
-                var q = "INSERT INTO invoice_items VALUES (:id, 'FEE', NULL, :description, :cost)";
369
+                var q = "INSERT INTO invoice_items (invoice_id, record_type, item_id, description, cost) VALUES (:id, 'FEE', NULL, :description, :cost)";
370
                 query.prepare(q);
370
                 query.prepare(q);
371
                 query.bind(":id", invoiceNumber);
371
                 query.bind(":id", invoiceNumber);
372
                 if(descriptionArray.length > 0)
372
                 if(descriptionArray.length > 0)

+ 3
- 3
config/Windows/roastmanager.xml View File

46
                 window.displayStatus("Item removed.");
46
                 window.displayStatus("Item removed.");
47
             });
47
             });
48
             restoreButton.clicked.connect(function() {
48
             restoreButton.clicked.connect(function() {
49
-                var q = "INSERT INTO current_items VALUES (:id)";
49
+                var q = "INSERT INTO current_items (item) VALUES (:id)";
50
                 query = new QSqlQuery();
50
                 query = new QSqlQuery();
51
                 query.prepare(q);
51
                 query.prepare(q);
52
                 query.bind(":id", drop2.currentData());
52
                 query.bind(":id", drop2.currentData());
59
                 window.displayStatus("Item restored.");
59
                 window.displayStatus("Item restored.");
60
             });
60
             });
61
             newItemButton.clicked.connect(function() {
61
             newItemButton.clicked.connect(function() {
62
-                var q = "INSERT INTO items VALUES (default, :name, NULL, 'lb', 0, 'Coffee: Roasted') RETURNING id";
62
+                var q = "INSERT INTO items (id, name, reference, unit, quantity, category) VALUES (default, :name, NULL, 'lb', 0, 'Coffee: Roasted') RETURNING id";
63
                 query = new QSqlQuery();
63
                 query = new QSqlQuery();
64
                 query.prepare(q);
64
                 query.prepare(q);
65
                 query.bind(":name", itemname.text);
65
                 query.bind(":name", itemname.text);
66
                 query.exec();
66
                 query.exec();
67
                 query.next();
67
                 query.next();
68
                 var i = query.value(0);
68
                 var i = query.value(0);
69
-                q = "INSERT INTO current_items VALUES(:id)";
69
+                q = "INSERT INTO current_items (item) VALUES(:id)";
70
                 query.prepare(q);
70
                 query.prepare(q);
71
                 query.bind(":id", i);
71
                 query.bind(":id", i);
72
                 query.exec();
72
                 query.exec();

Loading…
Cancel
Save