DepartmentProject/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/StudentGroup/ControlStudentGroupList.cs

85 lines
3.3 KiB
C#
Raw Permalink Normal View History

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;
2022-03-18 22:48:14 +04:00
using ToolsDesktop.Controls;
using ToolsDesktop.Enums;
using ToolsDesktop.Helpers;
2022-03-18 22:48:14 +04:00
using ToolsDesktop.Interfaces;
using ToolsDesktop.Models;
2022-03-20 10:10:44 +04:00
using ToolsModule.ManagmentSecurity;
2021-04-12 10:01:42 +04:00
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;
}
2021-04-12 10:01:42 +04:00
public IControl GetInstanceGenericControl() => new ControlStudentGroupList() { ControlId = Guid.NewGuid() };
2021-04-12 10:01:42 +04:00
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("Завершено успешно", "Сохранение списка группы");
}
}
}
2021-04-12 10:01:42 +04:00
}