2022-03-19 22:48:13 +04:00
|
|
|
|
using DepartmentContract.BindingModels;
|
|
|
|
|
using DepartmentContract.Logics.IGenericEntityLogic;
|
|
|
|
|
using DepartmentContract.ViewModels;
|
2022-12-19 22:12:03 +04:00
|
|
|
|
using DepartmentWindowsDesktop.EntityControls.StudentGroup;
|
2022-03-19 22:48:13 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2022-12-19 22:12:03 +04:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2022-03-18 22:48:14 +04:00
|
|
|
|
using ToolsDesktop.Controls;
|
|
|
|
|
using ToolsDesktop.Enums;
|
2022-12-19 22:12:03 +04:00
|
|
|
|
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
|
|
|
|
|
{
|
2022-03-19 22:48:13 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Реализация контрола для списка учебных групп
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class ControlStudentGroupList :
|
2022-12-19 22:12:03 +04:00
|
|
|
|
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
|
|
|
|
|
2022-12-19 22:12:03 +04:00
|
|
|
|
public IControl GetInstanceGenericControl() => new ControlStudentGroupList() { ControlId = Guid.NewGuid() };
|
2021-04-12 10:01:42 +04:00
|
|
|
|
|
2022-12-19 22:12:03 +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
|
|
|
|
}
|