Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
a9cace146f | |||
b87b2493c8 | |||
36b3dccf49 | |||
334111d632 | |||
34bf359bc0 | |||
b4a8359199 | |||
6999216c4a | |||
6a5d109bba | |||
0acc57f87e |
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,6 +4,8 @@
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||
|
||||
*.dll
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
|
28
COP/AppByPlugins/AppByPlugins.csproj
Normal file
28
COP/AppByPlugins/AppByPlugins.csproj
Normal file
@ -0,0 +1,28 @@
|
||||
<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="Microsoft.EntityFrameworkCore.Design" Version="7.0.20">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
|
||||
<PackageReference Include="System.Text.Encodings.Web" Version="7.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="7.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ClientsDatabaseImplement\ClientsDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
173
COP/AppByPlugins/FormMain.Designer.cs
generated
Normal file
173
COP/AppByPlugins/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,173 @@
|
||||
namespace AppByPlugins
|
||||
{
|
||||
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()
|
||||
{
|
||||
menuStrip = new MenuStrip();
|
||||
ControlsStripMenuItem = new ToolStripMenuItem();
|
||||
ActionsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ThesaurusToolStripMenuItem = new ToolStripMenuItem();
|
||||
AddElementToolStripMenuItem = new ToolStripMenuItem();
|
||||
UpdElementToolStripMenuItem = new ToolStripMenuItem();
|
||||
DelElementToolStripMenuItem = new ToolStripMenuItem();
|
||||
DocsToolStripMenuItem = new ToolStripMenuItem();
|
||||
SimpleDocToolStripMenuItem = new ToolStripMenuItem();
|
||||
TableDocToolStripMenuItem = new ToolStripMenuItem();
|
||||
ChartDocToolStripMenuItem = new ToolStripMenuItem();
|
||||
panelControl = new Panel();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { ControlsStripMenuItem, ActionsToolStripMenuItem, DocsToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(800, 24);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "Меню";
|
||||
//
|
||||
// ControlsStripMenuItem
|
||||
//
|
||||
ControlsStripMenuItem.Name = "ControlsStripMenuItem";
|
||||
ControlsStripMenuItem.Size = new Size(90, 20);
|
||||
ControlsStripMenuItem.Text = "Компоненты";
|
||||
//
|
||||
// ActionsToolStripMenuItem
|
||||
//
|
||||
ActionsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ThesaurusToolStripMenuItem, AddElementToolStripMenuItem, UpdElementToolStripMenuItem, DelElementToolStripMenuItem });
|
||||
ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem";
|
||||
ActionsToolStripMenuItem.Size = new Size(70, 20);
|
||||
ActionsToolStripMenuItem.Text = "Действия";
|
||||
//
|
||||
// ThesaurusToolStripMenuItem
|
||||
//
|
||||
ThesaurusToolStripMenuItem.Name = "ThesaurusToolStripMenuItem";
|
||||
ThesaurusToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.I;
|
||||
ThesaurusToolStripMenuItem.Size = new Size(180, 22);
|
||||
ThesaurusToolStripMenuItem.Text = "Справочник";
|
||||
ThesaurusToolStripMenuItem.Click += ThesaurusToolStripMenuItem_Click;
|
||||
//
|
||||
// AddElementToolStripMenuItem
|
||||
//
|
||||
AddElementToolStripMenuItem.Name = "AddElementToolStripMenuItem";
|
||||
AddElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
|
||||
AddElementToolStripMenuItem.Size = new Size(180, 22);
|
||||
AddElementToolStripMenuItem.Text = "Добавить";
|
||||
AddElementToolStripMenuItem.Click += AddElementToolStripMenuItem_Click;
|
||||
//
|
||||
// UpdElementToolStripMenuItem
|
||||
//
|
||||
UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
|
||||
UpdElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U;
|
||||
UpdElementToolStripMenuItem.Size = new Size(180, 22);
|
||||
UpdElementToolStripMenuItem.Text = "Изменить";
|
||||
UpdElementToolStripMenuItem.Click += UpdElementToolStripMenuItem_Click;
|
||||
//
|
||||
// DelElementToolStripMenuItem
|
||||
//
|
||||
DelElementToolStripMenuItem.Name = "DelElementToolStripMenuItem";
|
||||
DelElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
|
||||
DelElementToolStripMenuItem.Size = new Size(180, 22);
|
||||
DelElementToolStripMenuItem.Text = "Удалить";
|
||||
DelElementToolStripMenuItem.Click += DelElementToolStripMenuItem_Click;
|
||||
//
|
||||
// DocsToolStripMenuItem
|
||||
//
|
||||
DocsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SimpleDocToolStripMenuItem, TableDocToolStripMenuItem, ChartDocToolStripMenuItem });
|
||||
DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
|
||||
DocsToolStripMenuItem.Size = new Size(82, 20);
|
||||
DocsToolStripMenuItem.Text = "Документы";
|
||||
//
|
||||
// SimpleDocToolStripMenuItem
|
||||
//
|
||||
SimpleDocToolStripMenuItem.Name = "SimpleDocToolStripMenuItem";
|
||||
SimpleDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||
SimpleDocToolStripMenuItem.Size = new Size(233, 22);
|
||||
SimpleDocToolStripMenuItem.Text = "Простой документ";
|
||||
SimpleDocToolStripMenuItem.Click += SimpleDocToolStripMenuItem_Click;
|
||||
//
|
||||
// TableDocToolStripMenuItem
|
||||
//
|
||||
TableDocToolStripMenuItem.Name = "TableDocToolStripMenuItem";
|
||||
TableDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
|
||||
TableDocToolStripMenuItem.Size = new Size(233, 22);
|
||||
TableDocToolStripMenuItem.Text = "Документ с таблицой";
|
||||
TableDocToolStripMenuItem.Click += TableDocToolStripMenuItem_Click;
|
||||
//
|
||||
// ChartDocToolStripMenuItem
|
||||
//
|
||||
ChartDocToolStripMenuItem.Name = "ChartDocToolStripMenuItem";
|
||||
ChartDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
|
||||
ChartDocToolStripMenuItem.Size = new Size(233, 22);
|
||||
ChartDocToolStripMenuItem.Text = "Документ с диаграммой";
|
||||
ChartDocToolStripMenuItem.Click += ChartDocToolStripMenuItem_Click;
|
||||
//
|
||||
// panelControl
|
||||
//
|
||||
panelControl.Dock = DockStyle.Fill;
|
||||
panelControl.Location = new Point(0, 24);
|
||||
panelControl.Name = "panelControl";
|
||||
panelControl.Size = new Size(800, 426);
|
||||
panelControl.TabIndex = 1;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(panelControl);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormMain";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Главная форма";
|
||||
WindowState = FormWindowState.Maximized;
|
||||
KeyDown += FormMain_KeyDown;
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
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;
|
||||
}
|
||||
}
|
225
COP/AppByPlugins/FormMain.cs
Normal file
225
COP/AppByPlugins/FormMain.cs
Normal file
@ -0,0 +1,225 @@
|
||||
using PluginsConventionLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AppByPlugins
|
||||
{
|
||||
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()
|
||||
{
|
||||
var plugins = new Dictionary<string, IPluginsConvention>();
|
||||
|
||||
string pluginsDir = Directory.GetParent(Directory.GetCurrentDirectory())!.Parent!.Parent!.Parent!.FullName + "\\Plugins";
|
||||
|
||||
string[] dllFiles = Directory.GetFiles(pluginsDir, "*.dll", SearchOption.AllDirectories);
|
||||
|
||||
foreach (string dllFile in dllFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Assembly assembly = Assembly.LoadFrom(dllFile);
|
||||
Type[] types = assembly.GetTypes();
|
||||
|
||||
foreach (var type in types)
|
||||
{
|
||||
|
||||
if (typeof(IPluginsConvention).IsAssignableFrom(type) && !type.IsInterface)
|
||||
{
|
||||
var plugin = (IPluginsConvention)Activator.CreateInstance(type)!;
|
||||
plugins.Add(plugin.PluginName, plugin);
|
||||
CreateMenuItem(plugin.PluginName);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Ошибка при загрузке сборки {dllFile}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
return plugins;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void CreateMenuItem(string pluginName)
|
||||
{
|
||||
ToolStripMenuItem menuItem = new(pluginName);
|
||||
menuItem.Click += (object? sender, EventArgs e) =>
|
||||
{
|
||||
UserControl userControl = _plugins[pluginName].GetControl;
|
||||
if (userControl != null)
|
||||
{
|
||||
panelControl.Controls.Clear();
|
||||
userControl.Dock = DockStyle.Fill;
|
||||
_plugins[pluginName].ReloadData();
|
||||
_selectedPlugin = pluginName;
|
||||
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()
|
||||
{
|
||||
Filter = "Word Files|*.docx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||
|
||||
}
|
||||
}
|
||||
private void CreateTableDoc()
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "PDF Files|*.pdf"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||
|
||||
}
|
||||
}
|
||||
private void CreateChartDoc()
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "Excel Files|*.xlsx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].CreateChartDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
120
COP/AppByPlugins/FormMain.resx
Normal file
120
COP/AppByPlugins/FormMain.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>
|
17
COP/AppByPlugins/Program.cs
Normal file
17
COP/AppByPlugins/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace AppByPlugins
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
20
COP/BulatovaComponents/BulatovaComponents.csproj
Normal file
20
COP/BulatovaComponents/BulatovaComponents.csproj
Normal file
@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
<Version>$(VersionPrefix)1.0.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspose.Words" Version="24.10.0" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.0" />
|
||||
<PackageReference Include="Microsoft.Office.Interop.Excel" Version="15.0.4795.1001" />
|
||||
<PackageReference Include="Microsoft.Office.Interop.Word" Version="15.0.4797.1004" />
|
||||
<PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
58
COP/BulatovaComponents/Components/ComboBoxControl.Designer.cs
generated
Normal file
58
COP/BulatovaComponents/Components/ComboBoxControl.Designer.cs
generated
Normal file
@ -0,0 +1,58 @@
|
||||
namespace BulatovaComponents.Components
|
||||
{
|
||||
partial class ComboBoxControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.comboBoxCustom = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// comboBoxCustom
|
||||
//
|
||||
this.comboBoxCustom.FormattingEnabled = true;
|
||||
this.comboBoxCustom.Location = new System.Drawing.Point(3, 3);
|
||||
this.comboBoxCustom.Name = "comboBoxCustom";
|
||||
this.comboBoxCustom.Size = new System.Drawing.Size(321, 28);
|
||||
this.comboBoxCustom.TabIndex = 0;
|
||||
this.comboBoxCustom.SelectedIndexChanged += new System.EventHandler(this.comboBoxCustom_SelectedIndexChanged);
|
||||
//
|
||||
// ComboBoxControl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.comboBoxCustom);
|
||||
this.Name = "ComboBoxControl";
|
||||
this.Size = new System.Drawing.Size(328, 35);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBoxCustom;
|
||||
}
|
||||
}
|
54
COP/BulatovaComponents/Components/ComboBoxControl.cs
Normal file
54
COP/BulatovaComponents/Components/ComboBoxControl.cs
Normal file
@ -0,0 +1,54 @@
|
||||
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;
|
||||
|
||||
namespace BulatovaComponents.Components
|
||||
{
|
||||
public partial class ComboBoxControl : UserControl
|
||||
{
|
||||
public ComboBoxControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public string SelectedValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return comboBoxCustom.SelectedItem != null ? comboBoxCustom.SelectedItem.ToString() : "";
|
||||
}
|
||||
set
|
||||
{
|
||||
if (comboBoxCustom.Items.Contains(value)) //если есть такой элемент, то помечаем, если нет, ничего не делаем
|
||||
{
|
||||
comboBoxCustom.SelectedItem = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event Action<string?> SelectedValueChange;
|
||||
|
||||
public void addItems(List<string> items)
|
||||
{
|
||||
foreach (string item in items)
|
||||
{
|
||||
comboBoxCustom.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
comboBoxCustom.Items.Clear();
|
||||
}
|
||||
|
||||
private void comboBoxCustom_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
SelectedValueChange?.Invoke(comboBoxCustom.SelectedItem.ToString());
|
||||
}
|
||||
}
|
||||
}
|
120
COP/BulatovaComponents/Components/ComboBoxControl.resx
Normal file
120
COP/BulatovaComponents/Components/ComboBoxControl.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>
|
58
COP/BulatovaComponents/Components/ListBoxControl.Designer.cs
generated
Normal file
58
COP/BulatovaComponents/Components/ListBoxControl.Designer.cs
generated
Normal file
@ -0,0 +1,58 @@
|
||||
namespace BulatovaComponents.Components
|
||||
{
|
||||
partial class ListBoxControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.listBox = new System.Windows.Forms.ListBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// listBox
|
||||
//
|
||||
this.listBox.FormattingEnabled = true;
|
||||
this.listBox.ItemHeight = 20;
|
||||
this.listBox.Location = new System.Drawing.Point(0, 8);
|
||||
this.listBox.Name = "listBox";
|
||||
this.listBox.Size = new System.Drawing.Size(599, 224);
|
||||
this.listBox.TabIndex = 0;
|
||||
//
|
||||
// ListBoxControl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.listBox);
|
||||
this.Name = "ListBoxControl";
|
||||
this.Size = new System.Drawing.Size(599, 250);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ListBox listBox;
|
||||
}
|
||||
}
|
89
COP/BulatovaComponents/Components/ListBoxControl.cs
Normal file
89
COP/BulatovaComponents/Components/ListBoxControl.cs
Normal file
@ -0,0 +1,89 @@
|
||||
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;
|
||||
|
||||
namespace BulatovaComponents.Components
|
||||
{
|
||||
public partial class ListBoxControl : UserControl
|
||||
{
|
||||
public ListBoxControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public string? template;
|
||||
public char? fromChar;
|
||||
public char? toChar;
|
||||
|
||||
public void setItems<T>(List<T> items)
|
||||
where T : class
|
||||
{
|
||||
if (template == null || !fromChar.HasValue || !toChar.HasValue) throw new ArgumentException("Не хватает данных!");
|
||||
listBox.Items.Clear();
|
||||
var type = typeof(T);
|
||||
var fields = type.GetFields();
|
||||
foreach (T item in items)
|
||||
{
|
||||
string result = template;
|
||||
foreach (var field in fields)
|
||||
{
|
||||
string search = fromChar.Value + field.Name + toChar.Value;
|
||||
result = result.Replace(search, field.GetValue(item).ToString());
|
||||
}
|
||||
listBox.Items.Add(result);
|
||||
}
|
||||
}
|
||||
|
||||
public T? getSelectedItem<T>()
|
||||
{
|
||||
if (template == null || !fromChar.HasValue || !toChar.HasValue || listBox.SelectedIndex == -1) throw new ArgumentException("Не хватает данных!");
|
||||
var type = typeof(T);
|
||||
var fields = type.GetFields();
|
||||
|
||||
var item = Activator.CreateInstance(type);
|
||||
|
||||
string[] wordsTemplate = template.Split(' ');
|
||||
string[] words = listBox.SelectedItem.ToString().Split(' ');
|
||||
for (int i = 0; i < wordsTemplate.Length; i++)
|
||||
{
|
||||
string word = wordsTemplate[i];
|
||||
if (word.StartsWith(fromChar.Value))
|
||||
{
|
||||
string fieldName = word.Substring(1, word.Length - 2);
|
||||
var field = fields.FirstOrDefault(x => x.Name == fieldName);
|
||||
if (field == null) continue;
|
||||
int indexBefore = i > 0 ? Array.IndexOf(words, wordsTemplate[i - 1]) : -1;
|
||||
int indexAfter = i < wordsTemplate.Length - 1 ? Array.IndexOf(words, wordsTemplate[i + 1]) : wordsTemplate.Length - 1;
|
||||
var fieldValue = String.Join(' ', words.Skip(indexBefore + 1).Take(indexAfter - indexBefore - 1).ToArray());
|
||||
field.SetValue(item, Convert.ChangeType(fieldValue, field.FieldType));
|
||||
}
|
||||
}
|
||||
|
||||
return item != null ? (T)item : default(T);
|
||||
}
|
||||
|
||||
public int SelectedIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return listBox.SelectedIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
listBox.SelectedIndex = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void setParams(string template, char fromChar, char toChar)
|
||||
{
|
||||
this.template = template;
|
||||
this.fromChar = fromChar;
|
||||
this.toChar = toChar;
|
||||
}
|
||||
}
|
||||
}
|
120
COP/BulatovaComponents/Components/ListBoxControl.resx
Normal file
120
COP/BulatovaComponents/Components/ListBoxControl.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>
|
67
COP/BulatovaComponents/Components/MailControl.Designer.cs
generated
Normal file
67
COP/BulatovaComponents/Components/MailControl.Designer.cs
generated
Normal file
@ -0,0 +1,67 @@
|
||||
namespace BulatovaComponents.Components
|
||||
{
|
||||
partial class MailControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.textBoxMail = new System.Windows.Forms.TextBox();
|
||||
this.toolTipEmail = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxMail
|
||||
//
|
||||
this.textBoxMail.Location = new System.Drawing.Point(3, 3);
|
||||
this.textBoxMail.Name = "textBoxMail";
|
||||
this.textBoxMail.Size = new System.Drawing.Size(257, 27);
|
||||
this.textBoxMail.TabIndex = 0;
|
||||
this.textBoxMail.TextChanged += new System.EventHandler(this.textBoxMail_TextChanged);
|
||||
this.textBoxMail.MouseEnter += new System.EventHandler(this.textBoxMail_MouseEnter);
|
||||
//
|
||||
// toolTipEmail
|
||||
//
|
||||
this.toolTipEmail.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
|
||||
this.toolTipEmail.ToolTipTitle = "Пример ввода";
|
||||
//
|
||||
// MailControl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.textBoxMail);
|
||||
this.Name = "MailControl";
|
||||
this.Size = new System.Drawing.Size(264, 34);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxMail;
|
||||
private ToolTip toolTipEmail;
|
||||
}
|
||||
}
|
77
COP/BulatovaComponents/Components/MailControl.cs
Normal file
77
COP/BulatovaComponents/Components/MailControl.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BulatovaComponents.Components
|
||||
{
|
||||
public partial class MailControl : UserControl
|
||||
{
|
||||
public MailControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public Regex? validateEmailRegex
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public event Action<string> TextChange;
|
||||
private string? tooltipText;
|
||||
public string errorMessage = "";
|
||||
|
||||
|
||||
public string? Email
|
||||
{
|
||||
get
|
||||
{
|
||||
//не забыл ли пользователь ввести регулярку и соответствует ли она
|
||||
if (validateEmailRegex == null)
|
||||
{
|
||||
errorMessage = "Пустой шаблон!";
|
||||
return null;
|
||||
}
|
||||
else if (!validateEmailRegex.IsMatch(textBoxMail.Text))
|
||||
{
|
||||
errorMessage = "Некорректный адрес эл. почты!";
|
||||
return null;
|
||||
}
|
||||
else return textBoxMail.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (validateEmailRegex == null) errorMessage = "Пустой шаблон!";
|
||||
else if (!validateEmailRegex.IsMatch(value)) errorMessage = "Некорректный адрес эл. почты!";
|
||||
else
|
||||
{
|
||||
textBoxMail.Text = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void textBoxMail_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
TextChange?.Invoke(textBoxMail.Text);
|
||||
Email = textBoxMail.Text;
|
||||
}
|
||||
|
||||
public void setTooltipText(string text)
|
||||
{
|
||||
tooltipText = text;
|
||||
}
|
||||
|
||||
private void textBoxMail_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
toolTipEmail.Show(tooltipText ?? "", textBoxMail);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
120
COP/BulatovaComponents/Components/MailControl.resx
Normal file
120
COP/BulatovaComponents/Components/MailControl.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>
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace BulatovaComponents.Exceptions
|
||||
{
|
||||
[Serializable]
|
||||
public class NotMatchPatternException : ApplicationException
|
||||
{
|
||||
public NotMatchPatternException() : base() { }
|
||||
|
||||
public NotMatchPatternException(string message) : base(message) { }
|
||||
|
||||
public NotMatchPatternException(string message, Exception exception) : base(message, exception) { }
|
||||
|
||||
protected NotMatchPatternException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
21
COP/BulatovaComponents/Exceptions/NullPatternException.cs
Normal file
21
COP/BulatovaComponents/Exceptions/NullPatternException.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace BulatovaComponents.Exceptions
|
||||
{
|
||||
[Serializable]
|
||||
public class NullPatternException : ApplicationException
|
||||
{
|
||||
public NullPatternException() : base() { }
|
||||
|
||||
public NullPatternException(string message) : base(message) { }
|
||||
|
||||
public NullPatternException(string message, Exception exception) : base(message, exception) { }
|
||||
|
||||
protected NullPatternException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BulatovaComponents.NonVisualComponents
|
||||
{
|
||||
public enum DiagramLegendEnum
|
||||
{
|
||||
TopLeft = 0,
|
||||
TopRight = 1,
|
||||
BottomRight = 2,
|
||||
BottomLeft = 3,
|
||||
}
|
||||
}
|
36
COP/BulatovaComponents/NonVisualComponents/WordDiagramComponent.Designer.cs
generated
Normal file
36
COP/BulatovaComponents/NonVisualComponents/WordDiagramComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace BulatovaComponents.NonVisualComponents
|
||||
{
|
||||
partial class WordDiagramComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BulatovaComponents.NonVisualComponents
|
||||
{
|
||||
public partial class WordDiagramComponent : Component
|
||||
{
|
||||
public WordDiagramComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordDiagramComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private object missing = System.Reflection.Missing.Value;
|
||||
|
||||
private string GetExcelColumnName(int columnNumber)
|
||||
{
|
||||
string columnName = "";
|
||||
|
||||
while (columnNumber > 0)
|
||||
{
|
||||
int modulo = (columnNumber - 1) % 26;
|
||||
columnName = Convert.ToChar('A' + modulo) + columnName;
|
||||
columnNumber = (columnNumber - modulo) / 26;
|
||||
}
|
||||
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public void createWithDiagram<T>(string path, string title, string diagramTitle, DiagramLegendEnum diagramLegendAnchor, List<T> data, string seriesNameField, string valueField)
|
||||
{
|
||||
var excelApp = new Microsoft.Office.Interop.Excel.Application { SheetsInNewWorkbook = 1 };
|
||||
Workbook workbook = excelApp.Workbooks.Add(Type.Missing);
|
||||
Worksheet worksheet = (Worksheet)workbook.Worksheets.get_Item(1);
|
||||
|
||||
FieldInfo? seriesName = typeof(T).GetField(seriesNameField);
|
||||
FieldInfo? value = typeof(T).GetField(valueField);
|
||||
if (seriesName == null || value == null) throw new ArgumentException("Переданного поля не существует");
|
||||
int offsetX = 1;
|
||||
int offsetYMax = -1;
|
||||
foreach (var item in data)
|
||||
{
|
||||
string columnChar = GetExcelColumnName(offsetX);
|
||||
var cell = worksheet.get_Range(columnChar + "2", columnChar + "2");
|
||||
cell.Font.Size = 14;
|
||||
cell.Font.Name = "Times New Roman";
|
||||
cell.ColumnWidth = 8;
|
||||
cell.RowHeight = 25;
|
||||
cell.HorizontalAlignment = Constants.xlCenter;
|
||||
cell.VerticalAlignment = Constants.xlCenter;
|
||||
cell.Value2 = seriesName.GetValue(item);
|
||||
|
||||
int offsetY = 3;
|
||||
|
||||
foreach (var val in (value.GetValue(item) as IEnumerable))
|
||||
{
|
||||
cell = worksheet.get_Range(columnChar + offsetY, columnChar + offsetY);
|
||||
cell.Value2 = val;
|
||||
|
||||
offsetY++;
|
||||
}
|
||||
if (offsetY > offsetYMax) offsetYMax = offsetY;
|
||||
|
||||
offsetX++;
|
||||
}
|
||||
|
||||
var charts = worksheet.ChartObjects() as ChartObjects;
|
||||
int chartWidth = 300;
|
||||
int chartHeight = 300;
|
||||
var chartObject = charts.Add(250, 10, chartWidth, chartHeight);
|
||||
var chart = chartObject.Chart;
|
||||
var endColumn = GetExcelColumnName(offsetX - 1);
|
||||
var range = worksheet.get_Range($"A2", endColumn + (offsetYMax - 1));
|
||||
chart.SetSourceData(range);
|
||||
chart.ChartType = XlChartType.xlLine;
|
||||
switch (diagramLegendAnchor)
|
||||
{
|
||||
case DiagramLegendEnum.TopLeft:
|
||||
chart.Legend.Top = 0;
|
||||
chart.Legend.Left = 0;
|
||||
break;
|
||||
case DiagramLegendEnum.TopRight:
|
||||
chart.Legend.Top = 0;
|
||||
chart.Legend.Left = chartWidth - chart.Legend.Width;
|
||||
break;
|
||||
case DiagramLegendEnum.BottomLeft:
|
||||
chart.Legend.Top = chartHeight - chart.Legend.Height;
|
||||
chart.Legend.Left = 0;
|
||||
break;
|
||||
case DiagramLegendEnum.BottomRight:
|
||||
chart.Legend.Top = chartHeight - chart.Legend.Height;
|
||||
chart.Legend.Left = chartWidth - chart.Legend.Width;
|
||||
break;
|
||||
}
|
||||
chart.ChartWizard(Source: range, Title: diagramTitle);
|
||||
|
||||
chart.Export(path.Substring(0, path.Length - 5) + ".jpg", "JPG", false);
|
||||
|
||||
workbook.Close(SaveChanges: false);
|
||||
excelApp.Quit();
|
||||
|
||||
var winword = new Microsoft.Office.Interop.Word.Application();
|
||||
var document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing);
|
||||
document.PageSetup.RightMargin = 50;
|
||||
document.PageSetup.LeftMargin = 50;
|
||||
|
||||
var header = document.Content.Paragraphs.Add(Type.Missing);
|
||||
header.Range.Text = title;
|
||||
header.Format.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
|
||||
header.Range.Font.Name = "Times New Roman";
|
||||
header.Range.Font.Size = 22;
|
||||
header.Range.Font.Bold = 2;
|
||||
header.Format.SpaceAfter = 18;
|
||||
header.Range.InsertParagraphAfter();
|
||||
|
||||
document.Shapes.AddPicture(path.Substring(0, path.Length - 5) + ".jpg", Top: 200);
|
||||
|
||||
document.SaveAs(path, Type.Missing, Type.Missing, Type.Missing,
|
||||
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
|
||||
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
|
||||
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
|
||||
document.Close(ref missing, ref missing, ref missing);
|
||||
document = null;
|
||||
winword.Quit(ref missing, ref missing, ref missing);
|
||||
}
|
||||
}
|
||||
}
|
36
COP/BulatovaComponents/NonVisualComponents/WordLongTextComponent.Designer.cs
generated
Normal file
36
COP/BulatovaComponents/NonVisualComponents/WordLongTextComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace BulatovaComponents.NonVisualComponents
|
||||
{
|
||||
partial class WordLongTextComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BulatovaComponents.NonVisualComponents
|
||||
{
|
||||
public partial class WordLongTextComponent : Component
|
||||
{
|
||||
public WordLongTextComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordLongTextComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private object missing = System.Reflection.Missing.Value;
|
||||
|
||||
public void createWithLongText(WordLongTextInfo wordInfo)
|
||||
{
|
||||
var winword = new Microsoft.Office.Interop.Word.Application();
|
||||
var document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing);
|
||||
document.PageSetup.RightMargin = 50;
|
||||
document.PageSetup.LeftMargin = 50;
|
||||
|
||||
var header = document.Content.Paragraphs.Add(Type.Missing);
|
||||
header.Range.Text = wordInfo.header;
|
||||
header.Format.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
|
||||
header.Range.Font.Name = "Times New Roman";
|
||||
header.Range.Font.Size = 22;
|
||||
header.Range.Font.Bold = 2;
|
||||
header.Format.SpaceAfter = 18;
|
||||
header.Range.InsertParagraphAfter();
|
||||
|
||||
foreach (string text in wordInfo.paragraphs)
|
||||
{
|
||||
var paragraph = document.Content.Paragraphs.Add(Type.Missing);
|
||||
paragraph.Range.Text = text;
|
||||
paragraph.Format.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
|
||||
paragraph.Range.Font.Name = "Times New Roman";
|
||||
paragraph.Range.Font.Size = 14;
|
||||
paragraph.Range.Font.Bold = 0;
|
||||
paragraph.Format.SpaceAfter = 18;
|
||||
paragraph.Range.InsertParagraphAfter();
|
||||
}
|
||||
|
||||
document.SaveAs(wordInfo.path, Type.Missing, Type.Missing, Type.Missing,
|
||||
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
|
||||
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
|
||||
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
|
||||
document.Close(ref missing, ref missing, ref missing);
|
||||
document = null;
|
||||
winword.Quit(ref missing, ref missing, ref missing);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BulatovaComponents.NonVisualComponents
|
||||
{
|
||||
public class WordLongTextInfo
|
||||
{
|
||||
public string path;
|
||||
public string header;
|
||||
public string[] paragraphs;
|
||||
|
||||
public WordLongTextInfo(string path, string header, string[] paragraphs)
|
||||
{
|
||||
this.path = path;
|
||||
this.header = header;
|
||||
this.paragraphs = paragraphs;
|
||||
}
|
||||
}
|
||||
}
|
36
COP/BulatovaComponents/NonVisualComponents/WordTableComponent.Designer.cs
generated
Normal file
36
COP/BulatovaComponents/NonVisualComponents/WordTableComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace BulatovaComponents.NonVisualComponents
|
||||
{
|
||||
partial class WordTableComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
170
COP/BulatovaComponents/NonVisualComponents/WordTableComponent.cs
Normal file
170
COP/BulatovaComponents/NonVisualComponents/WordTableComponent.cs
Normal file
@ -0,0 +1,170 @@
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BulatovaComponents.NonVisualComponents
|
||||
{
|
||||
public partial class WordTableComponent : Component
|
||||
{
|
||||
public WordTableComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordTableComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private object missing = System.Reflection.Missing.Value;
|
||||
|
||||
public void createWithTable<T>(string path, string title, List<(int, int)> merges, List<int> widths, List<(string, string)> headers, List<T> items)
|
||||
{
|
||||
if (merges.Count == 0 || widths.Count == 0 || headers.Count == 0 || items.Count == 0) throw new ArgumentException("Недостаточно данных");
|
||||
int[] cellsArray = new int[widths.Count];
|
||||
foreach (var merge in merges)
|
||||
{
|
||||
if (merge.Item1 >= merge.Item2) throw new ArgumentException("Неправильно заполнены объединения строк");
|
||||
for (int i = merge.Item1; i < merge.Item2 + 1; i++)
|
||||
{
|
||||
cellsArray[i]++;
|
||||
}
|
||||
}
|
||||
foreach (int cell in cellsArray)
|
||||
{
|
||||
if (cell > 1) throw new ArgumentException("Объединения заходят друг на друга");
|
||||
}
|
||||
|
||||
var winword = new Microsoft.Office.Interop.Word.Application();
|
||||
var document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing);
|
||||
document.PageSetup.RightMargin = 50;
|
||||
document.PageSetup.LeftMargin = 50;
|
||||
document.PageSetup.Orientation = WdOrientation.wdOrientLandscape;
|
||||
|
||||
var header = document.Content.Paragraphs.Add(Type.Missing);
|
||||
header.Range.Text = title;
|
||||
header.Format.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
|
||||
header.Range.Font.Name = "Times New Roman";
|
||||
header.Range.Font.Size = 22;
|
||||
header.Range.Font.Bold = 2;
|
||||
header.Format.SpaceAfter = 18;
|
||||
header.Range.InsertParagraphAfter();
|
||||
|
||||
var table = document.Tables.Add(document.Bookmarks.get_Item("\\endofdoc").Range,
|
||||
items.Count + 2, widths.Count, Type.Missing, Type.Missing);
|
||||
table.Borders.Enable = 1;
|
||||
|
||||
for (int i = 0; i < widths.Count; i++)
|
||||
{
|
||||
table.Cell(1, i + 1).Width = widths[i];
|
||||
table.Cell(1, i + 1).Height = 20;
|
||||
table.Cell(2, i + 1).Width = widths[i];
|
||||
table.Cell(2, i + 1).Height = 20;
|
||||
}
|
||||
|
||||
//checks
|
||||
List<Cell> ranges = new List<Cell>();
|
||||
foreach (var merge in merges)
|
||||
{
|
||||
ranges.Add(table.Rows[1].Cells[merge.Item1 + 1]);
|
||||
}
|
||||
|
||||
//number of merged cell
|
||||
int rangeIndex = 0;
|
||||
//number of cell
|
||||
int headerIndex = 0;
|
||||
List<PropertyInfo> cellProperties = new List<PropertyInfo>();
|
||||
var type = typeof(T);
|
||||
for (int i = 0; i < widths.Count; i++)
|
||||
{
|
||||
if (cellsArray[i] == 1)
|
||||
{
|
||||
//work with merge
|
||||
if (!string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
|
||||
|
||||
var headerCell = ranges[rangeIndex];
|
||||
headerCell.Range.Text = headers[headerIndex].Item2;
|
||||
headerCell.Range.Font.Size = 11;
|
||||
headerIndex++;
|
||||
|
||||
//work with cells in merge
|
||||
for (; i <= merges[rangeIndex].Item2; i++)
|
||||
{
|
||||
//work with cell
|
||||
if (string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
|
||||
var property = type.GetProperty(headers[headerIndex].Item1);
|
||||
if (property == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
|
||||
//format header
|
||||
var cell = table.Cell(2, i + 1);
|
||||
cell.Range.Text = headers[headerIndex].Item2;
|
||||
cell.Width = widths[i];
|
||||
cell.Range.Font.Size = 11;
|
||||
|
||||
cellProperties.Add(property);
|
||||
headerIndex++;
|
||||
}
|
||||
i--;
|
||||
rangeIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//work with cell
|
||||
if (string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
|
||||
var property = type.GetProperty(headers[headerIndex].Item1);
|
||||
if (property == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
|
||||
//format header
|
||||
var cell = table.Cell(1, i + 1);
|
||||
|
||||
cell.Merge(table.Cell(2, i + 1));
|
||||
cell.Range.Text = headers[headerIndex].Item2;
|
||||
cell.Width = widths[i];
|
||||
cell.Range.Font.Size = 11;
|
||||
|
||||
cellProperties.Add(property);
|
||||
headerIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
int xOffset = 0;
|
||||
foreach (var merge in merges)
|
||||
{
|
||||
table.Cell(1, merge.Item1 + 1 - xOffset).Merge(table.Cell(1, merge.Item2 + 1 - xOffset));
|
||||
xOffset += merge.Item2 - merge.Item1;
|
||||
}
|
||||
|
||||
int rowNum = 3;
|
||||
foreach (T item in items)
|
||||
{
|
||||
int columnNum = 1;
|
||||
foreach (var cellProperty in cellProperties)
|
||||
{
|
||||
var cell = table.Cell(rowNum, columnNum);
|
||||
cell.Range.Text = cellProperty.GetValue(item)?.ToString();
|
||||
cell.Width = widths[columnNum - 1];
|
||||
cell.Range.Bold = 0;
|
||||
cell.Range.Font.Size = 11;
|
||||
cell.Height = 20;
|
||||
|
||||
columnNum++;
|
||||
}
|
||||
rowNum++;
|
||||
}
|
||||
|
||||
document.SaveAs(path, Type.Missing, Type.Missing, Type.Missing,
|
||||
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
|
||||
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
|
||||
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
|
||||
document.Close(ref missing, ref missing, ref missing);
|
||||
document = null;
|
||||
winword.Quit(ref missing, ref missing, ref missing);
|
||||
}
|
||||
}
|
||||
}
|
73
COP/COP.sln
Normal file
73
COP/COP.sln
Normal file
@ -0,0 +1,73 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32825.248
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Components", "Components\Components.csproj", "{218522CC-CD60-403C-9B12-C683EEA06E32}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinForms", "WinForms\WinForms.csproj", "{AFFC45E9-4318-4446-89E4-FEB441CD92F0}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientBusinessLogic", "ClientBusinessLogic\ClientBusinessLogic.csproj", "{56A00FAB-A39A-4110-BBC5-F07CB0465A13}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientsContracts", "ClientsContracts\ClientsContracts.csproj", "{74DDFCEC-CE98-4A60-8EF6-ADEA8BB202CA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientsDatabaseImplement", "ClientsDatabaseImplement\ClientsDatabaseImplement.csproj", "{725F3378-1474-4195-9F76-B9C98690CC76}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BulatovaComponents", "BulatovaComponents\BulatovaComponents.csproj", "{A8DDA2DE-1B0C-4870-BA0B-BDE84B705B3E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientsDataModels", "ClientsDataModels\ClientsDataModels.csproj", "{83105892-317C-4442-B064-E489D2CFE39D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsConventionLibrary", "PluginsConventionLibrary\PluginsConventionLibrary.csproj", "{21F2683A-8624-4C9B-A765-2E7CCA8D8BBD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppByPlugins", "AppByPlugins\AppByPlugins.csproj", "{586FCB30-AC9A-4229-B7F7-3FB2ADF581B6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{218522CC-CD60-403C-9B12-C683EEA06E32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{218522CC-CD60-403C-9B12-C683EEA06E32}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{218522CC-CD60-403C-9B12-C683EEA06E32}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{218522CC-CD60-403C-9B12-C683EEA06E32}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AFFC45E9-4318-4446-89E4-FEB441CD92F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AFFC45E9-4318-4446-89E4-FEB441CD92F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AFFC45E9-4318-4446-89E4-FEB441CD92F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AFFC45E9-4318-4446-89E4-FEB441CD92F0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{56A00FAB-A39A-4110-BBC5-F07CB0465A13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{56A00FAB-A39A-4110-BBC5-F07CB0465A13}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{56A00FAB-A39A-4110-BBC5-F07CB0465A13}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{56A00FAB-A39A-4110-BBC5-F07CB0465A13}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{74DDFCEC-CE98-4A60-8EF6-ADEA8BB202CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{74DDFCEC-CE98-4A60-8EF6-ADEA8BB202CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{74DDFCEC-CE98-4A60-8EF6-ADEA8BB202CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{74DDFCEC-CE98-4A60-8EF6-ADEA8BB202CA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{725F3378-1474-4195-9F76-B9C98690CC76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{725F3378-1474-4195-9F76-B9C98690CC76}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{725F3378-1474-4195-9F76-B9C98690CC76}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{725F3378-1474-4195-9F76-B9C98690CC76}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A8DDA2DE-1B0C-4870-BA0B-BDE84B705B3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A8DDA2DE-1B0C-4870-BA0B-BDE84B705B3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A8DDA2DE-1B0C-4870-BA0B-BDE84B705B3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A8DDA2DE-1B0C-4870-BA0B-BDE84B705B3E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{83105892-317C-4442-B064-E489D2CFE39D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{83105892-317C-4442-B064-E489D2CFE39D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{83105892-317C-4442-B064-E489D2CFE39D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{83105892-317C-4442-B064-E489D2CFE39D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{21F2683A-8624-4C9B-A765-2E7CCA8D8BBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{21F2683A-8624-4C9B-A765-2E7CCA8D8BBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{21F2683A-8624-4C9B-A765-2E7CCA8D8BBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{21F2683A-8624-4C9B-A765-2E7CCA8D8BBD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{586FCB30-AC9A-4229-B7F7-3FB2ADF581B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{586FCB30-AC9A-4229-B7F7-3FB2ADF581B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{586FCB30-AC9A-4229-B7F7-3FB2ADF581B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{586FCB30-AC9A-4229-B7F7-3FB2ADF581B6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F5BF17EB-25A7-411A-9B3C-049D6C7E8C56}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
88
COP/ClientBusinessLogic/BusinessLogics/ClientLogic.cs
Normal file
88
COP/ClientBusinessLogic/BusinessLogics/ClientLogic.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.BusinessLogicContracts;
|
||||
using ClientsContracts.SearchModels;
|
||||
using ClientsContracts.StorageContracts;
|
||||
using ClientsContracts.ViewModels;
|
||||
|
||||
namespace ClientBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ClientLogic : IClientLogic
|
||||
{
|
||||
private readonly IClientStorage _clientStorage;
|
||||
|
||||
public ClientLogic(IClientStorage clientStorage)
|
||||
{
|
||||
_clientStorage = clientStorage;
|
||||
}
|
||||
|
||||
public bool Create(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_clientStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_clientStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ClientViewModel? ReadElement(ClientSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
var element = _clientStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||
{
|
||||
var list = _clientStorage.GetFullList();
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_clientStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ClientBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
throw new ArgumentNullException("Client's name is missing!", nameof(model.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
88
COP/ClientBusinessLogic/BusinessLogics/StatusLogic.cs
Normal file
88
COP/ClientBusinessLogic/BusinessLogics/StatusLogic.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.BusinessLogicContracts;
|
||||
using ClientsContracts.SearchModels;
|
||||
using ClientsContracts.StorageContracts;
|
||||
using ClientsContracts.ViewModels;
|
||||
|
||||
namespace ClientBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class StatusLogic : IStatusLogic
|
||||
{
|
||||
private readonly IStatusStorage _statusStorage;
|
||||
|
||||
public StatusLogic(IStatusStorage statusStorage)
|
||||
{
|
||||
_statusStorage = statusStorage;
|
||||
}
|
||||
|
||||
public bool Create(StatusBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_statusStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(StatusBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_statusStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public StatusViewModel? ReadElement(StatusSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
var element = _statusStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<StatusViewModel>? ReadList()
|
||||
{
|
||||
var list = _statusStorage.GetFullList();
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(StatusBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_statusStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(StatusBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.StatusName))
|
||||
{
|
||||
throw new ArgumentNullException("Status's name is missing!", nameof(model.StatusName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
14
COP/ClientBusinessLogic/ClientBusinessLogic.csproj
Normal file
14
COP/ClientBusinessLogic/ClientBusinessLogic.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ClientsContracts\ClientsContracts.csproj" />
|
||||
<ProjectReference Include="..\ClientsDataModels\ClientsDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
17
COP/ClientsContracts/BindingModels/ClientBindingModel.cs
Normal file
17
COP/ClientsContracts/BindingModels/ClientBindingModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClientsContracts.BindingModels
|
||||
{
|
||||
public class ClientBindingModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string? Reviews { get; set; } = string.Empty;
|
||||
public float? Amount { get; set; } = null;
|
||||
public int StatusId { get; set; }
|
||||
}
|
||||
}
|
14
COP/ClientsContracts/BindingModels/StatusBindingModel.cs
Normal file
14
COP/ClientsContracts/BindingModels/StatusBindingModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClientsContracts.BindingModels
|
||||
{
|
||||
public class StatusBindingModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string StatusName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
15
COP/ClientsContracts/BusinessLogicContracts/IClientLogic.cs
Normal file
15
COP/ClientsContracts/BusinessLogicContracts/IClientLogic.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.SearchModels;
|
||||
using ClientsContracts.ViewModels;
|
||||
|
||||
namespace ClientsContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IClientLogic
|
||||
{
|
||||
List<ClientViewModel>? ReadList(ClientSearchModel? model);
|
||||
ClientViewModel? ReadElement(ClientSearchModel model);
|
||||
bool Create(ClientBindingModel model);
|
||||
bool Update(ClientBindingModel model);
|
||||
bool Delete(ClientBindingModel model);
|
||||
}
|
||||
}
|
15
COP/ClientsContracts/BusinessLogicContracts/IStatusLogic.cs
Normal file
15
COP/ClientsContracts/BusinessLogicContracts/IStatusLogic.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.SearchModels;
|
||||
using ClientsContracts.ViewModels;
|
||||
|
||||
namespace ClientsContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IStatusLogic
|
||||
{
|
||||
List<StatusViewModel> ReadList();
|
||||
StatusViewModel? ReadElement(StatusSearchModel model);
|
||||
bool Create(StatusBindingModel model);
|
||||
bool Update(StatusBindingModel model);
|
||||
bool Delete(StatusBindingModel model);
|
||||
}
|
||||
}
|
13
COP/ClientsContracts/ClientsContracts.csproj
Normal file
13
COP/ClientsContracts/ClientsContracts.csproj
Normal 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="..\ClientsDataModels\ClientsDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
13
COP/ClientsContracts/SearchModels/ClientSearchModel.cs
Normal file
13
COP/ClientsContracts/SearchModels/ClientSearchModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClientsContracts.SearchModels
|
||||
{
|
||||
public class ClientSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
13
COP/ClientsContracts/SearchModels/StatusSearchModel.cs
Normal file
13
COP/ClientsContracts/SearchModels/StatusSearchModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClientsContracts.SearchModels
|
||||
{
|
||||
public class StatusSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
15
COP/ClientsContracts/StorageContracts/IClientStorage.cs
Normal file
15
COP/ClientsContracts/StorageContracts/IClientStorage.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.SearchModels;
|
||||
using ClientsContracts.ViewModels;
|
||||
|
||||
namespace ClientsContracts.StorageContracts
|
||||
{
|
||||
public interface IClientStorage
|
||||
{
|
||||
List<ClientViewModel> GetFullList();
|
||||
ClientViewModel? GetElement(ClientSearchModel model);
|
||||
ClientViewModel? Insert(ClientBindingModel model);
|
||||
ClientViewModel? Update(ClientBindingModel model);
|
||||
ClientViewModel? Delete(ClientBindingModel model);
|
||||
}
|
||||
}
|
15
COP/ClientsContracts/StorageContracts/IStatusStorage.cs
Normal file
15
COP/ClientsContracts/StorageContracts/IStatusStorage.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.SearchModels;
|
||||
using ClientsContracts.ViewModels;
|
||||
|
||||
namespace ClientsContracts.StorageContracts
|
||||
{
|
||||
public interface IStatusStorage
|
||||
{
|
||||
List<StatusViewModel> GetFullList();
|
||||
StatusViewModel? GetElement(StatusSearchModel model);
|
||||
StatusViewModel? Insert(StatusBindingModel model);
|
||||
StatusViewModel? Update(StatusBindingModel model);
|
||||
StatusViewModel? Delete(StatusBindingModel model);
|
||||
}
|
||||
}
|
21
COP/ClientsContracts/ViewModels/ClientViewModel.cs
Normal file
21
COP/ClientsContracts/ViewModels/ClientViewModel.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.ComponentModel;
|
||||
using ClientsDataModels.Models;
|
||||
|
||||
namespace ClientsContracts.ViewModels
|
||||
{
|
||||
public class ClientViewModel : IClientModel
|
||||
{
|
||||
public int Id { get; set; } = 0;
|
||||
[DisplayName("ФИО")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[DisplayName("Сумма покупок")]
|
||||
public float? Amount { get; set; } = null;
|
||||
[DisplayName("Отзывы")]
|
||||
public string? Reviews { get; set; } = string.Empty;
|
||||
public int StatusId { get; set; } = 0;
|
||||
[DisplayName("Статус")]
|
||||
public string StatusName { get; set; } = string.Empty;
|
||||
public string ViewAmount { get; set; } = string.Empty;
|
||||
public string DocAmount { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
18
COP/ClientsContracts/ViewModels/StatusViewModel.cs
Normal file
18
COP/ClientsContracts/ViewModels/StatusViewModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using ClientsContracts.BusinessLogicContracts;
|
||||
using ClientsDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClientsContracts.ViewModels
|
||||
{
|
||||
public class StatusViewModel : IStatusModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название")]
|
||||
public string StatusName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
9
COP/ClientsDataModels/ClientsDataModels.csproj
Normal file
9
COP/ClientsDataModels/ClientsDataModels.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
14
COP/ClientsDataModels/IId.cs
Normal file
14
COP/ClientsDataModels/IId.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClientsDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
|
||||
}
|
17
COP/ClientsDataModels/Models/IClientModel.cs
Normal file
17
COP/ClientsDataModels/Models/IClientModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClientsDataModels.Models
|
||||
{
|
||||
public interface IClientModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
float? Amount { get; }
|
||||
string? Reviews { get; }
|
||||
int StatusId { get; }
|
||||
}
|
||||
}
|
14
COP/ClientsDataModels/Models/IStatusModel.cs
Normal file
14
COP/ClientsDataModels/Models/IStatusModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClientsDataModels.Models
|
||||
{
|
||||
public interface IStatusModel : IId
|
||||
{
|
||||
string StatusName { get; }
|
||||
}
|
||||
}
|
22
COP/ClientsDatabaseImplement/ClientsDatabase.cs
Normal file
22
COP/ClientsDatabaseImplement/ClientsDatabase.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ClientsDatabaseImplement.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace ClientsDatabaseImplement
|
||||
{
|
||||
public class ClientsDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-1DE5E8N\SQLEXPRESS;Initial Catalog=ClientsDatabase2;
|
||||
Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
public virtual DbSet<Status> Statuses { set; get; }
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
}
|
||||
}
|
22
COP/ClientsDatabaseImplement/ClientsDatabaseImplement.csproj
Normal file
22
COP/ClientsDatabaseImplement/ClientsDatabaseImplement.csproj
Normal 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.20" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.20" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.20">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ClientsContracts\ClientsContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
68
COP/ClientsDatabaseImplement/Implements/ClientStorage.cs
Normal file
68
COP/ClientsDatabaseImplement/Implements/ClientStorage.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using ClientsContracts.StorageContracts;
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ClientsDatabaseImplement.Models;
|
||||
using ClientsContracts.SearchModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ClientsDatabaseImplement.Implements
|
||||
{
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
public List<ClientViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ClientsDatabase();
|
||||
return context.Clients.Include(x => x.Status)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new ClientsDatabase();
|
||||
return context.Clients.Include(x => x.Status)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
using var context = new ClientsDatabase();
|
||||
var newClient = Client.Create(model, context);
|
||||
if (newClient == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Clients.Add(newClient);
|
||||
context.SaveChanges();
|
||||
return newClient.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Update(ClientBindingModel model)
|
||||
{
|
||||
using var context = new ClientsDatabase();
|
||||
var client = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (client == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
client.Update(model);
|
||||
context.SaveChanges();
|
||||
return client.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Delete(ClientBindingModel model)
|
||||
{
|
||||
using var context = new ClientsDatabase();
|
||||
var element = context.Clients.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Clients.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
68
COP/ClientsDatabaseImplement/Implements/StatusStorage.cs
Normal file
68
COP/ClientsDatabaseImplement/Implements/StatusStorage.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using ClientsContracts.StorageContracts;
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ClientsDatabaseImplement.Models;
|
||||
using System.Data;
|
||||
using ClientsContracts.SearchModels;
|
||||
|
||||
namespace ClientsDatabaseImplement.Implements
|
||||
{
|
||||
public class StatusStorage : IStatusStorage
|
||||
{
|
||||
public List<StatusViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ClientsDatabase();
|
||||
return context.Statuses
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public StatusViewModel? GetElement(StatusSearchModel model)
|
||||
{
|
||||
using var context = new ClientsDatabase();
|
||||
return context.Statuses
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public StatusViewModel? Insert(StatusBindingModel model)
|
||||
{
|
||||
var newStatus = Status.Create(model);
|
||||
if (newStatus == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ClientsDatabase();
|
||||
context.Statuses.Add(newStatus);
|
||||
context.SaveChanges();
|
||||
return newStatus.GetViewModel;
|
||||
}
|
||||
|
||||
public StatusViewModel? Update(StatusBindingModel model)
|
||||
{
|
||||
using var context = new ClientsDatabase();
|
||||
var status = context.Statuses.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (status == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
status.Update(model);
|
||||
context.SaveChanges();
|
||||
return status.GetViewModel;
|
||||
}
|
||||
|
||||
public StatusViewModel? Delete(StatusBindingModel model)
|
||||
{
|
||||
using var context = new ClientsDatabase();
|
||||
var element = context.Statuses.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Statuses.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
86
COP/ClientsDatabaseImplement/Migrations/20241028162549_InitialCreate.Designer.cs
generated
Normal file
86
COP/ClientsDatabaseImplement/Migrations/20241028162549_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,86 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ClientsDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ClientsDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ClientsDatabase))]
|
||||
[Migration("20241028162549_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.20")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ClientsDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<float?>("Amount")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Reviews")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("StatusId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StatusId");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClientsDatabaseImplement.Models.Status", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("StatusName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Statuses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClientsDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.HasOne("ClientsDatabaseImplement.Models.Status", "Status")
|
||||
.WithMany()
|
||||
.HasForeignKey("StatusId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Status");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ClientsDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Statuses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
StatusName = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Statuses", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
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),
|
||||
Reviews = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Amount = table.Column<float>(type: "real", nullable: true),
|
||||
StatusId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Clients_Statuses_StatusId",
|
||||
column: x => x.StatusId,
|
||||
principalTable: "Statuses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Clients_StatusId",
|
||||
table: "Clients",
|
||||
column: "StatusId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Statuses");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ClientsDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ClientsDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ClientsDatabase))]
|
||||
partial class ClientsDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.20")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ClientsDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<float?>("Amount")
|
||||
.HasColumnType("real");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Reviews")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("StatusId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StatusId");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClientsDatabaseImplement.Models.Status", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("StatusName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Statuses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClientsDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.HasOne("ClientsDatabaseImplement.Models.Status", "Status")
|
||||
.WithMany()
|
||||
.HasForeignKey("StatusId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Status");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
59
COP/ClientsDatabaseImplement/Models/Client.cs
Normal file
59
COP/ClientsDatabaseImplement/Models/Client.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ClientsDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data;
|
||||
|
||||
namespace ClientsDatabaseImplement.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
public string? Reviews { get; set; } = null;
|
||||
public float? Amount { get; set; } = null;
|
||||
[Required]
|
||||
public int StatusId { get; set; }
|
||||
public virtual Status Status { get; set; } = new();
|
||||
|
||||
|
||||
public static Client? Create(ClientBindingModel? model, ClientsDatabase context)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Client()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Reviews = model.Reviews,
|
||||
Amount = model.Amount,
|
||||
StatusId = model.StatusId,
|
||||
Status = context.Statuses.First(x => x.Id == model.StatusId),
|
||||
};
|
||||
}
|
||||
public void Update(ClientBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Name = model.Name;
|
||||
Reviews = model.Reviews;
|
||||
Amount = model.Amount;
|
||||
}
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Reviews = Reviews,
|
||||
Amount = Amount,
|
||||
StatusId = StatusId,
|
||||
StatusName = Status.StatusName,
|
||||
};
|
||||
|
||||
}
|
||||
}
|
49
COP/ClientsDatabaseImplement/Models/Status.cs
Normal file
49
COP/ClientsDatabaseImplement/Models/Status.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ClientsDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ClientsDatabaseImplement.Models
|
||||
{
|
||||
public class Status : IStatusModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string StatusName { get; private set; } = string.Empty;
|
||||
|
||||
public static Status? Create(StatusBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Status()
|
||||
{
|
||||
Id = model.Id,
|
||||
StatusName = model.StatusName,
|
||||
};
|
||||
}
|
||||
public static Status Create(StatusViewModel model)
|
||||
{
|
||||
return new Status
|
||||
{
|
||||
Id = model.Id,
|
||||
StatusName = model.StatusName,
|
||||
};
|
||||
}
|
||||
public void Update(StatusBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
StatusName = model.StatusName;
|
||||
}
|
||||
public StatusViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
StatusName = StatusName,
|
||||
};
|
||||
|
||||
}
|
||||
}
|
17
COP/Components/Components.csproj
Normal file
17
COP/Components/Components.csproj
Normal file
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspose.Words" Version="24.9.0" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.0" />
|
||||
<PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
59
COP/Components/Components/UserDropDownList.Designer.cs
generated
Normal file
59
COP/Components/Components/UserDropDownList.Designer.cs
generated
Normal file
@ -0,0 +1,59 @@
|
||||
namespace Components.Components
|
||||
{
|
||||
partial class UserDropDownList
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dropDownList = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dropDownList
|
||||
//
|
||||
this.dropDownList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.dropDownList.FormattingEnabled = true;
|
||||
this.dropDownList.Location = new System.Drawing.Point(3, 3);
|
||||
this.dropDownList.Name = "dropDownList";
|
||||
this.dropDownList.Size = new System.Drawing.Size(187, 24);
|
||||
this.dropDownList.TabIndex = 0;
|
||||
this.dropDownList.SelectedValueChanged += new System.EventHandler(this.comboBox_SelectedValueChanged);
|
||||
//
|
||||
// UserDropDownList
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.dropDownList);
|
||||
this.Name = "UserDropDownList";
|
||||
this.Size = new System.Drawing.Size(193, 30);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ComboBox dropDownList;
|
||||
}
|
||||
}
|
65
COP/Components/Components/UserDropDownList.cs
Normal file
65
COP/Components/Components/UserDropDownList.cs
Normal file
@ -0,0 +1,65 @@
|
||||
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;
|
||||
|
||||
namespace Components.Components
|
||||
{
|
||||
public partial class UserDropDownList : UserControl
|
||||
{
|
||||
public UserDropDownList()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public void LoadValues(List<string> Values)
|
||||
{
|
||||
if (Values.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
dropDownList.Items.AddRange(Values.ToArray());
|
||||
}
|
||||
public void Clear()
|
||||
{
|
||||
dropDownList.Items.Clear();
|
||||
}
|
||||
|
||||
public string SelectedValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return dropDownList.SelectedItem?.ToString() ?? string.Empty;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (dropDownList.Items.Contains(value))
|
||||
{
|
||||
dropDownList.SelectedItem = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private EventHandler onValueChanged;
|
||||
public event EventHandler ValueChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
onValueChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
onValueChanged -= value;
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
onValueChanged?.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
60
COP/Components/Components/UserDropDownList.resx
Normal file
60
COP/Components/Components/UserDropDownList.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
59
COP/Components/Components/UserEmailTextBox.Designer.cs
generated
Normal file
59
COP/Components/Components/UserEmailTextBox.Designer.cs
generated
Normal file
@ -0,0 +1,59 @@
|
||||
namespace Components.Components
|
||||
{
|
||||
partial class UserEmailTextBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.emailTextBox = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// emailTextBox
|
||||
//
|
||||
this.emailTextBox.Location = new System.Drawing.Point(3, 3);
|
||||
this.emailTextBox.Name = "emailTextBox";
|
||||
this.emailTextBox.Size = new System.Drawing.Size(170, 22);
|
||||
this.emailTextBox.TabIndex = 0;
|
||||
this.emailTextBox.TextChanged += new System.EventHandler(this.textBox_TextChanged);
|
||||
this.emailTextBox.Enter += new System.EventHandler(this.textBox_Enter);
|
||||
//
|
||||
// UserEmailTextBox
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.emailTextBox);
|
||||
this.Name = "UserEmailTextBox";
|
||||
this.Size = new System.Drawing.Size(177, 30);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox emailTextBox;
|
||||
}
|
||||
}
|
125
COP/Components/Components/UserEmailTextBox.cs
Normal file
125
COP/Components/Components/UserEmailTextBox.cs
Normal file
@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Components.Exceptions;
|
||||
|
||||
namespace Components.Components
|
||||
{
|
||||
public partial class UserEmailTextBox : UserControl
|
||||
{
|
||||
private string pattern;
|
||||
|
||||
private string example = "example@yandex.ru";
|
||||
public UserEmailTextBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
emailTextBox.Enter += textBox_Enter;
|
||||
emailTextBox.TextChanged += textBox_TextChanged;
|
||||
}
|
||||
|
||||
public string Pattern
|
||||
{
|
||||
get { return pattern; }
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
throw new NullPatternException("Шаблон не может быть нулевым или пустым");
|
||||
}
|
||||
pattern = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string TextBoxValue
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(Pattern))
|
||||
{
|
||||
throw new NullPatternException("Шаблон не задан");
|
||||
}
|
||||
|
||||
Regex rg = new Regex(Pattern);
|
||||
bool address = rg.IsMatch(emailTextBox.Text);
|
||||
if (address)
|
||||
{
|
||||
return emailTextBox.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotMatchPatternException("Введенный адрес электронной почты не соответствует шаблону.");
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(Pattern))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Regex rg = new Regex(Pattern);
|
||||
bool address = rg.IsMatch(value);
|
||||
if (address)
|
||||
{
|
||||
emailTextBox.Text = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Error
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public void SetExample(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Pattern))
|
||||
{
|
||||
throw new NullPatternException("Pattern is not set.");
|
||||
}
|
||||
|
||||
Regex rg = new Regex(Pattern);
|
||||
bool address = rg.IsMatch(str);
|
||||
if (address)
|
||||
{
|
||||
example = str;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotMatchPatternException("The provided example does not match the pattern.");
|
||||
}
|
||||
}
|
||||
|
||||
private void textBox_Enter(object sender, EventArgs e)
|
||||
{
|
||||
int VisibleTime = 2000; //ms
|
||||
ToolTip tooltip = new ToolTip();
|
||||
tooltip.Show(example, emailTextBox, 30, -20, VisibleTime);
|
||||
}
|
||||
|
||||
private EventHandler onValueChanged;
|
||||
public event EventHandler ValueChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
onValueChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
onValueChanged -= value;
|
||||
}
|
||||
}
|
||||
|
||||
private void textBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
onValueChanged?.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
60
COP/Components/Components/UserEmailTextBox.resx
Normal file
60
COP/Components/Components/UserEmailTextBox.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
59
COP/Components/Components/UserListBoxObject.Designer.cs
generated
Normal file
59
COP/Components/Components/UserListBoxObject.Designer.cs
generated
Normal file
@ -0,0 +1,59 @@
|
||||
namespace Components.Components
|
||||
{
|
||||
partial class UserListBoxObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.listBoxObj = new System.Windows.Forms.ListBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// listBoxObj
|
||||
//
|
||||
this.listBoxObj.FormattingEnabled = true;
|
||||
this.listBoxObj.HorizontalScrollbar = true;
|
||||
this.listBoxObj.ItemHeight = 16;
|
||||
this.listBoxObj.Location = new System.Drawing.Point(3, 3);
|
||||
this.listBoxObj.Name = "listBoxObj";
|
||||
this.listBoxObj.Size = new System.Drawing.Size(353, 116);
|
||||
this.listBoxObj.TabIndex = 0;
|
||||
//
|
||||
// UserListBoxObjects
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.listBoxObj);
|
||||
this.Name = "UserListBoxObjects";
|
||||
this.Size = new System.Drawing.Size(359, 133);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ListBox listBoxObj;
|
||||
}
|
||||
}
|
99
COP/Components/Components/UserListBoxObject.cs
Normal file
99
COP/Components/Components/UserListBoxObject.cs
Normal file
@ -0,0 +1,99 @@
|
||||
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;
|
||||
|
||||
namespace Components.Components
|
||||
{
|
||||
public partial class UserListBoxObject : UserControl
|
||||
{
|
||||
private string? _template;
|
||||
|
||||
private char? _fromChar;
|
||||
|
||||
private char? _toChar;
|
||||
|
||||
public int SelectedIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return listBoxObj.SelectedIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
listBoxObj.SelectedIndex = value;
|
||||
}
|
||||
}
|
||||
public UserListBoxObject()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public void SetParams(string template, char fromChar, char toChar)
|
||||
{
|
||||
_template = template;
|
||||
_fromChar = fromChar;
|
||||
_toChar = toChar;
|
||||
}
|
||||
|
||||
public T? GetObject<T>()
|
||||
{
|
||||
if (listBoxObj.SelectedIndex == -1 || string.IsNullOrEmpty(_template) || !_fromChar.HasValue || !_toChar.HasValue)
|
||||
throw new ArgumentException("Не хватает данных");
|
||||
|
||||
var type = typeof(T);
|
||||
var properties = type.GetProperties();
|
||||
var curObject = Activator.CreateInstance(type);
|
||||
|
||||
string[] wordsTemplate = _template.Split(' ');
|
||||
string[] words = listBoxObj.SelectedItem.ToString().Split(' ');
|
||||
|
||||
for (int i = 0; i < wordsTemplate.Length; i++)
|
||||
{
|
||||
string word = wordsTemplate[i];
|
||||
if (word.Contains(_fromChar.Value) && word.Contains(_toChar.Value))
|
||||
{
|
||||
int startCharIndex = word.IndexOf(_fromChar.Value);
|
||||
int endCharIndex = word.LastIndexOf(_toChar.Value);
|
||||
|
||||
string propertyName = word.Substring(startCharIndex + 1, endCharIndex - startCharIndex - 1);
|
||||
var property = properties.FirstOrDefault(x => x.Name == propertyName);
|
||||
if (property == null)
|
||||
continue;
|
||||
|
||||
int extraCharsBefore = startCharIndex;
|
||||
int extraCharsAfter = word.Length - endCharIndex - 1;
|
||||
|
||||
string propertyValue = words[i].Substring(extraCharsBefore,
|
||||
words[i].Length - extraCharsBefore - extraCharsAfter);
|
||||
property.SetValue(curObject, Convert.ChangeType(propertyValue, property.PropertyType));
|
||||
}
|
||||
}
|
||||
return (T?)curObject;
|
||||
}
|
||||
|
||||
public void AddItems<T>(List<T> items)
|
||||
where T : class
|
||||
{
|
||||
if (string.IsNullOrEmpty(_template) || !_fromChar.HasValue || !_toChar.HasValue)
|
||||
throw new ArgumentException("Не хватает данных");
|
||||
listBoxObj.Items.Clear();
|
||||
var type = typeof(T);
|
||||
var properties = type.GetProperties();
|
||||
foreach (T item in items)
|
||||
{
|
||||
string result = _template;
|
||||
foreach (var property in properties)
|
||||
{
|
||||
string search = _fromChar.Value + property.Name + _toChar.Value;
|
||||
result = result.Replace(search, property.GetValue(item)?.ToString() ?? "");
|
||||
}
|
||||
listBoxObj.Items.Add(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
COP/Components/Components/UserListBoxObject.resx
Normal file
120
COP/Components/Components/UserListBoxObject.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>
|
21
COP/Components/Exceptions/NotMatchPatternException.cs
Normal file
21
COP/Components/Exceptions/NotMatchPatternException.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Components.Exceptions
|
||||
{
|
||||
[Serializable]
|
||||
public class NotMatchPatternException : ApplicationException
|
||||
{
|
||||
public NotMatchPatternException() : base() { }
|
||||
|
||||
public NotMatchPatternException(string message) : base(message) { }
|
||||
|
||||
public NotMatchPatternException(string message, Exception exception) : base(message, exception) { }
|
||||
|
||||
protected NotMatchPatternException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
21
COP/Components/Exceptions/NullPatternException.cs
Normal file
21
COP/Components/Exceptions/NullPatternException.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Components.Exceptions
|
||||
{
|
||||
[Serializable]
|
||||
public class NullPatternException : ApplicationException
|
||||
{
|
||||
public NullPatternException() : base() { }
|
||||
|
||||
public NullPatternException(string message) : base(message) { }
|
||||
|
||||
public NullPatternException(string message, Exception exception) : base(message, exception) { }
|
||||
|
||||
protected NullPatternException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
36
COP/Components/NonVisualComponents/WordLineChart.Designer.cs
generated
Normal file
36
COP/Components/NonVisualComponents/WordLineChart.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace Components.NonVisualComponents
|
||||
{
|
||||
partial class WordLineChart
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
91
COP/Components/NonVisualComponents/WordLineChart.cs
Normal file
91
COP/Components/NonVisualComponents/WordLineChart.cs
Normal file
@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Words;
|
||||
using Aspose.Words.Drawing;
|
||||
using Aspose.Words.Drawing.Charts;
|
||||
using Components.SupportClasses;
|
||||
using Document = Aspose.Words.Document;
|
||||
|
||||
namespace Components.NonVisualComponents
|
||||
{
|
||||
public partial class WordLineChart : Component
|
||||
{
|
||||
public WordLineChart()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordLineChart(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
public void AddLineChart(SimpleLineChart simpleLineChart)
|
||||
{
|
||||
if (!CheckData(simpleLineChart.DataList))
|
||||
{
|
||||
throw new Exception("Не данные заполнены");
|
||||
}
|
||||
Document doc = new Document();
|
||||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||||
|
||||
Aspose.Words.Font font = builder.Font;
|
||||
font.Size = 24;
|
||||
font.Bold = true;
|
||||
font.Color = Color.Black;
|
||||
font.Name = "Times New Roman";
|
||||
|
||||
ParagraphFormat paragraphFormat = builder.ParagraphFormat;
|
||||
paragraphFormat.FirstLineIndent = 8;
|
||||
paragraphFormat.SpaceAfter = 24;
|
||||
paragraphFormat.Alignment = ParagraphAlignment.Center;
|
||||
paragraphFormat.KeepTogether = true;
|
||||
|
||||
builder.Writeln(simpleLineChart.FileHeader);
|
||||
|
||||
Shape shape = builder.InsertChart(ChartType.Line, 500, 270);
|
||||
|
||||
Chart chart = shape.Chart;
|
||||
|
||||
chart.Title.Text = simpleLineChart.LineChartName;
|
||||
|
||||
ChartSeriesCollection seriesColl = chart.Series;
|
||||
|
||||
Console.WriteLine(seriesColl.Count);
|
||||
|
||||
seriesColl.Clear();
|
||||
|
||||
foreach (var data in simpleLineChart.DataList)
|
||||
{
|
||||
seriesColl.Add(data.NameSeries, data.NameData, data.Data);
|
||||
}
|
||||
|
||||
ChartLegend legend = chart.Legend;
|
||||
|
||||
legend.Position = (LegendPosition)simpleLineChart.AreaLegend;
|
||||
|
||||
legend.Overlay = true;
|
||||
|
||||
doc.Save(simpleLineChart.FilePath);
|
||||
}
|
||||
static bool CheckData(List<DataLineChart> data)
|
||||
{
|
||||
foreach (var _data in data)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_data.NameSeries) || string.IsNullOrEmpty(_data.NameData.ToString()) || string.IsNullOrEmpty(_data.Data.ToString()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
36
COP/Components/NonVisualComponents/WordTable.Designer.cs
generated
Normal file
36
COP/Components/NonVisualComponents/WordTable.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace Components.NonVisualComponents
|
||||
{
|
||||
partial class WordTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
134
COP/Components/NonVisualComponents/WordTable.cs
Normal file
134
COP/Components/NonVisualComponents/WordTable.cs
Normal file
@ -0,0 +1,134 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Components.SupportClasses;
|
||||
using Aspose.Words;
|
||||
using Aspose.Words.Tables;
|
||||
|
||||
namespace Components.NonVisualComponents
|
||||
{
|
||||
public partial class WordTable : Component
|
||||
{
|
||||
public WordTable()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordTable(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateTable<T>(BigTable<T> bigTable)
|
||||
{
|
||||
if (bigTable.Data == null)
|
||||
{
|
||||
throw new ArgumentException("Не заданы все данные");
|
||||
}
|
||||
|
||||
foreach (var columnDefinition in bigTable.ColumnDefinitions)
|
||||
{
|
||||
if (string.IsNullOrEmpty(columnDefinition.PropertyName))
|
||||
{
|
||||
throw new ArgumentException($"Не задано свойство столбца: {columnDefinition.Header}");
|
||||
}
|
||||
}
|
||||
|
||||
Document document = new Document();
|
||||
DocumentBuilder builder = new DocumentBuilder(document);
|
||||
|
||||
Style titleStyle = builder.Document.Styles.Add(StyleType.Paragraph, "Title");
|
||||
titleStyle.Font.Size = 16;
|
||||
titleStyle.Font.Bold = true;
|
||||
|
||||
builder.ParagraphFormat.Style = titleStyle;
|
||||
builder.Writeln(bigTable.DocumentTitle);
|
||||
|
||||
Table table = builder.StartTable();
|
||||
|
||||
|
||||
foreach (var columnDefinition in bigTable.ColumnDefinitions)
|
||||
{
|
||||
builder.InsertCell();
|
||||
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition.Weight);
|
||||
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
|
||||
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
|
||||
builder.Write(columnDefinition.Header);
|
||||
}
|
||||
|
||||
foreach (var mergedColumn in bigTable.MergedColumns)
|
||||
{
|
||||
int startCellIndex = mergedColumn[0];
|
||||
int endCellIndex = mergedColumn[mergedColumn.Length - 1];
|
||||
|
||||
for (int i = startCellIndex; i <= endCellIndex; i++)
|
||||
{
|
||||
table.Rows[0].Cells[i].CellFormat.HorizontalMerge = CellMerge.First;
|
||||
table.Rows[0].Cells[i].CellFormat.VerticalMerge = CellMerge.First;
|
||||
}
|
||||
|
||||
for (int i = startCellIndex + 1; i <= endCellIndex; i++)
|
||||
{
|
||||
table.Rows[0].Cells[i].CellFormat.HorizontalMerge = CellMerge.Previous;
|
||||
table.Rows[0].Cells[i].CellFormat.VerticalMerge = CellMerge.First;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
builder.EndRow();
|
||||
|
||||
foreach (var columnDefinition2 in bigTable.ColumnDefinitions2)
|
||||
{
|
||||
builder.InsertCell();
|
||||
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition2.Weight);
|
||||
builder.Write(columnDefinition2.Header);
|
||||
}
|
||||
|
||||
builder.EndRow();
|
||||
|
||||
int columnIndex;
|
||||
foreach (var columnDefinition in bigTable.ColumnDefinitions)
|
||||
{
|
||||
string currentPropertyName = columnDefinition.PropertyName;
|
||||
columnIndex = 0;
|
||||
foreach (var columnDefinition2 in bigTable.ColumnDefinitions2)
|
||||
{
|
||||
string currentPropertyName1 = columnDefinition2.PropertyName;
|
||||
|
||||
if (currentPropertyName == currentPropertyName1)
|
||||
{
|
||||
table.Rows[0].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.First;
|
||||
table.Rows[1].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.Previous;
|
||||
|
||||
}
|
||||
columnIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in bigTable.Data)
|
||||
{
|
||||
foreach (var columnDefinition2 in bigTable.ColumnDefinitions2)
|
||||
{
|
||||
builder.InsertCell();
|
||||
var propertyValue = item.GetType()
|
||||
.GetProperty(columnDefinition2.PropertyName)?
|
||||
.GetValue(item)?.ToString();
|
||||
|
||||
builder.Write(propertyValue ?? "");
|
||||
}
|
||||
|
||||
builder.EndRow();
|
||||
}
|
||||
|
||||
builder.EndTable();
|
||||
|
||||
document.Save(bigTable.FilePath);
|
||||
}
|
||||
}
|
||||
}
|
36
COP/Components/NonVisualComponents/WordText.Designer.cs
generated
Normal file
36
COP/Components/NonVisualComponents/WordText.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace Components.NonVisualComponents
|
||||
{
|
||||
partial class WordText
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
106
COP/Components/NonVisualComponents/WordText.cs
Normal file
106
COP/Components/NonVisualComponents/WordText.cs
Normal file
@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using Components.SupportClasses;
|
||||
using DocumentFormat.OpenXml;
|
||||
|
||||
namespace Components.NonVisualComponents
|
||||
{
|
||||
public partial class WordText : Component
|
||||
{
|
||||
public WordText()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordText(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateWordText(LargeText largeText)
|
||||
{
|
||||
if (string.IsNullOrEmpty(largeText.FilePath) || string.IsNullOrEmpty(largeText.DocumentTitle) || !CheckData(largeText.TextData))
|
||||
{
|
||||
throw new Exception("Не все данные заполнены");
|
||||
}
|
||||
|
||||
using (var wordDocument = WordprocessingDocument.Create(largeText.FilePath, WordprocessingDocumentType.Document))
|
||||
{
|
||||
// Вытаскиваем главную часть из вордовского документа
|
||||
MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = new Document();
|
||||
|
||||
// Генерируем тело основной части документа
|
||||
Body docBody = mainPart.Document.AppendChild(new Body());
|
||||
|
||||
// Добавляем текст
|
||||
AddText(docBody, largeText);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddText(Body docBody, LargeText largeText)
|
||||
{
|
||||
#region Создание заголовка
|
||||
ParagraphProperties paragraphProperties = new();
|
||||
paragraphProperties.AppendChild(new Justification
|
||||
{
|
||||
Val = JustificationValues.Center
|
||||
});
|
||||
paragraphProperties.AppendChild(new Indentation());
|
||||
|
||||
Paragraph header = new();
|
||||
header.AppendChild(paragraphProperties);
|
||||
|
||||
var docRun = new Run();
|
||||
var properties = new RunProperties();
|
||||
properties.AppendChild(new FontSize
|
||||
{
|
||||
Val = "48"
|
||||
});
|
||||
properties.AppendChild(new Bold());
|
||||
docRun.AppendChild(properties);
|
||||
docRun.AppendChild(new Text(largeText.DocumentTitle));
|
||||
header.AppendChild(docRun);
|
||||
docBody.Append(header);
|
||||
#endregion
|
||||
|
||||
#region Создание текста
|
||||
for (int i = 0; i < largeText.TextData.Length; i++)
|
||||
{
|
||||
ParagraphProperties paragraphProperties2 = new();
|
||||
paragraphProperties2.AppendChild(new Justification
|
||||
{
|
||||
Val = JustificationValues.Both
|
||||
});
|
||||
paragraphProperties2.AppendChild(new Indentation());
|
||||
|
||||
Paragraph text = new();
|
||||
text.AppendChild(paragraphProperties2);
|
||||
|
||||
var docRun2 = new Run();
|
||||
var properties2 = new RunProperties();
|
||||
properties2.AppendChild(new FontSize
|
||||
{
|
||||
Val = "24"
|
||||
});
|
||||
docRun2.AppendChild(properties2);
|
||||
docRun2.AppendChild(new Text(largeText.TextData[i]));
|
||||
text.AppendChild(docRun2);
|
||||
docBody.Append(text);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
bool CheckData(string[] data)
|
||||
{
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
if (string.IsNullOrEmpty(data[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
31
COP/Components/SupportClasses/BigTable.cs
Normal file
31
COP/Components/SupportClasses/BigTable.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Components.SupportClasses
|
||||
{
|
||||
public class BigTable<T>
|
||||
{
|
||||
public string FilePath = string.Empty;
|
||||
|
||||
public string DocumentTitle = string.Empty;
|
||||
|
||||
public List<ColumnDefinition> ColumnDefinitions;
|
||||
public List<ColumnDefinition> ColumnDefinitions2;
|
||||
|
||||
public List<T> Data;
|
||||
|
||||
public List<int[]> MergedColumns;
|
||||
public BigTable(string filePath, string documentTitle, List<ColumnDefinition> columnDefinitions, List<ColumnDefinition> columnDefinitions2, List<T> data, List<int[]> mergedColumns)
|
||||
{
|
||||
FilePath = filePath;
|
||||
DocumentTitle = documentTitle;
|
||||
ColumnDefinitions = columnDefinitions;
|
||||
Data = data;
|
||||
MergedColumns = mergedColumns;
|
||||
ColumnDefinitions2 = columnDefinitions2;
|
||||
}
|
||||
}
|
||||
}
|
15
COP/Components/SupportClasses/ColumnDefenitions.cs
Normal file
15
COP/Components/SupportClasses/ColumnDefenitions.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Components.SupportClasses
|
||||
{
|
||||
public class ColumnDefinition
|
||||
{
|
||||
public string Header;
|
||||
public string PropertyName;
|
||||
public double Weight;
|
||||
}
|
||||
}
|
24
COP/Components/SupportClasses/DataLineChart.cs
Normal file
24
COP/Components/SupportClasses/DataLineChart.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Components.SupportClasses
|
||||
{
|
||||
public class DataLineChart
|
||||
{
|
||||
public string NameSeries { get; set; } = string.Empty;
|
||||
|
||||
public string[] NameData { get; set; }
|
||||
|
||||
public double[] Data { get; set; }
|
||||
|
||||
public DataLineChart(string nameSeries, string[] nameData, double[] data)
|
||||
{
|
||||
NameSeries = nameSeries;
|
||||
NameData = nameData;
|
||||
Data = data;
|
||||
}
|
||||
}
|
||||
}
|
23
COP/Components/SupportClasses/Enums/EnumAreaLegend.cs
Normal file
23
COP/Components/SupportClasses/Enums/EnumAreaLegend.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Components.SupportClasses.Enums
|
||||
{
|
||||
public enum EnumAreaLegend
|
||||
{
|
||||
None,
|
||||
|
||||
Left,
|
||||
|
||||
Top,
|
||||
|
||||
Right,
|
||||
|
||||
Bottom,
|
||||
|
||||
TopRight
|
||||
}
|
||||
}
|
24
COP/Components/SupportClasses/LargeText.cs
Normal file
24
COP/Components/SupportClasses/LargeText.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Components.SupportClasses
|
||||
{
|
||||
public class LargeText
|
||||
{
|
||||
public string FilePath = string.Empty;
|
||||
|
||||
public string DocumentTitle = string.Empty;
|
||||
|
||||
public string[] TextData;
|
||||
|
||||
public LargeText(string filePath, string documentTitle, string[] textData)
|
||||
{
|
||||
FilePath = filePath;
|
||||
DocumentTitle = documentTitle;
|
||||
TextData = textData;
|
||||
}
|
||||
}
|
||||
}
|
31
COP/Components/SupportClasses/SimpleLineChart.cs
Normal file
31
COP/Components/SupportClasses/SimpleLineChart.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using Components.SupportClasses.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Components.SupportClasses
|
||||
{
|
||||
public class SimpleLineChart
|
||||
{
|
||||
public string FilePath = string.Empty;
|
||||
|
||||
public string FileHeader = string.Empty;
|
||||
|
||||
public string LineChartName = string.Empty;
|
||||
|
||||
public EnumAreaLegend AreaLegend;
|
||||
|
||||
public List<DataLineChart> DataList = new();
|
||||
|
||||
public SimpleLineChart(string filePath, string fileHeader, string lineChartName, EnumAreaLegend areaLegend, List<DataLineChart> dataList)
|
||||
{
|
||||
FilePath = filePath;
|
||||
FileHeader = fileHeader;
|
||||
LineChartName = lineChartName;
|
||||
AreaLegend = areaLegend;
|
||||
DataList = dataList;
|
||||
}
|
||||
}
|
||||
}
|
64
COP/PluginsConventionLibrary/IPluginsConvention.cs
Normal file
64
COP/PluginsConventionLibrary/IPluginsConvention.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary
|
||||
{
|
||||
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>
|
||||
/// <returns></returns>
|
||||
Form GetThesaurus();
|
||||
/// <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);
|
||||
}
|
||||
}
|
13
COP/PluginsConventionLibrary/PluginsConventionElement.cs
Normal file
13
COP/PluginsConventionLibrary/PluginsConventionElement.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary
|
||||
{
|
||||
public class PluginsConventionElement
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
}
|
10
COP/PluginsConventionLibrary/PluginsConventionLibrary.csproj
Normal file
10
COP/PluginsConventionLibrary/PluginsConventionLibrary.csproj
Normal file
@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary
|
||||
{
|
||||
public class PluginsConventionSaveDocument
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
}
|
||||
}
|
155
COP/WinForms/FormClient.Designer.cs
generated
Normal file
155
COP/WinForms/FormClient.Designer.cs
generated
Normal file
@ -0,0 +1,155 @@
|
||||
using ControlsLibraryNet60.Input;
|
||||
|
||||
namespace WinForms
|
||||
{
|
||||
partial class FormClient
|
||||
{
|
||||
/// <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.controlInputAmount = new ControlsLibraryNet60.Input.ControlInputNullableDouble();
|
||||
this.comboBoxControlStatus = new BulatovaComponents.Components.ComboBoxControl();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxReviews = new System.Windows.Forms.TextBox();
|
||||
this.labelName = new System.Windows.Forms.Label();
|
||||
this.labelReviews = new System.Windows.Forms.Label();
|
||||
this.labelAmount = new System.Windows.Forms.Label();
|
||||
this.labelClient = new System.Windows.Forms.Label();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// controlInputAmount
|
||||
//
|
||||
this.controlInputAmount.Location = new System.Drawing.Point(14, 219);
|
||||
this.controlInputAmount.Margin = new System.Windows.Forms.Padding(5, 8, 5, 8);
|
||||
this.controlInputAmount.Name = "controlInputAmount";
|
||||
this.controlInputAmount.Size = new System.Drawing.Size(331, 36);
|
||||
this.controlInputAmount.TabIndex = 0;
|
||||
this.controlInputAmount.Value = null;
|
||||
//
|
||||
// comboBoxControlStatus
|
||||
//
|
||||
this.comboBoxControlStatus.Location = new System.Drawing.Point(22, 34);
|
||||
this.comboBoxControlStatus.Name = "comboBoxControlStatus";
|
||||
this.comboBoxControlStatus.SelectedValue = "";
|
||||
this.comboBoxControlStatus.Size = new System.Drawing.Size(333, 44);
|
||||
this.comboBoxControlStatus.TabIndex = 1;
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(22, 93);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(323, 27);
|
||||
this.textBoxName.TabIndex = 2;
|
||||
//
|
||||
// textBoxReviews
|
||||
//
|
||||
this.textBoxReviews.Location = new System.Drawing.Point(22, 151);
|
||||
this.textBoxReviews.Name = "textBoxReviews";
|
||||
this.textBoxReviews.Size = new System.Drawing.Size(323, 27);
|
||||
this.textBoxReviews.TabIndex = 3;
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
this.labelName.AutoSize = true;
|
||||
this.labelName.Location = new System.Drawing.Point(22, 70);
|
||||
this.labelName.Name = "labelName";
|
||||
this.labelName.Size = new System.Drawing.Size(52, 20);
|
||||
this.labelName.TabIndex = 4;
|
||||
this.labelName.Text = "ФИО";
|
||||
//
|
||||
// labelReviews
|
||||
//
|
||||
this.labelReviews.AutoSize = true;
|
||||
this.labelReviews.Location = new System.Drawing.Point(22, 128);
|
||||
this.labelReviews.Name = "labelReviews";
|
||||
this.labelReviews.Size = new System.Drawing.Size(131, 20);
|
||||
this.labelReviews.TabIndex = 5;
|
||||
this.labelReviews.Text = "Отзывы";
|
||||
//
|
||||
// labelAmount
|
||||
//
|
||||
this.labelAmount.AutoSize = true;
|
||||
this.labelAmount.Location = new System.Drawing.Point(26, 191);
|
||||
this.labelAmount.Name = "labelAmount";
|
||||
this.labelAmount.Size = new System.Drawing.Size(64, 20);
|
||||
this.labelAmount.TabIndex = 6;
|
||||
this.labelAmount.Text = "Сумма покупок";
|
||||
//
|
||||
// labelClient
|
||||
//
|
||||
this.labelClient.AutoSize = true;
|
||||
this.labelClient.Location = new System.Drawing.Point(25, 8);
|
||||
this.labelClient.Name = "labelClient";
|
||||
this.labelClient.Size = new System.Drawing.Size(63, 20);
|
||||
this.labelClient.TabIndex = 7;
|
||||
this.labelClient.Text = "Клиент";
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(36, 262);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonAdd.TabIndex = 8;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.buttonSave_Click);
|
||||
//
|
||||
// FormClient
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(404, 307);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.labelClient);
|
||||
this.Controls.Add(this.labelAmount);
|
||||
this.Controls.Add(this.labelReviews);
|
||||
this.Controls.Add(this.labelName);
|
||||
this.Controls.Add(this.textBoxReviews);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.comboBoxControlStatus);
|
||||
this.Controls.Add(this.controlInputAmount);
|
||||
this.Name = "FormClient";
|
||||
this.Text = "FormClient";
|
||||
this.Load += new System.EventHandler(this.FormClient_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ControlsLibraryNet60.Input.ControlInputNullableDouble controlInputAmount;
|
||||
private BulatovaComponents.Components.ComboBoxControl comboBoxControlStatus;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxReviews;
|
||||
private Label labelName;
|
||||
private Label labelReviews;
|
||||
private Label labelAmount;
|
||||
private Label labelClient;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
102
COP/WinForms/FormClient.cs
Normal file
102
COP/WinForms/FormClient.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.BusinessLogicContracts;
|
||||
using ClientsContracts.SearchModels;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ControlsLibraryNet60.Input;
|
||||
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;
|
||||
|
||||
namespace WinForms
|
||||
{
|
||||
public partial class FormClient : Form
|
||||
{
|
||||
private int? _id;
|
||||
private readonly IClientLogic _logic;
|
||||
private readonly IStatusLogic _roleLogic;
|
||||
private List<StatusViewModel> _roles;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormClient(IClientLogic logic, IStatusLogic roleLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
_roleLogic = roleLogic;
|
||||
_roles = new List<StatusViewModel>();
|
||||
}
|
||||
|
||||
private void FormClient_Load(object sender, EventArgs e)
|
||||
{
|
||||
_roles = _roleLogic.ReadList();
|
||||
comboBoxControlStatus.addItems(_roles.Select(x => x.StatusName).ToList());
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new ClientSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.Name;
|
||||
textBoxReviews.Text = view.Reviews;
|
||||
controlInputAmount.Value = view.Amount;
|
||||
|
||||
comboBoxControlStatus.SelectedValue = view.StatusName;
|
||||
}
|
||||
}
|
||||
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 buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(comboBoxControlStatus.SelectedValue))
|
||||
{
|
||||
MessageBox.Show("Выберете статус", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var model = new ClientBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Name = textBoxName.Text,
|
||||
Reviews = textBoxReviews.Text,
|
||||
Amount = controlInputAmount.Value.HasValue ? (float)controlInputAmount.Value.GetValueOrDefault() : null,
|
||||
StatusId = _roles.First(x => x.StatusName == comboBoxControlStatus.SelectedValue).Id,
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
COP/WinForms/FormClient.resx
Normal file
120
COP/WinForms/FormClient.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>
|
182
COP/WinForms/FormMain.Designer.cs
generated
Normal file
182
COP/WinForms/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,182 @@
|
||||
namespace WinForms
|
||||
{
|
||||
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.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.создатьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.редактироватьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.удалитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.отчётыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.документToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.документСТаблицейToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.документСДиаграммойToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.статусыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.myTreeView = new ChubykinaComponents.Components.UserTreeView();
|
||||
this.wordLongTextComponent = new BulatovaComponents.NonVisualComponents.WordLongTextComponent(this.components);
|
||||
this.excelDiagramComponent = new ChubykinaComponents.LogicalComponents.ExcelDiagramComponent(this.components);
|
||||
this.componentDocumentWithTableMultiHeaderPdf = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderPdf(this.components);
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.клиентыToolStripMenuItem,
|
||||
this.отчётыToolStripMenuItem,
|
||||
this.статусыToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(800, 28);
|
||||
this.menuStrip1.TabIndex = 0;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// клиентыToolStripMenuItem
|
||||
//
|
||||
this.клиентыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.создатьToolStripMenuItem,
|
||||
this.редактироватьToolStripMenuItem,
|
||||
this.удалитьToolStripMenuItem});
|
||||
this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||
this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(83, 24);
|
||||
this.клиентыToolStripMenuItem.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(246, 26);
|
||||
this.создатьToolStripMenuItem.Text = "Создать";
|
||||
this.создатьToolStripMenuItem.Click += new System.EventHandler(this.создатьToolStripMenuItem_Click);
|
||||
//
|
||||
// редактироватьToolStripMenuItem
|
||||
//
|
||||
this.редактироватьToolStripMenuItem.Name = "редактироватьToolStripMenuItem";
|
||||
this.редактироватьToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U)));
|
||||
this.редактироватьToolStripMenuItem.Size = new System.Drawing.Size(246, 26);
|
||||
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(246, 26);
|
||||
this.удалитьToolStripMenuItem.Text = "Удалить";
|
||||
this.удалитьToolStripMenuItem.Click += new System.EventHandler(this.удалитьToolStripMenuItem_Click);
|
||||
//
|
||||
// отчётыToolStripMenuItem
|
||||
//
|
||||
this.отчётыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.документToolStripMenuItem,
|
||||
this.документСТаблицейToolStripMenuItem,
|
||||
this.документСДиаграммойToolStripMenuItem});
|
||||
this.отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
||||
this.отчётыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
|
||||
this.отчётыToolStripMenuItem.Text = "Отчёты";
|
||||
//
|
||||
// документ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(313, 26);
|
||||
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(313, 26);
|
||||
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(313, 26);
|
||||
this.документСДиаграммойToolStripMenuItem.Text = "Документ с диаграммой";
|
||||
this.документСДиаграммойToolStripMenuItem.Click += new System.EventHandler(this.документСДиаграммойToolStripMenuItem_Click);
|
||||
//
|
||||
// статусыToolStripMenuItem
|
||||
//
|
||||
this.статусыToolStripMenuItem.Name = "статусыToolStripMenuItem";
|
||||
this.статусыToolStripMenuItem.Size = new System.Drawing.Size(77, 24);
|
||||
this.статусыToolStripMenuItem.Text = "Статусы";
|
||||
this.статусыToolStripMenuItem.Click += new System.EventHandler(this.статусыToolStripMenuItem_Click);
|
||||
//
|
||||
// myTreeView
|
||||
//
|
||||
this.myTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.myTreeView.Location = new System.Drawing.Point(0, 28);
|
||||
this.myTreeView.Name = "myTreeView";
|
||||
this.myTreeView.SelectedNodeIndex = -1;
|
||||
this.myTreeView.Size = new System.Drawing.Size(800, 422);
|
||||
this.myTreeView.TabIndex = 1;
|
||||
this.myTreeView.Load += new System.EventHandler(this.FormMain_Load);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.myTreeView);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "FormMain";
|
||||
this.Text = "Клиенты";
|
||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||
private ToolStripMenuItem отчётыToolStripMenuItem;
|
||||
private ToolStripMenuItem статусыToolStripMenuItem;
|
||||
private ChubykinaComponents.Components.UserTreeView myTreeView;
|
||||
private ToolStripMenuItem создатьToolStripMenuItem;
|
||||
private ToolStripMenuItem редактироватьToolStripMenuItem;
|
||||
private ToolStripMenuItem удалитьToolStripMenuItem;
|
||||
private ToolStripMenuItem документToolStripMenuItem;
|
||||
private ToolStripMenuItem документСТаблицейToolStripMenuItem;
|
||||
private ToolStripMenuItem документСДиаграммойToolStripMenuItem;
|
||||
private BulatovaComponents.NonVisualComponents.WordLongTextComponent wordLongTextComponent;
|
||||
private ChubykinaComponents.LogicalComponents.ExcelDiagramComponent excelDiagramComponent;
|
||||
private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderPdf componentDocumentWithTableMultiHeaderPdf;
|
||||
}
|
||||
}
|
196
COP/WinForms/FormMain.cs
Normal file
196
COP/WinForms/FormMain.cs
Normal file
@ -0,0 +1,196 @@
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.BusinessLogicContracts;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ChubykinaComponents.Components;
|
||||
using BulatovaComponents.NonVisualComponents;
|
||||
using ComponentsLibraryNet60.DocumentWithTable;
|
||||
using ComponentsLibraryNet60.Models;
|
||||
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 ChubykinaComponents.LogicalComponents;
|
||||
|
||||
namespace WinForms
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private IClientLogic _logic;
|
||||
|
||||
public FormMain(IClientLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
|
||||
}
|
||||
|
||||
private void статусыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormStatus));
|
||||
if (service is FormStatus form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
myTreeView.setHierarchy(new List<(string, bool)> { ("StatusName", false), ("ViewAmount", false), ("Id", true), ("Name", true) });
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
myTreeView.clear();
|
||||
var clients = _logic.ReadList(null);
|
||||
if (clients != null)
|
||||
{
|
||||
foreach (var client in clients)
|
||||
{
|
||||
if (!client.Amount.HasValue)
|
||||
{
|
||||
client.ViewAmount = "нет покупок";
|
||||
}
|
||||
else
|
||||
{
|
||||
client.ViewAmount = client.Amount.Value.ToString();
|
||||
}
|
||||
}
|
||||
myTreeView.addItems(clients);
|
||||
}
|
||||
}
|
||||
|
||||
private void создатьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClient));
|
||||
if (service is FormClient form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClient));
|
||||
if (service is FormClient form)
|
||||
{
|
||||
var selected = myTreeView.getSelecetedNodeValue<ClientViewModel>();
|
||||
if (selected == null) return;
|
||||
form.Id = selected.Id;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var selected = myTreeView.getSelecetedNodeValue<ClientViewModel>();
|
||||
if (selected == null) return;
|
||||
if (MessageBox.Show("Удалить запись?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
if (_logic.Delete(new ClientBindingModel { Id = selected.Id }))
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void документToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "Word Files|*.docx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
|
||||
List<string> paragraphs = new List<string>();
|
||||
foreach (var client in _logic.ReadList(null))
|
||||
{
|
||||
if (client.Amount == null)
|
||||
{
|
||||
paragraphs.Add(client.Name + ": " + client.Reviews);
|
||||
}
|
||||
}
|
||||
string path = saveFileDialog.FileName;
|
||||
wordLongTextComponent.createWithLongText(new WordLongTextInfo(path, "Клиенты без суммы покупок", paragraphs.ToArray()));
|
||||
MessageBox.Show("Документ создан");
|
||||
}
|
||||
|
||||
private void документСДиаграммойToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "Excel Files|*.xlsx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
|
||||
List<string> paragraphs = new List<string>();
|
||||
string path = saveFileDialog.FileName;
|
||||
var data = _logic.ReadList(null).Where(x => x.Amount == null).GroupBy(x => x.StatusName).Select(x => new
|
||||
{
|
||||
StatusName = x.Key,
|
||||
StatusCount = x.Count(),
|
||||
}).ToList();
|
||||
excelDiagramComponent.createWithDiagram(path, "Статусы без суммы покупок", "Статусы без суммы покупок", ChubykinaComponents.LogicalComponents.DiagramLegendEnum.BottomRight,
|
||||
data, "StatusName", "StatusCount");
|
||||
MessageBox.Show("Документ создан");
|
||||
}
|
||||
|
||||
private void документСТаблицейToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "PDF Files|*.pdf"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
|
||||
List<string> paragraphs = new List<string>();
|
||||
string path = saveFileDialog.FileName;
|
||||
var clients = _logic.ReadList(null);
|
||||
foreach (var client in clients)
|
||||
{
|
||||
if (!client.Amount.HasValue)
|
||||
{
|
||||
client.DocAmount = "нет покупок";
|
||||
}
|
||||
else
|
||||
{
|
||||
client.DocAmount = client.Amount.Value.ToString();
|
||||
}
|
||||
}
|
||||
ComponentDocumentWithTableHeaderDataConfig<ClientViewModel> config = new ComponentsLibraryNet60.Models.ComponentDocumentWithTableHeaderDataConfig<ClientViewModel>
|
||||
{
|
||||
Data = clients,
|
||||
UseUnion = false,
|
||||
Header = "Клиенты",
|
||||
ColumnsRowsDataCount = (4, 1),
|
||||
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
|
||||
{
|
||||
(0, 0, "Id", "Id"),
|
||||
(1, 0, "ФИО", "Name"),
|
||||
(2, 0, "Статус", "StatusName"),
|
||||
(3, 0, "Сумма покупок", "DocAmount")
|
||||
},
|
||||
ColumnsRowsWidth = new List<(int Column, int Row)>
|
||||
{
|
||||
(10, 10),
|
||||
(20, 20),
|
||||
(20, 20),
|
||||
(15, 15)
|
||||
},
|
||||
ColumnUnion = new List<(int StartIndex, int Count)>(),
|
||||
FilePath = path
|
||||
};
|
||||
componentDocumentWithTableMultiHeaderPdf.CreateDoc(config);
|
||||
MessageBox.Show("Документ создан");
|
||||
}
|
||||
}
|
||||
}
|
75
COP/WinForms/FormMain.resx
Normal file
75
COP/WinForms/FormMain.resx
Normal file
@ -0,0 +1,75 @@
|
||||
<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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordLongTextComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>152, 17</value>
|
||||
</metadata>
|
||||
<metadata name="excelDiagramComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>383, 17</value>
|
||||
</metadata>
|
||||
<metadata name="componentDocumentWithTableMultiHeaderPdf.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>609, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>65</value>
|
||||
</metadata>
|
||||
</root>
|
89
COP/WinForms/FormStatus.Designer.cs
generated
Normal file
89
COP/WinForms/FormStatus.Designer.cs
generated
Normal file
@ -0,0 +1,89 @@
|
||||
namespace WinForms
|
||||
{
|
||||
partial class FormStatus
|
||||
{
|
||||
/// <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();
|
||||
this.NameCol = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.NameCol,
|
||||
this.Id});
|
||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersWidth = 51;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(800, 450);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
this.dataGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellValueChanged);
|
||||
this.dataGridView.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.dataGridView_UserDeletingRow);
|
||||
this.dataGridView.KeyUp += new System.Windows.Forms.KeyEventHandler(this.dataGridView_KeyUp);
|
||||
//
|
||||
// NameCol
|
||||
//
|
||||
this.NameCol.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.NameCol.HeaderText = "Название";
|
||||
this.NameCol.MinimumWidth = 6;
|
||||
this.NameCol.Name = "NameCol";
|
||||
//
|
||||
// Id
|
||||
//
|
||||
this.Id.HeaderText = "Id";
|
||||
this.Id.MinimumWidth = 6;
|
||||
this.Id.Name = "Id";
|
||||
this.Id.Visible = false;
|
||||
this.Id.Width = 125;
|
||||
//
|
||||
// FormStatus
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormStatus";
|
||||
this.Text = "FormStatus";
|
||||
this.Load += new System.EventHandler(this.FormStatus_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn NameCol;
|
||||
private DataGridViewTextBoxColumn Id;
|
||||
}
|
||||
}
|
104
COP/WinForms/FormStatus.cs
Normal file
104
COP/WinForms/FormStatus.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.BusinessLogicContracts;
|
||||
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;
|
||||
|
||||
namespace WinForms
|
||||
{
|
||||
public partial class FormStatus : Form
|
||||
{
|
||||
private readonly IStatusLogic _logic;
|
||||
private bool loading = false;
|
||||
|
||||
public FormStatus(IStatusLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormStatus_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
loading = true;
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList();
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var role in list)
|
||||
{
|
||||
int rowIndex = dataGridView.Rows.Add();
|
||||
dataGridView.Rows[rowIndex].Cells[0].Value = role.StatusName;
|
||||
dataGridView.Rows[rowIndex].Cells[1].Value = role.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (loading || e.RowIndex < 0 || e.ColumnIndex != 0) return;
|
||||
if (dataGridView.Rows[e.RowIndex].Cells[1].Value != null && !string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[1].Value.ToString()))
|
||||
{
|
||||
var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
if (name is null) return;
|
||||
_logic.Update(new StatusBindingModel { Id = Convert.ToInt32(dataGridView.Rows[e.RowIndex].Cells[1].Value), StatusName = name.ToString() });
|
||||
}
|
||||
else
|
||||
{
|
||||
var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
if (name is null) return;
|
||||
_logic.Create(new StatusBindingModel { Id = 0, StatusName = name.ToString() });
|
||||
int newStatusId = _logic.ReadList().ToList().Last().Id;
|
||||
dataGridView.Rows[e.RowIndex].Cells[1].Value = newStatusId;
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Insert:
|
||||
dataGridView.Rows.Add();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteRows(DataGridViewSelectedRowCollection rows)
|
||||
{
|
||||
for (int i = 0; i < rows.Count; i++)
|
||||
{
|
||||
DataGridViewRow row = rows[i];
|
||||
if (!_logic.Delete(new StatusBindingModel { Id = Convert.ToInt32(row.Cells[1].Value) })) continue;
|
||||
dataGridView.Rows.Remove(row);
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
|
||||
{
|
||||
e.Cancel = true;
|
||||
if (dataGridView.SelectedRows == null) return;
|
||||
if (MessageBox.Show("Удалить записи?", "Подтвердите действие", MessageBoxButtons.YesNo) == DialogResult.No) return;
|
||||
deleteRows(dataGridView.SelectedRows);
|
||||
}
|
||||
}
|
||||
}
|
120
COP/WinForms/FormStatus.resx
Normal file
120
COP/WinForms/FormStatus.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>
|
200
COP/WinForms/PluginsConvention.cs
Normal file
200
COP/WinForms/PluginsConvention.cs
Normal file
@ -0,0 +1,200 @@
|
||||
using ChubykinaComponents.Components;
|
||||
using ChubykinaComponents.LogicalComponents;
|
||||
using BulatovaComponents.NonVisualComponents;
|
||||
using ComponentsLibraryNet60.DocumentWithChart;
|
||||
using ComponentsLibraryNet60.DocumentWithTable;
|
||||
using ComponentsLibraryNet60.Models;
|
||||
using ControlsLibraryNet60.Data;
|
||||
using ControlsLibraryNet60.Models;
|
||||
using PluginsConventionLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using ClientsContracts.BusinessLogicContracts;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ClientBusinessLogic.BusinessLogics;
|
||||
using ClientsDatabaseImplement.Implements;
|
||||
|
||||
namespace WinForms
|
||||
{
|
||||
public class PluginsConvention : IPluginsConvention
|
||||
{
|
||||
private readonly IClientLogic _clientLogic;
|
||||
private readonly IStatusLogic _statusLogic;
|
||||
private readonly UserTreeView _myTreeView;
|
||||
private readonly WordLongTextComponent wordLongTextComponent;
|
||||
private readonly ExcelDiagramComponent excelDiagramComponent;
|
||||
private readonly ComponentDocumentWithTableMultiHeaderPdf componentDocumentWithTableMultiHeaderPdf;
|
||||
public string PluginName { get; set; } = "LabWork_03_plugin";
|
||||
|
||||
public UserControl GetControl
|
||||
{
|
||||
get { return _myTreeView; }
|
||||
}
|
||||
|
||||
public PluginsConvention()
|
||||
{
|
||||
_clientLogic = new ClientLogic(new ClientStorage());
|
||||
_statusLogic = new StatusLogic(new StatusStorage());
|
||||
wordLongTextComponent = new();
|
||||
excelDiagramComponent = new();
|
||||
componentDocumentWithTableMultiHeaderPdf = new();
|
||||
_myTreeView = new();
|
||||
}
|
||||
|
||||
public PluginsConventionElement GetElement
|
||||
{
|
||||
get
|
||||
{
|
||||
int Id = _myTreeView.getSelecetedNodeValue<ClientViewModel>()!.Id;
|
||||
byte[] bytes = new byte[16];
|
||||
BitConverter.GetBytes(Id).CopyTo(bytes, 0);
|
||||
Guid guid = new Guid(bytes);
|
||||
return new PluginsConventionElement() { Id = guid };
|
||||
}
|
||||
}
|
||||
|
||||
public Form GetForm(PluginsConventionElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return new FormClient(_clientLogic, _statusLogic);
|
||||
}
|
||||
else
|
||||
{
|
||||
FormClient form = new FormClient(_clientLogic, _statusLogic);
|
||||
form.Id = element.Id.GetHashCode();
|
||||
return form;
|
||||
}
|
||||
}
|
||||
|
||||
public Form GetThesaurus()
|
||||
{
|
||||
return new FormStatus(_statusLogic);
|
||||
}
|
||||
|
||||
public bool DeleteElement(PluginsConventionElement element)
|
||||
{
|
||||
_clientLogic.Delete(
|
||||
new ClientsContracts.BindingModels.ClientBindingModel { Id = element.Id.GetHashCode() }
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ReloadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var clients = _clientLogic.ReadList(null);
|
||||
if (clients != null)
|
||||
{
|
||||
_myTreeView.clear();
|
||||
|
||||
_myTreeView.setHierarchy(new List<(string, bool)> { ("StatusName", false), ("ViewAmount", false), ("Id", true), ("Name", true) });
|
||||
|
||||
foreach (var client in clients)
|
||||
{
|
||||
if (!client.Amount.HasValue)
|
||||
{
|
||||
client.ViewAmount = "нет покупок";
|
||||
}
|
||||
else
|
||||
{
|
||||
client.ViewAmount = client.Amount.Value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
_myTreeView.addItems(clients);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
ex.Message,
|
||||
"Ошибка",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
List<string> paragraphs = new List<string>();
|
||||
foreach (var client in _clientLogic.ReadList(null))
|
||||
{
|
||||
if (client.Amount == null)
|
||||
{
|
||||
paragraphs.Add(client.Name + ": " + client.Reviews);
|
||||
}
|
||||
}
|
||||
string path = saveDocument.FileName;
|
||||
wordLongTextComponent.createWithLongText(new WordLongTextInfo(path, "Аккаунты без суммы покупок", paragraphs.ToArray()));
|
||||
MessageBox.Show("Документ создан");
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
List<string> paragraphs = new List<string>();
|
||||
string path = saveDocument.FileName;
|
||||
var clients = _clientLogic.ReadList(null);
|
||||
foreach (var client in clients)
|
||||
{
|
||||
if (!client.Amount.HasValue)
|
||||
{
|
||||
client.DocAmount = "нет";
|
||||
}
|
||||
else
|
||||
{
|
||||
client.DocAmount = client.Amount.Value.ToString();
|
||||
}
|
||||
}
|
||||
ComponentDocumentWithTableHeaderDataConfig<ClientViewModel> config = new ComponentsLibraryNet60.Models.ComponentDocumentWithTableHeaderDataConfig<ClientViewModel>
|
||||
{
|
||||
Data = clients,
|
||||
UseUnion = false,
|
||||
Header = "Аккаунты",
|
||||
ColumnsRowsDataCount = (4, 1),
|
||||
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
|
||||
{
|
||||
(0, 0, "Id", "Id"),
|
||||
(1, 0, "ФИО", "Name"),
|
||||
(2, 0, "Статус", "StatusName"),
|
||||
(3, 0, "Сумма покупок", "DocAmount")
|
||||
},
|
||||
ColumnsRowsWidth = new List<(int Column, int Row)>
|
||||
{
|
||||
(10, 10),
|
||||
(10, 10),
|
||||
(10, 10),
|
||||
(10, 10)
|
||||
},
|
||||
ColumnUnion = new List<(int StartIndex, int Count)>(),
|
||||
FilePath = path
|
||||
};
|
||||
componentDocumentWithTableMultiHeaderPdf.CreateDoc(config);
|
||||
MessageBox.Show("Документ создан");
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
List<string> paragraphs = new List<string>();
|
||||
string path = saveDocument.FileName;
|
||||
var data = _clientLogic.ReadList(null).Where(x => x.Amount == null).GroupBy(x => x.StatusName).Select(x => new
|
||||
{
|
||||
StatusName = x.Key,
|
||||
StatusCount = x.Count(),
|
||||
}).ToList();
|
||||
excelDiagramComponent.createWithDiagram(path, "Статус без суммы покупок", "Статус без суммы покупок", ChubykinaComponents.LogicalComponents.DiagramLegendEnum.BottomRight,
|
||||
data, "StatusName", "StatusCount");
|
||||
MessageBox.Show("Документ создан");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
41
COP/WinForms/Program.cs
Normal file
41
COP/WinForms/Program.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using ClientBusinessLogic.BusinessLogics;
|
||||
using ClientsContracts.BusinessLogicContracts;
|
||||
using ClientsContracts.StorageContracts;
|
||||
using ClientsDatabaseImplement.Implements;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
|
||||
namespace WinForms
|
||||
{
|
||||
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.AddTransient<IStatusStorage, StatusStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IStatusLogic, StatusLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormClient>();
|
||||
services.AddTransient<FormStatus>();
|
||||
}
|
||||
}
|
||||
}
|
37
COP/WinForms/WinForms.csproj
Normal file
37
COP/WinForms/WinForms.csproj
Normal file
@ -0,0 +1,37 @@
|
||||
<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="ChubykinaComponents" Version="1.0.3" />
|
||||
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
|
||||
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.20">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="CreatePluginsFolder" BeforeTargets="PreBuildEvent" Condition="!Exists('$(SolutionDir)Plugins')">
|
||||
<MakeDir Directories="$(SolutionDir)Plugins" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CopyPlugins" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)Plugins\*.dll"" />
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BulatovaComponents\BulatovaComponents.csproj" />
|
||||
<ProjectReference Include="..\ClientBusinessLogic\ClientBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\ClientsDatabaseImplement\ClientsDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user