167 lines
6.2 KiB
VB.net
167 lines
6.2 KiB
VB.net
Imports System.Data.SqlClient
|
|
Imports System.Reflection
|
|
|
|
Public Class cTranslate_LIST
|
|
|
|
Public list As New List(Of cTranslate)
|
|
Dim trs_progId
|
|
|
|
Sub New(trs_progId)
|
|
Me.trs_progId = trs_progId
|
|
LOAD()
|
|
End Sub
|
|
|
|
Public Sub LOAD()
|
|
Try
|
|
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
|
|
Using cmd As New SqlCommand("SELECT * FROM tblTranslate WHERE trs_progId=@trs_progId and [trs_active]=1 ", conn)
|
|
cmd.Parameters.AddWithValue("@trs_progId", trs_progId)
|
|
Dim dr = cmd.ExecuteReader()
|
|
While dr.Read
|
|
Dim T As New cTranslate
|
|
T.trs_id = dr("trs_id")
|
|
T.trs_progName = dr("trs_progName")
|
|
T.trs_object = dr("trs_object")
|
|
T.trs_control = dr("trs_control")
|
|
T.trs_subControl = dr("trs_subControl")
|
|
T.trs_sprache = dr("trs_sprache")
|
|
T.trs_text = dr("trs_text")
|
|
list.Add(T)
|
|
End While
|
|
dr.Close()
|
|
End Using
|
|
End Using
|
|
Catch ex As Exception
|
|
MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
End Class
|
|
Public Class cTranslate
|
|
Property trs_id As Integer
|
|
Property trs_progId As String
|
|
Property trs_progName As String
|
|
Property trs_object As String
|
|
Property trs_control As String
|
|
Property trs_subControl As Object = Nothing
|
|
Property trs_sprache As String
|
|
Property trs_text As String
|
|
|
|
|
|
Public hasEntry = False
|
|
|
|
Dim SQL As New SQL
|
|
Sub New()
|
|
|
|
End Sub
|
|
Sub New(trs_id)
|
|
Me.trs_id = trs_id
|
|
LOAD()
|
|
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("trs_id", trs_id,, True))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("trs_progId", trs_progId))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("trs_progName", trs_progName))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("trs_object", trs_object))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("trs_control", trs_control))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("trs_subControl", trs_subControl))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("trs_sprache", trs_sprache))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("trs_text", trs_text))
|
|
|
|
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 tblTranslate WHERE trs_id=@trs_id) " &
|
|
" BEGIN " & getUpdateCmd() & " END " &
|
|
" Else " &
|
|
" BEGIN " & getInsertCmd() & " END " &
|
|
" commit tran "
|
|
|
|
Return SQL.doSQLVarList(sqlstr, "FMZOLL", , list)
|
|
End Function
|
|
|
|
Public Sub LOAD()
|
|
Try
|
|
hasEntry = False
|
|
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
|
|
Using cmd As New SqlCommand("SELECT * FROM tblTranslate WHERE trs_id=@trs_id AND [trs_active]=1 ", conn)
|
|
cmd.Parameters.AddWithValue("@trs_id", trs_id)
|
|
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
|
|
MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
|
|
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 [tblTranslate] SET " & str & " WHERE trs_id=@trs_id ")
|
|
|
|
Catch ex As Exception
|
|
MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
|
|
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 tblTranslate (" & str & ") VALUES(" & values & ") ")
|
|
Catch ex As Exception
|
|
MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
|
|
End Try
|
|
Return ""
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
End Class
|