diff --git a/LawFirm/LawFirm.sln b/LawFirm/LawFirm.sln
index bbe56d6..49deb79 100644
--- a/LawFirm/LawFirm.sln
+++ b/LawFirm/LawFirm.sln
@@ -3,7 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34221.43
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirm", "LawFirm\LawFirm.csproj", "{003F906D-2F68-43B6-9668-BF3CE918739B}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LawFirmView", "LawFirm\LawFirmView.csproj", "{003F906D-2F68-43B6-9668-BF3CE918739B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmDataModels", "LawFirmDataModels\LawFirmDataModels.csproj", "{89AE92AD-3D6A-4C2F-AA8A-E36D895A55C8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmContracts", "LawFirmContracts\LawFirmContracts.csproj", "{6EB55DC4-8665-49CB-A0E6-DAF6E3CE58D3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmListImplement", "LawFirmListImplement\LawFirmListImplement.csproj", "{8B5C5B0D-7F02-4178-A047-13FE2D659A8A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmBusinessLogic", "LawFirmBusinessLogic\LawFirmBusinessLogic.csproj", "{0EB8CCEC-83C2-4425-A963-7979DB147D82}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +23,22 @@ Global
{003F906D-2F68-43B6-9668-BF3CE918739B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{003F906D-2F68-43B6-9668-BF3CE918739B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{003F906D-2F68-43B6-9668-BF3CE918739B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {89AE92AD-3D6A-4C2F-AA8A-E36D895A55C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {89AE92AD-3D6A-4C2F-AA8A-E36D895A55C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {89AE92AD-3D6A-4C2F-AA8A-E36D895A55C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {89AE92AD-3D6A-4C2F-AA8A-E36D895A55C8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6EB55DC4-8665-49CB-A0E6-DAF6E3CE58D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6EB55DC4-8665-49CB-A0E6-DAF6E3CE58D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6EB55DC4-8665-49CB-A0E6-DAF6E3CE58D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6EB55DC4-8665-49CB-A0E6-DAF6E3CE58D3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8B5C5B0D-7F02-4178-A047-13FE2D659A8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8B5C5B0D-7F02-4178-A047-13FE2D659A8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8B5C5B0D-7F02-4178-A047-13FE2D659A8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8B5C5B0D-7F02-4178-A047-13FE2D659A8A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0EB8CCEC-83C2-4425-A963-7979DB147D82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0EB8CCEC-83C2-4425-A963-7979DB147D82}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0EB8CCEC-83C2-4425-A963-7979DB147D82}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0EB8CCEC-83C2-4425-A963-7979DB147D82}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/LawFirm/LawFirm/Form1.Designer.cs b/LawFirm/LawFirm/Form1.Designer.cs
deleted file mode 100644
index cbe84f0..0000000
--- a/LawFirm/LawFirm/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace LawFirm
-{
- 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
- }
-}
\ No newline at end of file
diff --git a/LawFirm/LawFirm/Form1.cs b/LawFirm/LawFirm/Form1.cs
deleted file mode 100644
index d090cf4..0000000
--- a/LawFirm/LawFirm/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace LawFirm
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/LawFirm/LawFirm/FormBlank.Designer.cs b/LawFirm/LawFirm/FormBlank.Designer.cs
new file mode 100644
index 0000000..27073fa
--- /dev/null
+++ b/LawFirm/LawFirm/FormBlank.Designer.cs
@@ -0,0 +1,118 @@
+namespace LawFirmView
+{
+ partial class FormBlank
+ {
+ ///
+ /// 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()
+ {
+ labelName = new Label();
+ labelPrice = new Label();
+ textBoxName = new TextBox();
+ textBoxPrice = new TextBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelName
+ //
+ labelName.AutoSize = true;
+ labelName.Location = new Point(24, 26);
+ labelName.Name = "labelName";
+ labelName.Size = new Size(80, 20);
+ labelName.TabIndex = 0;
+ labelName.Text = "Название:";
+ //
+ // labelPrice
+ //
+ labelPrice.AutoSize = true;
+ labelPrice.Location = new Point(24, 64);
+ labelPrice.Name = "labelPrice";
+ labelPrice.Size = new Size(48, 20);
+ labelPrice.TabIndex = 1;
+ labelPrice.Text = "Цена:";
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(110, 26);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(386, 27);
+ textBoxName.TabIndex = 2;
+ //
+ // textBoxPrice
+ //
+ textBoxPrice.Location = new Point(110, 61);
+ textBoxPrice.Name = "textBoxPrice";
+ textBoxPrice.Size = new Size(386, 27);
+ textBoxPrice.TabIndex = 3;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(280, 106);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(94, 29);
+ buttonSave.TabIndex = 4;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(402, 106);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ buttonCancel.TabIndex = 5;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // FormBlank
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(528, 157);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxPrice);
+ Controls.Add(textBoxName);
+ Controls.Add(labelPrice);
+ Controls.Add(labelName);
+ Name = "FormBlank";
+ Text = "Бланк";
+ Load += FormBlank_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelName;
+ private Label labelPrice;
+ private TextBox textBoxName;
+ private TextBox textBoxPrice;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirm/FormBlank.cs b/LawFirm/LawFirm/FormBlank.cs
new file mode 100644
index 0000000..1ecf652
--- /dev/null
+++ b/LawFirm/LawFirm/FormBlank.cs
@@ -0,0 +1,86 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.BusinessLogicsContracts;
+using LawFirmContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+namespace LawFirmView
+{
+ public partial class FormBlank : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IBlankLogic _logic;
+ private int? _id;
+ public int Id { set { _id = value; } }
+ public FormBlank(ILogger logger, IBlankLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение бланка");
+ try
+ {
+ var model = new BlankBindingModel
+ {
+ Id = _id ?? 0,
+ BlankName = textBoxName.Text,
+ Price = Convert.ToDouble(textBoxPrice.Text)
+ };
+ var operationResult = _id.HasValue ? _logic.Update(model) :
+ _logic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. " + "Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения бланка");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ private void FormBlank_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ try
+ {
+ _logger.LogInformation("Получение бланка");
+ var view = _logic.ReadElement(new BlankSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.BlankName;
+ textBoxPrice.Text = view.Price.ToString();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения бланка");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+}
diff --git a/LawFirm/LawFirm/Form1.resx b/LawFirm/LawFirm/FormBlank.resx
similarity index 93%
rename from LawFirm/LawFirm/Form1.resx
rename to LawFirm/LawFirm/FormBlank.resx
index 1af7de1..af32865 100644
--- a/LawFirm/LawFirm/Form1.resx
+++ b/LawFirm/LawFirm/FormBlank.resx
@@ -1,17 +1,17 @@
-
diff --git a/LawFirm/LawFirm/FormBlanks.Designer.cs b/LawFirm/LawFirm/FormBlanks.Designer.cs
new file mode 100644
index 0000000..4a79ad5
--- /dev/null
+++ b/LawFirm/LawFirm/FormBlanks.Designer.cs
@@ -0,0 +1,123 @@
+namespace LawFirmView
+{
+ partial class FormBlanks
+ {
+ ///
+ /// 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();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.BackgroundColor = Color.White;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Dock = DockStyle.Left;
+ dataGridView.Location = new Point(0, 0);
+ dataGridView.Margin = new Padding(4, 3, 4, 3);
+ dataGridView.MultiSelect = false;
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersVisible = false;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+ dataGridView.Size = new Size(571, 617);
+ dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(578, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(166, 30);
+ buttonAdd.TabIndex = 1;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // buttonChange
+ //
+ buttonChange.Location = new Point(578, 57);
+ buttonChange.Name = "buttonChange";
+ buttonChange.Size = new Size(166, 30);
+ buttonChange.TabIndex = 2;
+ buttonChange.Text = "Изменить";
+ buttonChange.UseVisualStyleBackColor = true;
+ buttonChange.Click += buttonChange_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(578, 102);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(166, 30);
+ buttonDelete.TabIndex = 3;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += buttonDelete_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(578, 147);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(166, 30);
+ buttonUpdate.TabIndex = 4;
+ buttonUpdate.Text = "Обновить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += buttonUpdate_Click;
+ //
+ // FormBlanks
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(751, 617);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonChange);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ Name = "FormBlanks";
+ Text = "Бланки";
+ Load += FormBlanks_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonChange;
+ private Button buttonDelete;
+ private Button buttonUpdate;
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirm/FormBlanks.cs b/LawFirm/LawFirm/FormBlanks.cs
new file mode 100644
index 0000000..5e73ed7
--- /dev/null
+++ b/LawFirm/LawFirm/FormBlanks.cs
@@ -0,0 +1,102 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+
+namespace LawFirmView
+{
+ public partial class FormBlanks : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IBlankLogic _logic;
+ public FormBlanks(ILogger logger, IBlankLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void FormBlanks_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns["BlankName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ _logger.LogInformation("Загрузка бланков");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки бланков");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormBlank));
+ if (service is FormBlank 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(FormBlank));
+ if (service is FormBlank 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);
+ _logger.LogInformation("Удаление бланка");
+ try
+ {
+ if (!_logic.Delete(new BlankBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. " +
+ "Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления бланка");
+ MessageBox.Show(ex.Message, "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void buttonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/LawFirm/LawFirm/FormBlanks.resx b/LawFirm/LawFirm/FormBlanks.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/LawFirm/LawFirm/FormBlanks.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/LawFirm/LawFirm/FormCreateOrder.Designer.cs b/LawFirm/LawFirm/FormCreateOrder.Designer.cs
new file mode 100644
index 0000000..3047e38
--- /dev/null
+++ b/LawFirm/LawFirm/FormCreateOrder.Designer.cs
@@ -0,0 +1,143 @@
+namespace LawFirmView
+{
+ partial class FormCreateOrder
+ {
+ ///
+ /// 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()
+ {
+ labelDocument = new Label();
+ labelCount = new Label();
+ labelSum = new Label();
+ comboBoxDocument = new ComboBox();
+ textBoxCount = new TextBox();
+ textBoxSum = new TextBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelDocument
+ //
+ labelDocument.AutoSize = true;
+ labelDocument.Location = new Point(23, 30);
+ labelDocument.Name = "labelDocument";
+ labelDocument.Size = new Size(79, 20);
+ labelDocument.TabIndex = 0;
+ labelDocument.Text = "Документ:";
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(23, 70);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(84, 20);
+ labelCount.TabIndex = 1;
+ labelCount.Text = "Кличество:";
+ //
+ // labelSum
+ //
+ labelSum.AutoSize = true;
+ labelSum.Location = new Point(23, 112);
+ labelSum.Name = "labelSum";
+ labelSum.Size = new Size(58, 20);
+ labelSum.TabIndex = 2;
+ labelSum.Text = "Сумма:";
+ //
+ // comboBoxDocument
+ //
+ comboBoxDocument.FormattingEnabled = true;
+ comboBoxDocument.Location = new Point(122, 27);
+ comboBoxDocument.Name = "comboBoxDocument";
+ comboBoxDocument.Size = new Size(301, 28);
+ comboBoxDocument.TabIndex = 3;
+ comboBoxDocument.SelectedIndexChanged += comboBoxDocument_SelectedIndexChanged;
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(122, 67);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(301, 27);
+ textBoxCount.TabIndex = 4;
+ textBoxCount.TextChanged += textBoxCount_TextChanged;
+ //
+ // textBoxSum
+ //
+ textBoxSum.Location = new Point(122, 105);
+ textBoxSum.Name = "textBoxSum";
+ textBoxSum.Size = new Size(301, 27);
+ textBoxSum.TabIndex = 5;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(202, 166);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(94, 29);
+ buttonSave.TabIndex = 6;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(329, 166);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ buttonCancel.TabIndex = 7;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // FormCreateOrder
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(435, 224);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxSum);
+ Controls.Add(textBoxCount);
+ Controls.Add(comboBoxDocument);
+ Controls.Add(labelSum);
+ Controls.Add(labelCount);
+ Controls.Add(labelDocument);
+ Name = "FormCreateOrder";
+ Text = "Заказ";
+ Load += FormCreateOrder_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelDocument;
+ private Label labelCount;
+ private Label labelSum;
+ private ComboBox comboBoxDocument;
+ private TextBox textBoxCount;
+ private TextBox textBoxSum;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirm/FormCreateOrder.cs b/LawFirm/LawFirm/FormCreateOrder.cs
new file mode 100644
index 0000000..3102e03
--- /dev/null
+++ b/LawFirm/LawFirm/FormCreateOrder.cs
@@ -0,0 +1,117 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.BusinessLogicsContracts;
+using LawFirmContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+namespace LawFirmView
+{
+ public partial class FormCreateOrder : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IDocumentLogic _logicD;
+ private readonly IOrderLogic _logicO;
+ public FormCreateOrder(ILogger logger, IDocumentLogic logicD, IOrderLogic logicO)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicD = logicD;
+ _logicO = logicO;
+ }
+ private void FormCreateOrder_Load(object sender, EventArgs e)
+ {
+ _logger.LogInformation("Загрузка документов для заказа");
+ try
+ {
+ var list = _logicD.ReadList(null);
+ if (list != null)
+ {
+ comboBoxDocument.DisplayMember = "DocumentName";
+ comboBoxDocument.ValueMember = "Id";
+ comboBoxDocument.DataSource = list;
+ comboBoxDocument.SelectedItem = null;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки документов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void CalcSum()
+ {
+ if (comboBoxDocument.SelectedValue != null &&
+ !string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ try
+ {
+ int id = Convert.ToInt32(comboBoxDocument.SelectedValue);
+ var document = _logicD.ReadElement(new DocumentSearchModel
+ {
+ Id = id
+ });
+ int count = Convert.ToInt32(textBoxCount.Text);
+ textBoxSum.Text = Math.Round(count * (document?.Price ?? 0), 2).ToString();
+ _logger.LogInformation("Расчет суммы заказа");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка расчета суммы заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void textBoxCount_TextChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+ private void comboBoxDocument_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxDocument.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите документ", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Создание заказа");
+ try
+ {
+ var operationResult = _logicO.CreateOrder(new OrderBindingModel
+ {
+ DocumentId = Convert.ToInt32(comboBoxDocument.SelectedValue),
+ Count = Convert.ToInt32(textBoxCount.Text),
+ Sum = Convert.ToDouble(textBoxSum.Text)
+ });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка создания заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/LawFirm/LawFirm/FormCreateOrder.resx b/LawFirm/LawFirm/FormCreateOrder.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/LawFirm/LawFirm/FormCreateOrder.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/LawFirm/LawFirm/FormDocument.Designer.cs b/LawFirm/LawFirm/FormDocument.Designer.cs
new file mode 100644
index 0000000..e5eb270
--- /dev/null
+++ b/LawFirm/LawFirm/FormDocument.Designer.cs
@@ -0,0 +1,236 @@
+namespace LawFirmView
+{
+ partial class FormDocument
+ {
+ ///
+ /// 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()
+ {
+ labelName = new Label();
+ labelPrice = new Label();
+ textBoxName = new TextBox();
+ textBoxPrice = new TextBox();
+ groupBox = new GroupBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ buttonAdd = new Button();
+ buttonChange = new Button();
+ buttonDelete = new Button();
+ buttonUpdate = new Button();
+ dataGridView = new DataGridView();
+ BlankId = new DataGridViewTextBoxColumn();
+ Blank = new DataGridViewTextBoxColumn();
+ Count = new DataGridViewTextBoxColumn();
+ groupBox.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // labelName
+ //
+ labelName.AutoSize = true;
+ labelName.Location = new Point(22, 25);
+ labelName.Name = "labelName";
+ labelName.Size = new Size(80, 20);
+ labelName.TabIndex = 0;
+ labelName.Text = "Название:";
+ //
+ // labelPrice
+ //
+ labelPrice.AutoSize = true;
+ labelPrice.Location = new Point(22, 60);
+ labelPrice.Name = "labelPrice";
+ labelPrice.Size = new Size(86, 20);
+ labelPrice.TabIndex = 1;
+ labelPrice.Text = "Стоимость:";
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(124, 25);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(229, 27);
+ textBoxName.TabIndex = 2;
+ //
+ // textBoxPrice
+ //
+ textBoxPrice.Location = new Point(124, 60);
+ textBoxPrice.Name = "textBoxPrice";
+ textBoxPrice.Size = new Size(229, 27);
+ textBoxPrice.TabIndex = 3;
+ //
+ // groupBox
+ //
+ groupBox.Controls.Add(dataGridView);
+ groupBox.Controls.Add(buttonUpdate);
+ groupBox.Controls.Add(buttonDelete);
+ groupBox.Controls.Add(buttonChange);
+ groupBox.Controls.Add(buttonAdd);
+ groupBox.Location = new Point(12, 118);
+ groupBox.Name = "groupBox";
+ groupBox.Size = new Size(707, 468);
+ groupBox.TabIndex = 4;
+ groupBox.TabStop = false;
+ groupBox.Text = "Бланки";
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(502, 592);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(94, 29);
+ buttonSave.TabIndex = 5;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(625, 592);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ buttonCancel.TabIndex = 6;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(573, 41);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(94, 29);
+ buttonAdd.TabIndex = 7;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // buttonChange
+ //
+ buttonChange.Location = new Point(573, 85);
+ buttonChange.Name = "buttonChange";
+ buttonChange.Size = new Size(94, 29);
+ buttonChange.TabIndex = 8;
+ buttonChange.Text = "Изменить";
+ buttonChange.UseVisualStyleBackColor = true;
+ buttonChange.Click += buttonChange_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(573, 130);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(94, 29);
+ buttonDelete.TabIndex = 9;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += buttonDelete_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(573, 176);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(94, 29);
+ buttonUpdate.TabIndex = 10;
+ buttonUpdate.Text = "Обновить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += buttonUpdate_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.BackgroundColor = Color.White;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Columns.AddRange(new DataGridViewColumn[] { BlankId, Blank, Count });
+ dataGridView.Location = new Point(10, 26);
+ dataGridView.Margin = new Padding(3, 4, 3, 4);
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(528, 436);
+ dataGridView.TabIndex = 0;
+ //
+ // BlankId
+ //
+ BlankId.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
+ BlankId.HeaderText = "ID";
+ BlankId.MinimumWidth = 6;
+ BlankId.Name = "BlankId";
+ BlankId.ReadOnly = true;
+ BlankId.Visible = false;
+ BlankId.Width = 125;
+ //
+ // Blank
+ //
+ Blank.HeaderText = "Бланк";
+ Blank.MinimumWidth = 6;
+ Blank.Name = "Blank";
+ Blank.ReadOnly = true;
+ //
+ // Count
+ //
+ Count.HeaderText = "Количество";
+ Count.MinimumWidth = 6;
+ Count.Name = "Count";
+ Count.ReadOnly = true;
+ //
+ // FormDocument
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(731, 628);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(groupBox);
+ Controls.Add(textBoxPrice);
+ Controls.Add(textBoxName);
+ Controls.Add(labelPrice);
+ Controls.Add(labelName);
+ Name = "FormDocument";
+ Text = "Документ";
+ Load += FormDocument_Load;
+ groupBox.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelName;
+ private Label labelPrice;
+ private TextBox textBoxName;
+ private TextBox textBoxPrice;
+ private GroupBox groupBox;
+ private Button buttonSave;
+ private Button buttonCancel;
+ private DataGridView dataGridView;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonChange;
+ private Button buttonAdd;
+ private DataGridViewTextBoxColumn BlankId;
+ private DataGridViewTextBoxColumn Blank;
+ private DataGridViewTextBoxColumn Count;
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirm/FormDocument.cs b/LawFirm/LawFirm/FormDocument.cs
new file mode 100644
index 0000000..3cb4683
--- /dev/null
+++ b/LawFirm/LawFirm/FormDocument.cs
@@ -0,0 +1,213 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.BusinessLogicsContracts;
+using LawFirmContracts.SearchModels;
+using LawFirmDataModels.Models;
+using Microsoft.Extensions.Logging;
+
+namespace LawFirmView
+{
+ public partial class FormDocument : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IDocumentLogic _logic;
+ private int? _id;
+ private Dictionary _documentBlanks;
+ public int Id { set { _id = value; } }
+ public FormDocument(ILogger logger, IDocumentLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _documentBlanks = new Dictionary();
+ }
+ private void FormDocument_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Загрузка документа");
+ try
+ {
+ var view = _logic.ReadElement(new DocumentSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.DocumentName;
+ textBoxPrice.Text = view.Price.ToString();
+ _documentBlanks = view.DocumentBlanks ?? new
+ Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки документа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка бланков документа");
+ try
+ {
+ if (_documentBlanks != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var pc in _documentBlanks)
+ {
+ dataGridView.Rows.Add(new object[] { pc.Value.Item1.BlankName, pc.Value.Item2, pc.Key });
+ }
+ textBoxPrice.Text = CalcPrice().ToString();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки бланков документа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ var service =
+ Program.ServiceProvider?.GetService(typeof(FormDocumentBlank));
+ if (service is FormDocumentBlank form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.BlankModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Добавление нового бланка:{BlankName} - { Count}",
+ form.BlankModel.BlankName, form.Count);
+ if (_documentBlanks.ContainsKey(form.Id))
+ {
+ _documentBlanks[form.Id] = (form.BlankModel,
+ form.Count);
+ }
+ else
+ {
+ _documentBlanks.Add(form.Id, (form.BlankModel,
+ form.Count));
+ }
+ LoadData();
+ }
+ }
+ }
+ private void buttonChange_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormDocumentBlank));
+ if (service is FormDocumentBlank form)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
+ form.Id = id;
+ form.Count = _documentBlanks[id].Item2;
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.BlankModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Изменение бланка: {BlankName} - { Count}",
+ form.BlankModel.BlankName, form.Count);
+ _documentBlanks[form.Id] = (form.BlankModel, form.Count);
+ LoadData();
+ }
+ }
+ }
+ }
+ private void buttonDelete_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ try
+ {
+ _logger.LogInformation("Удаление бланка: {BlankName} - { Count}",
+ dataGridView.SelectedRows[0].Cells[1].Value);
+ _documentBlanks?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ LoadData();
+ }
+ }
+ }
+ private void buttonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (string.IsNullOrEmpty(textBoxPrice.Text))
+ {
+ MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ return;
+ }
+ if (_documentBlanks == null || _documentBlanks.Count == 0)
+ {
+ MessageBox.Show("Заполните бланки", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение документа");
+ try
+ {
+ var model = new DocumentBindingModel
+ {
+ Id = _id ?? 0,
+ DocumentName = textBoxName.Text,
+ Price = Convert.ToDouble(textBoxPrice.Text),
+ DocumentBlanks = _documentBlanks
+ };
+ var operationResult = _id.HasValue ? _logic.Update(model) :
+ _logic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения документа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ private double CalcPrice()
+ {
+ double price = 0;
+ foreach (var elem in _documentBlanks)
+ {
+ price += ((elem.Value.Item1?.Price ?? 0) * elem.Value.Item2);
+ }
+ return Math.Round(price * 1.1, 2);
+ }
+ }
+}
diff --git a/LawFirm/LawFirm/FormDocument.resx b/LawFirm/LawFirm/FormDocument.resx
new file mode 100644
index 0000000..8ea99a0
--- /dev/null
+++ b/LawFirm/LawFirm/FormDocument.resx
@@ -0,0 +1,138 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
\ No newline at end of file
diff --git a/LawFirm/LawFirm/FormDocumentBlank.Designer.cs b/LawFirm/LawFirm/FormDocumentBlank.Designer.cs
new file mode 100644
index 0000000..29b0cb0
--- /dev/null
+++ b/LawFirm/LawFirm/FormDocumentBlank.Designer.cs
@@ -0,0 +1,118 @@
+namespace LawFirmView
+{
+ partial class FormDocumentBlank
+ {
+ ///
+ /// 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()
+ {
+ labelBlank = new Label();
+ labelCount = new Label();
+ comboBoxBlank = new ComboBox();
+ textBoxCount = new TextBox();
+ buttonSave = new Button();
+ buttonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelBlank
+ //
+ labelBlank.AutoSize = true;
+ labelBlank.Location = new Point(12, 28);
+ labelBlank.Name = "labelBlank";
+ labelBlank.Size = new Size(53, 20);
+ labelBlank.TabIndex = 0;
+ labelBlank.Text = "Бланк:";
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(12, 75);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(93, 20);
+ labelCount.TabIndex = 1;
+ labelCount.Text = "Количество:";
+ //
+ // comboBoxBlank
+ //
+ comboBoxBlank.FormattingEnabled = true;
+ comboBoxBlank.Location = new Point(124, 28);
+ comboBoxBlank.Name = "comboBoxBlank";
+ comboBoxBlank.Size = new Size(315, 28);
+ comboBoxBlank.TabIndex = 2;
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(124, 75);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(315, 27);
+ textBoxCount.TabIndex = 3;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(225, 121);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(94, 29);
+ buttonSave.TabIndex = 4;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(345, 121);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(94, 29);
+ buttonCancel.TabIndex = 5;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += buttonCancel_Click;
+ //
+ // FormDocumentBlank
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(451, 171);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(textBoxCount);
+ Controls.Add(comboBoxBlank);
+ Controls.Add(labelCount);
+ Controls.Add(labelBlank);
+ Name = "FormDocumentBlank";
+ Text = "FormDocumentBlank";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelBlank;
+ private Label labelCount;
+ private ComboBox comboBoxBlank;
+ private TextBox textBoxCount;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirm/FormDocumentBlank.cs b/LawFirm/LawFirm/FormDocumentBlank.cs
new file mode 100644
index 0000000..7045d75
--- /dev/null
+++ b/LawFirm/LawFirm/FormDocumentBlank.cs
@@ -0,0 +1,79 @@
+using LawFirmContracts.BusinessLogicsContracts;
+using LawFirmContracts.ViewModels;
+using LawFirmDataModels.Models;
+
+namespace LawFirmView
+{
+ public partial class FormDocumentBlank : Form
+ {
+ private readonly List? _list;
+ public int Id
+ {
+ get
+ {
+ return Convert.ToInt32(comboBoxBlank.SelectedValue);
+ }
+ set
+ {
+ comboBoxBlank.SelectedValue = value;
+ }
+ }
+ public IBlankModel? BlankModel
+ {
+ get
+ {
+ if (_list == null)
+ {
+ return null;
+ }
+ foreach (var elem in _list)
+ {
+ if (elem.Id == Id)
+ {
+ return elem;
+ }
+ }
+ return null;
+ }
+ }
+ public int Count
+ {
+ get { return Convert.ToInt32(textBoxCount.Text); }
+ set { textBoxCount.Text = value.ToString(); }
+ }
+ public FormDocumentBlank(IBlankLogic logic)
+ {
+ InitializeComponent();
+ _list = logic.ReadList(null);
+ if (_list != null)
+ {
+ comboBoxBlank.DisplayMember = "BlankName";
+ comboBoxBlank.ValueMember = "Id";
+ comboBoxBlank.DataSource = _list;
+ comboBoxBlank.SelectedItem = null;
+ }
+ }
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxBlank.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите компонент", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/LawFirm/LawFirm/FormDocumentBlank.resx b/LawFirm/LawFirm/FormDocumentBlank.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/LawFirm/LawFirm/FormDocumentBlank.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/LawFirm/LawFirm/FormDocuments.Designer.cs b/LawFirm/LawFirm/FormDocuments.Designer.cs
new file mode 100644
index 0000000..3a1e8c3
--- /dev/null
+++ b/LawFirm/LawFirm/FormDocuments.Designer.cs
@@ -0,0 +1,119 @@
+namespace LawFirmView
+{
+ partial class FormDocuments
+ {
+ ///
+ /// 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();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.BackgroundColor = Color.White;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(0, 0);
+ dataGridView.Margin = new Padding(3, 4, 3, 4);
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(572, 594);
+ dataGridView.TabIndex = 5;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(578, 12);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(155, 29);
+ buttonAdd.TabIndex = 6;
+ buttonAdd.Text = "Добавить";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // buttonChange
+ //
+ buttonChange.Location = new Point(578, 56);
+ buttonChange.Name = "buttonChange";
+ buttonChange.Size = new Size(155, 29);
+ buttonChange.TabIndex = 8;
+ buttonChange.Text = "Изменить";
+ buttonChange.UseVisualStyleBackColor = true;
+ buttonChange.Click += buttonChange_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(578, 102);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(155, 29);
+ buttonDelete.TabIndex = 9;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += buttonDelete_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(578, 148);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(155, 29);
+ buttonUpdate.TabIndex = 10;
+ buttonUpdate.Text = "Обновить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += buttonUpdate_Click;
+ //
+ // FormDocuments
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(739, 596);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonChange);
+ Controls.Add(buttonAdd);
+ Controls.Add(dataGridView);
+ Name = "FormDocuments";
+ Text = "Документы";
+ Load += FormDocuments_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonChange;
+ private Button buttonDelete;
+ private Button buttonUpdate;
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirm/FormDocuments.cs b/LawFirm/LawFirm/FormDocuments.cs
new file mode 100644
index 0000000..024f362
--- /dev/null
+++ b/LawFirm/LawFirm/FormDocuments.cs
@@ -0,0 +1,103 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+
+namespace LawFirmView
+{
+ public partial class FormDocuments : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IDocumentLogic _logic;
+ public FormDocuments(ILogger logger, IDocumentLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void FormDocuments_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns["DocumentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["DocumentBlanks"].Visible = false;
+ }
+ _logger.LogInformation("Загрузка документов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки документов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormDocument));
+ if (service is FormDocument 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(FormDocument));
+ if (service is FormDocument 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);
+ _logger.LogInformation("Удаление бланка");
+ try
+ {
+ if (!_logic.Delete(new DocumentBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. " +
+ "Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления документа");
+ MessageBox.Show(ex.Message, "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void buttonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/LawFirm/LawFirm/FormDocuments.resx b/LawFirm/LawFirm/FormDocuments.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/LawFirm/LawFirm/FormDocuments.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/LawFirm/LawFirm/FormMain.Designer.cs b/LawFirm/LawFirm/FormMain.Designer.cs
new file mode 100644
index 0000000..2c5ca26
--- /dev/null
+++ b/LawFirm/LawFirm/FormMain.Designer.cs
@@ -0,0 +1,177 @@
+namespace LawFirmView
+{
+ partial class FormMain
+ {
+ ///
+ /// 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()
+ {
+ menuStrip = new MenuStrip();
+ toolStripMenuItem = new ToolStripMenuItem();
+ BlanksToolStripMenuItem = new ToolStripMenuItem();
+ DocumentsToolStripMenuItem = new ToolStripMenuItem();
+ dataGridView = new DataGridView();
+ buttonCreateOrder = new Button();
+ buttonTakeOrderInWork = new Button();
+ buttonOrderReady = new Button();
+ buttonIssuedOrder = new Button();
+ buttonUpdate = new Button();
+ menuStrip.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // menuStrip
+ //
+ menuStrip.ImageScalingSize = new Size(20, 20);
+ menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem });
+ menuStrip.Location = new Point(0, 0);
+ menuStrip.Name = "menuStrip";
+ menuStrip.Size = new Size(929, 28);
+ menuStrip.TabIndex = 0;
+ menuStrip.Text = "Справочники";
+ //
+ // toolStripMenuItem
+ //
+ toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { BlanksToolStripMenuItem, DocumentsToolStripMenuItem });
+ toolStripMenuItem.Name = "toolStripMenuItem";
+ toolStripMenuItem.Size = new Size(117, 24);
+ toolStripMenuItem.Text = "Справочники";
+ //
+ // BlanksToolStripMenuItem
+ //
+ BlanksToolStripMenuItem.Name = "BlanksToolStripMenuItem";
+ BlanksToolStripMenuItem.Size = new Size(224, 26);
+ BlanksToolStripMenuItem.Text = "Бланки";
+ BlanksToolStripMenuItem.Click += BlanksToolStripMenuItem_Click;
+ //
+ // DocumentsToolStripMenuItem
+ //
+ DocumentsToolStripMenuItem.Name = "DocumentsToolStripMenuItem";
+ DocumentsToolStripMenuItem.Size = new Size(224, 26);
+ DocumentsToolStripMenuItem.Text = "Документы";
+ DocumentsToolStripMenuItem.Click += DocumentsToolStripMenuItem_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.BackgroundColor = Color.White;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 31);
+ dataGridView.Margin = new Padding(3, 4, 3, 4);
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(714, 606);
+ dataGridView.TabIndex = 1;
+ //
+ // buttonCreateOrder
+ //
+ buttonCreateOrder.Location = new Point(732, 42);
+ buttonCreateOrder.Name = "buttonCreateOrder";
+ buttonCreateOrder.Size = new Size(185, 29);
+ buttonCreateOrder.TabIndex = 2;
+ buttonCreateOrder.Text = "Создать заказ";
+ buttonCreateOrder.UseVisualStyleBackColor = true;
+ buttonCreateOrder.Click += buttonCreateOrder_Click;
+ //
+ // buttonTakeOrderInWork
+ //
+ buttonTakeOrderInWork.Location = new Point(732, 86);
+ buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
+ buttonTakeOrderInWork.Size = new Size(185, 29);
+ buttonTakeOrderInWork.TabIndex = 3;
+ buttonTakeOrderInWork.Text = "Отдать на выполнение";
+ buttonTakeOrderInWork.UseVisualStyleBackColor = true;
+ buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click;
+ //
+ // buttonOrderReady
+ //
+ buttonOrderReady.Location = new Point(732, 132);
+ buttonOrderReady.Name = "buttonOrderReady";
+ buttonOrderReady.Size = new Size(185, 29);
+ buttonOrderReady.TabIndex = 4;
+ buttonOrderReady.Text = "Заказ готов";
+ buttonOrderReady.UseVisualStyleBackColor = true;
+ buttonOrderReady.Click += buttonOrderReady_Click;
+ //
+ // buttonIssuedOrder
+ //
+ buttonIssuedOrder.Location = new Point(732, 177);
+ buttonIssuedOrder.Name = "buttonIssuedOrder";
+ buttonIssuedOrder.Size = new Size(185, 29);
+ buttonIssuedOrder.TabIndex = 5;
+ buttonIssuedOrder.Text = "Заказ выдан";
+ buttonIssuedOrder.UseVisualStyleBackColor = true;
+ buttonIssuedOrder.Click += buttonIssuedOrder_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(732, 221);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(185, 29);
+ buttonUpdate.TabIndex = 6;
+ buttonUpdate.Text = "Обновить список";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += buttonUpdate_Click;
+ //
+ // FormMain
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(929, 649);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonIssuedOrder);
+ Controls.Add(buttonOrderReady);
+ Controls.Add(buttonTakeOrderInWork);
+ Controls.Add(buttonCreateOrder);
+ Controls.Add(dataGridView);
+ Controls.Add(menuStrip);
+ MainMenuStrip = menuStrip;
+ Name = "FormMain";
+ Text = "Юридическая фирма";
+ Load += FormMain_Load;
+ menuStrip.ResumeLayout(false);
+ menuStrip.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem toolStripMenuItem;
+ private ToolStripMenuItem BlanksToolStripMenuItem;
+ private ToolStripMenuItem DocumentsToolStripMenuItem;
+ private DataGridView dataGridView;
+ private Button buttonCreateOrder;
+ private Button buttonTakeOrderInWork;
+ private Button buttonOrderReady;
+ private Button buttonIssuedOrder;
+ private Button buttonUpdate;
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirm/FormMain.cs b/LawFirm/LawFirm/FormMain.cs
new file mode 100644
index 0000000..5ad75e5
--- /dev/null
+++ b/LawFirm/LawFirm/FormMain.cs
@@ -0,0 +1,167 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.BusinessLogicsContracts;
+using LawFirmDataModels.Enums;
+using Microsoft.Extensions.Logging;
+using System.Windows.Forms;
+
+namespace LawFirmView
+{
+ public partial class FormMain : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderLogic _orderLogic;
+ public FormMain(ILogger logger, IOrderLogic orderLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _orderLogic = orderLogic;
+ }
+ private void FormMain_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка заказов");
+ try
+ {
+ var list = _orderLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["DocumentId"].Visible = false;
+ }
+ _logger.LogInformation("Загрузка прошла успешно");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки заказов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void buttonCreateOrder_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
+ if (service is FormCreateOrder form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+ private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
+ try
+ {
+ var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
+ {
+ Id = id,
+ DocumentId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DocumentId"].Value),
+ Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
+ Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
+ Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
+ DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString())
+ });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка передачи заказа в работу");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void buttonOrderReady_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
+ try
+ {
+ var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
+ {
+ Id = id,
+ DocumentId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DocumentId"].Value),
+ Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
+ Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
+ Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
+ DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString())
+ });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о готовности заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void buttonIssuedOrder_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
+ try
+ {
+ var operationResult = _orderLogic.DeliveryOrder(new
+ OrderBindingModel
+ {
+ Id = id,
+ DocumentId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DocumentId"].Value),
+ Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
+ Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
+ Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
+ DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString())
+ });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ _logger.LogInformation("Заказ №{id} выдан", id);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void buttonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void BlanksToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormBlanks));
+ if (service is FormBlanks form)
+ {
+ form.ShowDialog();
+ }
+ }
+ private void DocumentsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormDocuments));
+ if (service is FormDocuments form)
+ {
+ form.ShowDialog();
+ }
+ }
+ }
+}
diff --git a/LawFirm/LawFirm/FormMain.resx b/LawFirm/LawFirm/FormMain.resx
new file mode 100644
index 0000000..6c82d08
--- /dev/null
+++ b/LawFirm/LawFirm/FormMain.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/LawFirm/LawFirm/LawFirm.csproj b/LawFirm/LawFirm/LawFirm.csproj
deleted file mode 100644
index b57c89e..0000000
--- a/LawFirm/LawFirm/LawFirm.csproj
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- WinExe
- net6.0-windows
- enable
- true
- enable
-
-
-
\ No newline at end of file
diff --git a/LawFirm/LawFirm/LawFirmView.csproj b/LawFirm/LawFirm/LawFirmView.csproj
new file mode 100644
index 0000000..3c403c3
--- /dev/null
+++ b/LawFirm/LawFirm/LawFirmView.csproj
@@ -0,0 +1,26 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LawFirm/LawFirm/Program.cs b/LawFirm/LawFirm/Program.cs
index 45182ca..79a64e7 100644
--- a/LawFirm/LawFirm/Program.cs
+++ b/LawFirm/LawFirm/Program.cs
@@ -1,7 +1,18 @@
-namespace LawFirm
+using LawFirmBusinessLogic.BusinessLogics;
+using LawFirmContracts.BusinessLogicsContracts;
+using LawFirmContracts.StoragesContracts;
+using LawFirmListImplement.Implements;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+using System;
+
+namespace LawFirmView
{
internal static class Program
{
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
///
/// The main entry point for the application.
///
@@ -11,7 +22,33 @@ namespace LawFirm
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
+ var services = new ServiceCollection();
+ ConfigureServices(services);
+ _serviceProvider = services.BuildServiceProvider();
+ Application.Run(_serviceProvider.GetRequiredService());
+ }
+ private static void ConfigureServices(ServiceCollection services)
+ {
+ services.AddLogging(option =>
+ {
+ option.SetMinimumLevel(LogLevel.Information);
+ option.AddNLog("nlog.config");
+ });
+ 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
diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogics/BlankLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogics/BlankLogic.cs
new file mode 100644
index 0000000..46b1c93
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/BusinessLogics/BlankLogic.cs
@@ -0,0 +1,115 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.BusinessLogicsContracts;
+using LawFirmContracts.SearchModels;
+using LawFirmContracts.StoragesContracts;
+using LawFirmContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+
+namespace LawFirmBusinessLogic.BusinessLogics
+{
+ public class BlankLogic : IBlankLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IBlankStorage _blankStorage;
+ public BlankLogic(ILogger logger, IBlankStorage blankStorage)
+ {
+ _logger = logger;
+ _blankStorage = blankStorage;
+ }
+ public List? ReadList(BlankSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. BlankName:{BlankName}.Id:{Id}",
+ model?.BlankName, model?.Id);
+ var list = model == null ? _blankStorage.GetFullList() :
+ _blankStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public BlankViewModel? ReadElement(BlankSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. BlankName:{BlankName}.Id:{Id}",
+ model.BlankName, model.Id);
+ var element = _blankStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
+ }
+ public bool Create(BlankBindingModel model)
+ {
+ CheckModel(model);
+ if (_blankStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(BlankBindingModel model)
+ {
+ CheckModel(model);
+ if (_blankStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(BlankBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_blankStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(BlankBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.BlankName))
+ {
+ throw new ArgumentNullException("Нет названия компонента",
+ nameof(model.BlankName));
+ }
+ if (model.Price <= 0)
+ {
+ throw new ArgumentNullException("Цена компонента должна быть больше 0",
+ nameof(model.Price));
+ }
+ _logger.LogInformation("Blank. BlankName:{BlackName}.Price:{Price}. Id: {Id}",
+ model.BlankName, model.Price, model.Id);
+ var element = _blankStorage.GetElement(
+ new BlankSearchModel
+ {
+ BlankName = model.BlankName
+ }
+ );
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Компонент с таким названием уже есть");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogics/DocumentLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogics/DocumentLogic.cs
new file mode 100644
index 0000000..e3376e5
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/BusinessLogics/DocumentLogic.cs
@@ -0,0 +1,115 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.BusinessLogicsContracts;
+using LawFirmContracts.SearchModels;
+using LawFirmContracts.StoragesContracts;
+using LawFirmContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+
+namespace LawFirmBusinessLogic.BusinessLogics
+{
+ public class DocumentLogic : IDocumentLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IDocumentStorage _documentStorage;
+ public DocumentLogic(ILogger logger, IDocumentStorage documentStorage)
+ {
+ _logger = logger;
+ _documentStorage = documentStorage;
+ }
+ public List? ReadList(DocumentSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. DocumentName:{DocumentName}.Id:{Id}",
+ model?.DocumentName, model?.Id);
+ var list = model == null ? _documentStorage.GetFullList() :
+ _documentStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public bool Create(DocumentBindingModel model)
+ {
+ CheckModel(model);
+ if (_documentStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(DocumentBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_documentStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ public DocumentViewModel? ReadElement(DocumentSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. DocumentName:{DocumentName}.Id:{Id}",
+ model.DocumentName, model.Id);
+ var element = _documentStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
+ }
+ public bool Update(DocumentBindingModel model)
+ {
+ CheckModel(model);
+ if (_documentStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(DocumentBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.DocumentName))
+ {
+ throw new ArgumentNullException("Нет названия документа",
+ nameof(model.DocumentName));
+ }
+ if (model.Price <= 0)
+ {
+ throw new ArgumentNullException("Цена Документа должна быть больше 0",
+ nameof(model.Price));
+ }
+ _logger.LogInformation("Document. DocumentName:{DocumentName}.Price:{Price}. Id: {Id}",
+ model.DocumentName, model.Price, model.Id);
+ var element = _documentStorage.GetElement(
+ new DocumentSearchModel
+ {
+ DocumentName = model.DocumentName
+ }
+ );
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Документ с таким названием уже есть");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs
new file mode 100644
index 0000000..7ded201
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -0,0 +1,118 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.BusinessLogicsContracts;
+using LawFirmContracts.SearchModels;
+using LawFirmContracts.StoragesContracts;
+using LawFirmContracts.ViewModels;
+using LawFirmDataModels.Enums;
+using Microsoft.Extensions.Logging;
+
+namespace LawFirmBusinessLogic.BusinessLogics
+{
+ public class OrderLogic : IOrderLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderStorage _orderStorage;
+ public OrderLogic(ILogger logger, IOrderStorage orderStorage)
+ {
+ _logger = logger;
+ _orderStorage = orderStorage;
+ }
+ public bool CreateOrder(OrderBindingModel model)
+ {
+ CheckModel(model);
+ if (model.Status != OrderStatus.Неизвестен)
+ {
+ _logger.LogWarning("Insert operation failed. Order status incorrect.");
+ return false;
+ }
+ model.Status = OrderStatus.Принят;
+ if (_orderStorage.Insert(model) == null)
+ {
+ model.Status = OrderStatus.Неизвестен;
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
+ {
+ var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
+ if (viewModel == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (viewModel.Status + 1 != newStatus)
+ {
+ _logger.LogWarning("Update operation failed. Order status incorrect.");
+ return false;
+ }
+ model.Status = newStatus;
+ if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.Now;
+ else
+ {
+ model.DateImplement = viewModel.DateImplement;
+ }
+ CheckModel(model, false);
+ if (_orderStorage.Update(model) == null)
+ {
+ model.Status--;
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool DeliveryOrder(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Выдан);
+ }
+ public bool FinishOrder(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Готов);
+ }
+ public bool TakeOrderInWork(OrderBindingModel model)
+ {
+ return StatusUpdate(model, OrderStatus.Выполняется);
+ }
+ public List? ReadList(OrderSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. OrderId:{Id}", model?.Id);
+ var list = model == null ? _orderStorage.GetFullList() :
+ _orderStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ private void CheckModel(OrderBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (model.DocumentId < 0)
+ {
+ throw new ArgumentNullException("Некорректный идентификатор документа",
+ nameof(model.DocumentId));
+ }
+ if (model.Count <= 0)
+ {
+ throw new ArgumentNullException("Количество документов в заказе должно быть больше 0",
+ nameof(model.Count));
+ }
+ if (model.Sum <= 0)
+ {
+ throw new ArgumentNullException("Сумма заказа должна быть больше 0",
+ nameof(model.Sum));
+ }
+ _logger.LogInformation("Document. OrderID:{Id}. Sum:{Sum}. DocumentID:{DocumentID}.}",
+ model.Id, model.Sum, model.DocumentId);
+ }
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmBusinessLogic/LawFirmBusinessLogic.csproj b/LawFirm/LawFirmBusinessLogic/LawFirmBusinessLogic.csproj
new file mode 100644
index 0000000..1e2c467
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/LawFirmBusinessLogic.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LawFirm/LawFirmContracts/BindingModels/BlankBindingModel.cs b/LawFirm/LawFirmContracts/BindingModels/BlankBindingModel.cs
new file mode 100644
index 0000000..e002bcb
--- /dev/null
+++ b/LawFirm/LawFirmContracts/BindingModels/BlankBindingModel.cs
@@ -0,0 +1,11 @@
+using LawFirmDataModels.Models;
+
+namespace LawFirmContracts.BindingModels
+{
+ public class BlankBindingModel : IBlankModel
+ {
+ public int Id { get; set; }
+ public string BlankName { get; set; } = string.Empty;
+ public double Price { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmContracts/BindingModels/DocumentBindingModel.cs b/LawFirm/LawFirmContracts/BindingModels/DocumentBindingModel.cs
new file mode 100644
index 0000000..6f6a635
--- /dev/null
+++ b/LawFirm/LawFirmContracts/BindingModels/DocumentBindingModel.cs
@@ -0,0 +1,16 @@
+using LawFirmDataModels.Models;
+
+namespace LawFirmContracts.BindingModels
+{
+ public class DocumentBindingModel : IDocumentModel
+ {
+ public int Id { get; set; }
+ public string DocumentName { get; set; } = string.Empty;
+ public double Price { get; set; }
+ public Dictionary DocumentBlanks
+ {
+ get;
+ set;
+ } = new();
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs b/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs
new file mode 100644
index 0000000..eaa08bf
--- /dev/null
+++ b/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs
@@ -0,0 +1,16 @@
+using LawFirmDataModels.Enums;
+using LawFirmDataModels.Models;
+
+namespace LawFirmContracts.BindingModels
+{
+ public class OrderBindingModel : IOrderModel
+ {
+ public int Id { get; set; }
+ public int DocumentId { get; set; }
+ public int Count { get; set; }
+ public double Sum { get; set; }
+ public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
+ public DateTime DateCreate { get; set; } = DateTime.Now;
+ public DateTime? DateImplement { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmContracts/BusinessLogicsContracts/IBlankLogic.cs b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IBlankLogic.cs
new file mode 100644
index 0000000..e4fcde4
--- /dev/null
+++ b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IBlankLogic.cs
@@ -0,0 +1,15 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.SearchModels;
+using LawFirmContracts.ViewModels;
+
+namespace LawFirmContracts.BusinessLogicsContracts
+{
+ public interface IBlankLogic
+ {
+ List? ReadList(BlankSearchModel? model);
+ BlankViewModel? ReadElement(BlankSearchModel model);
+ bool Create(BlankBindingModel model);
+ bool Update(BlankBindingModel model);
+ bool Delete(BlankBindingModel model);
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmContracts/BusinessLogicsContracts/IDocumentLogic.cs b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IDocumentLogic.cs
new file mode 100644
index 0000000..efe8bc0
--- /dev/null
+++ b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IDocumentLogic.cs
@@ -0,0 +1,15 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.SearchModels;
+using LawFirmContracts.ViewModels;
+
+namespace LawFirmContracts.BusinessLogicsContracts
+{
+ public interface IDocumentLogic
+ {
+ List? ReadList(DocumentSearchModel? model);
+ DocumentViewModel? ReadElement(DocumentSearchModel model);
+ bool Create(DocumentBindingModel model);
+ bool Update(DocumentBindingModel model);
+ bool Delete(DocumentBindingModel model);
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmContracts/BusinessLogicsContracts/IOrderLogic.cs b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IOrderLogic.cs
new file mode 100644
index 0000000..850fa8d
--- /dev/null
+++ b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IOrderLogic.cs
@@ -0,0 +1,15 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.SearchModels;
+using LawFirmContracts.ViewModels;
+
+namespace LawFirmContracts.BusinessLogicsContracts
+{
+ public interface IOrderLogic
+ {
+ List? ReadList(OrderSearchModel? model);
+ bool CreateOrder(OrderBindingModel model);
+ bool TakeOrderInWork(OrderBindingModel model);
+ bool FinishOrder(OrderBindingModel model);
+ bool DeliveryOrder(OrderBindingModel model);
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmContracts/LawFirmContracts.csproj b/LawFirm/LawFirmContracts/LawFirmContracts.csproj
new file mode 100644
index 0000000..46ea406
--- /dev/null
+++ b/LawFirm/LawFirmContracts/LawFirmContracts.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/LawFirm/LawFirmContracts/SearchModels/BlankSearchModel.cs b/LawFirm/LawFirmContracts/SearchModels/BlankSearchModel.cs
new file mode 100644
index 0000000..7b57aef
--- /dev/null
+++ b/LawFirm/LawFirmContracts/SearchModels/BlankSearchModel.cs
@@ -0,0 +1,8 @@
+namespace LawFirmContracts.SearchModels
+{
+ public class BlankSearchModel
+ {
+ public int? Id { get; set; }
+ public string? BlankName { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs b/LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs
new file mode 100644
index 0000000..2064f72
--- /dev/null
+++ b/LawFirm/LawFirmContracts/SearchModels/DocumentSearchModel.cs
@@ -0,0 +1,8 @@
+namespace LawFirmContracts.SearchModels
+{
+ public class DocumentSearchModel
+ {
+ public int? Id { get; set; }
+ public string? DocumentName { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmContracts/SearchModels/OrderSearchModel.cs b/LawFirm/LawFirmContracts/SearchModels/OrderSearchModel.cs
new file mode 100644
index 0000000..b73aafe
--- /dev/null
+++ b/LawFirm/LawFirmContracts/SearchModels/OrderSearchModel.cs
@@ -0,0 +1,7 @@
+namespace LawFirmContracts.SearchModels
+{
+ public class OrderSearchModel
+ {
+ public int? Id { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmContracts/StoragesContracts/IBlankStorage.cs b/LawFirm/LawFirmContracts/StoragesContracts/IBlankStorage.cs
new file mode 100644
index 0000000..3b718bc
--- /dev/null
+++ b/LawFirm/LawFirmContracts/StoragesContracts/IBlankStorage.cs
@@ -0,0 +1,16 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.SearchModels;
+using LawFirmContracts.ViewModels;
+
+namespace LawFirmContracts.StoragesContracts
+{
+ public interface IBlankStorage
+ {
+ List GetFullList();
+ List GetFilteredList(BlankSearchModel model);
+ BlankViewModel? GetElement(BlankSearchModel model);
+ BlankViewModel? Insert(BlankBindingModel model);
+ BlankViewModel? Update(BlankBindingModel model);
+ BlankViewModel? Delete(BlankBindingModel model);
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmContracts/StoragesContracts/IDocumentStorage.cs b/LawFirm/LawFirmContracts/StoragesContracts/IDocumentStorage.cs
new file mode 100644
index 0000000..89a0ca0
--- /dev/null
+++ b/LawFirm/LawFirmContracts/StoragesContracts/IDocumentStorage.cs
@@ -0,0 +1,16 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.SearchModels;
+using LawFirmContracts.ViewModels;
+
+namespace LawFirmContracts.StoragesContracts
+{
+ public interface IDocumentStorage
+ {
+ List GetFullList();
+ List GetFilteredList(DocumentSearchModel model);
+ DocumentViewModel? GetElement(DocumentSearchModel model);
+ DocumentViewModel? Insert(DocumentBindingModel model);
+ DocumentViewModel? Update(DocumentBindingModel model);
+ DocumentViewModel? Delete(DocumentBindingModel model);
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmContracts/StoragesContracts/IOrderStorage.cs b/LawFirm/LawFirmContracts/StoragesContracts/IOrderStorage.cs
new file mode 100644
index 0000000..26b5341
--- /dev/null
+++ b/LawFirm/LawFirmContracts/StoragesContracts/IOrderStorage.cs
@@ -0,0 +1,16 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.SearchModels;
+using LawFirmContracts.ViewModels;
+
+namespace LawFirmContracts.StoragesContracts
+{
+ public interface IOrderStorage
+ {
+ List GetFullList();
+ List GetFilteredList(OrderSearchModel model);
+ OrderViewModel? GetElement(OrderSearchModel model);
+ OrderViewModel? Insert(OrderBindingModel model);
+ OrderViewModel? Update(OrderBindingModel model);
+ OrderViewModel? Delete(OrderBindingModel model);
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmContracts/ViewModels/BlankViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/BlankViewModel.cs
new file mode 100644
index 0000000..3c9c200
--- /dev/null
+++ b/LawFirm/LawFirmContracts/ViewModels/BlankViewModel.cs
@@ -0,0 +1,14 @@
+using LawFirmDataModels.Models;
+using System.ComponentModel;
+
+namespace LawFirmContracts.ViewModels
+{
+ public class BlankViewModel : IBlankModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название бланка")]
+ public string BlankName { get; set; } = string.Empty;
+ [DisplayName("Цена")]
+ public double Price { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmContracts/ViewModels/DocumentViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/DocumentViewModel.cs
new file mode 100644
index 0000000..ef6a1a1
--- /dev/null
+++ b/LawFirm/LawFirmContracts/ViewModels/DocumentViewModel.cs
@@ -0,0 +1,19 @@
+using LawFirmDataModels.Models;
+using System.ComponentModel;
+
+namespace LawFirmContracts.ViewModels
+{
+ public class DocumentViewModel : IDocumentModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название документа")]
+ public string DocumentName { get; set; } = string.Empty;
+ [DisplayName("Цена")]
+ public double Price { get; set; }
+ public Dictionary DocumentBlanks
+ {
+ get;
+ set;
+ } = new();
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmContracts/ViewModels/OrderViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/OrderViewModel.cs
new file mode 100644
index 0000000..8dedf8b
--- /dev/null
+++ b/LawFirm/LawFirmContracts/ViewModels/OrderViewModel.cs
@@ -0,0 +1,25 @@
+using LawFirmDataModels.Enums;
+using LawFirmDataModels.Models;
+using System.ComponentModel;
+
+namespace LawFirmContracts.ViewModels
+{
+ public class OrderViewModel : IOrderModel
+ {
+ [DisplayName("Номер")]
+ public int Id { get; set; }
+ public int DocumentId { get; set; }
+ [DisplayName("Документ")]
+ public string DocumentName { get; set; } = string.Empty;
+ [DisplayName("Количество")]
+ public int Count { get; set; }
+ [DisplayName("Сумма")]
+ public double Sum { get; set; }
+ [DisplayName("Статус")]
+ public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
+ [DisplayName("Дата создания")]
+ public DateTime DateCreate { get; set; } = DateTime.Now;
+ [DisplayName("Дата выполнения")]
+ public DateTime? DateImplement { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmDataModels/Enums/OrderStatus.cs b/LawFirm/LawFirmDataModels/Enums/OrderStatus.cs
new file mode 100644
index 0000000..fa2c6b9
--- /dev/null
+++ b/LawFirm/LawFirmDataModels/Enums/OrderStatus.cs
@@ -0,0 +1,11 @@
+namespace LawFirmDataModels.Enums
+{
+ public enum OrderStatus
+ {
+ Неизвестен = -1,
+ Принят = 0,
+ Выполняется = 1,
+ Готов = 2,
+ Выдан = 3,
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmDataModels/IId.cs b/LawFirm/LawFirmDataModels/IId.cs
new file mode 100644
index 0000000..ac340f5
--- /dev/null
+++ b/LawFirm/LawFirmDataModels/IId.cs
@@ -0,0 +1,7 @@
+namespace LawFirmDataModels
+{
+ public interface IId
+ {
+ int Id { get; }
+ }
+}
diff --git a/LawFirm/LawFirmDataModels/LawFirmDataModels.csproj b/LawFirm/LawFirmDataModels/LawFirmDataModels.csproj
new file mode 100644
index 0000000..132c02c
--- /dev/null
+++ b/LawFirm/LawFirmDataModels/LawFirmDataModels.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/LawFirm/LawFirmDataModels/Models/IBlankModel.cs b/LawFirm/LawFirmDataModels/Models/IBlankModel.cs
new file mode 100644
index 0000000..c480375
--- /dev/null
+++ b/LawFirm/LawFirmDataModels/Models/IBlankModel.cs
@@ -0,0 +1,10 @@
+using System.Security.Cryptography;
+
+namespace LawFirmDataModels.Models
+{
+ public interface IBlankModel : IId
+ {
+ string BlankName { get; }
+ double Price { get; }
+ }
+}
diff --git a/LawFirm/LawFirmDataModels/Models/IDocumentModel.cs b/LawFirm/LawFirmDataModels/Models/IDocumentModel.cs
new file mode 100644
index 0000000..b8ac9a9
--- /dev/null
+++ b/LawFirm/LawFirmDataModels/Models/IDocumentModel.cs
@@ -0,0 +1,11 @@
+using System.Security.Cryptography;
+
+namespace LawFirmDataModels.Models
+{
+ public interface IDocumentModel : IId
+ {
+ string DocumentName { get; }
+ double Price { get; }
+ Dictionary DocumentBlanks { get; }
+ }
+}
diff --git a/LawFirm/LawFirmDataModels/Models/IOrderModel.cs b/LawFirm/LawFirmDataModels/Models/IOrderModel.cs
new file mode 100644
index 0000000..6dc919b
--- /dev/null
+++ b/LawFirm/LawFirmDataModels/Models/IOrderModel.cs
@@ -0,0 +1,15 @@
+using LawFirmDataModels.Enums;
+using System.Security.Cryptography;
+
+namespace LawFirmDataModels.Models
+{
+ public interface IOrderModel : IId
+ {
+ int DocumentId { get; }
+ int Count { get; }
+ double Sum { get; }
+ OrderStatus Status { get; }
+ DateTime DateCreate { get; }
+ DateTime? DateImplement { get; }
+ }
+}
diff --git a/LawFirm/LawFirmListImplement/DataListSingleton.cs b/LawFirm/LawFirmListImplement/DataListSingleton.cs
new file mode 100644
index 0000000..264ff29
--- /dev/null
+++ b/LawFirm/LawFirmListImplement/DataListSingleton.cs
@@ -0,0 +1,26 @@
+using LawFirmListImplement.Models;
+
+namespace LawFirmListImplement
+{
+ public class DataListSingleton
+ {
+ private static DataListSingleton? _instance;
+ public List Blanks { get; set; }
+ public List Orders { get; set; }
+ public List Documents { get; set; }
+ private DataListSingleton()
+ {
+ Blanks = new List();
+ Orders = new List();
+ Documents = new List();
+ }
+ public static DataListSingleton GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new DataListSingleton();
+ }
+ return _instance;
+ }
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmListImplement/Implements/BlankStorage.cs b/LawFirm/LawFirmListImplement/Implements/BlankStorage.cs
new file mode 100644
index 0000000..fdd5489
--- /dev/null
+++ b/LawFirm/LawFirmListImplement/Implements/BlankStorage.cs
@@ -0,0 +1,102 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.SearchModels;
+using LawFirmContracts.StoragesContracts;
+using LawFirmContracts.ViewModels;
+using LawFirmListImplement.Models;
+
+namespace LawFirmListImplement.Implements
+{
+ public class BlankStorage : IBlankStorage
+ {
+ private readonly DataListSingleton _source;
+ public BlankStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var blank in _source.Blanks)
+ {
+ result.Add(blank.GetViewModel);
+ }
+ return result;
+ }
+ public List GetFilteredList(BlankSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.BlankName))
+ {
+ return result;
+ }
+ foreach (var component in _source.Blanks)
+ {
+ if (component.BlankName.Contains(model.BlankName))
+ {
+ result.Add(component.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public BlankViewModel? GetElement(BlankSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.BlankName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var component in _source.Blanks)
+ {
+ if ((!string.IsNullOrEmpty(model.BlankName) &&
+ component.BlankName == model.BlankName) ||
+ (model.Id.HasValue && component.Id == model.Id))
+ {
+ return component.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public BlankViewModel? Insert(BlankBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var blank in _source.Blanks)
+ {
+ if (model.Id <= blank.Id)
+ {
+ model.Id = blank.Id + 1;
+ }
+ }
+ var newBlank = Blank.Create(model);
+ if (newBlank == null)
+ {
+ return null;
+ }
+ _source.Blanks.Add(newBlank);
+ return newBlank.GetViewModel;
+ }
+ public BlankViewModel? Update(BlankBindingModel model)
+ {
+ foreach (var blank in _source.Blanks)
+ {
+ if (blank.Id == model.Id)
+ {
+ blank.Update(model);
+ return blank.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public BlankViewModel? Delete(BlankBindingModel model)
+ {
+ for (int i = 0; i < _source.Blanks.Count; ++i)
+ {
+ if (_source.Blanks[i].Id == model.Id)
+ {
+ var element = _source.Blanks[i];
+ _source.Blanks.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmListImplement/Implements/DocumentStorage.cs b/LawFirm/LawFirmListImplement/Implements/DocumentStorage.cs
new file mode 100644
index 0000000..52d1892
--- /dev/null
+++ b/LawFirm/LawFirmListImplement/Implements/DocumentStorage.cs
@@ -0,0 +1,102 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.SearchModels;
+using LawFirmContracts.StoragesContracts;
+using LawFirmContracts.ViewModels;
+using LawFirmListImplement.Models;
+
+namespace LawFirmListImplement.Implements
+{
+ public class DocumentStorage : IDocumentStorage
+ {
+ private readonly DataListSingleton _source;
+ public DocumentStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var blank in _source.Documents)
+ {
+ result.Add(blank.GetViewModel);
+ }
+ return result;
+ }
+ public List GetFilteredList(DocumentSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.DocumentName))
+ {
+ return result;
+ }
+ foreach (var component in _source.Documents)
+ {
+ if (component.DocumentName.Contains(model.DocumentName))
+ {
+ result.Add(component.GetViewModel);
+ }
+ }
+ return result;
+ }
+ public DocumentViewModel? GetElement(DocumentSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.DocumentName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var component in _source.Documents)
+ {
+ if ((!string.IsNullOrEmpty(model.DocumentName) &&
+ component.DocumentName == model.DocumentName) ||
+ (model.Id.HasValue && component.Id == model.Id))
+ {
+ return component.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public DocumentViewModel? Insert(DocumentBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var blank in _source.Documents)
+ {
+ if (model.Id <= blank.Id)
+ {
+ model.Id = blank.Id + 1;
+ }
+ }
+ var newDocument = Document.Create(model);
+ if (newDocument == null)
+ {
+ return null;
+ }
+ _source.Documents.Add(newDocument);
+ return newDocument.GetViewModel;
+ }
+ public DocumentViewModel? Update(DocumentBindingModel model)
+ {
+ foreach (var blank in _source.Documents)
+ {
+ if (blank.Id == model.Id)
+ {
+ blank.Update(model);
+ return blank.GetViewModel;
+ }
+ }
+ return null;
+ }
+ public DocumentViewModel? Delete(DocumentBindingModel model)
+ {
+ for (int i = 0; i < _source.Documents.Count; ++i)
+ {
+ if (_source.Documents[i].Id == model.Id)
+ {
+ var element = _source.Documents[i];
+ _source.Documents.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs
new file mode 100644
index 0000000..dbf2874
--- /dev/null
+++ b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs
@@ -0,0 +1,113 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.SearchModels;
+using LawFirmContracts.StoragesContracts;
+using LawFirmContracts.ViewModels;
+using LawFirmListImplement.Models;
+
+namespace LawFirmListImplement.Implements
+{
+ public class OrderStorage : IOrderStorage
+ {
+ private readonly DataListSingleton _source;
+ public OrderStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var blank in _source.Orders)
+ {
+ result.Add(GetViewModel(blank));
+ }
+ return result;
+ }
+ public List GetFilteredList(OrderSearchModel model)
+ {
+ var result = new List();
+ if (!model.Id.HasValue)
+ {
+ return result;
+ }
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ result.Add(GetViewModel(order));
+ }
+ }
+ return result;
+ }
+ public OrderViewModel? GetElement(OrderSearchModel model)
+ {
+ if (!model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var order in _source.Orders)
+ {
+ if (model.Id.HasValue && order.Id == model.Id)
+ {
+ return GetViewModel(order);
+ }
+ }
+ return null;
+ }
+ public OrderViewModel? Insert(OrderBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var order in _source.Orders)
+ {
+ if (model.Id <= order.Id)
+ {
+ model.Id = order.Id + 1;
+ }
+ }
+ var newOrder = Order.Create(model);
+ if (newOrder == null)
+ {
+ return null;
+ }
+ _source.Orders.Add(newOrder);
+ return GetViewModel(newOrder);
+ }
+ public OrderViewModel? Update(OrderBindingModel model)
+ {
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ order.Update(model);
+ return GetViewModel(order);
+ }
+ }
+ return null;
+ }
+ public OrderViewModel? Delete(OrderBindingModel model)
+ {
+ for (int i = 0; i < _source.Orders.Count; ++i)
+ {
+ if (_source.Orders[i].Id == model.Id)
+ {
+ var element = _source.Orders[i];
+ _source.Orders.RemoveAt(i);
+ return GetViewModel(element);
+ }
+ }
+ return null;
+ }
+ private OrderViewModel GetViewModel(Order order)
+ {
+ var viewModel = order.GetViewModel;
+ foreach (var document in _source.Documents)
+ {
+ if (document.Id == order.DocumentId)
+ {
+ viewModel.DocumentName = document.DocumentName;
+ break;
+ }
+ }
+ return viewModel;
+ }
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmListImplement/LawFirmListImplement.csproj b/LawFirm/LawFirmListImplement/LawFirmListImplement.csproj
new file mode 100644
index 0000000..77fe5b1
--- /dev/null
+++ b/LawFirm/LawFirmListImplement/LawFirmListImplement.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/LawFirm/LawFirmListImplement/Models/Blank.cs b/LawFirm/LawFirmListImplement/Models/Blank.cs
new file mode 100644
index 0000000..078a972
--- /dev/null
+++ b/LawFirm/LawFirmListImplement/Models/Blank.cs
@@ -0,0 +1,41 @@
+using LawFirmDataModels.Models;
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.ViewModels;
+
+namespace LawFirmListImplement.Models
+{
+ public class Blank : IBlankModel
+ {
+ public int Id { get; private set; }
+ public string BlankName { get; private set; } = string.Empty;
+ public double Price { get; set; }
+ public static Blank? Create(BlankBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Blank()
+ {
+ Id = model.Id,
+ BlankName = model.BlankName,
+ Price = model.Price
+ };
+ }
+ public void Update(BlankBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ BlankName = model.BlankName;
+ Price = model.Price;
+ }
+ public BlankViewModel GetViewModel => new()
+ {
+ Id = Id,
+ BlankName = BlankName,
+ Price = Price
+ };
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmListImplement/Models/Document.cs b/LawFirm/LawFirmListImplement/Models/Document.cs
new file mode 100644
index 0000000..c682d1c
--- /dev/null
+++ b/LawFirm/LawFirmListImplement/Models/Document.cs
@@ -0,0 +1,49 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.ViewModels;
+using LawFirmDataModels.Models;
+
+namespace LawFirmListImplement.Models
+{
+ public class Document : IDocumentModel
+ {
+ public int Id { get; private set; }
+ public string DocumentName { get; private set; } = string.Empty;
+ public double Price { get; private set; }
+ public Dictionary DocumentBlanks
+ {
+ get;
+ private set;
+ } = new Dictionary();
+ public static Document? Create(DocumentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Document()
+ {
+ Id = model.Id,
+ DocumentName = model.DocumentName,
+ Price = model.Price,
+ DocumentBlanks = model.DocumentBlanks
+ };
+ }
+ public void Update(DocumentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ DocumentName = model.DocumentName;
+ Price = model.Price;
+ DocumentBlanks = model.DocumentBlanks;
+ }
+ public DocumentViewModel GetViewModel => new()
+ {
+ Id = Id,
+ DocumentName = DocumentName,
+ Price = Price,
+ DocumentBlanks = DocumentBlanks
+ };
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmListImplement/Models/Order.cs b/LawFirm/LawFirmListImplement/Models/Order.cs
new file mode 100644
index 0000000..9caf2dd
--- /dev/null
+++ b/LawFirm/LawFirmListImplement/Models/Order.cs
@@ -0,0 +1,54 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.ViewModels;
+using LawFirmDataModels.Enums;
+using LawFirmDataModels.Models;
+
+namespace LawFirmListImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int Id { get; private set; }
+ public int DocumentId { get; private set; }
+ public int Count { get; private set; }
+ public double Sum { get; private set; }
+ public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
+ public DateTime DateCreate { get; private set; } = DateTime.Now;
+ public DateTime? DateImplement { get; private set; }
+ public static Order? Create(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Order()
+ {
+ Id = model.Id,
+ DocumentId = model.DocumentId,
+ Count = model.Count,
+ Sum = model.Sum,
+ Status = model.Status,
+ DateCreate = model.DateCreate,
+ DateImplement = model.DateImplement
+ };
+ }
+ public void Update(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ Status = model.Status;
+ DateImplement = model.DateImplement;
+ }
+ public OrderViewModel GetViewModel => new()
+ {
+ Id = Id,
+ DocumentId = DocumentId,
+ Count = Count,
+ Sum = Sum,
+ Status = Status,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement
+ };
+ }
+}
\ No newline at end of file