Browse Source

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

宝臣 王 3 months ago
parent
commit
1aa5b18138

BIN
Document/被装材料数据库设计.docx


+ 4 - 0
UniformMaterialManagementSystem/Entities/Contract.cs

@@ -19,6 +19,8 @@ namespace UniformMaterialManagementSystem.Entities
 
         public byte[]? Attachment { get; set; }
 
+        public byte[]? ApplyAttachment { get; set; }
+
         [StringLength(50)] 
         public string EditUser { get; set; } = null!;
 
@@ -31,6 +33,8 @@ namespace UniformMaterialManagementSystem.Entities
 
         public int Year { get; set; }
 
+        public bool ChangedStatus { get; set; }
+
         public Company Company { get; set; } = null!;
 
         public Company PurchaseCompany { get; set; } = null!;

+ 4 - 0
UniformMaterialManagementSystem/Entities/ContractDetail.cs

@@ -13,6 +13,8 @@ namespace UniformMaterialManagementSystem.Entities
 
         public double ContractQty { get; set; }
 
+        public double ReduceQuantity { get; set; }
+
         public DateTime DeliveryTime { get; set; }
 
         public double InspectedQty { get; set; }
@@ -21,6 +23,8 @@ namespace UniformMaterialManagementSystem.Entities
 
         public double ShippedQuantity { get; set; }
 
+        public bool ShippedStatus { get; set; }
+
         [StringLength(50)] 
         public string InspectStatus { get; set; } = string.Empty;
 

+ 1211 - 0
UniformMaterialManagementSystem/Migrations/20240807075759_ModifyContract0807.Designer.cs

@@ -0,0 +1,1211 @@
+// <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("20240807075759_ModifyContract0807")]
+    partial class ModifyContract0807
+    {
+        /// <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[]>("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>("BatchNo")
+                        .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<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.HasKey("Guid");
+
+                    b.ToTable("DeliveryReceipts");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.DeliveryReceiptDetail", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("DeliveryReceiptGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("PacketNo")
+                        .IsRequired()
+                        .HasColumnType("TEXT");
+
+                    b.Property<double?>("ReceiveQuantity")
+                        .HasColumnType("REAL");
+
+                    b.Property<double>("ShippedQuantity")
+                        .HasColumnType("REAL");
+
+                    b.Property<double?>("UseQuantity")
+                        .HasColumnType("REAL");
+
+                    b.Property<string>("UseStatus")
+                        .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<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.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
+        }
+    }
+}

+ 51 - 0
UniformMaterialManagementSystem/Migrations/20240807075759_ModifyContract0807.cs

@@ -0,0 +1,51 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace UniformMaterialManagementSystem.Migrations
+{
+    /// <inheritdoc />
+    public partial class ModifyContract0807 : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AddColumn<bool>(
+                name: "ChangedStatus",
+                table: "Contracts",
+                type: "INTEGER",
+                nullable: false,
+                defaultValue: false);
+
+            migrationBuilder.AddColumn<double>(
+                name: "ReduceQuantity",
+                table: "ContractDetails",
+                type: "REAL",
+                nullable: false,
+                defaultValue: 0.0);
+
+            migrationBuilder.AddColumn<bool>(
+                name: "ShippedStatus",
+                table: "ContractDetails",
+                type: "INTEGER",
+                nullable: false,
+                defaultValue: false);
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropColumn(
+                name: "ChangedStatus",
+                table: "Contracts");
+
+            migrationBuilder.DropColumn(
+                name: "ReduceQuantity",
+                table: "ContractDetails");
+
+            migrationBuilder.DropColumn(
+                name: "ShippedStatus",
+                table: "ContractDetails");
+        }
+    }
+}

+ 1214 - 0
UniformMaterialManagementSystem/Migrations/20240808002907_1.Designer.cs

@@ -0,0 +1,1214 @@
+// <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("20240808002907_1")]
+    partial class _1
+    {
+        /// <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>("BatchNo")
+                        .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<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.HasKey("Guid");
+
+                    b.ToTable("DeliveryReceipts");
+                });
+
+            modelBuilder.Entity("UniformMaterialManagementSystem.Entities.DeliveryReceiptDetail", b =>
+                {
+                    b.Property<Guid>("Guid")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("TEXT");
+
+                    b.Property<Guid>("DeliveryReceiptGuid")
+                        .HasColumnType("TEXT");
+
+                    b.Property<string>("PacketNo")
+                        .IsRequired()
+                        .HasColumnType("TEXT");
+
+                    b.Property<double?>("ReceiveQuantity")
+                        .HasColumnType("REAL");
+
+                    b.Property<double>("ShippedQuantity")
+                        .HasColumnType("REAL");
+
+                    b.Property<double?>("UseQuantity")
+                        .HasColumnType("REAL");
+
+                    b.Property<string>("UseStatus")
+                        .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<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.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
+        }
+    }
+}

+ 28 - 0
UniformMaterialManagementSystem/Migrations/20240808002907_1.cs

@@ -0,0 +1,28 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace UniformMaterialManagementSystem.Migrations
+{
+    /// <inheritdoc />
+    public partial class _1 : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AddColumn<byte[]>(
+                name: "ApplyAttachment",
+                table: "Contracts",
+                type: "BLOB",
+                nullable: true);
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropColumn(
+                name: "ApplyAttachment",
+                table: "Contracts");
+        }
+    }
+}

+ 12 - 0
UniformMaterialManagementSystem/Migrations/SqliteContextModelSnapshot.cs

@@ -73,9 +73,15 @@ namespace UniformMaterialManagementSystem.Migrations
                         .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");
 
@@ -144,9 +150,15 @@ namespace UniformMaterialManagementSystem.Migrations
                     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");
 

+ 106 - 0
UniformMaterialManagementSystem/Models/ContractModel.cs

@@ -0,0 +1,106 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using System.Collections.ObjectModel;
+using UniformMaterialManagementSystem.Entities;
+
+namespace UniformMaterialManagementSystem.Models
+{
+    public partial class ContractModel : ObservableObject
+    {
+        [ObservableProperty]
+        private Guid _guid;
+
+        [ObservableProperty]
+        private Guid _companyGuid;
+
+        [ObservableProperty]
+        private Guid _purchaseCompanyGuid;
+
+        [ObservableProperty]
+        private string _contractNo = null!;
+
+        [ObservableProperty]
+        private DateTime _signingDate;
+
+        [ObservableProperty]
+        private byte[]? _attachment;
+
+        [ObservableProperty]
+        private byte[]? _applyAttachment;
+
+        [ObservableProperty]
+        private string _editUser = null!;
+
+        [ObservableProperty]
+        private string _telephone = null!;
+
+        [ObservableProperty]
+        private DateTime _editDate;
+
+        [ObservableProperty]
+        private bool _exportStatus;
+
+        [ObservableProperty]
+        private int _year;
+
+        [ObservableProperty]
+        private bool _changedStatus;
+
+        [ObservableProperty]
+        private bool _isSelected;
+
+        [ObservableProperty]
+        private Company _company = null!;
+
+        [ObservableProperty]
+        private Company _purchaseCompany = null!;
+
+        [ObservableProperty]
+        private ObservableCollection<ContractDetail> _contractDetails = [];
+
+        public ContractModel(Contract contract)
+        {
+            Guid = contract.Guid;
+            CompanyGuid = contract.CompanyGuid;
+            PurchaseCompanyGuid = contract.PurchaseCompanyGuid;
+            ContractNo = contract.ContractNo;
+            SigningDate = contract.SigningDate;
+            Attachment = contract.Attachment;
+            ApplyAttachment = contract.ApplyAttachment;
+            EditUser = contract.EditUser;
+            Telephone = contract.Telephone;
+            EditDate = contract.EditDate;
+            ExportStatus = contract.ExportStatus;
+            Year = contract.Year;
+            ChangedStatus = contract.ChangedStatus;
+            IsSelected = false;  //默认选中状态
+            Company = contract.Company;
+            PurchaseCompany = contract.PurchaseCompany;
+
+            foreach (var detail in contract.ContractDetails)
+            {
+                ContractDetails.Add(detail);
+            }
+        }
+
+        //public void ModifyContract(Contract contract)
+        //{
+        //    contract.Guid = Guid;
+        //    contract.CompanyGuid = CompanyGuid;
+        //    contract.PurchaseCompanyGuid = PurchaseCompanyGuid;
+        //    contract.ContractNo = ContractNo;
+        //    contract.SigningDate = SigningDate;
+        //    contract.Attachment = Attachment;
+        //    contract.ApplyAttachment = ApplyAttachment;
+        //    contract.EditUser = EditUser;
+        //    contract.Telephone = Telephone;
+        //    contract.EditDate = EditDate;
+        //    contract.ExportStatus = ExportStatus;
+        //    contract.Year = Year;
+        //    contract.ChangedStatus = ChangedStatus;
+        //    contract.Company = Company;
+        //    contract.PurchaseCompany = PurchaseCompany;
+        //    contract.ContractDetails = [];
+            
+        //}
+    }
+}

+ 2 - 2
UniformMaterialManagementSystem/Models/ContractDetailModel.cs → UniformMaterialManagementSystem/Models/SelectContractDetailModel.cs

@@ -3,7 +3,7 @@ using UniformMaterialManagementSystem.Entities;
 
 namespace UniformMaterialManagementSystem.Models
 {
-    public partial class ContractDetailModel : ObservableObject
+    public partial class SelectContractDetailModel : ObservableObject
     {
         [ObservableProperty]
         private Guid _guid;
@@ -44,7 +44,7 @@ namespace UniformMaterialManagementSystem.Models
         [ObservableProperty]
         private string _inspectStatus = null!;
 
-        public ContractDetailModel(ContractDetail detail)
+        public SelectContractDetailModel(ContractDetail detail)
         {
             Guid = detail.Guid;
             IsSelect = false;

+ 0 - 1
UniformMaterialManagementSystem/Utils/ContractUtil.cs

@@ -2,7 +2,6 @@
 using DocumentFormat.OpenXml;
 using DocumentFormat.OpenXml.Packaging;
 using DocumentFormat.OpenXml.Spreadsheet;
-
 using UniformMaterialManagementSystem.Entities;
 
 namespace UniformMaterialManagementSystem.Utils

+ 298 - 88
UniformMaterialManagementSystem/ViewModels/ContractPageViewModel.cs

@@ -8,6 +8,7 @@ using System.IO;
 using System.Text;
 using System.Windows;
 using UniformMaterialManagementSystem.Entities;
+using UniformMaterialManagementSystem.Models;
 using UniformMaterialManagementSystem.Services;
 using UniformMaterialManagementSystem.Utils;
 
@@ -45,10 +46,6 @@ namespace UniformMaterialManagementSystem.ViewModels
         [Required(ErrorMessage = "填报人不能为空")]
         private string? _editUser;
 
-        [ObservableProperty]
-        [Required(ErrorMessage = "填报时间不能为空")]
-        private DateTime? _editDate = DateTime.Now;
-
         [ObservableProperty]
         [Required(ErrorMessage = "联系电话不能为空")]
         private string? _telephone;
@@ -56,24 +53,30 @@ namespace UniformMaterialManagementSystem.ViewModels
         [ObservableProperty]
         private byte[]? _attachment;
 
+        [ObservableProperty]
+        private byte[]? _applyAttachment;
+
         [ObservableProperty]
         private bool _isUpload;
 
+        [ObservableProperty]
+        private bool _applyIsUpload;
+
         [ObservableProperty]
         private ObservableCollection<ContractDetail> _contractDetails = [];
 
         private ContractDetail? _selectedContractDetail;
 
-        private readonly IDataBaseService<Contract>? _contractService;
+        private readonly IDataBaseService<Contract> _contractService;
 
-        private readonly IDataBaseService<ContractDetail>? _contractDetailService;
+        private readonly IDataBaseService<ContractDetail> _contractDetailService;
 
         //查询结果
         [ObservableProperty]
-        private ObservableCollection<Contract> _unExportContracts = [];
+        private ObservableCollection<ContractModel> _unExportContracts = [];
 
         [ObservableProperty]
-        private Contract? _selectedUnExportContract;
+        private ContractModel? _selectedUnExportContract;
 
         private string _contactStatus = "Add";//Add:新增 Modify:修改
 
@@ -87,7 +90,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         [ObservableProperty]
         private Contract? _selectedContract;
 
-        private IDataBaseService<InspectApplyContractDetail>? _inspectApplyContractDetailService;
+        private readonly IDataBaseService<InspectApplyContractDetail> _inspectApplyContractDetailService;
 
         #endregion
 
@@ -122,8 +125,11 @@ namespace UniformMaterialManagementSystem.ViewModels
             SetDefaultCompany();
 
             //默认填报人
-            EditUser = App.CurrentUser.UserName;
+            EditUser = App.CurrentUser!.UserName;
 
+            //加载数据
+            LoadData();
+            LoadUnExportData();
         }
 
         #region 合同录入相关方法
@@ -156,28 +162,27 @@ namespace UniformMaterialManagementSystem.ViewModels
         private void LoadUnExportData()
         {
             /* 超级管理员和区域站可以查看所有企业数据,生产企业用户只能查看自己公司相关数据 */
-            List<Contract>? contractList;
+            List<Contract> contractList;
             if (CommonUtil.GetRoleType() == RoleType.Admin || CommonUtil.GetRoleType() == RoleType.Supervision)
             {
-                contractList = _contractService?.Query(x => !x.ExportStatus)
-                    .Include(x => x.ContractDetails)
+                contractList = _contractService.Query(x => !x.ExportStatus && x.Year == App.CurrentUser!.WorkYear)
+                    .Include(x => x.ContractDetails).ThenInclude(x => x.Material)
                     .Include(x => x.Company)
                     .Include(x => x.PurchaseCompany).ToList();
             }
             else
             {
-                contractList = _contractService?.Query(x => !x.ExportStatus && (x.CompanyGuid == App.CurrentUser!.CompanyGuid || x.PurchaseCompanyGuid == App.CurrentUser.CompanyGuid))
-                    .Include(x => x.ContractDetails)
+                contractList = _contractService.Query(x => !x.ExportStatus && x.Year == App.CurrentUser!.WorkYear && (x.CompanyGuid == App.CurrentUser.CompanyGuid || x.PurchaseCompanyGuid == App.CurrentUser.CompanyGuid))
+                    .Include(x => x.ContractDetails).ThenInclude(x => x.Material)
                     .Include(x => x.Company)
                     .Include(x => x.PurchaseCompany).ToList();
             }
 
             UnExportContracts.Clear();
 
-            if (contractList == null) return;
             foreach (var contract in contractList)
             {
-                UnExportContracts.Add(contract);
+                UnExportContracts.Add(new ContractModel(contract));
             }
         }
 
@@ -198,7 +203,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         /// 未导出合同列表选择行改变事件
         /// </summary>
         [RelayCommand]
-        private void UnExportContractSelectionChanged(Contract contract)
+        private void UnExportContractSelectionChanged(ContractModel contract)
         {
             SelectedUnExportContract = contract;
 
@@ -219,9 +224,9 @@ namespace UniformMaterialManagementSystem.ViewModels
             ContractNo = SelectedUnExportContract.ContractNo;
             SigningDate = SelectedUnExportContract.SigningDate;
             EditUser = SelectedUnExportContract.EditUser;
-            EditDate = SelectedUnExportContract.EditDate;
             Telephone = SelectedUnExportContract.Telephone;
             Attachment = SelectedUnExportContract.Attachment;
+            ApplyAttachment = SelectedUnExportContract.ApplyAttachment;
 
             ContractDetails.Clear();
             foreach (var detail in SelectedUnExportContract.ContractDetails)
@@ -236,6 +241,15 @@ namespace UniformMaterialManagementSystem.ViewModels
             {
                 IsUpload = true;
             }
+
+            if (ApplyAttachment == null || ApplyAttachment.Length == 0)
+            {
+                ApplyIsUpload = false;
+            }
+            else
+            {
+                ApplyIsUpload = true;
+            }
         }
 
         /// <summary>
@@ -277,12 +291,44 @@ namespace UniformMaterialManagementSystem.ViewModels
                     return;
                 }
 
+                if (SelectedUnExportContract.ChangedStatus) //合同变更状态
+                {
+                    if (ApplyAttachment == null || ApplyAttachment.Length == 0)
+                    {
+                        MessageBox.Show("请上传合同变更申请!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                        return;
+                    }
+
+                    StringBuilder sb = new StringBuilder();
+                    var existDetails = _contractDetailService.QueryNoTracking(x => x.ContractGuid == SelectedUnExportContract.Guid).ToList();
+                    for (int i = 0; i < ContractDetails.Count; i++)
+                    {
+                        var detail = ContractDetails[i];
+                        var existDetail = existDetails?.Find(x => x.Guid == detail.Guid);
+                        if (existDetail == null) continue;
+                        if (detail.ContractQty > existDetail.ContractQty + existDetail.ReduceQuantity)
+                        {
+                            sb.AppendLine($"合同明细第{i + 1}行,不可调增,只可调减!(原合同成交数量为{existDetail.ContractQty + existDetail.ReduceQuantity})");
+                        }
+                        else
+                        {
+                            detail.ReduceQuantity = existDetail.ContractQty + existDetail.ReduceQuantity - detail.ContractQty;
+                        }
+                    }
+
+                    if (sb.ToString().Length > 0)
+                    {
+                        MessageBox.Show(sb.ToString(), "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                        return;
+                    }
+                }
+
                 UpdateContract(SelectedUnExportContract);
                 UpdateContractDetails();
 
-                var result = _contractService?.SaveChanges();
+                var result = _contractService.SaveChanges();
 
-                if (result != null && (bool)result)
+                if (result)
                 {
                     MessageBox.Show($"材料合同号:{ContractNo},保存成功!");
                 }
@@ -292,18 +338,22 @@ namespace UniformMaterialManagementSystem.ViewModels
             LoadUnExportData();
         }
 
-        private void UpdateContract(Contract contract)
+        private void UpdateContract(ContractModel contractModel)
         {
-            contract.Company = SelectedMaterialCompany;
-            contract.CompanyGuid = SelectedMaterialCompany.Guid;
-            contract.PurchaseCompany = SelectedProductCompany;
-            contract.PurchaseCompanyGuid = SelectedProductCompany.Guid;
-            contract.ContractNo = ContractNo;
-            contract.SigningDate = SigningDate.GetValueOrDefault();
-            contract.EditUser = EditUser;
-            contract.EditDate = EditDate.GetValueOrDefault();
-            contract.Telephone = Telephone;
-            contract.Attachment = Attachment;
+            var contract = _contractService.Get(x => x.Guid == contractModel.Guid);
+            if (contract != null)
+            {
+                contract.Company = SelectedMaterialCompany;
+                contract.CompanyGuid = SelectedMaterialCompany.Guid;
+                contract.PurchaseCompany = SelectedProductCompany;
+                contract.PurchaseCompanyGuid = SelectedProductCompany.Guid;
+                contract.ContractNo = ContractNo;
+                contract.SigningDate = SigningDate.GetValueOrDefault();
+                contract.EditUser = EditUser;
+                contract.Telephone = Telephone;
+                contract.Attachment = Attachment;
+                contract.ApplyAttachment = ApplyAttachment;
+            }
         }
 
         private void UpdateContractDetails()
@@ -311,19 +361,19 @@ namespace UniformMaterialManagementSystem.ViewModels
             if (ContractDetails.Count == 0) return;
             if (SelectedUnExportContract == null) return;
 
-            var existDetails = _contractDetailService?.GetAll(x => x.ContractGuid == SelectedUnExportContract.Guid).ToList();
-            if (existDetails == null) return;
+            var existDetails = _contractDetailService.GetAll(x => x.ContractGuid == SelectedUnExportContract.Guid).ToList();
 
             foreach (var detail in ContractDetails)
             {
                 detail.ContractGuid = SelectedUnExportContract.Guid;
 
-                var existDetail = existDetails?.FirstOrDefault(x => x.Guid == detail.Guid);
+                var existDetail = existDetails.FirstOrDefault(x => x.Guid == detail.Guid);
                 if (existDetail != null)
                 {
                     //更新
                     existDetail.MaterialGuid = detail.Material.Guid;
                     existDetail.ContractQty = detail.ContractQty;
+                    existDetail.ReduceQuantity = detail.ReduceQuantity;
                     existDetail.DeliveryTime = detail.DeliveryTime;
                     existDetail.UnitPrice = detail.UnitPrice;
                 }
@@ -333,6 +383,15 @@ namespace UniformMaterialManagementSystem.ViewModels
                     _contractDetailService?.Insert(detail);
                 }
             }
+
+            foreach (var existDetail in existDetails)
+            {
+                var detail = ContractDetails?.FirstOrDefault(x => x.Guid == existDetail.Guid);
+                if (detail == null)
+                {
+                    _contractDetailService?.Delete(existDetail);
+                }
+            }
         }
 
         /// <summary>
@@ -341,16 +400,61 @@ namespace UniformMaterialManagementSystem.ViewModels
         [RelayCommand]
         private void DeleteUnExportContract()
         {
-            if (SelectedUnExportContract == null)
+            //if (SelectedUnExportContract == null)
+            //{
+            //    MessageBox.Show("请选中一行,再进行删除操作!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+            //    return;
+            //}
+
+            //if (SelectedUnExportContract.ChangedStatus)
+            //{
+            //    MessageBox.Show("合同正在变更,不可删除!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+            //    return;
+            //}
+            /* 确认删除提示 */
+            //var result = MessageBox.Show($"确认删除材料合同号:{SelectedUnExportContract.ContractNo}的材料采购合同吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+            //if (result != MessageBoxResult.OK) return;
+
+            //_contractService?.Delete(x => x.Guid == SelectedUnExportContract.Guid);
+            //_contractService?.SaveChanges();
+            
+
+            var selectedContracts = new List<ContractModel>();
+            var changedContracts = new List<ContractModel>();
+            foreach (var contract in UnExportContracts)
+            {
+                if (!contract.IsSelected) continue;
+                if (contract.ChangedStatus)
+                {
+                    changedContracts.Add(contract);
+                }
+                else
+                {
+                    selectedContracts.Add(contract);
+                }
+            }
+
+            if (selectedContracts.Count + changedContracts.Count == 0)
             {
-                MessageBox.Show("请选中一行,再进行删除操作!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                MessageBox.Show($"没有选中任何行", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                 return;
             }
+            if (selectedContracts.Count == 0)
+            {
+                MessageBox.Show($"变更状态的合同不允许删除,请选择未变更的合同进行删除!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                return;
+            }
+
             /* 确认删除提示 */
-            var result = MessageBox.Show($"确认删除材料合同号:{SelectedUnExportContract.ContractNo}的材料采购合同吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+            var result = MessageBox.Show($"您选中了{selectedContracts.Count + changedContracts.Count}条合同,将有{changedContracts.Count}条合同被删除,确认继续?(变更状态的合同不允许删除)", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
             if (result != MessageBoxResult.OK) return;
 
-            _contractService?.Delete(SelectedUnExportContract);
+            //删除选中行
+            foreach (var contract in selectedContracts)
+            {
+                _contractService?.Delete(x => x.Guid == contract.Guid);
+            }
+
             _contractService?.SaveChanges();
 
             /* 重新加载数据 */
@@ -364,11 +468,22 @@ namespace UniformMaterialManagementSystem.ViewModels
         private void ExportExcelAttachment()
         {
             /* 加载数据 */
-            LoadUnExportData();
+            //LoadUnExportData();
 
             if (UnExportContracts.Count == 0) return;
 
-            var result = MessageBox.Show($"确认导出所有合同数据吗?(导出文件将会按照成品企业合并数据,导出后将无法修改和删除)", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+            List<ContractModel> exportContracts = new List<ContractModel>();
+            foreach (var contract in UnExportContracts)
+            {
+                if (contract.IsSelected)
+                {
+                    exportContracts.Add(contract);
+                }
+            }
+
+            if (exportContracts.Count == 0) return;
+
+            var result = MessageBox.Show($"共选中{exportContracts.Count}行合同数据,确认导出已选中合同数据吗?(导出文件将会按照成品企业合并数据,导出后将无法修改和删除)", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
 
             if (result != MessageBoxResult.OK) return;
 
@@ -383,7 +498,7 @@ namespace UniformMaterialManagementSystem.ViewModels
                 var filePath = saveFileDialog.FileName;
 
                 HashSet<string> productCompanyNames = new HashSet<string>();
-                foreach (var contract in UnExportContracts)
+                foreach (var contract in exportContracts)
                 {
                     var name = contract.PurchaseCompany.Name;
                     productCompanyNames.Add(name);
@@ -397,7 +512,7 @@ namespace UniformMaterialManagementSystem.ViewModels
                 {
                     dictionary.Clear();
                     contractDetails.Clear();
-                    var contracts = UnExportContracts.Where(x => x.PurchaseCompany.Name == productCompanyName).ToList();
+                    var contracts = exportContracts.Where(x => x.PurchaseCompany.Name == productCompanyName).ToList();
                     foreach (var contract in contracts)
                     {
                         //只能添加一次
@@ -428,7 +543,7 @@ namespace UniformMaterialManagementSystem.ViewModels
                 MessageBox.Show($"文件导出成功!共生成{productCompanyNames.Count}个文件。");
 
                 /* 反写合同的导出状态为已导出 */
-                UpdateContractExportStatus(UnExportContracts, true);
+                UpdateContractExportStatus(exportContracts, true);
 
                 /* 重新加载数据 */
                 LoadUnExportData();
@@ -443,10 +558,9 @@ namespace UniformMaterialManagementSystem.ViewModels
         /// </summary>
         /// <param name="contracts"></param>
         /// <param name="status"></param>
-        private void UpdateContractExportStatus(ObservableCollection<Contract> contracts, bool status)
+        private void UpdateContractExportStatus(List<ContractModel> contracts, bool status)
         {
-            var contractList = _contractService?.Query(x => x.ExportStatus != status).ToList();
-            if (contractList == null) return;
+            var contractList = _contractService.Query(x => x.ExportStatus != status).ToList();
             foreach (var contract in contracts)
             {
                 var contractEntity = contractList.Find(x => x.Guid == contract.Guid);
@@ -454,7 +568,7 @@ namespace UniformMaterialManagementSystem.ViewModels
                 contractEntity.ExportStatus = status;
             }
 
-            _contractService?.SaveChanges();
+            _contractService.SaveChanges();
         }
 
         /// <summary>
@@ -484,29 +598,63 @@ namespace UniformMaterialManagementSystem.ViewModels
         private void DownLoadAttachment()
         {
             if (Attachment == null || Attachment.Length == 0) return;
-            SaveFileDialog saveFileDialog = new SaveFileDialog()
+            string fileName = SelectedMaterialCompany?.Name + "-" + ContractNo + "-" + WordUtil.GenerateFileSerialNumber();
+            ExportAttachment(Attachment, fileName);
+        }
+
+        /// <summary>
+        /// 移除附件
+        /// </summary>
+        [RelayCommand]
+        private void RemoveAttachment()
+        {
+            Attachment = null;
+
+            IsUpload = false;
+        }
+
+        /// <summary>
+        /// 上传变更申请附件
+        /// </summary>
+        [RelayCommand]
+        private void UploadApplyAttachment()
+        {
+            OpenFileDialog openFileDialog = new OpenFileDialog
             {
                 Filter = "PDF files (*.pdf)|*.pdf",
-                Title = "请选择保存文件位置",
-                FileName = SelectedMaterialCompany?.Name + "-" + ContractNo + "-" + WordUtil.GenerateFileSerialNumber()
+                Title = "请选择一个pdf文件"
             };
-            if (saveFileDialog.ShowDialog() == true)
+            if (openFileDialog.ShowDialog() == true)
             {
-                var fileName = saveFileDialog.FileName;
-                InspectApplyUtil.ConvertByteArrayToPdf(Attachment, fileName);
-                MessageBox.Show("下载完成!");
+                string selectedFile = openFileDialog.FileName;
+                ApplyAttachment = InspectApplyUtil.ConvertPdfToByteArray(selectedFile);
+
+                ApplyIsUpload = true;
             }
         }
 
         /// <summary>
-        /// 移除附件
+        /// 移除变更申请附件
         /// </summary>
         [RelayCommand]
-        private void RemoveAttachment()
+        private void RemoveApplyAttachment()
         {
-            Attachment = null;
+            ApplyAttachment = null;
 
-            IsUpload = false;
+            ApplyIsUpload = false;
+        }
+
+        /// <summary>
+        /// 下载变更附件
+        /// </summary>
+        [RelayCommand]
+        private void DownLoadApplyAttachment()
+        {
+            if (ApplyAttachment == null || ApplyAttachment.Length == 0) return;
+            string fileName = SelectedMaterialCompany?.Name + "-" + ContractNo + "-合同变更申请-" +
+                              WordUtil.GenerateFileSerialNumber();
+
+            ExportAttachment(ApplyAttachment, fileName);
         }
 
         /// <summary>
@@ -519,6 +667,8 @@ namespace UniformMaterialManagementSystem.ViewModels
             {
                 InspectedQty = 0,
                 InspectStatus = "未报检",
+                ShippedQuantity = 0,
+                ShippedStatus = false,
                 DeliveryTime = DateTime.Now
             };
             ContractDetails.Add(detail);
@@ -568,23 +718,28 @@ namespace UniformMaterialManagementSystem.ViewModels
         /// </summary>
         private bool? SaveContractAndDetail()
         {
-            Contract contract = new Contract();
-            contract.ContractNo = ContractNo == null ? "" : ContractNo;
-            contract.CompanyGuid = SelectedMaterialCompany.Guid;
-            contract.PurchaseCompanyGuid = SelectedProductCompany.Guid;
-            contract.SigningDate = SigningDate.GetValueOrDefault().Date;
-            contract.Attachment = Attachment;
-            contract.EditUser = EditUser;
-            contract.EditDate = EditDate.GetValueOrDefault();
-            contract.Telephone = Telephone;
-
-            contract.ContractDetails = new ObservableCollection<ContractDetail>();
+            Contract contract = new Contract
+            {
+                Year = App.CurrentUser!.WorkYear,
+                ContractNo = ContractNo == null ? "" : ContractNo,
+                CompanyGuid = SelectedMaterialCompany.Guid,
+                PurchaseCompanyGuid = SelectedProductCompany.Guid,
+                SigningDate = SigningDate.GetValueOrDefault().Date,
+                Attachment = Attachment,
+                ApplyAttachment = ApplyAttachment,
+                EditUser = EditUser,
+                EditDate = DateTime.Now,
+                Telephone = Telephone,
+
+                ContractDetails = new ObservableCollection<ContractDetail>()
+            };
             foreach (var detail in ContractDetails)
             {
                 ContractDetail contractDetail = new ContractDetail();
                 contractDetail.ContractGuid = contract.Guid;
                 contractDetail.MaterialGuid = detail.Material.Guid;
                 contractDetail.ContractQty = detail.ContractQty;
+                contractDetail.ReduceQuantity = detail.ReduceQuantity;
                 contractDetail.DeliveryTime = detail.DeliveryTime;
                 contractDetail.InspectedQty = detail.InspectedQty;
                 contractDetail.InspectStatus = detail.InspectStatus;
@@ -594,8 +749,8 @@ namespace UniformMaterialManagementSystem.ViewModels
                 contract.ContractDetails.Add(contractDetail);
             }
 
-            _contractService?.Insert(contract);
-            return _contractService?.SaveChanges();
+            _contractService.Insert(contract);
+            return _contractService.SaveChanges();
         }
 
         /// <summary>
@@ -619,7 +774,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             /* 校验材料合同号不重复 */
             if ("Add".Equals(_contactStatus))
             {
-                var contract = _contractService?.Get(x => x.ContractNo == ContractNo);
+                var contract = _contractService.Get(x => x.ContractNo == ContractNo);
                 if (contract != null)
                 {
                     errorMessage.Append($"材料合同号【{ContractNo}】已存在,不允许重复录入!\n");
@@ -627,7 +782,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             }
             else if ("Modify".Equals(_contactStatus))
             {
-                var count = _contractService?.GetAll(x => x.ContractNo == ContractNo).ToList().Count;
+                var count = _contractService.GetAll(x => x.ContractNo == ContractNo).ToList().Count;
                 if (count > 1)
                 {
                     errorMessage.Append($"材料合同号【{ContractNo}】已存在,不允许重复录入!\n");
@@ -670,7 +825,6 @@ namespace UniformMaterialManagementSystem.ViewModels
             ContractNo = string.Empty;
             SigningDate = DateTime.Now;
             EditUser = App.CurrentUser!.UserName;
-            EditDate = DateTime.Now;
             Telephone = string.Empty;
             Attachment = null;
             IsUpload = false;
@@ -681,15 +835,15 @@ namespace UniformMaterialManagementSystem.ViewModels
         #region 合同查询相关方法
 
         /// <summary>
-        /// 加载已导出合同数据
+        /// 加载所有合同数据
         /// </summary>
         [RelayCommand]
-        private void LoadExportedData()
+        private void LoadData()
         {
             List<Contract>? contractList;
             if (CommonUtil.GetRoleType() == RoleType.Admin || CommonUtil.GetRoleType() == RoleType.Supervision)
             {
-                contractList = _contractService?.Query(x => x.ExportStatus)
+                contractList = _contractService.Query(x => x.Year == App.CurrentUser!.WorkYear)
                     .Include(x => x.Company)
                     .Include(x => x.PurchaseCompany)
                     .Include(x => x.ContractDetails)
@@ -697,7 +851,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             }
             else
             {
-                contractList = _contractService?.Query(x => x.ExportStatus && (x.CompanyGuid == App.CurrentUser.CompanyGuid || x.PurchaseCompanyGuid == App.CurrentUser.CompanyGuid))
+                contractList = _contractService.Query(x => x.Year == App.CurrentUser!.WorkYear && (x.CompanyGuid == App.CurrentUser.CompanyGuid || x.PurchaseCompanyGuid == App.CurrentUser.CompanyGuid))
                     .Include(x => x.Company)
                     .Include(x => x.PurchaseCompany)
                     .Include(x => x.ContractDetails)
@@ -705,7 +859,6 @@ namespace UniformMaterialManagementSystem.ViewModels
             }
 
             Contracts.Clear();
-            if (contractList == null) return;
             foreach (var contract in contractList)
             {
                 Contracts.Add(contract);
@@ -721,6 +874,33 @@ namespace UniformMaterialManagementSystem.ViewModels
             SelectedContract = contract;
         }
 
+        /// <summary>
+        /// 申请变更
+        /// </summary>
+        [RelayCommand]
+        private void ApplyChanges()
+        {
+            if (SelectedContract == null) return;
+            if (!SelectedContract.ExportStatus)
+            {
+                MessageBox.Show($"材料合同号:{SelectedContract.ContractNo}未导出,可在合同录入界面修改!");
+                return;
+            }
+
+            var result = MessageBox.Show($"您正在申请变更材料合同号为{SelectedContract.ContractNo}的合同(确认变更后,可在合同录入界面调减合同成交数量并上传变更说明),确认继续?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
+            if (result != MessageBoxResult.OK) return;
+
+            //更改变更状态,重置导出状态为未导出
+            var contract = _contractService?.Get(x => x.Guid == SelectedContract.Guid);
+            if (contract == null) return;
+            contract.ChangedStatus = true;
+            contract.ExportStatus = false;
+            _contractService?.SaveChanges();
+
+            //重新加载数据
+            LoadData();
+        }
+
         /// <summary>
         /// 删除已导出状态合同
         /// </summary>
@@ -734,8 +914,8 @@ namespace UniformMaterialManagementSystem.ViewModels
             }
 
             /* 删除校验:检验申请单已使用的合同不允许删除 */
-            var applyContractDetails = _inspectApplyContractDetailService?.Query(x => x.ContractNo == SelectedContract.ContractNo).ToList();
-            if (applyContractDetails != null && applyContractDetails.Count > 0)
+            var applyContractDetails = _inspectApplyContractDetailService.Query(x => x.ContractNo == SelectedContract.ContractNo).ToList();
+            if (applyContractDetails.Count > 0)
             {
                 StringBuilder sb = new StringBuilder();
                 foreach (var contract in applyContractDetails)
@@ -743,7 +923,7 @@ namespace UniformMaterialManagementSystem.ViewModels
                     sb.Append(contract.ApplyNo).Append(";");
                 }
 
-                MessageBox.Show($"材料合同号【{SelectedContract.ContractNo}】已被检验申请表引用,不允许删除!检验申请表编号:{sb.ToString()}", "错误提示", MessageBoxButton.OK, MessageBoxImage.Error);
+                MessageBox.Show($"材料合同号【{SelectedContract.ContractNo}】已被检验申请表引用,不允许删除!检验申请表编号:{sb}", "错误提示", MessageBoxButton.OK, MessageBoxImage.Error);
                 return;
             }
             /* 确认删除提示 */
@@ -751,11 +931,11 @@ namespace UniformMaterialManagementSystem.ViewModels
             if (result != MessageBoxResult.OK) return;
 
             //删除
-            _contractService?.Delete(SelectedContract);
-            _contractService?.SaveChanges();
+            _contractService.Delete(SelectedContract);
+            _contractService.SaveChanges();
 
             //重新加载数据
-            LoadExportedData();
+            LoadData();
         }
 
         /// <summary>
@@ -771,12 +951,43 @@ namespace UniformMaterialManagementSystem.ViewModels
             }
 
             var attachment = SelectedContract.Attachment;
+            if (attachment == null) return;
+            string fileName = SelectedContract.Company.Name + "-" + SelectedContract.ContractNo + "-" +
+                              WordUtil.GenerateFileSerialNumber();
+            ExportAttachment(attachment, fileName);
+        }
+
+        /// <summary>
+        /// 下载选中合同的变更申请
+        /// </summary>
+        [RelayCommand]
+        private void DownLoadSelectedApplyAttachment()
+        {
+            if (SelectedContract == null)
+            {
+                MessageBox.Show("请选中一行数据,再执行下载附件!");
+                return;
+            }
+
+            var attachment = SelectedContract.ApplyAttachment;
+            string fileName = SelectedContract.Company.Name + "-" + SelectedContract.ContractNo + "-合同变更申请-" + WordUtil.GenerateFileSerialNumber();
+            ExportAttachment(attachment, fileName);
+        }
+
+
+
+        #endregion
+
+        #region 公用私有方法
+
+        private void ExportAttachment(byte[]? attachment, string name)
+        {
             if (attachment == null) return;
             SaveFileDialog saveFileDialog = new SaveFileDialog()
             {
                 Filter = "PDF files (*.pdf)|*.pdf",
                 Title = "请选择保存文件位置",
-                FileName = SelectedContract.Company.Name + "-" + SelectedContract.ContractNo + "-" + WordUtil.GenerateFileSerialNumber()
+                FileName = name
             };
             if (saveFileDialog.ShowDialog() == true)
             {
@@ -786,7 +997,6 @@ namespace UniformMaterialManagementSystem.ViewModels
             }
         }
 
-
         #endregion
     }
 }

+ 5 - 5
UniformMaterialManagementSystem/ViewModels/InspectApplyPageViewModel.cs

@@ -107,11 +107,11 @@ namespace UniformMaterialManagementSystem.ViewModels
         private ObservableCollection<InspectApplyDetail> _inspectApplyDetails = [];
 
         [ObservableProperty]
-        private ObservableCollection<ContractDetailModel> _contractDetails = [];
+        private ObservableCollection<SelectContractDetailModel> _contractDetails = [];
 
         private InspectApplyDetail? _selectedDetail;
 
-        private ContractDetailModel? _selecteContractDetail;
+        private SelectContractDetailModel? _selecteContractDetail;
 
         private readonly IDataBaseService<SerialNumber> _serialService;
         private readonly IDataBaseService<InspectApply> _inspectService;
@@ -508,7 +508,7 @@ namespace UniformMaterialManagementSystem.ViewModels
 
             foreach (var row in source)
             {
-                ContractDetailModel detail = (ContractDetailModel)row;
+                SelectContractDetailModel detail = (SelectContractDetailModel)row;
                 if (detail.IsSelect)
                 {
                     var model = ContractDetails.FirstOrDefault(d => d.Guid == detail.Guid);
@@ -548,7 +548,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         /// </summary>
         /// <param name="detail"></param>
         [RelayCommand]
-        private void ContractSelectionChanged(ContractDetailModel detail)
+        private void ContractSelectionChanged(SelectContractDetailModel detail)
         {
             _selecteContractDetail = detail;
         }
@@ -683,7 +683,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         /// <summary>
         /// 根据规则分摊报检数量
         /// </summary>
-        private void ShareInspectQty(ObservableCollection<ContractDetailModel> contractDetails, double remainQty)
+        private void ShareInspectQty(ObservableCollection<SelectContractDetailModel> contractDetails, double remainQty)
         {
             //分摊报检数量
             if (contractDetails.Count == 0) return;

+ 3 - 3
UniformMaterialManagementSystem/ViewModels/SelectContractWindowViewModel.cs

@@ -11,10 +11,10 @@ namespace UniformMaterialManagementSystem.ViewModels
 {
     public partial class SelectContractWindowViewModel : ObservableObject
     {
-        private readonly List<ContractDetailModel> _selectDetailModels = [];
+        private readonly List<SelectContractDetailModel> _selectDetailModels = [];
 
         [ObservableProperty]
-        private ObservableCollection<ContractDetailModel> _contractDetails = [];
+        private ObservableCollection<SelectContractDetailModel> _contractDetails = [];
 
         public SelectContractWindowViewModel(IDataBaseService<ContractDetail> service)
         {
@@ -31,7 +31,7 @@ namespace UniformMaterialManagementSystem.ViewModels
 
             foreach (var detail in query)
             {
-                ContractDetailModel model = new ContractDetailModel(detail);
+                SelectContractDetailModel model = new SelectContractDetailModel(detail);
                 _contractDetails.Add(model);
             }
         }

File diff suppressed because it is too large
+ 592 - 427
UniformMaterialManagementSystem/Views/ContractPage.xaml


+ 155 - 8
UniformMaterialManagementSystem/Views/ContractPage.xaml.cs

@@ -2,6 +2,8 @@
 using Microsoft.Extensions.DependencyInjection;
 using System.Windows.Controls;
 using System.Windows.Media;
+using UniformMaterialManagementSystem.Models;
+using UniformMaterialManagementSystem.Utils;
 using UniformMaterialManagementSystem.ViewModels;
 
 namespace UniformMaterialManagementSystem.Views
@@ -16,6 +18,30 @@ namespace UniformMaterialManagementSystem.Views
             InitializeComponent();
 
             this.DataContext = App.Current.Services.GetService<ContractPageViewModel>();
+
+            //根据角色类型设置材料企业、成品企业可编辑性
+            SetCompanyEditable();
+        }
+
+        private void SetCompanyEditable()
+        {
+            var type = CommonUtil.GetRoleType();
+            switch (type)
+            {
+                case RoleType.MaterialCompany:
+                    MaterialCompanyComboBox.IsEnabled = false;
+                    ProductCompanyComboBox.IsEnabled = true;
+                    break;
+                case RoleType.ProductCompany:
+                    MaterialCompanyComboBox.IsEnabled = true;
+                    ProductCompanyComboBox.IsEnabled = false;
+                    break;
+                case RoleType.Admin:
+                case RoleType.Supervision:
+                    MaterialCompanyComboBox.IsEnabled = true;
+                    ProductCompanyComboBox.IsEnabled = true;
+                    break;
+            }
         }
 
         private void IsUploadText_TextChanged(object sender, TextChangedEventArgs e)
@@ -57,17 +83,138 @@ namespace UniformMaterialManagementSystem.Views
             DataGridMain.CommitEdit();
         }
 
-        //private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
+        private void DataGridUnExportContractList_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            //用户选择多行时,自动勾选
+            var grid = sender as FilterDataGrid.FilterDataGrid;
+            if (grid == null) return;
+            var selectedItems = grid.SelectedItems;
+
+            var itemsSource = grid.ItemsSource;
+            foreach (var contract in itemsSource)
+            {
+                var contains = selectedItems.Contains(contract);
+                var model = contract as ContractModel;
+                if (model == null) continue;
+                model.IsSelected = contains ? true : false;
+            }
+
+            //根据选中合同的变更状态控制控件的可编辑性
+            var selectedItem = grid.SelectedItem as ContractModel;
+            if (selectedItem == null) return;
+
+            //变更状态,ChangedStatus=true 变更
+            SetControlEditable(selectedItem.ChangedStatus);
+        }
+
+        private void SetControlEditable(bool changedStatus)
+        {
+            //根据角色类型给材料企业或成品企业赋值编辑权限
+            var roleType = CommonUtil.GetRoleType();
+            switch (roleType)
+            {
+                case RoleType.MaterialCompany:
+                    ProductCompanyComboBox.IsEnabled = !changedStatus;
+                    break;
+                case RoleType.ProductCompany:
+                    MaterialCompanyComboBox.IsEnabled = !changedStatus;
+                    break;
+                case RoleType.Admin:
+                case RoleType.Supervision:
+                    ProductCompanyComboBox.IsEnabled = !changedStatus;
+                    MaterialCompanyComboBox.IsEnabled = !changedStatus;
+                    break;
+            }
+
+            ContractNoTextBox.IsEnabled = !changedStatus;
+            SigningDateDatePicker.IsEnabled = !changedStatus;
+            EditUserTextBox.IsEnabled = !changedStatus;
+            TelephoneTextBox.IsEnabled = !changedStatus;
+            UploadAttachmentButton.IsEnabled = !changedStatus;
+            DownLoadAttachmentButton.IsEnabled = true;
+            RemoveAttachmentButton.IsEnabled = !changedStatus;
+            AddDetailButton.IsEnabled = !changedStatus;
+            RemoveDetailButton.IsEnabled = !changedStatus;
+            MaterialNameColumn.IsReadOnly = changedStatus;
+            DeliveryTimeColumn.IsReadOnly = changedStatus;
+            UnitPriceColumn.IsReadOnly = changedStatus;
+
+            ChangedApplyText.Visibility = changedStatus ? Visibility.Visible : Visibility.Collapsed;
+            ChangedApplyStackPanel.Visibility = changedStatus ? Visibility.Visible : Visibility.Collapsed;
+
+            if (changedStatus)
+            {
+                RemoveAttachmentButton.Foreground = new SolidColorBrush(Color.FromRgb(155, 155, 155));
+                AddDetailButton.Foreground = new SolidColorBrush(Color.FromRgb(155, 155, 155));
+                RemoveDetailButton.Foreground = new SolidColorBrush(Color.FromRgb(155, 155, 155));
+            }
+            else
+            {
+                RemoveAttachmentButton.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
+                AddDetailButton.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
+                RemoveDetailButton.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
+            }
+        }
+
+        private void AddContractBtn_Click(object sender, RoutedEventArgs e)
+        {
+            SetControlEditable(false);
+        }
+
+        private void ApplyIsUploadText_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (bool.Parse(ApplyIsUploadText.Text))
+            {
+                UploadApplyAttachmentButton.Visibility = Visibility.Collapsed;
+                RemoveApplyAttachmentButton.Visibility = Visibility.Visible;
+                DownLoadApplyAttachmentButton.IsEnabled = true;
+
+                ApplyUploadedText.Visibility = Visibility.Visible;
+                ApplyAttachmentText.Visibility = Visibility.Visible;
+                ApplyUnUploadText.Visibility = Visibility.Collapsed;
+                ApplyUnAttachmentText.Visibility = Visibility.Collapsed;
+
+                UploadApplyAttachmentButton.Foreground = new SolidColorBrush(Color.FromRgb(155, 155, 155));
+                RemoveApplyAttachmentButton.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
+                DownLoadApplyAttachmentButton.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
+            }
+            else
+            {
+                UploadApplyAttachmentButton.Visibility = Visibility.Visible;
+                RemoveApplyAttachmentButton.Visibility = Visibility.Collapsed;
+                DownLoadApplyAttachmentButton.IsEnabled = false;
+
+                ApplyUploadedText.Visibility = Visibility.Collapsed;
+                ApplyAttachmentText.Visibility = Visibility.Collapsed;
+                ApplyUnUploadText.Visibility = Visibility.Visible;
+                ApplyUnAttachmentText.Visibility = Visibility.Visible;
+
+                UploadApplyAttachmentButton.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
+                RemoveApplyAttachmentButton.Foreground = new SolidColorBrush(Color.FromRgb(155, 155, 155));
+                DownLoadApplyAttachmentButton.Foreground = new SolidColorBrush(Color.FromRgb(155, 155, 155));
+            }
+        }
+
+        //private void DataGridUnExportContractList_CurrentCellChanged(object sender, EventArgs e)
         //{
-        //    if (bool.Parse(IsCompanyTextBox.Text))
-        //    {
-        //        MaterialCompanyComboBox.IsEnabled = false;
-        //    }
-        //    else
+        //    var grid = sender as FilterDataGrid.FilterDataGrid;
+        //    if (grid == null) return;
+        //    var selectedItems = grid.SelectedItems;
+        //    var itemsSource = grid.ItemsSource;
+
+        //    foreach (var item in itemsSource)
         //    {
-        //        MaterialCompanyComboBox.IsEnabled = true;
+        //        var contract = item as ContractModel;
+        //        if (contract == null) continue;
+        //        if (contract.IsSelected && !selectedItems.Contains(contract))
+        //        {
+        //            selectedItems.Add(contract);
+        //        }
+        //        else if(!contract.IsSelected && selectedItems.Contains(contract))
+        //        {
+        //            selectedItems.Remove(contract);
+        //        }
         //    }
-
         //}
     }
 }

Some files were not shown because too many files changed in this diff