69 lines
2.0 KiB
C#
69 lines
2.0 KiB
C#
using DepartmentBusinessLogic.BindingModels;
|
|
using DepartmentBusinessLogic.BusinessLogics;
|
|
using DepartmentBusinessLogic.ViewModels;
|
|
using ToolsDesktop.Controls;
|
|
using ToolsDesktop.Helpers;
|
|
using ToolsDesktop.Interfaces;
|
|
using ToolsDesktop.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
|
|
namespace DepartmentWindowsDesktop.EntityControls
|
|
{
|
|
/// <summary>
|
|
/// Реализация контрола для учебного плана
|
|
/// </summary>
|
|
public partial class ControlAcademicPlanElement :
|
|
GenericControlEntityElement<AcademicPlanGetBindingModel, AcademicPlanSetBindingModel, AcademicPlanListViewModel, AcademicPlanViewModel, AcademicPlanBusinessLogic>,
|
|
IGenericControlEntityElement
|
|
{
|
|
public ControlAcademicPlanElement()
|
|
{
|
|
InitializeComponent();
|
|
Title = "Учебный план";
|
|
ControlId = new Guid("bdba8fca-4c38-49cf-89b0-4906c4aa7aa3");
|
|
_genericControlViewEntityElement = this;
|
|
}
|
|
|
|
public IControl GetInstanceGenericControl() => new ControlAcademicPlanElement() { ControlId = Guid.NewGuid() };
|
|
|
|
public ControlViewEntityElementConfiguration GetConfigControl() => new()
|
|
{
|
|
ControlOnMoveElem = new Dictionary<string, (string Title, EventHandler Event)>
|
|
{
|
|
{ "ToolStripMenuItemLoadPlan", ("Загрузить план", (object sender, EventArgs e) => { LoadPlx(); }) }
|
|
}
|
|
};
|
|
|
|
/// <summary>
|
|
/// Загрузка учебного плана
|
|
/// </summary>
|
|
private void LoadPlx()
|
|
{
|
|
if (_element != null)
|
|
{
|
|
var dialog = new OpenFileDialog
|
|
{
|
|
Filter = "plx|*.plx"
|
|
};
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
var result = _businessLogic.LoadPlx(new AcademicPlanLoadPlxModel
|
|
{
|
|
AcademicPlanId = _element.Id,
|
|
FileName = dialog.FileName
|
|
});
|
|
if (result)
|
|
{
|
|
DialogHelper.MessageInformation("Загрузка прошла успешно", "Результат");
|
|
}
|
|
else
|
|
{
|
|
DialogHelper.MessageException(_businessLogic.Errors, $"Ошибки при загрузке плана");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |