Public Class frmLicense_User
    Dim CLIENT_ID As Integer = -1


    Private Sub frmLicense_User_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        

        Try
            cmbClients.DataSource = DT_CLIENT_USER
            cmbClients.DisplayMember = "CLIENT_NAME"
            cmbClients.ValueMember = "CLIENT_ID"
        Catch ex As Exception
            MsgBox("Unexpected Error in Loading Clients: " & ex.Message, MsgBoxStyle.Critical)
        End Try

        If DT_CLIENT_USER.Rows.Count = 1 Then
            cmbClients.Enabled = False
        End If

        Dim ClientId = cmbClients.SelectedValue
        RefreshLicense(ClientId)
    End Sub

    Private Sub cmbClients_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbClients.SelectedIndexChanged
        If cmbClients.SelectedIndex <> -1 Then
            Try
                Dim ClientId = cmbClients.SelectedValue
                RefreshLicense(ClientId)
            Catch ex As Exception
                CLIENT_ID = 99
            End Try
        End If
    End Sub

    Private Sub RefreshLicense(clientId As Integer)
        ClassLicence.Refresh_Licence(clientId)

        lbLicenceCount.Text = LICENSE_COUNT.ToString
        lbDossierCount.Text = LICENSE_DOSSIER_COUNT.ToString

        If USER_LANGUAGE = "de-DE" Then
            lbValidUntil.Text = LICENSE_DATE.ToString("dd.MM.yyyy")
        Else
            lbValidUntil.Text = LICENSE_DATE.ToString("MM-dd-yyyy")
        End If

        If (CBool(LICENSE_SAP_Connect) = True) Then
            chkSAP.Checked = True
        Else
            chkSAP.Checked = False
        End If
        If (CBool(LICENSE_SITE_PROXY) = True) Then
            chkSite.Checked = True
        Else
            chkSite.Checked = False
        End If
    End Sub
End Class