diff --git a/IceCreamShop/IceCreamBusinessLogic/BusinessLogics/OrderLogic.cs b/IceCreamShop/IceCreamBusinessLogic/BusinessLogics/OrderLogic.cs
index f4f83be..ef9485d 100644
--- a/IceCreamShop/IceCreamBusinessLogic/BusinessLogics/OrderLogic.cs
+++ b/IceCreamShop/IceCreamBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -95,11 +95,11 @@ namespace IceCreamBusinessLogic.BusinessLogics
_logger.LogInformation("Order. OrderID:{Id}.Sum:{ Sum}. DocumentId: { DocumentId}", model.Id, model.Sum, model.IceCreamId);
}
- public bool SetNewStatus(OrderBindingModel orderModel, OrderStatus newStatus)
+ public bool SetNewStatus(OrderBindingModel rawModel, OrderStatus newStatus)
{
var viewModel = _orderStorage.GetElement(new OrderSearchModel
{
- Id = orderModel.Id
+ Id = rawModel.Id
});
if (viewModel == null)
@@ -118,6 +118,11 @@ namespace IceCreamBusinessLogic.BusinessLogics
Count = viewModel.Count,
Sum = viewModel.Sum
};
+ if (rawModel.ImplementerId.HasValue)
+ {
+ model.ImplementerId = rawModel.ImplementerId;
+ }
+
CheckModel(model);
if (model.Status + 1 != newStatus)
{
@@ -126,7 +131,7 @@ namespace IceCreamBusinessLogic.BusinessLogics
}
model.Status = newStatus;
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
- if (_orderStorage.Update(model) == null)
+ if (_orderStorage. (model) == null)
{
model.Status--;
_logger.LogWarning("Update operation failed");
@@ -134,6 +139,7 @@ namespace IceCreamBusinessLogic.BusinessLogics
}
return true;
}
+
public OrderViewModel? ReadElement(OrderSearchModel model)
{
diff --git a/IceCreamShop/IceCreamBusinessLogic/BusinessLogics/WorkModeling.cs b/IceCreamShop/IceCreamBusinessLogic/BusinessLogics/WorkModeling.cs
index 20f9fd0..93109ed 100644
--- a/IceCreamShop/IceCreamBusinessLogic/BusinessLogics/WorkModeling.cs
+++ b/IceCreamShop/IceCreamBusinessLogic/BusinessLogics/WorkModeling.cs
@@ -74,10 +74,11 @@ namespace IceCreamBusinessLogic.BusinessLogic
// делаем работу
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
- _orderLogic.FinishOrder(new OrderBindingModel
+ _orderLogic.DeliveryOrder(new OrderBindingModel
{
- Id = order.Id
- });
+ Id = order.Id,
+ ImplementerId = implementer.Id
+ });
// отдыхаем
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
}
diff --git a/IceCreamShop/IceCreamShop/FormImplementer.Designer.cs b/IceCreamShop/IceCreamShop/FormImplementer.Designer.cs
new file mode 100644
index 0000000..643b7eb
--- /dev/null
+++ b/IceCreamShop/IceCreamShop/FormImplementer.Designer.cs
@@ -0,0 +1,184 @@
+namespace IceCreamShopView
+{
+ partial class FormImplementer
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.numericUpDownQualification = new System.Windows.Forms.NumericUpDown();
+ this.numericUpDownWorkExperience = new System.Windows.Forms.NumericUpDown();
+ this.textBoxPassword = new System.Windows.Forms.TextBox();
+ this.textBoxFio = new System.Windows.Forms.TextBox();
+ this.label4 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label1 = new System.Windows.Forms.Label();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownQualification)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWorkExperience)).BeginInit();
+ this.SuspendLayout();
+ //
+ // buttonSave
+ //
+ this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonSave.Location = new System.Drawing.Point(172, 148);
+ this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(102, 44);
+ this.buttonSave.TabIndex = 19;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonCancel.Location = new System.Drawing.Point(291, 148);
+ this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(102, 44);
+ this.buttonCancel.TabIndex = 18;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // numericUpDownQualification
+ //
+ this.numericUpDownQualification.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.numericUpDownQualification.Location = new System.Drawing.Point(303, 94);
+ this.numericUpDownQualification.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.numericUpDownQualification.Name = "numericUpDownQualification";
+ this.numericUpDownQualification.Size = new System.Drawing.Size(90, 27);
+ this.numericUpDownQualification.TabIndex = 17;
+ //
+ // numericUpDownWorkExperience
+ //
+ this.numericUpDownWorkExperience.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.numericUpDownWorkExperience.Location = new System.Drawing.Point(83, 92);
+ this.numericUpDownWorkExperience.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.numericUpDownWorkExperience.Name = "numericUpDownWorkExperience";
+ this.numericUpDownWorkExperience.Size = new System.Drawing.Size(94, 27);
+ this.numericUpDownWorkExperience.TabIndex = 16;
+ //
+ // textBoxPassword
+ //
+ this.textBoxPassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBoxPassword.Location = new System.Drawing.Point(83, 51);
+ this.textBoxPassword.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.textBoxPassword.Name = "textBoxPassword";
+ this.textBoxPassword.PasswordChar = '*';
+ this.textBoxPassword.Size = new System.Drawing.Size(310, 27);
+ this.textBoxPassword.TabIndex = 15;
+ //
+ // textBoxFio
+ //
+ this.textBoxFio.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBoxFio.Location = new System.Drawing.Point(58, 6);
+ this.textBoxFio.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.textBoxFio.Name = "textBoxFio";
+ this.textBoxFio.Size = new System.Drawing.Size(335, 27);
+ this.textBoxFio.TabIndex = 14;
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(183, 94);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(114, 20);
+ this.label4.TabIndex = 13;
+ this.label4.Text = "Квалификация:";
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(12, 90);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(46, 20);
+ this.label3.TabIndex = 12;
+ this.label3.Text = "Стаж:";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(12, 51);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(65, 20);
+ this.label2.TabIndex = 11;
+ this.label2.Text = "Пароль:";
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(12, 9);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(45, 20);
+ this.label1.TabIndex = 10;
+ this.label1.Text = "ФИО:";
+ //
+ // FormImplementer
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(405, 205);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.numericUpDownQualification);
+ this.Controls.Add(this.numericUpDownWorkExperience);
+ this.Controls.Add(this.textBoxPassword);
+ this.Controls.Add(this.textBoxFio);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Name = "FormImplementer";
+ this.Text = "Исполнитель";
+ this.Load += new System.EventHandler(this.FormImplementer_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownQualification)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWorkExperience)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Button buttonSave;
+ private Button buttonCancel;
+ private NumericUpDown numericUpDownQualification;
+ private NumericUpDown numericUpDownWorkExperience;
+ private TextBox textBoxPassword;
+ private TextBox textBoxFio;
+ private Label label4;
+ private Label label3;
+ private Label label2;
+ private Label label1;
+ }
+}
\ No newline at end of file
diff --git a/IceCreamShop/IceCreamShop/FormImplementer.cs b/IceCreamShop/IceCreamShop/FormImplementer.cs
new file mode 100644
index 0000000..e4cfb7e
--- /dev/null
+++ b/IceCreamShop/IceCreamShop/FormImplementer.cs
@@ -0,0 +1,99 @@
+using IceCreamShopContracts.BindingModels;
+using IceCreamShopContracts.BusinessLogicsContracts;
+using IceCreamShopContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+namespace IceCreamShopView
+{
+ public partial class FormImplementer : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IImplementerLogic _logic;
+ private int? _id;
+ public int Id { set { _id = value; } }
+
+ public FormImplementer(ILogger logger, IImplementerLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormImplementer_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ try
+ {
+ _logger.LogInformation("Получение исполнителя");
+ var view = _logic.ReadElement(new ImplementerSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxFio.Text = view.ImplementerFIO;
+ textBoxPassword.Text = view.Password;
+ numericUpDownQualification.Value = view.Qualification;
+ numericUpDownWorkExperience.Value = view.WorkExperience;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения исполнителя");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxPassword.Text))
+ {
+ MessageBox.Show("Заполните пароль", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (string.IsNullOrEmpty(textBoxFio.Text))
+ {
+ MessageBox.Show("Заполните фио", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение исполнителя");
+ try
+ {
+ var model = new ImplementerBindingModel
+ {
+ Id = _id ?? 0,
+ ImplementerFIO = textBoxFio.Text,
+ Password = textBoxPassword.Text,
+ Qualification = (int)numericUpDownQualification.Value,
+ WorkExperience = (int)numericUpDownWorkExperience.Value,
+ };
+ var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения исполнителя");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/IceCreamShop/IceCreamShop/FormImplementer.resx b/IceCreamShop/IceCreamShop/FormImplementer.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/IceCreamShop/IceCreamShop/FormImplementer.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/IceCreamShop/IceCreamShop/FormImplementers.Designer.cs b/IceCreamShop/IceCreamShop/FormImplementers.Designer.cs
new file mode 100644
index 0000000..66d72d3
--- /dev/null
+++ b/IceCreamShop/IceCreamShop/FormImplementers.Designer.cs
@@ -0,0 +1,127 @@
+namespace IceCreamShopView
+{
+ partial class FormImplementers
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.buttonRef = new System.Windows.Forms.Button();
+ this.buttonDel = new System.Windows.Forms.Button();
+ this.buttonUpd = new System.Windows.Forms.Button();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // buttonRef
+ //
+ this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonRef.Location = new System.Drawing.Point(688, 182);
+ this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonRef.Name = "buttonRef";
+ this.buttonRef.Size = new System.Drawing.Size(103, 49);
+ this.buttonRef.TabIndex = 14;
+ this.buttonRef.Text = "Обновить";
+ this.buttonRef.UseVisualStyleBackColor = true;
+ this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
+ //
+ // buttonDel
+ //
+ this.buttonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonDel.Location = new System.Drawing.Point(688, 130);
+ this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(103, 44);
+ this.buttonDel.TabIndex = 13;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
+ //
+ // buttonUpd
+ //
+ this.buttonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonUpd.Location = new System.Drawing.Point(688, 77);
+ this.buttonUpd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonUpd.Name = "buttonUpd";
+ this.buttonUpd.Size = new System.Drawing.Size(103, 45);
+ this.buttonUpd.TabIndex = 12;
+ this.buttonUpd.Text = "Изменить";
+ this.buttonUpd.UseVisualStyleBackColor = true;
+ this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonAdd.Location = new System.Drawing.Point(688, 29);
+ this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(103, 40);
+ this.buttonAdd.TabIndex = 11;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(12, 13);
+ this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 25;
+ this.dataGridView.Size = new System.Drawing.Size(670, 425);
+ this.dataGridView.TabIndex = 10;
+ //
+ // FormImplementers
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(803, 451);
+ this.Controls.Add(this.buttonRef);
+ this.Controls.Add(this.buttonDel);
+ this.Controls.Add(this.buttonUpd);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridView);
+ this.Name = "FormImplementers";
+ this.Text = "Исполнители";
+ this.Load += new System.EventHandler(this.FormImplementers_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Button buttonRef;
+ private Button buttonDel;
+ private Button buttonUpd;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/IceCreamShop/IceCreamShop/FormImplementers.cs b/IceCreamShop/IceCreamShop/FormImplementers.cs
new file mode 100644
index 0000000..3f68360
--- /dev/null
+++ b/IceCreamShop/IceCreamShop/FormImplementers.cs
@@ -0,0 +1,109 @@
+using IceCreamShop;
+using IceCreamShopContracts.BindingModels;
+using IceCreamShopContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+
+
+namespace IceCreamShopView
+{
+ public partial class FormImplementers : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IImplementerLogic _logic;
+ public FormImplementers(ILogger logger, IImplementerLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormImplementers_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["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ _logger.LogInformation("Загрузка исполнителей");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки исполнителей");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
+ if (service is FormImplementer form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonUpd_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
+ if (service is FormImplementer form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ int id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Удаление исполнителя");
+ try
+ {
+ if (!_logic.Delete(new ImplementerBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления исполнителя");
+ MessageBox.Show(ex.Message, "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/IceCreamShop/IceCreamShop/FormImplementers.resx b/IceCreamShop/IceCreamShop/FormImplementers.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/IceCreamShop/IceCreamShop/FormImplementers.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/IceCreamShop/IceCreamShop/FormMain.Designer.cs b/IceCreamShop/IceCreamShop/FormMain.Designer.cs
index 3b2da95..9a72c3b 100644
--- a/IceCreamShop/IceCreamShop/FormMain.Designer.cs
+++ b/IceCreamShop/IceCreamShop/FormMain.Designer.cs
@@ -30,26 +30,26 @@
{
this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonSetToFinish = new System.Windows.Forms.Button();
- this.buttonSetToDone = new System.Windows.Forms.Button();
- this.buttonSetToWork = new System.Windows.Forms.Button();
this.buttonCreateOrder = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.menuStrip = new System.Windows.Forms.MenuStrip();
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.мороженоеToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.ImplementersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.iceCreamComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.iceCreamToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ordersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.DoWorkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.menuStrip.SuspendLayout();
this.SuspendLayout();
//
// buttonUpdate
//
- this.buttonUpdate.Location = new System.Drawing.Point(1067, 390);
+ this.buttonUpdate.Location = new System.Drawing.Point(1235, 149);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(194, 49);
this.buttonUpdate.TabIndex = 13;
@@ -59,7 +59,7 @@
//
// buttonSetToFinish
//
- this.buttonSetToFinish.Location = new System.Drawing.Point(1067, 298);
+ this.buttonSetToFinish.Location = new System.Drawing.Point(1235, 94);
this.buttonSetToFinish.Name = "buttonSetToFinish";
this.buttonSetToFinish.Size = new System.Drawing.Size(194, 49);
this.buttonSetToFinish.TabIndex = 12;
@@ -67,29 +67,9 @@
this.buttonSetToFinish.UseVisualStyleBackColor = true;
this.buttonSetToFinish.Click += new System.EventHandler(this.buttonSetToFinish_Click);
//
- // buttonSetToDone
- //
- this.buttonSetToDone.Location = new System.Drawing.Point(1067, 211);
- this.buttonSetToDone.Name = "buttonSetToDone";
- this.buttonSetToDone.Size = new System.Drawing.Size(194, 49);
- this.buttonSetToDone.TabIndex = 11;
- this.buttonSetToDone.Text = "Заказ готов";
- this.buttonSetToDone.UseVisualStyleBackColor = true;
- this.buttonSetToDone.Click += new System.EventHandler(this.buttonSetToDone_Click);
- //
- // buttonSetToWork
- //
- this.buttonSetToWork.Location = new System.Drawing.Point(1067, 122);
- this.buttonSetToWork.Name = "buttonSetToWork";
- this.buttonSetToWork.Size = new System.Drawing.Size(194, 49);
- this.buttonSetToWork.TabIndex = 10;
- this.buttonSetToWork.Text = "Отдать на выполнение";
- this.buttonSetToWork.UseVisualStyleBackColor = true;
- this.buttonSetToWork.Click += new System.EventHandler(this.buttonSetToWork_Click);
- //
// buttonCreateOrder
//
- this.buttonCreateOrder.Location = new System.Drawing.Point(1067, 33);
+ this.buttonCreateOrder.Location = new System.Drawing.Point(1235, 39);
this.buttonCreateOrder.Name = "buttonCreateOrder";
this.buttonCreateOrder.Size = new System.Drawing.Size(194, 49);
this.buttonCreateOrder.TabIndex = 9;
@@ -104,7 +84,7 @@
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
- this.dataGridView.Size = new System.Drawing.Size(1047, 407);
+ this.dataGridView.Size = new System.Drawing.Size(1215, 407);
this.dataGridView.TabIndex = 8;
//
// menuStrip
@@ -112,11 +92,12 @@
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.справочникиToolStripMenuItem,
- this.отчетыToolStripMenuItem});
+ this.отчетыToolStripMenuItem,
+ this.DoWorkToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Padding = new System.Windows.Forms.Padding(6, 3, 0, 3);
- this.menuStrip.Size = new System.Drawing.Size(1273, 30);
+ this.menuStrip.Size = new System.Drawing.Size(1441, 30);
this.menuStrip.TabIndex = 7;
this.menuStrip.Text = "Справочники";
//
@@ -125,7 +106,8 @@
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.компонентыToolStripMenuItem,
this.мороженоеToolStripMenuItem,
- this.клиентыToolStripMenuItem});
+ this.клиентыToolStripMenuItem,
+ this.ImplementersToolStripMenuItem});
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
this.справочникиToolStripMenuItem.Text = "Справочники";
@@ -133,17 +115,31 @@
// компонентыToolStripMenuItem
//
this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
- this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
+ this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
this.компонентыToolStripMenuItem.Text = "Компоненты";
this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click);
//
// мороженоеToolStripMenuItem
//
this.мороженоеToolStripMenuItem.Name = "мороженоеToolStripMenuItem";
- this.мороженоеToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
+ this.мороженоеToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
this.мороженоеToolStripMenuItem.Text = "Мороженое";
this.мороженоеToolStripMenuItem.Click += new System.EventHandler(this.мороженоеToolStripMenuItem_Click);
//
+ // клиентыToolStripMenuItem
+ //
+ this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
+ this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
+ this.клиентыToolStripMenuItem.Text = "Клиенты";
+ this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click);
+ //
+ // ImplementersToolStripMenuItem
+ //
+ this.ImplementersToolStripMenuItem.Name = "ImplementersToolStripMenuItem";
+ this.ImplementersToolStripMenuItem.Size = new System.Drawing.Size(185, 26);
+ this.ImplementersToolStripMenuItem.Text = "Исполнители";
+ this.ImplementersToolStripMenuItem.Click += new System.EventHandler(this.ImplementersToolStripMenuItem_Click);
+ //
// отчетыToolStripMenuItem
//
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -175,22 +171,20 @@
this.ordersToolStripMenuItem.Text = "Список заказов";
this.ordersToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click);
//
- // клиентыToolStripMenuItem
+ // DoWorkToolStripMenuItem
//
- this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
- this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
- this.клиентыToolStripMenuItem.Text = "Клиенты";
- this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click);
+ this.DoWorkToolStripMenuItem.Name = "DoWorkToolStripMenuItem";
+ this.DoWorkToolStripMenuItem.Size = new System.Drawing.Size(114, 24);
+ this.DoWorkToolStripMenuItem.Text = "Запуск работ";
+ this.DoWorkToolStripMenuItem.Click += new System.EventHandler(this.DoWorkToolStripMenuItem_Click);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1273, 463);
+ this.ClientSize = new System.Drawing.Size(1441, 463);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonSetToFinish);
- this.Controls.Add(this.buttonSetToDone);
- this.Controls.Add(this.buttonSetToWork);
this.Controls.Add(this.buttonCreateOrder);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.menuStrip);
@@ -210,8 +204,6 @@
private Button buttonUpdate;
private Button buttonSetToFinish;
- private Button buttonSetToDone;
- private Button buttonSetToWork;
private Button buttonCreateOrder;
private DataGridView dataGridView;
private MenuStrip menuStrip;
@@ -223,5 +215,7 @@
private ToolStripMenuItem iceCreamToolStripMenuItem;
private ToolStripMenuItem ordersToolStripMenuItem;
private ToolStripMenuItem клиентыToolStripMenuItem;
+ private ToolStripMenuItem ImplementersToolStripMenuItem;
+ private ToolStripMenuItem DoWorkToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/IceCreamShop/IceCreamShop/FormMain.cs b/IceCreamShop/IceCreamShop/FormMain.cs
index 172e9b5..a7d5832 100644
--- a/IceCreamShop/IceCreamShop/FormMain.cs
+++ b/IceCreamShop/IceCreamShop/FormMain.cs
@@ -21,12 +21,14 @@ namespace IceCreamShopView
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic;
- public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic)
+ private readonly IWorkProcess _workProcess;
+ public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
_reportLogic = reportLogic;
+ _workProcess = workProcess;
}
private void FormMain_Load(object sender, EventArgs e)
@@ -45,6 +47,7 @@ namespace IceCreamShopView
dataGridView.DataSource = list;
dataGridView.Columns["IceCreamId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
+ dataGridView.Columns["ImplementerId"].Visible = false;
}
_logger.LogInformation("Загрузка заказов");
}
@@ -204,5 +207,22 @@ namespace IceCreamShopView
form.ShowDialog();
}
}
+
+ private void ImplementersToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
+ if (service is FormImplementers form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void DoWorkToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ _workProcess.DoWork((
+ Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!,_orderLogic);
+ MessageBox.Show("Процесс обработки запущен", "Сообщение",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
}
}
diff --git a/IceCreamShop/IceCreamShop/Program.cs b/IceCreamShop/IceCreamShop/Program.cs
index f78aa62..02ccaad 100644
--- a/IceCreamShop/IceCreamShop/Program.cs
+++ b/IceCreamShop/IceCreamShop/Program.cs
@@ -58,7 +58,9 @@ namespace IceCreamShop
services.AddTransient();
services.AddTransient();
- services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
diff --git a/IceCreamShop/IceCreamShopDatabaseImplement/Implements/OrderStorage.cs b/IceCreamShop/IceCreamShopDatabaseImplement/Implements/OrderStorage.cs
index 10ad604..c657526 100644
--- a/IceCreamShop/IceCreamShopDatabaseImplement/Implements/OrderStorage.cs
+++ b/IceCreamShop/IceCreamShopDatabaseImplement/Implements/OrderStorage.cs
@@ -107,21 +107,14 @@ namespace IceCreamShopDatabaseImplement.Implements
public OrderViewModel? Update(OrderBindingModel model)
{
using var context = new IceCreamShopDatabase();
-
- var order = context.Orders
- .Include(x => x.Client)
- .Include(x => x.Implementer)
- .FirstOrDefault(x => x.Id == model.Id);
-
+ var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
if (order == null)
{
return null;
}
-
order.Update(model);
context.SaveChanges();
-
- return order.GetViewModel;
+ return context.Orders.Include(x => x.IceCream).Include(x => x.Implementer).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
}
}
}
diff --git a/IceCreamShop/IceCreamShopDatabaseImplement/Models/Order.cs b/IceCreamShop/IceCreamShopDatabaseImplement/Models/Order.cs
index c28a550..4568883 100644
--- a/IceCreamShop/IceCreamShopDatabaseImplement/Models/Order.cs
+++ b/IceCreamShop/IceCreamShopDatabaseImplement/Models/Order.cs
@@ -26,8 +26,8 @@ namespace IceCreamShopDatabaseImplement.Models
public DateTime? DateImplement { get; set; }
public int Id { get; set; }
- public virtual IceCream IceCream{ get; set; }
- public virtual Client Client { get; set; }
+ public virtual IceCream IceCream{ get; private set; }
+ public virtual Client Client { get; private set; }
public Implementer? Implementer { get; private set; }
public static Order? Create(OrderBindingModel? model)
{
@@ -56,6 +56,7 @@ namespace IceCreamShopDatabaseImplement.Models
return;
}
Status = model.Status;
+ ImplementerId = model.ImplementerId;
DateImplement = model.DateImplement;
}
@@ -76,7 +77,7 @@ namespace IceCreamShopDatabaseImplement.Models
DateImplement = DateImplement,
Id = Id,
IceCreamName = context.IceCreams.FirstOrDefault(x => x.Id == IceCreamId)?.IceCreamName ?? string.Empty,
- ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty,
+ ImplementerFIO = context.Implementers.FirstOrDefault(x => x.Id == ImplementerId)?.ImplementerFIO ?? string.Empty,
ClientFIO = Client?.ClientFIO ?? string.Empty,
};
}