diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.Designer.cs new file mode 100644 index 0000000..74c7f79 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.Designer.cs @@ -0,0 +1,165 @@ +namespace BlacksmithWorkshopView +{ + partial class FormImplementer + { + /// + /// 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.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.labelQualification = new System.Windows.Forms.Label(); + this.labelWorkExperience = new System.Windows.Forms.Label(); + this.labelPassword = new System.Windows.Forms.Label(); + this.labelName = new System.Windows.Forms.Label(); + this.textBoxQualification = new System.Windows.Forms.TextBox(); + this.textBoxWorkExperience = new System.Windows.Forms.TextBox(); + this.textBoxPassword = new System.Windows.Forms.TextBox(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // 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(249, 122); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 11; + 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(168, 122); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(75, 23); + this.buttonSave.TabIndex = 12; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // labelQualification + // + this.labelQualification.AutoSize = true; + this.labelQualification.Location = new System.Drawing.Point(12, 96); + this.labelQualification.Name = "labelQualification"; + this.labelQualification.Size = new System.Drawing.Size(88, 15); + this.labelQualification.TabIndex = 7; + this.labelQualification.Text = "Квалификация"; + // + // labelWorkExperience + // + this.labelWorkExperience.AutoSize = true; + this.labelWorkExperience.Location = new System.Drawing.Point(12, 67); + this.labelWorkExperience.Name = "labelWorkExperience"; + this.labelWorkExperience.Size = new System.Drawing.Size(37, 15); + this.labelWorkExperience.TabIndex = 8; + this.labelWorkExperience.Text = "Опыт"; + // + // labelPassword + // + this.labelPassword.AutoSize = true; + this.labelPassword.Location = new System.Drawing.Point(12, 38); + this.labelPassword.Name = "labelPassword"; + this.labelPassword.Size = new System.Drawing.Size(49, 15); + this.labelPassword.TabIndex = 9; + this.labelPassword.Text = "Пароль"; + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(12, 9); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(34, 15); + this.labelName.TabIndex = 10; + this.labelName.Text = "ФИО"; + // + // textBoxQualification + // + this.textBoxQualification.Location = new System.Drawing.Point(106, 93); + this.textBoxQualification.Name = "textBoxQualification"; + this.textBoxQualification.Size = new System.Drawing.Size(218, 23); + this.textBoxQualification.TabIndex = 3; + // + // textBoxWorkExperience + // + this.textBoxWorkExperience.Location = new System.Drawing.Point(106, 64); + this.textBoxWorkExperience.Name = "textBoxWorkExperience"; + this.textBoxWorkExperience.Size = new System.Drawing.Size(218, 23); + this.textBoxWorkExperience.TabIndex = 4; + // + // textBoxPassword + // + this.textBoxPassword.Location = new System.Drawing.Point(106, 35); + this.textBoxPassword.Name = "textBoxPassword"; + this.textBoxPassword.Size = new System.Drawing.Size(218, 23); + this.textBoxPassword.TabIndex = 5; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(106, 6); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(218, 23); + this.textBoxName.TabIndex = 6; + // + // FormImplementer + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(337, 167); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.labelQualification); + this.Controls.Add(this.labelWorkExperience); + this.Controls.Add(this.labelPassword); + this.Controls.Add(this.labelName); + this.Controls.Add(this.textBoxQualification); + this.Controls.Add(this.textBoxWorkExperience); + this.Controls.Add(this.textBoxPassword); + this.Controls.Add(this.textBoxName); + this.Name = "FormImplementer"; + this.Text = "Исполнитель"; + this.Load += new System.EventHandler(this.FormImplementer_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button buttonCancel; + private Button buttonSave; + private Label labelQualification; + private Label labelWorkExperience; + private Label labelPassword; + private Label labelName; + private TextBox textBoxQualification; + private TextBox textBoxWorkExperience; + private TextBox textBoxPassword; + private TextBox textBoxName; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.cs new file mode 100644 index 0000000..b338381 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.cs @@ -0,0 +1,87 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicContracts; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopContracts.SearchModels; +using Microsoft.Extensions.Logging; + +namespace BlacksmithWorkshopView +{ + public partial class FormImplementer : Form + { + private readonly ILogger _logger; + private readonly IImplementerLogic _implementerLogic; + private int? _id; + public int Id { set { _id = value; } } + public FormImplementer(ILogger logger, IImplementerLogic implementerLogic) + { + InitializeComponent(); + _logger = logger; + _implementerLogic = implementerLogic; + } + private void FormImplementer_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение сотрудника"); + var view = _implementerLogic.ReadElement(new ImplementerSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.ImplementerFIO; + textBoxPassword.Text = view.Password; + textBoxQualification.Text = view.Qualification.ToString(); + textBoxWorkExperience.Text = view.WorkExperience.ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения сотрудника"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение сотрудника"); + try + { + var model = new ImplementerBindingModel() + { + Id = _id ?? 0, + ImplementerFIO = textBoxName.Text, + Password = textBoxPassword.Text, + Qualification = Convert.ToInt32(textBoxQualification.Text), + WorkExperience = Convert.ToInt32(textBoxWorkExperience.Text) + }; + var operationResult = _id.HasValue ? _implementerLogic.Update(model) : _implementerLogic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения сотрудника"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.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/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.Designer.cs new file mode 100644 index 0000000..eeb564a --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.Designer.cs @@ -0,0 +1,115 @@ +namespace BlacksmithWorkshopView +{ + partial class FormImplementers + { + /// + /// 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() + { + System.Windows.Forms.Button buttonRef; + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + buttonRef = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // buttonRef + // + buttonRef.Location = new System.Drawing.Point(620, 99); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new System.Drawing.Size(174, 23); + buttonRef.TabIndex = 3; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDel + // + this.buttonDel.Location = new System.Drawing.Point(620, 70); + this.buttonDel.Name = "buttonDel"; + this.buttonDel.Size = new System.Drawing.Size(174, 23); + this.buttonDel.TabIndex = 4; + this.buttonDel.Text = "Удалить"; + this.buttonDel.UseVisualStyleBackColor = true; + this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonUpd + // + this.buttonUpd.Location = new System.Drawing.Point(620, 41); + this.buttonUpd.Name = "buttonUpd"; + this.buttonUpd.Size = new System.Drawing.Size(174, 23); + this.buttonUpd.TabIndex = 5; + this.buttonUpd.Text = "Изменить"; + this.buttonUpd.UseVisualStyleBackColor = true; + this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(620, 12); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(174, 23); + this.buttonAdd.TabIndex = 6; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridView + // + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(6, 0); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(608, 450); + this.dataGridView.TabIndex = 2; + // + // FormImplementers + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(buttonRef); + this.Controls.Add(this.buttonDel); + this.Controls.Add(this.buttonUpd); + this.Controls.Add(this.buttonAdd); + this.Controls.Add(this.dataGridView); + this.Name = "FormImplementers"; + this.Text = "Сотрудники"; + this.Load += new System.EventHandler(this.FormImplementers_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.cs new file mode 100644 index 0000000..ca1e4c3 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.cs @@ -0,0 +1,98 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +namespace BlacksmithWorkshopView +{ + public partial class FormImplementers : Form + { + IImplementerLogic _implementerLogic; + ILogger _logger; + public FormImplementers(IImplementerLogic implementerLogic, ILogger logger) + { + _implementerLogic= implementerLogic; + _logger = logger; + InitializeComponent(); + } + private void FormImplementers_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _implementerLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + //dataGridView.Columns["Id"].Visible = false; + //dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка сотрудников"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки сотрудников"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); + if (service is FormImplementer form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormImplementer)); + if (service is FormImplementer form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление сотрудника"); + try + { + if (!_implementerLogic.Delete(new ImplementerBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления сотрудника"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.resx new file mode 100644 index 0000000..fa1d9b6 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.resx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + False + + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs index b761df5..892e72d 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs @@ -33,14 +33,14 @@ this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.manufacturesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.clientsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.implementersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.reportsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.reportComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.reportManufactureComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.reportOrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.doWorkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dataGridView = new System.Windows.Forms.DataGridView(); this.buttonCreateOrder = new System.Windows.Forms.Button(); - this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); - this.buttonOrderReady = new System.Windows.Forms.Button(); this.buttonIssuedOrder = new System.Windows.Forms.Button(); this.buttonRef = new System.Windows.Forms.Button(); this.menuStrip.SuspendLayout(); @@ -51,10 +51,11 @@ // this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.refbooksToolStripMenuItem, - this.reportsToolStripMenuItem}); + this.reportsToolStripMenuItem, + this.doWorkToolStripMenuItem}); this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.Name = "menuStrip"; - this.menuStrip.Size = new System.Drawing.Size(1294, 24); + this.menuStrip.Size = new System.Drawing.Size(1795, 24); this.menuStrip.TabIndex = 0; this.menuStrip.Text = "menuStrip1"; // @@ -63,7 +64,8 @@ this.refbooksToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.componentsToolStripMenuItem, this.manufacturesToolStripMenuItem, - this.clientsToolStripMenuItem}); + this.clientsToolStripMenuItem, + this.implementersToolStripMenuItem}); this.refbooksToolStripMenuItem.Name = "refbooksToolStripMenuItem"; this.refbooksToolStripMenuItem.Size = new System.Drawing.Size(94, 20); this.refbooksToolStripMenuItem.Text = "Справочники"; @@ -71,24 +73,31 @@ // componentsToolStripMenuItem // this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; - this.componentsToolStripMenuItem.Size = new System.Drawing.Size(145, 22); + this.componentsToolStripMenuItem.Size = new System.Drawing.Size(149, 22); this.componentsToolStripMenuItem.Text = "Компоненты"; this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); // // manufacturesToolStripMenuItem // this.manufacturesToolStripMenuItem.Name = "manufacturesToolStripMenuItem"; - this.manufacturesToolStripMenuItem.Size = new System.Drawing.Size(145, 22); + this.manufacturesToolStripMenuItem.Size = new System.Drawing.Size(149, 22); this.manufacturesToolStripMenuItem.Text = "Изделия"; this.manufacturesToolStripMenuItem.Click += new System.EventHandler(this.ManufacturesToolStripMenuItem_Click); // // clientsToolStripMenuItem // this.clientsToolStripMenuItem.Name = "clientsToolStripMenuItem"; - this.clientsToolStripMenuItem.Size = new System.Drawing.Size(145, 22); + this.clientsToolStripMenuItem.Size = new System.Drawing.Size(149, 22); this.clientsToolStripMenuItem.Text = "Клиенты"; this.clientsToolStripMenuItem.Click += new System.EventHandler(this.ClientsToolStripMenuItem_Click); // + // implementersToolStripMenuItem + // + this.implementersToolStripMenuItem.Name = "implementersToolStripMenuItem"; + this.implementersToolStripMenuItem.Size = new System.Drawing.Size(149, 22); + this.implementersToolStripMenuItem.Text = "Исполнители"; + this.implementersToolStripMenuItem.Click += new System.EventHandler(this.ImplementersToolStripMenuItem_Click); + // // reportsToolStripMenuItem // this.reportsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -120,6 +129,13 @@ this.reportOrdersToolStripMenuItem.Text = "Список заказов"; this.reportOrdersToolStripMenuItem.Click += new System.EventHandler(this.ReportOrdersToolStripMenuItem_Click); // + // doWorkToolStripMenuItem + // + this.doWorkToolStripMenuItem.Name = "doWorkToolStripMenuItem"; + this.doWorkToolStripMenuItem.Size = new System.Drawing.Size(92, 20); + this.doWorkToolStripMenuItem.Text = "Запуск работ"; + this.doWorkToolStripMenuItem.Click += new System.EventHandler(this.DoWorkToolStripMenuItem_Click); + // // dataGridView // this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; @@ -127,12 +143,12 @@ this.dataGridView.Location = new System.Drawing.Point(12, 27); this.dataGridView.Name = "dataGridView"; this.dataGridView.RowTemplate.Height = 25; - this.dataGridView.Size = new System.Drawing.Size(981, 456); + this.dataGridView.Size = new System.Drawing.Size(1482, 456); this.dataGridView.TabIndex = 1; // // buttonCreateOrder // - this.buttonCreateOrder.Location = new System.Drawing.Point(999, 27); + this.buttonCreateOrder.Location = new System.Drawing.Point(1500, 27); this.buttonCreateOrder.Name = "buttonCreateOrder"; this.buttonCreateOrder.RightToLeft = System.Windows.Forms.RightToLeft.No; this.buttonCreateOrder.Size = new System.Drawing.Size(283, 23); @@ -141,31 +157,9 @@ this.buttonCreateOrder.UseVisualStyleBackColor = true; this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); // - // buttonTakeOrderInWork - // - this.buttonTakeOrderInWork.Location = new System.Drawing.Point(999, 56); - this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - this.buttonTakeOrderInWork.RightToLeft = System.Windows.Forms.RightToLeft.No; - this.buttonTakeOrderInWork.Size = new System.Drawing.Size(283, 23); - this.buttonTakeOrderInWork.TabIndex = 2; - this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; - this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; - this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); - // - // buttonOrderReady - // - this.buttonOrderReady.Location = new System.Drawing.Point(999, 85); - this.buttonOrderReady.Name = "buttonOrderReady"; - this.buttonOrderReady.RightToLeft = System.Windows.Forms.RightToLeft.No; - this.buttonOrderReady.Size = new System.Drawing.Size(283, 23); - this.buttonOrderReady.TabIndex = 2; - this.buttonOrderReady.Text = "Заказ готов"; - this.buttonOrderReady.UseVisualStyleBackColor = true; - this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); - // // buttonIssuedOrder // - this.buttonIssuedOrder.Location = new System.Drawing.Point(1000, 114); + this.buttonIssuedOrder.Location = new System.Drawing.Point(1500, 56); this.buttonIssuedOrder.Name = "buttonIssuedOrder"; this.buttonIssuedOrder.RightToLeft = System.Windows.Forms.RightToLeft.No; this.buttonIssuedOrder.Size = new System.Drawing.Size(283, 23); @@ -176,7 +170,7 @@ // // buttonRef // - this.buttonRef.Location = new System.Drawing.Point(999, 143); + this.buttonRef.Location = new System.Drawing.Point(1499, 85); this.buttonRef.Name = "buttonRef"; this.buttonRef.RightToLeft = System.Windows.Forms.RightToLeft.No; this.buttonRef.Size = new System.Drawing.Size(283, 23); @@ -189,11 +183,9 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1294, 504); + this.ClientSize = new System.Drawing.Size(1795, 504); this.Controls.Add(this.buttonRef); this.Controls.Add(this.buttonIssuedOrder); - this.Controls.Add(this.buttonOrderReady); - this.Controls.Add(this.buttonTakeOrderInWork); this.Controls.Add(this.buttonCreateOrder); this.Controls.Add(this.dataGridView); this.Controls.Add(this.menuStrip); @@ -217,8 +209,6 @@ private ToolStripMenuItem manufacturesToolStripMenuItem; private DataGridView dataGridView; private Button buttonCreateOrder; - private Button buttonTakeOrderInWork; - private Button buttonOrderReady; private Button buttonIssuedOrder; private Button buttonRef; private ToolStripMenuItem reportsToolStripMenuItem; @@ -226,5 +216,7 @@ private ToolStripMenuItem reportManufactureComponentsToolStripMenuItem; private ToolStripMenuItem reportOrdersToolStripMenuItem; private ToolStripMenuItem clientsToolStripMenuItem; - } + private ToolStripMenuItem implementersToolStripMenuItem; + private ToolStripMenuItem doWorkToolStripMenuItem; + } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs index 226a780..6d248c0 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs @@ -11,12 +11,16 @@ namespace BlacksmithWorkshopView private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; private readonly IReportLogic _reportLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) + private readonly IImplementerLogic _implementerLogic; + private readonly IWorkProcess _workProcess; + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IImplementerLogic implementerLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; _reportLogic = reportLogic; + _workProcess = workProcess; + _implementerLogic = implementerLogic; } private void FormMain_Load(object sender, EventArgs e) { @@ -32,8 +36,9 @@ namespace BlacksmithWorkshopView { dataGridView.DataSource = list; dataGridView.Columns["ManufactureId"].Visible = false; - dataGridView.Columns["ClientId"].Visible = false; - dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ImplementerId"].Visible = false; + dataGridView.Columns["ClientId"].Visible = false; + dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } catch (Exception ex) @@ -186,5 +191,18 @@ namespace BlacksmithWorkshopView LoadData(); } } - } + private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormImplementers)); + if (service is FormImplementers form) + { + form.ShowDialog(); + LoadData(); + } + } + private void DoWorkToolStripMenuItem_Click(object sender, EventArgs e) + { + _workProcess.DoWork(_implementerLogic, _orderLogic); + } + } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs index 83c781a..83f6bd9 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs @@ -38,12 +38,15 @@ namespace BlacksmithWorkshopView services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -56,6 +59,8 @@ namespace BlacksmithWorkshopView services.AddTransient(); services.AddTransient(); services.AddTransient(); - } + services.AddTransient(); + services.AddTransient(); + } } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/WorkModeling.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/WorkModeling.cs index 452a88f..46f7f9a 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/WorkModeling.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/WorkModeling.cs @@ -22,7 +22,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics { _orderLogic = orderLogic; var implementers = implementerLogic.ReadList(null); - if (implementers == null) + if (implementers == null || implementers.Count == 0) { _logger.LogWarning("DoWork. Implementers is null"); return; diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatebaseImplement/Implements/OrderStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatebaseImplement/Implements/OrderStorage.cs index 1fcfa75..71e12f7 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatebaseImplement/Implements/OrderStorage.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatebaseImplement/Implements/OrderStorage.cs @@ -27,10 +27,6 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements } public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue && !model.ClientId.HasValue && (!model.DateFrom.HasValue || !model.DateTo.HasValue)) - { - return new(); - } using var context = new BlacksmithWorkshopDatabase(); List orderList = new(); if (model.Id.HasValue) //сначала ищем по Id diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatebaseImplement/Migrations/20230425172721_AddingImplementerMigration.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatebaseImplement/Migrations/20230425172721_AddingImplementerMigration.Designer.cs new file mode 100644 index 0000000..f58564a --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatebaseImplement/Migrations/20230425172721_AddingImplementerMigration.Designer.cs @@ -0,0 +1,255 @@ +// +using System; +using BlacksmithWorkshopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BlacksmithWorkshopDatebaseImplement.Migrations +{ + [DbContext(typeof(BlacksmithWorkshopDatabase))] + [Migration("20230425172721_AddingImplementerMigration")] + partial class AddingImplementerMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Component", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ComponentName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Cost") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Components"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ManufactureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Manufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureComponent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ComponentId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ComponentId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("ManufactureComponents"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ImplementerId") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("ManufactureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureComponent", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Component", "Component") + .WithMany("ManufactureComponents") + .HasForeignKey("ComponentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("Components") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Component"); + + b.Navigation("Manufacture"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", null) + .WithMany("Orders") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Component", b => + { + b.Navigation("ManufactureComponents"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => + { + b.Navigation("Components"); + + b.Navigation("Orders"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatebaseImplement/Migrations/20230425172721_AddingImplementerMigration.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatebaseImplement/Migrations/20230425172721_AddingImplementerMigration.cs new file mode 100644 index 0000000..6e9e434 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatebaseImplement/Migrations/20230425172721_AddingImplementerMigration.cs @@ -0,0 +1,67 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BlacksmithWorkshopDatebaseImplement.Migrations +{ + /// + public partial class AddingImplementerMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ImplementerId", + table: "Orders", + type: "int", + nullable: true); + + migrationBuilder.CreateTable( + name: "Implementers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false), + WorkExperience = table.Column(type: "int", nullable: false), + Qualification = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Implementers", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_Orders_ImplementerId", + table: "Orders", + column: "ImplementerId"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders", + column: "ImplementerId", + principalTable: "Implementers", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders"); + + migrationBuilder.DropTable( + name: "Implementers"); + + migrationBuilder.DropIndex( + name: "IX_Orders_ImplementerId", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "ImplementerId", + table: "Orders"); + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatebaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatebaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs index e82000e..bc3bddb 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatebaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatebaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs @@ -67,6 +67,33 @@ namespace BlacksmithWorkshopDatebaseImplement.Migrations b.ToTable("Components"); }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => { b.Property("Id") @@ -133,6 +160,9 @@ namespace BlacksmithWorkshopDatebaseImplement.Migrations b.Property("DateImplement") .HasColumnType("datetime2"); + b.Property("ImplementerId") + .HasColumnType("int"); + b.Property("ManufactureId") .HasColumnType("int"); @@ -146,6 +176,8 @@ namespace BlacksmithWorkshopDatebaseImplement.Migrations b.HasIndex("ClientId"); + b.HasIndex("ImplementerId"); + b.HasIndex("ManufactureId"); b.ToTable("Orders"); @@ -178,6 +210,10 @@ namespace BlacksmithWorkshopDatebaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", null) .WithMany("Orders") .HasForeignKey("ManufactureId") @@ -185,6 +221,8 @@ namespace BlacksmithWorkshopDatebaseImplement.Migrations .IsRequired(); b.Navigation("Client"); + + b.Navigation("Implementer"); }); modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b => @@ -197,6 +235,11 @@ namespace BlacksmithWorkshopDatebaseImplement.Migrations b.Navigation("ManufactureComponents"); }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b => { b.Navigation("Components"); diff --git a/BlacksmithWorkshop/BlacksmithWorkshopRestAPI/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshopRestAPI/Program.cs index 9f3d78b..663ba2b 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopRestAPI/Program.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopRestAPI/Program.cs @@ -16,10 +16,12 @@ builder.Logging.AddLog4Net("log4net.config"); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle