abp(net core)+easyui+efcore实现仓储管理系统目录
abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一)
abp(net core)+easyui+efcore实现仓储管理系统——解决方案介绍(二)
abp(net core)+easyui+efcore实现仓储管理系统——领域层创建实体(三)
abp(net core)+easyui+efcore实现仓储管理系统——定义仓储并实现 (四)
abp(net core)+easyui+efcore实现仓储管理系统——创建应用服务(五)
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之控制器(六)
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之列表视图(七)
在这一篇文章(abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之列表视图(七))中我们创建一个使用Razor视图引擎的视图模板文件,Razor视图模板文件的扩展名为.cshtml,并提供一种比较优雅的方式使用C#来创建HTML输出。Razor视图模板减少了编写程序所需要输入的字符数量和敲击键盘的次数,并实现了快速、流畅的编码工作。下面添加更新视图、删除视图、新增视图的具体步骤:
三、创建更新视图
在ASP.NET MVC的默认模板中,更新视图是通过“Edit”标签,使用“asp-route-id”属性在浏览器中生成指向Views\Module\Edit.cshtml 视图的链接。具体代码如下。
<a asp-action="Edit" class="waves-effect waves-block" asp-route-id="@item.Id"><i class="material-icons">edit</i>@L("Edit")</a>
1) 在Visual Studio 2017的解决方案资源管理器中,使用鼠标右键单击“Module”文件夹,然后选择“添加” > “新建项…”。 在“添加新项-ABP.TPLMS.Web.Mvc”对话框中,选择“Razor视图”,并将名称命名为Edit.cshmtl。在此视图中添加如下代码。
@using ABP.TPLMS.Web.Startup
@model ABP.TPLMS.Web.Models.Module.EditModuleModalViewModel
@{
ViewData["Title"] = "Edit";
}
<h2>Edit</h2>
<h4>模块编辑</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Edit">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="@Model.Module.Id" />
<div class="form-group">
<label asp-for="@Model.Module.Name" class="control-label"></label>
<input asp-for="@Model.Module.Name" class="form-control" />
<span asp-validation-for="@Model.Module.Name" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Module.DisplayName" class="control-label"></label>
<input asp-for="@Model.Module.DisplayName" class="form-control" />
<span asp-validation-for="@Model.Module.DisplayName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Module.Url" class="control-label"></label>
<input asp-for="@Model.Module.Url" class="form-control" />
<span asp-validation-for="@Model.Module.Url" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Module.HotKey" class="control-label"></label>
<input asp-for="@Model.Module.HotKey" class="form-control" />
<span asp-validation-for="@Model.Module.HotKey" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Module.IconName" class="control-label"></label>
<input asp-for="@Model.Module.IconName" class="form-control" />
<span asp-validation-for="@Model.Module.IconName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Module.RequiredPermissionName" class="control-label"></label>
<input asp-for="@Model.Module.RequiredPermissionName" class="form-control" />
<span asp-validation-for="@Model.Module.RequiredPermissionName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Module.RequiresAuthentication" class="control-label"></label>
<input asp-for="@Model.Module.RequiresAuthentication" type="checkbox" />
</div>
<div class="form-group">
<label asp-for="@Model.Module.ParentName" class="control-label"></label>
<input asp-for="@Model.Module.ParentName" class="form-control" value="根目录"/>
<span asp-validation-for="@Model.Module.ParentName" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
四、创建删除视图
如果你使用过ASP.NET MVC的进行过应用开发,那么你就知道删除视图是通过“Delete”标签,使用“asp-route-id”属性在浏览器中生成指向Views\Module\Delete.cshtml 视图的链接。具体代码如下。
<a asp-action="Delete" class="waves-effect waves-block" asp-route-id="@item.Id"><i class="material-icons">delete_sweep</i>@L("Delete")</a>
1) 在Visual Studio 2017的解决方案资源管理器中,使用鼠标右键单击“Module”文件夹,然后选择“添加” > “新建项…”。 在“添加新项-ABP.TPLMS.Web.Mvc”对话框中,选择“Razor视图”,并将名称命名为Delete.cshmtl。在删除视图文件中添加如下代码。
@using ABP.TPLMS.Web.Startup
@model ABP.TPLMS.Web.Models.Module.EditModuleModalViewModel
@{
ViewData["Title"] = PageNames.Module;
}
<h2>删除模块</h2>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>Cargo</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Module.Name)
</dt>
<dd>
@Html.DisplayFor(model => model.Module.Name)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Module.DisplayName)
</dt>
<dd>
@Html.DisplayFor(model => model.Module.DisplayName)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Module.Status)
</dt>
<dd>
@Html.DisplayFor(model => model.Module.Status)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Module.RequiredPermissionName)
</dt>
<dd>
@Html.DisplayFor(model => model.Module.RequiredPermissionName)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Module.IconName)
</dt>
<dd>
@Html.DisplayFor(model => model.Module.IconName)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Module.ParentName)
</dt>
<dd>
@Html.DisplayFor(model => model.Module.ParentName)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Module.RequiresAuthentication)
</dt>
<dd>
@Html.DisplayFor(model => model.Module.RequiresAuthentication)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Module.Url)
</dt>
<dd>
@Html.DisplayFor(model => model.Module.Url)
</dd>
</dl>
<form asp-action="Delete">
<input type="hidden" asp-for="@Model.Module.Id" />
<input type="submit" value="Delete" class="btn btn-default" /> |
<a asp-action="Index">Back to List</a>
</form>
</div>
五、创建新增视图
在ASP.NET MVC的默认模板中,新增视图是通过“Create”标签,使用asp-action="Create"属性在浏览器中生成指向Views\Module\Create.cshtml 视图的链接。具体代码如下。
<a asp-action="Create" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-right"> <i class="material-icons">add</i></a>
1) 在Visual Studio 2017的解决方案资源管理器中,使用鼠标右键单击“Module”文件夹,然后选择“添加” > “新建项…”。 在“添加新项-ABP.TPLMS.Web.Mvc”对话框中,选择“Razor视图”,并将名称命名为Create.cshmtl,代码如下。
@using ABP.TPLMS.Web.Startup
@model ABP.TPLMS.Web.Models.Module.EditModuleModalViewModel
@{
ViewData["Title"] = "Create";
}
<h4>创建模块</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Create">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="@Model.Module.Name" class="control-label"></label>
<input asp-for="@Model.Module.Name" class="form-control" />
<span asp-validation-for="@Model.Module.Name" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Module.DisplayName" class="control-label"></label>
<input asp-for="@Model.Module.DisplayName" class="form-control" />
<span asp-validation-for="@Model.Module.DisplayName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Module.Url" class="control-label"></label>
<input asp-for="@Model.Module.Url" class="form-control" />
<span asp-validation-for="@Model.Module.Url" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Module.HotKey" class="control-label"></label>
<input asp-for="@Model.Module.HotKey" class="form-control" />
<span asp-validation-for="@Model.Module.HotKey" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Module.IconName" class="control-label"></label>
<input asp-for="@Model.Module.IconName" class="form-control" />
<span asp-validation-for="@Model.Module.IconName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Module.RequiredPermissionName" class="control-label"></label>
<input asp-for="@Model.Module.RequiredPermissionName" class="form-control" />
<span asp-validation-for="@Model.Module.RequiredPermissionName" class="text-danger"></span>
</div>
<div class="row clearfix">
<div class="form-group">
<div class="checkbox">
<label asp-for="@Model.Module.RequiresAuthentication"></label>
<input asp-for="@Model.Module.RequiresAuthentication" type="checkbox" class="filled-in" checked />
</div>
</div>
</div>
<div class="form-group">
<label asp-for="@Model.Module.ParentName" class="control-label"></label>
<input asp-for="@Model.Module.ParentName" class="form-control" value="根目录" />
<span asp-validation-for="@Model.Module.ParentName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Module.Status" class="control-label"></label>
<input asp-for="@Model.Module.Status" class="form-control" />
<span asp-validation-for="@Model.Module.Status" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Module.SortNo" class="control-label"></label>
<input asp-for="@Model.Module.SortNo" class="form-control" />
<span asp-validation-for="@Model.Module.SortNo" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
来源:https://www.cnblogs.com/chillsrc/p/11159642.html