Почти работает
This commit is contained in:
parent
e825cc46c2
commit
7ca62ddb1d
@ -7,11 +7,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cop.Borovkov.Var3", "Cop.Bo
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestCustomComponents", "TestCustomComponents\TestCustomComponents.csproj", "{E2C46D08-ACCE-4547-922B-E92AD76D99C8}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestCustomComponents", "TestCustomComponents\TestCustomComponents.csproj", "{E2C46D08-ACCE-4547-922B-E92AD76D99C8}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PIHelperSh.PdfCreator", "PIHelperSh.PdfCreater\PIHelperSh.PdfCreator.csproj", "{572BD835-A500-43C9-A66F-648540F4A1C8}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab3", "Lab3\Lab3.csproj", "{1E630CC7-090F-471C-ADA1-74107CF3DC2A}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab3", "Lab3\Lab3.csproj", "{1E630CC7-090F-471C-ADA1-74107CF3DC2A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab3.Database", "Lab3.Database\Lab3.Database.csproj", "{698DE9E8-7885-4F98-AFE3-9A9C6CD2FCF5}"
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab3.Database", "Lab3.Database\Lab3.Database.csproj", "{698DE9E8-7885-4F98-AFE3-9A9C6CD2FCF5}"
|
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -27,10 +25,6 @@ Global
|
|||||||
{E2C46D08-ACCE-4547-922B-E92AD76D99C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{E2C46D08-ACCE-4547-922B-E92AD76D99C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E2C46D08-ACCE-4547-922B-E92AD76D99C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{E2C46D08-ACCE-4547-922B-E92AD76D99C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E2C46D08-ACCE-4547-922B-E92AD76D99C8}.Release|Any CPU.Build.0 = Release|Any CPU
|
{E2C46D08-ACCE-4547-922B-E92AD76D99C8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{572BD835-A500-43C9-A66F-648540F4A1C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{572BD835-A500-43C9-A66F-648540F4A1C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{572BD835-A500-43C9-A66F-648540F4A1C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{572BD835-A500-43C9-A66F-648540F4A1C8}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{1E630CC7-090F-471C-ADA1-74107CF3DC2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{1E630CC7-090F-471C-ADA1-74107CF3DC2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{1E630CC7-090F-471C-ADA1-74107CF3DC2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1E630CC7-090F-471C-ADA1-74107CF3DC2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1E630CC7-090F-471C-ADA1-74107CF3DC2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1E630CC7-090F-471C-ADA1-74107CF3DC2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
@ -7,11 +7,26 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||||
<PackageId>$(AssemblyName)</PackageId>
|
<PackageId>$(AssemblyName)</PackageId>
|
||||||
<Version>$(VersionPrefix)8.0.1</Version>
|
<Version>$(VersionPrefix)8.0.2</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\PIHelperSh.PdfCreater\PIHelperSh.PdfCreator.csproj" />
|
<None Include="..\..\LICENSE" Link="PdfCreator\LICENSE">
|
||||||
|
<PackagePath>\</PackagePath>
|
||||||
|
<Pack>True</Pack>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||||
|
<PackageReference Include="PIHelperSh.Core" Version="1.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="PdfCreator\README.md">
|
||||||
|
<PackagePath>\</PackagePath>
|
||||||
|
<Pack>True</Pack>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
using MigraDoc.DocumentObjectModel;
|
using MigraDoc.DocumentObjectModel;
|
||||||
using System.Text;
|
|
||||||
using MigraDoc.Rendering;
|
using MigraDoc.Rendering;
|
||||||
using MigraDoc.DocumentObjectModel.Tables;
|
using MigraDoc.DocumentObjectModel.Tables;
|
||||||
using System.Reflection;
|
|
||||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||||
using PIHelperSh.Core.Extensions;
|
using PIHelperSh.Core.Extensions;
|
||||||
using PIHelperSh.PdfCreator.Enums;
|
using PIHelperSh.PdfCreator.Enums;
|
||||||
@ -11,6 +9,11 @@ using PIHelperSh.PdfCreator.Models.TextModels;
|
|||||||
using PIHelperSh.PdfCreator.Models.ImageModels;
|
using PIHelperSh.PdfCreator.Models.ImageModels;
|
||||||
using PIHelperSh.PdfCreator.Models.PieChartModel;
|
using PIHelperSh.PdfCreator.Models.PieChartModel;
|
||||||
using PIHelperSh.PdfCreator.Interfaces;
|
using PIHelperSh.PdfCreator.Interfaces;
|
||||||
|
using System.Text;
|
||||||
|
using TabAlignment = MigraDoc.DocumentObjectModel.TabAlignment;
|
||||||
|
using System.Reflection;
|
||||||
|
using HorizontalAlignment = MigraDoc.DocumentObjectModel.Shapes.Charts.HorizontalAlignment;
|
||||||
|
using Color = MigraDoc.DocumentObjectModel.Color;
|
||||||
|
|
||||||
namespace PIHelperSh.PdfCreator
|
namespace PIHelperSh.PdfCreator
|
||||||
{
|
{
|
||||||
@ -413,7 +416,7 @@ namespace PIHelperSh.PdfCreator
|
|||||||
|
|
||||||
if (rowHeaded)
|
if (rowHeaded)
|
||||||
{
|
{
|
||||||
_section!.PageSetup.Orientation = Orientation.Landscape;
|
_section!.PageSetup.Orientation = MigraDoc.DocumentObjectModel.Orientation.Landscape;
|
||||||
_section.PageSetup.LeftMargin = 10;
|
_section.PageSetup.LeftMargin = 10;
|
||||||
MakeTableWithHederInRow(_document.LastSection.AddTable(), header);
|
MakeTableWithHederInRow(_document.LastSection.AddTable(), header);
|
||||||
return;
|
return;
|
||||||
@ -456,7 +459,7 @@ namespace PIHelperSh.PdfCreator
|
|||||||
|
|
||||||
if (tableData.ChangePageOrientation)
|
if (tableData.ChangePageOrientation)
|
||||||
{
|
{
|
||||||
_section!.PageSetup.Orientation = Orientation.Landscape;
|
_section!.PageSetup.Orientation = MigraDoc.DocumentObjectModel.Orientation.Landscape;
|
||||||
_section.PageSetup.LeftMargin = 10;
|
_section.PageSetup.LeftMargin = 10;
|
||||||
_section.PageSetup.BottomMargin = 5;
|
_section.PageSetup.BottomMargin = 5;
|
||||||
}
|
}
|
||||||
@ -535,7 +538,7 @@ namespace PIHelperSh.PdfCreator
|
|||||||
|
|
||||||
if (item.Color.HasValue)
|
if (item.Color.HasValue)
|
||||||
{
|
{
|
||||||
series.FillFormat.Color = new Color((uint)item.Color.Value.ToArgb());
|
series.FillFormat.Color = new MigraDoc.DocumentObjectModel.Color((uint)item.Color.Value.ToArgb());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,20 @@ namespace Lab3.Database.Repository.Implementations
|
|||||||
return _mapper.Map<StudentDTO>(result.Entity);
|
return _mapper.Map<StudentDTO>(result.Entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<StudentDTO> DeleteAsync(Guid id) => throw new NotImplementedException();
|
public async Task<StudentDTO?> DeleteAsync(Guid id)
|
||||||
|
{
|
||||||
|
var student = await _context.Students.FindAsync(id);
|
||||||
|
|
||||||
|
if (student == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = _context.Students.Remove(student);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return _mapper.Map<StudentDTO>(result.Entity);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<List<StudentDTO>> GetAsync(int limit = 10000, int offset = 0)
|
public async Task<List<StudentDTO>> GetAsync(int limit = 10000, int offset = 0)
|
||||||
=> _mapper.Map<List<StudentDTO>>(
|
=> _mapper.Map<List<StudentDTO>>(
|
||||||
|
@ -10,7 +10,7 @@ namespace Lab3.Database.Repository.Interfaces
|
|||||||
|
|
||||||
Task<StudentDTO?> UpdateAsync(StudentDTO studentDTO);
|
Task<StudentDTO?> UpdateAsync(StudentDTO studentDTO);
|
||||||
|
|
||||||
Task<StudentDTO> DeleteAsync(Guid id);
|
Task<StudentDTO?> DeleteAsync(Guid id);
|
||||||
|
|
||||||
Task<StudentDTO> CreateAsync(StudentDTO studentDTO);
|
Task<StudentDTO> CreateAsync(StudentDTO studentDTO);
|
||||||
}
|
}
|
||||||
|
@ -57,20 +57,22 @@ namespace Lab3.Forms
|
|||||||
|
|
||||||
private async void ButtonSave_ClickAsync(object sender, EventArgs e)
|
private async void ButtonSave_ClickAsync(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(NameTextBox.Text)
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(NameTextBox.Text)
|
||||||
|| string.IsNullOrEmpty(FormSelector.ComboBoxSelectedValue))
|
|| string.IsNullOrEmpty(FormSelector.ComboBoxSelectedValue))
|
||||||
{
|
{
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
StudentDTO student = new()
|
StudentDTO student = new()
|
||||||
{
|
{
|
||||||
Id = _updatedStudentGuid ?? Guid.NewGuid(),
|
Id = _updatedStudentGuid ?? Guid.NewGuid(),
|
||||||
Name = NameTextBox.Text,
|
Name = NameTextBox.Text,
|
||||||
StartEducation = StartEducationDataPicker.Value,
|
StartEducation = StartEducationDataPicker.Value,
|
||||||
EducationForm = FormSelector.ComboBoxSelectedValue,
|
EducationForm = FormSelector.ComboBoxSelectedValue,
|
||||||
StudentSessions = [
|
StudentSessions = [
|
||||||
new(){
|
new(){
|
||||||
Score = session1Score.Value,
|
Score = session1Score.Value,
|
||||||
Number = 1,
|
Number = 1,
|
||||||
},
|
},
|
||||||
@ -95,15 +97,21 @@ namespace Lab3.Forms
|
|||||||
Number = 6,
|
Number = 6,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_updatedStudentGuid != null)
|
if (_updatedStudentGuid != null)
|
||||||
{
|
{
|
||||||
await _studentRepository.UpdateAsync(student);
|
await _studentRepository.UpdateAsync(student);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _studentRepository.CreateAsync(student);
|
||||||
|
}
|
||||||
|
Close();
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await _studentRepository.CreateAsync(student);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,11 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
|
components = new System.ComponentModel.Container();
|
||||||
StudentsListBox = new Cop.Borovkov.Var3.Components.CustomListBox();
|
StudentsListBox = new Cop.Borovkov.Var3.Components.CustomListBox();
|
||||||
|
SimpleTableCreator = new Cop.Borovkov.Var3.Components.CustomPdfTable(components);
|
||||||
|
ExcelTableCreator = new CustomComponentsVar2.CustomExcelTable(components);
|
||||||
|
WordDiogramCreator = new ComponentsLibrary.ComponentDiagram(components);
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// StudentsListBox
|
// StudentsListBox
|
||||||
@ -49,12 +53,14 @@
|
|||||||
Name = "MainForm";
|
Name = "MainForm";
|
||||||
Text = "MainForm";
|
Text = "MainForm";
|
||||||
Load += MainForm_LoadAsync;
|
Load += MainForm_LoadAsync;
|
||||||
KeyDown += MainForm_KeyDown;
|
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Cop.Borovkov.Var3.Components.CustomListBox StudentsListBox;
|
private Cop.Borovkov.Var3.Components.CustomListBox StudentsListBox;
|
||||||
|
private Cop.Borovkov.Var3.Components.CustomPdfTable SimpleTableCreator;
|
||||||
|
private CustomComponentsVar2.CustomExcelTable ExcelTableCreator;
|
||||||
|
private ComponentsLibrary.ComponentDiagram WordDiogramCreator;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,13 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
using ComponentsLibrary.entities;
|
||||||
|
using ComponentsLibrary.entities.enums;
|
||||||
|
using DocumentFormat.OpenXml.Bibliography;
|
||||||
|
using DocumentFormat.OpenXml.Drawing;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
using Lab3.Database.DTO;
|
||||||
using Lab3.Database.Repository.Interfaces;
|
using Lab3.Database.Repository.Interfaces;
|
||||||
using Lab3.Models;
|
using Lab3.Models;
|
||||||
|
using NPOI.OpenXml4Net.OPC.Internal;
|
||||||
|
|
||||||
namespace Lab3.Forms
|
namespace Lab3.Forms
|
||||||
{
|
{
|
||||||
@ -10,6 +17,8 @@ namespace Lab3.Forms
|
|||||||
private readonly IMapper _mapper;
|
private readonly IMapper _mapper;
|
||||||
private readonly Func<Guid?, CreateForm> _getCreateOrUpdateForm;
|
private readonly Func<Guid?, CreateForm> _getCreateOrUpdateForm;
|
||||||
|
|
||||||
|
private bool _cont = false;
|
||||||
|
|
||||||
public MainForm(
|
public MainForm(
|
||||||
IStudentRepository repository,
|
IStudentRepository repository,
|
||||||
IMapper mapper,
|
IMapper mapper,
|
||||||
@ -23,42 +32,216 @@ namespace Lab3.Forms
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void MainForm_LoadAsync(object sender, EventArgs e)
|
private void MainForm_LoadAsync(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var students = _mapper.Map<List<StudentViewModel>>(await _studentRepository.GetAsync());
|
LoadAsync();
|
||||||
StudentsListBox.FillValues(
|
}
|
||||||
students.Select(s => string.Join(" ",
|
|
||||||
[
|
private async void LoadAsync()
|
||||||
s.Id,
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var students = _mapper.Map<List<StudentViewModel>>(await _studentRepository.GetAsync());
|
||||||
|
StudentsListBox.FillValues(
|
||||||
|
students.Select(s => string.Join(" ",
|
||||||
|
[
|
||||||
|
s.Id,
|
||||||
s.Name,
|
s.Name,
|
||||||
s.EducationForm,
|
s.EducationForm,
|
||||||
s.StartEducation.ToLongDateString(),
|
s.StartEducation.ToLongDateString(),
|
||||||
s.SessionMarks,
|
s.SessionMarks,
|
||||||
]
|
]
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
ex.Message,
|
||||||
|
"Ошибка",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainForm_KeyDown(object sender, KeyEventArgs e)
|
private async void RemoveStudentAsync()
|
||||||
{
|
{
|
||||||
if (e.Modifiers != Keys.Control)
|
if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
return;
|
try
|
||||||
|
{
|
||||||
|
await _studentRepository
|
||||||
|
.DeleteAsync(Guid.Parse(StudentsListBox.Selected.Split()[0]));
|
||||||
|
LoadAsync();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void CreateSimpleDocAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var saveFileDialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "pdf|*.pdf"
|
||||||
|
};
|
||||||
|
if (saveFileDialog.ShowDialog() != DialogResult.OK)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var values = (await _studentRepository.GetAsync())
|
||||||
|
.Select(s => s.StudentSessions
|
||||||
|
.OrderBy(x => x.Number)
|
||||||
|
.Select(x => x.Score.ToString())
|
||||||
|
.ToArray())
|
||||||
|
.ToArray();
|
||||||
|
var tables = new string[values.Length, 6];
|
||||||
|
|
||||||
|
for (int i = 0; i < values.Length; ++i)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < 6; ++j)
|
||||||
|
{
|
||||||
|
tables[i, j] = values[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleTableCreator.SaveToPdf(new()
|
||||||
|
{
|
||||||
|
FilePath = saveFileDialog.FileName,
|
||||||
|
Title = "Сессии",
|
||||||
|
Tables = [tables]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void CreateTableAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var saveFileDialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "xlsx|*.xlsx"
|
||||||
|
};
|
||||||
|
if (saveFileDialog.ShowDialog() != DialogResult.OK)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ExcelTableCreator.SaveToExcel<StudentDTO>(new()
|
||||||
|
{
|
||||||
|
FilePath = saveFileDialog.FileName,
|
||||||
|
Title = "Студенты",
|
||||||
|
Headers =
|
||||||
|
[
|
||||||
|
("Id", nameof(StudentDTO.Id)),
|
||||||
|
("ФИО", nameof(StudentDTO.Name)),
|
||||||
|
("Форма обучения", nameof(StudentDTO.EducationForm)),
|
||||||
|
("Дата поступления", nameof(StudentDTO.StartEducation)),
|
||||||
|
],
|
||||||
|
HeaderGroups = [new() {
|
||||||
|
GroupHeader = "Образование",
|
||||||
|
FirstHeader = 2,
|
||||||
|
LastHeader = 3,
|
||||||
|
}],
|
||||||
|
Values = await _studentRepository.GetAsync()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void CreateWordDocAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var saveFileDialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "docx|*.docx"
|
||||||
|
};
|
||||||
|
if (saveFileDialog.ShowDialog() != DialogResult.OK)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = (await _studentRepository.GetAsync())
|
||||||
|
.GroupBy(s => s.EducationForm)
|
||||||
|
.Select(s => new DataLine(
|
||||||
|
s.Key,
|
||||||
|
s.GroupBy(x => x.StartEducation.Year)
|
||||||
|
.Select(x => (year: x.Key.ToString(), count: (double)x.Count()))
|
||||||
|
.ToArray()))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
WordDiogramCreator.AddDiagram(
|
||||||
|
new(
|
||||||
|
saveFileDialog.FileName,
|
||||||
|
"Поступления",
|
||||||
|
"Диограмма",
|
||||||
|
|
||||||
|
EnumAreaLegend.Bottom,
|
||||||
|
data
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||||
|
{
|
||||||
|
if (keyData == (Keys.ControlKey | Keys.Control)) _cont = true;
|
||||||
|
|
||||||
|
if (_cont && keyData == Keys.A)
|
||||||
|
{
|
||||||
|
_getCreateOrUpdateForm(null).ShowDialog(this);
|
||||||
|
LoadAsync();
|
||||||
|
}
|
||||||
|
else if (_cont && keyData == Keys.U)
|
||||||
|
{
|
||||||
|
var elem = StudentsListBox.Selected;
|
||||||
|
_getCreateOrUpdateForm(
|
||||||
|
Guid.Parse(elem.Split()[0])
|
||||||
|
).ShowDialog(this);
|
||||||
|
LoadAsync();
|
||||||
|
}
|
||||||
|
else if (_cont && keyData == Keys.D)
|
||||||
|
{
|
||||||
|
RemoveStudentAsync();
|
||||||
|
}
|
||||||
|
else if (_cont && keyData == Keys.S)
|
||||||
|
{
|
||||||
|
CreateSimpleDocAsync();
|
||||||
|
}
|
||||||
|
else if (_cont && keyData == Keys.T)
|
||||||
|
{
|
||||||
|
CreateTableAsync();
|
||||||
|
}
|
||||||
|
else if (_cont && keyData == Keys.C)
|
||||||
|
{
|
||||||
|
CreateWordDocAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (e.KeyCode)
|
if (keyData == Keys.A ||
|
||||||
{
|
keyData == Keys.U ||
|
||||||
case Keys.A:
|
keyData == Keys.D ||
|
||||||
_getCreateOrUpdateForm(null).Show(this);
|
keyData == Keys.S ||
|
||||||
break;
|
keyData == Keys.T ||
|
||||||
case Keys.U:
|
keyData == Keys.C) _cont = false;
|
||||||
_getCreateOrUpdateForm(
|
//if (keyData != Keys.None && keyData != (System.Windows.Forms.Keys.ControlKey | System.Windows.Forms.Keys.Control)) cont = false;
|
||||||
Guid.Parse(StudentsListBox.Selected.Split()[0])
|
return true;
|
||||||
).Show(this);
|
return base.ProcessCmdKey(ref msg, keyData);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,4 +117,13 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="SimpleTableCreator.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ExcelTableCreator.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>203, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="WordDiogramCreator.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>377, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
@ -15,7 +15,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ComponentsLibraryLab1" Version="8.0.2" />
|
<PackageReference Include="ComponentsLibraryLab1" Version="8.0.2" />
|
||||||
<PackageReference Include="ComponentsLibraryLab2" Version="8.0.1" />
|
<PackageReference Include="ComponentsLibraryLab2" Version="8.0.1" />
|
||||||
<PackageReference Include="Cop.Borovkov.Var3" Version="8.0.1" />
|
<PackageReference Include="Cop.Borovkov.Var3" Version="8.0.2" />
|
||||||
<PackageReference Include="CustomComponentsVar2" Version="8.0.2" />
|
<PackageReference Include="CustomComponentsVar2" Version="8.0.2" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -20,7 +20,7 @@ namespace Lab3
|
|||||||
|
|
||||||
var app = CreateHostBuilder().Build();
|
var app = CreateHostBuilder().Build();
|
||||||
|
|
||||||
Application.Run(app.Services.GetRequiredService<CatalogForm>());
|
Application.Run(app.Services.GetRequiredService<MainForm>());
|
||||||
}
|
}
|
||||||
|
|
||||||
static IHostBuilder CreateHostBuilder()
|
static IHostBuilder CreateHostBuilder()
|
||||||
|
@ -16,23 +16,9 @@
|
|||||||
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="..\..\LICENSE">
|
|
||||||
<Pack>True</Pack>
|
|
||||||
<PackagePath>\</PackagePath>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||||
<PackageReference Include="PIHelperSh.Core" Version="1.0.1" />
|
<PackageReference Include="PIHelperSh.Core" Version="1.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="README.md">
|
|
||||||
<Pack>True</Pack>
|
|
||||||
<PackagePath>\</PackagePath>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user