Imports IntraSell_DLL

Public Class MitarbeiterControl
    Public Const SQL = "SELECT IDNR, concat(IFNULL(concat(Name, ' '),''), IFNULL(Vorname,'')) as Namen " &
                       " FROM ofMitarbeiter where name is not null or Vorname is not null ORDER BY Name, Vorname"
    Private _IDNR As Integer

    Public Property IDNR() As Integer
        Get
            Return _IDNR
        End Get
        Set(value As Integer)
            _IDNR = value
            MitarbeiterComboBox.SelectedValue = _IDNR

            If _IDNR > 0 Then
                MitarbeiterComboBox.BackColor = MitarbeiterFarbe(_IDNR)
            End If
        End Set
    End Property

    Private Sub MitarbeiterControl_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load
        FillComboBox(MitarbeiterComboBox, SQL, "Namen", "IDNR")
        MitarbeiterComboBox.Text = ""
    End Sub

    Private Sub MitarbeiterSelectorButton_Click(sender As Object, e As System.EventArgs) Handles MitarbeiterSelectorButton.Click
        Try
            'AdressenSelector.Show()
            'AdressenSelector.AdressenComboBox = MitarbeiterComboBox
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub


    Private Sub MitarbeiterComboBox_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles MitarbeiterComboBox.SelectedIndexChanged
        Try
            If IsNumeric(MitarbeiterComboBox.SelectedValue) Then
                IDNR = MitarbeiterComboBox.SelectedValue
            End If
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub


    ''' <summary>
    ''' Clean for Filters etc.
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MitarbeiterComboBox_TextUpdate(sender As Object, e As System.EventArgs) Handles MitarbeiterComboBox.TextUpdate
        Try
            If MitarbeiterComboBox.Text = "" Then
                IDNR = Nothing
            End If
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub
End Class
