Click here to Skip to main content
       

.NET Framework

 
GeneralRe: dont allow user to select existing date PinprotectorPete O'Hanlon11-Dec-12 0:51 
GeneralRe: dont allow user to select existing date PinmemberxnaLearner11-Dec-12 1:21 
GeneralRe: dont allow user to select existing date PinprotectorPete O'Hanlon11-Dec-12 2:02 
QuestionRun through loop for week and dont select weekends PinmemberxnaLearner10-Dec-12 5:13 
So the user can select 2 different dates, a start date and an end date from 2 calendars, when they click 'add' the dates between&including the dates selected will be added to the DB, each date as a separate record.
 
This works fine however I dont want weekends to be added to the DB.
 
Iv updated the UI of datepicker http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerCustomCellRender.html but if a user selects fri-mon for example fri,sat,sun and mon will be added to the db Iv tried to only run the code if datyofweek is not saturday or sunday
 
 public ActionResult listHolidays(Holiday holiday, int? PersonId, string HolidayDate, string endDate)
        {
            DateTime startDates = Convert.ToDateTime(HolidayDate),
                     endDates = Convert.ToDateTime(endDate);
 
            while (startDates <= endDates)
            {
                if (startDates.DayOfWeek != DayOfWeek.Saturday || startDates.DayOfWeek != DayOfWeek.Sunday)
                {
                    Holiday holiday1 = new Holiday();
                    holiday1.PersonId = PersonId.Value;
                    holiday1.HolidayDate = startDates;
              
                    db.Holidays.AddObject(holiday1);
                    db.SaveChanges();
 
                    //say start date is 10. AddDays(1) will make it 11 then return it to startDates in 'startDates' = startdates,
                    //but doesnt chage the value of startdates = 'startdates'
                   // startDates = startDates.AddDays(1);

                     startDates = startDates.AddDays(1);
                }
            }
 
            return RedirectToAction("Index");
        }
any help?
Thanks
AnswerRe: Run through loop for week and dont select weekends PinprotectorPete O'Hanlon10-Dec-12 5:31 
GeneralRe: Run through loop for week and dont select weekends PinmemberxnaLearner10-Dec-12 5:52 
GeneralRe: Run through loop for week and dont select weekends PinprotectorPete O'Hanlon10-Dec-12 5:53 
QuestionDeploying a Windows Service Pinmemberindian14310-Dec-12 5:09 
AnswerRe: Deploying a Windows Service PinprotectorPete O'Hanlon10-Dec-12 6:04 
GeneralRe: Deploying a Windows Service Pinmemberindian14310-Dec-12 6:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 23 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid