2024-12-19 15:31:39 +04:00
|
|
|
|
using ProjectLibrary.Reports;
|
|
|
|
|
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;
|
|
|
|
|
using Unity;
|
|
|
|
|
|
|
|
|
|
namespace ProjectLibrary.Forms;
|
|
|
|
|
|
2024-12-20 01:07:20 +04:00
|
|
|
|
public partial class FDocReport : Form
|
2024-12-19 15:31:39 +04:00
|
|
|
|
{
|
|
|
|
|
private readonly IUnityContainer _container;
|
|
|
|
|
|
2024-12-20 01:07:20 +04:00
|
|
|
|
public FDocReport(IUnityContainer container)
|
2024-12-19 15:31:39 +04:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!checkBoxBooks.Checked && !checkBoxReaders.Checked && !checkBoxIncludeTicketExtensions.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, checkBoxBooks.Checked,
|
|
|
|
|
checkBoxReaders.Checked, checkBoxIncludeTicketExtensions.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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|