天天看点

ASP.NET MVC5+EF6+EasyUI 后台管理系统(6)1.直接改代码2.总结

本次参考学习了

https://www.cnblogs.com/ymnets/p/3424309.htmlC

这个人的教程

但是由于时代久远,教程节奏快,版本的问题。对于初学者来说,很不友好。

正好我也要学习,所以自己重新写一下,顺带改一改其中的小bug。

系统目标:实现一个权限管理案例 用户—角色—权限

本节目标:前台用easyui的datagrid展示

1.直接改代码

创建

ASP.NET MVC5+EF6+EasyUI 后台管理系统(6)1.直接改代码2.总结

代码

<!DOCTYPE html>
<html>
<head>
    <title>Main</title>

    <script src="@Url.Content("~/Scripts/jquery-3.3.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.easyui.min.js")" type="text/javascript"></script>
    @Styles.Render("~/Content/css")
    @Styles.Render("~/Content/themes/black/css")
</head>
<body>
    <div style="padding:5px 5px 0px 5px;">
        @RenderBody()
    </div>
</body>
</html>

           

修改index

ASP.NET MVC5+EF6+EasyUI 后台管理系统(6)1.直接改代码2.总结

代码

@using Apps.App;
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index_Layout.cshtml";


}

<table id="List"></table>
<script type="text/javascript">
    $(function () {
        $('#List').datagrid({
            url: '/SysSample/GetList',
            width: $(window).width() - 10,
            methord: 'post',
            height: $(window).height() -35,
            fitColumns: true,
            sortName: 'Id',
            sortOrder: 'desc',
            idField: 'Id',
            striped: true, //奇偶行是否区分
            singleSelect: true,//单选模式
            rownumbers: true,//行号
            columns: [[
                { field: 'Id', title: 'ID', width: 40 },
                { field: 'Name', title: '名称', width: 80 },
                { field: 'Age', title: '年龄', width: 80, align: 'center' },
                { field: 'Bir', title: '生日', width: 120, align: 'center' },
                { field: 'Photo', title: '照片', width: 100, align: 'center' },
                { field: 'Note', title: '说明', width: 60, align: 'center' },
                { field: 'CreateTime', title: '创建时间', width: 120, align: 'center' }
            ]]
        });
    });
</script>
           

修改后台控制器

ASP.NET MVC5+EF6+EasyUI 后台管理系统(6)1.直接改代码2.总结

添加如下代码

[HttpPost]
        public JsonResult GetList()
        {
            List<SysSampleModel> list = m_BLL.GetList("");
            var json = new
            {
                total = list.Count,
                rows = (from r in list
                        select new SysSampleModel()
                        {

                            Id = r.Id,
                            Name = r.Name,
                            Age = r.Age,
                            Bir = r.Bir,
                            Photo = r.Photo,
                            Note = r.Note,
                            CreateTime = r.CreateTime,

                        }).ToArray()
            };
            return Json(json, JsonRequestBehavior.AllowGet);
        }
           

运行截图

ASP.NET MVC5+EF6+EasyUI 后台管理系统(6)1.直接改代码2.总结

2.总结

学习这些内容主要是为了

好好学习一下后台

前段时间一直在做省情报院的一个项目

前台用的EasyUI

后台代码基本都在控制器实现

代码结构很乱

本次系列的文章做完之后

我会抽时间把Easyui的一些基础和技巧分享给大家

然后会同步学习Vue

也会更新

还有就是一些实用性的功能

比如pdf,word,excle,导入导出

再后就是有一门课程springboot

更新啊,必须更新

大概到今年10月多吧

还会有一个实际项目

应该会用springboot

加油