Hi there,
I have a perentform which contains a datagridview to present and seek customer-data
and use a childformdialog to open a child-window to edit a selected record.
This is the code in my parent-form
Dim cErr As String = ""
Me.KundenBO1.Edit()
If Me.ChildKundNeu.ShowDialog(False, Me) = DialogResult.OK Then
If KundenBO1.Save <> MicroFour.StrataFrame.Data.SaveUndoResult.Success Then
cErr = "Fehler beim Speichern!"
mymsgbox(cErr, 48, cProgtitle)
Else
cErr = "Satz gespeichert!"
mymsgbox(cErr, 64, cProgtitle)
End If
Else
cErr = "Abbruch"
Me.KundenBO1.Undo(MicroFour.StrataFrame.Business.BusinessUndoType.CurrentRowOnly)
mymsgbox(cErr, 64, cProgtitle)
End If
So far, so good. The first parameter in the constructor determines, if a record ist added (True) or edited (False). Now whe I edit a record I want enable the use to undo changes in the child-form without closing and opening it again. So I put an "Undo-Button" on the form and call the Undo-Method of the childform-BO which is set up in the BO-Translations of the childformdialog as the destination BO.
KundenBO1.Undo(MicroFour.StrataFrame.Business.BusinessUndoType.CurrentRowOnly)
But this leads to the following error (Translated from german):
"Invalid conversion from type DBNull to type string"
And this is where it happens:
Public Overrides Sub SetValue(ByVal component As Object, ByVal value As Object)
Select Case Me.Field
Case KundenBOFieldNames.KUNDENNR
DirectCast(component, KundenBO).KUNDENNR = CType(value, System.Int32)
Case KundenBOFieldNames.ANREDE
DirectCast(component, KundenBO).ANREDE = CType(value, System.String)
The last Directcast is where the error happens.
I wonxder now if I am doing something wrong or if this can not be done this way.
Thanks for your help
Thomas