Compare commits
2 Commits
9b4c15a95e
...
1bd9dce5f8
Author | SHA1 | Date | |
---|---|---|---|
1bd9dce5f8 | |||
5ec407fa6d |
@ -11,6 +11,12 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||||
<PackageReference Include="EPPlus" Version="6.2.10" />
|
<PackageReference Include="EPPlus" Version="6.2.10" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.13" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.13" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.13">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="NPOI" Version="2.6.2" />
|
<PackageReference Include="NPOI" Version="2.6.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
34
COP/COP.sln
34
COP/COP.sln
@ -3,9 +3,19 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.3.32825.248
|
VisualStudioVersion = 17.3.32825.248
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "COP", "COP.csproj", "{B22B20DB-B359-48B7-88CF-35A6EC770FD1}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "COP", "COP.csproj", "{B22B20DB-B359-48B7-88CF-35A6EC770FD1}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestComponents", "..\TestComponents\TestComponents.csproj", "{C0F09A72-65A3-49DD-8208-291778E03E81}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestComponents", "..\TestComponents\TestComponents.csproj", "{C0F09A72-65A3-49DD-8208-291778E03E81}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityDataModels", "..\UniversityDataModels\UniversityDataModels.csproj", "{843E5B85-F60A-45D7-9B52-96284FFDCA1F}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityBusinessLogic", "..\UniversityBusinessLogic\UniversityBusinessLogic.csproj", "{453BBFDD-7D8B-463F-A622-AFD6F3E6C644}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityContracts", "..\UniversityContracts\UniversityContracts.csproj", "{2EFD9DCC-226F-45D0-8688-4E0D716BC179}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityDatabaseImplement", "..\UniversityDatabaseImplement\UniversityDatabaseImplement.csproj", "{7ED4372B-4D10-411D-9CC1-13CAA2833789}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityView", "..\UniversityView\UniversityView.csproj", "{99AE36FC-FEF0-4E8C-8C0B-F6AB1952DEE6}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -21,6 +31,26 @@ Global
|
|||||||
{C0F09A72-65A3-49DD-8208-291778E03E81}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{C0F09A72-65A3-49DD-8208-291778E03E81}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{C0F09A72-65A3-49DD-8208-291778E03E81}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C0F09A72-65A3-49DD-8208-291778E03E81}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{C0F09A72-65A3-49DD-8208-291778E03E81}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C0F09A72-65A3-49DD-8208-291778E03E81}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{843E5B85-F60A-45D7-9B52-96284FFDCA1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{843E5B85-F60A-45D7-9B52-96284FFDCA1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{843E5B85-F60A-45D7-9B52-96284FFDCA1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{843E5B85-F60A-45D7-9B52-96284FFDCA1F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{453BBFDD-7D8B-463F-A622-AFD6F3E6C644}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{453BBFDD-7D8B-463F-A622-AFD6F3E6C644}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{453BBFDD-7D8B-463F-A622-AFD6F3E6C644}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{453BBFDD-7D8B-463F-A622-AFD6F3E6C644}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{2EFD9DCC-226F-45D0-8688-4E0D716BC179}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2EFD9DCC-226F-45D0-8688-4E0D716BC179}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2EFD9DCC-226F-45D0-8688-4E0D716BC179}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2EFD9DCC-226F-45D0-8688-4E0D716BC179}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{7ED4372B-4D10-411D-9CC1-13CAA2833789}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{7ED4372B-4D10-411D-9CC1-13CAA2833789}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{7ED4372B-4D10-411D-9CC1-13CAA2833789}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{7ED4372B-4D10-411D-9CC1-13CAA2833789}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{99AE36FC-FEF0-4E8C-8C0B-F6AB1952DEE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{99AE36FC-FEF0-4E8C-8C0B-F6AB1952DEE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{99AE36FC-FEF0-4E8C-8C0B-F6AB1952DEE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{99AE36FC-FEF0-4E8C-8C0B-F6AB1952DEE6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace COP
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
|
||||||
|
namespace COP
|
||||||
{
|
{
|
||||||
public partial class UserCheckedListBox : UserControl
|
public partial class UserCheckedListBox : UserControl
|
||||||
{
|
{
|
||||||
@ -28,27 +30,16 @@
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
string checkedItems = "";
|
return string.Join(";", checkedListBox.CheckedItems.Cast<string>());
|
||||||
for (int i = 0; i < checkedListBox.Items.Count; i++)
|
|
||||||
{
|
|
||||||
if (checkedListBox.GetItemChecked(i))
|
|
||||||
{
|
|
||||||
checkedItems += checkedListBox.Items[i].ToString() + " ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (checkedListBox.CheckedItems != null)
|
|
||||||
return checkedItems;
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
for (int i = 0; i < checkedListBox.Items.Count; i++)
|
if (!string.IsNullOrEmpty(value))
|
||||||
{
|
{
|
||||||
if (checkedListBox.Items[i].ToString() == value)
|
string[] selectedValues = value.Split(';');
|
||||||
|
for (int i = 0; i < checkedListBox.Items.Count; i++)
|
||||||
{
|
{
|
||||||
checkedListBox.SetItemChecked(i, true);
|
checkedListBox.SetItemChecked(i, selectedValues.Contains(checkedListBox.Items[i].ToString()) || checkedListBox.GetItemChecked(i));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
120
COP/UserCheckedListBox.resx
Normal file
120
COP/UserCheckedListBox.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -62,7 +62,7 @@ namespace COP
|
|||||||
}
|
}
|
||||||
//проверка что выбранный элем последний в ветке
|
//проверка что выбранный элем последний в ветке
|
||||||
|
|
||||||
public void PopulateTree<T>(List<T> items)
|
public void PopulateTree<T>(List<T> items, List<string> Hierarchy)
|
||||||
{
|
{
|
||||||
treeView.BeginUpdate();
|
treeView.BeginUpdate();
|
||||||
treeView.Nodes.Clear();
|
treeView.Nodes.Clear();
|
||||||
|
1
TestComponents/FormTestComponents.Designer.cs
generated
1
TestComponents/FormTestComponents.Designer.cs
generated
@ -49,7 +49,6 @@
|
|||||||
//
|
//
|
||||||
this.userCheckedListBox.Location = new System.Drawing.Point(0, -1);
|
this.userCheckedListBox.Location = new System.Drawing.Point(0, -1);
|
||||||
this.userCheckedListBox.Name = "userCheckedListBox";
|
this.userCheckedListBox.Name = "userCheckedListBox";
|
||||||
this.userCheckedListBox.SelectedValue = "";
|
|
||||||
this.userCheckedListBox.Size = new System.Drawing.Size(150, 150);
|
this.userCheckedListBox.Size = new System.Drawing.Size(150, 150);
|
||||||
this.userCheckedListBox.TabIndex = 0;
|
this.userCheckedListBox.TabIndex = 0;
|
||||||
this.userCheckedListBox.SelectedValueChanged += new System.EventHandler(this.UserCheckedListBox_SelectedValueChanged);
|
this.userCheckedListBox.SelectedValueChanged += new System.EventHandler(this.UserCheckedListBox_SelectedValueChanged);
|
||||||
|
@ -66,7 +66,7 @@ namespace TestComponents
|
|||||||
new Employee1 { Department = "Отдел1", Position = "Должность1", Name = "Сотрудник3" },
|
new Employee1 { Department = "Отдел1", Position = "Должность1", Name = "Сотрудник3" },
|
||||||
new Employee1 { Department = "Отдел2", Position = "Должность3", Name = "Сотрудник4" },
|
new Employee1 { Department = "Отдел2", Position = "Должность3", Name = "Сотрудник4" },
|
||||||
};
|
};
|
||||||
var Hierarchy = new List<string> { "Department", "Position", "Name" };
|
var Hierarchy = new List<string> { "Department", "Name" };
|
||||||
foreach (var prop in employees[0].GetType().GetProperties())
|
foreach (var prop in employees[0].GetType().GetProperties())
|
||||||
{
|
{
|
||||||
userTreeView.Hierarchy.Add(prop.Name);
|
userTreeView.Hierarchy.Add(prop.Name);
|
||||||
@ -74,7 +74,7 @@ namespace TestComponents
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
userTreeView.PopulateTree(employees);
|
userTreeView.PopulateTree(employees, Hierarchy);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -8,8 +8,18 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.13" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.13" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.13">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\COP\COP.csproj" />
|
<ProjectReference Include="..\COP\COP.csproj" />
|
||||||
|
<ProjectReference Include="..\UniversityDatabaseImplement\UniversityDatabaseImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
62
UniversityBusinessLogic/BusinessLogics/DirectionLogic.cs
Normal file
62
UniversityBusinessLogic/BusinessLogics/DirectionLogic.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.BusinessLogicsContracts;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class DirectionLogic : IDirectionLogic
|
||||||
|
{
|
||||||
|
private readonly IDirectionStorage _directionStorage;
|
||||||
|
public DirectionLogic(IDirectionStorage directionStorage)
|
||||||
|
{
|
||||||
|
_directionStorage = directionStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateOrUpdate(DirectionBindingModel model)
|
||||||
|
{
|
||||||
|
var element = _directionStorage.GetElement(
|
||||||
|
new DirectionBindingModel
|
||||||
|
{
|
||||||
|
Name = model.Name
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new Exception("Такое направление уже существует");
|
||||||
|
}
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
_directionStorage.Update(model);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_directionStorage.Insert(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(DirectionBindingModel model)
|
||||||
|
{
|
||||||
|
var element = _directionStorage.GetElement(new DirectionBindingModel { Id = model.Id });
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Направление не найдено");
|
||||||
|
}
|
||||||
|
_directionStorage.Delete(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DirectionViewModel> Read(DirectionBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return _directionStorage.GetFullList();
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
return new List<DirectionViewModel> { _directionStorage.GetElement(model) };
|
||||||
|
}
|
||||||
|
return _directionStorage.GetFilteredList(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
64
UniversityBusinessLogic/BusinessLogics/StudentLogic.cs
Normal file
64
UniversityBusinessLogic/BusinessLogics/StudentLogic.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.BusinessLogicsContracts;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class StudentLogic : IStudentLogic
|
||||||
|
{
|
||||||
|
private readonly IStudentStorage _studentStorage;
|
||||||
|
public StudentLogic(IStudentStorage studentStorage)
|
||||||
|
{
|
||||||
|
_studentStorage = studentStorage;
|
||||||
|
}
|
||||||
|
public void CreateOrUpdate(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
var element = _studentStorage.GetElement(
|
||||||
|
new StudentBindingModel
|
||||||
|
{
|
||||||
|
FIO = model.FIO,
|
||||||
|
Email = model.Email,
|
||||||
|
PhotoFilePath = model.PhotoFilePath,
|
||||||
|
DirectionName = model.DirectionName,
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new Exception("Студент с таким именем уже существует.");
|
||||||
|
}
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
_studentStorage.Update(model);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_studentStorage.Insert(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
var element = _studentStorage.GetElement(new StudentBindingModel { Id = model.Id });
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Студент не найден");
|
||||||
|
}
|
||||||
|
_studentStorage.Delete(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StudentViewModel> Read(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return _studentStorage.GetFullList();
|
||||||
|
}
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return new List<StudentViewModel> { _studentStorage.GetElement(model) };
|
||||||
|
}
|
||||||
|
return _studentStorage.GetFilteredList(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
UniversityBusinessLogic/UniversityBusinessLogic.csproj
Normal file
18
UniversityBusinessLogic/UniversityBusinessLogic.csproj
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\UniversityContracts\UniversityContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
10
UniversityContracts/BindingModels/DirectionBindingModel.cs
Normal file
10
UniversityContracts/BindingModels/DirectionBindingModel.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using UniversityDataModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class DirectionBindingModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
13
UniversityContracts/BindingModels/StudentBindingModel.cs
Normal file
13
UniversityContracts/BindingModels/StudentBindingModel.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using UniversityDataModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class StudentBindingModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string FIO { get; set; }
|
||||||
|
public string PhotoFilePath { get; set; }
|
||||||
|
public string Email { get; set; }
|
||||||
|
public string DirectionName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IDirectionLogic
|
||||||
|
{
|
||||||
|
List<DirectionViewModel> Read(DirectionBindingModel model);
|
||||||
|
void CreateOrUpdate(DirectionBindingModel model);
|
||||||
|
void Delete(DirectionBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
13
UniversityContracts/BusinessLogicsContracts/IStudentLogic.cs
Normal file
13
UniversityContracts/BusinessLogicsContracts/IStudentLogic.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IStudentLogic
|
||||||
|
{
|
||||||
|
List<StudentViewModel> Read(StudentBindingModel model);
|
||||||
|
void CreateOrUpdate(StudentBindingModel model);
|
||||||
|
void Delete(StudentBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
8
UniversityContracts/SearchModels/DirectionSearchModel.cs
Normal file
8
UniversityContracts/SearchModels/DirectionSearchModel.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace UniversityContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class DirectionSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
11
UniversityContracts/SearchModels/StudentSearchModel.cs
Normal file
11
UniversityContracts/SearchModels/StudentSearchModel.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace UniversityContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class StudentSearchModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string FIO { get; set; }
|
||||||
|
public string Email { get; set; }
|
||||||
|
public string PhotoFilePath { get; set; }
|
||||||
|
public string DirectionName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
15
UniversityContracts/StoragesContracts/IDirectionStorage.cs
Normal file
15
UniversityContracts/StoragesContracts/IDirectionStorage.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IDirectionStorage
|
||||||
|
{
|
||||||
|
List<DirectionViewModel> GetFullList();
|
||||||
|
List<DirectionViewModel> GetFilteredList(DirectionBindingModel model);
|
||||||
|
DirectionViewModel GetElement(DirectionBindingModel model);
|
||||||
|
void Insert(DirectionBindingModel model);
|
||||||
|
void Update(DirectionBindingModel model);
|
||||||
|
void Delete(DirectionBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
16
UniversityContracts/StoragesContracts/IStudentStorage.cs
Normal file
16
UniversityContracts/StoragesContracts/IStudentStorage.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IStudentStorage
|
||||||
|
{
|
||||||
|
List<StudentViewModel> GetFullList();
|
||||||
|
List<StudentViewModel> GetFilteredList(StudentBindingModel model);
|
||||||
|
StudentViewModel? GetElement(StudentBindingModel model);
|
||||||
|
void Insert(StudentBindingModel model);
|
||||||
|
void Update(StudentBindingModel model);
|
||||||
|
void Delete(StudentBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
14
UniversityContracts/UniversityContracts.csproj
Normal file
14
UniversityContracts/UniversityContracts.csproj
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\UniversityDataModels\UniversityDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
12
UniversityContracts/ViewModels/DirectionViewModel.cs
Normal file
12
UniversityContracts/ViewModels/DirectionViewModel.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using UniversityDataModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class DirectionViewModel : IDirectionModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Название направления")]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
18
UniversityContracts/ViewModels/StudentViewModel.cs
Normal file
18
UniversityContracts/ViewModels/StudentViewModel.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using UniversityDataModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class StudentViewModel : IStudentModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
[DisplayName("ФИО студента")]
|
||||||
|
public string FIO { get; set; }
|
||||||
|
[DisplayName("Путь к фото")]
|
||||||
|
public string PhotoFilePath { get; set; }
|
||||||
|
[DisplayName("Электронная почта")]
|
||||||
|
public string Email { get; set; }
|
||||||
|
[DisplayName("Направление")]
|
||||||
|
public string DirectionName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
7
UniversityDataModels/IId.cs
Normal file
7
UniversityDataModels/IId.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace UniversityDataModels
|
||||||
|
{
|
||||||
|
public interface IId
|
||||||
|
{
|
||||||
|
int Id { get; }
|
||||||
|
}
|
||||||
|
}
|
7
UniversityDataModels/Models/IDirectionModel.cs
Normal file
7
UniversityDataModels/Models/IDirectionModel.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace UniversityDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IDirectionModel : IId
|
||||||
|
{
|
||||||
|
string Name { get; }
|
||||||
|
}
|
||||||
|
}
|
10
UniversityDataModels/Models/IStudentModel.cs
Normal file
10
UniversityDataModels/Models/IStudentModel.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace UniversityDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IStudentModel
|
||||||
|
{
|
||||||
|
string FIO { get; }
|
||||||
|
string PhotoFilePath { get; }
|
||||||
|
string Email { get; }
|
||||||
|
string DirectionName { get; }
|
||||||
|
}
|
||||||
|
}
|
10
UniversityDataModels/UniversityDataModels.csproj
Normal file
10
UniversityDataModels/UniversityDataModels.csproj
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
116
UniversityDatabaseImplement/Implements/DirectionStorage.cs
Normal file
116
UniversityDatabaseImplement/Implements/DirectionStorage.cs
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityDatabaseImplement;
|
||||||
|
using UniversityDatabaseImplement.Models;
|
||||||
|
|
||||||
|
namespace UniversityUniversityDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class DirectionStorage : IDirectionStorage
|
||||||
|
{
|
||||||
|
public void Delete(DirectionBindingModel model)
|
||||||
|
{
|
||||||
|
var context = new UniversityDatabase();
|
||||||
|
var direction = context.Directions.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (direction != null)
|
||||||
|
{
|
||||||
|
context.Directions.Remove(direction);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Направление не найдено");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DirectionViewModel GetElement(DirectionBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new UniversityDatabase();
|
||||||
|
|
||||||
|
var direction = context.Directions
|
||||||
|
.ToList()
|
||||||
|
.FirstOrDefault(rec => rec.Id == model.Id || rec.Name == model.Name);
|
||||||
|
return direction != null ? CreateModel(direction) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<DirectionViewModel> GetFilteredList(DirectionBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new UniversityDatabase();
|
||||||
|
return context.Directions
|
||||||
|
.Where(rec => rec.Name.Contains(model.Name))
|
||||||
|
.Select(CreateModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DirectionViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new UniversityDatabase();
|
||||||
|
return context.Directions
|
||||||
|
.Select(CreateModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(DirectionBindingModel model)
|
||||||
|
{
|
||||||
|
var context = new UniversityDatabase();
|
||||||
|
var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
context.Directions.Add(CreateModel(model, new Direction()));
|
||||||
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(DirectionBindingModel model)
|
||||||
|
{
|
||||||
|
var context = new UniversityDatabase();
|
||||||
|
var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var direction = context.Directions.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (direction == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Направление не найдено");
|
||||||
|
}
|
||||||
|
CreateModel(model, direction);
|
||||||
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Direction CreateModel(DirectionBindingModel model, Direction direction)
|
||||||
|
{
|
||||||
|
direction.Name = model.Name;
|
||||||
|
return direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DirectionViewModel CreateModel(Direction direction)
|
||||||
|
{
|
||||||
|
return new DirectionViewModel
|
||||||
|
{
|
||||||
|
Id = direction.Id,
|
||||||
|
Name = direction.Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
119
UniversityDatabaseImplement/Implements/StudentStorage.cs
Normal file
119
UniversityDatabaseImplement/Implements/StudentStorage.cs
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using UniversityDatabaseImplement;
|
||||||
|
using UniversityDatabaseImplement.Models;
|
||||||
|
|
||||||
|
namespace UniversityUniversityDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class StudentStorage : IStudentStorage
|
||||||
|
{
|
||||||
|
public void Delete(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
var context = new UniversityDatabase();
|
||||||
|
var student = context.Students.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (student != null)
|
||||||
|
{
|
||||||
|
context.Students.Remove(student);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Студент не найден");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public StudentViewModel GetElement(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new UniversityDatabase();
|
||||||
|
var student = context.Students
|
||||||
|
.ToList()
|
||||||
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
return student != null ? CreateModel(student) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StudentViewModel> GetFilteredList(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
var context = new UniversityDatabase();
|
||||||
|
return context.Students
|
||||||
|
.Where(student => student.FIO.Contains(model.FIO))
|
||||||
|
.ToList()
|
||||||
|
.Select(CreateModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StudentViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new UniversityDatabase();
|
||||||
|
return context.Students
|
||||||
|
.ToList()
|
||||||
|
.Select(CreateModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
var context = new UniversityDatabase();
|
||||||
|
var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
context.Students.Add(CreateModel(model, new Student()));
|
||||||
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
var context = new UniversityDatabase();
|
||||||
|
var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var student = context.Students.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (student == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Студент не найден");
|
||||||
|
}
|
||||||
|
CreateModel(model, student);
|
||||||
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Student CreateModel(StudentBindingModel model, Student student)
|
||||||
|
{
|
||||||
|
student.FIO = model.FIO;
|
||||||
|
student.PhotoFilePath = model.PhotoFilePath;
|
||||||
|
student.Email = model.Email;
|
||||||
|
student.DirectionName = model.DirectionName;
|
||||||
|
|
||||||
|
return student;
|
||||||
|
}
|
||||||
|
|
||||||
|
private StudentViewModel CreateModel(Student student)
|
||||||
|
{
|
||||||
|
return new StudentViewModel
|
||||||
|
{
|
||||||
|
Id = student.Id,
|
||||||
|
FIO = student.FIO,
|
||||||
|
PhotoFilePath = student.PhotoFilePath,
|
||||||
|
Email = student.Email,
|
||||||
|
DirectionName = student.DirectionName,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
75
UniversityDatabaseImplement/Migrations/20231108231603_InitialCreate.Designer.cs
generated
Normal file
75
UniversityDatabaseImplement/Migrations/20231108231603_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using UniversityDatabaseImplement;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace UniversityDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(UniversityDatabase))]
|
||||||
|
[Migration("20231108231603_InitialCreate")]
|
||||||
|
partial class InitialCreate
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.13")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("UniversityDatabaseImplement.Models.Direction", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Directions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("DirectionName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("FIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("PhotoFilePath")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Students");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace UniversityDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class InitialCreate : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Directions",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Directions", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Students",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
FIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
PhotoFilePath = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
DirectionName = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Students", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Directions");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Students");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using UniversityDatabaseImplement;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace UniversityDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(UniversityDatabase))]
|
||||||
|
partial class UniversityDatabaseModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.13")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("UniversityDatabaseImplement.Models.Direction", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Directions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("DirectionName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("FIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("PhotoFilePath")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Students");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
UniversityDatabaseImplement/Models/Direction.cs
Normal file
12
UniversityDatabaseImplement/Models/Direction.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using UniversityDataModels.Models;
|
||||||
|
|
||||||
|
namespace UniversityDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Direction
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
16
UniversityDatabaseImplement/Models/Student.cs
Normal file
16
UniversityDatabaseImplement/Models/Student.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
namespace UniversityDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Student
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string FIO { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Email { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string PhotoFilePath { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string DirectionName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
19
UniversityDatabaseImplement/UniversityDatabase.cs
Normal file
19
UniversityDatabaseImplement/UniversityDatabase.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using UniversityDatabaseImplement.Models;
|
||||||
|
|
||||||
|
namespace UniversityDatabaseImplement
|
||||||
|
{
|
||||||
|
public class UniversityDatabase : DbContext
|
||||||
|
{
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
if (optionsBuilder.IsConfigured == false)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-IHH1ICP\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;TrustServerCertificate=True");
|
||||||
|
}
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
}
|
||||||
|
public virtual DbSet<Student> Students { set; get; }
|
||||||
|
public virtual DbSet<Direction> Directions { set; get; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.13" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.13" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.13">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\UniversityContracts\UniversityContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\UniversityDataModels\UniversityDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
66
UniversityView/FormHandbooks.Designer.cs
generated
Normal file
66
UniversityView/FormHandbooks.Designer.cs
generated
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
namespace UniversityView
|
||||||
|
{
|
||||||
|
partial class FormHandbooks
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(429, 297);
|
||||||
|
this.dataGridView.TabIndex = 0;
|
||||||
|
this.dataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellEndEdit);
|
||||||
|
this.dataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridView_KeyDown);
|
||||||
|
//
|
||||||
|
// FormHandbooks
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(429, 297);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "FormHandbooks";
|
||||||
|
this.Text = "Направления";
|
||||||
|
this.Load += new System.EventHandler(this.FormHandbooks_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
110
UniversityView/FormHandbooks.cs
Normal file
110
UniversityView/FormHandbooks.cs
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.BusinessLogicsContracts;
|
||||||
|
|
||||||
|
namespace UniversityView
|
||||||
|
{
|
||||||
|
public partial class FormHandbooks : Form
|
||||||
|
{
|
||||||
|
private readonly IDirectionLogic _logic;
|
||||||
|
BindingList<DirectionBindingModel> _list;
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
public FormHandbooks(IDirectionLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
_list = new BindingList<DirectionBindingModel>();
|
||||||
|
dataGridView.AllowUserToAddRows = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormHandbooks_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.Read(null);
|
||||||
|
_list.Clear();
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
_list.Add(new DirectionBindingModel
|
||||||
|
{
|
||||||
|
Id = item.Id,
|
||||||
|
Name = item.Name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = _list;
|
||||||
|
dataGridView.Columns[0].Visible = false;
|
||||||
|
dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
||||||
|
{
|
||||||
|
var typeName = (string)dataGridView.CurrentRow.Cells[1].Value;
|
||||||
|
if (!string.IsNullOrEmpty(typeName))
|
||||||
|
{
|
||||||
|
if (dataGridView.CurrentRow.Cells[0].Value != null)
|
||||||
|
{
|
||||||
|
_logic.CreateOrUpdate(new DirectionBindingModel()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(dataGridView.CurrentRow.Cells[0].Value),
|
||||||
|
Name = (string)dataGridView.CurrentRow.Cells[1].EditedFormattedValue
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logic.CreateOrUpdate(new DirectionBindingModel()
|
||||||
|
{
|
||||||
|
Name = (string)dataGridView.CurrentRow.Cells[1].EditedFormattedValue
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Введена пустая строка", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.KeyData == Keys.Insert)
|
||||||
|
{
|
||||||
|
if (dataGridView.Rows.Count == 0)
|
||||||
|
{
|
||||||
|
_list.Add(new DirectionBindingModel());
|
||||||
|
dataGridView.DataSource = new BindingList<DirectionBindingModel>(_list);
|
||||||
|
dataGridView.CurrentCell = dataGridView.Rows[0].Cells[1];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dataGridView.Rows[dataGridView.Rows.Count - 1].Cells[1].Value != null)
|
||||||
|
{
|
||||||
|
_list.Add(new DirectionBindingModel());
|
||||||
|
dataGridView.DataSource = new BindingList<DirectionBindingModel>(_list);
|
||||||
|
dataGridView.CurrentCell = dataGridView.Rows[dataGridView.Rows.Count - 1].Cells[1];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (e.KeyData == Keys.Delete)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить выбранный элемент", "Удаление",
|
||||||
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
_logic.Delete(new DirectionBindingModel() { Id = (int)dataGridView.CurrentRow.Cells[0].Value });
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
UniversityView/FormHandbooks.resx
Normal file
60
UniversityView/FormHandbooks.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
156
UniversityView/FormMain.Designer.cs
generated
Normal file
156
UniversityView/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
namespace UniversityView
|
||||||
|
{
|
||||||
|
partial class FormMain
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.tableOfValues = new WinFormsControlLibrary.TableOfValues();
|
||||||
|
this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||||
|
this.создатьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.изменитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.удалитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.создатьПростойДокументToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.создатьДокументСТаблицейToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.создатьДокументСДиаграммойToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.excelComponent = new COP.ExcelComponent(this.components);
|
||||||
|
this.gistogramPdfComponent = new WinFormsControlLibrary.GistogramPdfComponent3(this.components);
|
||||||
|
this.componentWord = new COPWinForms.ComponentWord2(this.components);
|
||||||
|
this.contextMenuStrip.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// tableOfValues
|
||||||
|
//
|
||||||
|
this.tableOfValues.ContextMenuStrip = this.contextMenuStrip;
|
||||||
|
this.tableOfValues.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tableOfValues.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.tableOfValues.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||||
|
this.tableOfValues.Name = "tableOfValues";
|
||||||
|
this.tableOfValues.SelectedRowIndex = -1;
|
||||||
|
this.tableOfValues.Size = new System.Drawing.Size(405, 302);
|
||||||
|
this.tableOfValues.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// contextMenuStrip
|
||||||
|
//
|
||||||
|
this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.создатьToolStripMenuItem,
|
||||||
|
this.изменитьToolStripMenuItem,
|
||||||
|
this.удалитьToolStripMenuItem,
|
||||||
|
this.справочникиToolStripMenuItem,
|
||||||
|
this.создатьПростойДокументToolStripMenuItem,
|
||||||
|
this.создатьДокументСТаблицейToolStripMenuItem,
|
||||||
|
this.создатьДокументСДиаграммойToolStripMenuItem});
|
||||||
|
this.contextMenuStrip.Name = "contextMenuStrip";
|
||||||
|
this.contextMenuStrip.Size = new System.Drawing.Size(296, 158);
|
||||||
|
//
|
||||||
|
// создатьToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.создатьToolStripMenuItem.Name = "создатьToolStripMenuItem";
|
||||||
|
this.создатьToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
|
||||||
|
this.создатьToolStripMenuItem.Size = new System.Drawing.Size(295, 22);
|
||||||
|
this.создатьToolStripMenuItem.Text = "Создать";
|
||||||
|
this.создатьToolStripMenuItem.Click += new System.EventHandler(this.СоздатьToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// изменитьToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.изменитьToolStripMenuItem.Name = "изменитьToolStripMenuItem";
|
||||||
|
this.изменитьToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U)));
|
||||||
|
this.изменитьToolStripMenuItem.Size = new System.Drawing.Size(295, 22);
|
||||||
|
this.изменитьToolStripMenuItem.Text = "Изменить";
|
||||||
|
this.изменитьToolStripMenuItem.Click += new System.EventHandler(this.ИзменитьToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// удалитьToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
|
||||||
|
this.удалитьToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D)));
|
||||||
|
this.удалитьToolStripMenuItem.Size = new System.Drawing.Size(295, 22);
|
||||||
|
this.удалитьToolStripMenuItem.Text = "Удалить";
|
||||||
|
this.удалитьToolStripMenuItem.Click += new System.EventHandler(this.УдалитьToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// справочникиToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||||
|
this.справочникиToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
|
||||||
|
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(295, 22);
|
||||||
|
this.справочникиToolStripMenuItem.Text = "Справочники";
|
||||||
|
this.справочникиToolStripMenuItem.Click += new System.EventHandler(this.СправочникиToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// создатьПростойДокументToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.создатьПростойДокументToolStripMenuItem.Name = "создатьПростойДокументToolStripMenuItem";
|
||||||
|
this.создатьПростойДокументToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||||
|
this.создатьПростойДокументToolStripMenuItem.Size = new System.Drawing.Size(295, 22);
|
||||||
|
this.создатьПростойДокументToolStripMenuItem.Text = "Создать простой документ";
|
||||||
|
this.создатьПростойДокументToolStripMenuItem.Click += new System.EventHandler(this.СоздатьПростойДокументToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// создатьДокументСТаблицейToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.создатьДокументСТаблицейToolStripMenuItem.Name = "создатьДокументСТаблицейToolStripMenuItem";
|
||||||
|
this.создатьДокументСТаблицейToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T)));
|
||||||
|
this.создатьДокументСТаблицейToolStripMenuItem.Size = new System.Drawing.Size(295, 22);
|
||||||
|
this.создатьДокументСТаблицейToolStripMenuItem.Text = "Создать документ с таблицей";
|
||||||
|
this.создатьДокументСТаблицейToolStripMenuItem.Click += new System.EventHandler(this.СоздатьДокументСТаблицейToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// создатьДокументСДиаграммойToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.создатьДокументСДиаграммойToolStripMenuItem.Name = "создатьДокументСДиаграммойToolStripMenuItem";
|
||||||
|
this.создатьДокументСДиаграммойToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
|
||||||
|
this.создатьДокументСДиаграммойToolStripMenuItem.Size = new System.Drawing.Size(295, 22);
|
||||||
|
this.создатьДокументСДиаграммойToolStripMenuItem.Text = "Создать документ с диаграммой";
|
||||||
|
this.создатьДокументСДиаграммойToolStripMenuItem.Click += new System.EventHandler(this.СоздатьДокументСДиаграммойToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// FormMain
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(405, 302);
|
||||||
|
this.Controls.Add(this.tableOfValues);
|
||||||
|
this.Name = "FormMain";
|
||||||
|
this.Text = "Университет";
|
||||||
|
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||||
|
this.contextMenuStrip.ResumeLayout(false);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private WinFormsControlLibrary.TableOfValues tableOfValues;
|
||||||
|
private ContextMenuStrip contextMenuStrip;
|
||||||
|
private ToolStripMenuItem создатьToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem изменитьToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem удалитьToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem создатьПростойДокументToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem создатьДокументСТаблицейToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem создатьДокументСДиаграммойToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||||
|
private COP.ExcelComponent excelComponent;
|
||||||
|
private WinFormsControlLibrary.GistogramPdfComponent3 gistogramPdfComponent;
|
||||||
|
private COPWinForms.ComponentWord2 componentWord;
|
||||||
|
}
|
||||||
|
}
|
259
UniversityView/FormMain.cs
Normal file
259
UniversityView/FormMain.cs
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
using COP.Info;
|
||||||
|
using COPWinForms;
|
||||||
|
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using UniversityBusinessLogic.BusinessLogics;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.BusinessLogicsContracts;
|
||||||
|
using UniversityContracts.SearchModels;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
using WinFormsControlLibrary;
|
||||||
|
using static COP.ExcelComponent;
|
||||||
|
using static COPWinForms.ComponentWord2;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
|
||||||
|
using LegendPosition = WinFormsControlLibrary.LegendPosition;
|
||||||
|
|
||||||
|
namespace UniversityView
|
||||||
|
{
|
||||||
|
public partial class FormMain : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IStudentLogic _studentLogic;
|
||||||
|
private readonly IDirectionLogic _directionLogic;
|
||||||
|
public FormMain(ILogger<FormMain> logger, IStudentLogic studentLogic, IDirectionLogic directionLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_studentLogic = studentLogic;
|
||||||
|
_directionLogic = directionLogic;
|
||||||
|
Configure();
|
||||||
|
; }
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка студентов");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tableOfValues.ClearRows();
|
||||||
|
var list = _studentLogic.Read(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
tableOfValues.SetCellValueFromList(list);
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка студентов");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки студентов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void СоздатьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormStudent));
|
||||||
|
if (service is FormStudent form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Configure()
|
||||||
|
{
|
||||||
|
var columnConfigs = new List<GridColumnConfig>
|
||||||
|
{
|
||||||
|
new GridColumnConfig { HeaderText = "Id", Width = 100, Visible = false, PropertyName = "Id" },
|
||||||
|
new GridColumnConfig { HeaderText = "ФИО", Width = 100, Visible = true, PropertyName = "FIO" },
|
||||||
|
new GridColumnConfig { HeaderText = "Направление", Width = 80, Visible = true, PropertyName = "DirectionName" },
|
||||||
|
new GridColumnConfig { HeaderText = "Электронная почта", Width = 80, Visible = true, PropertyName = "Email" },
|
||||||
|
};
|
||||||
|
|
||||||
|
tableOfValues.ConfigureColumns(columnConfigs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ИзменитьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormStudent));
|
||||||
|
if (service is FormStudent form)
|
||||||
|
{
|
||||||
|
if (tableOfValues.SelectedRowIndex != -1)
|
||||||
|
{
|
||||||
|
var selectedStudent = tableOfValues.GetSelectedObject<StudentSearchModel>();
|
||||||
|
form.Id = Convert.ToInt32(selectedStudent.Id);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите студента для редактирования");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void УдалитьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
var selectedStudent = tableOfValues.GetSelectedObject<StudentSearchModel>();
|
||||||
|
int id = Convert.ToInt32(selectedStudent.Id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_studentLogic.Delete(new StudentBindingModel { Id = id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void СоздатьПростойДокументToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var list = _studentLogic.Read(null);
|
||||||
|
List<ImageInfo> images = new();
|
||||||
|
using var dialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "xlsx|*.xlsx"
|
||||||
|
};
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
images.Add(new ImageInfo() { FilePath = item.PhotoFilePath });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ExcelImageInfo info = new(dialog.FileName, "Документ с фотографиями студентов", images);
|
||||||
|
excelComponent.GenerateExcelWithImages(info);
|
||||||
|
MessageBox.Show("Сохарнено успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void СоздатьДокументСТаблицейToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var list = _studentLogic.Read(null);
|
||||||
|
List<StudentBindingModel> data = new();
|
||||||
|
List<int[]> mergedColumns = new()
|
||||||
|
{
|
||||||
|
new int[] { 1, 2 }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
List<ColumnDefinition> columnDefinitions = new()
|
||||||
|
{
|
||||||
|
new ColumnDefinition { Header = "Идентификатор", PropertyName = "Id", Width = 11 },
|
||||||
|
new ColumnDefinition { Header = "Личные данные", PropertyName = "PersonalData", Width = 11 },
|
||||||
|
new ColumnDefinition { Header = "Личные данные", PropertyName = "PersonalData1", Width = 11 },
|
||||||
|
new ColumnDefinition { Header = "Направление", PropertyName = "DirectionName", Width = 21 }
|
||||||
|
};
|
||||||
|
|
||||||
|
List<ColumnDefinition> columnDefinitions2 = new()
|
||||||
|
{
|
||||||
|
new ColumnDefinition { Header = "Идентификатор", PropertyName = "Id", Width = 11 },
|
||||||
|
new ColumnDefinition { Header = "ФИО", PropertyName = "FIO", Width = 11 },
|
||||||
|
new ColumnDefinition { Header = "Электронная почта", PropertyName = "Email", Width = 70 },
|
||||||
|
new ColumnDefinition { Header = "Направление", PropertyName = "DirectionName", Width = 21 }
|
||||||
|
};
|
||||||
|
|
||||||
|
using var dialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "docx|*.docx"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
data.Add(new StudentBindingModel() { Id = item.Id, FIO = item.FIO, Email = item.Email, DirectionName = item.DirectionName});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TableWord<StudentBindingModel> tableWord = new(dialog.FileName, "Таблица со студентами", columnDefinitions, columnDefinitions2, data, mergedColumns);
|
||||||
|
componentWord.CreateTable(tableWord);
|
||||||
|
MessageBox.Show("Сохарнено успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void СоздатьДокументСДиаграммойToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var listStudents = _studentLogic.Read(null);
|
||||||
|
var listDirections = _directionLogic.Read(null);
|
||||||
|
List<(string, int)> data = new();
|
||||||
|
List<HistogramData> gistData = new();
|
||||||
|
using var dialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "pdf|*.pdf"
|
||||||
|
};
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (int i = 0; i < listDirections.Count; i++)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (int j = 0; j < listStudents.Count; j++)
|
||||||
|
{
|
||||||
|
if (listStudents[j].DirectionName == listDirections[i].Name) count++;
|
||||||
|
}
|
||||||
|
data.Add((listDirections[i].Name, count));
|
||||||
|
}
|
||||||
|
if (data != null) {
|
||||||
|
foreach (var item in data)
|
||||||
|
{
|
||||||
|
gistData.Add(new HistogramData
|
||||||
|
{
|
||||||
|
SeriesName = item.Item1,
|
||||||
|
Data = new double[] { item.Item2 }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gistogramPdfComponent.GenerateHistogramDocument(dialog.FileName, "Histogram", "Students-Directions", LegendPosition.TopRight, gistData);
|
||||||
|
MessageBox.Show("Сохарнено успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void СправочникиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormHandbooks));
|
||||||
|
if (service is FormHandbooks form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
72
UniversityView/FormMain.resx
Normal file
72
UniversityView/FormMain.resx
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="contextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="excelComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>166, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="gistogramPdfComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>309, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="componentWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>499, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
174
UniversityView/FormStudent.Designer.cs
generated
Normal file
174
UniversityView/FormStudent.Designer.cs
generated
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
namespace UniversityView
|
||||||
|
{
|
||||||
|
partial class FormStudent
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.textBoxFIO = new System.Windows.Forms.TextBox();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.componenttBox1 = new COPWinForms.ComponentTBox();
|
||||||
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.userCheckedListBox1 = new COP.UserCheckedListBox();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonAddPhoto = new System.Windows.Forms.Button();
|
||||||
|
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||||
|
this.groupBox1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// textBoxFIO
|
||||||
|
//
|
||||||
|
this.textBoxFIO.Location = new System.Drawing.Point(105, 27);
|
||||||
|
this.textBoxFIO.Name = "textBoxFIO";
|
||||||
|
this.textBoxFIO.Size = new System.Drawing.Size(214, 23);
|
||||||
|
this.textBoxFIO.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(65, 30);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(34, 15);
|
||||||
|
this.label1.TabIndex = 1;
|
||||||
|
this.label1.Text = "ФИО";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(65, 68);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(113, 15);
|
||||||
|
this.label2.TabIndex = 3;
|
||||||
|
this.label2.Text = "Электронная почта";
|
||||||
|
//
|
||||||
|
// componenttBox1
|
||||||
|
//
|
||||||
|
this.componenttBox1.Location = new System.Drawing.Point(184, 65);
|
||||||
|
this.componenttBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
|
this.componenttBox1.Name = "componenttBox1";
|
||||||
|
this.componenttBox1.Pattern = null;
|
||||||
|
this.componenttBox1.Size = new System.Drawing.Size(135, 38);
|
||||||
|
this.componenttBox1.TabIndex = 4;
|
||||||
|
this.componenttBox1.TextBoxValue = null;
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
this.groupBox1.Controls.Add(this.userCheckedListBox1);
|
||||||
|
this.groupBox1.Location = new System.Drawing.Point(12, 108);
|
||||||
|
this.groupBox1.Name = "groupBox1";
|
||||||
|
this.groupBox1.Size = new System.Drawing.Size(362, 150);
|
||||||
|
this.groupBox1.TabIndex = 5;
|
||||||
|
this.groupBox1.TabStop = false;
|
||||||
|
this.groupBox1.Text = "Направление";
|
||||||
|
//
|
||||||
|
// userCheckedListBox1
|
||||||
|
//
|
||||||
|
this.userCheckedListBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.userCheckedListBox1.Location = new System.Drawing.Point(3, 19);
|
||||||
|
this.userCheckedListBox1.Name = "userCheckedListBox1";
|
||||||
|
this.userCheckedListBox1.SelectedValue = "";
|
||||||
|
this.userCheckedListBox1.Size = new System.Drawing.Size(356, 128);
|
||||||
|
this.userCheckedListBox1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(218, 465);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonSave.TabIndex = 6;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(299, 465);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonCancel.TabIndex = 7;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||||
|
//
|
||||||
|
// buttonAddPhoto
|
||||||
|
//
|
||||||
|
this.buttonAddPhoto.Location = new System.Drawing.Point(12, 264);
|
||||||
|
this.buttonAddPhoto.Name = "buttonAddPhoto";
|
||||||
|
this.buttonAddPhoto.Size = new System.Drawing.Size(360, 23);
|
||||||
|
this.buttonAddPhoto.TabIndex = 8;
|
||||||
|
this.buttonAddPhoto.Text = "Загрузить фото";
|
||||||
|
this.buttonAddPhoto.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddPhoto.Click += new System.EventHandler(this.buttonAddPhoto_Click);
|
||||||
|
//
|
||||||
|
// pictureBox
|
||||||
|
//
|
||||||
|
this.pictureBox.Location = new System.Drawing.Point(12, 293);
|
||||||
|
this.pictureBox.Name = "pictureBox";
|
||||||
|
this.pictureBox.Size = new System.Drawing.Size(359, 166);
|
||||||
|
this.pictureBox.TabIndex = 9;
|
||||||
|
this.pictureBox.TabStop = false;
|
||||||
|
//
|
||||||
|
// FormStudent
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(384, 500);
|
||||||
|
this.Controls.Add(this.pictureBox);
|
||||||
|
this.Controls.Add(this.buttonAddPhoto);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.groupBox1);
|
||||||
|
this.Controls.Add(this.componenttBox1);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.textBoxFIO);
|
||||||
|
this.Name = "FormStudent";
|
||||||
|
this.Text = "Студент";
|
||||||
|
this.Load += new System.EventHandler(this.FormStudent_Load);
|
||||||
|
this.groupBox1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox textBoxFIO;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private COPWinForms.ComponentTBox componenttBox1;
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private COP.UserCheckedListBox userCheckedListBox1;
|
||||||
|
private Button buttonAddPhoto;
|
||||||
|
private PictureBox pictureBox;
|
||||||
|
}
|
||||||
|
}
|
159
UniversityView/FormStudent.cs
Normal file
159
UniversityView/FormStudent.cs
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using NPOI.OpenXmlFormats.Spreadsheet;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using UniversityBusinessLogic.BusinessLogics;
|
||||||
|
using UniversityContracts.BindingModels;
|
||||||
|
using UniversityContracts.BusinessLogicsContracts;
|
||||||
|
using UniversityContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace UniversityView
|
||||||
|
{
|
||||||
|
public partial class FormStudent : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IStudentLogic _studentLogic;
|
||||||
|
private readonly IDirectionLogic _directionLogic;
|
||||||
|
private string imagePath;
|
||||||
|
BindingList<DirectionBindingModel> _list;
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
private string? _item;
|
||||||
|
private string itemChecked { set { _item = value; } }
|
||||||
|
List<string> directions = new();
|
||||||
|
public FormStudent(ILogger<FormStudent> logger, IStudentLogic studentLogic, IDirectionLogic directionLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_studentLogic = studentLogic;
|
||||||
|
_directionLogic = directionLogic;
|
||||||
|
imagePath = "";
|
||||||
|
_list = new BindingList<DirectionBindingModel>();
|
||||||
|
componenttBox1.Pattern = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$";
|
||||||
|
componenttBox1.setExample("example@mail.ru");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxFIO.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(componenttBox1.TextBoxValue))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните электронную почту", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (userCheckedListBox1.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните направление", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pictureBox.Image == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Загрузите фото", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Сохранение студента");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_studentLogic.CreateOrUpdate(new StudentBindingModel
|
||||||
|
{
|
||||||
|
Id = _id,
|
||||||
|
FIO = textBoxFIO.Text,
|
||||||
|
PhotoFilePath = imagePath,
|
||||||
|
Email = componenttBox1.TextBoxValue,
|
||||||
|
DirectionName = userCheckedListBox1.SelectedValue
|
||||||
|
}); ;
|
||||||
|
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения студента");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormStudent_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
StudentViewModel? view = _studentLogic.Read(new StudentBindingModel { Id = _id.Value })?[0];
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxFIO.Text = view.FIO;
|
||||||
|
componenttBox1.TextBoxValue = view.Email;
|
||||||
|
imagePath = view.PhotoFilePath;
|
||||||
|
string[] dirs = view.DirectionName.Split(";");
|
||||||
|
foreach (var dir in dirs)
|
||||||
|
{
|
||||||
|
userCheckedListBox1.SelectedValue = dir;
|
||||||
|
}
|
||||||
|
pictureBox.Image = Image.FromFile(imagePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка направлений");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _directionLogic.Read(null);
|
||||||
|
userCheckedListBox1.ClearList();
|
||||||
|
directions.Clear();
|
||||||
|
_list.Clear();
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
directions.Add(item.Name);
|
||||||
|
_list.Add(new DirectionBindingModel
|
||||||
|
{
|
||||||
|
Id = item.Id,
|
||||||
|
Name = item.Name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
userCheckedListBox1.FillList(directions);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки направлений");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAddPhoto_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OpenFileDialog openFileDialog = new()
|
||||||
|
{
|
||||||
|
Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG|All files (*.*)|*.*"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
imagePath = openFileDialog.FileName;
|
||||||
|
pictureBox.Image = Image.FromFile(imagePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
UniversityView/FormStudent.resx
Normal file
60
UniversityView/FormStudent.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
43
UniversityView/Program.cs
Normal file
43
UniversityView/Program.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using NLog.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using UniversityBusinessLogic.BusinessLogics;
|
||||||
|
using UniversityContracts.BusinessLogicsContracts;
|
||||||
|
using UniversityContracts.StoragesContracts;
|
||||||
|
using UniversityUniversityDatabaseImplement.Implements;
|
||||||
|
|
||||||
|
namespace UniversityView
|
||||||
|
{
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
private static ServiceProvider? _serviceProvider;
|
||||||
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||||
|
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
ApplicationConfiguration.Initialize();
|
||||||
|
var services = new ServiceCollection();
|
||||||
|
ConfigureServices(services);
|
||||||
|
_serviceProvider = services.BuildServiceProvider();
|
||||||
|
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddLogging(option =>
|
||||||
|
{
|
||||||
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
|
option.AddNLog("nlog.config");
|
||||||
|
});
|
||||||
|
services.AddTransient<IDirectionStorage, DirectionStorage>();
|
||||||
|
services.AddTransient<IStudentStorage, StudentStorage>();
|
||||||
|
services.AddTransient<IDirectionLogic, DirectionLogic>();
|
||||||
|
services.AddTransient<IStudentLogic, StudentLogic>();
|
||||||
|
services.AddTransient<FormMain>();
|
||||||
|
services.AddTransient<FormStudent>();
|
||||||
|
services.AddTransient<FormHandbooks>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
63
UniversityView/Properties/Resources.Designer.cs
generated
Normal file
63
UniversityView/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан программой.
|
||||||
|
// Исполняемая версия:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||||
|
// повторной генерации кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace UniversityView.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||||
|
/// </summary>
|
||||||
|
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||||
|
// с помощью такого средства, как ResGen или Visual Studio.
|
||||||
|
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||||
|
// с параметром /str или перестройте свой проект VS.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("UniversityView.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||||
|
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
UniversityView/Properties/Resources.resx
Normal file
120
UniversityView/Properties/Resources.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
46
UniversityView/UniversityView.csproj
Normal file
46
UniversityView/UniversityView.csproj
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="COPWinForms" Version="1.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.13">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
|
||||||
|
<PackageReference Include="NLog" Version="5.2.5" />
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" />
|
||||||
|
<PackageReference Include="WinFormsControlLibrary" Version="1.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\COP\COP.csproj" />
|
||||||
|
<ProjectReference Include="..\UniversityBusinessLogic\UniversityBusinessLogic.csproj" />
|
||||||
|
<ProjectReference Include="..\UniversityContracts\UniversityContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\UniversityDatabaseImplement\UniversityDatabaseImplement.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Update="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
Loading…
Reference in New Issue
Block a user