王 垚
2021-02-28 156e06ad46f0e4cb61c5f74553f6c2bc51e21a04
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
using Kingdee.BOS.Core.List.PlugIn;
using Kingdee.BOS.Core.Metadata;
using System.Drawing;
using System;
using Kingdee.BOS;
using System.ComponentModel;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.Util;
using System.Data;
using Kingdee.BOS.ServiceHelper;
 
namespace Demo.BillView.PRD
{
    [Description("列表插件设置颜色")]
    [HotUpdate]
    public class PODemandPlanListLoad : AbstractListPlugIn
    {
        public override void OnFormatRowConditions(Kingdee.BOS.Core.List.PlugIn.Args.ListFormatConditionArgs args)
        {
            base.OnFormatRowConditions(args);
            try
            {
                FormatCondition fc = new FormatCondition();
                fc.ApplayRow = true;
                DataTable dt = new DataTable();
                dt = DBServiceHelper.ExecuteDataSet(Context, "/*dialect*/select * from Jit_TlPlanConfigureDetail").Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    if (args.DataRow["FLateReason2"].ToString() == dr["FLateReason"].ToString())
                    {
                        fc.BackColor = ColorTranslator.ToHtml(Color.FromName(dr["FSYSTEMCOLOR"].ToString()));
                    }
                }
                args.FormatConditions.Add(fc);
            }
            catch (Exception ex)
            {
                LogService.WriteAsync("测试");
            }
        }
 
        #region [颜色:16进制转成RGB]
        /// <summary>
        /// [颜色:16进制转成RGB]
        /// </summary>
        /// <param name="strColor">设置16进制颜色 [返回RGB]</param>
        /// <returns></returns>
        public static System.Drawing.Color colorHx16toRGB(string strHxColor)
        {
            try
            {
                if (strHxColor.Length == 0)
                {//如果为空
                    return System.Drawing.Color.FromArgb(0, 0, 0);//设为黑色
                }
                else
                {//转换颜色
                    return System.Drawing.Color.FromArgb(System.Int32.Parse(strHxColor.Substring(1, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(3, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(5, 2), System.Globalization.NumberStyles.AllowHexSpecifier));
                }
            }
            catch
            {//设为黑色
                return System.Drawing.Color.FromArgb(0, 0, 0);
            }
        }
        #endregion
 
    }
}