Imports IntraSell_DLL
Imports IntraSell_Net_Base

''' <summary>
'''  VorgangWizzard
''' </summary>
''' <remarks></remarks>
Public Class VorgangWizzardSammelrechnung

    Dim loading As Boolean = True
    Shared Property RechnungsNummern As List(Of dsVorgaenge.buchVorgangListeRow)
    Shared Property MandantNr As Integer

    Private Sub VorgangWizzard_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load
        Try
            loading = True
            FillComboBox(MandantComboBox, "SELECT IDNR, Firma FROM Mandant ORDER By Firma", "Firma", "IDNR")
            MandantComboBox.SelectedValue = MandantNr
            'KundNrAdressenControl.IDNR = ModuleGlobals.KundenIDNR
            KundNrAdressenControl.Filter = String.Format("Mandant!={0} and Status='Kunde'", MandantNr)
            SetControlStatus()
            loading = False
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub

    Private Sub OK_Button_Click(sender As Object, e As System.EventArgs) Handles OK_Button.Click
        Try
            SammelRechnungErstellen(MandantComboBox.SelectedValue, KundNrAdressenControl.IDNR, VorgangTypen.AR, RechnungsNummern:=RechnungsNummern)
            DialogResult = DialogResult.OK
            Close()
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub

    Private Sub Cancel_Button_Click(sender As Object, e As System.EventArgs) Handles Cancel_Button.Click
        DialogResult = DialogResult.Cancel
        Close()
    End Sub



    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub SetControlStatus()
        Try
            OK_Button.Enabled = KundNrAdressenControl.IDNR > 0
        Catch ex As Exception
        End Try
    End Sub

    Private Sub KundNrAdressenControl_IDNRChanged(IDNR As Integer) Handles KundNrAdressenControl.IDNRChanged
        SetControlStatus()
    End Sub

End Class
