소스 검색

修改查询

ltwork 1 년 전
부모
커밋
a42959266c

+ 11 - 7
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/BaseConfigViewModel.cs

@@ -72,8 +72,14 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
 
         private void OnLoad()
         {
-            DeviceKindNameList = _iBasicDeviceKindService.FindAllDeviceKind();
            
+            DeviceKindNameList.Clear();
+            DeviceKindNameList.Add("---");
+            var kinds = _iBasicDeviceKindService.FindAllDeviceKind();
+            foreach (var kind in kinds)
+            {
+                DeviceKindNameList.Add(kind);
+            }
         }
 
         /// <summary>
@@ -87,7 +93,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         private void Reset(object obj)
         {
             ScheduleName = string.Empty;
-            DeviceKindName = string.Empty;
+            DeviceKindName = "---";
             TestName = string.Empty;
             SelectTest = string.Empty;
             StartTime = DateTime.MinValue;
@@ -114,9 +120,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             conditionConfig = (from a in allConfigList
                                       where (EndTime == DateTime.MinValue ? true : (a.CreateTime < Convert.ToDateTime(EndTime)) && (Convert.ToDateTime(StartTime) < a.CreateTime))
                                        && (string.IsNullOrEmpty(ScheduleName) ? true : (a.SchemeName == ScheduleName))
-                            
-                                         && (string.IsNullOrEmpty(DeviceKindName) ? true : (a.DeviceKindName == DeviceKindName))
-                                       
+                                         && (DeviceKindName == "---") ? true : (a.DeviceKindName == DeviceKindName)
                                select a).ToList();
             //默认显示的第一页
             conditionConfig = conditionConfig.OrderBy(x => x.SchemeName).ThenBy(x => x.SchemeId).ToList();
@@ -364,8 +368,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <summary>
         /// 设备类型
         /// </summary>
-        private List<string> deviceKindNameList;
-        public List<string> DeviceKindNameList
+        private ObservableCollection<string> deviceKindNameList = new ObservableCollection<string>();
+        public ObservableCollection<string> DeviceKindNameList
         {
             get { return deviceKindNameList; }
             set { deviceKindNameList = value; RaisePropertyChanged(); }

+ 13 - 7
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/DeviceKindViewModel.cs

@@ -52,14 +52,20 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         #region 私有方法
         private void OnLoad()
         {
-            DeviceKindNameList = _iBasicDeviceKindService.FindAllDeviceKind();
-
+            DeviceKindNameList.Clear();
+            DeviceKindNameList.Add("---");
+            var kinds = _iBasicDeviceKindService.FindAllDeviceKind();
+            foreach(var kind in kinds)
+            {
+                DeviceKindNameList.Add(kind);
+            }
+           // DeviceKindNameList= _iBasicDeviceKindService.FindAllDeviceKind();
         }
         private void Reset(object obj)
         {
             DeviceKindNo = string.Empty;
-            DeviceKindName = string.Empty;
-    
+            DeviceKindName = "---";
+            
 
         }
         /// <summary>
@@ -138,7 +144,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         private void Query(object obj)
         {
             conditionDeviceKind = (from a in allDeviceKindList
-                                where (string.IsNullOrEmpty(DeviceKindName) ? true : (a.DeviceKindName == DeviceKindName))
+                                where ((DeviceKindName== "---") ? true : (a.DeviceKindName == DeviceKindName))
                                 && (string.IsNullOrEmpty(DeviceKindNo) ? true : (a.DeviceKindNo == DeviceKindNo))
                         
                                 select a).ToList();
@@ -319,8 +325,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <summary>
         /// 设备类型
         /// </summary>
-        private List<string> deviceKindNameList;
-        public List<string> DeviceKindNameList
+        private ObservableCollection<string> deviceKindNameList=new ObservableCollection<string>();
+        public ObservableCollection<string> DeviceKindNameList
         {
             get { return deviceKindNameList; }
             set { deviceKindNameList = value; RaisePropertyChanged(); }

+ 22 - 8
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/DeviceViewModel.cs

@@ -58,14 +58,27 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         #region 私有方法
         private void OnLoad()
         {
-            DeviceKindNameList = _iBasicDeviceKindService.FindAllDeviceKind();
-            ProjectNameList = _iBasicProjectService.FindAllProject();
+            DeviceKindNameList.Clear();
+            DeviceKindNameList.Add("---");
+            ProjectNameList.Clear();
+            ProjectNameList.Add("---");
+            var Kinds = _iBasicDeviceKindService.FindAllDeviceKind();
+            foreach(var kind in Kinds)
+            {
+                DeviceKindNameList.Add(kind);
+            }
+            var projects= _iBasicProjectService.FindAllProject();
+            foreach(var project in projects)
+            {
+                ProjectNameList.Add(project);
+            }
         }
         private void Reset(object obj)
         {
             DeviceNo = string.Empty;
             DeviceName = string.Empty;
-
+            DeviceKindName = "---";
+            ProjectName = "---";
 
         }
         /// <summary>
@@ -146,7 +159,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             conditionDevices = (from a in allDeviceList
                                    where (string.IsNullOrEmpty(DeviceName) ? true : (a.DeviceName == DeviceName))
                                    && (string.IsNullOrEmpty(DeviceNo) ? true : (a.DeviceNo == DeviceNo))
-                               
+                                   && (DeviceKindName == "---") ? true : (a.DeviceKindName == DeviceKindName)
+                                   &&(ProjectName == "---") ? true : (a.ProjectName == ProjectName)
                                 select a).ToList();
             //默认显示的第一页
             conditionDevices = conditionDevices.OrderBy(x => x.DeviceId).ToList();
@@ -343,8 +357,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <summary>
         /// 项目名称
         /// </summary>
-        private List<string> projectNameList;
-        public List<string> ProjectNameList
+        private ObservableCollection<string> projectNameList=new ObservableCollection<string>();
+        public ObservableCollection<string> ProjectNameList
         {
             get { return projectNameList; }
             set { projectNameList = value; RaisePropertyChanged(); }
@@ -352,8 +366,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <summary>
         /// 设备类型
         /// </summary>
-        private List<string> deviceKindNameList;
-        public List<string> DeviceKindNameList
+        private ObservableCollection<string> deviceKindNameList=new ObservableCollection<string>();
+        public ObservableCollection<string> DeviceKindNameList
         {
             get { return deviceKindNameList; }
             set { deviceKindNameList = value; RaisePropertyChanged(); }

+ 1 - 1
BlankApp1/BlankApp1/Views/BasicConfigView/DeviceKindView.xaml

@@ -23,7 +23,7 @@
             <RowDefinition Height="40"/>
 
         </Grid.RowDefinitions>
-        <UniformGrid Grid.Row="0" Columns="2">
+        <UniformGrid Grid.Row="0" Columns="3">
             <StackPanel Orientation="Horizontal">
                 <TextBlock Text="设备类型编号:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
                 <TextBox  Height="28" Width="120" Text="{Binding DeviceKindNo}" />