Imports IntraSell_DLL
Imports IntraSell_Net_Base

Public Class ZustellerAbrechnung
    Inherits AbstractForm

    Private Sub FahrerAbrechnung_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
            DatumVon.Value = AdaptZeiten(AdaptToday())
            DatumUntil.Value = AdaptZeiten(AdaptToday().AddDays(1).AddSeconds(-1))

            DatumVon.Format = DateTimePickerFormat.Custom
            DatumVon.CustomFormat = "dd MM yyyy HH mm"

            DatumUntil.Format = DateTimePickerFormat.Custom
            DatumUntil.CustomFormat = "dd MM yyyy HH mm"

            Dim email As String = FirstRow("select Email from ofMitarbeiter where idnr= " & MitarbeiterID)
            If Not email.Contains("@") Then
                TextBoxEmail.Text = "Email hier eintragen..."
            Else
                TextBoxEmail.Text = email
            End If

        Catch ex As Exception

        End Try
    End Sub

    Private Sub Form_Verlassen() Handles MyBase.Verlassen
        Me.Close()
    End Sub

    Private Sub FilterButton_Click(sender As Object, e As EventArgs) Handles FilterButton.Click
        Try
            Dim filter = ""
            If IsNumeric(MitarbeiterComboBox.IDNR) AndAlso MitarbeiterComboBox.IDNR > 0 Then
                filter = "MitarbeiterNR=" & MitarbeiterComboBox.IDNR
            End If
            ModuleReports.ShowZustellungen(DatumVon.Value, DatumUntil.Value, filter)
        Catch ex As Exception
            'Ignore
        End Try
    End Sub

    Private Sub FilterButtonPOS_Click(sender As Object, e As EventArgs) Handles FilterButtonPOS.Click
        Try
            Dim filter = ""
            If IsNumeric(MitarbeiterComboBox.IDNR) AndAlso MitarbeiterComboBox.IDNR > 0 Then
                filter = "MitarbeiterNR=" & MitarbeiterComboBox.IDNR
            End If
            ModuleReports.ShowZustellungen(DatumVon.Value, DatumUntil.Value, filter, reportName:="ReportZustellungPOS.rdlc")
        Catch ex As Exception
            'Ignore
        End Try
    End Sub

    Private Sub ButtonSenden_Click(sender As Object, e As EventArgs) Handles ButtonSenden.Click
        Try
            ModuleReports.ShowZustellungen(DatumVon.Value, DatumUntil.Value, exportAsPDF:=True)
        Catch ex As Exception
            'Ignore
        End Try
    End Sub
End Class