Smart Date Enhancer Ver 1.0

Smart Date Enhancer Ver 1.0

Old forum URL: forums.lhotka.net/forums/t/1563.aspx


Vinodonly posted on Monday, October 23, 2006

I have created a module which enhances functionalities of Smart Date, pasted below are the comments from the original code and code is attached with this post. (Source code ext changed to Txt as VB extension was not getting uploaded)

I would like to hear feedback from everyone and if this is found to be useful then it can be incorporated in Original Smart Date Structure so everybody can get benefitted.

Smart Date Enhancer Ver 1.0

SDEnhancer adds following additional functionalities to Smart Date (without modifying CSLA Code)

Assuming Current Date is :- Dec 15, 2006, and Current DateTimeFormat ShortDate Pattern is :- M/d/yyyy

 User Entry :- 12, Gets Converted into 12-1-2006 (Dec 1, 2006)

User Entry :- 12/20, Gets Converted into 12-20-2006 (Dec 20, 2006)

User Entry :- 1, Gets Converted into 1-1-2007 (Jan 1, 2007)

 If Current Date is :- Jan 15, 2007

User Entry :- 12, Gets Converted into 12-1-2006 (Dec 1, 2006)

mDaysGap variable is by default set to 90 days so it automatically makes a jump of 90 days

backward/forward depending on current date and value entered by user

If Enhancer is not able to Apply these enhancements or date entered is illegal then

original value is returned.

ShortDate Pattern and Date seperator are taken from Current DateTimeFormat so it should work with

other local settings also.

Given below is the property block (Set portion for using it)

Set(ByVal Value As String)

CanWriteProperty(True)

Try

If mOrderCfmDt <> Value Then

mOrderCfmDt.Text = Value

PropertyHasChanged()

End If

' Smart Date throws ArgumentException (Chk Function StringToDate)

' which is caught here and SDEnhancer is applied

Catch ex As ArgumentException

Value = SDEnhancer.SDEnhancer(Value)

mOrderCfmDt.Text = Value

PropertyHasChanged()

End Try

End Set

 

Copyright (c) Marimer LLC