|
1 /** |
|
2 * EditSupplier.cpp is part of bmsapp. |
|
3 * |
|
4 * bmsapp is free software: you can redistribute it and/or modify |
|
5 * it under the terms of the GNU General Public License as published by |
|
6 * the Free Software Foundation, either version 3 of the License, or |
|
7 * (at your option) any later version. |
|
8 * |
|
9 * bmsapp is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU General Public License |
|
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 */ |
|
17 #include "EditSupplier.h" |
|
18 #include "../ui/ui_EditSupplier.h" |
|
19 #include "bmsapp.h" |
|
20 #include <QDebug> |
|
21 #include <QtSql> |
|
22 |
|
23 |
|
24 EditSupplier::EditSupplier(int id, QWidget *parent) : QDialog(parent), ui(new Ui::EditSupplier) |
|
25 { |
|
26 QSqlQuery query; |
|
27 |
|
28 qDebug() << Q_FUNC_INFO << id; |
|
29 ui->setupUi(this); |
|
30 |
|
31 if (id < 0) { |
|
32 setWindowTitle( QString("BMSapp - Add new supplier")); |
|
33 } else { |
|
34 setWindowTitle( QString("BMSapp - Edit supplier %1").arg(id)); |
|
35 query.prepare("SELECT * FROM inventory_suppliers WHERE record = :recno"); |
|
36 query.bindValue(":recno", id); |
|
37 query.exec(); |
|
38 query.next(); |
|
39 |
|
40 ui->nameEdit->setText(query.value(1).toString()); |
|
41 ui->addressEdit->setText(query.value(2).toString()); |
|
42 ui->cityEdit->setText(query.value(3).toString()); |
|
43 ui->zipEdit->setText(query.value(4).toString()); |
|
44 ui->countryEdit->setText(query.value(5).toString()); |
|
45 ui->webEdit->setText(query.value(6).toString()); |
|
46 ui->emailEdit->setText(query.value(7).toString()); |
|
47 ui->phoneEdit->setText(query.value(8).toString()); |
|
48 ui->notesEdit->setText(query.value(9).toString()); |
|
49 } |
|
50 } |
|
51 |
|
52 |
|
53 EditSupplier::~EditSupplier() |
|
54 { |
|
55 qDebug() << Q_FUNC_INFO; |
|
56 delete ui; |
|
57 } |
|
58 |
|
59 |
|
60 void EditSupplier::onOKButtonClicked() |
|
61 { |
|
62 qDebug() << Q_FUNC_INFO << "Ok, check for valid data"; |
|
63 |
|
64 /* If there are errors in the form, show a message and do "return;" */ |
|
65 |
|
66 /* Save or insert the data */ |
|
67 |
|
68 this->close(); |
|
69 this->setResult(1); |
|
70 } |
|
71 |
|
72 |
|
73 void EditSupplier::onCancelButtonClicked() |
|
74 { |
|
75 qDebug() << Q_FUNC_INFO; |
|
76 this->close(); |
|
77 this->setResult(0); |
|
78 } |