diff --git a/BeautySaloon/BeautySaloonDatabaseImplement/NewdbContext.cs b/BeautySaloon/BeautySaloonDatabaseImplement/NewdbContext.cs index def7f31..2a7bb91 100644 --- a/BeautySaloon/BeautySaloonDatabaseImplement/NewdbContext.cs +++ b/BeautySaloon/BeautySaloonDatabaseImplement/NewdbContext.cs @@ -159,7 +159,7 @@ public partial class NewdbContext : DbContext .HasComment("Уникальный идентификатор") .HasColumnName("id"); entity.Property(e => e.Name) - .HasMaxLength(40) + .HasMaxLength(100) .HasComment("Название") .HasColumnName("name"); entity.Property(e => e.Price) diff --git a/BeautySaloon/BeautySaloonView/FormMain.Designer.cs b/BeautySaloon/BeautySaloonView/FormMain.Designer.cs index 23c881a..af20e02 100644 --- a/BeautySaloon/BeautySaloonView/FormMain.Designer.cs +++ b/BeautySaloon/BeautySaloonView/FormMain.Designer.cs @@ -36,6 +36,7 @@ this.сотрудникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.buttonUpdate = new System.Windows.Forms.Button(); + this.buttonTest = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -103,7 +104,7 @@ // // buttonUpdate // - this.buttonUpdate.Location = new System.Drawing.Point(917, 241); + this.buttonUpdate.Location = new System.Drawing.Point(917, 225); this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonUpdate.Name = "buttonUpdate"; this.buttonUpdate.Size = new System.Drawing.Size(116, 58); @@ -112,11 +113,23 @@ this.buttonUpdate.UseVisualStyleBackColor = true; this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); // + // buttonTest + // + this.buttonTest.Location = new System.Drawing.Point(917, 287); + this.buttonTest.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonTest.Name = "buttonTest"; + this.buttonTest.Size = new System.Drawing.Size(116, 58); + this.buttonTest.TabIndex = 18; + this.buttonTest.Text = "Тесты"; + this.buttonTest.UseVisualStyleBackColor = true; + this.buttonTest.Click += new System.EventHandler(this.ButtonTest_Click); + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1037, 539); + this.Controls.Add(this.buttonTest); this.Controls.Add(this.buttonUpdate); this.Controls.Add(this.dataGridView); this.Controls.Add(this.menuStrip1); @@ -143,5 +156,6 @@ private ToolStripMenuItem клиентыToolStripMenuItem; private Button buttonUpdate; private Button buttonCreateOrder; + private Button buttonTest; } } \ No newline at end of file diff --git a/BeautySaloon/BeautySaloonView/FormMain.cs b/BeautySaloon/BeautySaloonView/FormMain.cs index 417d81d..c8fbf29 100644 --- a/BeautySaloon/BeautySaloonView/FormMain.cs +++ b/BeautySaloon/BeautySaloonView/FormMain.cs @@ -72,5 +72,14 @@ namespace BeautySaloonView form.ShowDialog(); } } + + private void ButtonTest_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormTest)); + if (service is FormTest form) + { + form.ShowDialog(); + } + } } } \ No newline at end of file diff --git a/BeautySaloon/BeautySaloonView/FormTest.Designer.cs b/BeautySaloon/BeautySaloonView/FormTest.Designer.cs new file mode 100644 index 0000000..496a4cc --- /dev/null +++ b/BeautySaloon/BeautySaloonView/FormTest.Designer.cs @@ -0,0 +1,153 @@ +namespace BeautySaloonView +{ + partial class FormTest + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonAdd = new System.Windows.Forms.Button(); + this.comboBoxWhat = new System.Windows.Forms.ComboBox(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.comboBoxQuery = new System.Windows.Forms.ComboBox(); + this.labelQuery = new System.Windows.Forms.Label(); + this.labelWhat = new System.Windows.Forms.Label(); + this.labelCount = new System.Windows.Forms.Label(); + this.label = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(119, 95); + this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(82, 22); + this.buttonAdd.TabIndex = 0; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // comboBoxWhat + // + this.comboBoxWhat.FormattingEnabled = true; + this.comboBoxWhat.Items.AddRange(new object[] { + "Сотрудники", + "Клиенты", + "Заказы"}); + this.comboBoxWhat.Location = new System.Drawing.Point(68, 31); + this.comboBoxWhat.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBoxWhat.Name = "comboBoxWhat"; + this.comboBoxWhat.Size = new System.Drawing.Size(133, 23); + this.comboBoxWhat.TabIndex = 1; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(68, 6); + this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(133, 23); + this.textBoxCount.TabIndex = 2; + // + // comboBoxQuery + // + this.comboBoxQuery.FormattingEnabled = true; + this.comboBoxQuery.Items.AddRange(new object[] { + "Добавить", + "Выбрать"}); + this.comboBoxQuery.Location = new System.Drawing.Point(68, 56); + this.comboBoxQuery.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBoxQuery.Name = "comboBoxQuery"; + this.comboBoxQuery.Size = new System.Drawing.Size(133, 23); + this.comboBoxQuery.TabIndex = 4; + // + // labelQuery + // + this.labelQuery.AutoSize = true; + this.labelQuery.Location = new System.Drawing.Point(10, 59); + this.labelQuery.Name = "labelQuery"; + this.labelQuery.Size = new System.Drawing.Size(47, 15); + this.labelQuery.TabIndex = 5; + this.labelQuery.Text = "Запрос"; + // + // labelWhat + // + this.labelWhat.AutoSize = true; + this.labelWhat.Location = new System.Drawing.Point(10, 34); + this.labelWhat.Name = "labelWhat"; + this.labelWhat.Size = new System.Drawing.Size(27, 15); + this.labelWhat.TabIndex = 6; + this.labelWhat.Text = "Что"; + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(10, 9); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(46, 15); + this.labelCount.TabIndex = 7; + this.labelCount.Text = "Кол-во"; + // + // label + // + this.label.AutoSize = true; + this.label.Location = new System.Drawing.Point(12, 95); + this.label.Name = "label"; + this.label.Size = new System.Drawing.Size(51, 15); + this.label.TabIndex = 8; + this.label.Text = "Время..."; + // + // FormTest + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(209, 137); + this.Controls.Add(this.label); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.labelWhat); + this.Controls.Add(this.labelQuery); + this.Controls.Add(this.comboBoxQuery); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.comboBoxWhat); + this.Controls.Add(this.buttonAdd); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "FormTest"; + this.Text = "FormTest"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button buttonAdd; + private ComboBox comboBoxWhat; + private TextBox textBoxCount; + private ComboBox comboBoxQuery; + private Label labelQuery; + private Label labelWhat; + private Label labelCount; + private Label label; + } +} \ No newline at end of file diff --git a/BeautySaloon/BeautySaloonView/FormTest.cs b/BeautySaloon/BeautySaloonView/FormTest.cs new file mode 100644 index 0000000..9c5c4f2 --- /dev/null +++ b/BeautySaloon/BeautySaloonView/FormTest.cs @@ -0,0 +1,216 @@ +using BeautySaloonContracts.BindingModels; +using BeautySaloonContracts.BusinessLogicsContracts; +using BeautySaloonContracts.SearchModels; +using BeautySaloonContracts.ViewModels; +using BeautySaloonDataModels; +using System.Diagnostics; +using System.Drawing; +using System.Text; + +namespace BeautySaloonView +{ + public partial class FormTest : Form + { + private readonly IServiceLogic _SLogic; + private readonly IPositionLogic _PLogic; + private readonly IEmployeeLogic _ELogic; + private readonly IClientLogic _CLogic; + private readonly IOrderLogic _OLogic; + private readonly List? SList; + private readonly List? PList; + private List? EList; + private List? CList; + private List? OList; + public FormTest(IServiceLogic serviceLogic, IPositionLogic positionLogic, + IEmployeeLogic employeeLogic, + IClientLogic clientLogic, IOrderLogic orderLogic) + { + InitializeComponent(); + _SLogic = serviceLogic; + _PLogic = positionLogic; + _ELogic = employeeLogic; + _CLogic = clientLogic; + _OLogic = orderLogic; + SList = _SLogic.ReadList(null); + PList = _PLogic.ReadList(null); + } + string[] names = new string[] { "Захар", "Ева", "Сергей", "Максим", "Максимильян", "Лука", "Олег", "Мишель", "София", "Стела", "Аким", "Матвей", "Анисия", "Василий", "Лукьян", "Руслан", "Клара", "Андрей", "Мстислав", "Федот", "Олег", "Аркадий", "Ангелина", "Анжелика", "Стефания", "Мариам", "Дементий", "Андрон", "Даниил", "Адам", "Евдоким", "Валерий", "Дамир", "Фёдор", "Василиса", "Сафина", "Даниэль", "Дарина", "Мир", "Феофан", "Всеслава", "Инна", "Платон", "Ирина", "Рафаэль", "Милана", "Клавдий", "Лейла", "Роза", "Тимофей", "Пимен", "Модест", "Эмма", "Георгий", "Дарья", "Дмитрий", "Эрик", "Филипп", "Владилен", "Евсей", "Даниль", "Ростислав", "Тихон", "Тея", "Наум", "Виолетта", "Анатолий", "Рустам", "Юлия", "Дана", "Самсон", "Ариадна", "Ибрагим", "Светлана", "Инга", "Али", "Виталий", "Алисия", "Оксана", "Тимур", "Аида", "Камиль", "Иннокентий", "Элина", "Виктория", "Анна", "Амелия", "Япсина", "Эвелина", "Кира", "Артур", "Владлена", "Никифор", "Марина", "Артем", "Моисей", "Иван", "Лидия", "Трофим", "Игорь" }; + string[] surnames = new string[] { "Пищальников", "Яхонтов", "Кочетов", "Ермилова", "Разбойникова", "Окулова", "Дудинова", "Добрынина", "Кучава", "Лазарев", "Егорова", "Ипатьев", "Байдавлетов", "Шалаганов", "Масмехов", "Шентеряков", "Юдачёв", "Дагина", "Лавлинский", "Гунин", "Яшвили", "Шуршалина", "Сомкина", "Бояринов", "Коленко", "Меншикова", "Бойков", "Ябловский", "Любова", "Ямпольский", "Фанина", "Молчанова", "Верещагин", "Окладников", "Чичерина", "Ключников", "Барышев", "Вятт", "Толбугин", "Радченко", "Веселкова", "Щавлева", "Слепынина", "Садков", "Барышников", "Бенедиктов", "Графова", "Мирнова", "Васильев", "Никишина", "Краснов", "Набатников", "Пронин", "Стрельцов", "Булка", "Саврасова", "Элиашева", "Канаев", "Кичеева", "Портнова", "Машарин", "Ларина", "Курганова", "Лапаева", "Яшуков", "Шлыков", "Арнаутова", "Ширяев", "Зуев", "Синдеева", "Трутнев", "Кошечкин", "Логинов", "Колпаков", "Бендлина", "Мурзакова", "Витинский", "Ратаева", "Щедрин", "Овощников", "Язвецова", "Крупин", "Седельников", "Юхтрица", "Лыков", "Смешной", "Пожарский", "Мичуев", "Шлиппенбах", "Татаринов", "Янютин", "Кулагина", "Семёнов", "Зверева", "Ивакин", "Бабинова", "Цейдлерин", "Сагадиев", "Истлентьев", "Деменока" }; + string[] patronymics = new string[] { "Владимирович(на)", "Олегович(на)", "Александрович(на)", "Алексеевич(на)", "Генадьевич(на)", "Максимович(на)", "Павлович(на)", "Акимович(на)", "Лукьянович(на)", "Матвеевич(на)", "Адреевич(на)", "Федотович(на)", "Аркадий(на)", "Мстиславович(на)", "Федотович(на)", "Даниилович(на)", "Никитьевич(на)", "Евдокимович(на)", "Валерьевич(на)", "Дамирович(на)", "Клавдьевич(на)", "Мирович(на)", "Миронович(на)", "Платонович(на)", "Игоревич(на)", "Антонович(на)", "Валерьевич(на)", "Модестович(на)", "Тимофеевич(на)", "Владленович(на)", "Дмитриевич(на)", "Бенедиктович(на)", "Рустамович(на)", "Ростиславович(на)", "Николаевич(на)", "Данателович(на)", "Ибрагимович(на)", "Анатольевич(на)" }; + string[] positions = new string[] { "Администратор","Продавец", "Парикмахер", "Мастер ногтевого сервиса", "Мастер по наращиванию ресниц", "Мастер депиляции", "Массажист", "Визажист", "Косметолог", "Мастер перманентного макияжа" }; + string[] services = new string[] { "Свадебные и вечерние прически", "Завивка и выпрямление волос", "Кератиновое разглаживание", "Долговременная укладка", "Брондирование и колорирование", "Мелирование и блондирование", "Каутеризация", "Ламинирование волос", "Амбре-окрашивание", "Укладки и тонирование", "Цветовой дизайн волос", "Женская, мужская и детская стрижка", "Уход за волосами и лечение волос", "Наращивание и окраска волос", "Биопилинг кожи головы", "Плетение косичек", "Аппаратный", "Классический мужской и детский", "Европейский", "Долгосрочное покрытие гель-лаками(ши-лаками)", "Горячие обвертывания", "Наращивание и коррекция ногтей гелем", "Парафинотерапия", "Артдизайн", "Spa-маникюр", "Отбеливание", "Укрепление натуральных ногтей", "Уход за руками", "Массаж рук", "Лимфодренаж", "Cолярий", "Криодеструкция", "Микродермообразия", "Криотерапия" }; + Random rd = new Random(); + Random rand = new Random(); + string GetRandomTelNo() + { + StringBuilder telNo = new StringBuilder(11); + int number; + telNo = telNo.Append('8'); + for (int i = 0; i < 10; i++) + { + number = rand.Next(1, 10); + telNo = telNo.Append(number.ToString()); + } + return telNo.ToString(); + } + DateTime RandomDate() + { + DateTime start = new DateTime(1970, 1, 1); + int range = (DateTime.Today - start).Days; + return start.AddDays(rd.Next(range)).AddHours(rd.Next(0,24)).AddMinutes(rd.Next(0,60)); + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + if (SList?.Count == 0) + foreach (string service in services) + { + var model = new ServiceBindingModel + { + Id = 0, + Name = service, + Price = rd.Next(1, 10001) + }; + _SLogic.Create(model); + } + if (PList?.Count == 0) + foreach (string pos in positions) + { + var model = new PositionBindingModel + { + Id = 0, + Name = pos + }; + _PLogic.Create(model); + } + switch (comboBoxQuery.SelectedItem) + { + case "Добавить": + switch (comboBoxWhat.SelectedItem) + { + case "Сотрудники": + Stopwatch stopwatch = new Stopwatch(); + stopwatch.Start(); + for (int i = 0; i < Convert.ToInt32(textBoxCount.Text); i++) + { + var model = new EmployeeBindingModel + { + Id = 0, + Name = names[rd.Next(0, names.Length - 1)], + Surname = surnames[rd.Next(0, surnames.Length - 1)], + Patronymic = patronymics[rd.Next(0, patronymics.Length - 1)], + Phone = GetRandomTelNo(), + PositionId = rd.Next(1, positions.Length) + }; + _ELogic.Create(model); + } + stopwatch.Stop(); + TimeSpan ts = stopwatch.Elapsed; + + string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", + ts.Hours, ts.Minutes, ts.Seconds, + ts.Milliseconds / 10); + label.Text = ("Время: " + elapsedTime); + break; + case "Клиенты": + Stopwatch stopwatch2 = new Stopwatch(); + stopwatch2.Start(); + for (int i = 0; i < Convert.ToInt32(textBoxCount.Text); i++) + { + var model = new ClientBindingModel + { + Id = 0, + Name = names[rd.Next(0, names.Length - 1)], + Surname = surnames[rd.Next(0, surnames.Length - 1)], + Patronymic = patronymics[rd.Next(0, patronymics.Length - 1)], + Phone = GetRandomTelNo() + }; + _CLogic.Create(model); + } + stopwatch2.Stop(); + TimeSpan ts1 = stopwatch2.Elapsed; + + string elapsedTime1 = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", + ts1.Hours, ts1.Minutes, ts1.Seconds, + ts1.Milliseconds / 10); + label.Text = ("Время: " + elapsedTime1); + break; + case "Заказы": + + EList = _ELogic.ReadList(null); + CList = _CLogic.ReadList(null); + OList = _OLogic.ReadList(null); + + Stopwatch stopwatch1 = new Stopwatch(); + stopwatch1.Start(); + + for (int i = 0; i < Convert.ToInt32(textBoxCount.Text); i++) + { + int random = rd.Next(1, 29); + var elem = _SLogic.ReadElement(new ServiceSearchModel() { Id = random }) as IServiceModel; + var model = new OrderBindingModel + { + Id = 0, + Date = DateOnly.FromDateTime(RandomDate()), + Sum = rd.Next(1,10001), + ClientId = CList?.ElementAt(rd.Next(1, CList.Count)).Id ?? 1, + EmployeeId = EList?.ElementAt(rd.Next(1, EList.Count)).Id ?? 1, + OrderServices = new() { { random, + (TimeOnly.FromDateTime(RandomDate()), + elem, EList?.ElementAt(rd.Next(1, EList.Count)).Id ?? 1) } } + }; + _OLogic.CreateOrder(model); + } + stopwatch1.Stop(); + TimeSpan ts2 = stopwatch1.Elapsed; + + + string elapsedTime2 = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", + ts2.Hours, ts2.Minutes, ts2.Seconds, + ts2.Milliseconds / 10); + label.Text = ("Время: " + elapsedTime2); + break; + } + break; + case "Выбрать": + switch (comboBoxWhat.SelectedItem) + { + case "Сотрудники": + Stopwatch stopwatch = new Stopwatch(); + stopwatch.Start(); + var list = _ELogic.ReadList(null); + stopwatch.Stop(); + TimeSpan ts = stopwatch.Elapsed; + string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", + ts.Hours, ts.Minutes, ts.Seconds, + ts.Milliseconds / 10); + label.Text = ("Время: " + elapsedTime); + break; + case "Клиенты": + Stopwatch stopwatch1 = new Stopwatch(); + stopwatch1.Start(); + var list1 = _CLogic.ReadList(null); + stopwatch1.Stop(); + TimeSpan ts1 = stopwatch1.Elapsed; + string elapsedTime1 = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", + ts1.Hours, ts1.Minutes, ts1.Seconds, + ts1.Milliseconds / 10); + label.Text = ("Время: " + elapsedTime1); + break; + case "Заказы": + Stopwatch stopwatch2 = new Stopwatch(); + stopwatch2.Start(); + var list2 = _OLogic.ReadList(null); + stopwatch2.Stop(); + TimeSpan ts2 = stopwatch2.Elapsed; + string elapsedTime2 = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", + ts2.Hours, ts2.Minutes, ts2.Seconds, + ts2.Milliseconds / 10); + label.Text = ("Время: " + elapsedTime2); + break; + } + break; + } + + } + } +} diff --git a/BeautySaloon/BeautySaloonView/FormTest.resx b/BeautySaloon/BeautySaloonView/FormTest.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/BeautySaloon/BeautySaloonView/FormTest.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BeautySaloon/BeautySaloonView/Program.cs b/BeautySaloon/BeautySaloonView/Program.cs index 0624990..4ec300c 100644 --- a/BeautySaloon/BeautySaloonView/Program.cs +++ b/BeautySaloon/BeautySaloonView/Program.cs @@ -53,6 +53,7 @@ namespace BeautySaloonView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file