Parcourir la source

Merge branch 'master' of https://git.xxb.lttc.cn/wangbc/UniformMaterialManagementSystem

宝臣 王 il y a 3 mois
Parent
commit
76df301377

+ 4 - 1
UniformMaterialManagementSystem/Entities/DeliveryReceipt.cs

@@ -67,11 +67,14 @@ namespace UniformMaterialManagementSystem.Entities
         public bool IsExportUsage { get; set; } = false;
 
         [NotMapped]
-        public decimal RemainQty { get; set; }
+        public decimal? HasShippedQty { get; set; } = null;
 
         [NotMapped]
         public bool IsNewRow { get; set; } = true;
 
+        [NotMapped]
+        public bool IsSelected { get; set; }
+
         // 发货、接收和使用使用同一张表,明细也用同一张表,三个模块分别控制不同的必录项
         public ObservableCollection<DeliveryReceiptDetail> DeliveryReceiptDetails { get; set; } = [];
 

Fichier diff supprimé car celui-ci est trop grand
+ 421 - 261
UniformMaterialManagementSystem/ViewModels/DeliveryReceiptViewModel.cs


+ 3 - 3
UniformMaterialManagementSystem/ViewModels/MaterialCompanyViewModel.cs

@@ -214,7 +214,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             {
                 StringBuilder illegalCodeMsg = new StringBuilder();
                 int firstIllegalRowIndex = Companies.Count;
-                foreach (var illegalCompany in illegalCodeCompanies)
+                foreach (Company illegalCompany in illegalCodeCompanies)
                 {
                     int rowIndex = Companies.IndexOf(illegalCompany);
                     illegalCodeMsg.Append($"\n第 {rowIndex} 行的代码 '{illegalCompany.Code}'");
@@ -324,7 +324,7 @@ namespace UniformMaterialManagementSystem.ViewModels
 
             // 新增行插入数据库
             int changedCount = 0;
-            foreach (var item in Companies)
+            foreach (Company item in Companies)
             {
                 // 跳过已保存行
                 if (!item.IsNewRow) { continue; }
@@ -363,7 +363,7 @@ namespace UniformMaterialManagementSystem.ViewModels
 
             // 数据库数据展示到界面
             Companies.Clear();
-            foreach (var company in data)
+            foreach (Company company in data)
             {
                 company.IsNewRow = false; // 已保存的行 IsNewRow 为 false
                 Companies.Add(company);

+ 9 - 7
UniformMaterialManagementSystem/ViewModels/MaterialViewModel.cs

@@ -33,7 +33,7 @@ namespace UniformMaterialManagementSystem.ViewModels
     {
         // 数据源
         [ObservableProperty]
-        private ObservableCollection<Material> _materials = new ObservableCollection<Material>();
+        private ObservableCollection<Material> _materials = [];
 
         private IDataBaseService<Material>? _service;
 
@@ -57,6 +57,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             if (cells.Count == 0) { return; }
             Material? currMaterial = cells[0].Item as Material;
             if (currMaterial == null) { return; }
+            //if (cells[0].Item is not Material currMaterial) { return; }
 
             foreach (DataGridColumn col in dataGridMaterial.Columns)
             {
@@ -135,10 +136,10 @@ namespace UniformMaterialManagementSystem.ViewModels
 
             // 检查新增行的必录项是否为空
             var nullMaterials = Materials.Where(x => x.IsNewRow && (string.IsNullOrEmpty(x.Name) || string.IsNullOrEmpty(x.VarietyCode) || string.IsNullOrEmpty(x.CategoryCode) || string.IsNullOrEmpty(x.Specification) || string.IsNullOrEmpty(x.MeasureUnit)));
-            if (nullMaterials.Count() > 0)
+            if (nullMaterials.Any())
             {
                 // 如果存在未填的必录项,则提示
-                Dictionary<int, int> nullIndexes = new Dictionary<int, int>();
+                Dictionary<int, int> nullIndexes = [];
                 StringBuilder nullMsg = new StringBuilder();
                 int firstNullRowIndex = Materials.Count;
                 foreach (Material nullItem in nullMaterials)
@@ -174,7 +175,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             // 保存时检查材料名称是否存在重复项
             var repeatNames = Materials.GroupBy(x => x.Name).Where(g => g.Count() > 1).Select(g => g.Key);
             StringBuilder repeatMsg = new StringBuilder();
-            Dictionary<int, int> repeatIndexes = new Dictionary<int, int>();
+            Dictionary<int, int> repeatIndexes = [];
             int firstRepeatRowIndex = Materials.Count;
             if (repeatNames.Any())
             {
@@ -388,7 +389,7 @@ namespace UniformMaterialManagementSystem.ViewModels
 
             // 获取数据源
             var materials = _service?.Query(x => x.IsEnabled);
-            if (materials == null || materials.Count() == 0) { return; }
+            if (materials == null || !materials.Any()) { return; }
 
             // 绑定到界面
             Materials.Clear();
@@ -514,8 +515,9 @@ namespace UniformMaterialManagementSystem.ViewModels
         private Material ConvertToEntity(DataRow dr)
         {
             Material material = new Material();
+            if (dr == null) { return material; }
+
             material.Guid = Guid.Parse(dr["内码"].ToString() ?? "");
-            if (dr == null) { return null; }
             material.Name = dr["材料名称*"].ToString() ?? "";
             material.VarietyCode = dr["品种代码*"].ToString() ?? "";
             material.CategoryCode = dr["材料类型代码*"].ToString() ?? "";
@@ -523,7 +525,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             material.MeasureUnit = dr["计量单位*"].ToString() ?? "";
             material.NormName = dr["材料规范名称"].ToString() ?? "";
             material.Note = dr["备注"].ToString();
-            material.IsEnabled = dr["是否可用"].ToString()!.Equals("是") ? true : false;
+            material.IsEnabled = dr["是否可用"].ToString()!.Equals("是");
             material.IsNewRow = false;  // 直接保存
 
             return material;

+ 16 - 8
UniformMaterialManagementSystem/ViewModels/SelectApplyContractDialogViewModel.cs

@@ -58,7 +58,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         public SelectApplyContractDialogViewModel()
         {
             // 当前用户为空,直接返回
-            if(_currUser == null) { return; }
+            if (_currUser == null) { return; }
 
             // 获取产品名称数据源
             var materials = App.Current.Services.GetService<IDataBaseService<Material>>()?.Query(x => x.IsEnabled);
@@ -96,6 +96,7 @@ namespace UniformMaterialManagementSystem.ViewModels
 
                 var scrollBar0 = FindVisualChild<ScrollBar>(fdgContractDetail); // null
                 var scrollBar = FindVisualChild<ScrollBar>(scrollViewer); // 能获取到
+                if (scrollBar == null) { return; }
 
                 double barWidth0 = scrollBar.ActualWidth; // 0
                 double barWidth1 = scrollBar.Width; // 17
@@ -140,6 +141,7 @@ namespace UniformMaterialManagementSystem.ViewModels
 
                 var scrollBar0 = FindVisualChild<ScrollBar>(fdgContractDetail); // null
                 var scrollBar = FindVisualChild<ScrollBar>(scrollViewer); // 能获取到
+                if (scrollBar == null) { return; }
 
                 double barWidth0 = scrollBar.ActualWidth; // 0
                 double barWidth1 = scrollBar.Width; // 17
@@ -214,7 +216,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             foreach (var contract in contracts)
             {
                 var details = contract.ContractDetails;
-                var count = details.Where(x => x.MaterialGuid.Equals(SelectedMaterial.Guid)).Count();
+                var count = details.Where(x => x.MaterialGuid.Equals(SelectedMaterial.Guid) && !x.ShippedStatus).Count();
                 if (count > 0)
                 {
                     mateContracts.Add(contract);
@@ -224,7 +226,7 @@ namespace UniformMaterialManagementSystem.ViewModels
 
             if (mateContracts.Count == 0)
             {
-                MessageBox.Show("该材料没有对应的合同数据!");
+                MessageBox.Show("该材料没有可发货的合同数据!");
                 return;
             }
             Contracts = new ObservableCollection<Contract>(mateContracts);
@@ -241,10 +243,11 @@ namespace UniformMaterialManagementSystem.ViewModels
 
             if (SelectedMaterial == null || SelectedContract == null) { return; }
 
-            // 筛选合同明细
-            var details = App.Current.Services.GetService<IDataBaseService<ContractDetail>>()?.Query(x => x.ContractGuid.Equals(SelectedContract.Guid) && x.MaterialGuid.Equals(SelectedMaterial.Guid))
-                .Include(x => x.Material);
-            if (details == null)
+            // 筛选合同明细:当前合同下,当前选择的产品名称,且未发货完成的明细
+            var details = App.Current.Services.GetService<IDataBaseService<ContractDetail>>()?
+                                              .Query(x => x.ContractGuid.Equals(SelectedContract.Guid) && x.MaterialGuid.Equals(SelectedMaterial.Guid) && !x.ShippedStatus)
+                                              .Include(x => x.Material);
+            if (details == null || !details.Any())
             {
                 MessageBox.Show("获取合同明细失败");
                 return;
@@ -272,7 +275,12 @@ namespace UniformMaterialManagementSystem.ViewModels
             // 如果选择了合同主表且子表只有一行明细,自动勾选明细
             if (SelectedContractDetail == null)
             {
-                if (ContractDetails.Count == 1)
+                if (ContractDetails.Count == 0)
+                {
+                    MessageBox.Show("当前合同下没有可发货的合同明细,请重新选择!");
+                    return;
+                }
+                else if (ContractDetails.Count == 1)
                 {
                     SelectedContractDetail = ContractDetails[0];
                 }

+ 10 - 22
UniformMaterialManagementSystem/Views/DeliveryReceiptControl.xaml

@@ -375,7 +375,7 @@
                     <!-- 调用方法:传递事件参数 -->
                     <!-- TargetObject="{Binding }" 表示目标对象是当前的数据上下文 -->
                     <b:CallMethodAction TargetObject="{Binding }" 
-                                        MethodName="fdgDelivery_SelectionChanged" />
+                                        MethodName="FdgDelivery_SelectionChanged" />
 
                 </b:EventTrigger>
             </b:Interaction.Triggers>
@@ -568,8 +568,8 @@
                                      IsEnabled="False"
                                      Style="{StaticResource CustomFieldTextBoxStyle}" />
 
-                            <!-- 检验合格数量、剩余数量:非保存列 -->
-                            <StackPanel x:Name="spRemainQty"
+                            <!-- 可发运数量:非保存列 -->
+                            <!--<StackPanel x:Name="spRemainQty"
                                         Orientation="Horizontal">
                                 <TextBlock Text="可发运数量:"
                                        Style="{StaticResource CustomTextBlockStyle}" />
@@ -578,7 +578,7 @@
                                        Foreground="Red"
                                        TextAlignment="Left"
                                        Style="{StaticResource CustomTextBlockStyle}" />
-                            </StackPanel>
+                            </StackPanel>-->
 
                         </WrapPanel>
                     </Grid>
@@ -760,7 +760,8 @@
                         Content="导入"
                         Tag="{x:Static utils:RegularFontUtil.Arrow_Circle_Down_32}"
                         Template="{StaticResource CustomToolBarButtomTemplate}"
-                        Command="{Binding ImportDetailCommand}" />
+                        Command="{Binding ImportDetailCommand}"
+                        CommandParameter="{Binding ElementName=fdgDelivery}"/>
                 <Button x:Name="btnExportDtl"
                         Content="导出"
                         Tag="{x:Static utils:RegularFontUtil.Arrow_Circle_Up_32}"
@@ -812,23 +813,22 @@
                 <!-- 选择单元格切换事件 -->
                 <b:EventTrigger EventName="SelectedCellsChanged">
                     <b:CallMethodAction TargetObject="{Binding }"
-                                        MethodName="fdgDeliveryDetail_SelectedCellsChanged" />
+                                        MethodName="FdgDeliveryDetail_SelectedCellsChanged" />
                 </b:EventTrigger>
 
             </b:Interaction.Triggers>
 
             <!-- 数据结构 -->
             <fdg:FilterDataGrid.Columns>
-                <!--<DataGridTextColumn Header="序号" Width="*" />-->
                 <fdg:FilterDataGridCheckBoxColumn Header="  " Width="30"
                                                   ElementStyle="{StaticResource CheckBoxColumnElementStyle}"
                                                   EditingElementStyle="{StaticResource CheckBoxColumnElementStyle}"
-                                                  Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=DataGridRow}, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
-                <fdg:FilterDataGridTextColumn Header="批次号" Width="100"
+                                                  Binding="{Binding IsSelected, UpdateSourceTrigger=PropertyChanged}"/>
+                <fdg:FilterDataGridTextColumn Header="材料批号" Width="200"
                                               ElementStyle="{StaticResource TextColumnElementStyle}"
                                               EditingElementStyle="{StaticResource TextColumnEditingStyle}"
                                               Binding="{Binding BatchNo, UpdateSourceTrigger=PropertyChanged}" />
-                <fdg:FilterDataGridTextColumn Header="材料包号" Width="100"
+                <fdg:FilterDataGridTextColumn Header="包号" Width="100"
                                               ElementStyle="{StaticResource TextColumnElementStyle}"
                                               EditingElementStyle="{StaticResource TextColumnEditingStyle}"
                                               Binding="{Binding PacketNo, UpdateSourceTrigger=PropertyChanged}" />
@@ -848,22 +848,10 @@
                                               ElementStyle="{StaticResource TextColumnElementStyle}"
                                               EditingElementStyle="{StaticResource TextColumnEditingStyle}"
                                               Binding="{Binding UsageStatus}" />
-                <!-- 不可编辑:直接使用Text类型列,直接赋值 -->
-                <!--<fdg:FilterDataGridComboBoxColumn Header="使用状态" Width="100"
-                                                  SelectedItemBinding="{Binding UsageStatus, UpdateSourceTrigger=PropertyChanged}">
-                    <DataGridComboBoxColumn.ItemsSource>
-                        <x:Array Type="sys:String" >
-                            <sys:String>未使用</sys:String>
-                            <sys:String>部分使用</sys:String>
-                            <sys:String>全部使用</sys:String>
-                        </x:Array>
-                    </DataGridComboBoxColumn.ItemsSource>
-                </fdg:FilterDataGridComboBoxColumn>-->
                 <fdg:FilterDataGridTextColumn Header="备注" Width="200"
                                               ElementStyle="{StaticResource TextColumnElementStyle}"
                                               EditingElementStyle="{StaticResource TextColumnEditingStyle}"
                                               Binding="{Binding ShipNote, UpdateSourceTrigger=PropertyChanged}" />
-                
             </fdg:FilterDataGrid.Columns>
         </fdg:FilterDataGrid>
     </Grid>

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff