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]
///
/// [颜色:16进制转成RGB]
///
/// 设置16进制颜色 [返回RGB]
///
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
}
}