7 Commits
Lab2 ... Lab4

136 changed files with 3163 additions and 1 deletions

View File

@@ -11,7 +11,9 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Aspose.Words" Version="23.10.0" /> <PackageReference Include="Aspose.Words" Version="23.10.0" />
<PackageReference Include="COP" Version="1.0.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" /> <PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
<PackageReference Include="WinFormsControlLibrary" Version="1.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -33,12 +33,13 @@
// //
// listBox // listBox
// //
this.listBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.listBox.FormattingEnabled = true; this.listBox.FormattingEnabled = true;
this.listBox.HorizontalScrollbar = true; this.listBox.HorizontalScrollbar = true;
this.listBox.ItemHeight = 20; this.listBox.ItemHeight = 20;
this.listBox.Location = new System.Drawing.Point(0, 0); this.listBox.Location = new System.Drawing.Point(0, 0);
this.listBox.Name = "listBox"; this.listBox.Name = "listBox";
this.listBox.Size = new System.Drawing.Size(278, 144); this.listBox.Size = new System.Drawing.Size(281, 150);
this.listBox.TabIndex = 0; this.listBox.TabIndex = 0;
// //
// ComponentLBox // ComponentLBox

View File

@@ -97,6 +97,7 @@ namespace COPWinForms
{ {
return; return;
} }
listBox.Items.Clear();
foreach (var item in objects) foreach (var item in objects)
{ {
string str = layoutString; string str = layoutString;

View File

@@ -7,6 +7,20 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "COPWinForms", "..\COPWinFor
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsTest", "..\WinFormsTest\WinFormsTest.csproj", "{75E77B58-7C69-4C52-8283-03EBC03D2C85}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsTest", "..\WinFormsTest\WinFormsTest.csproj", "{75E77B58-7C69-4C52-8283-03EBC03D2C85}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityDataBaseImplements", "UniversityDataBaseImplements\UniversityDataBaseImplements.csproj", "{49DDC838-58F6-465D-B5C9-05E45241241B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityDataModels", "UniversityDataModels\UniversityDataModels.csproj", "{4E4F31E2-833A-4049-BE3C-5BC12EF46D51}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityContracts", "UniversityContracts\UniversityContracts.csproj", "{91E718F5-9B31-4491-96E0-25A450C41FED}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityBusinessLogic", "UniversityBusinessLogic\UniversityBusinessLogic.csproj", "{2AAADED7-BE04-41CF-B45D-9FBF1DFD346B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityForms", "UniversityForms\UniversityForms.csproj", "{690ADFAC-1C2A-4130-82BD-46A59ECE933A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginsConventionLibraryNet60", "PluginsConventionLibraryNet60\PluginsConventionLibraryNet60.csproj", "{07A710A3-C6B0-4D52-85AA-4882151F5BFA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsByPlugins", "FormsByPlugins\FormsByPlugins.csproj", "{45B39F84-AF33-4739-9FD9-A0E1D7C062AE}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -21,6 +35,34 @@ Global
{75E77B58-7C69-4C52-8283-03EBC03D2C85}.Debug|Any CPU.Build.0 = Debug|Any CPU {75E77B58-7C69-4C52-8283-03EBC03D2C85}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75E77B58-7C69-4C52-8283-03EBC03D2C85}.Release|Any CPU.ActiveCfg = Release|Any CPU {75E77B58-7C69-4C52-8283-03EBC03D2C85}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75E77B58-7C69-4C52-8283-03EBC03D2C85}.Release|Any CPU.Build.0 = Release|Any CPU {75E77B58-7C69-4C52-8283-03EBC03D2C85}.Release|Any CPU.Build.0 = Release|Any CPU
{49DDC838-58F6-465D-B5C9-05E45241241B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{49DDC838-58F6-465D-B5C9-05E45241241B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{49DDC838-58F6-465D-B5C9-05E45241241B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49DDC838-58F6-465D-B5C9-05E45241241B}.Release|Any CPU.Build.0 = Release|Any CPU
{4E4F31E2-833A-4049-BE3C-5BC12EF46D51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E4F31E2-833A-4049-BE3C-5BC12EF46D51}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E4F31E2-833A-4049-BE3C-5BC12EF46D51}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E4F31E2-833A-4049-BE3C-5BC12EF46D51}.Release|Any CPU.Build.0 = Release|Any CPU
{91E718F5-9B31-4491-96E0-25A450C41FED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91E718F5-9B31-4491-96E0-25A450C41FED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91E718F5-9B31-4491-96E0-25A450C41FED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91E718F5-9B31-4491-96E0-25A450C41FED}.Release|Any CPU.Build.0 = Release|Any CPU
{2AAADED7-BE04-41CF-B45D-9FBF1DFD346B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2AAADED7-BE04-41CF-B45D-9FBF1DFD346B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2AAADED7-BE04-41CF-B45D-9FBF1DFD346B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2AAADED7-BE04-41CF-B45D-9FBF1DFD346B}.Release|Any CPU.Build.0 = Release|Any CPU
{690ADFAC-1C2A-4130-82BD-46A59ECE933A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{690ADFAC-1C2A-4130-82BD-46A59ECE933A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{690ADFAC-1C2A-4130-82BD-46A59ECE933A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{690ADFAC-1C2A-4130-82BD-46A59ECE933A}.Release|Any CPU.Build.0 = Release|Any CPU
{07A710A3-C6B0-4D52-85AA-4882151F5BFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07A710A3-C6B0-4D52-85AA-4882151F5BFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07A710A3-C6B0-4D52-85AA-4882151F5BFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07A710A3-C6B0-4D52-85AA-4882151F5BFA}.Release|Any CPU.Build.0 = Release|Any CPU
{45B39F84-AF33-4739-9FD9-A0E1D7C062AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45B39F84-AF33-4739-9FD9-A0E1D7C062AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45B39F84-AF33-4739-9FD9-A0E1D7C062AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45B39F84-AF33-4739-9FD9-A0E1D7C062AE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

231
COP_1/FormsByPlugins/FormMain.Designer.cs generated Normal file
View File

@@ -0,0 +1,231 @@
namespace FormsByPlugins
{
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.menuStrip = new System.Windows.Forms.MenuStrip();
this.ControlsStripMenuItem = new
System.Windows.Forms.ToolStripMenuItem();
this.ActionsToolStripMenuItem = new
System.Windows.Forms.ToolStripMenuItem();
this.DocsToolStripMenuItem = new
System.Windows.Forms.ToolStripMenuItem();
this.SimpleDocToolStripMenuItem = new
System.Windows.Forms.ToolStripMenuItem();
this.TableDocToolStripMenuItem = new
System.Windows.Forms.ToolStripMenuItem();
this.ChartDocToolStripMenuItem = new
System.Windows.Forms.ToolStripMenuItem();
this.panelControl = new System.Windows.Forms.Panel();
this.ThesaurusToolStripMenuItem = new
System.Windows.Forms.ToolStripMenuItem();
this.AddElementToolStripMenuItem = new
System.Windows.Forms.ToolStripMenuItem();
this.UpdElementToolStripMenuItem = new
System.Windows.Forms.ToolStripMenuItem();
this.DelElementToolStripMenuItem = new
System.Windows.Forms.ToolStripMenuItem();
this.menuStrip.SuspendLayout();
this.SuspendLayout();
//
// menuStrip
//
this.menuStrip.Items.AddRange(new
System.Windows.Forms.ToolStripItem[] {
this.ControlsStripMenuItem,
this.ActionsToolStripMenuItem,
this.DocsToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(800, 24);
this.menuStrip.TabIndex = 0;
this.menuStrip.Text = "Меню";
//
// ControlsStripMenuItem
//
this.ControlsStripMenuItem.Name = "ControlsStripMenuItem";
this.ControlsStripMenuItem.Size = new System.Drawing.Size(94,
20);
this.ControlsStripMenuItem.Text = "Компоненты";
//
// ActionsToolStripMenuItem
//
this.ActionsToolStripMenuItem.DropDownItems.AddRange(new
System.Windows.Forms.ToolStripItem[] {
this.ThesaurusToolStripMenuItem,
this.AddElementToolStripMenuItem,
this.UpdElementToolStripMenuItem,
this.DelElementToolStripMenuItem});
this.ActionsToolStripMenuItem.Name =
"ActionsToolStripMenuItem";
this.ActionsToolStripMenuItem.Size = new
System.Drawing.Size(70, 20);
this.ActionsToolStripMenuItem.Text = "Действия";
//
// DocsToolStripMenuItem
//
this.DocsToolStripMenuItem.DropDownItems.AddRange(new
System.Windows.Forms.ToolStripItem[] {
this.SimpleDocToolStripMenuItem,
this.TableDocToolStripMenuItem,
this.ChartDocToolStripMenuItem});
this.DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
this.DocsToolStripMenuItem.Size = new System.Drawing.Size(82, 20);
this.DocsToolStripMenuItem.Text = "Документы";
//
// SimpleDocToolStripMenuItem
//
this.SimpleDocToolStripMenuItem.Name = "SimpleDocToolStripMenuItem";
this.SimpleDocToolStripMenuItem.ShortcutKeys =
((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control |
System.Windows.Forms.Keys.S)));
this.SimpleDocToolStripMenuItem.Size = new
System.Drawing.Size(233, 22);
this.SimpleDocToolStripMenuItem.Text = "Простой документ";
this.SimpleDocToolStripMenuItem.Click += new
System.EventHandler(this.SimpleDocToolStripMenuItem_Click);
//
// TableDocToolStripMenuItem
//
this.TableDocToolStripMenuItem.Name =
"TableDocToolStripMenuItem";
this.TableDocToolStripMenuItem.ShortcutKeys =
((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control |
System.Windows.Forms.Keys.T)));
this.TableDocToolStripMenuItem.Size = new
System.Drawing.Size(233, 22);
this.TableDocToolStripMenuItem.Text = "Документ с таблицой";
this.TableDocToolStripMenuItem.Click += new
System.EventHandler(this.TableDocToolStripMenuItem_Click);
//
// ChartDocToolStripMenuItem
//
this.ChartDocToolStripMenuItem.Name =
"ChartDocToolStripMenuItem";
this.ChartDocToolStripMenuItem.ShortcutKeys =
((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control |
System.Windows.Forms.Keys.C)));
this.ChartDocToolStripMenuItem.Size = new
System.Drawing.Size(233, 22);
this.ChartDocToolStripMenuItem.Text = "Диаграмма";
this.ChartDocToolStripMenuItem.Click += new
System.EventHandler(this.ChartDocToolStripMenuItem_Click);
//
// panelControl
//
this.panelControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelControl.Location = new System.Drawing.Point(0, 24);
this.panelControl.Name = "panelControl";
this.panelControl.Size = new System.Drawing.Size(800, 426);
this.panelControl.TabIndex = 1;
//
// ThesaurusToolStripMenuItem
//
this.ThesaurusToolStripMenuItem.Name =
"ThesaurusToolStripMenuItem";
this.ThesaurusToolStripMenuItem.ShortcutKeys =
((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control |
System.Windows.Forms.Keys.I)));
this.ThesaurusToolStripMenuItem.Size = new
System.Drawing.Size(180, 22);
this.ThesaurusToolStripMenuItem.Text = "Справочник";
this.ThesaurusToolStripMenuItem.Click += new
System.EventHandler(this.ThesaurusToolStripMenuItem_Click);
//
// AddElementToolStripMenuItem
//
this.AddElementToolStripMenuItem.Name =
"AddElementToolStripMenuItem";
this.AddElementToolStripMenuItem.ShortcutKeys =
((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control |
System.Windows.Forms.Keys.A)));
this.AddElementToolStripMenuItem.Size = new
System.Drawing.Size(180, 22);
this.AddElementToolStripMenuItem.Text = "Добавить";
this.AddElementToolStripMenuItem.Click += new
System.EventHandler(this.AddElementToolStripMenuItem_Click);
//
// UpdElementToolStripMenuItem
//
this.UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
this.UpdElementToolStripMenuItem.ShortcutKeys =
((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control |
System.Windows.Forms.Keys.U)));
this.UpdElementToolStripMenuItem.Size = new
System.Drawing.Size(180, 22);
this.UpdElementToolStripMenuItem.Text = "Изменить";
this.UpdElementToolStripMenuItem.Click += new
System.EventHandler(this.UpdElementToolStripMenuItem_Click);
//
// DelElementToolStripMenuItem
//
this.DelElementToolStripMenuItem.Name =
"DelElementToolStripMenuItem";
this.DelElementToolStripMenuItem.ShortcutKeys =
((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control |
System.Windows.Forms.Keys.D)));
this.DelElementToolStripMenuItem.Size = new
System.Drawing.Size(180, 22);
this.DelElementToolStripMenuItem.Text = "Удалить";
this.DelElementToolStripMenuItem.Click += new
System.EventHandler(this.DelElementToolStripMenuItem_Click);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.panelControl);
this.Controls.Add(this.menuStrip);
this.MainMenuStrip = this.menuStrip;
this.Name = "FormMain";
this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Главная форма";
this.WindowState =
System.Windows.Forms.FormWindowState.Maximized;
this.KeyDown += new
System.Windows.Forms.KeyEventHandler(this.FormMain_KeyDown);
this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip;
private System.Windows.Forms.ToolStripMenuItem ControlsStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem DocsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem SimpleDocToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem TableDocToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ChartDocToolStripMenuItem;
private System.Windows.Forms.Panel panelControl;
private System.Windows.Forms.ToolStripMenuItem ActionsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ThesaurusToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem AddElementToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem UpdElementToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem DelElementToolStripMenuItem;
}
}

View File

@@ -0,0 +1,221 @@
using PluginsConventionLibraryNet60;
using System.Reflection;
namespace FormsByPlugins
{
public partial class FormMain : Form
{
private readonly Dictionary<string, IPluginsConvention> _plugins;
private string _selectedPlugin;
public FormMain()
{
InitializeComponent();
_plugins = LoadPlugins();
_selectedPlugin = string.Empty;
}
private Dictionary<string, IPluginsConvention> LoadPlugins()
{
Dictionary<string, IPluginsConvention> plugins = new();
string currentDirectory = Directory.GetParent(Environment.CurrentDirectory)!.Parent!.Parent!.Parent!.FullName + "\\plugin";
string[] dllFiles = Directory.GetFiles(currentDirectory, "*.dll", SearchOption.AllDirectories);
foreach (string dllFile in dllFiles)
{
try
{
Assembly assembly = Assembly.LoadFrom(dllFile);
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
if (typeof(IPluginsConvention).IsAssignableFrom(type) && !type.IsInterface)
{
var plugin = (IPluginsConvention)Activator.CreateInstance(type)!;
plugins.Add(plugin.PluginName, plugin);
}
}
}
catch (Exception ex)
{
Console.WriteLine($" {dllFile}: {ex.Message}");
}
}
foreach (var plugin in plugins)
{
CreateMenuItem(plugin.Value.PluginName);
}
return plugins;
}
private void CreateMenuItem(string pluginName)
{
ToolStripMenuItem menuItem = new ToolStripMenuItem(pluginName);
menuItem.Click += (object? sender, EventArgs a) =>
{
_selectedPlugin = pluginName;
IPluginsConvention plugin = _plugins[pluginName];
UserControl userControl = plugin.GetControl;
if (userControl != null)
{
panelControl.Controls.Clear();
plugin.ReloadData();
userControl.Dock = DockStyle.Fill;
panelControl.Controls.Add(userControl);
}
};
ControlsStripMenuItem.DropDownItems.Add(menuItem);
}
private void FormMain_KeyDown(object sender, KeyEventArgs e)
{
if (string.IsNullOrEmpty(_selectedPlugin) ||
!_plugins.ContainsKey(_selectedPlugin))
{
return;
}
if (!e.Control)
{
return;
}
switch (e.KeyCode)
{
case Keys.I:
ShowThesaurus();
break;
case Keys.A:
AddNewElement();
break;
case Keys.U:
UpdateElement();
break;
case Keys.D:
DeleteElement();
break;
case Keys.S:
CreateSimpleDoc();
break;
case Keys.T:
CreateTableDoc();
break;
case Keys.C:
CreateChartDoc();
break;
}
}
private void ShowThesaurus()
{
_plugins[_selectedPlugin].GetThesaurus()?.Show();
}
private void AddNewElement()
{
var form = _plugins[_selectedPlugin].GetForm(null);
if (form != null && form.ShowDialog() == DialogResult.OK)
{
_plugins[_selectedPlugin].ReloadData();
}
}
private void UpdateElement()
{
var element = _plugins[_selectedPlugin].GetElement;
if (element == null)
{
MessageBox.Show("Нет выбранного элемента", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var form = _plugins[_selectedPlugin].GetForm(element);
if (form != null && form.ShowDialog() == DialogResult.OK)
{
_plugins[_selectedPlugin].ReloadData();
}
}
private void DeleteElement()
{
if (MessageBox.Show("Удалить выбранный элемент", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
var element = _plugins[_selectedPlugin].GetElement;
if (element == null)
{
MessageBox.Show("Нет выбранного элемента", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (_plugins[_selectedPlugin].DeleteElement(element))
{
_plugins[_selectedPlugin].ReloadData();
}
}
private void CreateSimpleDoc()
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "PDF Files (*.docx)|*.docx";
saveFileDialog.Title = "Список";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
if (_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName }))
{
MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Ошибка при создании документа",
"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void CreateTableDoc()
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "PDF Files (*.pdf)|*.pdf";
saveFileDialog.Title = "Table";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
if (_plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName }))
{
MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Ошибка при создании документа",
"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void CreateChartDoc()
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Excel Files (*.xlsx)|*.xlsx";
saveFileDialog.Title = "Круговая диаграмма";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
if (_plugins[_selectedPlugin].CreateChartDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName }))
{
MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ThesaurusToolStripMenuItem_Click(object sender,
EventArgs e) => ShowThesaurus();
private void AddElementToolStripMenuItem_Click(object sender,
EventArgs e) => AddNewElement();
private void UpdElementToolStripMenuItem_Click(object sender,
EventArgs e) => UpdateElement();
private void DelElementToolStripMenuItem_Click(object sender,
EventArgs e) => DeleteElement();
private void SimpleDocToolStripMenuItem_Click(object sender,
EventArgs e) => CreateSimpleDoc();
private void TableDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateTableDoc();
private void ChartDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateChartDoc();
}
}

View 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>

View File

@@ -0,0 +1,20 @@
<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="System.ComponentModel.Composition" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PluginsConventionLibraryNet60\PluginsConventionLibraryNet60.csproj" />
<ProjectReference Include="..\UniversityForms\UniversityForms.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,48 @@
using PluginsConventionLibraryNet60;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FormsByPlugins
{
public class PluginsManager
{
//Тег, указывающий, что plugins должны быть заполнены CompositionContainer
[ImportMany(typeof(IPluginsConvention))]
IEnumerable<IPluginsConvention> plugins { get; set; }
public readonly Dictionary<string, IPluginsConvention> plugins_dictionary = new Dictionary<string, IPluginsConvention>();
public PluginsManager()
{
AggregateCatalog catalog = new AggregateCatalog();
catalog.Catalogs.Add(new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory));
catalog.Catalogs.Add(new DirectoryCatalog(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins")));
//Контейнер композиции
CompositionContainer container = new CompositionContainer(catalog);
try
{
container.ComposeParts(this);
}
catch (CompositionException compositionException)
{
MessageBox.Show(compositionException.ToString());
}
if (plugins.Any())
{
plugins
.ToList()
.ForEach(p =>
{
if (!plugins_dictionary.Keys.Contains(p.PluginName))
plugins_dictionary.Add(p.PluginName, p);
});
}
}
}
}

View File

@@ -0,0 +1,17 @@
namespace FormsByPlugins
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormMain());
}
}
}

View File

@@ -0,0 +1,16 @@
namespace PluginsConventionLibraryNet60
{
public interface IPluginsConvention
{
string PluginName { get; }
UserControl GetControl { get; }
PluginsConventionElement GetElement { get; }
Form GetForm(PluginsConventionElement element);
Form GetThesaurus();
bool DeleteElement(PluginsConventionElement element);
void ReloadData();
bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument);
bool CreateTableDocument(PluginsConventionSaveDocument saveDocument);
bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PluginsConventionLibraryNet60
{
public class PluginsConventionElement
{
public Guid Id { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<UseWindowsForms>true</UseWindowsForms>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PluginsConventionLibraryNet60
{
public class PluginsConventionSaveDocument
{
public string FileName { get; set; }
}
}

View File

@@ -0,0 +1,101 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.BusinessLogicsContracts;
using UniversityContracts.SearchModels;
using UniversityContracts.StorageContracts;
using UniversityContracts.ViewModels;
namespace UniversityBusinessLogic.BusinessLogics
{
public class CourseLogic: ICourseLogic
{
private readonly ICourseStorage _courseStorage;
public CourseLogic( ICourseStorage courseStorage)
{
_courseStorage = courseStorage;
}
public bool Create(CourseBindingModels model)
{
CheckModel(model);
if (_courseStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Delete(CourseBindingModels model)
{
CheckModel(model, false);
if (_courseStorage.Delete(model) == null)
{
return false;
}
return true;
}
public CourseViewModel? ReadElement(CourseSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _courseStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public List<CourseViewModel>? ReadList(CourseSearchModel? model)
{
var list = model == null ? _courseStorage.GetFullList() : _courseStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public bool Update(CourseBindingModels model)
{
CheckModel(model);
if (_courseStorage.Update(model) == null)
{
return false;
}
return true;
}
private void CheckModel(CourseBindingModels model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет названия курса", nameof(model.Name));
}
var element = _courseStorage.GetElement(new CourseSearchModel
{
Name = model.Name
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Курс с таким названием уже есть");
}
}
}
}

View File

@@ -0,0 +1,108 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.BusinessLogicsContracts;
using UniversityContracts.SearchModels;
using UniversityContracts.StorageContracts;
using UniversityContracts.ViewModels;
namespace UniversityBusinessLogic.BusinessLogics
{
public class StudentLogic: IStudentLogic
{
private readonly IStudentStorage _studentStorage;
public StudentLogic(IStudentStorage studentStorage)
{
_studentStorage = studentStorage;
}
public bool Create(StudentBindingModels model)
{
CheckModel(model);
if (_studentStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Delete(StudentBindingModels model)
{
CheckModel(model, false);
if (_studentStorage.Delete(model) == null)
{
return false;
}
return true;
}
public StudentViewModel? ReadElement(StudentSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _studentStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public List<StudentViewModel>? ReadList(StudentBindingModels? model)
{
var list = model == null ? _studentStorage.GetFullList() : _studentStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public bool Update(StudentBindingModels model)
{
CheckModel(model);
if (_studentStorage.Update(model) == null)
{
return false;
}
return true;
}
private void CheckModel(StudentBindingModels model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.FIO))
{
throw new ArgumentNullException("Нет ФИО", nameof(model.FIO));
}
if (string.IsNullOrEmpty(model.Сharacteristic))
{
throw new ArgumentNullException("Нет характеристики", nameof(model.Сharacteristic));
}
if (string.IsNullOrEmpty(model.Course))
{
throw new ArgumentNullException("Студент должен обязательно числиться на курсе", nameof(model.Сharacteristic));
}
var element = _studentStorage.GetElement(new StudentSearchModel
{
FIO = model.FIO
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Студент с таким ФИО уже есть");
}
}
}
}

View File

@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\UniversityContracts\UniversityContracts.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.BindingModels
{
public class CourseBindingModels : ICourseModel
{
public int Id { get; set; }
public string Name { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.BindingModels
{
public class StudentBindingModels: IStudentModel
{
public int Id { get; set; }
public string FIO { get; set; } = string.Empty;
public string Сharacteristic { get; set; } = string.Empty;
public string Course { get; set; } = string.Empty;
public int? Scholarship { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.BusinessLogicsContracts
{
public interface ICourseLogic
{
List<CourseViewModel>? ReadList(CourseSearchModel? model);
CourseViewModel? ReadElement(CourseSearchModel model);
bool Create(CourseBindingModels model);
bool Update(CourseBindingModels model);
bool Delete(CourseBindingModels model);
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.BusinessLogicsContracts
{
public interface IStudentLogic
{
List<StudentViewModel>? ReadList(StudentBindingModels? model);
StudentViewModel? ReadElement(StudentSearchModel model);
bool Create(StudentBindingModels model);
bool Update(StudentBindingModels model);
bool Delete(StudentBindingModels model);
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityContracts.SearchModels
{
public class CourseSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityContracts.SearchModels
{
public class StudentSM
{
public string Course { get; set; }
public int Scholarship { get; set; }
public int Id { get; set; }
public string FIO { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityContracts.SearchModels
{
public class StudentSearchModel
{
public string? Course { get; set; }
public int? Scholarship { get; set; }
public int? Id { get; set; }
public string? FIO { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.StorageContracts
{
public interface ICourseStorage
{
List<CourseViewModel> GetFullList();
List<CourseViewModel> GetFilteredList(CourseSearchModel model);
CourseViewModel? GetElement(CourseSearchModel model);
CourseViewModel? Insert(CourseBindingModels model);
CourseViewModel? Update(CourseBindingModels model);
CourseViewModel? Delete(CourseBindingModels model);
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
namespace UniversityContracts.StorageContracts
{
public interface IStudentStorage
{
List<StudentViewModel> GetFullList();
List<StudentViewModel> GetFilteredList(StudentBindingModels model);
StudentViewModel? GetElement(StudentSearchModel model);
StudentViewModel? Insert(StudentBindingModels model);
StudentViewModel? Update(StudentBindingModels model);
StudentViewModel? Delete(StudentBindingModels model);
}
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\UniversityDataModels\UniversityDataModels.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.ViewModels
{
public class CourseViewModel: ICourseModel
{
public int Id { get; set; }
[DisplayName("Название курса")]
public string Name { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.ViewModels
{
public class StudentViewModel: IStudentModel
{
public int Id { get; set; }
[DisplayName("ФИО")]
public string FIO { get; set; } = string.Empty;
[DisplayName("Краткая характеристика")]
public string Сharacteristic { get; set; } = string.Empty;
[DisplayName("Курс")]
public string Course { get; set; } = string.Empty;
public int? Scholarship { get; set; }
[DisplayName("Стипендия")]
public string ScholarshipStr { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.ViewModels
{
public class StudentViewModel1 : IStudentModel
{
public int Id { get; set; }
[DisplayName("ФИО")]
public string FIO { get; set; } = string.Empty;
[DisplayName("Краткая характеристика")]
public string Сharacteristic { get; set; } = string.Empty;
[DisplayName("Курс")]
public string Course { get; set; } = string.Empty;
[DisplayName("Стипендия")]
public string ScholarshipStr { get; set; } = string.Empty;
public int? Scholarship { get; set; }
}
}

View File

@@ -0,0 +1,88 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.StorageContracts;
using UniversityContracts.ViewModels;
using UniversityDataBaseImplements.Models;
namespace UniversityDataBaseImplements.Implements
{
public class CourseStorage : ICourseStorage
{
public List<CourseViewModel> GetFullList()
{
using var context = new UniversityDatabase();
return context.Courses
.Select(x => x.GetViewModel)
.ToList();
}
public List<CourseViewModel> GetFilteredList(CourseSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return new();
}
using var context = new UniversityDatabase();
return context.Courses
.Select(x => x.GetViewModel)
.ToList();
}
public CourseViewModel? GetElement(CourseSearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return null;
}
using var context = new UniversityDatabase();
return context.Courses
.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.Name) && x.Name ==
model.Name) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public CourseViewModel? Insert(CourseBindingModels model)
{
using var context = new UniversityDatabase();
var newCourse = Course.Create(model);
if (newCourse == null)
{
return null;
}
context.Courses.Add(newCourse);
context.SaveChanges();
return newCourse.GetViewModel;
}
public CourseViewModel? Update(CourseBindingModels model)
{
using var context = new UniversityDatabase();
var medicine = context.Courses.FirstOrDefault(x => x.Id == model.Id);
if (medicine == null)
{
return null;
}
medicine.Update(model);
context.SaveChanges();
return medicine.GetViewModel;
}
public CourseViewModel? Delete(CourseBindingModels model)
{
using var context = new UniversityDatabase();
var element = context.Courses.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Courses.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@@ -0,0 +1,105 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.SearchModels;
using UniversityContracts.StorageContracts;
using UniversityContracts.ViewModels;
using UniversityDataBaseImplements.Models;
namespace UniversityDataBaseImplements.Implements
{
public class StudentStorage : IStudentStorage
{
public List<StudentViewModel> GetFullList()
{
using var context = new UniversityDatabase();
return context.Students
.Select(x => x.GetViewModel)
.ToList();
}
public List<StudentViewModel> GetFilteredList(StudentBindingModels model)
{
if (string.IsNullOrEmpty(model.FIO))
{
return new();
}
using var context = new UniversityDatabase();
return context.Students
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
public StudentViewModel? GetElement(StudentSearchModel model)
{
using var context = new UniversityDatabase();
return context.Students.FirstOrDefault(x =>
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public StudentViewModel? Insert(StudentBindingModels model)
{
using var context = new UniversityDatabase();
var newMedicine = Student.Create(model);
if (newMedicine == null)
{
return null;
}
context.Students.Add(newMedicine);
context.SaveChanges();
return context.Students.FirstOrDefault(x => x.Id == newMedicine.Id)
?.GetViewModel;
}
public StudentViewModel? Update(StudentBindingModels model)
{
using var context = new UniversityDatabase();
var medicine = context.Students.FirstOrDefault(x => x.Id == model.Id);
if (medicine == null)
{
return null;
}
medicine.Update(model);
context.SaveChanges();
return medicine.GetViewModel;
}
public StudentViewModel? Delete(StudentBindingModels model)
{
using var context = new UniversityDatabase();
var element = context.Students.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Students.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
//private static Student CreateModel(StudentBindingModels model, Student student)
//{
// student.Scholarship = model.Scholarship;
// student.FIO = model.FIO;
// student.Course = model.Course;
// student.Characteristic = model.Сharacteristic;
// return student;
//}
//private StudentViewModel CreateModel(Student student)
//{
// return new StudentViewModel
// {
// Id = student.Id,
// Scholarship = student.Scholarship.ToString(),
// FIO = student.FIO,
// Course = student.Course,
// Сharacteristic = student.Сharacteristic
// };
//}
}
}

View File

@@ -0,0 +1,75 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using UniversityDataBaseImplements;
#nullable disable
namespace UniversityDataBaseImplements.Migrations
{
[DbContext(typeof(UniversityDatabase))]
[Migration("20231027200653_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("UniversityDataBaseImplements.Models.Course", 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("Courses");
});
modelBuilder.Entity("UniversityDataBaseImplements.Models.Student", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Course")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("Scholarship")
.HasColumnType("int");
b.Property<string>("Сharacteristic")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Students");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,53 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace UniversityDataBaseImplements.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Courses",
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_Courses", 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),
Сharacteristic = table.Column<string>(type: "nvarchar(max)", nullable: false),
Scholarship = table.Column<int>(type: "int", nullable: true),
Course = 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: "Courses");
migrationBuilder.DropTable(
name: "Students");
}
}
}

View File

@@ -0,0 +1,72 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using UniversityDataBaseImplements;
#nullable disable
namespace UniversityDataBaseImplements.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("UniversityDataBaseImplements.Models.Course", 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("Courses");
});
modelBuilder.Entity("UniversityDataBaseImplements.Models.Student", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Course")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("Scholarship")
.HasColumnType("int");
b.Property<string>("Сharacteristic")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Students");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.ViewModels;
namespace UniversityDataBaseImplements.Models
{
public class Course
{
public int Id { get; private set; }
[Required]
public string Name { get; private set; } = string.Empty;
public static Course? Create(CourseBindingModels model)
{
if (model == null)
{
return null;
}
return new Course()
{
Id = model.Id,
Name = model.Name
};
}
public static Course Create(CourseViewModel model)
{
return new Course
{
Id = model.Id,
Name = model.Name
};
}
public void Update(CourseBindingModels model)
{
if (model == null)
{
return;
}
Name = model.Name;
}
public CourseViewModel GetViewModel => new()
{
Id = Id,
Name = Name
};
}
}

View File

@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.ViewModels;
namespace UniversityDataBaseImplements.Models
{
public class Student
{
public int Id { get; private set; }
[Required]
public string FIO { get; private set; } = string.Empty;
[Required]
public string Сharacteristic { get; private set; } = string.Empty;
public int? Scholarship { get; private set; }
[Required]
public string Course { get; private set; } = string.Empty;
public static Student? Create(StudentBindingModels model)
{
if (model == null)
{
return null;
}
return new Student()
{
Id = model.Id,
Course = model.Course,
FIO = model.FIO,
Scholarship = model.Scholarship,
Сharacteristic = model.Сharacteristic
};
}
public static Student Create(StudentViewModel model)
{
return new Student()
{
Id = model.Id,
Course = model.Course,
FIO = model.FIO,
Scholarship = model.Scholarship,
Сharacteristic = model.Сharacteristic
};
}
public void Update(StudentBindingModels model)
{
Course = model.Course;
FIO = model.FIO;
Scholarship = model.Scholarship;
Сharacteristic = model.Сharacteristic;
}
public StudentViewModel GetViewModel => new()
{
Id = Id,
Course = Course,
FIO = FIO,
Scholarship = Scholarship,
Сharacteristic = Сharacteristic,
ScholarshipStr = Scholarship.ToString()
};
}
}

View File

@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</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" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityDataBaseImplements.Models;
namespace UniversityDataBaseImplements
{
public class UniversityDatabase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-0BJHUJC\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
public virtual DbSet<Student> Students { set; get; }
public virtual DbSet<Course> Courses { set; get; }
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityDataModels
{
public interface IId
{
int Id { get; }
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityDataModels.Models
{
public interface ICourseModel : IId
{
string Name { get; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UniversityDataModels.Models
{
public interface IStudentModel : IId
{
string FIO { get; }
string Сharacteristic { get; }
string Course { get; }
int? Scholarship { get; }
}
}

View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,68 @@
namespace UniversityForms
{
partial class FormCourses
{
/// <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.dataGridView1 = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// dataGridView1
//
this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.InactiveBorder;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(0, 0);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowHeadersWidth = 51;
this.dataGridView1.RowTemplate.Height = 29;
this.dataGridView1.Size = new System.Drawing.Size(266, 261);
this.dataGridView1.TabIndex = 0;
this.dataGridView1.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEndEdit);
this.dataGridView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridView1_KeyDown);
//
// FormCourses
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(266, 261);
this.Controls.Add(this.dataGridView1);
this.Name = "FormCourses";
this.Text = "Курсы";
this.Load += new System.EventHandler(this.FormCourses_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
}
}

View File

@@ -0,0 +1,120 @@
using DocumentFormat.OpenXml.Office2010.Excel;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using UniversityBusinessLogic.BusinessLogics;
using UniversityContracts.BindingModels;
using UniversityContracts.BusinessLogicsContracts;
namespace UniversityForms
{
public partial class FormCourses : Form
{
private readonly ICourseLogic courseLogic;
BindingList<CourseBindingModels> list;
public FormCourses(ICourseLogic _courseLogic)
{
InitializeComponent();
courseLogic = _courseLogic;
list = new BindingList<CourseBindingModels>();
dataGridView1.AllowUserToAddRows = false;
}
private void FormCourses_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list1 = courseLogic.ReadList(null);
list.Clear();
foreach (var item in list1)
{
list.Add(new CourseBindingModels
{
Id = item.Id,
Name = item.Name,
});
}
if (list != null)
{
dataGridView1.DataSource = list;
dataGridView1.Columns[0].Visible = false;
dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
var typeName = (string)dataGridView1.CurrentRow.Cells[1].Value;
if (!string.IsNullOrEmpty(typeName))
{
if (dataGridView1.CurrentRow.Cells[0].Value != null && int.TryParse(dataGridView1.CurrentRow.Cells[0].Value.ToString(), out int id))
{
courseLogic.Create(new CourseBindingModels()
{
Id = id,
Name = typeName
});
}
else
{
var newDirection = new CourseBindingModels()
{
Name = typeName
};
courseLogic.Create(newDirection);
list.Add(newDirection);
}
}
else
{
MessageBox.Show("Введена пустая строка", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Insert)
{
if (dataGridView1.Rows.Count == 0)
{
list.Add(new CourseBindingModels());
dataGridView1.DataSource = new BindingList<CourseBindingModels>(list);
dataGridView1.CurrentCell = dataGridView1.Rows[0].Cells[1];
return;
}
if (dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1].Value != null)
{
list.Add(new CourseBindingModels());
dataGridView1.DataSource = new BindingList<CourseBindingModels>(list);
dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1];
return;
}
}
if (e.KeyData == Keys.Delete)
{
if (MessageBox.Show("Удалить выбранный элемент", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
courseLogic.Delete(new CourseBindingModels() { Id = (int)dataGridView1.CurrentRow.Cells[0].Value });
LoadData();
}
}
}
}
}

View 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>

197
COP_1/UniversityForms/FormMain.Designer.cs generated Normal file
View File

@@ -0,0 +1,197 @@
namespace UniversityForms
{
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.contextMenuStrip1 = 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.label1 = new System.Windows.Forms.Label();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.менюToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.справочникToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.componentWord11 = new COPWinForms.ComponentWord1(this.components);
this.pieChart1 = new COP.PieChart(this.components);
this.tablePdfComponent11 = new WinFormsControlLibrary.TablePdfComponent1(this.components);
this.myTreeView1 = new VisableComponents.MyTreeView();
this.contextMenuStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// contextMenuStrip1
//
this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.добавитьToolStripMenuItem,
this.редактироваьToolStripMenuItem,
this.изменитьToolStripMenuItem,
this.созданиеПростогоЭлементаToolStripMenuItem,
this.созданиеДокаСНастраиваемойТаблицейToolStripMenuItem,
this.созданиеДиаграммыToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(432, 148);
this.contextMenuStrip1.Text = "Студент";
//
// добавить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(431, 24);
this.добавитьToolStripMenuItem.Text = "Добавить";
this.добавитьToolStripMenuItem.Click += new System.EventHandler(this.добавитьToolStripMenuItem_Click_1);
//
// редактироваь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(431, 24);
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(431, 24);
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(431, 24);
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(431, 24);
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(431, 24);
this.созданиеДиаграммыToolStripMenuItem.Text = "Создание диаграммы";
this.созданиеДиаграммыToolStripMenuItem.Click += new System.EventHandler(this.созданиеДиаграммыToolStripMenuItem_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 31);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(131, 20);
this.label1.TabIndex = 1;
this.label1.Text = "Список студентов";
//
// menuStrip1
//
this.menuStrip1.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.менюToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(409, 28);
this.menuStrip1.TabIndex = 2;
this.menuStrip1.Text = "menuStrip1";
//
// менюToolStripMenuItem
//
this.менюToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.справочникToolStripMenuItem});
this.менюToolStripMenuItem.Name = енюToolStripMenuItem";
this.менюToolStripMenuItem.Size = new System.Drawing.Size(65, 24);
this.менюToolStripMenuItem.Text = "Меню";
//
// справочникToolStripMenuItem
//
this.справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
this.справочникToolStripMenuItem.Size = new System.Drawing.Size(177, 26);
this.справочникToolStripMenuItem.Text = "Справочник";
this.справочникToolStripMenuItem.Click += new System.EventHandler(this.справочникToolStripMenuItem_Click);
//
// myTreeView1
//
this.myTreeView1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.myTreeView1.BackColor = System.Drawing.SystemColors.ControlDark;
this.myTreeView1.Location = new System.Drawing.Point(0, 55);
this.myTreeView1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.myTreeView1.MinimumSize = new System.Drawing.Size(200, 200);
this.myTreeView1.Name = "myTreeView1";
this.myTreeView1.Size = new System.Drawing.Size(409, 750);
this.myTreeView1.TabIndex = 3;
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(409, 437);
this.Controls.Add(this.myTreeView1);
this.Controls.Add(this.label1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "FormMain";
this.Text = "Главная";
this.Load += new System.EventHandler(this.FormMain_Load);
this.contextMenuStrip1.ResumeLayout(false);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label label1;
private MenuStrip menuStrip1;
private ToolStripMenuItem менюToolStripMenuItem;
private ToolStripMenuItem справочникToolStripMenuItem;
private ContextMenuStrip contextMenuStrip1;
private ToolStripMenuItem добавитьToolStripMenuItem;
private ToolStripMenuItem редактироваьToolStripMenuItem;
private ToolStripMenuItem изменитьToolStripMenuItem;
private ToolStripMenuItem созданиеПростогоЭлементаToolStripMenuItem;
private ToolStripMenuItem созданиеДокаСНастраиваемойТаблицейToolStripMenuItem;
private ToolStripMenuItem созданиеДиаграммыToolStripMenuItem;
private COPWinForms.ComponentWord1 componentWord11;
private COP.PieChart pieChart1;
private WinFormsControlLibrary.TablePdfComponent1 tablePdfComponent11;
private VisableComponents.MyTreeView myTreeView1;
}
}

View File

@@ -0,0 +1,231 @@
using COP;
using COP.Info;
using COPWinForms;
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
using NPOI.HPSF;
using NPOI.SS.Formula.Functions;
using System.Windows.Forms;
using UniversityContracts.BindingModels;
using UniversityContracts.BusinessLogicsContracts;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
using WinFormsControlLibrary;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace UniversityForms
{
public partial class FormMain : Form
{
private readonly IStudentLogic _studentLogic;
private readonly ICourseLogic _courseLogic;
public FormMain(IStudentLogic studentLogic, ICourseLogic courseLogic)
{
_studentLogic = studentLogic;
_courseLogic = courseLogic;
InitializeComponent();
List<string> stringToHierachy = new List<string>() { "Course", "ScholarshipStr", "Id", "FIO" };
myTreeView1.addToHierarchy(stringToHierachy);
myTreeView1.ContextMenuStrip = contextMenuStrip1;
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _studentLogic.ReadList(null);
for (int i = 0; i < list.Count; i++)
{
if (list[i].Scholarship == null) { list[i].ScholarshipStr = "<22><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"; }
}
myTreeView1.LoadTree(list);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCourses));
if (service is FormCourses form)
{
form.ShowDialog();
}
}
private void <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ToolStripMenuItem_Click_1(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormStudent));
if (service is FormStudent form)
{
form.ShowDialog();
}
LoadData();
}
private void <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormStudent));
if (service is FormStudent form)
{
var selectedClient = myTreeView1.GetNode(typeof(StudentViewModel));
if (selectedClient != null)
{
form.Id = Convert.ToInt32((selectedClient as StudentViewModel).Id);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
else
{
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
}
}
private void <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ToolStripMenuItem_Click(object sender, EventArgs e)
{
List<string> textList = new List<string>();
var list = _studentLogic.ReadList(null);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
if (list != null)
{
foreach (var item in list)
{
if (item.Scholarship != null)
{
string clients = string.Concat("<22><><EFBFBD>: ", item.FIO, ", <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ", item.<EFBFBD>haracteristic);
textList.Add(clients);
}
}
string[] textArray = textList.ToArray();
componentWord11.CreateWordText(new(dialog.FileName, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", textArray));
}
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ToolStripMenuItem_Click(object sender, EventArgs e)
{
PieChart chart = new();
COP.Enums.LegendPosition legend = new();
var listStudents = _studentLogic.ReadList(null);
var listCourses = _courseLogic.ReadList(null);
List<(string, int)> data = new List<(string, int)>();
for (int i = 0; i < listCourses.Count; i++)
{
int counter = 0;
for (int j = 0; j < listStudents.Count; j++)
{
if (listStudents[j].Course == listCourses[i].Name && listStudents[j].Scholarship != null) counter++;
}
data.Add((listCourses[i].Name, counter));
}
List<DataItem> chartData = new List<DataItem>();
foreach (var item in data)
{
chartData.Add(new DataItem
{
Name = item.Item1,
Value = item.Item2
});
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
using var dialog = new SaveFileDialog
{
Filter = "xlsx|*.xlsx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
ExcelChartInfo info = new(dialog.FileName, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD>", COP.Enums.LegendPosition.Right, chartData);
chart.GenerateDocument(info);
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ToolStripMenuItem_Click(object sender, EventArgs e)
{
CustomTablePdfComponent2 generator = new CustomTablePdfComponent2();
var list = _studentLogic.ReadList(null);
for (int i = 0; i < list.Count; i++)
{
if (list[i].Scholarship == null) { list[i].ScholarshipStr = "No"; }
}
var columnConfigs = new List<ColumnConfig>
{
new ColumnConfig { Width = 50f, PropertyName = "Id", ShowName = "Id"},
new ColumnConfig { Width = 300f, PropertyName = "FIO", ShowName = "FIO" },
new ColumnConfig { Width = 100f, PropertyName = "Course", ShowName = "Course" },
new ColumnConfig { Width = 100f, PropertyName = "ScholarshipStr", ShowName = "Scholarship" },
};
using var dialog = new SaveFileDialog
{
Filter = "pdf|*.pdf"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
generator.GenerateDocument(dialog.FileName, "Students", 100f, 50f, list, columnConfigs);
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
var selectedClient = myTreeView1.GetNode(typeof(StudentViewModel));
if (selectedClient != null)
{
int id = Convert.ToInt32((selectedClient as StudentViewModel).Id);
try
{
_studentLogic.Delete(new StudentBindingModels { Id = id });
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
}
}
}
}

View File

@@ -0,0 +1,78 @@
<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="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>152, 17</value>
</metadata>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="componentWord11.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>338, 17</value>
</metadata>
<metadata name="pieChart1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>524, 17</value>
</metadata>
<metadata name="tablePdfComponent11.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>643, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
</root>

View File

@@ -0,0 +1,154 @@
namespace UniversityForms
{
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.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.buttonAdd = new System.Windows.Forms.Button();
this.textBoxFIO = new System.Windows.Forms.TextBox();
this.textBoxCharacter = new System.Windows.Forms.TextBox();
this.componentcBox1 = new COPWinForms.ComponentCBox();
this.fieldForInt1 = new WinFormsControlLibrary.FieldForInt();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(25, 21);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(45, 20);
this.label1.TabIndex = 0;
this.label1.Text = "ФИО:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(25, 101);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(179, 20);
this.label2.TabIndex = 1;
this.label2.Text = "Краткая характеристика:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(175, 170);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(44, 20);
this.label3.TabIndex = 2;
this.label3.Text = "Курс:";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(25, 170);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(87, 20);
this.label4.TabIndex = 3;
this.label4.Text = "Стипендия:";
//
// buttonAdd
//
this.buttonAdd.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.buttonAdd.Location = new System.Drawing.Point(12, 288);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(316, 29);
this.buttonAdd.TabIndex = 4;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = false;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// textBoxFIO
//
this.textBoxFIO.Location = new System.Drawing.Point(12, 44);
this.textBoxFIO.Name = "textBoxFIO";
this.textBoxFIO.Size = new System.Drawing.Size(316, 27);
this.textBoxFIO.TabIndex = 5;
//
// textBoxCharacter
//
this.textBoxCharacter.Location = new System.Drawing.Point(12, 124);
this.textBoxCharacter.Name = "textBoxCharacter";
this.textBoxCharacter.Size = new System.Drawing.Size(316, 27);
this.textBoxCharacter.TabIndex = 6;
//
// componentcBox1
//
this.componentcBox1.Location = new System.Drawing.Point(175, 206);
this.componentcBox1.Name = "componentcBox1";
this.componentcBox1.Selected = "";
this.componentcBox1.Size = new System.Drawing.Size(153, 33);
this.componentcBox1.TabIndex = 8;
//
// fieldForInt1
//
this.fieldForInt1.Location = new System.Drawing.Point(1, 170);
this.fieldForInt1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.fieldForInt1.Name = "fieldForInt1";
this.fieldForInt1.Size = new System.Drawing.Size(120, 147);
this.fieldForInt1.TabIndex = 9;
this.fieldForInt1.TextBoxValue = null;
//
// FormStudent
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(340, 335);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.label4);
this.Controls.Add(this.fieldForInt1);
this.Controls.Add(this.componentcBox1);
this.Controls.Add(this.textBoxCharacter);
this.Controls.Add(this.textBoxFIO);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "FormStudent";
this.Text = "Добавление студента";
this.Load += new System.EventHandler(this.FormStudent_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label label1;
private Label label2;
private Label label3;
private Label label4;
private Button buttonAdd;
private TextBox textBoxFIO;
private TextBox textBoxCharacter;
private COPWinForms.ComponentCBox componentcBox1;
private WinFormsControlLibrary.FieldForInt fieldForInt1;
}
}

View File

@@ -0,0 +1,110 @@
using MathNet.Numerics;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using UniversityContracts.BindingModels;
using UniversityContracts.BusinessLogicsContracts;
using UniversityContracts.SearchModels;
using UniversityContracts.ViewModels;
using UniversityDataBaseImplements.Models;
namespace UniversityForms
{
public partial class FormStudent : Form
{
public int Id { set { id = value; } }
private readonly IStudentLogic _studentlogic;
private readonly ICourseLogic _courselogic;
private int? id;
public FormStudent(IStudentLogic studentLogic, ICourseLogic courseLogic)
{
InitializeComponent();
_studentlogic = studentLogic;
_courselogic = courseLogic;
}
private void buttonAdd_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxFIO.Text))
{
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(componentcBox1.Selected))
{
MessageBox.Show("Выберите курс", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (textBoxCharacter.Text == null)
{
MessageBox.Show("Заполните характеристику", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
int? scholarship = fieldForInt1.TextBoxValue;
try
{
var model = new StudentBindingModels
{
Id = id ?? 0,
Сharacteristic = textBoxCharacter.Text,
FIO = textBoxFIO.Text,
Course = componentcBox1.Selected.ToString(),
Scholarship = scholarship
};
var opI = id.HasValue ? _studentlogic.Update(model) : _studentlogic.Create(model);
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormStudent_Load(object sender, EventArgs e)
{
List<CourseViewModel> viewS = _courselogic.ReadList(null);
if (viewS != null)
{
List<string> list = new List<string>();
foreach (CourseViewModel s in viewS)
{
list.Add(s.Name);
}
componentcBox1.AddingToList(list);
}
if (id.HasValue)
{
try
{
StudentViewModel? view = _studentlogic.ReadElement(new StudentSearchModel { Id = id.Value });
if (view != null)
{
textBoxFIO.Text = view.FIO;
textBoxCharacter.Text = view.Сharacteristic;
componentcBox1.Selected = view.Course;
if (view.Scholarship != null)
{
fieldForInt1.TextBoxValue = view.Scholarship;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View 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>

View File

@@ -0,0 +1,215 @@
using COP;
using COP.Info;
using COPWinForms;
using PluginsConventionLibraryNet60;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityBusinessLogic.BusinessLogics;
using UniversityContracts.BindingModels;
using UniversityContracts.ViewModels;
using UniversityDataBaseImplements.Implements;
using VisableComponents;
using WinFormsControlLibrary;
namespace UniversityForms
{
public class PluginsConvention : IPluginsConvention
{
private readonly StudentLogic _studentLogic = new StudentLogic(new StudentStorage());
private readonly CourseLogic _courseLogic = new CourseLogic(new CourseStorage());
private MyTreeView myTreeView1 = new MyTreeView();
public string PluginName { get; set; } = "Дерево";
public UserControl GetControl
{
get
{
Load();
return myTreeView1;
}
}
public PluginsConventionElement GetElement
{
get
{
var selectedStudent = myTreeView1.GetNode(typeof(StudentViewModel));
int? id = null;
if (selectedStudent != null)
{
id = Convert.ToInt32((selectedStudent as StudentViewModel).Id);
}
byte[] bytes = new byte[16];
if (!id.HasValue)
{
id = -1;
}
BitConverter.GetBytes(id.Value).CopyTo(bytes, 0);
return new()
{
Id = new Guid(bytes)
};
}
}
public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
{
try
{
PieChart chart = new();
var listStudents = _studentLogic.ReadList(null);
var listCourses = _courseLogic.ReadList(null);
List<(string, int)> data = new List<(string, int)>();
for (int i = 0; i < listCourses.Count; i++)
{
int counter = 0;
for (int j = 0; j < listStudents.Count; j++)
{
if (listStudents[j].Course == listCourses[i].Name && listStudents[j].Scholarship != null) counter++;
}
data.Add((listCourses[i].Name, counter));
}
List<DataItem> chartData = new List<DataItem>();
foreach (var item in data)
{
chartData.Add(new DataItem
{
Name = item.Item1,
Value = item.Item2
});
}
chart.GenerateDocument(new ExcelChartInfo(saveDocument.FileName, "Сколько студентов на каком курсе", "Курсы", COP.Enums.LegendPosition.Right, chartData));
return true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
{
try
{
ComponentWord1 text = new ComponentWord1();
List<string> textList = new List<string>();
var list = _studentLogic.ReadList(null);
if (list != null)
{
foreach (var item in list)
{
if (item.Scholarship != null)
{
string clients = string.Concat("ФИО: ", item.FIO, ", Краткая характеристика: ", item.Сharacteristic);
textList.Add(clients);
}
}
string[] textArray = textList.ToArray();
text.CreateWordText(new(saveDocument.FileName, "Документ по студентам со стипендией", textArray));
}
return true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
{
try
{
CustomTablePdfComponent2 generator = new CustomTablePdfComponent2();
var list = _studentLogic.ReadList(null);
for (int i = 0; i < list.Count; i++)
{
if (list[i].Scholarship == null) { list[i].ScholarshipStr = "No"; }
}
var columnConfigs = new List<ColumnConfig>
{
new ColumnConfig { Width = 50f, PropertyName = "Id", ShowName = "Id"},
new ColumnConfig { Width = 300f, PropertyName = "FIO", ShowName = "FIO" },
new ColumnConfig { Width = 100f, PropertyName = "Course", ShowName = "Course" },
new ColumnConfig { Width = 100f, PropertyName = "ScholarshipStr", ShowName = "Scholarship" },
};
generator.GenerateDocument(saveDocument.FileName, "Students", 100f, 50f, list, columnConfigs);
return true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
private void Load()
{
List<string> stringToHierachy = new List<string>() { "Course", "ScholarshipStr", "Id", "FIO" };
myTreeView1.addToHierarchy(stringToHierachy);
LoadData();
}
private void LoadData()
{
try
{
var list = _studentLogic.ReadList(null);
for (int i = 0; i < list.Count; i++)
{
if (list[i].Scholarship == null) { list[i].ScholarshipStr = "Нет стипендии"; }
}
myTreeView1.LoadTree(list);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public bool DeleteElement(PluginsConventionElement element)
{
var selectedStudent = myTreeView1.GetNode(typeof(StudentViewModel));
int id = Convert.ToInt32((selectedStudent as StudentViewModel).Id);
try
{
_studentLogic.Delete(new StudentBindingModels { Id = id });
LoadData();
return true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
public Form GetForm(PluginsConventionElement element)
{
if (element == null)
{
return new FormStudent(_studentLogic, _courseLogic);
}
if (element.Id.GetHashCode() >= 0)
{
FormStudent form = new FormStudent(_studentLogic, _courseLogic);
form.Id = element.Id.GetHashCode();
return form;
}
return null;
}
public Form GetThesaurus()
{
return new FormCourses(_courseLogic);
}
public void ReloadData()
{
LoadData();
}
}
}

View File

@@ -0,0 +1,46 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using UniversityBusinessLogic.BusinessLogics;
using UniversityContracts.BusinessLogicsContracts;
using UniversityContracts.StorageContracts;
using UniversityDataBaseImplements.Implements;
using NLog.Extensions.Logging;
namespace UniversityForms
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
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<IStudentStorage, StudentStorage>();
services.AddTransient<ICourseStorage, CourseStorage>();
services.AddTransient<IStudentLogic, StudentLogic>();
services.AddTransient<ICourseLogic, CourseLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormStudent>();
services.AddTransient<FormCourses>();
}
}
}

View File

@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)plugin\*.dll&quot;" />
</Target>
<ItemGroup>
<PackageReference Include="cop" 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="NLog.Extensions.Logging" Version="5.3.5" />
<PackageReference Include="VisableComponents" Version="1.0.9" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\COPWinForms\COPWinForms.csproj" />
<ProjectReference Include="..\PluginsConventionLibraryNet60\PluginsConventionLibraryNet60.csproj" />
<ProjectReference Include="..\UniversityBusinessLogic\UniversityBusinessLogic.csproj" />
<ProjectReference Include="..\UniversityContracts\UniversityContracts.csproj" />
<ProjectReference Include="..\UniversityDataBaseImplements\UniversityDataBaseImplements.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

Binary file not shown.

Binary file not shown.

BIN
COP_1/plugin/Azure.Core.dll Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
COP_1/plugin/COP.dll Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
COP_1/plugin/EPPlus.dll Normal file

Binary file not shown.

BIN
COP_1/plugin/Enums.NET.dll Normal file

Binary file not shown.

BIN
COP_1/plugin/Humanizer.dll Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More