This commit is contained in:
vladimir_zinovev 2024-05-12 16:26:49 +04:00
parent 2b4db4f5f4
commit 9b6e58a265
2 changed files with 7 additions and 24 deletions

View File

@ -17,9 +17,7 @@ namespace FurnitureAssemblyView
public partial class FormCreateOrder : Form
{
private readonly ILogger _logger;
private readonly IFurnitureLogic _logicM;
private readonly IOrderLogic _logicO;
private readonly IClientLogic _logicC;
@ -31,7 +29,6 @@ namespace FurnitureAssemblyView
_logicM = logicM;
_logicO = logicO;
_logicC = logicC;
}
private void FormCreateOrder_Load(object sender, EventArgs e)
@ -56,22 +53,6 @@ namespace FurnitureAssemblyView
}
_logger.LogInformation("Загрузка клиентов для заказа");
try
{
var clientList = _logicC.ReadList(null);
if (clientList != null)
{
clientBox.DisplayMember = "Client";
clientBox.ValueMember = "Id";
clientBox.DataSource = clientList.Select(c => c.ClientFIO).ToList();
clientBox.SelectedItem = null;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка клиентов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
var list = _logicC.ReadList(null);
@ -97,16 +78,17 @@ namespace FurnitureAssemblyView
{
try
{
var list = _logicM.ReadList(null);
int id = list.Where(l => l.FurnitureName == comboBoxFurniture.SelectedValue.ToString())
.Select(l => l.Id).First();
int id = Convert.ToInt32(comboBoxFurniture.SelectedValue);
var furniture = _logicM.ReadElement(new FurnitureSearchModel
{
Id = id,
FurnitureName = comboBoxFurniture.Text
Id = id
});
int count = Convert.ToInt32(textBoxCount.Text);
textBoxSum.Text = Math.Round(count * (furniture?.Price ?? 0), 2).ToString();
_logger.LogInformation("Расчет суммы заказа");
}
catch (Exception ex)

View File

@ -49,6 +49,7 @@ namespace FurnitureAssemblyView
dataGridView.DataSource = list;
dataGridView.Columns["FurnitureId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["ImplementerId"].Visible = false;
}
_logger.LogInformation("Загрузка заказов");