Quellcode durchsuchen

feat: 添加材料发货单三个页面

JaneDoe vor 3 Monaten
Ursprung
Commit
7a36f816b4
21 geänderte Dateien mit 2351 neuen und 345 gelöschten Zeilen
  1. 3 0
      UniformMaterialManagementSystem/App.xaml.cs
  2. 8 10
      UniformMaterialManagementSystem/Entities/DeliveryReceipt.cs
  3. 4 2
      UniformMaterialManagementSystem/Entities/DeliveryReceiptDetail.cs
  4. 1235 0
      UniformMaterialManagementSystem/Migrations/20240813031746_Modify_Delivery.Designer.cs
  5. 104 0
      UniformMaterialManagementSystem/Migrations/20240813031746_Modify_Delivery.cs
  6. 39 27
      UniformMaterialManagementSystem/Migrations/SqliteContextModelSnapshot.cs
  7. BIN
      UniformMaterialManagementSystem/Resources/Pictures/MaterialDelivery.png
  8. BIN
      UniformMaterialManagementSystem/Resources/Pictures/MaterialReceipt.png
  9. BIN
      UniformMaterialManagementSystem/Resources/Pictures/MaterialUsage.png
  10. 321 40
      UniformMaterialManagementSystem/ViewModels/DeliveryReceiptViewModel.cs
  11. 62 43
      UniformMaterialManagementSystem/ViewModels/SelectApplyContractDialogViewModel.cs
  12. 1 2
      UniformMaterialManagementSystem/ViewModels/UsersViewModel.cs
  13. 405 214
      UniformMaterialManagementSystem/Views/DeliveryReceiptControl.xaml
  14. 11 3
      UniformMaterialManagementSystem/Views/DeliveryReceiptControl.xaml.cs
  15. 17 0
      UniformMaterialManagementSystem/Views/MaterialDeliveryPage.xaml
  16. 33 0
      UniformMaterialManagementSystem/Views/MaterialDeliveryPage.xaml.cs
  17. 17 0
      UniformMaterialManagementSystem/Views/MaterialReceiptPage.xaml
  18. 32 0
      UniformMaterialManagementSystem/Views/MaterialReceiptPage.xaml.cs
  19. 18 0
      UniformMaterialManagementSystem/Views/MaterialUsagePage.xaml
  20. 32 0
      UniformMaterialManagementSystem/Views/MaterialUsagePage.xaml.cs
  21. 9 4
      UniformMaterialManagementSystem/Views/SelectApplyContractDialog.xaml

+ 3 - 0
UniformMaterialManagementSystem/App.xaml.cs

@@ -75,6 +75,9 @@ namespace UniformMaterialManagementSystem
             services.AddKeyedTransient<UserControl, InspectionOrganizationPage>("InspectionOrganizationPage");
             services.AddKeyedTransient<UserControl, InspectionOrganizationPage>("InspectionOrganizationPage");
             services.AddKeyedTransient<UserControl, FactoryLicensePage>("FactoryLicensePage");
+            services.AddKeyedTransient<UserControl, MaterialDeliveryPage>("MaterialDeliveryPage");
+            services.AddKeyedTransient<UserControl, MaterialReceiptPage>("MaterialReceiptPage");
+            services.AddKeyedTransient<UserControl, MaterialUsagePage>("MaterialUsagePage");
             services.AddKeyedTransient<UserControl, InspectApplyAndInspectionRecordPage>("InspectApplyAndInspectionRecordPage");
 
             // ViewModel 注册

+ 8 - 10
UniformMaterialManagementSystem/Entities/DeliveryReceipt.cs

@@ -14,6 +14,7 @@ namespace UniformMaterialManagementSystem.Entities
         [Key]
         public Guid Guid { get; set; } = Guid.NewGuid();
 
+        // todo 用没用到,转为 NotMapped ?
         public string ApplyNo { get; set; } = string.Empty;
 
         public Guid ContractGuid { get; set; } = default!;
@@ -32,8 +33,6 @@ namespace UniformMaterialManagementSystem.Entities
 
         public string ReceivedCompanyName { get; set; } = null!;
 
-        public string BatchNo { get; set; } = null!;
-
         // todo default! 0! 0 三种情况分别表示什么意思?在这用什么比较合适
         public int ShippedPackets { get; set; } = 0!;
 
@@ -59,20 +58,19 @@ namespace UniformMaterialManagementSystem.Entities
 
         public byte[]? Licence { get; set; } = null!;
 
-        //[NotMapped]
-        //public double InspQty { get; set; }
+        public int WorkYear { get; set; }
 
-        [NotMapped]
-        public double RemainQty { get; set; }
+        public bool IsExportDelivery { get; set; } = false;
 
-        [NotMapped]
-        public bool IsNewRow { get; set; } = true;
+        public bool IsExportReceive { get; set; } = false;
+
+        public bool IsExportUsage { get; set; } = false;
 
         [NotMapped]
-        public bool IsReported { get; set; } = false;
+        public double RemainQty { get; set; }
 
         [NotMapped]
-        public int WorkYear { get; set; }
+        public bool IsNewRow { get; set; } = true;
 
         // 发货、接收和使用使用同一张表,明细也用同一张表,三个模块分别控制不同的必录项
         public ObservableCollection<DeliveryReceiptDetail> DeliveryReceiptDetails { get; set; } = [];

+ 4 - 2
UniformMaterialManagementSystem/Entities/DeliveryReceiptDetail.cs

@@ -15,15 +15,17 @@ namespace UniformMaterialManagementSystem.Entities
 
         public Guid DeliveryReceiptGuid { get; set; } = default!;
 
+        public string BatchNo { get; set; } = null!;
+
         public string PacketNo { get; set; } = null!;
         
         public double ShippedQuantity { get; set; } = 0!;
 
         public double? ReceiveQuantity { get; set; }
 
-        public double? UseQuantity { get; set; }
+        public double? UsageQuantity { get; set; }
 
-        public string? UseStatus { get; set; }
+        public string? UsageStatus { get; set; }
 
         public string? ShipNote { get; set; }
 

+ 1235 - 0
UniformMaterialManagementSystem/Migrations/20240813031746_Modify_Delivery.Designer.cs

@@ -0,0 +1,1235 @@
+// <auto-generated />
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using UniformMaterialManagementSystem.Data;
+
+#nullable disable
+
+namespace UniformMaterialManagementSystem.Migrations
+{
+    [DbContext(typeof(SqliteContext))]
+    [Migration("20240813031746_Modify_Delivery")]
+    partial class Modify_Delivery
+    {
+        /// <inheritdoc />
+        protected override void BuildTargetModel(ModelBuilder modelBuilder)
+        {
+#pragma warning disable 612, 618
+            modelBuilder.HasAnnotation("ProductVersion", "7.0.20");
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.Company", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Address")
+                        .HasMaxLength(100)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Category")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Code")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<bool>("IsEnabled")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<string>("Manager")
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Name")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Note")
+                        .HasMaxLength(100)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ShortName")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("SystemCode")
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.HasKey("Guid");
+
+                    b.ToTable("Companies");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.Contract", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<byte[]>("ApplyAttachment")
+                        .HasColumnType("BLOB");
+
+                    b.Property<byte[]>("Attachment")
+                        .HasColumnType("BLOB");
+
+                    b.Property<bool>("ChangedStatus")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<Guid>("CompanyGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ContractNo")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<DateTime>("EditDate")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("EditUser")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<bool>("ExportStatus")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<Guid>("PurchaseCompanyGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<DateTime>("SigningDate")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Telephone")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<int>("Year")
+                        .HasColumnType("INTEGER");
+
+                    b.HasKey("Guid");
+
+                    b.HasIndex("CompanyGuid");
+
+                    b.HasIndex("PurchaseCompanyGuid");
+
+                    b.ToTable("Contracts");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.ContractDetail", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("ContractGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<double>("ContractQty")
+                        .HasColumnType("REAL");
+
+                    b.Property<DateTime>("DeliveryTime")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("InspectStatus")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<double>("InspectedQty")
+                        .HasColumnType("REAL");
+
+                    b.Property<Guid>("MaterialGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<double>("ReduceQuantity")
+                        .HasColumnType("REAL");
+
+                    b.Property<double>("ShippedQuantity")
+                        .HasColumnType("REAL");
+
+                    b.Property<bool>("ShippedStatus")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<double>("UnitPrice")
+                        .HasColumnType("REAL");
+
+                    b.HasKey("Guid");
+
+                    b.HasIndex("ContractGuid");
+
+                    b.HasIndex("MaterialGuid");
+
+                    b.ToTable("ContractDetails");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.DeliveryReceipt", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ApplyNo")
+                        .IsRequired()
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("CompanyName")
+                        .IsRequired()
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("ContractGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ContractNo")
+                        .IsRequired()
+                        .HasColumnType("TEXT");
+
+                    b.Property<double>("ContractQty")
+                        .HasColumnType("REAL");
+
+                    b.Property<DateTime>("ContractSigningDate")
+                        .HasColumnType("TEXT");
+
+                    b.Property<bool>("IsExportDelivery")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<bool>("IsExportReceive")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<bool>("IsExportUsage")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<byte[]>("Licence")
+                        .HasColumnType("BLOB");
+
+                    b.Property<string>("ProductName")
+                        .IsRequired()
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("PurchaseCompanyName")
+                        .IsRequired()
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ReceivedCompanyName")
+                        .IsRequired()
+                        .HasColumnType("TEXT");
+
+                    b.Property<DateTime?>("ReceivedDate")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ReceivedMan")
+                        .HasColumnType("TEXT");
+
+                    b.Property<int?>("ReceivedPackets")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<double?>("ReceivedQty")
+                        .HasColumnType("REAL");
+
+                    b.Property<string>("ReceivedStatus")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ReceivedTel")
+                        .HasColumnType("TEXT");
+
+                    b.Property<DateTime>("ShippedDate")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ShippedMan")
+                        .HasColumnType("TEXT");
+
+                    b.Property<int>("ShippedPackets")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<double>("ShippedQty")
+                        .HasColumnType("REAL");
+
+                    b.Property<string>("ShippedTel")
+                        .HasColumnType("TEXT");
+
+                    b.Property<int>("WorkYear")
+                        .HasColumnType("INTEGER");
+
+                    b.HasKey("Guid");
+
+                    b.ToTable("DeliveryReceipts");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.DeliveryReceiptDetail", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("BatchNo")
+                        .IsRequired()
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("DeliveryReceiptGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("PacketNo")
+                        .IsRequired()
+                        .HasColumnType("TEXT");
+
+                    b.Property<double?>("ReceiveQuantity")
+                        .HasColumnType("REAL");
+
+                    b.Property<string>("ShipNote")
+                        .HasColumnType("TEXT");
+
+                    b.Property<double>("ShippedQuantity")
+                        .HasColumnType("REAL");
+
+                    b.Property<double?>("UsageQuantity")
+                        .HasColumnType("REAL");
+
+                    b.Property<string>("UsageStatus")
+                        .HasColumnType("TEXT");
+
+                    b.HasKey("Guid");
+
+                    b.HasIndex("DeliveryReceiptGuid");
+
+                    b.ToTable("DeliveryReceiptDetails");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.FactoryLicense", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ApproveUser")
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("AuditUser")
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Department")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("EditUser")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<DateTime>("FactoryDate")
+                        .HasColumnType("TEXT");
+
+                    b.Property<double>("FactoryQuantity")
+                        .HasColumnType("REAL");
+
+                    b.Property<Guid>("InspectApplyGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("LicenseListNo")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("LicenseNo")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<DateTime>("SignDate")
+                        .HasColumnType("TEXT");
+
+                    b.HasKey("Guid");
+
+                    b.HasIndex("InspectApplyGuid");
+
+                    b.ToTable("FactoryLicenses");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectApply", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ApplyDescription")
+                        .HasMaxLength(1000)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ApplyNo")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<DateTime?>("ApplyReceiveDate")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ApplyUser")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("BatchNo")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Company")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("CompanyGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<DateTime>("EndProductDate")
+                        .HasColumnType("TEXT");
+
+                    b.Property<int>("ExportStatus")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<string>("InspCategory")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<DateTime>("InspDate")
+                        .HasColumnType("TEXT");
+
+                    b.Property<double>("InspQuantity")
+                        .HasColumnType("REAL");
+
+                    b.Property<byte[]>("InspReport")
+                        .HasColumnType("BLOB");
+
+                    b.Property<string>("InspReportNo")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<bool>("LicenseStatus")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<Guid>("MaterialGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ProductName")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<bool>("ReportStatus")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<bool>("SampleStatus")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<DateTime>("StartProductDate")
+                        .HasColumnType("TEXT");
+
+                    b.Property<int>("Year")
+                        .HasColumnType("INTEGER");
+
+                    b.HasKey("Guid");
+
+                    b.HasIndex("CompanyGuid");
+
+                    b.HasIndex("MaterialGuid");
+
+                    b.ToTable("InspectApplies");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectApplyContractDetail", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("ApplyGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ApplyNo")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("ContractDetailGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ContractNo")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<double>("InspectQty")
+                        .HasColumnType("REAL");
+
+                    b.Property<string>("PurchaseCompany")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("PurchaseCompanyShortName")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("SigningDate")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<double>("UnInspectQty")
+                        .HasColumnType("REAL");
+
+                    b.HasKey("Guid");
+
+                    b.HasIndex("ApplyGuid");
+
+                    b.ToTable("InspectApplyContractDetails");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectApplyDetail", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("ApplyGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ApplyNo")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Note")
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("PacketNo")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<double>("Quantity")
+                        .HasColumnType("REAL");
+
+                    b.Property<bool>("ShippedStatus")
+                        .HasColumnType("INTEGER");
+
+                    b.HasKey("Guid");
+
+                    b.HasIndex("ApplyGuid");
+
+                    b.ToTable("InspectApplyDetails");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectionOrganization", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Address")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Contacts")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<bool>("IsEnabled")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<string>("Name")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<int>("OrderNo")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<string>("Telephone")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.HasKey("Guid");
+
+                    b.ToTable("InspectionOrganizations");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectionReport", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Conclusion")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ConclusionDesc")
+                        .IsRequired()
+                        .HasMaxLength(1000)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Department")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("EditUser")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("InspectApplyGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<bool>("IsSample")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<string>("ReportBasis")
+                        .IsRequired()
+                        .HasMaxLength(200)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ReportDesc")
+                        .IsRequired()
+                        .HasMaxLength(1000)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ReportNo")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<DateTime>("ReportTime")
+                        .HasColumnType("TEXT");
+
+                    b.HasKey("Guid");
+
+                    b.HasIndex("InspectApplyGuid");
+
+                    b.ToTable("InspectionReports");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectionReportDetail", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("InspectionReportGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Inspector")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("JobCategory")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("SupervisionUnit")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.HasKey("Guid");
+
+                    b.HasIndex("InspectionReportGuid");
+
+                    b.ToTable("InspectionReportDetails");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.Material", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("CategoryCode")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<bool>("IsEnabled")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<string>("MeasureUnit")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Name")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("NormName")
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Note")
+                        .HasMaxLength(100)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Specification")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("VarietyCode")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.HasKey("Guid");
+
+                    b.ToTable("Materials");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.MenuItem", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Icon")
+                        .HasMaxLength(100)
+                        .HasColumnType("TEXT");
+
+                    b.Property<bool>("IsEnabled")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<bool>("IsVisible")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<string>("Name")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<int>("OrderIndex")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<Guid?>("ParentGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Path")
+                        .HasMaxLength(100)
+                        .HasColumnType("TEXT");
+
+                    b.HasKey("Guid");
+
+                    b.HasIndex("ParentGuid");
+
+                    b.ToTable("MenuItems");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.Role", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Description")
+                        .IsRequired()
+                        .HasMaxLength(100)
+                        .HasColumnType("TEXT");
+
+                    b.Property<bool>("IsEnabled")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<string>("Name")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.HasKey("Guid");
+
+                    b.ToTable("Roles");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.RoleMenuItem", b =>
+                {
+                    b.Property<Guid>("MenuItemGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("RoleGuid")
+                        .HasColumnType("TEXT");
+
+                    b.HasKey("MenuItemGuid", "RoleGuid");
+
+                    b.HasIndex("RoleGuid");
+
+                    b.ToTable("RoleMenuItems");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.SampleRegistration", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("BatchNo")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Department")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<DateTime>("EditTime")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("EditUser")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("InspectApplyGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("InspectionOrganization")
+                        .IsRequired()
+                        .HasMaxLength(500)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("PacketNo")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<DateTime>("ProductDate")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ProductUsers")
+                        .HasMaxLength(100)
+                        .HasColumnType("TEXT");
+
+                    b.Property<double>("Quantity")
+                        .HasColumnType("REAL");
+
+                    b.Property<string>("SampleNo")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("SingleIndexItem")
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Telephone")
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("TestingItem")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.HasKey("Guid");
+
+                    b.HasIndex("InspectApplyGuid");
+
+                    b.ToTable("SampleRegistrations");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.SerialNumber", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("CompanyCode")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("CompanyGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("InspCategory")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("MaxNumber")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("SupervisionUnitGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<int>("Year")
+                        .HasColumnType("INTEGER");
+
+                    b.HasKey("Guid");
+
+                    b.ToTable("SerialNumbers");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.SupervisionUnit", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<bool>("IsEnabled")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<string>("Name")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Note")
+                        .HasMaxLength(100)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("ShortName")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.HasKey("Guid");
+
+                    b.ToTable("SupervisionUnits");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.User", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid?>("CompanyGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("CompanyName")
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("IdNumber")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<bool>("IsEnabled")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<string>("LoginName")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Password")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<DateTime>("RegisterDate")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("Salt")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("SupervisionUnitGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("UserName")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("TEXT");
+
+                    b.HasKey("Guid");
+
+                    b.HasIndex("CompanyGuid");
+
+                    b.HasIndex("SupervisionUnitGuid");
+
+                    b.ToTable("Users");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.UserRole", b =>
+                {
+                    b.Property<Guid>("RoleGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("UserGuid")
+                        .HasColumnType("TEXT");
+
+                    b.HasKey("RoleGuid", "UserGuid");
+
+                    b.HasIndex("UserGuid");
+
+                    b.ToTable("UserRoles");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.Contract", b =>
+                {
+                    b.HasOne("UniformMaterialManagementSystem.Entities.Company", "Company")
+                        .WithMany()
+                        .HasForeignKey("CompanyGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.HasOne("UniformMaterialManagementSystem.Entities.Company", "PurchaseCompany")
+                        .WithMany()
+                        .HasForeignKey("PurchaseCompanyGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("Company");
+
+                    b.Navigation("PurchaseCompany");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.ContractDetail", b =>
+                {
+                    b.HasOne("UniformMaterialManagementSystem.Entities.Contract", "Contract")
+                        .WithMany("ContractDetails")
+                        .HasForeignKey("ContractGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.HasOne("UniformMaterialManagementSystem.Entities.Material", "Material")
+                        .WithMany()
+                        .HasForeignKey("MaterialGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("Contract");
+
+                    b.Navigation("Material");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.DeliveryReceiptDetail", b =>
+                {
+                    b.HasOne("UniformMaterialManagementSystem.Entities.DeliveryReceipt", null)
+                        .WithMany("DeliveryReceiptDetails")
+                        .HasForeignKey("DeliveryReceiptGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.FactoryLicense", b =>
+                {
+                    b.HasOne("UniformMaterialManagementSystem.Entities.InspectApply", "InspectApply")
+                        .WithMany()
+                        .HasForeignKey("InspectApplyGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("InspectApply");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectApply", b =>
+                {
+                    b.HasOne("UniformMaterialManagementSystem.Entities.Company", "MaterialCompany")
+                        .WithMany()
+                        .HasForeignKey("CompanyGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.HasOne("UniformMaterialManagementSystem.Entities.Material", "Material")
+                        .WithMany()
+                        .HasForeignKey("MaterialGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("Material");
+
+                    b.Navigation("MaterialCompany");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectApplyContractDetail", b =>
+                {
+                    b.HasOne("UniformMaterialManagementSystem.Entities.InspectApply", "InspectApply")
+                        .WithMany("InspectApplyContractDetails")
+                        .HasForeignKey("ApplyGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("InspectApply");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectApplyDetail", b =>
+                {
+                    b.HasOne("UniformMaterialManagementSystem.Entities.InspectApply", "InspectApply")
+                        .WithMany("InspectApplyDetails")
+                        .HasForeignKey("ApplyGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("InspectApply");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectionReport", b =>
+                {
+                    b.HasOne("UniformMaterialManagementSystem.Entities.InspectApply", "InspectApply")
+                        .WithMany()
+                        .HasForeignKey("InspectApplyGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("InspectApply");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectionReportDetail", b =>
+                {
+                    b.HasOne("UniformMaterialManagementSystem.Entities.InspectionReport", "InspectionReport")
+                        .WithMany("InspectionReportDetails")
+                        .HasForeignKey("InspectionReportGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("InspectionReport");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.MenuItem", b =>
+                {
+                    b.HasOne("UniformMaterialManagementSystem.Entities.MenuItem", "Parent")
+                        .WithMany("Children")
+                        .HasForeignKey("ParentGuid")
+                        .OnDelete(DeleteBehavior.Restrict);
+
+                    b.Navigation("Parent");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.RoleMenuItem", b =>
+                {
+                    b.HasOne("UniformMaterialManagementSystem.Entities.MenuItem", "MenuItem")
+                        .WithMany("MenuRoles")
+                        .HasForeignKey("MenuItemGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.HasOne("UniformMaterialManagementSystem.Entities.Role", "Role")
+                        .WithMany("RoleMenus")
+                        .HasForeignKey("RoleGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("MenuItem");
+
+                    b.Navigation("Role");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.SampleRegistration", b =>
+                {
+                    b.HasOne("UniformMaterialManagementSystem.Entities.InspectApply", "InspectApply")
+                        .WithMany()
+                        .HasForeignKey("InspectApplyGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("InspectApply");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.User", b =>
+                {
+                    b.HasOne("UniformMaterialManagementSystem.Entities.Company", "Company")
+                        .WithMany()
+                        .HasForeignKey("CompanyGuid");
+
+                    b.HasOne("UniformMaterialManagementSystem.Entities.SupervisionUnit", "SupervisionUnit")
+                        .WithMany()
+                        .HasForeignKey("SupervisionUnitGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("Company");
+
+                    b.Navigation("SupervisionUnit");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.UserRole", b =>
+                {
+                    b.HasOne("UniformMaterialManagementSystem.Entities.Role", "Role")
+                        .WithMany("UserRoles")
+                        .HasForeignKey("RoleGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.HasOne("UniformMaterialManagementSystem.Entities.User", "User")
+                        .WithMany("UserRoles")
+                        .HasForeignKey("UserGuid")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("Role");
+
+                    b.Navigation("User");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.Contract", b =>
+                {
+                    b.Navigation("ContractDetails");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.DeliveryReceipt", b =>
+                {
+                    b.Navigation("DeliveryReceiptDetails");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectApply", b =>
+                {
+                    b.Navigation("InspectApplyContractDetails");
+
+                    b.Navigation("InspectApplyDetails");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectionReport", b =>
+                {
+                    b.Navigation("InspectionReportDetails");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.MenuItem", b =>
+                {
+                    b.Navigation("Children");
+
+                    b.Navigation("MenuRoles");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.Role", b =>
+                {
+                    b.Navigation("RoleMenus");
+
+                    b.Navigation("UserRoles");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.User", b =>
+                {
+                    b.Navigation("UserRoles");
+                });
+#pragma warning restore 612, 618
+        }
+    }
+}

+ 104 - 0
UniformMaterialManagementSystem/Migrations/20240813031746_Modify_Delivery.cs

@@ -0,0 +1,104 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace UniformMaterialManagementSystem.Migrations
+{
+    /// <inheritdoc />
+    public partial class Modify_Delivery : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropColumn(
+                name: "BatchNo",
+                table: "DeliveryReceipts");
+
+            migrationBuilder.RenameColumn(
+                name: "UseStatus",
+                table: "DeliveryReceiptDetails",
+                newName: "UsageStatus");
+
+            migrationBuilder.RenameColumn(
+                name: "UseQuantity",
+                table: "DeliveryReceiptDetails",
+                newName: "UsageQuantity");
+
+            migrationBuilder.AddColumn<bool>(
+                name: "IsExportDelivery",
+                table: "DeliveryReceipts",
+                type: "INTEGER",
+                nullable: false,
+                defaultValue: false);
+
+            migrationBuilder.AddColumn<bool>(
+                name: "IsExportReceive",
+                table: "DeliveryReceipts",
+                type: "INTEGER",
+                nullable: false,
+                defaultValue: false);
+
+            migrationBuilder.AddColumn<bool>(
+                name: "IsExportUsage",
+                table: "DeliveryReceipts",
+                type: "INTEGER",
+                nullable: false,
+                defaultValue: false);
+
+            migrationBuilder.AddColumn<int>(
+                name: "WorkYear",
+                table: "DeliveryReceipts",
+                type: "INTEGER",
+                nullable: false,
+                defaultValue: 0);
+
+            migrationBuilder.AddColumn<string>(
+                name: "BatchNo",
+                table: "DeliveryReceiptDetails",
+                type: "TEXT",
+                nullable: false,
+                defaultValue: "");
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropColumn(
+                name: "IsExportDelivery",
+                table: "DeliveryReceipts");
+
+            migrationBuilder.DropColumn(
+                name: "IsExportReceive",
+                table: "DeliveryReceipts");
+
+            migrationBuilder.DropColumn(
+                name: "IsExportUsage",
+                table: "DeliveryReceipts");
+
+            migrationBuilder.DropColumn(
+                name: "WorkYear",
+                table: "DeliveryReceipts");
+
+            migrationBuilder.DropColumn(
+                name: "BatchNo",
+                table: "DeliveryReceiptDetails");
+
+            migrationBuilder.RenameColumn(
+                name: "UsageStatus",
+                table: "DeliveryReceiptDetails",
+                newName: "UseStatus");
+
+            migrationBuilder.RenameColumn(
+                name: "UsageQuantity",
+                table: "DeliveryReceiptDetails",
+                newName: "UseQuantity");
+
+            migrationBuilder.AddColumn<string>(
+                name: "BatchNo",
+                table: "DeliveryReceipts",
+                type: "TEXT",
+                nullable: false,
+                defaultValue: "");
+        }
+    }
+}

+ 39 - 27
UniformMaterialManagementSystem/Migrations/SqliteContextModelSnapshot.cs

@@ -64,7 +64,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasKey("Guid");
 
-                    b.ToTable("Companies", (string)null);
+                    b.ToTable("Companies");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.Contract", b =>
@@ -121,7 +121,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasIndex("PurchaseCompanyGuid");
 
-                    b.ToTable("Contracts", (string)null);
+                    b.ToTable("Contracts");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.ContractDetail", b =>
@@ -168,7 +168,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasIndex("MaterialGuid");
 
-                    b.ToTable("ContractDetails", (string)null);
+                    b.ToTable("ContractDetails");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.DeliveryReceipt", b =>
@@ -181,10 +181,6 @@ namespace UniformMaterialManagementSystem.Migrations
                         .IsRequired()
                         .HasColumnType("TEXT");
 
-                    b.Property<string>("BatchNo")
-                        .IsRequired()
-                        .HasColumnType("TEXT");
-
                     b.Property<string>("CompanyName")
                         .IsRequired()
                         .HasColumnType("TEXT");
@@ -202,6 +198,15 @@ namespace UniformMaterialManagementSystem.Migrations
                     b.Property<DateTime>("ContractSigningDate")
                         .HasColumnType("TEXT");
 
+                    b.Property<bool>("IsExportDelivery")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<bool>("IsExportReceive")
+                        .HasColumnType("INTEGER");
+
+                    b.Property<bool>("IsExportUsage")
+                        .HasColumnType("INTEGER");
+
                     b.Property<byte[]>("Licence")
                         .HasColumnType("BLOB");
 
@@ -250,9 +255,12 @@ namespace UniformMaterialManagementSystem.Migrations
                     b.Property<string>("ShippedTel")
                         .HasColumnType("TEXT");
 
+                    b.Property<int>("WorkYear")
+                        .HasColumnType("INTEGER");
+
                     b.HasKey("Guid");
 
-                    b.ToTable("DeliveryReceipts", (string)null);
+                    b.ToTable("DeliveryReceipts");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.DeliveryReceiptDetail", b =>
@@ -261,6 +269,10 @@ namespace UniformMaterialManagementSystem.Migrations
                         .ValueGeneratedOnAdd()
                         .HasColumnType("TEXT");
 
+                    b.Property<string>("BatchNo")
+                        .IsRequired()
+                        .HasColumnType("TEXT");
+
                     b.Property<Guid>("DeliveryReceiptGuid")
                         .HasColumnType("TEXT");
 
@@ -277,17 +289,17 @@ namespace UniformMaterialManagementSystem.Migrations
                     b.Property<double>("ShippedQuantity")
                         .HasColumnType("REAL");
 
-                    b.Property<double?>("UseQuantity")
+                    b.Property<double?>("UsageQuantity")
                         .HasColumnType("REAL");
 
-                    b.Property<string>("UseStatus")
+                    b.Property<string>("UsageStatus")
                         .HasColumnType("TEXT");
 
                     b.HasKey("Guid");
 
                     b.HasIndex("DeliveryReceiptGuid");
 
-                    b.ToTable("DeliveryReceiptDetails", (string)null);
+                    b.ToTable("DeliveryReceiptDetails");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.FactoryLicense", b =>
@@ -340,7 +352,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasIndex("InspectApplyGuid");
 
-                    b.ToTable("FactoryLicenses", (string)null);
+                    b.ToTable("FactoryLicenses");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectApply", b =>
@@ -433,7 +445,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasIndex("MaterialGuid");
 
-                    b.ToTable("InspectApplies", (string)null);
+                    b.ToTable("InspectApplies");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectApplyContractDetail", b =>
@@ -483,7 +495,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasIndex("ApplyGuid");
 
-                    b.ToTable("InspectApplyContractDetails", (string)null);
+                    b.ToTable("InspectApplyContractDetails");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectApplyDetail", b =>
@@ -519,7 +531,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasIndex("ApplyGuid");
 
-                    b.ToTable("InspectApplyDetails", (string)null);
+                    b.ToTable("InspectApplyDetails");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectionOrganization", b =>
@@ -556,7 +568,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasKey("Guid");
 
-                    b.ToTable("InspectionOrganizations", (string)null);
+                    b.ToTable("InspectionOrganizations");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectionReport", b =>
@@ -613,7 +625,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasIndex("InspectApplyGuid");
 
-                    b.ToTable("InspectionReports", (string)null);
+                    b.ToTable("InspectionReports");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.InspectionReportDetail", b =>
@@ -644,7 +656,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasIndex("InspectionReportGuid");
 
-                    b.ToTable("InspectionReportDetails", (string)null);
+                    b.ToTable("InspectionReportDetails");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.Material", b =>
@@ -691,7 +703,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasKey("Guid");
 
-                    b.ToTable("Materials", (string)null);
+                    b.ToTable("Materials");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.MenuItem", b =>
@@ -729,7 +741,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasIndex("ParentGuid");
 
-                    b.ToTable("MenuItems", (string)null);
+                    b.ToTable("MenuItems");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.Role", b =>
@@ -753,7 +765,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasKey("Guid");
 
-                    b.ToTable("Roles", (string)null);
+                    b.ToTable("Roles");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.RoleMenuItem", b =>
@@ -768,7 +780,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasIndex("RoleGuid");
 
-                    b.ToTable("RoleMenuItems", (string)null);
+                    b.ToTable("RoleMenuItems");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.SampleRegistration", b =>
@@ -840,7 +852,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasIndex("InspectApplyGuid");
 
-                    b.ToTable("SampleRegistrations", (string)null);
+                    b.ToTable("SampleRegistrations");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.SerialNumber", b =>
@@ -875,7 +887,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasKey("Guid");
 
-                    b.ToTable("SerialNumbers", (string)null);
+                    b.ToTable("SerialNumbers");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.SupervisionUnit", b =>
@@ -903,7 +915,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasKey("Guid");
 
-                    b.ToTable("SupervisionUnits", (string)null);
+                    b.ToTable("SupervisionUnits");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.User", b =>
@@ -959,7 +971,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasIndex("SupervisionUnitGuid");
 
-                    b.ToTable("Users", (string)null);
+                    b.ToTable("Users");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.UserRole", b =>
@@ -974,7 +986,7 @@ namespace UniformMaterialManagementSystem.Migrations
 
                     b.HasIndex("UserGuid");
 
-                    b.ToTable("UserRoles", (string)null);
+                    b.ToTable("UserRoles");
                 });
 
             modelBuilder.Entity("UniformMaterialManagementSystem.Entities.Contract", b =>

BIN
UniformMaterialManagementSystem/Resources/Pictures/MaterialDelivery.png


BIN
UniformMaterialManagementSystem/Resources/Pictures/MaterialReceipt.png


BIN
UniformMaterialManagementSystem/Resources/Pictures/MaterialUsage.png


+ 321 - 40
UniformMaterialManagementSystem/ViewModels/DeliveryReceiptViewModel.cs

@@ -4,6 +4,8 @@ using System.Collections.ObjectModel;
 using System.ComponentModel;
 using System.Data;
 using System.Linq;
+using System.Reflection;
+using System.Runtime.InteropServices;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
@@ -17,6 +19,7 @@ using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Win32;
 using UniformMaterialManagementSystem.Custom;
 using UniformMaterialManagementSystem.Entities;
+using UniformMaterialManagementSystem.Models;
 using UniformMaterialManagementSystem.Services;
 using UniformMaterialManagementSystem.Utils;
 using UniformMaterialManagementSystem.Views;
@@ -37,11 +40,17 @@ namespace UniformMaterialManagementSystem.ViewModels
         [ObservableProperty]
         private ObservableCollection<DeliveryReceiptDetail> _deliveryDetails = new ObservableCollection<DeliveryReceiptDetail>();
 
+        [ObservableProperty]
+        private Visibility _mainColVisibility;
+
         [ObservableProperty]
         private DeliveryReceipt? _currDeliveryReceipt = null;
 
         #endregion
 
+        // 默认是发货单
+        internal DeliveryPageCategroy? _deliveryPageCategroy;
+
         private Contract _selectedContract = null!;
 
         private ContractDetail _selectedContractDetail = null!;
@@ -52,15 +61,182 @@ namespace UniformMaterialManagementSystem.ViewModels
 
         private bool _isExcute = true;
 
-        private IDataBaseService<DeliveryReceipt> _service;
+        private int _workYear = 0;
+
+        private string _companyName = string.Empty;
+
+        private LoginUser? _currUser = App.CurrentUser;
 
-        public DeliveryReceiptViewModel(IDataBaseService<DeliveryReceipt> service)
+        private IDataBaseService<DeliveryReceipt> _service = null!;
+
+        public DeliveryReceiptViewModel(IDataBaseService<DeliveryReceipt> service, DeliveryPageCategroy categroy)
         {
             _service = service;
+            _deliveryPageCategroy = categroy;
+
+            if (_currUser == null || _currUser.Company == null)
+            {
+                MessageBox.Show("获取当前用户的数据失败,请联系系统管理员!");
+                return;
+            }
+            _workYear = _currUser.WorkYear;
+            _companyName = _currUser.Company.Name;
+
+            // 设置控件的可见性和列的可见性
+
+            // 获取主表数据源
+            switch (categroy)
+            {
+                case DeliveryPageCategroy.Delivery:
+                    // 只获取发货数据,不关心接收、使用数据
+                    LoadDeliveryData();
+                    MainColVisibility = Visibility.Collapsed;
+                    break;
+                case DeliveryPageCategroy.Receipt:
+                    LoadReceiptData();
+                    MainColVisibility = Visibility.Visible;
+                    break;
+                case DeliveryPageCategroy.Usage:
+                    // 已复核的发货单才允许录入使用数据,使用数据必录许可证。
+                    LoadUsageData();
+                    MainColVisibility = Visibility.Visible;
+                    break;
+            }
+        }
+
+        [RelayCommand]
+        public void UserControlLoad(DeliveryReceiptControl page)
+        {
+            // 设置工具栏按钮、列的可见性
+            if (_deliveryPageCategroy == DeliveryPageCategroy.Delivery)
+            {
+                // Visibility.Hidden 会为控件保留位置,会有空白区域;使用 Visibility.Collapsed
+                // 隐藏主表接收和使用按钮
+                page.sep1.Visibility = page.btnExportThree.Visibility = page.btnCheck.Visibility = page.btnExportFour.Visibility = Visibility.Collapsed;
+
+                // todo 绑定无效,找不到源:RelativeSource
+                var v0 = MainColVisibility; // Collapsed
+                var v = page.fdgDelivery.Columns[13].Visibility; // Visible
+
+                // 隐藏主表接收字段
+                foreach (var col in page.fdgDelivery.Columns)
+                {
+                    if (col == null) { continue; }
+
+                    string header = col.Header.ToString() ?? "";
+                    if (header.StartsWith("接收") && !header.Equals("接收单位"))
+                    {
+                        col.Visibility = Visibility.Collapsed;
+                    }
+                }
+
+                // 隐藏许可证字段
+                page.tBlkLicence.Visibility = page.btnUploadLic.Visibility = page.btnDownloadLic.Visibility = page.tBlkLicIcon.Visibility = page.tBlkLicHint.Visibility = Visibility.Collapsed;
+
+                // 隐藏接收信息
+                page.borderReceipt.Visibility = Visibility.Collapsed;
+
+                // 隐藏明细接收和使用按钮
+                page.btnReceiveDtl.Visibility = page.btnUseDtl.Visibility = Visibility.Collapsed;
+
+                // 隐藏明细表接收和使用字段
+                foreach (var col in page.fdgDeliveryDetail.Columns)
+                {
+                    if (col == null) { continue; }
+
+                    string header = col.Header.ToString() ?? "";
+                    if (header.StartsWith("接收") || header.StartsWith("使用"))
+                    {
+                        col.Visibility = Visibility.Collapsed;
+                        continue;
+                    }
+
+                    // 批次号和包号只能导入,只允许编辑发运数量和备注列
+                    col.IsReadOnly = header.Equals("发运数量*") || header.Equals("备注") ? false : true;
+                }
+            }
+            else if (_deliveryPageCategroy == DeliveryPageCategroy.Receipt)
+            {
+                // 隐藏发货和使用按钮
+                page.btnNew.Visibility = page.btnDelete.Visibility = page.sep0.Visibility = page.btnExportFour.Visibility = Visibility.Collapsed;
+
+                // 隐藏许可证字段
+                page.tBlkLicence.Visibility = page.btnUploadLic.Visibility = page.btnDownloadLic.Visibility = page.tBlkLicIcon.Visibility = page.tBlkLicHint.Visibility = Visibility.Collapsed;
+
+                // 隐藏可发运数量
+                page.spRemainQty.Visibility = Visibility.Collapsed;
+
+                // 发运字段不可编辑
+                page.tBlkShippedDate.Text = "发运时间:";
+                page.dpShippedDate.IsEnabled = page.fieldShippedMan.IsEnabled = page.fieldShippedTel.IsEnabled = false;
 
-            // 只获取发货数据,不关心接收、使用数据
-            // 已复核的发货单才允许录入使用数据,使用数据必录许可证。
-            LoadData();
+                // 隐藏明细发货和使用按钮
+                page.btnAddDtl.Visibility = page.btnDeleteDtl.Visibility = page.sep2.Visibility = page.btnImportDtl.Visibility = page.btnExportDtl.Visibility = page.btnUseDtl.Visibility = Visibility.Collapsed;
+
+                foreach (var col in page.fdgDeliveryDetail.Columns)
+                {
+                    if (col == null) { continue; }
+
+                    // 隐藏选择列
+                    if (col is DataGridCheckBoxColumn)
+                    {
+                        col.Visibility = Visibility.Collapsed;
+                        continue;
+                    }
+
+                    // 隐藏明细表使用字段
+                    string header = col.Header.ToString() ?? "";
+                    if (header.StartsWith("使用"))
+                    {
+                        col.Visibility = Visibility.Collapsed;
+                        continue;
+                    }
+
+                    // todo 其他列的 * 去掉
+
+                    // 只允许编辑接收数量和备注列
+                    col.IsReadOnly = header.Equals("接收数量*") || header.Equals("备注") ? false : true;
+                }
+            }
+            else if (_deliveryPageCategroy == DeliveryPageCategroy.Usage)
+            {
+                // 隐藏发货和接收按钮
+                page.btnNew.Visibility = page.btnDelete.Visibility = page.sep0.Visibility = page.btnExportThree.Visibility = page.btnCheck.Visibility = Visibility.Collapsed;
+
+                // 隐藏可发运数量
+                page.spRemainQty.Visibility = Visibility.Collapsed;
+
+                // 发运字段不可编辑
+                page.tBlkShippedDate.Text = "发运时间:";
+                page.dpShippedDate.IsEnabled = page.fieldShippedMan.IsEnabled = page.fieldShippedTel.IsEnabled = false;
+                // todo 接收字段不可编辑 下拉列表的标题去掉 *
+
+                // 隐藏明细发货和接收按钮
+                page.btnAddDtl.Visibility = page.btnDeleteDtl.Visibility = page.sep2.Visibility = page.btnImportDtl.Visibility = page.btnExportDtl.Visibility = page.btnReceiveDtl.Visibility = Visibility.Collapsed;
+
+                // 隐藏明细表发货字段
+                foreach (var col in page.fdgDeliveryDetail.Columns)
+                {
+                    if (col == null) { continue; }
+
+                    // 隐藏选择列
+                    if (col is DataGridCheckBoxColumn)
+                    {
+                        col.Visibility = Visibility.Collapsed;
+                        continue;
+                    }
+
+                    string header = col.Header.ToString() ?? "";
+                    if (header.StartsWith("发运"))
+                    {
+                        col.Visibility = Visibility.Collapsed;
+                        continue;
+                    }
+
+                    // 只允许编辑使用数量和备注列
+                    col.IsReadOnly = header.Equals("使用数量*") || header.Equals("备注") ? false : true;
+                }
+            }
         }
 
         // CallMethodAction 不需要注册命令,可以传递事件参数。参数列表必须与事件自带的参数列表保持一致
@@ -68,6 +244,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         {
             // 手动屏蔽本事件
             if (!_isExcute) { return; }
+            //args.Handled = true;
 
             DataGrid? fdgDelivery = sender as DataGrid;
             if (fdgDelivery == null) { return; }
@@ -160,7 +337,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             // 检验合格数量:检验申请主表-报检数量 todo 不用显示
             //CurrDeliveryReceipt.InspQty = inspApply.InspQuantity;
             // 可发运数量:检验申请主表-报检数量 - 已发运数量
-            //CurrDeliveryReceipt.RemainQty = CurrDeliveryReceipt.InspQty - hasShippedQty;
+            CurrDeliveryReceipt.RemainQty = _selectedContractDetail.ContractQty - hasShippedQty;
             // 接收单位:等于合同-采购机构
             CurrDeliveryReceipt.ReceivedCompanyName = _selectedContract.PurchaseCompany.Name;
             // 批次号:根据上传的 Excel
@@ -187,7 +364,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             }
 
             // 已导出数据包不允许删除(不允许编辑)
-            if (CurrDeliveryReceipt.IsReported)
+            if (CurrDeliveryReceipt.IsExportDelivery)
             {
                 MessageBox.Show("当前发货单已导出数据包,不允许删除!");
                 return;
@@ -231,26 +408,47 @@ namespace UniformMaterialManagementSystem.ViewModels
         }
 
         [RelayCommand]
-        public void Save()
+        public void Save(DeliveryReceiptControl page)
         {
-            // 当前行未导出数据包才允许保存
+            // 未选择行或者当前行已导出,直接返回
             if (CurrDeliveryReceipt == null) { return; }
-            if (CurrDeliveryReceipt.IsReported) { return; }
+            if (CurrDeliveryReceipt.IsExportDelivery || CurrDeliveryReceipt.IsExportReceive || CurrDeliveryReceipt.IsExportUsage) { return; }
 
-            // 判断必录项
-            if (CurrDeliveryReceipt.BatchNo == null || string.IsNullOrEmpty(CurrDeliveryReceipt.BatchNo))
+            // todo 主表和子表 带 * 的列必录
+            // 判断主表必录项:主表不允许编辑,判断编辑界面控件的值
+            switch (_deliveryPageCategroy)
             {
-                MessageBox.Show("请上传发货明细后保存");
-                return;
+                case DeliveryPageCategroy.Delivery:
+                    // todo 清空日期选择框,但 发运日期 并不会清空
+                    if (string.IsNullOrWhiteSpace(page.dpShippedDate.Text)) // DateTime 类型永远不等于 null
+                    {
+                        MessageBox.Show("发运时间为空,不允许保存!");
+                        return;
+                    }
+                    break;
+                case DeliveryPageCategroy.Receipt:
+                    if (string.IsNullOrEmpty(CurrDeliveryReceipt.ReceivedStatus))
+                    {
+                        MessageBox.Show("收货单状态为空,不允许保存!");
+                        return;
+                    }
+                    break;
+                case DeliveryPageCategroy.Usage:
+                    if (CurrDeliveryReceipt.Licence == null)
+                    {
+                        MessageBox.Show("未上传许可证,不允许保存!");
+                        return;
+                    }
+                    break;
             }
 
-            // todo 清空日期选择框,但 发运日期 并不会清空
-            // 检查发运时间是否已录入
-            if (CurrDeliveryReceipt.ShippedDate == null)
-            {
-                MessageBox.Show("发运时间为空,不允许保存!");
-                return;
-            }
+            // 判断子表必录项:带 * 的列必录(不好实现,先固定检查每一列)
+            var nullBatchNoRows = CurrDeliveryReceipt.DeliveryReceiptDetails.Where(x => string.IsNullOrEmpty(x.BatchNo));
+            var nullPackageNoRows = CurrDeliveryReceipt.DeliveryReceiptDetails.Where(x => string.IsNullOrEmpty(x.PacketNo));
+            var nullShippedQty = CurrDeliveryReceipt.DeliveryReceiptDetails.Where(x => x.ShippedQuantity == 0);
+            var nullReceivedQty = CurrDeliveryReceipt.DeliveryReceiptDetails.Where(x => x.ReceiveQuantity == 0);
+            var nullUsageQty = CurrDeliveryReceipt.DeliveryReceiptDetails.Where(x => x.UsageQuantity == 0);
+            // 根据页面类型校验子表必录项
 
             // 删除子表空行
             DeleteEmptyRows();
@@ -311,12 +509,36 @@ namespace UniformMaterialManagementSystem.ViewModels
             }
         }
 
-        // todo 子表发运数据列变化后实时更新发运数量的值
-        // todo 新增和删除行的时候 / 行切换的时候,自动汇总发运包数的值
         [RelayCommand]
-        public void DetailSelectionChanged()
+        public void DetailSelectionChanged(DataGrid fdgDeliveryDetail)
         {
 
+            // todo 子表发运数据列变化后实时更新发运数量的值
+            // todo 新增和删除行的时候 / 行切换的时候,自动汇总发运包数的值
+            fdgDeliveryDetail.CommitEdit(); // 单击进入编辑状态
+            //fdgDeliveryDetail.UnselectAllCells();
+            if (fdgDeliveryDetail.SelectedCells.Count > 0)
+            {
+                //MessageBox.Show("选中 " + fdgDeliveryDetail.SelectedCells.Count + " 个");// 5个(5列)
+            }
+            //fdgDeliveryDetail.CancelEdit();
+        }
+
+        [RelayCommand]
+        public void DetailCellChanged(DataGrid fdgDeliveryDetail)
+        {
+            fdgDeliveryDetail.BeginEdit(); // 单击进入编辑状态
+                                           //fdgDeliveryDetail.CommitEdit();
+
+
+            var items = fdgDeliveryDetail.Items;
+            DeliveryReceiptDetail? row = fdgDeliveryDetail.CurrentCell.Item as DeliveryReceiptDetail;
+            if (row != null)
+            {
+                int rowIndex = DeliveryDetails.IndexOf(row);
+                int colIndex = fdgDeliveryDetail.CurrentCell.Column.DisplayIndex;
+            }
+
         }
 
         [RelayCommand]
@@ -340,14 +562,14 @@ namespace UniformMaterialManagementSystem.ViewModels
             if (CurrDeliveryReceipt == null) { return; }
 
             // 已导出数据包的发货的不允许再新增明细
-            if (CurrDeliveryReceipt.IsReported)
+            if (CurrDeliveryReceipt.IsExportDelivery)
             {
                 MessageBox.Show("当前发货单已导出数据包,不允许新增明细!");
                 return;
             }
 
             // 已导出数据包的发货的不允许再删除明细
-            if (CurrDeliveryReceipt.IsReported)
+            if (CurrDeliveryReceipt.IsExportDelivery)
             {
                 MessageBox.Show("当前发货单已导出数据包,不允许删除明细!");
                 return;
@@ -409,7 +631,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             if (CurrDeliveryReceipt == null) { return; }
 
             // 已导出数据包的发货的不允许再导入明细
-            if (CurrDeliveryReceipt.IsReported)
+            if (CurrDeliveryReceipt.IsExportDelivery)
             {
                 MessageBox.Show("当前发货单已导出数据包,不允许导入明细!");
                 return;
@@ -553,28 +775,77 @@ namespace UniformMaterialManagementSystem.ViewModels
         }
 
         /// <summary>
-        /// 加载数据
+        /// 加载发货单数据
         /// </summary>
-        private void LoadData()
+        private void LoadDeliveryData()
         {
-            // 发货单主表数据源
-            var deliveryReceipts = _service.Query().Include(x => x.DeliveryReceiptDetails);
+            // 筛选当前工作年度、当前生产企业的发货单
+            var deliveryReceipts = _service.Query(x => x.WorkYear.Equals(_workYear) && x.CompanyName.Equals(_companyName))
+                                           .Include(x => x.DeliveryReceiptDetails);
             DeliveryReceipts = new ObservableCollection<DeliveryReceipt>(deliveryReceipts);
 
             // 获取每一行发货单对应的检验合格数量和剩余数量
             foreach (var delivery in DeliveryReceipts)
             {
-                // 检验合格数量:检验申请主表-报检数量
-                //string applyNo = delivery.ApplyNo;
-                //InspectApply? apply = App.Current.Services.GetService<IDataBaseService<InspectApply>>()?.Query(x => x.ApplyNo.Equals(applyNo)).FirstOrDefault();
-                //if (apply == null) { continue; }
-                //delivery.InspQty = apply.InspQuantity;
+                // 可发运数量:合同数量 - 已发运数量
+                string contractNo = delivery.ContractNo;
+                string productName = delivery.ProductName;
+                double hasShippedQty = (double)DeliveryReceipts.Where(x => x.ContractNo.Equals(contractNo) && x.ProductName.Equals(productName)).Select(x => x.ShippedQty).Sum();
+                delivery.RemainQty = delivery.ContractQty - hasShippedQty;
 
-                // 可发运数量:检验申请主表-报检数量 - 已发运数量
-                //string contractNo = delivery.ContractNo;
-                //double hasShippedQty = (double)DeliveryReceipts.Where(x => x.ApplyNo.Equals(applyNo) && x.ContractNo.Equals(contractNo)).Select(x => x.ShippedQty).Sum();
-                //delivery.RemainQty = delivery.InspQty - hasShippedQty;
+                // 是否为新行:否
+                delivery.IsNewRow = false;
 
+                // 子表明细行
+                var details = delivery.DeliveryReceiptDetails.OrderBy(x => x.PacketNo).ToArray();
+                foreach (var dtl in details)
+                {
+                    dtl.IsNewRow = false;
+                }
+                delivery.DeliveryReceiptDetails = new ObservableCollection<DeliveryReceiptDetail>(details);
+            }
+        }
+
+        /// <summary>
+        /// 加载接收单数据
+        /// </summary>
+        private void LoadReceiptData()
+        {
+            // 材料企业-发货单导出数据包赋值 IsExportDelivery 字段为 true:导出后不可再修改、删除
+            // 成品企业-接收单导出附件3的时候赋值 IsExportReceive 字段为 true:导出后不可编辑,不可重复导出
+            // 成品企业-使用单导出附件4的时候赋值 IsExportUsage 字段为 true:导出后不可编辑,不可重复导出
+            // 筛选当前工作年度、当前成品企业的所有发货单(数据包导入)
+            var deliveryReceipts = _service.Query(x => x.WorkYear.Equals(_workYear) && x.ReceivedCompanyName.Equals(_companyName))
+                                           .Include(x => x.DeliveryReceiptDetails);
+            DeliveryReceipts = new ObservableCollection<DeliveryReceipt>(deliveryReceipts);
+
+            foreach (var delivery in DeliveryReceipts)
+            {
+                // 是否为新行:否
+                delivery.IsNewRow = false;
+
+                // 子表明细行
+                var details = delivery.DeliveryReceiptDetails.OrderBy(x => x.PacketNo).ToArray();
+                foreach (var dtl in details)
+                {
+                    dtl.IsNewRow = false;
+                }
+                delivery.DeliveryReceiptDetails = new ObservableCollection<DeliveryReceiptDetail>(details);
+            }
+        }
+
+        /// <summary>
+        /// 加载使用单数据
+        /// </summary>
+        private void LoadUsageData()
+        {
+            // 筛选当前工作年度、当前成品企业、已复核的发货单
+            var deliveryReceipts = _service.Query(x => x.WorkYear.Equals(_workYear) && x.ReceivedCompanyName.Equals(_companyName) && x.ReceivedStatus!.Equals("已复核"))
+                                           .Include(x => x.DeliveryReceiptDetails);
+            DeliveryReceipts = new ObservableCollection<DeliveryReceipt>(deliveryReceipts);
+
+            foreach (var delivery in DeliveryReceipts)
+            {
                 // 是否为新行:否
                 delivery.IsNewRow = false;
 
@@ -661,4 +932,14 @@ namespace UniformMaterialManagementSystem.ViewModels
             return false;
         }
     }
+
+    /// <summary>
+    /// 页面类型
+    /// </summary>
+    public enum DeliveryPageCategroy
+    {
+        Delivery,
+        Receipt,
+        Usage
+    }
 }

+ 62 - 43
UniformMaterialManagementSystem/ViewModels/SelectApplyContractDialogViewModel.cs

@@ -15,6 +15,7 @@ using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.DependencyInjection;
 using UniformMaterialManagementSystem.Custom;
 using UniformMaterialManagementSystem.Entities;
+using UniformMaterialManagementSystem.Models;
 using UniformMaterialManagementSystem.Services;
 using Contract = UniformMaterialManagementSystem.Entities.Contract;
 
@@ -50,8 +51,15 @@ namespace UniformMaterialManagementSystem.ViewModels
 
         #endregion
 
+        private bool _isMaterialChanged = false;
+
+        private LoginUser? _currUser = App.CurrentUser;
+
         public SelectApplyContractDialogViewModel()
         {
+            // 当前用户为空,直接返回
+            if(_currUser == null) { return; }
+
             // 获取产品名称数据源
             var materials = App.Current.Services.GetService<IDataBaseService<Material>>()?.Query(x => x.IsEnabled);
             if (materials != null && materials.Any())
@@ -65,9 +73,10 @@ namespace UniformMaterialManagementSystem.ViewModels
             }
         }
 
-        [RelayCommand]
+        //[RelayCommand]
         public void Loaded(DataGrid fdgContractDetail)
         {
+            // 没办法解决不同设备,分辨率不同的情况。只能固定宽度,不同设备下拉框
             // todo 当窗口 SizeChanged 重新计算列宽
             // todo 没有减去 FilterDataGrid 右侧竖向条的宽度,暂时不研究
             // 看下 fdg 的 VisualTree,能找到就找,找不到就删掉 ScrolView?
@@ -110,8 +119,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             }
         }
 
-
-        [RelayCommand]
+        //[RelayCommand]
         public void DialogSizeChanged(DataGrid fdgContractDetail)
         {
             // todo 如果 width 小于 700,返回。设置了 MinWidth 后列标题不会被遮挡,但窗口依然可以变窄
@@ -156,40 +164,53 @@ namespace UniformMaterialManagementSystem.ViewModels
         }
 
         [RelayCommand]
-        public void Query(AutoCompleteBox autoListBoxMate)
+        public void MaterialSelectionChanged()
+        {
+            _isMaterialChanged = true;
+        }
+
+        [RelayCommand]
+        public void Query()
         {
-            if (autoListBoxMate == null) { return; }
+            // 获取当前用户的数据
+            int workYear = _currUser!.WorkYear;
+            var currCompanyGuid = _currUser.CompanyGuid;
+            if (currCompanyGuid == null)
+            {
+                MessageBox.Show("没有获取到当前用户的生产企业数据,请联系系统管理员!");
+                return;
+            }
 
-            // 清空已选择的合同
+            // 清空已选择的合同和明细数据
             SelectedContract = null;
             SelectedContractDetail = null;
+            ContractDetails = new ObservableCollection<ContractDetail>(); // 主表行切换才重新获取数据
+            _isMaterialChanged = false;
 
             // 编辑 autoCompleteBox 的显示文本,不会修改 SelectedItem,用选择项即可
-            if (SelectedMaterial == null)
+            if (SelectedMaterial == null) // Text 属性更新不及时,SelectedItem 更新及时,前台绑定 SelectedItem
             {
+                // 若没有选择项,则清空界面数据
+                Contracts = new ObservableCollection<Contract>();
+                ContractDetails = new ObservableCollection<ContractDetail>();
+
                 MessageBox.Show("请先选择材料!");
                 return;
             }
 
-            //if (SelectedMaterialName == null || string.IsNullOrEmpty(SelectedMaterialName))
-            //{
-            //    MessageBox.Show("请先选择材料!");
-            //    return;
-            //}
-            //string? materialName = autoListBoxMate.Text; // Text 属性更新不及时,SelectedItem更新及时
-            //string? materialName = autoListBoxMate.SelectedItem.ToString();
-
-            // 获取全部合同数据
-            List<Contract>? mateContracts = new List<Contract>();
-
-            // todo 根据当前角色,筛选全部 / 当前生产企业的合同
-            var contracts = App.Current.Services.GetService<IDataBaseService<Contract>>()?.Query().Include(x => x.Company).Include(x => x.PurchaseCompany).Include(x => x.ContractDetails);
+            // 获取主表数据源:前台绑定需要 Include() 两个企业字段
+            var contracts = App.Current.Services.GetService<IDataBaseService<Contract>>()?.Query(x => x.CompanyGuid.Equals(currCompanyGuid) && x.Year.Equals(workYear))
+                .Include(x => x.Company)
+                .Include(x => x.PurchaseCompany)
+                .Include(x => x.ContractDetails);
             if (contracts == null || !contracts.Any())
             {
                 MessageBox.Show("获取合同数据失败!");
                 return;
             }
 
+            // 根据合同明细筛选合同
+            List<Contract>? mateContracts = new List<Contract>();
             foreach (var contract in contracts)
             {
                 var details = contract.ContractDetails;
@@ -201,24 +222,6 @@ namespace UniformMaterialManagementSystem.ViewModels
                 }
             }
 
-            // 获取所有的合同明细
-            var contractDetails = App.Current.Services.GetService<IDataBaseService<ContractDetail>>()?.Query().Include(x => x.Material).Include(x => x.Contract);
-            if (contractDetails == null || !contractDetails.Any())
-            {
-                MessageBox.Show("获取合同数据失败!");
-                return;
-            }
-
-            // 根据选择的 产品名称 获取合同数据
-            foreach (var detail in contractDetails)
-            {
-                // todo 明细表 Material 字段为空,怎么 Include ?
-                if (detail.Material.Name.Equals(SelectedMaterialName))
-                {
-                    mateContracts.Add(detail.Contract);
-                }
-            }
-
             if (mateContracts.Count == 0)
             {
                 MessageBox.Show("该材料没有对应的合同数据!");
@@ -228,13 +231,19 @@ namespace UniformMaterialManagementSystem.ViewModels
         }
 
         [RelayCommand]
-        public void SelectionChanged()
+        public void ContractSelectionChanged()
         {
-            if (SelectedMaterial == null) { return; }
-            if (SelectedContract == null) { return; }
+            if (_isMaterialChanged)
+            {
+                MessageBox.Show("当前选择的产品已修改,请查询后重新选择合同!");
+                return;
+            }
+
+            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));
+            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)
             {
                 MessageBox.Show("获取合同明细失败");
@@ -248,7 +257,12 @@ namespace UniformMaterialManagementSystem.ViewModels
         {
             // 不需要传递控件,因为有字段绑定
 
-            // 检查是否勾选行
+            if (_isMaterialChanged)
+            {
+                MessageBox.Show("当前选择的产品已修改,请查询后重新选择合同!");
+                return;
+            }
+
             if (SelectedContract == null)
             {
                 MessageBox.Show("请选择合同!");
@@ -277,6 +291,11 @@ namespace UniformMaterialManagementSystem.ViewModels
         [RelayCommand]
         public void Cancel(Window window)
         {
+            // 清空选择的项
+            SelectedMaterial = null;
+            SelectedContract = null;
+            SelectedContractDetail = null;
+
             window.Close();
         }
 

+ 1 - 2
UniformMaterialManagementSystem/ViewModels/UsersViewModel.cs

@@ -613,8 +613,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             // 生产企业数据源
             if (Companies == null || Companies.Count == 0)
             {
-                // 只选择材料生产企业
-                var companies = App.Current.Services.GetService<IDataBaseService<Company>>()?.GetAll(x => x.IsEnabled && x.Category.Equals("material"));
+                var companies = App.Current.Services.GetService<IDataBaseService<Company>>()?.GetAll(x => x.IsEnabled);
                 if (companies != null)
                 {
                     Companies = new ObservableCollection<Company>(companies);

+ 405 - 214
UniformMaterialManagementSystem/Views/DeliveryReceiptControl.xaml

@@ -10,8 +10,10 @@
              xmlns:converters="clr-namespace:UniformMaterialManagementSystem.Converters"
              xmlns:fdg="http://FilterDataGrid.Control.com/2024"
              xmlns:custom="clr-namespace:UniformMaterialManagementSystem.Custom"
+             xmlns:sys="clr-namespace:System;assembly=mscorlib"
              mc:Ignorable="d" 
-             d:DesignHeight="450" d:DesignWidth="800">
+             d:DesignHeight="450" d:DesignWidth="800"
+             x:Name="delveryReceiptControl">
     <UserControl.Resources>
         <!-- 工具栏按钮模板 -->
         <ControlTemplate x:Key="CustomToolBarButtomTemplate" TargetType="Button">
@@ -167,6 +169,36 @@
             <Setter Property="Padding" Value="0, 5, 0, 5" />
         </Style>
 
+        <!-- todo Template 里的使用样式;特殊的字段单独设置样式和模板 -->
+        <!-- 编辑界面字段 -->
+        <Style x:Key="CustomFieldTextBoxStyle" TargetType="TextBox">
+            <Setter Property="Template" >
+                <Setter.Value>
+                    <ControlTemplate>
+                        <StackPanel Orientation="Horizontal">
+                            <TextBlock Text="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}"
+                                       Width="100"
+                                       Height="20"
+                                       FontSize="14"
+                                       VerticalAlignment="Center"
+                                       TextAlignment="Right"
+                                       Margin="5" />
+                            <TextBox Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}" 
+                                     IsEnabled="{Binding IsEnabled, RelativeSource={RelativeSource TemplatedParent}}"
+                                     BorderBrush="Gray"
+                                     BorderThickness="1"
+                                     Width="250"
+                                     Height="30"
+                                     FontSize="14"
+                                     HorizontalContentAlignment="Center"
+                                     VerticalContentAlignment="Center"
+                                     Margin="0 5 0 5" />
+                        </StackPanel>
+                    </ControlTemplate>
+                </Setter.Value>
+            </Setter>
+        </Style>
+
         <!-- TextBlock 一般用来展示文本,TextBox 一般用于输入文本 -->
         <!-- TextBlock 样式 -->
         <Style x:Key="CustomTextBlockStyle" TargetType="TextBlock">
@@ -185,7 +217,7 @@
             <Setter Property="BorderThickness" Value="1" />
             <!--<Setter Property="Background" Value="WhiteSmoke" />-->
             <Setter Property="Foreground" Value="Gray" />
-            <Setter Property="Width" Value="200" />
+            <Setter Property="Width" Value="250" />
             <Setter Property="Height" Value="30" />
             <Setter Property="FontSize" Value="14" />
             <Setter Property="HorizontalContentAlignment" Value="Center" />
@@ -197,7 +229,7 @@
         <Style x:Key="CustomTextBoxStyle" TargetType="TextBox">
             <Setter Property="BorderBrush" Value="Gray" />
             <Setter Property="BorderThickness" Value="1" />
-            <Setter Property="Width" Value="200" />
+            <Setter Property="Width" Value="250" />
             <Setter Property="Height" Value="30" />
             <Setter Property="FontSize" Value="14" />
             <Setter Property="HorizontalContentAlignment" Value="Center" />
@@ -223,6 +255,13 @@
             <RowDefinition Height="*" />
         </Grid.RowDefinitions>
 
+        <b:Interaction.Triggers>
+            <b:EventTrigger EventName="Loaded">
+                <b:InvokeCommandAction Command="{Binding UserControlLoadCommand}"
+                                       CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}" />
+            </b:EventTrigger>
+        </b:Interaction.Triggers>
+
         <!-- 发货单工具栏 -->
         <Border x:Name="toolBarDelivery"
                 Grid.Row="0" 
@@ -232,19 +271,38 @@
                 BorderThickness="1">
             <ToolBar Background="White"
                      ToolBarTray.IsLocked="True">
-                <Button Content="新增发货单"
+                <Button x:Name="btnNew"
+                        Content="新增发货单"
                         Tag="{x:Static utils:RegularFontUtil.Add_Square_32}"
                         Template="{StaticResource CustomToolBarButtomTemplate}"
                         Command="{Binding AddDeliveryCommand}" />
-                <Button Content="删除发货单"
+                <Button x:Name="btnDelete"
+                        Content="删除发货单"
                         Tag="{x:Static utils:RegularFontUtil.Delete_32}"
                         Template="{StaticResource CustomToolBarButtomTemplate}"
                         Command="{Binding DeleteDeliveryCommand}"
                         CommandParameter="{Binding ElementName=fdgDelivery}" />
-                <Separator />
+                <Separator x:Name="sep0" />
                 <Button Content="保存" 
                         Tag="{x:Static utils:RegularFontUtil.Save_32}"
                         Template="{StaticResource CustomToolBarButtomTemplate}"
+                        Command="{Binding SaveCommand}"
+                        CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}" />
+                <Separator x:Name="sep1" />
+                <Button x:Name="btnExportThree"
+                        Content="导出附件3" 
+                        Tag="{x:Static utils:RegularFontUtil.Open_32}"
+                        Template="{StaticResource CustomToolBarButtomTemplate}"
+                        Command="{Binding SaveCommand}" />
+                <Button x:Name="btnCheck"
+                        Content="复核" 
+                        Tag="{x:Static utils:RegularFontUtil.Clipboard_Checkmark_24}"
+                        Template="{StaticResource CustomToolBarButtomTemplate}"
+                        Command="{Binding SaveCommand}" />
+                <Button x:Name="btnExportFour"
+                        Content="导出附件4" 
+                        Tag="{x:Static utils:RegularFontUtil.Arrow_Turn_Right_48}"
+                        Template="{StaticResource CustomToolBarButtomTemplate}"
                         Command="{Binding SaveCommand}" />
 
                 <!--<WrapPanel Orientation="Horizontal">
@@ -299,6 +357,7 @@
                             HeadersVisibility="All"
                             ShowRowsCount="True"
                             RowHeaderWidth="30"
+                            LoadingRow="DataGrid_LoadingRow"
                             ColumnHeaderStyle="{StaticResource CustomColumnHeaderStyle}"
                             RowHeaderStyle="{StaticResource CustomRowHeaderStyle}"
                             RowStyle="{StaticResource CustomRowStyle}"
@@ -331,22 +390,18 @@
                                               IsColumnFiltered="True"
                                               ElementStyle="{StaticResource TextColumnElementStyle}"
                                               Binding="{Binding ContractNo}" />
-                <fdg:FilterDataGridTextColumn Header="产品名称" Width="200"
+                <fdg:FilterDataGridTextColumn Header="产品名称" Width="250"
                                               IsColumnFiltered="True"
                                               ElementStyle="{StaticResource TextColumnElementStyle}"
                                               Binding="{Binding ProductName}" />
-                <fdg:FilterDataGridTextColumn Header="生产企业" Width="200"
+                <fdg:FilterDataGridTextColumn Header="生产企业" Width="250"
                                               IsColumnFiltered="True"
                                               ElementStyle="{StaticResource TextColumnElementStyle}"
                                               Binding="{Binding CompanyName}" />
-                <fdg:FilterDataGridTextColumn Header="接收单位" Width="200"
+                <fdg:FilterDataGridTextColumn Header="接收单位" Width="250"
                                               IsColumnFiltered="True"
                                               ElementStyle="{StaticResource TextColumnElementStyle}"
                                               Binding="{Binding ReceivedCompanyName}" />
-                <fdg:FilterDataGridTextColumn Header="批次号" Width="100"
-                                              IsColumnFiltered="True"
-                                              ElementStyle="{StaticResource TextColumnElementStyle}"
-                                              Binding="{Binding BatchNo}" />
                 <fdg:FilterDataGridTextColumn Header="发运包数" Width="100"
                                               IsColumnFiltered="True"
                                               ElementStyle="{StaticResource TextColumnElementStyle}"
@@ -363,10 +418,43 @@
                                               IsColumnFiltered="True"
                                               ElementStyle="{StaticResource TextColumnElementStyle}"
                                               Binding="{Binding ShippedMan}" />
-                <fdg:FilterDataGridTextColumn Header="联系电话" Width="100"
+                <fdg:FilterDataGridTextColumn Header="发运联系电话" Width="200"
                                               IsColumnFiltered="True"
                                               ElementStyle="{StaticResource TextColumnElementStyle}"
                                               Binding="{Binding ShippedTel}" />
+                <fdg:FilterDataGridTextColumn Header="接收包数" Width="100"
+                                              IsColumnFiltered="True"
+                                              ElementStyle="{StaticResource TextColumnElementStyle}"
+                                              Binding="{Binding ReceivedPackets}" 
+                                              Visibility="{Binding DataContext.MainColVisibility, RelativeSource={RelativeSource Mode=FindAncestor,AncestorLevel=3, AncestorType={x:Type UserControl}},
+                    PresentationTraceSources.TraceLevel=High}"  />
+                <fdg:FilterDataGridTextColumn Header="接收数量" Width="100"
+                                              IsColumnFiltered="True"
+                                              ElementStyle="{StaticResource TextColumnElementStyle}"
+                                              Binding="{Binding ReceivedQty}" 
+                                              Visibility="{Binding DataContext.MainColVisibility}"  />
+                <fdg:FilterDataGridTextColumn Header="接收时间" Width="100"
+                                              IsColumnFiltered="True"
+                                              ElementStyle="{StaticResource TextColumnElementStyle}"
+                                              Binding="{Binding ReceivedDate, StringFormat='yyyy/MM/dd'}" 
+                                              Visibility="{Binding DataContext.MainColVisibility}"  />
+                <fdg:FilterDataGridTextColumn Header="接收承办人" Width="100"
+                                              IsColumnFiltered="True"
+                                              ElementStyle="{StaticResource TextColumnElementStyle}"
+                                              Binding="{Binding ReceivedMan}" 
+                                              Visibility="{Binding DataContext.MainColVisibility}"  />
+                <fdg:FilterDataGridTextColumn Header="接收联系电话" Width="200"
+                                              IsColumnFiltered="True"
+                                              ElementStyle="{StaticResource TextColumnElementStyle}"
+                                              Binding="{Binding ReceivedTel}" 
+                                              Visibility="{Binding DataContext.MainColVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorLevel=3, AncestorType=local:DeliveryReceiptControl},
+                    PresentationTraceSources.TraceLevel=High}"  />
+                <fdg:FilterDataGridTextColumn Header="接收状态" Width="100"
+                                              IsColumnFiltered="True"
+                                              ElementStyle="{StaticResource TextColumnElementStyle}"
+                                              Binding="{Binding ReceivedStatus}" 
+                                              Visibility="{Binding DataContext.MainColVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type fdg:FilterDataGrid}},
+                    PresentationTraceSources.TraceLevel=High}"  />
             </fdg:FilterDataGrid.Columns>
         </fdg:FilterDataGrid>
 
@@ -374,219 +462,272 @@
         <!-- 水平拖动分割线 -->
         <GridSplitter Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Height="5"  HorizontalAlignment="Stretch" />
 
-        <!-- todo 设置 StackPanel 高度超出范围时自动拉伸 -->
         <!-- 发货单信息 -->
-        <StackPanel x:Name="panelInfo"
-                    Grid.Row="3" 
-                    Grid.RowSpan="2"
-                    Grid.Column="0"
-                    Background="White"
-                    Orientation="Vertical"
-                    CanVerticallyScroll="True"
-                    VerticalAlignment="Stretch">
-
-            <!-- 表头信息 -->
-            <Border Grid.Row="0" Grid.Column="0"
+        <Border Grid.Row="3" 
+                Grid.RowSpan="2"
+                Grid.Column="0"
+                BorderBrush="Gray"
+                BorderThickness="1">
+            <Grid Background="White">
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="*" />
+                    <RowDefinition Height="auto" />
+                    <RowDefinition Height="auto" />
+                    <RowDefinition Height="auto" />
+                    <RowDefinition Height="auto" />
+                    <RowDefinition Height="*" />
+                </Grid.RowDefinitions>
+
+                <!-- 表头信息 -->
+                <Border Grid.Row="1" 
                     BorderBrush="Gray" 
                     BorderThickness="1">
-                <Grid Background="White">
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition Width="auto" />
-                        <ColumnDefinition Width="*" />
-                    </Grid.ColumnDefinitions>
-
-                    <Label Grid.Column="0" 
-                           BorderBrush="Gray" BorderThickness="1 0 1 0" 
-                           Width="100"
-                           Content="表头信息" 
-                           FontWeight="Bold"
-                           VerticalAlignment="Stretch"
-                           HorizontalContentAlignment="Center"
-                           VerticalContentAlignment="Center"
-                           Padding="5" />
-
-                    <WrapPanel Grid.Column="1" 
+                    <Grid Background="White">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="auto" />
+                            <ColumnDefinition Width="*" />
+                        </Grid.ColumnDefinitions>
+
+                        <Label Grid.Column="0" 
+                               BorderBrush="Gray" BorderThickness="1 0 1 0" 
+                               Width="100"
+                               Content="表头信息" 
+                               FontWeight="Bold"
+                               VerticalAlignment="Stretch"
+                               HorizontalContentAlignment="Center"
+                               VerticalContentAlignment="Center"
+                               Padding="5" />
+
+                        <WrapPanel Grid.Column="1" 
                                    Orientation="Horizontal">
-                        <!-- 产品名称 -->
-                        <StackPanel Orientation="Horizontal">
-                            <TextBlock Text="产品名称:" Style="{StaticResource CustomTextBlockStyle}" />
-                            <Label x:Name="lblMaterial"
-                                   Content="{Binding CurrDeliveryReceipt.ProductName}" 
-                                   Style="{StaticResource CustomLabelStyle}" />
-                        </StackPanel>
-                        <!-- 生产企业 -->
-                        <StackPanel Orientation="Horizontal">
-                            <TextBlock Text="生产企业:" Style="{StaticResource CustomTextBlockStyle}" />
-                            <Label Content="{Binding CurrDeliveryReceipt.CompanyName}" 
-                                   Style="{StaticResource CustomLabelStyle}" />
-                        </StackPanel>
-
-                    </WrapPanel>
-                </Grid>
-
-            </Border>
-
-            <!-- 合同信息 -->
-            <Border Grid.Row="1" Grid.Column="0"
+                            <TextBox Tag="产品名称:"
+                                     Text="{Binding CurrDeliveryReceipt.ProductName}"
+                                     IsEnabled="False"
+                                     Style="{StaticResource CustomFieldTextBoxStyle}" />
+                            <TextBox Tag="生产企业:"
+                                     Text="{Binding CurrDeliveryReceipt.CompanyName}"
+                                     IsEnabled="False"
+                                     Style="{StaticResource CustomFieldTextBoxStyle}" />
+                            <TextBlock x:Name="tBlkLicence"
+                                       Text="许可证*:"
+                                       Style="{StaticResource CustomTextBlockStyle}" />
+                            <Button x:Name="btnUploadLic" 
+                                    Content="上传许可证" />
+                            <Button x:Name="btnDownloadLic" 
+                                    Content="下载许可证" />
+                            <TextBlock x:Name="tBlkLicIcon"
+                                       HorizontalAlignment="Center"
+                                       FontFamily="{StaticResource FluentSystemIconsRegular}"
+                                       FontSize="20"
+                                       Text="{x:Static utils:RegularFontUtil.Attach_24}" />
+                            <TextBlock x:Name="tBlkLicHint" 
+                                       Text="许可证未上传" />
+                        </WrapPanel>
+                    </Grid>
+
+                </Border>
+
+                <!-- 合同信息 -->
+                <Border Grid.Row="2" 
                     BorderBrush="Gray" 
                     BorderThickness="1">
-                <Grid Background="White">
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition Width="auto" />
-                        <ColumnDefinition Width="*" />
-                    </Grid.ColumnDefinitions>
-
-                    <Label Grid.Column="0" 
-                           BorderBrush="Gray" 
-                           BorderThickness="1 0 1 0" 
-                           Width="100"
-                           Content="合同信息"
-                           FontWeight="Bold"
-                           VerticalAlignment="Stretch"
-                           HorizontalContentAlignment="Center"
-                           VerticalContentAlignment="Center" />
-
-                    <WrapPanel Grid.Column="1" 
+                    <Grid Background="White">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="auto" />
+                            <ColumnDefinition Width="*" />
+                        </Grid.ColumnDefinitions>
+
+                        <Label Grid.Column="0" 
+                               BorderBrush="Gray" 
+                               BorderThickness="1 0 1 0" 
+                               Width="100"
+                               Content="合同信息"
+                               FontWeight="Bold"
+                               VerticalAlignment="Stretch"
+                               HorizontalContentAlignment="Center"
+                               VerticalContentAlignment="Center" />
+
+                        <WrapPanel Grid.Column="1" 
                                Orientation="Horizontal">
-                        <!-- 合同编号 -->
-                        <StackPanel Orientation="Horizontal">
-                            <TextBlock Text="合同编号:"
-                                       Style="{StaticResource CustomTextBlockStyle}" />
-                            <Label Content="{Binding CurrDeliveryReceipt.ContractNo}"
-                                   Style="{StaticResource CustomLabelStyle}" />
-                        </StackPanel>
-                        <!-- 采购机构 -->
-                        <StackPanel Orientation="Horizontal">
-                            <TextBlock Text="采购机构:"
-                                       Style="{StaticResource CustomTextBlockStyle}" />
-                            <Label Content="{Binding CurrDeliveryReceipt.PurchaseCompanyName}"
-                                   Style="{StaticResource CustomLabelStyle}" />
-                        </StackPanel>
-                        <!-- 合同数量 -->
-                        <StackPanel Orientation="Horizontal">
-                            <TextBlock Text="合同数量:"
-                                       Style="{StaticResource CustomTextBlockStyle}" />
-                            <Label Content="{Binding CurrDeliveryReceipt.ContractQty}"
-                                   Style="{StaticResource CustomLabelStyle}" />
-                        </StackPanel>
-                        <!-- todo 日期格式设置不生效 -->
-                        <!-- 合同时间 -->
-                        <StackPanel Orientation="Horizontal">
-                            <TextBlock Text="合同时间:"
-                                       Style="{StaticResource CustomTextBlockStyle}" />
-                            <Label Content="{Binding CurrDeliveryReceipt.ContractSigningDate, StringFormat='yyyy:MM:dd'}"
-                                   Style="{StaticResource CustomLabelStyle}" />
-                        </StackPanel>
-                        <!-- 检验合格数量、剩余数量:非保存列 -->
-                        <!--<StackPanel Orientation="Horizontal">
-                            <TextBlock Text="检验合格数量:"
-                                       Style="{StaticResource CustomTextBlockStyle}" />
-                            <TextBlock Text="{Binding CurrDeliveryReceipt.InspQty}" 
-                                       Width="50"
-                                       Foreground="Red"
-                                       TextAlignment="Left"
-                                       Style="{StaticResource CustomTextBlockStyle}" />
-                            <TextBlock Text="可发运数量:"
+                            <TextBox Tag="合同编号:"
+                                     Text="{Binding CurrDeliveryReceipt.ContractNo}"
+                                     IsEnabled="False"
+                                     Style="{StaticResource CustomFieldTextBoxStyle}" />
+                            <TextBox Tag="采购机构:"
+                                     Text="{Binding CurrDeliveryReceipt.PurchaseCompanyName}"
+                                     IsEnabled="False"
+                                     Style="{StaticResource CustomFieldTextBoxStyle}" />
+                            <TextBox Tag="合同数量:"
+                                     Text="{Binding CurrDeliveryReceipt.ContractQty}"
+                                     IsEnabled="False"
+                                     Style="{StaticResource CustomFieldTextBoxStyle}" />
+                            <!-- Label 设置日期格式设置不生效,改用 TextBox ,IsEnable=False -->
+                            <TextBox Tag="合同时间:"
+                                     Text="{Binding CurrDeliveryReceipt.ContractSigningDate, StringFormat='yyyy/MM/dd'}"
+                                     IsEnabled="False"
+                                     Style="{StaticResource CustomFieldTextBoxStyle}" />
+
+                            <!-- 检验合格数量、剩余数量:非保存列 -->
+                            <StackPanel x:Name="spRemainQty"
+                                        Orientation="Horizontal">
+                                <TextBlock Text="可发运数量:"
                                        Style="{StaticResource CustomTextBlockStyle}" />
-                            <TextBlock Text="{Binding CurrDeliveryReceipt.RemainQty}" 
+                                <TextBlock Text="{Binding CurrDeliveryReceipt.RemainQty}" 
                                        Width="50"
                                        Foreground="Red"
                                        TextAlignment="Left"
                                        Style="{StaticResource CustomTextBlockStyle}" />
-                        </StackPanel>-->
+                            </StackPanel>
 
-                    </WrapPanel>
-                </Grid>
+                        </WrapPanel>
+                    </Grid>
 
-            </Border>
+                </Border>
 
-            <!-- 发运信息 -->
-            <Border Grid.Row="3" Grid.Column="0" Grid.RowSpan="2"  
+                <!-- 发运信息 -->
+                <Border Grid.Row="3" 
                     BorderBrush="Gray" 
                     BorderThickness="1">
-                <Grid Background="White">
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition Width="auto" />
-                        <ColumnDefinition Width="*" />
-                    </Grid.ColumnDefinitions>
-
-                    <Label Grid.Column="0"
-                           BorderBrush="Gray" BorderThickness="1 0 1 0" 
-                           Width="100"
-                           Content="发运信息"
-                           FontWeight="Bold"
-                           VerticalAlignment="Stretch"
-                           HorizontalContentAlignment="Center"
-                           VerticalContentAlignment="Center" />
-
-                    <WrapPanel Grid.Column="1"
+                    <Grid Background="White">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="auto" />
+                            <ColumnDefinition Width="*" />
+                        </Grid.ColumnDefinitions>
+
+                        <Label Grid.Column="0"
+                               BorderBrush="Gray" BorderThickness="1 0 1 0" 
+                               Width="100"
+                               Content="发运信息"
+                               FontWeight="Bold"
+                               VerticalAlignment="Stretch"
+                               HorizontalContentAlignment="Center"
+                               VerticalContentAlignment="Center" />
+
+                        <WrapPanel Grid.Column="1"
                                    Orientation="Horizontal">
-                        <!-- todo FontSize 默认 12? -->
-                        <!-- 接收单位 -->
-                        <StackPanel Orientation="Horizontal">
-                            <TextBlock Text="接收单位:"
-                                       Style="{StaticResource CustomTextBlockStyle}" />
-                            <Label Content="{Binding CurrDeliveryReceipt.ReceivedCompanyName}"
-                                   Style="{StaticResource CustomLabelStyle}" />
-                        </StackPanel>
-                        <!-- 批次号 -->
-                        <StackPanel Orientation="Horizontal">
-                            <TextBlock Text="批次号:" 
-                                       Style="{StaticResource CustomTextBlockStyle}" />
-                            <Label Content="{Binding CurrDeliveryReceipt.BatchNo}"
-                                   Style="{StaticResource CustomLabelStyle}" />
-                        </StackPanel>
-                        <!-- 发运包数 -->
-                        <StackPanel Orientation="Horizontal">
-                            <TextBlock Text="发运包数:"
-                                       Style="{StaticResource CustomTextBlockStyle}" />
-                            <Label Content="{Binding CurrDeliveryReceipt.ShippedPackets}"
-                                   Style="{StaticResource CustomLabelStyle}" />
-                        </StackPanel>
-                        <!-- 发运数量 -->
-                        <StackPanel Orientation="Horizontal">
-                            <TextBlock Text="发运数量:"
-                                       Style="{StaticResource CustomTextBlockStyle}" />
-                            <Label Content="{Binding CurrDeliveryReceipt.ShippedQty}"
-                                   Style="{StaticResource CustomLabelStyle}" />
-                        </StackPanel>
-                        <!-- todo 设置日期显示格式(需要修改Template,暂时不修改)减少日期选择框的 Padding(内部间距),选择按钮居右 -->
-                        <!-- 发运时间 -->
-                        <StackPanel Orientation="Horizontal">
-                            <TextBlock Text="*发运时间:"
-                                       Foreground="Black"
-                                       Style="{StaticResource CustomTextBlockStyle}" />
-                            <DatePicker Width="200" 
+                            <!-- todo FontSize 默认 12? -->
+                            <TextBox Tag="接收单位:"
+                                     Text="{Binding CurrDeliveryReceipt.ReceivedCompanyName}"
+                                     IsEnabled="False"
+                                     Style="{StaticResource CustomFieldTextBoxStyle}" />
+                            <TextBox Tag="发运包数:"
+                                     Text="{Binding CurrDeliveryReceipt.ShippedPackets}"
+                                     IsEnabled="False"
+                                     Style="{StaticResource CustomFieldTextBoxStyle}" />
+                            <TextBox Tag="发运数量:"
+                                     Text="{Binding CurrDeliveryReceipt.ShippedQty}"
+                                     IsEnabled="False"
+                                     Style="{StaticResource CustomFieldTextBoxStyle}" />
+
+
+                            <!-- todo 设置日期显示格式(需要修改Template,暂时不修改)减少日期选择框的 Padding(内部间距),选择按钮居右
+                             todo 宽度高度绑定-->
+                            <!-- 发运时间 -->
+                            <StackPanel Orientation="Horizontal">
+                                <TextBlock x:Name="tBlkShippedDate"
+                                           Text="*发运时间:"
+                                           Foreground="Black"
+                                           Style="{StaticResource CustomTextBlockStyle}" />
+                                <DatePicker x:Name="dpShippedDate"
+                                            Width="250" 
                                         Text="{Binding CurrDeliveryReceipt.ShippedDate, Mode=TwoWay}"
                                         SelectedDateFormat="Short"
                                         HorizontalContentAlignment="Center"
                                         VerticalContentAlignment="Center"
-                                        Height="{Binding ElementName=lblMaterial, Path=Height}"
+                                        Height="30"
                                         FontSize="14" />
-                        </StackPanel>
-                        <!-- 发运承办人 -->
-                        <StackPanel Orientation="Horizontal">
-                            <TextBlock Text="发运承办人:"
-                                       Foreground="Black"
-                                       Style="{StaticResource CustomTextBlockStyle}" />
-                            <TextBox Text="{Binding CurrDeliveryReceipt.ShippedMan, Mode=TwoWay}"
-                                     Style="{StaticResource CustomTextBoxStyle}" />
-                        </StackPanel>
-                        <!-- 联系电话 -->
-                        <StackPanel Orientation="Horizontal">
-                            <TextBlock Text="联系电话:"
-                                       Foreground="Black"
-                                       Style="{StaticResource CustomTextBlockStyle}" />
-                            <TextBox Text="{Binding CurrDeliveryReceipt.ShippedTel, Mode=TwoWay}"
-                                     Style="{StaticResource CustomTextBoxStyle}" />
-                        </StackPanel>
-
-                    </WrapPanel>
-                </Grid>
-
-            </Border>
-
-        </StackPanel>
+                            </StackPanel>
+
+                            <TextBox x:Name="fieldShippedMan"
+                                     Tag="发运承办人:"
+                                     Text="{Binding CurrDeliveryReceipt.ShippedMan}"
+                                     IsEnabled="True"
+                                     Style="{StaticResource CustomFieldTextBoxStyle}" />
+                            <TextBox x:Name="fieldShippedTel"
+                                     Tag="联系电话:"
+                                     Text="{Binding CurrDeliveryReceipt.ShippedTel}"
+                                     IsEnabled="True"
+                                     Style="{StaticResource CustomFieldTextBoxStyle}" />
+                        </WrapPanel>
+                    </Grid>
+
+                </Border>
+
+                <!-- 接收信息 -->
+                <Border x:Name="borderReceipt"
+                        Grid.Row="4" 
+                        BorderBrush="Gray" 
+                        BorderThickness="1">
+                    <Grid Background="White">
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="auto" />
+                            <ColumnDefinition Width="*" />
+                        </Grid.ColumnDefinitions>
+
+                        <Label Grid.Column="0"
+                               BorderBrush="Gray" BorderThickness="1 0 1 0" 
+                               Width="100"
+                               Content="接收信息"
+                               FontWeight="Bold"
+                               VerticalAlignment="Stretch"
+                               HorizontalContentAlignment="Center"
+                               VerticalContentAlignment="Center" />
+
+                        <WrapPanel Grid.Column="1"
+                                   Orientation="Horizontal">
+                            <TextBox Tag="接收包数:"
+                                     Text="{Binding CurrDeliveryReceipt.ReceivedPackets}"
+                                     IsEnabled="False"
+                                     Style="{StaticResource CustomFieldTextBoxStyle}" />
+                            <TextBox Tag="接收数量:"
+                                     Text="{Binding CurrDeliveryReceipt.ReceivedQty}"
+                                     IsEnabled="False"
+                                     Style="{StaticResource CustomFieldTextBoxStyle}" />
+
+                            <!-- 接收时间 -->
+                            <StackPanel Orientation="Horizontal">
+                                <TextBlock Text="接收时间:"
+                                           Foreground="Black"
+                                           Style="{StaticResource CustomTextBlockStyle}" />
+                                <DatePicker Width="250" 
+                                            Text="{Binding CurrDeliveryReceipt.ReceivedDate, Mode=TwoWay}"
+                                            SelectedDateFormat="Short"
+                                            HorizontalContentAlignment="Center"
+                                            VerticalContentAlignment="Center"
+                                            Height="30"
+                                            FontSize="14" />
+                            </StackPanel>
+
+                            <TextBox Tag="接收承办人:"
+                                     Text="{Binding CurrDeliveryReceipt.ReceivedMan}"
+                                     IsEnabled="True"
+                                     Style="{StaticResource CustomFieldTextBoxStyle}" />
+                            <TextBox Tag="联系电话:"
+                                     Text="{Binding CurrDeliveryReceipt.ReceivedTel}"
+                                     IsEnabled="True"
+                                     Style="{StaticResource CustomFieldTextBoxStyle}" />
+
+                            <!-- 收货单状态 -->
+                            <StackPanel Orientation="Horizontal">
+                                <TextBlock Text="收货单状态*:"
+                                           Foreground="Black"
+                                           Style="{StaticResource CustomTextBlockStyle}" />
+                                <ComboBox Width="250"
+                                          Height="30"
+                                          FontSize="14"
+                                          HorizontalContentAlignment="Center"
+                                          VerticalContentAlignment="Center"
+                                          SelectedItem="{Binding CurrDeliveryReceipt.ReceivedStatus}">
+                                    <ComboBoxItem>未复核</ComboBoxItem>
+                                    <ComboBoxItem>已复核</ComboBoxItem>
+                                </ComboBox>
+                            </StackPanel>
+                        </WrapPanel>
+                    </Grid>
+                </Border>
+
+            </Grid>
+        </Border>
 
         <!-- 发货单明细工具栏 -->
         <Border Grid.Row="3" 
@@ -596,25 +737,39 @@
                 Height="{Binding Path=ActualHeight,ElementName=toolBarDelivery}">
             <ToolBar Background="White"
                          ToolBarTray.IsLocked="True">
-                <Button Content="新增"
+                <Button x:Name="btnAddDtl"
+                        Content="新增"
                         Tag="{x:Static utils:RegularFontUtil.Add_Circle_32}"
                         Template="{StaticResource CustomToolBarButtomTemplate}"
                         Command="{Binding AddDetailCommand}" />
-                <Button Content="删除"
+                <Button x:Name="btnDeleteDtl"
+                        Content="删除"
                         Tag="{x:Static utils:RegularFontUtil.Delete_32}"
                         Template="{StaticResource CustomToolBarButtomTemplate}"
                         Command="{Binding DeleteDetailCommand}"
                         CommandParameter="{Binding ElementName=fdgDeliveryDetail}" />
-                <Separator />
+                <Separator x:Name="sep2" />
                 <!-- Arrow_Turn_Right_48 -->
-                <Button Content="导入"
+                <Button x:Name="btnImportDtl"
+                        Content="导入"
                         Tag="{x:Static utils:RegularFontUtil.Arrow_Circle_Down_32}"
                         Template="{StaticResource CustomToolBarButtomTemplate}"
                         Command="{Binding ImportDetailCommand}" />
-                <Button Content="导出"
+                <Button x:Name="btnExportDtl"
+                        Content="导出"
                         Tag="{x:Static utils:RegularFontUtil.Arrow_Circle_Up_32}"
                         Template="{StaticResource CustomToolBarButtomTemplate}"
                         Command="{Binding ExportDetailCommand}" />
+                <Button x:Name="btnReceiveDtl"
+                        Content="全部接收"
+                        Tag="{x:Static utils:RegularFontUtil.Clipboard_Checkmark_24}"
+                        Template="{StaticResource CustomToolBarButtomTemplate}"
+                        Command="{Binding ReceiveCommand}" />
+                <Button x:Name="btnUseDtl"
+                        Content="全部使用"
+                        Tag="{x:Static utils:RegularFontUtil.Box_Checkmark_24}"
+                        Template="{StaticResource CustomToolBarButtomTemplate}"
+                        Command="{Binding UsageCommand}" />
             </ToolBar>
         </Border>
 
@@ -628,11 +783,12 @@
                             CanUserAddRows="False"
                             CanUserResizeRows="False"
                             SelectionMode="Single"
-                            SelectionUnit="FullRow"
+                            SelectionUnit="CellOrRowHeader"
                             HeadersVisibility="All"
                             GridLinesVisibility="All"
                             ShowRowsCount="True"
                             RowHeaderWidth="30"
+                            LoadingRow="DataGrid_LoadingRow"
                             ColumnHeaderStyle="{StaticResource CustomColumnHeaderStyle}"
                             RowHeaderStyle="{StaticResource CustomRowHeaderStyle}"
                             RowStyle="{StaticResource CustomRowStyle}"
@@ -643,7 +799,14 @@
             <b:Interaction.Triggers>
                 <!-- 选择行切换事件 -->
                 <b:EventTrigger EventName="SelectionChanged">
-                    <b:InvokeCommandAction Command="{Binding DetailSelectionChangedCommand}" />
+                    <b:InvokeCommandAction Command="{Binding DetailSelectionChangedCommand}"
+                                           CommandParameter="{Binding ElementName=fdgDeliveryDetail}" />
+                </b:EventTrigger>
+
+                <!-- 选择单元格切换事件 -->
+                <b:EventTrigger EventName="SelectedCellsChanged">
+                    <b:InvokeCommandAction Command="{Binding DetailCellChangedCommand}"
+                                           CommandParameter="{Binding ElementName=fdgDeliveryDetail}" />
                 </b:EventTrigger>
 
             </b:Interaction.Triggers>
@@ -654,18 +817,46 @@
                 <fdg:FilterDataGridCheckBoxColumn Header="  " Width="30"
                                                   ElementStyle="{StaticResource CheckBoxColumnElementStyle}"
                                                   EditingElementStyle="{StaticResource CheckBoxColumnElementStyle}" />
-                <fdg:FilterDataGridTextColumn Header="材料包号" Width="*"
+                <fdg:FilterDataGridTextColumn Header="批次号*" Width="100"
+                                              ElementStyle="{StaticResource TextColumnElementStyle}"
+                                              EditingElementStyle="{StaticResource TextColumnEditingStyle}"
+                                              Binding="{Binding BatchNo, UpdateSourceTrigger=PropertyChanged}" />
+                <fdg:FilterDataGridTextColumn Header="材料包号*" Width="100"
                                               ElementStyle="{StaticResource TextColumnElementStyle}"
                                               EditingElementStyle="{StaticResource TextColumnEditingStyle}"
                                               Binding="{Binding PacketNo, UpdateSourceTrigger=PropertyChanged}" />
-                <fdg:FilterDataGridTextColumn Header="发运数量" Width="*"
+                <fdg:FilterDataGridTextColumn Header="发运数量*" Width="100"
                                               ElementStyle="{StaticResource TextColumnElementStyle}"
                                               EditingElementStyle="{StaticResource TextColumnEditingStyle}"
                                               Binding="{Binding ShippedQuantity, UpdateSourceTrigger=PropertyChanged}" />
-                <fdg:FilterDataGridTextColumn Header="备注" Width="*"
+                <fdg:FilterDataGridTextColumn Header="接收数量*" Width="100"
+                                              ElementStyle="{StaticResource TextColumnElementStyle}"
+                                              EditingElementStyle="{StaticResource TextColumnEditingStyle}"
+                                              Binding="{Binding ReceiveQuantity, UpdateSourceTrigger=PropertyChanged}" />
+                <fdg:FilterDataGridTextColumn Header="使用数量*" Width="100"
+                                              ElementStyle="{StaticResource TextColumnElementStyle}"
+                                              EditingElementStyle="{StaticResource TextColumnEditingStyle}"
+                                              Binding="{Binding UsageQuantity, UpdateSourceTrigger=PropertyChanged}" />
+                <fdg:FilterDataGridTextColumn Header="使用状态" Width="100"
+                                              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>

+ 11 - 3
UniformMaterialManagementSystem/Views/DeliveryReceiptControl.xaml.cs

@@ -31,12 +31,20 @@ namespace UniformMaterialManagementSystem.Views
 
             // 绑定 ViewModel
             this.DataContext = App.Current.Services.GetService<DeliveryReceiptViewModel>();
+        }
 
-            // 注册控件事件
-            this.fdgDelivery.LoadingRow += DataGrid_LoadingRow;
-            this.fdgDeliveryDetail.LoadingRow += DataGrid_LoadingRow;
+        public DeliveryReceiptControl(DeliveryPageCategroy categroy)
+        {
+            InitializeComponent();
+
+            // 绑定 ViewModel
+            var service = App.Current.Services.GetService<IDataBaseService<DeliveryReceipt>>();
+            if (service == null) { return; }
+            DeliveryReceiptViewModel vm = new DeliveryReceiptViewModel(service, categroy);
+            this.DataContext = vm;
         }
 
+        // 控件属性注册事件
         private void DataGrid_LoadingRow(object? sender, DataGridRowEventArgs e)
         {
             // 设置行标题:行索引+1

+ 17 - 0
UniformMaterialManagementSystem/Views/MaterialDeliveryPage.xaml

@@ -0,0 +1,17 @@
+<UserControl x:Class="UniformMaterialManagementSystem.Views.MaterialDeliveryPage"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:UniformMaterialManagementSystem.Views"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <Grid>
+        <Border BorderBrush="Gray"
+                BorderThickness="1"
+                Background="White">
+            <ContentControl x:Name="currContentControl" />
+
+        </Border> 
+    </Grid>
+</UserControl>

+ 33 - 0
UniformMaterialManagementSystem/Views/MaterialDeliveryPage.xaml.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+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;
+using Microsoft.Extensions.DependencyInjection;
+using UniformMaterialManagementSystem.ViewModels;
+
+namespace UniformMaterialManagementSystem.Views
+{
+    /// <summary>
+    /// MaterialDeliveryPage.xaml 的交互逻辑
+    /// </summary>
+    public partial class MaterialDeliveryPage : UserControl
+    {
+        public MaterialDeliveryPage()
+        {
+            InitializeComponent();
+
+            // 展示材料发货单
+            this.currContentControl.Content = new DeliveryReceiptControl(DeliveryPageCategroy.Delivery);
+        }
+    }
+}

+ 17 - 0
UniformMaterialManagementSystem/Views/MaterialReceiptPage.xaml

@@ -0,0 +1,17 @@
+<UserControl x:Class="UniformMaterialManagementSystem.Views.MaterialReceiptPage"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:UniformMaterialManagementSystem.Views"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <Grid>
+        <Border BorderBrush="Gray"
+                BorderThickness="1"
+                Background="White">
+            <ContentControl x:Name="currContentControl" />
+
+        </Border>
+    </Grid>
+</UserControl>

+ 32 - 0
UniformMaterialManagementSystem/Views/MaterialReceiptPage.xaml.cs

@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+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;
+using UniformMaterialManagementSystem.ViewModels;
+
+namespace UniformMaterialManagementSystem.Views
+{
+    /// <summary>
+    /// MaterialReceiptPage.xaml 的交互逻辑
+    /// </summary>
+    public partial class MaterialReceiptPage : UserControl
+    {
+        public MaterialReceiptPage()
+        {
+            InitializeComponent();
+
+            // 展示材料接收单
+            this.currContentControl.Content = new DeliveryReceiptControl(DeliveryPageCategroy.Receipt);
+        }
+    }
+}

+ 18 - 0
UniformMaterialManagementSystem/Views/MaterialUsagePage.xaml

@@ -0,0 +1,18 @@
+<UserControl x:Class="UniformMaterialManagementSystem.Views.MaterialUsagePage"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:UniformMaterialManagementSystem.Views"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <Grid>
+        <Border BorderBrush="Gray"
+                BorderThickness="1"
+                Background="White">
+            <ContentControl x:Name="currContentControl" />
+
+        </Border>
+            
+    </Grid>
+</UserControl>

+ 32 - 0
UniformMaterialManagementSystem/Views/MaterialUsagePage.xaml.cs

@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+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;
+using UniformMaterialManagementSystem.ViewModels;
+
+namespace UniformMaterialManagementSystem.Views
+{
+    /// <summary>
+    /// MaterialUsagePage.xaml 的交互逻辑
+    /// </summary>
+    public partial class MaterialUsagePage : UserControl
+    {
+        public MaterialUsagePage()
+        {
+            InitializeComponent();
+
+            // 展示材料使用单
+            this.currContentControl.Content = new DeliveryReceiptControl(DeliveryPageCategroy.Usage);
+        }
+    }
+}

+ 9 - 4
UniformMaterialManagementSystem/Views/SelectApplyContractDialog.xaml

@@ -205,14 +205,19 @@
                                             Margin="0 3 0 3"
                                             ItemsSource="{Binding Materials}"
                                             DisplayMemberPath="Name"
-                                            SelectedItem="{Binding SelectedMaterial, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+                                            SelectedItem="{Binding SelectedMaterial, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
+                        <b:Interaction.Triggers>
+                            <b:EventTrigger EventName="SelectionChanged">
+                                <b:InvokeCommandAction Command="{Binding  MaterialSelectionChangedCommand}" /> 
+                            </b:EventTrigger>
+                        </b:Interaction.Triggers>
+                    </custom:AutoCompleteBox>
                 </StackPanel>
                 <Button Content="查询"
                         Margin="5 0 5 0"
                         Tag="{x:Static utils:RegularFontUtil.Search_32}"
                         Template="{StaticResource CustomToolBarButtomTemplate}"
-                        Command="{Binding QueryCommand}"
-                        CommandParameter="{Binding ElementName=autoListBoxMate}">
+                        Command="{Binding QueryCommand}" >
                 </Button>
                 <Separator />
                 <Button Content="确认选择"
@@ -343,7 +348,7 @@
             <b:Interaction.Triggers>
                 <!-- 行切换事件 -->
                 <b:EventTrigger EventName="SelectionChanged">
-                    <b:InvokeCommandAction Command="{Binding SelectionChangedCommand}"
+                    <b:InvokeCommandAction Command="{Binding ContractSelectionChangedCommand}"
                                            CommandParameter="{Binding ElementName=fdgContract}" />
                 </b:EventTrigger>
             </b:Interaction.Triggers>