Imports System.CodeDom Imports DocumentFormat.OpenXml.Bibliography Imports Org.BouncyCastle.Utilities Public Class frmRoutendauerBerechnen Public calculatedDate As New DateTime Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL Dim destination As String = "" Dim departure As String Dim transportmittel As String = "LKW" Dim days As Integer = -1 Sub New(dest As String) InitializeComponent() destination = dest End Sub Private Sub frmRoutendauerBerechnen_Load(sender As Object, e As EventArgs) Handles MyBase.Load txtNach.Text = destination.ToString txbAbgangsdatum._value = CStr(Date.Today()) initCheckBoxDepartment() End Sub Sub initCheckBoxDepartment() cbxVon.Items.Clear() cbxVon.fillWithSQL("SELECT [nctsr_dauer_in_tagen], [nctsr_von] FROM [tblNTCSRouten] WHERE [nctsr_nach] = '" & destination & "'", False, "FMZOLL", False) cbxVon.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("", "")) cbxVon.changeItem("") End Sub Private Sub btnPlus_Click(sender As Object, e As EventArgs) Handles btnPlus.Click 'addDaysToGivenDate(1) addDaysToGivenDate2(datVoraussichtlichesEintreffen, 1) End Sub Private Sub btnMinus_Click(sender As Object, e As EventArgs) Handles btnMinus.Click addDaysToGivenDate2(datVoraussichtlichesEintreffen, -1) 'addDaysToGivenDate(-1) End Sub Function calculateTripDuration() As Integer Dim destination As String Dim departure As String departure = cbxVon.Text destination = txtNach.Text Try days = CInt(SQL.DLookup("nctsr_dauer_in_tagen", "tblNTCSRouten", "[nctsr_von]='" & departure & "' AND [nctsr_nach]= '" & destination & "' AND [nctsr_route]= 'Landweg' AND [nctsr_tansportmittel]= '" & transportmittel & "'", "VERAG", -1)) Catch ex As Exception VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) End Try Return days End Function Private Sub cbxVon_SelectedValueChanged(sender As Object, e As EventArgs) Handles cbxVon.SelectedValueChanged departure = cbxVon.Text Dim calculatedDuration = calculateTripDuration() If calculatedDuration > 0 Then addDaysToGivenDate2(txbAbgangsdatum, calculatedDuration) End If End Sub Private Sub addDaysTocurrentDate(days As Integer) datVoraussichtlichesEintreffen._value = Convert.ToDateTime(txbAbgangsdatum._value).AddDays(days) datVoraussichtlichesEintreffen.Show() End Sub Private Sub addDaysToGivenDate(days As Integer) datVoraussichtlichesEintreffen._value = Convert.ToDateTime(datVoraussichtlichesEintreffen._value).AddDays(days) datVoraussichtlichesEintreffen.Show() End Sub Private Sub addDaysToGivenDate2(givenDate As VERAG_PROG_ALLGEMEIN.MyTextBox, days As Integer) datVoraussichtlichesEintreffen._value = Convert.ToDateTime(givenDate._value).AddDays(days) datVoraussichtlichesEintreffen.Show() End Sub Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click calculatedDate = CDate(datVoraussichtlichesEintreffen._value) Close() End Sub Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click Close() End Sub Private Sub txbAbgangsdatum_TextChanged(sender As Object, e As EventArgs) Handles txbAbgangsdatum.TextChanged If days > 0 Then addDaysToGivenDate2(txbAbgangsdatum, days) End If End Sub End Class