vendredi 22 juillet 2011

How to select records in a grid of a temporary table and enable/disable button according to these records

Here is a job in the active method of a temporary table of a dataSource of a form that shows how to pass records to another instance of a table to be able to read records ( using while)

// Changed on 19 Jui 2011 at 16:09:07 by iba
int active()
{
    int                             ret;
    TmpInventTransWMS               InventTransWMS;
    ;
    //<iba>
    InventTransWMS.setTmpData(TmpInventTransWMS);

    select firstOnly InventDimId from InventTransWMS
            where   InventTransWMS.Thy_ValidationField == false;

    //</iba>
    ret = super();


    tmpInventTransWMS_DS.setEnabled(!tmpInventTransWMS.RecId);

    tmpInventDim_DS.active();

    //<iba>
        if (InventTransWMS.InventDimId != '')
        {
            ctrlUpdateButton.enabled(false);

        }
        else
             ctrlUpdateButton.enabled(true);
    //</iba>
    return ret;
}

Here is an other example to run through records in a dataSource Grid :

//  Created on 21 Jui 2011 at 13:57:25 by iba
ItemId findDocNumItem(BomId    bomId)
{
    InventTable         inventTable;
    Bom                 localBom;
    ;
    localBom.setTmpData(Bom);
    select firstOnly ItemId from localBom
        join inventTable
            where localBom.ItemId == inventTable.ItemId
                && inventTable.ItemGroupId == InventParameters::find().Thy_ItemGroupId
                    && localBom.BOMId   == bomId;
    BomItemId =  localBom.ItemId ;
    return BomItemId;
}

Aucun commentaire:

Enregistrer un commentaire