2023-03-13 23:04:34 +04:00
|
|
|
|
using LawFirmContracts.BusinessLogicsContracts;
|
|
|
|
|
using System;
|
|
|
|
|
using LawFirmContracts.BindingModels;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace LawFirmView
|
|
|
|
|
{
|
|
|
|
|
public partial class FormReportDocumentBlanks : Form
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
private readonly IReportLogic _logic;
|
|
|
|
|
public FormReportDocumentBlanks(ILogger<FormReportDocumentBlanks> logger, IReportLogic logic)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_logic = logic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FormReportDocumentBlanks_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var dict = _logic.GetDocumentBlank();
|
|
|
|
|
if (dict != null)
|
|
|
|
|
{
|
|
|
|
|
dataGridView.Rows.Clear();
|
|
|
|
|
foreach (var elem in dict)
|
|
|
|
|
{
|
2023-03-27 19:39:11 +04:00
|
|
|
|
dataGridView.Rows.Add(new object[] { elem.DocumentName, "", "" });
|
|
|
|
|
foreach (var listElem in elem.Blanks)
|
2023-03-13 23:04:34 +04:00
|
|
|
|
{
|
2023-04-21 14:19:31 +04:00
|
|
|
|
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
2023-03-13 23:04:34 +04:00
|
|
|
|
}
|
2023-04-21 14:19:31 +04:00
|
|
|
|
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
|
2023-03-13 23:04:34 +04:00
|
|
|
|
dataGridView.Rows.Add(Array.Empty<object>());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_logger.LogInformation("Загрузка списка изделий по компонентам");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам");
|
|
|
|
|
|
|
|
|
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2023-03-27 19:39:11 +04:00
|
|
|
|
|
|
|
|
|
private void ButtonSaveToExcel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using var dialog = new SaveFileDialog
|
|
|
|
|
{
|
|
|
|
|
Filter = "xlsx|*.xlsx"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_logic.SaveDocumentBlankToExcelFile(new ReportBindingModel
|
|
|
|
|
{
|
|
|
|
|
FileName = dialog.FileName
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("Saving list of computers by components");
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error saving list of computers by components");
|
|
|
|
|
|
|
|
|
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-13 23:04:34 +04:00
|
|
|
|
}
|
|
|
|
|
}
|