
Public Class cUserBerechtigungen
    Property ber_id As String = ""
    Property ber_name As String = ""
    Property bepr_programm As String = ""
    Property ber_sicherheitsstufe As String = ""
End Class
Public Class cBerechtigungen
    Property ber_id As String = ""
    Property ber_name As String = ""
    Property ber_sicherheitsstufe As String = ""
    Property ber_progId As String = ""
    Property prog_codename As String = ""
End Class
Public Class cProgramm
    Property prog_id As Integer
    Property prog_codename As String = ""
    Property prog_name As String = ""
    Property prog_aktuelleVersion As String = ""
    Property prog_info As String = ""
    Property prog_source_path As String = ""
    Property prog_dev_path As String = ""
    Property prog_prod_path As String = ""
    Property prog_installer_source_path As String = ""
    Property prog_installer_dev_path As String = ""
    Property prog_installer_prod_path As String = ""
    Property prog_installer_prod_path_atilla As String = ""
    Property prog_prod_path_atilla As String = ""
    Property prog_prod_path_imex As String = ""
    Property prog_installer_prod_path_imex As String = ""
    Property prog_prod_path_SBG As String = ""
    Property prog_installer_prod_path_SBG As String = ""
    Property prog_prod_path_WAI As String = ""
    Property prog_installer_prod_path_WAI As String = ""
    Property prog_prod_path_NKD As String = ""
    Property prog_installer_prod_path_NKD As String = ""
    Property prog_prod_path_NEU As String = ""
    Property prog_installer_prod_path_NEU As String = ""

    Property prog_prod_path_UNI As String = ""
    Property prog_installer_prod_path_UNI As String = ""
    Property prog_prod_path_AMB As String = ""
    Property prog_installer_prod_path_AMB As String = ""

    Property prog_prod_path_Backup As String = ""
    Property prog_installer_prod_path_Backup As String = ""
End Class

Public Class cSeminar
    Property sem_id As Integer
    Property sem_von As DateTime
    Property sem_bis As DateTime
    Property sem_dauer As String = ""
    Property sem_name As String = ""
    Property sem_vortragender As String = ""
    Property sem_vortragender_mitId As Integer
    Property sem_ort As String = ""
    Property sem_inhalt As String = ""
    Property sem_inhalt2 As String = ""
    Property sem_info As String = ""
    Property sem_type As String = ""
    Property sem_isVeragSeminar As Boolean
    Property sem_isIntAusbildung As Boolean
    Property sem_bezeichnung As String = ""

End Class

Public Class cBuergschaft
    Property brg_id As Integer = -1
    Property brg_datum As String = ""
    Property brg_at_tag As String = ""
    Property brg_at_woche As String = ""
    Property brg_de_tag As String = ""
    Property brg_de_woche As String = ""
    Property brg_at_tag_atlas As String = ""
    Property brg_at_tag_zolaris As String = ""
    Property brg_at_woche_atlas As String = ""
    Property brg_at_woche_zolaris As String = ""
    Property brg_de_tag_atlas As String = ""
    Property brg_de_woche_atlas As String = ""

    Property brg_de2_tag As String = ""
    Property brg_de2_woche As String = ""
    Property brg_de2_tag_atlas As String = ""
    Property brg_de2_woche_atlas As String = ""
End Class

Public Class cDienstMA
    Property dstma_id As Integer
    Property dstma_mitId As Integer
    Property dstma_land As String = ""
    Property dstma_abteilung As String = ""
    Property dstma_funktion As String = ""
    Property dstma_arbvh As String = ""
    Property dstma_wochenStunden As Double = 0
    Property dstma_stammSchicht As String = ""
    Property dstma_kuerzel As String = ""
    Property dstma_reihenfolge As Integer
    Property dstma_farbe As String
    Property dstma_muster As Boolean = False
    Property dstma_WEStdRegelAZ As Boolean = False
    Property dstma_4wo As Boolean = False
    Property dstma_TageProWoche As Integer = -1
    Property dstma_inaktiv As Boolean = False
    Property dstma_TzFeiertageStd As Object = Nothing

End Class

Public Class cDienstAbwesendheiten
    Property dstna_id As Integer
    Property dstna_mitId As Integer
    Property dstna_datum_von As Date
    Property dstna_datum_bis As Date
    Property dstna_grund As String = ""
End Class

Public Class cDienstAbwesendheitenKW
    Property dstnk_id As Integer
    Property dstnk_mitId As Integer
    Property dstnk_kw As Integer
    Property dstnk_jahr As Integer
    Property dstnk_grund As String = ""
    Property dstnk_info As String = ""
End Class

Public Class cDienstEintrag
    Property dstetr_id As Integer
    Property dstetr_dstmaId As Integer
    Property dstetr_datum As String = ""
    Property dstetr_art As String = ""
    Property dstetr_von As String = ""
    Property dstetr_bis As String = ""
    Property dstetr_pause As Double = 0
    Property dstetr_grund As String = ""
    Property dstetr_info As String = ""
    Property dstetr_splitschicht As Boolean = False
    Property dstetr_hauptsplitschicht As Boolean = False


End Class


Public Class cMAShort
    Property mit_id As Integer
    Property mit_vname As String = ""
    Property mit_nname As String = ""
End Class

Public Class cDienstTeilzeit
    Property dsttz_id As Integer
    Property dsttz_maId As Integer
    Property dsttz_dienstplan As String = ""
    Property dsttz_wotag As String = ""
    Property dsttz_abt As String = ""
    Property dsttz_von As String = ""
    Property dsttz_bis As String = ""
    Property dsttz_pause As String = ""
    Property dsttz_bemerkung As String = ""

End Class


Public Class cDienstDetails
    Property dedet_id As Integer
    Property dedet_abt As String = ""
    Property dedet_woTag As String = ""
    Property dedet_info As String = ""
    Property dedet_von As String = ""
    Property dedet_bis As String = ""
    Property dedet_pause As Double = 0

End Class

Public Class cDienstDGV
  
    Property dgvName As String
    Property dgvDatum As Date
    Property dgvAbteilung As String = ""
    Property dgvVon As String = ""
    Property dgvBis As String = ""
    Property dgvIsHauptsplitschicht As Boolean = False
    Property USRCNTL As usrCntlDienstWoche = Nothing

    Public Sub New(ByVal dgvName As String, ByVal dgvDatum As Date, ByVal dgvAbteilung As String, ByVal dgvVon As String, ByVal dgvBis As String, Optional USRCNTL As Object = Nothing)
        Me.dgvName = dgvName
        Me.dgvDatum = dgvDatum
        Me.dgvAbteilung = dgvAbteilung
        Me.dgvVon = dgvVon
        Me.dgvBis = dgvBis
        Me.USRCNTL = USRCNTL
    End Sub

    Public Sub New(ByVal dgvName As String, ByVal dgvDatum As Date, ByVal dgvAbteilung As String, Optional USRCNTL As Object = Nothing, Optional dgvIsHauptsplitschicht As Boolean = False)
        Me.dgvName = dgvName
        Me.dgvDatum = dgvDatum
        Me.dgvAbteilung = dgvAbteilung
        Me.dgvVon = "00:00"
        Me.dgvBis = "00:00"
        Me.USRCNTL = USRCNTL
        Me.dgvIsHauptsplitschicht = dgvIsHauptsplitschicht
    End Sub


End Class


Public Class cDienstNA
    Property dstna_id As Integer
    Property dstna_mitId As Integer
    Property dstna_datum As Date
    Property dstna_grund As String = ""
    Property dstna_info As String = ""

End Class



Public Class cDienstMitarbAbweichendeWochenstunden
    Property dstaw_id As Integer
    Property dstaw_dstmaId As Integer
    Property dstaw_von As Date
    Property dstaw_bis As Date
    Property dstaw_std As Double

    Shared Function GET_STD(dstmaId As Integer, datum As Date) As Double
        Dim sql As New VERAG_PROG_ALLGEMEIN.SQL
        Return sql.getValueTxtBySql("SELECT TOP 1 [dstaw_std] FROM [tblDienstMitarbAbweichendeWochenstunden]  where [dstaw_dstmaId]='" & dstmaId & "' and '" & datum.ToShortDateString & "' between dstaw_von and dstaw_bis", "ADMIN",,, -1)
    End Function

    Shared Function GET_STD_LIST(datum As Date) As List(Of cDienstMitarbAbweichendeWochenstunden)
        GET_STD_LIST = New List(Of cDienstMitarbAbweichendeWochenstunden)
        Dim sql As New VERAG_PROG_ALLGEMEIN.SQL
        Dim dt = sql.loadDgvBySql("SELECT * FROM [tblDienstMitarbAbweichendeWochenstunden]", "ADMIN")
        If dt IsNot Nothing Then
            For Each r In dt.Rows
                Dim ABW As New cDienstMitarbAbweichendeWochenstunden
                ABW.dstaw_id = r("dstaw_id")
                ABW.dstaw_dstmaId = r("dstaw_dstmaId")
                ABW.dstaw_von = r("dstaw_von")
                ABW.dstaw_bis = r("dstaw_bis")
                ABW.dstaw_std = r("dstaw_std")
                GET_STD_LIST.Add(ABW)
            Next
        End If
        '  Return sql.getValueTxtBySql("SELECT TOP 1 [dstaw_std] FROM [tblDienstMitarbAbweichendeWochenstunden]  where [dstaw_dstmaId]='" & dstmaId & "' and '" & datum.ToShortDateString & "' between dstaw_von and dstaw_bis", "ADMIN",,, -1)
    End Function


    Shared Function GET_STD(dstmaId As Integer, datumMontag As Date, NormalWochenstunden As Integer, TZTagesStunden As Integer) As Double
        GET_STD = 0
        Dim abw_bool As Boolean = False
        Dim sql As New VERAG_PROG_ALLGEMEIN.SQL

        Dim exists = sql.getValueTxtBySql("SELECT count(*) FROM [tblDienstMitarbAbweichendeWochenstunden]  where [dstaw_dstmaId]='" & dstmaId & "' and dstaw_bis > '" & datumMontag.ToShortDateString & "' ", "ADMIN",,, -1)
        If exists <= 0 Then Return NormalWochenstunden

        For i = 0 To 4
            Dim abw = sql.getValueTxtBySql("SELECT TOP 1 [dstaw_std] FROM [tblDienstMitarbAbweichendeWochenstunden]  where [dstaw_dstmaId]='" & dstmaId & "' and '" & datumMontag.AddDays(i).ToShortDateString & "' between dstaw_von and dstaw_bis", "ADMIN",,, -1)

            If abw > 0 Then
                GET_STD += abw / 5
                abw_bool = True
            Else
                If False Then 'TZTagesStunden > 0 Then
                    GET_STD += TZTagesStunden
                Else
                    GET_STD += NormalWochenstunden / 5
                End If
            End If
        Next
        If Not abw_bool Then GET_STD = NormalWochenstunden ' Wenn keine Abweicheung, einfach normal belassen...
    End Function



    Shared Function GET_STD_LIST(STD_LIST As List(Of cDienstMitarbAbweichendeWochenstunden), dstmaId As Integer, datumMontag As Date, NormalWochenstunden As Integer, TZTagesStunden As Integer) As Double
        If STD_LIST Is Nothing Then Return NormalWochenstunden
        GET_STD_LIST = 0
        Dim abw_bool As Boolean = False

        For i = 0 To 4
            Dim abw As Double = 0
            For Each l In STD_LIST
                If l.dstaw_dstmaId = dstmaId AndAlso (datumMontag.AddDays(i) >= l.dstaw_von And datumMontag.AddDays(i) <= l.dstaw_bis) Then
                    abw = l.dstaw_std
                End If
            Next

            If abw > 0 Then
                GET_STD_LIST += abw / 5
                abw_bool = True
            Else
                If False Then 'TZTagesStunden > 0 Then
                    GET_STD_LIST += TZTagesStunden
                Else
                    GET_STD_LIST += NormalWochenstunden / 5
                End If
            End If
        Next
        If Not abw_bool Then GET_STD_LIST = NormalWochenstunden ' Wenn keine Abweicheung, einfach normal belassen...
    End Function

End Class
