23
This commit is contained in:
parent
4b0700dee1
commit
a75413f8ad
@ -12,9 +12,9 @@ namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
|||||||
// Бизнес-логика для продуктов
|
// Бизнес-логика для продуктов
|
||||||
public interface IUsersLogic
|
public interface IUsersLogic
|
||||||
{
|
{
|
||||||
List<FurnitureViewModel>? ReadList(UsersSearchModel? model);
|
List<UsersViewModel>? ReadList(UsersSearchModel? model);
|
||||||
|
|
||||||
FurnitureViewModel? ReadElement(UsersSearchModel model);
|
UsersViewModel? ReadElement(UsersSearchModel model);
|
||||||
|
|
||||||
bool Create(UsersBindingModel model);
|
bool Create(UsersBindingModel model);
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace FurnitureAssemblyView
|
|||||||
|
|
||||||
private int? _id;
|
private int? _id;
|
||||||
|
|
||||||
private Dictionary<int, (IKommentModel, int)> _furnitureWorkPieces;
|
private Dictionary<int, (IKommentModel, int)> _usersKomments;
|
||||||
|
|
||||||
public int Id { set { _id = value; } }
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ namespace FurnitureAssemblyView
|
|||||||
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
_furnitureWorkPieces = new Dictionary<int, (IKommentModel, int)>();
|
_usersKomments = new Dictionary<int, (IKommentModel, int)>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormFurniture_Load(object sender, EventArgs e)
|
private void FormFurniture_Load(object sender, EventArgs e)
|
||||||
@ -50,7 +50,7 @@ namespace FurnitureAssemblyView
|
|||||||
{
|
{
|
||||||
textBoxName.Text = view.UsersName;
|
textBoxName.Text = view.UsersName;
|
||||||
textBoxPrice.Text = view.Price.ToString();
|
textBoxPrice.Text = view.Price.ToString();
|
||||||
_furnitureWorkPieces = view.FurnitureWorkPieces ?? new Dictionary<int, (IKommentModel, int)>();
|
_usersKomments = view.UsersKomments ?? new Dictionary<int, (IKommentModel, int)>();
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,11 +68,11 @@ namespace FurnitureAssemblyView
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(_furnitureWorkPieces != null)
|
if(_usersKomments != null)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Clear();
|
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 });
|
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);
|
_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
|
else
|
||||||
{
|
{
|
||||||
_furnitureWorkPieces.Add(form.Id, (form.WorkPieceModel, form.Count));
|
_usersKomments.Add(form.Id, (form.WorkPieceModel, form.Count));
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadData();
|
LoadData();
|
||||||
@ -126,7 +126,7 @@ namespace FurnitureAssemblyView
|
|||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
form.Id = id;
|
form.Id = id;
|
||||||
form.Count = _furnitureWorkPieces[id].Item2;
|
form.Count = _usersKomments[id].Item2;
|
||||||
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
@ -136,7 +136,7 @@ namespace FurnitureAssemblyView
|
|||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Изменение компонента:{WorkPieceName} - {Count}", form.WorkPieceModel.WorkPieceName, form.Count);
|
_logger.LogInformation("Изменение компонента:{WorkPieceName} - {Count}", form.WorkPieceModel.WorkPieceName, form.Count);
|
||||||
_furnitureWorkPieces[form.Id] = (form.WorkPieceModel, form.Count);
|
_usersKomments[form.Id] = (form.WorkPieceModel, form.Count);
|
||||||
|
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ namespace FurnitureAssemblyView
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Удаление заготовки:{WorkPieceName} - {Count}", dataGridView.SelectedRows[0].Cells[1].Value);
|
_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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -186,7 +186,7 @@ namespace FurnitureAssemblyView
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_furnitureWorkPieces == null || _furnitureWorkPieces.Count == 0)
|
if (_usersKomments == null || _usersKomments.Count == 0)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ namespace FurnitureAssemblyView
|
|||||||
Id = _id ?? 0,
|
Id = _id ?? 0,
|
||||||
UsersName = textBoxName.Text,
|
UsersName = textBoxName.Text,
|
||||||
Price = Convert.ToDouble(textBoxPrice.Text),
|
Price = Convert.ToDouble(textBoxPrice.Text),
|
||||||
FurnitureWorkPieces = _furnitureWorkPieces
|
UsersKomments = _usersKomments
|
||||||
};
|
};
|
||||||
|
|
||||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
@ -230,12 +230,11 @@ namespace FurnitureAssemblyView
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// В конце умножить на 1.1, так как прибавляем к итоговой стоимости некоторый процент (в данном случае 10%)
|
|
||||||
private double CalcPrice()
|
private double CalcPrice()
|
||||||
{
|
{
|
||||||
double price = 0;
|
double price = 0;
|
||||||
|
|
||||||
foreach (var elem in _furnitureWorkPieces)
|
foreach (var elem in _usersKomments)
|
||||||
{
|
{
|
||||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user