DepartmentProject/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/AcademicPlan/ControlAcademicPlanList.cs

81 lines
2.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DepartmentContract.BindingModels;
using DepartmentContract.Logics.IGenericEntityLogic;
using DepartmentContract.ViewModels;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using ToolsDesktop.Controls;
using ToolsDesktop.Enums;
using ToolsDesktop.Helpers;
using ToolsDesktop.Interfaces;
using ToolsDesktop.Models;
using ToolsModule.ManagmentSecurity;
namespace DepartmentWindowsDesktop.EntityControls
{
/// <summary>
/// Реализация контрола для списка учебных планов
/// </summary>
public partial class ControlAcademicPlanList :
GenericControlEntityList<AcademicPlanGetBindingModel, AcademicPlanSetBindingModel, AcademicPlanListViewModel, AcademicPlanViewModel, IAcademicPlanLogic>,
IGenericControlEntityList
{
public ControlAcademicPlanList()
{
InitializeComponent();
Title = "Учебные планы";
ControlId = new Guid("144d098c-ff55-4786-ae63-3105a92990cd");
AccessOperation = AccessOperation.УчебныеПланы;
ControlViewEntityElement = new ControlAcademicPlanElement();
_genericControlViewEntityList = this;
}
public IControl GetInstanceGenericControl() => new ControlAcademicPlanList() { ControlId = Guid.NewGuid() };
public ControlViewEntityListConfiguration GetConfigControl() => new()
{
PaginationOn = false,
HideToolStripButton = new List<ToolStripButtonListNames>
{
ToolStripButtonListNames.toolStripButtonSearch
},
ControlOnMoveElem = new Dictionary<string, (string Title, EventHandler Event)>
{
{ "ToolStripMenuItemLoadPlx", ("Загрузить план", (object sender, EventArgs e) => { LoadPlx(); }) }
}
};
/// <summary>
/// Загрузка учебного плана
/// </summary>
private void LoadPlx()
{
var ids = GetSelectedIds();
if (ids.Count != 1)
{
DialogHelper.MessageException("Должна быть выбрана одна запись", $"Ошибка");
return;
}
var dialog = new OpenFileDialog
{
Filter = "plx|*.plx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
var result = _businessLogic.LoadPlx(new AcademicPlanLoadPlxModel
{
AcademicPlanId = ids[0],
FileName = dialog.FileName
});
if (result)
{
DialogHelper.MessageInformation("Загрузка прошла успешно", "Результат");
}
else
{
DialogHelper.MessageException(_businessLogic.Errors, $"Ошибки при загрузке плана");
}
}
}
}
}