Доделал

This commit is contained in:
Артём Алейкин 2023-05-17 00:48:03 +04:00
parent b9c7b83110
commit 447f298c49
14 changed files with 807 additions and 2 deletions

View File

@ -102,5 +102,25 @@ namespace RestaurantBusinessLogic.BusinessLogics
throw new InvalidOperationException("Заказ с таким номером уже есть"); 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);
}
} }
} }

View File

@ -20,5 +20,10 @@ namespace RestaurantContracts.BusinessLogicsContracts
bool Update(OrderBindingModel model); bool Update(OrderBindingModel model);
bool Delete(OrderBindingModel model); bool Delete(OrderBindingModel model);
string SetTest(int count);
string GetTest(int count);
string DiffGetTest(int count);
bool ClearList();
} }
} }

View File

@ -22,5 +22,10 @@ namespace RestaurantContracts.StoragesContracts
OrderViewModel? Update(OrderBindingModel model); OrderViewModel? Update(OrderBindingModel model);
OrderViewModel? Delete(OrderBindingModel model); OrderViewModel? Delete(OrderBindingModel model);
string SetTest(int count);
string GetTest(int count);
string DiffGetTest(int count);
bool ClearList();
} }
} }

View File

@ -6,6 +6,7 @@ using RestaurantContracts.ViewModels;
using RestaurantDatabaseImplement.Models; using RestaurantDatabaseImplement.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -121,5 +122,82 @@ namespace RestaurantDatabaseImplement.Implements
} }
return null; 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;
}
} }
} }

View File

@ -6,6 +6,7 @@ using RestaurantContracts.ViewModels;
using RestaurantDatabaseImplement.Models; using RestaurantDatabaseImplement.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -117,5 +118,6 @@ namespace RestaurantDatabaseImplement.Implements
} }
return null; return null;
} }
} }
} }

View File

@ -0,0 +1,319 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Number")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("RestaurantDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Price")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Components");
});
modelBuilder.Entity("RestaurantDatabaseImplement.Models.ComponentProvider", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<int>("ProviderId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("ProviderId");
b.ToTable("ComponentProviders");
});
modelBuilder.Entity("RestaurantDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<double>("Price")
.HasColumnType("double precision");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Orders");
});
modelBuilder.Entity("RestaurantDatabaseImplement.Models.OrderProduct", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<int>("OrderId")
.HasColumnType("integer");
b.Property<int>("ProductId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("OrderId");
b.HasIndex("ProductId");
b.ToTable("OrderProducts");
});
modelBuilder.Entity("RestaurantDatabaseImplement.Models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Products");
});
modelBuilder.Entity("RestaurantDatabaseImplement.Models.ProductComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<int>("ProductId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("ProductId");
b.ToTable("ProductComponents");
});
modelBuilder.Entity("RestaurantDatabaseImplement.Models.Provider", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<string>("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
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace RestaurantDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class migr3 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -15,7 +15,7 @@ namespace RestaurantDatabaseImplement
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
optionsBuilder.UseNpgsql(@" optionsBuilder.UseNpgsql(@"
Host=localhost; Host=192.168.0.108;
Port=5432; Port=5432;
Database=RestaurantDatabase; Database=RestaurantDatabase;
Username=postgres; Username=postgres;

View File

@ -37,6 +37,7 @@
this.ProductsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ProductsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.backUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.backUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonUpd = new System.Windows.Forms.Button(); this.buttonUpd = new System.Windows.Forms.Button();
this.TestsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@ -67,7 +68,8 @@
this.ProvidersToolStripMenuItem, this.ProvidersToolStripMenuItem,
this.ComponentsToolStripMenuItem, this.ComponentsToolStripMenuItem,
this.ProductsToolStripMenuItem, this.ProductsToolStripMenuItem,
this.backUpToolStripMenuItem}); this.backUpToolStripMenuItem,
this.TestsToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1163, 24); this.menuStrip1.Size = new System.Drawing.Size(1163, 24);
@ -119,6 +121,13 @@
this.buttonUpd.UseVisualStyleBackColor = true; this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click); 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 // FormMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
@ -151,5 +160,6 @@
private ToolStripMenuItem ProductsToolStripMenuItem; private ToolStripMenuItem ProductsToolStripMenuItem;
private Button buttonUpd; private Button buttonUpd;
private ToolStripMenuItem backUpToolStripMenuItem; private ToolStripMenuItem backUpToolStripMenuItem;
private ToolStripMenuItem TestsToolStripMenuItem;
} }
} }

View File

@ -123,5 +123,15 @@ namespace RestaurantView
MessageBoxIcon.Error); 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();
}
}
} }
} }

View File

@ -0,0 +1,225 @@
namespace RestaurantView
{
partial class FormTests
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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);
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -55,6 +55,7 @@ namespace RestaurantView
services.AddTransient<FormProductComponent>(); services.AddTransient<FormProductComponent>();
services.AddTransient<FormCreateOrder>(); services.AddTransient<FormCreateOrder>();
services.AddTransient<FormOrderProduct>(); services.AddTransient<FormOrderProduct>();
services.AddTransient<FormTests>();
} }
} }
} }