Option Compare Database
Option Explicit

' ============================================================
' : mAlphaRelease
'
' :
'      " Alpha"   .
'
'  :
'   -  /  ;
'   -      ;
'   -      dev-;
'   -    //;
'   -  -   ACCDE.
'
' :
'     :    .
'           .
' ============================================================


Private Const APP_NAME As String = " Alpha"


' ============================================================
'   /  
' ============================================================

Public Sub ApplyAlphaClientUiMode(ByVal targetForm As Form)

    '      f.
    '
    '  :
    '   -  ;
    '   -   ;
    '   -   .
    '
    ' :
    '   -   Alpha-;
    '   -  ;
    '   -  Access-;
    '   -   ;
    '   -   Access.

    On Error Resume Next

    '   .
    SetControlVisible targetForm, "cmdCreateAlphaTrialLicense", False
    SetControlVisible targetForm, "cmdResetLicense", False

    '    Access.
    SetControlVisible targetForm, "cmdEnableAlphaShell", False
    SetControlVisible targetForm, "cmdEnableAlphaShell_", False

    SetControlVisible targetForm, "cmdEnableAlphaShellStrict", False
    SetControlVisible targetForm, "cmdEnableAlphaShellStrict_", False

    SetControlVisible targetForm, "cmdRestoreDeveloperShell", False
    SetControlVisible targetForm, "cmdRestoreDeveloperShell_", False

    SetControlVisible targetForm, "cmdHideAccessInterface", False
    SetControlVisible targetForm, "cmdHideAccessInterface_", False

    SetControlVisible targetForm, "cmdShowAccessInterface", False
    SetControlVisible targetForm, "cmdShowAccessInterface_", False

    SetControlVisible targetForm, "cmdShowAlphaPackagingChecklist", False
    SetControlVisible targetForm, "cmdShowAlphaPackagingChecklist_", False

    '    .
    SetControlVisible targetForm, "cmdCheckLicense", True
    SetControlVisible targetForm, "cmdCopyMachineCode", True
    SetControlVisible targetForm, "cmdEnterLicenseKey", True

End Sub


Public Sub ApplyDeveloperUiMode(ByVal targetForm As Form)

    '      f.
    '
    '    dev-.

    On Error Resume Next

    SetControlVisible targetForm, "cmdCreateAlphaTrialLicense", True
    SetControlVisible targetForm, "cmdResetLicense", True

    SetControlVisible targetForm, "cmdEnableAlphaShell", True
    SetControlVisible targetForm, "cmdEnableAlphaShell_", True

    SetControlVisible targetForm, "cmdEnableAlphaShellStrict", True
    SetControlVisible targetForm, "cmdEnableAlphaShellStrict_", True

    SetControlVisible targetForm, "cmdRestoreDeveloperShell", True
    SetControlVisible targetForm, "cmdRestoreDeveloperShell_", True

    SetControlVisible targetForm, "cmdHideAccessInterface", True
    SetControlVisible targetForm, "cmdHideAccessInterface_", True

    SetControlVisible targetForm, "cmdShowAccessInterface", True
    SetControlVisible targetForm, "cmdShowAccessInterface_", True

    SetControlVisible targetForm, "cmdShowAlphaPackagingChecklist", True
    SetControlVisible targetForm, "cmdShowAlphaPackagingChecklist_", True

    SetControlVisible targetForm, "cmdCheckLicense", True
    SetControlVisible targetForm, "cmdCopyMachineCode", True
    SetControlVisible targetForm, "cmdEnterLicenseKey", True

End Sub


Public Sub PrepareAlphaClientCopy(ByVal targetForm As Form)

    '       .
    '
    ' :
    '      ,     dev-.

    On Error GoTo ErrorHandler

    If MsgBox( _
        "      ?" & vbCrLf & vbCrLf & _
        "       ." & vbCrLf & _
        "    ." & vbCrLf & vbCrLf & _
        "     .", _
        vbQuestion + vbYesNo + vbDefaultButton2, _
        APP_NAME _
    ) <> vbYes Then
        Exit Sub
    End If

    Call ApplyAlphaClientUiMode(targetForm)

    MsgBox "    Alpha-." & vbCrLf & vbCrLf & _
           ":" & vbCrLf & _
           "1.  -> ." & vbCrLf & _
           "2.  Alpha-." & vbCrLf & _
           "3.    ." & vbCrLf & _
           "4.  ." & vbCrLf & _
           "5.  ACCDE.", _
           vbInformation, _
           APP_NAME

    Exit Sub

ErrorHandler:

    MsgBox "    Alpha-." & vbCrLf & _
           ": " & Err.Description, _
           vbExclamation, _
           APP_NAME

End Sub


Public Sub RestoreDeveloperUiOnForm(ByVal targetForm As Form)

    '  dev-  .
    '
    '     dev-.

    On Error GoTo ErrorHandler

    If MsgBox( _
        "      ?", _
        vbQuestion + vbYesNo + vbDefaultButton2, _
        APP_NAME _
    ) <> vbYes Then
        Exit Sub
    End If

    Call ApplyDeveloperUiMode(targetForm)

    MsgBox "    .", _
           vbInformation, _
           APP_NAME

    Exit Sub

ErrorHandler:

    MsgBox "    ." & vbCrLf & _
           ": " & Err.Description, _
           vbExclamation, _
           APP_NAME

End Sub


' ============================================================
'   
' ============================================================

Public Sub ShowAlphaReleaseChecklist()

    '   -   ACCDE.

    MsgBox _
        "- Alpha-:" & vbCrLf & vbCrLf & _
        "1.      dev-." & vbCrLf & _
        "2.   :" & vbCrLf & _
        "   -   ;" & vbCrLf & _
        "   -  ;" & vbCrLf & _
        "   -   Access." & vbCrLf & _
        "3.    :" & vbCrLf & _
        "     = RequiresLicense." & vbCrLf & _
        "4.  :" & vbCrLf & _
        "   -    ;" & vbCrLf & _
        "   -    ." & vbCrLf & _
        "5.  ." & vbCrLf & _
        "6.   ." & vbCrLf & _
        "7. Alpha- ." & vbCrLf & _
        "8.     f." & vbCrLf & _
        "9. Ribbon/  ." & vbCrLf & _
        "10. :  -> ." & vbCrLf & _
        "11.  ACCDE." & vbCrLf & _
        "12.   Templates  Reports.", _
        vbInformation, _
        APP_NAME

End Sub


Public Sub CheckAlphaFolders()

    '    Templates  Reports   .

    On Error GoTo ErrorHandler

    Dim templatesPath As String
    Dim reportsPath As String
    Dim messageText As String

    templatesPath = CurrentProject.Path & "\Templates"
    reportsPath = CurrentProject.Path & "\Reports"

    messageText = ""

    If Dir(templatesPath, vbDirectory) = "" Then
        messageText = messageText & "-   Templates" & vbCrLf
    End If

    If Dir(reportsPath, vbDirectory) = "" Then
        messageText = messageText & "-   Reports" & vbCrLf
    End If

    If messageText = "" Then

        MsgBox " Templates  Reports .", _
               vbInformation, _
               APP_NAME

    Else

        MsgBox "   :" & vbCrLf & vbCrLf & _
               messageText, _
               vbExclamation, _
               APP_NAME

    End If

    Exit Sub

ErrorHandler:

    MsgBox "    Alpha-." & vbCrLf & _
           ": " & Err.Description, _
           vbExclamation, _
           APP_NAME

End Sub


' ============================================================
'  
' ============================================================

Private Sub SetControlVisible( _
    ByVal targetForm As Form, _
    ByVal controlName As String, _
    ByVal isVisible As Boolean _
)

    '     .

    On Error Resume Next

    If ControlExistsOnForm(targetForm, controlName) Then
        targetForm.Controls(controlName).Visible = isVisible
    End If

End Sub


Private Function ControlExistsOnForm( _
    ByVal targetForm As Form, _
    ByVal controlName As String _
) As Boolean

    On Error GoTo ErrorHandler

    Dim ctl As Control

    For Each ctl In targetForm.Controls

        If StrComp(Trim$(ctl.Name), Trim$(controlName), vbTextCompare) = 0 Then
            ControlExistsOnForm = True
            Exit Function
        End If

    Next ctl

    ControlExistsOnForm = False

    Exit Function

ErrorHandler:

    ControlExistsOnForm = False

End Function