Erstattunsgsvhreiben, Kundenblatt, Seriendruck, ustva, uta

This commit is contained in:
2024-12-27 17:12:59 +01:00
parent 3b57f8e6ab
commit a4199bf316
16 changed files with 2009 additions and 212 deletions

View File

@@ -831,6 +831,130 @@ Public Class cUTA
End Class
Public Class UTADocuments
Property Id As Integer
Property DocumentName As String
Property DocumentTyp As String
Property Zeitstempel As DateTime
Property daId As Integer
Property KundenNr As Integer
Property RechnungsNr As String
Property Datum As Object = Nothing
Public hasEntry = False
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Sub New(Id)
Me.Id = Id
LOAD()
End Sub
Sub New()
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("DocumentName", DocumentName))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DocumentTyp", DocumentTyp))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Zeitstempel", Zeitstempel))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("daId", daId))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("KundenNr", KundenNr))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("RechnungsNr", RechnungsNr))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Datum", 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 tblUTADocuments WHERE Datum=@Datum AND KundenNr = @KundenNr AND RechnungsNr=@RechnungsNr ) " &
" 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 tblUTADocuments 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.MethodBase.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 tblUTADocuments SET " & str & " WHERE Datum=@Datum AND KundenNr = @KundenNr AND RechnungsNr=@RechnungsNr")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.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 tblUTADocuments (" & str & ") VALUES(" & values & ") ")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name)
End Try
Return ""
End Function
End Class
Public Function readAndSaveUTA(objFileRead As StreamReader, fi As FileInfo, cnt As Integer, Optional onlyTestkunedn As Boolean = False) As Boolean