Browse Source

修改设备方案

ltwork 1 năm trước cách đây
mục cha
commit
5eb000e252

+ 2 - 0
BlankApp1/BlankApp1/App.xaml.cs

@@ -75,6 +75,8 @@ namespace BlankApp1
             containerRegistry.RegisterDialog<WritePLCView, WritePLCViewModel>();
             containerRegistry.RegisterDialog<CopySchView, CopySchViewModel>();
             containerRegistry.RegisterDialog<AddOrEditProjectView, AddOrEditProjectViewModel>();
+            containerRegistry.RegisterDialog<AddOrEditDeviceKindView, AddOrEditDeviceKindViewModel>();
+            
         }
 
         private IMapper GetMapper(IContainerProvider container)

+ 161 - 0
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/AddOrEditDeviceKindViewModel.cs

@@ -0,0 +1,161 @@
+using AutoMapper;
+using BizService;
+using Model.Dto;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace PLCTool.ViewModels.BasicConfigViewModel
+{
+    
+    public class AddOrEditDeviceKindViewModel : BindableBase, IDialogAware
+    {
+        private readonly IEventAggregator _aggregator;
+        private readonly IBasicDeviceKindService _iBasicDeviceKindService;
+
+        private readonly IMapper _mapper;
+        private List<BasPlcItemConfigDto> plcConfigs = new List<BasPlcItemConfigDto>();
+        private long id = 0;
+        public AddOrEditDeviceKindViewModel(IEventAggregator aggregator, IBasicDeviceKindService iBasicDeviceKindService, IMapper mapper)
+        {
+            _aggregator = aggregator;
+            _iBasicDeviceKindService = iBasicDeviceKindService;
+            _mapper = mapper;
+            CloseCommand = new DelegateCommand(Close);
+            SureCommand = new DelegateCommand<string>(Sure);
+            CancelCommand = new DelegateCommand(Close);
+
+        }
+
+
+
+
+
+
+        #region idialog接口实现
+        public string Title { set; get; } = "新增设备类型";
+
+        public event Action<IDialogResult> RequestClose;
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+            var getMsg = parameters.GetValues<BasDeviceKindDto>("Key");
+            ///值不为空,表示修改
+            if (getMsg != null)
+            {
+                foreach (var item in getMsg)
+                {
+                    if (item != null)
+                    {
+                        Title = "修改设备类型";
+
+                        DeviceKindName = item.DeviceKindName;
+                        DeviceKindNo = item.DeviceKindNo;
+                
+                        Remark = item.Remark;
+
+                    }
+
+                }
+
+            }
+        }
+
+        #endregion
+        #region 私有方法
+
+
+        private void Close()
+        {
+            RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+        }
+        /// <summary>
+        /// 确认
+        /// </summary>
+        /// <param name="obj"></param>
+        private void Sure(string obj)
+        {
+            if (string.IsNullOrEmpty(DeviceKindName))
+            {
+                MessageBox.Show("请填写设备类型!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                return;
+            }
+            if (string.IsNullOrEmpty(DeviceKindNo))
+            {
+                MessageBox.Show("请填写设备类型编号!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                return;
+            }
+        
+            BasDeviceKindDto basDeviceKind = new BasDeviceKindDto();
+            basDeviceKind.DeviceKindName = DeviceKindName;
+            basDeviceKind.DeviceKindNo = DeviceKindNo;
+            basDeviceKind.Remark = Remark;
+            DialogParameters parm = new DialogParameters();
+            parm.Add("ReturnValue", basDeviceKind);
+            RequestClose?.Invoke(new DialogResult(ButtonResult.OK, parm));
+        }
+        /// <summary>
+        /// 重置
+        /// </summary>
+        /// <param name="obj"></param>
+        private void ResetMethod(string obj)
+        {
+
+        }
+
+        #endregion
+
+
+
+        #region 命令绑定
+        public DelegateCommand CloseCommand { set; get; }
+        public DelegateCommand<string> SureCommand { set; get; }
+        public DelegateCommand CancelCommand { set; get; }
+        public DelegateCommand TxtLostFocusCommand { set; get; }
+        public DelegateCommand TxtPLCValueLostFocusCommand { set; get; }
+
+
+        #endregion
+        #region 变量绑定
+        private string deviceKindName;
+        public string DeviceKindName
+        {
+            get { return deviceKindName; }
+            set { deviceKindName = value; RaisePropertyChanged(); }
+        }
+
+        private string deviceKindNo;
+        public string DeviceKindNo
+        {
+            get { return deviceKindNo; }
+            set { deviceKindNo = value; RaisePropertyChanged(); }
+        }
+     
+
+        private string remark;
+        public string Remark
+        {
+            get { return remark; }
+            set { remark = value; RaisePropertyChanged(); }
+        }
+
+        #endregion
+    }
+}

+ 334 - 2
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/DeviceKindViewModel.cs

@@ -1,12 +1,344 @@
-using System;
+using AutoMapper;
+using BizService;
+using Microsoft.Extensions.Logging;
+using MiniExcelLibs;
+using Model.Dto;
+using Model.Entities;
+using PLCTool.Common;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows;
 
 namespace PLCTool.ViewModels.BasicConfigViewModel
 {
-    class DeviceKindViewModel
+  
+
+    public class DeviceKindViewModel : BindableBase
     {
+        private readonly IBasicDeviceKindService _iBasicDeviceKindService;
+        private readonly IMapper _mapper;
+        private readonly IDialogService _dialog;
+        private readonly ILogger _logger;
+        private List<BasDeviceKindDto> allDeviceKindList = new List<BasDeviceKindDto>();//所有方案
+        private List<BasDeviceKindDto> conditionDeviceKind = new List<BasDeviceKindDto>();//符合条件的方案
+        public DeviceKindViewModel(IBasicDeviceKindService iBasicDeviceKindService, IMapper mapper, IDialogService dialog, ILogger logger)
+        {
+            _iBasicDeviceKindService = iBasicDeviceKindService;
+            _mapper = mapper;
+            _dialog = dialog;
+            _logger = logger;
+            QueryCommand = new DelegateCommand<object>(Query);
+            AddCommand = new DelegateCommand<object>(Add);
+            ExportCommand = new DelegateCommand<string>(Export);
+            EditCommand = new DelegateCommand<object>(Edit);
+            DeleteCommand = new DelegateCommand<object>(Delete);
+            ResetCommand = new DelegateCommand<object>(Reset);
+            GetPprojectConfig();
+        }
+
+
+
+
+
+
+        #region 私有方法
+
+        private void Reset(object obj)
+        {
+            DeviceKindNo = string.Empty;
+            DeviceKindName = string.Empty;
+    
+
+        }
+        /// <summary>
+        /// 修改
+        /// </summary>
+        /// <param name="obj"></param>
+        private void Edit(object obj)
+        {
+            int id = Convert.ToInt32(obj);
+            var finrProject = allDeviceKindList.FirstOrDefault(x => (x.DeviceKindId == id));
+            DialogParameters parm = new DialogParameters();
+            parm.Add("Key", finrProject);
+            //弹出详情对话框
+            _dialog.ShowDialog("AddOrEditDeviceKindView", parm, async callback =>
+            {
+                if (callback.Result == ButtonResult.OK)
+                {
+                    BasDeviceKindDto returnValue = callback.Parameters.GetValue<BasDeviceKindDto>("ReturnValue");
+
+                    if (returnValue != null)
+                    {
+                        //更新时间
+                        returnValue.UpdateTime = DateTime.Now;
+                        returnValue.UpdateBy = Appsession.UserName;
+                        //创建时间
+                        returnValue.CreateTime = finrProject.CreateTime;
+                        returnValue.CreateBy = finrProject?.CreateBy;
+
+                        var deviceKindCon = _mapper.Map<BasDeviceKindDto, bas_device_kind>(returnValue);
+                        var findPlcs = allDeviceKindList.FindAll(x => (x.DeviceKindName == returnValue.DeviceKindName) || (x.DeviceKindNo == returnValue.DeviceKindNo));
+                        foreach (var item in findPlcs)
+                        {
+                            if (item.DeviceKindId != id)
+                            {
+                                MessageBox.Show("已有此设备类型或编号,请更改名称!", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
+                                return;
+                            }
+                        }
+
+                        //修改
+                        deviceKindCon.devicekind_id = id;
+                        bool isSucc = _iBasicDeviceKindService.Edit(deviceKindCon);
+                        if (isSucc)
+                        {
+                            //重新读取PLC
+                            GetPprojectConfig();
+                            _logger.LogInformation($"修改项目成功");
+                            MessageBox.Show("修改项目成功", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
+                        }
+                    }
+                }
+
+            });
+        }
+
+        private void Delete(object obj)
+        {
+            int id = Convert.ToInt32(obj);
+            MessageBoxResult boxResult = MessageBox.Show("确认删除此条数据?", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+            if (boxResult == MessageBoxResult.OK)
+            {
+                var del = _iBasicDeviceKindService.Delete(id);
+                if (del)
+                {
+                    MessageBox.Show("删除成功!", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
+                    GetPprojectConfig();
+                }
+
+            }
+        }
+
+        /// <summary>
+        /// 查询
+        /// </summary>
+        /// <param name="obj"></param>
+        private void Query(object obj)
+        {
+            conditionDeviceKind = (from a in allDeviceKindList
+                                where (string.IsNullOrEmpty(DeviceKindName) ? true : (a.DeviceKindName == DeviceKindName))
+                                && (string.IsNullOrEmpty(DeviceKindNo) ? true : (a.DeviceKindNo == DeviceKindNo))
+                        
+                                select a).ToList();
+            //默认显示的第一页
+            conditionDeviceKind = conditionDeviceKind.OrderBy(x => x.DeviceKindId).ToList();
+            Getpage();
+        }
+
+        private void Export(string obj)
+        {
+            using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog()
+            {
+                //设置文件类型
+                //书写规则例如:txt files(*.txt)|*.txt
+                Filter = "Excel files(*.xlsx)|*.xlsx|All files(*.*)|*.*",
+                //设置默认文件名(可以不设置)
+                FileName = "项目配置表",
+
+                //获取或设置一个值,该值指示如果用户省略扩展名,文件对话框是否自动在文件名中添加扩展名。(可以不设置)
+                AddExtension = true,
+
+                //保存对话框是否记忆上次打开的目录
+                RestoreDirectory = true
+            })
+            {
+                // Show save file dialog box
+
+                //点了保存按钮进入
+                if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+                {
+                    try
+                    {
+                        //获得文件路径
+                        string localFilePath = saveFileDialog.FileName.ToString();
+
+                        //获取文件内容
+                        MiniExcel.SaveAs(localFilePath, DeviceKindItemList);
+                    }
+                    catch (Exception ex)
+                    {
+                        _logger.LogError(ex.ToString());
+                    }
+
+
+                }
+
+            }
+        }
+        /// <summary>
+        /// 添加PLC变量
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <exception cref="NotImplementedException"></exception>
+        private void Add(object obj)
+        {
+
+            //弹出详情对话框
+            _dialog.ShowDialog("AddOrEditDeviceKindView", async callback =>
+            {
+                if (callback.Result == ButtonResult.OK)
+                {
+                    BasDeviceKindDto returnValue = callback.Parameters.GetValue<BasDeviceKindDto>("ReturnValue");
+                    if (returnValue != null)
+                    {
+                        returnValue.CreateTime = DateTime.Now;
+                        returnValue.CreateBy = Appsession.UserName;
+                        returnValue.UpdateTime = DateTime.Now;
+                        returnValue.UpdateBy = Appsession.UserName;
+                        var deviceKindCon = _mapper.Map<BasDeviceKindDto, bas_device_kind>(returnValue);
+                        var findPlc = allDeviceKindList.FirstOrDefault(x => (x.DeviceKindName == returnValue.DeviceKindName) || (x.DeviceKindNo == returnValue.DeviceKindNo));
+                        if (findPlc != null)
+                        {
+                            MessageBox.Show("已有此项目名称或编号,请更改!", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
+                            return;
+                        }
+                        bool isSucc = _iBasicDeviceKindService.Add(deviceKindCon);
+                        if (isSucc)
+                        {
+                            //重新读取PLC
+                            GetPprojectConfig();
+                            _logger.LogInformation($"添加项目成功");
+                            MessageBox.Show("添加项目成功!", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
+                        }
+                    }
+                }
+
+            });
+        }
+        /// <summary>
+        /// 获取所有项目
+        /// </summary>
+        private void GetPprojectConfig()
+        {
+            allDeviceKindList.Clear();
+            conditionDeviceKind.Clear();
+            var projectlist = _iBasicDeviceKindService.QueryList();
+            var allDeviceKinds = _mapper.Map<List<bas_device_kind>, List<BasDeviceKindDto>>(projectlist);
+            foreach (var plc in allDeviceKinds)
+            {
+                allDeviceKindList.Add(plc);
+                conditionDeviceKind.Add(plc);
+            }
+            conditionDeviceKind = conditionDeviceKind.OrderBy(x => x.DeviceKindId).ToList();
+            Getpage();
+        }
+        /// <summary>
+        /// 获取页面
+        /// </summary>
+        private void Getpage()
+        {
+            CurrentPage = 1;
+            TotalCount = conditionDeviceKind.Count;
+            CurrentPageChanged();
+
+
+        }
+        /// <summary>
+        /// 页面变化
+        /// </summary>
+        private void CurrentPageChanged()
+        {
+
+            DeviceKindItemList.Clear();
+
+            foreach (var i in conditionDeviceKind.Skip((CurrentPage - 1) * CountPerPage).Take(CountPerPage))
+            {
+                DeviceKindItemList.Add(i);
+            }
+        }
+
+        #endregion
+        #region 命令绑定
+
+        public DelegateCommand<object> QueryCommand { set; get; }
+        public DelegateCommand<object> AddCommand { set; get; }
+        public DelegateCommand<string> ExportCommand { set; get; }
+
+        /// <summary>
+        /// 表格删除
+        /// </summary>
+        public DelegateCommand<Object> DeleteCommand { set; get; }
+        /// <summary>
+        /// 表格编辑按钮
+        /// </summary>
+        public DelegateCommand<Object> EditCommand { set; get; }
+        public DelegateCommand<object> ResetCommand { set; get; }
+        #endregion
+
+        #region 数据绑定
+        private ObservableCollection<BasDeviceKindDto> deviceKindItemList = new ObservableCollection<BasDeviceKindDto>();
+        public ObservableCollection<BasDeviceKindDto> DeviceKindItemList
+        {
+            get { return deviceKindItemList; }
+            set { deviceKindItemList = value; RaisePropertyChanged(); }
+        }
+
+        /// <summary>
+        /// 设备类型编号
+        /// </summary>
+        private string deviceKindNo;
+        public string DeviceKindNo
+        {
+            get { return deviceKindNo; }
+            set { deviceKindNo = value; RaisePropertyChanged(); }
+        }
+
+        /// <summary>
+        /// 设备类型名称
+        /// </summary>
+        private string deviceKindName;
+        public string DeviceKindName
+        {
+            get { return deviceKindName; }
+            set { deviceKindName = value; RaisePropertyChanged(); }
+        }
+
+ 
+        /// <summary>
+        /// 总条数
+        /// </summary>
+        private int totalCount;
+        public int TotalCount
+        {
+            get { return totalCount; }
+            set { totalCount = value; RaisePropertyChanged(); CurrentPageChanged(); }
+        }
+        /// <summary>
+        /// 每页数量
+        /// </summary>
+        private int countPerPage = 15;
+        public int CountPerPage
+        {
+            get { return countPerPage; }
+            set { countPerPage = value; RaisePropertyChanged(); CurrentPageChanged(); }
+        }
+        /// <summary>
+        /// 单前页
+        /// </summary>
+        private int currentPage = 1;
+        public int CurrentPage
+        {
+            get { return currentPage; }
+            set { currentPage = value; RaisePropertyChanged(); CurrentPageChanged(); }
+        }
+
+        #endregion
     }
 }

+ 1 - 1
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/ProjectViewModel.cs

@@ -18,7 +18,7 @@ using System.Windows;
 
 namespace PLCTool.ViewModels.BasicConfigViewModel
 {
-    class ProjectViewModel : BindableBase
+    public class ProjectViewModel : BindableBase
     {
         private readonly IBasicProjectService _iBasicProjectService;
         private readonly IMapper _mapper;

+ 54 - 0
BlankApp1/BlankApp1/Views/BasicConfigView/AddOrEditDeviceKindView.xaml

@@ -0,0 +1,54 @@
+<UserControl x:Class="PLCTool.Views.BasicConfigView.AddOrEditDeviceKindView"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:PLCTool.Views.BasicConfigView"
+                          xmlns:prism="http://prismlibrary.com/"
+             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
+             Height="300" Width="400" BorderBrush="#CBCBCB" BorderThickness="1">
+    <!--<prism:Dialog.WindowStyle>
+        <Style TargetType="Window">
+            <Setter Property="SizeToContent" Value="WidthAndHeight" />
+            <Setter Property="ResizeMode" Value="NoResize" />
+            <Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterScreen" />
+            <Setter Property="WindowStyle" Value="None" />
+        </Style>
+    </prism:Dialog.WindowStyle>-->
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="20"/>
+            <RowDefinition />
+            <RowDefinition />
+            <RowDefinition />
+            <RowDefinition />
+
+        </Grid.RowDefinitions>
+
+        <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Center">
+            <TextBlock Text="设备类型:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0" TextAlignment="Right" Width="80"/>
+            <TextBox  Height="28" Width="120" Text="{Binding DeviceKindName}" >
+
+
+            </TextBox>
+        </StackPanel>
+        <StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Center">
+            <TextBlock Text="设备类型编号:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0" TextAlignment="Right" Width="80"/>
+            <!--<ComboBox  Height="28" Width="120" ItemsSource="{Binding PLCVars}" SelectedItem="{Binding SelectPLCVar}" />-->
+            <TextBox  Height="28" Width="120" Text="{Binding DeviceKindNo}" />
+        </StackPanel>
+       
+
+        <StackPanel Orientation="Horizontal" Grid.Row="3" HorizontalAlignment="Center">
+            <TextBlock Text="描述:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0" TextAlignment="Right" Width="80" />
+            <TextBox  Height="28" Width="220" Text="{Binding Remark}" />
+        </StackPanel>
+        <StackPanel Orientation="Horizontal" Grid.Row="4" HorizontalAlignment="Center">
+
+            <Button  Content="取消" Width="80"  Margin="5,0"  Command="{Binding CancelCommand}" Opacity="0.7" Style="{StaticResource NormalButtonStyle}" />
+            <Button  Content="确认" Width="80"  Margin="5,0"  Command="{Binding SureCommand}" Style="{StaticResource NormalButtonStyle}" />
+        </StackPanel>
+
+
+    </Grid>
+</UserControl>

+ 28 - 0
BlankApp1/BlankApp1/Views/BasicConfigView/AddOrEditDeviceKindView.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PLCTool.Views.BasicConfigView
+{
+    /// <summary>
+    /// AddOrEditDeviceKindView.xaml 的交互逻辑
+    /// </summary>
+    public partial class AddOrEditDeviceKindView : UserControl
+    {
+        public AddOrEditDeviceKindView()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 3 - 3
BlankApp1/BlankApp1/Views/BasicConfigView/AddOrEditProjectView.xaml

@@ -4,8 +4,8 @@
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:PLCTool.Views.BasicConfigView"
-                     xmlns:prism="http://prismlibrary.com/"
-               xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
+             xmlns:prism="http://prismlibrary.com/"
+             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
              Height="300" Width="400" BorderBrush="#CBCBCB" BorderThickness="1">
     <!--<prism:Dialog.WindowStyle>
         <Style TargetType="Window">
@@ -23,7 +23,7 @@
             <RowDefinition />
             <RowDefinition />
             <RowDefinition />
-            <RowDefinition />
+            
         </Grid.RowDefinitions>
 
         <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Center">

+ 13 - 25
BlankApp1/BlankApp1/Views/BasicConfigView/DeviceKindView.xaml

@@ -20,19 +20,13 @@
         <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 ScheduleName}" />
+                <TextBox  Height="28" Width="120" Text="{Binding DeviceKindNo}" />
             </StackPanel>
             <StackPanel Orientation="Horizontal">
                 <TextBlock Text="设备类型名称:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
-                <TextBox  Height="28" Width="120" Text="{Binding DeviceName}"/>
+                <TextBox  Height="28" Width="120" Text="{Binding DeviceKindName}"/>
             </StackPanel>
-            <StackPanel Orientation="Horizontal" >
-                <TextBlock Text="创建人:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
-                <TextBox  Height="28" Width="120" Text="{Binding DeviceName}"/>
-            </StackPanel>
-
-
-
+   
         </UniformGrid>
         <Grid Grid.Row="1">
             <Grid.ColumnDefinitions>
@@ -53,46 +47,40 @@
 
                 <Button  Content="查询" Width="80"  Margin="5,0"  Command="{Binding QueryCommand}" Style="{StaticResource NormalButtonStyle}" />
                 <Button  Content="重置" Width="80"  Margin="5,0"  Command="{Binding ResetCommand}" Style="{StaticResource NormalButtonStyle}" />
-                <Button  Content="新增" Width="80"  Margin="5,0"  Command="{Binding AddPlanCommand}" Style="{StaticResource NormalButtonStyle}"/>
+                <Button  Content="新增" Width="80"  Margin="5,0"  Command="{Binding AddCommand}" Style="{StaticResource NormalButtonStyle}"/>
 
                 <Button Content="导出Excel" Width="80"  Margin="5,0"  Command="{Binding ExportCommand}" Style="{StaticResource NormalButtonStyle}" />
             </StackPanel>
         </Grid>
         <DataGrid  Grid.Row="2"  ColumnWidth="*" AutoGenerateColumns="False" HeadersVisibility="All" CanUserAddRows="False"  SelectionUnit="FullRow" SelectionMode="Single"   RowHeaderWidth="0"
                   ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}"  RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
-                 ItemsSource="{Binding BaseConfigList}" IsReadOnly="True" Padding="0"  >
+                 ItemsSource="{Binding DeviceKindItemList}" IsReadOnly="True" Padding="0"  >
             <DataGrid.Columns >
-                <DataGridTextColumn Header="序号" Width="50" Binding="{Binding SchemeId}" CellStyle="{StaticResource MyDataGridCellStyle}" />
-                <DataGridTextColumn Header="设备类型编号" Binding="{Binding SchemeName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="设备类型名称" Binding="{Binding DeviceName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="描述" Binding="{Binding ItemName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="创建者" Binding="{Binding CreateBy}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="序号" Width="50" Binding="{Binding DeviceKindId}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                <DataGridTextColumn Header="设备类型编号" Binding="{Binding DeviceKindNo}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="设备类型名称" Binding="{Binding DeviceKindName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="描述" Binding="{Binding Remark}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+
                 <DataGridTextColumn Header="创建时间" Binding="{Binding CreateTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                 <DataGridTemplateColumn Header="操作" Width="180" CellStyle="{StaticResource MyDataGridCellStyle}">
                     <DataGridTemplateColumn.CellTemplate>
                         <DataTemplate>
                             <StackPanel Orientation="Horizontal">
                                 <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-                                        Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding SchemeId}" Cursor="Hand" Margin="0,0,10,0" >
+                                        Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding DeviceKindId}" Cursor="Hand" Margin="0,0,10,0" >
 
                                     <StackPanel Orientation="Horizontal">
                                         <TextBlock  Text="编辑" VerticalAlignment="Center" Foreground="Blue"/>
                                     </StackPanel>
                                 </Button>
                                 <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-                                        Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding SchemeId}" Cursor="Hand" Margin="0,0,10,0">
+                                        Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding DeviceKindId}" Cursor="Hand" Margin="0,0,10,0">
 
                                     <StackPanel Orientation="Horizontal">
                                         <TextBlock  Text="删除" VerticalAlignment="Center" Foreground="Blue"/>
                                     </StackPanel>
                                 </Button>
-                                <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-       Command="{Binding DataContext.CopyCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding SchemeName}" Cursor="Hand" >
-
-                                    <StackPanel Orientation="Horizontal">
-                                        <TextBlock  Text="复制方案" VerticalAlignment="Center" Foreground="Blue"/>
-                                    </StackPanel>
-                                </Button>
+                               
                             </StackPanel>
                         </DataTemplate>
                     </DataGridTemplateColumn.CellTemplate>

+ 2 - 22
BlankApp1/Model/Dto/BasDeviceKindDto.cs

@@ -43,29 +43,9 @@ namespace Model.Dto
             get { return deviceKindName; }
             set { deviceKindName = value; OnPropertyChanged(); }
         }
-        /// <summary>
-        /// Desc:所属项目编号
-        /// Default:
-        /// Nullable:True
-        /// </summary>           
-        private string projectNo { get; set; }
-        public string ProjectNo
-        {
-            get { return projectNo; }
-            set { projectNo = value; OnPropertyChanged(); }
-        }
+  
       
-        /// <summary>
-        /// Desc:描述
-        /// Default:
-        /// Nullable:False
-        /// </summary>           
-        private string describe { get; set; }
-        public string Describe
-        {
-            get { return describe; }
-            set { describe = value; OnPropertyChanged(); }
-        }
+     
         /// <summary>
         /// Desc:创建者
         /// Default: