Pārlūkot izejas kodu

修改项目配置

ltwork 1 gadu atpakaļ
vecāks
revīzija
914836c0db

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

@@ -74,6 +74,7 @@ namespace BlankApp1
             containerRegistry.RegisterDialog<TestResultDetailView, TestResultDetailViewModel>();
             containerRegistry.RegisterDialog<WritePLCView, WritePLCViewModel>();
             containerRegistry.RegisterDialog<CopySchView, CopySchViewModel>();
+            containerRegistry.RegisterDialog<AddOrEditProjectView, AddOrEditProjectViewModel>();
         }
 
         private IMapper GetMapper(IContainerProvider container)

+ 34 - 0
BlankApp1/BlankApp1/Common/AutoMapper/AutoMapProfile.cs

@@ -87,6 +87,40 @@ namespace BlankApp1.Common.AutoMapper
                              .ForMember(dest => dest.UpdateBy, opt => opt.MapFrom(src => src.update_by))
                          .ForMember(dest => dest.Remark, opt => opt.MapFrom(src => src.remark)).ReverseMap();
 
+            CreateMap<bas_device, BasDeviceDto>()
+                 .ForMember(dest => dest.DeviceNo, opt => opt.MapFrom(src => src.device_no))
+               .ForMember(dest => dest.DeviceNo, opt => opt.MapFrom(src => src.device_no))
+                .ForMember(dest => dest.DeviceName, opt => opt.MapFrom(src => src.device_name))
+                 .ForMember(dest => dest.ProjectId, opt => opt.MapFrom(src => src.project_id))
+                  .ForMember(dest => dest.DeviceKindId, opt => opt.MapFrom(src => src.device_kind_id))
+                      .ForMember(dest => dest.CreateBy, opt => opt.MapFrom(src => src.create_by))
+                       .ForMember(dest => dest.CreateTime, opt => opt.MapFrom(src => src.create_time))
+                        .ForMember(dest => dest.UpdateTime, opt => opt.MapFrom(src => src.update_time))
+                              .ForMember(dest => dest.UpdateBy, opt => opt.MapFrom(src => src.update_by))
+                       .ForMember(dest => dest.Remark, opt => opt.MapFrom(src => src.remark)).ReverseMap();
+
+            CreateMap<bas_device_kind, BasDeviceKindDto>()
+                 .ForMember(dest => dest.DeviceKindId, opt => opt.MapFrom(src => src.devicekind_id))
+           .ForMember(dest => dest.DeviceKindNo, opt => opt.MapFrom(src => src.devicekind_no))
+            .ForMember(dest => dest.DeviceKindName, opt => opt.MapFrom(src => src.devicekind_name))
+              .ForMember(dest => dest.CreateBy, opt => opt.MapFrom(src => src.create_by))
+               .ForMember(dest => dest.CreateTime, opt => opt.MapFrom(src => src.create_time))
+                .ForMember(dest => dest.UpdateTime, opt => opt.MapFrom(src => src.update_time))
+                .ForMember(dest => dest.UpdateBy, opt => opt.MapFrom(src => src.update_by))
+                .ForMember(dest => dest.Remark, opt => opt.MapFrom(src => src.remark)).ReverseMap();
+
+
+            CreateMap<bas_project, BasProjectDto>()
+                 .ForMember(dest => dest.ProjectId, opt => opt.MapFrom(src => src.project_id))
+             .ForMember(dest => dest.ProjectNo, opt => opt.MapFrom(src => src.project_no))
+              .ForMember(dest => dest.ProjectName, opt => opt.MapFrom(src => src.project_name))
+                 .ForMember(dest => dest.ProjectLeader, opt => opt.MapFrom(src => src.project_leader))
+                .ForMember(dest => dest.CreateBy, opt => opt.MapFrom(src => src.create_by))
+                 .ForMember(dest => dest.CreateTime, opt => opt.MapFrom(src => src.create_time))
+                  .ForMember(dest => dest.UpdateTime, opt => opt.MapFrom(src => src.update_time))
+                  .ForMember(dest => dest.UpdateBy, opt => opt.MapFrom(src => src.update_by))
+                  .ForMember(dest => dest.Remark, opt => opt.MapFrom(src => src.remark)).ReverseMap();
+
         }
 
         private string ItemTypeToStr(int? type)

+ 174 - 0
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/AddOrEditProjectViewModel.cs

@@ -0,0 +1,174 @@
+using AutoMapper;
+using BizService;
+using Model.Dto;
+using Model.Entities;
+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.Text.RegularExpressions;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace PLCTool.ViewModels.BasicConfigViewModel
+{
+    public class AddOrEditProjectViewModel : BindableBase, IDialogAware
+    {
+        private readonly IEventAggregator _aggregator;
+        private readonly IBasicProjectService _iBasicProjectService;
+
+        private readonly IMapper _mapper;
+        private List<BasPlcItemConfigDto> plcConfigs = new List<BasPlcItemConfigDto>();
+        private long id = 0;
+        public AddOrEditProjectViewModel(IEventAggregator aggregator, IBasicProjectService iBasicProjectService, IMapper mapper)
+        {
+            _aggregator = aggregator;
+            _iBasicProjectService = iBasicProjectService;
+            _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<BasProjectDto>("Key");
+            ///值不为空,表示修改
+            if (getMsg != null)
+            {
+                foreach (var item in getMsg)
+                {
+                    if (item != null)
+                    {
+                        Title = "修改项目";
+
+                        ProjectName = item.ProjectName;
+                        ProjectNo = item.ProjectNo;
+                        ProjectLeader = item.ProjectLeader;
+                        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(ProjectName))
+            {
+                MessageBox.Show("请填写项目名称!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                return;
+            }
+            if (string.IsNullOrEmpty(ProjectNo))
+            {
+                MessageBox.Show("请填写项目编号!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                return;
+            }
+            if (string.IsNullOrEmpty(ProjectLeader))
+            {
+                MessageBox.Show("请选择项目负责人!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                return;
+            }
+
+            BasProjectDto basProject = new BasProjectDto();
+            basProject.ProjectName = ProjectName;
+            basProject.ProjectNo = ProjectNo;
+            basProject.ProjectLeader = ProjectLeader;
+            basProject.Remark = Remark;
+
+            DialogParameters parm = new DialogParameters();
+            parm.Add("ReturnValue", basProject);
+            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 projectName;
+        public string ProjectName
+        {
+            get { return projectName; }
+            set { projectName = value; RaisePropertyChanged(); }
+        }
+
+        private string projectNo;
+        public string ProjectNo
+        {
+            get { return projectNo; }
+            set { projectNo = value; RaisePropertyChanged(); }
+        }
+        private string projectLeader;
+        public string ProjectLeader
+        {
+            get { return projectLeader; }
+            set { projectLeader = value; RaisePropertyChanged(); }
+        }
+
+        private string remark;
+        public string Remark
+        {
+            get { return remark; }
+            set { remark = value; RaisePropertyChanged(); }
+        }
+
+        #endregion
+    }
+}

+ 7 - 6
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/PLCConfigViewModel.cs

@@ -40,6 +40,13 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             DeleteCommand = new DelegateCommand<object>(Delete);
             GetPLCConfig();
         }
+
+
+
+
+
+
+        #region 私有方法
         /// <summary>
         /// 修改
         /// </summary>
@@ -103,12 +110,6 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             }
         }
 
-
-
-
-
-
-        #region 私有方法
         /// <summary>
         /// 查询
         /// </summary>

+ 341 - 2
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/ProjectViewModel.cs

@@ -1,12 +1,351 @@
-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 ProjectViewModel
+    class ProjectViewModel : BindableBase
     {
+        private readonly IBasicProjectService _iBasicProjectService;
+        private readonly IMapper _mapper;
+        private readonly IDialogService _dialog;
+        private readonly ILogger _logger;
+        private List<BasProjectDto> allProjectList = new List<BasProjectDto>();//所有方案
+        private List<BasProjectDto> conditionProject = new List<BasProjectDto>();//符合条件的方案
+        public ProjectViewModel(IBasicProjectService iBasicProjectService, IMapper mapper, IDialogService dialog, ILogger logger)
+        {
+            _iBasicProjectService = iBasicProjectService;
+            _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)
+        {
+            ProjectName = string.Empty;
+            ProjectNo = string.Empty;
+            ProjectLeader = string.Empty;
+            
+        }
+        /// <summary>
+        /// 修改
+        /// </summary>
+        /// <param name="obj"></param>
+        private void Edit(object obj)
+        {
+            int id = Convert.ToInt32(obj);
+            var finrProject = allProjectList.FirstOrDefault(x => (x.ProjectId == id));
+            DialogParameters parm = new DialogParameters();
+            parm.Add("Key", finrProject);
+            //弹出详情对话框
+            _dialog.ShowDialog("AddOrEditProjectView", parm, async callback =>
+            {
+                if (callback.Result == ButtonResult.OK)
+                {
+                    BasProjectDto returnValue = callback.Parameters.GetValue<BasProjectDto>("ReturnValue");
+
+                    if (returnValue != null)
+                    {
+                        //更新时间
+                        returnValue.UpdateTime = DateTime.Now;
+                        returnValue.UpdateBy = Appsession.UserName;
+                        //创建时间
+                        returnValue.CreateTime = finrProject.CreateTime;
+                        returnValue.CreateBy = finrProject?.CreateBy;
+
+                        var projectCon = _mapper.Map<BasProjectDto, bas_project>(returnValue);
+                        var findPlcs = allProjectList.FindAll(x => (x.ProjectName == returnValue.ProjectName) || (x.ProjectNo == returnValue.ProjectNo));
+                        foreach (var item in findPlcs)
+                        {
+                            if (item.ProjectId != id)
+                            {
+                                MessageBox.Show("已有此项目名称或编号,请更改名称!", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
+                                return;
+                            }
+                        }
+
+                        //修改
+                        projectCon.project_id = id;
+                        bool isSucc = _iBasicProjectService.Edit(projectCon);
+                        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 = _iBasicProjectService.Delete(id);
+                if (del)
+                {
+                    MessageBox.Show("删除成功!", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
+                    GetPprojectConfig();
+                }
+
+            }
+        }
+
+        /// <summary>
+        /// 查询
+        /// </summary>
+        /// <param name="obj"></param>
+        private void Query(object obj)
+        {
+            conditionProject = (from a in allProjectList
+                               where (string.IsNullOrEmpty(ProjectNo) ? true : (a.ProjectNo == ProjectNo))
+                               && (string.IsNullOrEmpty(ProjectName) ? true : (a.ProjectName == ProjectName))
+                                 && (string.IsNullOrEmpty(ProjectLeader) ? true : (a.ProjectLeader == ProjectLeader))
+                                select a).ToList();
+            //默认显示的第一页
+            conditionProject = conditionProject.OrderBy(x => x.ProjectId).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, ProjectItemList);
+                    }
+                    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("AddOrEditProjectView", async callback =>
+            {
+                if (callback.Result == ButtonResult.OK)
+                {
+                    BasProjectDto returnValue = callback.Parameters.GetValue<BasProjectDto>("ReturnValue");
+                    if (returnValue != null)
+                    {
+                        returnValue.CreateTime = DateTime.Now;
+                        returnValue.CreateBy = Appsession.UserName;
+                        returnValue.UpdateTime = DateTime.Now;
+                        returnValue.UpdateBy = Appsession.UserName;
+                        var plcCon = _mapper.Map<BasProjectDto, bas_project>(returnValue);
+                        var findPlc = allProjectList.FirstOrDefault(x => (x.ProjectName == returnValue.ProjectName) || (x.ProjectNo == returnValue.ProjectNo));
+                        if (findPlc != null)
+                        {
+                            MessageBox.Show("已有此项目名称或编号,请更改!", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
+                            return;
+                        }
+                        bool isSucc = _iBasicProjectService.Add(plcCon);
+                        if (isSucc)
+                        {
+                            //重新读取PLC
+                            GetPprojectConfig();
+                            _logger.LogInformation($"添加项目成功");
+                            MessageBox.Show("添加项目成功!", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
+                        }
+                    }
+                }
+
+            });
+        }
+        /// <summary>
+        /// 获取所有项目
+        /// </summary>
+        private void GetPprojectConfig()
+        {
+            allProjectList.Clear();
+            conditionProject.Clear();
+            var projectlist = _iBasicProjectService.QueryList();
+            var allPlc = _mapper.Map<List<bas_project>, List<BasProjectDto>>(projectlist);
+            foreach (var plc in allPlc)
+            {
+                allProjectList.Add(plc);
+                conditionProject.Add(plc);
+            }
+            conditionProject = conditionProject.OrderBy(x => x.ProjectId).ToList();
+            Getpage();
+        }
+        /// <summary>
+        /// 获取页面
+        /// </summary>
+        private void Getpage()
+        {
+            CurrentPage = 1;
+            TotalCount = conditionProject.Count;
+            CurrentPageChanged();
+
+
+        }
+        /// <summary>
+        /// 页面变化
+        /// </summary>
+        private void CurrentPageChanged()
+        {
+
+            ProjectItemList.Clear();
+
+            foreach (var i in conditionProject.Skip((CurrentPage - 1) * CountPerPage).Take(CountPerPage))
+            {
+                ProjectItemList.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<BasProjectDto> projectItemList = new ObservableCollection<BasProjectDto>();
+        public ObservableCollection<BasProjectDto> ProjectItemList
+        {
+            get { return projectItemList; }
+            set { projectItemList = value; RaisePropertyChanged(); }
+        }
+
+        /// <summary>
+        /// 项目编号
+        /// </summary>
+        private string projectNo;
+        public string ProjectNo
+        {
+            get { return projectNo; }
+            set { projectNo = value; RaisePropertyChanged(); }
+        }
+
+        /// <summary>
+        /// 项目名称
+        /// </summary>
+        private string projectName;
+        public string ProjectName
+        {
+            get { return projectName; }
+            set { projectName = value; RaisePropertyChanged(); }
+        }
+
+        /// <summary>
+        /// 项目名称
+        /// </summary>
+        private string projectLeader;
+        public string ProjectLeader
+        {
+            get { return projectLeader; }
+            set { projectLeader = 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
     }
 }
+

+ 58 - 0
BlankApp1/BlankApp1/Views/BasicConfigView/AddOrEditProjectView.xaml

@@ -0,0 +1,58 @@
+<UserControl x:Class="PLCTool.Views.BasicConfigView.AddOrEditProjectView"
+             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 />
+            <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 ProjectName}" >
+               
+
+            </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 ProjectNo}" />
+        </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="120" Text="{Binding ProjectLeader}" />
+        </StackPanel>
+     
+        <StackPanel Orientation="Horizontal" Grid.Row="4" 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="5" 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/AddOrEditProjectView.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>
+    /// AddOrEditProjectView.xaml 的交互逻辑
+    /// </summary>
+    public partial class AddOrEditProjectView : UserControl
+    {
+        public AddOrEditProjectView()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 13 - 19
BlankApp1/BlankApp1/Views/BasicConfigView/ProjectView.xaml

@@ -20,15 +20,15 @@
         <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 ProjectNo}" />
             </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 ProjectName}"/>
             </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 ProjectLeader}"/>
             </StackPanel>
          
 
@@ -53,20 +53,20 @@
 
                 <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 ProjectItemList}" 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 ItemType}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="描述" Binding="{Binding ItemName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="序号" Width="50" Binding="{Binding ProjectId}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                <DataGridTextColumn Header="项目编号" Binding="{Binding ProjectNo}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="项目名称" Binding="{Binding ProjectName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="负责人" Binding="{Binding ProjectLeader}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="描述" Binding="{Binding Remark}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                 <DataGridTextColumn Header="创建者" Binding="{Binding CreateBy}" 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}">
@@ -74,26 +74,20 @@
                         <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 ProjectId}" 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 ProjectId}" 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>

+ 26 - 13
BlankApp1/Model/Dto/BasDeviceDto.cs

@@ -7,11 +7,24 @@ using System.Threading.Tasks;
 namespace Model.Dto
 {
     public  class BasDeviceDto : BaseDto
-    {           /// <summary>
-                /// Desc:设备编号
-                /// Default:
-                /// Nullable:False
-                /// </summary>           
+    {
+        /// <summary>
+        /// Desc:设备主键ID
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+
+        private long deviceId { get; set; }
+        public long DeviceId
+        {
+            get { return deviceId; }
+            set { deviceId = value; OnPropertyChanged(); }
+        }
+        /// <summary>
+        /// Desc:设备编号
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
         private  string deviceNo { get; set; }
 
         public string DeviceNo
@@ -35,22 +48,22 @@ namespace Model.Dto
         /// Default:
         /// Nullable:True
         /// </summary>           
-        private string projectNo { get; set; }
-        public string ProjectNo
+        private string projectId { get; set; }
+        public string ProjectId
         {
-            get { return projectNo; }
-            set { projectNo = value; OnPropertyChanged(); }
+            get { return projectId; }
+            set { projectId = value; OnPropertyChanged(); }
         }
         /// <summary>
         /// Desc:所属设备类型编号
         /// Default:
         /// Nullable:False
         /// </summary>           
-        private string deviceKindNo { get; set; }
-        public string DeviceKindNo
+        private string deviceKindId { get; set; }
+        public string DeviceKindId
         {
-            get { return deviceKindNo; }
-            set { deviceKindNo = value; OnPropertyChanged(); }
+            get { return deviceKindId; }
+            set { deviceKindId = value; OnPropertyChanged(); }
         }
         /// <summary>
         /// Desc:描述

+ 19 - 6
BlankApp1/Model/Dto/BasDeviceKindDto.cs

@@ -6,12 +6,25 @@ using System.Threading.Tasks;
 
 namespace Model.Dto
 {
-    internal class BasDeviceKindDto : BaseDto
-    {  /// <summary>
-       /// Desc:设备类型编号
-       /// Default:
-       /// Nullable:False
-       /// </summary>           
+    public  class BasDeviceKindDto : BaseDto
+    {
+        /// <summary>
+        /// Desc:设备类型主键ID
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+
+        private long deviceKindId { get; set; }
+        public long DeviceKindId
+        {
+            get { return deviceKindId; }
+            set { deviceKindId = value; OnPropertyChanged(); }
+        }
+        // <summary>
+        /// Desc:设备类型编号
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
         private string deviceKindNo { get; set; }
 
         public string DeviceKindNo

+ 77 - 1
BlankApp1/Model/Dto/BasProjectDto.cs

@@ -6,7 +6,83 @@ using System.Threading.Tasks;
 
 namespace Model.Dto
 {
-    internal class BasProjectDto
+    public  class BasProjectDto:BaseDto
     {
+        private long projectId { get; set; }
+        public long ProjectId
+        {
+            get { return projectId; }
+            set { projectId = value; OnPropertyChanged(); }
+        }
+        /// <summary>
+        /// Desc:项目编号
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        private string projectNo { get; set; }
+
+        public string ProjectNo
+        {
+            get { return projectNo; }
+            set { projectNo = value; OnPropertyChanged(); }
+        }
+        /// <summary>
+        /// Desc:项目名称
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        private string projectName { get; set; }
+        public string ProjectName
+        {
+            get { return projectName; }
+            set { projectName = value; OnPropertyChanged(); }
+        }
+
+        /// <summary>
+        /// 项目负责人
+        /// </summary>
+        private string projectLeader { get; set; }
+        public string ProjectLeader
+        {
+            get { return projectLeader; }
+            set { projectLeader = value; OnPropertyChanged(); }
+        }
+        
+
+
+        /// <summary>
+        /// Desc:创建者
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        public string CreateBy { get; set; }
+
+        /// <summary>
+        /// Desc:创建时间
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        public DateTime CreateTime { get; set; }
+
+        /// <summary>
+        /// Desc:更新者
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        public string UpdateBy { get; set; }
+
+        /// <summary>
+        /// Desc:更新时间
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        public DateTime UpdateTime { get; set; }
+
+        /// <summary>
+        /// Desc:备注
+        /// Default:
+        /// Nullable:True
+        /// </summary>           
+        public string Remark { get; set; }
     }
 }

+ 3 - 3
BlankApp1/Model/Entities/bas_device.cs

@@ -21,7 +21,7 @@ namespace Model.Entities
            /// Nullable:False
            /// </summary>           
            [SugarColumn(IsPrimaryKey=true)]
-           public long id {get;set;}
+           public long device_id {get;set;}
 
            /// <summary>
            /// Desc:设备编号
@@ -42,14 +42,14 @@ namespace Model.Entities
            /// Default:
            /// Nullable:True
            /// </summary>           
-           public string project_no {get;set;}
+           public string project_id {get;set;}
 
            /// <summary>
            /// Desc:所属设备类型编号
            /// Default:
            /// Nullable:False
            /// </summary>           
-           public string device_kind_no {get;set;}
+           public string device_kind_id {get;set;}
 
            /// <summary>
            /// Desc:描述

+ 1 - 1
BlankApp1/Model/Entities/bas_device_kind.cs

@@ -21,7 +21,7 @@ namespace Model.Entities
            /// Nullable:False
            /// </summary>           
            [SugarColumn(IsPrimaryKey=true)]
-           public long id {get;set;}
+           public long devicekind_id {get;set;}
 
            /// <summary>
            /// Desc:设备类型编号

+ 3 - 3
BlankApp1/Model/Entities/bas_project.cs

@@ -21,21 +21,21 @@ namespace Model.Entities
            /// Nullable:False
            /// </summary>           
            [SugarColumn(IsPrimaryKey=true)]
-           public long id {get;set;}
+           public long project_id {get;set;}
 
            /// <summary>
            /// Desc:项目编号
            /// Default:
            /// Nullable:False
            /// </summary>           
-           public string projecy_no {get;set;}
+           public string project_no {get;set;}
 
            /// <summary>
            /// Desc:项目名称
            /// Default:
            /// Nullable:False
            /// </summary>           
-           public string projecy_name {get;set;}
+           public string project_name {get;set;}
 
            /// <summary>
            /// Desc:项目负责人