コード例 #1
0
        public void Delete()
        {
            menu_role existing = repo.Find(x => x.ROLE_ID == this.ROLE_ID && x.MENU_ID == this.MENU_ID).FirstOrDefault();

            if (existing != null)
            {
                repo.Delete(existing);
            }
        }
コード例 #2
0
        public void Update()
        {
            menu_role existing = repo.Find(x => x.ROLE_ID == this.ROLE_ID && x.MENU_ID == this.MENU_ID).FirstOrDefault();

            if (existing != null)
            {
                repo.Edit(existing, this);
            }
        }
コード例 #3
0
ファイル: MenuBiz.cs プロジェクト: pawit1357/ALS.ALSI.Web
        public void getmenuByTree(ref TreeView tv, List <menu_role> roles)
        {
            using (var ctx = new ALSIEntities())
            {
                IEnumerable <menu> menus = repo.GetAll();

                foreach (menu _menu in menus.Where(x => x.PREVIOUS_MENU_ID == null).OrderBy(x => x.DISPLAY_ORDER))
                {
                    TreeNode           root       = new TreeNode(_menu.MENU_NAME, _menu.MENU_ID.ToString());
                    IEnumerable <menu> menuChilds = menus.Where(x => x.PREVIOUS_MENU_ID == _menu.MENU_ID).OrderBy(x => x.DISPLAY_ORDER);
                    if (menuChilds != null)
                    {
                        foreach (menu _childmenu in menuChilds)
                        {
                            TreeNode child = new TreeNode(_childmenu.MENU_NAME, _childmenu.MENU_ID.ToString());
                            child.ShowCheckBox = true;
                            menu_role menuRole = roles.Where(x => x.MENU_ID == _childmenu.MENU_ID).FirstOrDefault();
                            if (menuRole != null)
                            {
                                child.Expanded = !((bool)menuRole.IS_CREATE && (bool)menuRole.IS_DELETE && (bool)menuRole.IS_EDIT);
                                child.Checked  = true;
                                foreach (MenuRoleActionEnum val in Enum.GetValues(typeof(MenuRoleActionEnum)))
                                {
                                    TreeNode childLevel1 = new TreeNode(val.ToString(), menuRole.MENU_ID.ToString());
                                    childLevel1.ShowCheckBox = true;
                                    switch (val)
                                    {
                                    case MenuRoleActionEnum.Add:
                                        childLevel1.Checked = (bool)menuRole.IS_CREATE;
                                        break;

                                    case MenuRoleActionEnum.Delete:
                                        childLevel1.Checked = (bool)menuRole.IS_DELETE;
                                        break;

                                    case MenuRoleActionEnum.Edit:
                                        childLevel1.Checked = (bool)menuRole.IS_EDIT;
                                        break;
                                    }
                                    child.ChildNodes.Add(childLevel1);
                                }
                            }
                            else
                            {
                                //

                                foreach (MenuRoleActionEnum val in Enum.GetValues(typeof(MenuRoleActionEnum)))
                                {
                                    TreeNode childLevel1 = new TreeNode(val.ToString(), _childmenu.MENU_ID.ToString());
                                    childLevel1.ShowCheckBox = true;
                                    child.ChildNodes.Add(childLevel1);
                                }
                            }
                            root.ChildNodes.Add(child);
                        }
                        tv.Nodes.Add(root);
                    }
                }
                Console.WriteLine("");
            }
        }