+
+ // Set up actions
+
+ connect(nextVendorButton, SIGNAL(clicked()), this, SLOT(GetNextVendor()));
+ connect(previousVendorButton, SIGNAL(clicked()), this, SLOT(GetPreviousVendor()));
+
+ GetVendorIDs();
+ GetVendor(vendorID[vidCursor]);
+}
+
+
+void SCMWidget::GetNextVendor(void)
+{
+ if (vidCursor < (vendorID.size() - 1))
+ {
+ vidCursor++;
+ GetVendor(vendorID[vidCursor]);
+ }
+}
+
+
+void SCMWidget::GetPreviousVendor(void)
+{
+ if (vidCursor > 0)
+ {
+ vidCursor--;
+ GetVendor(vendorID[vidCursor]);
+ }
+}
+
+
+void SCMWidget::GetVendorIDs(void)
+{
+ vendorID.clear();
+
+ QSqlQuery query;
+ query.prepare("SELECT vid FROM Vendor ORDER BY name");
+ query.exec();
+
+ while (query.next())
+ {
+ int vid = query.value(0).toInt();
+ vendorID.push_back(vid);
+ }
+}
+
+
+void SCMWidget::GetVendor(int key)
+{
+ // Get main vendor data
+ QSqlQuery query;
+ query.prepare("SELECT v.name, signedNDA, l.address, city, state, country, code, "
+ "c.name, email, c.address, phone1, phone2, fax, description, v.vlid FROM "
+ "Vendor AS v LEFT OUTER JOIN Location AS l ON v.vid = l.vid "
+ "LEFT OUTER JOIN (Contact AS c JOIN ContactType AS ct ON c.ctid = ct.ctid) "
+ "ON v.vid = c.vid WHERE v.vid = ?");
+ query.addBindValue(key);
+ query.exec();
+
+ // There's a possibility that the query will return multiple rows (which we need
+ // to handle, with multiple tabs), but for now, we ignore any and grab the first.
+ if (query.next())
+ {
+ vendorName->setText(query.value(0).toString());
+
+ vaw1->SetFields(query.value(2).toString(),
+ query.value(3).toString(), query.value(4).toString(),
+ query.value(5).toString(), query.value(6).toString());
+ vcw1->SetFields(query.value(13).toString(),
+ query.value(7).toString(), query.value(8).toString(),
+ query.value(9).toString(), query.value(10).toString(),
+ query.value(11).toString(), query.value(12).toString());
+
+ int vlid = query.value(14).toInt();
+ vendorLevel->DoQuery(vlid);
+ }
+
+ // Get vendor classes
+ query.prepare("SELECT description FROM VendorSpecificTypes AS vst, VendorType AS vt "
+ "WHERE vst.vid = ? AND vst.vtid = vt.vtid ORDER BY seqNo");
+ query.addBindValue(key);
+ query.exec();
+
+ vendorClass->clear();
+
+ while (query.next())
+ {
+ QListWidgetItem * item = new QListWidgetItem(query.value(0).toString());
+ vendorClass->addItem(item);
+ }