341 lines
12 KiB
VB.net
341 lines
12 KiB
VB.net
|
|
Imports System.Security.Authentication.ExtendedProtection
|
|
Imports DocumentFormat.OpenXml.Drawing
|
|
Imports GrapeCity.ActiveReports.Document.Section
|
|
Imports VERAG_PROG_ALLGEMEIN
|
|
|
|
|
|
Public Class frmNCTSRouten
|
|
|
|
Dim routenId As Integer = -1
|
|
Dim 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()
|
|
|
|
initDGVRouten()
|
|
|
|
'Abgangszollstelle/Gebiet - woher kommt der LKW
|
|
cbxVon.Items.Clear()
|
|
cbxVon.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("", ""))
|
|
cbxVon.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Istanbul", "TR341300"))
|
|
cbxVon.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("München", "DE001526"))
|
|
cbxVon.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Ankara", "TR061500"))
|
|
'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 - an Welcher Zollstelle kommt der LKW
|
|
cbxNach.Items.Clear()
|
|
cbxNach.fillWithSQL("SELECT [grz_ZollamtDST],[grz_Grenzstelle] 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("")
|
|
|
|
cbxTransportmittel.Items.Clear()
|
|
cbxTransportmittel.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("LKW", "LKW"))
|
|
'aktuell nur der Defaultwert "LKW" verfügbar!
|
|
cbxTransportmittel.changeItem("LKW")
|
|
|
|
|
|
txtDauer.Text = ""
|
|
txtVon.Text = ""
|
|
txtVonRegion.Text = ""
|
|
|
|
txtNach.Text = ""
|
|
|
|
dgvNCTSRouten.ClearSelection()
|
|
DisableUserControl()
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Sub initDGVRouten()
|
|
|
|
dgvNCTSRouten.Enabled = True
|
|
|
|
With dgvNCTSRouten
|
|
|
|
.Columns.Clear()
|
|
|
|
.DataSource = sql.loadDgvBySql("SELECT [nctsr_id],[nctsr_von],[nctsr_von_region],[nctsr_nach],[nctsr_dauer_in_tagen],[nctsr_route], [nctsr_transportmittel] FROM [VERAG].[dbo].[tblNTCSRouten]",
|
|
"VERAG")
|
|
|
|
' .RowTemplate.Height = 30
|
|
.Columns("nctsr_id").Visible = False
|
|
.Columns("nctsr_von").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
|
|
.Columns("nctsr_von").HeaderText = "Von"
|
|
.Columns("nctsr_von_region").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
|
|
.Columns("nctsr_von_region").HeaderText = "Herkunftsregion"
|
|
.Columns("nctsr_nach").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
|
|
.Columns("nctsr_nach").HeaderText = "Nach"
|
|
.Columns("nctsr_dauer_in_tagen").Visible = True
|
|
.Columns("nctsr_dauer_in_tagen").Width = 50
|
|
.Columns("nctsr_dauer_in_tagen").HeaderText = "Dauer"
|
|
.Columns("nctsr_dauer_in_tagen").DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter
|
|
.Columns("nctsr_route").Visible = True
|
|
.Columns("nctsr_route").Width = 100
|
|
.Columns("nctsr_route").HeaderText = "Route"
|
|
.Columns("nctsr_route").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft
|
|
.Columns("nctsr_transportmittel").HeaderText = "Transportmittel"
|
|
.Columns("nctsr_transportmittel").DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter
|
|
|
|
|
|
|
|
End With
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub saveRoute(curRoute As cNCTSRouten)
|
|
|
|
curRoute.nctsr_von = txtVon._value.ToString 'IIf(sbxVon._value Is Nothing Or sbxVon._value = "", cbxVon._value, sbxVon._value)
|
|
curRoute.nctsr_von_region = txtVonRegion._value.ToString
|
|
curRoute.nctsr_nach = txtNach._value.ToString 'IIf(sbxNach._value Is Nothing Or sbxNach._value = "", cbxNach._value, sbxNach._value)
|
|
curRoute.nctsr_route = cbxRoutenart._value
|
|
curRoute.nctsr_dauer_in_tagen = CInt(txtDauer.Text)
|
|
curRoute.nctsr_transportmittel = cbxTransportmittel._value
|
|
If Not curRoute.SAVE() Then
|
|
Me.DialogResult = Windows.Forms.DialogResult.None
|
|
End If
|
|
|
|
dgvNCTSRouten.GetOrder()
|
|
initDGVRouten()
|
|
dgvNCTSRouten.SetOrder()
|
|
|
|
setOKButton()
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub btnNeu_Click(sender As Object, e As EventArgs) Handles btnNeu.Click
|
|
|
|
dgvNCTSRouten.ClearSelection()
|
|
|
|
dgvNCTSRouten.Enabled = False
|
|
|
|
currentRoute = New VERAG_PROG_ALLGEMEIN.cNCTSRouten With {
|
|
.nctsr_von = "",
|
|
.nctsr_von_region = "",
|
|
.nctsr_nach = "",
|
|
.nctsr_dauer_in_tagen = 0,
|
|
.nctsr_route = "",
|
|
.nctsr_transportmittel = ""
|
|
}
|
|
loadChangedDSToPanel(currentRoute)
|
|
EnableUserControl()
|
|
setSaveButton()
|
|
|
|
End Sub
|
|
|
|
Sub setSaveButton()
|
|
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)
|
|
|
|
|
|
txtVon.Text = curRoute.nctsr_von.ToString
|
|
txtVonRegion.Text = curRoute.nctsr_von_region.ToString
|
|
txtNach.Text = curRoute.nctsr_nach.ToString
|
|
|
|
cbxRoutenart._value = curRoute.nctsr_route.ToString
|
|
txtDauer.Text = curRoute.nctsr_dauer_in_tagen.ToString
|
|
cbxTransportmittel._value = curRoute.nctsr_transportmittel.ToString
|
|
|
|
For Each c As Control In pnlNCTSRouten.Controls
|
|
If TypeOf (c) Is CheckBox Then
|
|
AddHandler CType(c, ComboBox).SelectedValueChanged, AddressOf SomethingChanged
|
|
ElseIf TypeOf (c) Is TextBox Then
|
|
AddHandler CType(c, TextBox).TextChanged, AddressOf SomethingChanged
|
|
End If
|
|
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 btnOK.Click
|
|
Close()
|
|
|
|
End Sub
|
|
|
|
Private Sub btn_Cancel_Click(sender As Object, e As EventArgs) Handles btn_Cancel.Click
|
|
Close()
|
|
End Sub
|
|
|
|
Private Sub EnableUserControl()
|
|
|
|
For Each c As Control In pnlNCTSRouten.Controls
|
|
c.Enabled = True
|
|
Next
|
|
|
|
End Sub
|
|
|
|
Private Sub DisableUserControl()
|
|
|
|
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
|
|
|
|
|
|
If dgvNCTSRouten.SelectedRows.Count > 0 Then
|
|
EnableUserControl()
|
|
Dim rowindex = dgvNCTSRouten.SelectedRows(0).Index
|
|
currentRoute = New VERAG_PROG_ALLGEMEIN.cNCTSRouten(dgvNCTSRouten.SelectedRows(0).Cells("nctsr_id").Value)
|
|
|
|
loadChangedDSToPanel(currentRoute)
|
|
cbxVon.changeItem("")
|
|
cbxNach.changeItem("")
|
|
|
|
|
|
If dgvNCTSRouten.Enabled = False Then Exit Sub
|
|
routenId = dgvNCTSRouten.SelectedRows(0).Cells("nctsr_id").Value
|
|
End If
|
|
|
|
End Sub
|
|
|
|
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
|
|
|
|
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
|
|
If (txtVon._value = "") Then
|
|
lblWarningAZS.Visible = True
|
|
validInputs = False
|
|
End If
|
|
'If (cbxNach._value = "" Or cbxNach._value Is Nothing) Then
|
|
If (txtNach._value = "") 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 (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
|
|
|
|
If cbxTransportmittel._value = "" Or cbxTransportmittel._value Is Nothing Then
|
|
lblWarningTransportmittel.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
|
|
txtVonRegion.Text = cbxVon.Text.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
|
|
txtNach.Text = cbxNach._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
|
|
|
|
Sub cbxNach_ValueChanged() Handles sbxNach.VALUE_CHANGED
|
|
If cbxNach._value = "???" AndAlso sbxNach._value <> "" Then
|
|
txtNach.Text = sbxNach._value
|
|
End If
|
|
End Sub
|
|
|
|
End Class
|
|
|