|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using ICSharpCode.Core;
|
|
|
|
|
using Mesnac.Codd.Session;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Alarm.PmtAlarm
|
|
|
|
|
{
|
|
|
|
|
public partial class FrmInsert : Form
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#region 字段定义
|
|
|
|
|
|
|
|
|
|
private ActionType _actionType = ActionType.Add; //操作类别,默认为添加
|
|
|
|
|
PmtAlarmInfo entity = null;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 构造方法
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 无参构造方法
|
|
|
|
|
/// </summary>
|
|
|
|
|
public FrmInsert()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 参数构造方法
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="actionType">操作类型</param>
|
|
|
|
|
public FrmInsert(ActionType actionType, PmtAlarmInfo _entity)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
this._actionType = actionType;
|
|
|
|
|
if (actionType == ActionType.Modify)
|
|
|
|
|
{
|
|
|
|
|
entity = new PmtAlarmInfo();
|
|
|
|
|
entity = _entity;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 属性定义
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 报警PLC
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int ID { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 报警PLC
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string AlarmPLC
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this.cmbAlarmPLC.SelectedValue as string;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 报警数据块
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string AlarmBlock
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this.txtAlarmBlock.Text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 报警代码
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Alarm_Alias
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this.txtAlarmAlias.Text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 中文报警名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Alarm_Cn_Info
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this.txtAlarmCn.Text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 方法定义
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化界面元素
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void InitUIMethod()
|
|
|
|
|
{
|
|
|
|
|
//if (this._actionType == ActionType.Add)
|
|
|
|
|
//{
|
|
|
|
|
// this.txtAlarmCn.Enabled = false;
|
|
|
|
|
// this.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_Text")); //添加报警参数
|
|
|
|
|
// this.groupBox1.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_groupBox1_Text")); //报警参数信息
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// this.txtAlarmCn.Enabled = true;
|
|
|
|
|
// this.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_Text_Query")); //查询报警参数
|
|
|
|
|
// this.groupBox1.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_groupBox1_Text_Query")); //查询条件
|
|
|
|
|
//}
|
|
|
|
|
this.label8.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_label8_Text")); //报警PLC
|
|
|
|
|
this.label7.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_label7_Text")); //报警数据块
|
|
|
|
|
//this.label1.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_label1_Text")); //报警地址
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.btnOk.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Dialog_btnOK")); //确定
|
|
|
|
|
this.btnCancel.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Dialog_btnCancel")); //取消
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化界面数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void InitData()
|
|
|
|
|
{
|
|
|
|
|
List<string> plcList = new List<string>();
|
|
|
|
|
plcList.Add(Mesnac.Basic.LanguageHelper.PleaseSelect);
|
|
|
|
|
foreach(string plc in Mesnac.Equips.Factory.Instance.AllEquips.Keys)
|
|
|
|
|
{
|
|
|
|
|
plcList.Add(plc);
|
|
|
|
|
}
|
|
|
|
|
this.cmbAlarmPLC.DataSource = plcList;
|
|
|
|
|
|
|
|
|
|
if (this._actionType == ActionType.Modify)
|
|
|
|
|
{
|
|
|
|
|
this.cmbAlarmPLC.SelectedIndex = cmbAlarmPLC.Items.IndexOf(entity.AlarmPLC);
|
|
|
|
|
this.txtAlarmBlock.Text = entity.AlarmBlock;
|
|
|
|
|
this.txtAlarmAlias.Text = entity.AlarmAlias;
|
|
|
|
|
this.txtAlarmCn.Text = entity.Alarm_Cn_Info;
|
|
|
|
|
ID = entity.ID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 事件处理
|
|
|
|
|
|
|
|
|
|
private void FrmInsert_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.InitUIMethod();
|
|
|
|
|
this.InitData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnOk_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this._actionType == ActionType.Add|| this._actionType == ActionType.Modify)
|
|
|
|
|
{
|
|
|
|
|
if (this.AlarmPLC.Contains("请选择"))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<FrmInsert>.Warn("请选择报警PLC!");
|
|
|
|
|
string msg101 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_msg101")); //请选择报警PLC!
|
|
|
|
|
MessageBox.Show(msg101, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
this.cmbAlarmPLC.Focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (String.IsNullOrEmpty(this.txtAlarmBlock.Text.Trim()))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<FrmInsert>.Warn("报警数据块不能为空,请输入报警数据块!");
|
|
|
|
|
string msg10 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_msg10")); //报警数据块不能为空,请输入报警数据块!
|
|
|
|
|
MessageBox.Show(msg10, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
this.txtAlarmBlock.Focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!Mesnac.Basic.DataProcessor.IsNumeric(this.txtAlarmBlock.Text.Trim()))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<FrmInsert>.Warn("报警数据块应为数字!");
|
|
|
|
|
string msg12 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_msg12")); //报警数据块应为数字!
|
|
|
|
|
MessageBox.Show(msg12, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
this.txtAlarmBlock.Focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(this.txtAlarmAlias.Text.Trim()))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<FrmInsert>.Warn("报警地址别名不能为空,请输入报警别名!");
|
|
|
|
|
string msg1 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_msg1")); //报警地址不能为空,请输入报警地址!
|
|
|
|
|
MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
this.txtAlarmAlias.Focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//判断报警PLC、报警数据块、报警地址字和报警地址位是否都相同
|
|
|
|
|
if (AlarmHelper.IsExists(entity.ID, this.AlarmPLC, this.AlarmBlock, this.Alarm_Alias))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<FrmInsert>.Warn("报警PLC、报警数据块、报警地址别名不能都相同!");
|
|
|
|
|
string msg13 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_msg13")); //报警PLC、报警数据块、报警地址字和报警地址位不能都相同!
|
|
|
|
|
MessageBox.Show(msg13, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
this.txtAlarmBlock.Focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|