|
|
|
|
using ICSharpCode.Core;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Solvent.Alarm
|
|
|
|
|
{
|
|
|
|
|
public partial class FrmInsert : Form
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#region 字段定义
|
|
|
|
|
|
|
|
|
|
private ActionType _actionType = ActionType.Add; //操作类别,默认为添加
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 构造方法
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 无参构造方法
|
|
|
|
|
/// </summary>
|
|
|
|
|
public FrmInsert()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 参数构造方法
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="actionType">操作类型</param>
|
|
|
|
|
public FrmInsert(ActionType actionType)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
this._actionType = actionType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 属性定义
|
|
|
|
|
|
|
|
|
|
/// <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 AlarmCode
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this.txtAlarmCode.Text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 报警信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string AlarmName
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this.txtAlarmName.Text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 报警地址字
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int AlarmAddress
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
int intAlarmAddress = -1;
|
|
|
|
|
if (!String.IsNullOrEmpty(this.txtAlarmAddress.Text.Trim()))
|
|
|
|
|
{
|
|
|
|
|
int.TryParse(this.txtAlarmAddress.Text, out intAlarmAddress);
|
|
|
|
|
}
|
|
|
|
|
return intAlarmAddress;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 报警位
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int AlarmBit
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
int intAlarmBit = -1;
|
|
|
|
|
if (!String.IsNullOrEmpty(this.txtAlarmBit.Text.Trim()))
|
|
|
|
|
{
|
|
|
|
|
int.TryParse(this.txtAlarmBit.Text, out intAlarmBit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return intAlarmBit;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 报警位置
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string AlarmPosition
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this.txtAlarmPosition.Text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 方法定义
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化界面元素
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void InitUIMethod()
|
|
|
|
|
{
|
|
|
|
|
if (this._actionType == ActionType.Add)
|
|
|
|
|
{
|
|
|
|
|
this.txtAlarmCode.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.txtAlarmCode.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.label2.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_label2_Text")); //报警位
|
|
|
|
|
this.label3.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_label3_Text")); //报警代码
|
|
|
|
|
this.label4.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_label4_Text")); //报警名称
|
|
|
|
|
this.label5.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_label5_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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
{
|
|
|
|
|
if (this.AlarmPLC == Mesnac.Basic.LanguageHelper.PleaseSelect)
|
|
|
|
|
{
|
|
|
|
|
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.txtAlarmAddress.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.txtAlarmAddress.Focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!Mesnac.Basic.DataProcessor.IsNumeric(this.txtAlarmAddress.Text.Trim()))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<FrmInsert>.Warn("报警地址应为数字!");
|
|
|
|
|
string msg2 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_msg2")); //报警地址应为数字!
|
|
|
|
|
MessageBox.Show(msg2, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
txtAlarmAddress.Focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(this.txtAlarmBit.Text.Trim()))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<FrmInsert>.Warn("报警位不能为空,请输入报警位!");
|
|
|
|
|
string msg3 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_msg3")); //报警位不能为空,请输入报警位!
|
|
|
|
|
MessageBox.Show(msg3, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
this.txtAlarmBit.Focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!Mesnac.Basic.DataProcessor.IsNumeric(this.txtAlarmBit.Text.Trim()))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<FrmInsert>.Warn("报警位应为数字!");
|
|
|
|
|
string msg4 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_msg4")); //报警位应为数字!
|
|
|
|
|
MessageBox.Show(msg4, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
this.txtAlarmBit.Focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//if (String.IsNullOrEmpty(this.txtAlarmCode.Text.Trim()))
|
|
|
|
|
//{
|
|
|
|
|
// ICSharpCode.Core.LoggingService<FrmInsert>.Warn("报警代码不能为空,请输入代码名称!");
|
|
|
|
|
// string msg5 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_msg5")); //报警代码不能为空,请输入代码名称!
|
|
|
|
|
// MessageBox.Show(msg5, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
// this.txtAlarmCode.Focus();
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
//if (AlarmHelper.IsExistsAlarmCode(this.AlarmCode))
|
|
|
|
|
//{
|
|
|
|
|
// ICSharpCode.Core.LoggingService<FrmInsert>.Warn("已存在此报警代码,请输入新的报警代码!");
|
|
|
|
|
// string msg6 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_msg6")); //已存在此报警代码,请输入新的报警代码!
|
|
|
|
|
// MessageBox.Show(msg6, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
// this.txtAlarmCode.Focus();
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
if (String.IsNullOrEmpty(this.txtAlarmName.Text.Trim()))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<FrmInsert>.Warn("报警名称不能为空,请输入报警名称!");
|
|
|
|
|
string msg7 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_msg7")); //报警名称不能为空,请输入报警名称!
|
|
|
|
|
MessageBox.Show(msg7, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
this.txtAlarmName.Focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (AlarmHelper.IsExistsAlarmName(this.AlarmPLC, this.AlarmName))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<FrmInsert>.Warn("此报警PLC中已存在此报警名称,请输入新的报警名称!");
|
|
|
|
|
string msg8 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Alarm_PmtAlarm_FrmInsert_msg8")); //此报警PLC中已存在此报警名称,请输入新的报警名称!
|
|
|
|
|
MessageBox.Show(msg8, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
this.txtAlarmName.Focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//判断报警PLC、报警数据块、报警地址字和报警地址位是否都相同
|
|
|
|
|
if (AlarmHelper.IsExists(this.AlarmPLC, this.AlarmBlock, this.AlarmAddress, this.AlarmBit))
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|