85 lines
3.3 KiB
C#
85 lines
3.3 KiB
C#
using DepartmentContract.BindingModels;
|
||
using DepartmentContract.Logics.IGenericEntityLogic;
|
||
using DepartmentContract.ViewModels;
|
||
using DepartmentWindowsDesktop.EntityControls.StudentGroup;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Threading.Tasks;
|
||
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 ControlStudentGroupList :
|
||
GenericControlEntityList<StudentGroupGetBindingModel, StudentGroupSetBindingModel, StudentGroupListViewModel, StudentGroupViewModel, IStudentGroupLogic>,
|
||
IGenericControlEntityList
|
||
{
|
||
public ControlStudentGroupList()
|
||
{
|
||
InitializeComponent();
|
||
Title = "Учебные группы";
|
||
ControlId = new Guid("453666ff-511e-4751-887f-0fec5c1e95c8");
|
||
AccessOperation = AccessOperation.УчебныеГруппы;
|
||
ControlViewEntityElement = new ControlStudentGroupElement();
|
||
_genericControlViewEntityList = this;
|
||
}
|
||
|
||
public IControl GetInstanceGenericControl() => new ControlStudentGroupList() { ControlId = Guid.NewGuid() };
|
||
|
||
public ControlViewEntityListConfiguration GetConfigControl() => new()
|
||
{
|
||
PaginationOn = false,
|
||
HideToolStripButton = new List<ToolStripButtonListNames>
|
||
{
|
||
ToolStripButtonListNames.toolStripButtonSearch
|
||
},
|
||
ControlOnMoveElem = new()
|
||
{
|
||
{ "ToolStripMenuItemSaveStudentGroup", ("Сохранить список студентов", async (object sender, EventArgs e) => { await SaveToFile(); }) }
|
||
}
|
||
};
|
||
|
||
/// <summary>
|
||
/// Сохранение в файл
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private async Task SaveToFile()
|
||
{
|
||
var guids = GetSelectedIds();
|
||
if (guids == null || guids.Count != 1)
|
||
{
|
||
DialogHelper.MessageException("Должна быть выбрана одна группа", "Ошибки при создании документа");
|
||
return;
|
||
}
|
||
var form = new FormSaveToFile();
|
||
if (form.ShowDialog() != DialogResult.OK)
|
||
{
|
||
return;
|
||
}
|
||
var model = form.Model;
|
||
if (model == null)
|
||
{
|
||
DialogHelper.MessageException("Данные для сохранения не получены", "Ошибки при создании документа");
|
||
return;
|
||
}
|
||
model.StudentGroupId = guids[0];
|
||
var flag = await _businessLogic.SaveToWord(model);
|
||
if (!flag)
|
||
{
|
||
DialogHelper.MessageException(_businessLogic.Errors, "Ошибки при создании документа");
|
||
}
|
||
else
|
||
{
|
||
DialogHelper.MessageInformation("Завершено успешно", "Сохранение списка группы");
|
||
}
|
||
}
|
||
}
|
||
} |