ASP.NET.4.5.1+MVC5.0设置系统角色与权限(二)

内容摘要
系统角色篇
数据结构

用户管理

Controller代码
/@ViewBag.ControllerName/search">

<dl>

<dd>关键词:</dd>

文章正文

系统角色篇

数据结构

用户管理

Controller代码

/@ViewBag.ControllerName/search">
                <dl>
                    <dd>关键词:</dd>
                    <dd>
                        <input name="KeyWord" type="text" class="rgtxt2" /></dd>
                    <dd>
                        <input type="submit" value="查 询" class="rgbut1" /></dd>
                </dl>
            </form>
        </div>
        <div class="rgc">
            <dl class="rgt11">
                <dt>
                    <span class="sple"><a href="/systemuser/add">添加用户</a></span>
                </dt>
            </dl>
            <div class="rg3">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td class="rgtd2">用户编号</td>
                        <td class="rgtd3">登录名</td>
                        <td class="rgtd3">手机</td>
                        <td class="rgtd3">Email</td>
                        <td class="rgtd3">昵称</td>
                        <td class="rgtd3">状态</td>
                        <td class="rgtd4">操作</td>
                    </tr>
                </table>
            </div>
            <div class="rg4">
                @{int classnum = 1;}
                @foreach (var item in Model)
                {
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" @if (classnum % 2 == 0)
                                                                                   {<text>class="rgbg2"</text>}>
                        <tr>
                            <td class="rgtd2">@item.SystemUserID</td>
                            <td class="rgtd3">@(item.LogName)</td>
                            <td class="rgtd3">@item.Mobile</td>
                            <td class="rgtd3">@item.Email</td>
                            <td class="rgtd3">@item.TrueName</td>
                            <td class="rgtd3">@(item.State == 1 ? "有效" : "无效")</td>
                            <td class="rgtd4"><a href="/systemuser/delete/@item.SystemUserID">删除</a> | <a href="/systemuser/edit/@item.SystemUserID">编辑</a>  </td>
                        </tr>
                    </table>
                                                                                   classnum = classnum + 1;
                }
            </div>
        </div>
        <div class="rg5">
            @UIHelper.PagesHelper(ViewBag.ControllerName, Model.TotalPages, Model.PageIndex, Model.PageSize, Model.TotalCount, Model.HasPreviousPage, Model.HasNextPage, Model.PageList)
        </div>
    </div>
</div>
<script>
    //菜单显示
    $("#@(ViewBag.ControllerName)sys").addClass("hbg");
    $("#@(ViewBag.ControllerName)").removeClass("navli");
    $("#@(ViewBag.ControllerName)").addClass("navlihg");
    $(".@(ViewBag.ControllerName)sys").each(function (index, item) {
        $(this).show();
    });
</script>

Add.cshtml

#@(ViewBag.ControllerName)sys").addClass("hbg");
    $("#@(ViewBag.ControllerName)").removeClass("navli");
    $("#@(ViewBag.ControllerName)").addClass("navlihg");
    $(".@(ViewBag.ControllerName)sys").each(function (index, item) {
        $(this).show();
    });
</script>

Edit.cshtml

" value="@Model.LogName"/>
                    </dd>
                </dl>
                <dl>
                    <dd class="dc1">昵称:</dd>
                    <dd>
                        <input name="TrueName" type="text" class="rgtxt2" datatype="n" nullmsg="请输入产品名称" value="@Model.TrueName" />
                    </dd>
                </dl>
                <dl>
                    <dd class="dc1">Email:</dd>
                    <dd>
                        <input type="text" name="Email" id="Email" class="rgtxt2" value="@Model.Email" />
                    </dd>
                </dl>
                <dl>
                    <dd class="dc1">手机号:</dd>
                    <dd>
                        <input type="text" name="Mobile" id="Mobile" class="rgtxt2" value="@Model.Mobile" />
                    </dd>
                </dl>
                <dl>
                    <dd class="dc1">修改密码:</dd>
                    <dd>
                        <input type="text" name="Password" id="Password" class="rgtxt2" value="@Model.Password" />
                    </dd>
                </dl>
                <dl>
                    <dd class="dc1">岗位:</dd>
                    <dd>
                        @Html.DropDownList("JobID", ViewBag.JobID as SelectList)
                    </dd>
                </dl>
                <dl>
                    <dd class="dc1">部门:</dd>
                    <dd>
                         @Html.DropDownList("DepartmentID", ViewBag.DepartmentID as SelectList)
                    </dd>
                </dl>
                <dl>
                    <dd class="dc1">角色:</dd>
                    <dd>
                         @Html.DropDownList("RoleID", ViewBag.RoleID as SelectList)
                    </dd>
                </dl>
                <dl>
                    <dd>
                        <input type="submit" value="提 交" class="rgbut4" />
                    </dd>
                </dl>
            }
        </div>
    </div>
</div>
<script>
    //菜单显示
    $("#@(ViewBag.ControllerName)sys").addClass("hbg");
    $("#@(ViewBag.ControllerName)").removeClass("navli");
    $("#@(ViewBag.ControllerName)").addClass("navlihg");
    $(".@(ViewBag.ControllerName)sys").each(function (index, item) {
        $(this).show();
    });
</script>

Search.cshtml

/@ViewBag.ControllerName/search">
                <dl>
                    <dd>关键词:</dd>
                    <dd>
                        <input name="KeyWord" type="text" class="rgtxt2" /></dd>
                    <dd>
                        <input type="submit" value="查 询" class="rgbut1" /></dd>
                </dl>
            </form>
        </div>
        <div class="rgc">
            <dl class="rgt11">
                <dt>
                    <span class="sple"><a href="/systemuser/add">添加用户</a></span>
                </dt>
            </dl>
            <div class="rg3">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td class="rgtd2">用户编号</td>
                        <td class="rgtd3">登录名</td>
                        <td class="rgtd3">手机</td>
                        <td class="rgtd3">Email</td>
                        <td class="rgtd3">昵称</td>
                        <td class="rgtd3">状态</td>
                        <td class="rgtd4">操作</td>
                    </tr>
                </table>
            </div>
            <div class="rg4">
                @{int classnum = 1;}
                @foreach (var item in Model)
                {
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" @if (classnum % 2 == 0)
                                                                                   {<text>class="rgbg2"</text>}>
                        <tr>
                            <td class="rgtd2">@item.SystemUserID</td>
                            <td class="rgtd3">@(item.LogName)</td>
                            <td class="rgtd3">@item.Mobile</td>
                            <td class="rgtd3">@item.Email</td>
                            <td class="rgtd3">@item.TrueName</td>
                            <td class="rgtd3">@(item.State == 1 ? "有效" : "无效")</td>
                            <td class="rgtd4"><a href="/systemuser/delete/@item.SystemUserID">删除</a> | <a href="/systemuser/edit/@item.SystemUserID">编辑</a>  </td>
                        </tr>
                    </table>
                                                                                   classnum = classnum + 1;
                }
            </div>
        </div>
    </div>
</div>
<script>
    //菜单显示
    $("#@(ViewBag.ControllerName)sys").addClass("hbg");
    $("#@(ViewBag.ControllerName)").removeClass("navli");
    $("#@(ViewBag.ControllerName)").addClass("navlihg");
    $(".@(ViewBag.ControllerName)sys").each(function (index, item) {
        $(this).show();
    });
</script>

 角色管理

Controller代码

/@ViewBag.ControllerName/search">
                <dl>
                    <dd>关键词:</dd>
                    <dd>
                        <input name="KeyWord" type="text" class="rgtxt2" /></dd>
                    <dd>
                        <input type="submit" value="查 询" class="rgbut1" /></dd>
                </dl>
            </form>
        </div>
        <div class="rgc">
            <dl class="rgt11">
                <dt>
                   <span class="sple"><a href="/@ViewBag.ControllerName/add">添加</a></span>
                </dt>
            </dl>
            <div class="rg3">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td class="rgtd2">编号</td>
                        <td class="rgtd2">角色名称</td>
                        <td class="rgtd3">角色内容</td>
                        <td class="rgtd3">创建时间</td>
                        <td class="rgtd3">状态</td>
                        <td class="rgtd4">操作</td>
                    </tr>
                </table>
            </div>
            <div class="rg4">
                @{int classnum = 1;}
                @foreach (var item in Model)
                {
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" @if (classnum % 2 == 0)
                                                                                   {<text>class="rgbg2"</text>}>
                        <tr>
                            <td class="rgtd2">@item.RoleID</td>
                            <td class="rgtd2">@item.RoleName</td>
                            <td class="rgtd3">@item.RoleContent</td>
                            <td class="rgtd3">@String.Format("{0:yyyy-MM-dd}", item.CreateTime)</td>
                            <td class="rgtd3">@(item.State == 1 ? "有效" : "无效")</td>
                            <td class="rgtd4"><a href="/@ViewBag.ControllerName/delete/@item.RoleID">删除</a> | <a href="/@ViewBag.ControllerName/edit/@item.RoleID">编辑</a>  </td>
                        </tr>
                    </table>
                                                                                   classnum = classnum + 1;
                }
            </div>
        </div>
        <div class="rg5">
           @UIHelper.PagesHelper(ViewBag.ControllerName, Model.TotalPages, Model.PageIndex, Model.PageSize, Model.TotalCount, Model.HasPreviousPage, Model.HasNextPage, Model.PageList);
        </div>
    </div>
</div>
<script>
    //菜单显示
    $("#systemusersys").addClass("hbg");
    $("#@(ViewBag.ControllerName)").removeClass("navli");
    $("#@(ViewBag.ControllerName)").addClass("navlihg");
    $(".systemusersys").each(function (index, item) {
        $(this).show();
    });
</script>

Add.cshtml

#@(ViewBag.ControllerName)").removeClass("navli");
    $("#@(ViewBag.ControllerName)").addClass("navlihg");
    $(".systemusersys").each(function (index, item) {
        $(this).show();
    });
</script>

Edit.cshtml

" value="@Model.RoleName"/>
                     </dd>
                 </dl>
       <dl>
                     <dd class="dc1">角色权限:</dd>
                     <dd>
                         @Html.CheckBoxList("Menu")
                     </dd>
                 </dl>
                 <dl>
                     <dd class="dc1">角色内容:</dd>
                     <dd>
                          <textarea rows="10" cols="82" name="RoleContent" id="RoleContent">@Model.RoleName</textarea>
                     </dd>
                 </dl>
                 <dl>
                     <dd>
                         <input type="submit" value="提 交" class="rgbut4" />
                     </dd>
                 </dl>
             }
         </div>
     </div>
 </div>
 <script>
     //菜单显示
     $("#systemusersys").addClass("hbg");
     $("#@(ViewBag.ControllerName)").removeClass("navli");
     $("#@(ViewBag.ControllerName)").addClass("navlihg");
     $(".systemusersys").each(function (index, item) {
         $(this).show();
     });
 </script>

Search.cshtml

/@ViewBag.ControllerName/search">
                <dl>
                    <dd>关键词:</dd>
                    <dd>
                        <input name="KeyWord" type="text" class="rgtxt2" /></dd>
                    <dd>
                        <input type="submit" value="查 询" class="rgbut1" /></dd>
                </dl>
            </form>
        </div>
        <div class="rgc">
            <dl class="rgt11">
                <dt>
                   <span class="sple"><a href="/@ViewBag.ControllerName/add">添加</a></span>
                </dt>
            </dl>
            <div class="rg3">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td class="rgtd2">编号</td>
                        <td class="rgtd2">角色名称</td>
                        <td class="rgtd3">角色内容</td>
                        <td class="rgtd3">创建时间</td>
                        <td class="rgtd3">状态</td>
                        <td class="rgtd4">操作</td>
                    </tr>
                </table>
            </div>
            <div class="rg4">
                @{int classnum = 1;}
                @foreach (var item in Model)
                {
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" @if (classnum % 2 == 0)
                                                                                   {<text>class="rgbg2"</text>}>
                        <tr>
                            <td class="rgtd2">@item.RoleID</td>
                            <td class="rgtd2">@item.RoleName</td>
                            <td class="rgtd3">@item.RoleContent</td>
                            <td class="rgtd3">@String.Format("{0:yyyy-MM-dd}", item.CreateTime)</td>
                            <td class="rgtd3">@(item.State == 1 ? "有效" : "无效")</td>
                            <td class="rgtd4"><a href="/@ViewBag.ControllerName/delete/@item.RoleID">删除</a> | <a href="/@ViewBag.ControllerName/edit/@item.RoleID">编辑</a>  </td>
                        </tr>
                    </table>
                                                                                   classnum = classnum + 1;
                }
            </div>
        </div>
    </div>
</div>
<script>
    //菜单显示
    $("#systemusersys").addClass("hbg");
    $("#@(ViewBag.ControllerName)").removeClass("navli");
    $("#@(ViewBag.ControllerName)").addClass("navlihg");
    $(".systemusersys").each(function (index, item) {
        $(this).show();
    });
</script>

 菜单管理

Controller代码

/@ViewBag.ControllerName/search">
                <dl>
                    <dd>关键词:</dd>
                    <dd>
                        <input name="KeyWord" type="text" class="rgtxt2" /></dd>
                    <dd>
                        <input type="submit" value="查 询" class="rgbut1" /></dd>
                </dl>
            </form>
        </div>
        <div class="rgc">
            <dl class="rgt11">
                <dt>
                   <span class="sple"><a href="/@ViewBag.ControllerName/add">添加</a></span>
                </dt>
            </dl>
            <div class="rg3">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td class="rgtd2">编号</td>
                        <td class="rgtd3">菜单名称</td>
                        <td class="rgtd3">别名样式</td>
                        <td class="rgtd3">连接地址</td>
                        <td class="rgtd3">创建时间</td>
                        <td class="rgtd3">状态</td>
                        <td class="rgtd4">操作</td>
                    </tr>
                </table>
            </div>
            <div class="rg4">
                @{int classnum = 1;}
                @foreach (var item in Model)
                {
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" @if (classnum % 2 == 0)
                                                                                   {<text>class="rgbg2"</text>}>
                        <tr>
                            <td class="rgtd2">@item.MenuID</td>
                            <td class="rgtd3">@item.MenuName</td>
                            <td class="rgtd3">@item.Alias</td>
                            <td class="rgtd3">@item.Url</td>
                            <td class="rgtd3">@String.Format("{0:yyyy-MM-dd}", item.CreateTime)</td>
                            <td class="rgtd3">@(item.State == 1 ? "有效" : "无效")</td>
                            <td class="rgtd4"><a href="/@ViewBag.ControllerName/delete/@item.MenuID">删除</a> | <a href="/@ViewBag.ControllerName/edit/@item.MenuID">编辑</a>  </td>
                        </tr>
                    </table>
                                                                                   classnum = classnum + 1;
                }
            </div>
        </div>
        <div class="rg5">
           @UIHelper.PagesHelper(ViewBag.ControllerName, Model.TotalPages, Model.PageIndex, Model.PageSize, Model.TotalCount, Model.HasPreviousPage, Model.HasNextPage, Model.PageList);
        </div>
    </div>
</div>
<script>
    //菜单显示
    $("#systemusersys").addClass("hbg");
    $("#@(ViewBag.ControllerName)").removeClass("navli");
    $("#@(ViewBag.ControllerName)").addClass("navlihg");
    $(".systemusersys").each(function (index, item) {
        $(this).show();
    });
</script>

Add.cshtml

#@(ViewBag.ControllerName)").removeClass("navli");
    $("#@(ViewBag.ControllerName)").addClass("navlihg");
    $(".systemusersys").each(function (index, item) {
        $(this).show();
    });
</script>

Edit.cshtml

" value="@Model.MenuName" />
                    </dd>
                </dl>
                <dl>
                    <dd class="dc1">连接地址:</dd>
                    <dd>
                        <input name="Url" type="text" class="rgtxt2" datatype="n" nullmsg="请输入产品名称" value="@Model.Url" />
                    </dd>
                </dl>
                <dl>
                    <dd class="dc1">别名样式:</dd>
                    <dd>
                        <input name="Alias" type="text" class="rgtxt2" datatype="n" nullmsg="请输入产品名称" value="@Model.Alias" />
                    </dd>
                </dl>
                <dl>
                    <dd>
                        <input type="submit" value="提 交" class="rgbut4" />
                    </dd>
                </dl>
            }
        </div>
    </div>
</div>
<script>
    //菜单显示
    $("#systemusersys").addClass("hbg");
    $("#@(ViewBag.ControllerName)").removeClass("navli");
    $("#@(ViewBag.ControllerName)").addClass("navlihg");
    $(".systemusersys").each(function (index, item) {
        $(this).show();
    });
</script>

Search.cshtml

/@ViewBag.ControllerName/search">
                 <dl>
                     <dd>关键词:</dd>
                     <dd>
                         <input name="KeyWord" type="text" class="rgtxt2" /></dd>
                     <dd>
                         <input type="submit" value="查 询" class="rgbut1" /></dd>
                 </dl>
             </form>
         </div>
         <div class="rgc">
             <dl class="rgt11">
                 <dt>
                    <span class="sple"><a href="/@ViewBag.ControllerName/add">添加</a></span>
                 </dt>
             </dl>
             <div class="rg3">
                 <table width="100%" border="0" cellspacing="0" cellpadding="0">
                     <tr>
                         <td class="rgtd2">编号</td>
                         <td class="rgtd3">菜单名称</td>
                         <td class="rgtd3">别名样式</td>
                         <td class="rgtd3">连接地址</td>
                         <td class="rgtd3">创建时间</td>
                         <td class="rgtd3">状态</td>
                         <td class="rgtd4">操作</td>
                     </tr>
                 </table>
             </div>
             <div class="rg4">
                 @{int classnum = 1;}
                 @foreach (var item in Model)
                 {
                &nbs
代码注释

作者:喵哥笔记

IDC笔记

学的不仅是技术,更是梦想!

© 2020 IDC笔记 . | 备案号:辽ICP备18000516号