KundenUID
This commit is contained in:
125
VERAG_PROG_ALLGEMEIN/Classes/cKundenveranlagungUID.vb
Normal file
125
VERAG_PROG_ALLGEMEIN/Classes/cKundenveranlagungUID.vb
Normal file
@@ -0,0 +1,125 @@
|
||||
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Reflection
|
||||
|
||||
Public Class cKundenveranlagungUID
|
||||
Property kdNr As Integer
|
||||
Property UstIdKz As Object = Nothing
|
||||
Property UstIdNr As Object = Nothing
|
||||
Property UstIdGeprüft As Object = Nothing
|
||||
|
||||
Public hasEntry = False
|
||||
|
||||
Dim SQL As New SQL
|
||||
|
||||
|
||||
Sub New(kdNr, UstIdKz)
|
||||
Me.kdNr = kdNr
|
||||
Me.UstIdKz = UstIdKz
|
||||
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("kdNr", kdNr))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UstIdKz", UstIdKz))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UstIdNr", UstIdNr))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("UstIdGeprüft", UstIdGeprüft))
|
||||
|
||||
Return list
|
||||
End Function
|
||||
|
||||
|
||||
Shared Sub LOAD_LIST_ByKdNr(ByRef UID_LIST As List(Of cKundenveranlagungUID), kdNr As Integer)
|
||||
If UID_LIST Is Nothing Then UID_LIST = New List(Of cKundenveranlagungUID)
|
||||
UID_LIST.Clear()
|
||||
Dim SQL As New SQL
|
||||
For Each r In SQL.loadDgvBySql("SELECT UstIdKz FROM tblKundenveranlagungUID WHERE kdNr=" & kdNr, "AVISO").Rows
|
||||
UID_LIST.Add(New VERAG_PROG_ALLGEMEIN.cKundenveranlagungUID(kdNr, r("UstIdKz")))
|
||||
Next
|
||||
End Sub
|
||||
|
||||
|
||||
Public Function SAVE() As Boolean
|
||||
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
||||
|
||||
Dim sqlstr = " BEGIN TRAN IF EXISTS(SELECT * FROM tblKundenveranlagungUID WHERE kdNr=@kdNr and UstIdKz = @UstIdKz) " &
|
||||
" 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 tblKundenveranlagungUID WHERE kdNr=@kdNr and UstIdKz = @UstIdKz ", conn)
|
||||
cmd.Parameters.AddWithValue("@kdNr", kdNr)
|
||||
cmd.Parameters.AddWithValue("@UstIdKz", UstIdKz)
|
||||
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 [tblKundenveranlagungUID] SET " & str & " WHERE kdNr=@kdNr and UstIdKz = @UstIdKz ")
|
||||
|
||||
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 tblKundenveranlagungUID (" & 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