public JsonResult EditManager_role(int id, string txt_role_name, string txt_action_type) { Common.Json json = new Common.Json(); DAO.BLL.B_Manager_role b_mr = new DAO.BLL.B_Manager_role(); var m_mr = b_mr.Get(id); List <SearchTemplate> st = new List <SearchTemplate>() { new SearchTemplate() { key = "role_name", value = txt_role_name, searchType = Common.EnumBase.SearchType.Eq } }; var res = b_mr.GetCount(st); if (m_mr.role_name != txt_role_name) { if (res > 0) { json.status = -1; json.msg = "角色名已存在!"; json.pitchId = "txt_role_name"; return(Json(json)); } } Domain.Manager_role model = m_mr; model.role_name = txt_role_name; b_mr.Update(model); B_Manager_role_value b_mrv = new B_Manager_role_value(); b_mrv.Update(txt_action_type, model.id); json.msg = "修改成功!"; return(Json(json)); }
public JsonResult CheckManager_role_value(int role_id, int nav_id, string action_type) { B_Manager_role_value b_mrv = new B_Manager_role_value(); List <SearchTemplate> st = new List <SearchTemplate>() { new SearchTemplate() { key = "role_id", value = role_id, searchType = Common.EnumBase.SearchType.Eq }, new SearchTemplate() { key = "nav_id", value = nav_id, searchType = Common.EnumBase.SearchType.Eq } }; var list = b_mrv.GetList(st, null); if (list.Count == 0) { return(Json("false")); } else { if (list[0].action_type.Contains(action_type)) { return(Json("true")); } else { return(Json("false")); } } }
public JsonResult AddManager_role(string txt_role_name, string txt_action_type) { Common.Json json = new Common.Json(); DAO.BLL.B_Manager_role b_mr = new DAO.BLL.B_Manager_role(); List <SearchTemplate> st = new List <SearchTemplate>() { new SearchTemplate() { key = "role_name", value = txt_role_name, searchType = Common.EnumBase.SearchType.Eq } }; var res = b_mr.GetCount(st); if (res > 0) { json.status = -1; json.msg = "角色名已存在!"; json.pitchId = "txt_role_name"; return(Json(json)); } Domain.Manager_role model = new Domain.Manager_role(); model.role_name = txt_role_name; res = b_mr.Save(model); if (res <= 0) { json.status = -1; json.msg = "添加失败!"; return(Json(json)); } B_Manager_role_value b_mrv = new B_Manager_role_value(); b_mrv.Update(txt_action_type, res); json.msg = "添加成功!"; return(Json(json)); }
public static string Menu(this HtmlHelper helper, int role_id) { B_Navigation b_nav = new B_Navigation(); //先查询出所有的一级菜单 List <Order> order = new List <Order>() { Order.Asc("sort_id") }; var list_nav = b_nav.LoadAll(order, 0); StringBuilder sb = new StringBuilder(); B_Manager_role_value b_mrv = new B_Manager_role_value(); foreach (var nav in list_nav) { List <SearchTemplate> st = new List <SearchTemplate>() { new SearchTemplate() { key = "role_id", value = role_id, searchType = Common.EnumBase.SearchType.Eq }, new SearchTemplate() { key = "nav_id", value = nav.id, searchType = Common.EnumBase.SearchType.Eq } }; IList <Domain.Manager_role_value> list = b_mrv.GetList(st, null); if (list.Count == 0) { continue; } if (!list[0].action_type.Contains("查看")) { continue; } sb.Append("<li>"); sb.Append("<a href=\"" + nav.link_url + "\">"); sb.Append(nav.icon_url); sb.Append("<span class=\"nav-label\">" + nav.title + "</span>"); sb.Append("<span class=\"fa arrow\"></span>"); sb.Append("</a>"); sb.Append("<ul class=\"nav nav-second-level\">"); //查询二级菜单 st = new List <SearchTemplate>() { new SearchTemplate() { key = "parent_id", value = nav.id, searchType = Common.EnumBase.SearchType.Eq } }; var list_sub_nav = b_nav.GetList(st, order); foreach (var sub_nav in list_sub_nav) { st = new List <SearchTemplate>() { new SearchTemplate() { key = "role_id", value = role_id, searchType = Common.EnumBase.SearchType.Eq }, new SearchTemplate() { key = "nav_id", value = sub_nav.id, searchType = Common.EnumBase.SearchType.Eq } }; list = b_mrv.GetList(st, null); if (list.Count == 0) { continue; } if (!list[0].action_type.Contains("查看")) { continue; } sb.Append("<li>"); sb.Append("<a class=\"J_menuItem\" href=" + sub_nav.link_url + " data-index=" + sub_nav.sort_id + ">" + sub_nav.icon_url + "</i>" + sub_nav.title + "</a>"); sb.Append("</li>"); } sb.Append("</ul>"); sb.Append("</li>"); } return(sb.ToString()); }
public static string select_auth(this HtmlHelper helper, string manager_id, string controllerName) { B_Navigation b_nav = new B_Navigation(); List <SearchTemplate> st = new List <SearchTemplate>() { new SearchTemplate() { key = "controllerName", value = controllerName, searchType = Common.EnumBase.SearchType.Eq } }; var list_nav = b_nav.GetList(st, null); int nav_id = 0; if (list_nav.Count > 0) { nav_id = list_nav[0].id; } B_Manager_role_value b_mrv = new B_Manager_role_value(); B_Manager b_manager = new B_Manager(); var m_manager = b_manager.Get(Convert.ToInt32(manager_id)); st = new List <SearchTemplate>() { new SearchTemplate() { key = "role_id", value = m_manager.manager_role.id, searchType = Common.EnumBase.SearchType.Eq }, new SearchTemplate() { key = "nav_id", value = nav_id, searchType = Common.EnumBase.SearchType.Eq } }; var list_mrv = b_mrv.GetList(st, null); if (list_mrv.Count == 0) { return(""); } StringBuilder sb = new StringBuilder(); sb.Append("<div id=\"toolbar\" class=\"btn-group\">"); if (list_mrv[0].action_type.Contains(EnumBase.Authorize.添加.Description())) { sb.Append("<button id=\"btn_add\" type=\"button\" class=\"btn btn-blue\">"); sb.Append("<span class=\"glyphicon glyphicon-plus\" aria-hidden=\"true\"></span>" + EnumBase.Authorize.添加.Description()); sb.Append("</button>"); } if (list_mrv[0].action_type.Contains(EnumBase.Authorize.修改.Description())) { sb.Append("<button id=\"btn_edit\" type=\"button\" class=\"btn btn-warning\">"); sb.Append("<span class=\"glyphicon glyphicon-pencil\" aria-hidden=\"true\"></span>" + EnumBase.Authorize.修改.Description()); sb.Append("</button>"); } if (list_mrv[0].action_type.Contains(EnumBase.Authorize.除.Description())) { sb.Append("<button id=\"btn_delete\" type=\"button\" class=\"btn btn-danger\">"); sb.Append("<span class=\"glyphicon glyphicon-remove\" aria-hidden=\"true\"></span>" + EnumBase.Authorize.除.Description()); sb.Append("</button>"); } if (list_mrv[0].action_type.Contains(EnumBase.Authorize.审核.Description())) { sb.Append("<button id=\"btn_exam\" type=\"button\" class=\"btn btn-info\">"); sb.Append("<span class=\"glyphicon glyphicon-check\" aria-hidden=\"true\"></span>" + EnumBase.Authorize.审核.Description()); sb.Append("</button>"); } if (list_mrv[0].action_type.Contains(EnumBase.Authorize.载.Description())) { sb.Append("<button id=\"btn_download\" type=\"button\" class=\"btn btn-success\">"); sb.Append("<span class=\"fa fa-cloud-download\" aria-hidden=\"true\"></span>" + EnumBase.Authorize.载.Description()); sb.Append("</button>"); } sb.Append("</div>"); return(sb.ToString()); }