Frachtkostenberechnung

This commit is contained in:
2023-08-23 14:32:57 +02:00
parent 363ea3aa5e
commit 8ef39f02a7
5 changed files with 712 additions and 477 deletions

View File

@@ -1,4 +1,7 @@
Imports DocumentFormat.OpenXml.Drawing.Diagrams
Imports DocumentFormat.OpenXml.Drawing.Charts
Imports DocumentFormat.OpenXml.Drawing.Diagrams
Imports Microsoft.Office.Interop.Excel
Imports SDL
Public Class usrcntlFrachtkostenberechnung
@@ -14,65 +17,67 @@ Public Class usrcntlFrachtkostenberechnung
Dim gesamtFrachtkosten As Double
Dim sql As New VERAG_PROG_ALLGEMEIN.SQL
Dim warenbez As String
Dim avisoid As Integer = -1
Sub New()
InitializeComponent()
End Sub
Public Sub init(absID As String, empfID As String, gewichtInput As String, gesamtfrachtkostenInput As String, ware As String, warenwert As String)
Public Sub init(avisoid As Integer, absID As String, empfID As String, gewichtInput As String, gesamtfrachtkostenInput As String, ware As String, warenwert As String)
Me.avisoid = avisoid
If gesamtfrachtkostenInput IsNot Nothing AndAlso gesamtfrachtkostenInput.ToString <> "" AndAlso IsNumeric(gesamtfrachtkostenInput) Then
gesamtFrachtkosten = CDbl(gesamtfrachtkostenInput)
tbxGesamtfrachtkosten._value = gesamtFrachtkosten
Else
gesamtFrachtkosten = 0
End If
gesamtFrachtkosten = CDbl(gesamtfrachtkostenInput)
tbxGesamtfrachtkosten._value = gesamtFrachtkosten
Else
gesamtFrachtkosten = 0
End If
If gewichtInput IsNot Nothing AndAlso gewichtInput.ToString <> "" AndAlso IsNumeric(gewichtInput) Then
gewicht = CDbl(gewichtInput)
Else
gewicht = 0
End If
If gewichtInput IsNot Nothing AndAlso gewichtInput.ToString <> "" AndAlso IsNumeric(gewichtInput) Then
gewicht = CDbl(gewichtInput)
Else
gewicht = 0
End If
If absID IsNot Nothing AndAlso absID.ToString <> "" AndAlso IsNumeric(absID) Then
absenderID = CInt(absID)
Else
absenderID = -1
End If
If absID IsNot Nothing AndAlso absID.ToString <> "" AndAlso IsNumeric(absID) Then
absenderID = CInt(absID)
Else
absenderID = -1
End If
If empfID IsNot Nothing AndAlso empfID.ToString <> "" AndAlso IsNumeric(empfID) Then
If empfID IsNot Nothing AndAlso empfID.ToString <> "" AndAlso IsNumeric(empfID) Then
empfaengerID = Int(empfID)
Else
empfaengerID = -1
End If
empfaengerID = Int(empfID)
Else
empfaengerID = -1
End If
'cbxLandVon.fillWithSQL("SELECT Distinct(ISNULL([LandKz],'')) as LandKZ FROM [Adressen] order by LandKz asc", False, "FMZOLL", True, True)
cbxLandVon.fillWithSQL(" select distinct landkz, Währungstabelle.Land from Währungstabelle where landkz is not null order by LandKz", True, "FMZOLL", True)
'cbxLandVon.fillWithSQL("SELECT Distinct(ISNULL([LandKz],'')) as LandKZ FROM [Adressen] order by LandKz asc", False, "FMZOLL", True, True)
cbxLandVon.fillWithSQL(" select distinct landkz, Währungstabelle.Land from Währungstabelle where landkz is not null order by LandKz", True, "FMZOLL", True)
cbxLandVon.changeItem(sql.DLookup("[LandKz]", "[Adressen]", "[AdressenNr]='" & absenderID & "'", "FMZOLL", ""))
txbVonPLZ.fillWithSQL("SELECT ISNULL([PLZ],'') FROM [Adressen] where AdressenNr = '" & absenderID & "'", "FMZOLL")
txbVonOrt.fillWithSQL("SELECT ISNULL([Ort],'') FROM [Adressen] where AdressenNr = '" & absenderID & "'", "FMZOLL")
cbxLandVon.changeItem(sql.DLookup("[LandKz]", "[Adressen]", "[AdressenNr]='" & absenderID & "'", "FMZOLL", ""))
txbVonPLZ.fillWithSQL("SELECT ISNULL([PLZ],'') FROM [Adressen] where AdressenNr = '" & absenderID & "'", "FMZOLL")
txbVonOrt.fillWithSQL("SELECT ISNULL([Ort],'') FROM [Adressen] where AdressenNr = '" & absenderID & "'", "FMZOLL")
cbxLandNach.Items.AddRange(cbxLandVon.Items.Cast(Of VERAG_PROG_ALLGEMEIN.MyListItem).ToArray())
cbxLandNach.changeItem(sql.DLookup("[LandKz]", "[Adressen]", "[AdressenNr]='" & empfaengerID & "'", "FMZOLL", ""))
txbNachPLZ.fillWithSQL("SELECT ISNULL([PLZ],'-') FROM [Adressen] where AdressenNr = '" & empfaengerID & "'", "FMZOLL")
txbNachOrt.fillWithSQL("SELECT ISNULL([Ort],'') FROM [Adressen] where AdressenNr = '" & empfaengerID & "'", "FMZOLL")
cbxLandNach.Items.AddRange(cbxLandVon.Items.Cast(Of VERAG_PROG_ALLGEMEIN.MyListItem).ToArray())
cbxLandNach.changeItem(sql.DLookup("[LandKz]", "[Adressen]", "[AdressenNr]='" & empfaengerID & "'", "FMZOLL", ""))
txbNachPLZ.fillWithSQL("SELECT ISNULL([PLZ],'-') FROM [Adressen] where AdressenNr = '" & empfaengerID & "'", "FMZOLL")
txbNachOrt.fillWithSQL("SELECT ISNULL([Ort],'') FROM [Adressen] where AdressenNr = '" & empfaengerID & "'", "FMZOLL")
ckbManAnteilsermittlung.Checked = True
ckbManAnteilsermittlung.Checked = True
tbEUAnteil._value = 0
tbNichtEUAnteil._value = 0
txbGewicht._value = gewicht.ToString
txbFactor._value = 0.15
tbEUAnteil._value = 0
tbNichtEUAnteil._value = 0
txbGewicht._value = gewicht.ToString
txbFactor._value = 0.15
txtWare._value = ware
txtGesamtgewicht._value = gewichtInput
txtWare._value = ware
txtGesamtgewicht._value = gewichtInput
checkInputFields()
checkInputFields()
End Sub
@@ -129,7 +134,7 @@ Public Class usrcntlFrachtkostenberechnung
ElseIf cbxLandVon._value = "SRB" AndAlso cbxLandNach._value = "D" AndAlso (absenderID = "551038" Or absenderID = "722998") AndAlso ckbManAnteilsermittlung.Checked Then
twoRouteRequest = True
'Sonderfall für Lukow-Berechnung
'Sonderfall für Lukowa-Berechnung
VERAG_PROG_ALLGEMEIN.cGoogleAPI.GoogleDistance(origin, "Bajakovo", duration, distance,, getValues)
VERAG_PROG_ALLGEMEIN.cGoogleAPI.GoogleDistance("Bajakovo", destination, durationEU, distanceEU,, getValues)
@@ -305,8 +310,8 @@ Public Class usrcntlFrachtkostenberechnung
End Sub
Private Sub txbCalcDistanceEU_TextChanged(sender As Object, e As EventArgs) Handles txbCalcDistanceEU.TextChanged, txbCalcDistanceNichtEU.TextChanged, txbCalcDistanceNichtEU.TextChanged, tbNichtEUAnteilberechnet.TextChanged, tbEUAnteil.TextChanged, tbNichtEUAnteil.TextChanged
txbCalcDistanceEU2.Text = txbCalcDistanceEU.Text
txbCalcDistanceNichtEU2.Text = txbCalcDistanceNichtEU.Text
txtDistanzEU.Text = txbCalcDistanceEU.Text
txtDistanzNichtEU.Text = txbCalcDistanceNichtEU.Text
'tbEUAnteilberechnet2.Text = txbCalcDistanceNichtEU.Text
'tbNichtEUAnteilberechnet22.Text = tbNichtEUAnteilberechnet.Text
@@ -316,33 +321,33 @@ Public Class usrcntlFrachtkostenberechnung
End Sub
Private Sub MyTextBox1_ValueChanged() Handles MyTextBox1.ValueChanged
If IsNumeric(MyTextBox1._value) AndAlso IsNumeric(txtVerzollungskosten._value) Then
If CDbl(MyTextBox1._value) < 100 And CDbl(MyTextBox1._value) > 0 And CDbl(txtVerzollungskosten._value) > 0 Then
txtWeitereTarifPos._value = CDbl((MyTextBox1._value * 100) * txtVerzollungskosten._value / (100 + CDbl(MyTextBox1._value * 100)))
Private Sub MyTextBox1_ValueChanged() Handles txtAnteilZollInProzent.ValueChanged
If IsNumeric(txtAnteilZollInProzent._value) AndAlso IsNumeric(txtVerzollungskosten._value) Then
If CDbl(txtAnteilZollInProzent._value) < 100 And CDbl(txtAnteilZollInProzent._value) > 0 And CDbl(txtVerzollungskosten._value) > 0 Then
txtAnteilZoll._value = CDbl((txtAnteilZollInProzent._value * 100) * txtVerzollungskosten._value / (100 + CDbl(txtAnteilZollInProzent._value * 100)))
End If
End If
End Sub
Private Sub MyTextBox2_ValueChanged() Handles MyTextBox2.ValueChanged, MyTextBox3.ValueChanged
If IsNumeric(MyTextBox2._value) And IsNumeric(MyTextBox3._value) Then
txtPreis._value = MyTextBox2._value * MyTextBox3._value
Private Sub MyTextBox2_ValueChanged() Handles txtPreis.ValueChanged, txtWarengewichtNetto.ValueChanged
If IsNumeric(txtPreis._value) And IsNumeric(txtWarengewichtNetto._value) Then
txtGesamtpreis._value = txtPreis._value * txtWarengewichtNetto._value
End If
End Sub
Private Sub txtFrachtanteil_ValueChanged() Handles txtFrachtanteil.ValueChanged, txtPreis.ValueChanged
If IsNumeric(txtFrachtanteil._value) And IsNumeric(txtPreis._value) Then
txtVerzollungskosten._value = CDbl(txtPreis._value - txtFrachtanteil._value)
Private Sub txtFrachtanteil_ValueChanged() Handles txtFrachtkostenanteil.ValueChanged, txtGesamtpreis.ValueChanged
If IsNumeric(txtFrachtkostenanteil._value) And IsNumeric(txtGesamtpreis._value) Then
txtVerzollungskosten._value = CDbl(txtGesamtpreis._value - txtFrachtkostenanteil._value)
End If
End Sub
Private Sub txtWarengewicht_ValueChanged() Handles txtWarengewicht.ValueChanged, MyTextBox6.ValueChanged
If IsNumeric(txtWarengewicht._value) And IsNumeric(txtGesamtgewicht._value) Then
Dim anteil As Double = Math.Round(CDbl(txtWarengewicht._value / txtGesamtgewicht._value * 100), 2)
Private Sub txtWarengewicht_ValueChanged() Handles txtWarengewichtBrutto.ValueChanged, txtGesamtfracht.ValueChanged
If IsNumeric(txtWarengewichtBrutto._value) And IsNumeric(txtGesamtgewicht._value) Then
Dim anteil As Double = Math.Round(CDbl(txtWarengewichtBrutto._value / txtGesamtgewicht._value * 100), 2)
lblAnteil.Text = anteil & " %"
If IsNumeric(MyTextBox6._value) Then
txtWarenanteil._value = CDbl(MyTextBox6._value * anteil / 100)
If IsNumeric(txtGesamtfracht._value) Then
txtWarenanteilsumme._value = CDbl(txtGesamtfracht._value * anteil / 100)
End If
Else
@@ -351,31 +356,103 @@ Public Class usrcntlFrachtkostenberechnung
End If
End Sub
Private Sub txbCalcDistanceNichtEU2_TextChanged(sender As Object, e As EventArgs) Handles txbCalcDistanceNichtEU2.TextChanged, txbCalcDistanceEU2.TextAlignChanged
If IsNumeric(txbCalcDistanceNichtEU2._value) AndAlso IsNumeric(txbCalcDistanceEU2._value) Then
txtDistanzGes._value = CDbl(txbCalcDistanceNichtEU2._value) + CDbl(txbCalcDistanceEU2._value)
Private Sub txbCalcDistanceNichtEU2_TextChanged(sender As Object, e As EventArgs) Handles txtDistanzNichtEU.TextChanged, txtDistanzEU.TextAlignChanged
If IsNumeric(txtDistanzNichtEU._value) AndAlso IsNumeric(txtDistanzEU._value) Then
txtGesamtdistanz._value = CDbl(txtDistanzNichtEU._value) + CDbl(txtDistanzEU._value)
End If
End Sub
Private Sub txtDistanzGes_ValueChanged() Handles txtDistanzGes.ValueChanged, txtWarenanteil.ValueChanged
If IsNumeric(txtDistanzGes._value) And IsNumeric(txtWarenanteil._value) And IsNumeric(txbCalcDistanceEU2._value) Then
txtGesamtsumme._value = CDbl(txtWarenanteil._value / txtDistanzGes._value * txbCalcDistanceEU2._value)
txtFrachtanteil._value = txtGesamtsumme._value
Private Sub txtDistanzGes_ValueChanged() Handles txtGesamtdistanz.ValueChanged, txtWarenanteilsumme.ValueChanged
If IsNumeric(txtGesamtdistanz._value) And IsNumeric(txtWarenanteilsumme._value) And IsNumeric(txtDistanzEU._value) Then
txtGesamtfrachtAnteil._value = CDbl(txtWarenanteilsumme._value / txtGesamtdistanz._value * txtDistanzEU._value)
txtFrachtkostenanteil._value = txtGesamtfrachtAnteil._value
End If
End Sub
Private Sub txtVerzollungskosten_ValueChanged() Handles txtVerzollungskosten.ValueChanged, txtWeitereTarifPos.ValueChanged
If IsNumeric(txtVerzollungskosten._value) AndAlso IsNumeric(txtWeitereTarifPos._value) Then
txtBGLZoll._value = CDbl(txtVerzollungskosten._value) + CDbl(txtWeitereTarifPos._value)
Private Sub txtVerzollungskosten_ValueChanged() Handles txtVerzollungskosten.ValueChanged, txtAnteilZoll.ValueChanged
If IsNumeric(txtVerzollungskosten._value) AndAlso IsNumeric(txtAnteilZoll._value) Then
txtBGLZoll._value = CDbl(txtVerzollungskosten._value) + CDbl(txtAnteilZoll._value)
End If
End Sub
Private Sub txtPreis_ValueChanged() Handles txtPreis.ValueChanged
If IsNumeric(txtPreis._value) Then
txtEUST._value = txtPreis._value
Private Sub txtPreis_ValueChanged() Handles txtGesamtpreis.ValueChanged
If IsNumeric(txtGesamtpreis._value) Then
txtBGLEUST._value = txtGesamtpreis._value
End If
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
If Not ContextMenuStrip1.Items.ContainsKey("open") Then
Dim uploadPictures = New ToolStripMenuItem() With {.Text = "öffnen", .Name = "open"}
ContextMenuStrip1.Items.Add(uploadPictures)
AddHandler uploadPictures.Click, AddressOf mnuItem_Clicked
End If
If Not ContextMenuStrip1.Items.ContainsKey("createAttachment") Then
Dim copyToClipboard = New ToolStripMenuItem() With {.Text = "als Anhang anfügen", .Name = "createAttachment"}
AddHandler copyToClipboard.Click, AddressOf mnuItem_Clicked
ContextMenuStrip1.Items.Add(copyToClipboard)
End If
ContextMenuStrip1.Show(Cursor.Position)
End Sub
Private Sub mnuItem_Clicked(sender As Object, e As EventArgs)
ContextMenuStrip1.Hide()
Dim item As ToolStripMenuItem = TryCast(sender, ToolStripMenuItem)
If item IsNot Nothing Then
Dim tmpPath = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.getTMPPath("Frachtkostenberechnung", ".pdf", , False)
If item.Name = "open" Then
createFrachtkostenberechnung(tmpPath)
Process.Start(tmpPath)
ElseIf item.Name = "createAttachment" Then
createFrachtkostenberechnung(tmpPath)
If avisoid < 0 Then
MsgBox("AvisoId wurde nicht korrekt ermittelt!")
Exit Sub
End If
Dim f As New frmSendungAnhangImport(avisoid)
If f.addData_SendungAnhang(tmpPath) > 0 Then
MsgBox("Formular wurde in der Sendung angefügt")
Else
MsgBox("Fehler beim Einfügen")
End If
Else
MsgBox("Funktion nicht implementiert!")
End If
End If
End Sub
Private Sub createFrachtkostenberechnung(tmpPath As String)
Try
Me.Cursor = Cursors.WaitCursor
Dim rptFrachtkosten As New SDL.rptFrachtkostenberechnung(txtWare.Text, txtPreis.Text, txtWarengewichtNetto.Text, txtGesamtpreis.Text, txtFrachtkostenanteil.Text, txtVerzollungskosten.Text, txtAnteilZoll.Text, txtAnteilZollInProzent._value, txtBGLZoll.Text, txtBGLEUST.Text, txtDistanzEU.Text, txtDistanzNichtEU.Text, txtGesamtdistanz.Text, txtGesamtgewicht.Text, txtWarengewichtBrutto.Text, lblAnteil.Text, txtWarenanteilsumme.Text, txtGesamtfracht.Text, txtGesamtfrachtAnteil.Text)
Dim p As New GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport
rptFrachtkosten.Run(False)
p.NeverEmbedFonts = ""
p.Export(rptFrachtkosten.Document, tmpPath)
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
End Class