diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.Designer.cs new file mode 100644 index 0000000..961876b --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.Designer.cs @@ -0,0 +1,161 @@ +namespace BlacksmithWorkshop +{ + 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() + { + labelFIO = new Label(); + labelPassword = new Label(); + labelWorkExperience = new Label(); + labelQualification = new Label(); + textBoxImplementerFIO = new TextBox(); + textBoxPassword = new TextBox(); + textBoxWorkExperience = new TextBox(); + textBoxQualification = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelFIO + // + labelFIO.AutoSize = true; + labelFIO.Location = new Point(38, 27); + labelFIO.Name = "labelFIO"; + labelFIO.Size = new Size(45, 20); + labelFIO.TabIndex = 0; + labelFIO.Text = "ФИО:"; + // + // labelPassword + // + labelPassword.AutoSize = true; + labelPassword.Location = new Point(38, 79); + labelPassword.Name = "labelPassword"; + labelPassword.Size = new Size(65, 20); + labelPassword.TabIndex = 1; + labelPassword.Text = "Пароль:"; + // + // labelWorkExperience + // + labelWorkExperience.AutoSize = true; + labelWorkExperience.Location = new Point(38, 136); + labelWorkExperience.Name = "labelWorkExperience"; + labelWorkExperience.Size = new Size(102, 20); + labelWorkExperience.TabIndex = 2; + labelWorkExperience.Text = "Стаж работы:"; + // + // labelQualification + // + labelQualification.AutoSize = true; + labelQualification.Location = new Point(319, 136); + labelQualification.Name = "labelQualification"; + labelQualification.Size = new Size(114, 20); + labelQualification.TabIndex = 3; + labelQualification.Text = "Квалификация:"; + // + // textBoxImplementerFIO + // + textBoxImplementerFIO.Location = new Point(160, 24); + textBoxImplementerFIO.Name = "textBoxImplementerFIO"; + textBoxImplementerFIO.Size = new Size(436, 27); + textBoxImplementerFIO.TabIndex = 4; + // + // textBoxPassword + // + textBoxPassword.Location = new Point(160, 76); + textBoxPassword.Name = "textBoxPassword"; + textBoxPassword.Size = new Size(436, 27); + textBoxPassword.TabIndex = 5; + // + // textBoxWorkExperience + // + textBoxWorkExperience.Location = new Point(160, 133); + textBoxWorkExperience.Name = "textBoxWorkExperience"; + textBoxWorkExperience.Size = new Size(126, 27); + textBoxWorkExperience.TabIndex = 6; + // + // textBoxQualification + // + textBoxQualification.Location = new Point(444, 133); + textBoxQualification.Name = "textBoxQualification"; + textBoxQualification.Size = new Size(152, 27); + textBoxQualification.TabIndex = 7; + // + // buttonSave + // + buttonSave.Location = new Point(387, 178); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 8; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(502, 178); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 9; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormImplementer + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(662, 224); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxQualification); + Controls.Add(textBoxWorkExperience); + Controls.Add(textBoxPassword); + Controls.Add(textBoxImplementerFIO); + Controls.Add(labelQualification); + Controls.Add(labelWorkExperience); + Controls.Add(labelPassword); + Controls.Add(labelFIO); + Name = "FormImplementer"; + Text = "Исполнитель"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelFIO; + private Label labelPassword; + private Label labelWorkExperience; + private Label labelQualification; + private TextBox textBoxImplementerFIO; + private TextBox textBoxPassword; + private TextBox textBoxWorkExperience; + private TextBox textBoxQualification; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.cs new file mode 100644 index 0000000..47eeacc --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementer.cs @@ -0,0 +1,138 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using BlacksmithWorkshopContracts.SearchModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BlacksmithWorkshop +{ + public partial class FormImplementer : Form + { + private readonly ILogger _logger; + + private readonly IImplementerLogic _logic; + + private int? _id; + + public int Id { set { _id = value; } } + + //конструктор + public FormImplementer(ILogger logger, IImplementerLogic logic) + { + InitializeComponent(); + + _logger = logger; + _logic = logic; + } + + //при загрузке формы + private void FormWorkPiece_Load(object sender, EventArgs e) + { + //проверка на заполнение поля id. Если оно заполнено, то пробуем получить запись и выести её на экран + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение исполнителя"); + + var view = _logic.ReadElement(new ImplementerSearchModel { Id = _id.Value }); + + if (view != null) + { + textBoxImplementerFIO.Text = view.ImplementerFIO; + textBoxPassword.Text = view.Password; + textBoxWorkExperience.Text = view.WorkExperience.ToString(); + textBoxQualification.Text = view.Qualification.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(textBoxImplementerFIO.Text)) + { + MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + + return; + } + + //проверка на заполнение поля с паролем + if (string.IsNullOrEmpty(textBoxPassword.Text)) + { + MessageBox.Show("Введите пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + + return; + } + + //проверка на заполнение поля со стажем + if (string.IsNullOrEmpty(textBoxWorkExperience.Text)) + { + MessageBox.Show("Введите ваш стаж", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + + return; + } + + //проверка на заполнение поля с квалификацией + if (string.IsNullOrEmpty(textBoxQualification.Text)) + { + MessageBox.Show("Введите свою квалификацию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + + return; + } + + _logger.LogInformation("Сохранение исполнителя"); + + try + { + var model = new ImplementerBindingModel + { + Id = _id ?? 0, + ImplementerFIO = textBoxImplementerFIO.Text, + Password = textBoxPassword.Text, + WorkExperience = Convert.ToInt16(textBoxWorkExperience.Text), + Qualification = Convert.ToInt16(textBoxQualification.Text) + }; + + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.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..f4fdf02 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.Designer.cs @@ -0,0 +1,114 @@ +namespace BlacksmithWorkshop +{ + 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() + { + dataGridView1 = new DataGridView(); + buttonCreate = new Button(); + buttonChange = new Button(); + buttonDelete = new Button(); + buttonUpdate = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + SuspendLayout(); + // + // dataGridView1 + // + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Location = new Point(12, 12); + dataGridView1.Name = "dataGridView1"; + dataGridView1.RowHeadersWidth = 51; + dataGridView1.RowTemplate.Height = 29; + dataGridView1.Size = new Size(768, 426); + dataGridView1.TabIndex = 0; + // + // buttonCreate + // + buttonCreate.Location = new Point(805, 22); + buttonCreate.Name = "buttonCreate"; + buttonCreate.Size = new Size(160, 29); + buttonCreate.TabIndex = 1; + buttonCreate.Text = "Создать"; + buttonCreate.UseVisualStyleBackColor = true; + buttonCreate.Click += ButtonCreate_Click; + // + // buttonChange + // + buttonChange.Location = new Point(805, 90); + buttonChange.Name = "buttonChange"; + buttonChange.Size = new Size(160, 29); + buttonChange.TabIndex = 2; + buttonChange.Text = "Изменить"; + buttonChange.UseVisualStyleBackColor = true; + buttonChange.Click += ButtonChange_Click; + // + // buttonDelete + // + buttonDelete.Location = new Point(805, 153); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(160, 29); + buttonDelete.TabIndex = 3; + buttonDelete.Text = "Удалить"; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // buttonUpdate + // + buttonUpdate.Location = new Point(805, 218); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(160, 29); + buttonUpdate.TabIndex = 4; + buttonUpdate.Text = "Обновить"; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpdate_Click; + // + // FormImplementers + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(991, 450); + Controls.Add(buttonUpdate); + Controls.Add(buttonDelete); + Controls.Add(buttonChange); + Controls.Add(buttonCreate); + Controls.Add(dataGridView1); + Name = "FormImplementers"; + Text = "Исполнители"; + Load += FormImplementers_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView1; + private Button buttonCreate; + private Button buttonChange; + private Button buttonDelete; + private Button buttonUpdate; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.cs new file mode 100644 index 0000000..8195e01 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BlacksmithWorkshop +{ + public partial class FormImplementers : Form + { + public FormImplementers() + { + InitializeComponent(); + } + + private void FormImplementers_Load(object sender, EventArgs e) + { + + } + + private void ButtonCreate_Click(object sender, EventArgs e) + { + + } + + private void ButtonChange_Click(object sender, EventArgs e) + { + + } + + private void ButtonDelete_Click(object sender, EventArgs e) + { + + } + + private void ButtonUpdate_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.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