diff --git a/FishFactory/FishFactory/FormImplementer.Designer.cs b/FishFactory/FishFactory/FormImplementer.Designer.cs index 0c73bdb..bb96438 100644 --- a/FishFactory/FishFactory/FormImplementer.Designer.cs +++ b/FishFactory/FishFactory/FormImplementer.Designer.cs @@ -43,36 +43,36 @@ // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(6, 17); + this.label1.Location = new System.Drawing.Point(7, 23); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(37, 15); + this.label1.Size = new System.Drawing.Size(45, 20); this.label1.TabIndex = 0; this.label1.Text = "ФИО:"; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(6, 46); + this.label2.Location = new System.Drawing.Point(7, 61); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(52, 15); + this.label2.Size = new System.Drawing.Size(65, 20); this.label2.TabIndex = 1; this.label2.Text = "Пароль:"; // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(6, 75); + this.label3.Location = new System.Drawing.Point(7, 100); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(82, 15); + this.label3.Size = new System.Drawing.Size(102, 20); this.label3.TabIndex = 2; this.label3.Text = "Стаж работы:"; // // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(178, 75); + this.label4.Location = new System.Drawing.Point(203, 100); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(91, 15); + this.label4.Size = new System.Drawing.Size(114, 20); this.label4.TabIndex = 3; this.label4.Text = "Квалификация:"; // @@ -80,65 +80,73 @@ // this.textBoxFio.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxFio.Location = new System.Drawing.Point(94, 9); + this.textBoxFio.Location = new System.Drawing.Point(107, 12); + this.textBoxFio.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.textBoxFio.Name = "textBoxFio"; - this.textBoxFio.Size = new System.Drawing.Size(297, 23); + this.textBoxFio.Size = new System.Drawing.Size(339, 27); this.textBoxFio.TabIndex = 4; // // textBoxPassword // this.textBoxPassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxPassword.Location = new System.Drawing.Point(94, 38); + this.textBoxPassword.Location = new System.Drawing.Point(107, 51); + this.textBoxPassword.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.textBoxPassword.Name = "textBoxPassword"; this.textBoxPassword.PasswordChar = '*'; - this.textBoxPassword.Size = new System.Drawing.Size(297, 23); + this.textBoxPassword.Size = new System.Drawing.Size(339, 27); this.textBoxPassword.TabIndex = 5; // // buttonCancel // this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.Location = new System.Drawing.Point(302, 96); + this.buttonCancel.Location = new System.Drawing.Point(345, 128); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(89, 33); + this.buttonCancel.Size = new System.Drawing.Size(102, 44); this.buttonCancel.TabIndex = 8; this.buttonCancel.Text = "Отмена"; this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // // buttonSave // this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSave.Location = new System.Drawing.Point(207, 96); + this.buttonSave.Location = new System.Drawing.Point(237, 128); + this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(89, 33); + this.buttonSave.Size = new System.Drawing.Size(102, 44); this.buttonSave.TabIndex = 9; this.buttonSave.Text = "Сохранить"; this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); // // textBoxStage // this.textBoxStage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxStage.Location = new System.Drawing.Point(94, 67); + this.textBoxStage.Location = new System.Drawing.Point(107, 89); + this.textBoxStage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.textBoxStage.Name = "textBoxStage"; - this.textBoxStage.Size = new System.Drawing.Size(71, 23); + this.textBoxStage.Size = new System.Drawing.Size(81, 27); this.textBoxStage.TabIndex = 10; // // textBoxCval // this.textBoxCval.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxCval.Location = new System.Drawing.Point(275, 67); + this.textBoxCval.Location = new System.Drawing.Point(314, 89); + this.textBoxCval.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.textBoxCval.Name = "textBoxCval"; - this.textBoxCval.Size = new System.Drawing.Size(116, 23); + this.textBoxCval.Size = new System.Drawing.Size(132, 27); this.textBoxCval.TabIndex = 11; // // FormImplementer // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSize = true; - this.ClientSize = new System.Drawing.Size(403, 174); + this.ClientSize = new System.Drawing.Size(461, 232); this.Controls.Add(this.textBoxCval); this.Controls.Add(this.textBoxStage); this.Controls.Add(this.buttonSave); @@ -149,6 +157,7 @@ this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.label1); + this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.Name = "FormImplementer"; this.Text = "Исполнитель"; this.ResumeLayout(false); diff --git a/FishFactory/FishFactory/FormImplementer.cs b/FishFactory/FishFactory/FormImplementer.cs index 91b1f2e..0be8c4b 100644 --- a/FishFactory/FishFactory/FormImplementer.cs +++ b/FishFactory/FishFactory/FormImplementer.cs @@ -78,8 +78,8 @@ namespace FishFactoryView Id = _id ?? 0, ImplementerFIO = textBoxFio.Text, Password = textBoxPassword.Text, - Qualification = int.Parse(textBoxStage.Text), - WorkExperience = int.Parse(textBoxCval.Text), + WorkExperience = Convert.ToInt32(textBoxStage.Text), + Qualification = Convert.ToInt32(textBoxCval.Text), }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) diff --git a/FishFactory/FishFactory/FormImplementers.Designer.cs b/FishFactory/FishFactory/FormImplementers.Designer.cs index da7a465..0d5b67e 100644 --- a/FishFactory/FishFactory/FormImplementers.Designer.cs +++ b/FishFactory/FishFactory/FormImplementers.Designer.cs @@ -39,39 +39,46 @@ // buttonRef // this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRef.Location = new System.Drawing.Point(575, 127); + this.buttonRef.Location = new System.Drawing.Point(657, 169); + this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonRef.Name = "buttonRef"; - this.buttonRef.Size = new System.Drawing.Size(90, 37); + this.buttonRef.Size = new System.Drawing.Size(103, 49); this.buttonRef.TabIndex = 9; this.buttonRef.Text = "Обновить"; this.buttonRef.UseVisualStyleBackColor = true; + this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); // // buttonDel // this.buttonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDel.Location = new System.Drawing.Point(575, 88); + this.buttonDel.Location = new System.Drawing.Point(657, 117); + this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonDel.Name = "buttonDel"; - this.buttonDel.Size = new System.Drawing.Size(90, 33); + this.buttonDel.Size = new System.Drawing.Size(103, 44); this.buttonDel.TabIndex = 8; this.buttonDel.Text = "Удалить"; this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); // // buttonUpd // this.buttonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonUpd.Location = new System.Drawing.Point(575, 48); + this.buttonUpd.Location = new System.Drawing.Point(657, 64); + this.buttonUpd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonUpd.Name = "buttonUpd"; - this.buttonUpd.Size = new System.Drawing.Size(90, 34); + this.buttonUpd.Size = new System.Drawing.Size(103, 45); this.buttonUpd.TabIndex = 7; this.buttonUpd.Text = "Изменить"; this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); // // buttonAdd // this.buttonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonAdd.Location = new System.Drawing.Point(575, 12); + this.buttonAdd.Location = new System.Drawing.Point(657, 16); + this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonAdd.Name = "buttonAdd"; - this.buttonAdd.Size = new System.Drawing.Size(90, 30); + this.buttonAdd.Size = new System.Drawing.Size(103, 40); this.buttonAdd.TabIndex = 6; this.buttonAdd.Text = "Добавить"; this.buttonAdd.UseVisualStyleBackColor = true; @@ -83,22 +90,25 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(12, 12); + this.dataGridView.Location = new System.Drawing.Point(14, 16); + this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersWidth = 51; this.dataGridView.RowTemplate.Height = 25; - this.dataGridView.Size = new System.Drawing.Size(557, 302); + this.dataGridView.Size = new System.Drawing.Size(637, 403); this.dataGridView.TabIndex = 5; // // FormImplementers // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(677, 319); + this.ClientSize = new System.Drawing.Size(774, 425); this.Controls.Add(this.buttonRef); this.Controls.Add(this.buttonDel); this.Controls.Add(this.buttonUpd); this.Controls.Add(this.buttonAdd); this.Controls.Add(this.dataGridView); + this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.Name = "FormImplementers"; this.Text = "Исполнители"; this.Load += new System.EventHandler(this.FormImplementers_Load); diff --git a/FishFactory/FishFactory/FormMain.Designer.cs b/FishFactory/FishFactory/FormMain.Designer.cs index 35043d7..210a313 100644 --- a/FishFactory/FishFactory/FormMain.Designer.cs +++ b/FishFactory/FishFactory/FormMain.Designer.cs @@ -50,18 +50,20 @@ // dataGridView // this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(12, 32); + this.dataGridView.Location = new System.Drawing.Point(14, 43); + this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.dataGridView.Name = "dataGridView"; this.dataGridView.RowHeadersWidth = 51; this.dataGridView.RowTemplate.Height = 25; - this.dataGridView.Size = new System.Drawing.Size(768, 402); + this.dataGridView.Size = new System.Drawing.Size(988, 536); this.dataGridView.TabIndex = 0; // // ButtonCreateOrder // - this.ButtonCreateOrder.Location = new System.Drawing.Point(786, 32); + this.ButtonCreateOrder.Location = new System.Drawing.Point(1008, 43); + this.ButtonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.ButtonCreateOrder.Name = "ButtonCreateOrder"; - this.ButtonCreateOrder.Size = new System.Drawing.Size(186, 23); + this.ButtonCreateOrder.Size = new System.Drawing.Size(213, 31); this.ButtonCreateOrder.TabIndex = 1; this.ButtonCreateOrder.Text = "Создать заказ"; this.ButtonCreateOrder.UseVisualStyleBackColor = true; @@ -69,9 +71,10 @@ // // ButtonIssuedOrder // - this.ButtonIssuedOrder.Location = new System.Drawing.Point(786, 88); + this.ButtonIssuedOrder.Location = new System.Drawing.Point(1008, 117); + this.ButtonIssuedOrder.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.ButtonIssuedOrder.Name = "ButtonIssuedOrder"; - this.ButtonIssuedOrder.Size = new System.Drawing.Size(186, 23); + this.ButtonIssuedOrder.Size = new System.Drawing.Size(213, 31); this.ButtonIssuedOrder.TabIndex = 4; this.ButtonIssuedOrder.Text = "Заказ выдан"; this.ButtonIssuedOrder.UseVisualStyleBackColor = true; @@ -79,9 +82,10 @@ // // ButtonRef // - this.ButtonRef.Location = new System.Drawing.Point(786, 144); + this.ButtonRef.Location = new System.Drawing.Point(1008, 192); + this.ButtonRef.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.ButtonRef.Name = "ButtonRef"; - this.ButtonRef.Size = new System.Drawing.Size(186, 23); + this.ButtonRef.Size = new System.Drawing.Size(213, 31); this.ButtonRef.TabIndex = 5; this.ButtonRef.Text = "Обновить список"; this.ButtonRef.UseVisualStyleBackColor = true; @@ -93,20 +97,20 @@ this.компонентыToolStripMenuItem1, this.консервыToolStripMenuItem}); this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem"; - this.изделияToolStripMenuItem.Size = new System.Drawing.Size(94, 20); + this.изделияToolStripMenuItem.Size = new System.Drawing.Size(117, 24); this.изделияToolStripMenuItem.Text = "Справочники"; // // компонентыToolStripMenuItem1 // this.компонентыToolStripMenuItem1.Name = "компонентыToolStripMenuItem1"; - this.компонентыToolStripMenuItem1.Size = new System.Drawing.Size(145, 22); + this.компонентыToolStripMenuItem1.Size = new System.Drawing.Size(182, 26); this.компонентыToolStripMenuItem1.Text = "Компоненты"; this.компонентыToolStripMenuItem1.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click); // // консервыToolStripMenuItem // this.консервыToolStripMenuItem.Name = "консервыToolStripMenuItem"; - this.консервыToolStripMenuItem.Size = new System.Drawing.Size(145, 22); + this.консервыToolStripMenuItem.Size = new System.Drawing.Size(182, 26); this.консервыToolStripMenuItem.Text = "Консервы"; this.консервыToolStripMenuItem.Click += new System.EventHandler(this.КонсервыToolStripMenuItem_Click); // @@ -121,8 +125,8 @@ this.запускРаботToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2); - this.menuStrip1.Size = new System.Drawing.Size(978, 24); + this.menuStrip1.Padding = new System.Windows.Forms.Padding(6, 3, 0, 3); + this.menuStrip1.Size = new System.Drawing.Size(1233, 30); this.menuStrip1.TabIndex = 6; this.menuStrip1.Text = "menuStrip1"; // @@ -133,62 +137,63 @@ this.компонентыПоИзделиямToolStripMenuItem, this.списокЗаказовToolStripMenuItem}); this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; - this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20); + this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24); this.отчетыToolStripMenuItem.Text = "Отчеты"; // // списокКомпонентовToolStripMenuItem // this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; - this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(276, 26); this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов"; this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.списокКомпонентовToolStripMenuItem_Click_1); // // компонентыПоИзделиямToolStripMenuItem // this.компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; - this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(276, 26); this.компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; this.компонентыПоИзделиямToolStripMenuItem.Click += new System.EventHandler(this.компонентыПоИзделиямToolStripMenuItem_Click_1); // // списокЗаказовToolStripMenuItem // this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; - this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(276, 26); this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовToolStripMenuItem_Click_1); // // клиентыToolStripMenuItem // this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; - this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(67, 20); + this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(83, 24); this.клиентыToolStripMenuItem.Text = "Клиенты"; this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click); // // исполнителиToolStripMenuItem // this.исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem"; - this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(94, 20); + this.исполнителиToolStripMenuItem.Size = new System.Drawing.Size(116, 24); this.исполнителиToolStripMenuItem.Text = "Исполнители"; this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.исполнителиToolStripMenuItem_Click); // // запускРаботToolStripMenuItem // this.запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem"; - this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(92, 20); + this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(114, 24); this.запускРаботToolStripMenuItem.Text = "Запуск работ"; this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.запускРаботToolStripMenuItem_Click); // // FormMain // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(978, 446); + this.ClientSize = new System.Drawing.Size(1233, 595); this.Controls.Add(this.ButtonRef); this.Controls.Add(this.ButtonIssuedOrder); this.Controls.Add(this.ButtonCreateOrder); this.Controls.Add(this.dataGridView); this.Controls.Add(this.menuStrip1); this.MainMenuStrip = this.menuStrip1; + this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.Name = "FormMain"; this.Text = "Рыбный завод"; this.Load += new System.EventHandler(this.FormMain_Load); diff --git a/FishFactory/FishFactory/FormMain.cs b/FishFactory/FishFactory/FormMain.cs index 2360827..beee5cb 100644 --- a/FishFactory/FishFactory/FormMain.cs +++ b/FishFactory/FishFactory/FormMain.cs @@ -47,8 +47,10 @@ namespace FishFactoryView dataGridView.DataSource = list; dataGridView.Columns["CannedId"].Visible = false; dataGridView.Columns["ClientId"].Visible = false; + dataGridView.Columns["ImplementerId"].Visible = false; dataGridView.Columns["CannedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); } @@ -174,6 +176,7 @@ namespace FishFactoryView private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e) { _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic); + MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } diff --git a/FishFactory/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs b/FishFactory/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs index 5ca9656..fe058e9 100644 --- a/FishFactory/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/FishFactory/FishFactoryBusinessLogic/BusinessLogic/OrderLogic.cs @@ -52,6 +52,15 @@ namespace FishFactoryBusinessLogic.BusinessLogic return false; } model.Status = newStatus; + model.DateCreate = viewModel.DateCreate; + model.Sum = viewModel.Sum; + model.Count = viewModel.Count; + model.DateImplement = viewModel.DateImplement; + model.CannedId = viewModel.CannedId; + if (viewModel.ImplementerId.HasValue) + { + model.ImplementerId = viewModel.ImplementerId; + } if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); else { @@ -118,5 +127,21 @@ namespace FishFactoryBusinessLogic.BusinessLogic nameof(model.Sum)); } } + public OrderViewModel? ReadElement(OrderSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. Id:{ Id}", model.Id); + var element = _orderStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } } } diff --git a/FishFactory/FishFactoryBusinessLogic/BusinessLogic/WorkModeling.cs b/FishFactory/FishFactoryBusinessLogic/BusinessLogic/WorkModeling.cs index d751c9c..c363bb6 100644 --- a/FishFactory/FishFactoryBusinessLogic/BusinessLogic/WorkModeling.cs +++ b/FishFactory/FishFactoryBusinessLogic/BusinessLogic/WorkModeling.cs @@ -14,71 +14,80 @@ namespace FishFactoryBusinessLogic.BusinessLogic { public class WorkModeling : IWorkProcess { - private readonly ILogger _logger; + private readonly ILogger _logger; + private readonly Random _rnd; + private IOrderLogic? _orderLogic; + public WorkModeling(ILogger logger) { _logger = logger; _rnd = new Random(1000); } + public void DoWork(IImplementerLogic implementerLogic, IOrderLogic orderLogic) { _orderLogic = orderLogic; var implementers = implementerLogic.ReadList(null); + if (implementers == null) { _logger.LogWarning("DoWork. Implementers is null"); return; } + var orders = _orderLogic.ReadList(new OrderSearchModel { - /*Status = OrderStatus.Принят*/ + Status = OrderStatus.Принят }); + if (orders == null || orders.Count == 0) { _logger.LogWarning("DoWork. Orders is null or empty"); return; } + _logger.LogDebug("DoWork for {Count} orders", orders.Count); foreach (var implementer in implementers) { Task.Run(() => WorkerWorkAsync(implementer, orders)); } } - /// - /// Иммитация работы исполнителя - /// - /// - /// + + // Иммитация работы исполнителя private async Task WorkerWorkAsync(ImplementerViewModel implementer, List orders) { if (_orderLogic == null || implementer == null) { return; } + await RunOrderInWork(implementer); + await Task.Run(() => { foreach (var order in orders) { try { - _logger.LogDebug("DoWork. Worker {Id} try get order { Order}", implementer.Id, order.Id); + _logger.LogDebug("DoWork. Worker {Id} try get order {Order}", implementer.Id, order.Id); + // пытаемся назначить заказ на исполнителя _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = order.Id, ImplementerId = implementer.Id }); + // делаем работу - Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, - 1000) * order.Count); - _logger.LogDebug("DoWork. Worker {Id} finish order{ Order}", implementer.Id, order.Id); + Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count); + _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id); + _orderLogic.FinishOrder(new OrderBindingModel - { - Id = order.Id - }); + { + Id = order.Id, + }); } // кто-то мог уже перехватить заказ, игнорируем ошибку catch (InvalidOperationException ex) @@ -91,43 +100,48 @@ namespace FishFactoryBusinessLogic.BusinessLogic _logger.LogError(ex, "Error while do work"); throw; } + // отдыхаем Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); } }); } - /// - /// Ищем заказ, которые уже в работе (вдруг исполнителя прервали) - /// - /// - /// + + //Ищем заказ, которые уже в работе (вдруг исполнителя прервали) private async Task RunOrderInWork(ImplementerViewModel implementer) { if (_orderLogic == null || implementer == null) { return; } + try { - /*var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel + var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel { ImplementerId = implementer.Id, Status = OrderStatus.Выполняется })); + if (runOrder == null) { return; } + _logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, runOrder.Id); + // доделываем работу Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count); + _logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, runOrder.Id); + _orderLogic.FinishOrder(new OrderBindingModel { Id = runOrder.Id }); + // отдыхаем - Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));*/ + Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); } // заказа может не быть, просто игнорируем ошибку catch (InvalidOperationException ex) diff --git a/FishFactory/FishFactoryContracts/BusinessLogicsContracts/IOrderLogic.cs b/FishFactory/FishFactoryContracts/BusinessLogicsContracts/IOrderLogic.cs index 0bd427b..e5854fe 100644 --- a/FishFactory/FishFactoryContracts/BusinessLogicsContracts/IOrderLogic.cs +++ b/FishFactory/FishFactoryContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -16,5 +16,6 @@ namespace FishFactoryContracts.BusinessLogicsContracts bool TakeOrderInWork(OrderBindingModel model); bool FinishOrder(OrderBindingModel model); bool DeliveryOrder(OrderBindingModel model); + OrderViewModel? ReadElement(OrderSearchModel model); } } diff --git a/FishFactory/FishFactoryContracts/SearchModels/OrderSearchModel.cs b/FishFactory/FishFactoryContracts/SearchModels/OrderSearchModel.cs index 17ca48f..a9b781e 100644 --- a/FishFactory/FishFactoryContracts/SearchModels/OrderSearchModel.cs +++ b/FishFactory/FishFactoryContracts/SearchModels/OrderSearchModel.cs @@ -14,6 +14,6 @@ namespace FishFactoryContracts.SearchModels public DateTime? DateTo { get; set; } public int? ClientId { get; set; } public int? ImplementerId { get; set; } - public List? Statusses { get; set; } + public OrderStatus? Status { get; set; } } } diff --git a/FishFactory/FishFactoryDatabaseImplement/FishFactoryDatabase.cs b/FishFactory/FishFactoryDatabaseImplement/FishFactoryDatabase.cs index 242e900..907f7b0 100644 --- a/FishFactory/FishFactoryDatabaseImplement/FishFactoryDatabase.cs +++ b/FishFactory/FishFactoryDatabaseImplement/FishFactoryDatabase.cs @@ -15,7 +15,7 @@ namespace FishFactoryDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=FishFactoryLab51;Username=postgres;Password=postgres"); + optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=FishFactoryLab6;Username=postgres;Password=postgres"); } base.OnConfiguring(optionsBuilder); } diff --git a/FishFactory/FishFactoryDatabaseImplement/Implements/OrderStorage.cs b/FishFactory/FishFactoryDatabaseImplement/Implements/OrderStorage.cs index 91ac6ed..6e2ffff 100644 --- a/FishFactory/FishFactoryDatabaseImplement/Implements/OrderStorage.cs +++ b/FishFactory/FishFactoryDatabaseImplement/Implements/OrderStorage.cs @@ -22,6 +22,8 @@ namespace FishFactoryDatabaseImplement.Implements { var deletedElement = context.Orders .Include(x => x.Canned) + .Include(x => x.Client) + .Include(x => x.Implementer) .FirstOrDefault(x => x.Id == model.Id) ?.GetViewModel; context.Orders.Remove(element); @@ -43,7 +45,10 @@ namespace FishFactoryDatabaseImplement.Implements return context.Orders .Include(x => x.Canned) .Include(x => x.Client) - .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) + .Include(x => x.Implementer) + .FirstOrDefault(x => (model.Status == null || model.Status != null && model.Status == x.Status) && + model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId || + model.Id.HasValue && x.Id == model.Id) ?.GetViewModel; } @@ -55,6 +60,7 @@ namespace FishFactoryDatabaseImplement.Implements return context.Orders .Include(x => x.Canned) .Include(x => x.Client) + .Include(x => x.Implementer) .Where(x => x.Id == model.Id) .Select(x => x.GetViewModel) .ToList(); @@ -64,6 +70,7 @@ namespace FishFactoryDatabaseImplement.Implements return context.Orders .Include(x => x.Canned) .Include(x => x.Client) + .Include(x => x.Implementer) .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) .Select(x => x.GetViewModel) .ToList(); @@ -73,14 +80,28 @@ namespace FishFactoryDatabaseImplement.Implements return context.Orders .Include(x => x.Canned) .Include(x => x.Client) + .Include(x => x.Implementer) .Where(x => x.ClientId == model.ClientId) .Select(x => x.GetViewModel) .ToList(); } - else + else if (model.ImplementerId.HasValue) { - return new(); + return context.Orders + .Include(x => x.Canned) + .Include(x => x.Client) + .Include(x => x.Implementer) + .Where(x => x.ImplementerId == model.ImplementerId) + .Select(x => x.GetViewModel) + .ToList(); } + return context.Orders + .Include(x => x.Canned) + .Include(x => x.Client) + .Include(x => x.Implementer) + .Where(x => model.Status == x.Status) + .Select(x => x.GetViewModel) + .ToList(); } public List GetFullList() @@ -89,6 +110,7 @@ namespace FishFactoryDatabaseImplement.Implements return context.Orders .Include(x => x.Canned) .Include(x => x.Client) + .Include(x => x.Implementer) .Select(x => x.GetViewModel) .ToList(); } @@ -106,6 +128,7 @@ namespace FishFactoryDatabaseImplement.Implements return context.Orders .Include(x => x.Canned) .Include(x => x.Client) + .Include(x => x.Implementer) .FirstOrDefault(x => x.Id == newOrder.Id) ?.GetViewModel; } @@ -125,6 +148,7 @@ namespace FishFactoryDatabaseImplement.Implements return context.Orders .Include(x => x.Canned) .Include(x => x.Client) + .Include(x => x.Implementer) .FirstOrDefault(x => x.Id == model.Id) ?.GetViewModel; } diff --git a/FishFactory/FishFactoryDatabaseImplement/Migrations/20230410133743_Init.Designer.cs b/FishFactory/FishFactoryDatabaseImplement/Migrations/20230411050354_Init.Designer.cs similarity index 81% rename from FishFactory/FishFactoryDatabaseImplement/Migrations/20230410133743_Init.Designer.cs rename to FishFactory/FishFactoryDatabaseImplement/Migrations/20230411050354_Init.Designer.cs index 551eb0c..fbc3d34 100644 --- a/FishFactory/FishFactoryDatabaseImplement/Migrations/20230410133743_Init.Designer.cs +++ b/FishFactory/FishFactoryDatabaseImplement/Migrations/20230411050354_Init.Designer.cs @@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace FishFactoryDatabaseImplement.Migrations { [DbContext(typeof(FishFactoryDatabase))] - [Migration("20230410133743_Init")] + [Migration("20230411050354_Init")] partial class Init { /// @@ -116,6 +116,33 @@ namespace FishFactoryDatabaseImplement.Migrations b.ToTable("Components"); }); + modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Qualification") + .HasColumnType("integer"); + + b.Property("WorkExperience") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b => { b.Property("Id") @@ -139,6 +166,10 @@ namespace FishFactoryDatabaseImplement.Migrations b.Property("DateImplement") .HasColumnType("timestamp with time zone"); + b.Property("ImplementerId") + .IsRequired() + .HasColumnType("integer"); + b.Property("Status") .HasColumnType("integer"); @@ -151,6 +182,8 @@ namespace FishFactoryDatabaseImplement.Migrations b.HasIndex("ClientId"); + b.HasIndex("ImplementerId"); + b.ToTable("Orders"); }); @@ -187,9 +220,17 @@ namespace FishFactoryDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("FishFactoryDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.Navigation("Canned"); b.Navigation("Client"); + + b.Navigation("Implementer"); }); modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b => @@ -208,6 +249,11 @@ namespace FishFactoryDatabaseImplement.Migrations { b.Navigation("CannedComponents"); }); + + modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); #pragma warning restore 612, 618 } } diff --git a/FishFactory/FishFactoryDatabaseImplement/Migrations/20230410133743_Init.cs b/FishFactory/FishFactoryDatabaseImplement/Migrations/20230411050354_Init.cs similarity index 81% rename from FishFactory/FishFactoryDatabaseImplement/Migrations/20230410133743_Init.cs rename to FishFactory/FishFactoryDatabaseImplement/Migrations/20230411050354_Init.cs index 7d6f011..f03d01b 100644 --- a/FishFactory/FishFactoryDatabaseImplement/Migrations/20230410133743_Init.cs +++ b/FishFactory/FishFactoryDatabaseImplement/Migrations/20230411050354_Init.cs @@ -56,34 +56,19 @@ namespace FishFactoryDatabaseImplement.Migrations }); migrationBuilder.CreateTable( - name: "Orders", + name: "Implementers", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - CannedId = table.Column(type: "integer", nullable: false), - ClientId = table.Column(type: "integer", nullable: false), - Count = table.Column(type: "integer", nullable: false), - Sum = table.Column(type: "double precision", nullable: false), - Status = table.Column(type: "integer", nullable: false), - DateCreate = table.Column(type: "timestamp with time zone", nullable: false), - DateImplement = table.Column(type: "timestamp with time zone", nullable: true) + ImplementerFIO = table.Column(type: "text", nullable: false), + Password = table.Column(type: "text", nullable: false), + WorkExperience = table.Column(type: "integer", nullable: false), + Qualification = table.Column(type: "integer", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_Orders", x => x.Id); - table.ForeignKey( - name: "FK_Orders_Canneds_CannedId", - column: x => x.CannedId, - principalTable: "Canneds", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Orders_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + table.PrimaryKey("PK_Implementers", x => x.Id); }); migrationBuilder.CreateTable( @@ -113,6 +98,44 @@ namespace FishFactoryDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "Orders", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CannedId = table.Column(type: "integer", nullable: false), + ClientId = table.Column(type: "integer", nullable: false), + ImplementerId = table.Column(type: "integer", nullable: false), + Count = table.Column(type: "integer", nullable: false), + Sum = table.Column(type: "double precision", nullable: false), + Status = table.Column(type: "integer", nullable: false), + DateCreate = table.Column(type: "timestamp with time zone", nullable: false), + DateImplement = table.Column(type: "timestamp with time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Orders", x => x.Id); + table.ForeignKey( + name: "FK_Orders_Canneds_CannedId", + column: x => x.CannedId, + principalTable: "Canneds", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Orders_Clients_ClientId", + column: x => x.ClientId, + principalTable: "Clients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + column: x => x.ImplementerId, + principalTable: "Implementers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateIndex( name: "IX_CannedComponents_CannedId", table: "CannedComponents", @@ -132,6 +155,11 @@ namespace FishFactoryDatabaseImplement.Migrations name: "IX_Orders_ClientId", table: "Orders", column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_Orders_ImplementerId", + table: "Orders", + column: "ImplementerId"); } /// @@ -151,6 +179,9 @@ namespace FishFactoryDatabaseImplement.Migrations migrationBuilder.DropTable( name: "Clients"); + + migrationBuilder.DropTable( + name: "Implementers"); } } } diff --git a/FishFactory/FishFactoryDatabaseImplement/Migrations/FishFactoryDatabaseModelSnapshot.cs b/FishFactory/FishFactoryDatabaseImplement/Migrations/FishFactoryDatabaseModelSnapshot.cs index a32e0af..d21a62f 100644 --- a/FishFactory/FishFactoryDatabaseImplement/Migrations/FishFactoryDatabaseModelSnapshot.cs +++ b/FishFactory/FishFactoryDatabaseImplement/Migrations/FishFactoryDatabaseModelSnapshot.cs @@ -113,6 +113,33 @@ namespace FishFactoryDatabaseImplement.Migrations b.ToTable("Components"); }); + modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Qualification") + .HasColumnType("integer"); + + b.Property("WorkExperience") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Order", b => { b.Property("Id") @@ -136,6 +163,10 @@ namespace FishFactoryDatabaseImplement.Migrations b.Property("DateImplement") .HasColumnType("timestamp with time zone"); + b.Property("ImplementerId") + .IsRequired() + .HasColumnType("integer"); + b.Property("Status") .HasColumnType("integer"); @@ -148,6 +179,8 @@ namespace FishFactoryDatabaseImplement.Migrations b.HasIndex("ClientId"); + b.HasIndex("ImplementerId"); + b.ToTable("Orders"); }); @@ -184,9 +217,17 @@ namespace FishFactoryDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("FishFactoryDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.Navigation("Canned"); b.Navigation("Client"); + + b.Navigation("Implementer"); }); modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b => @@ -205,6 +246,11 @@ namespace FishFactoryDatabaseImplement.Migrations { b.Navigation("CannedComponents"); }); + + modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); #pragma warning restore 612, 618 } }