user_lt преди 1 година
родител
ревизия
4978071d53

+ 8 - 4
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/PLCConfigViewModel.cs

@@ -59,12 +59,16 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                     if (returnValue != null)
                     {
                         var plcCon = _mapper.Map<BasPlcItemConfigDto, bas_plc_item_config>(returnValue);
-                        var findPlc = allPLCConfigList.FirstOrDefault(x => (x.PlcAddress == returnValue.PlcAddress) || (x.PlcItem == returnValue.PlcAddress));
-                        if ((findPlc != null)&&(findPlc.Id!=id))
+                        var findPlcs = allPLCConfigList.FindAll(x => (x.PlcAddress == returnValue.PlcAddress) || (x.PlcItem == returnValue.PlcAddress));
+                        foreach(var item in  findPlcs)
                         {
-                            MessageBox.Show("已有此PLC变量地址或名称,请更改名称!", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
-                            return;
+                            if(item.Id != id)
+                            {
+                                MessageBox.Show("已有此PLC变量地址或名称,请更改名称!", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
+                                return;
+                            }
                         }
+                       
                         //修改
                         plcCon.id = id;
                         bool isSucc = _iBasPlcItemConfigService.Edit(plcCon);

+ 31 - 42
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/QueryViewModel.cs

@@ -20,6 +20,7 @@ using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Linq;
+using System.Reflection.Metadata;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
@@ -217,58 +218,46 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 var model = GetReportPLCInfo(id);
                 var document = new InvoiceDocument(model);
                 //pdf名称为轴编号+时间
-                string strDt = "报表" + string.Format("{0:yyyyMMddHHmm}", DateTime.Now)+ ".pdf"; ;
-                string pathToPDF = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "PDF", strDt);
-               
+
                 //输出文件
+                using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog()
+                {
+                    //设置文件类型
+                    //书写规则例如:txt files(*.txt)|*.txt
+                    Filter = "pdf文件|*.pdf",
+                    //设置默认文件名(可以不设置)
+                    FileName = "报表" + string.Format("{0:yyyyMMddHHmm}", DateTime.Now),
+
+                    //获取或设置一个值,该值指示如果用户省略扩展名,文件对话框是否自动在文件名中添加扩展名。(可以不设置)
+                    AddExtension = true,
+
+                    //保存对话框是否记忆上次打开的目录
+                    RestoreDirectory = true
+                })
+                {
+
 
-                document.GeneratePdf(pathToPDF);
-                MessageBox.Show("生成PDF报告成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                    //点了保存按钮进入
+                    if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+                    {
+                            //获得文件路径
+                            string localFilePath = saveFileDialog.FileName.ToString();
+                            document.GeneratePdf(localFilePath);
+
+                    }
+
+                }
+              
+               
             }
             catch(Exception ex)
             {
                 _logger.LogError(ex.ToString());
             }
-        
-
-
-            //using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog()
-            //{
-            //    //设置文件类型
-            //    //书写规则例如:txt files(*.txt)|*.txt
-            //    Filter = "pdf文|*.pdf",
-            //    //设置默认文件名(可以不设置)
-            //    FileName = "报表" + string.Format("{0:yyyyMMddHHmm}", DateTime.Now),
-
-            //    //获取或设置一个值,该值指示如果用户省略扩展名,文件对话框是否自动在文件名中添加扩展名。(可以不设置)
-            //    AddExtension = true,
-
-            //    //保存对话框是否记忆上次打开的目录
-            //    RestoreDirectory = true
-            //})
-            //{
-                
 
-            //    //点了保存按钮进入
-            //    if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
-            //    {
-            //        try
-            //        {
-            //            //获得文件路径
-            //            string localFilePath = saveFileDialog.FileName.ToString();
 
 
-            //            document.GeneratePdf(localFilePath);
-            //        }
-            //        catch (Exception ex)
-            //        {
-
-            //        }
-
-
-            //    }
-
-            //}
+          
 
         }