erp.h
void loadItemUnits(QComboBox *combo, QString itemid)
    {
        combo->clear();
        QString sql = "select pcsperpackunitid,packpermasterunitid,masterpackingunitid from tblitems where itemid = :itemid " ;
        QSqlQuery qry;
        qry.prepare(sql);
        qry.bindValue(":itemid", itemid);
        qry.exec();
        qry.next();

        QSqlQuery units;
        units.prepare("select * from tblinventoryunitname order by unitname ASC");
        units.exec();
        while(units.next())
        {
            if( (units.value("id").toInt()==qry.value("pcsperpackunitid").toInt()) || (units.value("id").toInt()==qry.value("packpermasterunitid").toInt()) || (units.value("id").toInt()==qry.value("masterpackingunitid").toInt()) )
            {
                int v = units.value("id").toInt();
                QString s = units.value("unitname").toString();
                combo->addItem(s, QVariant(v));
                if(units.value("id").toInt()==qry.value("masterpackingunitid").toInt())
                {
                    setComboBoxSelected(combo, units.value("id").toInt());
                }
            }
        }
    }
/********************************* Load Item units in combobox by itemid *******************************************************/
Load Item units in combobox by itemid
Load Item units in combobox by itemid
void loadItemUnits(QComboBox *combo, QString itemid)
    {
        combo->clear();
        QString sql = "select pcsperpackunitid,packpermasterunitid,masterpackingunitid from tblitems where itemid = :itemid " ;
        QSqlQuery qry;
        qry.prepare(sql);
        qry.bindValue(":itemid", itemid);
        qry.exec();
        qry.next();
        QSqlQuery units;
        units.prepare("select * from tblinventoryunitname order by unitname ASC");
        units.exec();
        while(units.next())
        {
            if( (units.value("id").toInt()==qry.value("pcsperpackunitid").toInt()) || (units.value("id").toInt()==qry.value("packpermasterunitid").toInt()) || (units.value("id").toInt()==qry.value("masterpackingunitid").toInt()) )
            {
                int v = units.value("id").toInt();
                QString s = units.value("unitname").toString();
                combo->addItem(s, QVariant(v));
                if(units.value("id").toInt()==qry.value("masterpackingunitid").toInt())
                {
                    setComboBoxSelected(combo, units.value("id").toInt());
                }
            }
        }
    }
void loadItemUnits ( QComboBox * combo , QString itemid ) { combo -> clear ( ) ; QString sql = " " ; QSqlQuery qry ; qry . prepare ( sql ) ; qry . bindValue ( " " , itemid ) ; qry . exec ( ) ; qry . next ( ) ; QSqlQuery units ; units . prepare ( " " ) ; units . exec ( ) ; while ( units . next ( ) ) { if ( ( units . value ( " " ) . toInt ( ) == qry . value ( " " ) . toInt ( ) ) || ( units . value ( " " ) . toInt ( ) == qry . value ( " " ) . toInt ( ) ) || ( units . value ( " " ) . toInt ( ) == qry . value ( " " ) . toInt ( ) ) ) { int v = units . value ( " " ) . toInt ( ) ; QString s = units . value ( " " ) . toString ( ) ; combo -> addItem ( s , QVariant ( v ) ) ; if ( units . value ( " " ) . toInt ( ) == qry . value ( " " ) . toInt ( ) ) { setComboBoxSelected ( combo , units . value ( " " ) . toInt ( ) ) ; } } } }
Load Item units in combobox by itemid
Load Item units in combobox by itemid