feature_Frachtkostenberechnung

This commit is contained in:
2022-10-10 17:36:28 +02:00
parent 276c19cc30
commit 70e583853f
6 changed files with 1015 additions and 797 deletions

View File

@@ -1,4 +1,5 @@
Imports VERAG_PROG_ALLGEMEIN
Imports DocumentFormat.OpenXml.Drawing
Imports VERAG_PROG_ALLGEMEIN
Public Class frmFrachtkostenBerechnen
@@ -6,45 +7,99 @@ Public Class frmFrachtkostenBerechnen
Dim empfaengerID As Integer
Dim origin As String
Dim destination As String
Dim EUAnteil As Integer
Dim nichtEUAnteil As Integer
Dim gewicht As Double
Dim gesamtFrachtkosten As Double
Sub New(absID As String, empfID As String)
Sub New(absID As String, empfID As String, gewichtInput As Double)
InitializeComponent()
absenderID = CInt(absID)
empfaengerID = CInt(empfID)
gewicht = gewichtInput
End Sub
Private Sub frmFrachtkotenBerechnen_Load(sender As Object, e As EventArgs) Handles MyBase.Load
txbVon.fillWithSQL("SELECT ISNULL([LandKz],'-') AS , ISNULL([PLZ],'-'), ISNULL([Ort],''), ISNULL([Straße],'-') FROM [VERAG].[dbo].[Adressen] where AdressenNr = '" & absenderID & "'")
txbNach.fillWithSQL("SELECT ISNULL([LandKz],'-') AS , ISNULL([PLZ],'-'), ISNULL([Ort],''), ISNULL([Straße],'-') FROM [VERAG].[dbo].[Adressen] where AdressenNr = '" & empfaengerID & "'")
txbVonPLZ.fillWithSQL("SELECT ISNULL([LandKz],'') + '-' + ISNULL([PLZ],'') FROM [VERAG].[dbo].[Adressen] where AdressenNr = '" & absenderID & "'")
txbVonOrt.fillWithSQL("SELECT ISNULL([Ort],'') FROM [VERAG].[dbo].[Adressen] where AdressenNr = '" & absenderID & "'")
txbNachPLZ.fillWithSQL("SELECT ISNULL([LandKz],'') + '-' + ISNULL([PLZ],'-') FROM [VERAG].[dbo].[Adressen] where AdressenNr = '" & empfaengerID & "'")
txbNachOrt.fillWithSQL("SELECT ISNULL([Ort],'') FROM [VERAG].[dbo].[Adressen] where AdressenNr = '" & empfaengerID & "'")
'tbEUAnteil._value = EUAnteil.ToString
'tbNichtEUAnteil._value = nichtEUAnteil.ToString
txbGewicht._value = gewicht.ToString
txbFactor._value = 0.15
End Sub
Sub calculateFreight()
origin = IIf(txbVonPLZ._value <> "", txbVonPLZ._value, "") & " " & IIf(txbVonOrt._value <> "", txbVonOrt._value, "")
destination = IIf(txbNachPLZ._value <> "", txbNachPLZ._value, "") & " " & IIf(txbNachOrt._value <> "", txbNachOrt._value, "")
Dim duration = ""
Dim distance = ""
'If ALLG.sbAbgangZollstelle._value <> "" Then
' origin = ALLG.sbAbgangZollstelle._value.Substring(0, 2) & " " & ALLG.sbAbgangZollstelle.Text
'End If
VERAG_PROG_ALLGEMEIN.cGoogleAPI.GoogleDistance(origin, destination, duration, distance)
txbCalcDistance._value = distance
'Dim usrCntlEmpf = ADRESSEN.usrCntlEmpfaenger
destination &= usrCntlEmpf.txtStrasse.Text & " "
destination &= usrCntlEmpf.sbLand._value & " "
destination &= usrCntlEmpf.txtPlz.Text & " "
destination &= usrCntlEmpf.txtOrt.Text & " "
VERAG_PROG_ALLGEMEIN.cGoogleAPI.GoogleDistance(origin, destination, duration, "", distance)
End Sub
Sub calculateFreightCosts()
Try
gesamtFrachtkosten = gewicht * CDbl(txbFactor._value)
tbxGesamtfrachtkosten._value = gesamtFrachtkosten
EUAnteil = gesamtFrachtkosten * tbEUAnteil._value / 100
nichtEUAnteil = gesamtFrachtkosten * tbNichtEUAnteil._value / 100
Catch ex As Exception
End Try
End Sub
Sub checkInputFields()
If (tbEUAnteil._value = "" Or Not IsNumeric(tbEUAnteil._value)) Then
'Hinweis INPUT false
End If
If (tbNichtEUAnteil._value = "" Or Not IsNumeric(tbNichtEUAnteil._value)) Then
'Hinweis INPUT false
End If
If (txbFactor._value = "" Or Not IsNumeric(txbFactor._value)) Then
'Hinweis INPUT false
End If
End Sub
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
resetInputFIeld()
calculateFreight()
calculateFreightCosts()
End Sub
Private Sub resetInputFIeld()
txbCalcDistance._value = ""
End Sub
End Class