Compile function NDW_ADD_PROB_CAT_EVENTS(CtrlEntId, Event, @PARAMS)

Declare function React_Prob_Cat_Services, Get_Property
Declare subroutine Set_Property, REACTOR_MODES_Services, End_Dialog

$Insert REACTOR_MODES_EQUATES

#pragma precomp SRP_PreCompiler
#window NDW_ADD_PROB_CAT

GoToEvent Event for CtrlEntId else
    // Event not implemented
end

Return EventFlow or 1

//-----------------------------------------------------------------------------
// EVENT HANDLERS
//-----------------------------------------------------------------------------

Event WINDOW.CREATE(CreateParam)
    
    EventFlow = 1
    Set_Property(@Window:'.EDT_REACTOR_MODE','TEXT', CreateParam)
    //Result  = False$
End Event

Event EDT_NEW_PROB_CAT.CHAR(VirtCode, ScanCode, CtrlKey, ShiftKey, AltKey)
    
    ModeEditing = Get_Property(@Window:'.EDT_REACTOR_MODE','TEXT')
    ExistingProbs = XLATE('REACTOR_MODES', ModeEditing, REACTOR_MODES_SERVICE_CATEGORIES$, 'X')
    
    NewValue = Get_Property(@Window:'.EDT_NEW_PROB_CAT', 'TEXT')
    
    If NewValue NE '' AND ModeEditing NE '' then
        Locate NewValue in ExistingProbs using @VM setting existingPos then
            Set_Property(@Window:'.BTN_SAVE', 'ENABLED', 0)
        end else
            Set_Property(@Window:'.BTN_SAVE', 'ENABLED', 1)
        end
    end else
        Set_Property(@Window:'.BTN_SAVE', 'ENABLED', 0)
    end
    
    
end event
Event BTN_SAVE.CLICK()
    
    ModeEditing = Get_Property(@Window:'.EDT_REACTOR_MODE','TEXT')
    ModeEditingCategory = XLATE('REACTOR_MODES', ModeEditing, REACTOR_MODES_MODE_CATEGORY$, 'X')
    NewCategory = Get_Property(@Window:'.EDT_NEW_PROB_CAT', 'TEXT')
    
    IF ModeEditing NE '' AND NewCategory NE '' then
        Reactor_Modes_Services('AddServiceCategory', ModeEditing, NewCategory, ModeEditingCategory)
    end
    End_Dialog(@Window, 1)
end event

Event   BTN_CANCEL.CLICK()
    End_Dialog(@Window, 1)
end event


