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

.NET (Core and Framework)

 
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 
So I am using the JQuery.datePicker example... http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerStartEnd.html

I had the Jquery calendar working fine, but it olnly allowed me to enter 1 date at a time and save it to the DB.

I want the user to select a start and a multiple date, run a loop through the dates and each day to the DB.

Slightly lost at the minute and any help would be appreciated....

Here is part of my view for my ActionResult create()//which allows the user to add a new day.

HTML
<form action ="ListHolidays" id="listHolidays" method="post">
@using (Html.BeginForm()) {
      @Html.ValidationSummary(true)
<fieldset>
    <legend>Holiday</legend>

    <div>
        @Html.LabelFor(model => model.PersonId, "Person")
    </div>

    <div>     
        @Html.DropDownListFor(model => model.PersonId,
                            new SelectList(ViewBag.Id, "Value", "Text"),
                            "---Select---"
                            )   
     @Html.ValidationMessageFor(model => model.PersonId)            
    </div>

    <div>
        @Html.LabelFor(model => model.HolidayDate)
    </div>

    <div>

        @Html.TextBoxFor(model => model.HolidayDate)

        @Html.TextBoxFor(model => model.endDate)
<script>

    $("#HolidayDate").addClass('date-pick');
    $("#endDate").addClass('date-pick');
        //$('.date-pick').datePicker//({dateFormat: 'dd-mm-yy'}).val();

        $(function () 
        {
            $('.date-pick').datePicker()
            $('#HolidayDate').bind('dpClosed',
                function (e, selectedDates) 
                {
                    var d = selectedDates[0];
                    if (d) 
                    {
                        d = new Date(d);
                        $('#endDate').dpSetStartDate(d.addDays(1).asString());
                    }
                }
        );
            $('#endDate').bind('dpClosed',
                function (e, selectedDates) 
                {
                    var d = selectedDates[0];
                    if (d) 
                    {
                        d = new Date(d);
                        $('#HolidayDate').dpSetEndDate(d.addDays(-1).asString());
                    }
                }
            );
        });



</script>

 @Html.ValidationMessageFor(model => model.HolidayDate)
    </div>

    <p>
        <input type="submit" value="Create"/>
    </p>


and my post for listHolidays:
C#
[HttpPost]
public ActionResult listHolidays(Holiday holiday, int? PersonId, string HolidayDate, string endDate)
    {
        IList<DateTime> dates = new List<DateTime>();
        dates.Add(DateTime.Parse(HolidayDate));
        dates.Add(DateTime.Parse(endDate));
        List<DateTime> orderedDates = dates.OrderBy(d => d).ToList();

            for (int i = 0; i < orderedDates.Count; i++ )
            //if (ModelState.IsValid)
            {
                db.Holidays.AddObject(holiday);
                db.SaveChanges();
                return View();
            }

            return RedirectToAction("Index");
           // return View();
        }


The problem being in my list Holidays, im not sure how to run through the loop from start to end date, and add a new record to the DB for each one.

Please advise
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 
QuestionEnter 3 dates and display order in different VIEW, after click Pin
xnaLearner7-Dec-12 9:52
xnaLearner7-Dec-12 9:52 
Question[VB.NET 2008] How to detect if a page of a TabControl is selected (Windows CE) Pin
steve_94966136-Dec-12 21:37
professionalsteve_94966136-Dec-12 21:37 
AnswerRe: [VB.NET 2008] How to detect if a page of a TabControl is selected (Windows CE) Pin
Zaf Khan10-Dec-12 17:57
Zaf Khan10-Dec-12 17:57 
GeneralRe: [VB.NET 2008] How to detect if a page of a TabControl is selected (Windows CE) Pin
steve_949661311-Dec-12 21:20
professionalsteve_949661311-Dec-12 21:20 
GeneralRe: [VB.NET 2008] How to detect if a page of a TabControl is selected (Windows CE) Pin
Zaf Khan12-Dec-12 2:13
Zaf Khan12-Dec-12 2:13 
Question[VB.NET 2008] How to get control on objects created at runtime Pin
steve_94966135-Dec-12 4:54
professionalsteve_94966135-Dec-12 4:54 
AnswerRe: [VB.NET 2008] How to get control on objects created at runtime Pin
Eddy Vluggen5-Dec-12 5:40
professionalEddy Vluggen5-Dec-12 5:40 
GeneralRe: [VB.NET 2008] How to get control on objects created at runtime Pin
steve_94966135-Dec-12 20:59
professionalsteve_94966135-Dec-12 20:59 

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.