]> Shamusworld >> Repos - schematic/blobdiff - src/scmwidget.cpp
Added Note capability.
[schematic] / src / scmwidget.cpp
index 07b9cd18f2c41ce13b25b2d16644e2091e2bb115..a04e8947050a424dcc4ba53e844b8ef8187796a3 100644 (file)
@@ -15,6 +15,7 @@
 #include <QtSql>
 #include "addresswidget.h"
 #include "contactwidget.h"
+#include "notedialog.h"
 
 
 SCMWidget::SCMWidget(QWidget * parent/*= 0*/): QWidget(parent),
@@ -43,7 +44,7 @@ SCMWidget::SCMWidget(QWidget * parent/*= 0*/): QWidget(parent),
        showClosed(new QPushButton("Closed")),
        showAll(new QPushButton("All")),
        createPO(new QPushButton("Create")),
-       vendorRelated(new QCheckBox("Related to this Vendor")),
+       vendorRelated(new QCheckBox("Show POs for this Vendor only")),
        vidCursor(0)
 {
        // Create main page widgets & layout
@@ -211,6 +212,16 @@ SCMWidget::SCMWidget(QWidget * parent/*= 0*/): QWidget(parent),
 
        connect(nextVendorButton, SIGNAL(clicked()), this, SLOT(GetNextVendor()));
        connect(previousVendorButton, SIGNAL(clicked()), this, SLOT(GetPreviousVendor()));
+       connect(createNote, SIGNAL(clicked()), this, SLOT(CreateNote()));
+       connect(createAlert, SIGNAL(clicked()), this, SLOT(CreateAlert()));
+       connect(createPO, SIGNAL(clicked()), this, SLOT(CreatePurchaseOrder()));
+       connect(showOpen, SIGNAL(clicked()), this, SLOT(ShowOpenPOs()));
+       connect(showClosed, SIGNAL(clicked()), this, SLOT(ShowClosedPOs()));
+       connect(showAll, SIGNAL(clicked()), this, SLOT(ShowAllPOs()));
+//     connect(addVendor, SIGNAL(clicked()), this, SLOT(AddVendor()));
+       connect(addLocation, SIGNAL(clicked()), this, SLOT(AddLocation()));
+       connect(addContact, SIGNAL(clicked()), this, SLOT(AddContact()));
+       connect(editVendor, SIGNAL(clicked()), this, SLOT(EditVendor()));
 
        GetVendorIDs();
        GetVendor(vendorID[vidCursor]);
@@ -237,6 +248,81 @@ void SCMWidget::GetPreviousVendor(void)
 }
 
 
+void SCMWidget::CreateNote(void)
+{
+       NoteDialog dlg;
+       
+       if (dlg.exec() == true)
+       {
+               // Add note to DB for this user
+               QString note = dlg.note->document()->toPlainText();
+
+               QSqlQuery query;
+               query.prepare("INSERT INTO Notes VALUES ('', ?, NULL, ?)");
+               query.addBindValue(currentUID);
+//             query.addBindValue(NULL);
+               query.addBindValue(note.toAscii());
+               query.exec();
+
+               UpdateNotes();
+       }
+}
+
+
+void SCMWidget::CreateAlert(void)
+{
+       QMessageBox::warning(this, "Approaching Singularity!", "TODO: Implementation");
+}
+
+
+void SCMWidget::CreatePurchaseOrder(void)
+{
+       QMessageBox::warning(this, "Approaching Singularity!", "TODO: Implementation");
+}
+
+
+void SCMWidget::ShowOpenPOs(void)
+{
+       QMessageBox::warning(this, "Approaching Singularity!", "TODO: Implementation");
+}
+
+
+void SCMWidget::ShowClosedPOs(void)
+{
+       QMessageBox::warning(this, "Approaching Singularity!", "TODO: Implementation");
+}
+
+
+void SCMWidget::ShowAllPOs(void)
+{
+       QMessageBox::warning(this, "Approaching Singularity!", "TODO: Implementation");
+}
+
+
+void SCMWidget::AddVendor(void)
+{
+       QMessageBox::warning(this, "Approaching Singularity!", "TODO: Implementation");
+}
+
+
+void SCMWidget::AddLocation(void)
+{
+       QMessageBox::warning(this, "Approaching Singularity!", "TODO: Implementation");
+}
+
+
+void SCMWidget::AddContact(void)
+{
+       QMessageBox::warning(this, "Approaching Singularity!", "TODO: Implementation");
+}
+
+
+void SCMWidget::EditVendor(void)
+{
+       QMessageBox::warning(this, "Approaching Singularity!", "TODO: Implementation");
+}
+
+
 void SCMWidget::GetVendorIDs(void)
 {
        vendorID.clear();
@@ -298,3 +384,27 @@ void SCMWidget::GetVendor(int key)
        }
 }
 
+
+void SCMWidget::UpdateNotes(void)
+{
+//             QMessageBox::warning(this, "Approaching Singularity!", "TODO: Implementation");
+//NID (P-key) | UID | POID | Note
+
+       QSqlQuery query;
+       query.prepare("SELECT note FROM Notes WHERE uid = ?");
+//             "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(currentUID);
+       query.exec();
+
+       notes->clear();
+
+       while (query.next())
+       {
+               QListWidgetItem * item = new QListWidgetItem(query.value(0).toString());
+               notes->addItem(item);
+       }
+}
+