1
yhj
2024-07-24 5e5d945e91568b973faa27d8ab0bcef99fc4a6c5
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
#region
 
using System;
using CSFrameworkV5.Business;
using CSFrameworkV5.Common;
using CSFrameworkV5.Models;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Repository;
 
#endregion
 
namespace CSFrameworkV5.Library.CommonClass
{
    public class PermissionBinder
    {
        public static void BoundCheckEdit(CheckEdit chk)
        {
            chk.Properties.AutoHeight = false;
            chk.Properties.NullStyle = StyleIndeterminate.Unchecked;
            chk.Properties.ValueChecked = "Y";
            chk.Properties.ValueUnchecked = "N";
        }
 
        public static void BoundCheckEdit(RepositoryItemCheckEdit lueCheck)
        {
            lueCheck.AutoHeight = false;
            lueCheck.NullStyle = StyleIndeterminate.Unchecked;
            lueCheck.ValueChecked = "Y";
            lueCheck.ValueUnchecked = "N";
        }
 
        public static void BoundUser(LookUpEdit lue)
        {
            lue.Properties.NullText = "";
            lue.Properties.DropDownRows = 15;
            InitializeControl(lue, new[] { "帐号", "姓名" },
                new[] { "Account", "UserName" });
            lue.Properties.Columns[0].Width = 60;
            lue.Properties.Columns[1].Width = 140;
            lue.Properties.PopupWidth = 200;
            DataBinder.BindingLookupEditDataSource(lue,
                DataDictCache.Cache.User, "UserName", "Account");
        }
 
        public static void BoundUser(RepositoryItemLookUpEdit lue)
        {
            lue.Columns.Clear();
            InitializeControl(lue, new[] { "姓名" },
                new[] { tb_MyUser.UserName });
            lue.DropDownRows = 25;
            var dt = DataDictCache.Cache.User;
            DataBinder.BindingLookupEditDataSource(lue, dt, tb_MyUser.UserName,
                tb_MyUser.Account);
        }
 
        /// <summary>
        ///     初始化控件列(Names和FileNames必须保证长度一致)
        /// </summary>
        /// <param name="lue"></param>
        /// <param name="Names">显示列名集合</param>
        /// <param name="FileNames">对应字段名</param>
        public static void InitializeControl(LookUpEdit lue, string[] Names,
            string[] FileNames)
        {
            try
            {
                lue.Properties.Columns.Clear();
                lue.Properties.NullText = "";
                lue.Properties.DropDownRows = 25;
 
                if (lue.Properties.Columns.Count == 0)
                    for (var i = 0; i < Names.Length; i++)
                    {
                        var col = new LookUpColumnInfo();
                        col.Caption = Names[i];
                        col.FieldName = FileNames[i];
                        lue.Properties.Columns.Add(col);
                    }
            }
            catch (Exception e)
            {
                Msg.Warning(e.Message);
            }
        }
 
        /// <summary>
        ///     初始化控件列(Names和FileNames必须保证长度一致)
        /// </summary>
        /// <param name="lue"></param>
        /// <param name="Names">显示列名集合</param>
        /// <param name="FileNames">对应字段名</param>
        private static void InitializeControl(RepositoryItemLookUpEdit lue,
            string[] Names, string[] FileNames)
        {
            try
            {
                lue.Columns.Clear();
                lue.NullText = "";
                if (lue.Columns.Count == 0)
                    for (var i = 0; i < Names.Length; i++)
                    {
                        var col = new LookUpColumnInfo();
                        col.Caption = Names[i];
                        col.FieldName = FileNames[i];
                        lue.Columns.Add(col);
                    }
            }
            catch (Exception e)
            {
                Msg.Warning(e.Message);
            }
        }
    }
}