转载

Web应用程序系统的多用户权限控制设计及实现-页面模块【9】

前五章均是从整体上讲述了Web应用程序的多用户权限控制实现流程,本章讲述Web权限管理系统的基本模块-页面模块。页面模块涉及到的数据表为页面表。

1.1分组域

为了更规范和方便后期系统的二次开发和维护,对应特定的业务模块采用Area(域)的方式开发,页面模块的开发域如下图所示:

由于在Areas下还建立了一个新的目录SystemManage,故需要改变原来的路由。页面模块的路由文件名称为pageManageAreaRegistration。改变路由代码的文件名称为如下:

using System.Web.Mvc;

namespace CodeForMvcTest.Areas.PageManage

{

public class PageManageAreaRegistration : AreaRegistration

{

public override string AreaName

{

get

{

return "SystemManage/PageManage";

}

}

public override void RegisterArea(AreaRegistrationContext context)

{

context.MapRoute(

"SystemManage_PageManage_default",

"SystemManage/PageManage/{controller}/{action}/{id}",

new { action = "Index", id = UrlParameter.Optional }

);

}

}

}

1.2Model

页面模块的Model可参看第三章项目架构的系统共有类,对应model为Page.cs。文件路径为Areas/SystemManage/Models。

1.3视图

页面模块的视图包含在页面域中,文件路径为Areas/SystemManage/OperatorManage/Views/PageManage,视图名称为PageMange.cshtml。视图的完整代码如下:

Web应用程序系统的多用户权限控制设计及实现-页面模块【9】
  1 @{   2     ViewBag.Title = "页面管理";   3     Layout = "~/Views/Shared/_BaseLayout.cshtml";   4 }   5    6    7    8 <div class="easyui-layout" data-options="fit:true">   9   10     <div data-options="region:'north',split:true" style="height: 50px;">  11         <form id="searchForm" method="POST" action="@Url.Action("PageManage", "PageManage")">  12             <!--属性组筛选栏-->  13             <table style="margin-left: 5px; margin-top: 5px;">  14                 <tr>  15                     <td><span>栏目:</span></td>  16                     <td>  17                         <select class="easyui-combotree" name="categoryId" id="categoryId" style="width: 180px;"  18                             data-options="url:'/SystemManage/PageManage/PageManage/InitCatalog'">  19                         </select>  20                     </td>  21                     <td><span style="margin-left: 10px;">状态:</span></td>  22                     <td>  23                         <select class="easyui-combobox" name="isAvailable" id="isAvailable" style="width: 150px;"  24                             data-options="editable:false">  25                             <option value="-1">全部</option>  26                             <option value="1">启用</option>  27                             <option value="0">不启用</option>  28                         </select>  29                     </td>  30                     <td><span style="margin-left: 10px;">页面名称:</span></td>  31                     <td>  32                         <input class="easyui-validatebox" id="pageName" name="pageName" />  33                     </td>  34                     <td>  35                         <input type="submit" value="查找" id="btn_submit" style="margin-left: 10px; margin-right: 10px;" />  36                     </td>  37                 </tr>  38             </table>  39         </form>  40     </div>  41   42     <div data-options="region:'center',split:true" style="padding-bottom: 10px;" id="centerDiv">  43         <table id="dataGrid">  44             <thead>  45                 <tr>  46                     <th data-options="field:'CategoryName',align:'left'">所属栏目</th>  47                     <th data-options="field:'PageIndex',align:'left'">页面ID</th>  48                     <th data-options="field:'PageName',align:'left'">页面名称</th>  49                     <th data-options="field:'PageUrl',align:'left'">页面访问地址</th>  50                     <th data-options="field:'Title',align:'left'">报表标题</th>  51                     <th data-options="field:'Subtitle',align:'left'">副标题</th>  52                     <th data-options="field:'ShowNum',align:'left'">排序值</th>  53                     <th data-options="field:'IsAvailable',align:'center',formatter:statusformater">状态</th>  54                     <th data-options="field:'Operate',align:'center',formatter:operateFormater">操作</th>  55                 </tr>  56             </thead>  57             <tbody>  58             </tbody>  59         </table>  60         <br />  61     </div>  62   63 </div>  64   65 <!--属性组工具栏-->  66 <div id="page_tb" style="height: auto">  67     <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="openAddWindow();">添加页面</a>  68 </div>  69   70   71 <!--页面信息编辑窗体-->  72 <div id="pageEditWin" title="修改页面信息" style="width: 450px; height: 460px; padding: 20px; text-align: center;">  73     <form id="pageEditForm" method="POST" action="@Url.Action("UpdatePage", "PageManage")">  74         <table style="margin: auto;">  75             <tr>  76                 <td style="text-align: right;"><span>栏目:</span></td>  77                 <td>  78                     <select class="easyui-combotree" name="CategoryId" id="e_categoryId" style="width: 200px;"  79                         data-options="url:'/SystemManage/PageManage/PageManage/InitCatalogWithoutRoot'">  80                     </select>  81                 </td>  82             </tr>  83             <tr style="height: 30px;">  84                 <td style="text-align: right;"><span>名称:</span></td>  85                 <td>  86                     <input class="easyui-validatebox" id="e_pageName" name="PageName" style="width: 200px;" />  87                 </td>  88             </tr>  89             <tr style="height: 30px;">  90                 <td style="text-align: right;"><span>访问路径:</span></td>  91                 <td>  92                     <input class="easyui-validatebox" id="e_pageUrl" name="PageUrl" style="width: 200px;" />  93                 </td>  94             </tr>  95             <tr style="height: 30px;">  96                 <td style="text-align: right;"><span>标题:</span></td>  97                 <td>  98                     <input class="easyui-validatebox" id="e_title" name="Title" style="width: 200px;" />  99                 </td> 100             </tr> 101             <tr style="height: 30px;"> 102                 <td style="text-align: right;"><span>副标题:</span></td> 103                 <td> 104                     <input class="easyui-validatebox" id="e_subtitle" name="Subtitle" style="width: 200px;" /> 105                 </td> 106             </tr> 107             <tr style="height: 30px;"> 108                 <td style="text-align: right;"><span>显示顺序:</span></td> 109                 <td> 110                     <input class="easyui-numberbox" id="e_showNum" name="ShowNum" style="width: 205px;" /> 111                 </td> 112             </tr> 113             <tr style="height: 40px;"> 114                 <td style="text-align: right;"><span>状态:</span></td> 115                 <td> 116                     <select class="easyui-combobox" name="IsAvailable" id="e_isAvailable" style="width: 205px;" 117                         data-options="editable:false,required:true"> 118                         <option value="0">不可用</option> 119                         <option value="1">可用</option> 120                     </select> 121                 </td> 122             </tr> 123             <tr style="height: 50px;"> 124                 <td colspan="2" style="text-align: right;"> 125                     <input type="hidden" id="e_pageIndex" name="PageIndex" /> 126                     <input type="reset" style="display: none;" /> 127                     <input type="submit" value="提交" id="btn_editsubmit" style="margin-left: 10px; margin-right: 10px;" /> 128                     <input type="button" value="取消" id="btn_editCancel" onclick="javascript: return $('#pageEditWin').window('close');" 129                         style="margin-left: 10px; margin-right: 10px;" /> 130                 </td> 131             </tr> 132         </table> 133     </form> 134 </div> 135  136  137  138  139  140 @section scripts 141 { 142     <script type="text/javascript"  src="/Areas/SystemManage/SystemJS/pageManage.js"></script> 143 }
PageMange.cshtml

1.4JS文件

页面模块相关的JS文件路径为Areas/SystemManage/SystemJS,JS文件名称为pageManage.js。JS的完整代码如下:

Web应用程序系统的多用户权限控制设计及实现-页面模块【9】
  1 //状态显示格式化   2 function statusformater(value, row, index) {   3     if (value == "0") {   4         return "不可用";   5     } else {   6         return "可用";   7     }   8 };   9   10 //属性组操作显示格式化  11 function operateFormater(value, row, index) {  12     var operationStr = "<a href='#' onclick=/"openEditWindow(" + row.CategoryId + "," + row.PageIndex + ",'" + row.PageName  13         + "','" + row.PageUrl + "','" + row.Title + "','" + row.Subtitle + "'," + row.ShowNum + "," + row.IsAvailable  14         + ");/" style='margin-right:10px;'>编辑</a>";  15     return operationStr;  16 };  17   18   19 //开启编辑窗体  20 function openEditWindow(categoryId, pageIndex,  21     pageName, pageUrl, title, subtitle, showNum, isAvailable) {  22     $("#e_categoryId").combotree('setValue', categoryId);  23     $("#e_pageName").val(pageName);  24     $("#e_pageUrl").val(pageUrl);  25     $("#e_title").val(title);  26     $("#e_subtitle").val(subtitle);  27     $("#e_showNum").numberbox('setValue', showNum);  28     $("#e_isAvailable").combobox('select', isAvailable);  29     $("#e_pageIndex").val(pageIndex);  30   31     $('#pageEditWin').window({  32         title: '修改页面',  33     });  34     $('#pageEditWin').window('open');  35 };  36   37   38 //“点击添加按钮时,打开添加用户窗体”  39 function openAddWindow() {  40     $("#e_pageName").val("");  41     $("#e_pageUrl").val("");  42     $("#e_title").val("");  43     $("#e_subtitle").val("");  44     $('#e_categoryId').combotree('setValue', 0); //重新加载数据   45     $("#e_isAvailable").combobox('setValue', 0);  46     $("#e_pageIndex").val("-1");  47     $('#pageEditWin').window({  48         title: '新增页面',  49     });  50     $('#pageEditWin').window('open');  51 };  52   53   54 //删除用户  55 function deletePage(pageId) {  56     startDatagridLoading("dataGrid", "btn_submit");  57     $.ajax({  58         url: '/SystemManage/PageManage/PageManage/DeletePage',  59         type: 'POST',  60         dataType: 'text',  61         data: { pageId: pageId },  62         success: function (data) {  63             if (data.indexOf("/Login/Login") >= 0) {  64                 window.parent.location.href = '/Login/Login';  65             }  66             var groupId = $("#groupId").combobox('getValue');  67             var pageName = $("#pageName").val();  68             var url = "/SystemManage/PageManage/PageManage/PageManage?groupId=" + groupId  69                 + "&pageName=" + pageName;  70   71             alert(data);  72   73             reloadDatagrid(url, "dataGrid", "btn_submit", "无页面数据返回!", "查询页面数据出错!");  74         },  75         error: function (data) {  76             commErrorHandle(data, true, 'dataGrid', 'btn_submit', "操作出错!");  77         }  78     });  79 };  80   81   82 $(function () {  83     //设置DataGrid基本属性  84     var centerHeight = $("#centerDiv").height();  85     $("#dataGrid").datagrid({  86         height: centerHeight - 15,  87         rownumbers: false,  88         singleSelect: true,  89         autoRowHeight: false,  90         fitColumns: true,  91         pagination: true,  92         pageSize: 20,  93         loadMsg: 'Loading... ...',  94         url: '/SystemManage/PageManage/PageManage/PageManage?categoryId=0&isAvailable=-1&pageName=',  95         toolbar: '#page_tb',  96         title: "页面列表",  97         remoteSort: false,  98         onLoadSuccess: function (data) {  99             //设置查询按钮可用 100             $("#btn_submit").attr("disabled", false); 101             if (data.total <= 0) 102                 alert("无数据返回!"); 103             $(".datagrid-wrap.panel-body").css("width", '100%'); 104             $(".datagrid-wrap.panel-body .datagrid-view").css("width", '100%'); 105         }, 106         onLoadError: function (data) { 107             //判断是否是首次加载,不是首次加载再判断错误原因 108             var isFirstLoad = $("#firstLoadFlag").val(); 109             if (isFirstLoad == "false") { 110                 //设置查询按钮可用 111                 $("#btn_submit").attr("disabled", false); 112                 if (data.responseText.indexOf("/Login/Login") >= 0) { 113                     window.parent.location.href = '/Login/Login'; 114                 } else { 115                     $("#btn_submit").attr("disabled", false); 116                     //隐藏加载状态 117                     $('#dataGrid').datagrid('loaded'); 118                     alert("对不起,查询失败!"); 119                 } 120             } 121         } 122     }); 123  124     $('#pageEditWin').window({ 125         modal: true, 126         collapsible: false, 127         minimizable: false, 128         maximizable: false, 129         draggable: true, 130         resizable: false, 131         closable: false, 132         closed: true 133     }); 134  135     $("#searchForm").submit(function (event) { 136         //中断当前的提交事件 137         event.preventDefault(); 138         //将首次加载标志设置为false 139         $("#firstLoadFlag").val("false"); 140         //清空数据 141         $("#dataGrid").datagrid('loadData', { total: 1, rows: [] }); 142         //查询条件 143         var categoryId = $("#categoryId").combotree("getValue"); 144         if (categoryId == "") { 145             categoryId = "0"; 146         } 147         var isAvailable = $("#isAvailable").combobox("getValue"); 148         var pageName = $("#pageName").val(); 149  150         $("#btn_submit").attr("disabled", true); 151         $("#dataGrid").datagrid('load', { 152             categoryId: categoryId, 153             isAvailable: isAvailable, 154             pageName: pageName 155         }); 156     }); 157  158  159  160     //修改页面信息 161     $("#pageEditForm").submit(function (event) { 162         //中断当前的提交事件 163         event.preventDefault(); 164         //提交的URL,默认为属性组修改或添加路径 165         var url = "/SystemManage/PageManage/PageManage/UpdatePage"; 166         //路径 167         var pageUrl = $("#e_pageUrl").val(); 168         if (pageUrl == "") { 169             alert("路径不能为空!"); 170             return false; 171         } 172         //名称 173         var pageName = $("#e_pageName").val(); 174         if (pageName == "") { 175             alert("名称不能为空!"); 176             return false; 177         } 178  179         //排序值 180         var orderNum = $("#e_showNum").numberbox('getValue'); 181         if (orderNum == "") { 182             alert("排序值不能为空!"); 183             return false; 184         } 185  186         //判断是增加页面还是修改页面信息 187         var pageIndex = $("#e_pageIndex").val(); 188         if (pageIndex == "-1") { 189             url = "/SystemManage/PageManage/PageManage/AddPage"; 190         } 191  192         $('#pageEditWin').window('close'); 193  194         $("#dataGrid").datagrid("loading"); 195         $("#btn_submit").attr("disabled", true); 196  197         //startDatagridLoading('dataGrid', 'btn_submit'); 198  199         //表单序列化 200         var formData = $("#pageEditForm").serializeJson(); 201         var categoryId = $("#e_categoryId").combotree("getValue"); 202         formData.CategoryId = categoryId; 203  204         //完整路径 205         //url = url + "?" + formData; 206  207         $.ajax({ 208             url: url, 209             type: 'POST', 210             data: { pageStr: JSON.stringify(formData) }, 211             dataType: 'text', 212             traditional: true, 213             success: function (data) { 214                 if (data.indexOf("/Login/Login") >= 0) { 215                     window.parent.location.href = '/Login/Login'; 216                 } 217                 categoryId = $("#categoryId").combotree('getValue'); 218                 if (categoryId == "") { 219                     categoryId = "0"; 220                 } 221                 var isAvailable = $("#isAvailable").combobox("getValue"); 222                 pageName = $("#pageName").val(); 223  224                 $("#btn_submit").attr("disabled", false); 225                 $("#dataGrid").datagrid('load', { 226                     categoryId: categoryId, 227                     isAvailable: isAvailable, 228                     pageName: pageName 229                 }); 230  231                 alert(data); 232  233                 // reloadDatagrid(url, "dataGrid", "btn_submit", "无页面数据返回!", "查询页面数据出错!"); 234             }, 235             error: function (data) { 236                 commErrorHandle(data, true, 'dataGrid', 'btn_submit', "操作出错!"); 237             } 238         }); 239     }); 240  241  242 });
pageManage.js

1.5控制器

页面模块的控制器包含在页面域中,文件路径为Areas/SystemManage/PageMange/Controllers,控制器名称为PageManageController.cs。控制器的完整代码如下:

Web应用程序系统的多用户权限控制设计及实现-页面模块【9】
  1 using System;   2 using System.Collections.Generic;   3 using System.Linq;   4 using System.Web;   5 using System.Web.Mvc;   6 using Session;   7 using OdbcDbAccess;   8 using System.Data;   9 using Models;  10 using Controllers;  11 using System.Data.SqlClient;  12 using Newtonsoft.Json;  13 using LogInfo;  14   15   16 namespace CodeForMvcTest.Areas.PageManage.Controllers  17 {  18     //|++++++++++++++++++++++++++++++  19     /// 功能:页面信息类  20     /// 作者:Author  21     /// 时间:2015-7-17  22     /// 邮箱:1129137758@qq.com  23     //|+++++++++++++++++++++++++++++  24     public class PageManageController : BaseController  25     {  26         public ActionResult PageManage()  27         {  28             return View();  29         }  30   31   32         //初始化栏目树  33         public ActionResult InitCatalog()  34         {  35             IList<TreeModel> resultList = new List<TreeModel>();  36             try  37             {  38                 //获取栏目信息  39                 string strSql = "select * from catalog order by catalogid,showno";  40                 DataSet categoryDt = SqlHelper.ExecuteQuery(SqlSeverConnectionName , strSql);  41                 if (categoryDt != null && categoryDt.Tables.Count > 0)  42                 {  43                     DataTable table = categoryDt.Tables[0];  44                     resultList = TreeModel.BuildTreeNodeListIncludeAll(table.Rows, "catalogid", "catalogname",  45                         "parentid");  46                 }  47             }  48             catch (Exception)  49             {  50             }  51   52             return Json(resultList, JsonRequestBehavior.AllowGet);  53         }  54   55   56   57   58         //初始化栏目树  59         public ActionResult InitCatalogWithoutRoot()  60         {  61             IList<TreeModel> resultList = new List<TreeModel>();  62             try  63             {  64                 //获取栏目信息  65                 string strSql = "select * from catalog order by catalogid,showno";  66                 DataSet categoryDt = SqlHelper.ExecuteQuery(SqlSeverConnectionName, strSql);  67                 if (categoryDt != null && categoryDt.Tables.Count > 0)  68                 {  69                     DataTable table = categoryDt.Tables[0];  70                     resultList = TreeModel.BuildTreeNodeList(table.Rows, "catalogid", "catalogname",  71                         "parentid", false);  72                 }  73             }  74             catch (Exception)  75             {  76             }  77   78             return Json(resultList, JsonRequestBehavior.AllowGet);  79         }  80   81   82   83         /// <summary>  84         /// 通过分类以及页面名称,返回页面数据列表  85         /// </summary>  86         /// <param name="categoryId">一级分类</param>  87         /// <param name="subcategoryId">二级分类</param>  88         /// <param name="isAvailable">页面启用状态</param>  89         /// <param name="pageName">页面名称</param>  90         /// <param name="page">当前页</param>  91         /// <param name="rows">每页显示条数</param>  92         /// <returns></returns>  93         [HttpPost]  94         public ActionResult PageManage(int categoryId, int isAvailable, string pageName, int page, int rows)  95         {  96             int totalCount = 0;  97             IList<Page> pageList = GetPageList(categoryId, isAvailable, pageName, page, rows, out totalCount);  98             //封装数据  99             object result = new 100             { 101                 total = totalCount, 102                 rows = pageList 103             }; 104             return Json(result); 105         } 106  107  108  109  110         /// <summary> 111         /// 修改页面信息 112         /// </summary> 113         /// <param name="pageStr">修改页面后的信息</param> 114         /// <returns></returns> 115         [HttpPost] 116         public ActionResult UpdatePage(string pageStr) 117         { 118             Page page = JsonConvert.DeserializeObject<Page>(pageStr); 119  120             string sql = "update pageinfo set showno=" + page.ShowNum + ",title='" + page.Title + "'," 121                 + "subtitle='" + page.Subtitle + "',isavailable=" + page.IsAvailable + ",pageurl='" + page.PageUrl + 122                 "',pagename='" + page.PageName + "',catalogid=" + page.CategoryId + " where pageid=" + page.PageIndex; 123  124             try 125             { 126                 127                 SqlHelper.ExecuteNonQuery(SqlSeverConnectionName ,sql); 128  129                 Log.SaveOperatorLog(sql, 1, "修改页面信息"); 130                 return Content("修改成功!"); 131             } 132             catch (Exception ex) 133             { 134                 Log.SaveErrorLog(ex.ToString(), "修改页面信息出错!"); 135                 return Content("修改页面信息失败!"); 136             } 137         } 138  139  140  141  142         /// <summary> 143         /// 添加页面 144         /// </summary> 145         /// <param name="pageStr">页面信息对应的json字符串</param> 146         /// <returns></returns> 147         [HttpPost] 148         public ActionResult AddPage(string pageStr) 149         { 150             Page page = JsonConvert.DeserializeObject<Page>(pageStr); 151             string sql = "select count(*) from pageinfo where catalogid='" + page.CategoryId + "' and pagename='" + page.PageName + "'"; 152             try 153             { 154                 int count = SqlHelper.ExecuteScalar<int>(SqlSeverConnectionName, sql); 155                 if (count > 0) 156                 { 157                     Log.SaveOperatorLog("", 0, "由于页面名称重复,添加页面失败"); 158                     return Content("在同一类别下,已经存在相同名称的页面!"); 159                 } 160                 sql = "insert into pageinfo (catalogid,showno,title,subtitle,isavailable,pageurl,pagename) values('" + page.CategoryId + "','" + page.ShowNum + "','" + page.Title + "','" + page.Subtitle + "','" + page.IsAvailable + "','" + page.PageUrl + "', '"+page.PageName+"')"; 161                 SqlHelper.ExecuteNonQuery(SqlSeverConnectionName, sql); 162                 Log.SaveOperatorLog(sql, 1, "添加页面"); 163                 return Content("添加成功!"); 164             } 165             catch (Exception ex) 166             { 167                 Log.SaveErrorLog(ex.ToString(), "添加页面信息出错!"); 168                 return Content("添加页面失败!"); 169             } 170         } 171  172  173  174  175         /// <summary> 176         /// 删除页面 177         /// </summary> 178         /// <param name="pageId">页面ID</param> 179         /// <returns></returns> 180         [HttpPost] 181         public ActionResult DeletePage(int pageId) 182         { 183             string sql = "delete from pageinfo where pageid='" + pageId + "'"; 184             try 185             { 186                 SqlHelper.ExecuteNonQuery(SqlSeverConnectionName ,sql); 187                 Log.SaveOperatorLog(sql, 1, "删除页面"); 188                 return Content("删除成功!"); 189             } 190             catch (Exception ex) 191             { 192                 Log.SaveErrorLog(ex.ToString(), "删除页面出错!"); 193                 return Content("删除页面失败!"); 194             } 195         } 196  197  198  199         /// <summary> 200         /// 查找页面信息 201         /// </summary> 202         /// <param name="categoryId">一级分类ID</param> 203         /// <param name="isAvailable">页面启用状态</param> 204         /// <param name="pageName">页面名称</param> 205         /// <param name="pageIndex"></param> 206         /// <param name="pageSize"></param> 207         /// <param name="totalCount"></param> 208         /// <returns></returns> 209         private IList<Page> GetPageList(int categoryId, int isAvailable, string pageName, 210             int pageIndex, int pageSize, out int totalCount) 211         { 212             IList<Page> pageList = new List<Page>(); 213             totalCount = 0; 214  215             #region 封装Sql 216  217             string sql = "select * from (select pageinfo.*,catalogname ,ROW_NUMBER() over(order by pageinfo.pageid) as rows from pageinfo left join catalog on pageinfo.catalogid=catalog.catalogid where 1=1 "; 218            219             string totalSql = "select count(*) from pageinfo where 1=1 "; 220             if (categoryId != 0) 221             { 222                 sql += " and pageinfo.catalogid in (select catalogid from catalog where catalogid=" + categoryId + " or parentid=" + categoryId + ")"; 223                 totalSql += " and catalogid in (select catalogid from catalog where catalogid=" + categoryId + " or parentid=" + categoryId + ")"; 224             } 225             if (isAvailable != -1) 226             { 227                 sql += " and pageinfo.isavailable=" + isAvailable; 228                 totalSql += " and isavailable=" + isAvailable; 229             } 230             if (!string.IsNullOrEmpty(pageName)) 231             { 232                 sql += " and pageinfo.pagename like '%" + pageName + "%'"; 233                 totalSql += " and pagename like '%" + pageName + "%'"; 234             } 235             sql += " ) as temptable where rows between " + (pageIndex - 1) * pageSize + " and " + pageSize * pageIndex + " "; 236  237             #endregion 238  239             try 240             { 241                 totalCount = SqlHelper.ExecuteScalar<int>(SqlSeverConnectionName , totalSql); 242  243                 if (totalCount > 0) 244                 { 245                     DataSet dataSet = SqlHelper.ExecuteQuery(SqlSeverConnectionName, sql); 246                     if (dataSet != null && dataSet.Tables.Count > 0) 247                     { 248                         //获取页面分类 249                         var table = dataSet.Tables[0]; 250                         foreach (DataRow dr in table.Rows) 251                         { 252                             #region 封装数据列表 253  254                             int class1Id = DBNull.Value.Equals(dr["catalogid"]) ? -1 : Convert.ToInt32(dr["catalogid"]); 255  256                             var item = new Page 257                             { 258                                 CategoryId = class1Id, 259                                 CategoryName = DBNull.Value.Equals(dr["catalogname"]) ? "" : Convert.ToString(dr["catalogname"]), 260                                 PageIndex = DBNull.Value.Equals(dr["pageid"]) ? -1 : Convert.ToInt32(dr["pageid"]), 261                                 PageName = DBNull.Value.Equals(dr["pagename"]) ? "" : Convert.ToString(dr["pagename"]), 262                                 PageUrl = DBNull.Value.Equals(dr["pageurl"]) ? "" : Convert.ToString(dr["pageurl"]), 263                                 Title = DBNull.Value.Equals(dr["title"]) ? "" : Convert.ToString(dr["title"]), 264                                 Subtitle = DBNull.Value.Equals(dr["subtitle"]) ? "" : Convert.ToString(dr["subtitle"]), 265                                 ShowNum = DBNull.Value.Equals(dr["showno"]) ? -1 : Convert.ToInt32(dr["showno"]), 266                                 IsAvailable = DBNull.Value.Equals(dr["isavailable"]) ? 0 : Convert.ToInt32(dr["isavailable"]) 267                             }; 268  269                             pageList.Add(item); 270  271                             #endregion 272                         } 273                     } 274                 } 275             } 276             catch (Exception ex) 277             { 278                 Log.SaveErrorLog(ex.ToString(), "查询页面出错"); 279             } 280             return pageList; 281         } 282  283  284     } 285 }
pageGroupMange.cs

1.6界面运行截图

页面管理主界面如下图所示:

页面访问地址由Areas下的返回路控制器由+控制器名称+Action名称。

编辑页面界面如下图所示:

添加页面界面如下图所示:

正文到此结束
Loading...