55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
|
using GasStation.Reports;
|
|||
|
using Unity;
|
|||
|
|
|||
|
namespace GasStation.Forms;
|
|||
|
|
|||
|
public partial class FormDirectoryReport : Form
|
|||
|
{
|
|||
|
private readonly IUnityContainer _container;
|
|||
|
|
|||
|
public FormDirectoryReport(IUnityContainer container)
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
_container = container ??
|
|||
|
throw new ArgumentNullException(nameof(container));
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void ButtonBuild_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (!checkBoxGasmen.Checked && !checkBoxSuppliers.Checked && !checkBoxProducts.Checked)
|
|||
|
{
|
|||
|
throw new Exception("Не выбран ни один справочник для выгрузки");
|
|||
|
}
|
|||
|
|
|||
|
var sfd = new SaveFileDialog()
|
|||
|
{
|
|||
|
Filter = "Docx Files | *.docx"
|
|||
|
};
|
|||
|
|
|||
|
if (sfd.ShowDialog() != DialogResult.OK)
|
|||
|
{
|
|||
|
throw new Exception("Не выбран файла для отчета");
|
|||
|
}
|
|||
|
|
|||
|
if (_container.Resolve<DocReport>().CreateDoc(sfd.FileName, checkBoxGasmen.Checked, checkBoxSuppliers.Checked, checkBoxProducts.Checked))
|
|||
|
{
|
|||
|
MessageBox.Show("Документ сформирован", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", "Формирование документа",
|
|||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
MessageBox.Show(ex.Message, "Ошибка при создании отчета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|