Files
SDL/SDL/mdm/SDLLeistungenDetails/cValidationSDLLeistungen.vb
2024-10-02 08:59:41 +00:00

71 lines
1.9 KiB
VB.net

Imports System.Globalization
Public Class cValidationSDLLeistungen
Dim culture As CultureInfo = New CultureInfo("de-DE")
Sub setFalse(o)
Try
If o.GetType.Name = "TextBox" Then
o.BackColor = Color.Red
o.ForeColor = Color.White
End If
Catch ex As Exception
End Try
End Sub
Sub setTrue(o)
Try
If o.GetType.Name = "TextBox" Then
o.BackColor = Color.White
o.ForeColor = Color.Black
End If
Catch ex As Exception
End Try
End Sub
Function checkValidDate(ByVal o As Object, Optional empty As Boolean = False) As Boolean
If empty And o.Text = "" Then Return True
'If o.length < 10 Then Return True
Try
DateTime.ParseExact(o.Text, "dd.MM.yyyy", culture)
setTrue(o)
Return True
Catch ex As Exception
setFalse(o)
Return False
End Try
End Function
Function checkValidDate2(ByVal o As VERAG_PROG_ALLGEMEIN.DateTimePickerEx, Optional empty As Boolean = False) As Boolean
If o.Checked = False Then Return True
' If empty And o.Text = "" Then Return True
'If o.length < 10 Then Return True
Try
DateTime.ParseExact(o.Text, "dd.MM.yyyy", culture)
setTrue(o)
Return True
Catch ex As Exception
setFalse(o)
Return False
End Try
End Function
Function checkValidDateEnd(ByVal o As Object, Optional empty As Boolean = False) As Boolean
If empty And o.Text = "" Then Return True
Try
DateTime.ParseExact(o.Text, "dd.MM.yyyy", culture)
setTrue(o)
Return True
Catch ex As Exception
setFalse(o)
Return False
End Try
End Function
End Class