From a75413f8ad78f99543e39df2226e3467e531d9c1 Mon Sep 17 00:00:00 2001 From: platoff aeeee Date: Fri, 24 May 2024 16:50:09 +0400 Subject: [PATCH] 23 --- .../BusinessLogicsContracts/IUsersLogic.cs | 4 +-- .../FurnitureAssemblyView/FormUser.cs | 31 +++++++++---------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IUsersLogic.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IUsersLogic.cs index 4a9d2cc..b9ecc3b 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IUsersLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IUsersLogic.cs @@ -12,9 +12,9 @@ namespace FurnitureAssemblyContracts.BusinessLogicsContracts // Бизнес-логика для продуктов public interface IUsersLogic { - List? ReadList(UsersSearchModel? model); + List? ReadList(UsersSearchModel? model); - FurnitureViewModel? ReadElement(UsersSearchModel model); + UsersViewModel? ReadElement(UsersSearchModel model); bool Create(UsersBindingModel model); diff --git a/FurnitureAssembly/FurnitureAssemblyView/FormUser.cs b/FurnitureAssembly/FurnitureAssemblyView/FormUser.cs index b303145..4169ff8 100644 --- a/FurnitureAssembly/FurnitureAssemblyView/FormUser.cs +++ b/FurnitureAssembly/FurnitureAssemblyView/FormUser.cs @@ -23,7 +23,7 @@ namespace FurnitureAssemblyView private int? _id; - private Dictionary _furnitureWorkPieces; + private Dictionary _usersKomments; public int Id { set { _id = value; } } @@ -33,7 +33,7 @@ namespace FurnitureAssemblyView _logger = logger; _logic = logic; - _furnitureWorkPieces = new Dictionary(); + _usersKomments = new Dictionary(); } private void FormFurniture_Load(object sender, EventArgs e) @@ -50,7 +50,7 @@ namespace FurnitureAssemblyView { textBoxName.Text = view.UsersName; textBoxPrice.Text = view.Price.ToString(); - _furnitureWorkPieces = view.FurnitureWorkPieces ?? new Dictionary(); + _usersKomments = view.UsersKomments ?? new Dictionary(); LoadData(); } } @@ -68,11 +68,11 @@ namespace FurnitureAssemblyView try { - if(_furnitureWorkPieces != null) + if(_usersKomments != null) { dataGridView.Rows.Clear(); - foreach(var awp in _furnitureWorkPieces) + foreach(var awp in _usersKomments) { dataGridView.Rows.Add(new object[] { awp.Key, awp.Value.Item1.WorkPieceName, awp.Value.Item2 }); } @@ -102,13 +102,13 @@ namespace FurnitureAssemblyView _logger.LogInformation("Добавление новой заготовки:{WorkPieceName} - {Count}", form.WorkPieceModel.WorkPieceName, form.Count); - if (_furnitureWorkPieces.ContainsKey(form.Id)) + if (_usersKomments.ContainsKey(form.Id)) { - _furnitureWorkPieces[form.Id] = (form.WorkPieceModel, form.Count); + _usersKomments[form.Id] = (form.WorkPieceModel, form.Count); } else { - _furnitureWorkPieces.Add(form.Id, (form.WorkPieceModel, form.Count)); + _usersKomments.Add(form.Id, (form.WorkPieceModel, form.Count)); } LoadData(); @@ -126,7 +126,7 @@ namespace FurnitureAssemblyView { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); form.Id = id; - form.Count = _furnitureWorkPieces[id].Item2; + form.Count = _usersKomments[id].Item2; if (form.ShowDialog() == DialogResult.OK) { @@ -135,8 +135,8 @@ namespace FurnitureAssemblyView return; } - _logger.LogInformation("Изменение компонента:{WorkPieceName} - {Count}", form.WorkPieceModel.WorkPieceName, form.Count); - _furnitureWorkPieces[form.Id] = (form.WorkPieceModel, form.Count); + _logger.LogInformation("Изменение компонента:{WorkPieceName} - {Count}", form.WorkPieceModel.WorkPieceName, form.Count); + _usersKomments[form.Id] = (form.WorkPieceModel, form.Count); LoadData(); } @@ -153,7 +153,7 @@ namespace FurnitureAssemblyView try { _logger.LogInformation("Удаление заготовки:{WorkPieceName} - {Count}", dataGridView.SelectedRows[0].Cells[1].Value); - _furnitureWorkPieces?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + _usersKomments?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); } catch (Exception ex) { @@ -186,7 +186,7 @@ namespace FurnitureAssemblyView return; } - if (_furnitureWorkPieces == null || _furnitureWorkPieces.Count == 0) + if (_usersKomments == null || _usersKomments.Count == 0) { MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -202,7 +202,7 @@ namespace FurnitureAssemblyView Id = _id ?? 0, UsersName = textBoxName.Text, Price = Convert.ToDouble(textBoxPrice.Text), - FurnitureWorkPieces = _furnitureWorkPieces + UsersKomments = _usersKomments }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); @@ -230,12 +230,11 @@ namespace FurnitureAssemblyView Close(); } - // В конце умножить на 1.1, так как прибавляем к итоговой стоимости некоторый процент (в данном случае 10%) private double CalcPrice() { double price = 0; - foreach (var elem in _furnitureWorkPieces) + foreach (var elem in _usersKomments) { price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); }