Shuxia Ning
2025-01-08 687a3dfd095bc8c099b7fa6e65f0dc699fdc8f1d
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
using DevExpress.XtraEditors;
using NetTaste;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Yw;
using Yw.WinFrmUI;
 
namespace HStation.WinFrmUI
{
    public partial class RoleProjectMenuPage : DocumentPage
    {
        public RoleProjectMenuPage()
        {
            InitializeComponent();
            this.treeList1.InitialMultiColSettings();
 
            this.roleTreeListCtrl1.FocusedChangedEvent += RoleTreeListCtrl1_FocusedChangedEvent;
        }
 
        public override void InitialDataSource()
        {
            this.roleTreeListCtrl1.InitialData();
        }
 
        private List<RoleProjcetMenuViewModel> _allBindingList;
 
        private long _roleID;
 
        /// <summary>
        /// 聚焦改变事件
        /// </summary>
        private async void RoleTreeListCtrl1_FocusedChangedEvent(Yw.Vmo.Role obj)
        {
            _roleID = obj.ID;
 
            _allBindingList = new List<RoleProjcetMenuViewModel>();
            var allList = await BLLFactory<Yw.BLL.RoleProjectMenuMapping>.Instance.GetAuthorizeMenuList(1, obj.ID);
            foreach (var item in allList)
            {
                _allBindingList.Add(new RoleProjcetMenuViewModel(item));
            }
            this.roleProjcetMenuViewModelBindingSource.DataSource = _allBindingList;
            this.roleProjcetMenuViewModelBindingSource.ResetBindings(false);
        }
 
        //保存
        private async void BtnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var menuList = new List<long>();
            foreach (var item in _allBindingList)
            {
                if (item.Have)
                {
                    menuList.Add(item.ID);
                }
            }
            var bol = await BLLFactory<Yw.BLL.RoleProjectMenuMapping>.Instance.Set(1, _roleID, menuList);
            if (bol)
            {
                TipFormHelper.ShowSucceed("保存成功!");
            }
            else
            {
                TipFormHelper.ShowError("保存失败!");
            }
        }
    }
}