lixiaojun
2025-01-21 f589894c84d47b9671eef6d3a8337b6b51b32edb
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using Yw.WinFrmUI;
 
namespace HStation.WinFrmUI.Auth
{
    public partial class MenuMgrMainPanel : DocumentPage
    {
        public MenuMgrMainPanel()
        {
            InitializeComponent();
            GetData();
        }
        Yw.BLL.ProjectMenu _sever = new Yw.BLL.ProjectMenu();
        List<HStation.WinFrmUI.Auth.MenuViewModel> _AllMenu = new List<HStation.WinFrmUI.Auth.MenuViewModel>();
        public async void GetData()
        {
            var AllMenu = await this._sever.GetByProjectID(0);
            _AllMenu.Clear();
            foreach (var menus in AllMenu)
            {
                var menu = new HStation.WinFrmUI.Auth.MenuViewModel(menus);
                _AllMenu.Add(menu);
            }
            //Yw.Vmo.ProjectMenu a = new Yw.Vmo.ProjectMenu();
            //a.ID = 1;
            //a.Name = "aa";
            //a.Description = "aa";
            //a.Permission = "aa";
            //a.IsHide = true;
            //a.ParentID = 0;
            //Yw.Vmo.ProjectMenu b = new Yw.Vmo.ProjectMenu();
            //b.ID = 2;
            //b.Name = "aa";
            //b.Description = "aa";
            //b.Permission = "aa";
            //b.IsHide = true;
            //b.ParentID = 1;
            //_AllMenu.Add(a);
            //_AllMenu.Add(b);
            treeList.Nodes.Clear();
            treeList.KeyFieldName = "ID";
            treeList.ParentFieldName = "ParentID";
            bindingSourceMenu.DataSource = _AllMenu;
            this.bindingSourceMenu.ResetBindings(false);
        }
        //添加
        private void AddMenu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var dlg = new AddMenuDlg();
            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            GetData();
        }
        //编辑
        private void EditMenu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var dlg = new UpdataMenuDlg();
            var currentVm = this.treeList.GetCurrentViewModel(_AllMenu);
            //var a =currentVm.ErpCode;
            if (currentVm == null)
            {
                MessageBoxHelper.ShowWarning("请选择数据行");
                return;
            }
            var CurrentVm = currentVm.ConvertToProjectMenu(currentVm);
            dlg.SetMenuData(CurrentVm);
            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            GetData();
        }
        //删除
        private void DeleteMenu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
 
        }
 
        private void treeList_CustomUnboundColumnData(object sender, DevExpress.XtraTreeList.TreeListCustomColumnDataEventArgs e)
        {
            if (e.Column == treeListColumnType)
            {
                var employee = e.Row as HStation.Vmo.EmployeeMain;
                var Type = e.Row as HStation.WinFrmUI.Auth.MenuViewModel;
                if (Type == null)
                {
                    MessageBox.Show("错误!");
                    return;
                }
                if (Type.Type == 0)
                {
                    e.Value = "菜单";
                }
                else if (Type.Type == 1)
                {
                    e.Value = "目录";
                }
                else if (Type.Type == 2)
                {
                    e.Value = "功能点";
                }
                else
                {
                    MessageBox.Show("Type传入值错误!");
                    return;
                }
            }
            if (e.Column == treeListColumnWeight)
            {
                var Weight = e.Row as HStation.WinFrmUI.Auth.MenuViewModel;
                if (Weight == null)
                {
                    MessageBox.Show("错误!");
                    return;
                }
                if (Weight.Weight == Yw.Auth.eAuthWeight.Normal)
                {
                    e.Value = "普通";
                }
                else if (Weight.Weight == Yw.Auth.eAuthWeight.Admin)
                {
                    e.Value = "管理";
                }
                else if (Weight.Weight == Yw.Auth.eAuthWeight.System)
                {
                    e.Value = "系统";
                }
                else
                {
                    MessageBox.Show("Weight传入值错误!");
                    return;
                }
 
            }
        }
    }
}