diff --git a/PersonnelDepartment/PersonnelDepartmentView/Form1.Designer.cs b/PersonnelDepartment/PersonnelDepartmentView/Form1.Designer.cs
deleted file mode 100644
index facf5d2..0000000
--- a/PersonnelDepartment/PersonnelDepartmentView/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace PersonnelDepartmentView
-{
- partial class Form1
- {
- ///
- /// 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.components = new System.ComponentModel.Container();
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Text = "Form1";
- }
-
- #endregion
- }
-}
diff --git a/PersonnelDepartment/PersonnelDepartmentView/Form1.cs b/PersonnelDepartment/PersonnelDepartmentView/Form1.cs
deleted file mode 100644
index 522663e..0000000
--- a/PersonnelDepartment/PersonnelDepartmentView/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace PersonnelDepartmentView
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/PersonnelDepartment/PersonnelDepartmentView/Form1.resx b/PersonnelDepartment/PersonnelDepartmentView/Form1.resx
deleted file mode 100644
index 1af7de1..0000000
--- a/PersonnelDepartment/PersonnelDepartmentView/Form1.resx
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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/PersonnelDepartment/PersonnelDepartmentView/FormDeal.Designer.cs b/PersonnelDepartment/PersonnelDepartmentView/FormDeal.Designer.cs
new file mode 100644
index 0000000..fce7a34
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormDeal.Designer.cs
@@ -0,0 +1,232 @@
+namespace PersonnelDepartmentView
+{
+ partial class FormDeal
+ {
+ ///
+ /// 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()
+ {
+ buttonCancel = new Button();
+ buttonSave = new Button();
+ label1 = new Label();
+ label2 = new Label();
+ dateTimePickerFrom = new DateTimePicker();
+ dateTimePickerTo = new DateTimePicker();
+ label3 = new Label();
+ comboBoxType = new ComboBox();
+ label4 = new Label();
+ comboBoxEmployee = new ComboBox();
+ label5 = new Label();
+ comboBoxDepartment = new ComboBox();
+ label6 = new Label();
+ comboBoxPosition = new ComboBox();
+ label7 = new Label();
+ SuspendLayout();
+ //
+ // buttonCancel
+ //
+ buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonCancel.Location = new Point(230, 186);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 19;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonSave.Location = new Point(149, 186);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 18;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(15, 20);
+ label1.Name = "label1";
+ label1.Size = new Size(44, 15);
+ label1.TabIndex = 20;
+ label1.Text = "Дата с:";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(15, 47);
+ label2.Name = "label2";
+ label2.Size = new Size(52, 15);
+ label2.TabIndex = 21;
+ label2.Text = "Дата по:";
+ //
+ // dateTimePickerFrom
+ //
+ dateTimePickerFrom.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ dateTimePickerFrom.Location = new Point(105, 12);
+ dateTimePickerFrom.Name = "dateTimePickerFrom";
+ dateTimePickerFrom.Size = new Size(200, 23);
+ dateTimePickerFrom.TabIndex = 22;
+ //
+ // dateTimePickerTo
+ //
+ dateTimePickerTo.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ dateTimePickerTo.Location = new Point(105, 41);
+ dateTimePickerTo.Name = "dateTimePickerTo";
+ dateTimePickerTo.Size = new Size(200, 23);
+ dateTimePickerTo.TabIndex = 23;
+ //
+ // label3
+ //
+ label3.AutoSize = true;
+ label3.Location = new Point(15, 73);
+ label3.Name = "label3";
+ label3.Size = new Size(84, 15);
+ label3.TabIndex = 24;
+ label3.Text = "Тип договора:";
+ //
+ // comboBoxType
+ //
+ comboBoxType.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ comboBoxType.FormattingEnabled = true;
+ comboBoxType.Location = new Point(105, 70);
+ comboBoxType.Name = "comboBoxType";
+ comboBoxType.Size = new Size(200, 23);
+ comboBoxType.TabIndex = 25;
+ //
+ // label4
+ //
+ label4.AutoSize = true;
+ label4.Location = new Point(114, 144);
+ label4.Name = "label4";
+ label4.Size = new Size(0, 15);
+ label4.TabIndex = 26;
+ //
+ // comboBoxEmployee
+ //
+ comboBoxEmployee.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ comboBoxEmployee.FormattingEnabled = true;
+ comboBoxEmployee.Location = new Point(105, 99);
+ comboBoxEmployee.Name = "comboBoxEmployee";
+ comboBoxEmployee.Size = new Size(200, 23);
+ comboBoxEmployee.TabIndex = 28;
+ //
+ // label5
+ //
+ label5.AutoSize = true;
+ label5.Location = new Point(15, 102);
+ label5.Name = "label5";
+ label5.Size = new Size(69, 15);
+ label5.TabIndex = 27;
+ label5.Text = "Сотрудник:";
+ //
+ // comboBoxDepartment
+ //
+ comboBoxDepartment.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ comboBoxDepartment.FormattingEnabled = true;
+ comboBoxDepartment.Location = new Point(105, 128);
+ comboBoxDepartment.Name = "comboBoxDepartment";
+ comboBoxDepartment.Size = new Size(200, 23);
+ comboBoxDepartment.TabIndex = 30;
+ //
+ // label6
+ //
+ label6.AutoSize = true;
+ label6.Location = new Point(15, 131);
+ label6.Name = "label6";
+ label6.Size = new Size(43, 15);
+ label6.TabIndex = 29;
+ label6.Text = "Отдел:";
+ //
+ // comboBoxPosition
+ //
+ comboBoxPosition.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ comboBoxPosition.FormattingEnabled = true;
+ comboBoxPosition.Location = new Point(105, 157);
+ comboBoxPosition.Name = "comboBoxPosition";
+ comboBoxPosition.Size = new Size(200, 23);
+ comboBoxPosition.TabIndex = 32;
+ //
+ // label7
+ //
+ label7.AutoSize = true;
+ label7.Location = new Point(15, 160);
+ label7.Name = "label7";
+ label7.Size = new Size(72, 15);
+ label7.TabIndex = 31;
+ label7.Text = "Должность:";
+ //
+ // FormDeal
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(324, 223);
+ Controls.Add(comboBoxPosition);
+ Controls.Add(label7);
+ Controls.Add(comboBoxDepartment);
+ Controls.Add(label6);
+ Controls.Add(comboBoxEmployee);
+ Controls.Add(label5);
+ Controls.Add(label4);
+ Controls.Add(comboBoxType);
+ Controls.Add(label3);
+ Controls.Add(dateTimePickerTo);
+ Controls.Add(dateTimePickerFrom);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ FormBorderStyle = FormBorderStyle.FixedSingle;
+ MinimumSize = new Size(340, 262);
+ Name = "FormDeal";
+ StartPosition = FormStartPosition.CenterScreen;
+ Text = "Договор";
+ Load += FormDeal_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button buttonCancel;
+ private Button buttonSave;
+ private Label label1;
+ private Label label2;
+ private DateTimePicker dateTimePickerFrom;
+ private DateTimePicker dateTimePickerTo;
+ private Label label3;
+ private ComboBox comboBoxType;
+ private Label label4;
+ private ComboBox comboBoxEmployee;
+ private Label label5;
+ private ComboBox comboBoxDepartment;
+ private Label label6;
+ private ComboBox comboBoxPosition;
+ private Label label7;
+ }
+}
\ No newline at end of file
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormDeal.cs b/PersonnelDepartment/PersonnelDepartmentView/FormDeal.cs
new file mode 100644
index 0000000..bfc5166
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormDeal.cs
@@ -0,0 +1,139 @@
+using Microsoft.EntityFrameworkCore.Metadata.Internal;
+using PersonnelDepartmentContracts.BindingModels;
+using PersonnelDepartmentContracts.BusinessLogicContracts;
+using PersonnelDepartmentContracts.SearchModels;
+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 PersonnelDepartmentView
+{
+ public partial class FormDeal : Form
+ {
+ private readonly IDealLogic _dealLogic;
+ private readonly IDepartmentLogic _departmentLogic;
+ private readonly IEmployeeLogic _employeeLogic;
+ private readonly IPositionLogic _positionLogic;
+ private readonly ITypeLogic _typeLogic;
+ private int? _id;
+ public int Id { set { _id = value; } }
+
+ public FormDeal(IDealLogic dealLogic, IDepartmentLogic departmentLogic, IEmployeeLogic employeeLogic, IPositionLogic positionLogic, ITypeLogic typeLogic)
+ {
+ InitializeComponent();
+ _dealLogic = dealLogic;
+ _departmentLogic = departmentLogic;
+ _employeeLogic = employeeLogic;
+ _positionLogic = positionLogic;
+ _typeLogic = typeLogic;
+ }
+
+ private void FormDeal_Load(object sender, EventArgs e)
+ {
+ comboBoxDepartment.DisplayMember = "Name";
+ comboBoxDepartment.ValueMember = "Id";
+ comboBoxDepartment.DataSource = _departmentLogic.ReadList(null);
+ comboBoxEmployee.DisplayMember = "LastName";
+ comboBoxEmployee.ValueMember = "Id";
+ comboBoxEmployee.DataSource = _employeeLogic.ReadList(null);
+ comboBoxPosition.DisplayMember = "Name";
+ comboBoxPosition.ValueMember = "Id";
+ comboBoxPosition.DataSource = _positionLogic.ReadList(null);
+ comboBoxType.DisplayMember = "Name";
+ comboBoxType.ValueMember = "Id";
+ comboBoxType.DataSource = _typeLogic.ReadList(null);
+ if (_id.HasValue)
+ {
+ try
+ {
+ var view = _dealLogic.ReadElement(new DealSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ dateTimePickerFrom.Value = view.DateFrom;
+ dateTimePickerTo.Value = view.DateTo;
+ comboBoxDepartment.SelectedItem = view.DepartmentId;
+ comboBoxEmployee.SelectedItem = view.EmployeeId;
+ comboBoxPosition.SelectedItem = view.PositionId;
+ comboBoxType.SelectedItem = view.TypeId;
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ else
+ {
+ comboBoxDepartment.SelectedItem = null;
+ comboBoxEmployee.SelectedItem = null;
+ comboBoxPosition.SelectedItem = null;
+ comboBoxType.SelectedItem = null;
+ }
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (comboBoxDepartment.SelectedItem == null)
+ {
+ MessageBox.Show("Выберите отдел", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxEmployee.SelectedItem == null)
+ {
+ MessageBox.Show("Выберите сотрудника", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxPosition.SelectedItem == null)
+ {
+ MessageBox.Show("Выберите должность", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxType.SelectedItem == null)
+ {
+ MessageBox.Show("Выберите тип договора", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ try
+ {
+ var model = new DealBindingModel
+ {
+ Id = _id ?? 0,
+ DateFrom = DateTime.SpecifyKind(dateTimePickerFrom.Value, DateTimeKind.Utc),
+ DateTo = DateTime.SpecifyKind(dateTimePickerTo.Value, DateTimeKind.Utc),
+ DepartmentId = Convert.ToInt32(comboBoxDepartment.SelectedValue),
+ EmployeeId = Convert.ToInt32(comboBoxEmployee.SelectedValue),
+ PositionId = Convert.ToInt32(comboBoxPosition.SelectedValue),
+ TypeId = Convert.ToInt32(comboBoxType.SelectedValue)
+ };
+ var operationResult = _id.HasValue ? _dealLogic.Update(model) : _dealLogic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormDeal.resx b/PersonnelDepartment/PersonnelDepartmentView/FormDeal.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormDeal.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/PersonnelDepartment/PersonnelDepartmentView/FormDeals.Designer.cs b/PersonnelDepartment/PersonnelDepartmentView/FormDeals.Designer.cs
new file mode 100644
index 0000000..3913687
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormDeals.Designer.cs
@@ -0,0 +1,206 @@
+namespace PersonnelDepartmentView
+{
+ partial class FormDeals
+ {
+ ///
+ /// 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()
+ {
+ dataGridView = new DataGridView();
+ buttonAdd = new Button();
+ buttonChange = new Button();
+ buttonDelete = new Button();
+ buttonUpdate = new Button();
+ buttonDepartment = new Button();
+ buttonEmployee = new Button();
+ buttonPosition = new Button();
+ buttonType = new Button();
+ buttonGenerate = new Button();
+ buttonBackUp = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ dataGridView.BackgroundColor = Color.DarkSeaGreen;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 41);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.Size = new Size(888, 368);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Anchor = AnchorStyles.Top;
+ buttonAdd.Location = new Point(12, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(75, 23);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Создать";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // buttonChange
+ //
+ buttonChange.Anchor = AnchorStyles.Top;
+ buttonChange.Location = new Point(93, 12);
+ buttonChange.Name = "buttonChange";
+ buttonChange.Size = new Size(75, 23);
+ buttonChange.TabIndex = 2;
+ buttonChange.Text = "Изменить";
+ buttonChange.UseVisualStyleBackColor = true;
+ buttonChange.Click += ButtonChange_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Anchor = AnchorStyles.Top;
+ buttonDelete.Location = new Point(174, 12);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(75, 23);
+ buttonDelete.TabIndex = 3;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Anchor = AnchorStyles.Top;
+ buttonUpdate.Location = new Point(255, 12);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(75, 23);
+ buttonUpdate.TabIndex = 4;
+ buttonUpdate.Text = "Обновить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonDepartment
+ //
+ buttonDepartment.Anchor = AnchorStyles.Top;
+ buttonDepartment.Location = new Point(336, 12);
+ buttonDepartment.Name = "buttonDepartment";
+ buttonDepartment.Size = new Size(128, 23);
+ buttonDepartment.TabIndex = 5;
+ buttonDepartment.Text = "Таблица с отделами";
+ buttonDepartment.UseVisualStyleBackColor = true;
+ buttonDepartment.Click += ButtonDepartment_Click;
+ //
+ // buttonEmployee
+ //
+ buttonEmployee.Anchor = AnchorStyles.Top;
+ buttonEmployee.Location = new Point(470, 12);
+ buttonEmployee.Name = "buttonEmployee";
+ buttonEmployee.Size = new Size(152, 23);
+ buttonEmployee.TabIndex = 6;
+ buttonEmployee.Text = "Таблица с сотрудниками";
+ buttonEmployee.UseVisualStyleBackColor = true;
+ buttonEmployee.Click += ButtonEmployee_Click;
+ //
+ // buttonPosition
+ //
+ buttonPosition.Anchor = AnchorStyles.Top;
+ buttonPosition.Location = new Point(628, 12);
+ buttonPosition.Name = "buttonPosition";
+ buttonPosition.Size = new Size(149, 23);
+ buttonPosition.TabIndex = 7;
+ buttonPosition.Text = "Таблица с должностями";
+ buttonPosition.UseVisualStyleBackColor = true;
+ buttonPosition.Click += ButtonPosition_Click;
+ //
+ // buttonType
+ //
+ buttonType.Anchor = AnchorStyles.Top;
+ buttonType.Location = new Point(783, 12);
+ buttonType.Name = "buttonType";
+ buttonType.Size = new Size(117, 23);
+ buttonType.TabIndex = 8;
+ buttonType.Text = "Таблица с типами";
+ buttonType.UseVisualStyleBackColor = true;
+ buttonType.Click += ButtonType_Click;
+ //
+ // buttonGenerate
+ //
+ buttonGenerate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
+ buttonGenerate.Location = new Point(12, 415);
+ buttonGenerate.Name = "buttonGenerate";
+ buttonGenerate.Size = new Size(163, 23);
+ buttonGenerate.TabIndex = 9;
+ buttonGenerate.Text = "Сгенерировать сущности";
+ buttonGenerate.UseVisualStyleBackColor = true;
+ buttonGenerate.Click += ButtonGenerate_Click;
+ //
+ // buttonBackUp
+ //
+ buttonBackUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ buttonBackUp.Location = new Point(783, 415);
+ buttonBackUp.Name = "buttonBackUp";
+ buttonBackUp.Size = new Size(117, 23);
+ buttonBackUp.TabIndex = 10;
+ buttonBackUp.Text = "Создать BackUp";
+ buttonBackUp.UseVisualStyleBackColor = true;
+ buttonBackUp.Click += CreateBackup_Click;
+ //
+ // FormDeals
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ BackColor = SystemColors.Control;
+ ClientSize = new Size(914, 446);
+ Controls.Add(buttonBackUp);
+ Controls.Add(buttonGenerate);
+ Controls.Add(buttonType);
+ Controls.Add(buttonPosition);
+ Controls.Add(buttonEmployee);
+ Controls.Add(buttonDepartment);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonChange);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ MinimumSize = new Size(930, 240);
+ Name = "FormDeals";
+ StartPosition = FormStartPosition.CenterScreen;
+ Text = "Таблица Договоров";
+ Load += FormDeals_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonChange;
+ private Button buttonDelete;
+ private Button buttonUpdate;
+ private Button buttonDepartment;
+ private Button buttonEmployee;
+ private Button buttonPosition;
+ private Button buttonType;
+ private Button buttonGenerate;
+ private Button buttonBackUp;
+ }
+}
\ No newline at end of file
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormDeals.cs b/PersonnelDepartment/PersonnelDepartmentView/FormDeals.cs
new file mode 100644
index 0000000..b4aa107
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormDeals.cs
@@ -0,0 +1,180 @@
+using PersonnelDepartmentContracts.BindingModels;
+using PersonnelDepartmentContracts.BusinessLogicContracts;
+
+namespace PersonnelDepartmentView
+{
+ public partial class FormDeals : Form
+ {
+ private readonly IDealLogic _dealLogic;
+ private readonly IBackUpLogic _backUpLogic;
+
+ public FormDeals(IDealLogic dealLogic, IBackUpLogic backUpLogic)
+ {
+ InitializeComponent();
+ _dealLogic = dealLogic;
+ _backUpLogic = backUpLogic;
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _dealLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns["EmployeeId"].Visible = false;
+ dataGridView.Columns["PositionId"].Visible = false;
+ dataGridView.Columns["DepartmentId"].Visible = false;
+ dataGridView.Columns["TypeId"].Visible = false;
+ dataGridView.Columns["DateFrom"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["DateTo"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["TypeName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["EmployeeName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["DepartmentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["PositionName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void FormDeals_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void ButtonDepartment_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormDepartments));
+ if (service is FormDepartments form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void ButtonEmployee_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormEmployees));
+ if (service is FormEmployees form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void ButtonPosition_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPositions));
+ if (service is FormPositions form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void ButtonType_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormTypes));
+ if (service is FormTypes form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormDeal));
+ if (service is FormDeal form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonChange_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormDeal));
+ if (service is FormDeal form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonDelete_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);
+ try
+ {
+ if (!_dealLogic.Delete(new DealBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception(" .");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void ButtonGenerate_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormGeneration));
+ if (service is FormGeneration form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void CreateBackup_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (_backUpLogic != null)
+ {
+ var fbd = new FolderBrowserDialog();
+ if (fbd.ShowDialog() == DialogResult.OK)
+ {
+ _backUpLogic.CreateBackUp(new BackUpBinidngModel
+ {
+ FolderName = fbd.SelectedPath
+ });
+ MessageBox.Show(" ", "",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormDeals.resx b/PersonnelDepartment/PersonnelDepartmentView/FormDeals.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormDeals.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/PersonnelDepartment/PersonnelDepartmentView/FormDepartment.Designer.cs b/PersonnelDepartment/PersonnelDepartmentView/FormDepartment.Designer.cs
new file mode 100644
index 0000000..8b20a95
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormDepartment.Designer.cs
@@ -0,0 +1,120 @@
+namespace PersonnelDepartmentView
+{
+ partial class FormDepartment
+ {
+ ///
+ /// 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()
+ {
+ label2 = new Label();
+ textBoxTelephone = new TextBox();
+ buttonCancel = new Button();
+ buttonSave = new Button();
+ label1 = new Label();
+ textBoxName = new TextBox();
+ SuspendLayout();
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(20, 44);
+ label2.Name = "label2";
+ label2.Size = new Size(126, 15);
+ label2.TabIndex = 19;
+ label2.Text = "Контактный телефон:";
+ //
+ // textBoxTelephone
+ //
+ textBoxTelephone.Location = new Point(153, 41);
+ textBoxTelephone.Name = "textBoxTelephone";
+ textBoxTelephone.Size = new Size(202, 23);
+ textBoxTelephone.TabIndex = 18;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(280, 70);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 17;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(199, 70);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 16;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(20, 15);
+ label1.Name = "label1";
+ label1.Size = new Size(102, 15);
+ label1.TabIndex = 15;
+ label1.Text = "Название отдела:";
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(153, 12);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(202, 23);
+ textBoxName.TabIndex = 14;
+ //
+ // FormDepartment
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(375, 108);
+ Controls.Add(label2);
+ Controls.Add(textBoxTelephone);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(label1);
+ Controls.Add(textBoxName);
+ FormBorderStyle = FormBorderStyle.FixedSingle;
+ Name = "FormDepartment";
+ StartPosition = FormStartPosition.CenterScreen;
+ Text = "Отдел";
+ Load += FormDepartment_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label label2;
+ private TextBox textBoxTelephone;
+ private Button buttonCancel;
+ private Button buttonSave;
+ private Label label1;
+ private TextBox textBoxName;
+ }
+}
\ No newline at end of file
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormDepartment.cs b/PersonnelDepartment/PersonnelDepartmentView/FormDepartment.cs
new file mode 100644
index 0000000..0091653
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormDepartment.cs
@@ -0,0 +1,93 @@
+using PersonnelDepartmentBusinessLogic.BusinessLogics;
+using PersonnelDepartmentContracts.BindingModels;
+using PersonnelDepartmentContracts.BusinessLogicContracts;
+using PersonnelDepartmentContracts.SearchModels;
+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 PersonnelDepartmentView
+{
+ public partial class FormDepartment : Form
+ {
+ private readonly IDepartmentLogic _departmentLogic;
+ private int? _id;
+ public int Id { set { _id = value; } }
+ public FormDepartment(IDepartmentLogic departmentLogic)
+ {
+ InitializeComponent();
+ _departmentLogic = departmentLogic;
+ }
+
+ private void FormDepartment_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ try
+ {
+ var view = _departmentLogic.ReadElement(new DepartmentSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.Name;
+ textBoxTelephone.Text = view.Telephone.ToString();
+ }
+ }
+ catch (Exception 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;
+ }
+ if (string.IsNullOrEmpty(textBoxTelephone.Text))
+ {
+ MessageBox.Show("Введите контактный номер", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ try
+ {
+ var model = new DepartmentBindingModel
+ {
+ Id = _id ?? 0,
+ Name = textBoxName.Text,
+ Telephone = long.Parse(textBoxTelephone.Text)
+ };
+ var operationResult = _id.HasValue ? _departmentLogic.Update(model) : _departmentLogic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormDepartment.resx b/PersonnelDepartment/PersonnelDepartmentView/FormDepartment.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormDepartment.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/PersonnelDepartment/PersonnelDepartmentView/FormDepartments.Designer.cs b/PersonnelDepartment/PersonnelDepartmentView/FormDepartments.Designer.cs
new file mode 100644
index 0000000..79acda8
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormDepartments.Designer.cs
@@ -0,0 +1,117 @@
+namespace PersonnelDepartmentView
+{
+ partial class FormDepartments
+ {
+ ///
+ /// 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()
+ {
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonChange = new Button();
+ buttonAdd = new Button();
+ dataGridView = new DataGridView();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(255, 9);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(75, 23);
+ buttonUpdate.TabIndex = 9;
+ buttonUpdate.Text = "Обновить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(174, 9);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(75, 23);
+ buttonDelete.TabIndex = 8;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // buttonChange
+ //
+ buttonChange.Location = new Point(93, 9);
+ buttonChange.Name = "buttonChange";
+ buttonChange.Size = new Size(75, 23);
+ buttonChange.TabIndex = 7;
+ buttonChange.Text = "Изменить";
+ buttonChange.UseVisualStyleBackColor = true;
+ buttonChange.Click += ButtonChange_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(12, 9);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(75, 23);
+ buttonAdd.TabIndex = 6;
+ buttonAdd.Text = "Создать";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ dataGridView.BackgroundColor = Color.DarkSeaGreen;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 38);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.Size = new Size(564, 368);
+ dataGridView.TabIndex = 5;
+ //
+ // FormDepartments
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(590, 418);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonChange);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ MinimumSize = new Size(400, 200);
+ Name = "FormDepartments";
+ StartPosition = FormStartPosition.CenterScreen;
+ Text = "Таблица Отделов";
+ Load += FormDepartments_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonChange;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormDepartments.cs b/PersonnelDepartment/PersonnelDepartmentView/FormDepartments.cs
new file mode 100644
index 0000000..e0b64ce
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormDepartments.cs
@@ -0,0 +1,108 @@
+using PersonnelDepartmentBusinessLogic.BusinessLogics;
+using PersonnelDepartmentContracts.BindingModels;
+using PersonnelDepartmentContracts.BusinessLogicContracts;
+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 PersonnelDepartmentView
+{
+ public partial class FormDepartments : Form
+ {
+ private readonly IDepartmentLogic _departmentLogic;
+ public FormDepartments(IDepartmentLogic departmentLogic)
+ {
+ InitializeComponent();
+ _departmentLogic = departmentLogic;
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _departmentLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["Telephone"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка загрузки", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormDepartment));
+ if (service is FormDepartment form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonChange_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormDepartment));
+ if (service is FormDepartment form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonDelete_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);
+ try
+ {
+ if (!_departmentLogic.Delete(new DepartmentBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void FormDepartments_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormDepartments.resx b/PersonnelDepartment/PersonnelDepartmentView/FormDepartments.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormDepartments.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/PersonnelDepartment/PersonnelDepartmentView/FormEmployee.Designer.cs b/PersonnelDepartment/PersonnelDepartmentView/FormEmployee.Designer.cs
new file mode 100644
index 0000000..bb15f54
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormEmployee.Designer.cs
@@ -0,0 +1,142 @@
+namespace PersonnelDepartmentView
+{
+ partial class FormEmployee
+ {
+ ///
+ /// 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()
+ {
+ buttonCancel = new Button();
+ buttonSave = new Button();
+ label1 = new Label();
+ textBoxFirstName = new TextBox();
+ label2 = new Label();
+ textBoxLastName = new TextBox();
+ label3 = new Label();
+ textBoxPatronymic = new TextBox();
+ SuspendLayout();
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(276, 99);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 11;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(195, 99);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 10;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(16, 15);
+ label1.Name = "label1";
+ label1.Size = new Size(100, 15);
+ label1.TabIndex = 9;
+ label1.Text = "Имя сотрудника:";
+ //
+ // textBoxFirstName
+ //
+ textBoxFirstName.Location = new Point(149, 12);
+ textBoxFirstName.Name = "textBoxFirstName";
+ textBoxFirstName.Size = new Size(202, 23);
+ textBoxFirstName.TabIndex = 8;
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(16, 44);
+ label2.Name = "label2";
+ label2.Size = new Size(127, 15);
+ label2.TabIndex = 13;
+ label2.Text = "Фамилия сотрудника:";
+ //
+ // textBoxLastName
+ //
+ textBoxLastName.Location = new Point(149, 41);
+ textBoxLastName.Name = "textBoxLastName";
+ textBoxLastName.Size = new Size(202, 23);
+ textBoxLastName.TabIndex = 12;
+ //
+ // label3
+ //
+ label3.AutoSize = true;
+ label3.Location = new Point(16, 73);
+ label3.Name = "label3";
+ label3.Size = new Size(127, 15);
+ label3.TabIndex = 15;
+ label3.Text = "Отчество сотрудника:";
+ //
+ // textBoxPatronymic
+ //
+ textBoxPatronymic.Location = new Point(149, 70);
+ textBoxPatronymic.Name = "textBoxPatronymic";
+ textBoxPatronymic.Size = new Size(202, 23);
+ textBoxPatronymic.TabIndex = 14;
+ //
+ // FormEmployee
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(369, 136);
+ Controls.Add(label3);
+ Controls.Add(textBoxPatronymic);
+ Controls.Add(label2);
+ Controls.Add(textBoxLastName);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(label1);
+ Controls.Add(textBoxFirstName);
+ FormBorderStyle = FormBorderStyle.FixedSingle;
+ Name = "FormEmployee";
+ StartPosition = FormStartPosition.CenterScreen;
+ Text = "Сотрудник";
+ Load += FormEmployee_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button buttonCancel;
+ private Button buttonSave;
+ private Label label1;
+ private TextBox textBoxFirstName;
+ private Label label2;
+ private TextBox textBoxLastName;
+ private Label label3;
+ private TextBox textBoxPatronymic;
+ }
+}
\ No newline at end of file
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormEmployee.cs b/PersonnelDepartment/PersonnelDepartmentView/FormEmployee.cs
new file mode 100644
index 0000000..90a2c52
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormEmployee.cs
@@ -0,0 +1,95 @@
+using PersonnelDepartmentBusinessLogic.BusinessLogics;
+using PersonnelDepartmentContracts.BindingModels;
+using PersonnelDepartmentContracts.BusinessLogicContracts;
+using PersonnelDepartmentContracts.SearchModels;
+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 PersonnelDepartmentView
+{
+ public partial class FormEmployee : Form
+ {
+ private readonly IEmployeeLogic _employeeLogic;
+ private int? _id;
+ public int Id { set { _id = value; } }
+ public FormEmployee(IEmployeeLogic employeeLogic)
+ {
+ InitializeComponent();
+ _employeeLogic = employeeLogic;
+ }
+
+ private void FormEmployee_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ try
+ {
+ var view = _employeeLogic.ReadElement(new EmployeeSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxFirstName.Text = view.FirstName;
+ textBoxLastName.Text = view.LastName;
+ textBoxPatronymic.Text = view.Patronymic;
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxFirstName.Text))
+ {
+ MessageBox.Show("Введите название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (string.IsNullOrEmpty(textBoxLastName.Text))
+ {
+ MessageBox.Show("Введите контактный номер", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ try
+ {
+ var model = new EmployeeBindingModel
+ {
+ Id = _id ?? 0,
+ FirstName = textBoxFirstName.Text,
+ LastName = textBoxLastName.Text,
+ Patronymic = textBoxPatronymic.Text
+ };
+ var operationResult = _id.HasValue ? _employeeLogic.Update(model) : _employeeLogic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormEmployee.resx b/PersonnelDepartment/PersonnelDepartmentView/FormEmployee.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormEmployee.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/PersonnelDepartment/PersonnelDepartmentView/FormEmployees.Designer.cs b/PersonnelDepartment/PersonnelDepartmentView/FormEmployees.Designer.cs
new file mode 100644
index 0000000..563ffa2
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormEmployees.Designer.cs
@@ -0,0 +1,117 @@
+namespace PersonnelDepartmentView
+{
+ partial class FormEmployees
+ {
+ ///
+ /// 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()
+ {
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonChange = new Button();
+ buttonAdd = new Button();
+ dataGridView = new DataGridView();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(255, 9);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(75, 23);
+ buttonUpdate.TabIndex = 9;
+ buttonUpdate.Text = "Обновить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(174, 9);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(75, 23);
+ buttonDelete.TabIndex = 8;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // buttonChange
+ //
+ buttonChange.Location = new Point(93, 9);
+ buttonChange.Name = "buttonChange";
+ buttonChange.Size = new Size(75, 23);
+ buttonChange.TabIndex = 7;
+ buttonChange.Text = "Изменить";
+ buttonChange.UseVisualStyleBackColor = true;
+ buttonChange.Click += ButtonChange_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(12, 9);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(75, 23);
+ buttonAdd.TabIndex = 6;
+ buttonAdd.Text = "Создать";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ dataGridView.BackgroundColor = Color.DarkSeaGreen;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 38);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.Size = new Size(564, 368);
+ dataGridView.TabIndex = 5;
+ //
+ // FormEmployees
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(589, 418);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonChange);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ MinimumSize = new Size(400, 200);
+ Name = "FormEmployees";
+ StartPosition = FormStartPosition.CenterScreen;
+ Text = "Таблица Сотрудников";
+ Load += FormEmployees_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonChange;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormEmployees.cs b/PersonnelDepartment/PersonnelDepartmentView/FormEmployees.cs
new file mode 100644
index 0000000..12a6a3a
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormEmployees.cs
@@ -0,0 +1,109 @@
+using PersonnelDepartmentBusinessLogic.BusinessLogics;
+using PersonnelDepartmentContracts.BindingModels;
+using PersonnelDepartmentContracts.BusinessLogicContracts;
+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 PersonnelDepartmentView
+{
+ public partial class FormEmployees : Form
+ {
+ private readonly IEmployeeLogic _employeeLogic;
+ public FormEmployees(IEmployeeLogic employeeLogic)
+ {
+ InitializeComponent();
+ _employeeLogic = employeeLogic;
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _employeeLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns["FirstName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["LastName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["Patronymic"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка загрузки", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormEmployee));
+ if (service is FormEmployee form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonChange_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormEmployee));
+ if (service is FormEmployee form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonDelete_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);
+ try
+ {
+ if (!_employeeLogic.Delete(new EmployeeBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void FormEmployees_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormEmployees.resx b/PersonnelDepartment/PersonnelDepartmentView/FormEmployees.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormEmployees.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/PersonnelDepartment/PersonnelDepartmentView/FormGeneration.Designer.cs b/PersonnelDepartment/PersonnelDepartmentView/FormGeneration.Designer.cs
new file mode 100644
index 0000000..8abb0c5
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormGeneration.Designer.cs
@@ -0,0 +1,229 @@
+namespace PersonnelDepartmentView
+{
+ partial class FormGeneration
+ {
+ ///
+ /// 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()
+ {
+ groupBox1 = new GroupBox();
+ textBoxGet = new TextBox();
+ numericGet = new NumericUpDown();
+ buttonGetTest = new Button();
+ groupBox2 = new GroupBox();
+ textBoxDiffGet = new TextBox();
+ numericDiffGet = new NumericUpDown();
+ buttonDiffGetTest = new Button();
+ groupBox3 = new GroupBox();
+ textBoxSet = new TextBox();
+ numericSet = new NumericUpDown();
+ buttonSetTest = new Button();
+ buttonClear = new Button();
+ groupBox1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)numericGet).BeginInit();
+ groupBox2.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)numericDiffGet).BeginInit();
+ groupBox3.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)numericSet).BeginInit();
+ SuspendLayout();
+ //
+ // groupBox1
+ //
+ groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ groupBox1.Controls.Add(textBoxGet);
+ groupBox1.Controls.Add(numericGet);
+ groupBox1.Controls.Add(buttonGetTest);
+ groupBox1.Location = new Point(12, 12);
+ groupBox1.Name = "groupBox1";
+ groupBox1.Size = new Size(470, 93);
+ groupBox1.TabIndex = 0;
+ groupBox1.TabStop = false;
+ groupBox1.Text = "Тест обычного запроса:";
+ //
+ // textBoxGet
+ //
+ textBoxGet.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ textBoxGet.Location = new Point(221, 51);
+ textBoxGet.Name = "textBoxGet";
+ textBoxGet.ReadOnly = true;
+ textBoxGet.Size = new Size(243, 23);
+ textBoxGet.TabIndex = 2;
+ //
+ // numericGet
+ //
+ numericGet.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ numericGet.Location = new Point(221, 22);
+ numericGet.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
+ numericGet.Name = "numericGet";
+ numericGet.Size = new Size(243, 23);
+ numericGet.TabIndex = 1;
+ //
+ // buttonGetTest
+ //
+ buttonGetTest.Anchor = AnchorStyles.Left | AnchorStyles.Right;
+ buttonGetTest.Location = new Point(6, 22);
+ buttonGetTest.Name = "buttonGetTest";
+ buttonGetTest.Size = new Size(209, 52);
+ buttonGetTest.TabIndex = 0;
+ buttonGetTest.Text = "GetTest";
+ buttonGetTest.UseVisualStyleBackColor = true;
+ buttonGetTest.Click += ButtonGetTest_Click;
+ //
+ // groupBox2
+ //
+ groupBox2.Anchor = AnchorStyles.Left | AnchorStyles.Right;
+ groupBox2.Controls.Add(textBoxDiffGet);
+ groupBox2.Controls.Add(numericDiffGet);
+ groupBox2.Controls.Add(buttonDiffGetTest);
+ groupBox2.Location = new Point(12, 111);
+ groupBox2.Name = "groupBox2";
+ groupBox2.Size = new Size(470, 93);
+ groupBox2.TabIndex = 1;
+ groupBox2.TabStop = false;
+ groupBox2.Text = "Тест сложного запроса:";
+ //
+ // textBoxDiffGet
+ //
+ textBoxDiffGet.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ textBoxDiffGet.Location = new Point(221, 51);
+ textBoxDiffGet.Name = "textBoxDiffGet";
+ textBoxDiffGet.ReadOnly = true;
+ textBoxDiffGet.Size = new Size(243, 23);
+ textBoxDiffGet.TabIndex = 2;
+ //
+ // numericDiffGet
+ //
+ numericDiffGet.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ numericDiffGet.Location = new Point(221, 22);
+ numericDiffGet.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
+ numericDiffGet.Name = "numericDiffGet";
+ numericDiffGet.Size = new Size(243, 23);
+ numericDiffGet.TabIndex = 1;
+ //
+ // buttonDiffGetTest
+ //
+ buttonDiffGetTest.Anchor = AnchorStyles.Left | AnchorStyles.Right;
+ buttonDiffGetTest.Location = new Point(6, 22);
+ buttonDiffGetTest.Name = "buttonDiffGetTest";
+ buttonDiffGetTest.Size = new Size(209, 52);
+ buttonDiffGetTest.TabIndex = 0;
+ buttonDiffGetTest.Text = "GetDiffTest";
+ buttonDiffGetTest.UseVisualStyleBackColor = true;
+ buttonDiffGetTest.Click += ButtonDiffGetTest_Click;
+ //
+ // groupBox3
+ //
+ groupBox3.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ groupBox3.Controls.Add(textBoxSet);
+ groupBox3.Controls.Add(numericSet);
+ groupBox3.Controls.Add(buttonSetTest);
+ groupBox3.Location = new Point(12, 210);
+ groupBox3.Name = "groupBox3";
+ groupBox3.Size = new Size(470, 93);
+ groupBox3.TabIndex = 3;
+ groupBox3.TabStop = false;
+ groupBox3.Text = "Тест на заполнение:";
+ //
+ // textBoxSet
+ //
+ textBoxSet.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+ textBoxSet.Location = new Point(221, 51);
+ textBoxSet.Name = "textBoxSet";
+ textBoxSet.ReadOnly = true;
+ textBoxSet.Size = new Size(243, 23);
+ textBoxSet.TabIndex = 2;
+ //
+ // numericSet
+ //
+ numericSet.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ numericSet.Location = new Point(221, 22);
+ numericSet.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
+ numericSet.Name = "numericSet";
+ numericSet.Size = new Size(243, 23);
+ numericSet.TabIndex = 1;
+ //
+ // buttonSetTest
+ //
+ buttonSetTest.Anchor = AnchorStyles.Left | AnchorStyles.Right;
+ buttonSetTest.Location = new Point(6, 22);
+ buttonSetTest.Name = "buttonSetTest";
+ buttonSetTest.Size = new Size(209, 52);
+ buttonSetTest.TabIndex = 0;
+ buttonSetTest.Text = "SetTest";
+ buttonSetTest.UseVisualStyleBackColor = true;
+ buttonSetTest.Click += ButtonSetTest_Click;
+ //
+ // buttonClear
+ //
+ buttonClear.Anchor = AnchorStyles.Bottom;
+ buttonClear.Location = new Point(149, 309);
+ buttonClear.Name = "buttonClear";
+ buttonClear.Size = new Size(162, 23);
+ buttonClear.TabIndex = 4;
+ buttonClear.Text = "Очистить сущность";
+ buttonClear.UseVisualStyleBackColor = true;
+ buttonClear.Click += ButtonClear_Click;
+ //
+ // FormGeneration
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(493, 344);
+ Controls.Add(buttonClear);
+ Controls.Add(groupBox3);
+ Controls.Add(groupBox2);
+ Controls.Add(groupBox1);
+ Name = "FormGeneration";
+ StartPosition = FormStartPosition.CenterScreen;
+ Text = "FormGeneration";
+ groupBox1.ResumeLayout(false);
+ groupBox1.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)numericGet).EndInit();
+ groupBox2.ResumeLayout(false);
+ groupBox2.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)numericDiffGet).EndInit();
+ groupBox3.ResumeLayout(false);
+ groupBox3.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)numericSet).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private GroupBox groupBox1;
+ private TextBox textBoxGet;
+ private NumericUpDown numericGet;
+ private Button buttonGetTest;
+ private GroupBox groupBox2;
+ private TextBox textBoxDiffGet;
+ private NumericUpDown numericDiffGet;
+ private Button buttonDiffGetTest;
+ private GroupBox groupBox3;
+ private TextBox textBoxSet;
+ private NumericUpDown numericSet;
+ private Button buttonSetTest;
+ private Button buttonClear;
+ }
+}
\ No newline at end of file
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormGeneration.cs b/PersonnelDepartment/PersonnelDepartmentView/FormGeneration.cs
new file mode 100644
index 0000000..5f37982
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormGeneration.cs
@@ -0,0 +1,48 @@
+using PersonnelDepartmentContracts.BusinessLogicContracts;
+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 PersonnelDepartmentView
+{
+ public partial class FormGeneration : Form
+ {
+ private readonly IDealLogic _dealLogic;
+ public FormGeneration(IDealLogic dealLogic)
+ {
+ InitializeComponent();
+ _dealLogic = dealLogic;
+ }
+
+ private void ButtonGetTest_Click(object sender, EventArgs e)
+ {
+ textBoxGet.Text = _dealLogic.GetTest(Convert.ToInt32(numericGet.Value)) + "мс";
+ }
+
+ private void ButtonDiffGetTest_Click(object sender, EventArgs e)
+ {
+ textBoxDiffGet.Text = _dealLogic.DiffGetTest(Convert.ToInt32(numericDiffGet.Value)) + "мс";
+ }
+
+ private void ButtonSetTest_Click(object sender, EventArgs e)
+ {
+ textBoxSet.Text = _dealLogic.SetTest(Convert.ToInt32(numericSet.Value)) + "мс";
+ }
+
+ private void ButtonClear_Click(object sender, EventArgs e)
+ {
+ if (_dealLogic.ClearList())
+ {
+ MessageBox.Show("Удаление записей завершено", "Успешно", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ return;
+ }
+ MessageBox.Show("Удаление записей провалилось", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+}
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormGeneration.resx b/PersonnelDepartment/PersonnelDepartmentView/FormGeneration.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormGeneration.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/PersonnelDepartment/PersonnelDepartmentView/FormPosition.Designer.cs b/PersonnelDepartment/PersonnelDepartmentView/FormPosition.Designer.cs
new file mode 100644
index 0000000..971ffdb
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormPosition.Designer.cs
@@ -0,0 +1,98 @@
+namespace PersonnelDepartmentView
+{
+ partial class FormPosition
+ {
+ ///
+ /// 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()
+ {
+ buttonCancel = new Button();
+ buttonSave = new Button();
+ label1 = new Label();
+ textBoxName = new TextBox();
+ SuspendLayout();
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(112, 56);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 7;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(31, 56);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 6;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(15, 15);
+ label1.Name = "label1";
+ label1.Size = new Size(62, 15);
+ label1.TabIndex = 5;
+ label1.Text = "Название:";
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(80, 12);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(107, 23);
+ textBoxName.TabIndex = 4;
+ //
+ // FormPosition
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(205, 92);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(label1);
+ Controls.Add(textBoxName);
+ FormBorderStyle = FormBorderStyle.FixedSingle;
+ Name = "FormPosition";
+ StartPosition = FormStartPosition.CenterScreen;
+ Text = "Должность";
+ Load += FormPosition_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button buttonCancel;
+ private Button buttonSave;
+ private Label label1;
+ private TextBox textBoxName;
+ }
+}
\ No newline at end of file
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormPosition.cs b/PersonnelDepartment/PersonnelDepartmentView/FormPosition.cs
new file mode 100644
index 0000000..6396230
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormPosition.cs
@@ -0,0 +1,86 @@
+using PersonnelDepartmentBusinessLogic.BusinessLogics;
+using PersonnelDepartmentContracts.BindingModels;
+using PersonnelDepartmentContracts.BusinessLogicContracts;
+using PersonnelDepartmentContracts.SearchModels;
+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 PersonnelDepartmentView
+{
+ public partial class FormPosition : Form
+ {
+ private readonly IPositionLogic _positionLogic;
+ private int? _id;
+ public int Id { set { _id = value; } }
+ public FormPosition(IPositionLogic positionLogic)
+ {
+ InitializeComponent();
+ _positionLogic = positionLogic;
+ }
+
+ private void FormPosition_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ try
+ {
+ var view = _positionLogic.ReadElement(new PositionSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.Name;
+ }
+ }
+ catch (Exception 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;
+ }
+ try
+ {
+ var model = new PositionBindingModel
+ {
+ Id = _id ?? 0,
+ Name = textBoxName.Text
+ };
+ var operationResult = _id.HasValue ? _positionLogic.Update(model) : _positionLogic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormPosition.resx b/PersonnelDepartment/PersonnelDepartmentView/FormPosition.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormPosition.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/PersonnelDepartment/PersonnelDepartmentView/FormPositions.Designer.cs b/PersonnelDepartment/PersonnelDepartmentView/FormPositions.Designer.cs
new file mode 100644
index 0000000..e46911c
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormPositions.Designer.cs
@@ -0,0 +1,117 @@
+namespace PersonnelDepartmentView
+{
+ partial class FormPositions
+ {
+ ///
+ /// 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()
+ {
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonChange = new Button();
+ buttonAdd = new Button();
+ dataGridView = new DataGridView();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(255, 9);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(75, 23);
+ buttonUpdate.TabIndex = 9;
+ buttonUpdate.Text = "Обновить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(174, 9);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(75, 23);
+ buttonDelete.TabIndex = 8;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // buttonChange
+ //
+ buttonChange.Location = new Point(93, 9);
+ buttonChange.Name = "buttonChange";
+ buttonChange.Size = new Size(75, 23);
+ buttonChange.TabIndex = 7;
+ buttonChange.Text = "Изменить";
+ buttonChange.UseVisualStyleBackColor = true;
+ buttonChange.Click += ButtonChange_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(12, 9);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(75, 23);
+ buttonAdd.TabIndex = 6;
+ buttonAdd.Text = "Создать";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ dataGridView.BackgroundColor = Color.DarkSeaGreen;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 38);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.Size = new Size(564, 368);
+ dataGridView.TabIndex = 5;
+ //
+ // FormPositions
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(590, 418);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonChange);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ MinimumSize = new Size(400, 200);
+ Name = "FormPositions";
+ StartPosition = FormStartPosition.CenterScreen;
+ Text = "Таблица Должностей";
+ Load += FormPositions_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonChange;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormPositions.cs b/PersonnelDepartment/PersonnelDepartmentView/FormPositions.cs
new file mode 100644
index 0000000..4fbbb05
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormPositions.cs
@@ -0,0 +1,108 @@
+using PersonnelDepartmentBusinessLogic.BusinessLogics;
+using PersonnelDepartmentContracts.BindingModels;
+using PersonnelDepartmentContracts.BusinessLogicContracts;
+using PersonnelDepartmentContracts.SearchModels;
+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 PersonnelDepartmentView
+{
+ public partial class FormPositions : Form
+ {
+ private readonly IPositionLogic _positionLogic;
+ public FormPositions(IPositionLogic positionLogic)
+ {
+ InitializeComponent();
+ _positionLogic = positionLogic;
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _positionLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка загрузки", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPosition));
+ if (service is FormPosition form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonChange_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPosition));
+ if (service is FormPosition form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonDelete_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);
+ try
+ {
+ if (!_positionLogic.Delete(new PositionBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void FormPositions_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormPositions.resx b/PersonnelDepartment/PersonnelDepartmentView/FormPositions.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormPositions.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/PersonnelDepartment/PersonnelDepartmentView/FormType.Designer.cs b/PersonnelDepartment/PersonnelDepartmentView/FormType.Designer.cs
new file mode 100644
index 0000000..b45fd30
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormType.Designer.cs
@@ -0,0 +1,98 @@
+namespace PersonnelDepartmentView
+{
+ partial class FormType
+ {
+ ///
+ /// 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()
+ {
+ textBoxName = new TextBox();
+ label1 = new Label();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(78, 12);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(107, 23);
+ textBoxName.TabIndex = 0;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(13, 15);
+ label1.Name = "label1";
+ label1.Size = new Size(62, 15);
+ label1.TabIndex = 1;
+ label1.Text = "Название:";
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(29, 56);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 2;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += ButtonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(110, 56);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(75, 23);
+ buttonCancel.TabIndex = 3;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormType
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(204, 91);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(label1);
+ Controls.Add(textBoxName);
+ FormBorderStyle = FormBorderStyle.FixedSingle;
+ Name = "FormType";
+ StartPosition = FormStartPosition.CenterScreen;
+ Text = "Тип договора";
+ Load += FormType_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private TextBox textBoxName;
+ private Label label1;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormType.cs b/PersonnelDepartment/PersonnelDepartmentView/FormType.cs
new file mode 100644
index 0000000..57e820a
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormType.cs
@@ -0,0 +1,86 @@
+using PersonnelDepartmentBusinessLogic.BusinessLogics;
+using PersonnelDepartmentContracts.BindingModels;
+using PersonnelDepartmentContracts.BusinessLogicContracts;
+using PersonnelDepartmentContracts.SearchModels;
+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 PersonnelDepartmentView
+{
+ public partial class FormType : Form
+ {
+ private readonly ITypeLogic _typeLogic;
+ private int? _id;
+ public int Id { set { _id = value; } }
+ public FormType(ITypeLogic typeLogic)
+ {
+ InitializeComponent();
+ _typeLogic = typeLogic;
+ }
+
+ private void FormType_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ try
+ {
+ var view = _typeLogic.ReadElement(new TypeSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.Name;
+ }
+ }
+ catch (Exception 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;
+ }
+ try
+ {
+ var model = new TypeBindingModel
+ {
+ Id = _id ?? 0,
+ Name = textBoxName.Text
+ };
+ var operationResult = _id.HasValue ? _typeLogic.Update(model) : _typeLogic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormType.resx b/PersonnelDepartment/PersonnelDepartmentView/FormType.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormType.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/PersonnelDepartment/PersonnelDepartmentView/FormTypes.Designer.cs b/PersonnelDepartment/PersonnelDepartmentView/FormTypes.Designer.cs
new file mode 100644
index 0000000..9c8ac1a
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormTypes.Designer.cs
@@ -0,0 +1,117 @@
+namespace PersonnelDepartmentView
+{
+ partial class FormTypes
+ {
+ ///
+ /// 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()
+ {
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonChange = new Button();
+ buttonAdd = new Button();
+ dataGridView = new DataGridView();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(255, 9);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(75, 23);
+ buttonUpdate.TabIndex = 9;
+ buttonUpdate.Text = "Обновить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += ButtonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(174, 9);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(75, 23);
+ buttonDelete.TabIndex = 8;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += ButtonDelete_Click;
+ //
+ // buttonChange
+ //
+ buttonChange.Location = new Point(93, 9);
+ buttonChange.Name = "buttonChange";
+ buttonChange.Size = new Size(75, 23);
+ buttonChange.TabIndex = 7;
+ buttonChange.Text = "Изменить";
+ buttonChange.UseVisualStyleBackColor = true;
+ buttonChange.Click += ButtonChange_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(12, 9);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(75, 23);
+ buttonAdd.TabIndex = 6;
+ buttonAdd.Text = "Создать";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += ButtonAdd_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ dataGridView.BackgroundColor = Color.DarkSeaGreen;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 38);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.Size = new Size(564, 368);
+ dataGridView.TabIndex = 5;
+ //
+ // FormTypes
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(590, 420);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonChange);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ MinimumSize = new Size(400, 200);
+ Name = "FormTypes";
+ StartPosition = FormStartPosition.CenterScreen;
+ Text = "Таблица Типов";
+ Load += FormTypes_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonChange;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormTypes.cs b/PersonnelDepartment/PersonnelDepartmentView/FormTypes.cs
new file mode 100644
index 0000000..2b21f77
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormTypes.cs
@@ -0,0 +1,107 @@
+using PersonnelDepartmentBusinessLogic.BusinessLogics;
+using PersonnelDepartmentContracts.BindingModels;
+using PersonnelDepartmentContracts.BusinessLogicContracts;
+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 PersonnelDepartmentView
+{
+ public partial class FormTypes : Form
+ {
+ private readonly ITypeLogic _typeLogic;
+ public FormTypes(ITypeLogic typeLogic)
+ {
+ InitializeComponent();
+ _typeLogic = typeLogic;
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _typeLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка загрузки", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormType));
+ if (service is FormType form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonChange_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormType));
+ if (service is FormType form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonDelete_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);
+ try
+ {
+ if (!_typeLogic.Delete(new TypeBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+
+ private void ButtonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void FormTypes_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/PersonnelDepartment/PersonnelDepartmentView/FormTypes.resx b/PersonnelDepartment/PersonnelDepartmentView/FormTypes.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PersonnelDepartment/PersonnelDepartmentView/FormTypes.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/PersonnelDepartment/PersonnelDepartmentView/PersonnelDepartmentView.csproj b/PersonnelDepartment/PersonnelDepartmentView/PersonnelDepartmentView.csproj
index 54f7a40..60f5614 100644
--- a/PersonnelDepartment/PersonnelDepartmentView/PersonnelDepartmentView.csproj
+++ b/PersonnelDepartment/PersonnelDepartmentView/PersonnelDepartmentView.csproj
@@ -16,4 +16,10 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PersonnelDepartment/PersonnelDepartmentView/Program.cs b/PersonnelDepartment/PersonnelDepartmentView/Program.cs
index ce6151b..71db762 100644
--- a/PersonnelDepartment/PersonnelDepartmentView/Program.cs
+++ b/PersonnelDepartment/PersonnelDepartmentView/Program.cs
@@ -1,17 +1,59 @@
+using System;
+using Microsoft.Extensions.DependencyInjection;
+using PersonnelDepartmentBusinessLogic.BusinessLogics;
+using PersonnelDepartmentContracts.BusinessLogicContracts;
+using PersonnelDepartmentContracts.StoragesContracts;
+using PersonnelDepartmentDatabaseImplement.Implements;
+using PersonnelTypeContracts.StoragesContracts;
+
namespace PersonnelDepartmentView
{
- internal static class Program
- {
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- static void Main()
- {
- // To customize application configuration such as set high DPI settings or default font,
- // see https://aka.ms/applicationconfiguration.
- ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
- }
- }
+ internal static class Program
+ {
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ // To customize application configuration such as set high DPI settings or default font,
+ // see https://aka.ms/applicationconfiguration.
+ ApplicationConfiguration.Initialize();
+ var services = new ServiceCollection();
+ ConfigureServices(services);
+ _serviceProvider = services.BuildServiceProvider();
+ Application.Run(_serviceProvider.GetRequiredService());
+ }
+
+ private static void ConfigureServices(ServiceCollection services)
+ {
+ 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();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ }
+ }
}
\ No newline at end of file