南骏 池
2024-09-01 fc1b563df6d0405a24e7898c997bd52472ae9154
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using Gs.DevApp.Models;
using Gs.DevApp.ToolBox;
using Newtonsoft.Json;
using System;
using System.Data;
 
 
namespace Gs.DevApp.DevFrm.User
{
    public partial class SysMenu : DevExpress.XtraEditors.XtraForm
    {
        public SysMenu()
        {
            InitializeComponent();
            getTree();
            this.toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick;
            this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick;
            this.toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick;
            this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
        }
 
        private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
        {
            getTree();
        }
 
        private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
        {
            String rowGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("guid"));
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要删除的行!");
                return;
            }
            SysMenuAdd frm = new SysMenuAdd(rowGuid);
            frm.ShowDialog();
        }
 
        private void ToolBarMenu1_btnDelClick(object sender, EventArgs e)
        {
            String rowGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("guid"));
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要删除的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了【" + tlMenu.FocusedNode.GetValue("name") + "】,确定删除吗?"))
            {
                return;
            }
            var _obj = new
            {
                guid = rowGuid,//主建
            };
            string strJson = "";
            try
            {
                strJson = UtilityHelper.HttpPost("", "MenuAction/DeleteModel", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
                if (_rtn.rtnCode > 0) { getTree(); }
                ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
 
        private void ToolBarMenu1_btnAddClick(object sender, EventArgs e)
        {
            SysMenuAdd frm = new SysMenuAdd("");
            frm.UpdateParent += Frm_UpdateParent;
            frm.ShowDialog();
        }
        private void Frm_UpdateParent(object sender, UpdateParentEventArgs e)
        {
            getTree();
        }
        private void getTree()
        {
            Models.PageQueryModel pgq = new Models.PageQueryModel(1, 999999, "idx", "asc", "", "");
            string json = JsonConvert.SerializeObject(pgq);
            string strReturn = "";
            try
            {
                strReturn = UtilityHelper.HttpPost("", "MenuAction/GetListPage", json);
                ReturnModel<PageListModel> dd = UtilityHelper.GetTableByJson(strReturn);
                DataTable dt = dd.rtnData.list;
                this.tlMenu.DataSource = dt;
                this.tlMenu.KeyFieldName = "guid";
                this.tlMenu.ParentFieldName = "upGuid";
                this.tlMenu.Tag = "name";
                this.tlMenu.EndUpdate();
                this.tlMenu.ExpandAll();
                tlMenu.OptionsView.CheckBoxStyle = DevExpress.XtraTreeList.DefaultNodeCheckBoxStyle.Default;
                // 设置不关联选择
                //tlMenu.OptionsSelection.MultiSelect = true;
                //tlMenu.OptionsSelection.MaintainState = false; // 关键设置
                //this.tlMenu.OptionsBehavior.AllowIndeterminateCheckState = true;
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
 
    }
}