Revert "commit"
This commit is contained in:
940
SDL/ZOLLSYSTEM/DAKOSY/ATLAS/EZA/usrCntlATLAS_EZA.vb
Normal file
940
SDL/ZOLLSYSTEM/DAKOSY/ATLAS/EZA/usrCntlATLAS_EZA.vb
Normal file
@@ -0,0 +1,940 @@
|
||||
Imports DAKOSY_Worker
|
||||
Imports Tamir
|
||||
Imports Tamir.SharpSsh
|
||||
Imports Microsoft.Office.Interop
|
||||
Imports VERAG_PROG_ALLGEMEIN
|
||||
|
||||
Public Class usrCntlATLAS_EZA
|
||||
|
||||
Property ALLG As usrCntlATLAS_EZA_Allg
|
||||
Property ADRESSEN As usrCntlATLAS_EZA_Adressen
|
||||
Property POSITIONEN As usrCntlATLAS_EZA_Positionen
|
||||
Property DV1 As usrCntlATLAS_EZA_DV1
|
||||
|
||||
|
||||
|
||||
|
||||
Property Jahr2Stellig As Integer
|
||||
Property zusatz As String
|
||||
Property BezugsNr As String = ""
|
||||
Dim sentToDakosy = False
|
||||
|
||||
|
||||
Property AVISO As VERAG_PROG_ALLGEMEIN.cAviso
|
||||
Property SENDUNG As VERAG_PROG_ALLGEMEIN.cSendungen
|
||||
|
||||
|
||||
Dim cDy_ART As String = "EZA"
|
||||
|
||||
Dim EZA As cDakosyEZA = Nothing
|
||||
Dim DY_ANM As cDakosy_Zollanmeldungen = Nothing
|
||||
|
||||
|
||||
Dim FIRMA_DY = VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA
|
||||
|
||||
Property isSTAMMREF As Boolean = False
|
||||
Property STAMMREF As String = ""
|
||||
|
||||
|
||||
Sub New(DY_ANM As cDakosy_Zollanmeldungen, AVISO As VERAG_PROG_ALLGEMEIN.cAviso, SENDUNG As VERAG_PROG_ALLGEMEIN.cSendungen, Jahr2Stellig As Integer, Optional zusatz As String = "", Optional isSTAMMREF As Boolean = False, Optional STAMMREF As String = "")
|
||||
' Dieser Aufruf ist für den Designer erforderlich.
|
||||
InitializeComponent()
|
||||
|
||||
' Me.cDy_ART = If(ART = "NCTS", "T2", ART)
|
||||
|
||||
Me.Jahr2Stellig = Jahr2Stellig
|
||||
Me.zusatz = zusatz
|
||||
|
||||
Me.AVISO = AVISO
|
||||
Me.SENDUNG = SENDUNG
|
||||
Me.DY_ANM = DY_ANM
|
||||
|
||||
Me.isSTAMMREF = isSTAMMREF
|
||||
Me.STAMMREF = STAMMREF
|
||||
|
||||
If DY_ANM IsNot Nothing Then
|
||||
Me.EZA = DAKOSY_Worker.cDakosyEZA.LOADByAnmIDFull(DY_ANM.dy_Id, True)
|
||||
If Me.EZA IsNot Nothing AndAlso Me.EZA.eza_firma IsNot Nothing Then Me.FIRMA_DY = Me.EZA.eza_firma
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Sub New(EZA As cDakosyEZA, Optional isSTAMMREF As Boolean = False, Optional STAMMREF As String = "")
|
||||
InitializeComponent()
|
||||
Me.EZA = EZA
|
||||
DY_ANM = New cDakosy_Zollanmeldungen(EZA.eza_dyaAnmID)
|
||||
|
||||
Me.isSTAMMREF = isSTAMMREF
|
||||
Me.STAMMREF = STAMMREF
|
||||
|
||||
If DY_ANM.dy_AvisoId > 0 Then
|
||||
Dim AV As New VERAG_PROG_ALLGEMEIN.cAvisoDAL
|
||||
AVISO = AV.LesenAviso(DY_ANM.dy_AvisoId, "")
|
||||
End If
|
||||
If DY_ANM.dy_SendungsId > 0 Then
|
||||
SENDUNG = New VERAG_PROG_ALLGEMEIN.cSendungen(DY_ANM.dy_SendungsId)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub New(ART As String, AvisoId As Integer, SENDUNGS_ID As Integer, Jahr2Stellig As Integer, Optional zusatz As String = "", Optional isSTAMMREF As Boolean = False, Optional STAMMREF As String = "")
|
||||
' Dieser Aufruf ist für den Designer erforderlich.
|
||||
InitializeComponent()
|
||||
Me.cDy_ART = If(ART <> "", ART, "EX")
|
||||
|
||||
If AvisoId > 0 Then
|
||||
Dim AV As New VERAG_PROG_ALLGEMEIN.cAvisoDAL
|
||||
AVISO = AV.LesenAviso(AvisoId, "")
|
||||
End If
|
||||
If SENDUNGS_ID > 0 Then
|
||||
SENDUNG = New VERAG_PROG_ALLGEMEIN.cSendungen(SENDUNGS_ID)
|
||||
End If
|
||||
|
||||
Me.isSTAMMREF = isSTAMMREF
|
||||
Me.STAMMREF = STAMMREF
|
||||
|
||||
Me.Jahr2Stellig = Jahr2Stellig
|
||||
Me.zusatz = zusatz
|
||||
|
||||
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
||||
End Sub
|
||||
|
||||
Sub New(ART As String, Aviso As VERAG_PROG_ALLGEMEIN.cAviso, SENDUNG As VERAG_PROG_ALLGEMEIN.cSendungen, Jahr2Stellig As Integer, Optional zusatz As String = "", Optional isSTAMMREF As Boolean = False, Optional STAMMREF As String = "", Optional FIRMA_DY As String = "")
|
||||
' Dieser Aufruf ist für den Designer erforderlich.
|
||||
InitializeComponent()
|
||||
|
||||
Me.cDy_ART = If(ART <> "", ART, "EX")
|
||||
Me.AVISO = Aviso
|
||||
Me.SENDUNG = SENDUNG
|
||||
|
||||
Me.Jahr2Stellig = Jahr2Stellig
|
||||
Me.zusatz = zusatz
|
||||
|
||||
|
||||
Me.isSTAMMREF = isSTAMMREF
|
||||
Me.STAMMREF = STAMMREF
|
||||
|
||||
If FIRMA_DY <> "" Then Me.FIRMA_DY = FIRMA_DY
|
||||
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
||||
End Sub
|
||||
|
||||
|
||||
Function getBezugsnr(ByRef BezugsNr)
|
||||
Dim BezugsNrTmp = ""
|
||||
Select Case FIRMA_DY
|
||||
Case "UNISPED"
|
||||
If If(SENDUNG.tblSnd_DakosyRef, "") <> "" Then
|
||||
BezugsNrTmp = SENDUNG.tblSnd_DakosyRef
|
||||
Else
|
||||
BezugsNrTmp = SENDUNG.FilialenNr & "/" & SENDUNG.AbfertigungsNr
|
||||
End If
|
||||
Case Else
|
||||
BezugsNrTmp = SENDUNG.FilialenNr & "/" & SENDUNG.AbfertigungsNr '& If(zusatz <> "", "/" & zusatz, "") 'zusatz ' & "/" & Jahr2Stellig
|
||||
End Select
|
||||
BezugsNr = BezugsNrTmp
|
||||
zusatz = "A"
|
||||
'Soloagne bis die Bezugsnummer noch nicht existiert
|
||||
While DAKOSY_Worker.cDakosy_Zollanmeldungen.ExistsBezugsNr(BezugsNr) 'IsNot Nothing
|
||||
BezugsNr = SENDUNG.FilialenNr & "/" & SENDUNG.AbfertigungsNr & "/" & zusatz
|
||||
If zusatz.Length = 1 Then
|
||||
zusatz = Chr(Asc(zusatz.ToString) + 1)
|
||||
Else
|
||||
zusatz = zusatz.Substring(0, 1) & Chr(Asc(zusatz.Substring(0, 2).ToString) + 1)
|
||||
End If
|
||||
If zusatz = "Z" Then zusatz = "AA"
|
||||
End While
|
||||
lblBezugsnummer.Text = BezugsNr
|
||||
|
||||
Return BezugsNr
|
||||
End Function
|
||||
|
||||
|
||||
Function getKdnr(ByRef art) As Integer
|
||||
Try
|
||||
If ADRESSEN IsNot Nothing Then
|
||||
Select Case art
|
||||
Case "EMPF" : Return ADRESSEN.usrCntl_Empfaenger.kdFirma.KdNr_value
|
||||
Case "ABS" : Return ADRESSEN.usrCntl_Versender.kdFirma.KdNr_value
|
||||
Case "ANM" : Return ADRESSEN.usrCntl_Anmelder.kdFirma.KdNr_value
|
||||
Case "VERTR" : Return ADRESSEN.usrCntl_Vertretener.kdFirma.KdNr_value
|
||||
Case "VERTRANM" : Return ADRESSEN.usrCntl_VertreterAnmelder.kdFirma.KdNr_value
|
||||
End Select
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Return -1
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
|
||||
Private Sub usrCntlATLAS_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
|
||||
cboDakosyAction.Items.Clear()
|
||||
cboDakosyAction.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Neuen Datensatz erstellen", DY_ObjektAktion.OBJ_CREATE))
|
||||
cboDakosyAction.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Vohr. DS ändern", DY_ObjektAktion.OBJ_CHANGE))
|
||||
cboDakosyAction.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Vorh. DS stornieren", DY_ObjektAktion.OBJ_CANCEL))
|
||||
cboDakosyAction.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Datensatz an ZOLL senden", DY_ObjektAktion.OBJ_SEND))
|
||||
cboDakosyAction.changeItem(DY_ObjektAktion.OBJ_CREATE)
|
||||
|
||||
ADRESSEN = New usrCntlATLAS_EZA_Adressen(EZA)
|
||||
ALLG = New usrCntlATLAS_EZA_Allg(EZA)
|
||||
POSITIONEN = New usrCntlATLAS_EZA_Positionen(EZA, Me)
|
||||
DV1 = New usrCntlATLAS_EZA_DV1(EZA)
|
||||
|
||||
Select Case FIRMA_DY
|
||||
Case "VERAG" : txtDyMandant.Text = "VERG"
|
||||
txtDyNiederlassung.Text = VERAG_PROG_ALLGEMEIN.cAllgemein.NIEDERLASSUNG
|
||||
' Select Case VERAG_PROG_ALLGEMEIN.cAllgemein.NIEDERLASSUNG
|
||||
'Case "SUB" : txtDyNiederlassung.Text = "VERG"
|
||||
'Case "SUW" : txtDyNiederlassung.Text = "ATIL"
|
||||
''Case "SBG" : txtDyNiederlassung.Text = "IMEX"
|
||||
'Case "NEU" : txtDyNiederlassung.Text = "IMEX"
|
||||
'Case "NKD" : txtDyNiederlassung.Text = "IMEX"
|
||||
'End Select
|
||||
Case "AMBAR" : txtDyMandant.Text = "ATIL" : txtDyNiederlassung.Text = "AMBWO"
|
||||
Case "ATILLA" : txtDyMandant.Text = "ATIL" : txtDyNiederlassung.Text = "SUW"
|
||||
Case "UNISPED" : txtDyMandant.Text = "UNAT" : txtDyNiederlassung.Text = "ATSPED"
|
||||
Case "IMEX" : txtDyMandant.Text = "IMEX" : txtDyNiederlassung.Text = "IME"
|
||||
End Select
|
||||
|
||||
|
||||
cboStammreferenz.fillWithSQL("SELECT [dySr_Stammreferenz],[dySr_Bezeichnung] FROM [tblDakosy_Stammreferenzen] WHERE dySr_Land='DE' AND dySr_Verfahren='EZA' and dySr_dy_Mandant='" & txtDyMandant.Text & "' and dySr_dy_Niederlassung='" & txtDyNiederlassung.Text.Replace("DTB", "SUB") & "' and dySr_visible=1", False, "FMZOLL", True)
|
||||
cboStammreferenz.changeItem("")
|
||||
|
||||
|
||||
If isSTAMMREF Then
|
||||
Me.BezugsNr = "STAMMREFERENZ"
|
||||
If EZA Is Nothing Then EZA = New cDakosyEZA
|
||||
EZA.eza_ObjectName = BezugsNr
|
||||
Button1.Enabled = False
|
||||
cboDakosyAction.Enabled = False
|
||||
Else
|
||||
If EZA Is Nothing Then ' NEUE ZOLLANMELDUNG
|
||||
|
||||
Dim kdnr As Object = Nothing
|
||||
If SENDUNG IsNot Nothing AndAlso SENDUNG.tblSnd_EmpfaengerKdNr > 0 Then
|
||||
kdnr = SENDUNG.tblSnd_EmpfaengerKdNr
|
||||
End If
|
||||
Dim f As New frmDakosyStammreferenz("DE", "EZA", False, kdnr,, FIRMA_DY)
|
||||
Dim Stammreferenz = Nothing
|
||||
If f.ShowDialog(Me) Then
|
||||
Stammreferenz = f.STAMMREF
|
||||
sentToDakosy = f.sentToDakosy
|
||||
End If
|
||||
Try
|
||||
|
||||
BezugsNr = getBezugsnr(BezugsNr)
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message & ex.StackTrace)
|
||||
End Try
|
||||
EZA = cDakosyEZA.LOADByBezugsNr(BezugsNr, True)
|
||||
If EZA Is Nothing Then
|
||||
'Falls zur BezugsNr schon ein Eintrag in der DB vorhanden ist
|
||||
EZA = cDakosyEZA.LOADByAnmIDFull(f.STAMMREF_DYID, True) ' DyID --> Falls bei der Stammreferenz eine Vorlage hinterlegt ist!
|
||||
|
||||
|
||||
If EZA IsNot Nothing Then
|
||||
'Stmmreferenz - Werte zurücksetzen, damit nicht falsch übergeben
|
||||
EZA.eza_dyaAnmID = -1
|
||||
EZA.eza_Id = -1
|
||||
Else
|
||||
EZA = New cDakosyEZA
|
||||
End If
|
||||
|
||||
'Wenn bei der Stammref eine andere NL ausgewählt wurde, wird dies hier korrigiert (zb. IMEX / GLOBAL!):
|
||||
If f.nl <> txtDyNiederlassung.Text Then
|
||||
txtDyNiederlassung.Text = f.nl
|
||||
cboStammreferenz.fillWithSQL("SELECT [dySr_Stammreferenz],[dySr_Bezeichnung] FROM [tblDakosy_Stammreferenzen] WHERE dySr_Land='DE' AND dySr_Verfahren='EZA' and dySr_dy_Mandant='" & txtDyMandant.Text & "' and dySr_dy_Niederlassung='" & txtDyNiederlassung.Text & "' and dySr_visible=1", False, "FMZOLL", True)
|
||||
|
||||
End If
|
||||
|
||||
loaddataFromAVISO(EZA)
|
||||
cboStammreferenz.changeItem(Stammreferenz)
|
||||
|
||||
|
||||
End If
|
||||
'eza_OUT
|
||||
|
||||
Else
|
||||
' eza_OUT is ot nothing
|
||||
Me.BezugsNr = EZA.eza_ObjectName
|
||||
'MsgBox(eza_OUT.eza_Hauptverpflichteter_Name)
|
||||
|
||||
End If
|
||||
End If
|
||||
If If(EZA.eza_firma, "") = "" Then If FIRMA_DY <> "" Then EZA.eza_firma = FIRMA_DY
|
||||
|
||||
|
||||
' If EZA.ncts_ArtAnmeldung Is Nothing Or EZA.ncts_ArtAnmeldung = "" Then
|
||||
'EZA.ncts_ArtAnmeldung = "T2"
|
||||
'End If
|
||||
|
||||
|
||||
'hinzufügen, damit alle Controls richtig geladen und initialisiert werden:s
|
||||
Me.SplitContainer.Panel2.Controls.Add(ALLG)
|
||||
Me.SplitContainer.Panel2.Controls.Add(POSITIONEN)
|
||||
Me.SplitContainer.Panel2.Controls.Add(ADRESSEN)
|
||||
Me.SplitContainer.Panel2.Controls.Add(DV1)
|
||||
|
||||
AddHandler ALLG.DV1_changed, Sub(dv1)
|
||||
btnDV1.Visible = dv1
|
||||
End Sub
|
||||
|
||||
' MsgBox(EZA.ncts_Hauptverpflichteter_Name)
|
||||
'Werte setzen:
|
||||
ADRESSEN.setValues(EZA)
|
||||
ALLG.setValues(EZA)
|
||||
POSITIONEN.setValues(EZA)
|
||||
DV1.setValues(EZA)
|
||||
|
||||
'Controls wieder entfernen:
|
||||
Me.SplitContainer.Panel2.Controls.Clear()
|
||||
|
||||
|
||||
|
||||
'If ALLG.txtRechnungspreis.Text = "" Then ALLG.txtRechnungspreis.Text = BezugsNr
|
||||
|
||||
|
||||
|
||||
' ADRESSEN.CreateControl()
|
||||
For Each c In MyFlowLayoutPanel1.Controls
|
||||
If c.GetType.ToString = GetType(System.Windows.Forms.Button).ToString Then
|
||||
AddHandler DirectCast(c, System.Windows.Forms.Button).Click, AddressOf buttonClick
|
||||
End If
|
||||
Next
|
||||
|
||||
SplitContainer.Panel2.Controls.Add(ALLG)
|
||||
lblBezugsnummer.Text = BezugsNr
|
||||
|
||||
ALLG.Dock = DockStyle.Fill
|
||||
ADRESSEN.Dock = DockStyle.Fill
|
||||
POSITIONEN.Dock = DockStyle.Fill
|
||||
DV1.Dock = DockStyle.Fill
|
||||
|
||||
AddHandler POSITIONEN.RohmasseChanged, Sub(rohmasse)
|
||||
Label5.Text = rohmasse.ToString("N2") & " kg"
|
||||
End Sub
|
||||
AddHandler POSITIONEN.PosAnzChanged, Sub(anz)
|
||||
Label3.Text = anz
|
||||
End Sub
|
||||
|
||||
If sentToDakosy Then
|
||||
Try
|
||||
Me.Button1.PerformClick()
|
||||
Me.FindForm.Close()
|
||||
Catch
|
||||
End Try
|
||||
|
||||
End If
|
||||
Try
|
||||
If Not VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("ZOLL_DakosyZA_AVISO_Edit", "AVISO") Then
|
||||
Me.FindForm.Close()
|
||||
End If
|
||||
Catch
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Sub buttonClick(sender As Object, e As EventArgs) 'HANDLED
|
||||
Dim btn As System.Windows.Forms.Button = DirectCast(sender, System.Windows.Forms.Button)
|
||||
|
||||
For Each c In MyFlowLayoutPanel1.Controls
|
||||
If c.GetType.ToString = GetType(System.Windows.Forms.Button).ToString Then
|
||||
DirectCast(c, System.Windows.Forms.Button).BackColor = Drawing.Color.White
|
||||
DirectCast(c, System.Windows.Forms.Button).ForeColor = Drawing.Color.Black
|
||||
End If
|
||||
Next
|
||||
|
||||
btn.BackColor = Drawing.Color.SteelBlue 'Drawing.Color.FromArgb(0, 54, 128)
|
||||
btn.ForeColor = Drawing.Color.White
|
||||
|
||||
|
||||
SplitContainer.Panel2.Controls.Clear()
|
||||
|
||||
If btn Is btnAllgemein Then
|
||||
SplitContainer.Panel2.Controls.Add(ALLG)
|
||||
ElseIf btn Is btnAdressen Then
|
||||
SplitContainer.Panel2.Controls.Add(ADRESSEN)
|
||||
ElseIf btn Is btnPositionen Then
|
||||
SplitContainer.Panel2.Controls.Add(POSITIONEN)
|
||||
ElseIf btn Is btnDV1 Then
|
||||
SplitContainer.Panel2.Controls.Add(DV1)
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
Sub loaddataFromAVISO(ByRef cdy As cDakosyEZA)
|
||||
Try
|
||||
|
||||
'==> VORBLENDUNG:
|
||||
|
||||
' Dim cdy As New cDakosyEZA
|
||||
cdy.eza_ObjectName = BezugsNr
|
||||
' cdy.EZA_AbgangsDienststellennummer = "DE004102"
|
||||
'frmZollanmeldung.setAbgangszollstelle(cdy.eza_Eingangszollstelle, AVISO)
|
||||
frmZollanmeldung.setZollstelle(cdy.eza_AdressierteZollstelle, AVISO)
|
||||
If cdy.eza_AdressierteZollstelle IsNot Nothing AndAlso cdy.eza_AdressierteZollstelle.Length = 8 Then 'nur 4 stellen erlaubt!! 'DE00 fällt weg
|
||||
EZA.eza_AdressierteZollstelle = cdy.eza_AdressierteZollstelle.Substring(4, 4)
|
||||
End If
|
||||
|
||||
' cdy.EZA_VersendungsLandCode = "DE"
|
||||
cdy.eza_dyaArt = cDy_ART
|
||||
If AVISO IsNot Nothing Then
|
||||
' cdy.EZA_Befoerderungsmittel_KennzeichenAbgang = AVISO.LKW_Nr
|
||||
' cdy.EZA_Befoerderungsmittel_KennzeichenGrenzueberschreitend = "X"
|
||||
|
||||
End If
|
||||
|
||||
|
||||
|
||||
' Dim AD As New VERAG_PROG_ALLGEMEIN.cAdressen(712255) ' VERAG Neuhaus
|
||||
' Dim KD As New VERAG_PROG_ALLGEMEIN.cKunde(712255) ' VERAG Neuhaus
|
||||
If False Then
|
||||
|
||||
If AVISO.Frächter_KdNr IsNot Nothing AndAlso IsNumeric(AVISO.Frächter_KdNr) AndAlso AVISO.Frächter_KdNr > 0 Then
|
||||
Dim AD_Befoerderer As New VERAG_PROG_ALLGEMEIN.cAdressen(AVISO.Frächter_KdNr) ' Befoerderer
|
||||
Dim KD_Befoerderer As New VERAG_PROG_ALLGEMEIN.cKunde(AVISO.Frächter_KdNr) ' Befoerderer
|
||||
Else
|
||||
' cdy.EZA_SumA_Befoerderer_Name = If(AVISO.Frächter, "")
|
||||
End If
|
||||
|
||||
|
||||
|
||||
If SENDUNG IsNot Nothing Then
|
||||
|
||||
Dim p As New DAKOSY_Worker.cDakosy_EZA_Warenposition
|
||||
p.ezaWP_Warenbezeichnung = SENDUNG.tblSnd_Warenbezeichnung
|
||||
If SENDUNG.tblSnd_Colli IsNot Nothing AndAlso IsNumeric(SENDUNG.tblSnd_Colli) Then
|
||||
' Dim pk As New DAKOSY_Worker.cDakosy_EZA_WarenpositionPackstuecke
|
||||
' pk.EZAWpPk_PackstueckeAnzahl = SENDUNG.tblSnd_Colli
|
||||
' pk.EZAWpPk_Verpackungsart = "PK"
|
||||
' p.EZAWP_PACKSTUECKE.Add(pk)
|
||||
End If
|
||||
p.ezaWP_Rohmasse = SENDUNG.tblSnd_Gewicht
|
||||
p.ezaWP_Warenbezeichnung = SENDUNG.tblSnd_Warenbezeichnung
|
||||
cdy.eza_WARENPOS.Add(p)
|
||||
|
||||
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If SENDUNG IsNot Nothing Then
|
||||
|
||||
|
||||
'Test Vorpapier:
|
||||
If If(SENDUNG.tblSnd_Vorpapier, "") <> "" Then
|
||||
EZA.eza_VorpapierArtCode = "T1"
|
||||
EZA.eza_VorpapierNr = SENDUNG.tblSnd_Vorpapier
|
||||
End If
|
||||
|
||||
|
||||
Dim Vorsystem = False
|
||||
If (SENDUNG.VORSYSTEM IsNot Nothing) AndAlso MsgBox("Möchten Sie die Daten aus dem Vorsystem laden?", vbYesNoCancel) Then
|
||||
Try
|
||||
Dim SH As New VERAG_PROG_ALLGEMEIN.cVERAG_in_eza_FULL(CInt(SENDUNG.VORSYSTEM_Id))
|
||||
If SH IsNot Nothing Then
|
||||
Dim ABFERTIGUNGSART = 1 'DEFAULT Fiskal?
|
||||
EZA.eza_GesamtRohmasse = SH.EZA.TotGrossWeight
|
||||
If If(SH.EZA.Incoterm, "") <> "" Then
|
||||
EZA.eza_LieferbedingungCode = SH.EZA.Incoterm
|
||||
End If
|
||||
'EZA.pack= SH.EZA.TotPackage
|
||||
'EZA.eza_Rechnungspreis = SH.EZA.TotGrossWeight
|
||||
'EZA.eza_Rechnungswaehrung = SENDUNG.tblSnd_WarenwertWaehrung
|
||||
' If If(SH.EZA.TransportModeBorder, "") <> "" Then EZA.eza_BeförderungsmittelGrenzeArt = SH.EZA.TransportModeBorder
|
||||
'If If(SH.EZA.TransportBorderType, "") <> "" Then EZA.bef = SH.EZA.TransportBorderType
|
||||
|
||||
If If(SH.EZA.PrePaperCode, "") <> "" Then EZA.eza_VorpapierArtCode = SH.EZA.PrePaperCode
|
||||
If If(SH.EZA.PrePaperNr, "") <> "" Then EZA.eza_VorpapierNr = SH.EZA.PrePaperNr
|
||||
If If(SH.EZA.CountryCodeDeparture, "") <> "" Then EZA.eza_VersendungsLandCode = SH.EZA.CountryCodeDeparture
|
||||
|
||||
If If(SH.EZA.TransportModeBorder, "") <> "" Then EZA.eza_VerkehrszweigInland = SH.EZA.TransportModeBorder
|
||||
If If(SH.EZA.TransportModeBorder, "") <> "" Then EZA.eza_VerkehrszweigGrenze = SH.EZA.TransportModeBorder
|
||||
If If(SH.EZA.TransportBorderType, "") <> "" Then EZA.eza_BeförderungsmittelGrenzeArt = SH.EZA.TransportBorderType
|
||||
|
||||
'If If(AD.ezaAd_LandCode, "") = "DE" And AD.ezaAd_PLZ IsNot Nothing Then
|
||||
' EZA.eza_Bestimmungsbundesland = VERAG_PROG_ALLGEMEIN.cDEBundeslaenderPLZ.LOADBundeslandCode_ByPLZ(AD.ezaAd_PLZ)
|
||||
'ElseIf If(AD.ezaAd_LandCode, "") <> "" Then
|
||||
' EZA.eza_Bestimmungsbundesland = 25
|
||||
'End If
|
||||
|
||||
Dim InvoiceSum As Double = 0.0
|
||||
Dim InvoiceCurr As String = ""
|
||||
|
||||
For Each SH_POS In SH.EZA.POSITIONS
|
||||
Dim EZA_POS As New DAKOSY_Worker.cDakosy_EZA_Warenposition
|
||||
EZA_POS.ezaWP_PackstueckAnzahl = SH_POS.NumberOfPackages
|
||||
EZA_POS.ezaWP_Rohmasse = SH_POS.GrossWeight
|
||||
EZA_POS.ezaWP_Eigenmasse = SH_POS.NetWeight
|
||||
EZA_POS.ezaWP_Warenbezeichnung = SH_POS.GoodsDescription
|
||||
EZA_POS.ezaWP_WarennummerEZT = SH_POS.GoodsTariff
|
||||
|
||||
|
||||
EZA_POS.ezaWP_UrsprungslandCode = SH_POS.OriginCountryCode
|
||||
'If If(SH_POS.KindOfPackages, "") <> "" Then EZA_POS.ezaWP_PackstueckArt = SH_POS.KindOfPackages
|
||||
EZA_POS.ezaWP_PackstueckArt = "PK"
|
||||
|
||||
If SH_POS.ItemInvoiceAmount IsNot Nothing Then
|
||||
EZA_POS.ezaWP_Artikelpreis = SH_POS.ItemInvoiceAmount
|
||||
EZA_POS.ezaWP_ArtikelpreisWaehrung = SH_POS.ItemInvoiceCurrency
|
||||
EZA_POS.ezaWP_AHStatWert = SH_POS.ItemInvoiceAmount
|
||||
InvoiceSum += CDbl(SH_POS.ItemInvoiceAmount)
|
||||
If SH_POS.ItemInvoiceCurrency = "" Then
|
||||
InvoiceCurr = SH_POS.ItemInvoiceCurrency
|
||||
ElseIf SH_POS.ItemInvoiceCurrency <> InvoiceCurr Then
|
||||
InvoiceCurr = "XXX" ' Wenn währung unterschiedlich XX --> kein Übertrag
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
For Each SH_POS_DOC In SH_POS.DOCUMENTS
|
||||
Dim bool_add = False
|
||||
Dim EZA_POS_DOC As New DAKOSY_Worker.cDakosy_EZA_WarenpositionVorgelegteUnterlagen
|
||||
EZA_POS_DOC.ezaWpUl_DatumAusstellung = SH_POS_DOC.DocumentDate
|
||||
EZA_POS_DOC.ezaWpUl_Nummer = SH_POS_DOC.DocumentNr
|
||||
Select Case SH_POS_DOC.DocumentType
|
||||
Case "CMR" : EZA_POS_DOC.ezaWpUl_Art = "7HHF" : EZA_POS_DOC.ezaWpUl_Bereich = "4" : EZA_POS_DOC.ezaWpUl_VorlageKz = "J" : bool_add = True
|
||||
Case "INV" : EZA_POS_DOC.ezaWpUl_Art = "N380" : EZA_POS_DOC.ezaWpUl_Bereich = "4" : EZA_POS_DOC.ezaWpUl_VorlageKz = "J" : bool_add = True
|
||||
Case "ATR" : EZA_POS_DOC.ezaWpUl_Art = "N018" : EZA_POS_DOC.ezaWpUl_Bereich = "6" : EZA_POS_DOC.ezaWpUl_VorlageKz = "J" : bool_add = True
|
||||
' Case "EX" : EZA_POS_DOC.ezaWpUl_Art = "N380": EZA_POS_DOC.ezaWpUl_Bereich = "4
|
||||
End Select
|
||||
|
||||
If bool_add Then EZA_POS.ezaWP_UNTERLAGEN.Add(EZA_POS_DOC)
|
||||
Next
|
||||
|
||||
EZA.eza_WARENPOS.Add(EZA_POS)
|
||||
Next
|
||||
|
||||
EZA.eza_Rechnungspreis = InvoiceSum
|
||||
' If InvoiceCurr <> "XXX" Then EZA.eza_Rechnungswaehrung = InvoiceCurr
|
||||
If If(SH.EZA.InvoiceCurrency, "") <> "" Then EZA.eza_Rechnungswaehrung = SH.EZA.InvoiceCurrency
|
||||
|
||||
Dim LieferbedingungOrtAbsedner = ""
|
||||
Dim LieferbedingungOrtEmpfaenger = ""
|
||||
For Each SH_AD In SH.EZA.ADDRESS
|
||||
Dim EZA_AD As New DAKOSY_Worker.cDakosy_EZA_Adressen
|
||||
EZA_AD.ezaAd_AdressTyp = SH_AD.AddressCode
|
||||
EZA_AD.ezaAd_LandCode = SH_AD.CountryCode
|
||||
|
||||
EZA_AD.ezaAd_NameFirma1 = SH_AD.Name1
|
||||
EZA_AD.ezaAd_NameFirma2 = SH_AD.Name2
|
||||
EZA_AD.ezaAd_NameFirma3 = SH_AD.Name3
|
||||
EZA_AD.ezaAd_StrasseHausNr1 = SH_AD.Street1
|
||||
EZA_AD.ezaAd_StrasseHausNr2 = SH_AD.Street2
|
||||
EZA_AD.ezaAd_Ort = SH_AD.City
|
||||
EZA_AD.ezaAd_PLZ = SH_AD.PostalCode
|
||||
EZA_AD.ezaAd_UStIDAnmelder = SH_AD.UStID
|
||||
|
||||
If EZA_AD.ezaAd_AdressTyp = "CN" Then 'EMPFÄNGER
|
||||
EZA_AD.ezaAd_TeilnehmerEORI = SH_AD.EORI
|
||||
EZA_AD.ezaAd_TeilnehmerNLNR = SH_AD.NLNR
|
||||
|
||||
If If(EZA_AD.ezaAd_LandCode, "") = "DE" And EZA_AD.ezaAd_PLZ IsNot Nothing Then
|
||||
EZA.eza_Bestimmungsbundesland = VERAG_PROG_ALLGEMEIN.cDEBundeslaenderPLZ.LOADBundeslandCode_ByPLZ(EZA_AD.ezaAd_PLZ)
|
||||
ElseIf If(EZA_AD.ezaAd_LandCode, "") <> "" Then
|
||||
EZA.eza_Bestimmungsbundesland = 25
|
||||
End If
|
||||
|
||||
If If(EZA_AD.ezaAd_Ort, "") <> "" Then LieferbedingungOrtEmpfaenger = EZA_AD.ezaAd_Ort
|
||||
End If
|
||||
|
||||
If EZA_AD.ezaAd_AdressTyp = "CZ" Then 'ABSENDER
|
||||
If If(EZA_AD.ezaAd_Ort, "") <> "" Then LieferbedingungOrtAbsedner = EZA_AD.ezaAd_Ort
|
||||
End If
|
||||
|
||||
EZA.eza_ADRESSEN.Add(EZA_AD)
|
||||
Next
|
||||
|
||||
|
||||
Select Case If(EZA.eza_LieferbedingungCode, "")
|
||||
Case ""
|
||||
Case "EXW", "FCA", "FOB", "FAS"
|
||||
EZA.eza_LieferbedingungSchluessel = 1
|
||||
EZA.eza_LieferbedingungOrt = LieferbedingungOrtAbsedner
|
||||
Case Else
|
||||
EZA.eza_LieferbedingungSchluessel = 3
|
||||
EZA.eza_LieferbedingungOrt = LieferbedingungOrtEmpfaenger
|
||||
End Select
|
||||
|
||||
Vorsystem = True
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message & ex.StackTrace)
|
||||
End Try
|
||||
End If
|
||||
|
||||
If Not Vorsystem Then
|
||||
|
||||
EZA.eza_GesamtRohmasse = SENDUNG.tblSnd_Gewicht
|
||||
EZA.eza_Rechnungspreis = SENDUNG.tblSnd_Warenwert
|
||||
EZA.eza_Rechnungswaehrung = SENDUNG.tblSnd_WarenwertWaehrung
|
||||
|
||||
If SENDUNG.tblSnd_Abfertigungsart_ID = 1 Then
|
||||
If SENDUNG.tblSnd_EmpfaengerKdNr > 0 Then
|
||||
|
||||
Dim AD As New DAKOSY_Worker.cDakosy_EZA_Adressen
|
||||
AD.ezaAd_AdressCode = SENDUNG.tblSnd_EmpfaengerKdNr
|
||||
AD.ezaAd_AdressTyp = "CN"
|
||||
Dim ADFmzoll As New VERAG_PROG_ALLGEMEIN.cAdressen(SENDUNG.tblSnd_EmpfaengerKdNr)
|
||||
Dim KDFmzoll As New VERAG_PROG_ALLGEMEIN.cKunde(SENDUNG.tblSnd_EmpfaengerKdNr)
|
||||
|
||||
AD.ezaAd_NameFirma1 = ADFmzoll.Name_1
|
||||
AD.ezaAd_NameFirma2 = ADFmzoll.Name_2
|
||||
|
||||
AD.ezaAd_StrasseHausNr1 = ADFmzoll.Straße
|
||||
AD.ezaAd_PLZ = ADFmzoll.PLZ
|
||||
AD.ezaAd_Ort = ADFmzoll.Ort
|
||||
AD.ezaAd_LandCode = cProgramFunctions.getISO2Land(ADFmzoll.LandKz)
|
||||
AD.ezaAd_TeilnehmerEORI = KDFmzoll.EORITIN
|
||||
AD.ezaAd_TeilnehmerNLNR = KDFmzoll.EORITIN_NL
|
||||
|
||||
If If(AD.ezaAd_LandCode, "") <> "" Then
|
||||
EZA.eza_Bestimmungsland = AD.ezaAd_LandCode
|
||||
End If
|
||||
|
||||
If If(AD.ezaAd_LandCode, "") = "DE" And AD.ezaAd_PLZ IsNot Nothing Then
|
||||
EZA.eza_Bestimmungsbundesland = VERAG_PROG_ALLGEMEIN.cDEBundeslaenderPLZ.LOADBundeslandCode_ByPLZ(AD.ezaAd_PLZ)
|
||||
ElseIf If(AD.ezaAd_LandCode, "") <> "" Then
|
||||
EZA.eza_Bestimmungsbundesland = 25
|
||||
End If
|
||||
|
||||
cdy.eza_ADRESSEN.Add(AD)
|
||||
End If
|
||||
If SENDUNG.tblSnd_AbsenderKdNr > 0 Then
|
||||
|
||||
Dim AD As New DAKOSY_Worker.cDakosy_EZA_Adressen
|
||||
AD.ezaAd_AdressCode = SENDUNG.tblSnd_AbsenderKdNr
|
||||
AD.ezaAd_AdressTyp = "CZ"
|
||||
Dim ADFmzoll As New VERAG_PROG_ALLGEMEIN.cAdressen(SENDUNG.tblSnd_AbsenderKdNr)
|
||||
Dim KDFmzoll As New VERAG_PROG_ALLGEMEIN.cKunde(SENDUNG.tblSnd_AbsenderKdNr)
|
||||
|
||||
AD.ezaAd_NameFirma1 = ADFmzoll.Name_1
|
||||
AD.ezaAd_NameFirma2 = ADFmzoll.Name_2
|
||||
|
||||
AD.ezaAd_StrasseHausNr1 = ADFmzoll.Straße
|
||||
AD.ezaAd_PLZ = ADFmzoll.PLZ
|
||||
AD.ezaAd_Ort = ADFmzoll.Ort
|
||||
AD.ezaAd_LandCode = cProgramFunctions.getISO2Land(ADFmzoll.LandKz)
|
||||
AD.ezaAd_TeilnehmerEORI = KDFmzoll.EORITIN
|
||||
AD.ezaAd_TeilnehmerNLNR = KDFmzoll.EORITIN_NL
|
||||
|
||||
If If(AD.ezaAd_LandCode, "") <> "" Then
|
||||
EZA.eza_VersendungsLandCode = AD.ezaAd_LandCode
|
||||
End If
|
||||
|
||||
cdy.eza_ADRESSEN.Add(AD)
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
|
||||
cdy.eza_KennzeichenNameBefoerderungsmittelAnkunft = AVISO.LKW_Nr
|
||||
cdy.eza_BeförderungsmittelGrenzeStaatszugehörigkeitCode = AVISO.LKW_Nationalitaet
|
||||
'cdy.EZA_BefoerderungsmittelGrenzeKennzeichen = AVISO.LKW_Nr
|
||||
'cdy.EZA_Ausfuhrland = "DE"
|
||||
|
||||
' cdy.EZA_VerkehrszweigGrenze = "3"
|
||||
' cdy.EZA_VerkehrszweigInland = "3"
|
||||
' cdy.eza_BeförderungsmittelGrenzeArt = "33"
|
||||
|
||||
' cdy.EZA_Rechnungwaehrung = "EUR"
|
||||
|
||||
' NCTS= cdy
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.StackTrace)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
Sub setValue(EZA)
|
||||
BezugsNr = EZA.ncts_ObjectName
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub pnl_Paint(sender As Object, e As PaintEventArgs)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub loadDYZollanmeldungen(Optional Status As String = "") ' + Speichern
|
||||
If DY_ANM Is Nothing Then
|
||||
DY_ANM = New cDakosy_Zollanmeldungen(EZA.eza_dyaAnmID)
|
||||
End If
|
||||
DY_ANM.dy_ART = ALLG.EZA_ART 'cDy_ART
|
||||
DY_ANM.dy_BezugsNr = BezugsNr
|
||||
DY_ANM.dy_AvisoId = If(AVISO Is Nothing, Nothing, AVISO.AvisoID)
|
||||
DY_ANM.dy_SendungsId = If(SENDUNG Is Nothing, Nothing, SENDUNG.tblSnd_SendungID)
|
||||
'Status?
|
||||
DY_ANM.SAVE() 'Speichern, ID wird erzeugt
|
||||
|
||||
End Sub
|
||||
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
||||
|
||||
Me.Refresh()
|
||||
cboDakosyAction.Focus() 'nur, damit alle _value aktualisuiert sind...
|
||||
If sentToDakosy OrElse vbYes = MsgBox("Sollen die Daten abgeschickt werden?" & vbNewLine & "Eine Änderung ist nur noch in der Dakosy Software möglich.", vbYesNoCancel) Then
|
||||
' Dim cDyAnm As New cDakosy_Zollanmeldungen(cDy_ART, BezugsNr, AVISO.AvisoID, SENDUNG.tblSnd_SendungID)
|
||||
loadDYZollanmeldungen()
|
||||
|
||||
If EZA IsNot Nothing Then
|
||||
'Dim cDY As New cDakosyEZA(cDyAnm.dy_Id, cDyAnm.dy_Erstellung_SB)
|
||||
EZA.eza_dyaAnmID = DY_ANM.dy_Id
|
||||
EZA.eza_Erstellung_SB = DY_ANM.dy_Erstellung_SB
|
||||
EZA.eza_LetzteBearbeitung = Now
|
||||
EZA.eza_LetzteBearbeitung_SB = DY_ANM.dy_LetzteBearbeitung_SB
|
||||
EZA.eza_firma = Me.FIRMA_DY
|
||||
DAKOSY_Interface_SEND.loadInClass_VersandanmeldungEZA(EZA, Me, DY_ANM)
|
||||
If Not EZA.SAVE_ALL() Then Exit Sub
|
||||
Dim saveFile = ""
|
||||
If DAKOSY_Interface_SEND.generateVersandanmeldungEZA(EZA, saveFile, cboDakosyAction._value) Then
|
||||
If saveFile <> "" Then
|
||||
If Not cDakosyFunftions.send_Data_To_Dakosy_FTP(saveFile, BezugsNr, DY_ANM.dy_Id, FIRMA_DY) Then
|
||||
MsgBox("Sendefehler!")
|
||||
Else
|
||||
If SENDUNG IsNot Nothing Then SENDUNG.SET_VGMA() ' MA Vorgeschrieben in Sendung setzen.
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
DY_ANM.UPDATE_DATA()
|
||||
|
||||
'Beim Senden soll die Sendung überhnommen + tblSnd_VG_MA gesetzt werden --> damit gleich gesehen wird, dass der Akt in Bearbeitung ist.
|
||||
DY_ANM.UPDATE_AVISO_SND(DY_ANM.dy_SendungsId)
|
||||
|
||||
|
||||
Me.FindForm.Close()
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub SpeichernToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SpeichernToolStripMenuItem.Click
|
||||
|
||||
Me.Refresh()
|
||||
|
||||
cboDakosyAction.Focus() 'nur, damit alle _value aktualisuiert sind...
|
||||
|
||||
' Dim cDyAnm As New cDakosy_Zollanmeldungen(cDy_ART, BezugsNr, If(AVISO Is Nothing, Nothing, AVISO.AvisoID), If(SENDUNG Is Nothing, Nothing, SENDUNG.tblSnd_SendungID))
|
||||
loadDYZollanmeldungen()
|
||||
|
||||
If EZA IsNot Nothing Then
|
||||
'Dim cDY As New cDakosyEZA(cDyAnm.dy_Id, cDyAnm.dy_Erstellung_SB)
|
||||
EZA.eza_dyaAnmID = DY_ANM.dy_Id
|
||||
EZA.eza_Erstellung_SB = DY_ANM.dy_Erstellung_SB
|
||||
EZA.eza_LetzteBearbeitung = Now
|
||||
EZA.eza_LetzteBearbeitung_SB = DY_ANM.dy_LetzteBearbeitung_SB
|
||||
DAKOSY_Interface_SEND.loadInClass_VersandanmeldungEZA(EZA, Me, DY_ANM)
|
||||
|
||||
If Not EZA.SAVE_ALL() Then
|
||||
'gespeichert
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
DY_ANM.UPDATE_DATA()
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub NeueBezugsnummerVergebenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles NeueBezugsnummerVergebenToolStripMenuItem.Click
|
||||
BezugsNr = getBezugsnr(BezugsNr)
|
||||
End Sub
|
||||
|
||||
Private Sub EZAIDToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles EZAIDToolStripMenuItem.Click
|
||||
If EZA IsNot Nothing Then
|
||||
MsgBox(EZA.eza_Id)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub BezugsnummerKopierenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BezugsnummerKopierenToolStripMenuItem.Click
|
||||
Clipboard.SetText(lblBezugsnummer.Text)
|
||||
End Sub
|
||||
|
||||
Private Sub DynamicAutomotiveXLSToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DynamicAutomotiveXLSToolStripMenuItem.Click
|
||||
importExcel_DynamicAutomotive()
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Function checkExcel_DynamicAutomotive(Blatt As Excel.Worksheet) As Boolean
|
||||
'Prüfung
|
||||
Try
|
||||
If Blatt Is Nothing Then Return False
|
||||
If Blatt.Range("B23") Is Nothing Then Return False
|
||||
If Blatt.Range("B23").Value.ToString <> "Code" Then Return False
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox("Fehler bei der Prüfung!" & ex.Message)
|
||||
Me.Cursor = Cursors.Default
|
||||
Return False
|
||||
End Try
|
||||
Return True
|
||||
|
||||
End Function
|
||||
Private Function importExcel_DynamicAutomotive() As Boolean
|
||||
|
||||
|
||||
Dim fd As New OpenFileDialog
|
||||
fd.Filter = "Excel Dateien|*.xls;*.xlsx"
|
||||
Dim result As DialogResult = fd.ShowDialog()
|
||||
|
||||
If Not fd.FileName.EndsWith(".xls") And Not fd.FileName.EndsWith(".xlsx") Then
|
||||
Me.Cursor = Cursors.Default
|
||||
Return False
|
||||
End If
|
||||
|
||||
If result = System.Windows.Forms.DialogResult.OK Then
|
||||
|
||||
|
||||
Me.Cursor = Cursors.WaitCursor
|
||||
Dim exclApp As New Excel.Application 'Object 'as Application
|
||||
Dim Datei As Excel.Workbook ' 'as WorkBook
|
||||
Dim Blatt As Excel.Worksheet 'Object 'as WorkSheet
|
||||
|
||||
With exclApp
|
||||
Try
|
||||
|
||||
.CutCopyMode = False
|
||||
|
||||
.DisplayAlerts = False
|
||||
|
||||
|
||||
Datei = .Workbooks.Open(fd.FileName)
|
||||
Blatt = Datei.Worksheets(1)
|
||||
|
||||
Datei.Activate()
|
||||
|
||||
Try
|
||||
Blatt.ShowAllData() 'Falls Filter ausgewählt wurde
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
|
||||
Dim startFound As Boolean = False
|
||||
Dim endFound As Boolean = False
|
||||
|
||||
If Not checkExcel_DynamicAutomotive(Blatt) Then 'VALIDIERUNG
|
||||
Me.Cursor = Cursors.Default
|
||||
Return False
|
||||
End If
|
||||
|
||||
If EZA.eza_WARENPOS.Count > 0 Then
|
||||
If vbYes = MsgBox("Sollten die aktuellen Einträge gelöscht werden?", vbYesNo) Then
|
||||
EZA.eza_WARENPOS.Clear() 'Zurücksetzen
|
||||
End If
|
||||
End If
|
||||
|
||||
Dim startRows As Integer = 24
|
||||
|
||||
Dim endRows As Integer = startRows
|
||||
While endRows < Blatt.UsedRange.Rows.Count
|
||||
If Not Blatt.Range("B" & endRows) Is Nothing AndAlso Not Blatt.Range("B" & endRows).Value Is Nothing AndAlso Not Blatt.Range("B" & endRows).Value.ToString.Trim = "" Then
|
||||
endFound = True
|
||||
Else
|
||||
Exit While
|
||||
End If
|
||||
endRows += 1
|
||||
End While
|
||||
endRows -= 1
|
||||
|
||||
If Not endFound Then
|
||||
MsgBox("Keine Daten vorhanden!")
|
||||
Me.Cursor = Cursors.Default
|
||||
Return False
|
||||
End If
|
||||
|
||||
'Laden des Bereiches aus dem Excel:
|
||||
Dim myRange As Excel.Range
|
||||
myRange = Blatt.Range("B" & startRows & ":I" & endRows & "")
|
||||
Dim myArray As Object(,) '<-- declared as 2D Array
|
||||
myArray = myRange.Value 'store the content of each cell
|
||||
'myArray(i_soll2 - startRows + 1, 4)
|
||||
|
||||
|
||||
Dim cnt = 0
|
||||
|
||||
Try
|
||||
For i As Integer = 1 To endRows - startRows + 1 Step 1
|
||||
Dim POSITION As New DAKOSY_Worker.cDakosy_EZA_Warenposition
|
||||
POSITION.ezaWP_WarennummerEZT = myArray(i, 5).ToString()
|
||||
POSITION.ezaWP_PackstueckAnzahl = myArray(i, 6).ToString()
|
||||
POSITION.ezaWP_PackstueckArt = "PK"
|
||||
POSITION.ezaWP_Artikelpreis = CDbl(myArray(i, 8).ToString()).ToString("N2")
|
||||
POSITION.ezaWP_ArtikelpreisWaehrung = "EUR"
|
||||
POSITION.ezaWP_Warenbezeichnung = myArray(i, 2).ToString()
|
||||
Select Case myArray(i, 4).ToString
|
||||
Case "TURKEY" : POSITION.ezaWP_UrsprungslandCode = "TR"
|
||||
Case "ITALY" : POSITION.ezaWP_UrsprungslandCode = "IT"
|
||||
Case "SPAIN" : POSITION.ezaWP_UrsprungslandCode = "ES"
|
||||
Case "GERMANY" : POSITION.ezaWP_UrsprungslandCode = "DE"
|
||||
Case "CZECH REPUBLIC" : POSITION.ezaWP_UrsprungslandCode = "CZ"
|
||||
Case "FRANCE" : POSITION.ezaWP_UrsprungslandCode = "FR"
|
||||
|
||||
End Select
|
||||
|
||||
EZA.eza_WARENPOS.Add(POSITION)
|
||||
cnt += 1
|
||||
Next
|
||||
Catch ex As Exception
|
||||
MsgBox("Fehler beim Einlesen der Excel-Datei!" & vbNewLine & vbNewLine & ex.Message & ex.StackTrace)
|
||||
Me.Cursor = Cursors.Default
|
||||
Return False
|
||||
End Try
|
||||
|
||||
|
||||
.Visible = False
|
||||
|
||||
' AddHandler exclApp.WorkbookBeforeClose, AddressOf BeforeBookClose
|
||||
'Excelobjekte freistellten
|
||||
' For Each obj In New Object() {exclApp, Datei, Datei, Blatt, Blatt}
|
||||
' System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj)
|
||||
' Next
|
||||
Datei.Close()
|
||||
|
||||
Me.FindForm.SuspendLayout()
|
||||
POSITIONEN.setValues(EZA, True)
|
||||
btnPositionen.PerformClick()
|
||||
MsgBox(cnt & " Datensätze wurden eingelesen. ")
|
||||
Me.FindForm.ResumeLayout()
|
||||
|
||||
Me.Cursor = Cursors.Default
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
'
|
||||
Me.Cursor = Cursors.Default
|
||||
MsgBox("FEHLER! Datei im richtigen Format?" & vbNewLine & vbNewLine & ex.Message & ex.StackTrace)
|
||||
' Return False
|
||||
End Try
|
||||
End With
|
||||
Return True
|
||||
Else
|
||||
MsgBox("Keine Datei ausgewählt!")
|
||||
End If
|
||||
|
||||
Me.Cursor = Cursors.Default
|
||||
Return False
|
||||
|
||||
End Function
|
||||
|
||||
Private Sub pnl_Paint_1(sender As Object, e As PaintEventArgs) Handles pnl.Paint
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user