frmRoutenBerechnung im frmEintragAvios eingebaut, inkl. Berechnungslogik

This commit is contained in:
2022-10-05 17:07:53 +02:00
parent 01b51759b0
commit ed48c0eaef
9 changed files with 892 additions and 121 deletions

View File

@@ -1,36 +1,62 @@

Imports System.Security.Authentication.ExtendedProtection
Imports GrapeCity.ActiveReports.Document.Section
Imports VERAG_PROG_ALLGEMEIN
Public Class frmNCTSRouten
Dim routenId As Integer = -1
Private sql As New VERAG_PROG_ALLGEMEIN.SQL
Dim currentRoute As New VERAG_PROG_ALLGEMEIN.cNCTSRouten
Public FIRMA_TMP As String = VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA
Private Sub frmNCTSRouten_Load(sender As Object, e As EventArgs) Handles MyBase.Load
init()
End Sub
Sub init()
btn_OK.Text = "OK"
initDGVRouten()
'Abgangszollstelle
cbxVon.Items.Clear()
cbxVon.fillWithSQL("SELECT [grz_Grenzstelle],[grz_BezeichnungCBO] FROM tblGrenzstelle where [grz_Firma]='" & FIRMA_TMP & "' OR grz_Cluster='" & VERAG_PROG_ALLGEMEIN.cAllgemein.CLUSTER & "' AND grz_Aktiv=1 order by grz_Reihenfolge, grz_Grenzstelle", False, "AVISO", True,)
cbxVon.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("???", "???"))
cbxVon.changeItem("")
sbxVon.initSearchBox(Me.FindForm, "[Code] ,[Code] as Nr,Description as Dienststelle,left(Code,2) as Land,[Description] +' (' +left(Code,2)+')' as display FROM [tbl_DY_ZollDE_C0141_Zollstellen]",
{" [Code]", "Description"},
" (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ",
" left(Code,2),[Description]", "Code", "display", "FMZOLL", , 400, 200, {"display", "Code"})
'Bestimmungszollstelle
cbxNach.Items.Clear()
cbxNach.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("", ""))
cbxNach.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Suben", "SUB"))
cbxNach.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Salzburg", "SBG"))
cbxNach.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Waidhofen", "WAI"))
cbxNach.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Nickelsdorf", "NKD"))
cbxNach.fillWithSQL("SELECT [grz_Grenzstelle],[grz_BezeichnungCBO] FROM tblGrenzstelle where [grz_Firma]='" & FIRMA_TMP & "' OR grz_Cluster='" & VERAG_PROG_ALLGEMEIN.cAllgemein.CLUSTER & "' AND grz_Aktiv=1 order by grz_Reihenfolge, grz_Grenzstelle", False, "AVISO", True,)
cbxNach.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("???", "???"))
cbxNach.changeItem("")
sbxNach.initSearchBox(Me.FindForm, "[Code] ,[Code] as Nr,Description as Dienststelle,left(Code,2) as Land,[Description] +' (' +left(Code,2)+')' as display FROM [tbl_DY_ZollDE_C0141_Zollstellen]",
{" [Code]", "Description"},
" (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ",
" left(Code,2),[Description]", "Code", "display", "FMZOLL", , 400, 200, {"display", "Code"})
cbxRoutenart.Items.Clear()
cbxRoutenart.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("", ""))
cbxRoutenart.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Landweg", "Landweg"))
cbxRoutenart.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Seeweg", "Seeweg"))
cbxRoutenart.changeItem("")
sbxVon.initSearchBox(Me.FindForm, "[Code] ,[Code] as Nr,Description as Dienststelle,left(Code,2) as Land,[Description] +' (' +left(Code,2)+')' as display FROM [tbl_DY_ZollDE_C0141_Zollstellen]", {" [Code]", "Description"}, " (StartDate is null OR StartDate< GETDATE()) AND (EndDate is null OR EndDate> GETDATE()) ", " left(Code,2),[Description]", "Code", "display", "FMZOLL", , 400, 200, {"display", "Code"})
txtDauer.Text = ""
txtVon.Text = ""
txtNach.Text = ""
dgvNCTSRouten.ClearSelection()
DisableUserControl()
@@ -47,7 +73,7 @@ Public Class frmNCTSRouten
.Columns.Clear()
.DataSource = sql.loadDgvBySql("SELECT [nctsr_id],[nctsr_von],[nctsr_nach],[nctsr_dauer_in_tagen],[nctsr_route] FROM [VERAG].[dbo].[tblNTCSRouten]",
.DataSource = sql.loadDgvBySql("SELECT [nctsr_id],[nctsr_von],[nctsr_nach],[nctsr_dauer_in_tagen],[nctsr_route], [nctsr_tansportmittel] FROM [VERAG].[dbo].[tblNTCSRouten]",
"VERAG")
' .RowTemplate.Height = 30
@@ -64,6 +90,8 @@ Public Class frmNCTSRouten
.Columns("nctsr_route").Width = 100
.Columns("nctsr_route").HeaderText = "Route"
.Columns("nctsr_route").DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter
.Columns("nctsr_tansportmittel").HeaderText = "Transportmittel"
.Columns("nctsr_tansportmittel").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft
@@ -77,8 +105,8 @@ Public Class frmNCTSRouten
Private Sub saveRoute(curRoute As cNCTSRouten)
curRoute.nctsr_von = sbxVon._value
curRoute.nctsr_nach = cbxNach._value
curRoute.nctsr_von = IIf(sbxVon._value Is Nothing, cbxVon._value, sbxVon._value)
curRoute.nctsr_nach = IIf(sbxNach._value Is Nothing, cbxNach._value, sbxNach._value)
curRoute.nctsr_route = cbxRoutenart._value
curRoute.nctsr_dauer_in_tagen = CInt(txtDauer.Text)
@@ -104,7 +132,8 @@ Public Class frmNCTSRouten
.nctsr_von = "",
.nctsr_nach = "",
.nctsr_dauer_in_tagen = 0,
.nctsr_route = "Landweg"
.nctsr_route = "",
.nctsr_tansportmittel = "LKW"
}
loadChangedDSToPanel(currentRoute)
EnableUserControl()
@@ -113,14 +142,20 @@ Public Class frmNCTSRouten
End Sub
Sub setSaveButton()
btn_OK.Text = "Speichern"
btnSave.Visible = True
btnOK.Visible = False
End Sub
Sub setOKButton()
btnSave.Visible = False
btnOK.Visible = True
End Sub
Private Sub loadChangedDSToPanel(curRoute As VERAG_PROG_ALLGEMEIN.cNCTSRouten)
sbxVon.SET_VALUE(curRoute.nctsr_von.ToString)
cbxNach.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem(curRoute.nctsr_nach.ToString, curRoute.nctsr_nach.ToString))
cbxNach._value = curRoute.nctsr_nach.ToString
txtVon.Text = curRoute.nctsr_von.ToString
txtNach.Text = curRoute.nctsr_nach.ToString
cbxRoutenart._value = curRoute.nctsr_route.ToString
txtDauer.Text = curRoute.nctsr_dauer_in_tagen.ToString
@@ -133,18 +168,17 @@ Public Class frmNCTSRouten
Next
End Sub
Private Sub checkDestination()
End Sub
Private Sub SomethingChanged(sender As Object, e As EventArgs)
setSaveButton()
End Sub
Private Sub btn_OK_Click(sender As Object, e As EventArgs) Handles btn_OK.Click
If (btn_OK.Text = "Speichern") Then
saveRoute(currentRoute)
btn_OK.Text = "OK"
Else
Close()
End If
Private Sub btn_OK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
Close()
End Sub
@@ -153,17 +187,19 @@ Public Class frmNCTSRouten
End Sub
Private Sub EnableUserControl()
cbxNach.Enabled = True
cbxRoutenart.Enabled = True
sbxVon.Enabled = True
txtDauer.Enabled = True
For Each c As Control In pnlNCTSRouten.Controls
c.Enabled = True
Next
End Sub
Private Sub DisableUserControl()
cbxNach.Enabled = False
cbxRoutenart.Enabled = False
sbxVon.Enabled = False
txtDauer.Enabled = False
For Each c As Control In pnlNCTSRouten.Controls
c.Enabled = False
Next
End Sub
Private Sub dgvNCTSRouten_SelectionChanged(sender As Object, e As EventArgs) Handles dgvNCTSRouten.SelectionChanged
@@ -174,8 +210,10 @@ Public Class frmNCTSRouten
Dim rowindex = dgvNCTSRouten.SelectedRows(0).Index
currentRoute = New VERAG_PROG_ALLGEMEIN.cNCTSRouten(dgvNCTSRouten.SelectedRows(0).Cells("nctsr_id").Value)
'checkIfValueInComboboxAndAdd(currentRoute)
loadChangedDSToPanel(currentRoute)
If dgvNCTSRouten.Enabled = False Then Exit Sub
routenId = dgvNCTSRouten.SelectedRows(0).Cells("nctsr_id").Value
End If
@@ -184,5 +222,103 @@ Public Class frmNCTSRouten
Private Sub sbxVon_PreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs) Handles sbxVon.PreviewKeyDown
If sender Is sbxVon Then sbxVon.FireReturn() : e.IsInputKey = True : Me.DialogResult = DialogResult.None
If sender Is sbxNach Then sbxNach.FireReturn() : e.IsInputKey = True : Me.DialogResult = DialogResult.None
End Sub
End Class
'Private Sub checkIfValueInComboboxAndAdd(curRoute As cNCTSRouten)
' Dim index As Integer
' Dim inList As Boolean
' inList = False
' For index = 0 To cbxNach.Items.Count - 1
' If curRoute.nctsr_nach.ToString = cbxNach.Items(index).ToString Then
' inList = True
' Exit For
' End If
' Next index
' If inList = False Then cbxNach.Items.Add(curRoute.nctsr_nach.ToString)
'End Sub
Public Function GetTxtDauer() As TextBox
Return txtDauer
End Function
Function checkUserInput(txtDauer As TextBox) As Boolean
Dim validInputs As Boolean = True
lblWarningBST.Visible = False
lblWarningAZS.Visible = False
lblWarningDauer.Visible = False
lblWarningRoute.Visible = False
If (cbxVon._value = "" Or cbxVon._value Is Nothing) Then
lblWarningAZS.Visible = True
validInputs = False
End If
If (cbxNach._value = "" Or cbxNach._value Is Nothing) Then
lblWarningBST.Visible = True
validInputs = False
End If
If (cbxVon._value = "???" AndAlso sbxVon._value Is Nothing) Then
lblWarningAZS.Visible = True
validInputs = False
End If
If (cbxNach._value = "???" AndAlso sbxNach._value Is Nothing) Then
lblWarningAZS.Visible = True
validInputs = False
End If
If (cbxNach._value = "" Or cbxNach._value Is Nothing) Then
lblWarningBST.Visible = True
validInputs = False
End If
If (Not IsNumeric(txtDauer.Text) Or txtDauer.Text = "") Then
lblWarningDauer.Visible = True
validInputs = False
End If
If cbxRoutenart._value = "" Or cbxRoutenart._value Is Nothing Then
lblWarningRoute.Visible = True
validInputs = False
End If
Return validInputs
End Function
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
If checkUserInput(GetTxtDauer()) Then saveRoute(currentRoute)
End Sub
Private Sub cbxVon_SelectedValueChanged(sender As Object, e As EventArgs) Handles cbxVon.SelectedValueChanged
If cbxVon._value.ToString = "???" Then
setSearchboxVisible(sbxVon, True)
Else
txtVon.Text = cbxVon._value.ToString
setSearchboxVisible(sbxVon, False)
sbxVon.Clear()
End If
End Sub
Private Sub cbxNach_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbxNach.SelectedValueChanged
If cbxNach._value.ToString = "???" Then
setSearchboxVisible(sbxNach, True)
Else
txtVon.Text = cbxVon._value.ToString
setSearchboxVisible(sbxNach, False)
sbxNach.Clear()
End If
End Sub
Sub setSearchboxVisible(searchbox As VERAG_PROG_ALLGEMEIN.MySearchBox, visible As Boolean)
searchbox.Visible = visible
End Sub
End Class