user_lt il y a 1 an
Parent
commit
b25b5cb7fc

+ 2 - 0
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/BaseConfigViewModel.cs

@@ -99,6 +99,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                                            && (string.IsNullOrEmpty(SelectTest) ? true : (a.ItemType == SelectTest))
                                select a).ToList();
             //默认显示的第一页
+            conditionConfig = conditionConfig.OrderBy(x => x.SchemeId).ToList();
             Getpage();
             //BaseConfigList = new ObservableCollection<BasicPlcTestSchemeDto>(conditionConfig);
         }
@@ -295,6 +296,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                     conditionConfig.Add(basicPlcTestSchemeDto);
                    
                 }
+                conditionConfig=conditionConfig.OrderBy(x => x.SchemeId).ToList();
                 //默认显示的第一页
                 Getpage();
             }

+ 2 - 0
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/PLCConfigViewModel.cs

@@ -120,6 +120,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                                && (string.IsNullOrEmpty(PLCAddr) ? true : (a.PlcAddress == PLCAddr))
                                select a).ToList();
             //默认显示的第一页
+            conditionConfig = conditionConfig.OrderBy(x => x.Id).ToList();
             Getpage();
         }
 
@@ -213,6 +214,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                     allPLCConfigList.Add(plc);
                     conditionConfig.Add(plc);
             }
+            conditionConfig = conditionConfig.OrderBy(x => x.Id).ToList();
             Getpage();
         }
         /// <summary>

+ 2 - 0
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/QueryViewModel.cs

@@ -318,6 +318,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                                     && (string.IsNullOrEmpty(SelectTest) ? true : (a.ItemType == SelectTest))
                                select a).ToList();
             //默认显示的第一页
+            conditionConfig = conditionConfig.OrderBy(x => x.SchemeId).ToList();
             Getpage();
             //BaseConfigList = new ObservableCollection<BasicPlcTestSchemeDto>(conditionConfig);
         }
@@ -460,6 +461,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                    
 
                 }
+                conditionConfig = conditionConfig.OrderBy(x => x.SchemeId).ToList();
                 //默认显示的第一页
                 Getpage();
             }

+ 2 - 0
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/TestOperViewModel.cs

@@ -140,6 +140,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                                     && (string.IsNullOrEmpty(SelectTest) ? true : (a.ItemType == SelectTest))
                                select a).ToList();
             //默认显示的第一页
+            conditionConfig = conditionConfig.OrderBy(x => x.SchemeId).ToList();
             Getpage();
             //BaseConfigList = new ObservableCollection<BasicPlcTestSchemeDto>(conditionConfig);
         }
@@ -289,6 +290,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                     conditionConfig.Add(basicPlcTestSchemeDto);
 
                 }
+                conditionConfig = conditionConfig.OrderBy(x => x.SchemeId).ToList();
                 //默认显示的第一页
                 Getpage();
             }

+ 1 - 0
BlankApp1/BlankApp1/ViewModels/MonitorManageViewModel/PLCReadViewModel.cs

@@ -57,6 +57,7 @@ namespace PLCTool.ViewModels.MonitorManageViewModel
                 }
                 
             }
+            PLCItemList = new AsyncObservableCollection<BasPlcItemConfigDto>(PLCItemList.OrderBy(x => x.Id));
         }
         private void ReadPLCRealValue()
         {

+ 19 - 2
BlankApp1/BlankApp1/ViewModels/MonitorManageViewModel/PLCWriteViewModel.cs

@@ -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));
         }
 
     

+ 1 - 0
BlankApp1/BlankApp1/ViewModels/StatisticsViewModel.cs

@@ -130,6 +130,7 @@ namespace BlankApp1.ViewModels
                     //统计所有测试项个数
                     allSchCount++;
                 }
+                conditionConfig = conditionConfig.OrderBy(x => x.SchemeId).ToList();
                 //默认显示的第一页
                 Getpage();
             }

+ 1 - 1
BlankApp1/BlankApp1/Views/MonitorManageView/PLCWriteView.xaml

@@ -26,7 +26,7 @@
                     <DataGridTemplateColumn.CellTemplate>
                         <DataTemplate>
                             <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
-                                <TextBox  Width="60" Text="{Binding PlcValue, Mode=OneWayToSource, UpdateSourceTrigger=LostFocus}"  HorizontalContentAlignment ="Left" Foreground="Black" Height="20" 
+                                <TextBox  Width="60" Text="{Binding PlcValue, Mode=OneWayToSource, UpdateSourceTrigger=LostFocus}"  HorizontalContentAlignment ="Left" Foreground="Black" Height="15" 
                                         Cursor="Hand" Margin="0,0,2,0" >
                                 </TextBox>
                                 <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"