限制NG为98

This commit is contained in:
liming 蔡
2026-08-11 18:57:20 +08:00
parent 25f2ae3d44
commit 3ea4e4fd7b
3 changed files with 39 additions and 36 deletions
+12 -9
View File
@@ -81,11 +81,14 @@ namespace LargeSquareOne
// 保存
private void btnSave_Click(object sender, EventArgs e)
{
// 更新当前通道数据
if (_currentChannel != null)
var errList = _config.Channels.Where(x => x.AllContent.Contains("NG") && x.DefaultValue != 98).ToList();
if (errList.Count > 0)
{
_currentChannel.DefaultValue = (int)numDefaultValue.Value;
var errArr = errList.Select(it => it.DefaultValue).ToArray();
MessageBox.Show($"NG写给PLC的值必须为98,不能为{string.Join(",", errArr)}");
return;
}
CommonMethods.SaveToJson(CommonMethods.ChannelPath, _config);
MessageBox.Show("保存成功!");
}
@@ -122,12 +125,12 @@ namespace LargeSquareOne
private void numDefaultValue_Validating(object sender, CancelEventArgs e)
{
if ((int)numDefaultValue.Value == 98)
{
MessageBox.Show("98: 扫码NG(不允许在界面配置)");
e.Cancel = true;
return;
}
//if ((int)numDefaultValue.Value == 98)
//{
// MessageBox.Show("98: 扫码NG(不允许在界面配置)");
// e.Cancel = true;
// return;
//}
}
}
}