From 447f298c491ce4343f9228a33e4bef2c15df32cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=90=D0=BB=D0=B5=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= Date: Wed, 17 May 2023 00:48:03 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/OrderLogic.cs | 20 ++ .../BusinessLogicsContracts/IOrderLogic.cs | 5 + .../StoragesContracts/IOrderStorage.cs | 5 + .../Implements/OrderStorage.cs | 78 +++++ .../Implements/ProductStorage.cs | 2 + .../20230516204531_migr3.Designer.cs | 319 ++++++++++++++++++ .../Migrations/20230516204531_migr3.cs | 22 ++ .../RestaurantDatabase.cs | 2 +- .../RestaurantView/FormMain.Designer.cs | 12 +- Restaurant/RestaurantView/FormMain.cs | 10 + .../RestaurantView/FormTests.Designer.cs | 225 ++++++++++++ Restaurant/RestaurantView/FormTests.cs | 48 +++ Restaurant/RestaurantView/FormTests.resx | 60 ++++ Restaurant/RestaurantView/Program.cs | 1 + 14 files changed, 807 insertions(+), 2 deletions(-) create mode 100644 Restaurant/RestaurantDatabaseImplement/Migrations/20230516204531_migr3.Designer.cs create mode 100644 Restaurant/RestaurantDatabaseImplement/Migrations/20230516204531_migr3.cs create mode 100644 Restaurant/RestaurantView/FormTests.Designer.cs create mode 100644 Restaurant/RestaurantView/FormTests.cs create mode 100644 Restaurant/RestaurantView/FormTests.resx diff --git a/Restaurant/RestaurantBusinessLogic/BusinessLogics/OrderLogic.cs b/Restaurant/RestaurantBusinessLogic/BusinessLogics/OrderLogic.cs index 26e2b6a..fa0989f 100644 --- a/Restaurant/RestaurantBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/Restaurant/RestaurantBusinessLogic/BusinessLogics/OrderLogic.cs @@ -102,5 +102,25 @@ namespace RestaurantBusinessLogic.BusinessLogics throw new InvalidOperationException("Заказ с таким номером уже есть"); } } + + public bool ClearList() + { + return _orderStorage.ClearList(); + } + + public string DiffGetTest(int count) + { + return _orderStorage.DiffGetTest(count); + } + + public string GetTest(int count) + { + return _orderStorage.GetTest(count); + } + + public string SetTest(int count) + { + return _orderStorage.SetTest(count); + } } } diff --git a/Restaurant/RestaurantContracts/BusinessLogicsContracts/IOrderLogic.cs b/Restaurant/RestaurantContracts/BusinessLogicsContracts/IOrderLogic.cs index 666a59c..a428031 100644 --- a/Restaurant/RestaurantContracts/BusinessLogicsContracts/IOrderLogic.cs +++ b/Restaurant/RestaurantContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -20,5 +20,10 @@ namespace RestaurantContracts.BusinessLogicsContracts bool Update(OrderBindingModel model); bool Delete(OrderBindingModel model); + + string SetTest(int count); + string GetTest(int count); + string DiffGetTest(int count); + bool ClearList(); } } diff --git a/Restaurant/RestaurantContracts/StoragesContracts/IOrderStorage.cs b/Restaurant/RestaurantContracts/StoragesContracts/IOrderStorage.cs index c48ab20..8d5190e 100644 --- a/Restaurant/RestaurantContracts/StoragesContracts/IOrderStorage.cs +++ b/Restaurant/RestaurantContracts/StoragesContracts/IOrderStorage.cs @@ -22,5 +22,10 @@ namespace RestaurantContracts.StoragesContracts OrderViewModel? Update(OrderBindingModel model); OrderViewModel? Delete(OrderBindingModel model); + + string SetTest(int count); + string GetTest(int count); + string DiffGetTest(int count); + bool ClearList(); } } diff --git a/Restaurant/RestaurantDatabaseImplement/Implements/OrderStorage.cs b/Restaurant/RestaurantDatabaseImplement/Implements/OrderStorage.cs index 4d5c8a0..5be009b 100644 --- a/Restaurant/RestaurantDatabaseImplement/Implements/OrderStorage.cs +++ b/Restaurant/RestaurantDatabaseImplement/Implements/OrderStorage.cs @@ -6,6 +6,7 @@ using RestaurantContracts.ViewModels; using RestaurantDatabaseImplement.Models; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -121,5 +122,82 @@ namespace RestaurantDatabaseImplement.Implements } return null; } + + public string DiffGetTest(int count) + { + using var context = new RestaurantDatabase(); + Stopwatch stopwatch = new(); + stopwatch.Start(); + var list = context.Orders + .Include(x => x.Client) + .Join(context.Clients, + order => order.ClientId, + client => client.Id, + (order, client) => new { Order = order, Client = client }) + .Select(order => new + { + Order = order.Order.GetViewModel, + Client = order.Client.GetViewModel, + }) + .Take(count) + .ToList(); + stopwatch.Stop(); + return stopwatch.ElapsedMilliseconds.ToString(); + } + + public string GetTest(int count) + { + using var context = new RestaurantDatabase(); + Stopwatch stopwatch = new(); + stopwatch.Start(); + var list = context.Orders + .Include(x => x.Client) + .Take(count) + .Select(x => x.GetViewModel) + .ToList(); + stopwatch.Stop(); + return stopwatch.ElapsedMilliseconds.ToString(); + } + + public string SetTest(int count) + { + Random rnd = new Random(); + using var context = new RestaurantDatabase(); + var listClients = context.Clients.Select(x => x.Id).ToList(); + if (listClients.Count < 1) + { + throw new Exception("Недостаточно для генерации!"); + } + for (int i = 0; i < count; ++i) + { + context.Orders.Add(Order.Create(context, new OrderBindingModel + { + Id = 0, + Date = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc), + Price = rnd.NextDouble(), + ClientId = listClients[rnd.Next(listClients.Count)], + })); + } + Stopwatch stopwatch = new(); + stopwatch.Start(); + context.SaveChanges(); + stopwatch.Stop(); + return stopwatch.ElapsedMilliseconds.ToString(); + } + + public bool ClearList() + { + try + { + using var context = new RestaurantDatabase(); + var tableName = context.Model.FindEntityType(typeof(Order)).GetTableName(); + context.Database.ExecuteSqlRaw($"DELETE FROM \"{tableName}\""); + } + catch (Exception) + { + return false; + } + return true; + } } } diff --git a/Restaurant/RestaurantDatabaseImplement/Implements/ProductStorage.cs b/Restaurant/RestaurantDatabaseImplement/Implements/ProductStorage.cs index b59a8f2..9274d42 100644 --- a/Restaurant/RestaurantDatabaseImplement/Implements/ProductStorage.cs +++ b/Restaurant/RestaurantDatabaseImplement/Implements/ProductStorage.cs @@ -6,6 +6,7 @@ using RestaurantContracts.ViewModels; using RestaurantDatabaseImplement.Models; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -117,5 +118,6 @@ namespace RestaurantDatabaseImplement.Implements } return null; } + } } diff --git a/Restaurant/RestaurantDatabaseImplement/Migrations/20230516204531_migr3.Designer.cs b/Restaurant/RestaurantDatabaseImplement/Migrations/20230516204531_migr3.Designer.cs new file mode 100644 index 0000000..78f14fa --- /dev/null +++ b/Restaurant/RestaurantDatabaseImplement/Migrations/20230516204531_migr3.Designer.cs @@ -0,0 +1,319 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using RestaurantDatabaseImplement; + +#nullable disable + +namespace RestaurantDatabaseImplement.Migrations +{ + [DbContext(typeof(RestaurantDatabase))] + [Migration("20230516204531_migr3")] + partial class migr3 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Number") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.Component", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Components"); + }); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.ComponentProvider", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ComponentId") + .HasColumnType("integer"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("ProviderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ComponentId"); + + b.HasIndex("ProviderId"); + + b.ToTable("ComponentProviders"); + }); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("integer"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.OrderProduct", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("OrderId") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProductId"); + + b.ToTable("OrderProducts"); + }); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.ProductComponent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ComponentId") + .HasColumnType("integer"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ComponentId"); + + b.HasIndex("ProductId"); + + b.ToTable("ProductComponents"); + }); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.Provider", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Providers"); + }); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.ComponentProvider", b => + { + b.HasOne("RestaurantDatabaseImplement.Models.Component", "Component") + .WithMany("Providers") + .HasForeignKey("ComponentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RestaurantDatabaseImplement.Models.Provider", "Provider") + .WithMany("ComponentProviders") + .HasForeignKey("ProviderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Component"); + + b.Navigation("Provider"); + }); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.Order", b => + { + b.HasOne("RestaurantDatabaseImplement.Models.Client", "Client") + .WithMany() + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + }); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.OrderProduct", b => + { + b.HasOne("RestaurantDatabaseImplement.Models.Order", "Order") + .WithMany("Products") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RestaurantDatabaseImplement.Models.Product", "Product") + .WithMany("OrderProducts") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.ProductComponent", b => + { + b.HasOne("RestaurantDatabaseImplement.Models.Component", "Component") + .WithMany("ProductComponents") + .HasForeignKey("ComponentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RestaurantDatabaseImplement.Models.Product", "Product") + .WithMany("Components") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Component"); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.Component", b => + { + b.Navigation("ProductComponents"); + + b.Navigation("Providers"); + }); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.Order", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.Product", b => + { + b.Navigation("Components"); + + b.Navigation("OrderProducts"); + }); + + modelBuilder.Entity("RestaurantDatabaseImplement.Models.Provider", b => + { + b.Navigation("ComponentProviders"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Restaurant/RestaurantDatabaseImplement/Migrations/20230516204531_migr3.cs b/Restaurant/RestaurantDatabaseImplement/Migrations/20230516204531_migr3.cs new file mode 100644 index 0000000..2437940 --- /dev/null +++ b/Restaurant/RestaurantDatabaseImplement/Migrations/20230516204531_migr3.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace RestaurantDatabaseImplement.Migrations +{ + /// + public partial class migr3 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/Restaurant/RestaurantDatabaseImplement/RestaurantDatabase.cs b/Restaurant/RestaurantDatabaseImplement/RestaurantDatabase.cs index b1f48e4..0672b59 100644 --- a/Restaurant/RestaurantDatabaseImplement/RestaurantDatabase.cs +++ b/Restaurant/RestaurantDatabaseImplement/RestaurantDatabase.cs @@ -15,7 +15,7 @@ namespace RestaurantDatabaseImplement if (optionsBuilder.IsConfigured == false) { optionsBuilder.UseNpgsql(@" - Host=localhost; + Host=192.168.0.108; Port=5432; Database=RestaurantDatabase; Username=postgres; diff --git a/Restaurant/RestaurantView/FormMain.Designer.cs b/Restaurant/RestaurantView/FormMain.Designer.cs index 482b6f7..7ab89e0 100644 --- a/Restaurant/RestaurantView/FormMain.Designer.cs +++ b/Restaurant/RestaurantView/FormMain.Designer.cs @@ -37,6 +37,7 @@ this.ProductsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.backUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.buttonUpd = new System.Windows.Forms.Button(); + this.TestsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -67,7 +68,8 @@ this.ProvidersToolStripMenuItem, this.ComponentsToolStripMenuItem, this.ProductsToolStripMenuItem, - this.backUpToolStripMenuItem}); + this.backUpToolStripMenuItem, + this.TestsToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(1163, 24); @@ -119,6 +121,13 @@ this.buttonUpd.UseVisualStyleBackColor = true; this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click); // + // TestsToolStripMenuItem + // + this.TestsToolStripMenuItem.Name = "TestsToolStripMenuItem"; + this.TestsToolStripMenuItem.Size = new System.Drawing.Size(51, 20); + this.TestsToolStripMenuItem.Text = "Тесты"; + this.TestsToolStripMenuItem.Click += new System.EventHandler(this.TestsToolStripMenuItem_Click); + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -151,5 +160,6 @@ private ToolStripMenuItem ProductsToolStripMenuItem; private Button buttonUpd; private ToolStripMenuItem backUpToolStripMenuItem; + private ToolStripMenuItem TestsToolStripMenuItem; } } \ No newline at end of file diff --git a/Restaurant/RestaurantView/FormMain.cs b/Restaurant/RestaurantView/FormMain.cs index dda1cd9..3f32213 100644 --- a/Restaurant/RestaurantView/FormMain.cs +++ b/Restaurant/RestaurantView/FormMain.cs @@ -123,5 +123,15 @@ namespace RestaurantView MessageBoxIcon.Error); } } + + private void TestsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormTests)); + if (service is FormTests form) + { + form.ShowDialog(); + LoadData(); + } + } } } diff --git a/Restaurant/RestaurantView/FormTests.Designer.cs b/Restaurant/RestaurantView/FormTests.Designer.cs new file mode 100644 index 0000000..b3e0d5d --- /dev/null +++ b/Restaurant/RestaurantView/FormTests.Designer.cs @@ -0,0 +1,225 @@ +namespace RestaurantView +{ + partial class FormTests + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.textBoxGetTest = new System.Windows.Forms.TextBox(); + this.numericUpDownGetTest = new System.Windows.Forms.NumericUpDown(); + this.buttonGetTest = new System.Windows.Forms.Button(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.textBoxGetDiffTest = new System.Windows.Forms.TextBox(); + this.numericUpDownGetDiffTest = new System.Windows.Forms.NumericUpDown(); + this.buttonGetDiffTest = new System.Windows.Forms.Button(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.textBoxSetTest = new System.Windows.Forms.TextBox(); + this.numericUpDownSetTest = new System.Windows.Forms.NumericUpDown(); + this.buttonSetTest = new System.Windows.Forms.Button(); + this.buttonClear = new System.Windows.Forms.Button(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownGetTest)).BeginInit(); + this.groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownGetDiffTest)).BeginInit(); + this.groupBox3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSetTest)).BeginInit(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.textBoxGetTest); + this.groupBox1.Controls.Add(this.numericUpDownGetTest); + this.groupBox1.Controls.Add(this.buttonGetTest); + this.groupBox1.Location = new System.Drawing.Point(29, 22); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(531, 112); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Тест обычного запроса"; + // + // textBoxGetTest + // + this.textBoxGetTest.Location = new System.Drawing.Point(193, 69); + this.textBoxGetTest.Name = "textBoxGetTest"; + this.textBoxGetTest.Size = new System.Drawing.Size(315, 23); + this.textBoxGetTest.TabIndex = 2; + // + // numericUpDownGetTest + // + this.numericUpDownGetTest.Location = new System.Drawing.Point(193, 32); + this.numericUpDownGetTest.Maximum = new decimal(new int[] { + 1000000, + 0, + 0, + 0}); + this.numericUpDownGetTest.Name = "numericUpDownGetTest"; + this.numericUpDownGetTest.Size = new System.Drawing.Size(315, 23); + this.numericUpDownGetTest.TabIndex = 1; + // + // buttonGetTest + // + this.buttonGetTest.Location = new System.Drawing.Point(16, 32); + this.buttonGetTest.Name = "buttonGetTest"; + this.buttonGetTest.Size = new System.Drawing.Size(149, 60); + this.buttonGetTest.TabIndex = 0; + this.buttonGetTest.Text = "GetTest"; + this.buttonGetTest.UseVisualStyleBackColor = true; + this.buttonGetTest.Click += new System.EventHandler(this.ButtonGetTest_Click); + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.textBoxGetDiffTest); + this.groupBox2.Controls.Add(this.numericUpDownGetDiffTest); + this.groupBox2.Controls.Add(this.buttonGetDiffTest); + this.groupBox2.Location = new System.Drawing.Point(29, 174); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(531, 96); + this.groupBox2.TabIndex = 1; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Тест сложного запроса"; + // + // textBoxGetDiffTest + // + this.textBoxGetDiffTest.Location = new System.Drawing.Point(193, 57); + this.textBoxGetDiffTest.Name = "textBoxGetDiffTest"; + this.textBoxGetDiffTest.Size = new System.Drawing.Size(315, 23); + this.textBoxGetDiffTest.TabIndex = 2; + // + // numericUpDownGetDiffTest + // + this.numericUpDownGetDiffTest.Location = new System.Drawing.Point(193, 22); + this.numericUpDownGetDiffTest.Maximum = new decimal(new int[] { + 1000000, + 0, + 0, + 0}); + this.numericUpDownGetDiffTest.Name = "numericUpDownGetDiffTest"; + this.numericUpDownGetDiffTest.Size = new System.Drawing.Size(315, 23); + this.numericUpDownGetDiffTest.TabIndex = 1; + // + // buttonGetDiffTest + // + this.buttonGetDiffTest.Location = new System.Drawing.Point(16, 22); + this.buttonGetDiffTest.Name = "buttonGetDiffTest"; + this.buttonGetDiffTest.Size = new System.Drawing.Size(149, 58); + this.buttonGetDiffTest.TabIndex = 0; + this.buttonGetDiffTest.Text = "GetDiffTest"; + this.buttonGetDiffTest.UseVisualStyleBackColor = true; + this.buttonGetDiffTest.Click += new System.EventHandler(this.ButtonDiffGetTest_Click); + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.textBoxSetTest); + this.groupBox3.Controls.Add(this.numericUpDownSetTest); + this.groupBox3.Controls.Add(this.buttonSetTest); + this.groupBox3.Location = new System.Drawing.Point(29, 321); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(531, 100); + this.groupBox3.TabIndex = 2; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Тест на заполнение"; + // + // textBoxSetTest + // + this.textBoxSetTest.Location = new System.Drawing.Point(193, 62); + this.textBoxSetTest.Name = "textBoxSetTest"; + this.textBoxSetTest.Size = new System.Drawing.Size(315, 23); + this.textBoxSetTest.TabIndex = 2; + // + // numericUpDownSetTest + // + this.numericUpDownSetTest.Location = new System.Drawing.Point(193, 22); + this.numericUpDownSetTest.Maximum = new decimal(new int[] { + 1000000, + 0, + 0, + 0}); + this.numericUpDownSetTest.Name = "numericUpDownSetTest"; + this.numericUpDownSetTest.Size = new System.Drawing.Size(315, 23); + this.numericUpDownSetTest.TabIndex = 1; + // + // buttonSetTest + // + this.buttonSetTest.Location = new System.Drawing.Point(16, 22); + this.buttonSetTest.Name = "buttonSetTest"; + this.buttonSetTest.Size = new System.Drawing.Size(149, 63); + this.buttonSetTest.TabIndex = 0; + this.buttonSetTest.Text = "SetTest"; + this.buttonSetTest.UseVisualStyleBackColor = true; + this.buttonSetTest.Click += new System.EventHandler(this.ButtonSetTest_Click); + // + // buttonClear + // + this.buttonClear.Location = new System.Drawing.Point(235, 438); + this.buttonClear.Name = "buttonClear"; + this.buttonClear.Size = new System.Drawing.Size(124, 36); + this.buttonClear.TabIndex = 3; + this.buttonClear.Text = "Очистить"; + this.buttonClear.UseVisualStyleBackColor = true; + this.buttonClear.Click += new System.EventHandler(this.ButtonClear_Click); + // + // FormTests + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(588, 498); + this.Controls.Add(this.buttonClear); + this.Controls.Add(this.groupBox3); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.Name = "FormTests"; + this.Text = "Тесты"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownGetTest)).EndInit(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownGetDiffTest)).EndInit(); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSetTest)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private GroupBox groupBox1; + private TextBox textBoxGetTest; + private NumericUpDown numericUpDownGetTest; + private Button buttonGetTest; + private GroupBox groupBox2; + private TextBox textBoxGetDiffTest; + private NumericUpDown numericUpDownGetDiffTest; + private Button buttonGetDiffTest; + private GroupBox groupBox3; + private TextBox textBoxSetTest; + private NumericUpDown numericUpDownSetTest; + private Button buttonSetTest; + private Button buttonClear; + } +} \ No newline at end of file diff --git a/Restaurant/RestaurantView/FormTests.cs b/Restaurant/RestaurantView/FormTests.cs new file mode 100644 index 0000000..4b14343 --- /dev/null +++ b/Restaurant/RestaurantView/FormTests.cs @@ -0,0 +1,48 @@ +using RestaurantContracts.BusinessLogicsContracts; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RestaurantView +{ + public partial class FormTests : Form + { + private readonly IOrderLogic _orderLogic; + public FormTests(IOrderLogic orderLogic) + { + InitializeComponent(); + _orderLogic = orderLogic; + } + + private void ButtonGetTest_Click(object sender, EventArgs e) + { + textBoxGetTest.Text = _orderLogic.GetTest(Convert.ToInt32(numericUpDownGetTest.Value)) + "мс"; + } + + private void ButtonDiffGetTest_Click(object sender, EventArgs e) + { + textBoxGetDiffTest.Text = _orderLogic.DiffGetTest(Convert.ToInt32(numericUpDownGetDiffTest.Value)) + "мс"; + } + + private void ButtonSetTest_Click(object sender, EventArgs e) + { + textBoxSetTest.Text = _orderLogic.SetTest(Convert.ToInt32(numericUpDownSetTest.Value)) + "мс"; + } + + private void ButtonClear_Click(object sender, EventArgs e) + { + if (_orderLogic.ClearList()) + { + MessageBox.Show("Удаление записей завершено", "Успешно", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + MessageBox.Show("Удаление записей провалилось", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } +} diff --git a/Restaurant/RestaurantView/FormTests.resx b/Restaurant/RestaurantView/FormTests.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Restaurant/RestaurantView/FormTests.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Restaurant/RestaurantView/Program.cs b/Restaurant/RestaurantView/Program.cs index fa4a4e9..f0deb97 100644 --- a/Restaurant/RestaurantView/Program.cs +++ b/Restaurant/RestaurantView/Program.cs @@ -55,6 +55,7 @@ namespace RestaurantView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file