Handling Null Dates


Author
Message
Randy Jean
Randy Jean
StrataFrame User (169 reputation)StrataFrame User (169 reputation)StrataFrame User (169 reputation)StrataFrame User (169 reputation)StrataFrame User (169 reputation)StrataFrame User (169 reputation)StrataFrame User (169 reputation)StrataFrame User (169 reputation)StrataFrame User (169 reputation)
Group: StrataFrame Users
Posts: 105, Visits: 641
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.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Randy Jean - 17 Years Ago
Peter Jones - 17 Years Ago
Randy Jean - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Randy Jean - 17 Years Ago
Randy Jean - 17 Years Ago
                         The OnValidation is actually the default for .NET binding... it...
StrataFrame Team - 17 Years Ago
                             Hi Ben,
It's starting to make sense now... I'm still a newbie at...
Randy Jean - 17 Years Ago
                                 Yes, creating an imaginary control to focus would work, but firstly, I...
StrataFrame Team - 17 Years Ago
                                     Works for me! :D

Thanks, Randy
Randy Jean - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search