TimasAPI, Ueberstundenprotokollierung, etc.
This commit is contained in:
142
VERAG_PROG_ALLGEMEIN/Classes/cUeberstunden.vb
Normal file
142
VERAG_PROG_ALLGEMEIN/Classes/cUeberstunden.vb
Normal file
@@ -0,0 +1,142 @@
|
||||
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Reflection
|
||||
|
||||
Public Class cUeberstunden
|
||||
|
||||
Property uest_id As Integer
|
||||
Property uest_maId As Object = Nothing
|
||||
Property uest_timasId As Object = Nothing
|
||||
Property uest_100 As Object = Nothing
|
||||
Property uest_50 As Object = Nothing
|
||||
Property uest_0 As Object = Nothing
|
||||
Property uest_date As Date = Nothing
|
||||
Property uest_created As Object = Nothing
|
||||
Property uest_lastChanged As Object = Nothing
|
||||
Property uest_deleted As Boolean
|
||||
Property uest_systemuser As Object = Nothing
|
||||
|
||||
Public hasEntry = False
|
||||
|
||||
Dim SQL As New SQL
|
||||
|
||||
|
||||
|
||||
Sub New(uest_maId, uest_date)
|
||||
Me.uest_maId = uest_maId
|
||||
Me.uest_date = uest_date
|
||||
LOAD()
|
||||
End Sub
|
||||
|
||||
Sub New(uest_maId, uest_date, uest_created)
|
||||
Me.uest_maId = uest_maId
|
||||
Me.uest_date = uest_date
|
||||
Me.uest_created = uest_created
|
||||
End Sub
|
||||
|
||||
Function getParameterList() As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
|
||||
Dim list As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("uest_id", uest_id,, True, True))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("uest_maId", uest_maId))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("uest_timasId", uest_timasId))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("uest_100", uest_100))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("uest_50", uest_50))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("uest_0", uest_0))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("uest_date", uest_date))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("uest_created", uest_created))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("uest_lastChanged", uest_lastChanged))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("uest_deleted", uest_deleted))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("uest_systemuser", uest_systemuser))
|
||||
|
||||
Return list
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Public Function SAVE() As Boolean
|
||||
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
||||
|
||||
Dim sqlstr = " BEGIN TRAN IF EXISTS(SELECT * FROM tblUeberstunden WHERE uest_maId=@uest_maId AND uest_date=@uest_date AND uest_deleted = 0) " &
|
||||
" BEGIN " & getUpdateCmd() & " END " &
|
||||
" Else " &
|
||||
" BEGIN " & getInsertCmd() & " END " &
|
||||
" commit tran "
|
||||
|
||||
Return SQL.doSQLVarList(sqlstr, "ADMIN", , list)
|
||||
End Function
|
||||
|
||||
Public Sub LOAD()
|
||||
Try
|
||||
hasEntry = False
|
||||
Using conn As SqlConnection = SQL.GetNewOpenConnectionADMIN()
|
||||
Using cmd As New SqlCommand("SELECT TOP(1) * FROM tblUeberstunden WHERE uest_maId=@uest_maId AND uest_date=@uest_date AND uest_deleted = 0 order by uest_created desc", conn)
|
||||
cmd.Parameters.AddWithValue("@uest_maId", uest_maId)
|
||||
cmd.Parameters.AddWithValue("@uest_date", uest_date)
|
||||
Dim dr = cmd.ExecuteReader()
|
||||
If dr.Read Then
|
||||
For Each li In getParameterList()
|
||||
Dim propInfo As PropertyInfo = Me.GetType.GetProperty(li.Scalarvariable)
|
||||
|
||||
If dr.Item(li.Text) Is DBNull.Value Then
|
||||
propInfo.SetValue(Me, Nothing)
|
||||
Else
|
||||
propInfo.SetValue(Me, dr.Item(li.Text))
|
||||
End If
|
||||
|
||||
Next
|
||||
hasEntry = True
|
||||
End If
|
||||
dr.Close()
|
||||
End Using
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Public Function getUpdateCmd() As String
|
||||
Try
|
||||
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
||||
|
||||
|
||||
Dim str As String = ""
|
||||
For Each i In list
|
||||
If Not i.isPrimaryParam Then
|
||||
str &= "[" & i.Text & "] = @" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
|
||||
End If
|
||||
Next
|
||||
str = str.Substring(0, str.Length - 1) 'wg. ','
|
||||
Return (" UPDATE [tblUeberstunden] SET " & str & " WHERE uest_maId=@uest_maId AND uest_date=@uest_date AND uest_deleted = 0 ")
|
||||
|
||||
Catch ex As Exception
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
Return ""
|
||||
End Function
|
||||
|
||||
|
||||
Public Function getInsertCmd() As String
|
||||
Try
|
||||
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
||||
Dim str As String = ""
|
||||
Dim values As String = ""
|
||||
For Each i In list
|
||||
If Not i.isPrimaryParam Then
|
||||
str &= "[" & i.Text & "],"
|
||||
values &= "@" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
|
||||
End If
|
||||
Next
|
||||
str = str.Substring(0, str.Length - 1) 'wg. ','
|
||||
values = values.Substring(0, values.Length - 1) 'wg. ','
|
||||
Return (" INSERT INTO tblUeberstunden (" & str & ") VALUES(" & values & ") ")
|
||||
Catch ex As Exception
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
Return ""
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user