jj 03.02 Rename RecordOrganiser to RecordOrganizer
This commit is contained in:
55
app/DD-Record-Organizer/ClassControlValueCache.vb
Normal file
55
app/DD-Record-Organizer/ClassControlValueCache.vb
Normal file
@@ -0,0 +1,55 @@
|
||||
Public Class ClassControlValueCache
|
||||
Private Shared Property Cache As New Dictionary(Of String, DataTable)
|
||||
|
||||
' ClassControlValueCache
|
||||
' Ordnet SQL Queries den daraus resultierenden DataTables zu.
|
||||
'
|
||||
' Somit kann eine Query in der Laufzeit des Programms von mehreren Forms genutzt werden,
|
||||
' muss aber nur einmal vom Server abgefragt werden.
|
||||
Public Shared Function LoadFromCache(sqlCommand As String) As DataTable
|
||||
' Mit ToUpper wird das Command case-insensitive,
|
||||
' es ist also egal, ob die query GROSS oder klein geschrieben wird
|
||||
Dim UpperCaseCommand = sqlCommand.ToUpper()
|
||||
|
||||
If Cache.ContainsKey(UpperCaseCommand) Then
|
||||
Return Cache.Item(UpperCaseCommand)
|
||||
Else
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
Public Shared Sub SaveToCache(sqlCommand As String, dt As DataTable)
|
||||
Dim UpperCaseCommand = sqlCommand.ToUpper()
|
||||
|
||||
' Dynamische Queries dürfen nicht gecached werden
|
||||
If (UpperCaseCommand.Contains("@")) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Cache.Item(UpperCaseCommand) = dt
|
||||
End Sub
|
||||
|
||||
Public Shared Sub ClearCache()
|
||||
Cache.Clear()
|
||||
End Sub
|
||||
|
||||
' =========================================================================================
|
||||
|
||||
Private Shared Property HintCache As New Dictionary(Of Integer, String)
|
||||
Public Shared Function LoadHint(controlId As Integer) As String
|
||||
If HintCache.ContainsKey(controlId) Then
|
||||
Dim hint As String = HintCache.Item(controlId)
|
||||
If hint.Length = 0 Then
|
||||
Return Nothing
|
||||
End If
|
||||
Return HintCache.Item(controlId)
|
||||
Else
|
||||
Return Nothing
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Shared Sub SaveHint(controlId As Integer, hint As String)
|
||||
HintCache.Item(controlId) = hint
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user