третья усложненка вроде работает
This commit is contained in:
parent
7ce7fe4c2d
commit
db93b2f4a9
@ -15,7 +15,7 @@ namespace ComputersShopDatabaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-1DE5E8N\SQLEXPRESS;Initial Catalog=ComputersShopDatabaseFull;
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-1DE5E8N\SQLEXPRESS;Initial Catalog=ComputersShopDatabaseHard3;
|
||||
Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
|
@ -2,7 +2,9 @@
|
||||
using ComputersShopContracts.SearchModels;
|
||||
using ComputersShopContracts.StoragesContracts;
|
||||
using ComputersShopContracts.ViewModels;
|
||||
using ComputersShopDatabaseImplement.Models;
|
||||
using ComputersShopDataModels.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -166,3 +168,4 @@ namespace ComputersShopDatabaseImplement.Implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace ComputersShopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ComputersShopDatabase))]
|
||||
[Migration("20240326105531_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
[Migration("20240519063447_HardCreate")]
|
||||
partial class HardCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -124,6 +124,59 @@ namespace ComputersShopDatabaseImplement.Migrations
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputersShopDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("DateOpening")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("MaxComputers")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputersShopDatabaseImplement.Models.ShopComputer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComputerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ShopId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComputerId");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.ToTable("ShopComputers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputersShopDatabaseImplement.Models.ComputerComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputersShopDatabaseImplement.Models.Component", "Component")
|
||||
@ -154,6 +207,25 @@ namespace ComputersShopDatabaseImplement.Migrations
|
||||
b.Navigation("Computer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputersShopDatabaseImplement.Models.ShopComputer", b =>
|
||||
{
|
||||
b.HasOne("ComputersShopDatabaseImplement.Models.Computer", "Computer")
|
||||
.WithMany()
|
||||
.HasForeignKey("ComputerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputersShopDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Computers")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Computer");
|
||||
|
||||
b.Navigation("Shop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputersShopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("ComputerComponents");
|
||||
@ -165,6 +237,11 @@ namespace ComputersShopDatabaseImplement.Migrations
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputersShopDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Computers");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
namespace ComputersShopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
public partial class HardCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
@ -39,6 +39,22 @@ namespace ComputersShopDatabaseImplement.Migrations
|
||||
table.PrimaryKey("PK_Computers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Shops",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ShopName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Address = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateOpening = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
MaxComputers = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Shops", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ComputerComponents",
|
||||
columns: table => new
|
||||
@ -90,6 +106,33 @@ namespace ComputersShopDatabaseImplement.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ShopComputers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ShopId = table.Column<int>(type: "int", nullable: false),
|
||||
ComputerId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ShopComputers", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ShopComputers_Computers_ComputerId",
|
||||
column: x => x.ComputerId,
|
||||
principalTable: "Computers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ShopComputers_Shops_ShopId",
|
||||
column: x => x.ShopId,
|
||||
principalTable: "Shops",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ComputerComponents_ComponentId",
|
||||
table: "ComputerComponents",
|
||||
@ -104,6 +147,16 @@ namespace ComputersShopDatabaseImplement.Migrations
|
||||
name: "IX_Orders_ComputerId",
|
||||
table: "Orders",
|
||||
column: "ComputerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopComputers_ComputerId",
|
||||
table: "ShopComputers",
|
||||
column: "ComputerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopComputers_ShopId",
|
||||
table: "ShopComputers",
|
||||
column: "ShopId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -115,11 +168,17 @@ namespace ComputersShopDatabaseImplement.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ShopComputers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Computers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Shops");
|
||||
}
|
||||
}
|
||||
}
|
@ -121,6 +121,59 @@ namespace ComputersShopDatabaseImplement.Migrations
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputersShopDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("DateOpening")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("MaxComputers")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputersShopDatabaseImplement.Models.ShopComputer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComputerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ShopId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComputerId");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.ToTable("ShopComputers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputersShopDatabaseImplement.Models.ComputerComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputersShopDatabaseImplement.Models.Component", "Component")
|
||||
@ -151,6 +204,25 @@ namespace ComputersShopDatabaseImplement.Migrations
|
||||
b.Navigation("Computer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputersShopDatabaseImplement.Models.ShopComputer", b =>
|
||||
{
|
||||
b.HasOne("ComputersShopDatabaseImplement.Models.Computer", "Computer")
|
||||
.WithMany()
|
||||
.HasForeignKey("ComputerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputersShopDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Computers")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Computer");
|
||||
|
||||
b.Navigation("Shop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputersShopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("ComputerComponents");
|
||||
@ -162,6 +234,11 @@ namespace ComputersShopDatabaseImplement.Migrations
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputersShopDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Computers");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
@ -12,34 +12,34 @@ namespace ComputersShopDatabaseImplement.Models
|
||||
{
|
||||
public class Order
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int ComputerId { get; private set; }
|
||||
public int ComputerId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; private set; }
|
||||
public int Count { get; set; }
|
||||
[Required]
|
||||
public double Sum { get; private set; }
|
||||
public double Sum { get; set; }
|
||||
[Required]
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
public OrderStatus Status { get; set; }
|
||||
[Required]
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
public virtual Computer Computer { get; private set; }
|
||||
public DateTime DateCreate { get; set; }
|
||||
public DateTime? DateImplement { get; set; }
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Order
|
||||
{
|
||||
Id = model.Id,
|
||||
ComputerId = model.ComputerId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
Id = model.Id,
|
||||
DateImplement = model.DateImplement
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel? model)
|
||||
@ -48,19 +48,19 @@ namespace ComputersShopDatabaseImplement.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ComputerId = ComputerId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
Id = Id,
|
||||
Status = Status,
|
||||
ComputerName = Computer.ComputerName
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -102,3 +102,4 @@ namespace ComputersShopDatabaseImplement.Models
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,4 +21,3 @@ namespace ComputersShopDatabaseImplement.Models
|
||||
public virtual Computer Computer { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,7 @@ namespace ComputersShopFileImplement.Implements
|
||||
return null;
|
||||
}
|
||||
|
||||
return GetViewModel(_source.Orders
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)));
|
||||
return GetViewModel(_source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)));
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
|
14
ComputersShop/ComputersShopView/FormMain.Designer.cs
generated
14
ComputersShop/ComputersShopView/FormMain.Designer.cs
generated
@ -71,35 +71,35 @@
|
||||
// компонентыToolStripMenuItem
|
||||
//
|
||||
this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(218, 26);
|
||||
this.компонентыToolStripMenuItem.Text = "Компоненты";
|
||||
this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
|
||||
//
|
||||
// изделияToolStripMenuItem
|
||||
//
|
||||
this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
|
||||
this.изделияToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.изделияToolStripMenuItem.Size = new System.Drawing.Size(218, 26);
|
||||
this.изделияToolStripMenuItem.Text = "Изделия";
|
||||
this.изделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click);
|
||||
//
|
||||
// магазиныToolStripMenuItem
|
||||
//
|
||||
this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(218, 26);
|
||||
this.магазиныToolStripMenuItem.Text = "Магазины";
|
||||
this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.МагазиныToolStripMenuItem_Click);
|
||||
//
|
||||
// поставкиToolStripMenuItem
|
||||
//
|
||||
this.поставкиToolStripMenuItem.Name = "поставкиToolStripMenuItem";
|
||||
this.поставкиToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.поставкиToolStripMenuItem.Size = new System.Drawing.Size(218, 26);
|
||||
this.поставкиToolStripMenuItem.Text = "Поставки";
|
||||
this.поставкиToolStripMenuItem.Click += new System.EventHandler(this.ПоставкиToolStripMenuItem_Click);
|
||||
//
|
||||
// продажаИзделийToolStripMenuItem
|
||||
//
|
||||
this.продажаИзделийToolStripMenuItem.Name = "продажаИзделийToolStripMenuItem";
|
||||
this.продажаИзделийToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.продажаИзделийToolStripMenuItem.Size = new System.Drawing.Size(218, 26);
|
||||
this.продажаИзделийToolStripMenuItem.Text = "Продажа изделий";
|
||||
this.продажаИзделийToolStripMenuItem.Click += new System.EventHandler(this.ПродажаизделийToolStripMenuItem_Click);
|
||||
//
|
||||
@ -144,7 +144,7 @@
|
||||
this.buttonOrderReady.TabIndex = 4;
|
||||
this.buttonOrderReady.Text = "Заказ готов";
|
||||
this.buttonOrderReady.UseVisualStyleBackColor = true;
|
||||
this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
|
||||
this.buttonOrderReady.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
@ -154,7 +154,7 @@
|
||||
this.buttonIssuedOrder.TabIndex = 5;
|
||||
this.buttonIssuedOrder.Text = "Заказ выдан";
|
||||
this.buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
|
||||
this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonOrderReady_Click);
|
||||
//
|
||||
// buttonRef
|
||||
//
|
||||
|
@ -1,7 +1,7 @@
|
||||
using ComputersShopBusinessLogic.BusinessLogics;
|
||||
using ComputersShopContracts.BusinessLogicsContracts;
|
||||
using ComputersShopContracts.StoragesContracts;
|
||||
using ComputersShopFileImplement.Implements;
|
||||
using ComputersShopDatabaseImplement.Implements;
|
||||
using ComputersShopView;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
Loading…
Reference in New Issue
Block a user