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

qlabparteditor.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 
00011 void QlabPartEditor::checkEAN()
00012 {
00013         if ( !inInit ) {
00014                 if ( serial->text().stripWhiteSpace().isEmpty() ) {
00015                         return ;
00016                 }
00017                 if ( buffer->value( "serial" ).toString() == serial->text() ) {
00018                         return ;
00019                 }
00020                 parts->setFilter( QString( "serial='%1'" ).arg( serial->text() ) ) ;
00021                 parts->select() ;
00022                 if ( parts->next() ) {
00023                         QMessageBox::critical( this, tr( "Invalid EAN code" ),
00024                                                            tr( "Invalid Bar Code\n\n"
00025                                                                    "This value is rejected.\n"
00026                                                                    "as it already exist\n"
00027                                                                    "Please retry with a valid value" ),
00028                                                            tr( "Ok" ), 0, 0, 0, 0 ) ;
00029                         return ;
00030                 }
00031                 updateMsg( QString( tr( "BarCode Changed from %1" ) )
00032                                    .arg( buffer->value( "serial" ).toString() ) ) ;
00033                 buffer->setValue( "serial", serial->text() ) ;
00034                 okButton->setEnabled( TRUE ) ;
00035         }
00036 }
00037 
00038 
00039 void QlabPartEditor::checkBuyUnit( bool isbuy )
00040 {
00041         if ( !inInit ) {
00042                 updateMsg( QString( tr( "Buy unit changed from %1 to %2" ) )
00043                                    .arg( buffer->value( "isstd_buy_unit" ).toBool() ? tr( "Yes" ) : tr( "No" ) )
00044                                    .arg( buffer->value( "isstd_buy_unit" ).toBool() ? tr( "No" ) : tr( "Yes" ) ) ) ;
00045                 buffer->setValue( "isstd_buy_unit", isbuy ? 1 : 0 ) ;
00046         }
00047 }
00048 
00049 
00050 void QlabPartEditor::recalc()
00051 {
00052         if ( !inInit ) {
00053                 inInit = TRUE ;
00054                 QString fld = QObject::sender()->name() ;
00055                 if ( fld == "quick_rate" ) {
00056                         updateMsg( QString( tr( "Default Coefficient changed to %1" ) )
00057                                            .arg( quick_rate->text() ) ) ;
00058                         updateMsg( QString( tr( "Price changed from %1" ) )
00059                                            .arg( buffer->value( "price" ).toString() ) ) ;
00060                         buffer->setValue( "price", QString( "" )
00061                                                           .number( buffer->value( "cost" ).toDouble() * quick_rate->text().toDouble(), 'f', 2 ) ) ;
00062                         updateMsg( QString( tr( "Retail changed from %1" ) )
00063                                            .arg( buffer->value( "retail" ).toString() ) ) ;
00064                         buffer->setValue( "retail", QString( "" )
00065                                                           .number( buffer->value( "price" ).toDouble() +
00066                                                                            ( buffer->value( "price" ).toDouble() * tax_rate / 100 ), 'f', 2 ) ) ;
00067                         price->setText( QString( "" ).number( buffer->value( "price" ).toDouble(), 'f', 2 ) ) ;
00068                         retail->setText( QString( "" ).number( buffer->value( "retail" ).toDouble(), 'f', 2 ) ) ;
00069                 } else if ( fld == "vatCombo" ) {
00070                         taxes->setFilter( QString( "tax_rate='%1'" ).arg( tax_rate ) ) ;
00071                         taxes->select() ;
00072                         taxes->next() ;
00073                         updateMsg( QString( tr( "Price changed from %1" ) )
00074                                            .arg( taxes->value( "tax_name" ).toString() ) ) ;
00075                         taxes->setFilter( QString( "tax_name='%1'" ).arg( vatCombo->currentText() ) ) ;
00076                         taxes->select() ;
00077                         taxes->next() ;
00078                         tax_rate = taxes->value( "tax_rate" ).toDouble() ;
00079                         buffer->setValue( "Taxid", tax_rate ) ;
00080                         updateMsg( QString( tr( "Retail changed from %1" ) )
00081                                            .arg( buffer->value( "retail" ).toString() ) ) ;
00082                         buffer->setValue( "retail", buffer->value( "price" ).toDouble() +
00083                                                           ( buffer->value( "price" ).toDouble() * tax_rate / 100 ) ) ;
00084                         retail->setText( QString( "" ).number( buffer->value( "retail" ).toDouble(), 'f', 2 ) ) ;
00085                 } else if ( fld == "cost" ) {
00086                         updateMsg( QString( tr( "Cost changed from %1" ) )
00087                                            .arg( buffer->value( "cost" ).toString() ) ) ;
00088                         buffer->setValue( "cost", cost->text().toDouble() ) ;
00089                         updateMsg( QString( tr( "Price changed from %1" ) )
00090                                            .arg( buffer->value( "price" ).toString() ) ) ;
00091                         buffer->setValue( "price", cost->text().toDouble() * quick_rate->text().toDouble() ) ;
00092                         updateMsg( QString( tr( "Retail changed from %1" ) )
00093                                            .arg( buffer->value( "retail" ).toString() ) ) ;
00094                         buffer->setValue( "retail", buffer->value( "price" ).toDouble() + 
00095                                                           ( buffer->value( "price" ).toDouble() * tax_rate / 100 ) ) ;
00096                         price->setText( QString( "" ).number( buffer->value( "price" ).toDouble(), 'f', 2 ) ) ;
00097                 } else if ( fld == "retail" ) {
00098                         updateMsg( QString( tr( "Retail changed from %1" ) )
00099                                            .arg( buffer->value( "retail" ).toString() ) ) ;
00100                         buffer->setValue( "retail", retail->text().toDouble() ) ;
00101                         updateMsg( QString( tr( "Price changed from %1" ) )
00102                                            .arg( buffer->value( "price" ).toString() ) ) ;
00103                         buffer->setValue( "price", buffer->value( "retail" ).toDouble() -
00104                                                          ( buffer->value( "retail" ).toDouble() * tax_rate / 100 ) ) ;
00105                         price->setText( QString( "" ).number( buffer->value( "price" ).toDouble(), 'f', 2 ) ) ;
00106                 }
00107                 inInit = FALSE ;
00108         }
00109 }
00110 
00111 
00112 void QlabPartEditor::setBuffer( QSqlRecord * buff )
00113 {
00114         inInit = TRUE ;
00115         buffer = buff ;
00116         if ( buffer->value( "recid" ).toInt() == 0 ) {
00117                 titleLabel->setText( tr( "Creation" ) ) ;
00118                 okButton->setEnabled( FALSE ) ;
00119         } else {
00120                 titleLabel->setText( "Edition" ) ;
00121                 okButton->setEnabled( TRUE ) ;
00122         }
00123         serial->setText( buffer->value( "serial" ).toString() ) ;
00124         if ( buffer->value( "price" ).toDouble() > 0 ) {
00125                 quick_rate->setText( QString( "" ).number( buffer->value( "price" ).toDouble() /
00126                                                                                                    buffer->value( "cost" ).toDouble(), 'f', 3 ) ) ;
00127         }
00128         taxes->setFilter( QString( "recid='%1'" ).arg( buffer->value( "Taxid" ).toString() ) ) ;
00129         taxes->select() ;
00130         taxes->next() ;
00131         vatCombo->setCurrentText( taxes->value( "tax_name" ).toString() ) ;
00132         cost->setText( QString( "" ).number( buffer->value( "cost" ).toDouble(), 'f', 2 ) ) ;
00133         price->setText( QString( "" ).number( buffer->value( "price" ).toDouble(), 'f', 2 ) ) ;
00134         retail->setText( QString( "" ).number( buffer->value( "retail" ).toDouble(), 'f', 2 ) ) ;
00135         stock->setValue( buffer->value( "stock" ).toInt() ) ;
00136         isstd_buy_unit->setChecked( buffer->value( "isstd_buy_unit" ).toBool() ) ;
00137         qty_unit->setValue( isstd_buy_unit->isChecked() ? buffer->value( "qty_unit" ).toInt() : 1 ) ;
00138         hassavings->setChecked( buffer->value( "savings" ).toBool() ) ;
00139         if ( buffer->value( "savings" ).toInt() > 0 ) {
00140                 QSqlCursor * discount = new QSqlCursor( "System_discount_subrule", TRUE ) ;
00141                 discount->setFilter( QString( "recid='%1'" ).arg( buffer->value( "savings" ).toInt() ) ) ;
00142                 discount->select() ;
00143                 discount->next() ;
00144                 savingsName->setText( discount->value( "name" ).toString() ) ;
00145         }
00146         startdate->setDateTime( buffer->value( "startdate" ).toDateTime() ) ;
00147         stopdate->setDateTime( buffer->value( "stopdate" ).toDateTime() ) ;
00148         costupdate->setText( buffer->value( "costupdate" ).toDateTime().toString( "dddd dd MMMM yyyy @ hh:mm:ss" ) ) ;
00149         priceupdate->setText( buffer->value( "priceupdate" ).toDateTime().toString( "dddd dd MMMM yyyy @ hh:mm:ss" ) ) ;
00150         lastchanged->setText( buffer->value( "lastchanged" ).toDateTime().toString( "dddd dd MMMM yyyy @ hh:mm:ss" ) ) ;
00151         lastchangedreason->setText( buffer->value( "lastchangedreason" ).toString()
00152                                                                 .section( '\n', 0, 0 ) ) ;
00153         savingsName->setEnabled( buffer->value( "savings" ).toBool() ) ;
00154         startdate->setEnabled( buffer->value( "savings" ).toBool() ) ;
00155         stopdate->setEnabled( buffer->value( "savings" ).toBool() ) ;
00156         
00157         inInit = FALSE ;
00158 }
00159 
00160 
00161 void QlabPartEditor::setAvail( int av )
00162 {
00163         if ( !inInit ) {
00164                 updateMsg( QString( tr( "Available Qty changed from %1 to %2" ) )
00165                                    .arg( buffer->value( "stock" ).toString() )
00166                                    .arg( av ) ) ;
00167                 buffer->setValue( "stock", av ) ;
00168         }
00169 }
00170 
00171 
00172 void QlabPartEditor::setCampain( const QDateTime & dt )
00173 {
00174         if ( !inInit ) {
00175                 QString wid = QObject::sender()->name() ;
00176                 updateMsg( QString( tr( "%1 changed from %2 to %3" ) )
00177                                    .arg( wid )
00178                                    .arg( buffer->value( wid ).toString() )
00179                                    .arg( dt.toString() ) ) ;
00180                 buffer->setValue( wid, dt ) ;
00181         }
00182 }
00183 
00184 
00185 void QlabPartEditor::setProduct( const QString & prod )
00186 {
00187         prod_name->setText( prod ) ;
00188 }
00189 
00190 
00191 
00192 void QlabPartEditor::init()
00193 {
00194         inInit = TRUE ;
00195         taxes = new QSqlCursor( "System_taxrates", TRUE ) ;
00196         taxes->setFilter( "" ) ;
00197         taxes->index( "recid" ) ;
00198         taxes->select() ;
00199         while ( taxes->next() ) {
00200                 vatCombo->insertItem( taxes->value( "tax_name" ).toString() ) ;
00201         }
00202         parts = new QSqlCursor( "Inv_parts", TRUE ) ;
00203         inInit = FALSE ;
00204 }
00205 
00206 
00207 void QlabPartEditor::setDefaultRate( const QString & rate )
00208 {
00209         inInit = TRUE ;
00210         quick_rate->setText( rate ) ;
00211         inInit = FALSE ;
00212 }
00213 
00214 
00215 void QlabPartEditor::setQtyUnit( int qty )
00216 {
00217         if ( !inInit ) {
00218                 updateMsg( QString( tr( "Qty/Unit changed from %1 to %2" ) )
00219                                    .arg( buffer->value( "qty_unit" ).toString() )
00220                                    .arg( qty ) ) ;
00221                 buffer->setValue( "qty_unit", qty ) ;
00222         }
00223 }
00224 
00225 
00226 void QlabPartEditor::updateMsg( const QString & msg )
00227 {
00228         if ( buffer->value( "recid" ).toInt() > 0 ) {
00229                 QString oldmsg = buffer->value( "lastchangedreason" ).toString() ;
00230                 buffer->setValue( "lastchangedreason", QString( "%1\n======\n%2" )
00231                                                   .arg( msg ).arg( oldmsg ) ) ;
00232         }
00233 }
00234 
00235 
00236 void QlabPartEditor::activateSavings( bool b )
00237 {
00238         savingsName->setEnabled( b ) ;
00239         startdate->setEnabled( b ) ;
00240         stopdate->setEnabled( b ) ;
00241 }

 

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