src/EditSupplier.cpp

Mon, 14 Feb 2022 20:58:07 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 14 Feb 2022 20:58:07 +0100
changeset 10
8aa2bd9ba9e8
child 11
c9cdc15d3caf
permissions
-rw-r--r--

Added the EditSupplier popup window. It is now ready to validate the form data.

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"
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 #include "bmsapp.h"
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 #include <QDebug>
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 #include <QtSql>
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
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 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
25 {
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 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
27
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 qDebug() << Q_FUNC_INFO << id;
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 ui->setupUi(this);
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 if (id < 0) {
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 setWindowTitle( QString("BMSapp - Add new supplier"));
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 } else {
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 setWindowTitle( QString("BMSapp - Edit supplier %1").arg(id));
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.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
36 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
37 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
38 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
39
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->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
41 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
42 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
43 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
44 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
45 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
46 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
47 ui->phoneEdit->setText(query.value(8).toString());
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 ui->notesEdit->setText(query.value(9).toString());
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 }
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 }
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 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
54 {
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 qDebug() << Q_FUNC_INFO;
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 delete ui;
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 }
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58
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 void EditSupplier::onOKButtonClicked()
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 qDebug() << Q_FUNC_INFO << "Ok, check for valid data";
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 /* If there are errors in the form, show a message and do "return;" */
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 /* Save or insert the data */
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 this->close();
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 this->setResult(1);
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 }
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 void EditSupplier::onCancelButtonClicked()
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 {
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 qDebug() << Q_FUNC_INFO;
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 this->close();
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 this->setResult(0);
8aa2bd9ba9e8 Added the EditSupplier popup window. It is now ready to validate the form data.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 }

mercurial