public static Sys_Config_ListPage GetListConfig(string moduleName, out Sys_Config_ListPage M_Model, out List<Sys_Config_Fieled> D_List) { ADOSys_Config_ListPage ListInstance = new ADOSys_Config_ListPage(); ADOSys_Config_Fieled FieledInstance = new ADOSys_Config_Fieled(); M_Model = null; D_List = null; try { if (!string.IsNullOrEmpty(moduleName)) { //第一步:根据传入模块获取Grid配置 List<Sys_Config_ListPage> _ListPage = ListInstance.GetListByWhere(" AND M_ModuleCode='" + moduleName + "'"); if (_ListPage.Count > 0) { M_Model = _ListPage[0]; } //第二步:根据模块获取所有字段 D_List = FieledInstance.GetListByWhere(" AND D_ModuleCode='" + moduleName + "'"); } else { M_Model = null; D_List = null; } } catch (System.Exception ex) { M_Model = null; D_List = null; } return M_Model; }
public static string GenToolbarNoPermissionHelper(this HtmlHelper helper, string moduleName, string prefix, string ToolBarConfig) { ADOComm comInstance = new ADOComm(); bool HiddeOther = false; Sys_Config_ListPage M_Model = new Sys_Config_ListPage(); //第一步:根据传入模块获取Grid配置 List<Sys_Config_ListPage> _ListPage = new DAL.ADOSys_Config_ListPage().GetListByWhere(" AND M_ModuleCode='" + moduleName + "'"); if (_ListPage.Count > 0) { M_Model = _ListPage[0]; } string strPrefix = ""; strPrefix = prefix; ToolBar bar = new ToolBar(); if (!string.IsNullOrEmpty(ToolBarConfig)) { bar = JsonConvert.DeserializeObject<ToolBar>("{" + ToolBarConfig + "}"); } var HasAdd = 1; var HasEdit = 1; var HasView = 1; var HasDel = 1; var HasImport = 1; var HasExport = 1; //var IS_OPEN_PERMISSION = ConfigHelper.GetApp("IS_OPEN_PERMISSION"); //if (!string.IsNullOrEmpty(IS_OPEN_PERMISSION) && IS_OPEN_PERMISSION == "true") //{ // var Permission = comInstance.UserPermissionList(QX.Config.SessionConfig.UserId()); // HasAdd = Permission.Where(o => o.Fun_UDef1 == strPrefix + "_add").Count(); // HasEdit = Permission.Where(o => o.Fun_UDef1 == strPrefix + "_edit").Count(); // HasView = Permission.Where(o => o.Fun_UDef1 == strPrefix + "_view").Count(); // HasDel = Permission.Where(o => o.Fun_UDef1 == strPrefix + "_delete").Count(); // HasImport = Permission.Where(o => o.Fun_UDef1 == strPrefix + "_import").Count(); // HasExport = Permission.Where(o => o.Fun_UDef1 == strPrefix + "_export").Count(); //} #region 按钮Html string Li_add = @"<li {add} id='{prefix}_toolbar_add' class='{toolbar_add}'><a class='hide' id='{prefix}_add' onclick='{prefix}ToolBar.Add()' href='#'>{addN}</a></li>"; string Li_edit = @"<li {edit} id='{prefix}_toolbar_edit' class='{toolbar_edit}'><a class='hide' id='{prefix}_edit' onclick='{prefix}ToolBar.Edit()' href='#'>{editN}</a></li>"; string Li_del = @"<li {del} id='{prefix}_toolbar_delete' class='{toolbar_delete}'><a class='hide' id='{prefix}_delete' onclick='{prefix}ToolBar.Delete()' href='#'>{delN}</a></li> "; string Li_view = @"<li {view} id='{prefix}_toolbar_view' class='{toolbar_view}'><a class='hide' id='{prefix}_view' onclick='{prefix}ToolBar.View()' href='#'>{viewN}</a></li> "; //string Li_import = @"<li {import} id='{prefix}_toolbar_import' class='{toolbar_import}'><a class='hide' id='{prefix}_import' onclick='{prefix}ToolBar.Import()' href='#'>{importN}</a></li>"; //string Li_export = @"<li {export} id='{prefix}_toolbar_export' class='{toolbar_export}'><a class='hide' id='{prefix}_export' onclick='{prefix}ToolBar.Export()' href='#'>{exportN}</a></li>"; string Li_search = @"<li {search} id='{prefix}_toolbar_search' class='{toolbar_search}'><input style='display:none' id='search_txt' type='text' value='' /> <a id='{prefix}_search' onclick='{prefix}ToolBar.Search()' href='#'>{searchN}</a> </li> "; string Li_Custom = @"<li {add} id='{prefix}_toolbar_add' class='{toolbar_add}'><a id='{prefix}_add' onclick='{prefix}ToolBar.Add()' href='#'>{addN}</a></li>"; #endregion #region 按钮解析 bool toolbar = !string.IsNullOrEmpty(bar.toolbar) ? true : false; string add = !string.IsNullOrEmpty(bar.add) ? "style='display:none'" : "style='display:block'"; string addN = !string.IsNullOrEmpty(bar.addN) ? bar.addN : "添加"; string addClass = !string.IsNullOrEmpty(bar.addClass) ? bar.addClass : "toolbar_add"; string edit = !string.IsNullOrEmpty(bar.edit) ? "style='display:none'" : "style='display:block'"; string editN = !string.IsNullOrEmpty(bar.editN) ? bar.editN : "修改"; string editClass = !string.IsNullOrEmpty(bar.editClass) ? bar.editClass : "toolbar_edit"; string del = !string.IsNullOrEmpty(bar.del) ? "style='display:none'" : "style='display:block'"; string delN = !string.IsNullOrEmpty(bar.delN) ? bar.delN : "删除"; string delClass = !string.IsNullOrEmpty(bar.delClass) ? bar.delClass : "toolbar_delete"; string view = !string.IsNullOrEmpty(bar.view) ? "style='display:none'" : "style='display:block'"; string viewN = !string.IsNullOrEmpty(bar.viewN) ? bar.viewN : "查看"; string viewClass = !string.IsNullOrEmpty(bar.viewClass) ? bar.viewClass : "toolbar_view"; //string import = !string.IsNullOrEmpty(bar.import) ? "style='display:none'" : "style='display:block'"; //string importN = !string.IsNullOrEmpty(bar.importN) ? bar.importN : "导入"; //string importClass = !string.IsNullOrEmpty(bar.importClass) ? bar.importClass : "toolbar_import"; //string export = !string.IsNullOrEmpty(bar.export) ? "style='display:none'" : "style='display:block'"; //string exportN = !string.IsNullOrEmpty(bar.exportN) ? bar.exportN : "导出"; //string exportClass = !string.IsNullOrEmpty(bar.exportClass) ? bar.exportClass : "toolbar_export"; string search = !string.IsNullOrEmpty(bar.search) ? "style='display:none'" : "style='display:block'"; string searchN = !string.IsNullOrEmpty(bar.searchN) ? bar.searchN : "搜索"; string searchClass = !string.IsNullOrEmpty(bar.searchClass) ? bar.searchClass : "toolbar_search"; #endregion #region 事件定义 string validatemethod = @" if ($.isFunction(window.{prefix}ToolBar{OpType})) { {prefix}ToolBar{OpType}(); } else { {nameSpace}_{moduleName}ToolBar{OpType}(); }"; string addJS = !string.IsNullOrEmpty(bar.addFunJs) ? "{prefix}" + bar.addFunJs : validatemethod.Replace("{OpType}", "Add"); string editJs = !string.IsNullOrEmpty(bar.editFunJs) ? "{prefix}" + bar.editFunJs : validatemethod.Replace("{OpType}", "Edit"); string delJs = !string.IsNullOrEmpty(bar.delFunJs) ? "{prefix}" + bar.delFunJs : validatemethod.Replace("{OpType}", "Del"); string viewJs = !string.IsNullOrEmpty(bar.viewFunJs) ? "{prefix}" + bar.viewFunJs : validatemethod.Replace("{OpType}", "View"); //string importJs = !string.IsNullOrEmpty(bar.importFunJs) ? "{prefix}" + bar.importFunJs : "{prefix}ToolBarImport()"; //string exportJs = !string.IsNullOrEmpty(bar.exportFunJs) ? "{prefix}" + bar.exportFunJs : "{prefix}ToolBarExport()"; string searchJs = !string.IsNullOrEmpty(bar.searchFunJs) ? "{prefix}" + bar.searchFunJs : "{prefix}ToolBarSearch()"; #endregion #region HTML生成 string str = @" <div id='{prefix}toolbar' class='toolbar'> <ul> {Li_add} {Li_edit} {Li_del} {Li_view} {Li_search} </ul> </div> <script type='text/javascript'> var {prefix}ToolBar = { Add: function() { {addJs}; }, Edit: function() { {editJs}; }, Delete: function() { {delJs}; }, View: function() { {viewJs}; }, Search: function() { {searchJs}; }, Import: function() { {importJs}; }, Export: function() { {exportJs}; }, HideElement:function(id){ $('#id').hide(); }, ChangeElement:function(id,name){ $('#id').find('a').val(name); } } //插入菜单项:文本,回调,位置(ID),样式 </script> "; #endregion Li_add = HasAdd > 0 ? Li_add : ""; Li_edit = HasEdit > 0 ? Li_edit : ""; Li_del = HasDel > 0 ? Li_del : ""; //Li_import = HasImport > 0 ? Li_import : ""; //Li_export = HasExport > 0 ? Li_export : ""; Li_view = HasView > 0 ? Li_view : ""; bool HasConfig = !string.IsNullOrEmpty(ToolBarConfig) ? true : false; if (HasConfig) { str = str.Replace("{Li_add}", ((!string.IsNullOrEmpty(bar.addN) || !string.IsNullOrEmpty(bar.addFunJs))) ? Li_add : ""); str = str.Replace("{Li_edit}", ((!string.IsNullOrEmpty(bar.editN) || !string.IsNullOrEmpty(bar.editFunJs))) ? Li_edit : ""); str = str.Replace("{Li_del}", ((!string.IsNullOrEmpty(bar.delN) || !string.IsNullOrEmpty(bar.delFunJs))) ? Li_del : ""); str = str.Replace("{Li_view}", ((!string.IsNullOrEmpty(bar.viewN) || !string.IsNullOrEmpty(bar.viewFunJs))) ? Li_view : ""); //str = str.Replace("{Li_import}", ((!string.IsNullOrEmpty(bar.importN) || !string.IsNullOrEmpty(bar.importFunJs))) ? Li_import : ""); //str = str.Replace("{Li_export}", ((!string.IsNullOrEmpty(bar.exportN) || !string.IsNullOrEmpty(bar.exportFunJs))) ? Li_export : ""); //str = str.Replace("{Li_search}", ((!string.IsNullOrEmpty(bar.searchN) || !string.IsNullOrEmpty(bar.searchFunJs))) ? Li_search : ""); } else//默认生成的话根据配置进行生成 { if (M_Model.M_IsAdd == 1) { str = str.Replace("{Li_add}", Li_add); } else { str = str.Replace("{Li_add}", ""); } if (M_Model.M_IsEdit == 1) { str = str.Replace("{Li_edit}", Li_edit); } else { str = str.Replace("{Li_edit}", ""); } if (M_Model.M_IsDelete == 1) { str = str.Replace("{Li_del}", Li_del); } else { str = str.Replace("{Li_del}", ""); } if (M_Model.M_IsView == "true") { str = str.Replace("{Li_view}", Li_view); } else { str = str.Replace("{Li_view}", ""); } //str = str.Replace("{Li_import}", Li_import); //str = str.Replace("{Li_export}", Li_export); } //搜索 默认输出 str = str.Replace("{Li_search}", Li_search); if (M_Model.M_IsAdd == 1) { str = str.Replace("{toolbar_add}", addClass); } else { str = str.Replace("{toolbar_add}", ""); } if (M_Model.M_IsEdit == 1) { str = str.Replace("{toolbar_edit}", editClass); } else { str = str.Replace("{toolbar_edit}", ""); } str = str.Replace("{toolbar_delete}", delClass); if (M_Model.M_IsView == "true") { str = str.Replace("{toolbar_view}", viewClass); } else { str = str.Replace("{toolbar_view}", ""); } //str = str.Replace("{toolbar_import}", importClass); //str = str.Replace("{toolbar_export}", exportClass); str = str.Replace("{toolbar_search}", searchClass); if (M_Model.M_IsAdd == 1) { str = str.Replace("{addJs}", addJS); } else { str = str.Replace("{addJs}", ""); } if (M_Model.M_IsEdit == 1) { str = str.Replace("{editJs}", editJs); } else { str = str.Replace("{editJs}", ""); } if (M_Model.M_IsDelete == 1) { str = str.Replace("{delJs}", delJs); } else { str = str.Replace("{delJs}", ""); } if (M_Model.M_IsView == "true") { str = str.Replace("{viewJs}", viewJs); } else { str = str.Replace("{viewJs}", ""); } //str = str.Replace("{viewJs}", viewJs); str = str.Replace("{searchJs}", searchJs); //str = str.Replace("{importJs}", importJs); //str = str.Replace("{exportJs}", exportJs); str = str.Replace("{searchJs}", searchJs); str = str.Replace("{prefix}", strPrefix); str = str.Replace("{newprefix}", prefix); str = str.Replace("{add}", add); str = str.Replace("{addN}", addN); str = str.Replace("{edit}", edit); str = str.Replace("{editN}", editN); str = str.Replace("{del}", del); str = str.Replace("{delN}", delN); str = str.Replace("{view}", view); str = str.Replace("{viewN}", viewN); //str = str.Replace("{import}", import); //str = str.Replace("{importN}", importN); //str = str.Replace("{export}", export); //str = str.Replace("{exportN}", exportN); str = str.Replace("{search}", search); str = str.Replace("{searchN}", searchN); str = str.Replace("{moduleName}", M_Model.M_ModuleCode); str = str.Replace("{nameSpace}", M_Model.M_NameSpace); if (toolbar) { str = ""; } return str; }
public static string GenToolbarHelper(this HtmlHelper helper, string moduleName, string prefix, bool HiddeOther, string ToolBarConfig) { ADOComm comInstance = new ADOComm(); Sys_Config_ListPage M_Model = new Sys_Config_ListPage(); //第一步:根据传入模块获取Grid配置 List<Sys_Config_ListPage> _ListPage = new DAL.ADOSys_Config_ListPage().GetListByWhere(" AND M_ModuleCode='" + moduleName + "'"); //工具条配置 List<Sys_Config_Toolbar> _Config = new List<Sys_Config_Toolbar>(); DAL.ADOSys_Config_Toolbar tInstance = new ADOSys_Config_Toolbar(); _Config = tInstance.GetListByWhere(string.Format("AND CT_Module='{0}' and isnull(CT_Show,'true')='true'", moduleName)); if (_ListPage.Count > 0) { M_Model = _ListPage[0]; } //工具条各控件前缀 string strPrefix = ""; strPrefix = prefix; ToolBar bar = new ToolBar(); if (!string.IsNullOrEmpty(ToolBarConfig)) { bar = JsonConvert.DeserializeObject<ToolBar>("{" + ToolBarConfig + "}"); } var HasAdd = 1; var HasEdit = 1; var HasView = 1; var HasDel = 1; var HasImport = 1; var HasExport = 1; var IS_OPEN_PERMISSION = ConfigHelper.GetApp("IS_OPEN_PERMISSION"); ///ToDo:暂时屏蔽 //if (!string.IsNullOrEmpty(IS_OPEN_PERMISSION) && IS_OPEN_PERMISSION == "true") //{ // var Permission = comInstance.UserPermissionList(QX.Config.SessionConfig.UserId()); // HasAdd = Permission.Where(o => o.Fun_UDef1 == strPrefix + "_add").Count(); // HasEdit = Permission.Where(o => o.Fun_UDef1 == strPrefix + "_edit").Count(); // HasView = Permission.Where(o => o.Fun_UDef1 == strPrefix + "_view").Count(); // HasDel = Permission.Where(o => o.Fun_UDef1 == strPrefix + "_delete").Count(); // HasImport = Permission.Where(o => o.Fun_UDef1 == strPrefix + "_import").Count(); // HasExport = Permission.Where(o => o.Fun_UDef1 == strPrefix + "_export").Count(); //} #region 按钮Html(定义增删改搜索等模板) //{add} -->补充属性 prefix-->id前缀 {toolbar_add}--->样式 string controlTpl = @"<li {attr} id='{toolbar_id}' class='{toolbar_class}'><a class='hide' onclick='{toolbar_event}' href='#'>{addN}</a></li>"; string Li_edit = @"<li {edit} id='{prefix}_toolbar_edit' class='{toolbar_edit}'><a class='hide' id='{prefix}_edit' onclick='{prefix}ToolBar.Edit()' href='#'>{editN}</a></li>"; string Li_del = @"<li {del} id='{prefix}_toolbar_delete' class='{toolbar_delete}'><a class='hide' id='{prefix}_delete' onclick='{prefix}ToolBar.Delete()' href='#'>{delN}</a></li> "; string Li_view = @"<li {view} id='{prefix}_toolbar_view' class='{toolbar_view}'><a class='hide' id='{prefix}_view' onclick='{prefix}ToolBar.View()' href='#'>{viewN}</a></li> "; //string Li_import = @"<li {import} id='{prefix}_toolbar_import' class='{toolbar_import}'><a class='hide' id='{prefix}_import' onclick='{prefix}ToolBar.Import()' href='#'>{importN}</a></li>"; //string Li_export = @"<li {export} id='{prefix}_toolbar_export' class='{toolbar_export}'><a class='hide' id='{prefix}_export' onclick='{prefix}ToolBar.Export()' href='#'>{exportN}</a></li>"; string Li_search = @"<li {search} id='{prefix}_toolbar_search' class='{toolbar_search}'><input style='display:none' id='search_txt' type='text' value='' /> <a id='{prefix}_search' onclick='{prefix}ToolBar.Search()' href='#'>{searchN}</a> </li> "; string Li_Custom = @"<li {add} id='{prefix}_toolbar_add' class='{toolbar_add}'><a id='{prefix}_add' onclick='{prefix}ToolBar.Add()' href='#'>{addN}</a></li>"; #endregion bool toolbar = !string.IsNullOrEmpty(bar.toolbar) ? true : false; string validatemethod = @" if ($.isFunction(window.{prefix}ToolBar{OpType})) { {prefix}ToolBar{OpType}(); } else { {nameSpace}_{moduleName}ToolBar{OpType}(); }"; string str = @" <div id='{prefix}toolbar' class='toolbar'> <ul> {Toolbar_Config} </ul> </div> <script type='text/javascript'> var {prefix}ToolBar = { {Toolbar_Function} HideElement:function(id){ $('#id').hide(); }, ChangeElement:function(id,name){ $('#id').find('a').val(name); } } //插入菜单项:文本,回调,位置(ID),样式 </script> "; StringBuilder configSb = new StringBuilder(); StringBuilder functionSb = new StringBuilder(); foreach (var m in _Config) { switch (m.CT_Type) { case "add": case "edit": case "del": case "view": { //控件id string id = prefix + "_toolbar_" + m.CT_Type; string eventjs = string.Format(prefix + "ToolBar.{0}()", m.CT_Type); string classjs = string.Format("toolbar_{0}", m.CT_Type); configSb.Append(controlTpl.Replace("{prefix}", prefix) .Replace("{toolbar_id}", id) .Replace("{addN}", m.CT_Name) .Replace("{toolbar_class}", string.IsNullOrEmpty(m.CT_Class) ? classjs : m.CT_Class) .Replace("{toolbar_event}", eventjs) .Replace("{attr}", m.CT_Attr) ); if (string.IsNullOrEmpty(m.CT_Event)) { m.CT_Event = validatemethod.Replace("{OpType}", m.CT_Type).Replace("{prefix}", strPrefix).Replace("{nameSpace}", prefix).Replace("{moduleName}", moduleName); } //事件定义 //string.IsNullOrEmpty(m.CT_Event)?eventjs:m.CT_Event functionSb.AppendLine(); functionSb.AppendLine(" " + m.CT_Type + ":function(){"); functionSb.AppendLine(" " + m.CT_Event); functionSb.AppendLine(" },"); break; } //case "edit": // { // break; // } //case "del": // { // break; // } //case "view": // { // break; // } case "search": { break; } case "text": { break; } case "btn": { string id = prefix + "_toolbar_" + m.CT_Field; string eventjs = string.Format(prefix + "ToolBar.{0}()", m.CT_Field); string classjs = string.Format("toolbar_{0}", m.CT_Field); configSb.Append(controlTpl.Replace("{prefix}", prefix) .Replace("{toolbar_id}", id) .Replace("{addN}", m.CT_Name) .Replace("{toolbar_class}", string.IsNullOrEmpty(m.CT_Class) ? classjs : m.CT_Class) .Replace("{toolbar_event}", eventjs) .Replace("{attr}", m.CT_Attr) ); //事件定义 //string.IsNullOrEmpty(m.CT_Event)?eventjs:m.CT_Event functionSb.AppendLine(); functionSb.AppendLine(" " + m.CT_Type + ":function(){"); functionSb.AppendLine(" " + m.CT_Event); functionSb.AppendLine(" },"); break; } } }//end foreach str = str.Replace("{prefix}", prefix).Replace("{Toolbar_Config}", configSb.ToString()).Replace("{Toolbar_Function}", functionSb.ToString()); //#region 按钮解析(配置生成) //string add = !string.IsNullOrEmpty(bar.add) ? "style='display:none'" : "style='display:block'"; //string addN = !string.IsNullOrEmpty(bar.addN) ? bar.addN : "添加"; //string addClass = !string.IsNullOrEmpty(bar.addClass) ? bar.addClass : "toolbar_add"; //string edit = !string.IsNullOrEmpty(bar.edit) ? "style='display:none'" : "style='display:block'"; //string editN = !string.IsNullOrEmpty(bar.editN) ? bar.editN : "修改"; //string editClass = !string.IsNullOrEmpty(bar.editClass) ? bar.editClass : "toolbar_edit"; //string del = !string.IsNullOrEmpty(bar.del) ? "style='display:none'" : "style='display:block'"; //string delN = !string.IsNullOrEmpty(bar.delN) ? bar.delN : "删除"; //string delClass = !string.IsNullOrEmpty(bar.delClass) ? bar.delClass : "toolbar_delete"; //string view = !string.IsNullOrEmpty(bar.view) ? "style='display:none'" : "style='display:block'"; //string viewN = !string.IsNullOrEmpty(bar.viewN) ? bar.viewN : "查看"; //string viewClass = !string.IsNullOrEmpty(bar.viewClass) ? bar.viewClass : "toolbar_view"; ////string import = !string.IsNullOrEmpty(bar.import) ? "style='display:none'" : "style='display:block'"; ////string importN = !string.IsNullOrEmpty(bar.importN) ? bar.importN : "导入"; ////string importClass = !string.IsNullOrEmpty(bar.importClass) ? bar.importClass : "toolbar_import"; ////string export = !string.IsNullOrEmpty(bar.export) ? "style='display:none'" : "style='display:block'"; ////string exportN = !string.IsNullOrEmpty(bar.exportN) ? bar.exportN : "导出"; ////string exportClass = !string.IsNullOrEmpty(bar.exportClass) ? bar.exportClass : "toolbar_export"; //string search = !string.IsNullOrEmpty(bar.search) ? "style='display:none'" : "style='display:block'"; //string searchN = !string.IsNullOrEmpty(bar.searchN) ? bar.searchN : "搜索"; //string searchClass = !string.IsNullOrEmpty(bar.searchClass) ? bar.searchClass : "toolbar_search"; //#endregion //#region 事件定义 //string addJS = !string.IsNullOrEmpty(bar.addFunJs) ? "{prefix}" + bar.addFunJs : validatemethod.Replace("{OpType}", "Add"); //string editJs = !string.IsNullOrEmpty(bar.editFunJs) ? "{prefix}" + bar.editFunJs : validatemethod.Replace("{OpType}", "Edit"); //string delJs = !string.IsNullOrEmpty(bar.delFunJs) ? "{prefix}" + bar.delFunJs : validatemethod.Replace("{OpType}", "Del"); //string viewJs = !string.IsNullOrEmpty(bar.viewFunJs) ? "{prefix}" + bar.viewFunJs : validatemethod.Replace("{OpType}", "View"); ////string importJs = !string.IsNullOrEmpty(bar.importFunJs) ? "{prefix}" + bar.importFunJs : "{prefix}ToolBarImport()"; ////string exportJs = !string.IsNullOrEmpty(bar.exportFunJs) ? "{prefix}" + bar.exportFunJs : "{prefix}ToolBarExport()"; //string searchJs = !string.IsNullOrEmpty(bar.searchFunJs) ? "{prefix}" + bar.searchFunJs : "{prefix}ToolBarSearch()"; //#endregion // #region HTML生成 // string str = @" // <div id='{prefix}toolbar' class='toolbar'> // <ul> // {Li_add} // {Li_edit} // {Li_del} // {Li_view} // {Li_search} // </ul> // </div> // <script type='text/javascript'> // var {prefix}ToolBar = { // Add: function() { // {addJs}; // }, // Edit: function() { // {editJs}; // }, // Delete: function() { // {delJs}; // }, // View: function() { // {viewJs}; // }, // Search: function() { // {searchJs}; // }, // Import: function() { // {importJs}; // }, // Export: function() { // {exportJs}; // }, // HideElement:function(id){ // $('#id').hide(); // }, // ChangeElement:function(id,name){ // $('#id').find('a').val(name); // } // } // //插入菜单项:文本,回调,位置(ID),样式 // // // </script> // "; // #endregion // Li_add = HasAdd > 0 ? Li_add : ""; // Li_edit = HasEdit > 0 ? Li_edit : ""; // Li_del = HasDel > 0 ? Li_del : ""; // //Li_import = HasImport > 0 ? Li_import : ""; // //Li_export = HasExport > 0 ? Li_export : ""; // Li_view = HasView > 0 ? Li_view : ""; // bool HasConfig = !string.IsNullOrEmpty(ToolBarConfig) ? true : false; // if (HasConfig) // { // str = str.Replace("{Li_add}", ((!string.IsNullOrEmpty(bar.addN) || !string.IsNullOrEmpty(bar.addFunJs))) ? Li_add : ""); // str = str.Replace("{Li_edit}", ((!string.IsNullOrEmpty(bar.editN) || !string.IsNullOrEmpty(bar.editFunJs))) ? Li_edit : ""); // str = str.Replace("{Li_del}", ((!string.IsNullOrEmpty(bar.delN) || !string.IsNullOrEmpty(bar.delFunJs))) ? Li_del : ""); // str = str.Replace("{Li_view}", ((!string.IsNullOrEmpty(bar.viewN) || !string.IsNullOrEmpty(bar.viewFunJs))) ? Li_view : ""); // //str = str.Replace("{Li_import}", ((!string.IsNullOrEmpty(bar.importN) || !string.IsNullOrEmpty(bar.importFunJs))) ? Li_import : ""); // //str = str.Replace("{Li_export}", ((!string.IsNullOrEmpty(bar.exportN) || !string.IsNullOrEmpty(bar.exportFunJs))) ? Li_export : ""); // //str = str.Replace("{Li_search}", ((!string.IsNullOrEmpty(bar.searchN) || !string.IsNullOrEmpty(bar.searchFunJs))) ? Li_search : ""); // } // else//默认生成的话根据配置进行生成 // { // if (M_Model.M_IsAdd == 1) // { // str = str.Replace("{Li_add}", Li_add); // } // else // { // str = str.Replace("{Li_add}", ""); // } // if (M_Model.M_IsEdit == 1) // { // str = str.Replace("{Li_edit}", Li_edit); // } // else // { // str = str.Replace("{Li_edit}", ""); // } // if (M_Model.M_IsDelete == 1) // { // str = str.Replace("{Li_del}", Li_del); // } // else // { // str = str.Replace("{Li_del}", ""); // } // if (M_Model.M_IsView == "true") // { // str = str.Replace("{Li_view}", Li_view); // } // else // { // str = str.Replace("{Li_view}", ""); // } // //str = str.Replace("{Li_import}", Li_import); // //str = str.Replace("{Li_export}", Li_export); // } // //搜索 默认输出 // str = str.Replace("{Li_search}", Li_search); // if (M_Model.M_IsAdd == 1) // { // str = str.Replace("{toolbar_add}", addClass); // } // else // { // str = str.Replace("{toolbar_add}", ""); // } // if (M_Model.M_IsEdit == 1) // { // str = str.Replace("{toolbar_edit}", editClass); // } // else // { // str = str.Replace("{toolbar_edit}", ""); // } // str = str.Replace("{toolbar_delete}", delClass); // if (M_Model.M_IsView == "true") // { // str = str.Replace("{toolbar_view}", viewClass); // } // else // { // str = str.Replace("{toolbar_view}", ""); // } // //str = str.Replace("{toolbar_import}", importClass); // //str = str.Replace("{toolbar_export}", exportClass); // str = str.Replace("{toolbar_search}", searchClass); // if (M_Model.M_IsAdd == 1) // { // str = str.Replace("{addJs}", addJS); // } // else // { // str = str.Replace("{addJs}", ""); // } // if (M_Model.M_IsEdit == 1) // { // str = str.Replace("{editJs}", editJs); // } // else // { // str = str.Replace("{editJs}", ""); // } // if (M_Model.M_IsDelete == 1) // { // str = str.Replace("{delJs}", delJs); // } // else // { // str = str.Replace("{delJs}", ""); // } // if (M_Model.M_IsView == "true") // { // str = str.Replace("{viewJs}", viewJs); // } // else // { // str = str.Replace("{viewJs}", ""); // } // //str = str.Replace("{viewJs}", viewJs); // str = str.Replace("{searchJs}", searchJs); // //str = str.Replace("{importJs}", importJs); // //str = str.Replace("{exportJs}", exportJs); // str = str.Replace("{searchJs}", searchJs); // str = str.Replace("{prefix}", strPrefix); // str = str.Replace("{newprefix}", prefix); // str = str.Replace("{add}", add); // str = str.Replace("{addN}", addN); // str = str.Replace("{edit}", edit); // str = str.Replace("{editN}", editN); // str = str.Replace("{del}", del); // str = str.Replace("{delN}", delN); // str = str.Replace("{view}", view); // str = str.Replace("{viewN}", viewN); // //str = str.Replace("{import}", import); // //str = str.Replace("{importN}", importN); // //str = str.Replace("{export}", export); // //str = str.Replace("{exportN}", exportN); // str = str.Replace("{search}", search); // str = str.Replace("{searchN}", searchN); // str = str.Replace("{moduleName}", M_Model.M_ModuleCode); // str = str.Replace("{nameSpace}", M_Model.M_NameSpace); // if (toolbar) // { // str = ""; // } return str; }
public static string GenNToolbarHelper(this HtmlHelper helper, string moduleName, string prefix, bool nopermission, Dictionary<string, string> permisons) { ADOComm comInstance = new ADOComm(); Sys_Config_ListPage M_Model = new Sys_Config_ListPage(); //第一步:根据传入模块获取Grid配置 List<Sys_Config_ListPage> _ListPage = new DAL.ADOSys_Config_ListPage().GetListByWhere(" AND M_ModuleCode='" + moduleName + "'"); //工具条配置 List<Sys_Config_Toolbar> _Config = new List<Sys_Config_Toolbar>(); DAL.ADOSys_Config_Toolbar tInstance = new ADOSys_Config_Toolbar(); _Config = tInstance.GetListByWhere(string.Format("AND CT_Module='{0}' and isnull(CT_Show,'true')='true'", moduleName)); if (_ListPage.Count > 0) { M_Model = _ListPage[0]; } //工具条各控件前缀 string strPrefix = ""; strPrefix = prefix; var IS_OPEN_PERMISSION = ConfigHelper.GetApp("IS_OPEN_PERMISSION"); #region 按钮Html(定义增删改搜索等模板) //{add} -->补充属性 prefix-->id前缀 {toolbar_add}--->样式 string controlTpl = @"<li {attr} id='{toolbar_id}' class='{toolbar_class}'><a class='hide' onclick='{toolbar_event}' href='#'>{addN}</a></li>"; #endregion string validatemethod = @" if ($.isFunction(window.{prefix}ToolBar{OpType})) { {prefix}ToolBar{OpType}(); } else { {nameSpace}_{moduleName}ToolBar{OpType}(); }"; string str = @" <div id='{prefix}toolbar' class='toolbar'> <ul> {Toolbar_Config} </ul> </div> <script type='text/javascript'> var {prefix}ToolBar = { {Toolbar_Function} HideElement:function(id){ $('#id').hide(); }, ChangeElement:function(id,name){ $('#id').find('a').val(name); } } //插入菜单项:文本,回调,位置(ID),样式 </script> "; StringBuilder configSb = new StringBuilder(); StringBuilder functionSb = new StringBuilder(); foreach (var m in _Config) { //控件id string cid = prefix + "_toolbar_" + m.CT_Type; //默认事件 string eventjs = string.Format(prefix + "ToolBar.{0}()", m.CT_Type); //默认样式 string classjs = string.Format("toolbar_{0}", m.CT_Type); ///如果存在该权限则进行后面的生成操作 if (nopermission&&(permisons == null || permisons.Values.FirstOrDefault(o => !string.IsNullOrEmpty(o) && cid.ToLower().Equals(o.ToLower())) == null)) { continue; } switch (m.CT_Type) { case "add": case "edit": case "del": case "view": { configSb.Append(controlTpl.Replace("{prefix}", prefix) .Replace("{toolbar_id}", cid) .Replace("{addN}", m.CT_Name) .Replace("{toolbar_class}", string.IsNullOrEmpty(m.CT_Class) ? classjs : m.CT_Class) .Replace("{toolbar_event}", eventjs) .Replace("{attr}", m.CT_Attr) ); if (string.IsNullOrEmpty(m.CT_Event)) { m.CT_Event = validatemethod.Replace("{OpType}", m.CT_Type).Replace("{prefix}", strPrefix).Replace("{nameSpace}", prefix).Replace("{moduleName}", moduleName); } //事件定义 functionSb.AppendLine(); functionSb.AppendLine(" " + m.CT_Type + ":function(){"); functionSb.AppendLine(" " + m.CT_Event); functionSb.AppendLine(" },"); break; } case "search": { break; } case "text": { break; } case "btn": { string bid = prefix + "_toolbar_" + m.CT_Field; string beventjs = string.Format(prefix + "ToolBar.{0}()", m.CT_Field); string bclassjs = string.Format("toolbar_{0}", m.CT_Field); configSb.Append(controlTpl.Replace("{prefix}", prefix) .Replace("{toolbar_id}", bid) .Replace("{addN}", m.CT_Name) .Replace("{toolbar_class}", string.IsNullOrEmpty(m.CT_Class) ? bclassjs : m.CT_Class) .Replace("{toolbar_event}", beventjs) .Replace("{attr}", m.CT_Attr) ); //事件定义 functionSb.AppendLine(); functionSb.AppendLine(" " + m.CT_Type + ":function(){"); functionSb.AppendLine(" " + m.CT_Event); functionSb.AppendLine(" },"); break; } } }//end foreach str = str.Replace("{prefix}", prefix).Replace("{Toolbar_Config}", configSb.ToString()).Replace("{Toolbar_Function}", functionSb.ToString()); return str; }
public static DataTable ListDataByCode(string TableName, string filter) { ADOSys_Config_ListPage instance = new ADOSys_Config_ListPage(); string sql = "SELECT * FROM " + TableName + " WHERE (Stat is null or Stat=0) AND " + filter; return instance.idb.ReturnDataTable(sql); }