удаление 1000 записей

This commit is contained in:
goldfest 2024-05-04 09:58:44 +04:00
parent a0ea4e27b1
commit fba92025ec
2 changed files with 47 additions and 2 deletions

View File

@ -42,6 +42,8 @@
textBoxTest1 = new TextBox();
textBoxTest2 = new TextBox();
buttonTest2 = new Button();
buttonTest3 = new Button();
textBoxTest3 = new TextBox();
menuStrip1.SuspendLayout();
SuspendLayout();
//
@ -52,7 +54,7 @@
menuStrip1.Items.AddRange(new ToolStripItem[] { tablesToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(570, 24);
menuStrip1.Size = new Size(878, 24);
menuStrip1.TabIndex = 0;
menuStrip1.Text = "menuStrip1";
//
@ -161,11 +163,34 @@
buttonTest2.UseVisualStyleBackColor = false;
buttonTest2.Click += buttonTest2_Click;
//
// buttonTest3
//
buttonTest3.BackColor = SystemColors.Highlight;
buttonTest3.Font = new Font("Microsoft Sans Serif", 19.8000011F, FontStyle.Regular, GraphicsUnit.Point);
buttonTest3.ForeColor = SystemColors.ActiveCaption;
buttonTest3.Location = new Point(635, 73);
buttonTest3.Name = "buttonTest3";
buttonTest3.Size = new Size(232, 86);
buttonTest3.TabIndex = 6;
buttonTest3.Text = "Тест";
buttonTest3.UseVisualStyleBackColor = false;
buttonTest3.Click += buttonTest3_Click;
//
// textBoxTest3
//
textBoxTest3.Location = new Point(635, 27);
textBoxTest3.Multiline = true;
textBoxTest3.Name = "textBoxTest3";
textBoxTest3.Size = new Size(232, 40);
textBoxTest3.TabIndex = 5;
//
// FormMain
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(570, 167);
ClientSize = new Size(878, 167);
Controls.Add(buttonTest3);
Controls.Add(textBoxTest3);
Controls.Add(buttonTest2);
Controls.Add(textBoxTest2);
Controls.Add(textBoxTest1);
@ -196,5 +221,7 @@
private ToolStripMenuItem cargoordersToolStripMenuItem;
private TextBox textBoxTest2;
private Button buttonTest2;
private Button buttonTest3;
private TextBox textBoxTest3;
}
}

View File

@ -118,5 +118,23 @@ namespace Forms
textBoxTest2.Text = $"Добавление 1000 строк выполнено за {(endTime - startTime).TotalMilliseconds} миллисекунд";
}
}
private void buttonTest3_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(Abstractions));
if (service is Abstractions bd)
{
DateTime startTime = DateTime.Now;
for (int i = 0; i < 1000; i++)
{
var cargos = bd.GetCargos();
int id = cargos.Last().id;
bd.DeleteCargo(id);
}
DateTime endTime = DateTime.Now;
textBoxTest3.Text = $"Удаление 1000 строк выполнено за {(endTime - startTime).TotalMilliseconds} миллисекунд";
}
}
}
}