Forráskód Böngészése

抽样登记录入开发;修改抽样登记管理

LT069288 3 hónapja
szülő
commit
6cb0bb60c4

+ 5 - 1
UniformMaterialManagementSystem/App.xaml.cs

@@ -12,6 +12,7 @@ using UniformMaterialManagementSystem.Views;
 using UniformMaterialManagementSystem.Views.FactoryLicense;
 using UniformMaterialManagementSystem.Views.InspectionReport;
 using UniformMaterialManagementSystem.Views.LoginAndRegister;
+using UniformMaterialManagementSystem.Views.SampleRegistration;
 
 namespace UniformMaterialManagementSystem
 {
@@ -75,6 +76,8 @@ namespace UniformMaterialManagementSystem
             services.AddKeyedTransient<UserControl, InspectionReportManagePage>("InspectionReportManagePage");
             services.AddKeyedTransient<UserControl, InspectionReportPage>("InspectionReportPage");
             services.AddKeyedTransient<UserControl, SampleRegistrationPage>("SampleRegistrationPage");
+            services.AddKeyedTransient<UserControl, SampleRegistrationManagePage>("SampleRegistrationManagePage");
+            services.AddKeyedTransient<UserControl, SampleRegistrationInputPage>("SampleRegistrationInputPage");
             services.AddKeyedTransient<UserControl, SelectApplyContractDialog>("SelectApplyContractDialog");
             services.AddKeyedTransient<UserControl, InspectionOrganizationPage>("InspectionOrganizationPage");
             services.AddKeyedTransient<UserControl, FactoryLicensePage>("FactoryLicensePage");
@@ -106,7 +109,8 @@ namespace UniformMaterialManagementSystem
             services.AddTransient<DeliveryReceiptViewModel>();
             services.AddTransient<InspectionReportManagePageViewModel>();
             services.AddTransient<InspectionReportInputPageViewModel>();
-            services.AddTransient<SampleRegistrationPageViewModel>();
+            services.AddTransient<SampleRegistrationManagePageViewModel>();
+            services.AddTransient<SampleRegistrationInputPageViewModel>();
             services.AddTransient<InspectionOrganizationPageViewModel>();
             services.AddTransient<FactoryLicenseInputPageViewModel>();
             services.AddTransient<FactoryLicenseManagePageViewModel>();

+ 98 - 0
UniformMaterialManagementSystem/Utils/SampleRegistrationUtil.cs

@@ -0,0 +1,98 @@
+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.Models;
+
+namespace UniformMaterialManagementSystem.Utils
+{
+    public static class SampleRegistrationUtil
+    {
+        public static void ExportSampleRegistrationFile(SampleRegistrationModel sampleRegistration)
+        {
+            const string templateFilePath = "Template\\被装材料产品抽样信息登记表模板.docx";
+            SaveFileDialog saveFileDialog = new SaveFileDialog()
+            {
+                Title = "请选择抽样信息登记表保存位置",
+                FileName = "抽样信息登记表-" + sampleRegistration.SampleNo + "-" + WordUtil.GenerateFileSerialNumber(),
+                Filter = "PDF文件格式 (*.pdf)|*.pdf",
+            };
+            if (saveFileDialog.ShowDialog() == false) return;
+            var destinationFile = saveFileDialog.FileName;
+
+            var dictionary = CreateDictionary(sampleRegistration);
+            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(SampleRegistrationModel sampleRegistration)
+        {
+            Dictionary<string, string> dictionary = new()
+            {
+                { "SampleNo", sampleRegistration.SampleNo },
+                { "Department", sampleRegistration.Department },
+                { "EditTime", sampleRegistration.EditTime.ToString("yyyy年MM月dd日") }
+            };
+            //检验类别
+            switch (sampleRegistration.InspectApply.InspCategory)
+            {
+                case "首批检验":
+                    dictionary.Add("FirstSelected", "\u25a0");//选中框
+                    break;
+                case "出厂检验":
+                    dictionary.Add("SecondSelected", "\u25a0");//选中框
+                    break;
+            }
+            dictionary.Add("ProductName", sampleRegistration.InspectApply.ProductName);
+            dictionary.Add("Company", sampleRegistration.InspectApply.Company);
+            dictionary.Add("ProductDate", sampleRegistration.ProductDate.ToString("yyyy-MM-dd"));
+            dictionary.Add("BatchNo", sampleRegistration.BatchNo);
+            dictionary.Add("PacketNo", sampleRegistration.PacketNo);
+            dictionary.Add("Quantity", sampleRegistration.Quantity + sampleRegistration.InspectApply.Material.MeasureUnit + "\u00d7" + "3");
+            dictionary.Add("TestProductDate", sampleRegistration.ProductDate.ToString("yyyy-MM-dd"));
+            dictionary.Add("TestBatchNo", sampleRegistration.BatchNo);
+            dictionary.Add("TestPacketNo", sampleRegistration.PacketNo);
+            dictionary.Add("TestQuantity", sampleRegistration.Quantity + sampleRegistration.InspectApply.Material.MeasureUnit);
+            switch (sampleRegistration.TestingItem)
+            {
+                case "全检":
+                    dictionary.Add("TestAll", "\u25a0");
+                    break;
+                case "强制性指标":
+                    dictionary.Add("MandatoryTest", "\u25a0");
+                    break;
+                case "色牢度":
+                    dictionary.Add("ColorFastness", "\u25a0");
+                    break;
+                case "光谱":
+                    dictionary.Add("Spectrum", "\u25a0");
+                    break;
+                case "参考性指标":
+                    dictionary.Add("Reference", "\u25a0");
+                    break;
+                case "单项指标":
+                    dictionary.Add("Single", "\u25a0");
+
+                    break;
+            }
+            dictionary.Add("SingleIndexItem", sampleRegistration.SingleIndexItem ?? "");
+            dictionary.Add("InspectionOrganization", sampleRegistration.InspectionOrganization);
+            dictionary.Add("ProductUsers", sampleRegistration.ProductUsers ?? "");
+            dictionary.Add("EditUser", sampleRegistration.EditUser);
+            dictionary.Add("Telephone", sampleRegistration.Telephone ?? "");
+
+            return dictionary;
+        }
+    }
+}

+ 6 - 0
UniformMaterialManagementSystem/ViewModels/InspectionReportManagePageViewModel.cs

@@ -235,6 +235,12 @@ namespace UniformMaterialManagementSystem.ViewModels
                 return;
             }
 
+            if (SelectedInspectionReport.InspectApply.LicenseStatus)
+            {
+                MessageBox.Show($"检验报告编号:【{SelectedInspectionReport.ReportNo}】已生成许可证,不允许删除!(如需删除,请先删除对应的许可证,再删除检验报告!)", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+
             var result = MessageBox.Show($"确定删除编号为【{SelectedInspectionReport.ReportNo}】的检验报告吗?", "提示", MessageBoxButton.OKCancel,
                 MessageBoxImage.Question);
             if (result != MessageBoxResult.OK) return;

+ 276 - 0
UniformMaterialManagementSystem/ViewModels/SampleRegistrationInputPageViewModel.cs

@@ -0,0 +1,276 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using Microsoft.EntityFrameworkCore;
+using System.Collections.ObjectModel;
+using System.ComponentModel.DataAnnotations;
+using System.Text;
+using System.Windows;
+using UniformMaterialManagementSystem.Entities;
+using UniformMaterialManagementSystem.Models;
+using UniformMaterialManagementSystem.Services;
+using UniformMaterialManagementSystem.Utils;
+
+namespace UniformMaterialManagementSystem.ViewModels
+{
+    public partial class SampleRegistrationInputPageViewModel : ObservableValidator
+    {
+        [ObservableProperty]
+        private string _sampleNo = string.Empty;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "单位不能为空")]
+        private string _department = string.Empty;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "时间不能为空")]
+        private DateTime _editTime;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "样品生产日期不能为空")]
+        private DateTime _productDate;
+
+        [ObservableProperty]
+        private string _batchNo = string.Empty;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "包号不能为空")]
+        [CustomValidation(typeof(SampleRegistrationInputPageViewModel), nameof(ValidatePacketNo))]
+        private string _packetNo = string.Empty;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "数量不能为空")]
+        [Range(0.1,double.MaxValue,ErrorMessage = "数量必须大于0")]
+        private decimal _quantity;
+
+        [ObservableProperty]
+        private string _testingItem = string.Empty;
+
+        [ObservableProperty]
+        [CustomValidation(typeof(SampleRegistrationInputPageViewModel), nameof(ValidateSingleIndexItem))]
+        private string? _singleIndexItem;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "检测机构不能为空,请抽取检测机构")]
+        private string _inspectionOrganization = string.Empty;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "生产企业人员不能为空")]
+        private string _productUsers = string.Empty;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "承办人不能为空")]
+        private string _editUser = string.Empty;
+
+        [ObservableProperty]
+        [Required(ErrorMessage = "联系电话不能为空")]
+        private string _telephone = string.Empty;
+
+        [ObservableProperty]
+        private string? _randomTip;
+
+        [ObservableProperty]
+        private InspectApply? _inspectApply;
+
+        [ObservableProperty]
+        private ObservableCollection<InspectApply> _inspectApplies = [];
+
+        private SampleRegistration? _sampleRegistration;
+
+        private readonly IDataBaseService<InspectApply> _inspectApplyService;
+        private readonly IDataBaseService<InspectApplyDetail> _inspectApplyDetailService;
+        private readonly IDataBaseService<InspectionOrganization> _organizationService;
+        private readonly IDataBaseService<SampleRegistration> _sampleRegistrationService;
+
+        public SampleRegistrationInputPageViewModel(IDataBaseService<InspectApply> inspectApplyService, IDataBaseService<InspectionOrganization> organizationService, IDataBaseService<InspectApplyDetail> inspectApplyDetailService,IDataBaseService<SampleRegistration> sampleRegistrationService)
+        {
+            _inspectApplyService = inspectApplyService;
+            _inspectApplyDetailService = inspectApplyDetailService;
+            _organizationService = organizationService;
+            _sampleRegistrationService = sampleRegistrationService;
+
+            //加载数据
+            LoadData();
+        }
+
+        /// <summary>
+        /// 加载数据
+        /// </summary>
+        [RelayCommand]
+        private void LoadData()
+        {
+            var inspectApplyList = _inspectApplyService.QueryNoTracking(x => x.Year == App.CurrentUser!.WorkYear && !x.SampleStatus)
+                .Include(x => x.Material)
+                .Include(x => x.InspectApplyContractDetails).ToList();
+
+            InspectApplies.Clear();
+            foreach (var inspectApply in inspectApplyList)
+            {
+                InspectApplies.Add(inspectApply);
+            }
+        }
+
+        /// <summary>
+        /// 保存
+        /// </summary>
+        [RelayCommand]
+        private void SaveSampleRegistration()
+        {
+            ValidateAllProperties();
+            if (HasErrors) return;
+
+            AddSampleRegistration();
+
+            if (_sampleRegistration == null) return;
+
+            //反写检验申请表的样品登记状态为true
+            var inspectApply = _inspectApplyService.Get(x => x.Guid == _sampleRegistration.InspectApplyGuid);
+            if (inspectApply != null)
+            {
+                inspectApply.SampleStatus = true;
+            }
+
+            var result = _sampleRegistrationService.SaveChanges();
+            if (result)
+            {
+                MessageBox.Show("保存成功!");
+            }
+
+            //脱离跟踪
+            if (inspectApply != null)
+            {
+                _inspectApplyService.SetEntryState(inspectApply, EntityState.Detached);
+            }
+
+            //生成文档
+            SampleRegistrationUtil.ExportSampleRegistrationFile(new SampleRegistrationModel(_sampleRegistration));
+
+            //重新加载数据
+            LoadData();
+
+            //清空界面
+            ClearInput();
+        }
+
+        /// <summary>
+        /// 鼠标双击事件,新增抽样登记表
+        /// </summary>
+        [RelayCommand]
+        private void MouseDoubleClick(InspectApply inspectApply)
+        {
+            InspectApply = inspectApply;
+            if (InspectApply == null) return;
+
+            SampleNo = inspectApply.ApplyNo.Replace("申请", "");
+            Department = App.CurrentUser!.SupervisionUnit.Name;
+            EditTime = inspectApply.InspDate; //默认报检时间
+            ProductDate = inspectApply.StartProductDate; //默认开始生产日期
+            BatchNo = inspectApply.BatchNo;
+            TestingItem = "全检";
+            ProductUsers = "我已知悉样品用途和后续处置方式,对以上样品的抽取封样程序、处理方式及样品的真实性和代表性均无异议。";
+            EditUser = App.CurrentUser.UserName;
+        }
+
+        /// <summary>
+        /// 抽取检测机构
+        /// </summary>
+        [RelayCommand]
+        private void RandomInspectionOrg()
+        {
+            //获取检测机构数量
+            var organizations = _organizationService.QueryNoTracking(x => x.IsEnabled).OrderBy(x => x.OrderNo).ToList();
+            if (organizations.Count == 0)
+            {
+                RandomTip = "没有要抽取的检测机构,请先维护检测机构信息!";
+                return;
+            }
+
+            //生成随机数1-3000
+            int random = RandomHelper.CreateRandom(3000);
+            int count = random % 5 + 1;
+
+            InspectionOrganization? organization = organizations.Find(x => x.OrderNo == count);
+            if (organization == null)
+            {
+                RandomTip = $"第{count}家检测机构不存在,请确保检测机构序号正确!";
+                return;
+            }
+
+            RandomTip = $"随机数:{random}";
+
+            StringBuilder sb = new StringBuilder();
+            sb.AppendLine("随机数:" + random);
+            sb.AppendLine("1.名称:" + organization.Name);
+            sb.AppendLine("2.地址:" + organization.Address);
+            sb.AppendLine("3.联系人:" + organization.Contacts);
+            sb.AppendLine("4.联系电话:" + organization.Telephone);
+
+            InspectionOrganization = sb.ToString();
+        }
+
+        private void ClearInput()
+        {
+            InspectApply = null;
+            SampleNo = string.Empty;
+            Department = string.Empty;
+            EditTime = DateTime.Now;
+            ProductDate = DateTime.Now; ;
+            BatchNo = string.Empty;
+            PacketNo = string.Empty;
+            Quantity = 0;
+            TestingItem = "全检";
+            SingleIndexItem = string.Empty;
+            InspectionOrganization = string.Empty;
+            ProductUsers = string.Empty;
+            EditUser = string.Empty;
+            Telephone = string.Empty;
+        }
+
+        private void AddSampleRegistration()
+        {
+            if (InspectApply == null) return;
+            _sampleRegistration = new SampleRegistration()
+            {
+                InspectApplyGuid = InspectApply.Guid,
+                SampleNo = SampleNo,
+                Department = Department,
+                EditTime = EditTime,
+                ProductDate = ProductDate,
+                BatchNo = BatchNo,
+                PacketNo = PacketNo,
+                Quantity = Quantity,
+                TestingItem = TestingItem,
+                SingleIndexItem = SingleIndexItem,
+                InspectionOrganization = InspectionOrganization,
+                ProductUsers = ProductUsers,
+                EditUser = EditUser,
+                Telephone = Telephone,
+                Year = App.CurrentUser!.WorkYear,
+            };
+            _sampleRegistrationService.Insert(_sampleRegistration);
+        }
+
+        public static ValidationResult? ValidatePacketNo(string packetNo, ValidationContext context)
+        {
+            var instance = (SampleRegistrationInputPageViewModel)context.ObjectInstance;
+            if (instance.InspectApply == null) return ValidationResult.Success;
+            
+            var detail = instance._inspectApplyDetailService.QueryNoTracking(x => x.ApplyGuid == instance.InspectApply.Guid).FirstOrDefault(x => x.PacketNo == packetNo);
+
+            return detail == null ? new ValidationResult("包号不存在") : ValidationResult.Success;
+        }
+
+        public static ValidationResult? ValidateSingleIndexItem(string singleIndexItem, ValidationContext context)
+        {
+            var instance = (SampleRegistrationInputPageViewModel)context.ObjectInstance;
+            if (instance.InspectApply == null) return ValidationResult.Success;
+
+            if (instance.TestingItem == "单项指标" && string.IsNullOrEmpty(singleIndexItem))
+            {
+                return new ValidationResult("单项指标内容不能为空");
+            }
+
+            return  ValidationResult.Success;
+        }
+
+    }
+}

+ 357 - 0
UniformMaterialManagementSystem/ViewModels/SampleRegistrationManagePageViewModel.cs

@@ -0,0 +1,357 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using Microsoft.EntityFrameworkCore;
+using System.Collections.ObjectModel;
+using System.Text;
+using System.Windows;
+using UniformMaterialManagementSystem.Entities;
+using UniformMaterialManagementSystem.Models;
+using UniformMaterialManagementSystem.Services;
+using UniformMaterialManagementSystem.Utils;
+
+namespace UniformMaterialManagementSystem.ViewModels
+{
+    public partial class SampleRegistrationManagePageViewModel : ObservableObject
+    {
+        [ObservableProperty]
+        private ObservableCollection<SampleRegistrationModel> _sampleRegistrations = [];
+
+        [ObservableProperty]
+        private SampleRegistrationModel? _selectedSampleRegistration;
+
+        private readonly IDataBaseService<SampleRegistration> _sampleService;
+        private readonly IDataBaseService<InspectApply> _inspectApplyService;
+        private readonly IDataBaseService<InspectionOrganization> _organizationService;
+
+        public SampleRegistrationManagePageViewModel(IDataBaseService<SampleRegistration> sampleService, IDataBaseService<InspectApply> inspectApplyService, IDataBaseService<InspectionOrganization> organizationService)
+        {
+            _sampleService = sampleService;
+            _inspectApplyService = inspectApplyService;
+            _organizationService = organizationService;
+
+            //加载数据
+            LoadData();
+        }
+
+        /// <summary>
+        /// 加载数据
+        /// </summary>
+        [RelayCommand]
+        private void LoadData()
+        {
+            //询问是否保存
+            //if (!AskIsSave()) return;
+
+            var sampleRegistrations = _sampleService.Query()
+                .Include(x => x.InspectApply)
+                .ThenInclude(x => x.Material)
+                .Where(x => x.Year == App.CurrentUser!.WorkYear)
+                .ToList();
+
+            SampleRegistrations.Clear();
+            foreach (var sample in sampleRegistrations)
+            {
+                SampleRegistrations.Add(new SampleRegistrationModel(sample));
+            }
+        }
+
+        /// <summary>
+        /// 删除登记表
+        /// </summary>
+        [RelayCommand]
+        private void RemoveSampleRegistration()
+        {
+            if (SelectedSampleRegistration == null) return;
+
+            var result = MessageBox.Show($"确认删除编号为【{SelectedSampleRegistration.SampleNo}】抽样登记表吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+            if (result != MessageBoxResult.OK) return;
+
+            //删除并反写检验申请单的送样状态为false
+            _sampleService.Delete(x => x.Guid == SelectedSampleRegistration.Guid);
+
+            var inspect = _inspectApplyService.Get(x => x.Guid == SelectedSampleRegistration.InspectApplyGuid);
+            if (inspect != null)
+            {
+                inspect.SampleStatus = false;
+            }
+            var success = _sampleService.SaveChanges();
+            if (success)
+            {
+                MessageBox.Show("删除成功!");
+                SampleRegistrations.Remove(SelectedSampleRegistration);
+            }
+        }
+
+        ///// <summary>
+        ///// 新增
+        ///// </summary>
+        //[RelayCommand]
+        //private void AddSampleRegistration()
+        //{
+        //    if (SelectedSampleRegistration != null)
+        //    {
+        //        //询问是否保存
+        //        if (!AskIsSave()) return;
+        //    }
+
+        //    /* 打开窗口,展示抽样状态未生成的检验申请列表,选择检验申请,携带检验申请数据 */
+        //    SelectInspectApplyWindowViewModel viewModel = new SelectInspectApplyWindowViewModel(_inspectApplyService, "SampleRegistration");
+        //    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;
+
+        //    //新增抽样登记并设置默认值
+        //    SampleRegistration sampleRegistration = new SampleRegistration
+        //    {
+        //        InspectApply = inspectApply,
+        //        InspectApplyGuid = inspectApply.Guid,
+        //        SampleNo = inspectApply.ApplyNo.Replace("申请", ""),
+        //        EditTime = DateTime.Now,
+        //        ProductDate = DateTime.Now,
+        //        BatchNo = inspectApply.BatchNo,
+        //        TestingItem = "全检",
+        //        Department = App.CurrentUser!.SupervisionUnit.Name,
+        //        EditUser = App.CurrentUser.UserName,
+        //        Year = App.CurrentUser.WorkYear,
+        //    };
+        //    SampleRegistrationModel model = new SampleRegistrationModel(sampleRegistration);
+
+        //    SampleRegistrations.Add(model);
+
+        //    //选中当前行
+        //    SelectedSampleRegistration = model;
+        //}
+
+        ///// <summary>
+        ///// 保存
+        ///// </summary>
+        //[RelayCommand]
+        //private void SaveSampleRegistration()
+        //{
+        //    if (SelectedSampleRegistration == null) return;
+
+        //    //自定义校验
+        //    var validateDictionary = CustomValidate();
+        //    if (validateDictionary.ContainsKey("result") && !string.IsNullOrEmpty(validateDictionary["result"]))
+        //    {
+        //        MessageBox.Show(validateDictionary["result"], "提示", MessageBoxButton.OK, MessageBoxImage.Error);
+        //        return;
+        //    }
+
+        //    //对新增或修改的抽样登记单进行保存
+        //    var sampleRegistration = _sampleService.Get(x => x.Guid == SelectedSampleRegistration.Guid);
+        //    if (sampleRegistration == null)  //新增
+        //    {
+        //        sampleRegistration = new SampleRegistration();
+        //        SelectedSampleRegistration.ModifySampleRegistration(sampleRegistration);
+        //        _sampleService.Insert(sampleRegistration);
+        //    }
+        //    else  //修改
+        //    {
+        //        SelectedSampleRegistration.ModifySampleRegistration(sampleRegistration);
+        //    }
+
+        //    //反写检验申请单的抽样送检状态
+        //    var inspectApply = _inspectApplyService.Get(x => x.Guid == sampleRegistration.InspectApplyGuid);
+        //    if (inspectApply != null)
+        //    {
+        //        inspectApply.SampleStatus = true;
+        //    }
+
+        //    var result = _sampleService.SaveChanges();
+
+        //    if (result)
+        //    {
+        //        MessageBox.Show("保存成功!");
+        //    }
+        //}
+
+        /// <summary>
+        /// 导出登记表
+        /// </summary>
+        [RelayCommand]
+        private void ExportSampleRegistration()
+        {
+            if (SelectedSampleRegistration == null)
+            {
+                MessageBox.Show("请先选中一行抽样登记表,再执行导出操作!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+            //询问是否保存
+            //if (!AskIsSave()) return;
+
+            SampleRegistrationUtil.ExportSampleRegistrationFile(SelectedSampleRegistration);
+        }
+
+        /// <summary>
+        /// 随机抽取检测机构
+        /// </summary>
+        [RelayCommand]
+        private void RandomInspectionOrg()
+        {
+            if (SelectedSampleRegistration == null) return;
+
+            //获取检测机构数量
+            var organizations = _organizationService.QueryNoTracking(x => x.IsEnabled).OrderBy(x => x.OrderNo).ToList();
+            if (organizations.Count == 0)
+            {
+                SelectedSampleRegistration.RandomTip = "没有要抽取的检测机构,请先维护检测机构信息!";
+                return;
+            }
+
+            //生成随机数
+            int random = RandomHelper.CreateRandom(3000);
+            int count = random % 5 + 1;
+
+            SelectedSampleRegistration.RandomTip = $"系统生成随机数为{random},将使用第{count}家检测机构。";
+
+            InspectionOrganization? organization = organizations.Find(x => x.OrderNo == count);
+            if (organization == null)
+            {
+                SelectedSampleRegistration.RandomTip = $"第{count}家检测机构不存在,请确保检测机构序号正确!";
+                return;
+            }
+
+            SelectedSampleRegistration.RandomTip = $"随机数:{random}";
+
+            StringBuilder sb = new StringBuilder();
+            sb.AppendLine("随机数:" + random);
+            sb.AppendLine("1.名称:" + organization.Name);
+            sb.AppendLine("2.地址:" + organization.Address);
+            sb.AppendLine("3.联系人:" + organization.Contacts);
+            sb.AppendLine("4.联系电话:" + organization.Telephone);
+
+            SelectedSampleRegistration.InspectionOrganization = sb.ToString();
+        }
+
+        /// <summary>
+        ///判断单据是否有修改,true:已修改 false:未修改
+        /// </summary>
+        private bool IsCurrentSampleChanged(SampleRegistrationModel sampleRegistrationModel)
+        {
+            var sampleRegistration = _sampleService.Get(x => x.Guid == sampleRegistrationModel.Guid);
+            if (sampleRegistration == null) //新增
+            {
+                return true;
+            }
+            else
+            {
+                sampleRegistrationModel.ModifySampleRegistration(sampleRegistration);
+                var state = _sampleService.Entry(sampleRegistration);
+                if (state == EntityState.Modified)
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        ///// <summary>
+        ///// 询问是否保存
+        ///// </summary>
+        //private bool AskIsSave()
+        //{
+        //    if (SelectedSampleRegistration == null) return true;
+        //    var isChanged = IsCurrentSampleChanged(SelectedSampleRegistration);
+        //    if (!isChanged) return true;
+        //    var result = MessageBox.Show($"抽样登记表【{SelectedSampleRegistration.SampleNo}】已修改,是否保存修改?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
+
+        //    if (result == MessageBoxResult.Yes)
+        //    {
+        //        //自定义校验
+        //        var validateDictionary = CustomValidate();
+        //        if (validateDictionary.ContainsKey("result") && !string.IsNullOrEmpty(validateDictionary["result"]))
+        //        {
+        //            MessageBox.Show(validateDictionary["result"], "提示", MessageBoxButton.OK, MessageBoxImage.Error);
+        //            return false;
+        //        }
+        //        SaveSampleRegistration();
+        //    }
+        //    else if (result == MessageBoxResult.No)
+        //    {
+        //        var sampleRegistration = _sampleService.Get(x => x.Guid == SelectedSampleRegistration.Guid);
+        //        if (sampleRegistration == null)//新增
+        //        {
+        //            SampleRegistrations.Remove(SelectedSampleRegistration);
+        //        }
+        //        else  //修改
+        //        {
+        //            _sampleService.SetEntryState(sampleRegistration, EntityState.Unchanged);
+        //            ModifyModelFromSampleRegistration(SelectedSampleRegistration, sampleRegistration);
+        //        }
+        //    }
+
+        //    return true;
+        //}
+
+        private Dictionary<string, string> CustomValidate()
+        {
+            Dictionary<string, string> result = new Dictionary<string, string>();
+            StringBuilder errorMessage = new StringBuilder();
+
+            if (string.IsNullOrEmpty(SelectedSampleRegistration?.Department))
+            {
+                errorMessage.Append("单位不允许为空!\n");
+            }
+            if (SelectedSampleRegistration?.EditTime == null)
+            {
+                errorMessage.Append("时间不允许为空!\n");
+            }
+            if (SelectedSampleRegistration?.ProductDate == null)
+            {
+                errorMessage.Append("样品生产日期不允许为空!\n");
+            }
+            if (string.IsNullOrEmpty(SelectedSampleRegistration?.PacketNo))
+            {
+                errorMessage.Append("包号不允许为空!\n");
+            }
+            if (SelectedSampleRegistration?.Quantity <= 0)
+            {
+                errorMessage.Append("数量不允许小于等于0!\n");
+            }
+            if (SelectedSampleRegistration?.TestingItem == "单项指标" && string.IsNullOrEmpty(SelectedSampleRegistration?.SingleIndexItem))
+            {
+                errorMessage.Append("检测项目为“单项指标”,单项指标内容不允许为空!\n");
+            }
+            if (string.IsNullOrEmpty(SelectedSampleRegistration?.InspectionOrganization))
+            {
+                errorMessage.Append("检测机构不允许为空,请抽取检测机构!\n");
+            }
+            if (string.IsNullOrEmpty(SelectedSampleRegistration?.ProductUsers))
+            {
+                errorMessage.Append("生产企业人员不允许为空!\n");
+            }
+            if (string.IsNullOrEmpty(SelectedSampleRegistration?.EditUser))
+            {
+                errorMessage.Append("承办人不允许为空!\n");
+            }
+            if (string.IsNullOrEmpty(SelectedSampleRegistration?.Telephone))
+            {
+                errorMessage.Append("联系电话不允许为空!\n");
+            }
+            result.Add("result", errorMessage.ToString());
+            return result;
+        }
+
+        private void ModifyModelFromSampleRegistration(SampleRegistrationModel model, SampleRegistration sampleRegistration)
+        {
+            model.Department = sampleRegistration.Department;
+            model.EditTime = sampleRegistration.EditTime;
+            model.ProductDate = sampleRegistration.ProductDate;
+            model.BatchNo = sampleRegistration.BatchNo;
+            model.PacketNo = sampleRegistration.PacketNo;
+            model.Quantity = sampleRegistration.Quantity;
+            model.TestingItem = sampleRegistration.TestingItem;
+            model.SingleIndexItem = sampleRegistration.SingleIndexItem;
+            model.InspectionOrganization = sampleRegistration.InspectionOrganization;
+            model.ProductUsers = sampleRegistration.ProductUsers;
+            model.EditUser = sampleRegistration.EditUser;
+            model.Telephone = sampleRegistration.Telephone;
+        }
+
+    }
+}

+ 0 - 422
UniformMaterialManagementSystem/ViewModels/SampleRegistrationPageViewModel.cs

@@ -1,422 +0,0 @@
-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.Entities;
-using UniformMaterialManagementSystem.Models;
-using UniformMaterialManagementSystem.Services;
-using UniformMaterialManagementSystem.Utils;
-using UniformMaterialManagementSystem.Views;
-
-namespace UniformMaterialManagementSystem.ViewModels
-{
-    public partial class SampleRegistrationPageViewModel : ObservableObject
-    {
-        [ObservableProperty]
-        private List<int> _years = [];
-
-        [ObservableProperty]
-        private int _selectedYear = DateTime.Now.Year;
-
-        [ObservableProperty]
-        private ObservableCollection<SampleRegistrationModel> _sampleRegistrations = [];
-
-        [ObservableProperty]
-        private SampleRegistrationModel? _selectedSampleRegistration;
-
-        private readonly IDataBaseService<SampleRegistration> _sampleService;
-        private readonly IDataBaseService<InspectApply> _inspectApplyService;
-        private readonly IDataBaseService<InspectionOrganization> _organizationService;
-
-        public SampleRegistrationPageViewModel(IDataBaseService<SampleRegistration> sampleService, IDataBaseService<InspectApply> inspectApplyService, IDataBaseService<InspectionOrganization> organizationService)
-        {
-            _sampleService = sampleService;
-            _inspectApplyService = inspectApplyService;
-            _organizationService = organizationService;
-
-            //初始化年份
-            for (int i = DateTime.Now.Year - 10; i <= DateTime.Now.Year + 1; i++)
-            {
-                Years.Add(i);
-            }
-
-            //加载数据
-            LoadData();
-        }
-
-        /// <summary>
-        /// 加载数据
-        /// </summary>
-        [RelayCommand]
-        private void LoadData()
-        {
-            //询问是否保存
-            if (!AskIsSave()) return;
-
-            var sampleRegistrations = _sampleService.Query()
-                .Include(x => x.InspectApply)
-                .ThenInclude(x => x.Material)
-                .Where(x => x.Year == SelectedYear)
-                .ToList();
-
-            SampleRegistrations.Clear();
-            foreach (var sample in sampleRegistrations)
-            {
-                SampleRegistrations.Add(new SampleRegistrationModel(sample));
-            }
-        }
-
-        /// <summary>
-        /// 新增
-        /// </summary>
-        [RelayCommand]
-        private void AddSampleRegistration()
-        {
-            if (SelectedSampleRegistration != null)
-            {
-                //询问是否保存
-                if (!AskIsSave()) return;
-            }
-
-            /* 打开窗口,展示抽样状态未生成的检验申请列表,选择检验申请,携带检验申请数据 */
-            SelectInspectApplyWindowViewModel viewModel = new SelectInspectApplyWindowViewModel(_inspectApplyService, "SampleRegistration");
-            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;
-
-            //新增抽样登记并设置默认值
-            SampleRegistration sampleRegistration = new SampleRegistration
-            {
-                InspectApply = inspectApply,
-                InspectApplyGuid = inspectApply.Guid,
-                SampleNo = inspectApply.ApplyNo.Replace("申请", ""),
-                EditTime = DateTime.Now,
-                ProductDate = DateTime.Now,
-                BatchNo = inspectApply.BatchNo,
-                TestingItem = "全检",
-                Department = App.CurrentUser!.SupervisionUnit.Name,
-                EditUser = App.CurrentUser.UserName,
-                Year = App.CurrentUser.WorkYear,
-            };
-            SampleRegistrationModel model = new SampleRegistrationModel(sampleRegistration);
-
-            SampleRegistrations.Add(model);
-
-            //选中当前行
-            SelectedSampleRegistration = model;
-        }
-
-        /// <summary>
-        /// 保存
-        /// </summary>
-        [RelayCommand]
-        private void SaveSampleRegistration()
-        {
-            if (SelectedSampleRegistration == null) return;
-
-            //自定义校验
-            var validateDictionary = CustomValidate();
-            if (validateDictionary.ContainsKey("result") && !string.IsNullOrEmpty(validateDictionary["result"]))
-            {
-                MessageBox.Show(validateDictionary["result"], "提示", MessageBoxButton.OK, MessageBoxImage.Error);
-                return;
-            }
-
-            //对新增或修改的抽样登记单进行保存
-            var sampleRegistration = _sampleService.Get(x => x.Guid == SelectedSampleRegistration.Guid);
-            if (sampleRegistration == null)  //新增
-            {
-                sampleRegistration = new SampleRegistration();
-                SelectedSampleRegistration.ModifySampleRegistration(sampleRegistration);
-                _sampleService.Insert(sampleRegistration);
-            }
-            else  //修改
-            {
-                SelectedSampleRegistration.ModifySampleRegistration(sampleRegistration);
-            }
-
-            //反写检验申请单的抽样送检状态
-            var inspectApply = _inspectApplyService.Get(x => x.Guid == sampleRegistration.InspectApplyGuid);
-            if (inspectApply != null)
-            {
-                inspectApply.SampleStatus = true;
-            }
-
-            var result = _sampleService.SaveChanges();
-
-            if (result)
-            {
-                MessageBox.Show("保存成功!");
-            }
-        }
-
-        /// <summary>
-        /// 导出登记表
-        /// </summary>
-        [RelayCommand]
-        private void ExportSampleRegistration()
-        {
-            if (SelectedSampleRegistration == null)
-            {
-                MessageBox.Show("请先选中一行抽样登记表,再执行导出操作!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
-                return;
-            }
-            //询问是否保存
-            if (!AskIsSave()) return;
-
-            const string templateFilePath = "Template\\被装材料产品抽样信息登记表模板.docx";
-            SaveFileDialog saveFileDialog = new SaveFileDialog()
-            {
-                Title = "请选择抽样信息登记表保存位置",
-                FileName = "抽样信息登记表-" + SelectedSampleRegistration.SampleNo + "-" + WordUtil.GenerateFileSerialNumber(),
-                Filter = "PDF文件格式 (*.pdf)|*.pdf",
-            };
-            if (saveFileDialog.ShowDialog() == false) return;
-            var destinationFile = saveFileDialog.FileName;
-
-            var dictionary = CreateDictionary(SelectedSampleRegistration);
-            var tempFile = $"Template\\temp_{WordUtil.GenerateFileSerialNumber()}.docx";
-
-            WordUtil.GenerateWordByTemplate(templateFilePath, tempFile, dictionary);
-            WordUtil.SaveWordToPdf(tempFile, destinationFile);
-
-            //删除临时文件
-            File.Delete(tempFile);
-
-            MessageBox.Show("文档已生成!");
-        }
-
-        /// <summary>
-        /// 随机抽取检测机构
-        /// </summary>
-        [RelayCommand]
-        private void RandomInspectionOrg()
-        {
-            if (SelectedSampleRegistration == null) return;
-
-            //获取检测机构数量
-            var organizations = _organizationService.QueryNoTracking(x => x.IsEnabled).OrderBy(x => x.OrderNo).ToList();
-            if (organizations.Count == 0)
-            {
-                //MessageBox.Show("没有要抽取的检测机构,请先维护检测机构信息!");
-                SelectedSampleRegistration.RandomTip = "没有要抽取的检测机构,请先维护检测机构信息!";
-                return;
-            }
-
-            //生成随机数
-            int random = RandomHelper.CreateRandom(5);
-            int count = random == 0 ? organizations.Count : random;
-
-            //MessageBox.Show($"系统生成随机数为{random},将使用第{count}家检测机构。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
-            SelectedSampleRegistration.RandomTip = $"系统生成随机数为{random},将使用第{count}家检测机构。";
-
-            InspectionOrganization? organization = organizations.Find(x => x.OrderNo == count);
-            if (organization == null)
-            {
-                //MessageBox.Show($"第{count}家检测机构不存在,请确保检测机构序号正确!");
-                SelectedSampleRegistration.RandomTip = $"第{count}家检测机构不存在,请确保检测机构序号正确!";
-                return;
-            }
-
-            StringBuilder sb = new StringBuilder();
-            sb.AppendLine("1.名称:" + organization.Name);
-            sb.AppendLine("2.地址:" + organization.Address);
-            sb.AppendLine("3.联系人:" + organization.Contacts);
-            sb.AppendLine("4.联系电话:" + organization.Telephone);
-
-            SelectedSampleRegistration.InspectionOrganization = sb.ToString();
-        }
-
-        /// <summary>
-        ///判断单据是否有修改,true:已修改 false:未修改
-        /// </summary>
-        private bool IsCurrentSampleChanged(SampleRegistrationModel sampleRegistrationModel)
-        {
-            var sampleRegistration = _sampleService.Get(x => x.Guid == sampleRegistrationModel.Guid);
-            if (sampleRegistration == null) //新增
-            {
-                return true;
-            }
-            else
-            {
-                sampleRegistrationModel.ModifySampleRegistration(sampleRegistration);
-                var state = _sampleService.Entry(sampleRegistration);
-                if (state == EntityState.Modified)
-                {
-                    return true;
-                }
-            }
-            return false;
-        }
-
-        /// <summary>
-        /// 询问是否保存
-        /// </summary>
-        private bool AskIsSave()
-        {
-            if (SelectedSampleRegistration == null) return true;
-            var isChanged = IsCurrentSampleChanged(SelectedSampleRegistration);
-            if (!isChanged) return true;
-            var result = MessageBox.Show($"抽样登记表【{SelectedSampleRegistration.SampleNo}】已修改,是否保存修改?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
-
-            if (result == MessageBoxResult.Yes)
-            {
-                //自定义校验
-                var validateDictionary = CustomValidate();
-                if (validateDictionary.ContainsKey("result") && !string.IsNullOrEmpty(validateDictionary["result"]))
-                {
-                    MessageBox.Show(validateDictionary["result"], "提示", MessageBoxButton.OK, MessageBoxImage.Error);
-                    return false;
-                }
-                SaveSampleRegistration();
-            }
-            else if (result == MessageBoxResult.No)
-            {
-                var sampleRegistration = _sampleService.Get(x => x.Guid == SelectedSampleRegistration.Guid);
-                if (sampleRegistration == null)//新增
-                {
-                    SampleRegistrations.Remove(SelectedSampleRegistration);
-                }
-                else  //修改
-                {
-                    _sampleService.SetEntryState(sampleRegistration, EntityState.Unchanged);
-                    ModifyModelFromSampleRegistration(SelectedSampleRegistration, sampleRegistration);
-                }
-            }
-
-            return true;
-        }
-
-        private Dictionary<string, string> CustomValidate()
-        {
-            Dictionary<string, string> result = new Dictionary<string, string>();
-            StringBuilder errorMessage = new StringBuilder();
-
-            if (string.IsNullOrEmpty(SelectedSampleRegistration?.Department))
-            {
-                errorMessage.Append("单位不允许为空!\n");
-            }
-            if (SelectedSampleRegistration?.EditTime == null)
-            {
-                errorMessage.Append("时间不允许为空!\n");
-            }
-            if (SelectedSampleRegistration?.ProductDate == null)
-            {
-                errorMessage.Append("样品生产日期不允许为空!\n");
-            }
-            if (string.IsNullOrEmpty(SelectedSampleRegistration?.PacketNo))
-            {
-                errorMessage.Append("包号不允许为空!\n");
-            }
-            if (SelectedSampleRegistration?.Quantity <= 0)
-            {
-                errorMessage.Append("数量不允许小于等于0!\n");
-            }
-            if (SelectedSampleRegistration?.TestingItem == "单项指标" && string.IsNullOrEmpty(SelectedSampleRegistration?.SingleIndexItem))
-            {
-                errorMessage.Append("检测项目为“单项指标”,单项指标内容不允许为空!\n");
-            }
-            if (string.IsNullOrEmpty(SelectedSampleRegistration?.InspectionOrganization))
-            {
-                errorMessage.Append("检测机构不允许为空,请抽取检测机构!\n");
-            }
-            if (string.IsNullOrEmpty(SelectedSampleRegistration?.ProductUsers))
-            {
-                errorMessage.Append("生产企业人员不允许为空!\n");
-            }
-            if (string.IsNullOrEmpty(SelectedSampleRegistration?.EditUser))
-            {
-                errorMessage.Append("承办人不允许为空!\n");
-            }
-            if (string.IsNullOrEmpty(SelectedSampleRegistration?.Telephone))
-            {
-                errorMessage.Append("联系电话不允许为空!\n");
-            }
-            result.Add("result", errorMessage.ToString());
-            return result;
-        }
-
-        private void ModifyModelFromSampleRegistration(SampleRegistrationModel model, SampleRegistration sampleRegistration)
-        {
-            model.Department = sampleRegistration.Department;
-            model.EditTime = sampleRegistration.EditTime;
-            model.ProductDate = sampleRegistration.ProductDate;
-            model.BatchNo = sampleRegistration.BatchNo;
-            model.PacketNo = sampleRegistration.PacketNo;
-            model.Quantity = sampleRegistration.Quantity;
-            model.TestingItem = sampleRegistration.TestingItem;
-            model.SingleIndexItem = sampleRegistration.SingleIndexItem;
-            model.InspectionOrganization = sampleRegistration.InspectionOrganization;
-            model.ProductUsers = sampleRegistration.ProductUsers;
-            model.EditUser = sampleRegistration.EditUser;
-            model.Telephone = sampleRegistration.Telephone;
-        }
-
-        private Dictionary<string, string> CreateDictionary(SampleRegistrationModel sampleRegistration)
-        {
-            Dictionary<string, string> dictionary = new()
-            {
-                { "SampleNo", sampleRegistration.SampleNo },
-                { "Department", sampleRegistration.Department },
-                { "EditTime", sampleRegistration.EditTime.ToString("yyyy年MM月dd日") }
-            };
-            //检验类别
-            switch (sampleRegistration.InspectApply.InspCategory)
-            {
-                case "首批检验":
-                    dictionary.Add("FirstSelected", "\u25a0");//选中框
-                    break;
-                case "出厂检验":
-                    dictionary.Add("SecondSelected", "\u25a0");//选中框
-                    break;
-            }
-            dictionary.Add("ProductName", sampleRegistration.InspectApply.ProductName);
-            dictionary.Add("Company", sampleRegistration.InspectApply.Company);
-            dictionary.Add("ProductDate", sampleRegistration.ProductDate.ToString("yyyy-MM-dd"));
-            dictionary.Add("BatchNo", sampleRegistration.BatchNo);
-            dictionary.Add("PacketNo", sampleRegistration.PacketNo);
-            dictionary.Add("Quantity", sampleRegistration.Quantity + "\u00d7" + "3");
-            dictionary.Add("TestProductDate", sampleRegistration.ProductDate.ToString("yyyy-MM-dd"));
-            dictionary.Add("TestBatchNo", sampleRegistration.BatchNo);
-            dictionary.Add("TestPacketNo", sampleRegistration.PacketNo);
-            dictionary.Add("TestQuantity", sampleRegistration.Quantity + "");
-            switch (sampleRegistration.TestingItem)
-            {
-                case "全检":
-                    dictionary.Add("TestAll", "\u25a0");
-                    break;
-                case "强制性指标":
-                    dictionary.Add("MandatoryTest", "\u25a0");
-                    break;
-                case "色牢度":
-                    dictionary.Add("ColorFastness", "\u25a0");
-                    break;
-                case "光谱":
-                    dictionary.Add("Spectrum", "\u25a0");
-                    break;
-                case "参考性指标":
-                    dictionary.Add("Reference", "\u25a0");
-                    break;
-                case "单项指标":
-                    dictionary.Add("Single", "\u25a0");
-
-                    break;
-            }
-            dictionary.Add("SingleIndexItem", sampleRegistration.SingleIndexItem ?? "");
-            dictionary.Add("InspectionOrganization", sampleRegistration.InspectionOrganization);
-            dictionary.Add("ProductUsers", sampleRegistration.ProductUsers ?? "");
-            dictionary.Add("EditUser", sampleRegistration.EditUser);
-            dictionary.Add("Telephone", sampleRegistration.Telephone ?? "");
-
-            return dictionary;
-        }
-    }
-}

+ 666 - 0
UniformMaterialManagementSystem/Views/SampleRegistration/SampleRegistrationInputPage.xaml

@@ -0,0 +1,666 @@
+<UserControl
+    x:Class="UniformMaterialManagementSystem.Views.SampleRegistration.SampleRegistrationInputPage"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    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:local="clr-namespace:UniformMaterialManagementSystem.Views.SampleRegistration"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:utils="clr-namespace:UniformMaterialManagementSystem.Utils"
+    d:DesignHeight="450"
+    d:DesignWidth="800"
+    mc:Ignorable="d">
+    <UserControl.Resources>
+        <converters:ContentToBoolConverter x:Key="ContentToBoolConverter" />
+        <!--  定义一个全局的TextBlock样式  -->
+        <Style TargetType="TextBlock">
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="Margin" Value="5" />
+            <Setter Property="VerticalAlignment" Value="Center" />
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <Style TargetType="RadioButton">
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="VerticalAlignment" Value="Center" />
+        </Style>
+        <Style TargetType="ComboBox">
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <Style TargetType="DatePicker">
+            <Setter Property="Height" Value="25" />
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <Style TargetType="TextBox">
+            <Setter Property="Height" Value="25" />
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="VerticalContentAlignment" Value="Center" />
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <ControlTemplate x:Key="CustomColumnHeaderTemplate" TargetType="DataGridColumnHeader">
+            <Border BorderBrush="LightSlateGray" BorderThickness="0,0,1,1">
+                <Grid>
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition />
+                        <ColumnDefinition Width="Auto" />
+                        <ColumnDefinition Width="Auto" />
+                    </Grid.ColumnDefinitions>
+                    <Border
+                        Grid.Column="0"
+                        BorderBrush="#E9ECF1"
+                        BorderThickness="0,0,0,1">
+                        <ContentPresenter
+                            Margin="5,0"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center" />
+                    </Border>
+                    <Path
+                        x:Name="SortArrow"
+                        Grid.Column="1"
+                        Margin="0,0,5,0"
+                        VerticalAlignment="Center"
+                        Data="M 0 0 L 10 0 L 5 5 Z"
+                        Fill="Gray"
+                        Visibility="Collapsed" />
+                    <Thumb
+                        x:Name="PART_RightHeaderGripper"
+                        Grid.Column="2"
+                        Width="1"
+                        Height="25"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        BorderBrush="#E9ECF1"
+                        BorderThickness="1"
+                        Cursor="SizeWE" />
+                </Grid>
+            </Border>
+            <ControlTemplate.Triggers>
+                <Trigger Property="SortDirection" Value="Ascending">
+                    <Setter TargetName="SortArrow" Property="Data" Value="M 0 5 L 10 5 L 5 0 Z" />
+                    <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
+                </Trigger>
+                <Trigger Property="SortDirection" Value="Descending">
+                    <Setter TargetName="SortArrow" Property="Data" Value="M 0 0 L 10 0 L 5 5 Z" />
+                    <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
+                </Trigger>
+            </ControlTemplate.Triggers>
+        </ControlTemplate>
+
+        <Style x:Key="CustomColumnHeaderStyle" TargetType="DataGridColumnHeader">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="Foreground" Value="Black" />
+            <Setter Property="FontWeight" Value="Bold" />
+            <Setter Property="HorizontalContentAlignment" Value="Center" />
+            <Setter Property="VerticalContentAlignment" Value="Center" />
+            <Setter Property="Height" Value="40" />
+            <Setter Property="Template" Value="{StaticResource CustomColumnHeaderTemplate}" />
+        </Style>
+
+        <Style x:Key="CustomRowHeaderStyle" TargetType="DataGridRowHeader">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="Foreground" Value="Black" />
+            <Setter Property="BorderThickness" Value="0,0,1,1" />
+            <Setter Property="BorderBrush" Value="LightSlateGray" />
+        </Style>
+
+        <Style x:Key="CustomRowStyle" TargetType="DataGridRow">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="FontSize" Value="13" />
+            <Setter Property="Height" Value="26" />
+
+            <Style.Triggers>
+                <Trigger Property="AlternationIndex" Value="1">
+                    <Setter Property="Background" Value="WhiteSmoke" />
+                </Trigger>
+                <Trigger Property="IsSelected" Value="True">
+                    <Setter Property="Background" Value="LightBlue" />
+                </Trigger>
+            </Style.Triggers>
+        </Style>
+        <Style
+            x:Key="CustomCellStyle"
+            BasedOn="{StaticResource {x:Type DataGridCell}}"
+            TargetType="DataGridCell">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="HorizontalContentAlignment" Value="Center" />
+            <Setter Property="VerticalContentAlignment" Value="Center" />
+            <Setter Property="Padding" Value="10" />
+            <Style.Triggers>
+                <Trigger Property="IsSelected" Value="True">
+                    <Setter Property="Background" Value="LightBlue" />
+                    <Setter Property="Foreground" Value="Black" />
+                </Trigger>
+            </Style.Triggers>
+        </Style>
+
+    </UserControl.Resources>
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="*" />
+            <ColumnDefinition Width="Auto" />
+            <ColumnDefinition Width="2*" />
+        </Grid.ColumnDefinitions>
+        <Grid Grid.Column="0">
+            <Grid.RowDefinitions>
+                <RowDefinition Height="Auto" />
+                <RowDefinition Height="*" />
+            </Grid.RowDefinitions>
+            <Grid Grid.Row="0">
+                <!--  菜单项  -->
+                <Border
+                    Grid.Row="0"
+                    BorderBrush="Gray"
+                    BorderThickness="1">
+                    <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.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 SaveSampleRegistrationCommand}">
+                                <Button.Template>
+                                    <ControlTemplate>
+                                        <Border
+                                            Width="100"
+                                            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>
+                        </ToolBar>
+                    </ToolBarPanel>
+                </Border>
+            </Grid>
+            <filterDataGrid:FilterDataGrid
+                x:Name="DataGridMain"
+                Grid.Row="1"
+                behaviors:DataGridBehavior.RowNumbers="True"
+                AutoGenerateColumns="False"
+                Background="White"
+                CanUserAddRows="False"
+                CanUserReorderColumns="True"
+                CellStyle="{StaticResource CustomCellStyle}"
+                ColumnHeaderStyle="{StaticResource CustomColumnHeaderStyle}"
+                FilterLanguage="SimplifiedChinese"
+                HeadersVisibility="All"
+                HorizontalGridLinesBrush="LightSlateGray"
+                ItemsSource="{Binding InspectApplies, Mode=TwoWay}"
+                RowHeaderStyle="{StaticResource CustomRowHeaderStyle}"
+                RowStyle="{StaticResource CustomRowStyle}"
+                SelectionMode="Single"
+                ShowRowsCount="True"
+                ShowStatusBar="True"
+                VerticalGridLinesBrush="LightSlateGray">
+
+                <!--  选择行事件  -->
+                <b:Interaction.Triggers>
+                    <b:EventTrigger EventName="MouseDoubleClick">
+                        <b:InvokeCommandAction Command="{Binding MouseDoubleClickCommand}" CommandParameter="{Binding ElementName=DataGridMain, Path=SelectedItem}" />
+                    </b:EventTrigger>
+                </b:Interaction.Triggers>
+
+                <control:FilterDataGrid.Resources>
+                    <!--  非编辑模式下文本居中的样式  -->
+                    <Style x:Key="TextColumnElementStyle" TargetType="TextBlock">
+                        <Setter Property="HorizontalAlignment" Value="Center" />
+                        <Setter Property="VerticalAlignment" Value="Center" />
+                        <Setter Property="TextAlignment" Value="Center" />
+                    </Style>
+
+                    <!--  编辑模式下文本居中的样式  -->
+                    <Style x:Key="TextColumnEditingElementStyle" TargetType="TextBox">
+                        <Setter Property="HorizontalAlignment" Value="Stretch" />
+                        <Setter Property="VerticalAlignment" Value="Stretch" />
+                        <Setter Property="VerticalContentAlignment" Value="Center" />
+                    </Style>
+
+                    <Style x:Key="CheckBoxColumnElementStyle" TargetType="CheckBox">
+                        <Setter Property="HorizontalAlignment" Value="Center" />
+                        <Setter Property="VerticalAlignment" Value="Center" />
+                        <Setter Property="IsEnabled" Value="False" />
+                    </Style>
+                </control:FilterDataGrid.Resources>
+
+                <control:FilterDataGrid.Columns>
+                    <control:FilterDataGridTextColumn
+                        Width="300"
+                        Binding="{Binding ApplyNo}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="申请表编号"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="120"
+                        Binding="{Binding InspCategory}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="检验类别"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="200"
+                        Binding="{Binding ProductName}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="产品名称"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="200"
+                        Binding="{Binding Company}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="生产企业"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="200"
+                        Binding="{Binding BatchNo}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="材料批号"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="100"
+                        Binding="{Binding InspQuantity}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="报检数量"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="150"
+                        Binding="{Binding InspDate, StringFormat=yyyy-MM-dd}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="申请检验日期"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="100"
+                        Binding="{Binding ApplyUser}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="申请人"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+
+                </control:FilterDataGrid.Columns>
+            </filterDataGrid:FilterDataGrid>
+        </Grid>
+
+        <GridSplitter
+            Grid.Column="1"
+            Width="2"
+            HorizontalAlignment="Stretch" />
+        <Grid Grid.Column="2" Background="White">
+            <ScrollViewer>
+                <Grid Background="White">
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="50" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="45" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="80" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="165" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+
+                    </Grid.RowDefinitions>
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition Width="2*" />
+                        <ColumnDefinition Width="3*" />
+                        <ColumnDefinition Width="3*" />
+                        <ColumnDefinition Width="3*" />
+                        <ColumnDefinition Width="*" />
+                    </Grid.ColumnDefinitions>
+
+                    <TextBlock
+                        Grid.Row="0"
+                        Grid.Column="0"
+                        Grid.ColumnSpan="5"
+                        HorizontalAlignment="Center"
+                        VerticalAlignment="Center"
+                        FontSize="25"
+                        Text="被装材料产品抽样信息登记表" />
+                    <TextBlock
+                        Grid.Row="1"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="编号:" />
+                    <TextBlock
+                        Grid.Row="1"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Text="{Binding SampleNo}" />
+                    <TextBlock
+                        Grid.Row="2"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*单位:" />
+                    <TextBox
+                        Grid.Row="2"
+                        Grid.Column="1"
+                        Text="{Binding Department, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="2"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*时间:" />
+                    <DatePicker
+                        Grid.Row="2"
+                        Grid.Column="3"
+                        Text="{Binding EditTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="3"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="类别:" />
+                    <Grid
+                        Grid.Row="3"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Background="White"
+                        IsEnabled="False">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="*" />
+                            <ColumnDefinition Width="*" />
+                        </Grid.ColumnDefinitions>
+                        <TextBox
+                            x:Name="InspectCategory"
+                            Grid.Column="0"
+                            Text="{Binding InspectApply.InspCategory}"
+                            Visibility="Collapsed" />
+                        <RadioButton
+                            x:Name="FirstSelected"
+                            Grid.Column="0"
+                            HorizontalAlignment="Center"
+                            Content="首批检验"
+                            GroupName="CategoryGroup"
+                            IsChecked="{Binding InspectApply.InspCategory, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=首批检验}" />
+                        <RadioButton
+                            x:Name="SecondSelected"
+                            Grid.Column="1"
+                            HorizontalAlignment="Center"
+                            Content="出厂检验"
+                            GroupName="CategoryGroup"
+                            IsChecked="{Binding InspectApply.InspCategory, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=出厂检验}" />
+                    </Grid>
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="样品名称:"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="1"
+                        Text="{Binding InspectApply.Material.Name}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="生产企业:"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="3"
+                        Text="{Binding InspectApply.Company}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="5"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="样品生产日期:"
+                        TextWrapping="Wrap" />
+                    <DatePicker
+                        Grid.Row="5"
+                        Grid.Column="1"
+                        Text="{Binding ProductDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="5"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*批号:" />
+                    <TextBlock
+                        Grid.Row="5"
+                        Grid.Column="3"
+                        Text="{Binding BatchNo}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="6"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*包号:" />
+                    <TextBox
+                        Grid.Row="6"
+                        Grid.Column="1"
+                        Text="{Binding PacketNo, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="6"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="数量:" />
+                    <TextBox
+                        Grid.Row="6"
+                        Grid.Column="3"
+                        Text="{Binding Quantity, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="7"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="检测项目:"
+                        TextWrapping="Wrap" />
+                    <GroupBox
+                        Grid.Row="7"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        VerticalAlignment="Center"
+                        Header="检测项目">
+
+                        <WrapPanel
+                            AllowDrop="True"
+                            FlowDirection="LeftToRight"
+                            Orientation="Horizontal">
+                            <RadioButton
+                                x:Name="TestAllRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="全检"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=全检}" />
+                            <RadioButton
+                                x:Name="MandatoryTestRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="强制性指标"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=强制性指标}" />
+                            <RadioButton
+                                x:Name="ColorFastnessRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="色牢度"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=色牢度}" />
+                            <RadioButton
+                                x:Name="SpectrumRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="光谱"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=光谱}" />
+                            <RadioButton
+                                x:Name="ReferenceRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="参考性指标"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=参考性指标}" />
+                            <RadioButton
+                                x:Name="SingleRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="单项指标"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=单项指标}" />
+                            <TextBox Width="200" Text="{Binding SingleIndexItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                        </WrapPanel>
+                    </GroupBox>
+                    <Button
+                        Grid.Row="8"
+                        Grid.Column="1"
+                        HorizontalAlignment="Left"
+                        Command="{Binding RandomInspectionOrgCommand}">
+                        <Button.Template>
+                            <ControlTemplate>
+                                <Border
+                                    Width="140"
+                                    Height="30"
+                                    Background="{TemplateBinding Background}"
+                                    CornerRadius="5">
+                                    <StackPanel
+                                        HorizontalAlignment="Center"
+                                        VerticalAlignment="Center"
+                                        Orientation="Horizontal">
+                                        <TextBlock VerticalAlignment="Center" Text="抽取检测机构" />
+                                        <TextBlock
+                                            HorizontalAlignment="Center"
+                                            VerticalAlignment="Center"
+                                            FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                            FontSize="20"
+                                            Text="{x:Static utils:RegularFontUtil.Tap_Double_24}" />
+                                    </StackPanel>
+                                </Border>
+                                <ControlTemplate.Triggers>
+                                    <Trigger Property="IsMouseOver" Value="True">
+                                        <Setter Property="Background" Value="LightGray" />
+                                    </Trigger>
+                                </ControlTemplate.Triggers>
+                            </ControlTemplate>
+                        </Button.Template>
+                    </Button>
+                    <TextBlock
+                        Grid.Row="8"
+                        Grid.Column="2"
+                        Grid.ColumnSpan="2"
+                        HorizontalAlignment="Left"
+                        Foreground="DimGray"
+                        Text="{Binding RandomTip, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="9"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*检测机构:"
+                        TextWrapping="Wrap" />
+                    <TextBox
+                        Grid.Row="9"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Height="150"
+                        AcceptsReturn="True"
+                        Text="{Binding InspectionOrganization, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                        TextWrapping="Wrap"
+                        VerticalScrollBarVisibility="Auto" />
+                    <TextBlock
+                        Grid.Row="10"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*生产企业人员:"
+                        TextWrapping="Wrap" />
+                    <TextBox
+                        Grid.Row="10"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Text="{Binding ProductUsers, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="11"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*承办人:"
+                        TextWrapping="Wrap" />
+                    <TextBox
+                        Grid.Row="11"
+                        Grid.Column="1"
+                        Text="{Binding EditUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="11"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*联系电话:" />
+                    <TextBox
+                        Grid.Row="11"
+                        Grid.Column="3"
+                        Text="{Binding Telephone, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                </Grid>
+            </ScrollViewer>
+
+
+        </Grid>
+
+    </Grid>
+</UserControl>

+ 19 - 0
UniformMaterialManagementSystem/Views/SampleRegistration/SampleRegistrationInputPage.xaml.cs

@@ -0,0 +1,19 @@
+using Microsoft.Extensions.DependencyInjection;
+using System.Windows.Controls;
+using UniformMaterialManagementSystem.ViewModels;
+
+namespace UniformMaterialManagementSystem.Views.SampleRegistration
+{
+    /// <summary>
+    /// SampleRegistrationInputPage.xaml 的交互逻辑
+    /// </summary>
+    public partial class SampleRegistrationInputPage : UserControl
+    {
+        public SampleRegistrationInputPage()
+        {
+            InitializeComponent();
+
+            this.DataContext = App.Current.Services.GetService<SampleRegistrationInputPageViewModel>();
+        }
+    }
+}

+ 741 - 0
UniformMaterialManagementSystem/Views/SampleRegistration/SampleRegistrationManagePage.xaml

@@ -0,0 +1,741 @@
+<UserControl
+    x:Class="UniformMaterialManagementSystem.Views.SampleRegistration.SampleRegistrationManagePage"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    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:local="clr-namespace:UniformMaterialManagementSystem.Views"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:utils="clr-namespace:UniformMaterialManagementSystem.Utils"
+    d:DesignHeight="450"
+    d:DesignWidth="800"
+    mc:Ignorable="d">
+
+    <UserControl.Resources>
+        <converters:ContentToBoolConverter x:Key="ContentToBoolConverter" />
+        <!--  定义一个全局的TextBlock样式  -->
+        <Style TargetType="TextBlock">
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="Margin" Value="5" />
+            <Setter Property="VerticalAlignment" Value="Center" />
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <Style TargetType="RadioButton">
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="VerticalAlignment" Value="Center" />
+        </Style>
+        <Style TargetType="ComboBox">
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <Style TargetType="DatePicker">
+            <Setter Property="Height" Value="25" />
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <Style TargetType="TextBox">
+            <Setter Property="Height" Value="25" />
+            <Setter Property="FontSize" Value="14" />
+            <Setter Property="VerticalContentAlignment" Value="Center" />
+            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
+        </Style>
+        <ControlTemplate x:Key="CustomColumnHeaderTemplate" TargetType="DataGridColumnHeader">
+            <Border BorderBrush="LightSlateGray" BorderThickness="0,0,1,1">
+                <Grid>
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition />
+                        <ColumnDefinition Width="Auto" />
+                        <ColumnDefinition Width="Auto" />
+                    </Grid.ColumnDefinitions>
+                    <Border
+                        Grid.Column="0"
+                        BorderBrush="#E9ECF1"
+                        BorderThickness="0,0,0,1">
+                        <ContentPresenter
+                            Margin="5,0"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center" />
+                    </Border>
+                    <Path
+                        x:Name="SortArrow"
+                        Grid.Column="1"
+                        Margin="0,0,5,0"
+                        VerticalAlignment="Center"
+                        Data="M 0 0 L 10 0 L 5 5 Z"
+                        Fill="Gray"
+                        Visibility="Collapsed" />
+                    <Thumb
+                        x:Name="PART_RightHeaderGripper"
+                        Grid.Column="2"
+                        Width="1"
+                        Height="25"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        BorderBrush="#E9ECF1"
+                        BorderThickness="1"
+                        Cursor="SizeWE" />
+                </Grid>
+            </Border>
+            <ControlTemplate.Triggers>
+                <Trigger Property="SortDirection" Value="Ascending">
+                    <Setter TargetName="SortArrow" Property="Data" Value="M 0 5 L 10 5 L 5 0 Z" />
+                    <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
+                </Trigger>
+                <Trigger Property="SortDirection" Value="Descending">
+                    <Setter TargetName="SortArrow" Property="Data" Value="M 0 0 L 10 0 L 5 5 Z" />
+                    <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
+                </Trigger>
+            </ControlTemplate.Triggers>
+        </ControlTemplate>
+
+        <Style x:Key="CustomColumnHeaderStyle" TargetType="DataGridColumnHeader">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="Foreground" Value="Black" />
+            <Setter Property="FontWeight" Value="Bold" />
+            <Setter Property="HorizontalContentAlignment" Value="Center" />
+            <Setter Property="VerticalContentAlignment" Value="Center" />
+            <Setter Property="Height" Value="40" />
+            <Setter Property="Template" Value="{StaticResource CustomColumnHeaderTemplate}" />
+        </Style>
+
+        <Style x:Key="CustomRowHeaderStyle" TargetType="DataGridRowHeader">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="Foreground" Value="Black" />
+            <Setter Property="BorderThickness" Value="0,0,1,1" />
+            <Setter Property="BorderBrush" Value="LightSlateGray" />
+        </Style>
+
+        <Style x:Key="CustomRowStyle" TargetType="DataGridRow">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="FontSize" Value="13" />
+            <Setter Property="Height" Value="26" />
+
+            <Style.Triggers>
+                <Trigger Property="AlternationIndex" Value="1">
+                    <Setter Property="Background" Value="WhiteSmoke" />
+                </Trigger>
+                <Trigger Property="IsSelected" Value="True">
+                    <Setter Property="Background" Value="LightBlue" />
+                </Trigger>
+            </Style.Triggers>
+        </Style>
+        <Style
+            x:Key="CustomCellStyle"
+            BasedOn="{StaticResource {x:Type DataGridCell}}"
+            TargetType="DataGridCell">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="HorizontalContentAlignment" Value="Center" />
+            <Setter Property="VerticalContentAlignment" Value="Center" />
+            <Setter Property="Padding" Value="10" />
+            <Style.Triggers>
+                <Trigger Property="IsSelected" Value="True">
+                    <Setter Property="Background" Value="LightBlue" />
+                    <Setter Property="Foreground" Value="Black" />
+                </Trigger>
+            </Style.Triggers>
+        </Style>
+
+    </UserControl.Resources>
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="*" />
+            <ColumnDefinition Width="Auto" />
+            <ColumnDefinition Width="2*" />
+        </Grid.ColumnDefinitions>
+        <Grid Grid.Column="0">
+            <Grid.RowDefinitions>
+                <RowDefinition Height="Auto" />
+                <RowDefinition Height="*" />
+            </Grid.RowDefinitions>
+            <Grid Grid.Row="0">
+                <!--  菜单项  -->
+                <Border
+                    Grid.Row="0"
+                    BorderBrush="Gray"
+                    BorderThickness="1">
+                    <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.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 AddSampleRegistrationCommand}">
+                                <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 Command="{Binding SaveSampleRegistrationCommand}">
+                                <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>-->
+                            <Button Command="{Binding RemoveSampleRegistrationCommand}">
+                                <Button.Template>
+                                    <ControlTemplate>
+                                        <Border
+                                            Width="70"
+                                            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 ExportSampleRegistrationCommand}">
+                                <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>
+                </Border>
+            </Grid>
+            <filterDataGrid:FilterDataGrid
+                x:Name="DataGridMain"
+                Grid.Row="1"
+                behaviors:DataGridBehavior.RowNumbers="True"
+                AutoGenerateColumns="False"
+                Background="White"
+                CanUserAddRows="False"
+                CanUserReorderColumns="True"
+                CellStyle="{StaticResource CustomCellStyle}"
+                ColumnHeaderStyle="{StaticResource CustomColumnHeaderStyle}"
+                FilterLanguage="SimplifiedChinese"
+                HeadersVisibility="All"
+                HorizontalGridLinesBrush="LightSlateGray"
+                ItemsSource="{Binding SampleRegistrations, Mode=TwoWay}"
+                RowHeaderStyle="{StaticResource CustomRowHeaderStyle}"
+                RowStyle="{StaticResource CustomRowStyle}"
+                SelectedItem="{Binding SelectedSampleRegistration, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                SelectionChanged="DataGridMain_OnSelectionChanged"
+                SelectionMode="Single"
+                ShowRowsCount="True"
+                ShowStatusBar="True"
+                VerticalGridLinesBrush="LightSlateGray">
+
+                <!--  选择行事件  -->
+                <!--<b:Interaction.Triggers>
+                    <b:EventTrigger EventName="SelectionChanged">
+                        <b:InvokeCommandAction Command="{Binding SampleRegistrationSelectionChangedCommand}" CommandParameter="{Binding ElementName=DataGridMain, Path=SelectedItem}" />
+                    </b:EventTrigger>
+                </b:Interaction.Triggers>-->
+
+                <control:FilterDataGrid.Resources>
+                    <!--  非编辑模式下文本居中的样式  -->
+                    <Style x:Key="TextColumnElementStyle" TargetType="TextBlock">
+                        <Setter Property="HorizontalAlignment" Value="Center" />
+                        <Setter Property="VerticalAlignment" Value="Center" />
+                        <Setter Property="TextAlignment" Value="Center" />
+                    </Style>
+
+                    <!--  编辑模式下文本居中的样式  -->
+                    <Style x:Key="TextColumnEditingElementStyle" TargetType="TextBox">
+                        <Setter Property="HorizontalAlignment" Value="Stretch" />
+                        <Setter Property="VerticalAlignment" Value="Stretch" />
+                        <Setter Property="VerticalContentAlignment" Value="Center" />
+                    </Style>
+
+                    <Style x:Key="CheckBoxColumnElementStyle" TargetType="CheckBox">
+                        <Setter Property="HorizontalAlignment" Value="Center" />
+                        <Setter Property="VerticalAlignment" Value="Center" />
+                        <Setter Property="IsEnabled" Value="False" />
+                    </Style>
+                </control:FilterDataGrid.Resources>
+
+                <control:FilterDataGrid.Columns>
+                    <DataGridTextColumn
+                        Width="60"
+                        Binding="{Binding Year}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="工作年度"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="300"
+                        Binding="{Binding SampleNo}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="抽样登记表编号"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="200"
+                        Binding="{Binding InspectApply.Company}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="生产企业"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="120"
+                        Binding="{Binding EditTime, StringFormat=yyyy-MM-dd}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="抽样时间"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="200"
+                        Binding="{Binding BatchNo}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="批号"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+                    <control:FilterDataGridTextColumn
+                        Width="120"
+                        Binding="{Binding PacketNo}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="包号"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+
+                    <control:FilterDataGridTextColumn
+                        Width="100"
+                        Binding="{Binding EditUser}"
+                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
+                        ElementStyle="{StaticResource TextColumnElementStyle}"
+                        Header="承办人"
+                        IsColumnFiltered="True"
+                        IsReadOnly="True" />
+
+                </control:FilterDataGrid.Columns>
+            </filterDataGrid:FilterDataGrid>
+        </Grid>
+
+        <GridSplitter
+            Grid.Column="1"
+            Width="2"
+            HorizontalAlignment="Stretch" />
+        <Grid Grid.Column="2" Background="White">
+            <ScrollViewer>
+                <Grid Background="White">
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="50" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="45" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="80" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="150" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+
+                    </Grid.RowDefinitions>
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition Width="2*" />
+                        <ColumnDefinition Width="3*" />
+                        <ColumnDefinition Width="3*" />
+                        <ColumnDefinition Width="3*" />
+                        <ColumnDefinition Width="*" />
+                    </Grid.ColumnDefinitions>
+
+                    <TextBlock
+                        Grid.Row="0"
+                        Grid.Column="0"
+                        Grid.ColumnSpan="5"
+                        HorizontalAlignment="Center"
+                        VerticalAlignment="Center"
+                        FontSize="25"
+                        Text="被装材料产品抽样信息登记表" />
+                    <TextBlock
+                        Grid.Row="1"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="编号:" />
+                    <TextBlock
+                        Grid.Row="1"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Text="{Binding SelectedSampleRegistration.SampleNo}" />
+                    <TextBlock
+                        Grid.Row="2"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*单位:" />
+                    <TextBox
+                        Grid.Row="2"
+                        Grid.Column="1"
+                        IsReadOnly="True"
+                        Text="{Binding SelectedSampleRegistration.Department, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="2"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*时间:" />
+                    <DatePicker
+                        Grid.Row="2"
+                        Grid.Column="3"
+                        IsEnabled="False"
+                        Text="{Binding SelectedSampleRegistration.EditTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="3"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="类别:" />
+                    <Grid
+                        Grid.Row="3"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Background="White"
+                        IsEnabled="False">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="*" />
+                            <ColumnDefinition Width="*" />
+                        </Grid.ColumnDefinitions>
+                        <RadioButton
+                            x:Name="FirstSelected"
+                            Grid.Column="0"
+                            HorizontalAlignment="Center"
+                            Content="首批检验"
+                            GroupName="CategoryGroup"
+                            IsChecked="{Binding SelectedSampleRegistration.InspectApply.InspCategory, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=首批检验}" />
+                        <RadioButton
+                            x:Name="SecondSelected"
+                            Grid.Column="1"
+                            HorizontalAlignment="Center"
+                            Content="出厂检验"
+                            GroupName="CategoryGroup"
+                            IsChecked="{Binding SelectedSampleRegistration.InspectApply.InspCategory, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=出厂检验}" />
+                    </Grid>
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="样品名称:"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="1"
+                        Text="{Binding SelectedSampleRegistration.InspectApply.Material.Name}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="生产企业:"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="4"
+                        Grid.Column="3"
+                        Text="{Binding SelectedSampleRegistration.InspectApply.Company}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="5"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="样品生产日期:"
+                        TextWrapping="Wrap" />
+                    <DatePicker
+                        Grid.Row="5"
+                        Grid.Column="1"
+                        IsEnabled="False"
+                        Text="{Binding SelectedSampleRegistration.EditTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="5"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*批号:" />
+                    <TextBlock
+                        Grid.Row="5"
+                        Grid.Column="3"
+                        Text="{Binding SelectedSampleRegistration.BatchNo}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="6"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="包号:" />
+                    <TextBox
+                        Grid.Row="6"
+                        Grid.Column="1"
+                        IsReadOnly="True"
+                        Text="{Binding SelectedSampleRegistration.PacketNo, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="6"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="数量:" />
+                    <TextBox
+                        Grid.Row="6"
+                        Grid.Column="3"
+                        IsReadOnly="True"
+                        Text="{Binding SelectedSampleRegistration.Quantity, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="7"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="检测项目:"
+                        TextWrapping="Wrap" />
+                    <GroupBox
+                        Grid.Row="7"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        VerticalAlignment="Center"
+                        Header="检测项目"
+                        IsEnabled="False">
+
+                        <WrapPanel
+                            AllowDrop="True"
+                            FlowDirection="LeftToRight"
+                            Orientation="Horizontal">
+                            <RadioButton
+                                x:Name="TestAllRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="全检"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding SelectedSampleRegistration.TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=全检}" />
+                            <RadioButton
+                                x:Name="MandatoryTestRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="强制性指标"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding SelectedSampleRegistration.TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=强制性指标}" />
+                            <RadioButton
+                                x:Name="ColorFastnessRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="色牢度"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding SelectedSampleRegistration.TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=色牢度}" />
+                            <RadioButton
+                                x:Name="SpectrumRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="光谱"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding SelectedSampleRegistration.TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=光谱}" />
+                            <RadioButton
+                                x:Name="ReferenceRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="参考性指标"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding SelectedSampleRegistration.TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=参考性指标}" />
+                            <RadioButton
+                                x:Name="SingleRadioButton"
+                                Padding="10,0,10,0"
+                                VerticalContentAlignment="Center"
+                                Content="单项指标"
+                                GroupName="TestingItemGroup"
+                                IsChecked="{Binding SelectedSampleRegistration.TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=单项指标}" />
+                            <TextBox Width="200" Text="{Binding SelectedSampleRegistration.SingleIndexItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                        </WrapPanel>
+                    </GroupBox>
+                    <Button
+                        Grid.Row="8"
+                        Grid.Column="1"
+                        HorizontalAlignment="Left"
+                        Command="{Binding RandomInspectionOrgCommand}"
+                        Foreground="Gray"
+                        IsEnabled="False">
+                        <Button.Template>
+                            <ControlTemplate>
+                                <Border
+                                    Width="140"
+                                    Height="30"
+                                    Background="{TemplateBinding Background}"
+                                    CornerRadius="5">
+                                    <StackPanel
+                                        HorizontalAlignment="Center"
+                                        VerticalAlignment="Center"
+                                        Orientation="Horizontal">
+                                        <TextBlock VerticalAlignment="Center" Text="抽取检测机构" />
+                                        <TextBlock
+                                            HorizontalAlignment="Center"
+                                            VerticalAlignment="Center"
+                                            FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                            FontSize="20"
+                                            Text="{x:Static utils:RegularFontUtil.Tap_Double_24}" />
+                                    </StackPanel>
+                                </Border>
+                                <ControlTemplate.Triggers>
+                                    <Trigger Property="IsMouseOver" Value="True">
+                                        <Setter Property="Background" Value="LightGray" />
+                                    </Trigger>
+                                </ControlTemplate.Triggers>
+                            </ControlTemplate>
+                        </Button.Template>
+                    </Button>
+                    <TextBlock
+                        Grid.Row="8"
+                        Grid.Column="2"
+                        Grid.ColumnSpan="2"
+                        HorizontalAlignment="Left"
+                        Foreground="DimGray"
+                        Text="{Binding SelectedSampleRegistration.RandomTip, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                        TextWrapping="Wrap" />
+                    <TextBlock
+                        Grid.Row="9"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="检测机构:"
+                        TextWrapping="Wrap" />
+                    <TextBox
+                        Grid.Row="9"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        Height="150"
+                        AcceptsReturn="True"
+                        IsReadOnly="True"
+                        Text="{Binding SelectedSampleRegistration.InspectionOrganization, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+                        TextWrapping="Wrap"
+                        VerticalScrollBarVisibility="Auto" />
+                    <TextBlock
+                        Grid.Row="10"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*生产企业人员:"
+                        TextWrapping="Wrap" />
+                    <TextBox
+                        Grid.Row="10"
+                        Grid.Column="1"
+                        Grid.ColumnSpan="3"
+                        IsReadOnly="True"
+                        Text="{Binding SelectedSampleRegistration.ProductUsers, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="11"
+                        Grid.Column="0"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*承办人:"
+                        TextWrapping="Wrap" />
+                    <TextBox
+                        Grid.Row="11"
+                        Grid.Column="1"
+                        IsReadOnly="True"
+                        Text="{Binding SelectedSampleRegistration.EditUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                    <TextBlock
+                        Grid.Row="11"
+                        Grid.Column="2"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Center"
+                        Text="*联系电话:" />
+                    <TextBox
+                        Grid.Row="11"
+                        Grid.Column="3"
+                        IsReadOnly="True"
+                        Text="{Binding SelectedSampleRegistration.Telephone, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                </Grid>
+            </ScrollViewer>
+
+
+        </Grid>
+
+    </Grid>
+</UserControl>

+ 87 - 0
UniformMaterialManagementSystem/Views/SampleRegistration/SampleRegistrationManagePage.xaml.cs

@@ -0,0 +1,87 @@
+using Microsoft.Extensions.DependencyInjection;
+using System.Collections.ObjectModel;
+using System.Windows.Controls;
+using UniformMaterialManagementSystem.Models;
+using UniformMaterialManagementSystem.ViewModels;
+
+namespace UniformMaterialManagementSystem.Views.SampleRegistration
+{
+    /// <summary>
+    /// SampleRegistrationPage.xaml 的交互逻辑
+    /// </summary>
+    public partial class SampleRegistrationManagePage : UserControl
+    {
+        public SampleRegistrationManagePage()
+        {
+            InitializeComponent();
+
+            this.DataContext = App.Current.Services.GetService<SampleRegistrationManagePageViewModel>();
+        }
+
+        //private void RadioButton_Checked(object sender, System.Windows.RoutedEventArgs e)
+        //{
+        //    var testingItem = sender as RadioButton;
+        //    if (testingItem != null && testingItem.Content != null)
+        //    {
+        //        var testingItemText = testingItem.Content.ToString();
+        //        TestingItemTextBox.Text = testingItemText == null ? "" : testingItemText;
+        //    }
+        //}
+
+        private void DataGridMain_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            var itemsSource = DataGridMain.ItemsSource as ObservableCollection<SampleRegistrationModel>;
+            var count = e.RemovedItems.Count;
+
+            //判断移除选中的行是否需要保存
+            if (count == 0) return;
+            SampleRegistrationModel? preSampleRegistration = e.RemovedItems[0] as SampleRegistrationModel;
+            if (preSampleRegistration == null) return;
+
+            //using SqliteContext context = new();
+            //var sampleRegistration = context.SampleRegistrations.Where(x => x.Guid == preSampleRegistration.Guid).ToList().FirstOrDefault();
+            //if (sampleRegistration == null)//新增行
+            //{
+            //    MessageBox.Show("数据已新增,请保存后切换行!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+
+            //    //选中原来行
+            //    //e.AddedItems.Clear();
+            //    DataGridMain.SelectedItem = preSampleRegistration;
+            //}
+            //else
+            //{
+            //    //判断是否修改
+            //    IDataBaseService<SampleRegistration> service = new DataBaseService<SampleRegistration>(context);
+            //    ModifySampleRegistrationFromModel(sampleRegistration, preSampleRegistration);
+            //    var state = service.Entry(sampleRegistration);
+            //    if (state == EntityState.Modified)
+            //    {
+            //        MessageBox.Show("数据已修改,请保存后切换行!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+
+            //        //选中原来行
+            //        //if (e.AddedItems.Count > 0)
+            //        //{
+            //        //    e.AddedItems[0] = preSampleRegistration;
+            //        //}
+            //        DataGridMain.SelectedItem = preSampleRegistration;
+            //    }
+            //}
+        }
+
+        private void ModifySampleRegistrationFromModel(Entities.SampleRegistration sampleRegistration, SampleRegistrationModel model)
+        {
+            sampleRegistration.Department = model.Department;
+            sampleRegistration.EditTime = model.EditTime;
+            sampleRegistration.ProductDate = model.ProductDate;
+            sampleRegistration.BatchNo = model.BatchNo;
+            sampleRegistration.PacketNo = model.PacketNo;
+            sampleRegistration.Quantity = model.Quantity;
+            sampleRegistration.TestingItem = model.TestingItem;
+            sampleRegistration.SingleIndexItem = model.SingleIndexItem;
+            sampleRegistration.InspectionOrganization = model.InspectionOrganization;
+            sampleRegistration.ProductUsers = model.ProductUsers;
+            sampleRegistration.EditUser = model.EditUser;
+            sampleRegistration.Telephone = model.Telephone;
+        }
+    }
+}

+ 9 - 717
UniformMaterialManagementSystem/Views/SampleRegistrationPage.xaml

@@ -2,730 +2,22 @@
     x:Class="UniformMaterialManagementSystem.Views.SampleRegistrationPage"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-    xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
-    xmlns:behaviors="clr-namespace:UniformMaterialManagementSystem.Behaviors"
-    xmlns:control="http://FilterDataGrid.Control.com/2024"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-    xmlns:filterDataGrid="http://FilterDataGrid.Control.com/2024"
     xmlns:local="clr-namespace:UniformMaterialManagementSystem.Views"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-    xmlns:utils="clr-namespace:UniformMaterialManagementSystem.Utils"
+    xmlns:sample="clr-namespace:UniformMaterialManagementSystem.Views.SampleRegistration"
     d:DesignHeight="450"
     d:DesignWidth="800"
     mc:Ignorable="d">
-
-    <UserControl.Resources>
-        <!--  定义一个全局的TextBlock样式  -->
-        <Style TargetType="TextBlock">
-            <Setter Property="FontSize" Value="14" />
-            <Setter Property="Margin" Value="5" />
-            <Setter Property="VerticalAlignment" Value="Center" />
-            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
-        </Style>
-        <Style TargetType="RadioButton">
-            <Setter Property="FontSize" Value="14" />
-            <Setter Property="VerticalAlignment" Value="Center" />
-        </Style>
-        <Style TargetType="ComboBox">
-            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
-        </Style>
-        <Style TargetType="DatePicker">
-            <Setter Property="Height" Value="25" />
-            <Setter Property="FontSize" Value="14" />
-            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
-        </Style>
-        <Style TargetType="TextBox">
-            <Setter Property="Height" Value="25" />
-            <Setter Property="FontSize" Value="14" />
-            <Setter Property="VerticalContentAlignment" Value="Center" />
-            <Setter Property="Validation.ErrorTemplate" Value="{StaticResource ValidationErrorTemplate}" />
-        </Style>
-        <ControlTemplate x:Key="CustomColumnHeaderTemplate" TargetType="DataGridColumnHeader">
-            <Border BorderBrush="LightSlateGray" BorderThickness="0,0,1,1">
-                <Grid>
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition />
-                        <ColumnDefinition Width="Auto" />
-                        <ColumnDefinition Width="Auto" />
-                    </Grid.ColumnDefinitions>
-                    <Border
-                        Grid.Column="0"
-                        BorderBrush="#E9ECF1"
-                        BorderThickness="0,0,0,1">
-                        <ContentPresenter
-                            Margin="5,0"
-                            HorizontalAlignment="Center"
-                            VerticalAlignment="Center" />
-                    </Border>
-                    <Path
-                        x:Name="SortArrow"
-                        Grid.Column="1"
-                        Margin="0,0,5,0"
-                        VerticalAlignment="Center"
-                        Data="M 0 0 L 10 0 L 5 5 Z"
-                        Fill="Gray"
-                        Visibility="Collapsed" />
-                    <Thumb
-                        x:Name="PART_RightHeaderGripper"
-                        Grid.Column="2"
-                        Width="1"
-                        Height="25"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        BorderBrush="#E9ECF1"
-                        BorderThickness="1"
-                        Cursor="SizeWE" />
-                </Grid>
-            </Border>
-            <ControlTemplate.Triggers>
-                <Trigger Property="SortDirection" Value="Ascending">
-                    <Setter TargetName="SortArrow" Property="Data" Value="M 0 5 L 10 5 L 5 0 Z" />
-                    <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
-                </Trigger>
-                <Trigger Property="SortDirection" Value="Descending">
-                    <Setter TargetName="SortArrow" Property="Data" Value="M 0 0 L 10 0 L 5 5 Z" />
-                    <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
-                </Trigger>
-            </ControlTemplate.Triggers>
-        </ControlTemplate>
-
-        <Style x:Key="CustomColumnHeaderStyle" TargetType="DataGridColumnHeader">
-            <Setter Property="Background" Value="White" />
-            <Setter Property="Foreground" Value="Black" />
-            <Setter Property="FontWeight" Value="Bold" />
-            <Setter Property="HorizontalContentAlignment" Value="Center" />
-            <Setter Property="VerticalContentAlignment" Value="Center" />
-            <Setter Property="Height" Value="40" />
-            <Setter Property="Template" Value="{StaticResource CustomColumnHeaderTemplate}" />
-        </Style>
-
-        <Style x:Key="CustomRowHeaderStyle" TargetType="DataGridRowHeader">
-            <Setter Property="Background" Value="White" />
-            <Setter Property="Foreground" Value="Black" />
-            <Setter Property="BorderThickness" Value="0,0,1,1" />
-            <Setter Property="BorderBrush" Value="LightSlateGray" />
-        </Style>
-
-        <Style x:Key="CustomRowStyle" TargetType="DataGridRow">
-            <Setter Property="Background" Value="White" />
-            <Setter Property="FontSize" Value="13" />
-            <Setter Property="Height" Value="26" />
-
-            <Style.Triggers>
-                <Trigger Property="AlternationIndex" Value="1">
-                    <Setter Property="Background" Value="WhiteSmoke" />
-                </Trigger>
-                <Trigger Property="IsSelected" Value="True">
-                    <Setter Property="Background" Value="LightBlue" />
-                </Trigger>
-            </Style.Triggers>
-        </Style>
-        <Style
-            x:Key="CustomCellStyle"
-            BasedOn="{StaticResource {x:Type DataGridCell}}"
-            TargetType="DataGridCell">
-            <Setter Property="Background" Value="White" />
-            <Setter Property="HorizontalContentAlignment" Value="Center" />
-            <Setter Property="VerticalContentAlignment" Value="Center" />
-            <Setter Property="Padding" Value="10" />
-            <Style.Triggers>
-                <Trigger Property="IsSelected" Value="True">
-                    <Setter Property="Background" Value="LightBlue" />
-                    <Setter Property="Foreground" Value="Black" />
-                </Trigger>
-            </Style.Triggers>
-        </Style>
-
-    </UserControl.Resources>
     <Grid>
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="*" />
-            <ColumnDefinition Width="Auto" />
-            <ColumnDefinition Width="2*" />
-        </Grid.ColumnDefinitions>
-        <Grid Grid.Column="0">
-            <Grid.RowDefinitions>
-                <RowDefinition Height="Auto" />
-                <RowDefinition Height="*" />
-            </Grid.RowDefinitions>
-            <Grid Grid.Row="0">
-                <!--  菜单项  -->
-                <Border
-                    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">
-
-                            <TextBlock Text="工作年度:" />
-                            <ComboBox
-                                Width="120"
-                                Height="23"
-                                IsEditable="True"
-                                ItemsSource="{Binding Years}"
-                                SelectedItem="{Binding SelectedYear, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-
-                        </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 AddSampleRegistrationCommand}">
-                                    <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 Command="{Binding SaveSampleRegistrationCommand}">
-                                    <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 ExportSampleRegistrationCommand}">
-                                    <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>
-                </Border>
-            </Grid>
-            <filterDataGrid:FilterDataGrid
-                x:Name="DataGridMain"
-                Grid.Row="1"
-                behaviors:DataGridBehavior.RowNumbers="True"
-                AutoGenerateColumns="False"
-                Background="White"
-                CanUserAddRows="False"
-                CanUserReorderColumns="True"
-                CellStyle="{StaticResource CustomCellStyle}"
-                ColumnHeaderStyle="{StaticResource CustomColumnHeaderStyle}"
-                FilterLanguage="SimplifiedChinese"
-                HeadersVisibility="All"
-                HorizontalGridLinesBrush="LightSlateGray"
-                ItemsSource="{Binding SampleRegistrations, Mode=TwoWay}"
-                RowHeaderStyle="{StaticResource CustomRowHeaderStyle}"
-                RowStyle="{StaticResource CustomRowStyle}"
-                SelectedItem="{Binding SelectedSampleRegistration, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
-                SelectionChanged="DataGridMain_OnSelectionChanged"
-                SelectionMode="Single"
-                ShowRowsCount="True"
-                ShowStatusBar="True"
-                VerticalGridLinesBrush="LightSlateGray">
-
-                <!--  选择行事件  -->
-                <!--<b:Interaction.Triggers>
-                    <b:EventTrigger EventName="SelectionChanged">
-                        <b:InvokeCommandAction Command="{Binding SampleRegistrationSelectionChangedCommand}" CommandParameter="{Binding ElementName=DataGridMain, Path=SelectedItem}" />
-                    </b:EventTrigger>
-                </b:Interaction.Triggers>-->
-
-                <control:FilterDataGrid.Resources>
-                    <!--  非编辑模式下文本居中的样式  -->
-                    <Style x:Key="TextColumnElementStyle" TargetType="TextBlock">
-                        <Setter Property="HorizontalAlignment" Value="Center" />
-                        <Setter Property="VerticalAlignment" Value="Center" />
-                        <Setter Property="TextAlignment" Value="Center" />
-                    </Style>
-
-                    <!--  编辑模式下文本居中的样式  -->
-                    <Style x:Key="TextColumnEditingElementStyle" TargetType="TextBox">
-                        <Setter Property="HorizontalAlignment" Value="Stretch" />
-                        <Setter Property="VerticalAlignment" Value="Stretch" />
-                        <Setter Property="VerticalContentAlignment" Value="Center" />
-                    </Style>
-
-                    <Style x:Key="CheckBoxColumnElementStyle" TargetType="CheckBox">
-                        <Setter Property="HorizontalAlignment" Value="Center" />
-                        <Setter Property="VerticalAlignment" Value="Center" />
-                        <Setter Property="IsEnabled" Value="False" />
-                    </Style>
-                </control:FilterDataGrid.Resources>
-
-                <control:FilterDataGrid.Columns>
-                    <DataGridTextColumn
-                        Width="60"
-                        Binding="{Binding Year}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="工作年度"
-                        IsReadOnly="True" />
-                    <control:FilterDataGridTextColumn
-                        Width="300"
-                        Binding="{Binding SampleNo}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="抽样登记表编号"
-                        IsColumnFiltered="True"
-                        IsReadOnly="True" />
-                    <control:FilterDataGridTextColumn
-                        Width="200"
-                        Binding="{Binding InspectApply.Company}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="生产企业"
-                        IsColumnFiltered="True"
-                        IsReadOnly="True" />
-                    <control:FilterDataGridTextColumn
-                        Width="120"
-                        Binding="{Binding EditTime, StringFormat=yyyy-MM-dd}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="抽样时间"
-                        IsColumnFiltered="True"
-                        IsReadOnly="True" />
-                    <control:FilterDataGridTextColumn
-                        Width="200"
-                        Binding="{Binding BatchNo}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="批号"
-                        IsColumnFiltered="True"
-                        IsReadOnly="True" />
-                    <control:FilterDataGridTextColumn
-                        Width="120"
-                        Binding="{Binding PacketNo}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="包号"
-                        IsColumnFiltered="True"
-                        IsReadOnly="True" />
-
-                    <control:FilterDataGridTextColumn
-                        Width="100"
-                        Binding="{Binding EditUser}"
-                        EditingElementStyle="{StaticResource TextColumnEditingElementStyle}"
-                        ElementStyle="{StaticResource TextColumnElementStyle}"
-                        Header="承办人"
-                        IsColumnFiltered="True"
-                        IsReadOnly="True" />
-
-                </control:FilterDataGrid.Columns>
-            </filterDataGrid:FilterDataGrid>
-        </Grid>
-
-        <GridSplitter
-            Grid.Column="1"
-            Width="2"
-            HorizontalAlignment="Stretch" />
-        <Grid Grid.Column="2" Background="White">
-            <ScrollViewer>
-                <Grid Background="White">
-                    <Grid.RowDefinitions>
-                        <RowDefinition Height="50" />
-                        <RowDefinition Height="40" />
-                        <RowDefinition Height="40" />
-                        <RowDefinition Height="40" />
-                        <RowDefinition Height="45" />
-                        <RowDefinition Height="40" />
-                        <RowDefinition Height="40" />
-                        <RowDefinition Height="80" />
-                        <RowDefinition Height="40" />
-                        <RowDefinition Height="150" />
-                        <RowDefinition Height="40" />
-                        <RowDefinition Height="40" />
-
-                    </Grid.RowDefinitions>
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition Width="2*" />
-                        <ColumnDefinition Width="3*" />
-                        <ColumnDefinition Width="3*" />
-                        <ColumnDefinition Width="3*" />
-                        <ColumnDefinition Width="*" />
-                    </Grid.ColumnDefinitions>
-
-                    <TextBlock
-                        Grid.Row="0"
-                        Grid.Column="0"
-                        Grid.ColumnSpan="5"
-                        HorizontalAlignment="Center"
-                        VerticalAlignment="Center"
-                        FontSize="25"
-                        Text="被装材料产品抽样信息登记表" />
-                    <TextBlock
-                        Grid.Row="1"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="编号:" />
-                    <TextBlock
-                        Grid.Row="1"
-                        Grid.Column="1"
-                        Grid.ColumnSpan="3"
-                        Text="{Binding SelectedSampleRegistration.SampleNo}" />
-                    <TextBlock
-                        Grid.Row="2"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="*单位:" />
-                    <TextBox
-                        Grid.Row="2"
-                        Grid.Column="1"
-                        Text="{Binding SelectedSampleRegistration.Department, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                    <TextBlock
-                        Grid.Row="2"
-                        Grid.Column="2"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="*时间:" />
-                    <DatePicker
-                        Grid.Row="2"
-                        Grid.Column="3"
-                        Text="{Binding SelectedSampleRegistration.EditTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                    <TextBlock
-                        Grid.Row="3"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="类别:" />
-                    <Grid
-                        Grid.Row="3"
-                        Grid.Column="1"
-                        Grid.ColumnSpan="3"
-                        Background="White">
-                        <Grid.ColumnDefinitions>
-                            <ColumnDefinition Width="*" />
-                            <ColumnDefinition Width="*" />
-                        </Grid.ColumnDefinitions>
-                        <TextBox
-                            x:Name="InspectCategory"
-                            Grid.Column="0"
-                            Text="{Binding SelectedSampleRegistration.InspectApply.InspCategory}"
-                            TextChanged="InspectCategory_TextChanged"
-                            Visibility="Collapsed" />
-                        <RadioButton
-                            x:Name="FirstSelected"
-                            Grid.Column="0"
-                            HorizontalAlignment="Center"
-                            Content="首批检验"
-                            GroupName="CategoryGroup" />
-                        <RadioButton
-                            x:Name="SecondSelected"
-                            Grid.Column="1"
-                            HorizontalAlignment="Center"
-                            Content="出厂检验"
-                            GroupName="CategoryGroup" />
-                    </Grid>
-                    <TextBlock
-                        Grid.Row="4"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="样品名称:"
-                        TextWrapping="Wrap" />
-                    <TextBlock
-                        Grid.Row="4"
-                        Grid.Column="1"
-                        Text="{Binding SelectedSampleRegistration.InspectApply.Material.Name}"
-                        TextWrapping="Wrap" />
-                    <TextBlock
-                        Grid.Row="4"
-                        Grid.Column="2"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="生产企业:"
-                        TextWrapping="Wrap" />
-                    <TextBlock
-                        Grid.Row="4"
-                        Grid.Column="3"
-                        Text="{Binding SelectedSampleRegistration.InspectApply.Company}"
-                        TextWrapping="Wrap" />
-                    <TextBlock
-                        Grid.Row="5"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="样品生产日期:"
-                        TextWrapping="Wrap" />
-                    <DatePicker
-                        Grid.Row="5"
-                        Grid.Column="1"
-                        Text="{Binding SelectedSampleRegistration.EditTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                    <TextBlock
-                        Grid.Row="5"
-                        Grid.Column="2"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="*批号:" />
-                    <TextBlock
-                        Grid.Row="5"
-                        Grid.Column="3"
-                        Text="{Binding SelectedSampleRegistration.BatchNo}"
-                        TextWrapping="Wrap" />
-                    <TextBlock
-                        Grid.Row="6"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="包号:" />
-                    <TextBox
-                        Grid.Row="6"
-                        Grid.Column="1"
-                        Text="{Binding SelectedSampleRegistration.PacketNo, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                    <TextBlock
-                        Grid.Row="6"
-                        Grid.Column="2"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="数量:" />
-                    <TextBox
-                        Grid.Row="6"
-                        Grid.Column="3"
-                        Text="{Binding SelectedSampleRegistration.Quantity, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                    <TextBlock
-                        Grid.Row="7"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="检测项目:"
-                        TextWrapping="Wrap" />
-                    <GroupBox
-                        Grid.Row="7"
-                        Grid.Column="1"
-                        Grid.ColumnSpan="3"
-                        VerticalAlignment="Center"
-                        Header="检测项目">
-
-                        <WrapPanel
-                            AllowDrop="True"
-                            FlowDirection="LeftToRight"
-                            Orientation="Horizontal">
-                            <RadioButton
-                                x:Name="TestAllRadioButton"
-                                Padding="10,0,10,0"
-                                VerticalContentAlignment="Center"
-                                Checked="RadioButton_Checked"
-                                Content="全检"
-                                GroupName="TestingItemGroup" />
-                            <RadioButton
-                                x:Name="MandatoryTestRadioButton"
-                                Padding="10,0,10,0"
-                                VerticalContentAlignment="Center"
-                                Checked="RadioButton_Checked"
-                                Content="强制性指标"
-                                GroupName="TestingItemGroup" />
-                            <RadioButton
-                                x:Name="ColorFastnessRadioButton"
-                                Padding="10,0,10,0"
-                                VerticalContentAlignment="Center"
-                                Checked="RadioButton_Checked"
-                                Content="色牢度"
-                                GroupName="TestingItemGroup" />
-                            <RadioButton
-                                x:Name="SpectrumRadioButton"
-                                Padding="10,0,10,0"
-                                VerticalContentAlignment="Center"
-                                Checked="RadioButton_Checked"
-                                Content="光谱"
-                                GroupName="TestingItemGroup" />
-                            <RadioButton
-                                x:Name="ReferenceRadioButton"
-                                Padding="10,0,10,0"
-                                VerticalContentAlignment="Center"
-                                Checked="RadioButton_Checked"
-                                Content="参考性指标"
-                                GroupName="TestingItemGroup" />
-                            <RadioButton
-                                x:Name="SingleRadioButton"
-                                Padding="10,0,10,0"
-                                VerticalContentAlignment="Center"
-                                Checked="RadioButton_Checked"
-                                Content="单项指标"
-                                GroupName="TestingItemGroup" />
-                            <TextBox Width="200" Text="{Binding SelectedSampleRegistration.SingleIndexItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                            <TextBox
-                                x:Name="TestingItemTextBox"
-                                Text="{Binding SelectedSampleRegistration.TestingItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
-                                TextChanged="TestingItemTextBox_TextChanged"
-                                Visibility="Collapsed" />
-                        </WrapPanel>
-                    </GroupBox>
-                    <Button
-                        Grid.Row="8"
-                        Grid.Column="1"
-                        HorizontalAlignment="Left"
-                        Command="{Binding RandomInspectionOrgCommand}">
-                        <Button.Template>
-                            <ControlTemplate>
-                                <Border
-                                    Width="140"
-                                    Height="30"
-                                    Background="{TemplateBinding Background}"
-                                    CornerRadius="5">
-                                    <StackPanel
-                                        HorizontalAlignment="Center"
-                                        VerticalAlignment="Center"
-                                        Orientation="Horizontal">
-                                        <TextBlock VerticalAlignment="Center" Text="抽取检测机构" />
-                                        <TextBlock
-                                            HorizontalAlignment="Center"
-                                            VerticalAlignment="Center"
-                                            FontFamily="{StaticResource FluentSystemIconsRegular}"
-                                            FontSize="20"
-                                            Text="{x:Static utils:RegularFontUtil.Tap_Double_24}" />
-                                    </StackPanel>
-                                </Border>
-                                <ControlTemplate.Triggers>
-                                    <Trigger Property="IsMouseOver" Value="True">
-                                        <Setter Property="Background" Value="LightGray" />
-                                    </Trigger>
-                                </ControlTemplate.Triggers>
-                            </ControlTemplate>
-                        </Button.Template>
-                    </Button>
-                    <TextBlock
-                        Grid.Row="8"
-                        Grid.Column="2"
-                        Grid.ColumnSpan="2"
-                        HorizontalAlignment="Left"
-                        Foreground="DimGray"
-                        Text="{Binding SelectedSampleRegistration.RandomTip, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
-                        TextWrapping="Wrap" />
-                    <TextBlock
-                        Grid.Row="9"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="检测机构:"
-                        TextWrapping="Wrap" />
-                    <TextBox
-                        Grid.Row="9"
-                        Grid.Column="1"
-                        Grid.ColumnSpan="3"
-                        Height="150"
-                        AcceptsReturn="True"
-                        Text="{Binding SelectedSampleRegistration.InspectionOrganization, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
-                        TextWrapping="Wrap"
-                        VerticalScrollBarVisibility="Auto" />
-                    <TextBlock
-                        Grid.Row="10"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="*生产企业人员:"
-                        TextWrapping="Wrap" />
-                    <TextBox
-                        Grid.Row="10"
-                        Grid.Column="1"
-                        Grid.ColumnSpan="3"
-                        Text="{Binding SelectedSampleRegistration.ProductUsers, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                    <TextBlock
-                        Grid.Row="11"
-                        Grid.Column="0"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="*承办人:"
-                        TextWrapping="Wrap" />
-                    <TextBox
-                        Grid.Row="11"
-                        Grid.Column="1"
-                        Text="{Binding SelectedSampleRegistration.EditUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                    <TextBlock
-                        Grid.Row="11"
-                        Grid.Column="2"
-                        HorizontalAlignment="Right"
-                        VerticalAlignment="Center"
-                        Text="*联系电话:" />
-                    <TextBox
-                        Grid.Row="11"
-                        Grid.Column="3"
-                        Text="{Binding SelectedSampleRegistration.Telephone, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
-                </Grid>
-            </ScrollViewer>
-
-
-        </Grid>
+        <TabControl>
+            <TabItem Header="抽样登记录入">
+                <sample:SampleRegistrationInputPage />
+            </TabItem>
+            <TabItem Header="抽样登记管理">
+                <sample:SampleRegistrationManagePage />
+            </TabItem>
+        </TabControl>
 
     </Grid>
 </UserControl>

+ 12 - 122
UniformMaterialManagementSystem/Views/SampleRegistrationPage.xaml.cs

@@ -1,13 +1,17 @@
-using System.Collections.ObjectModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
 using System.Windows;
-using Microsoft.Extensions.DependencyInjection;
 using System.Windows.Controls;
-using Microsoft.EntityFrameworkCore;
-using UniformMaterialManagementSystem.Data;
-using UniformMaterialManagementSystem.Models;
-using UniformMaterialManagementSystem.ViewModels;
-using UniformMaterialManagementSystem.Entities;
-using UniformMaterialManagementSystem.Services;
+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 UniformMaterialManagementSystem.Views
 {
@@ -19,120 +23,6 @@ namespace UniformMaterialManagementSystem.Views
         public SampleRegistrationPage()
         {
             InitializeComponent();
-
-            this.DataContext = App.Current.Services.GetService<SampleRegistrationPageViewModel>();
-        }
-
-        private void InspectCategory_TextChanged(object sender, TextChangedEventArgs e)
-        {
-            var category = sender as TextBox;
-            if (category != null)
-            {
-                switch (category.Text)
-                {
-                    case "首批检验":
-                        FirstSelected.IsChecked = true;
-                        break;
-                    case "出厂检验":
-                        SecondSelected.IsChecked = true;
-                        break;
-                }
-            }
-        }
-
-        private void TestingItemTextBox_TextChanged(object sender, TextChangedEventArgs e)
-        {
-            var testingItem = sender as TextBox;
-            if (testingItem != null)
-            {
-                switch (testingItem.Text)
-                {
-                    case "全检":
-                        TestAllRadioButton.IsChecked = true;
-                        break;
-                    case "强制性指标":
-                        MandatoryTestRadioButton.IsChecked = true;
-                        break;
-                    case "色牢度":
-                        ColorFastnessRadioButton.IsChecked = true;
-                        break;
-                    case "光谱":
-                        SpectrumRadioButton.IsChecked = true;
-                        break;
-                    case "参考性指标":
-                        ReferenceRadioButton.IsChecked = true;
-                        break;
-                    case "单项指标":
-                        SingleRadioButton.IsChecked = true;
-                        break;
-                }
-            }
-        }
-
-        private void RadioButton_Checked(object sender, System.Windows.RoutedEventArgs e)
-        {
-            var testingItem = sender as RadioButton;
-            if (testingItem != null && testingItem.Content != null)
-            {
-                var testingItemText = testingItem.Content.ToString();
-                TestingItemTextBox.Text = testingItemText == null ? "" : testingItemText;
-            }
-        }
-
-        private void DataGridMain_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            var itemsSource = DataGridMain.ItemsSource as ObservableCollection<SampleRegistrationModel>;
-            var count = e.RemovedItems.Count;
-
-            //判断移除选中的行是否需要保存
-            if (count == 0) return;
-            SampleRegistrationModel? preSampleRegistration = e.RemovedItems[0] as SampleRegistrationModel;
-            if (preSampleRegistration == null) return;
-
-            //using SqliteContext context = new();
-            //var sampleRegistration = context.SampleRegistrations.Where(x => x.Guid == preSampleRegistration.Guid).ToList().FirstOrDefault();
-            //if (sampleRegistration == null)//新增行
-            //{
-            //    MessageBox.Show("数据已新增,请保存后切换行!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
-
-            //    //选中原来行
-            //    //e.AddedItems.Clear();
-            //    DataGridMain.SelectedItem = preSampleRegistration;
-            //}
-            //else
-            //{
-            //    //判断是否修改
-            //    IDataBaseService<SampleRegistration> service = new DataBaseService<SampleRegistration>(context);
-            //    ModifySampleRegistrationFromModel(sampleRegistration, preSampleRegistration);
-            //    var state = service.Entry(sampleRegistration);
-            //    if (state == EntityState.Modified)
-            //    {
-            //        MessageBox.Show("数据已修改,请保存后切换行!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
-
-            //        //选中原来行
-            //        //if (e.AddedItems.Count > 0)
-            //        //{
-            //        //    e.AddedItems[0] = preSampleRegistration;
-            //        //}
-            //        DataGridMain.SelectedItem = preSampleRegistration;
-            //    }
-            //}
-        }
-
-        private void ModifySampleRegistrationFromModel(SampleRegistration sampleRegistration, SampleRegistrationModel model)
-        {
-            sampleRegistration.Department = model.Department;
-            sampleRegistration.EditTime = model.EditTime;
-            sampleRegistration.ProductDate = model.ProductDate;
-            sampleRegistration.BatchNo = model.BatchNo;
-            sampleRegistration.PacketNo = model.PacketNo;
-            sampleRegistration.Quantity = model.Quantity;
-            sampleRegistration.TestingItem = model.TestingItem;
-            sampleRegistration.SingleIndexItem = model.SingleIndexItem;
-            sampleRegistration.InspectionOrganization = model.InspectionOrganization;
-            sampleRegistration.ProductUsers = model.ProductUsers;
-            sampleRegistration.EditUser = model.EditUser;
-            sampleRegistration.Telephone = model.Telephone;
         }
     }
 }