2022-03-16 12:27:40 +04:00
|
|
|
|
using AcademicProgressBusinessLogic.BindingModels;
|
|
|
|
|
using AcademicProgressBusinessLogic.BusinessLogics;
|
|
|
|
|
using DepartmentWindowsDesktop.EntityControls;
|
2022-03-15 13:20:46 +04:00
|
|
|
|
using DesktopTools.BaseControls;
|
2022-03-16 12:27:40 +04:00
|
|
|
|
using DesktopTools.Helpers;
|
2022-03-15 13:20:46 +04:00
|
|
|
|
using DesktopTools.Interfaces;
|
|
|
|
|
using DesktopTools.Models;
|
2022-03-16 12:27:40 +04:00
|
|
|
|
using ModuleTools.BusinessLogics;
|
2022-03-15 13:20:46 +04:00
|
|
|
|
using ModuleTools.Enums;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
|
|
|
|
namespace AcademicProgressWindowsDesktop.SpecialControls
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Контрол для работы с выпускниками
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class ControlStudentGraduate : UserControl, IControl
|
|
|
|
|
{
|
2022-03-16 12:27:40 +04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Класс с бизнес-логикой работы с отчетом
|
|
|
|
|
/// </summary>
|
2022-03-28 22:03:10 +04:00
|
|
|
|
private readonly ReportLogic _reportLogic;
|
2022-03-16 12:27:40 +04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2022-03-15 13:20:46 +04:00
|
|
|
|
/// Событие, вызываемое при закрытии контрола
|
|
|
|
|
/// </summary>
|
|
|
|
|
private event Action<Guid> CloseEvent;
|
2022-03-16 12:27:40 +04:00
|
|
|
|
|
2022-03-28 22:03:10 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Событие получения значения из контрола
|
|
|
|
|
/// </summary>
|
|
|
|
|
private event Action<object> GetValues;
|
|
|
|
|
|
2022-03-16 12:27:40 +04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Контрол для работы с отчетом приложения к диплому
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ControlStudentGraduate()
|
2022-03-15 13:20:46 +04:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2022-03-28 22:03:10 +04:00
|
|
|
|
_reportLogic = DependencyManager.Instance.Resolve<ReportLogic>();
|
2022-03-15 13:20:46 +04:00
|
|
|
|
Title = "Приложение к диплому";
|
|
|
|
|
ControlId = new Guid("cc3944e6-5d92-4c89-b817-4c17ec382bc1");
|
|
|
|
|
AccessOperation = AccessOperation.Для_выпускников;
|
|
|
|
|
toolStripButtonClose.Click += (object sender, EventArgs e) =>
|
|
|
|
|
{
|
|
|
|
|
CloseEvent?.Invoke(ControlId);
|
|
|
|
|
Dispose();
|
|
|
|
|
};
|
|
|
|
|
LoadGroupBoxReportInfo();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#region IControl
|
|
|
|
|
public Guid ControlId { get; private set; }
|
|
|
|
|
|
|
|
|
|
public string Title { get; private set; }
|
|
|
|
|
|
|
|
|
|
public AccessOperation AccessOperation { get; private set; }
|
|
|
|
|
|
|
|
|
|
public IControl GetInstance() => new ControlStudentGraduate() { ControlId = Guid.NewGuid() };
|
|
|
|
|
|
|
|
|
|
public void Open(ControlOpenModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model.CloseList != null)
|
|
|
|
|
{
|
|
|
|
|
CloseEvent += model.CloseList;
|
|
|
|
|
}
|
|
|
|
|
Dock = DockStyle.Fill;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string SaveToXml() => new XElement("Control",
|
|
|
|
|
new XAttribute("Type", GetType().FullName),
|
|
|
|
|
new XAttribute("ControlId", ControlId),
|
|
|
|
|
new XAttribute("Title", Title),
|
|
|
|
|
new XAttribute("AccessOperation", AccessOperation)).ToString();
|
|
|
|
|
|
|
|
|
|
public void LoadFromXml(string xml)
|
|
|
|
|
{
|
|
|
|
|
var control = XElement.Parse(xml);
|
|
|
|
|
ControlId = new Guid(control.Attribute("ControlId").Value.ToString());
|
|
|
|
|
Title = control.Attribute("Title").Value.ToString();
|
|
|
|
|
AccessOperation = (AccessOperation)Enum.Parse(typeof(AccessOperation), control.Attribute("AccessOperation").Value.ToString());
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2022-03-16 12:27:40 +04:00
|
|
|
|
|
2022-03-15 13:20:46 +04:00
|
|
|
|
|
|
|
|
|
private void LoadGroupBoxReportInfo()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
int positionY = 40;
|
|
|
|
|
|
|
|
|
|
var controlStudent = new BaseControlGuid("StudentId", true, false, new ControlStudentList(), null)
|
|
|
|
|
{
|
|
|
|
|
Location = new System.Drawing.Point(50, positionY),
|
|
|
|
|
Size = new System.Drawing.Size(410, 23)
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
controlStudent.SetTitleWidth(controlStudent.SetTitle("Cтудент:"));
|
|
|
|
|
groupBoxReportInfo.Controls.Add(controlStudent);
|
2022-03-28 22:03:10 +04:00
|
|
|
|
GetValues += controlStudent.GetValue;
|
|
|
|
|
|
2022-03-15 13:20:46 +04:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-16 12:27:40 +04:00
|
|
|
|
private void buttonSaveSelectFolder_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var fbd = new FolderBrowserDialog();
|
|
|
|
|
if (fbd.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
textBoxSaveFolderName.Text = fbd.SelectedPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-28 22:03:10 +04:00
|
|
|
|
private void buttonSave_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var model = new StudentAcademicProgressSetBindingModel();
|
2022-03-16 12:27:40 +04:00
|
|
|
|
try
|
|
|
|
|
{
|
2022-03-28 22:03:10 +04:00
|
|
|
|
GetValues(model);
|
|
|
|
|
|
2022-03-16 12:27:40 +04:00
|
|
|
|
_reportLogic.SaveReportToWordFile(new ReportBindingModel
|
|
|
|
|
{
|
2022-03-28 22:03:10 +04:00
|
|
|
|
FolderName = textBoxSaveFolderName.Text,
|
|
|
|
|
StudentId = model.StudentId
|
2022-03-16 12:27:40 +04:00
|
|
|
|
});
|
|
|
|
|
DialogHelper.MessageInformation("Сохранение прошло успешно", "Результат");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2022-03-28 22:03:10 +04:00
|
|
|
|
DialogHelper.MessageException(ex.Message, "Ошибка при получении значений");
|
2022-03-16 12:27:40 +04:00
|
|
|
|
}
|
2022-03-28 22:03:10 +04:00
|
|
|
|
}
|
2022-03-16 12:27:40 +04:00
|
|
|
|
}
|
2022-03-15 13:20:46 +04:00
|
|
|
|
}
|