StrataFrame Forum

Custom Holiday DateTime picker

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

By Charles Thomas Blankenship - 2/8/2014

I needed a control that allowed the user to select a valid date (while specifying whether or not they wanted to Skip Holidays and/or Skip Weekends), and to also optionally, select a SQL Server validated Start and Ending Date/Time).  The control had to be driven by a table of customer generated Holidays ... IOW ... birthdays, Jewish Holidays, special company events, etc.  based upon the content of a Holiday table).

It also had to take the form of a user control so it could be used throughout the project just by dropping it on the form.

It took a while of trial and error (I not gonna tell you how much trial and error as I don't want to embarrass myself) before I reached a code base that was remotely professional.

The project contains custom controls (I never knew how to create these before now ... I wanted to learn).

It also contains a text file named HolidayDefinitionScript.txt which, when run, creates the required SQL Server Holiday table.

Hope this helps someone.

CT

https://www.dropbox.com/s/tb8af1gvhzcfiqc/NovantCustomControls.zip

Here is how to implement it after you drop it on one of your forms:

        public TestForm()        {            InitializeComponent();            DataTable dtHolidays = HolidaysBO.getAllFutureHolidays();            adpAppointmentPicker.addHolidays(dtHolidays);         }
All I did was to create a public method in my HolidaysBO business object that returns all future Holidays and then pass the resulting DataTable to the control's .AddHolidays() method.

Maybe ... just maybe ... someone will figure how to bind the properties ( _startDateTime, _endDateTime and _appointmentDate) to three corresponding properties of a BO ... hint, hint.

C.T.














By Charles Thomas Blankenship - 2/8/2014

Sorry about the formatting ... this should help:

I needed a control that allowed the user to select a valid date (while specifying whether or not they wanted to Skip Holidays and/or Skip Weekends), and to also optionally, select a SQL Server validated Start and Ending Date/Time).  The control had to be driven by a table of customer generated Holidays ... IOW ... birthdays, Jewish Holidays, special company events, etc.  based upon the content of a Holiday table).

It also had to take the form of a user control so it could be used throughout the project just by dropping it on the form.

It took a while of trial and error (I not gonna tell you how much trial and error as I don't want to embarrass myself) before I reached a code base that was remotely professional.

The project contains custom controls (I never knew how to create these before now ... I wanted to learn).

It also contains a text file named HolidayDefinitionScript.txt which, when run, creates the required SQL Server Holiday table.

Hope this helps someone.

CT

https://www.dropbox.com/s/tb8af1gvhzcfiqc/NovantCustomControls.zip

Here is how to implement it after you drop it on one of your forms:



        public TestForm()        
        {InitializeComponent();            
         DataTable dtHolidays = HolidaysBO.getAllFutureHolidays();            
         adpAppointmentPicker.addHolidays(dtHolidays);}
All I did was to create a public method in my HolidaysBO business object that returns all future Holidays and then pass the resulting DataTable to the control's .AddHolidays() method.

Maybe ... just maybe ... someone will figure how to bind the properties ( _startDateTime, _endDateTime and _appointmentDate) to three corresponding properties of a BO ... hint, hint.