пока не робит но я старалась
This commit is contained in:
parent
2cea47984c
commit
bb31c39775
16
COP/COP.sln
16
COP/COP.sln
@ -7,15 +7,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "COP", "COP.csproj", "{B22B2
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestComponents", "..\TestComponents\TestComponents.csproj", "{C0F09A72-65A3-49DD-8208-291778E03E81}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityDataModels", "..\UniversityDataModels\UniversityDataModels.csproj", "{843E5B85-F60A-45D7-9B52-96284FFDCA1F}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityDataModels", "..\UniversityDataModels\UniversityDataModels.csproj", "{843E5B85-F60A-45D7-9B52-96284FFDCA1F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityBusinessLogic", "..\UniversityBusinessLogic\UniversityBusinessLogic.csproj", "{453BBFDD-7D8B-463F-A622-AFD6F3E6C644}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityBusinessLogic", "..\UniversityBusinessLogic\UniversityBusinessLogic.csproj", "{453BBFDD-7D8B-463F-A622-AFD6F3E6C644}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityContracts", "..\UniversityContracts\UniversityContracts.csproj", "{2EFD9DCC-226F-45D0-8688-4E0D716BC179}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityContracts", "..\UniversityContracts\UniversityContracts.csproj", "{2EFD9DCC-226F-45D0-8688-4E0D716BC179}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityDatabaseImplement", "..\UniversityDatabaseImplement\UniversityDatabaseImplement.csproj", "{7ED4372B-4D10-411D-9CC1-13CAA2833789}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityDatabaseImplement", "..\UniversityDatabaseImplement\UniversityDatabaseImplement.csproj", "{7ED4372B-4D10-411D-9CC1-13CAA2833789}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversityView", "..\UniversityView\UniversityView.csproj", "{99AE36FC-FEF0-4E8C-8C0B-F6AB1952DEE6}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniversityView", "..\UniversityView\UniversityView.csproj", "{99AE36FC-FEF0-4E8C-8C0B-F6AB1952DEE6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsConventionLibrary", "..\PluginsConventionLibrary\PluginsConventionLibrary.csproj", "{651E8CAB-EEAD-41A7-AC99-F0F7D853AD84}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -51,6 +53,10 @@ Global
|
||||
{99AE36FC-FEF0-4E8C-8C0B-F6AB1952DEE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{99AE36FC-FEF0-4E8C-8C0B-F6AB1952DEE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{99AE36FC-FEF0-4E8C-8C0B-F6AB1952DEE6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{651E8CAB-EEAD-41A7-AC99-F0F7D853AD84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{651E8CAB-EEAD-41A7-AC99-F0F7D853AD84}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{651E8CAB-EEAD-41A7-AC99-F0F7D853AD84}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{651E8CAB-EEAD-41A7-AC99-F0F7D853AD84}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
66
PluginsConventionLibrary/Forms/FormDirection.Designer.cs
generated
Normal file
66
PluginsConventionLibrary/Forms/FormDirection.Designer.cs
generated
Normal file
@ -0,0 +1,66 @@
|
||||
namespace PluginsConventionLibrary.Forms
|
||||
{
|
||||
partial class FormDirection
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.Control;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(429, 297);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
this.dataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellEndEdit);
|
||||
this.dataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridView_KeyDown);
|
||||
//
|
||||
// FormHandbooks
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(429, 297);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormDirection";
|
||||
this.Text = "Направления";
|
||||
this.Load += new System.EventHandler(this.FormDirection_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
110
PluginsConventionLibrary/Forms/FormDirection.cs
Normal file
110
PluginsConventionLibrary/Forms/FormDirection.cs
Normal file
@ -0,0 +1,110 @@
|
||||
using System.ComponentModel;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace PluginsConventionLibrary.Forms
|
||||
{
|
||||
public partial class FormDirection : Form
|
||||
{
|
||||
private readonly IDirectionLogic _logic;
|
||||
BindingList<DirectionBindingModel> _list;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormDirection(IDirectionLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
_list = new BindingList<DirectionBindingModel>();
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
}
|
||||
|
||||
private void FormDirection_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.Read(null);
|
||||
_list.Clear();
|
||||
foreach (var item in list)
|
||||
{
|
||||
_list.Add(new DirectionBindingModel
|
||||
{
|
||||
Id = item.Id,
|
||||
Name = item.Name,
|
||||
});
|
||||
}
|
||||
if (_list != null)
|
||||
{
|
||||
dataGridView.DataSource = _list;
|
||||
dataGridView.Columns[0].Visible = false;
|
||||
dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
var typeName = (string)dataGridView.CurrentRow.Cells[1].Value;
|
||||
if (!string.IsNullOrEmpty(typeName))
|
||||
{
|
||||
if (dataGridView.CurrentRow.Cells[0].Value != null)
|
||||
{
|
||||
_logic.CreateOrUpdate(new DirectionBindingModel()
|
||||
{
|
||||
Id = Convert.ToInt32(dataGridView.CurrentRow.Cells[0].Value),
|
||||
Name = (string)dataGridView.CurrentRow.Cells[1].EditedFormattedValue
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_logic.CreateOrUpdate(new DirectionBindingModel()
|
||||
{
|
||||
Name = (string)dataGridView.CurrentRow.Cells[1].EditedFormattedValue
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Введена пустая строка", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyData == Keys.Insert)
|
||||
{
|
||||
if (dataGridView.Rows.Count == 0)
|
||||
{
|
||||
_list.Add(new DirectionBindingModel());
|
||||
dataGridView.DataSource = new BindingList<DirectionBindingModel>(_list);
|
||||
dataGridView.CurrentCell = dataGridView.Rows[0].Cells[1];
|
||||
return;
|
||||
}
|
||||
if (dataGridView.Rows[dataGridView.Rows.Count - 1].Cells[1].Value != null)
|
||||
{
|
||||
_list.Add(new DirectionBindingModel());
|
||||
dataGridView.DataSource = new BindingList<DirectionBindingModel>(_list);
|
||||
dataGridView.CurrentCell = dataGridView.Rows[dataGridView.Rows.Count - 1].Cells[1];
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (e.KeyData == Keys.Delete)
|
||||
{
|
||||
if (MessageBox.Show("Удалить выбранный элемент", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_logic.Delete(new DirectionBindingModel() { Id = (int)dataGridView.CurrentRow.Cells[0].Value });
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
PluginsConventionLibrary/Forms/FormDirection.resx
Normal file
120
PluginsConventionLibrary/Forms/FormDirection.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
173
PluginsConventionLibrary/Forms/FormStudent.Designer.cs
generated
Normal file
173
PluginsConventionLibrary/Forms/FormStudent.Designer.cs
generated
Normal file
@ -0,0 +1,173 @@
|
||||
namespace PluginsConventionLibrary.Forms
|
||||
{
|
||||
partial class FormStudent
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.textBoxFIO = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.componenttBox1 = new COPWinForms.ComponentTBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.userCheckedListBox1 = new COP.UserCheckedListBox();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonAddPhoto = new System.Windows.Forms.Button();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxFIO
|
||||
//
|
||||
this.textBoxFIO.Location = new System.Drawing.Point(105, 27);
|
||||
this.textBoxFIO.Name = "textBoxFIO";
|
||||
this.textBoxFIO.Size = new System.Drawing.Size(214, 23);
|
||||
this.textBoxFIO.TabIndex = 0;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(65, 30);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(34, 15);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "ФИО";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(65, 68);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(113, 15);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "Электронная почта";
|
||||
//
|
||||
// componenttBox1
|
||||
//
|
||||
this.componenttBox1.Location = new System.Drawing.Point(184, 65);
|
||||
this.componenttBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.componenttBox1.Name = "componenttBox1";
|
||||
this.componenttBox1.Pattern = null;
|
||||
this.componenttBox1.Size = new System.Drawing.Size(135, 38);
|
||||
this.componenttBox1.TabIndex = 4;
|
||||
this.componenttBox1.TextBoxValue = null;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.userCheckedListBox1);
|
||||
this.groupBox1.Location = new System.Drawing.Point(12, 108);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(362, 150);
|
||||
this.groupBox1.TabIndex = 5;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Направление";
|
||||
//
|
||||
// userCheckedListBox1
|
||||
//
|
||||
this.userCheckedListBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.userCheckedListBox1.Location = new System.Drawing.Point(3, 19);
|
||||
this.userCheckedListBox1.Name = "userCheckedListBox1";
|
||||
this.userCheckedListBox1.SelectedValue = "";
|
||||
this.userCheckedListBox1.Size = new System.Drawing.Size(356, 128);
|
||||
this.userCheckedListBox1.TabIndex = 0;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(218, 465);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonSave.TabIndex = 6;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(299, 465);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 7;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// buttonAddPhoto
|
||||
//
|
||||
this.buttonAddPhoto.Location = new System.Drawing.Point(12, 264);
|
||||
this.buttonAddPhoto.Name = "buttonAddPhoto";
|
||||
this.buttonAddPhoto.Size = new System.Drawing.Size(360, 23);
|
||||
this.buttonAddPhoto.TabIndex = 8;
|
||||
this.buttonAddPhoto.Text = "Загрузить фото";
|
||||
this.buttonAddPhoto.UseVisualStyleBackColor = true;
|
||||
this.buttonAddPhoto.Click += new System.EventHandler(this.buttonAddPhoto_Click);
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
this.pictureBox.Location = new System.Drawing.Point(12, 293);
|
||||
this.pictureBox.Name = "pictureBox";
|
||||
this.pictureBox.Size = new System.Drawing.Size(359, 166);
|
||||
this.pictureBox.TabIndex = 9;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
// FormStudent
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(384, 500);
|
||||
this.Controls.Add(this.pictureBox);
|
||||
this.Controls.Add(this.buttonAddPhoto);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.componenttBox1);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.textBoxFIO);
|
||||
this.Name = "FormStudent";
|
||||
this.Text = "Студент";
|
||||
this.Load += new System.EventHandler(this.FormStudent_Load);
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxFIO;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private COPWinForms.ComponentTBox componenttBox1;
|
||||
private GroupBox groupBox1;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private COP.UserCheckedListBox userCheckedListBox1;
|
||||
private Button buttonAddPhoto;
|
||||
private PictureBox pictureBox;
|
||||
}
|
||||
}
|
148
PluginsConventionLibrary/Forms/FormStudent.cs
Normal file
148
PluginsConventionLibrary/Forms/FormStudent.cs
Normal file
@ -0,0 +1,148 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.ComponentModel;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.BusinessLogicsContracts;
|
||||
using UniversityContracts.ViewModels;
|
||||
|
||||
namespace PluginsConventionLibrary.Forms
|
||||
{
|
||||
public partial class FormStudent : Form
|
||||
{
|
||||
private readonly IStudentLogic _studentLogic;
|
||||
private readonly IDirectionLogic _directionLogic;
|
||||
private string imagePath;
|
||||
BindingList<DirectionBindingModel> _list;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
List<string> directions = new();
|
||||
public FormStudent( IStudentLogic studentLogic, IDirectionLogic directionLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_studentLogic = studentLogic;
|
||||
_directionLogic = directionLogic;
|
||||
imagePath = "";
|
||||
_list = new BindingList<DirectionBindingModel>();
|
||||
componenttBox1.Pattern = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$";
|
||||
componenttBox1.setExample("example@mail.ru");
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxFIO.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(componenttBox1.TextBoxValue))
|
||||
{
|
||||
MessageBox.Show("Заполните электронную почту", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (userCheckedListBox1.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Заполните направление", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (pictureBox.Image == null)
|
||||
{
|
||||
MessageBox.Show("Загрузите фото", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
_studentLogic.CreateOrUpdate(new StudentBindingModel
|
||||
{
|
||||
Id = _id,
|
||||
FIO = textBoxFIO.Text,
|
||||
PhotoFilePath = imagePath,
|
||||
Email = componenttBox1.TextBoxValue,
|
||||
DirectionName = userCheckedListBox1.SelectedValue
|
||||
}); ;
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void FormStudent_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
StudentViewModel? view = _studentLogic.Read(new StudentBindingModel { Id = _id.Value })?[0];
|
||||
if (view != null)
|
||||
{
|
||||
textBoxFIO.Text = view.FIO;
|
||||
componenttBox1.TextBoxValue = view.Email;
|
||||
imagePath = view.PhotoFilePath;
|
||||
string[] dirs = view.DirectionName.Split(";");
|
||||
foreach (var dir in dirs)
|
||||
{
|
||||
userCheckedListBox1.SelectedValue = dir;
|
||||
}
|
||||
pictureBox.Image = Image.FromFile(imagePath);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _directionLogic.Read(null);
|
||||
userCheckedListBox1.ClearList();
|
||||
directions.Clear();
|
||||
_list.Clear();
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
directions.Add(item.Name);
|
||||
_list.Add(new DirectionBindingModel
|
||||
{
|
||||
Id = item.Id,
|
||||
Name = item.Name,
|
||||
});
|
||||
}
|
||||
}
|
||||
userCheckedListBox1.FillList(directions);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAddPhoto_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog openFileDialog = new()
|
||||
{
|
||||
Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG|All files (*.*)|*.*"
|
||||
};
|
||||
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
imagePath = openFileDialog.FileName;
|
||||
pictureBox.Image = Image.FromFile(imagePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
PluginsConventionLibrary/Forms/FormStudent.resx
Normal file
120
PluginsConventionLibrary/Forms/FormStudent.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
254
PluginsConventionLibrary/MainPluginConvention.cs
Normal file
254
PluginsConventionLibrary/MainPluginConvention.cs
Normal file
@ -0,0 +1,254 @@
|
||||
using COP;
|
||||
using COP.Info;
|
||||
using COPWinForms;
|
||||
using PluginsConventionLibrary.Forms;
|
||||
using PluginsConventionLibrary.Plugins;
|
||||
using System.ComponentModel.Composition;
|
||||
using UniversityBusinessLogic.BusinessLogics;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.BusinessLogicsContracts;
|
||||
using WinFormsControlLibrary;
|
||||
using static COP.ExcelComponent;
|
||||
using static COPWinForms.ComponentWord2;
|
||||
using LegendPosition = WinFormsControlLibrary.LegendPosition;
|
||||
|
||||
namespace PluginsConventionLibrary
|
||||
{
|
||||
[Export(typeof(IPluginsConvention))]
|
||||
public class MainPluginConvention : IPluginsConvention
|
||||
{
|
||||
|
||||
private TableOfValues tableOfValues;
|
||||
private readonly IStudentLogic _studentLogic;
|
||||
private readonly IDirectionLogic _directionLogic;
|
||||
|
||||
public MainPluginConvention()
|
||||
{
|
||||
_studentLogic = new StudentLogic();
|
||||
_directionLogic = new DirectionLogic();
|
||||
|
||||
tableOfValues = new TableOfValues();
|
||||
var menu = new ContextMenuStrip();
|
||||
var directionMenuItem = new ToolStripMenuItem("Формы");
|
||||
menu.Items.Add(directionMenuItem);
|
||||
directionMenuItem.Click += (sender, e) =>
|
||||
{
|
||||
var formDirection = new FormDirection(_directionLogic);
|
||||
formDirection.ShowDialog();
|
||||
};
|
||||
tableOfValues.ContextMenuStrip = menu;
|
||||
ReloadData();
|
||||
}
|
||||
|
||||
/// Название плагина
|
||||
string IPluginsConvention.PluginName => PluginName();
|
||||
public string PluginName()
|
||||
{
|
||||
return "Студенты";
|
||||
}
|
||||
|
||||
public UserControl GetControl => tableOfValues;
|
||||
|
||||
PluginsConventionElement IPluginsConvention.GetElement => GetElement();
|
||||
|
||||
public PluginsConventionElement GetElement()
|
||||
{
|
||||
var student = tableOfValues.GetSelectedObject<MainPluginConventionElement>(); ;
|
||||
MainPluginConventionElement element = null;
|
||||
if (tableOfValues != null)
|
||||
{
|
||||
element = new MainPluginConventionElement
|
||||
{
|
||||
Id = student.Id,
|
||||
FIO = student.FIO,
|
||||
PhotoFilePath = student.PhotoFilePath,
|
||||
Email = student.Email,
|
||||
DirectionName = student.DirectionName,
|
||||
};
|
||||
}
|
||||
return (new PluginsConventionElement { Id = element.Id });
|
||||
}
|
||||
|
||||
public Form GetForm(PluginsConventionElement element)
|
||||
{
|
||||
var formOrder = new FormStudent(_studentLogic, _directionLogic);
|
||||
if (element != null)
|
||||
{
|
||||
formOrder.Id = element.Id;
|
||||
}
|
||||
return formOrder;
|
||||
}
|
||||
|
||||
public bool DeleteElement(PluginsConventionElement element)
|
||||
{
|
||||
try
|
||||
{
|
||||
_studentLogic.Delete(new StudentBindingModel { Id = element.Id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ReloadData()
|
||||
{
|
||||
var columnConfigs = new List<GridColumnConfig>
|
||||
{
|
||||
new GridColumnConfig { HeaderText = "Id", Width = 100, Visible = false, PropertyName = "Id" },
|
||||
new GridColumnConfig { HeaderText = "ФИО", Width = 100, Visible = true, PropertyName = "FIO" },
|
||||
new GridColumnConfig { HeaderText = "Направление", Width = 80, Visible = true, PropertyName = "DirectionName" },
|
||||
new GridColumnConfig { HeaderText = "Электронная почта", Width = 80, Visible = true, PropertyName = "Email" },
|
||||
};
|
||||
|
||||
tableOfValues.ConfigureColumns(columnConfigs);
|
||||
}
|
||||
|
||||
private byte[] StringToImage(string bytes)
|
||||
{
|
||||
byte[] arrayimg = Convert.FromBase64String(bytes);
|
||||
return arrayimg;
|
||||
}
|
||||
|
||||
public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
ExcelComponent excelComponent = new();
|
||||
var list = _studentLogic.Read(null);
|
||||
List<ImageInfo> images = new();
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "xlsx|*.xlsx"
|
||||
};
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
images.Add(new ImageInfo() { FilePath = item.PhotoFilePath });
|
||||
}
|
||||
}
|
||||
ExcelImageInfo info = new(dialog.FileName, "Документ с фотографиями студентов", images);
|
||||
excelComponent.GenerateExcelWithImages(info);
|
||||
MessageBox.Show("Сохарнено успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
ComponentWord2 componentWord = new();
|
||||
var list = _studentLogic.Read(null);
|
||||
List<StudentBindingModel> data = new();
|
||||
List<int[]> mergedColumns = new()
|
||||
{
|
||||
new int[] { 1, 2 }
|
||||
};
|
||||
|
||||
List<ColumnDefinition> columnDefinitions = new()
|
||||
{
|
||||
new ColumnDefinition { Header = "ID", PropertyName = "Id", Width = 11 },
|
||||
new ColumnDefinition { Header = "Личные данные", PropertyName = "PersonalData", Width = 11 },
|
||||
new ColumnDefinition { Header = "Личные данные", PropertyName = "PersonalData1", Width = 11 },
|
||||
new ColumnDefinition { Header = "Направление", PropertyName = "DirectionName", Width = 21 }
|
||||
};
|
||||
|
||||
List<ColumnDefinition> columnDefinitions2 = new()
|
||||
{
|
||||
new ColumnDefinition { Header = "ID", PropertyName = "Id", Width = 11 },
|
||||
new ColumnDefinition { Header = "ФИО", PropertyName = "FIO", Width = 11 },
|
||||
new ColumnDefinition { Header = "Электронная почта", PropertyName = "Email", Width = 70 },
|
||||
new ColumnDefinition { Header = "Направление", PropertyName = "DirectionName", Width = 21 }
|
||||
};
|
||||
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "docx|*.docx"
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
data.Add(new StudentBindingModel() { Id = item.Id, FIO = item.FIO, Email = item.Email, DirectionName = item.DirectionName });
|
||||
}
|
||||
}
|
||||
TableWord<StudentBindingModel> tableWord = new(dialog.FileName, "Таблица со студентами", columnDefinitions, columnDefinitions2, data, mergedColumns);
|
||||
componentWord.CreateTable(tableWord);
|
||||
MessageBox.Show("Сохарнено успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
GistogramPdfComponent3 gistogramPdfComponent = new();
|
||||
var listStudents = _studentLogic.Read(null);
|
||||
var listDirections = _directionLogic.Read(null);
|
||||
List<(string, int)> data = new();
|
||||
List<HistogramData> gistData = new();
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "pdf|*.pdf"
|
||||
};
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < listDirections.Count; i++)
|
||||
{
|
||||
int count = 0;
|
||||
for (int j = 0; j < listStudents.Count; j++)
|
||||
{
|
||||
string[] dirs = listStudents[j].DirectionName.Split(";");
|
||||
foreach (var dir in dirs)
|
||||
{
|
||||
if (dir == listDirections[i].Name) count++;
|
||||
}
|
||||
}
|
||||
data.Add((listDirections[i].Name, count));
|
||||
}
|
||||
if (data != null)
|
||||
{
|
||||
foreach (var item in data)
|
||||
{
|
||||
gistData.Add(new HistogramData
|
||||
{
|
||||
SeriesName = item.Item1,
|
||||
Data = new double[] { item.Item2 }
|
||||
});
|
||||
}
|
||||
}
|
||||
gistogramPdfComponent.GenerateHistogramDocument(dialog.FileName, "Histogram", "Students-Directions", LegendPosition.TopRight, gistData);
|
||||
MessageBox.Show("Сохарнено успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
15
PluginsConventionLibrary/MainPluginConventionElement.cs
Normal file
15
PluginsConventionLibrary/MainPluginConventionElement.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using PluginsConventionLibrary.Plugins;
|
||||
|
||||
namespace PluginsConventionLibrary
|
||||
{
|
||||
public class MainPluginConventionElement : PluginsConventionElement
|
||||
{
|
||||
public string DirectionName { get; set; }
|
||||
|
||||
public string PhotoFilePath { get; set; }
|
||||
|
||||
public string FIO { get; set; }
|
||||
|
||||
public string Email { get; set; }
|
||||
}
|
||||
}
|
60
PluginsConventionLibrary/Plugins/IPluginsConvention.cs
Normal file
60
PluginsConventionLibrary/Plugins/IPluginsConvention.cs
Normal file
@ -0,0 +1,60 @@
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
{
|
||||
public interface IPluginsConvention
|
||||
{
|
||||
/// <summary>
|
||||
/// Название плагина
|
||||
/// </summary>
|
||||
string PluginName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Получение контрола для вывода набора данных
|
||||
/// </summary>
|
||||
UserControl GetControl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Получение элемента, выбранного в контроле
|
||||
/// </summary>
|
||||
PluginsConventionElement GetElement { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Получение формы для создания/редактирования объекта
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
/// <returns></returns>
|
||||
Form GetForm(PluginsConventionElement element);
|
||||
|
||||
/// <summary>
|
||||
/// Удаление элемента
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
/// <returns></returns>
|
||||
bool DeleteElement(PluginsConventionElement element);
|
||||
|
||||
/// <summary>
|
||||
/// Обновление набора данных в контроле
|
||||
/// </summary>
|
||||
void ReloadData();
|
||||
|
||||
/// <summary>
|
||||
/// Создание простого документа
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument);
|
||||
|
||||
/// <summary>
|
||||
/// Создание простого документа
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateTableDocument(PluginsConventionSaveDocument saveDocument);
|
||||
|
||||
/// <summary>
|
||||
/// Создание документа с диаграммой
|
||||
/// </summary>
|
||||
/// <param name="saveDocument"></param>
|
||||
/// <returns></returns>
|
||||
bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
{
|
||||
public class PluginsConventionElement
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
namespace PluginsConventionLibrary.Plugins
|
||||
{
|
||||
public class PluginsConventionSaveDocument
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
}
|
||||
}
|
21
PluginsConventionLibrary/PluginsConventionLibrary.csproj
Normal file
21
PluginsConventionLibrary/PluginsConventionLibrary.csproj
Normal file
@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="COPWinForms" Version="1.0.0" />
|
||||
<PackageReference Include="System.ComponentModel.Composition" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\COP\COP.csproj" />
|
||||
<ProjectReference Include="..\UniversityBusinessLogic\UniversityBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\UniversityContracts\UniversityContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -4,6 +4,7 @@ using UniversityContracts.BusinessLogicsContracts;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StoragesContracts;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityUniversityDatabaseImplement.Implements;
|
||||
|
||||
namespace UniversityBusinessLogic.BusinessLogics
|
||||
{
|
||||
@ -14,7 +15,10 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
{
|
||||
_directionStorage = directionStorage;
|
||||
}
|
||||
|
||||
public DirectionLogic()
|
||||
{
|
||||
_directionStorage = new DirectionStorage();
|
||||
}
|
||||
public void CreateOrUpdate(DirectionBindingModel model)
|
||||
{
|
||||
var element = _directionStorage.GetElement(
|
||||
|
@ -4,6 +4,7 @@ using UniversityContracts.BusinessLogicsContracts;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StoragesContracts;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityUniversityDatabaseImplement.Implements;
|
||||
|
||||
namespace UniversityBusinessLogic.BusinessLogics
|
||||
{
|
||||
@ -14,6 +15,10 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
{
|
||||
_studentStorage = studentStorage;
|
||||
}
|
||||
public StudentLogic()
|
||||
{
|
||||
_studentStorage = new StudentStorage();
|
||||
}
|
||||
public void CreateOrUpdate(StudentBindingModel model)
|
||||
{
|
||||
var element = _studentStorage.GetElement(
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\UniversityContracts\UniversityContracts.csproj" />
|
||||
<ProjectReference Include="..\UniversityDatabaseImplement\UniversityDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
180
UniversityView/FormMainPlugins.Designer.cs
generated
Normal file
180
UniversityView/FormMainPlugins.Designer.cs
generated
Normal file
@ -0,0 +1,180 @@
|
||||
namespace UniversityView
|
||||
{
|
||||
partial class FormMainPlugins
|
||||
{
|
||||
/// <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.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.ControlsStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ActionsToolStripMenuItem = 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.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.excelComponent1 = new COP.ExcelComponent(this.components);
|
||||
this.gistogramPdfComponent31 = new WinFormsControlLibrary.GistogramPdfComponent3(this.components);
|
||||
this.componentWord21 = new COPWinForms.ComponentWord2(this.components);
|
||||
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.AddElementToolStripMenuItem,
|
||||
this.UpdElementToolStripMenuItem,
|
||||
this.DelElementToolStripMenuItem});
|
||||
this.ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem";
|
||||
this.ActionsToolStripMenuItem.Size = new System.Drawing.Size(70, 20);
|
||||
this.ActionsToolStripMenuItem.Text = "Действия";
|
||||
//
|
||||
// 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(170, 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(170, 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(170, 22);
|
||||
this.DelElementToolStripMenuItem.Text = "Удалить";
|
||||
this.DelElementToolStripMenuItem.Click += new System.EventHandler(this.DelElementToolStripMenuItem_Click);
|
||||
//
|
||||
// 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(232, 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(232, 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(232, 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;
|
||||
//
|
||||
// FormMainPlugins
|
||||
//
|
||||
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 = "FormMainPlugins";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Главная форма";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormMainPlugins_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 AddElementToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem UpdElementToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem DelElementToolStripMenuItem;
|
||||
private COP.ExcelComponent excelComponent1;
|
||||
private WinFormsControlLibrary.GistogramPdfComponent3 gistogramPdfComponent31;
|
||||
private COPWinForms.ComponentWord2 componentWord21;
|
||||
}
|
||||
}
|
162
UniversityView/FormMainPlugins.cs
Normal file
162
UniversityView/FormMainPlugins.cs
Normal file
@ -0,0 +1,162 @@
|
||||
using PluginsConventionLibrary.Plugins;
|
||||
|
||||
namespace UniversityView
|
||||
{
|
||||
public partial class FormMainPlugins : Form
|
||||
{
|
||||
private readonly Dictionary<string, IPluginsConvention> _plugins;
|
||||
private string _selectedPlugin;
|
||||
private ContextMenuStrip contextMenu = new ContextMenuStrip();
|
||||
public FormMainPlugins()
|
||||
{
|
||||
InitializeComponent();
|
||||
_plugins = LoadPlugins();
|
||||
_selectedPlugin = string.Empty;
|
||||
}
|
||||
private Dictionary<string, IPluginsConvention> LoadPlugins()
|
||||
{
|
||||
PluginsManager manager = new();
|
||||
var plugins = manager.plugins_dictionary;
|
||||
|
||||
ToolStripItem[] toolStripItems = new ToolStripItem[plugins.Count];
|
||||
int i = 0;
|
||||
if (plugins.Count > 0)
|
||||
{
|
||||
foreach (var plugin in plugins)
|
||||
{
|
||||
ToolStripMenuItem itemMenu = new()
|
||||
{
|
||||
Text = plugin.Value.PluginName
|
||||
};
|
||||
itemMenu.Click += (sender, e) =>
|
||||
{
|
||||
_selectedPlugin = plugin.Value.PluginName;
|
||||
panelControl.Controls.Clear();
|
||||
panelControl.Controls.Add(_plugins[_selectedPlugin].GetControl);
|
||||
panelControl.Controls[0].Dock = DockStyle.Fill;
|
||||
};
|
||||
toolStripItems[i] = itemMenu;
|
||||
i++;
|
||||
}
|
||||
ControlsStripMenuItem.DropDownItems.AddRange(toolStripItems);
|
||||
}
|
||||
return plugins;
|
||||
}
|
||||
private void FormMainPlugins_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (!e.Control)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
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 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()
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" };
|
||||
if (_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument { FileName = dialog.FileName }))
|
||||
{
|
||||
MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ошибка при создании документа",
|
||||
"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void CreateTableDoc()
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (_plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument()))
|
||||
{
|
||||
MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ошибка при создании документа",
|
||||
"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void CreateChartDoc()
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
|
||||
if (_plugins[_selectedPlugin].CreateChartDocument(new
|
||||
PluginsConventionSaveDocument()))
|
||||
{
|
||||
MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ошибка при создании документа",
|
||||
"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
72
UniversityView/FormMainPlugins.resx
Normal file
72
UniversityView/FormMainPlugins.resx
Normal file
@ -0,0 +1,72 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="excelComponent1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>125, 17</value>
|
||||
</metadata>
|
||||
<metadata name="gistogramPdfComponent31.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>275, 17</value>
|
||||
</metadata>
|
||||
<metadata name="componentWord21.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>478, 17</value>
|
||||
</metadata>
|
||||
</root>
|
43
UniversityView/PluginsManager.cs
Normal file
43
UniversityView/PluginsManager.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using PluginsConventionLibrary.Plugins;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.ComponentModel.Composition.Hosting;
|
||||
|
||||
namespace UniversityView
|
||||
{
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
using System;
|
||||
using UniversityBusinessLogic.BusinessLogics;
|
||||
using UniversityContracts.BusinessLogicsContracts;
|
||||
using UniversityContracts.StoragesContracts;
|
||||
@ -21,7 +20,7 @@ namespace UniversityView
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMainPlugins>());
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
@ -35,9 +34,9 @@ namespace UniversityView
|
||||
services.AddTransient<IStudentStorage, StudentStorage>();
|
||||
services.AddTransient<IDirectionLogic, DirectionLogic>();
|
||||
services.AddTransient<IStudentLogic, StudentLogic>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormStudent>();
|
||||
services.AddTransient<FormHandbooks>();
|
||||
services.AddTransient<FormMainPlugins>();
|
||||
//services.AddTransient<FormStudent>();
|
||||
//services.AddTransient<FormHandbooks>();
|
||||
}
|
||||
}
|
||||
}
|
@ -18,11 +18,13 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
|
||||
<PackageReference Include="NLog" Version="5.2.5" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" />
|
||||
<PackageReference Include="System.ComponentModel.Composition" Version="7.0.0" />
|
||||
<PackageReference Include="WinFormsControlLibrary" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\COP\COP.csproj" />
|
||||
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||
<ProjectReference Include="..\UniversityBusinessLogic\UniversityBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\UniversityContracts\UniversityContracts.csproj" />
|
||||
<ProjectReference Include="..\UniversityDatabaseImplement\UniversityDatabaseImplement.csproj" />
|
||||
|
Loading…
Reference in New Issue
Block a user