ASP.NET实现电影票信息的增删查改功能(2)

@model IEnumerable<ProjectThree.Models.Movie> @{ ViewBag.Title = "Index"; } <p> @Html.ActionLink("新建", "Create") @using (Html.BeginForm("Index", "Movie", FormMethod.Get)) { <p> 电影是否上映:@Html.DropDownList("movieOn", "all") 电影类型:@Html.DropDownList("movieGenre", "all") 电影名称:@Html.TextBox("SearchString") 票价区间:@Html.TextBox("lowPrice")~@Html.TextBox("highPrice") <input type="submit" value="查询" /> </p> } </p> <table> <tr> <th> @Html.DisplayNameFor(model => model.Title) </th> <th> @Html.DisplayNameFor(model => model.ReleaseDate) </th> <th> @Html.DisplayNameFor(model => model.Genre) </th> <th> @Html.DisplayNameFor(model => model.Price) </th> <th> @Html.DisplayNameFor(model => model.Rating) </th> <th></th> </tr> @foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem => item.Title) </td> <td> @Html.DisplayFor(modelItem => item.ReleaseDate) </td> <td> @Html.DisplayFor(modelItem => item.Genre) </td> <td> @Html.DisplayFor(modelItem => item.Price) </td> <td> @Html.DisplayFor(modelItem => item.Rating) </td> <td> @Html.ActionLink("编辑", "Edit", new { id=item.ID }) | @Html.ActionLink("详情", "Details", new { id=item.ID }) | @Html.ActionLink("删除", "Delete", new { id=item.ID }, new { onclick = "return confirm('确认删除吗?')" }) </td> </tr> } </table>

Create.cshtml

@model ProjectThree.Models.Movie @{ ViewBag.Title = "Create"; } @using (Html.BeginForm()) { @Html.AntiForgeryToken() <div> <h4>Movie</h4> <hr /> @Html.ValidationSummary(true, "", new { @class = "text-danger" }) <div> @Html.LabelFor(model => model.Title, htmlAttributes: new { @class = "control-label col-md-2" }) <div> @Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Title, "", new { @class = "text-danger" }) </div> </div> <div> @Html.LabelFor(model => model.ReleaseDate, htmlAttributes: new { @class = "control-label col-md-2" }) <div> @Html.EditorFor(model => model.ReleaseDate, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.ReleaseDate, "", new { @class = "text-danger" }) </div> </div> <div> @Html.LabelFor(model => model.Genre, htmlAttributes: new { @class = "control-label col-md-2" }) <div> @Html.EditorFor(model => model.Genre, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Genre, "", new { @class = "text-danger" }) </div> </div> <div> @Html.LabelFor(model => model.Price, htmlAttributes: new { @class = "control-label col-md-2" }) <div> @Html.EditorFor(model => model.Price, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" }) </div> </div> <div> @Html.LabelFor(model => model.Rating, htmlAttributes: new { @class = "control-label col-md-2" }) <div> @Html.EditorFor(model => model.Rating, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Rating, "", new { @class = "text-danger" }) </div> </div> <div> <div> <input type="submit" value="Create" /> </div> </div> </div> } <div> @Html.ActionLink("Back to List", "Index") </div>

Edit.cshtml

@model ProjectThree.Models.Movie @{ ViewBag.Title = "Edit"; } <h2>Edit</h2> @using (Html.BeginForm()) { @Html.AntiForgeryToken() <div> <h4>Movie</h4> <hr /> @Html.ValidationSummary(true, "", new { @class = "text-danger" }) @Html.HiddenFor(model => model.ID) <div> @Html.LabelFor(model => model.Title, htmlAttributes: new { @class = "control-label col-md-2" }) <div> @Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Title, "", new { @class = "text-danger" }) </div> </div> <div> @Html.LabelFor(model => model.ReleaseDate, htmlAttributes: new { @class = "control-label col-md-2" }) <div> @Html.EditorFor(model => model.ReleaseDate, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.ReleaseDate, "", new { @class = "text-danger" }) </div> </div> <div> @Html.LabelFor(model => model.Genre, htmlAttributes: new { @class = "control-label col-md-2" }) <div> @Html.EditorFor(model => model.Genre, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Genre, "", new { @class = "text-danger" }) </div> </div> <div> @Html.LabelFor(model => model.Price, htmlAttributes: new { @class = "control-label col-md-2" }) <div> @Html.EditorFor(model => model.Price, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" }) </div> </div> <div> @Html.LabelFor(model => model.Rating, htmlAttributes: new { @class = "control-label col-md-2" }) <div> @Html.EditorFor(model => model.Rating, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.Rating, "", new { @class = "text-danger" }) </div> </div> <div> <div> <input type="submit" value="Save" /> </div> </div> </div> } <div> @Html.ActionLink("Back to List", "Index") </div>

源码地址

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjfsfd.html