Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

tickethistory.ui.h

00001 /****************************************************************************
00002 ** ui.h extension file, included from the uic-generated form implementation.
00003 **
00004 ** If you wish to add, delete or rename functions or slots use
00005 ** Qt Designer which will update this file, preserving your code. Create an
00006 ** init() function in place of a constructor, and a destroy() function in
00007 ** place of a destructor.
00008 *****************************************************************************/
00009 
00010 void TicketHistory::init()
00011 {
00012         listTable->setLeftMargin( 0 ) ;
00013         listTable->setColumnWidth( BOXID, 0 ) ;
00014         listTable->setColumnWidth( CASHIER, 0 ) ;
00015         listTable->setColumnWidth( TICKETDATE, 0 ) ;
00016         listTable->setColumnStretchable( TICKETNO, TRUE ) ;
00017         detailTable->setFilter( "recid=-1" ) ;
00018         detailTable->refresh() ;
00019         
00020 }
00021 
00022 void TicketHistory::ticketChanged( int row, int col )
00023 {
00024         if ( !inInit ) {
00025                 detailTable->setFilter( QString( "ticket_num='%1-%2-%3-%4 %5'" ) 
00026                                                                 .arg( listTable->text( row, BOXID ) )
00027                                                                 .arg( listTable->text( row, CASHIER ) )
00028                                                                 .arg( listTable->text( row, TICKETNO ) )
00029                                                                 .arg( listTable->text( row, TICKETDATE ) )
00030                                                                 .arg( listTable->text( row, TICKETTIME ) ) ) ;
00031                 detailTable->refresh() ;
00032         }
00033 }
00034 
00035 
00036 
00037 void TicketHistory::fillTable()
00038 {
00039         int row = 0 ;
00040         QString entry ;
00041         listTable->setNumRows( 0 ) ;
00042         while ( refer->next() ) {
00043                 entry = refer->value( 0 ).toString() ;
00044                 listTable->insertRows( row, 1 ) ;
00045                 listTable->setText( row, 0, entry.section( "-", 0, 0 ) ) ;
00046                 listTable->setText( row, 1, entry.section( "-", 1, 1 ) ) ;
00047                 listTable->setText( row, 2, entry.section( "-", 2, 2 ) ) ;
00048                 QString dt = entry.section( "-", 3, 3 ) ;
00049                 listTable->setText( row, 3, dt.section( " ", 0, 0 ) ) ;
00050                 listTable->setText( row, 4, dt.section( " ", 1, 1 ) ) ;
00051                 row++ ;
00052         }
00053         if ( listTable->numRows() > 0 ) {
00054                 listTable->setCurrentCell( 0, 0 ) ;
00055                 listTable->selectRow( 0 ) ;
00056                 ticketChanged( 0, 0 ) ;
00057         } else {
00058                 applyButton->setEnabled( FALSE ) ;
00059                 messageline->setText( tr( "No ticket means your criteria. Sorry" ) ) ;
00060         }
00061 }
00062 
00063 
00064 void TicketHistory::setDateValues( const QDate & dt )
00065 {
00066         inInit = TRUE ;
00067         QString filter = QString( "received >= '%1' AND received <= '%2'" )
00068                                          .arg( dt.toString( "yyyyMMdd000000" ) )
00069                                          .arg( dt.toString( "yyyyMMdd235959" ) ) ;
00070         refer = new QSqlQuery ( QString( "SELECT DISTINCT ticket_num FROM Ticket_receipts "
00071                                                                          "WHERE %1 ;" ).arg( filter ) ) ;
00072         dateLabel->setText( dt.toString( "dd MMMM yyyy" ) ) ;
00073         //fillTable() ;
00074         int row = 0 ;
00075         QString entry ;
00076         listTable->setNumRows( 0 ) ;
00077         while ( refer->next() ) {
00078                 entry = refer->value( 0 ).toString() ;
00079                 listTable->insertRows( row, 1 ) ;
00080                 listTable->setText( row, BOXID, entry.section( "-", 0, 0 ) ) ;
00081                 listTable->setText( row, CASHIER, entry.section( "-", 1, 1 ) ) ;
00082                 listTable->setText( row, TICKETNO, entry.section( "-", 2, 2 ) ) ;
00083                 QString dt = entry.section( "-", 3, 3 ) ;
00084                 listTable->setText( row, TICKETDATE, dt.section( " ", 0, 0 ) ) ;
00085                 listTable->setText( row, TICKETTIME, dt.section( " ", 1, 1 ) ) ;
00086                 row++ ;
00087         }
00088         if ( listTable->numRows() > 0 ) {
00089                 listTable->setCurrentCell( 0, 0 ) ;
00090                 listTable->selectRow( 0 ) ;
00091                 inInit = FALSE ;
00092                 ticketChanged( 0, 0 ) ;
00093         } else {
00094                 applyButton->setEnabled( FALSE ) ;
00095                 messageline->setText( tr( "No ticket means your criteria. Sorry" ) ) ;
00096         }
00097         inInit = FALSE ;        
00098 }
00099 
00100 
00101 void TicketHistory::setMessage( const QString & msg )
00102 {
00103         messageline->setText( msg ) ;
00104 }
00105 
00106 
00107 QString TicketHistory::getResult()
00108 {
00109         int row = listTable->currentRow() ;
00110         return QString( "ticket_num='%1-%2-%3-%4 %5" ) 
00111                         .arg( listTable->text( row, 0 ) )
00112                         .arg( listTable->text( row, 1 ) )
00113                         .arg( listTable->text( row, 2 ) )
00114                         .arg( listTable->text( row, 3 ) )
00115                         .arg( listTable->text( row, 4 ) ) ;
00116 }

 

L.A.B. Project © 2001-2004 LAB Project & DJ Anubis