You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lj_plc/Actions/Default/Mesnac.Action.Default/Purview/BasRole/InitFormAction.cs

74 lines
2.7 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Mesnac.Action.Base;
namespace Mesnac.Action.Default.Purview.BasRole
{
/// <summary>
/// 角色信息窗体初始化
/// </summary>
public class InitFormAction : DatabaseAction, IAction
{
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
ICSharpCode.Core.LoggingService<InitFormAction>.Debug("角色信息-窗体初始化...");
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "BasRole").FirstOrDefault();
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService<InitFormAction>.Warn("{角色信息-窗体初始化} 缺少datagridview控件...");
runtime.IsReturn = false;
return;
}
else
{
DataGridView clientGrid = (clientGridControl.BaseControl as DataGridView);
if (clientGrid != null)
{
clientGrid.DataSourceChanged += RefreshBackColor;
clientGrid.VisibleChanged += RefreshBackColor;
SetBackColor(clientGrid, "DeleteFlag", "1", System.Drawing.Color.Gray);
}
}
}
private void RefreshBackColor(object sender, EventArgs e)
{
DataGridView clientGrid = sender as DataGridView;
SetBackColor(clientGrid, "DeleteFlag", "1", System.Drawing.Color.Gray);
}
public static void SetBackColor(DataGridView grid, string columnName, object filterValue, System.Drawing.Color c)
{
lock (String.Empty)
{
try
{
if (grid == null)
{
ICSharpCode.Core.LoggingService<InitFormAction>.Warn("设置GridViewRow背景色失败网格控件为null");
return;
}
foreach (DataGridViewRow row in grid.Rows)
{
if (filterValue.Equals(row.Cells[columnName].Value))
{
row.DefaultCellStyle.BackColor = c;
}
}
}
catch (Exception ex)
{
ICSharpCode.Core.LoggingService<InitFormAction>.Error("设置GridViewRow背景色失败" + ex.Message);
}
}
}
}
}