Beispiel #1
0
 /// <summary>
 /// 设置CheckBox选中
 /// </summary>
 /// <param name="key"></param>
 /// <param name="node"></param>
 private void SetNodeChecked(String key, TreeListNodes node)
 {
     foreach (TreeListNode childeNode in node)
     {
         MenuEntity data = treeList1.GetDataRecordByNode(childeNode) as MenuEntity;
         if (data.id == key)
         {
             childeNode.Checked = true;
         }
         if (childeNode.HasChildren)
         {
             SetNodeChecked(key, childeNode.Nodes);
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// 设置菜单CheckBox选中
 /// </summary>
 /// <param name="key"></param>
 /// <param name="node"></param>
 private void SetMenuNodeChecked(DevExpress.XtraTreeList.TreeList treeList, String key, TreeListNodes node)
 {
     foreach (TreeListNode childeNode in node)
     {
         MenuEntity data = treeList.GetDataRecordByNode(childeNode) as MenuEntity;
         if (data.id == key)
         {
             childeNode.Checked = true;
         }
         if (childeNode.HasChildren)
         {
             SetMenuNodeChecked(treeList, key, childeNode.Nodes);
         }
     }
 }
Beispiel #3
0
        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            var selectedRow = new MenuEntity();

            selectedRow.parentId = Convert.ToString(treeList1.FocusedNode.GetValue("id"));
            var form = new MenuEdit();

            form.menu = selectedRow;
            if (form.ShowDialog() == DialogResult.OK)
            {
                Thread.Sleep(300);
                cmd.ShowOpaqueLayer();
                SearchData();
                MessageBoxUtils.Hint("添加菜单成功!", MainForm);
            }
        }
Beispiel #4
0
        private List <String> lstCheckedOfficeID = new List <String>();//选择局ID集合
        /// <summary>
        /// 获取选择状态的数据主键ID集合
        /// </summary>
        /// <param name="parentNode">父级节点</param>
        private void GetCheckedOfficeID(TreeListNode parentNode)
        {
            if (parentNode.Nodes.Count == 0)
            {
                return;//递归终止
            }

            foreach (TreeListNode node in parentNode.Nodes)
            {
                if (node.CheckState == CheckState.Checked || node.CheckState == CheckState.Indeterminate)
                {
                    MenuEntity menu = treeList1.GetDataRecordByNode(node) as MenuEntity;
                    if (menu != null)
                    {
                        lstCheckedOfficeID.Add(menu.id);
                    }
                }
                GetCheckedOfficeID(node);
            }
        }
Beispiel #5
0
        private List <String> lstCheckedFunctionID = new List <String>(); //功能ID集合
        /// <summary>
        /// 获取选择状态的数据主键ID集合
        /// </summary>
        /// <param name="parentNode">父级节点</param>
        private void GetCheckedID(DevExpress.XtraTreeList.TreeList treeList, TreeListNode parentNode, List <String> strList)
        {
            if (parentNode.Nodes.Count == 0)
            {
                return;//递归终止
            }

            foreach (TreeListNode node in parentNode.Nodes)
            {
                if (node.CheckState == CheckState.Checked || node.CheckState == CheckState.Indeterminate)
                {
                    MenuEntity menu = treeList.GetDataRecordByNode(node) as MenuEntity;
                    if (menu != null)
                    {
                        strList.Add(menu.id);
                    }
                }
                GetCheckedID(treeList, node, strList);
            }
        }
Beispiel #6
0
        private void btnUp_Click(object sender, EventArgs e)
        {
            String id          = Convert.ToString(treeList1.FocusedNode.GetValue("id"));
            var    selectedRow = new MenuEntity();

            if (id == null)
            {
                return;
            }
            selectedRow.id = id;
            var form = new MenuEdit();

            form.menu = selectedRow;
            form.Text = "菜单修改";
            if (form.ShowDialog() == DialogResult.OK)
            {
                Thread.Sleep(300);
                cmd.ShowOpaqueLayer();
                SearchData();
                MessageBoxUtils.Hint("修改菜单成功!", MainForm);
            }
        }
Beispiel #7
0
        private void MenuEdit_Load(object sender, EventArgs e)
        {
            cmd = new Xr.Common.Controls.OpaqueCommand(this);
            cmd.ShowOpaqueLayer(0f);
            dcMenu.DataType = typeof(MenuEntity);
            String extId = "";

            if (menu != null && menu.id != null)
            {
                extId = menu.id;
            }
            //获取下拉框数据
            String param = "?extId=" + extId;
            String url   = AppContext.AppConfig.serverUrl + "sys/sysMenu/treeData" + param;

            this.DoWorkAsync(500, (o) => //耗时逻辑处理(此处不能操作UI控件,因为是在异步中)
            {
                String data = HttpClass.httpPost(url);
                return(data);
            }, null, (data) => //显示结果(此处用于对上面结果的处理,比如显示到界面上)
            {
                JObject objT = JObject.Parse(data.ToString());
                if (string.Compare(objT["state"].ToString(), "true", true) == 0)
                {
                    treeParent.Properties.DataSource               = objT["result"].ToObject <List <MenuEntity> >();
                    treeParent.Properties.TreeList.KeyFieldName    = "id";       //设置ID  
                    treeParent.Properties.TreeList.ParentFieldName = "parentId"; //设置PreID  
                    treeParent.Properties.DisplayMember            = "name";     //要在树里展示的
                    treeParent.Properties.ValueMember              = "id";       //对应的value
                    treeParent.EditValue = "1";

                    if (menu != null)
                    {
                        if (menu.id != null)
                        {
                            this.DoWorkAsync(500, (o) => //耗时逻辑处理(此处不能操作UI控件,因为是在异步中)
                            {
                                data = HttpClass.httpPost(AppContext.AppConfig.serverUrl + "sys/sysMenu/getMenu?menuId=" + menu.id);
                                return(data);
                            }, null, (data2) => //显示结果(此处用于对上面结果的处理,比如显示到界面上)
                            {
                                objT = JObject.Parse(data2.ToString());
                                if (string.Compare(objT["state"].ToString(), "true", true) == 0)
                                {
                                    menu = objT["result"].ToObject <MenuEntity>();
                                    dcMenu.SetValue(menu);
                                    cmd.HideOpaqueLayer();
                                }
                                else
                                {
                                    cmd.HideOpaqueLayer();
                                    MessageBoxUtils.Show(objT["message"].ToString(), MessageBoxButtons.OK,
                                                         MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, this);
                                }
                            });
                        }
                        else
                        {
                            menu.isShow = "1";
                            dcMenu.SetValue(menu);
                            cmd.HideOpaqueLayer();
                        }
                    }
                    else
                    {
                        menu = new MenuEntity();
                        cmd.HideOpaqueLayer();
                    }
                }
                else
                {
                    cmd.HideOpaqueLayer();
                    MessageBoxUtils.Show(objT["message"].ToString(), MessageBoxButtons.OK,
                                         MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, this);
                }
            });
        }
Beispiel #8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!dcRole.Validate())
            {
                return;
            }
            dcRole.GetValue(role);
            //获取选中的权限
            this.lstCheckedOfficeID.Clear();
            if (treeList1.Nodes.Count > 0)
            {
                foreach (TreeListNode root in treeList1.Nodes)
                {
                    if (root.CheckState == CheckState.Checked || root.CheckState == CheckState.Indeterminate)
                    {
                        MenuEntity menu = treeList1.GetDataRecordByNode(root) as MenuEntity;
                        if (menu != null)
                        {
                            lstCheckedOfficeID.Add(menu.id);
                        }
                    }
                    GetCheckedOfficeID(root);
                }
            }

            string idStr = string.Empty;

            foreach (String id in lstCheckedOfficeID)
            {
                idStr += id + ",";
            }
            if (idStr.Length != 0)
            {
                idStr = idStr.Substring(0, idStr.Length - 1);
            }
            role.menuIds = idStr;
            //string strJson = JsonConvert.SerializeObject(test);
            String param = "?" + PackReflectionEntity <RoleEntity> .GetEntityToRequestParameters(role, true) + "&&oldName=" + oldName;

            String url = AppContext.AppConfig.serverUrl + "sys/sysRole/save" + param;

            cmd.ShowOpaqueLayer();
            this.DoWorkAsync(500, (o) => //耗时逻辑处理(此处不能操作UI控件,因为是在异步中)
            {
                String data = HttpClass.httpPost(url);
                return(data);
            }, null, (data) => //显示结果(此处用于对上面结果的处理,比如显示到界面上)
            {
                JObject objT = JObject.Parse(data.ToString());
                cmd.HideOpaqueLayer();
                if (string.Compare(objT["state"].ToString(), "true", true) == 0)
                {
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBoxUtils.Show(objT["message"].ToString(), MessageBoxButtons.OK,
                                         MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, this);
                }
            });
        }