2023-03-28 00:43:46 +04:00
|
|
|
|
using ConfectioneryContracts.BindingModels;
|
|
|
|
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace ConfectioneryView
|
|
|
|
|
{
|
|
|
|
|
public partial class FormReportPastryComponents : Form
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
private readonly IReportLogic _logic;
|
|
|
|
|
public FormReportPastryComponents(ILogger<FormReportPastryComponents>
|
|
|
|
|
logger, IReportLogic logic)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_logic = logic;
|
|
|
|
|
}
|
|
|
|
|
private void FormReportPastryComponents_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var dict = _logic.GetPastryComponent();
|
|
|
|
|
if (dict != null)
|
|
|
|
|
{
|
|
|
|
|
dataGridView.Rows.Clear();
|
|
|
|
|
foreach (var elem in dict)
|
|
|
|
|
{
|
2023-04-11 10:58:40 +04:00
|
|
|
|
dataGridView.Rows.Add(new object[] { elem.PastryName, "", "" });
|
|
|
|
|
foreach (var listElem in elem.Components)
|
2023-03-28 00:43:46 +04:00
|
|
|
|
{
|
|
|
|
|
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
|
|
|
|
}
|
|
|
|
|
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
|
|
|
|
|
dataGridView.Rows.Add(Array.Empty<object>());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_logger.LogInformation("Загрузка списка изделий по компонентам");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам");
|
|
|
|
|
|
|
|
|
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void ButtonSaveToExcel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using var dialog = new SaveFileDialog
|
|
|
|
|
{
|
|
|
|
|
Filter = "xlsx|*.xlsx"
|
|
|
|
|
};
|
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_logic.SavePastryComponentToExcelFile(new
|
|
|
|
|
ReportBindingModel
|
|
|
|
|
{
|
|
|
|
|
FileName = dialog.FileName
|
|
|
|
|
});
|
|
|
|
|
_logger.LogInformation("Сохранение списка изделий по компонентам");
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам");
|
|
|
|
|
|
|
|
|
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|