344 lines
12 KiB
VB.net
344 lines
12 KiB
VB.net
Imports DAKOSY_Worker
|
|
Imports SDL
|
|
|
|
Imports VERAG_PROG_ALLGEMEIN
|
|
|
|
|
|
Public Class usrCntlSND_ATBGestellung
|
|
|
|
Dim _SendungsId As Object
|
|
Public firmaId As Integer
|
|
|
|
'Public NCTS_GA As VERAG_PROG_ALLGEMEIN.cNCTSGestellungsadressen
|
|
|
|
Dim AVISO As VERAG_PROG_ALLGEMEIN.cAviso = Nothing
|
|
Dim SND As VERAG_PROG_ALLGEMEIN.cSendungen = Nothing
|
|
Dim gsnr_global As Integer = -1
|
|
Dim gsnr_proLKW_global As Integer = -1
|
|
|
|
Sub New(AVISO, SND)
|
|
|
|
|
|
' Dieser Aufruf ist für den Designer erforderlich.
|
|
InitializeComponent()
|
|
|
|
Me.AVISO = AVISO
|
|
Me.SND = SND
|
|
|
|
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
|
|
|
End Sub
|
|
|
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
|
|
|
Me.Refresh()
|
|
Me.Cursor = Cursors.WaitCursor
|
|
|
|
Dim f As frmSendungsdetailsNEU = Me.FindForm
|
|
If f.SAVE_ME() Then
|
|
|
|
SND = f.SENDUNG_LIST(f.CURRENT_INDEX)
|
|
|
|
If Not IsNumeric(SND.AbfertigungsNr) OrElse CInt(SND.AbfertigungsNr) < 100000 Then MsgBox("Abfertigungsnummer angeben!") : Exit Sub
|
|
|
|
If Not IsNumeric(SND.tblSnd_Warenwert) OrElse CInt(SND.tblSnd_Warenwert) < 0 Then MsgBox("Warenwert angeben!") : Exit Sub
|
|
|
|
If (SND.tblSnd_WarenwertWaehrung) Is Nothing Then MsgBox("Währungseinheit angeben!") : Exit Sub
|
|
|
|
If If(SND.tblSnd_ATB_T1, "") = "" Then MsgBox("MRN (Gestellung) angeben!") : Exit Sub
|
|
|
|
If SND.tblSnd_T1_Frist IsNot Nothing AndAlso IsDate(SND.tblSnd_T1_Frist) Then
|
|
If CDate(SND.tblSnd_T1_Frist) >= Today() Then
|
|
'-> OK
|
|
Else
|
|
MsgBox("T1 Frist ist abgelaufen!")
|
|
Exit Sub
|
|
End If
|
|
Else
|
|
MsgBox("T1 Frist muss befüllt werden")
|
|
Exit Sub
|
|
|
|
End If
|
|
|
|
Dim Standort As String = ""
|
|
|
|
Select Case SND.FilialenNr
|
|
Case 4803, 4809
|
|
Standort = "VERAG AG"
|
|
Case 5601
|
|
Standort = "Unisped GmbH"
|
|
Case 5701
|
|
Standort = "AMBAR GmbH"
|
|
Case 4810, 5103, 5901
|
|
Standort = "VERAG GmbH"
|
|
Case 5501
|
|
Standort = "IMEX"
|
|
End Select
|
|
|
|
'sonderfälle lt. Mestan
|
|
If SND.tblSnd_Zollsystem_Land = "DE" Then
|
|
|
|
Select Case SND.FilialenNr
|
|
Case 5501, 4803, 4809, 5103
|
|
Standort = "VERAG GmbH"
|
|
End Select
|
|
|
|
ElseIf SND.tblSnd_Zollsystem_Land = "AT" Then
|
|
|
|
If SND.tblSnd_Abfertigungsart_ID = 1 Then 'ZA
|
|
Standort = "VERAG CS"
|
|
ElseIf SND.tblSnd_Abfertigungsart_ID = 38 Then 'EV-Verz
|
|
Select Case SND.FilialenNr
|
|
Case 4803, 5303, 4809, 5103
|
|
Standort = "VERAG CS"
|
|
End Select
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
Dim GesSichRef = New VERAG_PROG_ALLGEMEIN.cGesamtsicherheitsReferenz(Standort)
|
|
If GesSichRef Is Nothing Then MsgBox("Verwahrungsreferenz kann nicht ermittelt werden!") : Exit Sub
|
|
|
|
Dim saldo = CDbl(GesSichRef.CalcSaldo())
|
|
|
|
Dim sicherheitsbertrag As Double = SND.tblSnd_Warenwert * (GesSichRef.gsr_zollsatz / 100)
|
|
|
|
If sicherheitsbertrag > saldo Then
|
|
If MsgBox("Gestellung kann NICHT durchgeführt werden!" & vbNewLine & "Eingetragener Warenwert: " & SND.tblSnd_Warenwert & " (Sicherheitsbetrag: " & sicherheitsbertrag & ") übersteigt den vorhandenen Sicherheitssaldo von: " & saldo & vbNewLine & "Trotzdem fortfahren", vbYesNoCancel) <> vbYes Then Exit Sub
|
|
End If
|
|
|
|
Dim frMZA As New SDL.frmZollanmeldung("AA", Nothing, AVISO, SND, Now.ToString("yy"), GesSichRef, Standort, gsnr_proLKW_global)
|
|
|
|
frMZA.Show()
|
|
|
|
|
|
AddHandler frMZA.FormClosed, Sub()
|
|
initGesamtsicherheiten()
|
|
' initdgvZollAnmeldungen()
|
|
End Sub
|
|
Else
|
|
MsgBox("Fehler beim Speichern. Ankunftsanzeige abgebrochen.")
|
|
End If
|
|
Me.Cursor = Cursors.Default
|
|
End Sub
|
|
|
|
|
|
Private Sub btnGesSicherheit_Click(sender As Object, e As EventArgs) Handles btnGesSicherheit.Click
|
|
|
|
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
|
Dim gsnr As Integer = 0
|
|
Dim sqlWhere = ""
|
|
|
|
Dim dt As New DataTable
|
|
|
|
|
|
'1.Schritt -> Gestellung nach aktuellster ATB-NR
|
|
If txtATBT1.Text <> "" Then
|
|
Dim SQLString As String = "Select top (1) gs_gsNr from [tblGesamtsicherheit] where [gs_ATBNr] = '" & txtATBT1.Text & "' order by gs_datum desc"
|
|
dt = SQL.loadDgvBySql(SQLString, "AVISO", 100, True)
|
|
If dt.Rows.Count > 0 Then
|
|
gsnr = dt.Rows(0).Item("gs_gsNr")
|
|
End If
|
|
End If
|
|
|
|
'falls nicht gefunden, 2 Schritt -> Gestellung nach AVISO ID, oder Aberftigungsnr and FilialNr
|
|
If gsnr = 0 Then
|
|
Dim SQLString As String = "Select top (1) gs_gsNr from [tblGesamtsicherheit] where ([gs_filialenNr] = '" & SND.FilialenNr & "' and [gs_abfertigungsNr] = " & SND.AbfertigungsNr & " ) order by gs_datum desc"
|
|
dt = SQL.loadDgvBySql(SQLString, "AVISO", 100, True)
|
|
If dt.Rows.Count > 0 Then
|
|
gsnr = dt.Rows(0).Item("gs_gsNr")
|
|
End If
|
|
End If
|
|
|
|
gsnr_global = gsnr
|
|
|
|
If gsnr > 0 Then
|
|
|
|
Dim gessicherheit As New cSicherheiten(gsnr)
|
|
Dim GesSichRef = New VERAG_PROG_ALLGEMEIN.cAufschubKonten(gessicherheit.gs_standort)
|
|
Dim frm As New frmGesamtsicherheitenNEU()
|
|
|
|
Select Case gessicherheit.gs_standort
|
|
Case "Verag GmbH"
|
|
firmaId = 2
|
|
Case "Verag AG"
|
|
firmaId = 1
|
|
Case "Unisped GmbH"
|
|
firmaId = 21
|
|
Case "AMBAR GmbH"
|
|
firmaId = 24
|
|
Case "Verag CS"
|
|
firmaId = 11
|
|
Case "IMEX"
|
|
firmaId = 20
|
|
|
|
End Select
|
|
|
|
With frm
|
|
|
|
.currentGesSichRef = GesSichRef
|
|
.gessicherheitID = gessicherheit.gs_gsNr
|
|
.datum = gessicherheit.gs_datum
|
|
.Standort = gessicherheit.gs_standort
|
|
.FilialNummer = SND.FilialenNr
|
|
.Abfertigungsnummer = SND.AbfertigungsNr
|
|
.warenortID = gessicherheit.gs_warenort
|
|
.LKWKZ = gessicherheit.gs_LKWKZ
|
|
.avisoID = gessicherheit.gs_avisoId
|
|
.firmaId = firmaId
|
|
'.warenortPrefix = SND.tblSnd_Zollsystem_Land
|
|
End With
|
|
|
|
AddHandler frm.FormClosing, Function()
|
|
GesSichRef.CalcSaldo()
|
|
Me.BringToFront()
|
|
End Function
|
|
frm.Show()
|
|
Else
|
|
|
|
|
|
Dim Standort As String = ""
|
|
|
|
|
|
Select Case SND.FilialenNr
|
|
Case 4803, 4809
|
|
Standort = "VERAG AG" : firmaId = 1
|
|
Case 5601
|
|
Standort = "Unisped GmbH" : firmaId = 21
|
|
Case 5701
|
|
Standort = "AMBAR GmbH" : firmaId = 24
|
|
Case 4810, 5103, 5901
|
|
Standort = "VERAG GmbH" : firmaId = 2
|
|
Case 5501
|
|
Standort = "IMEX" : firmaId = 20
|
|
End Select
|
|
|
|
'sonderfälle lt. Mestan
|
|
If SND.tblSnd_Zollsystem_Land = "DE" Then
|
|
|
|
Select Case SND.FilialenNr
|
|
Case 5501, 4803, 4809, 5103
|
|
Standort = "VERAG GmbH" : firmaId = 2
|
|
End Select
|
|
|
|
ElseIf SND.tblSnd_Zollsystem_Land = "AT" Then
|
|
|
|
If SND.tblSnd_Abfertigungsart_ID = 1 Then 'ZA
|
|
Standort = "VERAG CS" : firmaId = 11
|
|
ElseIf SND.tblSnd_Abfertigungsart_ID = 38 Then 'EV-Verz
|
|
Select Case SND.FilialenNr
|
|
Case 4803, 5303, 4809, 5103
|
|
Standort = "VERAG CS" : firmaId = 11
|
|
End Select
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
Dim GesSichRef = New VERAG_PROG_ALLGEMEIN.cAufschubKonten(Standort)
|
|
Dim frm As New frmGesamtsicherheitenNEU
|
|
|
|
|
|
If GesSichRef Is Nothing Then
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
With frm
|
|
.currentGesSichRef = GesSichRef
|
|
.Standort = Standort
|
|
.datum = Date.Now
|
|
.Neu = True
|
|
.FilialNummer = SND.FilialenNr
|
|
.Abfertigungsnummer = SND.AbfertigungsNr
|
|
.firmaId = firmaId
|
|
.grenzstelle = AVISO.Grenzstelle.ToString.Replace("WO_", "")
|
|
.txtlkwIdSearch.Text = AVISO.LKW_Nr
|
|
.txtSicherheitWarenwert.Text = SND.tblSnd_Warenwert
|
|
.txtSicherheitATBNr.Text = txtATBT1.Text
|
|
End With
|
|
AddHandler frm.FormClosing, Function()
|
|
GesSichRef.CalcSaldo()
|
|
Me.BringToFront()
|
|
End Function
|
|
frm.Show(Me)
|
|
|
|
End If
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub usrCntlSND_ATBGestellung_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
|
|
initGesamtsicherheiten()
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub initGesamtsicherheiten()
|
|
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
|
Dim gsnr As Integer = 0
|
|
Dim gsnr_proLKW As Integer = 0
|
|
Dim sqlWhere = ""
|
|
|
|
Dim dt As New DataTable
|
|
|
|
If SND.tblSnd_ATB_T1 IsNot Nothing Then txtATBT1.Text = SND.tblSnd_ATB_T1.ToString
|
|
|
|
If gsnr_proLKW = 0 Then
|
|
Dim SQLString As String = "Select top (1) gs_gsNr from [tblGesamtsicherheit] where gs_avisoId = '" & SND.tblSnd_AvisoID & "' order by gs_datum desc"
|
|
dt = SQL.loadDgvBySql(SQLString, "AVISO", 100, True)
|
|
If dt.Rows.Count > 0 Then
|
|
gsnr_proLKW = dt.Rows(0).Item("gs_gsNr")
|
|
End If
|
|
End If
|
|
|
|
'1.Schritt -> Gestellung nach aktuellster ATB-NR
|
|
If txtATBT1.Text <> "" Then
|
|
Dim SQLString As String = "Select top (1) gs_gsNr from [tblGesamtsicherheit] where [gs_ATBNr] = '" & txtATBT1.Text & "' order by gs_datum desc"
|
|
dt = SQL.loadDgvBySql(SQLString, "AVISO", 100, True)
|
|
If dt.Rows.Count > 0 Then
|
|
gsnr = dt.Rows(0).Item("gs_gsNr")
|
|
End If
|
|
End If
|
|
|
|
'falls nicht gefunden, 2 Schritt -> Gestellung nach AVISO ID, oder Aberftigungsnr and FilialNr
|
|
If gsnr = 0 Then
|
|
Dim SQLString As String = "Select top (1) gs_gsNr from [tblGesamtsicherheit] where ([gs_filialenNr] = '" & SND.FilialenNr & "' and [gs_abfertigungsNr] = " & SND.AbfertigungsNr & " ) order by gs_datum desc"
|
|
dt = SQL.loadDgvBySql(SQLString, "AVISO", 100, True)
|
|
If dt.Rows.Count > 0 Then
|
|
gsnr = dt.Rows(0).Item("gs_gsNr")
|
|
End If
|
|
End If
|
|
|
|
gsnr_global = gsnr
|
|
gsnr_proLKW_global = gsnr_proLKW
|
|
|
|
If gsnr_global > 0 Then 'es gibt
|
|
btnGesSicherheit.Enabled = True
|
|
Else
|
|
btnGesSicherheit.Enabled = False
|
|
End If
|
|
|
|
If gsnr_proLKW_global > 0 AndAlso gsnr_global < 1 OrElse gsnr_proLKW_global < 1 Then
|
|
Button1.Enabled = True
|
|
Else
|
|
Button1.Enabled = False
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub DateTimePicker1_ValueChanged(sender As Object, e As EventArgs) Handles DateTimePicker1.ValueChanged
|
|
txtT1Datum._value = CDate(sender.value).ToShortDateString
|
|
End Sub
|
|
|
|
Private Sub PictureBox5_Click(sender As Object, e As EventArgs) Handles PictureBox5.Click
|
|
Dim webAddress As String = "https://wiki.verag.ag/e/de/software/aviso/howtos/Gesamtsicherheiten-AUTO"
|
|
Process.Start(webAddress)
|
|
End Sub
|
|
|
|
End Class
|