mercredi 10 août 2011

How to get relation between inventSerial and inventTrans

From from InventTransId,  I can get InventDimId  and from InventDimId and, from InventDimId I can get InventSerialId, but that's not reversible :

// Changed on 08 Aoû 2011 at 12:33:54 by iba
void clicked()
{
    Args                args;
    InventTrans         inventTrans;
    InventDim           inventDim;
    inventDimId         _inventDimId;
    InventSerial        _inventSerial;
    InventTransType     InventTransType;
    ;

    dialog              = new Dialog();
    dialog.caption("@THY47");

    thy_InventVendNum   =  dialog.addField(typeId(Thy_InventVendNum));
    _inventVendNum      =  InventSerial.thy_InventVendNum;

    inventSerialId      =  InventSerial.InventSerialId;
    itemId              =  InventSerial.ItemId;
    thy_InventVendNum.value(_inventVendNum);

    if (dialog.run())
    {
        ttsbegin;
        while select inventDimId from inventDim
               where inventDim.inventSerialId == inventSerial.InventSerialId
        {
            while select forupdate Thy_InventVendNum, CustVendAC, inventtransid from InventTrans index hint TransIdIdx
                             where InventTrans.inventDimId               == inventDim.inventDimId
                                && InventTrans.TransType                 == InventTransType::Purch
                               
            {
                if (!InventTrans::Thy_existThy_InventVendNum(thy_InventVendNum.value(),
                                                                InventTrans.CustVendAC)
                        || thy_InventVendNum.value() == '' )
                {
                   
                    InventTrans.Thy_InventVendNum = thy_InventVendNum.value();
                    InventTrans.update();

                    select forupdate firstOnly Thy_InventVendNum from _inventSerial
                        index hint ItemSerialIdx
                             where  _inventSerial.InventSerialId          == inventSerialId
                                 &&  _inventSerial.ItemId                  == itemId;
                        _inventSerial.Thy_InventVendNum  = thy_InventVendNum.value();
                        _inventSerial.update();
                        inventSerial_DS.research();
                        break;
                }
                else
                {
                    error(strfmt( "@THY73" ,thy_InventVendNum.value(), InventTrans.CustVendAC));
                }
            }
        }
        ttscommit;
    }
    super();
}


Aucun commentaire:

Enregistrer un commentaire