trabajadores.cpp

Go to the documentation of this file.
00001 #include <QWidget>
00002 #include <QPushButton>
00003 #include "trabajadores.h"
00004 #include "funcaux.h"
00005 #include "ticket.h"
00006 #include "empresatpv.h"
00007 
00008 
00009 Trabajadores::Trabajadores(EmpresaBase *emp, QWidget *parent) : QDialog(parent), PEmpresaBase(emp) {
00010     setupUi(this);
00011 
00012     cursor2 *cur = empresaBase()->cargacursor("SELECT * FROM trabajador");
00013     while (!cur->eof()) {
00014         QPushButton *toolbutton = new QPushButton( mui_frame);
00015         toolbutton->setText(cur->valor("nomtrabajador") + " " + cur->valor("apellidostrabajador"));
00016 
00017         QVBoxLayout *m_hboxLayout1 = mui_frame->findChild<QVBoxLayout *>("hboxLayout1");
00018         if (!m_hboxLayout1) {
00019             m_hboxLayout1 = new QVBoxLayout(mui_frame);
00020             m_hboxLayout1->setSpacing(5);
00021             m_hboxLayout1->setMargin(5);
00022             m_hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1"));
00023         } // end if
00024         m_hboxLayout1->addWidget(toolbutton);
00025         connect(toolbutton,SIGNAL(pressed()), this, SLOT(trabajadorClicked()));
00026         cur->siguienteregistro();
00027     } // end while
00028     delete cur;
00029 }
00030 
00031 
00032 Trabajadores::~Trabajadores() {}
00033 
00034 
00035 
00036 void Trabajadores::trabajadorClicked() {
00037     EmpresaTPV *emp1 = (EmpresaTPV *) empresaBase();
00038     Ticket *ticket = NULL;
00039     Ticket *ticketv = NULL;
00040     bool encontrado = FALSE;
00041 
00043     cursor2 *cur = empresaBase()->cargacursor("SELECT * FROM trabajador");
00044     while (!encontrado) {
00045         if (((QPushButton *)sender())->text() == cur->valor("nomtrabajador") + " " + cur->valor("apellidostrabajador")) {
00046             encontrado = TRUE;
00047         } else {
00048             cur->siguienteregistro();
00049         } // end if
00050     } // end while
00051 
00053     for (int i = 0; i < emp1->listaTickets()->size(); ++i) {
00054         ticket = emp1->listaTickets()->at(i);
00055 
00056         if ( "" == ticket->DBvalue("nomticket") && cur->valor("idtrabajador") == ticket->DBvalue("idtrabajador")) {
00057             ((EmpresaTPV *) empresaBase())->setTicketActual(ticket);
00058             ticket->pintar();
00059             ticketv = ticket;
00060         }// end if
00061 
00062     }// end for
00063 
00065     if (!ticketv) {
00066         Ticket *tick = emp1->newTicket();
00067         tick->setDBvalue("idtrabajador", cur->valor("idtrabajador"));
00068         emp1->setTicketActual(tick);
00069         emp1->listaTickets()->append(tick);
00070         tick->pintar();
00071     }// end if
00072     delete cur;
00073 
00074     done(0);
00075 }
00076 

Generated on Sat Dec 15 00:01:23 2007 for BulmaGes by  doxygen 1.5.1