前五章均是從整體上講述了Web應用程序的多用戶權限控制實現流程,本章講述Web權限管理系統的基本模塊-頁面模塊。頁面模塊涉及到的數據表為頁面表。
為了更規范和方便後期系統的二次開發和維護,對應特定的業務模塊采用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 }
);
}
}
}
頁面模塊的Model可參看第三章項目架構的系統共有類,對應model為Page.cs。文件路徑為Areas/SystemManage/Models。
頁面模塊的視圖包含在頁面域中,文件路徑為Areas/SystemManage/OperatorManage/Views/PageManage,視圖名稱為PageMange.cshtml。視圖的完整代碼如下:
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" > 11 <form id="searchForm" method="POST" action="@Url.Action("PageManage", "PageManage")"> 12 <!--屬性組篩選欄--> 13 <table > 14 <tr> 15 <td><span>欄目:</span></td> 16 <td> 17 <select class="easyui-combotree" name="categoryId" id="categoryId" 18 data-options="url:'/SystemManage/PageManage/PageManage/InitCatalog'"> 19 </select> 20 </td> 21 <td><span >狀態:</span></td> 22 <td> 23 <select class="easyui-combobox" name="isAvailable" id="isAvailable" 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 >頁面名稱:</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" /> 36 </td> 37 </tr> 38 </table> 39 </form> 40 </div> 41 42 <div data-options="region:'center',split:true" 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" > 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="修改頁面信息" > 73 <form id="pageEditForm" method="POST" action="@Url.Action("UpdatePage", "PageManage")"> 74 <table > 75 <tr> 76 <td ><span>欄目:</span></td> 77 <td> 78 <select class="easyui-combotree" name="CategoryId" id="e_categoryId" 79 data-options="url:'/SystemManage/PageManage/PageManage/InitCatalogWithoutRoot'"> 80 </select> 81 </td> 82 </tr> 83 <tr > 84 <td ><span>名稱:</span></td> 85 <td> 86 <input class="easyui-validatebox" id="e_pageName" name="PageName" /> 87 </td> 88 </tr> 89 <tr > 90 <td ><span>訪問路徑:</span></td> 91 <td> 92 <input class="easyui-validatebox" id="e_pageUrl" name="PageUrl" /> 93 </td> 94 </tr> 95 <tr > 96 <td ><span>標題:</span></td> 97 <td> 98 <input class="easyui-validatebox" id="e_title" name="Title" /> 99 </td> 100 </tr> 101 <tr > 102 <td ><span>副標題:</span></td> 103 <td> 104 <input class="easyui-validatebox" id="e_subtitle" name="Subtitle" /> 105 </td> 106 </tr> 107 <tr > 108 <td ><span>顯示順序:</span></td> 109 <td> 110 <input class="easyui-numberbox" id="e_showNum" name="ShowNum" /> 111 </td> 112 </tr> 113 <tr > 114 <td ><span>狀態:</span></td> 115 <td> 116 <select class="easyui-combobox" name="IsAvailable" id="e_isAvailable" 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 > 124 <td colspan="2" > 125 <input type="hidden" id="e_pageIndex" name="PageIndex" /> 126 <input type="reset" /> 127 <input type="submit" value="提交" id="btn_editsubmit" /> 128 <input type="button" value="取消" id="btn_editCancel" onclick="javascript: return $('#pageEditWin').window('close');" 129 /> 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頁面模塊相關的JS文件路徑為Areas/SystemManage/SystemJS,JS文件名稱為pageManage.js。JS的完整代碼如下:
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頁面模塊的控制器包含在頁面域中,文件路徑為Areas/SystemManage/PageMange/Controllers,控制器名稱為PageManageController.cs。控制器的完整代碼如下:
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 /// 郵箱:[email protected] 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
頁面管理主界面如下圖所示:
頁面訪問地址由Areas下的返回路控制器由+控制器名稱+Action名稱。
編輯頁面界面如下圖所示:
添加頁面界面如下圖所示: