390 lines
14 KiB
VB.net
390 lines
14 KiB
VB.net
Imports System.ComponentModel
|
|
Imports System.Drawing
|
|
Imports System.Net
|
|
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
|
|
Dim requestDone 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()
|
|
End If
|
|
|
|
If VERAG_PROG_ALLGEMEIN.cAllgemein.MITARBEITER.mit_MAVerzeichnis_SettingsTstmp Is Nothing And Not VERAG_PROG_ALLGEMEIN.cAllgemein.MITARBEITER.mit_pseudoUser Then
|
|
MsgBox("Sie müssen Ihren Benutzer erstmal konfigurieren, um das Verzeichnis einsehen zu können. Sie können die Einstellungen jederzeit ändern.")
|
|
|
|
Dim f As New frmMitarbeitersucheBearbeiten(VERAG_PROG_ALLGEMEIN.cAllgemein.USRID)
|
|
If f.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then
|
|
Else
|
|
Me.Close()
|
|
End If
|
|
initMA()
|
|
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
|
|
initMA()
|
|
End Sub
|
|
|
|
Sub initMA()
|
|
btn.Visible = False
|
|
pnl.Visible = False
|
|
lblTimasZeiten.Visible = False
|
|
lblTimasSaldo.Visible = False
|
|
Panel1.Visible = False
|
|
btnSettings.Visible = False
|
|
Dim MA As cMitarbeiter = Nothing
|
|
If sbMitarbeiter._value <> "" Then
|
|
MA = New cMitarbeiter(sbMitarbeiter._value)
|
|
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, "")
|
|
|
|
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
|
|
|
|
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, "")
|
|
|
|
|
|
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
|
|
If VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("ADMINFUNCTIONS", "SDL") Then
|
|
btn.Visible = True
|
|
btnSettings.Visible = True
|
|
End If
|
|
If VERAG_PROG_ALLGEMEIN.cAllgemein.USRID = MA.mit_id Then
|
|
btn.Visible = True
|
|
'Eintrag für Zeitübersicht
|
|
lblTimasZeiten.Visible = True
|
|
lblTimasSaldo.Visible = True
|
|
If Not requestDone Then
|
|
|
|
If timas IsNot Nothing Then
|
|
timas.getTimeSaldo(MA.mit_timasId, lblTimasSaldo.Text)
|
|
timas.getTimeEntries(MA.mit_timasId, lblTimasZeiten.Text, requestDone)
|
|
End If
|
|
|
|
End If
|
|
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
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Sub clearMA()
|
|
|
|
lblName.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
|
|
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
|
|
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)
|
|
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
|
|
|
|
Private Sub getTime(maid)
|
|
Try
|
|
Dim returnText As String = ""
|
|
lblTimasZeiten.Text = ""
|
|
|
|
If maid Is Nothing Then
|
|
Exit Sub
|
|
End If
|
|
|
|
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
|
Dim rest As New Chilkat.Rest
|
|
Dim API_STRING As String
|
|
|
|
|
|
API_STRING = "https://zeit.verag.ag"
|
|
|
|
Dim success As Boolean
|
|
|
|
rest.VerboseLogging = True
|
|
Dim bTls As Boolean = True
|
|
Dim port As Integer = 443
|
|
Dim bAutoReconnect As Boolean = True
|
|
success = rest.Connect(API_STRING, port, bTls, bAutoReconnect)
|
|
If (success <> True) Then
|
|
Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
|
|
Debug.WriteLine(rest.LastErrorText)
|
|
'lblTimas.Text = rest.LastErrorText
|
|
|
|
End If
|
|
|
|
success = rest.SetAuthBasic("admin", "BmWr501956")
|
|
|
|
If (success <> True) Then
|
|
Debug.WriteLine("BAFailReason: " & rest.ConnectFailReason)
|
|
Debug.WriteLine(rest.LastErrorText)
|
|
'lblTimas.Text = rest.LastErrorText
|
|
|
|
End If
|
|
|
|
|
|
Dim responseJson As String = rest.FullRequestNoBody("GET", "/rest/web-api/employees/" & maid & "/balance")
|
|
If (rest.LastMethodSuccess <> True) Then
|
|
Debug.WriteLine(rest.LastErrorText)
|
|
Exit Sub
|
|
End If
|
|
|
|
If (rest.ResponseStatusCode <> 200) Then
|
|
Debug.WriteLine(rest.ResponseHeader)
|
|
'lblTimas.Text = rest.ResponseStatusCode & " " & rest.ResponseStatusText
|
|
Exit Sub
|
|
End If
|
|
|
|
Debug.WriteLine(responseJson)
|
|
|
|
|
|
Dim json As New Chilkat.JsonObject
|
|
success = json.Load(responseJson)
|
|
If (success <> True) Then
|
|
Debug.WriteLine(json.LastErrorText)
|
|
End If
|
|
|
|
Debug.WriteLine(json)
|
|
|
|
'"overallBalance" 101580,
|
|
'"dailyBalance": -17340,
|
|
'"monthlyBalance": -328380,
|
|
'"actualTimeOfDay": 4260,
|
|
|
|
|
|
Dim saldo = json.StringOf("dailyBalanceYesterday") 'Tagessaldo (gestern) in Sekunden
|
|
|
|
If saldo IsNot Nothing Then
|
|
Dim saldoAsDouble = CDbl(saldo)
|
|
saldoAsDouble = Math.Round(saldoAsDouble / 3600, 2)
|
|
returnText = "Saldo Vortag: " & saldoAsDouble & "h"
|
|
End If
|
|
lblTimasSaldo.Text = returnText
|
|
|
|
|
|
Dim yesterdayMidnight As DateTime
|
|
yesterdayMidnight = Today().AddDays(-5)
|
|
rest.AddQueryParam("id", maid)
|
|
rest.AddQueryParam("from", yesterdayMidnight.ToString("yyyy-MM-ddThh:mm:ss"))
|
|
rest.AddQueryParam("to", Now().ToString("yyyy-MM-ddThh:mm:ss"))
|
|
|
|
|
|
|
|
Dim Response As String
|
|
Response = rest.FullRequestNoBody("GET", "/rest/web-api/employees/" & maid & "/bookings")
|
|
If (rest.LastMethodSuccess <> True) Then
|
|
Debug.WriteLine(rest.LastErrorText)
|
|
Exit Sub
|
|
End If
|
|
|
|
If (rest.ResponseStatusCode <> 200) Then
|
|
Debug.WriteLine(rest.ResponseHeader)
|
|
'rest.ResponseStatusCode & " " & rest.ResponseStatusText
|
|
Exit Sub
|
|
End If
|
|
|
|
Debug.WriteLine(Response)
|
|
Dim jsonArray As New Chilkat.JsonArray
|
|
success = jsonArray.Load(Response)
|
|
If (success <> True) Then
|
|
Debug.WriteLine(jsonArray.LastErrorText)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
If jsonArray.Size = -1 Then
|
|
Exit Sub
|
|
End If
|
|
|
|
'Dim dt As New DataTable
|
|
'dt.Columns.Add("statusid", GetType(Integer))
|
|
'dt.Columns.Add("stamp", GetType(DateTime))
|
|
'dt.Columns.Add("type", GetType(String))
|
|
|
|
|
|
|
|
Dim j As Integer = 0
|
|
While j < jsonArray.Size
|
|
|
|
Dim timeEntry As Chilkat.JsonObject = jsonArray.ObjectAt(j)
|
|
|
|
If IsDate(timeEntry.StringOf("stamp")) Then
|
|
If CDate(timeEntry.StringOf("stamp")) >= Today() Then
|
|
|
|
|
|
'Dim R As DataRow = dt.NewRow
|
|
'R("statusid") = timeEntry.StringOf("statusid")
|
|
'R("stamp") = timeEntry.StringOf("stamp")
|
|
'R("type") = timeEntry.StringOf("type")
|
|
'dt.Rows.Add(R)
|
|
|
|
lblTimasZeiten.Text &= " " & IIf(timeEntry.StringOf("type") = "in", "+", " - ") & CDate(timeEntry.StringOf("stamp")).ToString("hh:mm:ss")
|
|
If jsonArray.Size - 1 = j Then
|
|
lblTimasZeiten.Text &= " Status: " & IIf(timeEntry.StringOf("type") = "in", "Anwesend", "Abwesend")
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
j = j + 1
|
|
End While
|
|
|
|
|
|
|
|
requestDone = True
|
|
rest.ClearAllQueryParams()
|
|
|
|
Catch ex As WebException
|
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
|
End Try
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub PictureBox9_Click(sender As Object, e As EventArgs) Handles PictureBox9.Click
|
|
Dim webAddress As String = "https://zeit.verag.ag/webterminal/"
|
|
Process.Start(webAddress)
|
|
End Sub
|
|
End Class |