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/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Alarm/PmtAlarm/InitFormAction.cs

49 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using Mesnac.Action.Base;
using Mesnac.Codd.Session;
namespace Mesnac.Action.ChemicalWeighing.Alarm.PmtAlarm
{
/// <summary>
/// 报警参数窗体初始化
/// </summary>
public class InitFormAction : ChemicalWeighingAction, IAction
{
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用的
ICSharpCode.Core.LoggingService<InitFormAction>.Debug("报警参数-窗体初始化...");
DbMCControl ctlAlarmPLC = base.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[Pmt_Alarm].[Alarm_PLC]").FirstOrDefault();
if (ctlAlarmPLC == null || !(ctlAlarmPLC.BaseControl is ComboBox))
{
ICSharpCode.Core.LoggingService<InitFormAction>.Warn("报警参数-窗体初始化-界面中缺少报警PLC组合框控件...");
return;
}
DataTable dt = new DataTable();
dt.Columns.Add("ItemName", typeof(string));
dt.Columns.Add("ItemValue", typeof(string));
DataRow dr = dt.NewRow();
dr["ItemName"] = Mesnac.Basic.LanguageHelper.PleaseSelect;
dr["ItemValue"] = Mesnac.Basic.LanguageHelper.PleaseSelect;
dt.Rows.Add(dr);
foreach(string plc in Mesnac.Equips.Factory.Instance.AllEquips.Keys)
{
dr = dt.NewRow();
dr["ItemName"] = plc;
dr["ItemValue"] = plc;
dt.Rows.Add(dr);
}
ctlAlarmPLC.BaseControl.BindDataSource = dt;
}
}
}