13 * |
13 * |
14 * You should have received a copy of the GNU General Public License |
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/>. |
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 */ |
16 */ |
17 #include "InventorySuppliers.h" |
17 #include "InventorySuppliers.h" |
|
18 #include "EditSupplier.h" |
18 #include "../ui/ui_InventorySuppliers.h" |
19 #include "../ui/ui_InventorySuppliers.h" |
19 #include "config.h" |
20 #include "config.h" |
|
21 #include "bmsapp.h" |
20 |
22 |
21 #include <QDebug> |
23 #include <QDebug> |
22 #include <QtSql> |
24 #include <QtSql> |
23 #include <QtWidgets> |
25 #include <QtWidgets> |
24 #include <QTableWidget> |
26 #include <QTableWidget> |
25 |
27 |
26 |
28 |
|
29 |
|
30 |
|
31 |
27 InventorySuppliers::InventorySuppliers(QWidget *parent) : QDialog(parent), ui(new Ui::InventorySuppliers) |
32 InventorySuppliers::InventorySuppliers(QWidget *parent) : QDialog(parent), ui(new Ui::InventorySuppliers) |
28 { |
33 { |
29 qDebug() << Q_FUNC_INFO; |
34 qDebug() << Q_FUNC_INFO; |
30 |
35 |
31 ui->setupUi(this); |
36 ui->setupUi(this); |
|
37 InventorySuppliers::loadTable(); |
32 |
38 |
|
39 setWindowTitle( QString("BMSapp - %1 - Inventory Suppliers").arg(VERSIONSTRING) ); |
|
40 } |
|
41 |
|
42 |
|
43 void InventorySuppliers::loadTable(void) |
|
44 { |
33 ui->tableSuppliers = new QTableWidget(ui->tableSuppliers); |
45 ui->tableSuppliers = new QTableWidget(ui->tableSuppliers); |
34 QSqlQuery query("SELECT * FROM inventory_suppliers ORDER BY name"); |
46 QSqlQuery query("SELECT * FROM inventory_suppliers ORDER BY name"); |
35 const QStringList labels({tr("Record"), tr("Name"), tr("Address"), tr("City"), tr("Country"), tr("Phone"), tr("Edit")}); |
47 const QStringList labels({tr("Record"), tr("Name"), tr("Address"), tr("City"), tr("Country"), tr("Phone"), tr("Edit")}); |
36 |
48 |
37 ui->tableSuppliers->setColumnCount(7); |
49 ui->tableSuppliers->setColumnCount(7); |
83 qDebug() << Q_FUNC_INFO; |
95 qDebug() << Q_FUNC_INFO; |
84 delete ui; |
96 delete ui; |
85 } |
97 } |
86 |
98 |
87 |
99 |
|
100 bool InventorySuppliers::edit(int recno) |
|
101 { |
|
102 qDebug() << Q_FUNC_INFO << recno; |
|
103 |
|
104 EditSupplier dialog(recno, this); |
|
105 dialog.setModal(true); |
|
106 int rc = dialog.exec(); /* rc 0 == cancel, rc 1 == ok */ |
|
107 |
|
108 qDebug() << Q_FUNC_INFO << recno << rc; |
|
109 return false; |
|
110 } |
|
111 |
|
112 |
88 void InventorySuppliers::on_editButton_clicked() |
113 void InventorySuppliers::on_editButton_clicked() |
89 { |
114 { |
90 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
115 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
91 int recno = pb->objectName().toInt(); |
116 int recno = pb->objectName().toInt(); |
92 qDebug() << Q_FUNC_INFO << recno; |
117 qDebug() << Q_FUNC_INFO << recno; |
93 |
118 edit(recno); |
94 // Call editor with recno |
|
95 } |
119 } |
96 |
120 |
97 |
121 |
98 void InventorySuppliers::on_insertButton_clicked() |
122 void InventorySuppliers::on_insertButton_clicked() |
99 { |
123 { |
100 qDebug() << Q_FUNC_INFO; |
124 qDebug() << Q_FUNC_INFO; |
101 |
125 edit(-1); |
102 // Call editor with -1 |
|
103 } |
126 } |
104 |
127 |
105 |
128 |
106 void InventorySuppliers::on_quitButton_clicked() |
129 void InventorySuppliers::on_quitButton_clicked() |
107 { |
130 { |