Merge branch 'ADMIN' of https://git.it.verag.ag/edv/ADMIN into ADMIN

This commit is contained in:
2026-03-10 08:49:41 +01:00
8 changed files with 1032 additions and 604 deletions

View File

@@ -360,13 +360,24 @@ Module Mail
Dim KdNr As String = "764755"
If dtParam.Rows.Count = 1 Then
If dtParam.Rows.Count > 1 Then
'System.Console.WriteLine("OPTION erkannt: " & dtParam.Rows(0).Item("ms_info"))
'System.Console.WriteLine("Auswertung Details gestartet...")
'If SendEmail_ZF(dtParam.Rows(0).Item("ms_an"), dtParam.Rows(0).Item("ms_kundenNr"), von, bis, "quarter", dtParam.Rows(0).Item("ms_cc"), dtParam.Rows(0).Item("ms_bcc"), dtParam.Rows(0).Item("ms_subject"), dtParam.Rows(0).Item("ms_mailtext")) Then
' System.Console.WriteLine("Vorgang erfolgreich abgeschlossen ...")
'End If
For Each r As DataRow In dtParam.Rows
System.Console.WriteLine("OPTION erkannt: " & r.Item("ms_info"))
System.Console.WriteLine("Auswertung Details gestartet...")
If SendEmail_ZF(dtParam.Rows(0).Item("ms_an"), dtParam.Rows(0).Item("ms_kundenNr"), von, bis, "quarter", dtParam.Rows(0).Item("ms_cc"), dtParam.Rows(0).Item("ms_bcc"), dtParam.Rows(0).Item("ms_subject"), dtParam.Rows(0).Item("ms_mailtext")) Then
System.Console.WriteLine("Vorgang erfolgreich abgeschlossen ...")
End If
Next
System.Console.WriteLine("OPTION erkannt: " & dtParam.Rows(0).Item("ms_info"))
System.Console.WriteLine("Auswertung Details gestartet...")
If SendEmail_ZF(dtParam.Rows(0).Item("ms_an"), dtParam.Rows(0).Item("ms_kundenNr"), von, bis, "quarter", dtParam.Rows(0).Item("ms_cc"), dtParam.Rows(0).Item("ms_bcc"), dtParam.Rows(0).Item("ms_subject"), dtParam.Rows(0).Item("ms_mailtext")) Then
System.Console.WriteLine("Vorgang erfolgreich abgeschlossen ...")
End If
Else
@@ -2663,10 +2674,17 @@ Module Mail
Public Function genEXCEL_ZF(KdNr As String, von As Date, bis As Date, Auswertungstyp As String) As String
Try
Dim KUNDENADR = New VERAG_PROG_ALLGEMEIN.cAdressen(KdNr)
Dim Path = ""
If KdNr = "714869" Or KdNr = "718486" Or KdNr = "764755" Then 'ZUR SICHERHEIT, FALLS FALSCHE KDNR EINGEGEBEN WIRD!!!
Dim dt As DataTable = loadDgvBySqlFMZOLL("SELECT CAST([FilialenNr] as varchar) + '/' + CAST([AbfertigungsNr] as varchar) Abfertigungsnummer
Dim dt As DataTable = loadDgvBySqlFMZOLL("SELECT CAST([FilialenNr] as varchar) + '/' + CAST([AbfertigungsNr] as varchar) Abfertigungsnummer
,cast([Abfertigungsdatum] as date)Abfertigungsdatum
,Absender
,Rechnungsbetrag Betrag
@@ -2677,117 +2695,159 @@ Module Mail
Dim sPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) & "\VERAG\SR\"
If Not My.Computer.FileSystem.DirectoryExists(sPath) Then
My.Computer.FileSystem.CreateDirectory(sPath)
End If
Dim Path = ""
Dim exclApp As Object 'as Application
Dim Datei As Object 'as WorkBook
Dim Blatt As Object 'Microsoft.Office.Interop.Excel.Worksheet 'As Object 'as Worksheet
exclApp = CreateObject("Excel.Application")
Select Case Auswertungstyp
Case "monthly"
Dim sPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) & "\VERAG\SR\"
If Not My.Computer.FileSystem.DirectoryExists(sPath) Then
My.Computer.FileSystem.CreateDirectory(sPath)
End If
With exclApp
.Visible = False
Try
Path = sPath & "ZF_" & KdNr & "_" & von.ToShortDateString & " - " & bis.ToShortDateString & "" & ".xlsx"
While System.IO.File.Exists(Path)
Path = sPath & "ZF_" & KdNr & "_" & von.ToShortDateString & "-" & bis.ToShortDateString & "_" & Now.ToString("ddMMyyyyHHmmss") & ".xlsx"
End While
My.Computer.FileSystem.WriteAllBytes(Path, My.Resources.RG_ZF, False)
Catch ex As System.Exception
' MsgBox(ex.Message)
MsgBox("Error 01: " & ex.Message & vbNewLine & ex.StackTrace)
Dim exclApp As Object 'as Application
Dim Datei As Object 'as WorkBook
Dim Blatt As Object 'Microsoft.Office.Interop.Excel.Worksheet 'As Object 'as Worksheet
exclApp = CreateObject("Excel.Application")
Select Case Auswertungstyp
Case "monthly"
Return ""
End Try
With exclApp
.Visible = False
Datei = .Workbooks.Open(Path) 'Anpassen
Blatt = Datei.Worksheets(1) 'Anpassen
Try
Path = sPath & "ZF_" & KdNr & "_" & von.ToShortDateString & " - " & bis.ToShortDateString & "" & ".xlsx"
While System.IO.File.Exists(Path)
Path = sPath & "ZF_" & KdNr & "_" & von.ToShortDateString & "-" & bis.ToShortDateString & "_" & Now.ToString("ddMMyyyyHHmmss") & ".xlsx"
End While
My.Computer.FileSystem.WriteAllBytes(Path, My.Resources.RG_ZF, False)
Catch ex As System.Exception
' MsgBox(ex.Message)
MsgBox("Error 01: " & ex.Message & vbNewLine & ex.StackTrace)
Blatt.Range("I1").Value = von.ToShortDateString & "-" & bis.ToShortDateString
Dim cnt = 3
For Each r In dt.Rows
Blatt.Range("A" & cnt).Value = cnt - 2
Blatt.Range("B" & cnt).Value = r("Abfertigungsnummer")
' Blatt.Range("C" & cnt).Value = r("RechnungsNr")
Blatt.Range("C" & cnt).Value = r("Abfertigungsdatum")
Blatt.Range("D" & cnt).Value = r("Abfertigungsbezeichnung")
Blatt.Range("E" & cnt).Value = r("Absender")
Blatt.Range("F" & cnt).Value = "" 'r("Betrag")
Blatt.Range("H" & cnt).Value = r("BelegNr")
Return ""
End Try
VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA = "VERAG"
Datei = .Workbooks.Open(Path) 'Anpassen
Blatt = Datei.Worksheets(1) 'Anpassen
Dim ZOLLANMELDUNG As New cZollsysteme_Aktenbeschriftung
Dim zS = If(r("Zollsystem_Land") IsNot DBNull.Value, r("Zollsystem_Land").ToString(), "")
If ZOLLANMELDUNG.getDataByBezugsnummer(r("FilialenNr") & "/" & r("AbfertigungsNr"), r("Abfertigungsart"), "", False, zS) Then
Blatt.Range("F" & cnt).Value = ZOLLANMELDUNG.Rechnungspreis
Blatt.Range("G" & cnt).Value = ZOLLANMELDUNG.Handelsrechnung.Replace(", ", "," & vbNewLine)
Blatt.Range("I" & cnt).Value = ZOLLANMELDUNG.ABGABEN_ZOLL
Blatt.Range("J" & cnt).Value = ZOLLANMELDUNG.ANZ_POS
If If(ZOLLANMELDUNG.ATCMRN, "") <> "" Then
Blatt.Range("H" & cnt).Value = ZOLLANMELDUNG.ATCMRN
Blatt.Range("I1").Value = von.ToShortDateString & "-" & bis.ToShortDateString
Dim cnt = 3
For Each r In dt.Rows
Blatt.Range("A" & cnt).Value = cnt - 2
Blatt.Range("B" & cnt).Value = r("Abfertigungsnummer")
' Blatt.Range("C" & cnt).Value = r("RechnungsNr")
Blatt.Range("C" & cnt).Value = r("Abfertigungsdatum")
Blatt.Range("D" & cnt).Value = r("Abfertigungsbezeichnung")
Blatt.Range("E" & cnt).Value = r("Absender")
Blatt.Range("F" & cnt).Value = "" 'r("Betrag")
Blatt.Range("H" & cnt).Value = r("BelegNr")
VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA = "VERAG"
Dim ZOLLANMELDUNG As New cZollsysteme_Aktenbeschriftung
Dim zS = If(r("Zollsystem_Land") IsNot DBNull.Value, r("Zollsystem_Land").ToString(), "")
If ZOLLANMELDUNG.getDataByBezugsnummer(r("FilialenNr") & "/" & r("AbfertigungsNr"), r("Abfertigungsart"), "", False, zS) Then
Blatt.Range("F" & cnt).Value = ZOLLANMELDUNG.Rechnungspreis
Blatt.Range("G" & cnt).Value = ZOLLANMELDUNG.Handelsrechnung.Replace(", ", "," & vbNewLine)
Blatt.Range("I" & cnt).Value = ZOLLANMELDUNG.ABGABEN_ZOLL
Blatt.Range("J" & cnt).Value = ZOLLANMELDUNG.ANZ_POS
If If(ZOLLANMELDUNG.ATCMRN, "") <> "" Then
Blatt.Range("H" & cnt).Value = ZOLLANMELDUNG.ATCMRN
End If
End If
End If
cnt += 1
cnt += 1
Next
Next
Datei.Save()
.DisplayAlerts = False
.quit()
Try : Datei.close(True) : Catch : End Try
End With
Datei.Save()
.DisplayAlerts = False
.quit()
Try : Datei.close(True) : Catch : End Try
End With
Case "quarter"
Case "quarter"
With exclApp
.Visible = False
With exclApp
.Visible = False
Try
Path = sPath & "ZF_" & KdNr & "_" & von.ToShortDateString & " - " & bis.ToShortDateString & "" & ".xlsx"
While System.IO.File.Exists(Path)
Path = sPath & "ZF_" & KdNr & "_" & von.ToShortDateString & "-" & bis.ToShortDateString & "_" & Now.ToString("ddMMyyyyHHmmss") & ".xlsx"
End While
My.Computer.FileSystem.WriteAllBytes(Path, My.Resources.RG_ZF_NEW, False)
Catch ex As System.Exception
' MsgBox(ex.Message)
MsgBox("Error 01: " & ex.Message & vbNewLine & ex.StackTrace)
Try
Path = sPath & "ZF_" & KdNr & "_" & von.ToShortDateString & " - " & bis.ToShortDateString & "" & ".xlsx"
While System.IO.File.Exists(Path)
Path = sPath & "ZF_" & KdNr & "_" & von.ToShortDateString & "-" & bis.ToShortDateString & "_" & Now.ToString("ddMMyyyyHHmmss") & ".xlsx"
End While
My.Computer.FileSystem.WriteAllBytes(Path, My.Resources.RG_ZF_NEW, False)
Catch ex As System.Exception
' MsgBox(ex.Message)
MsgBox("Error 01: " & ex.Message & vbNewLine & ex.StackTrace)
Return ""
End Try
Return ""
End Try
Datei = .Workbooks.Open(Path) 'Anpassen
Blatt = Datei.Worksheets(1) 'Anpassen
Datei = .Workbooks.Open(Path) 'Anpassen
Blatt = Datei.Worksheets(1) 'Anpassen
Dim cnt = 2
Dim cnt = 2
For Each r In dt.Rows
For Each r In dt.Rows
Dim ZOLLANMELDUNG As New DAKOSY_Worker.cZollsysteme_Aktenbeschriftung
Dim ZOLLANMELDUNG As New DAKOSY_Worker.cZollsysteme_Aktenbeschriftung
Dim zS = If(r("Zollsystem_Land") IsNot DBNull.Value, r("Zollsystem_Land").ToString(), "")
If ZOLLANMELDUNG.getDataByBezugsnummer(r("FilialenNr") & "/" & r("AbfertigungsNr"), r("Abfertigungsart"), "", False, zS) Then
Dim zS = If(r("Zollsystem_Land") IsNot DBNull.Value, r("Zollsystem_Land").ToString(), "")
If ZOLLANMELDUNG.getDataByBezugsnummer(r("FilialenNr") & "/" & r("AbfertigungsNr"), r("Abfertigungsart"), "", False, zS) Then
If ZOLLANMELDUNG.dtWARENPOS.Rows.Count > 0 Then
If ZOLLANMELDUNG.dtWARENPOS.Rows.Count > 0 Then
Dim rowcounter As Integer = 0
Dim rowcounter As Integer = 0
For Each row As DataRow In ZOLLANMELDUNG.dtWARENPOS.Rows
For Each row As DataRow In ZOLLANMELDUNG.dtWARENPOS.Rows
Dim ZollInProzent As Double = ZOLLANMELDUNG.ABGABEN_ZOLL / ZOLLANMELDUNG.RechnungspreisohneWahrung * 100
Blatt.Range("A" & cnt).Value = cnt - 1
Blatt.Range("B" & cnt).Value = r("Abfertigungsdatum")
Blatt.Range("C" & cnt).Value = VERAG_PROG_ALLGEMEIN.cAllgemein.getFirmaFromFiliale(r("FilialenNr"))
Blatt.Range("D" & cnt).Value = ZOLLANMELDUNG.Empfaenger
Blatt.Range("E" & cnt).Value = r("FilialenNr") & "/" & r("AbfertigungsNr")
Blatt.Range("F" & cnt).Value = r("BelegNr")
Blatt.Range("G" & cnt).Value = row.Item("PosNr")
Blatt.Range("H" & cnt).Value = row.Item("WarenNr")
Blatt.Range("I" & cnt).Value = "-"
Blatt.Range("J" & cnt).Value = row.Item("WarenBez")
Blatt.Range("K" & cnt).Value = ""
Blatt.Range("L" & cnt).Value = ZOLLANMELDUNG.Waehrungscode
Blatt.Range("M" & cnt).Value = ZOLLANMELDUNG.Geschaeftsart
Blatt.Range("N" & cnt).Value = ZOLLANMELDUNG.Zollstelle_Eingang
Blatt.Range("O" & cnt).Value = ""
Blatt.Range("P" & cnt).Value = row.Item("Netto")
Blatt.Range("Q" & cnt).Value = row.Item("PosWert")
Blatt.Range("R" & cnt).Value = IIf(rowcounter = 0, ZOLLANMELDUNG.ABGABEN_EUST, "")
Blatt.Range("S" & cnt).Value = IIf(rowcounter = 0, ZOLLANMELDUNG.ABGABEN_ZOLL, "")
Blatt.Range("T" & cnt).Value = IIf(rowcounter = 0, ZollInProzent.ToString("N2") & " %", "")
Blatt.Range("U" & cnt).Value = IIf(ZOLLANMELDUNG.VerBestLandZst.ToString.Count > 1, ZOLLANMELDUNG.VerBestLandZst.ToString.Substring(0, 2), "")
Blatt.Range("V" & cnt).Value = ZOLLANMELDUNG.Absender
Blatt.Range("W" & cnt).Value = row.Item("Herkunft")
Blatt.Range("X" & cnt).Value = ZOLLANMELDUNG.Incoterms
Blatt.Range("Y" & cnt).Value = row.Item("Verfahren")
Blatt.Range("Z" & cnt).Value = row.Item("Preferenz")
Blatt.Range("AA" & cnt).Value = IIf(row.Item("isCBAM"), "Y", "N")
If If(ZOLLANMELDUNG.ATCMRN, "") <> "" AndAlso Blatt.Range("F" & cnt).Value = "" Then
Blatt.Range("F" & cnt).Value = ZOLLANMELDUNG.ATCMRN
End If
cnt += 1
rowcounter += 1
Next
Else
Dim ZollInProzent As Double = ZOLLANMELDUNG.ABGABEN_ZOLL / ZOLLANMELDUNG.RechnungspreisohneWahrung * 100
@@ -2797,100 +2857,58 @@ Module Mail
Blatt.Range("D" & cnt).Value = ZOLLANMELDUNG.Empfaenger
Blatt.Range("E" & cnt).Value = r("FilialenNr") & "/" & r("AbfertigungsNr")
Blatt.Range("F" & cnt).Value = r("BelegNr")
Blatt.Range("G" & cnt).Value = row.Item("PosNr")
Blatt.Range("H" & cnt).Value = row.Item("WarenNr")
Blatt.Range("G" & cnt).Value = ""
Blatt.Range("H" & cnt).Value = ""
Blatt.Range("I" & cnt).Value = "-"
Blatt.Range("J" & cnt).Value = row.Item("WarenBez")
Blatt.Range("J" & cnt).Value = ""
Blatt.Range("K" & cnt).Value = ""
Blatt.Range("L" & cnt).Value = ZOLLANMELDUNG.Waehrungscode
Blatt.Range("M" & cnt).Value = ZOLLANMELDUNG.Geschaeftsart
Blatt.Range("N" & cnt).Value = ZOLLANMELDUNG.Zollstelle_Eingang
Blatt.Range("O" & cnt).Value = ""
Blatt.Range("P" & cnt).Value = row.Item("Netto")
Blatt.Range("Q" & cnt).Value = row.Item("PosWert")
Blatt.Range("R" & cnt).Value = IIf(rowcounter = 0, ZOLLANMELDUNG.ABGABEN_EUST, "")
Blatt.Range("S" & cnt).Value = IIf(rowcounter = 0, ZOLLANMELDUNG.ABGABEN_ZOLL, "")
Blatt.Range("T" & cnt).Value = IIf(rowcounter = 0, ZollInProzent.ToString("N2") & " %", "")
Blatt.Range("P" & cnt).Value = ""
Blatt.Range("Q" & cnt).Value = ""
Blatt.Range("R" & cnt).Value = ZOLLANMELDUNG.ABGABEN_EUST
Blatt.Range("S" & cnt).Value = ZOLLANMELDUNG.ABGABEN_ZOLL
Blatt.Range("T" & cnt).Value = ZollInProzent.ToString("N2") & " %"
Blatt.Range("U" & cnt).Value = IIf(ZOLLANMELDUNG.VerBestLandZst.ToString.Count > 1, ZOLLANMELDUNG.VerBestLandZst.ToString.Substring(0, 2), "")
Blatt.Range("V" & cnt).Value = ZOLLANMELDUNG.Absender
Blatt.Range("W" & cnt).Value = row.Item("Herkunft")
Blatt.Range("W" & cnt).Value = ""
Blatt.Range("X" & cnt).Value = ZOLLANMELDUNG.Incoterms
Blatt.Range("Y" & cnt).Value = row.Item("Verfahren")
Blatt.Range("Z" & cnt).Value = row.Item("Preferenz")
Blatt.Range("AA" & cnt).Value = IIf(row.Item("isCBAM"), "Y", "N")
Blatt.Range("Y" & cnt).Value = ""
Blatt.Range("Z" & cnt).Value = ""
Blatt.Range("AA" & cnt).Value = ""
If If(ZOLLANMELDUNG.ATCMRN, "") <> "" AndAlso Blatt.Range("F" & cnt).Value = "" Then
Blatt.Range("F" & cnt).Value = ZOLLANMELDUNG.ATCMRN
End If
cnt += 1
rowcounter += 1
Next
Else
Dim ZollInProzent As Double = ZOLLANMELDUNG.ABGABEN_ZOLL / ZOLLANMELDUNG.RechnungspreisohneWahrung * 100
Blatt.Range("A" & cnt).Value = cnt - 1
Blatt.Range("B" & cnt).Value = r("Abfertigungsdatum")
Blatt.Range("C" & cnt).Value = VERAG_PROG_ALLGEMEIN.cAllgemein.getFirmaFromFiliale(r("FilialenNr"))
Blatt.Range("D" & cnt).Value = ZOLLANMELDUNG.Empfaenger
Blatt.Range("E" & cnt).Value = r("FilialenNr") & "/" & r("AbfertigungsNr")
Blatt.Range("F" & cnt).Value = r("BelegNr")
Blatt.Range("G" & cnt).Value = ""
Blatt.Range("H" & cnt).Value = ""
Blatt.Range("I" & cnt).Value = "-"
Blatt.Range("J" & cnt).Value = ""
Blatt.Range("K" & cnt).Value = ""
Blatt.Range("L" & cnt).Value = ZOLLANMELDUNG.Waehrungscode
Blatt.Range("M" & cnt).Value = ZOLLANMELDUNG.Geschaeftsart
Blatt.Range("N" & cnt).Value = ZOLLANMELDUNG.Zollstelle_Eingang
Blatt.Range("O" & cnt).Value = ""
Blatt.Range("P" & cnt).Value = ""
Blatt.Range("Q" & cnt).Value = ""
Blatt.Range("R" & cnt).Value = ZOLLANMELDUNG.ABGABEN_EUST
Blatt.Range("S" & cnt).Value = ZOLLANMELDUNG.ABGABEN_ZOLL
Blatt.Range("T" & cnt).Value = ZollInProzent.ToString("N2") & " %"
Blatt.Range("U" & cnt).Value = IIf(ZOLLANMELDUNG.VerBestLandZst.ToString.Count > 1, ZOLLANMELDUNG.VerBestLandZst.ToString.Substring(0, 2), "")
Blatt.Range("V" & cnt).Value = ZOLLANMELDUNG.Absender
Blatt.Range("W" & cnt).Value = ""
Blatt.Range("X" & cnt).Value = ZOLLANMELDUNG.Incoterms
Blatt.Range("Y" & cnt).Value = ""
Blatt.Range("Z" & cnt).Value = ""
Blatt.Range("AA" & cnt).Value = ""
If If(ZOLLANMELDUNG.ATCMRN, "") <> "" AndAlso Blatt.Range("F" & cnt).Value = "" Then
Blatt.Range("F" & cnt).Value = ZOLLANMELDUNG.ATCMRN
End If
cnt += 1
End If
End If
Next
Next
Datei.Save()
.DisplayAlerts = False
.quit()
Try : Datei.close(True) : Catch : End Try
Datei.Save()
.DisplayAlerts = False
.quit()
Try : Datei.close(True) : Catch : End Try
End With
End With
End Select
End Select
'Dim filepath = VERAG_PROG_ALLGEMEIN.cProgramFunctions.genExcelFromDT_NEW(dt,,,,, False, "Report Data_" & KUNDENADR.FullName & "_" & von.ToShortDateString & "-" & bis.ToShortDateString)
End If
'Dim filepath = VERAG_PROG_ALLGEMEIN.cProgramFunctions.genExcelFromDT_NEW(dt,,,,, False, "Report Data_" & KUNDENADR.FullName & "_" & von.ToShortDateString & "-" & bis.ToShortDateString)
Dim filepath = Path
If filepath = "" Then Return "ERROR 01: Fehler beim Erzeugen des XLS."