|
@@ -12,6 +12,7 @@ using System.Collections.Generic;
|
|
|
using System.Collections.ObjectModel;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
+using System.Text.RegularExpressions;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
|
|
@@ -47,7 +48,7 @@ namespace PLCTool.ViewModels.MonitorManageViewModel
|
|
|
MessageBox.Show("PLC未连接!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
long id = Convert.ToInt64(obj);
|
|
|
var findPlcItem= PLCItemList.FirstOrDefault(l => l.Id == id);
|
|
|
if(findPlcItem!=null)
|
|
@@ -57,7 +58,12 @@ namespace PLCTool.ViewModels.MonitorManageViewModel
|
|
|
string plcValue = findPlcItem.PlcValue;
|
|
|
if (string.IsNullOrEmpty(plcValue))
|
|
|
{
|
|
|
- MessageBox.Show("请填写数据!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
+ MessageBox.Show("输入为空,请填写数据!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!IsInteger(plcValue))
|
|
|
+ {
|
|
|
+ MessageBox.Show("请填写正整数!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
return;
|
|
|
}
|
|
|
switch (plcAddType)
|
|
@@ -101,6 +107,16 @@ namespace PLCTool.ViewModels.MonitorManageViewModel
|
|
|
|
|
|
}
|
|
|
/// <summary>
|
|
|
+ /// 判断输入的数据
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="input"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool IsInteger(string input)
|
|
|
+ {
|
|
|
+ Regex regex = new Regex(@"^[1-9]\d*$");
|
|
|
+ return regex.IsMatch(input);
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
/// 获取PLC配置
|
|
|
/// </summary>
|
|
|
private void GetPLCConfig()
|
|
@@ -115,6 +131,7 @@ namespace PLCTool.ViewModels.MonitorManageViewModel
|
|
|
PLCItemList.Add(plc);
|
|
|
}
|
|
|
}
|
|
|
+ PLCItemList = new AsyncObservableCollection<BasPlcItemConfigDto>(PLCItemList.OrderBy(x => x.Id));
|
|
|
}
|
|
|
|
|
|
|