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)