Public Class frmDienstAbwesenheitenUebersicht
    Dim week() As String = {"SO", "MO", "DI", "MI", "DO", "FR", "SA"}
    Dim SQLDienst As New cDienstplan

    Private Sub frmDienstAbwesenheitenUebersicht_Load(sender As Object, e As EventArgs) Handles Me.Load
        initDGV()
    End Sub
    Sub initDGV()
        With dgvAbwesenheit
            .DataSource = SQLDienst.loadDGV("SELECT dstna_id,dstna_dstmaId,dstma_kuerzel ,dstna_datum_von,dstna_datum_bis, dstna_grund,dstna_info FROM tblDienstNichtAnwesend,tblDienstMitarb WHERE dstma_id=dstna_dstmaId AND dstna_datum_bis >= '" & Now.ToShortDateString & "' ORDER BY dstna_datum_von")
            .Columns(0).Visible = False
            .Columns(1).Visible = False
            .Columns(2).HeaderText = "Mitarbeiter"
            .Columns(3).HeaderText = "von"
            .Columns(4).HeaderText = "bis"
            .Columns(5).HeaderText = "Art"
            .Columns(6).HeaderText = "Info"


        End With
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btnDel.Click
        If dgvAbwesenheit.SelectedRows.Count > 0 Then
            If vbYes = MsgBox("Wirklich löschen?", vbYesNoCancel) Then
                SQLDienst.delDienstNichtAnwesend(dgvAbwesenheit.CurrentRow.Cells(0).Value)

                Dim d As Date = dgvAbwesenheit.CurrentRow.Cells(3).Value
                While d.ToShortDateString <= CDate(dgvAbwesenheit.CurrentRow.Cells(4).Value).ToShortDateString
                    SQLDienst.updateDienstEintragArtChangeByMitId(dgvAbwesenheit.CurrentRow.Cells(1).Value, d, "FREI", "00:00", "00:00", "0")
                    d = d.AddDays(1)
                End While

                initDGV()
                frmDienstplan.initDienstplan()
            End If
        End If
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles btnUrl.Click
        frmDiestEintrag.art = "URL"
        frmDiestEintrag.Show()
    End Sub

    Private Sub Button10_Click(sender As Object, e As EventArgs) Handles btnKs.Click
        frmDiestEintrag.art = "KS"
        frmDiestEintrag.Show()
    End Sub

    Private Sub Button12_Click(sender As Object, e As EventArgs) Handles btnSo.Click
        frmDiestEintrag.art = "DR"
        frmDiestEintrag.Show()
    End Sub

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