This commit is contained in:
2025-07-20 21:16:01 +02:00
parent f206b96009
commit d079aff6cc
18 changed files with 415 additions and 98 deletions

View File

@@ -379,7 +379,27 @@ Public Class cUTA
If dr.Item(li.Text) Is DBNull.Value Then
propInfo.SetValue(Me, Nothing)
Else
propInfo.SetValue(Me, dr.Item(li.Text))
Dim value = dr.Item(li.Text)
Dim targetType As Type = If(Nullable.GetUnderlyingType(propInfo.PropertyType), propInfo.PropertyType)
Try
If targetType Is GetType(Char) AndAlso TypeOf value Is String Then
Dim strValue As String = value.ToString()
If strValue.Length > 0 Then
propInfo.SetValue(Me, strValue(0)) ' String → erster Buchstabe als Char
Else
propInfo.SetValue(Me, Nothing) ' oder ein Standardwert wie " " (Leerzeichen)
End If
ElseIf targetType Is GetType(String) AndAlso TypeOf value Is Char Then
propInfo.SetValue(Me, value.ToString()) ' Char → String
Else
Dim convertedValue = Convert.ChangeType(value, targetType)
propInfo.SetValue(Me, convertedValue)
End If
Catch ex As Exception
Console.WriteLine("Fehler beim Setzen von " & li.Text & " auf " & value.ToString() & ": " & ex.Message)
MsgBox("Fehler beim Setzen von " & li.Text & " auf " & value.ToString() & vbCrLf & ex.ToString())
End Try
End If
Next
@@ -454,9 +474,9 @@ Public Class cUTA
Property Belegnummer_des_Lieferanten As Object
Property Kilometerstand As Object
Property Fakturierwarenart As Object
Property Vorzeichen_Statusfeld_für_alle_Beträge_und_Mengen As Object
Property Vorzeichen_Statusfeld_für_alle_Beträge_und_Mengen As String 'HIER object
Property Menge As Object
Property SB_BT As Object
Property SB_BT As String 'HIER object
Property Umsatzsteuerprozentsatz As Object
Property Lieferlandwährung_ISO As Object
Property Einzelpreis_Netto_in_Lieferlandwährung As Object