Initial
This commit is contained in:
131
Backup/Common/Tools.vb
Normal file
131
Backup/Common/Tools.vb
Normal file
@@ -0,0 +1,131 @@
|
||||
'''<summary>Diese klasse beinhaltet Methoden, welche im gesamten Edoka über alle Layers verwendet werden</summary>
|
||||
Public Class Tools
|
||||
|
||||
Public Shared Function CToInt16(ByVal o As Object) As Int16
|
||||
If o Is System.DBNull.Value Then
|
||||
Return 0
|
||||
Else
|
||||
If TypeOf o Is Int16 Then
|
||||
Return CShort(o)
|
||||
End If
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Shared Function CToInt32(ByVal o As Object) As Int32
|
||||
If o Is System.DBNull.Value Then
|
||||
Return 0
|
||||
Else
|
||||
If TypeOf o Is Int32 Then
|
||||
Return CInt(o)
|
||||
End If
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Shared Function CToInt64(ByVal o As Object) As Int64
|
||||
If o Is System.DBNull.Value Then
|
||||
Return 0
|
||||
Else
|
||||
If TypeOf o Is Int64 Then
|
||||
Return CLng(o)
|
||||
End If
|
||||
End If
|
||||
End Function
|
||||
|
||||
|
||||
Public Shared Function CToSingle(ByVal o As Object) As Single
|
||||
If o Is System.DBNull.Value Then
|
||||
Return 0
|
||||
Else
|
||||
If TypeOf o Is Single Then
|
||||
Return CSng(o)
|
||||
End If
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Shared Function CToDouble(ByVal o As Object) As Double
|
||||
If o Is System.DBNull.Value Then
|
||||
Return 0
|
||||
Else
|
||||
If TypeOf o Is Double Then
|
||||
Return CDbl(o)
|
||||
End If
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Shared Function CToDecimal(ByVal o As Object) As Decimal
|
||||
If o Is System.DBNull.Value Then
|
||||
Return 0
|
||||
Else
|
||||
If TypeOf o Is Decimal Then
|
||||
Return CDec(o)
|
||||
End If
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Shared Function CToByte(ByVal o As Object) As Byte
|
||||
If o Is System.DBNull.Value Then
|
||||
Return New Byte()
|
||||
Else
|
||||
If TypeOf o Is Byte Then
|
||||
Return CByte(o)
|
||||
End If
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Shared Function CToByteArr(ByVal o As Object) As Byte()
|
||||
If o Is System.DBNull.Value Then
|
||||
Return New Byte() {}
|
||||
Else
|
||||
If TypeOf o Is Byte() Then
|
||||
Return CType(o, Byte())
|
||||
End If
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Shared Function CToString(ByVal o As Object) As String
|
||||
If o Is System.DBNull.Value Then
|
||||
Return ""
|
||||
Else
|
||||
If TypeOf o Is String Then
|
||||
Return CStr(o)
|
||||
End If
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Shared Function CToBool(ByVal o As Object) As Boolean
|
||||
If o Is System.DBNull.Value Then
|
||||
Return False
|
||||
Else
|
||||
If TypeOf o Is Boolean Then
|
||||
Return CBool(o)
|
||||
End If
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Shared Function CToDateTime(ByVal o As Object) As DateTime
|
||||
If o Is System.DBNull.Value Then
|
||||
Return DateTime.MinValue
|
||||
Else
|
||||
If TypeOf o Is DateTime Then
|
||||
Return CDate(o)
|
||||
End If
|
||||
End If
|
||||
End Function
|
||||
|
||||
'''<summary>Überprüft TableCount und RowCount eines DataSet</summary>
|
||||
'''<param name="ds"></param>
|
||||
'''<returns>True wenn table- und rowcount > 0</returns>
|
||||
Public Shared Function ValidateDS(ByVal ds As DataSet) As Boolean
|
||||
Try
|
||||
If ds.Tables.Count > 0 Then
|
||||
If ds.Tables(0).Rows.Count > 0 Then
|
||||
Return True
|
||||
End If
|
||||
End If
|
||||
Return False
|
||||
Catch ex As Exception
|
||||
TKBLib.Errorhandling.TraceHelper.Msg("EDOKALib.Common.Tools.ValidateDS", ex.Message + " " + ex.StackTrace, TraceLevel.Error)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user