使用jQuery MVC5复制/克隆表记录

时间:2015-02-02 09:59:58

标签: jquery razor asp.net-mvc-5 clone


我正在使用 MVC5 开发沙龙预订系统,我想要做的是:在管理员输入每个员工的工作时间之后"在BookedHours表中"本周;应该有一个按钮,重复下周的相同记录(只需更改 DATE 字段)。
我可以在视图中使用 jQuery 执行此操作
感谢

索引视图:

@model PagedList.IPagedList<BookingSystem.Models.WorkingHour>
:
:
<table class="table">
<tr>
    <th>

        @Html.ActionLink("Branch", "Index", new { sortOrder = ViewBag.BranchSortParm, currentFilter1 = ViewBag.CurrentFilter1, currentFilter2 = ViewBag.CurrentFilter2 })
    </th>
    <th>
        @Html.ActionLink("Name", "Index", new { sortOrder = ViewBag.NameSortParm, currentFilter1 = ViewBag.CurrentFilter1, currentFilter2 = ViewBag.CurrentFilter2 })
    </th>
    <th>
       @Html.ActionLink("Date", "Index", new { sortOrder = ViewBag.DateSortParm, currentFilter1 = ViewBag.CurrentFilter1, currentFilter2 = ViewBag.CurrentFilter2 })
    </th>
    <th>
        Day
    </th>
    <th>
        Start Time
    </th>
    <th>
        End Time
    </th>
    <th></th>
</tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Branch.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ServiceProvider.FullName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Date)
        </td>
        <td>
            @item.Date.DayOfWeek
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.StartTime)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.EndTime)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.WorkingHourID }) |
            @Html.ActionLink("Details", "Details", new { id=item.WorkingHourID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.WorkingHourID })
        </td>
    </tr>
}

</table>

创建视图:

    @model BookingSystem.Models.WorkingHour

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>


@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4>WorkingHour</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.Date, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Date, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Date, "", new { @class = "text-danger" })
            </div>
        </div>
        <div class="form-group">
            @Html.Label("Select Shift", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("Direction", new List<SelectListItem>
                    {
                      new SelectListItem{ Text = "-Please Select Shift", Value = "0" },
                      new SelectListItem{ Text = "First Shift", Value = "1" },
                      new SelectListItem{ Text = "Second Shift", Value = "2" },
                      new SelectListItem{ Text = "Third Shift", Value = "3" }
                    }, htmlAttributes: new { @class = "form-control" })
                </div>
            </div>
        <div class="form-group">
            @Html.LabelFor(model => model.StartTime, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.StartTime, new { htmlAttributes = new { @id = "st", @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.StartTime, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.EndTime, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.EndTime, new { htmlAttributes = new { @id = "et", @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.EndTime, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.ServiceProviderID, "ServiceProviderID", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("ServiceProviderID", null, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.ServiceProviderID, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.BranchID, "BranchID", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("BranchID", null, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.BranchID, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

0 个答案:

没有答案