Procházet zdrojové kódy

优化检验申请管理

LT069288 před 3 měsíci
rodič
revize
b94bf87301

+ 64 - 118
UniformMaterialManagementSystem/ViewModels/InspectApplyPageViewModel.cs

@@ -3,7 +3,6 @@ using CommunityToolkit.Mvvm.Input;
 using Microsoft.Win32;
 using System.Collections.ObjectModel;
 using System.Collections.Specialized;
-using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
 using System.Data;
 using System.Text;
@@ -103,7 +102,7 @@ namespace UniformMaterialManagementSystem.ViewModels
 
         private InspectApplyDetail? _selectedDetail;
 
-        private SelectContractDetailModel? _selecteContractDetail;
+        private SelectContractDetailModel? _selectedContractDetail;
 
         private readonly IDataBaseService<SerialNumber> _serialService;
         private readonly IDataBaseService<InspectApply> _inspectService;
@@ -133,11 +132,8 @@ namespace UniformMaterialManagementSystem.ViewModels
             }
 
             //监管单位简称
-            SupervisionUnit? supervisionUnit = App.CurrentUser!.SupervisionUnit;
-            if (supervisionUnit != null)
-            {
-                SupervisionUnitShortName = supervisionUnit.ShortName;
-            }
+            var supervisionUnit = App.CurrentUser!.SupervisionUnit;
+            SupervisionUnitShortName = supervisionUnit.ShortName;
 
             //默认生产企业
             SelectedCompany = Companies.FirstOrDefault(c => c.Guid == App.CurrentUser.CompanyGuid);
@@ -174,9 +170,6 @@ namespace UniformMaterialManagementSystem.ViewModels
                 return;
             }
 
-            //生成材料批号:材料企业代码-材料代码-申请检验时间;待修改
-            //BatchNo = SelectedCompany?.SystemCode + "-" + SelectedMaterial?.VarietyCode + "-" + InspDate.ToString("yyyyMMdd");
-
             if (InspReport == null || InspReport.Length == 0)
             {
                 MessageBox.Show("请上传订购方检测报告!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
@@ -270,22 +263,6 @@ namespace UniformMaterialManagementSystem.ViewModels
             return totalInspectedQty;
         }
 
-        /// <summary>
-        /// 计算该品种历史累计抽样送检次数
-        /// </summary>
-        /// <param name="year">年度</param>
-        /// <param name="companyGuid">生产企业</param>
-        /// <param name="materialGuid">产品</param>
-        /// <returns></returns>
-        private int CalculateSampleTimes(int year, Guid? companyGuid, Guid? materialGuid)
-        {
-            if (companyGuid == null || materialGuid == null) return 0;
-
-            var inspectApplies = _inspectService.Query(x => x.Year == year && x.CompanyGuid == companyGuid && x.MaterialGuid == materialGuid && x.SampleStatus).ToList();
-
-            return inspectApplies.Count;
-        }
-
         /// <summary>
         /// 生成文档
         /// </summary>
@@ -471,7 +448,7 @@ namespace UniformMaterialManagementSystem.ViewModels
                 {
                     applyDetail.Note = dr["备注"].ToString();
                 }
-                
+
                 InspectApplyDetails.Add(applyDetail);
             }
 
@@ -485,7 +462,9 @@ namespace UniformMaterialManagementSystem.ViewModels
         [RelayCommand]
         private void ExportDetail()
         {
-            InspectApplyUtil.ExportBatchDetail(InspectApplyDetails, SelectedCompany?.Name, SelectedMaterial?.Name, BatchNo);
+            var companyName = SelectedCompany?.Name ?? string.Empty;
+            var materialName = SelectedMaterial?.Name ?? string.Empty;
+            InspectApplyUtil.ExportBatchDetail(InspectApplyDetails, companyName, materialName, BatchNo);
         }
 
         /// <summary>
@@ -529,12 +508,12 @@ namespace UniformMaterialManagementSystem.ViewModels
         [RelayCommand]
         private void DeleteContract()
         {
-            if (_selecteContractDetail == null)
+            if (_selectedContractDetail == null)
             {
                 MessageBox.Show("请先选中一行,再进行删除操作!");
                 return;
             }
-            ContractDetails.Remove(_selecteContractDetail);
+            ContractDetails.Remove(_selectedContractDetail);
         }
 
         /// <summary>
@@ -553,7 +532,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         [RelayCommand]
         private void ContractSelectionChanged(SelectContractDetailModel detail)
         {
-            _selecteContractDetail = detail;
+            _selectedContractDetail = detail;
         }
 
         /// <summary>
@@ -628,53 +607,59 @@ namespace UniformMaterialManagementSystem.ViewModels
         /// </summary>
         private bool SaveInspectAndDetails()
         {
-            _inspectApply = new InspectApply();
-            _inspectApply.ApplyNo = _applyNo;
-            _inspectApply.InspCategory = InspCategory;
-            _inspectApply.ProductName = SelectedMaterial.Name;
-            _inspectApply.MaterialGuid = SelectedMaterial.Guid;
-            _inspectApply.CompanyGuid = SelectedCompany.Guid;
-            _inspectApply.Company = SelectedCompany.Name;
-            _inspectApply.InspQuantity = InspQuantity;
-            _inspectApply.StartProductDate = StartProductDate;
-            _inspectApply.EndProductDate = EndProductDate;
-            _inspectApply.InspDate = InspDate;
-            _inspectApply.BatchNo = BatchNo;
-            _inspectApply.InspReportNo = InspReportNo;
-            _inspectApply.ApplyDescription = ApplyDescription;
-            _inspectApply.ReportStatus = false;
-            _inspectApply.InspReport = InspReport; //检验报告附件
-            _inspectApply.ApplyUser = App.CurrentUser!.UserName;
-            _inspectApply.Year = WorkYear;
-
-            _inspectApply.InspectApplyDetails = new ObservableCollection<InspectApplyDetail>();
+            _inspectApply = new InspectApply
+            {
+                ApplyNo = _applyNo,
+                InspCategory = InspCategory,
+                ProductName = SelectedMaterial?.Name ?? string.Empty,
+                MaterialGuid = SelectedMaterial?.Guid ?? Guid.Empty,
+                CompanyGuid = SelectedCompany?.Guid ?? Guid.Empty,
+                Company = SelectedCompany?.Name ?? string.Empty,
+                InspQuantity = InspQuantity,
+                StartProductDate = StartProductDate,
+                EndProductDate = EndProductDate,
+                InspDate = InspDate,
+                BatchNo = BatchNo,
+                InspReportNo = InspReportNo,
+                ApplyDescription = ApplyDescription,
+                ReportStatus = false,
+                InspReport = InspReport, //检验报告附件
+                ApplyUser = App.CurrentUser!.UserName,
+                Year = WorkYear,
+
+                InspectApplyDetails = []
+            };
             foreach (var detail in InspectApplyDetails)
             {
-                InspectApplyDetail newDetail = new InspectApplyDetail();
-                newDetail.ApplyGuid = _inspectApply.Guid;
-                newDetail.ApplyNo = _applyNo;
-                newDetail.PacketNo = detail.PacketNo;
-                newDetail.Quantity = detail.Quantity;
-                newDetail.Note = detail.Note;
-                newDetail.InspectApply = _inspectApply;
+                InspectApplyDetail newDetail = new()
+                {
+                    ApplyGuid = _inspectApply.Guid,
+                    ApplyNo = _applyNo,
+                    PacketNo = detail.PacketNo,
+                    Quantity = detail.Quantity,
+                    Note = detail.Note,
+                    InspectApply = _inspectApply
+                };
 
                 _inspectApply.InspectApplyDetails.Add(newDetail);
             }
 
-            _inspectApply.InspectApplyContractDetails = new ObservableCollection<InspectApplyContractDetail>();
+            _inspectApply.InspectApplyContractDetails = [];
 
             foreach (var detail in ContractDetails)
             {
-                InspectApplyContractDetail newDetail = new InspectApplyContractDetail();
-                newDetail.ApplyGuid = _inspectApply.Guid;
-                newDetail.ApplyNo = _applyNo;
-                newDetail.ContractDetailGuid = detail.Guid;
-                newDetail.PurchaseCompany = detail.PurchaseCompany;
-                newDetail.PurchaseCompanyShortName = detail.PurchaseCompanyShortName;
-                newDetail.ContractNo = detail.ContractNo;
-                newDetail.SigningDate = detail.SigningDate;
-                newDetail.UnInspectQty = detail.UnInspectQty;
-                newDetail.InspectQty = detail.ShareInspectQty;
+                InspectApplyContractDetail newDetail = new()
+                {
+                    ApplyGuid = _inspectApply.Guid,
+                    ApplyNo = _applyNo,
+                    ContractDetailGuid = detail.Guid,
+                    PurchaseCompany = detail.PurchaseCompany,
+                    PurchaseCompanyShortName = detail.PurchaseCompanyShortName,
+                    ContractNo = detail.ContractNo,
+                    SigningDate = detail.SigningDate,
+                    UnInspectQty = detail.UnInspectQty,
+                    InspectQty = detail.ShareInspectQty
+                };
 
                 _inspectApply.InspectApplyContractDetails.Add(newDetail);
             }
@@ -703,23 +688,19 @@ namespace UniformMaterialManagementSystem.ViewModels
                 {
                     //扣减剩余数量
                     detail.ShareInspectQty = remainQty;
-                    remainQty = 0;
                     break;
                 }
             }
-            //没有扣减完成,则找到第一个合同单据完成剩余扣减
-            //if (remainQty > 0)
-            //{
-            //    contractDetails[0].ShareInspectQty += remainQty;
-            //}
         }
 
         /// <summary>
         /// 更新合同明细中报检状态、已报检数量
         /// </summary>
-        private bool UpdateContractDetail()
+        private void UpdateContractDetail()
         {
-            var contractDetailList = _contractDetailService.GetAll(x => x.Contract.CompanyGuid == SelectedCompany.Guid && x.Material.Name == SelectedMaterial.Name).ToList();
+            var materialName = SelectedMaterial?.Name ?? string.Empty;
+            var companyGuid = SelectedCompany?.Guid ?? Guid.Empty;
+            var contractDetailList = _contractDetailService.GetAll(x => x.Contract.CompanyGuid == companyGuid && x.Material.Name == materialName).ToList();
 
             //更新已报检数量
             foreach (var detail in ContractDetails)
@@ -752,7 +733,7 @@ namespace UniformMaterialManagementSystem.ViewModels
                 }
             }
 
-            return _contractDetailService.SaveChanges();
+            _contractDetailService.SaveChanges();
         }
 
         /// <summary>
@@ -770,7 +751,7 @@ namespace UniformMaterialManagementSystem.ViewModels
 
             TotalPackage = InspectApplyDetails.Count;
 
-            string result = InspectApplyUtil.ReplaceApplyDescription(ApplyDescription, "InspQuantity", $"[{InspQuantity}{SelectedMaterial?.MeasureUnit}]");
+            var result = InspectApplyUtil.ReplaceApplyDescription(ApplyDescription ?? string.Empty, "InspQuantity", $"[{InspQuantity}{SelectedMaterial?.MeasureUnit}]");
             ApplyDescription = InspectApplyUtil.ReplaceApplyDescription(result, "PackageQty", $"[{TotalPackage}]");
         }
 
@@ -780,7 +761,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         private void GenerateSerialNumber()
         {
             var companyGuid = SelectedCompany!.Guid;
-            var supervisionUnitGuid = App.CurrentUser?.SupervisionUnit?.Guid;
+            var supervisionUnitGuid = App.CurrentUser!.SupervisionUnit.Guid;
 
             var serials = _serialService.Query(s =>
                 s.CompanyGuid == companyGuid
@@ -808,7 +789,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         private void UpdateSerialNumber()
         {
             var companyGuid = SelectedCompany!.Guid;
-            var supervisionUnitGuid = App.CurrentUser?.SupervisionUnit?.Guid;
+            var supervisionUnitGuid = App.CurrentUser!.SupervisionUnit.Guid;
 
             var serials = _serialService.GetAll(s =>
                 s.CompanyGuid == companyGuid
@@ -821,10 +802,9 @@ namespace UniformMaterialManagementSystem.ViewModels
             if (serials.Count > 0)
             {
                 var serial = serials[0];
-                int newMax;
                 int oldMax = int.Parse(serial.MaxNumber);
 
-                if (SerialNumber.Length > 3 || !int.TryParse(SerialNumber, out newMax)) return;
+                if (SerialNumber.Length > 3 || !int.TryParse(SerialNumber, out int newMax)) return;
                 if (newMax > oldMax)
                 {
                     serial.MaxNumber = newMax.ToString("000");
@@ -835,7 +815,7 @@ namespace UniformMaterialManagementSystem.ViewModels
                 var newSerialNumber = new SerialNumber()
                 {
                     CompanyGuid = SelectedCompany!.Guid,
-                    CompanyCode = CompanyCode,
+                    CompanyCode = CompanyCode ?? string.Empty,
                     SupervisionUnitGuid = App.CurrentUser.SupervisionUnit.Guid,
                     InspCategory = InspCategory,
                     Year = WorkYear,
@@ -847,40 +827,6 @@ namespace UniformMaterialManagementSystem.ViewModels
             _serialService.SaveChanges();
         }
 
-        /// <summary>
-        /// 校验用户输入的流水号不能超过系统记录的最大流水号
-        /// </summary>
-        private bool CheckCustomSerialNumber(string serialNumber)
-        {
-            var companyGuid = SelectedCompany!.Guid;
-            var supervisionUnitGuid = App.CurrentUser?.SupervisionUnit?.Guid;
-
-            var serials = _serialService.Query(s =>
-                s.CompanyGuid == companyGuid
-                && s.CompanyCode == CompanyCode
-                && s.SupervisionUnitGuid == supervisionUnitGuid
-                && s.InspCategory == InspCategory
-                && s.Year == WorkYear
-            ).ToList();
-
-            if (serials.Count == 0)
-            {
-                MessageBox.Show("不存在断号的流水号,请自动生成流水号!");
-                return false;
-            }
-            else
-            {
-                string maxNumber = serials.FirstOrDefault().MaxNumber;
-                if (int.Parse(serialNumber) > (int.Parse(maxNumber)))
-                {
-                    MessageBox.Show("手动录入编号时,只允许录入断号流水号!您输入的流水号已超出目前最大流水号,请选择自动获取编号或者使用断号流水号!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
-                    return false;
-                }
-            }
-
-            return true;
-        }
-
         #endregion
 
     }

+ 16 - 22
UniformMaterialManagementSystem/ViewModels/InspectionRecordPageViewModel.cs

@@ -25,13 +25,13 @@ namespace UniformMaterialManagementSystem.ViewModels
         private ObservableCollection<string> _inspectCategories = [];
 
         [ObservableProperty]
-        private string _selectedInspectCategory = string.Empty;
+        private string? _selectedInspectCategory = string.Empty;
 
         [ObservableProperty]
         private ObservableCollection<string> _companies = [];
 
         [ObservableProperty]
-        private string _selectedCompany = string.Empty;
+        private string? _selectedCompany;
 
         [ObservableProperty]
         private ObservableCollection<InspectApply> _inspectApplies = [];
@@ -45,9 +45,6 @@ namespace UniformMaterialManagementSystem.ViewModels
         [ObservableProperty]
         private int _totalPackage; //总包数
 
-        [ObservableProperty]
-        private bool _isCompany;//是否生产企业
-
         private readonly IDataBaseService<InspectApply> _inspectService;
 
         private readonly IDataBaseService<SerialNumber> _serialService;
@@ -79,15 +76,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             InspectCategories.Add("出厂检验");
 
             //生产企业
-            if (CommonUtil.GetRoleType() == RoleType.MaterialCompany)
-            {
-                IsCompany = true;
-            }
-
-            if (IsCompany)
-            {
-                SelectedCompany = App.CurrentUser.CompanyName;
-            }
+            SelectedCompany = App.CurrentUser?.CompanyName;
 
             _workYear = App.CurrentUser!.WorkYear;
         }
@@ -98,14 +87,14 @@ namespace UniformMaterialManagementSystem.ViewModels
         [RelayCommand]
         private void LoadData()
         {
-            SelectedInspectCategory = SelectedInspectCategory ?? "";
-            SelectedCompany = SelectedCompany ?? "";
+            var inspectCategory = SelectedInspectCategory ?? string.Empty;
+            var companyName = SelectedCompany ?? string.Empty;
             var materialName = SelectedMaterial?.Name ?? string.Empty;
 
-            var inspectAppliesList = _inspectService.QueryNoTracking(x => x.Year == WorkYear && x.Company.Contains(SelectedCompany) && x.InspCategory.Contains(SelectedInspectCategory) && x.ProductName.Contains(materialName))
+            var inspectAppliesList = _inspectService.QueryNoTracking(x => x.Year == WorkYear && x.Company.Contains(companyName) && x.InspCategory.Contains(inspectCategory) && x.ProductName.Contains(materialName))
                 .Include(x => x.InspectApplyDetails)
                 .Include(x => x.InspectApplyContractDetails)
-                .Include(x => x.Material).ToList();
+                .Include(x => x.Material).OrderByDescending(x=>x.InspDate).ToList();
 
             InspectApplies.Clear();
             foreach (var inspectApply in inspectAppliesList)
@@ -335,8 +324,9 @@ namespace UniformMaterialManagementSystem.ViewModels
         /// <summary>
         /// 更新合同明细中报检状态、已报检数量
         /// </summary>
-        private bool UpdateContractDetail()
+        private void UpdateContractDetail()
         {
+            if (InspectApply == null) return;
             var contractDetailList = _contractDetailService.GetAll(x => x.Contract.CompanyGuid == InspectApply.CompanyGuid && x.Material.Name == InspectApply.ProductName).ToList();
             foreach (var detail in InspectApply.InspectApplyContractDetails)
             {
@@ -363,7 +353,7 @@ namespace UniformMaterialManagementSystem.ViewModels
                 }
             }
 
-            return _contractDetailService.SaveChanges();
+            _contractDetailService.SaveChanges();
         }
 
         /// <summary>
@@ -371,13 +361,15 @@ namespace UniformMaterialManagementSystem.ViewModels
         /// </summary>
         private void HandleSerialNumber(int serialNumber)
         {
+            if (InspectApply == null) return;
             bool isMaxSerial = false;
-            var inspect = _inspectService.Query(x => x.ApplyNo == InspectApply.ApplyNo).Include(x => x.MaterialCompany).FirstOrDefault();
+            var inspect = _inspectService.Query(x => x.Guid == InspectApply.Guid).Include(x => x.MaterialCompany).FirstOrDefault();
+            if (inspect == null) return;
 
             var serial = _serialService.GetAll(s =>
                 s.CompanyGuid == inspect.CompanyGuid
                 && s.CompanyCode == inspect.MaterialCompany.Code
-                && s.SupervisionUnitGuid == App.CurrentUser.SupervisionUnitGuid
+                && s.SupervisionUnitGuid == App.CurrentUser!.SupervisionUnitGuid
                 && s.InspCategory == inspect.InspCategory
                 && s.Year == inspect.Year
             ).ToList().FirstOrDefault();
@@ -412,6 +404,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         [RelayCommand]
         private void DownLoadAttachment()
         {
+            if (InspectApply == null) return;
             if (InspectApply.InspReport == null || InspectApply.InspReport.Length == 0) return;
 
             SaveFileDialog saveFileDialog = new SaveFileDialog()
@@ -449,6 +442,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         [RelayCommand]
         private void ExportDetail()
         {
+            if (InspectApply == null) return;
             InspectApplyUtil.ExportBatchDetail(InspectApply.InspectApplyDetails, InspectApply.Company, InspectApply.ProductName, InspectApply.BatchNo);
         }
 

+ 9 - 5
UniformMaterialManagementSystem/Views/InspectApplyPage.xaml

@@ -16,6 +16,7 @@
     mc:Ignorable="d">
 
     <UserControl.Resources>
+        <converters:ContentToBoolConverter x:Key="ContentToBoolConverter" />
         <!--  定义一个全局的TextBlock样式  -->
         <Style TargetType="TextBlock">
             <Setter Property="FontSize" Value="14" />
@@ -334,25 +335,28 @@
                                         Grid.Column="0"
                                         Checked="RadioButton_Checked"
                                         Content="报样检验"
-                                        GroupName="InspectType" />
+                                        GroupName="InspectType"
+                                        IsChecked="{Binding InspCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=报样检验}" />
                                     <RadioButton
                                         x:Name="SecondRadioButton"
                                         Grid.Column="1"
                                         Checked="RadioButton_Checked"
                                         Content="首批检验"
-                                        GroupName="InspectType" />
+                                        GroupName="InspectType"
+                                        IsChecked="{Binding InspCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=首批检验}" />
                                     <RadioButton
                                         x:Name="ThirdRadioButton"
                                         Grid.Column="2"
                                         Checked="RadioButton_Checked"
                                         Content="出厂检验"
-                                        GroupName="InspectType" />
-                                    <TextBox
+                                        GroupName="InspectType"
+                                        IsChecked="{Binding InspCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=出厂检验}" />
+                                    <!--<TextBox
                                         x:Name="InspectTypeText"
                                         Grid.Column="2"
                                         Text="{Binding InspCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                         TextChanged="InspectTypeText_TextChanged"
-                                        Visibility="Collapsed" />
+                                        Visibility="Collapsed" />-->
                                 </Grid>
                             </StackPanel>
                             <TextBlock

+ 1 - 23
UniformMaterialManagementSystem/Views/InspectApplyPage.xaml.cs

@@ -71,11 +71,6 @@ namespace UniformMaterialManagementSystem.Views
                         TypeText.Text = "出厂";
                         break;
                 }
-
-                if (InspectTypeText != null)
-                {
-                    InspectTypeText.Text = inspectRadioButton.Content.ToString();
-                }
             }
         }
 
@@ -150,25 +145,9 @@ namespace UniformMaterialManagementSystem.Views
             string endSinspReportNoStr = "[" + inspReportNo + "]";
             string result = InspectApplyUtil.ReplaceApplyDescription(ApplyDescriptionTextBox.Text, "InspReportNo", endSinspReportNoStr);
             ApplyDescriptionTextBox.Text = result;
-
         }
 
-        private void InspectTypeText_TextChanged(object sender, TextChangedEventArgs e)
-        {
-            switch (InspectTypeText.Text)
-            {
-                case "报样检验":
-                    FirstRadioButton.IsChecked = true;
-                    break;
-                case "首批检验":
-                    SecondRadioButton.IsChecked = true;
-                    break;
-                case "出厂检验":
-                    ThirdRadioButton.IsChecked = true;
-                    break;
-
-            }
-        }
+        
 
         private void CheckBox_Checked(object sender, RoutedEventArgs e)
         {
@@ -198,7 +177,6 @@ namespace UniformMaterialManagementSystem.Views
                     itemsSource.Remove(selectedDetail);
                 }
             }
-
         }
 
         private void Button_Click(object sender, RoutedEventArgs e)

+ 8 - 151
UniformMaterialManagementSystem/Views/InspectionRecordPage.xaml

@@ -17,6 +17,7 @@
     mc:Ignorable="d">
 
     <UserControl.Resources>
+        <converters:ContentToBoolConverter x:Key="ContentToBoolConverter" />
         <!--  定义一个全局的TextBlock样式  -->
         <Style TargetType="TextBlock">
             <Setter Property="FontSize" Value="14" />
@@ -179,11 +180,11 @@
                             Grid.Column="0"
                             FlowDirection="LeftToRight"
                             Orientation="Horizontal">
-                            <TextBox
+                            <!--<TextBox
                                 x:Name="IsCompanyTextBox"
                                 Text="{Binding IsCompany, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                 TextChanged="IsCompanyTextBox_TextChanged"
-                                Visibility="Collapsed" />
+                                Visibility="Collapsed" />-->
                             <!--<TextBlock Text="工作年度:" />
                             <ComboBox
                                 Width="60"
@@ -589,26 +590,22 @@
                                                 Grid.Column="0"
                                                 Content="报样检验"
                                                 GroupName="InspectType"
+                                                IsChecked="{Binding InspectApply.InspCategory, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=报样检验}"
                                                 IsEnabled="False" />
                                             <RadioButton
                                                 x:Name="SecondRadioButton"
                                                 Grid.Column="1"
                                                 Content="首批检验"
                                                 GroupName="InspectType"
+                                                IsChecked="{Binding InspectApply.InspCategory, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=首批检验}"
                                                 IsEnabled="False" />
                                             <RadioButton
                                                 x:Name="ThirdRadioButton"
                                                 Grid.Column="2"
                                                 Content="出厂检验"
                                                 GroupName="InspectType"
-                                                IsChecked="True"
+                                                IsChecked="{Binding InspectApply.InspCategory, Converter={StaticResource ContentToBoolConverter}, ConverterParameter=出厂检验}"
                                                 IsEnabled="False" />
-                                            <TextBox
-                                                x:Name="InspectTypeText"
-                                                Grid.Column="2"
-                                                Text="{Binding InspectApply.InspCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
-                                                TextChanged="InspectTypeText_TextChanged"
-                                                Visibility="Collapsed" />
                                         </Grid>
                                     </StackPanel>
                                     <TextBlock
@@ -754,9 +751,8 @@
                                         Grid.Row="7"
                                         Grid.Column="0"
                                         HorizontalAlignment="Right"
-                                        TextWrapping="Wrap">
-                                        订购方检测报告:
-                                    </TextBlock>
+                                        Text="订购方检测报告:"
+                                        TextWrapping="Wrap" />
                                     <Border
                                         Grid.Row="7"
                                         Grid.Column="1"
@@ -766,35 +762,6 @@
                                             Background="White"
                                             FlowDirection="LeftToRight"
                                             Orientation="Horizontal">
-                                            <!--<Button
-                                            x:Name="UploadAttachmentButton"
-                                            Margin="3"
-                                            Command="{Binding UploadAttachmentCommand}"
-                                            IsEnabled="False">
-                                            <Button.Template>
-                                                <ControlTemplate>
-                                                    <Border
-                                                        Width="60"
-                                                        Background="{TemplateBinding Background}"
-                                                        CornerRadius="5">
-                                                        <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
-                                                            <TextBlock
-                                                                HorizontalAlignment="Center"
-                                                                FontFamily="{StaticResource FluentSystemIconsRegular}"
-                                                                FontSize="20"
-                                                                Foreground="LightSlateGray"
-                                                                Text="{x:Static utils:RegularFontUtil.Document_Add_16}" />
-                                                            <TextBlock Text="上传附件" />
-                                                        </StackPanel>
-                                                    </Border>
-                                                    <ControlTemplate.Triggers>
-                                                        <Trigger Property="IsMouseOver" Value="True">
-                                                            <Setter Property="Background" Value="LightGray" />
-                                                        </Trigger>
-                                                    </ControlTemplate.Triggers>
-                                                </ControlTemplate>
-                                            </Button.Template>
-                                        </Button>-->
                                             <Button
                                                 x:Name="DownLoadAttachmentButton"
                                                 Margin="3"
@@ -822,35 +789,6 @@
                                                     </ControlTemplate>
                                                 </Button.Template>
                                             </Button>
-                                            <!--<Button
-                                            x:Name="RemoveAttachmentButton"
-                                            Margin="3"
-                                            Command="{Binding RemoveAttachmentCommand}"
-                                            IsEnabled="False">
-                                            <Button.Template>
-                                                <ControlTemplate>
-                                                    <Border
-                                                        Width="60"
-                                                        Background="{TemplateBinding Background}"
-                                                        CornerRadius="5">
-                                                        <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
-                                                            <TextBlock
-                                                                HorizontalAlignment="Center"
-                                                                FontFamily="{StaticResource FluentSystemIconsRegular}"
-                                                                FontSize="20"
-                                                                Foreground="LightSlateGray"
-                                                                Text="{x:Static utils:RegularFontUtil.Document_Dismiss_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 />
                                             <TextBlock
                                                 x:Name="UnAttachmentText"
@@ -883,10 +821,6 @@
                                                 Foreground="Green"
                                                 Text="附件已上传"
                                                 Visibility="Collapsed" />
-                                            <!--<TextBlock
-                                            FontSize="12"
-                                            Foreground="Red"
-                                            Text="(*请选择PDF格式文件上传)" />-->
                                         </StackPanel>
 
                                     </Border>
@@ -1036,78 +970,6 @@
                                 BorderThickness="1">
                                 <ToolBarPanel>
                                     <ToolBar Background="White" ToolBarTray.IsLocked="True">
-                                        <!--<Button HorizontalContentAlignment="Center" Command="{Binding AddDetailCommand}">
-                                            <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_Square_20}" />
-                                                            <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 DeleteDetailCommand}">
-                                            <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.Dismiss_Square_20}" />
-                                                            <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 ImportDetailCommand}">
-                                            <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.Arrow_Enter_20}" />
-                                                            <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 ExportDetailCommand}">
                                             <Button.Template>
                                                 <ControlTemplate>
@@ -1175,11 +1037,6 @@
                                         <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" />
-                                    </Style>
                                 </control:FilterDataGrid.Resources>
                                 <control:FilterDataGrid.Columns>
                                     <control:FilterDataGridTextColumn

+ 24 - 25
UniformMaterialManagementSystem/Views/InspectionRecordPage.xaml.cs

@@ -19,6 +19,8 @@ namespace UniformMaterialManagementSystem.Views
             this.DataContext = App.Current.Services.GetService<InspectionRecordPageViewModel>();
 
             SetImportAndExportButtonVisible();
+
+            SetControlEnable();
         }
 
         private void SetImportAndExportButtonVisible()
@@ -35,19 +37,16 @@ namespace UniformMaterialManagementSystem.Views
             }
         }
 
-        private void InspectTypeText_TextChanged(object sender, TextChangedEventArgs e)
+        private void SetControlEnable()
         {
-            var text = InspectTypeText.Text;
-            switch (text)
+            var roleType = CommonUtil.GetRoleType();
+            switch (roleType)
             {
-                case "报样检验":
-                    FirstRadioButton.IsChecked = true;
-                    break;
-                case "首批检验":
-                    SecondRadioButton.IsChecked = true;
+                case RoleType.MaterialCompany:
+                    SelectedCompanyComboBox.IsEnabled = false;
                     break;
-                case "出厂检验":
-                    ThirdRadioButton.IsChecked = true;
+                default:
+                    SelectedCompanyComboBox.IsEnabled = true;
                     break;
             }
         }
@@ -88,20 +87,20 @@ namespace UniformMaterialManagementSystem.Views
             e.Row.Header = (e.Row.GetIndex() + 1).ToString();
         }
 
-        private void IsCompanyTextBox_TextChanged(object sender, TextChangedEventArgs e)
-        {
-            //生产企业
-            if (bool.Parse(IsCompanyTextBox.Text))
-            {
-                SelectedCompanyComboBox.Text = App.CurrentUser.CompanyName;
-                SelectedCompanyComboBox.IsEnabled = false;
-            }
-            //区域站
-            else
-            {
-                SelectedCompanyComboBox.IsEnabled = true;
-                SelectedCompanyComboBox.Text = "";
-            }
-        }
+        //private void IsCompanyTextBox_TextChanged(object sender, TextChangedEventArgs e)
+        //{
+        //    //生产企业
+        //    if (bool.Parse(IsCompanyTextBox.Text))
+        //    {
+        //        SelectedCompanyComboBox.Text = App.CurrentUser.CompanyName;
+        //        SelectedCompanyComboBox.IsEnabled = false;
+        //    }
+        //    //区域站
+        //    else
+        //    {
+        //        SelectedCompanyComboBox.IsEnabled = true;
+        //        SelectedCompanyComboBox.Text = "";
+        //    }
+        //}
     }
 }