Przeglądaj źródła

检验报告录入增加导出文档功能;检验报告管理删除年度过滤条件,增加删除功能

LT069288 3 miesięcy temu
rodzic
commit
ecc5104e1c

+ 107 - 0
UniformMaterialManagementSystem/Utils/InspectionReportUtil.cs

@@ -0,0 +1,107 @@
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using UniformMaterialManagementSystem.Entities;
+using UniformMaterialManagementSystem.Models;
+
+namespace UniformMaterialManagementSystem.Utils
+{
+    public static class InspectionReportUtil
+    {
+        public static void ExportInspectionReportFile(InspectionReportModel inspectionReport)
+        {
+            const string templateFilePath = "Template\\军需物资质量监督检验报告模板.docx";
+            SaveFileDialog saveFileDialog = new SaveFileDialog()
+            {
+                Title = "请选择检验报告保存位置",
+                FileName = "被装材料检验报告-" + inspectionReport.ReportNo + "-" + WordUtil.GenerateFileSerialNumber(),
+                Filter = "PDF文件格式 (*.pdf)|*.pdf",
+            };
+            if (saveFileDialog.ShowDialog() == false) return;
+            var destinationFile = saveFileDialog.FileName;
+
+            var dictionary = CreateDictionary(inspectionReport);
+            var tempFile = $"Template\\temp_{WordUtil.GenerateFileSerialNumber()}.docx";
+
+            WordUtil.GenerateWordByTemplate(templateFilePath, tempFile, dictionary);
+            WordUtil.SaveWordToPdf(tempFile, destinationFile);
+
+            //删除临时文件
+            File.Delete(tempFile);
+
+            MessageBox.Show("文档已生成!");
+        }
+
+        private static Dictionary<string, string> CreateDictionary(InspectionReportModel inspectionReport)
+        {
+            Dictionary<string, string> dictionary = new()
+            {
+                { "ReportNo", inspectionReport.ReportNo },
+                { "Department", inspectionReport.Department },
+                { "ReportTime", inspectionReport.ReportTime.ToString("yyyy-MM-dd") }
+            };
+            //检验类别
+            switch (inspectionReport.InspectApply.InspCategory)
+            {
+                case "报样检验":
+                    dictionary.Add("FirstSelected", "\u25a0");//选中框
+                    break;
+                case "首批检验":
+                    dictionary.Add("SecondSelected", "\u25a0");//选中框
+                    break;
+                case "过程检验":
+                    dictionary.Add("ThirdSelected", "\u25a0");//选中框
+                    break;
+                case "出厂检验":
+                    dictionary.Add("ForthSelected", "\u25a0");//选中框
+                    break;
+            }
+            dictionary.Add("ProductName", inspectionReport.InspectApply.ProductName);
+            dictionary.Add("Company", inspectionReport.InspectApply.Company);
+            dictionary.Add("InspQuantity", inspectionReport.InspectApply.InspQuantity + inspectionReport.InspectApply.Material.MeasureUnit);
+            dictionary.Add("ProductDate", inspectionReport.InspectApply.StartProductDate.ToString("yyyy-MM-dd") + "至" + inspectionReport.InspectApply.EndProductDate.ToString("yyyy-MM-dd"));
+
+            //采购机构、合同号
+            StringBuilder purchaseCompanies = new StringBuilder();
+            StringBuilder contractNos = new StringBuilder();
+            foreach (var detail in inspectionReport.InspectApply.InspectApplyContractDetails)
+            {
+                purchaseCompanies.Append(detail.PurchaseCompanyShortName).Append(" ");
+                contractNos.Append(detail.ContractNo).Append(";");
+            }
+            dictionary.Add("PurchaseCompany", purchaseCompanies.ToString().Substring(0, purchaseCompanies.Length - 1));
+            dictionary.Add("ContractNumber", contractNos.ToString().Substring(0, contractNos.Length - 1));
+
+            dictionary.Add("ReportBasis", inspectionReport.ReportBasis);
+            dictionary.Add("ReportDesc", inspectionReport.ReportDesc);
+            dictionary.Add("ConclusionDesc", inspectionReport.ConclusionDesc);
+
+            //验收组
+            for (int i = 0; i < 5; i++)
+            {
+                if (i < inspectionReport.InspectionReportDetails.Count)
+                {
+                    var detail = inspectionReport.InspectionReportDetails[i];
+                    dictionary.Add("JobCategory" + i, detail.JobCategory);
+                    dictionary.Add("SupervisionUnit" + i, detail.SupervisionUnit);
+                    dictionary.Add("Inspector" + i, detail.Inspector);
+                }
+                else
+                {
+                    dictionary.Add("JobCategory" + i, string.Empty);
+                    dictionary.Add("SupervisionUnit" + i, string.Empty);
+                    dictionary.Add("Inspector" + i, string.Empty);
+                }
+            }
+
+            dictionary.Add("EditUser", inspectionReport.EditUser);
+
+            return dictionary;
+        }
+    }
+}

+ 20 - 3
UniformMaterialManagementSystem/ViewModels/InspectionReportInputPageViewModel.cs

@@ -6,7 +6,9 @@ using System.ComponentModel.DataAnnotations;
 using System.Text;
 using UniformMaterialManagementSystem.Custom;
 using UniformMaterialManagementSystem.Entities;
+using UniformMaterialManagementSystem.Models;
 using UniformMaterialManagementSystem.Services;
+using UniformMaterialManagementSystem.Utils;
 
 namespace UniformMaterialManagementSystem.ViewModels
 {
@@ -74,6 +76,8 @@ namespace UniformMaterialManagementSystem.ViewModels
 
         private readonly IDataBaseService<InspectionReport> _inspectionReportService;
 
+        private InspectionReport? _inspectionReport;
+
         public InspectionReportInputPageViewModel(IDataBaseService<InspectApply> inspectApplyService, IDataBaseService<User> userService,IDataBaseService<InspectionReport> inspectionReportService)
         {
             _inspectApplyService = inspectApplyService;
@@ -157,10 +161,23 @@ namespace UniformMaterialManagementSystem.ViewModels
             //重新加载检验申请列表
             LoadData();
 
+            //生成文档
+            GenerateDocument();
+
             //清空录入内容
             ClearInput();
         }
 
+        private void GenerateDocument()
+        {
+            if (_inspectionReport == null) return;
+
+            _inspectionReport.InspectApply = SelectedInspectApply;
+
+            //生成pdf文档
+            InspectionReportUtil.ExportInspectionReportFile(new InspectionReportModel(_inspectionReport));
+        }
+
         private void ClearInput()
         {
             SelectedInspectApply = null;
@@ -182,7 +199,7 @@ namespace UniformMaterialManagementSystem.ViewModels
 
         private void AddInspectionReportAndDetail()
         {
-            InspectionReport report = new()
+            _inspectionReport = new()
             {
                 InspectApplyGuid = SelectedInspectApply.Guid,
                 ReportNo = ReportNo,
@@ -199,10 +216,10 @@ namespace UniformMaterialManagementSystem.ViewModels
 
             foreach (var detail in InspectionReportDetails)
             {
-                report.InspectionReportDetails.Add(detail);
+                _inspectionReport.InspectionReportDetails.Add(detail);
             }
 
-            _inspectionReportService.Insert(report);
+            _inspectionReportService.Insert(_inspectionReport);
         }
 
         /// <summary>

+ 190 - 268
UniformMaterialManagementSystem/ViewModels/InspectionReportManagePageViewModel.cs

@@ -1,16 +1,14 @@
 using CommunityToolkit.Mvvm.ComponentModel;
 using CommunityToolkit.Mvvm.Input;
 using Microsoft.EntityFrameworkCore;
-using Microsoft.Win32;
 using System.Collections.ObjectModel;
-using System.IO;
 using System.Text;
 using System.Windows;
+using UniformMaterialManagementSystem.Custom;
 using UniformMaterialManagementSystem.Entities;
 using UniformMaterialManagementSystem.Models;
 using UniformMaterialManagementSystem.Services;
 using UniformMaterialManagementSystem.Utils;
-using UniformMaterialManagementSystem.Views;
 
 namespace UniformMaterialManagementSystem.ViewModels
 {
@@ -23,18 +21,12 @@ namespace UniformMaterialManagementSystem.ViewModels
         [ObservableProperty]
         private InspectionReportModel? _selectedInspectionReport;
 
-        [ObservableProperty]
-        private List<int> _years = [];
-
         [ObservableProperty]
         private List<string> _jobCategories = [];
 
         [ObservableProperty]
         private List<string> _userNames = [];
 
-        [ObservableProperty]
-        private int _selectedYear = DateTime.Now.Year;
-
         private InspectionReportDetail? _selectedInspectionReportDetail;
 
         private readonly IDataBaseService<InspectionReport> _inspectionReportService;
@@ -49,13 +41,6 @@ namespace UniformMaterialManagementSystem.ViewModels
             _inspectionReportDetailService = inspectionReportDetailService;
             _inspectApplyService = inspectApplyService;
 
-            //初始化年份
-            int currYear = DateTime.Now.Year;
-            for (int i = currYear - 10; i <= currYear + 1; i++)
-            {
-                Years.Add(i);
-            }
-
             //初始化职位类别
             JobCategories.Add("组长");
             JobCategories.Add("成员");
@@ -79,7 +64,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         private void LoadData()
         {
             //询问是否保存
-            //AskIsSave();
+            if(!AskIsSave()) return;
 
             var inspectionReports = _inspectionReportService.Query()
                 .Include(x => x.InspectionReportDetails)
@@ -87,7 +72,7 @@ namespace UniformMaterialManagementSystem.ViewModels
                 .ThenInclude(x => x.Material)
                 .Include(x => x.InspectApply)
                 .ThenInclude(x => x.InspectApplyContractDetails)
-                .Where(x => x.InspectApply.Year == SelectedYear)
+                .Where(x => x.InspectApply.Year == App.CurrentUser.WorkYear)
                 .ToList();
 
             InspectionReports.Clear();
@@ -97,155 +82,44 @@ namespace UniformMaterialManagementSystem.ViewModels
             }
         }
 
-        /// <summary>
-        ///判断单据是否有修改,true:已修改 false:未修改
-        /// </summary>
-        private bool IsCurrentReportChanged(InspectionReportModel inspectionReportModel)
-        {
-            var inspectionReport = _inspectionReportService.Get(x => x.Guid == inspectionReportModel.Guid);
-            if (inspectionReport == null) //新增
-            {
-                return true;
-            }
-            else
-            {
-                inspectionReportModel.ModifyInspectionReport(inspectionReport);
-                var state = _inspectionReportService.Entry(inspectionReport);
-                if (state == EntityState.Modified)
-                {
-                    return true;
-                }
-
-                //判断明细表是否新增、修改或删除
-                var reportDetails = inspectionReportModel.InspectionReportDetails;
-                var existDetails = _inspectionReportDetailService.Query(x => x.InspectionReportGuid == inspectionReportModel.Guid).ToList();
-
-                foreach (var detail in reportDetails)  //新增行或修改行操作
-                {
-                    var detailState = _inspectionReportDetailService.Entry(detail);
-                    if (detailState != EntityState.Unchanged)
-                    {
-                        return true;
-                    }
-                }
-
-                foreach (var detail in existDetails) //删除行操作
-                {
-                    var detailState = _inspectionReportDetailService.Entry(detail);
-                    if (detailState == EntityState.Deleted)
-                    {
-                        return true;
-                    }
-                }
-            }
-
-            return false;
-        }
-
-        /// <summary>
-        /// 询问是否保存更改
-        /// </summary>
-        private bool AskIsSave()
-        {
-            if (SelectedInspectionReport == null) return true;
-            var isChanged = IsCurrentReportChanged(SelectedInspectionReport);
-            if (!isChanged) return true;
-
-            var result = MessageBox.Show($"检验报告编号【{SelectedInspectionReport?.ReportNo}】已修改,是否保存修改?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            if (result == MessageBoxResult.Yes)
-            {
-                Dictionary<string, string> dictionary = CustomValidate();
-                if (dictionary.ContainsKey("result") && !string.IsNullOrEmpty(dictionary["result"]))
-                {
-                    MessageBox.Show(dictionary["result"], "错误", MessageBoxButton.OK, MessageBoxImage.Error);
-                    return false;
-                }
-                //保存修改
-                SaveInspectionReport();
-            }
-            else if (result == MessageBoxResult.No) //放弃更改
-            {
-                var inspectionReport = _inspectionReportService.Get(x => x.Guid == SelectedInspectionReport!.Guid);
-
-                if (inspectionReport == null) //新增行直接移除
-                {
-                    if (SelectedInspectionReport != null) InspectionReports.Remove(SelectedInspectionReport);
-                }
-                else
-                {
-                    _inspectionReportService.SetEntryState(inspectionReport, EntityState.Unchanged);
-
-                    if (SelectedInspectionReport != null)
-                    {
-                        ModifyModelFromInspectReport(SelectedInspectionReport, inspectionReport);
-
-                        var details = _inspectionReportDetailService
-                            .GetAll(x => x.InspectionReportGuid == SelectedInspectionReport.Guid).ToList();
-                        SelectedInspectionReport.InspectionReportDetails.Clear();
-                        foreach (var detail in details) //重新将数据库的数据赋值过来,并设置跟踪状态Unchanged
-                        {
-                            SelectedInspectionReport.InspectionReportDetails.Add(detail);
-                            _inspectionReportDetailService.SetEntryState(detail, EntityState.Unchanged);
-                        }
-                    }
-                }
-            }
-            return true;
-        }
-
-        private void ModifyModelFromInspectReport(InspectionReportModel model, InspectionReport report)
-        {
-            model.ReportNo  = report.ReportNo;
-            model.Department = report.Department;
-            model.ReportTime = report.ReportTime;
-            model.ReportBasis = report.ReportBasis;
-            model.IsSample = report.IsSample;
-            model.ReportDesc = report.ReportDesc;
-            model.Conclusion = report.Conclusion;
-            model.ConclusionDesc = report.ConclusionDesc;
-            model.EditUser = report.EditUser;
-            model.InspectionReportDetails = report.InspectionReportDetails;
-        }
-
-        /// <summary>
-        /// 新增检验报告
-        /// </summary>
-        [RelayCommand]
-        public void AddInspectionReport()
-        {
-            if (!AskIsSave()) return;
-
-            /* 打开窗口,展示检验报告状态未生成的检验申请列表,选择检验申请,携带检验申请数据 */
-            SelectInspectApplyWindowViewModel viewModel =
-                new SelectInspectApplyWindowViewModel(_inspectApplyService, "InspectionReport");
-            SelectInspectApplyWindow inspectApplyWindow = new SelectInspectApplyWindow(viewModel);
-
-            var result = inspectApplyWindow.ShowDialog();
-            if (result == null || !(bool)result) return;
-
-            var inspectApply = inspectApplyWindow.DataGridMain.SelectedItem as InspectApply;
-            if (inspectApply == null) return;
-
-            //新增检验报告并设置默认值
-            InspectionReport inspectionReport = new InspectionReport
-            {
-                InspectApply = inspectApply,
-                InspectApplyGuid = inspectApply.Guid,
-                ReportNo = inspectApply.ApplyNo.Replace("申请", ""),
-                Department = App.CurrentUser!.SupervisionUnit.Name,
-                ReportTime = DateTime.Now,
-                ReportBasis = "依据" + inspectApply.Material.NormName,
-                Conclusion = "合格",
-                EditUser = App.CurrentUser.UserName,
-                InspectionReportDetails = []
-            };
-
-            InspectionReportModel model = new InspectionReportModel(inspectionReport);
-            InspectionReports.Add(model);
-
-            //选中当前行
-            SelectedInspectionReport = model;
-        }
+        ///// <summary>
+        ///// 新增检验报告
+        ///// </summary>
+        //public void AddInspectionReport()
+        //{
+        //    if (!AskIsSave()) return;
+
+        //    /* 打开窗口,展示检验报告状态未生成的检验申请列表,选择检验申请,携带检验申请数据 */
+        //    SelectInspectApplyWindowViewModel viewModel =
+        //        new SelectInspectApplyWindowViewModel(_inspectApplyService, "InspectionReport");
+        //    SelectInspectApplyWindow inspectApplyWindow = new SelectInspectApplyWindow(viewModel);
+
+        //    var result = inspectApplyWindow.ShowDialog();
+        //    if (result == null || !(bool)result) return;
+
+        //    var inspectApply = inspectApplyWindow.DataGridMain.SelectedItem as InspectApply;
+        //    if (inspectApply == null) return;
+
+        //    //新增检验报告并设置默认值
+        //    InspectionReport inspectionReport = new InspectionReport
+        //    {
+        //        InspectApply = inspectApply,
+        //        InspectApplyGuid = inspectApply.Guid,
+        //        ReportNo = inspectApply.ApplyNo.Replace("申请", ""),
+        //        Department = App.CurrentUser!.SupervisionUnit.Name,
+        //        ReportTime = DateTime.Now,
+        //        ReportBasis = "依据" + inspectApply.Material.NormName,
+        //        Conclusion = "合格",
+        //        EditUser = App.CurrentUser.UserName,
+        //        InspectionReportDetails = []
+        //    };
+
+        //    InspectionReportModel model = new InspectionReportModel(inspectionReport);
+        //    InspectionReports.Add(model);
+
+        //    //选中当前行
+        //    SelectedInspectionReport = model;
+        //}
 
         /// <summary>
         /// 新增验收组
@@ -261,7 +135,7 @@ namespace UniformMaterialManagementSystem.ViewModels
                 SupervisionUnit = App.CurrentUser!.SupervisionUnit.Name
             };
 
-            SelectedInspectionReport.InspectionReportDetails.Add(newDetail); //sql执行update操作,有异常
+            SelectedInspectionReport.InspectionReportDetails.Add(newDetail);
         }
 
         /// <summary>
@@ -305,25 +179,18 @@ namespace UniformMaterialManagementSystem.ViewModels
             }
 
             var inspectionReport = _inspectionReportService.Get(x => x.Guid == SelectedInspectionReport.Guid);
-            if (inspectionReport == null) //新增行
-            {
-                InspectionReport newInspectionReport = new InspectionReport();
-                SelectedInspectionReport.ModifyInspectionReport(newInspectionReport);
-                _inspectionReportService.Insert(newInspectionReport);
-            }
-            else  //判断是否修改
-            {
-                SelectedInspectionReport.ModifyInspectionReport(inspectionReport);
+            if (inspectionReport == null) return;
+            
+            SelectedInspectionReport.ModifyInspectionReport(inspectionReport);
 
-                ////处理明细表新增行(无法跟踪明细表的新增行)
-                var existReportDetails = _inspectionReportDetailService.GetAll(x => x.InspectionReportGuid == inspectionReport.Guid).ToList();
-                foreach (var detail in SelectedInspectionReport.InspectionReportDetails)
+            ////处理明细表新增行(无法跟踪明细表的新增行)
+            var existReportDetails = _inspectionReportDetailService.GetAll(x => x.InspectionReportGuid == inspectionReport.Guid).ToList();
+            foreach (var detail in SelectedInspectionReport.InspectionReportDetails)
+            {
+                var existDetail = existReportDetails.FirstOrDefault(x => x.Guid == detail.Guid);
+                if (existDetail == null)
                 {
-                    var existDetail = existReportDetails.FirstOrDefault(x => x.Guid == detail.Guid);
-                    if (existDetail == null)
-                    {
-                        _inspectionReportDetailService.Insert(detail);
-                    }
+                    _inspectionReportDetailService.Insert(detail);
                 }
             }
 
@@ -342,102 +209,47 @@ namespace UniformMaterialManagementSystem.ViewModels
         }
 
         /// <summary>
-        /// 导出检验报告
+        /// 删除检验报告
         /// </summary>
         [RelayCommand]
-        private void ExportInspectionReport()
+        private void RemoveInspectionReport()
         {
-            if (SelectedInspectionReport == null) return;
-
-            if (!AskIsSave()) return;
-
-            const string templateFilePath = "Template\\军需物资质量监督检验报告模板.docx";
-            SaveFileDialog saveFileDialog = new SaveFileDialog()
+            if (SelectedInspectionReport == null)
             {
-                Title = "请选择检验报告保存位置",
-                FileName = "被装材料检验报告-" + SelectedInspectionReport.ReportNo + "-" + WordUtil.GenerateFileSerialNumber(),
-                Filter = "PDF文件格式 (*.pdf)|*.pdf",
-            };
-            if (saveFileDialog.ShowDialog() == false) return;
-            var destinationFile = saveFileDialog.FileName;
+                MessageBox.Show("请选中一行,再执行删除操作!", "提示",MessageBoxButton.OK,MessageBoxImage.Warning);
+                return;
+            }
 
-            var dictionary = CreateDictionary(SelectedInspectionReport);
-            var tempFile = $"Template\\temp_{WordUtil.GenerateFileSerialNumber()}.docx";
+            var result = MessageBox.Show($"确定删除编号为【{SelectedInspectionReport.ReportNo}】的检验报告吗?", "提示", MessageBoxButton.OKCancel,
+                MessageBoxImage.Question);
+            if (result != MessageBoxResult.OK) return;
 
-            WordUtil.GenerateWordByTemplate(templateFilePath, tempFile, dictionary);
-            WordUtil.SaveWordToPdf(tempFile, destinationFile);
+            //反写检验申请单的检验报告生成状态
+            var inspectApply = _inspectApplyService.Get(x => x.Guid == SelectedInspectionReport.InspectApplyGuid);
+            if (inspectApply != null)
+            {
+                inspectApply.ReportStatus = false;
+            }
 
-            //删除临时文件
-            File.Delete(tempFile);
+            //删除
+            _inspectionReportService.Delete(x=>x.Guid == SelectedInspectionReport.Guid); //删除主表时会级联删除子表
+            _inspectionReportService.SaveChanges();
 
-            MessageBox.Show("文档已生成!");
+            //重新加载数据
+            LoadData();
         }
 
-        private Dictionary<string, string> CreateDictionary(InspectionReportModel inspectionReport)
+        /// <summary>
+        /// 导出检验报告
+        /// </summary>
+        [RelayCommand]
+        private void ExportInspectionReport()
         {
-            Dictionary<string, string> dictionary = new()
-            {
-                { "ReportNo", inspectionReport.ReportNo },
-                { "Department", inspectionReport.Department },
-                { "ReportTime", inspectionReport.ReportTime.ToString("yyyy-MM-dd") }
-            };
-            //检验类别
-            switch (inspectionReport.InspectApply.InspCategory)
-            {
-                case "报样检验":
-                    dictionary.Add("FirstSelected", "\u25a0");//选中框
-                    break;
-                case "首批检验":
-                    dictionary.Add("SecondSelected", "\u25a0");//选中框
-                    break;
-                case "过程检验":
-                    dictionary.Add("ThirdSelected", "\u25a0");//选中框
-                    break;
-                case "出厂检验":
-                    dictionary.Add("ForthSelected", "\u25a0");//选中框
-                    break;
-            }
-            dictionary.Add("ProductName", inspectionReport.InspectApply.ProductName);
-            dictionary.Add("Company", inspectionReport.InspectApply.Company);
-            dictionary.Add("InspQuantity", inspectionReport.InspectApply.InspQuantity + inspectionReport.InspectApply.Material.MeasureUnit);
-            dictionary.Add("ProductDate", inspectionReport.InspectApply.StartProductDate.ToString("yyyy-MM-dd") + "至" + inspectionReport.InspectApply.EndProductDate.ToString("yyyy-MM-dd"));
-
-            //采购机构、合同号
-            StringBuilder purchaseCompanies = new StringBuilder();
-            StringBuilder contractNos = new StringBuilder();
-            foreach (var detail in inspectionReport.InspectApply.InspectApplyContractDetails)
-            {
-                purchaseCompanies.Append(detail.PurchaseCompanyShortName).Append(" ");
-                contractNos.Append(detail.ContractNo).Append(";");
-            }
-            dictionary.Add("PurchaseCompany", purchaseCompanies.ToString().Substring(0, purchaseCompanies.Length - 1));
-            dictionary.Add("ContractNumber", contractNos.ToString().Substring(0, contractNos.Length - 1));
-
-            dictionary.Add("ReportBasis", inspectionReport.ReportBasis);
-            dictionary.Add("ReportDesc", inspectionReport.ReportDesc);
-            dictionary.Add("ConclusionDesc", inspectionReport.ConclusionDesc);
-
-            //验收组
-            for (int i = 0; i < 5; i++)
-            {
-                if (i < inspectionReport.InspectionReportDetails.Count)
-                {
-                    var detail = inspectionReport.InspectionReportDetails[i];
-                    dictionary.Add("JobCategory" + i, detail.JobCategory);
-                    dictionary.Add("SupervisionUnit" + i, detail.SupervisionUnit);
-                    dictionary.Add("Inspector" + i, detail.Inspector);
-                }
-                else
-                {
-                    dictionary.Add("JobCategory" + i, string.Empty);
-                    dictionary.Add("SupervisionUnit" + i, string.Empty);
-                    dictionary.Add("Inspector" + i, string.Empty);
-                }
-            }
+            if (SelectedInspectionReport == null) return;
 
-            dictionary.Add("EditUser", inspectionReport.EditUser);
+            if (!AskIsSave()) return;
 
-            return dictionary;
+            InspectionReportUtil.ExportInspectionReportFile(SelectedInspectionReport);
         }
 
         /// <summary>
@@ -533,5 +345,115 @@ namespace UniformMaterialManagementSystem.ViewModels
             result.Add("result", errorMessage.ToString());
             return result;
         }
+
+        /// <summary>
+        ///判断单据是否有修改,true:已修改 false:未修改
+        /// </summary>
+        private bool IsCurrentReportChanged(InspectionReportModel inspectionReportModel)
+        {
+            var inspectionReport = _inspectionReportService.Get(x => x.Guid == inspectionReportModel.Guid);
+            if (inspectionReport == null) //新增
+            {
+                return true;
+            }
+            else
+            {
+                inspectionReportModel.ModifyInspectionReport(inspectionReport);
+                var state = _inspectionReportService.Entry(inspectionReport);
+                if (state == EntityState.Modified)
+                {
+                    return true;
+                }
+
+                //判断明细表是否新增、修改或删除
+                var reportDetails = inspectionReportModel.InspectionReportDetails;
+                var existDetails = _inspectionReportDetailService.Query(x => x.InspectionReportGuid == inspectionReportModel.Guid).ToList();
+
+                foreach (var detail in reportDetails)  //新增行或修改行操作
+                {
+                    var detailState = _inspectionReportDetailService.Entry(detail);
+                    if (detailState != EntityState.Unchanged)
+                    {
+                        return true;
+                    }
+                }
+
+                foreach (var detail in existDetails) //删除行操作
+                {
+                    var detailState = _inspectionReportDetailService.Entry(detail);
+                    if (detailState == EntityState.Deleted)
+                    {
+                        return true;
+                    }
+                }
+            }
+
+            return false;
+        }
+
+        /// <summary>
+        /// 询问是否保存更改
+        /// </summary>
+        private bool AskIsSave()
+        {
+            if (SelectedInspectionReport == null) return true;
+            var isChanged = IsCurrentReportChanged(SelectedInspectionReport);
+            if (!isChanged) return true;
+
+            var result = MessageBox.Show($"检验报告编号【{SelectedInspectionReport?.ReportNo}】已修改,是否保存修改?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
+            if (result == MessageBoxResult.Yes)
+            {
+                Dictionary<string, string> dictionary = CustomValidate();
+                if (dictionary.ContainsKey("result") && !string.IsNullOrEmpty(dictionary["result"]))
+                {
+                    MessageBox.Show(dictionary["result"], "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+                    return false;
+                }
+                //保存修改
+                SaveInspectionReport();
+            }
+            else if (result == MessageBoxResult.No) //放弃更改
+            {
+                var inspectionReport = _inspectionReportService.Get(x => x.Guid == SelectedInspectionReport!.Guid);
+
+                if (inspectionReport == null) //新增行直接移除
+                {
+                    if (SelectedInspectionReport != null) InspectionReports.Remove(SelectedInspectionReport);
+                }
+                else
+                {
+                    _inspectionReportService.SetEntryState(inspectionReport, EntityState.Unchanged);
+
+                    if (SelectedInspectionReport != null)
+                    {
+                        ModifyModelFromInspectReport(SelectedInspectionReport, inspectionReport);
+
+                        var details = _inspectionReportDetailService
+                            .GetAll(x => x.InspectionReportGuid == SelectedInspectionReport.Guid).ToList();
+                        SelectedInspectionReport.InspectionReportDetails.Clear();//detail被跟踪,clear之后变为Deleted状态
+                        foreach (var detail in details) //重新将数据库的数据赋值过来,并设置跟踪状态Unchanged
+                        {
+                            SelectedInspectionReport.InspectionReportDetails.Add(detail);
+                            _inspectionReportDetailService.SetEntryState(detail, EntityState.Unchanged);
+                        }
+                    }
+                }
+            }
+            return true;
+        }
+
+        private void ModifyModelFromInspectReport(InspectionReportModel model, InspectionReport report)
+        {
+            model.ReportNo = report.ReportNo;
+            model.Department = report.Department;
+            model.ReportTime = report.ReportTime;
+            model.ReportBasis = report.ReportBasis;
+            model.IsSample = report.IsSample;
+            model.ReportDesc = report.ReportDesc;
+            model.Conclusion = report.Conclusion;
+            model.ConclusionDesc = report.ConclusionDesc;
+            model.EditUser = report.EditUser;
+            model.InspectionReportDetails = report.InspectionReportDetails;
+        }
     }
 }

+ 4 - 4
UniformMaterialManagementSystem/Views/InspectionReport/InspectionReportInputPage.xaml

@@ -178,7 +178,7 @@
                                                         HorizontalAlignment="Center"
                                                         FontFamily="{StaticResource FluentSystemIconsRegular}"
                                                         FontSize="20"
-                                                        Text="{x:Static utils:RegularFontUtil.Document_Search_16}" />
+                                                        Text="{x:Static utils:RegularFontUtil.Arrow_Clockwise_12}" />
                                                     <TextBlock Text=" 刷新 " />
                                                 </StackPanel>
                                             </Border>
@@ -197,7 +197,7 @@
                                     <Button.Template>
                                         <ControlTemplate>
                                             <Border
-                                                Width="70"
+                                                Width="90"
                                                 Background="{TemplateBinding Background}"
                                                 CornerRadius="5">
                                                 <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
@@ -205,8 +205,8 @@
                                                         HorizontalAlignment="Center"
                                                         FontFamily="{StaticResource FluentSystemIconsRegular}"
                                                         FontSize="20"
-                                                        Text="{x:Static utils:RegularFontUtil.Save_32}" />
-                                                    <TextBlock Text="保存并导出" />
+                                                        Text="{x:Static utils:RegularFontUtil.Save_Arrow_Right_20}" />
+                                                    <TextBlock Text="保存并导出报告" />
                                                 </StackPanel>
                                             </Border>
                                             <ControlTemplate.Triggers>

+ 149 - 145
UniformMaterialManagementSystem/Views/InspectionReport/InspectionReportManagePage.xaml

@@ -5,6 +5,7 @@
     xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
     xmlns:behaviors="clr-namespace:UniformMaterialManagementSystem.Behaviors"
     xmlns:control="http://FilterDataGrid.Control.com/2024"
+    xmlns:converters="clr-namespace:UniformMaterialManagementSystem.Converters"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:filterDataGrid="http://FilterDataGrid.Control.com/2024"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -14,6 +15,7 @@
     mc:Ignorable="d">
 
     <UserControl.Resources>
+        <converters:ContentToBoolConverter x:Key="ContentToBoolConverter" />
         <!--  定义一个全局的TextBlock样式  -->
         <Style TargetType="TextBlock">
             <Setter Property="FontSize" Value="14" />
@@ -154,134 +156,138 @@
                     Grid.Row="0"
                     BorderBrush="Gray"
                     BorderThickness="1">
-                    <Grid Background="White">
-                        <Grid.ColumnDefinitions>
-                            <ColumnDefinition Width="Auto" />
-                            <ColumnDefinition Width="*" />
-                        </Grid.ColumnDefinitions>
-                        <StackPanel
-                            Grid.Column="0"
-                            FlowDirection="LeftToRight"
-                            Orientation="Horizontal">
+                    <ToolBarPanel>
+                        <ToolBar Background="White" ToolBarTray.IsLocked="True">
+                            <Button Command="{Binding LoadDataCommand}">
+                                <Button.Template>
+                                    <ControlTemplate>
+                                        <Border
+                                            Width="45"
+                                            Background="{TemplateBinding Background}"
+                                            CornerRadius="5">
+                                            <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+                                                <TextBlock
+                                                    HorizontalAlignment="Center"
+                                                    FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                                    FontSize="20"
+                                                    Text="{x:Static utils:RegularFontUtil.Arrow_Clockwise_12}" />
+                                                <TextBlock Text="刷新" />
+                                            </StackPanel>
+                                        </Border>
+                                        <ControlTemplate.Triggers>
+                                            <Trigger Property="IsMouseOver" Value="True">
+                                                <Setter Property="Background" Value="LightGray" />
+                                            </Trigger>
+                                        </ControlTemplate.Triggers>
+                                    </ControlTemplate>
+                                </Button.Template>
+                            </Button>
 
-                            <TextBlock Text="工作年度:" />
-                            <ComboBox
-                                Width="120"
-                                Height="23"
-                                IsEditable="True"
-                                ItemsSource="{Binding Years}"
-                                SelectedItem="{Binding SelectedYear, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                            <Separator />
+                            <Button Command="{Binding RemoveInspectionReportCommand}">
+                                <Button.Template>
+                                    <ControlTemplate>
+                                        <Border
+                                            Width="60"
+                                            Background="{TemplateBinding Background}"
+                                            CornerRadius="5">
+                                            <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+                                                <TextBlock
+                                                    HorizontalAlignment="Center"
+                                                    FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                                    FontSize="20"
+                                                    Text="{x:Static utils:RegularFontUtil.Delete_48}" />
+                                                <TextBlock Text="删除报告" />
+                                            </StackPanel>
+                                        </Border>
+                                        <ControlTemplate.Triggers>
+                                            <Trigger Property="IsMouseOver" Value="True">
+                                                <Setter Property="Background" Value="LightGray" />
+                                            </Trigger>
+                                        </ControlTemplate.Triggers>
+                                    </ControlTemplate>
+                                </Button.Template>
+                            </Button>
+                            <Separator />
+                            <!--<Button Command="{Binding AddInspectionReportCommand}">
+                                <Button.Template>
+                                    <ControlTemplate>
+                                        <Border
+                                            Width="40"
+                                            Background="{TemplateBinding Background}"
+                                            CornerRadius="5">
+                                            <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+                                                <TextBlock
+                                                    HorizontalAlignment="Center"
+                                                    FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                                    FontSize="20"
+                                                    Text="{x:Static utils:RegularFontUtil.Add_Circle_32}" />
+                                                <TextBlock Text="新增" />
+                                            </StackPanel>
+                                        </Border>
+                                        <ControlTemplate.Triggers>
+                                            <Trigger Property="IsMouseOver" Value="True">
+                                                <Setter Property="Background" Value="LightGray" />
+                                            </Trigger>
+                                        </ControlTemplate.Triggers>
+                                    </ControlTemplate>
+                                </Button.Template>
+                            </Button>-->
+                            <Button
+                                x:Name="SaveButton"
+                                Click="SaveButton_OnClick"
+                                Command="{Binding SaveInspectionReportCommand}">
+                                <Button.Template>
+                                    <ControlTemplate>
+                                        <Border
+                                            Width="40"
+                                            Background="{TemplateBinding Background}"
+                                            CornerRadius="5">
+                                            <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+                                                <TextBlock
+                                                    HorizontalAlignment="Center"
+                                                    FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                                    FontSize="20"
+                                                    Text="{x:Static utils:RegularFontUtil.Save_32}" />
+                                                <TextBlock Text="保存" />
+                                            </StackPanel>
+                                        </Border>
+                                        <ControlTemplate.Triggers>
+                                            <Trigger Property="IsMouseOver" Value="True">
+                                                <Setter Property="Background" Value="LightGray" />
+                                            </Trigger>
+                                        </ControlTemplate.Triggers>
+                                    </ControlTemplate>
+                                </Button.Template>
+                            </Button>
+                            <Separator />
+                            <Button Command="{Binding ExportInspectionReportCommand}">
+                                <Button.Template>
+                                    <ControlTemplate>
+                                        <Border
+                                            Width="60"
+                                            Background="{TemplateBinding Background}"
+                                            CornerRadius="5">
+                                            <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+                                                <TextBlock
+                                                    HorizontalAlignment="Center"
+                                                    FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                                    FontSize="20"
+                                                    Text="{x:Static utils:RegularFontUtil.Dock_20}" />
+                                                <TextBlock Text="导出报告" />
+                                            </StackPanel>
+                                        </Border>
+                                        <ControlTemplate.Triggers>
+                                            <Trigger Property="IsMouseOver" Value="True">
+                                                <Setter Property="Background" Value="LightGray" />
+                                            </Trigger>
+                                        </ControlTemplate.Triggers>
+                                    </ControlTemplate>
+                                </Button.Template>
+                            </Button>
 
-                        </StackPanel>
-                        <ToolBarPanel Grid.Column="1">
-                            <ToolBar Background="White" ToolBarTray.IsLocked="True">
-
-                                <Button Command="{Binding LoadDataCommand}">
-                                    <Button.Template>
-                                        <ControlTemplate>
-                                            <Border
-                                                Width="45"
-                                                Background="{TemplateBinding Background}"
-                                                CornerRadius="5">
-                                                <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
-                                                    <TextBlock
-                                                        HorizontalAlignment="Center"
-                                                        FontFamily="{StaticResource FluentSystemIconsRegular}"
-                                                        FontSize="20"
-                                                        Text="{x:Static utils:RegularFontUtil.Document_Search_16}" />
-                                                    <TextBlock Text=" 查询 " />
-                                                </StackPanel>
-                                            </Border>
-                                            <ControlTemplate.Triggers>
-                                                <Trigger Property="IsMouseOver" Value="True">
-                                                    <Setter Property="Background" Value="LightGray" />
-                                                </Trigger>
-                                            </ControlTemplate.Triggers>
-                                        </ControlTemplate>
-                                    </Button.Template>
-                                </Button>
-
-                                <Separator />
-                                <Button Command="{Binding AddInspectionReportCommand}">
-                                    <Button.Template>
-                                        <ControlTemplate>
-                                            <Border
-                                                Width="40"
-                                                Background="{TemplateBinding Background}"
-                                                CornerRadius="5">
-                                                <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
-                                                    <TextBlock
-                                                        HorizontalAlignment="Center"
-                                                        FontFamily="{StaticResource FluentSystemIconsRegular}"
-                                                        FontSize="20"
-                                                        Text="{x:Static utils:RegularFontUtil.Add_Circle_32}" />
-                                                    <TextBlock Text="新增" />
-                                                </StackPanel>
-                                            </Border>
-                                            <ControlTemplate.Triggers>
-                                                <Trigger Property="IsMouseOver" Value="True">
-                                                    <Setter Property="Background" Value="LightGray" />
-                                                </Trigger>
-                                            </ControlTemplate.Triggers>
-                                        </ControlTemplate>
-                                    </Button.Template>
-                                </Button>
-                                <Button
-                                    x:Name="SaveButton"
-                                    Click="SaveButton_OnClick"
-                                    Command="{Binding SaveInspectionReportCommand}">
-                                    <Button.Template>
-                                        <ControlTemplate>
-                                            <Border
-                                                Width="40"
-                                                Background="{TemplateBinding Background}"
-                                                CornerRadius="5">
-                                                <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
-                                                    <TextBlock
-                                                        HorizontalAlignment="Center"
-                                                        FontFamily="{StaticResource FluentSystemIconsRegular}"
-                                                        FontSize="20"
-                                                        Text="{x:Static utils:RegularFontUtil.Save_32}" />
-                                                    <TextBlock Text="保存" />
-                                                </StackPanel>
-                                            </Border>
-                                            <ControlTemplate.Triggers>
-                                                <Trigger Property="IsMouseOver" Value="True">
-                                                    <Setter Property="Background" Value="LightGray" />
-                                                </Trigger>
-                                            </ControlTemplate.Triggers>
-                                        </ControlTemplate>
-                                    </Button.Template>
-                                </Button>
-                                <Separator />
-                                <Button Command="{Binding ExportInspectionReportCommand}">
-                                    <Button.Template>
-                                        <ControlTemplate>
-                                            <Border
-                                                Width="60"
-                                                Background="{TemplateBinding Background}"
-                                                CornerRadius="5">
-                                                <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
-                                                    <TextBlock
-                                                        HorizontalAlignment="Center"
-                                                        FontFamily="{StaticResource FluentSystemIconsRegular}"
-                                                        FontSize="20"
-                                                        Text="{x:Static utils:RegularFontUtil.Dock_20}" />
-                                                    <TextBlock Text="导出报告" />
-                                                </StackPanel>
-                                            </Border>
-                                            <ControlTemplate.Triggers>
-                                                <Trigger Property="IsMouseOver" Value="True">
-                                                    <Setter Property="Background" Value="LightGray" />
-                                                </Trigger>
-                                            </ControlTemplate.Triggers>
-                                        </ControlTemplate>
-                                    </Button.Template>
-                                </Button>
-
-                            </ToolBar>
-                        </ToolBarPanel>
-                    </Grid>
+                        </ToolBar>
+                    </ToolBarPanel>
                 </Border>
             </Grid>
             <filterDataGrid:FilterDataGrid
@@ -464,31 +470,35 @@
                                 Grid.Column="0"
                                 Content="报样检验"
                                 GroupName="InspectType"
+                                IsChecked="{Binding SelectedInspectionReport.InspectApply.InspCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=报样检验}"
                                 IsEnabled="False" />
                             <RadioButton
                                 x:Name="SecondRadioButton"
                                 Grid.Column="1"
                                 Content="首批检验"
                                 GroupName="InspectType"
+                                IsChecked="{Binding SelectedInspectionReport.InspectApply.InspCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=首批检验}"
                                 IsEnabled="False" />
                             <RadioButton
                                 x:Name="ThirdRadioButton"
                                 Grid.Column="2"
                                 Content="生产过程"
                                 GroupName="InspectType"
+                                IsChecked="{Binding SelectedInspectionReport.InspectApply.InspCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=生产过程}"
                                 IsEnabled="False" />
                             <RadioButton
                                 x:Name="ForthRadioButton"
                                 Grid.Column="3"
                                 Content="出厂检验"
                                 GroupName="InspectType"
+                                IsChecked="{Binding SelectedInspectionReport.InspectApply.InspCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=出厂检验}"
                                 IsEnabled="False" />
-                            <TextBox
+                            <!--<TextBox
                                 x:Name="InspectTypeText"
                                 Grid.Column="0"
                                 Text="{Binding SelectedInspectionReport.InspectApply.InspCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                 TextChanged="InspectTypeText_TextChanged"
-                                Visibility="Collapsed" />
+                                Visibility="Collapsed" />-->
                         </Grid>
                     </StackPanel>
                     <TextBlock
@@ -619,7 +629,8 @@
                             VerticalContentAlignment="Center"
                             Content="抽样送检"
                             Foreground="Red"
-                            GroupName="IsSampleGroup" />
+                            GroupName="IsSampleGroup"
+                            IsChecked="{Binding SelectedInspectionReport.IsSample, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                         <RadioButton
                             x:Name="NotSampleRadioButton"
                             Grid.Row="0"
@@ -627,14 +638,8 @@
                             Padding="10,0,10,0"
                             VerticalContentAlignment="Center"
                             Content="未抽样送检"
-                            GroupName="IsSampleGroup" />
-                        <TextBox
-                            x:Name="IsSampleTextBox"
-                            Grid.Row="0"
-                            Grid.Column="2"
-                            Text="{Binding SelectedInspectionReport.IsSample, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
-                            TextChanged="IsSampleTextBox_TextChanged"
-                            Visibility="Collapsed" />
+                            GroupName="IsSampleGroup"
+                            IsChecked="True" />
                         <TextBox
                             Grid.Row="1"
                             Grid.Column="0"
@@ -672,38 +677,37 @@
                             Grid.Column="0"
                             Padding="10,0,10,0"
                             VerticalContentAlignment="Center"
-                            Checked="ConclusionGroupRadioButton_Checked"
                             Content="合格"
                             Foreground="Green"
                             GroupName="ConclusionGroup"
-                            IsChecked="True" />
+                            IsChecked="{Binding SelectedInspectionReport.Conclusion, Mode=TwoWay, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=合格}" />
                         <RadioButton
                             x:Name="SecondQualifiedRadioButton"
                             Grid.Row="0"
                             Grid.Column="1"
                             Padding="10,0,10,0"
                             VerticalContentAlignment="Center"
-                            Checked="ConclusionGroupRadioButton_Checked"
                             Content="合格(初测不合格,复测合格)"
                             Foreground="DarkOrange"
-                            GroupName="ConclusionGroup" />
+                            GroupName="ConclusionGroup"
+                            IsChecked="{Binding SelectedInspectionReport.Conclusion, Mode=TwoWay, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=合格(初测不合格,复测合格)}" />
                         <RadioButton
                             x:Name="UnQualifiedRadioButton"
                             Grid.Row="0"
                             Grid.Column="2"
                             Padding="10,0,10,0"
                             VerticalContentAlignment="Center"
-                            Checked="ConclusionGroupRadioButton_Checked"
                             Content="不合格"
                             Foreground="Red"
-                            GroupName="ConclusionGroup" />
-                        <TextBox
+                            GroupName="ConclusionGroup"
+                            IsChecked="{Binding SelectedInspectionReport.Conclusion, Mode=TwoWay, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=不合格}" />
+                        <!--<TextBox
                             x:Name="ConclusionTextBox"
                             Grid.Row="0"
                             Grid.Column="2"
                             Text="{Binding SelectedInspectionReport.Conclusion, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                             TextChanged="ConclusionTextBox_TextChanged"
-                            Visibility="Collapsed" />
+                            Visibility="Collapsed" />-->
                         <TextBox
                             Grid.Row="1"
                             Grid.Column="0"

+ 19 - 61
UniformMaterialManagementSystem/Views/InspectionReport/InspectionReportManagePage.xaml.cs

@@ -18,67 +18,25 @@ namespace UniformMaterialManagementSystem.Views.InspectionReport
 
         }
 
-        private void InspectTypeText_TextChanged(object sender, TextChangedEventArgs e)
-        {
-            var inspectType = InspectTypeText.Text;
-            switch (inspectType)
-            {
-                case "报样检验":
-                    FirstRadioButton.IsChecked = true;
-                    break;
-                case "首批检验":
-                    SecondRadioButton.IsChecked = true;
-                    break;
-                case "过程检验":
-                    ThirdRadioButton.IsChecked = true;
-                    break;
-                case "出厂检验":
-                    ForthRadioButton.IsChecked = true;
-                    break;
-            }
-        }
-
-        private void IsSampleTextBox_TextChanged(object sender, TextChangedEventArgs e)
-        {
-            var isSample = IsSampleTextBox.Text;
-            if (!string.IsNullOrEmpty(isSample) && bool.Parse(isSample))
-            {
-                IsSampleRadioButton.IsChecked = true;
-            }
-            else
-            {
-                NotSampleRadioButton.IsChecked = true;
-            }
-        }
-
-        private void ConclusionTextBox_TextChanged(object sender, TextChangedEventArgs e)
-        {
-            var conclusion = ConclusionTextBox.Text;
-            switch (conclusion)
-            {
-                case "合格":
-                    FirstQualifiedRadioButton.IsChecked = true;
-                    break;
-                case "合格(初测不合格,复测合格)":
-                    SecondQualifiedRadioButton.IsChecked = true;
-                    break;
-                case "不合格":
-                    UnQualifiedRadioButton.IsChecked = true;
-                    break;
-            }
-        }
-
-        private void ConclusionGroupRadioButton_Checked(object sender, System.Windows.RoutedEventArgs e)
-        {
-            var radioButton = (RadioButton)sender;
-            if (radioButton.GroupName == "ConclusionGroup")
-            {
-                if (radioButton.Content != null && ConclusionTextBox != null)
-                {
-                    ConclusionTextBox.Text = radioButton.Content.ToString();
-                }
-            }
-        }
+        //private void InspectTypeText_TextChanged(object sender, TextChangedEventArgs e)
+        //{
+        //    var inspectType = InspectTypeText.Text;
+        //    switch (inspectType)
+        //    {
+        //        case "报样检验":
+        //            FirstRadioButton.IsChecked = true;
+        //            break;
+        //        case "首批检验":
+        //            SecondRadioButton.IsChecked = true;
+        //            break;
+        //        case "过程检验":
+        //            ThirdRadioButton.IsChecked = true;
+        //            break;
+        //        case "出厂检验":
+        //            ForthRadioButton.IsChecked = true;
+        //            break;
+        //    }
+        //}
 
         private void Name_OnLostFocus(object sender, RoutedEventArgs e)
         {