Been away from this issue for a while - thought I had it figured out before but must have tabled it. Anyway, datetime is the only type in SQL we allow nulls to handle when a date can be empty. So, I've set the bizobj to AllowNullValuesOnNewRow = False but in SetDefaultValues I set:
Me.CurrentRow("ExpirationDate") = DBNull.Value
I'm using the strataframe dt picker control.
So, this all seems to work fine for adding records, etc. The problem comes in that if I navigate from a record that has a date to one that is null OR I navigate from a row with a null to a record with a date the buffer is dirty. If I set a breakpoint in the IsDirtyChanged event I see it is the Set Alternate on Null code causing this:
>BayerAcquire.exe!BayerAcquire.DCAReagentsBO.DCAReagentsBO_IsDirtyChanged(Object sender = {BayerAcquire.DCAReagentsBO}, System.EventArgs e = {System.EventArgs}) Line 124Basic
[External Code]
BayerAcquire.exe!BayerAcquire.DCAReagentsBO.set_ExpirationDate(Date value = #1/1/1800#) Line 306 + 0x42 bytesBasic
BayerAcquire.exe!BayerAcquire.DCAReagentsBO.Field_ExpirationDate_Descriptor.SetValue(Object component = {BayerAcquire.DCAReagentsBO}, Object Value = #1/1/1800#) Line 691 + 0x45 bytesBasic
[External Code]
BayerAcquire.exe!BayerAcquire.AppMain.Main() Line 21 + 0x6 bytesBasic
[External Code]
The partial class code looks like this:
'''
''' ExpirationDate
'''
'''
BusinessFieldDisplayInEditor(), _
Description("ExpirationDate"), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Public Property [ExpirationDate]() As System.DateTime
Get
Dim loValue As Object
loValue = Me.CurrentRow.Item("ExpirationDate")
If loValue Is DBNull.Value Then
Return #1/1/1800#
Else
Return CType(loValue, System.DateTime)
End If
End Get
Set(ByVal value As System.DateTime)
Me.CurrentRow.Item("ExpirationDate") = value
End Set
End Property
How do I handle date fields when the date is optional (not required) and I don't want navigation to dirty the buffer? I also don't want to store 1/1/1800 in the DB.