215 lines
8.6 KiB
VB.net
215 lines
8.6 KiB
VB.net
|
|
Imports System.Data.SqlClient
|
|
Imports System.Reflection
|
|
|
|
Public Class cMDM_Bankspesen
|
|
Property id As Integer
|
|
Property kundenNr As Object = Nothing
|
|
Property umsatzID As Object = Nothing
|
|
Property buchungstext As Object = Nothing
|
|
Property datum As Object = Nothing
|
|
Property IBAN As Object = Nothing
|
|
Property BIC As Object = Nothing
|
|
Property waehrung As Object = Nothing
|
|
Property betrag As Object = Nothing
|
|
Property gebuehr As Object = Nothing
|
|
Property timestamp As Object = Nothing
|
|
Property kontoauszug As Object = Nothing
|
|
Property typ As Object = Nothing
|
|
Property verrechnet As Object = Nothing
|
|
Property RK_ID As Object = Nothing
|
|
Property SR_datum As Object = Nothing
|
|
|
|
|
|
Public hasEntry = False
|
|
|
|
Dim SQL As New SQL
|
|
|
|
Sub New(id)
|
|
Me.id = id
|
|
LOAD()
|
|
End Sub
|
|
|
|
Sub New(kundennr, datum, typ)
|
|
Me.kundenNr = kundennr
|
|
Me.datum = datum
|
|
Me.typ = typ
|
|
LOAD(kundennr, datum, typ)
|
|
|
|
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("id", id,, True))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("kundenNr", kundenNr))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("umsatzID", umsatzID))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("buchungstext", buchungstext))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("datum", datum))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("IBAN", IBAN))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("BIC", BIC))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("waehrung", waehrung))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("betrag", betrag))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("timestamp", timestamp))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("gebuehr", gebuehr))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("kontoauszug", kontoauszug))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("typ", typ))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("verrechnet", verrechnet))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("RK_ID", RK_ID))
|
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("SR_datum", SR_datum))
|
|
|
|
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 tblMDM_Bankspesen WHERE id=@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 tblMDM_Bankspesen WHERE id=@id ", conn)
|
|
cmd.Parameters.AddWithValue("@id", 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
|
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
|
End Try
|
|
End Sub
|
|
|
|
Public Sub LOAD(kundennr, BelegNr, typ)
|
|
Try
|
|
hasEntry = False
|
|
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
|
|
Using cmd As New SqlCommand("SELECT * FROM tblMDM_Bankspesen WHERE kundennr=@kundennr and datum=@datum and typ=@typ ", conn)
|
|
cmd.Parameters.AddWithValue("@kundennr", kundennr)
|
|
cmd.Parameters.AddWithValue("@datum", datum)
|
|
cmd.Parameters.AddWithValue("@typ", typ)
|
|
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 [tblMDM_Bankspesen] SET " & str & " WHERE id=@id ")
|
|
|
|
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 tblMDM_Bankspesen (" & 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
|
|
|
|
|
|
'Public Shared Function GET_NICHTABGERECHNETE_ZB(ByRef dt As DataTable, KundenNr As Integer) As Boolean
|
|
' Try
|
|
' Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
|
|
|
' Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
|
|
|
|
' Using cmd As New SqlCommand("SELECT id,belegNr,belegDatum,buchungstext,zahlungsBetrag,zahlungDatum, ueberschreitungInTagen, zinssatz,zinsbetrag, zahlungsperiode_start,zahlungsperiode_ende, faelligkeitsDatum
|
|
|
|
' FROM
|
|
' tblMDM_Zinsberechnung
|
|
' WHERE
|
|
' kundenNr = @KundenNr
|
|
' AND zinsbetrag <> 0
|
|
' AND verrechnet is null
|
|
' AND left(buchungstext,6) <> 'Zinsen'
|
|
' ORDER BY
|
|
' belegDatum", conn)
|
|
|
|
' cmd.Parameters.AddWithValue("@KundenNr", KundenNr)
|
|
|
|
' Dim dr = cmd.ExecuteReader()
|
|
' dt.Load(dr)
|
|
' 'While dr.Read
|
|
' ' dt.Load(dr)
|
|
' 'End While
|
|
' dr.Close()
|
|
|
|
' End Using
|
|
' End Using
|
|
' Return True
|
|
' Catch ex As Exception
|
|
' VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
|
' End Try
|
|
' Return False
|
|
|
|
'End Function
|
|
|
|
End Class
|