div. Punkte

This commit is contained in:
2025-10-14 17:38:23 +02:00
parent cd81ff6d90
commit e8ade89a6b
14 changed files with 789 additions and 325 deletions

View File

@@ -4,6 +4,11 @@ Imports System.Reflection
Imports javax.xml.bind.annotation
Imports VERAG_PROG_ALLGEMEIN
Imports System.Globalization
Imports System.Data.OleDb
Imports System.IO
Imports System.Web.UI.WebControls.Expressions
Imports System.DirectoryServices.ActiveDirectory
Imports Microsoft.Office.Interop
Public Class frmKundenblatt
@@ -1322,6 +1327,7 @@ Public Class frmKundenblatt
scanErstbestellung.Visible = False
scanMWSTAgreement.Visible = False
Button7.Visible = False
btnBestelldateiErzeugen.Visible = False
If dgvSDLLeistungenFull.SelectedRows.Count > 0 Then
Panel2.Visible = True
@@ -1335,7 +1341,7 @@ Public Class frmKundenblatt
Select Case tmpSDLNr
Case 100 : txtPartnerKdNr.Text = PartnerKdNrFromFMZOLL.IDSKundenNr 'IDS
Case 200 : txtPartnerKdNr.Text = PartnerKdNrFromFMZOLL.ATKundenNr : Button7.Visible = True 'AT
Case 200 : txtPartnerKdNr.Text = PartnerKdNrFromFMZOLL.ATKundenNr : Button7.Visible = True : btnBestelldateiErzeugen.Visible = True
Case 212 : txtPartnerKdNr.Text = PartnerKdNrFromFMZOLL.UTAKundenNr 'UTA
Case 101 : txtPartnerKdNr.Text = PartnerKdNrFromFMZOLL.WölflKundenNr 'WÖLFL
Case 202 : txtPartnerKdNr.Text = PartnerKdNrFromFMZOLL.TELEPASS_Kd_Nr 'TELEPASS
@@ -2489,5 +2495,136 @@ Public Class frmKundenblatt
End Sub
Private Sub btnBestelldateiErzeugen_Click(sender As Object, e As EventArgs) Handles btnBestelldateiErzeugen.Click
Dim dateBestelldatum As Date = Date.Now
Dim intBestellnummer As Integer
Dim lngBestellanzahl As Long
Dim strDateiname As String
Try
' Kreditkarten prüfen/eintragen
Dim dt_offeneBestellungen As New DataTable
dt_offeneBestellungen = SQL.loadDgvBySql("SELECT gb_bestelldatum, gb_bestellNr, gb_adressNr, gb_CardNum, gb_CardValidMonth, gb_CardValidYear, gb_licensePlate, gb_licensePlateNat, gb_Axles FROM [tblGOBOXBestellungen] WHERE gb_bestelldatum Is Null AND gb_bestellNr Is Null", "FMZOLL")
If dt_offeneBestellungen IsNot Nothing Then
lngBestellanzahl = dt_offeneBestellungen.Rows.Count
For Each r As DataRow In dt_offeneBestellungen.Rows
If Not IsDBNull(r.Item("gb_adressNr")) AndAlso Not IsDBNull(r.Item("gb_CardNum")) AndAlso Not IsDBNull(r.Item("gb_CardValidMonth")) AndAlso Not IsDBNull(r.Item("gb_CardValidYear")) Then
Dim countKK = SQL.getValueTxtBySql("SELECT COUNT(*) FROM Kreditkarten WHERE AdressenNr = " & r.Item("gb_adressNr") & " AND KartenNr =" & r.Item("gb_CardNum"), "FMZOLL")
If countKK = "0" Then
If SQL.doSQL("INSERT INTO Kreditkarten (AdressenNr, KartenNr, Kartenfreischaltungsdatum, Kartenablaufmonat, Kartenablaufjahr, Kartensperre, Zeitstempel, Sachbearbeiter)
VALUES ('" & r.Item("gb_adressNr") & "','" & r.Item("gb_CardNum") & "','" & Date.Now & "','" & r.Item("gb_CardValidMonth") & "','" & r.Item("gb_CardValidYear") & "','0','" & Now() & "','" & VERAG_PROG_ALLGEMEIN.cAllgemein.USRKURZNAME & "')", "FMZOLL") Then
End If
End If
End If
Next
End If
' 4 Bestelldaten lesen
Dim dtBestellungen As DataTable = SQL.loadDgvBySql("SELECT gb_ID,gb_bestelldatum, gb_bestellNr, gb_adressNr, gb_CardNum, gb_CardValidMonth, gb_CardValidYear, gb_licensePlate, gb_licensePlateNat, gb_Axles FROM [tblGOBOXBestellungen] WHERE gb_bestelldatum Is Null AND gb_bestellNr Is Null", "FMZOLL")
If dtBestellungen.Rows.Count = 0 Then
MessageBox.Show("Keine Bestelldaten vorhanden.", "Bestelldatei erzeugen", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If
'5 Neue Bestellnummer bestimmen
Dim bestellNr As String = SQL.getValueTxtBySql("SELECT Top(1) gb_bestellNr FROM [tblGOBOXBestellnummern] ORDER BY gb_bestelldatum DESC", "FMZOLL")
If bestellNr <> "" AndAlso IsNumeric(bestellNr) Then
intBestellnummer = CInt(bestellNr)
End If
' 6 Datensätze aktualisieren
Dim ID_bestellungen As String = ""
If dtBestellungen.Columns.Contains("gb_ID") Then
Dim dtNew As DataTable = dtBestellungen.Rows.Cast(Of DataRow)().Where(Function(row) Not row.ItemArray.All(Function(field) field Is DBNull.Value Or field.Equals(""))).CopyToDataTable()
If dtNew.Rows.Count > 0 Then
Dim counter = 0
For Each r As DataRow In dtNew.Rows
ID_bestellungen &= r.Item(0)
counter = counter + 1
If (dtNew.Rows.Count <> 0 And counter <> dtNew.Rows.Count) Then
ID_bestellungen &= ","
End If
Next
End If
End If
If ID_bestellungen <> "" Then
SQL.doSQL("UPDATE tblGOBOXBestellungen SET gb_bestelldatum = '" & dateBestelldatum.ToShortDateString & "', gb_bestellNr = " & intBestellnummer & " WHERE gb_ID in (" & ID_bestellungen & ")", "FMZOLL")
End If
' 7 Bestellnummer speichern
If IsDate(dateBestelldatum) AndAlso IsNumeric(intBestellnummer) AndAlso IsNumeric(lngBestellanzahl) Then
SQL.doSQL("INSERT INTO tblGOBOXBestellnummern (gb_bestelldatum, gb_bestellNr, gb_bestellAnzahl) VALUES ('" & dateBestelldatum.ToShortDateString & "', " & intBestellnummer & ", " & lngBestellanzahl & ")", "FMZOLL")
End If
'CSV erzeugen:
Dim SQL_String As String = "Select Top(1) 'S' As [Transaction Type], ''As Company1, ' ' As Company2, ' ' As CompanyStreet, ' ' As CompanyNumber, ' ' As CompanyCode, ' ' As CompanyCity, ' ' As CompanyCountry, ' ' As CompanyCountryAbbr, ' ' As CompanyTelephone, ' ' As CompanyTelefax, ' ' As Salutation, ' ' As Title, ' ' As FirstName, ' ' As LastName, ' ' As Email, ' ' As PersonLanguage, ' ' As [License plate], ' ' As [License plate Nationality], ' ' As VehicleType, ' ' As Axles, ' ' As [Stammnummer For Tripon Orders only], ' ' As CardNum, ' ' As CardValidMonth, ' ' As CardValidYear FROM [tblGOBOXBestellungen]
UNION ALL
Select gb_transactionTyp, gb_company1, gb_company2, gb_companyStreet, gb_adressNr, gb_companyPostalcode, gb_companyCountry, gb_companyCountryISO, gb_companyCountryISO, gb_companyTel, gb_companyFax, gb_salutation, gb_title, gb_firstname, gb_lastname, gb_email, gb_personLanguage, gb_licensePlate, gb_licensePlateNat, gb_vehicleTyp, gb_Axles, '', gb_CardNum,RIGHT('00' + CAST(gb_CardValidMonth AS VARCHAR(2)), 2) , RIGHT('00' + CAST(gb_CardValidYear AS VARCHAR(2)), 2)
From [tblGOBOXBestellungen] where gb_bestellNr = " & intBestellnummer & " and gb_transactionTyp = 'N'
UNION SELECT TOP (1) 'E', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' FROM [tblGOBOXBestellungen]"
Dim dt_export As DataTable = SQL.loadDgvBySql(SQL_String, "FMZOLL")
Dim outl As New Outlook.Application
Dim Mail As Microsoft.Office.Interop.Outlook.MailItem
Mail = outl.CreateItem(0)
Mail.Subject = "GO-BOX Bestellung Nr. " & intBestellnummer & " vom " & dateBestelldatum.ToShortDateString
strDateiname = "PO_VG_" & Format(intBestellnummer, "0000") & "_" & Format(dateBestelldatum, "ddmmyy") & ".csv"
Dim Path As String = VERAG_PROG_ALLGEMEIN.cProgramFunctions.genCSVFromDT(dt_export,,, strDateiname)
'muss genauer Bezeichnung haben!!
'"PO_VG_" & Format(Forms!frm_GO_BOX_Bestellvorgang!Bestellnummer, "0000") & "_" & Format(Forms!frm_GO_BOX_Bestellvorgang!Bestelldatum, "ddmmyy") & ".csv"
Mail.Body = "Als Anhang senden wir Ihnen die Datei """ & strDateiname & """ mit den GO-BOX-Bestellungen." &
vbCrLf & vbCrLf & "Mit freundlichen Grüssen" &
vbCrLf & "VERAG Spedition AG" &
vbCrLf & "ASFINAG-Mautabteilung" &
vbCrLf & "______________________" &
vbCrLf & "Tel. +43 7711 2777 - 14 o. 17 o. 47" &
vbCrLf & "Fax +43 7711 3386" &
vbCrLf & "email: maut.asfinag@verag.ag" &
vbCrLf & "www.verag.ag"
Mail.Attachments.Add(Path, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue,, strDateiname)
Mail.Display()
Me.Cursor = Cursors.Default
Catch ex As Exception
MessageBox.Show("Fehler beim Erzeugen der Bestelldatei: " & ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Class