Imports System.ComponentModel
Imports System.Drawing

Public Class frmMitarbeitersucheEinstellungen
    Dim MA As cMitarbeiter = Nothing


    Sub New(mit_id)

        ' Dieser Aufruf ist für den Designer erforderlich.
        InitializeComponent()

        ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
        MA = New cMitarbeiter(mit_id)
    End Sub



    Private Sub frmMitarbeitersuche_Load(sender As Object, e As EventArgs) Handles Me.Load
        If MA Is Nothing Then Me.Close()

        cboTeam.fillWithSQL("SELECT team_id, team_bezeichnung FROM tblTeams WHERE team_firma='" & MA.mit_firma & "'", False, "ADMIN", True)

        lbSprachen.fillWithSQL("SELECT [wert], [bezeichnung]  FROM [dbo].[tblSprachen]", False, "ADMIN")

        initMA()
    End Sub



    Sub initMA()
        If MA Is Nothing OrElse MA.mit_id <= 0 Then MsgBox("Fehler Benutzer!") : Exit Sub

        lblName.Text = If(MA.mit_vname, "") & " " & If(MA.mit_nname, "")


        cboTeam.changeItem(MA.mit_teamId)


        pic.BackgroundImage = My.Resources.personGray_m

        If MA.mit_foto_DocId IsNot Nothing Then
            Try
                pic.BackgroundImage = Image.FromFile(cDATENSERVER.GET_PDFPath_BY_DocID(MA.mit_foto_DocId))
            Catch ex As Exception
                pic.BackgroundImage = My.Resources.personGray_m
            End Try
        ElseIf MA.mit_geschlecht = "w" Then
            pic.BackgroundImage = My.Resources.personGray_w
        Else
            pic.BackgroundImage = My.Resources.personGray_m
        End If



        If MA.mit_Sprachkentnisse IsNot Nothing AndAlso MA.mit_Sprachkentnisse <> "" Then
            For Each f In MA.mit_Sprachkentnisse.ToString.Split(",")
                For i = 0 To lbSprachen.Items.Count - 1
                    If DirectCast(lbSprachen.Items(i), VERAG_PROG_ALLGEMEIN.MyListItem).Value.ToString = f.ToString Then
                        lbSprachen.SetSelected(i, True)
                    End If
                Next
            Next
        End If



    End Sub

    Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub


    Private Sub btn_Click(sender As Object, e As EventArgs) Handles btn.Click


        MA.mit_teamId = cboTeam._value

        If MA.mit_id <= 0 Then MsgBox("Fehler ID!") : Exit Sub


        MA.mit_Sprachkentnisse = ""

        If MA.mit_Sprachkentnisse = "" Then
            For Each i In lbSprachen.SelectedItems
                MA.mit_Sprachkentnisse &= DirectCast(i, VERAG_PROG_ALLGEMEIN.MyListItem).Value & ","
            Next
        End If
        If MA.mit_Sprachkentnisse <> "" And MA.mit_Sprachkentnisse.ToString.EndsWith(",") Then
            MA.mit_Sprachkentnisse = MA.mit_Sprachkentnisse.ToString.Substring(0, MA.mit_Sprachkentnisse.ToString.Length - 1)
        End If


        If MA.SAVE Then
            Me.DialogResult = Windows.Forms.DialogResult.OK
            Me.Close()
        End If
    End Sub


End Class