826 lines
35 KiB
VB.net
826 lines
35 KiB
VB.net
Imports System.Data.SqlClient
|
|
Imports System.Reflection
|
|
|
|
' ==========================================================================
|
|
' MASTER CLASS
|
|
' Customs Declaration (Header + Items + Duties + Documents)
|
|
' ==========================================================================
|
|
|
|
Public Class cVERAG_CustomsDeclarations
|
|
|
|
Public Property za_Id As Integer
|
|
Public Property za_System As String ' z.B. "DAKOSY"
|
|
Public Property za_CustomsSystem As String ' z.B. "ATLAS"
|
|
Public Property za_CustomsSystemCountry As String ' z.B. "DE"
|
|
Public Property za_IsExternalSystem As Boolean = False
|
|
Public Property za_IsFinalDeclaration As Boolean = False
|
|
Public Property za_UCR As String
|
|
Public Property za_Mandant_ID As String
|
|
Public Property za_Bereich_ID As String
|
|
Public Property za_Firma As String
|
|
Public Property za_Niederlassung As String
|
|
Public Property za_MRN As String
|
|
Public Property za_LRN As String
|
|
Public Property za_DeclarationNo As String
|
|
Public Property za_ReferenceCustomer As String
|
|
Public Property za_REGIME As String ' IMPORT, EXPORT, ...
|
|
Public Property za_RegistrationType As String
|
|
Public Property za_MainProcedure As String
|
|
Public Property za_AdditionalProcedure As String
|
|
Public Property za_DeclarationDate As Date?
|
|
Public Property za_ReleaseDate As Date?
|
|
Public Property za_AcceptanceDate As Date?
|
|
Public Property za_CustomsOffice As String
|
|
Public Property za_EntryCustomsOffice As String
|
|
Public Property za_RepresentationCode As String
|
|
Public Property za_TransportModeInland As String
|
|
Public Property za_TransportModeBorder As String
|
|
Public Property za_MeansOfTransport_Vehicle As String
|
|
Public Property za_MeansOfTransport_Type As String
|
|
Public Property za_MeansOfTransport_Nationality As String
|
|
|
|
Public Property za_ContainerNr1 As String
|
|
Public Property za_ContainerNr2 As String
|
|
Public Property za_ContainerNr3 As String
|
|
Public Property za_ContainerNr4 As String
|
|
Public Property za_ContainerNr5 As String
|
|
Public Property za_ContainerNr6 As String
|
|
Public Property za_ContainerNr7 As String
|
|
Public Property za_ContainerNr8 As String
|
|
Public Property za_ContainerNr9 As String
|
|
Public Property za_CountryDispatch As String
|
|
Public Property za_CountryDestination As String
|
|
Public Property za_CountryDestinationState As String
|
|
Public Property za_CountryImport As String
|
|
Public Property za_WarehouseCode As String
|
|
Public Property za_Incoterms As String
|
|
Public Property za_IncotermsPlace As String
|
|
Public Property za_InvoiceAmount As Decimal?
|
|
Public Property za_InvoiceCurrency As String
|
|
|
|
Public Property za_FiscalRepFlag As Boolean?
|
|
Public Property za_TaxDeduction As Boolean?
|
|
Public Property za_ApplicantTaxOffice As String
|
|
Public Property za_ApplicantVATNo As String
|
|
Public Property za_DV1Flag As Boolean?
|
|
Public Property za_PrevDocument_Type As String
|
|
Public Property za_PrevDocument_No As String
|
|
Public Property za_AvisoId As Integer?
|
|
Public Property za_SendungsId As Integer?
|
|
Public Property za_Remarks As String
|
|
Public Property za_Sachbearbeiter As String
|
|
Public Property za_SachbearbeiterId As String
|
|
|
|
Public Property Parties As New List(Of cVERAG_CustomsDeclarations_Parties)
|
|
Public Property Items As New List(Of cVERAG_CustomsDeclarations_Item)
|
|
Public Property Duties As New List(Of cVERAG_CustomsDeclarations_Duty)
|
|
Public Property Documents As New List(Of cVERAG_CustomsDeclarations_Document)
|
|
|
|
Public Property hasEntry As Boolean = False
|
|
|
|
|
|
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
|
|
|
Public Function getParameterList() As List(Of SQLVariable)
|
|
Return New List(Of SQLVariable) From {
|
|
New SQLVariable("za_Id", za_Id,, True),
|
|
New SQLVariable("za_System", za_System),
|
|
New SQLVariable("za_CustomsSystem", za_CustomsSystem),
|
|
New SQLVariable("za_CustomsSystemCountry", za_CustomsSystemCountry),
|
|
New SQLVariable("za_IsExternalSystem", za_IsExternalSystem),
|
|
New SQLVariable("za_IsFinalDeclaration", za_IsFinalDeclaration),
|
|
New SQLVariable("za_UCR", za_UCR),
|
|
New SQLVariable("za_Mandant_ID", za_Mandant_ID),
|
|
New SQLVariable("za_Bereich_ID", za_Bereich_ID),
|
|
New SQLVariable("za_Firma", za_Firma),
|
|
New SQLVariable("za_Niederlassung", za_Niederlassung),
|
|
New SQLVariable("za_MRN", za_MRN),
|
|
New SQLVariable("za_LRN", za_LRN),
|
|
New SQLVariable("za_DeclarationNo", za_DeclarationNo),
|
|
New SQLVariable("za_ReferenceCustomer", za_ReferenceCustomer),
|
|
New SQLVariable("za_REGIME", za_REGIME),
|
|
New SQLVariable("za_RegistrationType", za_RegistrationType),
|
|
New SQLVariable("za_MainProcedure", za_MainProcedure),
|
|
New SQLVariable("za_AdditionalProcedure", za_AdditionalProcedure),
|
|
New SQLVariable("za_DeclarationDate", za_DeclarationDate),
|
|
New SQLVariable("za_ReleaseDate", za_ReleaseDate),
|
|
New SQLVariable("za_AcceptanceDate", za_AcceptanceDate),
|
|
New SQLVariable("za_CustomsOffice", za_CustomsOffice),
|
|
New SQLVariable("za_EntryCustomsOffice", za_EntryCustomsOffice),
|
|
New SQLVariable("za_RepresentationCode", za_RepresentationCode),
|
|
New SQLVariable("za_TransportModeInland", za_TransportModeInland),
|
|
New SQLVariable("za_TransportModeBorder", za_TransportModeBorder),
|
|
New SQLVariable("za_MeansOfTransport_Vehicle", za_MeansOfTransport_Vehicle),
|
|
New SQLVariable("za_MeansOfTransport_Type", za_MeansOfTransport_Type),
|
|
New SQLVariable("za_MeansOfTransport_Nationality", za_MeansOfTransport_Nationality),
|
|
New SQLVariable("za_ContainerNr1", za_ContainerNr1),
|
|
New SQLVariable("za_ContainerNr2", za_ContainerNr2),
|
|
New SQLVariable("za_ContainerNr3", za_ContainerNr3),
|
|
New SQLVariable("za_ContainerNr4", za_ContainerNr4),
|
|
New SQLVariable("za_ContainerNr5", za_ContainerNr5),
|
|
New SQLVariable("za_ContainerNr6", za_ContainerNr6),
|
|
New SQLVariable("za_ContainerNr7", za_ContainerNr7),
|
|
New SQLVariable("za_ContainerNr8", za_ContainerNr8),
|
|
New SQLVariable("za_ContainerNr9", za_ContainerNr9),
|
|
New SQLVariable("za_CountryDispatch", za_CountryDispatch),
|
|
New SQLVariable("za_CountryDestination", za_CountryDestination),
|
|
New SQLVariable("za_CountryDestinationState", za_CountryDestinationState),
|
|
New SQLVariable("za_CountryImport", za_CountryImport),
|
|
New SQLVariable("za_WarehouseCode", za_WarehouseCode),
|
|
New SQLVariable("za_Incoterms", za_Incoterms),
|
|
New SQLVariable("za_IncotermsPlace", za_IncotermsPlace),
|
|
New SQLVariable("za_InvoiceAmount", za_InvoiceAmount),
|
|
New SQLVariable("za_InvoiceCurrency", za_InvoiceCurrency),
|
|
New SQLVariable("za_FiscalRepFlag", za_FiscalRepFlag),
|
|
New SQLVariable("za_TaxDeduction", za_TaxDeduction),
|
|
New SQLVariable("za_ApplicantTaxOffice", za_ApplicantTaxOffice),
|
|
New SQLVariable("za_ApplicantVATNo", za_ApplicantVATNo),
|
|
New SQLVariable("za_DV1Flag", za_DV1Flag),
|
|
New SQLVariable("za_PrevDocument_Type", za_PrevDocument_Type),
|
|
New SQLVariable("za_PrevDocument_No", za_PrevDocument_No),
|
|
New SQLVariable("za_AvisoId", za_AvisoId),
|
|
New SQLVariable("za_SendungsId", za_SendungsId),
|
|
New SQLVariable("za_Remarks", za_Remarks),
|
|
New SQLVariable("za_Sachbearbeiter", za_Sachbearbeiter),
|
|
New SQLVariable("za_SachbearbeiterId", za_SachbearbeiterId)
|
|
}
|
|
End Function
|
|
|
|
|
|
Public Function getInsertCmd() As String
|
|
Dim f As String = "", v As String = ""
|
|
For Each i In getParameterList()
|
|
If Not i.isPrimaryParam Then
|
|
f &= "[" & i.Text & "],"
|
|
v &= "@" & i.Scalarvariable & ","
|
|
End If
|
|
Next
|
|
Return "INSERT INTO tblVERAG_CustomsDeclarations (" &
|
|
f.TrimEnd(","c) & ") VALUES (" & v.TrimEnd(","c) & ")"
|
|
End Function
|
|
|
|
Public Function getUpdateCmd() As String
|
|
Dim s As String = ""
|
|
For Each i In getParameterList()
|
|
If Not i.isPrimaryParam Then
|
|
s &= "[" & i.Text & "]=@" & i.Scalarvariable & ","
|
|
End If
|
|
Next
|
|
Return "UPDATE tblVERAG_CustomsDeclarations SET " &
|
|
s.TrimEnd(","c) & " WHERE za_Id=@za_Id"
|
|
End Function
|
|
|
|
Public Sub LOAD()
|
|
Try
|
|
hasEntry = False
|
|
Using conn = SQL.GetNewOpenConnectionFMZOLL()
|
|
Using cmd As New SqlCommand(
|
|
"SELECT * FROM tblVERAG_CustomsDeclarations WHERE za_Id=@_BASE_id", conn)
|
|
|
|
cmd.Parameters.AddWithValue("@_BASE_id", za_Id)
|
|
Dim dr = cmd.ExecuteReader()
|
|
If dr.Read Then
|
|
For Each li In getParameterList()
|
|
Dim pi = Me.GetType.GetProperty(li.Scalarvariable)
|
|
If dr.Item(li.Text) Is DBNull.Value Then
|
|
pi.SetValue(Me, Nothing)
|
|
Else
|
|
pi.SetValue(Me, dr.Item(li.Text))
|
|
End If
|
|
Next
|
|
hasEntry = True
|
|
End If
|
|
dr.Close()
|
|
End Using
|
|
End Using
|
|
|
|
Parties = cVERAG_CustomsDeclarations_Parties.LOAD_BY_ZAID(za_Id)
|
|
Items = cVERAG_CustomsDeclarations_Item.LOAD_BY_ZAID(za_Id)
|
|
Duties = cVERAG_CustomsDeclarations_Duty.LOAD_BY_ZAID(za_Id)
|
|
Documents = cVERAG_CustomsDeclarations_Document.LOAD_HEAD_BY_ZAID(za_Id)
|
|
|
|
Catch ex As Exception
|
|
cErrorHandler.ERR(ex.Message, ex.StackTrace, MethodInfo.GetCurrentMethod.Name)
|
|
End Try
|
|
End Sub
|
|
|
|
Public Shared Function loadByMRN(MRN As String, loadall As Boolean) As cVERAG_CustomsDeclarations
|
|
Dim ZA As New cVERAG_CustomsDeclarations
|
|
If If(MRN, "") = "" Then Return ZA
|
|
Try
|
|
ZA.hasEntry = False
|
|
Using conn = SQL.GetNewOpenConnectionFMZOLL()
|
|
Using cmd As New SqlCommand(
|
|
"SELECT * FROM tblVERAG_CustomsDeclarations WHERE za_MRN=@_BASE_id", conn)
|
|
|
|
cmd.Parameters.AddWithValue("@_BASE_id", MRN)
|
|
Dim dr = cmd.ExecuteReader()
|
|
If dr.Read Then
|
|
For Each li In ZA.getParameterList()
|
|
Dim pi = ZA.GetType.GetProperty(li.Scalarvariable)
|
|
If dr.Item(li.Text) Is DBNull.Value Then
|
|
pi.SetValue(ZA, Nothing)
|
|
Else
|
|
pi.SetValue(ZA, dr.Item(li.Text))
|
|
End If
|
|
Next
|
|
ZA.hasEntry = True
|
|
End If
|
|
dr.Close()
|
|
End Using
|
|
End Using
|
|
If loadall Then
|
|
|
|
ZA.Parties = cVERAG_CustomsDeclarations_Parties.LOAD_BY_ZAID(ZA.za_Id)
|
|
ZA.Items = cVERAG_CustomsDeclarations_Item.LOAD_BY_ZAID(ZA.za_Id)
|
|
ZA.Duties = cVERAG_CustomsDeclarations_Duty.LOAD_BY_ZAID(ZA.za_Id)
|
|
ZA.Documents = cVERAG_CustomsDeclarations_Document.LOAD_HEAD_BY_ZAID(ZA.za_Id)
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
cErrorHandler.ERR(ex.Message, ex.StackTrace, MethodInfo.GetCurrentMethod.Name)
|
|
End Try
|
|
Return ZA
|
|
End Function
|
|
|
|
Public Function SAVE() As Boolean
|
|
Dim list = getParameterList()
|
|
|
|
Dim sqlstr =
|
|
"BEGIN TRAN " &
|
|
"IF EXISTS(SELECT 1 FROM tblVERAG_CustomsDeclarations WHERE za_Id=@za_Id) " &
|
|
"BEGIN " & getUpdateCmd() & " END " &
|
|
"ELSE BEGIN " & getInsertCmd() & " END " &
|
|
"COMMIT TRAN"
|
|
|
|
za_Id = SQL.doSQLVarListID(za_Id, sqlstr, "FMZOLL", , list)
|
|
If za_Id <= 0 Then Return False
|
|
|
|
cVERAG_CustomsDeclarations_Parties.REPLACE_ALL(za_Id, Parties)
|
|
cVERAG_CustomsDeclarations_Duty.REPLACE_ALL(za_Id, Duties)
|
|
cVERAG_CustomsDeclarations_Document.REPLACE_HEAD(za_Id, Documents)
|
|
cVERAG_CustomsDeclarations_Item.REPLACE_ALL(za_Id, Items)
|
|
|
|
Return True
|
|
End Function
|
|
End Class
|
|
|
|
Public Class cVERAG_CustomsDeclarations_Parties
|
|
|
|
Public Property zaParty_Id As Integer
|
|
Public Property zaParty_zaId As Integer
|
|
Public Property zaParty_Role As String
|
|
Public Property zaParty_EORI As String
|
|
Public Property zaParty_EORI_NL As String
|
|
Public Property zaParty_Name As String
|
|
Public Property zaParty_Street As String
|
|
Public Property zaParty_PostalCode As String
|
|
Public Property zaParty_City As String
|
|
Public Property zaParty_Country As String
|
|
Public Property zaParty_TIN As String
|
|
Public Property zaParty_VATNumber As String
|
|
Public Property zaParty_TaxOffice As String
|
|
Public Property zaParty_ContactName As String
|
|
Public Property zaParty_Phone As String
|
|
Public Property zaParty_Email As String
|
|
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
|
|
|
Public Function getParameterList() As List(Of SQLVariable)
|
|
Return New List(Of SQLVariable) From {
|
|
New SQLVariable("zaParty_Id", zaParty_Id,, True),
|
|
New SQLVariable("zaParty_zaId", zaParty_zaId),
|
|
New SQLVariable("zaParty_Role", zaParty_Role),
|
|
New SQLVariable("zaParty_EORI", zaParty_EORI),
|
|
New SQLVariable("zaParty_EORI_NL", zaParty_EORI_NL),
|
|
New SQLVariable("zaParty_Name", zaParty_Name),
|
|
New SQLVariable("zaParty_Street", zaParty_Street),
|
|
New SQLVariable("zaParty_PostalCode", zaParty_PostalCode),
|
|
New SQLVariable("zaParty_City", zaParty_City),
|
|
New SQLVariable("zaParty_Country", zaParty_Country),
|
|
New SQLVariable("zaParty_VATNumber", zaParty_VATNumber),
|
|
New SQLVariable("zaParty_TaxOffice", zaParty_TaxOffice),
|
|
New SQLVariable("zaParty_TIN", zaParty_TIN),
|
|
New SQLVariable("zaParty_ContactName", zaParty_ContactName),
|
|
New SQLVariable("zaParty_Phone", zaParty_Phone),
|
|
New SQLVariable("zaParty_Email", zaParty_Email)
|
|
}
|
|
End Function
|
|
|
|
Public Function getInsertCmd() As String
|
|
Dim f As String = "", v As String = ""
|
|
For Each i In getParameterList()
|
|
If Not i.isPrimaryParam Then
|
|
f &= "[" & i.Text & "],"
|
|
v &= "@" & i.Scalarvariable & ","
|
|
End If
|
|
Next
|
|
Return "INSERT INTO tblVERAG_CustomsDeclarations_Parties (" &
|
|
f.TrimEnd(","c) & ") VALUES (" & v.TrimEnd(","c) & ")"
|
|
End Function
|
|
|
|
Public Shared Sub REPLACE_ALL(zaId As Integer, list As List(Of cVERAG_CustomsDeclarations_Parties))
|
|
|
|
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
|
SQL.doSQL("DELETE FROM tblVERAG_CustomsDeclarations_Parties WHERE zaParty_zaId=" & zaId, "FMZOLL")
|
|
For Each p In list
|
|
p.zaParty_zaId = zaId
|
|
p.zaParty_Id = SQL.doSQLVarListID(p.zaParty_Id, p.getInsertCmd(), "FMZOLL", , p.getParameterList())
|
|
Next
|
|
End Sub
|
|
|
|
Public Shared Function LOAD_BY_ZAID(zaId As Integer) As List(Of cVERAG_CustomsDeclarations_Parties)
|
|
|
|
Dim result As New List(Of cVERAG_CustomsDeclarations_Parties)
|
|
|
|
Try
|
|
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
|
|
Using cmd As New SqlCommand(
|
|
"SELECT * FROM tblVERAG_CustomsDeclarations_Parties WHERE zaParty_zaId=@zaId",
|
|
conn)
|
|
|
|
cmd.Parameters.AddWithValue("@zaId", zaId)
|
|
|
|
Using dr As SqlDataReader = cmd.ExecuteReader()
|
|
While dr.Read()
|
|
|
|
Dim obj As New cVERAG_CustomsDeclarations_Parties
|
|
|
|
For Each li In obj.getParameterList()
|
|
Dim propInfo As PropertyInfo =
|
|
obj.GetType().GetProperty(li.Scalarvariable)
|
|
|
|
If dr.Item(li.Text) Is DBNull.Value Then
|
|
propInfo.SetValue(obj, Nothing)
|
|
Else
|
|
propInfo.SetValue(obj, dr.Item(li.Text))
|
|
End If
|
|
Next
|
|
|
|
result.Add(obj)
|
|
|
|
End While
|
|
End Using
|
|
End Using
|
|
End Using
|
|
|
|
Catch ex As Exception
|
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(
|
|
ex.Message,
|
|
ex.StackTrace,
|
|
System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
|
End Try
|
|
|
|
Return result
|
|
End Function
|
|
End Class
|
|
|
|
' ##########################################################
|
|
' ITEMS
|
|
' ##########################################################
|
|
Public Class cVERAG_CustomsDeclarations_Item
|
|
|
|
Public Property zaItem_Id As Integer
|
|
Public Property zaItem_zaId As Integer
|
|
Public Property zaItem_PosNo As Integer
|
|
|
|
Public Property zaItem_ArticleCode As String
|
|
Public Property zaItem_HSCode As String
|
|
Public Property zaItem_HSAddition1 As String
|
|
Public Property zaItem_HSAddition2 As String
|
|
Public Property zaItem_HSAddCodes1 As String
|
|
Public Property zaItem_HSAddCodes2 As String
|
|
Public Property zaItem_HSAddCodes3 As String
|
|
Public Property zaItem_HSAddCodes4 As String
|
|
Public Property zaItem_HSAddCodes5 As String
|
|
Public Property zaItem_HSAddCodes6 As String
|
|
Public Property zaItem_HSAddCodes7 As String
|
|
Public Property zaItem_HSAddCodes8 As String
|
|
Public Property zaItem_HSAddCodes9 As String
|
|
Public Property zaItem_HSAddCodes10 As String
|
|
Public Property zaItem_Description As String
|
|
|
|
Public Property zaItem_PackageColli As String
|
|
Public Property zaItem_PackageType As String
|
|
Public Property zaItem_PackageMark As String
|
|
Public Property zaItem_OriginCountry As String
|
|
Public Property zaItem_PreferentialCountry As String
|
|
Public Property zaItem_PreferenceCode As String
|
|
Public Property zaItem_QuotaNo As String
|
|
|
|
Public Property zaItem_MainProcedure As String
|
|
Public Property zaItem_AdditionalProc As String
|
|
Public Property zaItem_PrevProcedure As String
|
|
|
|
Public Property zaItem_GrossMass As Decimal?
|
|
Public Property zaItem_NetMass As Decimal?
|
|
|
|
Public Property zaItem_SuppUnitCode As String
|
|
Public Property zaItem_SuppQuantity As Decimal?
|
|
|
|
Public Property zaItem_StatisticalValueEUR As Decimal?
|
|
Public Property zaItem_CustomsValueEUR As Decimal?
|
|
|
|
Public Property zaItem_InvoiceCurrency As String
|
|
Public Property zaItem_InvoiceValueForeign As Decimal?
|
|
Public Property zaItem_InvoiceValueEUR As Decimal?
|
|
|
|
Public Property zaItem_BeguenstigungCode As String
|
|
Public Property zaItem_DV1Flag As Boolean?
|
|
Public Property zaItem_PosAddition As String
|
|
Public Property zaItem_Remarks As String
|
|
|
|
Public Property Documents As New List(Of cVERAG_CustomsDeclarations_Document)
|
|
Public Property hasEntry As Boolean = False
|
|
|
|
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
|
|
|
Public Function getParameterList() As List(Of SQLVariable)
|
|
Return New List(Of SQLVariable) From {
|
|
New SQLVariable("zaItem_Id", zaItem_Id,, True),
|
|
New SQLVariable("zaItem_zaId", zaItem_zaId),
|
|
New SQLVariable("zaItem_PosNo", zaItem_PosNo),
|
|
New SQLVariable("zaItem_ArticleCode", zaItem_ArticleCode),
|
|
New SQLVariable("zaItem_HSCode", zaItem_HSCode),
|
|
New SQLVariable("zaItem_HSAddition1", zaItem_HSAddition1),
|
|
New SQLVariable("zaItem_HSAddition2", zaItem_HSAddition2),
|
|
New SQLVariable("zaItem_HSAddCodes1", zaItem_HSAddCodes1),
|
|
New SQLVariable("zaItem_HSAddCodes2", zaItem_HSAddCodes2),
|
|
New SQLVariable("zaItem_HSAddCodes3", zaItem_HSAddCodes3),
|
|
New SQLVariable("zaItem_HSAddCodes4", zaItem_HSAddCodes4),
|
|
New SQLVariable("zaItem_HSAddCodes5", zaItem_HSAddCodes5),
|
|
New SQLVariable("zaItem_HSAddCodes6", zaItem_HSAddCodes6),
|
|
New SQLVariable("zaItem_HSAddCodes7", zaItem_HSAddCodes7),
|
|
New SQLVariable("zaItem_HSAddCodes8", zaItem_HSAddCodes8),
|
|
New SQLVariable("zaItem_HSAddCodes9", zaItem_HSAddCodes9),
|
|
New SQLVariable("zaItem_HSAddCodes10", zaItem_HSAddCodes10),
|
|
New SQLVariable("zaItem_Description", zaItem_Description),
|
|
New SQLVariable("zaItem_PackageColli", zaItem_PackageColli),
|
|
New SQLVariable("zaItem_PackageType", zaItem_PackageType),
|
|
New SQLVariable("zaItem_PackageMark", zaItem_PackageMark),
|
|
New SQLVariable("zaItem_OriginCountry", zaItem_OriginCountry),
|
|
New SQLVariable("zaItem_PreferentialCountry", zaItem_PreferentialCountry),
|
|
New SQLVariable("zaItem_PreferenceCode", zaItem_PreferenceCode),
|
|
New SQLVariable("zaItem_QuotaNo", zaItem_QuotaNo),
|
|
New SQLVariable("zaItem_MainProcedure", zaItem_MainProcedure),
|
|
New SQLVariable("zaItem_AdditionalProc", zaItem_AdditionalProc),
|
|
New SQLVariable("zaItem_PrevProcedure", zaItem_PrevProcedure),
|
|
New SQLVariable("zaItem_GrossMass", zaItem_GrossMass),
|
|
New SQLVariable("zaItem_NetMass", zaItem_NetMass),
|
|
New SQLVariable("zaItem_SuppUnitCode", zaItem_SuppUnitCode),
|
|
New SQLVariable("zaItem_SuppQuantity", zaItem_SuppQuantity),
|
|
New SQLVariable("zaItem_StatisticalValueEUR", zaItem_StatisticalValueEUR),
|
|
New SQLVariable("zaItem_CustomsValueEUR", zaItem_CustomsValueEUR),
|
|
New SQLVariable("zaItem_InvoiceCurrency", zaItem_InvoiceCurrency),
|
|
New SQLVariable("zaItem_InvoiceValueForeign", zaItem_InvoiceValueForeign),
|
|
New SQLVariable("zaItem_InvoiceValueEUR", zaItem_InvoiceValueEUR),
|
|
New SQLVariable("zaItem_BeguenstigungCode", zaItem_BeguenstigungCode),
|
|
New SQLVariable("zaItem_DV1Flag", zaItem_DV1Flag),
|
|
New SQLVariable("zaItem_PosAddition", zaItem_PosAddition),
|
|
New SQLVariable("zaItem_Remarks", zaItem_Remarks)
|
|
}
|
|
End Function
|
|
|
|
|
|
Public Function getInsertCmd() As String
|
|
Dim f As String = "", v As String = ""
|
|
For Each i In getParameterList()
|
|
If Not i.isPrimaryParam Then
|
|
f &= "[" & i.Text & "],"
|
|
v &= "@" & i.Scalarvariable & ","
|
|
End If
|
|
Next
|
|
Return "INSERT INTO tblVERAG_CustomsDeclarations_Items (" &
|
|
f.TrimEnd(","c) & ") VALUES (" & v.TrimEnd(","c) & ")"
|
|
End Function
|
|
|
|
|
|
' ---------- DELETE + INSERT ----------
|
|
Public Shared Sub REPLACE_ALL(zaId As Integer, list As List(Of cVERAG_CustomsDeclarations_Item))
|
|
|
|
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
|
|
|
SQL.doSQL("DELETE FROM tblVERAG_CustomsDeclarations_Items WHERE zaItem_zaId=" & zaId, "FMZOLL")
|
|
SQL.doSQL("DELETE FROM tblVERAG_CustomsDeclarations_Documents WHERE zaDoc_zaId=" & zaId & " AND zaDoc_ItemId is not null", "FMZOLL")
|
|
|
|
For Each it In list
|
|
it.zaItem_zaId = zaId
|
|
it.zaItem_Id = SQL.doSQLVarListID(it.zaItem_Id, it.getInsertCmd(), "FMZOLL", , it.getParameterList())
|
|
'MsgBox(it.zaItem_Id)
|
|
cVERAG_CustomsDeclarations_Document.INSERT_ITEM(it.zaItem_zaId, it.zaItem_Id, it.Documents)
|
|
Next
|
|
End Sub
|
|
|
|
Public Shared Function LOAD_BY_ZAID(zaId As Integer) As List(Of cVERAG_CustomsDeclarations_Item)
|
|
|
|
Dim result As New List(Of cVERAG_CustomsDeclarations_Item)
|
|
|
|
Try
|
|
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
|
|
|
|
Using cmd As New SqlCommand(
|
|
"SELECT * FROM tblVERAG_CustomsDeclarations_Items WHERE zaItem_zaId=@zaId",
|
|
conn)
|
|
|
|
cmd.Parameters.AddWithValue("@zaId", zaId)
|
|
|
|
Using dr As SqlDataReader = cmd.ExecuteReader()
|
|
While dr.Read()
|
|
|
|
Dim it As New cVERAG_CustomsDeclarations_Item
|
|
it.hasEntry = False
|
|
|
|
For Each li In it.getParameterList()
|
|
Dim pi As PropertyInfo =
|
|
it.GetType().GetProperty(li.Scalarvariable)
|
|
|
|
If dr.Item(li.Text) Is DBNull.Value Then
|
|
pi.SetValue(it, Nothing)
|
|
Else
|
|
pi.SetValue(it, dr.Item(li.Text))
|
|
End If
|
|
Next
|
|
|
|
it.hasEntry = True
|
|
result.Add(it)
|
|
|
|
End While
|
|
End Using
|
|
End Using
|
|
End Using
|
|
|
|
' ===== Documents NACHLADEN (pro Item) =====
|
|
For Each it In result
|
|
it.Documents =
|
|
cVERAG_CustomsDeclarations_Document.LOAD_ITEM_BY_ITEMID(zaId, it.zaItem_Id)
|
|
Next
|
|
|
|
Catch ex As Exception
|
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
|
End Try
|
|
|
|
Return result
|
|
End Function
|
|
End Class
|
|
|
|
' ##########################################################
|
|
' DUTIES
|
|
' ##########################################################
|
|
Public Class cVERAG_CustomsDeclarations_Duty
|
|
|
|
Public Property zaDuty_Id As Integer
|
|
Public Property zaDuty_zaId As Integer
|
|
Public Property zaDuty_AccountType As String
|
|
Public Property zaDuty_AccountHeadCustoms As String
|
|
Public Property zaDuty_ApplicationType As String
|
|
Public Property zaDuty_AccountNo As String
|
|
|
|
|
|
|
|
|
|
Public Property zaDuty_AccountEORI As String
|
|
Public Property zaDuty_AccountHolderName As String
|
|
Public Property zaDuty_DutyType As String
|
|
Public Property zaDuty_BIN As String
|
|
Public Property zaDuty_AmountEUR As Decimal?
|
|
Public Property zaDuty_AmountForeign As Decimal?
|
|
Public Property zaDuty_Currency As String
|
|
Public Property zaDuty_LimitDate As Date?
|
|
Public Property hasEntry As Boolean = False
|
|
|
|
Public Function getParameterList() As List(Of SQLVariable)
|
|
Return New List(Of SQLVariable) From {
|
|
New SQLVariable("zaDuty_Id", zaDuty_Id,, True),
|
|
New SQLVariable("zaDuty_zaId", zaDuty_zaId),
|
|
New SQLVariable("zaDuty_AccountType", zaDuty_AccountType),
|
|
New SQLVariable("zaDuty_AccountHeadCustoms", zaDuty_AccountHeadCustoms),
|
|
New SQLVariable("zaDuty_ApplicationType", zaDuty_ApplicationType),
|
|
New SQLVariable("zaDuty_AccountNo", zaDuty_AccountNo),
|
|
New SQLVariable("zaDuty_AccountEORI", zaDuty_AccountEORI),
|
|
New SQLVariable("zaDuty_AccountHolderName", zaDuty_AccountHolderName),
|
|
New SQLVariable("zaDuty_DutyType", zaDuty_DutyType),
|
|
New SQLVariable("zaDuty_BIN", zaDuty_BIN),
|
|
New SQLVariable("zaDuty_AmountEUR", zaDuty_AmountEUR),
|
|
New SQLVariable("zaDuty_AmountForeign", zaDuty_AmountForeign),
|
|
New SQLVariable("zaDuty_Currency", zaDuty_Currency),
|
|
New SQLVariable("zaDuty_LimitDate", zaDuty_LimitDate)
|
|
}
|
|
End Function
|
|
|
|
Public Function getInsertCmd() As String
|
|
Dim f As String = "", v As String = ""
|
|
For Each i In getParameterList()
|
|
If Not i.isPrimaryParam Then
|
|
f &= "[" & i.Text & "],"
|
|
v &= "@" & i.Scalarvariable & ","
|
|
End If
|
|
Next
|
|
Return "INSERT INTO tblVERAG_CustomsDeclarations_Duties (" &
|
|
f.TrimEnd(","c) & ") VALUES (" & v.TrimEnd(","c) & ")"
|
|
End Function
|
|
|
|
|
|
|
|
' ---------- DELETE + INSERT ----------
|
|
Public Shared Sub REPLACE_ALL(zaId As Integer, list As List(Of cVERAG_CustomsDeclarations_Duty))
|
|
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
|
|
|
SQL.doSQL("DELETE FROM tblVERAG_CustomsDeclarations_Duties WHERE zaDuty_zaId=" & zaId, "FMZOLL")
|
|
For Each d In list
|
|
d.zaDuty_zaId = zaId
|
|
d.zaDuty_Id = SQL.doSQLVarListID(d.zaDuty_Id, d.getInsertCmd(), "FMZOLL", , d.getParameterList())
|
|
Next
|
|
End Sub
|
|
|
|
Public Shared Function LOAD_BY_ZAID(zaId As Integer) _
|
|
As List(Of cVERAG_CustomsDeclarations_Duty)
|
|
|
|
Dim result As New List(Of cVERAG_CustomsDeclarations_Duty)
|
|
|
|
Try
|
|
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
|
|
Using cmd As New SqlCommand(
|
|
"SELECT * FROM tblVERAG_CustomsDeclarations_Duties WHERE zaDuty_zaId=@zaId",
|
|
conn)
|
|
|
|
cmd.Parameters.AddWithValue("@zaId", zaId)
|
|
|
|
Using dr As SqlDataReader = cmd.ExecuteReader()
|
|
While dr.Read()
|
|
|
|
Dim d As New cVERAG_CustomsDeclarations_Duty
|
|
d.hasEntry = False
|
|
|
|
' ===== DEINE LOAD-VORLAGE (1:1, nur in While) =====
|
|
For Each li In d.getParameterList()
|
|
Dim pi As PropertyInfo =
|
|
d.GetType().GetProperty(li.Scalarvariable)
|
|
|
|
If dr.Item(li.Text) Is DBNull.Value Then
|
|
pi.SetValue(d, Nothing)
|
|
Else
|
|
pi.SetValue(d, dr.Item(li.Text))
|
|
End If
|
|
Next
|
|
|
|
d.hasEntry = True
|
|
result.Add(d)
|
|
|
|
End While
|
|
End Using
|
|
End Using
|
|
End Using
|
|
|
|
Catch ex As Exception
|
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(
|
|
ex.Message,
|
|
ex.StackTrace,
|
|
System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
|
End Try
|
|
|
|
Return result
|
|
End Function
|
|
|
|
End Class
|
|
|
|
' ##########################################################
|
|
' DOCUMENTS (HEAD + ITEM)
|
|
' ##########################################################
|
|
Public Class cVERAG_CustomsDeclarations_Document
|
|
|
|
Public Property zaDoc_Id As Integer
|
|
Public Property zaDoc_zaId As Integer
|
|
Public Property zaDoc_ItemId As Integer?
|
|
Public Property zaDoc_Date As String
|
|
Public Property zaDoc_Section As String
|
|
Public Property zaDoc_Code As String
|
|
Public Property zaDoc_Presentation As String
|
|
Public Property zaDoc_DepreciationAmount As String
|
|
Public Property zaDoc_DepreciationUnitmeasurement As String
|
|
Public Property zaDoc_DepreciationUnitmeasurementQualifier As String
|
|
|
|
|
|
Public Property zaDoc_Reference As String
|
|
Public Property zaDoc_Description As String
|
|
|
|
Public Property hasEntry As Boolean = False
|
|
|
|
Public Function getParameterList() As List(Of SQLVariable)
|
|
Return New List(Of SQLVariable) From {
|
|
New SQLVariable("zaDoc_Id", zaDoc_Id,, True),
|
|
New SQLVariable("zaDoc_zaId", zaDoc_zaId),
|
|
New SQLVariable("zaDoc_ItemId", zaDoc_ItemId),
|
|
New SQLVariable("zaDoc_Date", zaDoc_Date),
|
|
New SQLVariable("zaDoc_Section", zaDoc_Section),
|
|
New SQLVariable("zaDoc_Code", zaDoc_Code),
|
|
New SQLVariable("zaDoc_Reference", zaDoc_Reference),
|
|
New SQLVariable("zaDoc_Presentation", zaDoc_Presentation),
|
|
New SQLVariable("zaDoc_DepreciationAmount", zaDoc_DepreciationAmount),
|
|
New SQLVariable("zaDoc_DepreciationUnitmeasurement", zaDoc_DepreciationUnitmeasurement),
|
|
New SQLVariable("zaDoc_DepreciationUnitmeasurementQualifier", zaDoc_DepreciationUnitmeasurementQualifier),
|
|
New SQLVariable("zaDoc_Description ", zaDoc_Description)
|
|
}
|
|
End Function
|
|
|
|
Public Function getInsertCmd() As String
|
|
Dim f As String = "", v As String = ""
|
|
For Each i In getParameterList()
|
|
If Not i.isPrimaryParam Then
|
|
f &= "[" & i.Text & "],"
|
|
v &= "@" & i.Scalarvariable & ","
|
|
End If
|
|
Next
|
|
Return "INSERT INTO tblVERAG_CustomsDeclarations_Documents (" &
|
|
f.TrimEnd(","c) & ") VALUES (" & v.TrimEnd(","c) & ")"
|
|
End Function
|
|
|
|
|
|
|
|
' ---------- DELETE + INSERT ----------
|
|
Public Shared Sub REPLACE_HEAD(zaId As Integer, list As List(Of cVERAG_CustomsDeclarations_Document))
|
|
|
|
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
|
SQL.doSQL(
|
|
"DELETE FROM tblVERAG_CustomsDeclarations_Documents
|
|
WHERE zaDoc_zaId=" & zaId & " AND zaDoc_ItemId IS NULL",
|
|
"FMZOLL")
|
|
|
|
For Each d In list
|
|
d.zaDoc_zaId = zaId
|
|
d.zaDoc_ItemId = Nothing
|
|
d.zaDoc_Id = SQL.doSQLVarListID(d.zaDoc_Id, d.getInsertCmd(), "FMZOLL", , d.getParameterList())
|
|
Next
|
|
End Sub
|
|
|
|
Public Shared Sub INSERT_ITEM(zaId As Integer, itemId As Integer, list As List(Of cVERAG_CustomsDeclarations_Document))
|
|
|
|
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
|
|
|
For Each d In list
|
|
d.zaDoc_zaId = zaId
|
|
d.zaDoc_ItemId = itemId
|
|
d.zaDoc_Id = SQL.doSQLVarListID(d.zaDoc_Id, d.getInsertCmd(), "FMZOLL", , d.getParameterList())
|
|
Next
|
|
End Sub
|
|
|
|
Public Shared Function LOAD_HEAD_BY_ZAID(zaId As Integer) As List(Of cVERAG_CustomsDeclarations_Document)
|
|
Return LOAD_BY_SQL(
|
|
"SELECT * FROM tblVERAG_CustomsDeclarations_Documents
|
|
WHERE zaDoc_zaId=" & zaId & " AND zaDoc_ItemId IS NULL")
|
|
End Function
|
|
|
|
Public Shared Function LOAD_ITEM_BY_ITEMID(zaId As Integer, itemId As Integer) As List(Of cVERAG_CustomsDeclarations_Document)
|
|
Return LOAD_BY_SQL(
|
|
"SELECT * FROM tblVERAG_CustomsDeclarations_Documents
|
|
WHERE zaDoc_zaId=" & zaId & " AND zaDoc_ItemId=" & itemId)
|
|
End Function
|
|
|
|
Private Shared Function LOAD_BY_SQL(sqlstr As String) _
|
|
As List(Of cVERAG_CustomsDeclarations_Document)
|
|
|
|
Dim result As New List(Of cVERAG_CustomsDeclarations_Document)
|
|
|
|
Try
|
|
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
|
|
Using cmd As New SqlCommand(sqlstr, conn)
|
|
|
|
Using dr As SqlDataReader = cmd.ExecuteReader()
|
|
While dr.Read()
|
|
|
|
Dim d As New cVERAG_CustomsDeclarations_Document
|
|
d.hasEntry = False
|
|
|
|
' ===== DEINE LOAD-VORLAGE (1:1, kombiniert) =====
|
|
For Each li In d.getParameterList()
|
|
Dim pi As PropertyInfo =
|
|
d.GetType().GetProperty(li.Scalarvariable)
|
|
|
|
If dr.Item(li.Text) Is DBNull.Value Then
|
|
pi.SetValue(d, Nothing)
|
|
Else
|
|
pi.SetValue(d, dr.Item(li.Text))
|
|
End If
|
|
Next
|
|
|
|
d.hasEntry = True
|
|
result.Add(d)
|
|
|
|
End While
|
|
End Using
|
|
End Using
|
|
End Using
|
|
|
|
Catch ex As Exception
|
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(
|
|
ex.Message,
|
|
ex.StackTrace,
|
|
System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
|
End Try
|
|
|
|
Return result
|
|
End Function
|
|
|
|
End Class
|
|
|
|
|
|
|