using HotelAbstractions.Logic; using HotelAbstractions.Models; namespace HotelView { public partial class FormMain : Form { public FormMain() { InitializeComponent(); } private void HotelToolStrip_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormHotel)); if (service is FormHotel form) { form.ShowDialog(); } } private void RoomToolStrip_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormRoom)); if (service is FormRoom form) { form.ShowDialog(); } } private void ReservationToolStrip_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormReservation)); if (service is FormReservation form) { form.ShowDialog(); } } private void GuestToolStrip_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormGuest)); if (service is FormGuest form) { form.ShowDialog(); } } private void ServiceToolStrip_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormService)); if (service is FormService form) { form.ShowDialog(); } } private void ServiceCheckToolStrip_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormServiceCheck)); if (service is FormServiceCheck form) { form.ShowDialog(); } } private void add1000ToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(IHotelLogic)); if (service is IHotelLogic hotelLogic) { DateTime startTime = DateTime.Now; for (int i = 0; i < 1000; i++) { Hotel hotel = new() { Id = i + 1000, HotelName = "Название гостиницы " + i, Address = "Адрес " + i, CountStar = i, CountRoom = i }; hotelLogic.CreateId(hotel); } DateTime endTime = DateTime.Now; labelTest.Text = $"Добавление 1000 строк выполнено за {(endTime - startTime).TotalMilliseconds} миллисекунд"; } } private void get1000ToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(IHotelLogic)); if (service is IHotelLogic hotelLogic) { DateTime startTime = DateTime.Now; for (int i =0; i < 1000; i++) hotelLogic.Get(i + 1000); DateTime endTime = DateTime.Now; labelTest.Text = $"Получение 1000 строк выполнено за {(endTime - startTime).TotalMilliseconds} миллисекунд"; } } private void update1000ToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(IHotelLogic)); if (service is IHotelLogic hoteLogic) { DateTime startTime = DateTime.Now; for (int i = 0; i < 1000; i++) { Hotel hotel = new() { Id = i + 1000, HotelName = "Название гостиницы " + i + 2000, Address = "Адрес " + i + 2000, CountStar = i + 2000, CountRoom = i + 2000 }; hoteLogic.Update(hotel); } DateTime endTime = DateTime.Now; labelTest.Text = $"Обновление 1000 строк выполнено за {(endTime - startTime).TotalMilliseconds} миллисекунд"; } } private void delete1000ToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(IHotelLogic)); if (service is IHotelLogic hoteLogic) { DateTime startTime = DateTime.Now; for (int i = 0; i < 1000; i++) { hoteLogic.Delete(i + 1000); } DateTime endTime = DateTime.Now; labelTest.Text = $"Удаление 1000 строк выполнено за {(endTime - startTime).TotalMilliseconds} миллисекунд"; } } } }