src/EditSupplier.cpp

Thu, 18 Aug 2022 19:47:28 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 18 Aug 2022 19:47:28 +0200
changeset 399
4b9aaf86094e
parent 90
2396457a8167
permissions
-rw-r--r--

Prompts corrections and updated translations. Minor layout changes so the prompts will fit.

10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditSupplier.cpp is part of bmsapp.
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "EditSupplier.h"
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 #include "../ui/ui_EditSupplier.h"
90
2396457a8167 Moved functions from bmsapp.cpp to MainWindow.cpp
Michiel Broek <mbroek@mbse.eu>
parents: 60
diff changeset
19 #include "MainWindow.h"
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 EditSupplier::EditSupplier(int id, QWidget *parent) : QDialog(parent), ui(new Ui::EditSupplier)
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 {
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 QSqlQuery query;
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
26 qDebug() << "EditSupplier record:" << id;
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 ui->setupUi(this);
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
28 this->recno = id;
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29
17
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
30 WindowTitle();
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
31 if (id >= 0) {
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 query.prepare("SELECT * FROM inventory_suppliers WHERE record = :recno");
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 query.bindValue(":recno", id);
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 query.exec();
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 query.next();
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 ui->nameEdit->setText(query.value(1).toString());
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 ui->addressEdit->setText(query.value(2).toString());
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 ui->cityEdit->setText(query.value(3).toString());
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 ui->zipEdit->setText(query.value(4).toString());
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 ui->countryEdit->setText(query.value(5).toString());
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 ui->webEdit->setText(query.value(6).toString());
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 ui->emailEdit->setText(query.value(7).toString());
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 ui->phoneEdit->setText(query.value(8).toString());
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
45 ui->notesEdit->setPlainText(query.value(9).toString());
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 }
17
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
47 connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditSupplier::is_changed);
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
48 connect(ui->addressEdit, &QLineEdit::textChanged, this, &EditSupplier::is_changed);
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
49 connect(ui->cityEdit, &QLineEdit::textChanged, this, &EditSupplier::is_changed);
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
50 connect(ui->zipEdit, &QLineEdit::textChanged, this, &EditSupplier::is_changed);
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
51 connect(ui->countryEdit, &QLineEdit::textChanged, this, &EditSupplier::is_changed);
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
52 connect(ui->webEdit, &QLineEdit::textChanged, this, &EditSupplier::is_changed);
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
53 connect(ui->emailEdit, &QLineEdit::textChanged, this, &EditSupplier::is_changed);
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
54 connect(ui->phoneEdit, &QLineEdit::textChanged, this, &EditSupplier::is_changed);
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
55 connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed()));
21
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
56
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
57 ui->saveButton->setEnabled(false);
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
58 ui->deleteButton->setEnabled((id >= 0) ? true:false);
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 }
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 EditSupplier::~EditSupplier()
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 {
21
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
64 qDebug() << "EditSupplier done";
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 delete ui;
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
66 emit entry_changed();
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 }
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69
17
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
70 /*
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
71 * Window header, mark any change with '**'
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
72 */
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
73 void EditSupplier::WindowTitle()
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
74 {
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
75 QString txt;
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
76
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
77 if (this->recno < 0) {
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
78 txt = QString(tr("BMSapp - Add new supplier"));
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
79 } else {
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
80 txt = QString(tr("BMSapp - Edit supplier %1").arg(this->recno));
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
81 }
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
82
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
83 if (this->textIsChanged) {
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
84 txt.append((QString(" **")));
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
85 }
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
86 setWindowTitle(txt);
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
87 }
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
88
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
89
21
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
90 void EditSupplier::on_saveButton_clicked()
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 {
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
92 QSqlQuery query;
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
93
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 /* If there are errors in the form, show a message and do "return;" */
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
95 if (ui->nameEdit->text().length() < 2) {
17
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
96 QMessageBox::warning(this, tr("Edit Supplier"), tr("Name empty or too short."));
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
97 return;
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
98 }
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99
17
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
100 if (this->textIsChanged) {
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
101 if (this->recno == -1) {
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
102 query.prepare("INSERT INTO inventory_suppliers SET name = :name, address = :address, city = :city, zip = :zip, "
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
103 "country = :country, website = :web, email = :email, phone = :phone, notes = :notes, uuid = :uuid");
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
104 } else {
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
105 query.prepare("UPDATE inventory_suppliers SET name = :name, address = :address, city = :city, zip = :zip, "
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
106 "country = :country, website = :web, email = :email, phone = :phone, notes = :notes WHERE record = :recno");
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
107 }
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
108 query.bindValue(":name", ui->nameEdit->text());
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
109 query.bindValue(":address", ui->addressEdit->text());
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
110 query.bindValue(":city", ui->cityEdit->text());
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
111 query.bindValue(":zip", ui->zipEdit->text());
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
112 query.bindValue(":country", ui->countryEdit->text());
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
113 query.bindValue(":web", ui->webEdit->text());
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
114 query.bindValue(":email", ui->emailEdit->text());
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
115 query.bindValue(":phone", ui->phoneEdit->text());
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
116 query.bindValue(":notes", ui->notesEdit->toPlainText());
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
117 if (this->recno == -1) {
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
118 query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36));
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
119 } else {
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
120 query.bindValue(":recno", this->recno);
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
121 }
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
122 query.exec();
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
123 if (query.lastError().isValid()) {
17
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
124 qDebug() << "EditSupplier" << query.lastError();
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
125 QMessageBox::warning(this, tr("Database error"),
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
126 tr("MySQL error: %1\n%2\n%3")
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
127 .arg(query.lastError().nativeErrorCode())
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
128 .arg(query.lastError().driverText())
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
129 .arg(query.lastError().databaseText()));
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
130 } else {
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
131 qDebug() << "EditSupplier Saved";
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
132 }
21
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
133 }
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134
21
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
135 ui->saveButton->setEnabled(false);
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
136 this->textIsChanged = false;
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
137 WindowTitle();
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
138 }
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
139
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
140
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
141 void EditSupplier::on_deleteButton_clicked()
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
142 {
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
143 QSqlQuery query;
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
144
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
145 query.prepare("DELETE FROM inventory_suppliers WHERE record = :recno");
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
146 query.bindValue(":recno", this->recno);
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
147 query.exec();
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
148 if (query.lastError().isValid()) {
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
149 qDebug() << "EditSupplier" << query.lastError();
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
150 QMessageBox::warning(this, tr("Database error"),
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
151 tr("MySQL error: %1\n%2\n%3")
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
152 .arg(query.lastError().nativeErrorCode())
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
153 .arg(query.lastError().driverText())
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
154 .arg(query.lastError().databaseText()));
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
155 } else {
21
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
156 qDebug() << "EditSupllier Deleted" << this->recno;
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
157 }
21
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
158
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
159 this->close();
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
160 this->setResult(1);
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
161 }
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
162
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
163
17
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
164 void EditSupplier::is_changed()
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
165 {
21
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
166 ui->saveButton->setEnabled(true);
11
c9cdc15d3caf The Supplier editor saves changes and inserts new suppliers. It sends a signal to InventorySuppliers when done (always for now). Refresh the table still doesn't work. Added a missing iconn in the Inventory menus dropdown.
Michiel Broek <mbroek@mbse.eu>
parents: 10
diff changeset
167 this->textIsChanged = true;
17
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
168 WindowTitle();
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 }
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171
21
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
172 void EditSupplier::on_quitButton_clicked()
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 {
21
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
174 if (this->textIsChanged) {
60
0d65238ebedc Updated translations and some messages.
Michiel Broek <mbroek@mbse.eu>
parents: 21
diff changeset
175 int rc = QMessageBox::warning(this, tr("Supplier changed"), tr("This supplier has been modified. Save changes?"),
21
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
176 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save);
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
177 switch (rc) {
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
178 case QMessageBox::Save:
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
179 on_saveButton_clicked();
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
180 break; /* Saved and then Quit */
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
181 case QMessageBox::Discard:
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
182 break; /* Quit without Save */
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
183 case QMessageBox::Cancel:
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
184 return; /* Return to the editor page */
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
185 }
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
186 }
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
187
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 this->close();
21
15e5879df8dc In EditSupplier backports from EditFermentables including a Delete button.
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
189 this->setResult(1);
10
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 }

mercurial