diff --git a/AbstractShopContracts/SearchModels/SupplySearchModel.cs b/AbstractShopContracts/SearchModels/SupplySearchModel.cs index 67d40b6..e7e6863 100644 --- a/AbstractShopContracts/SearchModels/SupplySearchModel.cs +++ b/AbstractShopContracts/SearchModels/SupplySearchModel.cs @@ -8,6 +8,7 @@ namespace DinerContracts.SearchModels { public class SupplySearchModel { + public int? SnackId { get; set; } public int? Count { get; set; } } diff --git a/Diner/Diner/DinerView.csproj b/Diner/Diner/DinerView.csproj index f8854ee..7e6084d 100644 --- a/Diner/Diner/DinerView.csproj +++ b/Diner/Diner/DinerView.csproj @@ -13,6 +13,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Diner/Diner/FormCreateSupply.Designer.cs b/Diner/Diner/FormCreateSupply.Designer.cs index fde6034..f7bf8e5 100644 --- a/Diner/Diner/FormCreateSupply.Designer.cs +++ b/Diner/Diner/FormCreateSupply.Designer.cs @@ -30,7 +30,7 @@ { comboBoxShop = new ComboBox(); labelShop = new Label(); - labelPizza = new Label(); + labelSnack = new Label(); comboBoxSnack = new ComboBox(); labelCount = new Label(); textBoxCount = new TextBox(); @@ -55,14 +55,14 @@ labelShop.TabIndex = 1; labelShop.Text = "Магазин: "; // - // labelPizza + // labelSnack // - labelPizza.AutoSize = true; - labelPizza.Location = new Point(12, 49); - labelPizza.Name = "labelPizza"; - labelPizza.Size = new Size(75, 20); - labelPizza.TabIndex = 2; - labelPizza.Text = "Изделие: "; + labelSnack.AutoSize = true; + labelSnack.Location = new Point(12, 49); + labelSnack.Name = "labelSnack"; + labelSnack.Size = new Size(75, 20); + labelSnack.TabIndex = 2; + labelSnack.Text = "Изделие: "; // // comboBoxSnack // @@ -118,7 +118,7 @@ Controls.Add(textBoxCount); Controls.Add(labelCount); Controls.Add(comboBoxSnack); - Controls.Add(labelPizza); + Controls.Add(labelSnack); Controls.Add(labelShop); Controls.Add(comboBoxShop); Name = "FormCreateSupply"; @@ -132,7 +132,7 @@ private ComboBox comboBoxShop; private Label labelShop; - private Label labelPizza; + private Label labelSnack; private ComboBox comboBoxSnack; private Label labelCount; private TextBox textBoxCount; diff --git a/Diner/Diner/FormSellSnack.Designer.cs b/Diner/Diner/FormSellSnack.Designer.cs index 8145f17..e08d87a 100644 --- a/Diner/Diner/FormSellSnack.Designer.cs +++ b/Diner/Diner/FormSellSnack.Designer.cs @@ -102,7 +102,7 @@ Controls.Add(labelSnack); Name = "FormSellSnack"; Text = "Продажа закуски"; - Load += FormSellingPizza_Load; + Load += FormSellingSnack_Load; ResumeLayout(false); PerformLayout(); } diff --git a/Diner/Diner/FormSellSnack.cs b/Diner/Diner/FormSellSnack.cs index d6f96a4..b906fa7 100644 --- a/Diner/Diner/FormSellSnack.cs +++ b/Diner/Diner/FormSellSnack.cs @@ -28,7 +28,7 @@ namespace DinerView _logicP = logicP; _logicS = logicS; } - private void FormSellingPizza_Load(object sender, EventArgs e) + private void FormSellingSnack_Load(object sender, EventArgs e) { _snackList = _logicP.ReadList(null); if (_snackList != null) diff --git a/Diner/DinerDatabaseImplements/DinerDatabase.cs b/Diner/DinerDatabaseImplements/DinerDatabase.cs index a4d86c1..3a3232b 100644 --- a/Diner/DinerDatabaseImplements/DinerDatabase.cs +++ b/Diner/DinerDatabaseImplements/DinerDatabase.cs @@ -10,7 +10,7 @@ namespace DinerDatabaseImplement { if (!optionsBuilder.IsConfigured) { - optionsBuilder.UseSqlServer(@"Data Source=SHADOWIK\SHADOWIK;Initial Catalog=PizzeriaHardDatabase;Integrated Security=True;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS01;Initial Catalog=DinerDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/Diner/DinerDatabaseImplements/Migrations/20240506162016_InitialCreate.Designer.cs b/Diner/DinerDatabaseImplements/Migrations/20240506162016_InitialCreate.Designer.cs new file mode 100644 index 0000000..b1efc68 --- /dev/null +++ b/Diner/DinerDatabaseImplements/Migrations/20240506162016_InitialCreate.Designer.cs @@ -0,0 +1,248 @@ +// +using System; +using DinerDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace DinerDatabaseImplement.Migrations +{ + [DbContext(typeof(DinerDatabase))] + [Migration("20240506162016_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Component", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ComponentName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Cost") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Components"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("SnackId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("SnackId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Shop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Adress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OpeningDate") + .HasColumnType("datetime2"); + + b.Property("ShopName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SnackMaxCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Shops"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.ShopSnacks", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ShopId") + .HasColumnType("int"); + + b.Property("SnackId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ShopId"); + + b.HasIndex("SnackId"); + + b.ToTable("ShopSnacks"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Snack", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("SnackName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Snacks"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.SnackComponent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ComponentId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("SnackId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ComponentId"); + + b.HasIndex("SnackId"); + + b.ToTable("SnackComponents"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Order", b => + { + b.HasOne("DinerDatabaseImplement.Models.Snack", "Snack") + .WithMany("Orders") + .HasForeignKey("SnackId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Snack"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.ShopSnacks", b => + { + b.HasOne("DinerDatabaseImplement.Models.Shop", "Shop") + .WithMany("Snacks") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DinerDatabaseImplement.Models.Snack", "Snack") + .WithMany() + .HasForeignKey("SnackId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Shop"); + + b.Navigation("Snack"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.SnackComponent", b => + { + b.HasOne("DinerDatabaseImplement.Models.Component", "Component") + .WithMany("SnackComponents") + .HasForeignKey("ComponentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DinerDatabaseImplement.Models.Snack", "Snack") + .WithMany("Components") + .HasForeignKey("SnackId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Component"); + + b.Navigation("Snack"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Component", b => + { + b.Navigation("SnackComponents"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Shop", b => + { + b.Navigation("Snacks"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Snack", b => + { + b.Navigation("Components"); + + b.Navigation("Orders"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Diner/DinerDatabaseImplements/Migrations/20240506162016_InitialCreate.cs b/Diner/DinerDatabaseImplements/Migrations/20240506162016_InitialCreate.cs new file mode 100644 index 0000000..0cf23df --- /dev/null +++ b/Diner/DinerDatabaseImplements/Migrations/20240506162016_InitialCreate.cs @@ -0,0 +1,184 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DinerDatabaseImplement.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Components", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ComponentName = table.Column(type: "nvarchar(max)", nullable: false), + Cost = table.Column(type: "float", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Components", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Shops", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ShopName = table.Column(type: "nvarchar(max)", nullable: false), + Adress = table.Column(type: "nvarchar(max)", nullable: false), + OpeningDate = table.Column(type: "datetime2", nullable: false), + SnackMaxCount = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Shops", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Snacks", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SnackName = table.Column(type: "nvarchar(max)", nullable: false), + Price = table.Column(type: "float", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Snacks", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Orders", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SnackId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false), + Sum = table.Column(type: "float", nullable: false), + Status = table.Column(type: "int", nullable: false), + DateCreate = table.Column(type: "datetime2", nullable: false), + DateImplement = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Orders", x => x.Id); + table.ForeignKey( + name: "FK_Orders_Snacks_SnackId", + column: x => x.SnackId, + principalTable: "Snacks", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ShopSnacks", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SnackId = table.Column(type: "int", nullable: false), + ShopId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ShopSnacks", x => x.Id); + table.ForeignKey( + name: "FK_ShopSnacks_Shops_ShopId", + column: x => x.ShopId, + principalTable: "Shops", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ShopSnacks_Snacks_SnackId", + column: x => x.SnackId, + principalTable: "Snacks", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "SnackComponents", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SnackId = table.Column(type: "int", nullable: false), + ComponentId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SnackComponents", x => x.Id); + table.ForeignKey( + name: "FK_SnackComponents_Components_ComponentId", + column: x => x.ComponentId, + principalTable: "Components", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_SnackComponents_Snacks_SnackId", + column: x => x.SnackId, + principalTable: "Snacks", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Orders_SnackId", + table: "Orders", + column: "SnackId"); + + migrationBuilder.CreateIndex( + name: "IX_ShopSnacks_ShopId", + table: "ShopSnacks", + column: "ShopId"); + + migrationBuilder.CreateIndex( + name: "IX_ShopSnacks_SnackId", + table: "ShopSnacks", + column: "SnackId"); + + migrationBuilder.CreateIndex( + name: "IX_SnackComponents_ComponentId", + table: "SnackComponents", + column: "ComponentId"); + + migrationBuilder.CreateIndex( + name: "IX_SnackComponents_SnackId", + table: "SnackComponents", + column: "SnackId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Orders"); + + migrationBuilder.DropTable( + name: "ShopSnacks"); + + migrationBuilder.DropTable( + name: "SnackComponents"); + + migrationBuilder.DropTable( + name: "Shops"); + + migrationBuilder.DropTable( + name: "Components"); + + migrationBuilder.DropTable( + name: "Snacks"); + } + } +} diff --git a/Diner/DinerDatabaseImplements/Migrations/DinerDatabaseModelSnapshot.cs b/Diner/DinerDatabaseImplements/Migrations/DinerDatabaseModelSnapshot.cs new file mode 100644 index 0000000..a4e5337 --- /dev/null +++ b/Diner/DinerDatabaseImplements/Migrations/DinerDatabaseModelSnapshot.cs @@ -0,0 +1,245 @@ +// +using System; +using DinerDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace DinerDatabaseImplement.Migrations +{ + [DbContext(typeof(DinerDatabase))] + partial class DinerDatabaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Component", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ComponentName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Cost") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Components"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("SnackId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("SnackId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Shop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Adress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OpeningDate") + .HasColumnType("datetime2"); + + b.Property("ShopName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SnackMaxCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Shops"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.ShopSnacks", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ShopId") + .HasColumnType("int"); + + b.Property("SnackId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ShopId"); + + b.HasIndex("SnackId"); + + b.ToTable("ShopSnacks"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Snack", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("SnackName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Snacks"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.SnackComponent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ComponentId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("SnackId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ComponentId"); + + b.HasIndex("SnackId"); + + b.ToTable("SnackComponents"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Order", b => + { + b.HasOne("DinerDatabaseImplement.Models.Snack", "Snack") + .WithMany("Orders") + .HasForeignKey("SnackId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Snack"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.ShopSnacks", b => + { + b.HasOne("DinerDatabaseImplement.Models.Shop", "Shop") + .WithMany("Snacks") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DinerDatabaseImplement.Models.Snack", "Snack") + .WithMany() + .HasForeignKey("SnackId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Shop"); + + b.Navigation("Snack"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.SnackComponent", b => + { + b.HasOne("DinerDatabaseImplement.Models.Component", "Component") + .WithMany("SnackComponents") + .HasForeignKey("ComponentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DinerDatabaseImplement.Models.Snack", "Snack") + .WithMany("Components") + .HasForeignKey("SnackId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Component"); + + b.Navigation("Snack"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Component", b => + { + b.Navigation("SnackComponents"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Shop", b => + { + b.Navigation("Snacks"); + }); + + modelBuilder.Entity("DinerDatabaseImplement.Models.Snack", b => + { + b.Navigation("Components"); + + b.Navigation("Orders"); + }); +#pragma warning restore 612, 618 + } + } +}