Files
SDL/VERAG_PROG_ALLGEMEIN/Mitarbeiterverzeichnis/frmMitarbeitersuche.vb
2025-03-26 09:55:35 +01:00

589 lines
23 KiB
VB.net

Imports System.ComponentModel
Imports System.Diagnostics.Eventing.Reader
Imports System.Drawing
Imports System.Net
Imports System.Threading
Imports System.Windows.Forms
Imports Therefore.API
Imports VERAG_PROG_ALLGEMEIN.cCreditSafeAPI
Public Class frmMitarbeitersuche
Dim mit_id As Integer = -1
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Dim timas As New cTimasAPI("timas")
Dim requestDone As Boolean = False
Dim MA As cMitarbeiter = Nothing
Dim online As Boolean = False
Sub New()
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
End Sub
Sub New(mit_id As Integer)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
Me.mit_id = mit_id
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
End Sub
Private Sub lblMail_Click(sender As Object, e As EventArgs) Handles lblMail.Click
If lblMail.Text <> "" Then Process.Start("Mailto:" & lblMail.Text)
End Sub
Private Sub frmMitarbeitersuche_Load(sender As Object, e As EventArgs) Handles Me.Load
pnl.Visible = False
If Not VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("MITARBEITER_VERZEICHNIS", "SDL") Then
MsgBox("Noch nicht verfügbar!")
Me.Close()
Exit Sub
End If
If VERAG_PROG_ALLGEMEIN.cAllgemein.MITARBEITER.mit_MAVerzeichnis_SettingsTstmp Is Nothing And Not VERAG_PROG_ALLGEMEIN.cAllgemein.MITARBEITER.mit_pseudoUser Then
Dim f As New frmMitarbeitersucheBearbeiten(VERAG_PROG_ALLGEMEIN.cAllgemein.USRID)
If f.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then
Else
Me.Close()
End If
VERAG_PROG_ALLGEMEIN.cAllgemein.MITARBEITER.LOAD(VERAG_PROG_ALLGEMEIN.cAllgemein.MITARBEITER.mit_id)
initMA(False)
End If
sbMitarbeiter.initSearchBox(Me.FindForm, " [mit_id] ,[mit_username] ,(mit_vname + ' ' + mit_nname ) AS Name , CASE WHEN mit_firma='ALL' THEN mit_firmaHaupt ELSE mit_firma END as Firma, mit_niederlassung as Niederlassung FROM tblMitarbeiter", {"mit_vname", "mit_nname"}, " 1=1 AND mit_gekuendigt=0 AND [mit_TESTonly]=0 AND [mit_pseudoUser]=0 ", "mit_id", "mit_id", "Name", "ADMIN", , 400, 200, {"mit_id", "mit_username"})
initMA()
End Sub
Private Sub sbMitarbeiter_PropertyChanged() Handles sbMitarbeiter.VALUE_CHANGED
requestDone = False
initMA(False)
End Sub
Sub initMA(Optional callTimasSaldo As Boolean = True)
btnEdit.Visible = False
pnl.Visible = False
'lblTimasZeiten.Visible = False
Panel1.Visible = False
btnSettings.Visible = False
Button3.Visible = False
' Dim MA As cMitarbeiter = Nothing
If sbMitarbeiter._value <> "" Then
MA = New cMitarbeiter(sbMitarbeiter._value)
Else
MA = Nothing
End If
If MA Is Nothing Then
clearMA()
Else
pnl.Visible = True
Panel1.Visible = True
lblName.Text = If(MA.mit_vname, "") & " " & If(MA.mit_nname, "")
lblSpitzname.Text = If(MA.mit_MAVerzeichnis_Spitzname, "")
lblFirma.Text = MA.getFirma
lblNiederlassung.Text = If(MA.mit_niederlassung, "")
lblMAId.Text = MA.mit_id
lblTelefon.Text = If(MA.mit_durchwahl, "")
lblMail.Text = If(MA.mit_email, "")
' lblWohnadresse.Text = (If(MA.mit_land, "") & " " & If(MA.mit_plz, "") & " " & If(MA.mit_ort, "")).Trim
lblWohnadresse.Text = (If(MA.mit_plz, "") & " " & If(MA.mit_ort, "")).Trim
pnlWohnadresse.Visible = MA.mit_MAVerzeichnis_allowWohnadresse
lblNotfall_Name.Text = If(MA.mit_Notfall_Name, "")
lblNotfall_Handy.Text = If(MA.mit_Notfall_Handy, "")
lblNotfall_Mail.Text = If(MA.mit_Notfall_Mail, "")
lblMotto.Text = MA.mit_MAVerzeichnis_Motto
If lblMotto.Text.Trim <> "" Then lblMotto.Text = """" & lblMotto.Text & """"
pnlMotto.Visible = (lblMotto.Text <> "")
lblHandyNr.Visible = MA.mit_MAVerzeichnis_allowHandynummer
lblHandyNr.Text = If(MA.mit_mobiltel, "")
cbxHomeoffice.Checked = MA.mit_homeoffice
Select Case If(MA.mit_abteilung, "")
Case "GF" : lblAbteilung.Text = "Geschäftsführung"
If MA.mit_vname = "Johann" And MA.mit_nname = "Luxbauer" Then lblAbteilung.Text = "VORSTAND / Geschäftsführung"
Case "VRR" : lblAbteilung.Text = "Verrechnung"
Case "BH", "BU" : lblAbteilung.Text = "Buchhaltung"
Case "MDM" : lblAbteilung.Text = "Maut/Diesel/Mehrwertsteuer"
Case "FISKAL" : lblAbteilung.Text = "Fiskalabteilung"
Case "ZOLL", "QS" : lblAbteilung.Text = "Zollabteilung"
If MA.mit_teamId IsNot Nothing Then
Dim team = SQL.DLookup("team_bezeichnung", "tblTeams", "team_id='" & MA.mit_teamId & "'", "ADMIN", "")
If team <> "" Then
lblAbteilung.Text &= " / " & team
End If
End If
Case Else : lblAbteilung.Text = If(MA.mit_abteilung, "")
End Select
If MA.mit_MAVerzeichnis_allowGebDat Then
pnlGeburtstag.Visible = True
If MA.mit_MAVerzeichnis_allowGebDatOhneJahr AndAlso IsDate(If(MA.mit_gebdat, "")) Then
lblGeburtstag.Text = CDate(MA.mit_gebdat).ToString("dd.MM.")
Else
lblGeburtstag.Text = If(MA.mit_gebdat, "")
End If
Else
pnlGeburtstag.Visible = False
End If
pic.BackgroundImage = My.Resources.personGray_m
picGeschlecht.Visible = True
If MA.mit_geschlecht = "w" Then
pic.BackgroundImage = My.Resources.personGray_w
picGeschlecht.BackgroundImage = My.Resources.weiblich
Else
pic.BackgroundImage = My.Resources.personGray_m
picGeschlecht.BackgroundImage = My.Resources.männlich
End If
If MA.mit_MAVerzeichnis_allowFoto AndAlso 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
End If
Select Case MA.getFirma
Case "VERAG" : PictureBox3.BackgroundImage = My.Resources.Verag_AG_Logopng
Case "UNISPED" : PictureBox3.BackgroundImage = My.Resources.Unisped_logo
Case "ATILLA" : PictureBox3.BackgroundImage = My.Resources.Atilla
Case "AMBAR" : PictureBox3.BackgroundImage = My.Resources.ambar_simple
Case "IMEX" : PictureBox3.BackgroundImage = My.Resources.IMEX_LOGO_simple
Case "FRONTOFFICE" : PictureBox3.BackgroundImage = My.Resources.FrontOfficeSUB_Horizontal
Case Else
PictureBox3.BackgroundImage = Nothing
End Select
'requestDone = Not callTimasSaldo
initTimasData()
pnlNotfallkontakt.Visible = False
If VERAG_PROG_ALLGEMEIN.cAllgemein.USRID = MA.mit_id Then
btnEdit.Visible = True
pnlNotfallkontakt.Visible = True
If VERAG_PROG_ALLGEMEIN.cAllgemein.MITARBEITER.mit_timasId IsNot Nothing Then
pnlZeiten.Visible = True
Else
pnlZeiten.Visible = False
End If
Else
pnlZeiten.Visible = False
End If
If VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("ADMINFUNCTIONS", "SDL") Then
btnEdit.Visible = True
btnSettings.Visible = True
pnlNotfallkontakt.Visible = True
End If
If VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("MA_TeamBearbeiten", "SDL") Then
If MA.getFirma = VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA Then 'MA derselben Firma bearbeiten
btnSettings.Visible = True
pnlNotfallkontakt.Visible = True
End If
End If
If VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("ZE_POSTGANG", "SDL") Then Button2.Visible = True
If VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("ZE_AKTENGANG", "SDL") Then btnAkten.Visible = True
If VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("Überstunden_auszahlen", "SDL") Then
If MA.getFirma = VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA Then 'MA derselben Firma bearbeiten
Button3.Visible = True
End If
End If
If VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("Überstunden_auszahlen_alle", "SDL") Then
Button3.Visible = True
End If
End If
End Sub
Sub clearMA()
lblName.Text = ""
lblMAId.Text = ""
lblSpitzname.Text = ""
lblFirma.Text = ""
lblNiederlassung.Text = ""
lblAbteilung.Text = ""
lblTelefon.Text = ""
lblMail.Text = ""
lblHandyNr.Text = ""
lblWohnadresse.Text = ""
pnlWohnadresse.Visible = False
pnlGeburtstag.Visible = False
pnlMotto.Visible = False
pic.BackgroundImage = My.Resources.personGray_m
picGeschlecht.Visible = False
pnlZeiten.Visible = False
lblNotfall_Name.Text = ""
lblNotfall_Handy.Text = ""
lblNotfall_Mail.Text = ""
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 btnEdit.Click
If sbMitarbeiter._value = "" Then Exit Sub
Dim f As New frmMitarbeitersucheBearbeiten(sbMitarbeiter._value)
f.ShowDialog(Me)
initMA()
End Sub
Private Sub frmMitarbeitersuche_Shown(sender As Object, e As EventArgs) Handles Me.Shown
If mit_id > 0 Then
sbMitarbeiter.SET_VALUE(mit_id)
sbMitarbeiter._value = mit_id
initMA()
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnSettings.Click
If sbMitarbeiter._value = "" Then Exit Sub
Dim f As New frmMitarbeitersucheEinstellungen(sbMitarbeiter._value)
f.ShowDialog(Me)
initMA()
End Sub
Sub setBGPic(art, MA)
HOVER_ART = art
If art = "" Or MA Is Nothing Then
pic.BackgroundImage = My.Resources.personGray_m
picGeschlecht.Visible = True
If MA.mit_geschlecht = "w" Then
pic.BackgroundImage = My.Resources.personGray_w
picGeschlecht.BackgroundImage = My.Resources.weiblich
Else
pic.BackgroundImage = My.Resources.personGray_m
picGeschlecht.BackgroundImage = My.Resources.männlich
End If
If MA Is Nothing Then Exit Sub
End If
If MA.mit_MAVerzeichnis_allowFoto Then
Try
Select Case art
Case "HOVER1" : If MA.mit_fotoHover1_DocId IsNot Nothing Then pic.BackgroundImage = Image.FromFile(cDATENSERVER.GET_PDFPath_BY_DocID(MA.mit_fotoHover1_DocId))
Case "HOVER2" : If MA.mit_fotoHover2_DocId IsNot Nothing Then pic.BackgroundImage = Image.FromFile(cDATENSERVER.GET_PDFPath_BY_DocID(MA.mit_fotoHover2_DocId))
Case Else : If MA.mit_foto_DocId IsNot Nothing Then pic.BackgroundImage = Image.FromFile(cDATENSERVER.GET_PDFPath_BY_DocID(MA.mit_foto_DocId))
End Select
Catch ex As Exception
pic.BackgroundImage = My.Resources.personGray_m
End Try
End If
End Sub
Private Sub pic_MouseHover(sender As Object, e As EventArgs) Handles pic.MouseHover
Dim point As Point
pic.PointToClient(point)
End Sub
Dim HOVER_ART = ""
Private Sub pic_MouseMove(sender As Object, e As MouseEventArgs) Handles pic.MouseMove
Dim art = ""
If e.X < pic.Size.Width / 2 Then
art = "HOVER1"
Else
art = "HOVER2"
End If
If art <> HOVER_ART Then
setBGPic(art, MA)
End If
End Sub
Private Sub pic_MouseLeave(sender As Object, e As EventArgs) Handles pic.MouseLeave
If HOVER_ART <> "" Then
setBGPic("", MA)
End If
End Sub
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles btnZEKommen.Click, btnZEGehen.Click, Button2.Click, btnAkten.Click
Dim art As String
If sender Is btnZEKommen Then
art = "in"
ElseIf sender Is btnZEGehen Then
art = "out"
ElseIf sender Is btnAkten Then
art = "akten"
Else
art = "post"
End If
If VERAG_PROG_ALLGEMEIN.cAllgemein.MITARBEITER.mit_timasId IsNot Nothing Then
Dim timas As New cTimasAPI("timas")
If art = "post" Then
'postgang ausstempen, dann beginn post, + 1h ende post
Dim askPost As MsgBoxResult = MsgBox("Postgang für " & VERAG_PROG_ALLGEMEIN.cAllgemein.USRKURZNAME & " eintragen?" & vbNewLine & Now.ToString(), vbYesNo)
If askPost = vbYes Then
Dim info As String = ""
Dim timestp = Now
Dim timeEntryExisting As Boolean = False
Dim isOnline = timas.getTimeEntries(cAllgemein.MITARBEITER.mit_timasId, Nothing, timeEntryExisting)
If timeEntryExisting AndAlso isOnline Then timas.setTimeEntry(cAllgemein.MITARBEITER, timestp, info, "out", 0) 'Ende
timestp = timestp.AddMinutes(1)
timas.setTimeEntry(cAllgemein.MITARBEITER, timestp, info, "in", 6) 'Start Post 6 Postgang
If VERAG_PROG_ALLGEMEIN.cAllgemein.MITARBEITER.mit_niederlassung <> "" Then
Select Case VERAG_PROG_ALLGEMEIN.cAllgemein.NIEDERLASSUNG
Case "SUB" : timestp = timestp.AddHours(1)
Case "SBG" : timestp = timestp.AddHours(1) 'Verag Post + AT Zoll
Case "WAI" : timestp = timestp.AddMinutes(30)
Case "NKD" : timestp = timestp.AddMinutes(20)
Case "DTB" : timestp = timestp.AddMinutes(30)
Case Else
timestp = timestp.AddMinutes(1) 'NICHT ERLAUBT
End Select
Else
timestp = timestp.AddMinutes(1) 'NICHT ERLAUBT
End If
timas.setTimeEntry(cAllgemein.MITARBEITER, timestp, info, "out", 6) ' Ende Post 6 Postgang
MsgBox(info)
Thread.Sleep(2000) 'warten bis Eintrag in Timas-DB
requestDone = False
initTimasData()
End If
ElseIf art = "akten" Then
Dim minutesBeforeStart As Integer = 1
If VERAG_PROG_ALLGEMEIN.cAllgemein.MITARBEITER.mit_niederlassung <> "" Then
Select Case VERAG_PROG_ALLGEMEIN.cAllgemein.NIEDERLASSUNG
Case "SUB" : minutesBeforeStart = 10
Case "NKN" : minutesBeforeStart = 45
Case Else
minutesBeforeStart = 1 'NICHT ERLAUBT
End Select
Else
minutesBeforeStart = 1 'NICHT ERLAUBT
End If
Dim aktengang As DateTime = Now().AddMinutes(-minutesBeforeStart)
Dim askPost As MsgBoxResult = MsgBox("Aktengang für " & VERAG_PROG_ALLGEMEIN.cAllgemein.USRKURZNAME & " eintragen?" & vbNewLine & aktengang.ToString(), vbYesNo)
If askPost = vbYes Then
Dim info As String = ""
Dim timestp = aktengang
Dim timeEntryExisting As Boolean = False
Dim isOnline = timas.getTimeEntries(cAllgemein.MITARBEITER.mit_timasId, Nothing, timeEntryExisting)
If Not timeEntryExisting AndAlso Not isOnline Then
timas.setTimeEntry(cAllgemein.MITARBEITER, timestp, info, "in", 10) 'Start 10 Aktengang
timestp = timestp.AddMinutes(minutesBeforeStart)
timas.setTimeEntry(cAllgemein.MITARBEITER, timestp, info, "out", 10) 'Ende 10 Aktengang
timestp = timestp.AddMinutes(1)
timas.setTimeEntry(cAllgemein.MITARBEITER, timestp, info, "in", 0) ' Start
End If
MsgBox(info)
Thread.Sleep(2000) 'warten bis Eintrag in Timas-DB
requestDone = False
initTimasData()
End If
Else
Dim resultCode As Integer = IIf(cbxHomeoffice.Checked, 3, 0)
If MA.mit_timasMehrereFirmen Then
Dim f As New frmZEButtons(art, MA.mit_timasFirmen)
f.ShowDialog()
If f.DialogResult = DialogResult.OK AndAlso f.resultCode >= 0 Then
resultCode = f.resultCode
Else
Exit Sub
End If
End If
'normales kommen/gehen
Dim a As MsgBoxResult = MsgBox(IIf(cbxHomeoffice.Checked, "Homeoffice", "Büro") & vbNewLine & sender.text & " für " & VERAG_PROG_ALLGEMEIN.cAllgemein.USRKURZNAME & vbNewLine & Now.ToString(), vbYesNo)
If a = vbYes Then
Dim info As String = ""
timas.setTimeEntry(cAllgemein.MITARBEITER, Now, info, art, resultCode)
MsgBox(info)
Thread.Sleep(2000) 'warten bis Eintrag in Timas-DB
requestDone = False
initTimasData()
End If
End If
End If
End Sub
Private Sub initTimasData()
'lblStatusZE.Visible = False
'btnEdit.Visible = False
'Eintrag für Zeitübersicht
'lblTimasZeiten.Visible = True
If Not requestDone Then
'lblTimasSaldo.Visible = False
lblTimasSaldo.Text = ""
Dim dtZeiten As New DataTable
If timas IsNot Nothing Then
Dim isServiceRunning As Boolean = True
Dim checkEntry As Boolean = timas.getTimeEntries(MA.mit_timasId, dtZeiten,, requestDone)
online = checkEntry
If requestDone Then
If checkEntry Then
lblStatusZE.BackColor = Color.Green
lblStatusZE.Text = "ONLINE"
btnZEGehen.Enabled = True
btnZEKommen.Enabled = False
btnAkten.Enabled = False
Else
lblStatusZE.Text = "OFFLINE"
lblStatusZE.BackColor = Color.Firebrick
btnZEGehen.Enabled = False
btnZEKommen.Enabled = True
btnAkten.Enabled = True
End If
Else
If MA.mit_timasId Is Nothing Then
lblStatusZE.Text = "keine ZE"
Else
lblStatusZE.Text = "Serverfehler"
End If
lblStatusZE.BackColor = Color.Gray
btnZEGehen.Enabled = False
btnZEKommen.Enabled = False
Button2.Enabled = False
btnAkten.Enabled = False
End If
If VERAG_PROG_ALLGEMEIN.cAllgemein.USRID = MA.mit_id Then
timas.getTimeSaldo(MA.mit_timasId, lblTimasSaldo.Text, "dailyBalanceYesterday", isServiceRunning, "time")
If Not isServiceRunning Then
MsgBox("Abfragefehler am Timas-Server!")
End If
lblStatusZE.Visible = True
lblTimasSaldo.Visible = True
If dtZeiten.Rows.Count > 0 Then
pnlZeiten.Visible = True
Else
pnlZeiten.Visible = False
End If
End If
End If
End If
End Sub
Private Sub Button1_Click_2(sender As Object, e As EventArgs) Handles Button1.Click
If Not ContextMenuStrip1.Items.ContainsKey("timas_old") Then
Dim plose = New ToolStripMenuItem() With {.Text = "TimasWEB", .Name = "timas_old", .Font = New Font(Me.Font.FontFamily, Me.Font.Size)}
ContextMenuStrip1.Items.Add(plose)
AddHandler plose.Click, AddressOf mnuItemTimas_Clicked
End If
If Not ContextMenuStrip1.Items.ContainsKey("timas_new") Then
Dim plose = New ToolStripMenuItem() With {.Text = "Timas ÜBERSICHT", .Name = "timas_new", .Font = New Font(Me.Font.FontFamily, Me.Font.Size)}
ContextMenuStrip1.Items.Add(plose)
AddHandler plose.Click, AddressOf mnuItemTimas_Clicked
End If
ContextMenuStrip1.Show(Cursor.Position)
End Sub
Private Sub mnuItemTimas_Clicked(sender As Object, e As EventArgs)
ContextMenuStrip1.Hide()
Dim item As ToolStripMenuItem = TryCast(sender, ToolStripMenuItem)
Dim Paramslist As New cParameterList(VERAG_PROG_ALLGEMEIN.cAllgemein.PROGID)
If item IsNot Nothing Then
If item.Name = "timas_new" Then
Process.Start(Paramslist.GET_PARAMETER_VALUE(item.Name))
ElseIf item.Name = "timas_old" Then
Process.Start(Paramslist.GET_PARAMETER_VALUE(item.Name))
End If
End If
End Sub
Private Sub PictureBox5_Click(sender As Object, e As EventArgs) Handles PictureBox5.Click
Dim webAddress As String = "https://wiki.verag.ag/de/software/zeiterfassung/zeiterfassung"
Process.Start(webAddress)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If sbMitarbeiter._value = "" Then Exit Sub
Dim f As New frmUeberstundenauszahlen(sbMitarbeiter._value)
f.ShowDialog(Me)
End Sub
End Class