public int doRecordChange(FieldInfo field, int iChangeType, boolean bDisplayOption)
    { // Read a valid record
        int iErrorCode = DBConstants.NORMAL_RETURN;
        switch (iChangeType)
        {
            case DBConstants.LOCK_TYPE:
                if (this.getMainRecord() != null)
                    iErrorCode = this.getMainRecord().handleRecordChange(this.getMainFileKeyField(false), DBConstants.FIELD_CHANGED_TYPE, bDisplayOption); // Tell the main file that I changed (so it can lock/whatever)
                break;
//            case DBConstants.AFTER_REFRESH_TYPE:
            case DBConstants.UPDATE_TYPE:   // If refresh is set, it is possible that first add is UPDATE_TYPE
                if (!this.getOwner().isRefreshedRecord())
                    break;  // No first add
            case DBConstants.ADD_TYPE:
                boolean bOldSelect = this.enableReselect(false);
                if (this.getMainRecord() != null)
                {
                    if (this.getMainRecord().getEditMode() == DBConstants.EDIT_ADD)
                    {
                        if (!m_bAddNewHeaderOnAdd)
                            return this.getOwner().getTask().setLastError("Can't add detail without a header record");
                        m_bMainRecordChanged = true;
                    }
                    iErrorCode = this.getMainRecord().handleRecordChange(this.getMainFileKeyField(false), DBConstants.FIELD_CHANGED_TYPE, bDisplayOption); // Tell the main file that I changed (so it can lock/whatever)
                    iErrorCode = DBConstants.NORMAL_RETURN; // Ignore error on lock main!
                }
                this.enableReselect(bOldSelect);
                break;
            case DBConstants.AFTER_ADD_TYPE:
// Note: This code is not necessary, since the newly added record is now a member of the new header record a refresh is not necessary!
//                if (m_bMainRecordChanged)
//                    iErrorCode = this.getMainFileKeyField(true).handleFieldChanged(bDisplayOption, DBConstants.SCREEN_MOVE); // Tell the main file that I changed (so it can lock/whatever)
                break;
            default:
                m_bMainRecordChanged = false;
                break;
        }
        if (iErrorCode != DBConstants.NORMAL_RETURN)
            return iErrorCode;
        return super.doRecordChange(field, iChangeType, bDisplayOption);   // Initialize the record
    }
public int doRecordChange ( FieldInfo field , int iChangeType , boolean bDisplayOption ) { int iErrorCode = DBConstants . NORMAL_RETURN ; switch ( iChangeType ) { case DBConstants . LOCK_TYPE : if ( this . getMainRecord ( ) != null ) iErrorCode = this . getMainRecord ( ) . handleRecordChange ( this . getMainFileKeyField ( false ) , DBConstants . FIELD_CHANGED_TYPE , bDisplayOption ) ; break ; case DBConstants . UPDATE_TYPE : if ( ! this . getOwner ( ) . isRefreshedRecord ( ) ) break ; case DBConstants . ADD_TYPE : boolean bOldSelect = this . enableReselect ( false ) ; if ( this . getMainRecord ( ) != null ) { if ( this . getMainRecord ( ) . getEditMode ( ) == DBConstants . EDIT_ADD ) { if ( ! m_bAddNewHeaderOnAdd ) return this . getOwner ( ) . getTask ( ) . setLastError ( "Can't add detail without a header record" ) ; m_bMainRecordChanged = true ; } iErrorCode = this . getMainRecord ( ) . handleRecordChange ( this . getMainFileKeyField ( false ) , DBConstants . FIELD_CHANGED_TYPE , bDisplayOption ) ; iErrorCode = DBConstants . NORMAL_RETURN ; } this . enableReselect ( bOldSelect ) ; break ; case DBConstants . AFTER_ADD_TYPE : break ; default : m_bMainRecordChanged = false ; break ; } if ( iErrorCode != DBConstants . NORMAL_RETURN ) return iErrorCode ; return super . doRecordChange ( field , iChangeType , bDisplayOption ) ; }
Called when a change is the record status is about to happen/has happened.
On an add or lock, makes sure the main key field is set to the current main target field
so it will be a child of the current main record.
@param field If this file change is due to a field, this is the field.
@param iChangeType The type of change that occurred.
@param bDisplayOption If true, display any changes.
@return an error code.
Before an add, set the key back to the original value.