public ActionResult Save(T_Menu model) { tmenu = new T_Menu(); tmenu = model; switch (Tools.getGuid(model.uMenu_ID).Equals(Guid.Empty)) { case true: this.KeyID = Tools.getGuidString(db.Add(tmenu, li)); if (Tools.getGuid(KeyID).Equals(Guid.Empty)) { throw new MessageBox(db.ErrorMessge); } break; case false: this.KeyID = Tools.getGuidString(model.uMenu_ID); if (!db.Edit <T_Menu>(tmenu, w => w.uMenu_ID == KeyID.To_Guid(), li)) { throw new MessageBox(db.ErrorMessge); } break; } if (!db.Commit(li)) { throw new MessageBox(db.ErrorMessge); } return(Json(new { status = 1, ID = KeyID }, JsonRequestBehavior.DenyGet)); }
private List <T_Menu> getMenu(List <T_Menu> menuList, int parentMenuID) { List <T_Menu> mL = new List <T_Menu>(); var subMenu = menuList.Where(i => i.ParentMenuID.Equals(parentMenuID)); if (subMenu == null || subMenu.Count() == 0) { return(mL); } foreach (var item in subMenu) { T_Menu m = new T_Menu { DisplayName = item.DisplayName, MenuIcon = item.MenuIcon, MenuID = item.MenuID, MenuURL = item.MenuURL, OrderNumber = item.OrderNumber, ParentMenuID = item.ParentMenuID, }; m.SubMenu = getMenu(menuList, item.MenuID); mL.Add(m); } return(mL); }
/// <summary> /// 数据绑定 /// </summary> protected void databind() { DataTable dt = new T_Menu().GetMenuList(); rpList.DataSource = dt; rpList.DataBind(); }
public ActionResult DisableForm(string F_Id) { T_Menu t_Menu = menuBLL.GetForm(F_Id); t_Menu.F_Enable_Mark = 0; menuBLL.SubmitForm(t_Menu); return(Success("操作成功")); }
private void Lock(HttpContext context) { bool flag = false; string id = ""; string opt = ""; if (null != context.Request.QueryString["id"]) { id = context.Request.QueryString["id"].ToString().Trim(); } Model.T_Menu t_menu = new T_Menu(); t_menu = bll_menu.GetModel(Convert.ToInt32(id)); if (t_menu.isDeleted == 1) { t_menu.isDeleted = 0; opt = "开启"; } else { t_menu.isDeleted = 1; opt = "关闭"; } flag = bll_menu.Update(t_menu); /* * //添加登录日志 * Model.T_Log t_log = new T_Log(); * t_log.type = "【开启】"; * t_log.user_id = Convert.ToInt32(context.Session["user_id"].ToString()); * t_log.user_name = context.Session["user_name"].ToString(); * t_log.ip = Web.utils.Util.GetIP(); * t_log.create_time = DateTime.Now; * t_log.id_role = context.Session["role_id"].ToString() + ""; * t_log.isDeleted = 0; * t_log.des = "IP为 " + t_log.ip + " 的用户【" + context.Session["user_name"].ToString() + "】 身份【" + list_role[0].name + "】在 " + DateTime.Now + " 【启用】"; * bll_log.Add(t_log); */ message = new Message(); if (flag) { message.flag = true; message.msg = opt + "成功"; } else { message.flag = false; message.msg = opt + "失败"; } context.Response.Write(JsonHelper.Object2Json <Message>(message));//返回给前台页面 }
public void databind() { int menuid = Requests.GetQueryInt("menuid", 0); string menuname = Requests.GetQueryString("menuname"); ltMenuName.Text = menuname; E_Menu data = new E_Menu(); data.MenuID = menuid; DataTable dt = new T_Menu().GetMenuTipsList(data); rpList.DataSource = dt; rpList.DataBind(); }
/// <summary> /// 点击确定按钮处理事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { int menuid = Requests.GetQueryInt("menuid", 0); //获取界面里所有隐藏域集合 System.Collections.Specialized.NameValueCollection nv = Request.Form; string[] TipsIDs = nv.GetValues("hdTipsIDs"); string[] TipsNameS = nv.GetValues("hdTipsNameS"); string ids = string.Empty, names = string.Empty; if (TipsIDs != null || TipsNameS != null) { if (TipsIDs.Length != TipsNameS.Length) { MLMGC.COMP.Jscript.ShowMsg("参数错误", this); return; } if (TipsIDs.Length == 0) { MLMGC.COMP.Jscript.ShowMsg("请输入选项", this); return; } for (int i = 0; i < TipsIDs.Length; i++) { ids += TipsIDs[i] + (i != TipsIDs.Length - 1 ? MLMGC.COMP.Config.Separation : ""); names += TipsNameS[i] + (i != TipsIDs.Length - 1 ? MLMGC.COMP.Config.Separation : ""); } } E_Menu data = new E_Menu(); data.MenuID = menuid; data.TipsIDs = ids; data.TipsNameS = names; bool flag = new T_Menu().UpdateMenuTips(data); if (flag) { MLMGC.COMP.Jscript.AlertAndRedirect(this, "操作成功", "MenuList.aspx"); } else { MLMGC.COMP.Jscript.ShowMsg("操作失败", this); } }
private void GetTips() { int menuid; int.TryParse(nv["menuid"], out menuid); DataTable dt = new T_Menu().GetMenuTipsList(new E_Menu() { MenuID = menuid }); List <string> list = new List <string> (); foreach (DataRow row in dt.Rows) { list.Add(row["Tips"].ToString()); } HttpContext.Current.Response.Write(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(list)); }
public ActionResult Find(string ID) { tmenu = db.Find <T_Menu>(w => w.uMenu_ID == ID.To_Guid()); if (Tools.getGuid(ID).Equals(Guid.Empty)) { tmenu.dMenu_CreateTime = Tools.getDateTime(DateTime.Now); } var menu = db.Find <T_Menu>(w => w.uMenu_ID == tmenu.uMenu_ParentID); var di = new ToJson().GetDictionary(new Dictionary <string, object>() { { "tmenu", tmenu }, { "pname", Tools.getString(menu.cMenu_Name) }, { "status", 1 } }); di["dMenu_CreateTime"] = di["dMenu_CreateTime"].To_DateTimeString("yyyy-MM-dd HH:mm:ss"); return(Json(di, JsonRequestBehavior.DenyGet)); }
/// <summary> /// 创建菜单 /// </summary> /// <returns></returns> public ActionResult CreateModifyMenu(T_Menu menu) { if (menu.Id <= 0) { var count = menuService.Add(menu); if (count >= 1) { return(JsonSuccess(menu)); } return(JsonError("添加失败")); } else { var model = menuService.Find(menu.Id); UpdateModel(model, null, new string[] { "_CreateDate" }); var count = menuService.Modify(model); if (count > 0) { return(JsonSuccess(model)); } return(JsonError("修改失败")); } }
protected override void Seed(DataEntities context) { //添加权限类型数据 if (!context.AuthorityTypes.Any()) { context.AuthorityTypes.AddOrUpdate( new T_AuthorityType() { Id = 1, Description = "菜单类型" }, new T_AuthorityType() { Id = 2, Description = "页面元素类型" }, new T_AuthorityType() { Id = 3, Description = "文件类型" }); } //添加初始用户 if (!context.Users.Any(x => x.UserName == "root")) { context.Users.Add(new T_User() { UserName = "******", Password = "******", RealName = "超级管理员" }); } //创建初始菜单 if (!context.Menus.Any(x => x.Title == "系统设置")) { var systemMenu = new T_Menu() { Title = "系统设置", Icon = "el-icon-setting", Url = "" }; context.SaveChanges(); context.Menus.AddOrUpdate( new T_Menu() { ParentId = systemMenu.Id, ParentMenu = systemMenu, Title = "菜单管理", Icon = "el-icon-document", Url = "/System/MenuManager" }, new T_Menu() { ParentId = systemMenu.Id, ParentMenu = systemMenu, Title = "用户管理", Icon = "el-icon-document", Url = "/System/UserManager" }, new T_Menu() { ParentId = systemMenu.Id, ParentMenu = systemMenu, Title = "权限管理", Icon = "el-icon-document", Url = "/System/AuthorityManager" }, new T_Menu() { ParentId = systemMenu.Id, ParentMenu = systemMenu, Title = "角色管理", Icon = "el-icon-document", Url = "/System/RoleManager" }, new T_Menu() { ParentId = systemMenu.Id, ParentMenu = systemMenu, Title = "用户组管理", Icon = "el-icon-document", Url = "/System/UserGroupManager" }, new T_Menu() { ParentId = systemMenu.Id, ParentMenu = systemMenu, Title = "操作日志", Icon = "el-icon-document", Url = "/System/OperationLog" }, new T_Menu() { ParentId = systemMenu.Id, ParentMenu = systemMenu, Title = "系统配置", Icon = "el-icon-edit", Url = "/System/Config" }); context.SaveChanges(); } //添加默认角色 if (!context.Roles.Any()) { var user = context.Users.First(x => x.UserName == "root"); var role = new T_Role() { Name = "超级管理员", Description = "系统的超级用户,拥有至高无上的权利", }; role.Users.Add(user); context.Roles.AddOrUpdate(role); context.SaveChanges(); } // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. }
public static void ModifyT_Menu(T_Menu t_Menu) { T_MenuService.ModifyT_Menu(t_Menu); }
public static void DeleteT_Menu(T_Menu t_Menu) { T_MenuService.DeleteT_Menu(t_Menu); }
public static T_Menu AddT_Menu(T_Menu t_Menu) { return(T_MenuService.AddT_Menu(t_Menu)); }
private void FindChildMenu(List <T_Menu> menu_list, List <T_RoleMenuFunction> trmf_list, List <T_Function> tf_list, List <T_MenuFunction> tmf_list, T_Menu menu, Guid roleid, List <Dictionary <string, object> > list) { var dic = new Dictionary <string, object>(); var _paret_menu_list = menu_list.FindAll(item => item.uMenu_ParentID != null && item.uMenu_ParentID.Equals(menu.uMenu_ID)); for (int i = _paret_menu_list.Count - 1; i >= 0; i--) { var _child_menu_list = menu_list.FindAll(x => x.uMenu_ParentID != null && x.uMenu_ParentID.Equals(_paret_menu_list[i].uMenu_ID)); //判断是否有子集 if (_child_menu_list.Count() > 0) { dic = new Dictionary <string, object>(); dic.Add("name", _paret_menu_list[i].cMenu_Name + "(" + _paret_menu_list[i].cMenu_Number + ")"); dic.Add("id", _paret_menu_list[i].uMenu_ID); dic.Add("pId", _paret_menu_list[i].uMenu_ParentID); dic.Add("num", _paret_menu_list[i].cMenu_Number); dic.Add("ur", _paret_menu_list[i].cMenu_Url); dic.Add("tag", null); dic.Add("checked", false); list.Add(dic); this.FindChildMenu(menu_list, trmf_list, tf_list, tmf_list, _paret_menu_list[i], Tools.getGuid(roleid), list); } else { if (tmf_list.FindAll(val => val.uMenuFunction_MenuID.Equals(_paret_menu_list[i].uMenu_ID)).Count() == 0)//判断该菜单是否有 勾选了功能 如果没有则删除 { _paret_menu_list.RemoveAt(i); continue; } dic = new Dictionary <string, object>(); dic.Add("name", _paret_menu_list[i].cMenu_Name + "(" + _paret_menu_list[i].cMenu_Number + ")"); dic.Add("id", _paret_menu_list[i].uMenu_ID); dic.Add("pId", _paret_menu_list[i].uMenu_ParentID); dic.Add("num", _paret_menu_list[i].cMenu_Number); dic.Add("ur", _paret_menu_list[i].cMenu_Url); dic.Add("tag", null); dic.Add("checked", false); list.Add(dic); //找出该菜单下的功能和选中的功能 tf_list.ForEach(a => { if (tmf_list.FindAll(val => val.uMenuFunction_FunctionID.Equals(a.uFunction_ID) && val.uMenuFunction_MenuID.Equals(_paret_menu_list[i].uMenu_ID)).Count() > 0) { dic = new Dictionary <string, object>(); dic.Add("name", a.cFunction_Name); dic.Add("id", a.uFunction_ID); dic.Add("pId", _paret_menu_list[i].uMenu_ID); dic.Add("num", a.iFunction_Number); dic.Add("ur", null); dic.Add("tag", "fun"); //判断该功能是否选中 var ischecked = trmf_list.FindAll(x => x.uRoleMenuFunction_FunctionID.Equals(a.uFunction_ID) && x.uRoleMenuFunction_MenuID.Equals(_paret_menu_list[i].uMenu_ID) && x.uRoleMenuFunction_RoleID.Equals(Tools.getGuid(roleid))).FirstOrDefault(); if (ischecked == null) { dic.Add("checked", false); } else { dic.Add("checked", true); } list.Add(dic); } }); } } }
public VM_Menu(T_Menu menu) { this.menu = menu; }
private void Query(HttpContext context) { string name, order, sort, oderby; //=============================================================== //获取查询条件:【用户名】 name = order = sort = oderby = ""; //获取前台传来的值 if (null != context.Request.QueryString["name"]) {//获取前台传来的值 name = context.Request.QueryString["name"].ToString().Trim(); } //================================================================ //获取分页和排序信息:页大小,页码,排序方式,排序字段 int pageRows, page; pageRows = 10; page = 1; if (null != context.Request.QueryString["rows"]) { pageRows = int.Parse(context.Request.QueryString["rows"].ToString().Trim()); } if (null != context.Request.QueryString["page"]) { page = int.Parse(context.Request.QueryString["page"].ToString().Trim()); } if (null != context.Request.QueryString["sort"]) { order = context.Request.QueryString["sort"].ToString().Trim(); } if (null != context.Request.QueryString["order"]) { sort = context.Request.QueryString["order"].ToString().Trim(); } //=================================================================== //组合查询语句:条件+排序 StringBuilder strWhere = new StringBuilder(); strWhere.Append(" 1=1 and"); if (name != "") { strWhere.AppendFormat(" name like '%{0}%' and ", name); } //删除多余的and int startindex = strWhere.ToString().LastIndexOf("and");//获取最后一个and的位置 if (startindex >= 0) { strWhere.Remove(startindex, 3);//删除多余的and关键字 } if (sort != "" && order != "") { //strWhere.AppendFormat(" order by {0} {1}", sort, order);//添加排序 oderby = order + " " + sort; } //调用分页的GetList方法 DataSet ds = bll_role.GetListByPage(strWhere.ToString(), oderby, (page - 1) * pageRows + 1, page * pageRows); //向ds中插入contentname(上级名称) ds.Tables[0].Columns.Add("contentname", typeof(System.String)); foreach (DataRow dr in ds.Tables[0].Rows) { StringBuilder sbconent = new StringBuilder(); //根据Menu id获取name if (dr["content"] != null && dr["content"] != DBNull.Value && dr["content"].ToString() != "") { //1,2,3,5 分割 String[] ids = dr["content"].ToString().Split(','); if (ids.Length > 0) { foreach (String id in ids) { int id_int = Convert.ToInt32(id); T_Menu t_menu = bll_menu.GetModel(id_int); if (t_menu != null) { sbconent.Append(t_menu.name + ","); } else { //是否是增删改查 if (AuthorityValidation.IsInCRUD(id_int)) { String _name = AuthorityValidation.GetMethodCRUD(id_int); sbconent.Append(_name + ","); } else { sbconent.Append(id + ","); } } } dr["contentname"] = sbconent.ToString().Substring(0, sbconent.ToString().Length - 1); } else { dr["contentname"] = ""; } } else { dr["contentname"] = ""; } } int count = bll_role.GetRecordCount(strWhere.ToString()); //获取条数 string strJson = JsonHelper.Dataset2Json(ds, count); //DataSet数据转化为Json数据 context.Response.Write(strJson); //返回给前台页面 }
public ActionResult SubmitForm(T_Menu t_Menu) { menuBLL.SubmitForm(t_Menu); return(Success("操作成功")); }
private void PowerLogic(ActionExecutedContext filterContext) { string ControllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName; string ActionName = filterContext.ActionDescriptor.ActionName; string Area = Tools.getString(filterContext.RouteData.DataTokens["area"]); string RoleID = Tools.getSession("RoleID"); //dynamic model = new ExpandoObject(); if (string.IsNullOrEmpty(MenuID)) { throw new MessageBox("区域(" + Area + "),控制器(" + ControllerName + "):的程序中缺少菜单ID"); } tmenu = db.Find <T_Menu>(w => w.cMenu_Number == MenuID); MenuID = Tools.getGuidString(tmenu.uMenu_ID); if (!tmenu.cMenu_Url.StartsWith("/" + Area + "/" + ControllerName + "/")) { throw new MessageBox("区域(" + Area + "),控制器(" + ControllerName + "):的程序中缺少菜单ID与该页面不匹配"); } //这里得判断一下是否是查找带回调用页面 string fun = Tools.getString(filterContext.HttpContext.Request.QueryString["fun"]); var _func_list = db.FindToList <T_Function>(null, " iFunction_Number "); var _role_menu_func_list = db.FindToList <T_RoleMenuFunction>(null); var _menu_func_list = db.FindToList <T_MenuFunction>(null); var _power_list = new Dictionary <string, object>(); if (string.IsNullOrEmpty(fun)) { if (!RoleID.Equals("admin")) { _power_list = new Dictionary <string, object>(); _func_list.ForEach(item => { var ispower = _role_menu_func_list.FindAll(x => x.uRoleMenuFunction_RoleID.Equals(Tools.getGuid(RoleID)) && x.uRoleMenuFunction_MenuID.Equals(Tools.getGuid(MenuID)) && x.uRoleMenuFunction_FunctionID.Equals(item.uFunction_ID)); if (ispower.Count > 0) { _power_list.Add(item.cFunction_ByName, true); } else { _power_list.Add(item.cFunction_ByName, false); } }); } else { _func_list.ForEach(item => { _power_list.Add(item.cFunction_ByName, true); //var ispower = _menu_func_list.FindAll(x => x.uMenuFunction_MenuID == Tools.getGuid(MenuID) && x.uMenuFunction_FunctionID == item.uFunction_ID); //if (ispower.Count > 0) // _power_list.Add(item.cFunction_ByName, true); //else // _power_list.Add(item.cFunction_ByName, false); }); } } else { _power_list = new Dictionary <string, object>(); _func_list.ForEach(item => { _power_list.Add(item.cFunction_ByName, false); }); _power_list["Have"] = true; _power_list["Search"] = true; _power_list["GetExcel"] = true; } filterContext.Controller.ViewData["PowerModel"] = jss.Serialize(_power_list);; }
public MenuVM() { TemData = new T_Menu(); }