Imports IntraSell_DLL
Imports IntraSell_Net_Base

Public Class Kundenadresse


    Private Sub TouchKundeAnlegen_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="KundNr"></param> 
    ''' <remarks></remarks>
    Public Sub ShowIDNR(KundNr As Integer)
        Try

            FillComboBox(PreislisteComboBox, SQL_PREISLISTEN, "PreislisteName")
            'TODO
            'FillComboBox(Me.KundengruppeComboBox, SQL_KUNDENGRUPPEN, "Kundengruppe")

            DataSetKunden._ofadressen_settings.Clear()
            DataSetKunden.ofadressen.Clear()
            OfAdressenTableAdapter.FillByIDNR(DataSetKunden.ofadressen, KundNr)
            Ofadressen_settingsTableAdapter.Fill(DataSetKunden._ofadressen_settings, KundNr)

            If Ofadressen_settingsBindingSource.Current Is Nothing Then
                KundeSettingsAnlegen(KundNr)
            End If

            Notiz.Text = FirstRow("select notizen from ofAnrufe where adrnr=" & KundNr & " order by AnrufNr desc")
            AdressenDetailControlQuick1.Enabled = True
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub


    Private Sub AdressenDetailControlQuick1_Enter(sender As Object, e As EventArgs) Handles AdressenDetailControlQuick1.Enter
        Exit Sub
        ' Dim cur As dsAdressen.ofadressenRow = Nothing
        ' If Me.ofAdressenBindingSource.Current Is Nothing Then
        '     cur = DataSetKunden.ofadressen.NewofadressenRow
        '     cur.IDNR = NextId("ofAdressen", "Idnr")
        '     DataSetKunden.ofadressen.AddofadressenRow(cur)
        '     Me.ofAdressenBindingSource.MoveLast()
        ' Else
        '     cur = Me.ofAdressenBindingSource.Current.row
        '
        ' End If
    End Sub

    Private Sub TouchKundeAnlegen(tel As Object)
        Dim cur As dsAdressen.ofadressenRow = Nothing
        cur = DataSetKunden.ofadressen.NewofadressenRow
        cur.IDNR = NextId("ofAdressen", "Idnr")
        cur.Tel = tel
        DataSetKunden.ofadressen.AddofadressenRow(cur)
        ofAdressenBindingSource.MoveLast()

        KundeSettingsAnlegen(cur.IDNR)

        AdressenDetailControlQuick1.Enabled = True
        AdressenDetailControlQuick1.Focus()
    End Sub

    Sub KundeSettingsAnlegen(IDNR As Integer)
        Dim curSettings As dsAdressen._ofadressen_settingsRow = Nothing
        curSettings = DataSetKunden._ofadressen_settings.New_ofadressen_settingsRow
        curSettings.IDNR = IDNR
        DataSetKunden._ofadressen_settings.Add_ofadressen_settingsRow(curSettings)
        Ofadressen_settingsBindingSource.MoveLast()
    End Sub


End Class
