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.

61 lines
2.3 KiB
C#

1 year ago
using Mesnac.Action.Base;
using Mesnac.Codd.Session;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.Alarm.PmtAlarm
{
public class DeleteAction : ChemicalWeighingAction, IAction
{
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
ICSharpCode.Core.LoggingService<InsertAction>.Debug("报警参数-添加...");
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_Alarm").FirstOrDefault();
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService<ModifyAction>.Error("{预警管理—初始化}缺少警管理控件...");
return;
}
DataGridView alarmGridView = clientGridControl.BaseControl as DataGridView;
string selectID =alarmGridView.SelectedRows[0].Cells["ID"].Value.ToString();
string strSql = @"delete from Pmt_Alarm where ID=@ID";
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
dbHelper.ClearParameter();
dbHelper.CommandText = strSql;
dbHelper.CommandType = System.Data.CommandType.Text;
dbHelper.AddParameter("@ID", selectID);
dbHelper.ExecuteNonQuery();
//清空报警缓存
Cache.CacheHelper.ClearAlarmInfo();
//刷新DataGridView数据
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService<InsertAction>.Warn("报警参数-添加-缺少报警参数DataGridView控件...");
runtime.IsReturn = false;
return;
}
string sql = "select * from Pmt_Alarm";
DataTable table = dbHelper.GetDataTableBySql(sql);
clientGridControl.BaseControl.BindDataSource = table;
}
}
}