56 lines
1.8 KiB
C#

using System.Windows.Forms;
using Unity;
namespace LDBproject.AdditionalForms
{
public partial class UpdReportF : Form
{
private string _fileName = string.Empty;
private readonly IUnityContainer _container;
public UpdReportF(IUnityContainer container)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void SelectFileNameBtn_Click(object sender, EventArgs e)
{
var sfd = new SaveFileDialog()
{
Filter = "Pdf Files | *.pdf"
};
if (sfd.ShowDialog() == DialogResult.OK)
{
_fileName = sfd.FileName;
FileNamelabel.Text = Path.GetFileName(_fileName);
}
}
private void CreateBtn_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(_fileName))
{
throw new Exception("No file (path) chosen");
}
if
(_container.Resolve<ChartReport>().CreateChart(_fileName, UpdDTP.Value))
{
MessageBox.Show("< PDF Document was formated >", "Creating chart report (pdf)",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
MessageBox.Show("< ERROR : see logs >", "Pdf. formating",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "< ERROR : while creating pdf document >",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}