Click here to Skip to main content
15,891,409 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: dont allow user to select existing date Pin
xnaLearner10-Dec-12 6:23
xnaLearner10-Dec-12 6:23 
GeneralRe: dont allow user to select existing date Pin
xnaLearner10-Dec-12 23:26
xnaLearner10-Dec-12 23:26 
GeneralRe: dont allow user to select existing date Pin
Pete O'Hanlon10-Dec-12 23:32
mvePete O'Hanlon10-Dec-12 23:32 
GeneralRe: dont allow user to select existing date Pin
xnaLearner10-Dec-12 23:46
xnaLearner10-Dec-12 23:46 
GeneralRe: dont allow user to select existing date Pin
Pete O'Hanlon10-Dec-12 23:51
mvePete O'Hanlon10-Dec-12 23:51 
GeneralRe: dont allow user to select existing date Pin
xnaLearner11-Dec-12 0:21
xnaLearner11-Dec-12 0:21 
GeneralRe: dont allow user to select existing date Pin
Pete O'Hanlon11-Dec-12 1:02
mvePete O'Hanlon11-Dec-12 1:02 
QuestionRun through loop for week and dont select weekends Pin
xnaLearner10-Dec-12 4:13
xnaLearner10-Dec-12 4:13 
SQL
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


C#
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 Pin
Pete O'Hanlon10-Dec-12 4:31
mvePete O'Hanlon10-Dec-12 4:31 
GeneralRe: Run through loop for week and dont select weekends Pin
xnaLearner10-Dec-12 4:52
xnaLearner10-Dec-12 4:52 
GeneralRe: Run through loop for week and dont select weekends Pin
Pete O'Hanlon10-Dec-12 4:53
mvePete O'Hanlon10-Dec-12 4:53 
QuestionDeploying a Windows Service Pin
indian14310-Dec-12 4:09
indian14310-Dec-12 4:09 
AnswerRe: Deploying a Windows Service Pin
Pete O'Hanlon10-Dec-12 5:04
mvePete O'Hanlon10-Dec-12 5:04 
GeneralRe: Deploying a Windows Service Pin
indian14310-Dec-12 5:08
indian14310-Dec-12 5:08 
GeneralRe: Deploying a Windows Service Pin
Pete O'Hanlon10-Dec-12 5:20
mvePete O'Hanlon10-Dec-12 5:20 
Questionrun through startDate to endDate and add each record to DB Pin
xnaLearner10-Dec-12 2:04
xnaLearner10-Dec-12 2:04 
AnswerRe: run through startDate to endDate and add each record to DB Pin
xnaLearner10-Dec-12 2:35
xnaLearner10-Dec-12 2:35 
QuestionASP.NET Post Textbox After Button Click Pin
xnaLearner9-Dec-12 11:15
xnaLearner9-Dec-12 11:15 
AnswerRe: ASP.NET Post Textbox After Button Click Pin
Richard MacCutchan9-Dec-12 21:54
mveRichard MacCutchan9-Dec-12 21:54 
GeneralRe: ASP.NET Post Textbox After Button Click Pin
xnaLearner10-Dec-12 0:14
xnaLearner10-Dec-12 0:14 
Question.netframework Pin
zofi518-Dec-12 4:30
zofi518-Dec-12 4:30 
AnswerRe: .netframework Pin
Dave Kreskowiak8-Dec-12 6:37
mveDave Kreskowiak8-Dec-12 6:37 
AnswerRe: .netframework Pin
Eddy Vluggen8-Dec-12 7:18
professionalEddy Vluggen8-Dec-12 7:18 
GeneralRe: .netframework Pin
Kevin Bewley13-Jan-13 23:46
Kevin Bewley13-Jan-13 23:46 
AnswerRe: .netframework Pin
Jibesh11-Dec-12 10:36
professionalJibesh11-Dec-12 10:36 

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

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