Mergekonflike ausbessern;

This commit is contained in:
2025-05-12 10:15:34 +02:00
parent 74817bffa8
commit f732845f15
16 changed files with 5377 additions and 2712 deletions

813
Aviso/ATEZ/frmATEZ_EZA.vb Normal file
View File

@@ -0,0 +1,813 @@

Imports DAKOSY_Worker.eZollTypes
Imports SDL
Imports VERAG_PROG_ALLGEMEIN
Public Class frmATEZ_EZA
Dim ART As String = ""
Dim FilialenNr As Integer
Dim AbfertigungsNr As Integer
Dim JAHR As Integer = Now.ToString("yy")
Public isSTAMMREF As Boolean = False
Public STAMMREF As String = ""
Public CopyFromZA_Id As Integer = -1
Dim FIRMA_DY = VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA
Dim ZOLL_SYSTEM = "DAKOSY"
Dim DY As DAKOSY_Worker.cDakosy_Zollanmeldungen = Nothing
Public ATT As List(Of String)
Dim AVISO As New cAviso
Dim zusatz As String
Dim cDy_ART As String = If(FIRMA_DY = "ATILLA", "T2", "T1")
Dim VermerkeDAL As New cVermerkeDAL
Dim NCTS As DAKOSY_Worker.cDakosyNCTSOut = Nothing
Dim openExisting As Boolean = False
Dim id As Integer = -1
Dim dgv As DataGridView = Nothing
Dim atez_data As cATEZ_NCTS_DATA
Dim atez = New cATEZ_NCTS_IN("atez_ncts")
Dim allSelected As Boolean = False
Property BezugsNr As String = ""
Property SENDUNG As VERAG_PROG_ALLGEMEIN.cSendungen
Sub New(AVISO As VERAG_PROG_ALLGEMEIN.cAviso, SENDUNG As VERAG_PROG_ALLGEMEIN.cSendungen, JAHR As Integer, Optional _dgv As DataGridView = Nothing)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
If _dgv IsNot Nothing Then Me.dgv = _dgv
Me.AVISO = AVISO
Me.SENDUNG = SENDUNG
Me.JAHR = JAHR
If SENDUNG IsNot Nothing Then
Me.FilialenNr = SENDUNG.FilialenNr
Me.AbfertigungsNr = SENDUNG.AbfertigungsNr
End If
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
End Sub
Sub New(_id As Integer, AVISO As VERAG_PROG_ALLGEMEIN.cAviso, SENDUNG As VERAG_PROG_ALLGEMEIN.cSendungen, JAHR As Integer)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
openExisting = True
id = _id
Me.AVISO = AVISO
Me.SENDUNG = SENDUNG
Me.JAHR = JAHR
If SENDUNG IsNot Nothing Then
Me.FilialenNr = SENDUNG.FilialenNr
Me.AbfertigungsNr = SENDUNG.AbfertigungsNr
End If
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnSend.Click
Try
'If Button1.Text = "JSON" Then
' If Not atez.setJson(atez_data) Then MsgBox("Fehler beim Erstellen der Daten")
' atez.setJsonPDF(atez_data, dgvAnhaenge)
' Dim data As New DataObject()
' data.SetData(DataFormats.Text, atez_data.json)
' Clipboard.SetDataObject(data)
' Me.Cursor = Cursors.Default
' MsgBox("JSON-Daten in Zwischenablage gespeichert")
' Exit Sub
'End If
'If atez_data.status = "Sent" Then
' Exit Sub
'End If
''auskommentiert, weil Sendungen ohne ANhang auch geschickt werden sollen: M.Akceylan
''If Not checkAttachment() Then
'' Exit Sub
''End If
If Not checkMandatoryField() Then
Exit Sub
End If
Me.Cursor = Cursors.WaitCursor
lblInfo.Text = ""
txtDyMandant.Text = "VERA" 'TEST!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' txtDyMandant.Text = "VERG" 'TEST!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' atez.setJsonPDF(atez_data, dgvAnhaenge)
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'----ATEZ EZA------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Dim procedureCodeRequested As Integer
Select Case SENDUNG.tblSnd_Abfertigungsart_ID
Case 26, 27
procedureCodeRequested = 42
Case Else
procedureCodeRequested = 40
End Select
Dim ioReference = lblBezugsnummer.Text & Now.ToString("ddMMyyyy_HHmmss")
'
'.DAKOSY_TemplateCode = cboStammreferenz._value
'If .DAKOSY_TemplateCode = "" Then .DAKOSY_TemplateCode = "*OWN"
'.documents = New List(Of VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubDocument) From {
' New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubDocument With {.type = "base64", .base64String = "SGVsbG8sIHRoaXMgaXMgYSBzYW1wbGUgYmFzZTY0IHN0cmluZy4=", .filename = "test.txt", .fileType = "invoice"},
' New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubDocument With {.type = "base64", .base64String = "SGVsbG8sIHRoaXMgaXMgYSBzYW1wbGUgYmFzZTY0IHN0cmluZy4=", .filename = "test2.txt", .fileType = "atr"},
' New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubDocument With {.type = "base64", .base64String = "SGVsbG8sIHRoaXMgaXMgYSBzYW1wbGUgYmFzZTY0IHN0cmluZy4=", .filename = "test3.txt", .fileType = "cmr"}
'},
Dim ATEZ_RH_EZA As New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubJobOrderRequest With {
.referenceNo = ioReference,
.regimeType = "IM",
.customer = "AVISO",
.additionalData = New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubAdditionalData With {
.transaction = New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubTransaction With {
.ioPartner = txtDyMandant.Text,
.ioDivision3 = txtDyNiederlassung.Text,
.ioReference = ioReference
},
.declaration = New List(Of VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubDeclaration) From {
New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubDeclaration With {
.objectIdentification = New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubObjectIdentification With {
.objectName = lblBezugsnummer.Text & "_TEST",
.objectAlias = ioReference,
.declarationType = "EZA-D"
},
.headerData = New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubHeaderData With {
.agentContact = New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubAgentContact With {
.contactPersonName = If(VERAG_PROG_ALLGEMEIN.cAllgemein.MITARBEITER.Fullname, ""),
.contactPersonPhoneNumber = If(VERAG_PROG_ALLGEMEIN.cAllgemein.MITARBEITER.mit_telefonnr, "+43 7711/2777 0"),
.contactPersonPosition = "Zolldeklarant/in"
},
.declarantIsConsignee = True,
.representationRelationshipCode = "",
.inputTaxDeduction = "",'"true",
.procedureCodeRequested = procedureCodeRequested.ToString,
.goodsStatus = "",'"EU",
.costs = New List(Of VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubCost) From {
New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubCost With {.costAmount = If(SENDUNG.tblSnd_Warenwert IsNot Nothing, CDbl(SENDUNG.tblSnd_Warenwert).ToString("F2", System.Globalization.CultureInfo.InvariantCulture), 0), .costCurrency = If(SENDUNG.tblSnd_WarenwertWaehrung, "")}
},
.transportMeansArrivalIdentity = txtLKWId.Text,
.transportMeansNationalityCode = If(AVISO.LKW_Nationalitaet, "")
}
}
}
}
}
If If(AVISO.Zollstelle, "").length >= 4 Then
ATEZ_RH_EZA.additionalData.declaration(0).headerData.addressedCustomsOffice = AVISO.Zollstelle.ToString.Substring(AVISO.Zollstelle.ToString.Length - 4)
'MsgBox(ATEZ_RH_EZA.additionalData.declaration(0).headerData.addressedCustomsOffice)
End If
ATEZ_RH_EZA.additionalData.declaration(0).objectIdentification.username = If(VERAG_PROG_ALLGEMEIN.cAllgemein.MITARBEITER.mit_DAKOSY_SB, "ANDREAS")
ATEZ_RH_EZA.additionalData.declaration(0).objectIdentification.referenceNumberOverlay = If(cboStammreferenz._value <> "", cboStammreferenz._value, "*OWN")
If If(SENDUNG.tblSnd_Vorpapier, "") <> "" Then
ATEZ_RH_EZA.additionalData.declaration(0).headerData.previousAdministrativeReferenceType = "T1"
ATEZ_RH_EZA.additionalData.declaration(0).headerData.previousAdministrativeReferenceNumber = SENDUNG.tblSnd_Vorpapier
End If
' .destinationCountry = "DE",
' .dispatchCountry = "DE",
', .destinationFederalState = "07"
' .destinationCountry = "DE",
' .departureCountry = "TR"
' .previousAdministrativeReferenceType = "T1",' SENDUNG.tblSnd_Vorpapier
'.previousAdministrativeReferenceNumber = "25TR160100001472M0",
',
'.addresses = New List(Of VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubAddress) From {
' New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubAddress With {.addressType = "CZ", .participantEORI = "EORI12345", .participantSubsidiaryNumber = "001", .companyName = "SISECAM DIS TIC.A.S.", .streetAndNumber = "D-100 KARAYOLU CD.YAYLA MH.NO.70/C", .countryCode = "TR", .postalCode = "34949", .city = "TUZLA ISTANBUL"},
' New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubAddress With {.addressType = "CN", .participantEORI = "EORI67890", .participantSubsidiaryNumber = "002", .companyName = "POLYNT COMPOSITES GERMANY GMBH", .streetAndNumber = "KIESELSTRASSE 2", .countryCode = "DE", .postalCode = "56357", .city = "MIEHLEN"}
ATEZ_RH_EZA.documents = New List(Of cRelayHub.cRelayHubDocument)
For Each r As DataGridViewRow In dgvAnhaenge.Rows
Dim isSelected As Boolean = If(DBNull.Value Is r.Cells("anh_selekt").Value, False, r.Cells("anh_selekt").Value)
If isSelected Then
Dim bd As New Chilkat.BinData
Dim DOC As New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubDocument
If r.Cells("anh_Art").Value IsNot DBNull.Value Then
Select Case r.Cells("anh_Art").Value
Case "Rechnung", "Konsi-Rechnung", "eFatura", "INVOICE" : DOC.fileType = "invoice"
Case "CMR" : DOC.fileType = "cmr"
Case "Ausfuhr", "EXPORT" : DOC.fileType = "tr_export_declaration"
Case "ATR" : DOC.fileType = "atr"
Case "Vorpapier", "T1" : DOC.fileType = "transit_declaration"
Case Else : DOC.fileType = "invoice"
' Case Else : DOC.fileType = "additional_data" --> DARF NCIHT -_> additional_data ist das verwednete Datenformat
End Select
End If
'invoice' | 'atr' | 'cmr' | 'transit_declaration' | 'tr_export_declaration' | 'additional_data', received 'PDF'
DOC.type = "base64"
DOC.filename = r.Cells("anh_Name").Value
Try
Dim dateiBytes As Byte() = IO.File.ReadAllBytes((VERAG_PROG_ALLGEMEIN.cDATENSERVER.GET_PDFPath_BY_DocID(r.Cells("anh_docId").Value)))
Dim base64String As String = Convert.ToBase64String(dateiBytes)
DOC.base64String = base64String
Catch ex As Exception
' Fehlerbehandlung, z.B. Datei nicht gefunden oder keine Zugriffsrechte
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
ATEZ_RH_EZA.documents.Add(DOC)
End If
Next
ATEZ_RH_EZA.additionalData.declaration(0).addresses = New List(Of cRelayHub.cRelayHubAddress)
If SENDUNG.tblSnd_EmpfaengerKdNr > 0 Then
Dim AD As New cAdressen(SENDUNG.tblSnd_EmpfaengerKdNr)
Dim KD As New cKunde(SENDUNG.tblSnd_EmpfaengerKdNr)
Dim CN As New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubAddress
CN.addressType = "CN"
CN.participantEORI = If(KD.EORITIN, "")
CN.participantSubsidiaryNumber = If(KD.EORITIN_NL, "")
CN.companyName = AD.Name_1
CN.streetAndNumber = AD.Straße
CN.postalCode = AD.PLZ
CN.city = AD.Ort
CN.countryCode = SDL.cProgramFunctions.getISO2Land(AD.LandKz)
ATEZ_RH_EZA.additionalData.declaration(0).addresses.Add(CN)
ATEZ_RH_EZA.additionalData.declaration(0).headerData.destinationCountry = CN.countryCode
ATEZ_RH_EZA.destinationCountry = CN.countryCode
If If(CN.countryCode, "") = "DE" AndAlso CN.postalCode IsNot Nothing AndAlso CN.postalCode <> "" Then
ATEZ_RH_EZA.additionalData.declaration(0).headerData.destinationFederalState = VERAG_PROG_ALLGEMEIN.cDEBundeslaenderPLZ.LOADBundeslandCode_ByPLZ(CN.postalCode)
ElseIf If(CN.countryCode, "") <> "" Then
ATEZ_RH_EZA.additionalData.declaration(0).headerData.destinationFederalState = "25"
End If
End If
If SENDUNG.tblSnd_AbsenderKdNr > 0 Then
Dim AD As New cAdressen(SENDUNG.tblSnd_AbsenderKdNr)
Dim KD As New cKunde(SENDUNG.tblSnd_AbsenderKdNr)
Dim CZ As New VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHubAddress
CZ.addressType = "CZ"
CZ.participantEORI = If(KD.EORITIN, "")
CZ.participantSubsidiaryNumber = If(KD.EORITIN_NL, "")
CZ.companyName = AD.Name_1
CZ.streetAndNumber = AD.Straße
CZ.postalCode = AD.PLZ
CZ.city = AD.Ort
CZ.countryCode = SDL.cProgramFunctions.getISO2Land(AD.LandKz)
ATEZ_RH_EZA.additionalData.declaration(0).addresses.Add(CZ)
ATEZ_RH_EZA.additionalData.declaration(0).headerData.departureCountry = CZ.countryCode
ATEZ_RH_EZA.dispatchCountry = CZ.countryCode
End If
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
VERAG_PROG_ALLGEMEIN.cRelayHub.cRelayHub_sendToRelayHub_JobOrderRequest.query_declarations(ATEZ_RH_EZA)
'With atez_data
' .AvisoId = AVISO.AvisoID
' .SendungsId = SENDUNG.tblSnd_SendungID
' .VERAG_LRN = lblBezugsnummer.Text
' .LicensePlateContainerNo = txtLKWId.Text
' .DAKOSY_TemplateCode = cboStammreferenz._value
' If .DAKOSY_TemplateCode = "" Then .DAKOSY_TemplateCode = "*OWN"
' .DAKOSY_Procedure = cboProzedur._value
' .DAKOSY_IOPartner = txtDyMandant.Text
' .DAKOSY_Division3 = txtDyNiederlassung.Text
' .DepartureCustomsOffice = sbAbgangZollstelle._value
' .DestinationCustomsOffice = sbBestimmungsZollstelle._value
' .DatDeterminationLimit = txtDat.Text
' .CoolingTemperature = IIf(cbxTemperatur.Checked, txtTransporttemp.Text, "")
' .Carrier_Name = usrCntl_Carrier.kdFirma.Text
' .Carrier_Adress_City = usrCntl_Carrier.txtOrt.Text
' .Carrier_Adress_Country = usrCntl_Carrier.sbLand._value
' .Carrier_Adress_Postcode = usrCntl_Carrier.txtPlz.Text
' .Carrier_Adress_Street = usrCntl_Carrier.txtStrasse.Text
' .Carrier_EORI = usrCntl_Carrier.txtEORI.Text
' .Guarantee_GRN = "" 'leer
' .erstellerId = VERAG_PROG_ALLGEMEIN.cAllgemein.USRID
' If .selectedDocuments <> "" Then .selectedDocuments = ""
' For Each doc As DataGridViewRow In dgvAnhaenge.Rows
' Dim isSelected = IIf(DBNull.Value Is doc.Cells("anh_selekt").Value, False, doc.Cells("anh_selekt").Value)
' If isSelected Then
' .selectedDocuments &= doc.Cells("anh_docId").Value & ", "
' End If
' Next
' .SAVE()
' End With
' saveDurchgangszollstelle(atez_data)
'saveRoute(atez_data)
'setDurchgangszolstellen()
'setRoute()
'If sendAtezData(atez_data, atez) Then
' AvisoStatusFunctions.insertSendungsVermerk(SENDUNG.tblSnd_SendungID, SENDUNG.tblSnd_AvisoID, "An ATEZ gesendet", 109)
' Me.Close()
'Else
' Me.Close()
'End If
Me.Cursor = Cursors.Default
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
Me.Cursor = Cursors.Default
End Try
End Sub
'Private Function sendAtezData(atezData As cATEZ_NCTS_DATA, atez As cATEZ_NCTS_IN) As Boolean
' Dim failreDesc As String
' Dim authResp = atez.authenticate("NCTS")
' If authResp <> "200" Then
' failreDesc = "Authentifizierung fehlgeschlagen"
' lblInfo.Text = failreDesc & " - " & authResp & vbNewLine & "Vorgang abgebrochen" & vbNewLine & " Bitte wiederholen!"
' Dim resultAuthentifizierung As MsgBoxResult = MsgBox("Fehler beim Authentifizieren" & vbNewLine & failreDesc & vbNewLine & "Soll NCTS als Entwurf gespeichert werden?", vbYesNoCancel)
' If resultAuthentifizierung = vbYes Then
' atezData.status = "Draft"
' atezData.fehlerbeschreibung = failreDesc
' Return atezData.SAVE()
' Else
' atezData.status = "Failure"
' atezData.fehlerbeschreibung = failreDesc
' Return atezData.SAVE()
' End If
' Return False
' End If
' atezData.sessionId = atez.sessionID
' If Not atez.setJsonNCTS(atezData) Then
' MsgBox("Fehler beim Erstellen der Daten" & vbNewLine & "Vorgang abgebrochen!")
' atezData.status = "Failure"
' atezData.fehlerbeschreibung = "Fehler beim Erstellen der Daten"
' Return atezData.SAVE
' End If
' If checkAttachment() Then
' If Not atez.setJsonPDF(atezData, dgvAnhaenge) Then
' MsgBox("Fehler beim Erstellen der PDF-Daten!" & vbNewLine & "Vorgang abgebrochen!")
' atezData.status = "Failure"
' atezData.fehlerbeschreibung = "Fehler beim Erstellen der PDF-Daten!"
' Return atezData.SAVE
' End If
' End If
' Dim azetId = atez.SendRequestWithAuthHeader("application/json", failreDesc, "/api/integrations/verag", "POST")
' If failreDesc <> "" Then
' If atezData.status = "Draft" Then
' MsgBox("Fehler beim Senden" & vbNewLine & failreDesc)
' atezData.fehlerbeschreibung = failreDesc
' Return atezData.SAVE()
' End If
' Dim result As MsgBoxResult = MsgBox("Fehler beim Senden" & vbNewLine & failreDesc & vbNewLine & "Soll NCTS als Entwurf gespeichert werden?", vbYesNoCancel)
' If result = vbYes Then
' atezData.status = "Draft"
' atezData.fehlerbeschreibung = failreDesc
' Return atezData.SAVE()
' Else
' atezData.status = "Failure"
' atezData.fehlerbeschreibung = failreDesc
' Return atezData.SAVE()
' End If
' lblInfo.Text = "Fehler in der API "
' Else
' If azetId = "-1" Then
' atezData.fehlerbeschreibung = "Request has been sent, but no header received!"
' Else
' atezData.fehlerbeschreibung = ""
' End If
' atezData.status = "Sent"
' atezData.atezId = IIf(azetId IsNot Nothing, azetId, "")
' Return atezData.SAVE()
' End If
'End Function
Function getBezugsnr(ByRef BezugsNr)
Dim BezugsNrTmp = ""
BezugsNrTmp = SENDUNG.FilialenNr & "/" & SENDUNG.AbfertigungsNr
BezugsNr = BezugsNrTmp
zusatz = "A"
If dgv IsNot Nothing AndAlso dgv.Rows.Count > 0 Then
BezugsNr = BezugsNrTmp & "/" & zusatz
For Each r As DataGridViewRow In dgv.Rows
If r.Cells("BezugsNr").Value = BezugsNr Then
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 If
BezugsNr = BezugsNrTmp & "/" & zusatz
Next
End If
While DAKOSY_Worker.cDakosy_Zollanmeldungen.ExistsBezugsNr(BezugsNr) 'IsNot Nothing
BezugsNr = BezugsNrTmp & "/" & 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
Private Sub frmATEZNCTS_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Select Case FIRMA_DY
Case "VERAG" : txtDyMandant.Text = "VERG"
txtDyNiederlassung.Text = VERAG_PROG_ALLGEMEIN.cAllgemein.NIEDERLASSUNG
Select Case FilialenNr
Case "5103" : txtDyNiederlassung.Text = "WAI"
End Select
Case "ATILLA" : txtDyMandant.Text = "ATIL" : txtDyNiederlassung.Text = "SUW"
Case "UNISPED" : txtDyMandant.Text = "UNAT" : txtDyNiederlassung.Text = "ATSPED"
Case "IMEX" : txtDyMandant.Text = "IMEX" : txtDyNiederlassung.Text = "IME"
Case "AMBAR" : txtDyMandant.Text = "ATIL" : txtDyNiederlassung.Text = "AMBWO"
End Select
initSeachboxes()
lblAnh.Visible = True
If openExisting Then
If id > 0 Then
atez_data = New cATEZ_NCTS_DATA(id)
initAttachment()
If atez_data.atezId <> "" Then
lblInfo.Text = "Atez-ID " & atez_data.atezId
Else
lblInfo.Text = "Status: " & IIf(atez_data.fehlerbeschreibung <> "", atez_data.status & "- " & atez_data.fehlerbeschreibung, atez_data.status)
End If
lblBezugsnummer.Text = atez_data.VERAG_LRN
cboStammreferenz.fillWithSQL("SELECT [dySr_Stammreferenz],[dySr_Bezeichnung] FROM [tblDakosy_Stammreferenzen] WHERE dySr_Land='DE' AND dySr_Verfahren='NCTS' and dySr_dy_Mandant='" & txtDyMandant.Text & "' and dySr_dy_Niederlassung IN ('','" & txtDyNiederlassung.Text & "') and dySr_visible=1", False, "FMZOLL", True)
cboStammreferenz.changeItem(atez_data.DAKOSY_TemplateCode)
'cboProzedur.changeItem(atez_data.DAKOSY_Procedure)
txtLKWId.Text = atez_data.LicensePlateContainerNo
'sbBestimmungsZollstelle.SET_VALUE(atez_data.DestinationCustomsOffice)
sbAdressierteZollstelle.SET_VALUE(atez_data.DepartureCustomsOffice)
If atez_data.status = "Draft" Then
btnSend.Text = "An ATEZ senden -->"
pnlHead.Enabled = True
btnSend.Enabled = True
'initAttachment()
Else
btnSend.Text = "JSON"
pnlHead.Enabled = False
dgvAnhaenge.ReadOnly = True
btnSend.Enabled = True
End If
Else
btnSend.Enabled = False
End If
Else
atez_data = New cATEZ_NCTS_DATA()
initAttachment()
'Button1.Text = "An ATEZ senden -->"
pnlHead.Enabled = True
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 IN ('','" & txtDyNiederlassung.Text & "') and dySr_visible=1", False, "FMZOLL", True)
cboStammreferenz.changeItem("")
getBezugsnr(BezugsNr)
txtLKWId.Text = AVISO.LKW_Nr
' sbBestimmungsZollstelle.SET_VALUE(SENDUNG.NCTS_Bestimmungszollstelle)
If AVISO.Grenzstelle.Replace("???", "") = "" Then
sbAdressierteZollstelle.SET_VALUE(AVISO.Zollstelle)
Else
Dim GRZ As New VERAG_PROG_ALLGEMEIN.cGrenzstelle(AVISO.Grenzstelle)
If GRZ IsNot Nothing AndAlso GRZ.hasEntry Then
If GRZ.grz_ZollamtDST IsNot Nothing Then
sbAdressierteZollstelle.SET_VALUE(GRZ.grz_ZollamtDST)
End If
End If
End If
End If
'initAttachment()
End Sub
Sub initAttachment()
Dim hSQL As String = " SELECT [anh_id],anh_Datum,[anh_Name],[anh_docId],
case WHEN [anh_size] > 0 Then ROUND([anh_size] / 1000000,2) End as anh_size,
CASE WHEN [anh_Art] = 'ATR-EUR1' then 'EUR'
when [anh_Art] = 'Rechnung' then 'INVOICE'
when [anh_Art] = 'eFatura' then 'INVOICE'
when [anh_Art] = 'CMR' then 'CMR'
when [anh_Art] = 'Ausfuhr' then 'OTHER'
when [anh_Art] = 'Vorpapier' then 'OTHER'
when [anh_Art] = 'Packliste' then 'PACK'
when [anh_Art] = 'Auftrag' then 'OTHER'
when [anh_Art] = 'Auftrag' then 'OTHER'
when [anh_Art] = 'Dispoliste' then 'OTHER'
when [anh_Art] = 'Vorkasse' then 'OTHER'
when [anh_Art] = 'Überweisungsbeleg' then 'OTHER'
when [anh_Art] = 'Vollmacht' then 'OTHER'
when [anh_Art] = 'ATB' then 'OTHER'
when [anh_Art] = 'ATA' then 'CarnetATA'
when [anh_Art] = 'Sonstiges' then 'OTHER'
when [anh_Art] ='' then 'OTHER' End
[anh_Art],[anh_Typ] FROM [tblAvisoAnhaenge]
WHERE [anh_AvisoId]=" & AVISO.AvisoID & "AND (anh_SendungsId is null OR anh_SendungsId <=0 OR anh_SendungsId='" & SENDUNG.tblSnd_SendungID & "') And anh_Typ = 'PDF'
ORDER BY anh_SendungsId desc,
case
when [anh_Art] = 'ATR-EUR1' then 0
when [anh_Art] = 'Rechnung' then 1
when [anh_Art] = 'eFatura' then 1.1
when [anh_Art] = 'CMR' then 2
when [anh_Art] = 'Ausfuhr' then 3
when [anh_Art] = 'Vorpapier' then 4
when [anh_Art] = 'Packliste' then 5
when [anh_Art] = 'Auftrag' then 6
when [anh_Art] = 'Auftrag' then 7
when [anh_Art] = 'Dispoliste' then 8
when [anh_Art] = 'Vorkasse' then 9
when [anh_Art] = 'Überweisungsbeleg' then 10
when [anh_Art] = 'Vollmacht' then 11
when [anh_Art] = 'ATB' then 12
when [anh_Art] = 'ATA' then 13
when [anh_Art] = 'Sonstiges' then 99
when [anh_Art] ='' then 15
END, [anh_Reihenfolge],[anh_id]"
Dim dt = VermerkeDAL.Anzeigen_Vermerke(hSQL)
Dim col As DataColumn
col = dt.Columns.Add("anh_selekt", GetType(Boolean))
col.SetOrdinal(0)
dgvAnhaenge.Columns.Clear()
dgvAnhaenge.DataSource = dt
If dgvAnhaenge.RowCount = 0 Then dgvAnhaenge.Columns.Clear() : Exit Sub
With dgvAnhaenge
.Enabled = True
.ReadOnly = False
.RowTemplate.MinimumHeight = 30
.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
.Columns("anh_id").Visible = False 'VermerkID nicht anzeigenconMenuVermerke
.Columns("anh_docId").Visible = False 'AvisoID nicht anzeigen
.Columns("anh_selekt").Width = 25
.Columns("anh_selekt").HeaderText = ""
.Columns("anh_selekt").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.Columns("anh_Datum").MinimumWidth = 50
.Columns("anh_Datum").HeaderText = "Datum"
.Columns("anh_Datum").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.Columns("anh_Datum").ReadOnly = True
.Columns("anh_Name").MinimumWidth = 150
.Columns("anh_Name").HeaderText = "Name"
.Columns("anh_Name").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
.Columns("anh_Name").ReadOnly = True
.Columns("anh_Art").MinimumWidth = 50
.Columns("anh_Art").HeaderText = "Art"
.Columns("anh_Art").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.Columns("anh_Art").ReadOnly = True
.Columns("anh_Typ").Width = 50
.Columns("anh_Typ").HeaderText = "Typ"
.Columns("anh_Typ").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.Columns("anh_Typ").ReadOnly = True
.Columns("anh_size").Width = 50
.Columns("anh_size").HeaderText = "Größe in MB"
.Columns("anh_size").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.Columns("anh_size").ReadOnly = True
End With
For Each doc As DataGridViewRow In dgvAnhaenge.Rows
If Not IsDBNull(doc.Cells("anh_size").Value) AndAlso doc.Cells("anh_size").Value > 0 Then
Dim size = (doc.Cells("anh_size").Value)
If size < 1 Then
doc.DefaultCellStyle.BackColor = Color.LightGreen
ElseIf size > 1 AndAlso size < 5 Then
doc.DefaultCellStyle.BackColor = Color.LightYellow
Else
doc.DefaultCellStyle.BackColor = Color.IndianRed
End If
End If
Next
If atez_data IsNot Nothing AndAlso atez_data.selectedDocuments <> "" Then
For Each doc As DataGridViewRow In dgvAnhaenge.Rows
If atez_data.selectedDocuments.Contains(doc.Cells("anh_docId").Value) Then doc.Cells("anh_selekt").Value = True
Next
End If
End Sub
Sub initSeachboxes()
sbAdressierteZollstelle.initSearchBox(Me.FindForm, "[Code] ,[Code] as Nr,Description as Dienststelle,left(Code,2) as Land,[Description] +' (' +left(Code,2)+')' as display FROM [tbl_DY_ZollDE_C0141_Zollstellen]", {" [Code]", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", " left(Code,2),[Description]", "Code", "display", "FMZOLL", , 400, 200, {"display", "Code"})
'sbBestimmungsZollstelle.initSearchBox(Me.FindForm, "[Code] ,[Code] as Nr,Description as Dienststelle,left(Code,2) as Land,[Description] +' (' +left(Code,2)+')' as display FROM [tbl_DY_ZollDE_C0141_Zollstellen]", {" [Code]", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", " left(Code,2),[Description]", "Code", "display", "FMZOLL", , 400, 200, {"display", "Code"})
End Sub
Public Function checkAttachment() As Boolean
Dim selectedDocuments As Boolean = False
For Each Row In dgvAnhaenge.Rows
selectedDocuments = IIf(DBNull.Value Is Row.Cells("anh_selekt").Value, False, Row.Cells("anh_selekt").Value)
If selectedDocuments Then Exit For
Next
'If Not selectedDocuments Then
' lblInfo.Text = "kein Anhang selektiert"
' Cursor = Cursors.Default
' Return selectedDocuments
'End If
Return selectedDocuments
End Function
Public Function checkMandatoryField() As Boolean
'TODO
Return True
End Function
Private Sub dgvAnhaenge_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvAnhaenge.CellDoubleClick
Try
If dgvAnhaenge.SelectedRows.Count > 0 Then
Dim docPath = VERAG_PROG_ALLGEMEIN.cDATENSERVER.GET_PDFPath_BY_DocID(dgvAnhaenge.SelectedRows(0).Cells("anh_docId").Value)
If Not IO.File.Exists(docPath) Then
MsgBox("Die Datei existiert nicht!")
Else
If docPath.ToString.ToLower.EndsWith(".msg") Then ' MSG - Mails --> lokale Kopie, sonst Fehler (bereits von Benutzer soUndSo geöffnet)
Dim docPathTMP = VERAG_PROG_ALLGEMEIN.cFormularManager.getTMPPath_MSG()
System.IO.File.Copy(docPath, docPathTMP)
Process.Start(docPathTMP)
Else
Process.Start(docPath)
End If
End If
End If
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End Sub
Private Sub dgvAnhaenge_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvAnhaenge.CellClick
Dim countAnh As Double = 0
If dgvAnhaenge.RowCount > 0 Then
If dgvAnhaenge.Columns(e.ColumnIndex).Name = "anh_selekt" Then
If Not IsDBNull(dgvAnhaenge.CurrentRow.Cells("anh_selekt").Value) AndAlso dgvAnhaenge.CurrentRow.Cells("anh_selekt").Value = True Then
countAnh += IIf(dgvAnhaenge.CurrentRow.Cells("anh_size").Value IsNot DBNull.Value, dgvAnhaenge.CurrentRow.Cells("anh_size").Value, 0)
End If
For Each Row As DataGridViewRow In dgvAnhaenge.Rows
If Row.Cells("anh_selekt").Value IsNot DBNull.Value AndAlso Row.Cells("anh_selekt").Value = True AndAlso Row.Cells("anh_size").Value IsNot DBNull.Value Then
countAnh += IIf(Row.Cells("anh_size").Value IsNot DBNull.Value, Row.Cells("anh_size").Value, 0)
End If
Next
lblAnh.Text = "Anhang in MB: " & countAnh.ToString
End If
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If dgvAnhaenge.RowCount > 0 Then
Dim countAnh As Double = 0
For Each Row As DataGridViewRow In dgvAnhaenge.Rows
If allSelected Then
Row.Cells("anh_selekt").Value = True
countAnh += IIf(Row.Cells("anh_size").Value IsNot DBNull.Value, Row.Cells("anh_size").Value, 0)
Else
Row.Cells("anh_selekt").Value = False
countAnh = 0
End If
Next
allSelected = Not allSelected
lblAnh.Text = "Anhang in MB: " & countAnh.ToString
End If
End Sub
End Class