From c905826512e87f88f7a741cbfc7eedf740980ce2 Mon Sep 17 00:00:00 2001 From: Timourka Date: Wed, 27 Mar 2024 03:31:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BC=D0=B5=D1=80=20=D0=B2=D1=80=D0=B5=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=20=D0=BE=D0=B4=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUBD_Car_rent/Forms/FormMain.Designer.cs | 24 ++++++++++++++++++++++++ SUBD_Car_rent/Forms/FormMain.cs | 16 ++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/SUBD_Car_rent/Forms/FormMain.Designer.cs b/SUBD_Car_rent/Forms/FormMain.Designer.cs index 7017f5d..a76dce7 100644 --- a/SUBD_Car_rent/Forms/FormMain.Designer.cs +++ b/SUBD_Car_rent/Forms/FormMain.Designer.cs @@ -35,6 +35,8 @@ branchToolStripMenuItem = new ToolStripMenuItem(); clientToolStripMenuItem = new ToolStripMenuItem(); rentalToolStripMenuItem = new ToolStripMenuItem(); + buttonTest = new Button(); + textBoxTest = new TextBox(); menuStrip1.SuspendLayout(); SuspendLayout(); // @@ -89,11 +91,31 @@ rentalToolStripMenuItem.Text = "rental"; rentalToolStripMenuItem.Click += rentalToolStripMenuItem_Click; // + // buttonTest + // + buttonTest.Location = new Point(24, 50); + buttonTest.Name = "buttonTest"; + buttonTest.Size = new Size(75, 23); + buttonTest.TabIndex = 1; + buttonTest.Text = "buttonTest"; + buttonTest.UseVisualStyleBackColor = true; + buttonTest.Click += buttonTest_Click; + // + // textBoxTest + // + textBoxTest.Location = new Point(121, 51); + textBoxTest.Multiline = true; + textBoxTest.Name = "textBoxTest"; + textBoxTest.Size = new Size(251, 75); + textBoxTest.TabIndex = 2; + // // FormMain // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(435, 167); + Controls.Add(textBoxTest); + Controls.Add(buttonTest); Controls.Add(menuStrip1); MainMenuStrip = menuStrip1; Name = "FormMain"; @@ -113,5 +135,7 @@ private ToolStripMenuItem branchToolStripMenuItem; private ToolStripMenuItem clientToolStripMenuItem; private ToolStripMenuItem rentalToolStripMenuItem; + private Button buttonTest; + private TextBox textBoxTest; } } \ No newline at end of file diff --git a/SUBD_Car_rent/Forms/FormMain.cs b/SUBD_Car_rent/Forms/FormMain.cs index f17418a..0b9de0a 100644 --- a/SUBD_Car_rent/Forms/FormMain.cs +++ b/SUBD_Car_rent/Forms/FormMain.cs @@ -1,4 +1,5 @@ using database; +using Microsoft.Extensions.DependencyInjection; namespace Forms { @@ -55,6 +56,21 @@ namespace Forms } } + private void buttonTest_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(Abstractions)); + if (service is Abstractions bd) + { + // Замените "GetCars" на метод вашего класса, который выполняет запрос к сущности + DateTime startTime = DateTime.Now; + var result = bd.GetClients(); // Выполняем запрос к сущности + DateTime endTime = DateTime.Now; + + // Выводим время выполнения запроса в консоль + textBoxTest.Text = $"Время выполнения запроса: {(endTime - startTime).TotalMilliseconds} миллисекунд"; + } + } + /* private Abstractions bd = new Implementation(); private void button1_Click(object sender, EventArgs e)