From 96812250788aa8445faa175748cdc082111a6b03 Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Fri, 1 Sep 2023 16:59:35 +0200 Subject: [PATCH] ATEZ ->Umgebaut --- Aviso/frmATEZ_NCTS.vb | 271 ++++++++++++++++------------ Aviso/usrcntlAktDetailsATILLANeu.vb | 3 +- 2 files changed, 157 insertions(+), 117 deletions(-) diff --git a/Aviso/frmATEZ_NCTS.vb b/Aviso/frmATEZ_NCTS.vb index 3d43719..6c0ad2b 100644 --- a/Aviso/frmATEZ_NCTS.vb +++ b/Aviso/frmATEZ_NCTS.vb @@ -27,6 +27,8 @@ Public Class frmATEZ_NCTS 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 Property BezugsNr As String = "" Property SENDUNG As VERAG_PROG_ALLGEMEIN.cSendungen @@ -74,95 +76,62 @@ Public Class frmATEZ_NCTS Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try + + If atez_data.status = "Sent" Then + MsgBox(IIf(atez_data.json <> "", atez_data.json, "")) + Exit Sub + End If + + If Not checkAttachment() Then + Exit Sub + End If + + + If Not checkMandatoryField() Then + Exit Sub + End If + + Me.Cursor = Cursors.WaitCursor - If id > 0 Then + lblInfo.Text = "" - Dim atezData = New cATEZ_NCTS_DATA(id) - If atezData.json <> "" And atezData.status <> "Draft" Then - MsgBox(atezData.json) - Else - Dim atez As New cATEZ_NCTS_IN - sendAtezData(atezData, atez) - End If + With atez_data - Else + .AvisoId = AVISO.AvisoID + .SendungsId = SENDUNG.tblSnd_SendungID + .VERAG_LRN = lblBezugsnummer.Text + .LicensePlateContainerNo = txtLKWId.Text + .DAKOSY_TemplateCode = cboStammreferenz._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 - lblInfo.Text = "" - - - 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 + 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 - If Not selectedDocuments Then - lblInfo.Text = "kein Anhang selektiert" - Cursor = Cursors.Default - Exit Sub - End If + .SAVE() - Dim atezData As New cATEZ_NCTS_DATA - Dim atez As New cATEZ_NCTS_IN + End With + saveDurchgangszollstelle(atez_data) + saveRoute(atez_data) - With atezData + sendAtezData(atez_data, atez) - .AvisoId = AVISO.AvisoID - .SendungsId = SENDUNG.tblSnd_SendungID - .VERAG_LRN = lblBezugsnummer.Text - .LicensePlateContainerNo = txtLKWId.Text - .DAKOSY_TemplateCode = cboStammreferenz._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 - - 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 - - If sbDurchgangszollstelle1._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle1._value) - If sbDurchgangszollstelle2._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle2._value) - If sbDurchgangszollstelle3._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle3._value) - If sbDurchgangszollstelle4._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle4._value) - If sbDurchgangszollstelle5._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle5._value) - If sbDurchgangszollstelle6._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle6._value) - If sbDurchgangszollstelle7._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle7._value) - If sbDurchgangszollstelle8._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle8._value) - If sbDurchgangszollstelle9._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle9._value) - - If sbRoute1._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute1._value) - If sbRoute2._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute2._value) - If sbRoute3._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute3._value) - If sbRoute4._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute4._value) - If sbRoute5._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute5._value) - If sbRoute6._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute6._value) - If sbRoute7._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute7._value) - If sbRoute8._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute8._value) - If sbRoute9._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute9._value) - - sendAtezData(atezData, atez) - - End If Me.Cursor = Cursors.Default Catch ex As Exception @@ -186,7 +155,7 @@ Public Class frmATEZ_NCTS If Not atez.setJson(atezData) Then MsgBox("Fehler beim Erstellen der Daten" & vbNewLine & "Vorgang abgebrochen!") - If Not atez.setJsonPDF(atezData, dgvAnhaenge) Then MsgBox("Fehler beim Erstellen der PDF-Daten" & vbNewLine & "Vorgang abgebrochen!") + If Not atez.setJsonPDF(atezData, dgvAnhaenge) Then MsgBox("Fehler beim Erstellen der PDF-Daten, kein Anhang ausgewählt!" & vbNewLine & "Vorgang abgebrochen!") Dim azetId = atez.SendRequestWithAuthHeader("application/json", failreDesc) @@ -274,7 +243,7 @@ Public Class frmATEZ_NCTS If openExisting Then If id > 0 Then - Dim atez_data = New cATEZ_NCTS_DATA(id) + atez_data = New cATEZ_NCTS_DATA(id) If atez_data.atezId <> "" Then lblInfo.Text = "Atez-ID " & atez_data.atezId @@ -306,39 +275,8 @@ Public Class frmATEZ_NCTS usrCntl_Carrier.txtEORI.Text = atez_data.Carrier_EORI - Dim TCO_LIST As New List(Of VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_TransitCustomsOffice) - VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_TransitCustomsOffice.LOAD_LIST_ByNCTS(TCO_LIST, id) - - Dim i As Integer = 0 - For Each tco In TCO_LIST - If i = 0 Then sbDurchgangszollstelle1.SET_VALUE(If(tco.TransitCustomsOffice, "")) - If i = 1 Then sbDurchgangszollstelle2.SET_VALUE(If(tco.TransitCustomsOffice, "")) - If i = 2 Then sbDurchgangszollstelle3.SET_VALUE(If(tco.TransitCustomsOffice, "")) - If i = 3 Then sbDurchgangszollstelle4.SET_VALUE(If(tco.TransitCustomsOffice, "")) - If i = 4 Then sbDurchgangszollstelle5.SET_VALUE(If(tco.TransitCustomsOffice, "")) - If i = 5 Then sbDurchgangszollstelle6.SET_VALUE(If(tco.TransitCustomsOffice, "")) - If i = 6 Then sbDurchgangszollstelle7.SET_VALUE(If(tco.TransitCustomsOffice, "")) - If i = 7 Then sbDurchgangszollstelle8.SET_VALUE(If(tco.TransitCustomsOffice, "")) - If i = 8 Then sbDurchgangszollstelle9.SET_VALUE(If(tco.TransitCustomsOffice, "")) - i = i + 1 - Next - - Dim Route_LIST As New List(Of VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_Routen) - VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_Routen.LOAD_LIST_ByNCTS(Route_LIST, id) - - i = 0 - For Each route In Route_LIST - If i = 0 Then sbRoute1.SET_VALUE(route.Route_Country) - If i = 1 Then sbRoute2.SET_VALUE(route.Route_Country) - If i = 2 Then sbRoute3.SET_VALUE(route.Route_Country) - If i = 3 Then sbRoute4.SET_VALUE(route.Route_Country) - If i = 4 Then sbRoute5.SET_VALUE(route.Route_Country) - If i = 5 Then sbRoute6.SET_VALUE(route.Route_Country) - If i = 6 Then sbRoute7.SET_VALUE(route.Route_Country) - If i = 7 Then sbRoute8.SET_VALUE(route.Route_Country) - If i = 8 Then sbRoute9.SET_VALUE(route.Route_Country) - i = i + 1 - Next + setDurchgangszolstellen() + setRoute() If atez_data.status = "Draft" Then Button1.Text = "An ATEZ senden -->" @@ -358,7 +296,7 @@ Public Class frmATEZ_NCTS End If Else - + atez_data = New cATEZ_NCTS_DATA() Button1.Text = "An ATEZ senden -->" pnlHead.Enabled = True @@ -403,7 +341,7 @@ Public Class frmATEZ_NCTS Sub initAttachment() Dim hSQL As String = " SELECT [anh_id],anh_Datum,[anh_Name],[anh_docId], -CASE WHEN [anh_Art] = 'ATR-EUR1' then 'EUR' + 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' @@ -528,4 +466,105 @@ CASE WHEN [anh_Art] = 'ATR-EUR1' then 'EUR' txtDat._value = CDate(sender.value).ToShortDateString 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 + + Public Sub setDurchgangszolstellen() + + Dim TCO_LIST As New List(Of VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_TransitCustomsOffice) + VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_TransitCustomsOffice.LOAD_LIST_ByNCTS(TCO_LIST, id) + + Dim i As Integer = 0 + For Each tco In TCO_LIST + If i = 0 Then sbDurchgangszollstelle1.SET_VALUE(If(tco.TransitCustomsOffice, "")) + If i = 1 Then sbDurchgangszollstelle2.SET_VALUE(If(tco.TransitCustomsOffice, "")) + If i = 2 Then sbDurchgangszollstelle3.SET_VALUE(If(tco.TransitCustomsOffice, "")) + If i = 3 Then sbDurchgangszollstelle4.SET_VALUE(If(tco.TransitCustomsOffice, "")) + If i = 4 Then sbDurchgangszollstelle5.SET_VALUE(If(tco.TransitCustomsOffice, "")) + If i = 5 Then sbDurchgangszollstelle6.SET_VALUE(If(tco.TransitCustomsOffice, "")) + If i = 6 Then sbDurchgangszollstelle7.SET_VALUE(If(tco.TransitCustomsOffice, "")) + If i = 7 Then sbDurchgangszollstelle8.SET_VALUE(If(tco.TransitCustomsOffice, "")) + If i = 8 Then sbDurchgangszollstelle9.SET_VALUE(If(tco.TransitCustomsOffice, "")) + i = i + 1 + Next + + End Sub + + Public Sub setRoute() + + Dim Route_LIST As New List(Of VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_Routen) + VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_Routen.LOAD_LIST_ByNCTS(Route_LIST, id) + + Dim i = 0 + For Each route In Route_LIST + If i = 0 Then sbRoute1.SET_VALUE(route.Route_Country) + If i = 1 Then sbRoute2.SET_VALUE(route.Route_Country) + If i = 2 Then sbRoute3.SET_VALUE(route.Route_Country) + If i = 3 Then sbRoute4.SET_VALUE(route.Route_Country) + If i = 4 Then sbRoute5.SET_VALUE(route.Route_Country) + If i = 5 Then sbRoute6.SET_VALUE(route.Route_Country) + If i = 6 Then sbRoute7.SET_VALUE(route.Route_Country) + If i = 7 Then sbRoute8.SET_VALUE(route.Route_Country) + If i = 8 Then sbRoute9.SET_VALUE(route.Route_Country) + i = i + 1 + Next + + + End Sub + + Public Sub saveDurchgangszollstelle(atezData As cATEZ_NCTS_DATA) + + + If sbDurchgangszollstelle1._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle1._value) + If sbDurchgangszollstelle2._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle2._value) + If sbDurchgangszollstelle3._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle3._value) + If sbDurchgangszollstelle4._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle4._value) + If sbDurchgangszollstelle5._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle5._value) + If sbDurchgangszollstelle6._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle6._value) + If sbDurchgangszollstelle7._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle7._value) + If sbDurchgangszollstelle8._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle8._value) + If sbDurchgangszollstelle9._value <> "" Then Dim TCO As New cATEZ_NCTS_TransitCustomsOffice(atezData.Id, sbDurchgangszollstelle9._value) + + End Sub + + Public Sub saveRoute(atezData As cATEZ_NCTS_DATA) + + + If sbRoute1._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute1._value) + If sbRoute2._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute2._value) + If sbRoute3._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute3._value) + If sbRoute4._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute4._value) + If sbRoute5._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute5._value) + If sbRoute6._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute6._value) + If sbRoute7._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute7._value) + If sbRoute8._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute8._value) + If sbRoute9._value <> "" Then Dim route As New cATEZ_NCTS_Routen(atezData.Id, sbRoute9._value) + End Sub End Class \ No newline at end of file diff --git a/Aviso/usrcntlAktDetailsATILLANeu.vb b/Aviso/usrcntlAktDetailsATILLANeu.vb index 48e5917..72d74bd 100644 --- a/Aviso/usrcntlAktDetailsATILLANeu.vb +++ b/Aviso/usrcntlAktDetailsATILLANeu.vb @@ -1653,6 +1653,7 @@ Public Class usrcntlAktDetailsATILLANeu Dim frmAttilaATEZNCTS = New frmATEZ_NCTS(AVISO, SND, Now.ToString("yy"), dgvATEZNCTS) frmAttilaATEZNCTS.Show(Me) + Me.Refresh() End If @@ -1676,7 +1677,7 @@ Public Class usrcntlAktDetailsATILLANeu Dim frmAttilaATEZNCTS = New frmATEZ_NCTS(dgvATEZNCTS.SelectedRows(0).Cells("Id").Value, AVISO, SND, Now.ToString("yy")) frmAttilaATEZNCTS.Show(Me) - + Me.Refresh() End If