|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using ICSharpCode.Core;
|
|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
using Mesnac.Codd.Session;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Alarm.PmtAlarm
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 报警参数查询业务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class SelectAction: ChemicalWeighingAction, IAction
|
|
|
|
|
{
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
|
|
{
|
|
|
|
|
base.RunIni(runtime); //必须要调用的
|
|
|
|
|
ICSharpCode.Core.LoggingService<SelectAction>.Debug("报警参数-查询...");
|
|
|
|
|
|
|
|
|
|
FrmInsert frmInsert = new FrmInsert(ActionType.Query);
|
|
|
|
|
DialogResult result = frmInsert.ShowDialog();
|
|
|
|
|
if (result == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = System.Data.CommandType.Text;
|
|
|
|
|
|
|
|
|
|
StringBuilder sbSql = new StringBuilder("SELECT * FROM Pmt_Alarm WHERE 1=1");
|
|
|
|
|
if (frmInsert.AlarmPLC != Mesnac.Basic.LanguageHelper.PleaseSelect)
|
|
|
|
|
{
|
|
|
|
|
sbSql.Append(" AND Alarm_PLC = @AlarmPLC");
|
|
|
|
|
dbHelper.AddParameter("@AlarmPLC", frmInsert.AlarmPLC);
|
|
|
|
|
}
|
|
|
|
|
if (!String.IsNullOrEmpty(frmInsert.AlarmBlock))
|
|
|
|
|
{
|
|
|
|
|
sbSql.Append(" AND Alarm_Block like @AlarmBlock");
|
|
|
|
|
dbHelper.AddParameter("@AlarmBlock", "%" + frmInsert.AlarmBlock + "%");
|
|
|
|
|
}
|
|
|
|
|
if (!String.IsNullOrEmpty(frmInsert.AlarmName))
|
|
|
|
|
{
|
|
|
|
|
sbSql.Append(" AND Alarm_Cn_Info like @AlarmName");
|
|
|
|
|
dbHelper.AddParameter("@AlarmName", "%" + frmInsert.AlarmName + "%");
|
|
|
|
|
}
|
|
|
|
|
if (!String.IsNullOrEmpty(frmInsert.AlarmCode))
|
|
|
|
|
{
|
|
|
|
|
sbSql.Append(" AND Alarm_ID like @AlarmCode");
|
|
|
|
|
dbHelper.AddParameter("@AlarmCode", "%" + frmInsert.AlarmCode + "%");
|
|
|
|
|
}
|
|
|
|
|
if (!String.IsNullOrEmpty(frmInsert.AlarmPosition))
|
|
|
|
|
{
|
|
|
|
|
sbSql.Append(" AND Alarm_Other_Info like @AlarmPosition");
|
|
|
|
|
dbHelper.AddParameter("@AlarmPosition", "%" + frmInsert.AlarmPosition + "%");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (frmInsert.AlarmAddress >= 0)
|
|
|
|
|
{
|
|
|
|
|
sbSql.Append(" AND Alarm_Word = @AlarmAddress");
|
|
|
|
|
dbHelper.AddParameter("@AlarmAddress", frmInsert.AlarmAddress);
|
|
|
|
|
}
|
|
|
|
|
if (frmInsert.AlarmBit >= 0)
|
|
|
|
|
{
|
|
|
|
|
sbSql.Append(" AND Alarm_Bit = @AlarmBit");
|
|
|
|
|
dbHelper.AddParameter("@AlarmBit", frmInsert.AlarmBit);
|
|
|
|
|
}
|
|
|
|
|
sbSql.Append(" ORDER BY Alarm_PLC, Alarm_Block, Alarm_Word, Alarm_Bit");
|
|
|
|
|
|
|
|
|
|
dbHelper.CommandText = sbSql.ToString();
|
|
|
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
|
|
|
|
|
|
|
//刷新DataGridView数据
|
|
|
|
|
DbMCControl dgPmtAlarmInfo = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_Alarm").FirstOrDefault();
|
|
|
|
|
if (dgPmtAlarmInfo == null || !(dgPmtAlarmInfo.BaseControl is DataGridView))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<InsertAction>.Warn("报警参数-查询-缺少报警参数DataGridView控件...");
|
|
|
|
|
runtime.IsReturn = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
dgPmtAlarmInfo.BaseControl.BindDataSource = null;
|
|
|
|
|
dgPmtAlarmInfo.BaseControl.BindDataSource = table;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|