Feature_Implementierung Frachkostenberechnung
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
Imports DocumentFormat.OpenXml.Drawing
|
||||
Imports System.Security.Cryptography
|
||||
Imports DocumentFormat.OpenXml.Drawing
|
||||
Imports DocumentFormat.OpenXml.Office.MetaAttributes
|
||||
Imports VERAG_PROG_ALLGEMEIN
|
||||
|
||||
Public Class frmFrachtkostenBerechnen
|
||||
@@ -7,8 +9,8 @@ Public Class frmFrachtkostenBerechnen
|
||||
Dim empfaengerID As Integer
|
||||
Dim origin As String
|
||||
Dim destination As String
|
||||
Dim EUAnteil As Integer
|
||||
Dim nichtEUAnteil As Integer
|
||||
Public EUAnteil As Double
|
||||
Public nichtEUAnteil As Double
|
||||
Dim gewicht As Double
|
||||
Dim gesamtFrachtkosten As Double
|
||||
|
||||
@@ -31,26 +33,111 @@ Public Class frmFrachtkostenBerechnen
|
||||
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 & "'")
|
||||
|
||||
ckbManAnteilsermittlung.Checked = True
|
||||
|
||||
'tbEUAnteil._value = EUAnteil.ToString
|
||||
'tbNichtEUAnteil._value = nichtEUAnteil.ToString
|
||||
tbEUAnteil._value = 0
|
||||
tbNichtEUAnteil._value = 0
|
||||
txbGewicht._value = gewicht.ToString
|
||||
txbFactor._value = 0.15
|
||||
checkInputFields()
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Sub calculateFreight()
|
||||
|
||||
'resetInputFields()
|
||||
setControlEUAnteile()
|
||||
|
||||
origin = IIf(txbVonPLZ._value <> "", txbVonPLZ._value, "") & " " & IIf(txbVonOrt._value <> "", txbVonOrt._value, "")
|
||||
destination = IIf(txbNachPLZ._value <> "", txbNachPLZ._value, "") & " " & IIf(txbNachOrt._value <> "", txbNachOrt._value, "")
|
||||
|
||||
Dim getValues = True
|
||||
Dim twoRouteRequest As Boolean = False
|
||||
Dim duration = ""
|
||||
Dim distance = ""
|
||||
Dim durationEU = ""
|
||||
Dim distanceEU = ""
|
||||
|
||||
VERAG_PROG_ALLGEMEIN.cGoogleAPI.GoogleDistance(origin, destination, duration, distance)
|
||||
|
||||
txbCalcDistance._value = distance
|
||||
If txbVonPLZ._value.Substring(0, 2) = "TR" AndAlso ckbManAnteilsermittlung.Checked Then
|
||||
|
||||
twoRouteRequest = True
|
||||
'Kapitan Andreevo ist EU Grenze für Lieferungen aus der Türkei
|
||||
VERAG_PROG_ALLGEMEIN.cGoogleAPI.GoogleDistance(origin, "Kapitan Andreevo", duration, distance,, getValues)
|
||||
VERAG_PROG_ALLGEMEIN.cGoogleAPI.GoogleDistance("Kapitan Andreevo", destination, durationEU, distanceEU,, getValues)
|
||||
|
||||
ElseIf txbVonPLZ._value.Substring(0, 3) = "SRB" AndAlso ckbManAnteilsermittlung.Checked Then
|
||||
twoRouteRequest = True
|
||||
'Horgoš ist EU Grenze für Lieferungen aus Serbien
|
||||
VERAG_PROG_ALLGEMEIN.cGoogleAPI.GoogleDistance(origin, "Horgoš", duration, distance,, getValues)
|
||||
VERAG_PROG_ALLGEMEIN.cGoogleAPI.GoogleDistance("Horgoš", destination, durationEU, distanceEU,, getValues)
|
||||
|
||||
End If
|
||||
|
||||
If twoRouteRequest = True AndAlso ckbManAnteilsermittlung.Checked Then
|
||||
|
||||
lblDistanzEU.Text = "EU-Distanz"
|
||||
lblDistanzNichtEU.Visible = True
|
||||
txbCalcDistanceNichtEU.Visible = True
|
||||
|
||||
Try
|
||||
|
||||
If (IsNumeric(distanceEU)) Then
|
||||
IIf(distanceEU > 1000, Math.Round(distanceEU / 1000, 0), distanceEU)
|
||||
txbCalcDistanceEU._value = IIf(distanceEU > 1000, Math.Round(distanceEU / 1000, 0), distanceEU)
|
||||
Else
|
||||
distanceEU = "0"
|
||||
|
||||
MsgBox("Standort vom Bestimmungsort kann nicht ermittelt werden!" & vbCr & "Bitte Eingabe " & txbNachPLZ._value & " " & txbNachOrt._value & " prüfen")
|
||||
Exit Sub
|
||||
|
||||
End If
|
||||
|
||||
If (IsNumeric(distance)) Then
|
||||
txbCalcDistanceNichtEU._value = IIf(CInt(distance) > 1000, Math.Round(CInt(distance) / 1000, 0), CInt(distance))
|
||||
Else
|
||||
distance = "0"
|
||||
MsgBox("Standort vom Abgangsort kann nicht ermittelt werden!" & vbCr & "Bitte Eingabe " & txbVonPLZ._value & " " & txbVonOrt._value & " prüfen")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim totalDistance = CDbl(distance) + CDbl(distanceEU)
|
||||
|
||||
Dim distanceNotEUpercent = CDbl(distance) * 100 / totalDistance
|
||||
Dim distanceEUpercent = CDbl(distanceEU) * 100 / totalDistance
|
||||
|
||||
Math.Round(distanceNotEUpercent, 2)
|
||||
Math.Round(distanceEUpercent, 2)
|
||||
|
||||
tbEUAnteil._value = CDbl(distanceEUpercent) / 100
|
||||
tbNichtEUAnteil._value = CDbl(distanceNotEUpercent) / 100
|
||||
|
||||
Catch ex As Exception
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
|
||||
|
||||
ElseIf ckbManAnteilsermittlung.Checked Then
|
||||
|
||||
VERAG_PROG_ALLGEMEIN.cGoogleAPI.GoogleDistance(origin, destination, duration, distance)
|
||||
|
||||
tbEUAnteil._value = 0.6
|
||||
tbNichtEUAnteil._value = 0.4
|
||||
|
||||
lblDistanzEU.Text = "Distanz"
|
||||
txbCalcDistanceEU._value = distance
|
||||
lblDistanzNichtEU.Visible = False
|
||||
txbCalcDistanceNichtEU.Visible = False
|
||||
|
||||
Else
|
||||
|
||||
lblDistanzEU.Text = "Distanz"
|
||||
txbCalcDistanceEU._value = distance
|
||||
lblDistanzNichtEU.Visible = False
|
||||
txbCalcDistanceNichtEU.Visible = False
|
||||
|
||||
End If
|
||||
|
||||
|
||||
End Sub
|
||||
@@ -60,46 +147,93 @@ Public Class frmFrachtkostenBerechnen
|
||||
Try
|
||||
gesamtFrachtkosten = gewicht * CDbl(txbFactor._value)
|
||||
tbxGesamtfrachtkosten._value = gesamtFrachtkosten
|
||||
EUAnteil = gesamtFrachtkosten * tbEUAnteil._value / 100
|
||||
nichtEUAnteil = gesamtFrachtkosten * tbNichtEUAnteil._value / 100
|
||||
EUAnteil = gesamtFrachtkosten * tbEUAnteil._value
|
||||
nichtEUAnteil = gesamtFrachtkosten * CDbl(tbNichtEUAnteil._value)
|
||||
tbEUAnteilberechnet._value = CStr(EUAnteil)
|
||||
tbNichtEUAnteilberechnet._value = CStr(nichtEUAnteil)
|
||||
|
||||
Catch ex As Exception
|
||||
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
Sub checkInputFields()
|
||||
Function checkInputFields() As Boolean
|
||||
|
||||
Dim isFilled As Boolean = True
|
||||
|
||||
lblWarningAbgangort.Visible = False
|
||||
lblWarningBestimmungsort.Visible = False
|
||||
lblWarningEUAnteil.Visible = False
|
||||
lblWarningNichtEUAnteil.Visible = False
|
||||
btnOK.DialogResult = DialogResult.OK
|
||||
|
||||
If (tbEUAnteil._value = "" Or Not IsNumeric(tbEUAnteil._value)) Then
|
||||
'Hinweis INPUT false
|
||||
lblWarningEUAnteil.Visible = True
|
||||
btnOK.DialogResult = DialogResult.OK
|
||||
isFilled = False
|
||||
End If
|
||||
|
||||
If (tbNichtEUAnteil._value = "" Or Not IsNumeric(tbNichtEUAnteil._value)) Then
|
||||
'Hinweis INPUT false
|
||||
lblWarningNichtEUAnteil.Visible = True
|
||||
btnOK.DialogResult = DialogResult.OK
|
||||
isFilled = False
|
||||
End If
|
||||
|
||||
If (txbFactor._value = "" Or Not IsNumeric(txbFactor._value)) Then
|
||||
'Hinweis INPUT false
|
||||
End If
|
||||
|
||||
If (txbVonOrt._value = "" Or txbVonPLZ._value = "") Then
|
||||
lblWarningAbgangort.Visible = True
|
||||
btnOK.DialogResult = DialogResult.OK
|
||||
isFilled = False
|
||||
End If
|
||||
|
||||
End Sub
|
||||
If (txbNachOrt._value = "" Or txbNachPLZ._value = "") Then
|
||||
lblWarningBestimmungsort.Visible = True
|
||||
btnOK.DialogResult = DialogResult.OK
|
||||
isFilled = False
|
||||
End If
|
||||
|
||||
Return isFilled
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
|
||||
resetInputFIeld()
|
||||
|
||||
If (checkInputFields() = False) Then Exit Sub
|
||||
calculateFreight()
|
||||
If (checkInputFields() = False) Then Exit Sub
|
||||
calculateFreightCosts()
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub resetInputFields()
|
||||
txbCalcDistanceEU.Clear()
|
||||
txbCalcDistanceNichtEU.Clear()
|
||||
tbEUAnteilberechnet.Clear()
|
||||
tbNichtEUAnteilberechnet.Clear()
|
||||
If tbEUAnteil._value = "" Then tbEUAnteil._value = 0
|
||||
If tbNichtEUAnteil._value = "" Then tbNichtEUAnteil._value = 0
|
||||
|
||||
|
||||
Private Sub resetInputFIeld()
|
||||
txbCalcDistance._value = ""
|
||||
End Sub
|
||||
|
||||
Private Sub setControlEUAnteile()
|
||||
If ckbManAnteilsermittlung.Checked Then
|
||||
tbEUAnteil.Enabled = False
|
||||
tbNichtEUAnteil.Enabled = False
|
||||
Else
|
||||
tbEUAnteil.Enabled = True
|
||||
tbNichtEUAnteil.Enabled = True
|
||||
resetInputFields()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ckbManAnteilsermittlung_CheckStateChanged(sender As Object, e As EventArgs) Handles ckbManAnteilsermittlung.CheckStateChanged
|
||||
setControlEUAnteile()
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user