была ошибка с бд, все пофиксил, можно сдавать

This commit is contained in:
Алексей Крюков 2024-04-22 08:50:09 +04:00
parent abe16f404d
commit f9ea8d3810
13 changed files with 128 additions and 23 deletions

View File

@ -21,7 +21,7 @@ namespace TypographyContracts.ViewModels
[DisplayName("ФИО Клиента")] [DisplayName("ФИО Клиента")]
public string ClientFIO { get; set; } = string.Empty; public string ClientFIO { get; set; } = string.Empty;
public int? ImplementerId { get; set; } public int? ImplementerId { get; set; }
[DisplayName("Implementer's FIO")] [DisplayName("ФИО работника")]
public string ImplementerFIO { get; set; } = string.Empty; public string ImplementerFIO { get; set; } = string.Empty;
[DisplayName("Количество")] [DisplayName("Количество")]
public int Count { get; set; } public int Count { get; set; }

View File

@ -2,7 +2,6 @@ using Microsoft.OpenApi.Models;
using TypographyBusinessLogic.BusinessLogics; using TypographyBusinessLogic.BusinessLogics;
using TypographyContracts.BusinessLogicsContracts; using TypographyContracts.BusinessLogicsContracts;
using TypographyContracts.StoragesContracts; using TypographyContracts.StoragesContracts;
using TypographyDatabaseImplement.Implements;
using TypographyDatabaseImplements.Implements; using TypographyDatabaseImplements.Implements;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);

View File

@ -3,9 +3,8 @@ using TypographyContracts.SearchModels;
using TypographyContracts.StoragesContracts; using TypographyContracts.StoragesContracts;
using TypographyContracts.ViewModels; using TypographyContracts.ViewModels;
using TypographyDatabaseImplement.Models; using TypographyDatabaseImplement.Models;
using TypographyDatabaseImplements;
namespace TypographyDatabaseImplement.Implements namespace TypographyDatabaseImplements.Implements
{ {
public class ComponentStorage : IComponentStorage public class ComponentStorage : IComponentStorage
{ {

View File

@ -4,9 +4,8 @@ using TypographyContracts.StoragesContracts;
using TypographyContracts.ViewModels; using TypographyContracts.ViewModels;
using TypographyDatabaseImplement.Models; using TypographyDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using TypographyDatabaseImplements;
namespace TypographyDatabaseImplement.Implements namespace TypographyDatabaseImplements.Implements
{ {
public class OrderStorage : IOrderStorage public class OrderStorage : IOrderStorage
{ {

View File

@ -4,10 +4,9 @@ using TypographyContracts.StoragesContracts;
using TypographyContracts.ViewModels; using TypographyContracts.ViewModels;
using TypographyDatabaseImplement.Models; using TypographyDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using TypographyDatabaseImplements;
using TypographyDatabaseImplements.Models; using TypographyDatabaseImplements.Models;
namespace TypographyDatabaseImplement.Implements namespace TypographyDatabaseImplements.Implements
{ {
public class PrintedStorage : IPrintedStorage public class PrintedStorage : IPrintedStorage
{ {

View File

@ -12,7 +12,7 @@ using TypographyDatabaseImplements;
namespace TypographyDatabaseImplements.Migrations namespace TypographyDatabaseImplements.Migrations
{ {
[DbContext(typeof(TypographyDatabase))] [DbContext(typeof(TypographyDatabase))]
[Migration("20240407171630_InitialCreate")] [Migration("20240422043507_InitialCreate")]
partial class InitialCreate partial class InitialCreate
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -65,6 +65,9 @@ namespace TypographyDatabaseImplements.Migrations
b.Property<DateTime?>("DateImplement") b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<int?>("ImplementerId")
.HasColumnType("int");
b.Property<int>("PrintedId") b.Property<int>("PrintedId")
.HasColumnType("int"); .HasColumnType("int");
@ -78,6 +81,8 @@ namespace TypographyDatabaseImplements.Migrations
b.HasIndex("ClientId"); b.HasIndex("ClientId");
b.HasIndex("ImplementerId");
b.HasIndex("PrintedId"); b.HasIndex("PrintedId");
b.ToTable("Orders"); b.ToTable("Orders");
@ -108,6 +113,33 @@ namespace TypographyDatabaseImplements.Migrations
b.ToTable("Clients"); b.ToTable("Clients");
}); });
modelBuilder.Entity("TypographyDatabaseImplements.Models.Implementer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ImplementerFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Qualification")
.HasColumnType("int");
b.Property<int>("WorkExperience")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Implementers");
});
modelBuilder.Entity("TypographyDatabaseImplements.Models.Printed", b => modelBuilder.Entity("TypographyDatabaseImplements.Models.Printed", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -162,6 +194,10 @@ namespace TypographyDatabaseImplements.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("TypographyDatabaseImplements.Models.Implementer", "Implementer")
.WithMany("Orders")
.HasForeignKey("ImplementerId");
b.HasOne("TypographyDatabaseImplements.Models.Printed", "Printed") b.HasOne("TypographyDatabaseImplements.Models.Printed", "Printed")
.WithMany("Orders") .WithMany("Orders")
.HasForeignKey("PrintedId") .HasForeignKey("PrintedId")
@ -170,6 +206,8 @@ namespace TypographyDatabaseImplements.Migrations
b.Navigation("Client"); b.Navigation("Client");
b.Navigation("Implementer");
b.Navigation("Printed"); b.Navigation("Printed");
}); });
@ -202,6 +240,11 @@ namespace TypographyDatabaseImplements.Migrations
b.Navigation("Orders"); b.Navigation("Orders");
}); });
modelBuilder.Entity("TypographyDatabaseImplements.Models.Implementer", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("TypographyDatabaseImplements.Models.Printed", b => modelBuilder.Entity("TypographyDatabaseImplements.Models.Printed", b =>
{ {
b.Navigation("Components"); b.Navigation("Components");

View File

@ -40,6 +40,22 @@ namespace TypographyDatabaseImplements.Migrations
table.PrimaryKey("PK_Components", x => x.Id); table.PrimaryKey("PK_Components", x => x.Id);
}); });
migrationBuilder.CreateTable(
name: "Implementers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
WorkExperience = table.Column<int>(type: "int", nullable: false),
Qualification = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Implementers", x => x.Id);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Printeds", name: "Printeds",
columns: table => new columns: table => new
@ -62,6 +78,7 @@ namespace TypographyDatabaseImplements.Migrations
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("SqlServer:Identity", "1, 1"),
PrintedId = table.Column<int>(type: "int", nullable: false), PrintedId = table.Column<int>(type: "int", nullable: false),
ClientId = table.Column<int>(type: "int", nullable: false), ClientId = table.Column<int>(type: "int", nullable: false),
ImplementerId = table.Column<int>(type: "int", nullable: true),
Count = table.Column<int>(type: "int", nullable: false), Count = table.Column<int>(type: "int", nullable: false),
Sum = table.Column<double>(type: "float", nullable: false), Sum = table.Column<double>(type: "float", nullable: false),
Status = table.Column<int>(type: "int", nullable: false), Status = table.Column<int>(type: "int", nullable: false),
@ -77,6 +94,11 @@ namespace TypographyDatabaseImplements.Migrations
principalTable: "Clients", principalTable: "Clients",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Orders_Implementers_ImplementerId",
column: x => x.ImplementerId,
principalTable: "Implementers",
principalColumn: "Id");
table.ForeignKey( table.ForeignKey(
name: "FK_Orders_Printeds_PrintedId", name: "FK_Orders_Printeds_PrintedId",
column: x => x.PrintedId, column: x => x.PrintedId,
@ -117,6 +139,11 @@ namespace TypographyDatabaseImplements.Migrations
table: "Orders", table: "Orders",
column: "ClientId"); column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Orders_ImplementerId",
table: "Orders",
column: "ImplementerId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Orders_PrintedId", name: "IX_Orders_PrintedId",
table: "Orders", table: "Orders",
@ -145,6 +172,9 @@ namespace TypographyDatabaseImplements.Migrations
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Clients"); name: "Clients");
migrationBuilder.DropTable(
name: "Implementers");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Components"); name: "Components");

View File

@ -62,6 +62,9 @@ namespace TypographyDatabaseImplements.Migrations
b.Property<DateTime?>("DateImplement") b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<int?>("ImplementerId")
.HasColumnType("int");
b.Property<int>("PrintedId") b.Property<int>("PrintedId")
.HasColumnType("int"); .HasColumnType("int");
@ -75,6 +78,8 @@ namespace TypographyDatabaseImplements.Migrations
b.HasIndex("ClientId"); b.HasIndex("ClientId");
b.HasIndex("ImplementerId");
b.HasIndex("PrintedId"); b.HasIndex("PrintedId");
b.ToTable("Orders"); b.ToTable("Orders");
@ -105,6 +110,33 @@ namespace TypographyDatabaseImplements.Migrations
b.ToTable("Clients"); b.ToTable("Clients");
}); });
modelBuilder.Entity("TypographyDatabaseImplements.Models.Implementer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ImplementerFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Qualification")
.HasColumnType("int");
b.Property<int>("WorkExperience")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Implementers");
});
modelBuilder.Entity("TypographyDatabaseImplements.Models.Printed", b => modelBuilder.Entity("TypographyDatabaseImplements.Models.Printed", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -159,6 +191,10 @@ namespace TypographyDatabaseImplements.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("TypographyDatabaseImplements.Models.Implementer", "Implementer")
.WithMany("Orders")
.HasForeignKey("ImplementerId");
b.HasOne("TypographyDatabaseImplements.Models.Printed", "Printed") b.HasOne("TypographyDatabaseImplements.Models.Printed", "Printed")
.WithMany("Orders") .WithMany("Orders")
.HasForeignKey("PrintedId") .HasForeignKey("PrintedId")
@ -167,6 +203,8 @@ namespace TypographyDatabaseImplements.Migrations
b.Navigation("Client"); b.Navigation("Client");
b.Navigation("Implementer");
b.Navigation("Printed"); b.Navigation("Printed");
}); });
@ -199,6 +237,11 @@ namespace TypographyDatabaseImplements.Migrations
b.Navigation("Orders"); b.Navigation("Orders");
}); });
modelBuilder.Entity("TypographyDatabaseImplements.Models.Implementer", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("TypographyDatabaseImplements.Models.Printed", b => modelBuilder.Entity("TypographyDatabaseImplements.Models.Printed", b =>
{ {
b.Navigation("Components"); b.Navigation("Components");

View File

@ -32,8 +32,8 @@ namespace TypographyDatabaseImplement.Models
public DateTime? DateImplement { get; set; } public DateTime? DateImplement { get; set; }
public virtual Printed Printed { get; set; } public virtual Printed? Printed { get; set; }
public virtual Client Client { get; set; } public virtual Client? Client { get; set; }
public Implementer? Implementer { get; private set; } public Implementer? Implementer { get; private set; }
public static Order? Create(OrderBindingModel? model) public static Order? Create(OrderBindingModel? model)
@ -78,8 +78,8 @@ namespace TypographyDatabaseImplement.Models
Status = Status, Status = Status,
DateCreate = DateCreate, DateCreate = DateCreate,
DateImplement = DateImplement, DateImplement = DateImplement,
PrintedName = Printed.PrintedName ?? string.Empty, PrintedName = Printed?.PrintedName ?? string.Empty,
ClientFIO = Client.ClientFIO ?? string.Empty, ClientFIO = Client?.ClientFIO ?? string.Empty,
ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty, ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty,
}; };
} }

View File

@ -16,7 +16,7 @@ namespace TypographyDatabaseImplements
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
optionsBuilder.UseSqlServer(@"Data Source = .\SQLEXPRESS; optionsBuilder.UseSqlServer(@"Data Source = .\SQLEXPRESS;
Initial Catalog=TypographyDatabaseFullBase; Initial Catalog=TypographyDatabaseFullBaseNew;
Integrated Security=True;MultipleActiveResultSets=True;; Integrated Security=True;MultipleActiveResultSets=True;;
TrustServerCertificate=True"); TrustServerCertificate=True");
} }

View File

@ -20,8 +20,4 @@
<ProjectReference Include="..\TypographyDataModels\TypographyDataModels.csproj" /> <ProjectReference Include="..\TypographyDataModels\TypographyDataModels.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project> </Project>

View File

@ -162,9 +162,7 @@
private Button buttonCancel; private Button buttonCancel;
private Button buttonSave; private Button buttonSave;
private TextBox textBoxCost;
private TextBox textBoxFIO; private TextBox textBoxFIO;
private Label labelCost;
private Label labelFIO; private Label labelFIO;
private TextBox textBoxPassword; private TextBox textBoxPassword;
private NumericUpDown numericUpDownQualification; private NumericUpDown numericUpDownQualification;

View File

@ -1,14 +1,13 @@
using TypographyBusinessLogic.BusinessLogics; using TypographyBusinessLogic.BusinessLogics;
using TypographyContracts.BusinessLogicsContracts; using TypographyContracts.BusinessLogicsContracts;
using TypographyContracts.StoragesContracts; using TypographyContracts.StoragesContracts;
using TypographyDatabaseImplement.Implements; using TypographyDatabaseImplements.Implements;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging; using NLog.Extensions.Logging;
using TypographyBusinessLogic.OfficePackage.Implements; using TypographyBusinessLogic.OfficePackage.Implements;
using TypographyBusinessLogic.OfficePackage; using TypographyBusinessLogic.OfficePackage;
using AbstractShopView; using AbstractShopView;
using TypographyDatabaseImplements.Implements;
namespace TypographyView namespace TypographyView
@ -41,7 +40,7 @@ namespace TypographyView
services.AddTransient<IComponentStorage, ComponentStorage>(); services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>(); services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IPrintedStorage, PrintedStorage>(); services.AddTransient<IPrintedStorage, PrintedStorage>();
services.AddTransient<IClientStorage, TypographyDatabaseImplements.Implements.ClientStorage>(); services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IImplementerStorage, ImplementerStorage>(); services.AddTransient<IImplementerStorage, ImplementerStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>(); services.AddTransient<IComponentLogic, ComponentLogic>();