Imports VERAG_PROG_ALLGEMEIN


Class frmNacherfassungImport
    Public Aviso As cAviso
    Public SendungId As Integer = -1
    Dim KDSQL As New SDL.kundenSQL
    Dim SQLAVISO As New cAvisoDAL
    Dim SQLADMIN As New adminfunc
    Public avisoLinkId = -1
    Public SPEDITIONSBUCH As VERAG_PROG_ALLGEMEIN.cSpeditionsbuch
    Dim PosAnzahl As Integer = 0
    Dim SENDUNG As VERAG_PROG_ALLGEMEIN.cSendungen

    Dim ATLAS_SERVER_VERBINDUNG = "ATLAS"
    Sub New()
        InitializeComponent()
    End Sub
    Sub New(AvisoID As Integer)
        InitializeComponent()
        Me.Aviso = SQLAVISO.LesenAviso(AvisoID, "")
    End Sub


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

    Function getKdNrFromSearch(Optional srchtxt As String = "") As String
        Dim testDialog As New SDL.frmKundenSuche(srchtxt)
        If testDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK Then
            Return testDialog.kundenNrSearch.Text
        Else
            Return ""
        End If
    End Function


    Private Sub ComboBoxZollsystem_KeyDown(sender As Object, e As KeyEventArgs) Handles ComboBoxZollsystem.KeyDown
        If e.KeyCode = Keys.Return Then
            TextBox1.Focus()
        End If
    End Sub

    Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyDown
        If e.KeyCode = Keys.Return Then
            TextBox2.Focus()
        End If
    End Sub

    Private Sub TextBox2_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox2.KeyDown
        If e.KeyCode = Keys.Return Then
            Button1.PerformClick()
        End If
    End Sub




    ' Private fNEF = DirectCast(Me.Owner, frmNacherfassung)

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim ZOLL_IMPORT As New DAKOSY_Worker.cZOLL_IMPORT
        Dim notFound = False
        SPEDITIONSBUCH = ZOLL_IMPORT.IMPORT(SPEDITIONSBUCH, avisoLinkId, SendungId, strManNr, strManNl, cboNiederlassung.SelectedIndex, TextBox1.Text, TextBox2.Text, notFound)
        If notFound Then
            MsgBox("Eintrag nicht gefunden")
        End If
        Me.Close()
    End Sub

    Dim strManNr = "VERA"
    Dim strManNl = "SUB"

    Private Sub frmNacherfassungImport_Load(sender As Object, e As EventArgs) Handles Me.Load

        ComboBoxZollsystem.SelectedIndex = 0
        Dim fNEF = DirectCast(Me.Owner, frmNacherfassungNEU)
        If fNEF.cboZollsystem._value = "A" Then ComboBoxZollsystem.SelectedIndex = 0
        If fNEF.cboZollsystem._value = "E" Then ComboBoxZollsystem.SelectedIndex = 1
        If fNEF.txtAtlasBezNrEZA.Text <> "" Then TextBox1.Text = fNEF.txtAtlasBezNrEZA.Text
        If fNEF.txtAtlasBezNrNCTS.Text <> "" Then TextBox2.Text = fNEF.txtAtlasBezNrNCTS.Text

        cboNiederlassung.SelectedIndex = 0
        Select Case SPEDITIONSBUCH.FilialenNr
            Case 4803, 4809
                cboNiederlassung.Text = "SUB"
            Case 4801
                cboNiederlassung.Text = "SUW"
            Case 5003
                cboNiederlassung.Text = "SBG" 'ANDERER DERVER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            Case 5303
                cboNiederlassung.Text = "WAI"
        End Select
        strManNr = txtFirma.Text
        strManNl = cboNiederlassung.Text

    End Sub

    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        If TextBox1.Text <> "" Then TextBox2.Text = ""
    End Sub

    Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
        If TextBox2.Text <> "" Then TextBox1.Text = ""
    End Sub



    Private Sub cboNiederlassung_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboNiederlassung.SelectedIndexChanged
        strManNr = txtFirma.Text
        strManNl = cboNiederlassung.Text

        If cboNiederlassung.Text = "SBG" Then
            ATLAS_SERVER_VERBINDUNG = "ATLAS_SBG"
        Else
            ATLAS_SERVER_VERBINDUNG = "ATLAS"
        End If
    End Sub
End Class
