diff --git a/TypographyContracts/ViewModels/OrderViewModel.cs b/TypographyContracts/ViewModels/OrderViewModel.cs index ee2e88b..7649073 100644 --- a/TypographyContracts/ViewModels/OrderViewModel.cs +++ b/TypographyContracts/ViewModels/OrderViewModel.cs @@ -21,7 +21,7 @@ namespace TypographyContracts.ViewModels [DisplayName("ФИО Клиента")] public string ClientFIO { get; set; } = string.Empty; public int? ImplementerId { get; set; } - [DisplayName("Implementer's FIO")] + [DisplayName("ФИО работника")] public string ImplementerFIO { get; set; } = string.Empty; [DisplayName("Количество")] public int Count { get; set; } diff --git a/TypographyRestApi/Program.cs b/TypographyRestApi/Program.cs index 082b08a..2570b9a 100644 --- a/TypographyRestApi/Program.cs +++ b/TypographyRestApi/Program.cs @@ -2,7 +2,6 @@ using Microsoft.OpenApi.Models; using TypographyBusinessLogic.BusinessLogics; using TypographyContracts.BusinessLogicsContracts; using TypographyContracts.StoragesContracts; -using TypographyDatabaseImplement.Implements; using TypographyDatabaseImplements.Implements; var builder = WebApplication.CreateBuilder(args); diff --git a/TypographyShopDatabaseImplements/Implements/ComponentStorage.cs b/TypographyShopDatabaseImplements/Implements/ComponentStorage.cs index ec3f592..03e8895 100644 --- a/TypographyShopDatabaseImplements/Implements/ComponentStorage.cs +++ b/TypographyShopDatabaseImplements/Implements/ComponentStorage.cs @@ -3,9 +3,8 @@ using TypographyContracts.SearchModels; using TypographyContracts.StoragesContracts; using TypographyContracts.ViewModels; using TypographyDatabaseImplement.Models; -using TypographyDatabaseImplements; -namespace TypographyDatabaseImplement.Implements +namespace TypographyDatabaseImplements.Implements { public class ComponentStorage : IComponentStorage { diff --git a/TypographyShopDatabaseImplements/Implements/OrderStorage.cs b/TypographyShopDatabaseImplements/Implements/OrderStorage.cs index 2ef60e4..3b0dccd 100644 --- a/TypographyShopDatabaseImplements/Implements/OrderStorage.cs +++ b/TypographyShopDatabaseImplements/Implements/OrderStorage.cs @@ -4,9 +4,8 @@ using TypographyContracts.StoragesContracts; using TypographyContracts.ViewModels; using TypographyDatabaseImplement.Models; using Microsoft.EntityFrameworkCore; -using TypographyDatabaseImplements; -namespace TypographyDatabaseImplement.Implements +namespace TypographyDatabaseImplements.Implements { public class OrderStorage : IOrderStorage { diff --git a/TypographyShopDatabaseImplements/Implements/PrintedStorage.cs b/TypographyShopDatabaseImplements/Implements/PrintedStorage.cs index 64cc8f8..a18307b 100644 --- a/TypographyShopDatabaseImplements/Implements/PrintedStorage.cs +++ b/TypographyShopDatabaseImplements/Implements/PrintedStorage.cs @@ -4,10 +4,9 @@ using TypographyContracts.StoragesContracts; using TypographyContracts.ViewModels; using TypographyDatabaseImplement.Models; using Microsoft.EntityFrameworkCore; -using TypographyDatabaseImplements; using TypographyDatabaseImplements.Models; -namespace TypographyDatabaseImplement.Implements +namespace TypographyDatabaseImplements.Implements { public class PrintedStorage : IPrintedStorage { diff --git a/TypographyShopDatabaseImplements/Migrations/20240407171630_InitialCreate.Designer.cs b/TypographyShopDatabaseImplements/Migrations/20240422043507_InitialCreate.Designer.cs similarity index 82% rename from TypographyShopDatabaseImplements/Migrations/20240407171630_InitialCreate.Designer.cs rename to TypographyShopDatabaseImplements/Migrations/20240422043507_InitialCreate.Designer.cs index 7d762d4..95bac54 100644 --- a/TypographyShopDatabaseImplements/Migrations/20240407171630_InitialCreate.Designer.cs +++ b/TypographyShopDatabaseImplements/Migrations/20240422043507_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using TypographyDatabaseImplements; namespace TypographyDatabaseImplements.Migrations { [DbContext(typeof(TypographyDatabase))] - [Migration("20240407171630_InitialCreate")] + [Migration("20240422043507_InitialCreate")] partial class InitialCreate { /// @@ -65,6 +65,9 @@ namespace TypographyDatabaseImplements.Migrations b.Property("DateImplement") .HasColumnType("datetime2"); + b.Property("ImplementerId") + .HasColumnType("int"); + b.Property("PrintedId") .HasColumnType("int"); @@ -78,6 +81,8 @@ namespace TypographyDatabaseImplements.Migrations b.HasIndex("ClientId"); + b.HasIndex("ImplementerId"); + b.HasIndex("PrintedId"); b.ToTable("Orders"); @@ -108,6 +113,33 @@ namespace TypographyDatabaseImplements.Migrations b.ToTable("Clients"); }); + modelBuilder.Entity("TypographyDatabaseImplements.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + modelBuilder.Entity("TypographyDatabaseImplements.Models.Printed", b => { b.Property("Id") @@ -162,6 +194,10 @@ namespace TypographyDatabaseImplements.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("TypographyDatabaseImplements.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + b.HasOne("TypographyDatabaseImplements.Models.Printed", "Printed") .WithMany("Orders") .HasForeignKey("PrintedId") @@ -170,6 +206,8 @@ namespace TypographyDatabaseImplements.Migrations b.Navigation("Client"); + b.Navigation("Implementer"); + b.Navigation("Printed"); }); @@ -202,6 +240,11 @@ namespace TypographyDatabaseImplements.Migrations b.Navigation("Orders"); }); + modelBuilder.Entity("TypographyDatabaseImplements.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("TypographyDatabaseImplements.Models.Printed", b => { b.Navigation("Components"); diff --git a/TypographyShopDatabaseImplements/Migrations/20240407171630_InitialCreate.cs b/TypographyShopDatabaseImplements/Migrations/20240422043507_InitialCreate.cs similarity index 82% rename from TypographyShopDatabaseImplements/Migrations/20240407171630_InitialCreate.cs rename to TypographyShopDatabaseImplements/Migrations/20240422043507_InitialCreate.cs index 6f4faf8..e176365 100644 --- a/TypographyShopDatabaseImplements/Migrations/20240407171630_InitialCreate.cs +++ b/TypographyShopDatabaseImplements/Migrations/20240422043507_InitialCreate.cs @@ -40,6 +40,22 @@ namespace TypographyDatabaseImplements.Migrations table.PrimaryKey("PK_Components", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Implementers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false), + WorkExperience = table.Column(type: "int", nullable: false), + Qualification = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Implementers", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Printeds", columns: table => new @@ -62,6 +78,7 @@ namespace TypographyDatabaseImplements.Migrations .Annotation("SqlServer:Identity", "1, 1"), PrintedId = table.Column(type: "int", nullable: false), ClientId = table.Column(type: "int", nullable: false), + ImplementerId = table.Column(type: "int", nullable: true), Count = table.Column(type: "int", nullable: false), Sum = table.Column(type: "float", nullable: false), Status = table.Column(type: "int", nullable: false), @@ -77,6 +94,11 @@ namespace TypographyDatabaseImplements.Migrations principalTable: "Clients", principalColumn: "Id", onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + column: x => x.ImplementerId, + principalTable: "Implementers", + principalColumn: "Id"); table.ForeignKey( name: "FK_Orders_Printeds_PrintedId", column: x => x.PrintedId, @@ -117,6 +139,11 @@ namespace TypographyDatabaseImplements.Migrations table: "Orders", column: "ClientId"); + migrationBuilder.CreateIndex( + name: "IX_Orders_ImplementerId", + table: "Orders", + column: "ImplementerId"); + migrationBuilder.CreateIndex( name: "IX_Orders_PrintedId", table: "Orders", @@ -145,6 +172,9 @@ namespace TypographyDatabaseImplements.Migrations migrationBuilder.DropTable( name: "Clients"); + migrationBuilder.DropTable( + name: "Implementers"); + migrationBuilder.DropTable( name: "Components"); diff --git a/TypographyShopDatabaseImplements/Migrations/TypographyDatabaseModelSnapshot.cs b/TypographyShopDatabaseImplements/Migrations/TypographyDatabaseModelSnapshot.cs index 987d0c1..bd6bd95 100644 --- a/TypographyShopDatabaseImplements/Migrations/TypographyDatabaseModelSnapshot.cs +++ b/TypographyShopDatabaseImplements/Migrations/TypographyDatabaseModelSnapshot.cs @@ -62,6 +62,9 @@ namespace TypographyDatabaseImplements.Migrations b.Property("DateImplement") .HasColumnType("datetime2"); + b.Property("ImplementerId") + .HasColumnType("int"); + b.Property("PrintedId") .HasColumnType("int"); @@ -75,6 +78,8 @@ namespace TypographyDatabaseImplements.Migrations b.HasIndex("ClientId"); + b.HasIndex("ImplementerId"); + b.HasIndex("PrintedId"); b.ToTable("Orders"); @@ -105,6 +110,33 @@ namespace TypographyDatabaseImplements.Migrations b.ToTable("Clients"); }); + modelBuilder.Entity("TypographyDatabaseImplements.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + modelBuilder.Entity("TypographyDatabaseImplements.Models.Printed", b => { b.Property("Id") @@ -159,6 +191,10 @@ namespace TypographyDatabaseImplements.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("TypographyDatabaseImplements.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + b.HasOne("TypographyDatabaseImplements.Models.Printed", "Printed") .WithMany("Orders") .HasForeignKey("PrintedId") @@ -167,6 +203,8 @@ namespace TypographyDatabaseImplements.Migrations b.Navigation("Client"); + b.Navigation("Implementer"); + b.Navigation("Printed"); }); @@ -199,6 +237,11 @@ namespace TypographyDatabaseImplements.Migrations b.Navigation("Orders"); }); + modelBuilder.Entity("TypographyDatabaseImplements.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("TypographyDatabaseImplements.Models.Printed", b => { b.Navigation("Components"); diff --git a/TypographyShopDatabaseImplements/Models/Order.cs b/TypographyShopDatabaseImplements/Models/Order.cs index b631eee..2af41f0 100644 --- a/TypographyShopDatabaseImplements/Models/Order.cs +++ b/TypographyShopDatabaseImplements/Models/Order.cs @@ -32,8 +32,8 @@ namespace TypographyDatabaseImplement.Models public DateTime? DateImplement { get; set; } - public virtual Printed Printed { get; set; } - public virtual Client Client { get; set; } + public virtual Printed? Printed { get; set; } + public virtual Client? Client { get; set; } public Implementer? Implementer { get; private set; } public static Order? Create(OrderBindingModel? model) @@ -78,8 +78,8 @@ namespace TypographyDatabaseImplement.Models Status = Status, DateCreate = DateCreate, DateImplement = DateImplement, - PrintedName = Printed.PrintedName ?? string.Empty, - ClientFIO = Client.ClientFIO ?? string.Empty, + PrintedName = Printed?.PrintedName ?? string.Empty, + ClientFIO = Client?.ClientFIO ?? string.Empty, ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty, }; } diff --git a/TypographyShopDatabaseImplements/TypographyDatabase.cs b/TypographyShopDatabaseImplements/TypographyDatabase.cs index 08ff139..7d30b2d 100644 --- a/TypographyShopDatabaseImplements/TypographyDatabase.cs +++ b/TypographyShopDatabaseImplements/TypographyDatabase.cs @@ -16,7 +16,7 @@ namespace TypographyDatabaseImplements if (optionsBuilder.IsConfigured == false) { optionsBuilder.UseSqlServer(@"Data Source = .\SQLEXPRESS; - Initial Catalog=TypographyDatabaseFullBase; + Initial Catalog=TypographyDatabaseFullBaseNew; Integrated Security=True;MultipleActiveResultSets=True;; TrustServerCertificate=True"); } diff --git a/TypographyShopDatabaseImplements/TypographyDatabaseImplements.csproj b/TypographyShopDatabaseImplements/TypographyDatabaseImplements.csproj index 480346e..30ea109 100644 --- a/TypographyShopDatabaseImplements/TypographyDatabaseImplements.csproj +++ b/TypographyShopDatabaseImplements/TypographyDatabaseImplements.csproj @@ -20,8 +20,4 @@ - - - - diff --git a/TypographyView/FormImplementer.Designer.cs b/TypographyView/FormImplementer.Designer.cs index 86f160a..ed9377c 100644 --- a/TypographyView/FormImplementer.Designer.cs +++ b/TypographyView/FormImplementer.Designer.cs @@ -162,9 +162,7 @@ private Button buttonCancel; private Button buttonSave; - private TextBox textBoxCost; private TextBox textBoxFIO; - private Label labelCost; private Label labelFIO; private TextBox textBoxPassword; private NumericUpDown numericUpDownQualification; diff --git a/TypographyView/Program.cs b/TypographyView/Program.cs index be5f358..702692b 100644 --- a/TypographyView/Program.cs +++ b/TypographyView/Program.cs @@ -1,14 +1,13 @@ using TypographyBusinessLogic.BusinessLogics; using TypographyContracts.BusinessLogicsContracts; using TypographyContracts.StoragesContracts; -using TypographyDatabaseImplement.Implements; +using TypographyDatabaseImplements.Implements; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; using TypographyBusinessLogic.OfficePackage.Implements; using TypographyBusinessLogic.OfficePackage; using AbstractShopView; -using TypographyDatabaseImplements.Implements; namespace TypographyView @@ -41,7 +40,7 @@ namespace TypographyView services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient();