Please help!!! Date type Properties... 
Author Message
 Please help!!! Date type Properties...

As per my previous post (i really need some help here - sorry to hassle
newsgroup readers!)....

I have a class which is part of a business object model. This class needs to
have a read/write date type property (easy enough!).... but, this property
will sometimes not contain a value (e.g. when a new object instance is
created).

I seem to be stuck on the fact that a date value can only contain valid
dates (and is automatically initialized to 1 January 0001) - I don't want to
have business logic in my UI, but at the same time I want to be able to read
and write this property as a true date, or a 'null' value.

.NET doesn't allow date type variables to be set to 'null' (or the new .NET
equiv, System.DBNull)... so should I be overloading my property, or does
someone have a better solution to what must be quite a regular issue...

Thanks in advance for any suggestions....

Chris Keeble



Mon, 12 Jul 2004 23:23:10 GMT  
 Please help!!! Date type Properties...
Granted this is a bit of hack, but perhaps you can set the date to something
like 1/1/1899 where you wish to represent no value?  And set up the specific
handlers accordingly.  Just a thought...

Jim


Quote:
> As per my previous post (i really need some help here - sorry to hassle
> newsgroup readers!)....

> I have a class which is part of a business object model. This class needs
to
> have a read/write date type property (easy enough!).... but, this property
> will sometimes not contain a value (e.g. when a new object instance is
> created).

> I seem to be stuck on the fact that a date value can only contain valid
> dates (and is automatically initialized to 1 January 0001) - I don't want
to
> have business logic in my UI, but at the same time I want to be able to
read
> and write this property as a true date, or a 'null' value.

> .NET doesn't allow date type variables to be set to 'null' (or the new
.NET
> equiv, System.DBNull)... so should I be overloading my property, or does
> someone have a better solution to what must be quite a regular issue...

> Thanks in advance for any suggestions....

> Chris Keeble




Mon, 12 Jul 2004 23:26:11 GMT  
 Please help!!! Date type Properties...
Hi Jim

Thanks for your reply - yep, I agree - that was one method I had thought of
using, my issue being that it leaves my with my appliction code needing to
contain lines like:

    MyObject.DateProperty = #1/1/0001#

Which is nowhere near as good as being able to say (as we used to)

    MyObject.DateProperty = Null

And as you can't simply overload where the method signatures are the same,
combined with the fact that a date value doesn't accept a DBNull object it's
all a bit nightmareish!

Sure - I can get round it but it just seems as though this has gone
backwards instead of moving forwards. Having only just started with .NET I'm
praying that I'm not going to find to many of these seemingly unnecessary
constraints on how we code.... but I'm guessing I will!

Any other suggestions / tips / techniques will be greatly received.

(Thanks again for your suggestion)

Chris

Quote:
> Granted this is a bit of hack, but perhaps you can set the date to
something
> like 1/1/1899 where you wish to represent no value?  And set up the
specific
> handlers accordingly.  Just a thought...

> Jim



> > As per my previous post (i really need some help here - sorry to hassle
> > newsgroup readers!)....

> > I have a class which is part of a business object model. This class
needs
> to
> > have a read/write date type property (easy enough!).... but, this
property
> > will sometimes not contain a value (e.g. when a new object instance is
> > created).

> > I seem to be stuck on the fact that a date value can only contain valid
> > dates (and is automatically initialized to 1 January 0001) - I don't
want
> to
> > have business logic in my UI, but at the same time I want to be able to
> read
> > and write this property as a true date, or a 'null' value.

> > .NET doesn't allow date type variables to be set to 'null' (or the new
> .NET
> > equiv, System.DBNull)... so should I be overloading my property, or does
> > someone have a better solution to what must be quite a regular issue...

> > Thanks in advance for any suggestions....

> > Chris Keeble




Tue, 13 Jul 2004 00:33:44 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

2. Please, Please, Please I need help working with dates

3. Invalid use of property please, please, please help!!!

4. Custom property of type date with empty value displays 30-Dec-1899

5. Date - Date/time comparison - please help

6. List Property in Property Pane (PLEASE HELP!)

7. Can anyone HELP me PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE

8. HELP - Need help on DATE data type

9. Please, Oh Please Help Find first date plus

10. Type Mismatch reading from Access 2K of type Date

11. implicit type conversion from date type to string - how to change

12. Date formatting of date type

 

 
Powered by phpBB® Forum Software