StrataFrame Forum

Newbie question: Null DateTime Fields

http://forum.strataframe.net/Topic5065.aspx

By Ben Kim - 12/7/2006

Hello,

I am throwing together a proof-of-concept application using StrataFrame.  We have several fields in our SQL datatables that allow null's (in fact most of them).  

Say I have a birthdate field in a personmaster table.   If the value is null, the bo throws an exception when I navigate to the record.  I have tried setting the alternate value on null to several things such as System.DBNull and System.DBNull.Value etc.  However it will not compile.

How does everyone else handle null values in their BO's especially datetime type fields?

Thanks!

Ben, Emergitech

By Trent L. Taylor - 12/7/2006

You will use a field customization to add NULL support.  You can find this in the Application Framework help:

Business Layer -> Business Object Mapper -> Customizing a Field

By Ben Kim - 12/7/2006

OK I see that.  We are new to this .NET thing.  Do you have a code snippet you can post to show us how to handle specifically Null datetimes that are bound to DateTimePicker control?
By Trent L. Taylor - 12/7/2006

Create a field customization on your date time field to "Return an Alternate Value" of #1/1/1800#.  Then rebuild your partial and run your application.  If you are using the SF DateTimePicker then by default the NULL dates will be "empty" until you assign a value.
By Ben Kim - 12/7/2006

Thank you.  Did as you said, now the datetimepicker control shows blank on Null fields!  Awesome.  But (there is always that huh?) I now have a new issue since doing this. I have defined a master->detail form.  The Birthdate field which I was having issues with is defined in the parent BO.   Now since added the #1/1/1800# code to the BO, the Save/Undo buttons enable themselves whenever I navigate to a table entry that has a blank birthdate!  Ideas???
By Trent L. Taylor - 12/7/2006

I don't think the two are related.  A BO field has no control of the editing state of a BO.  The MaintenanceFormToolstrip follows the EditingState of the business object.  I would look for other things that may have changed.

The editing state is controled off of the EditingState of the BO which is changed from the Add(), Edit(), Save(), and Undo() of a BO or form. 

By Trent L. Taylor - 12/7/2006

Ben,

We fixed a bug the other day that was affecting the IsDirty of the BO which will effect the Save and Undo buttons when refreshed.  This has been fixed and will be posted in the next update.  If this is keeping you from moving forward then we can give you a temporary fix, but if you are just on eval mode then this may not be an issue and you can just get a fix on the next update.

By Ben Kim - 12/7/2006

Wonderful.  I can wait for the fix since I am just evaluating and creating a POC application.  I thought I was doing something wrong.  Glad to hear you have a fix for it.
By Trent L. Taylor - 12/7/2006

Just so it makes a little sense....we enhanced the DateTimePicker in the last update which introduced the minor issue...as luck would have it, you ran into the obscure requirements for this to happen Smile  At any rate, you can get it in your next update and it will resolve itself.
By Ben Kim - 12/7/2006

Lucky me! BigGrin  On a lighter note, thank you for developing such a wonderful framework!   Did you guys ever give Clarion a peek?  It does a lot of what you are accomplishing with StrataFrame and more.  However, the company that develops the language has lagged behind in technology over the years and the company I work for has had enough...which is the reason why we are moving to .NET.

If you want a RDC/VNC/PCAnywhere demo of the product, please let me know.  I would be more than happy to show you the power of Clarion so you can replicate it <grin>.

Ben

By Trent L. Taylor - 12/7/2006

We think we are familiar with our competitors but are always willing to learn more. I appreciate your input and compliements and we look forward to working with you.