Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
3c0d1f9d6a | |||
d17275873b | |||
3eb4ab332d | |||
c5a31a3ca4 | |||
32e651c219 | |||
84c92c2d38 | |||
70ec02bfbd | |||
7d7ed2e49a | |||
2ba7165ccd | |||
6c2613df86 | |||
8888ebe3f0 | |||
1cd0c60973 | |||
101094a67a |
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
|
||||
|
26
COP/AppByPlugins/AppByPlugins.csproj
Normal file
26
COP/AppByPlugins/AppByPlugins.csproj
Normal file
@ -0,0 +1,26 @@
|
||||
<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="..\ClientDataBaseImplement\ClientDataBaseImplement.csproj" />
|
||||
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
188
COP/AppByPlugins/FormMain.Designer.cs
generated
Normal file
188
COP/AppByPlugins/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,188 @@
|
||||
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()
|
||||
{
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.ControlsStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ActionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ThesaurusToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.AddElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.UpdElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.DelElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.DocsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SimpleDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.TableDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ChartDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.panelControl = new System.Windows.Forms.Panel();
|
||||
this.menuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.ControlsStripMenuItem,
|
||||
this.ActionsToolStripMenuItem,
|
||||
this.DocsToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Padding = new System.Windows.Forms.Padding(7, 3, 0, 3);
|
||||
this.menuStrip.Size = new System.Drawing.Size(914, 30);
|
||||
this.menuStrip.TabIndex = 0;
|
||||
this.menuStrip.Text = "Меню";
|
||||
//
|
||||
// ControlsStripMenuItem
|
||||
//
|
||||
this.ControlsStripMenuItem.Name = "ControlsStripMenuItem";
|
||||
this.ControlsStripMenuItem.Size = new System.Drawing.Size(113, 24);
|
||||
this.ControlsStripMenuItem.Text = "Компоненты";
|
||||
//
|
||||
// ActionsToolStripMenuItem
|
||||
//
|
||||
this.ActionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.ThesaurusToolStripMenuItem,
|
||||
this.AddElementToolStripMenuItem,
|
||||
this.UpdElementToolStripMenuItem,
|
||||
this.DelElementToolStripMenuItem});
|
||||
this.ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem";
|
||||
this.ActionsToolStripMenuItem.Size = new System.Drawing.Size(88, 24);
|
||||
this.ActionsToolStripMenuItem.Text = "Действия";
|
||||
//
|
||||
// ThesaurusToolStripMenuItem
|
||||
//
|
||||
this.ThesaurusToolStripMenuItem.Name = "ThesaurusToolStripMenuItem";
|
||||
this.ThesaurusToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I)));
|
||||
this.ThesaurusToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.ThesaurusToolStripMenuItem.Text = "Справочник";
|
||||
this.ThesaurusToolStripMenuItem.Click += new System.EventHandler(this.ThesaurusToolStripMenuItem_Click);
|
||||
//
|
||||
// AddElementToolStripMenuItem
|
||||
//
|
||||
this.AddElementToolStripMenuItem.Name = "AddElementToolStripMenuItem";
|
||||
this.AddElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
|
||||
this.AddElementToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.AddElementToolStripMenuItem.Text = "Добавить";
|
||||
this.AddElementToolStripMenuItem.Click += new System.EventHandler(this.AddElementToolStripMenuItem_Click);
|
||||
//
|
||||
// UpdElementToolStripMenuItem
|
||||
//
|
||||
this.UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
|
||||
this.UpdElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U)));
|
||||
this.UpdElementToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.UpdElementToolStripMenuItem.Text = "Изменить";
|
||||
this.UpdElementToolStripMenuItem.Click += new System.EventHandler(this.UpdElementToolStripMenuItem_Click);
|
||||
//
|
||||
// DelElementToolStripMenuItem
|
||||
//
|
||||
this.DelElementToolStripMenuItem.Name = "DelElementToolStripMenuItem";
|
||||
this.DelElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D)));
|
||||
this.DelElementToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.DelElementToolStripMenuItem.Text = "Удалить";
|
||||
this.DelElementToolStripMenuItem.Click += new System.EventHandler(this.DelElementToolStripMenuItem_Click);
|
||||
//
|
||||
// DocsToolStripMenuItem
|
||||
//
|
||||
this.DocsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.SimpleDocToolStripMenuItem,
|
||||
this.TableDocToolStripMenuItem,
|
||||
this.ChartDocToolStripMenuItem});
|
||||
this.DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
|
||||
this.DocsToolStripMenuItem.Size = new System.Drawing.Size(101, 24);
|
||||
this.DocsToolStripMenuItem.Text = "Документы";
|
||||
//
|
||||
// SimpleDocToolStripMenuItem
|
||||
//
|
||||
this.SimpleDocToolStripMenuItem.Name = "SimpleDocToolStripMenuItem";
|
||||
this.SimpleDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||
this.SimpleDocToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
|
||||
this.SimpleDocToolStripMenuItem.Text = "Простой документ";
|
||||
this.SimpleDocToolStripMenuItem.Click += new System.EventHandler(this.SimpleDocToolStripMenuItem_Click);
|
||||
//
|
||||
// TableDocToolStripMenuItem
|
||||
//
|
||||
this.TableDocToolStripMenuItem.Name = "TableDocToolStripMenuItem";
|
||||
this.TableDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T)));
|
||||
this.TableDocToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
|
||||
this.TableDocToolStripMenuItem.Text = "Документ с таблицой";
|
||||
this.TableDocToolStripMenuItem.Click += new System.EventHandler(this.TableDocToolStripMenuItem_Click);
|
||||
//
|
||||
// ChartDocToolStripMenuItem
|
||||
//
|
||||
this.ChartDocToolStripMenuItem.Name = "ChartDocToolStripMenuItem";
|
||||
this.ChartDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
|
||||
this.ChartDocToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
|
||||
this.ChartDocToolStripMenuItem.Text = "Документ с диаграммой";
|
||||
this.ChartDocToolStripMenuItem.Click += new System.EventHandler(this.ChartDocToolStripMenuItem_Click);
|
||||
//
|
||||
// panelControl
|
||||
//
|
||||
this.panelControl.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panelControl.Location = new System.Drawing.Point(0, 30);
|
||||
this.panelControl.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.panelControl.Name = "panelControl";
|
||||
this.panelControl.Size = new System.Drawing.Size(914, 570);
|
||||
this.panelControl.TabIndex = 1;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(914, 600);
|
||||
this.Controls.Add(this.panelControl);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
this.MainMenuStrip = this.menuStrip;
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormMain";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Главная форма";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.MenuStrip menuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem ControlsStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem DocsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem SimpleDocToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem TableDocToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ChartDocToolStripMenuItem;
|
||||
private System.Windows.Forms.Panel panelControl;
|
||||
private System.Windows.Forms.ToolStripMenuItem ActionsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ThesaurusToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem AddElementToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem UpdElementToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem DelElementToolStripMenuItem;
|
||||
}
|
||||
}
|
226
COP/AppByPlugins/FormMain.cs
Normal file
226
COP/AppByPlugins/FormMain.cs
Normal file
@ -0,0 +1,226 @@
|
||||
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 = "Excel Files|*.xlsx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||
|
||||
}
|
||||
}
|
||||
private void CreateTableDoc()
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "Word Files|*.docx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||
|
||||
}
|
||||
}
|
||||
private void CreateChartDoc()
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "PDF Files|*.pdf"
|
||||
};
|
||||
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();
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
63
COP/AppByPlugins/FormMain.resx
Normal file
63
COP/AppByPlugins/FormMain.resx
Normal file
@ -0,0 +1,63 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</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());
|
||||
}
|
||||
}
|
||||
}
|
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", "{F22A3AAE-6F8D-4AEB-91B1-E8303166B5FF}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsTest", "WinFormsTest\WinFormsTest.csproj", "{F589AB00-F69A-4826-BE33-662F14E39F25}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientsDataModels", "ClientsDataModels\ClientsDataModels.csproj", "{9BE06619-49B5-4C59-984B-A70E7BF352D7}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientsBusinessLogics", "ClientsBusinessLogics\ClientsBusinessLogics.csproj", "{BF3640B7-0602-4D4A-95CF-51E2DD9E1A9D}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientsContracts", "ClientsContracts\ClientsContracts.csproj", "{8E8650C4-A930-442C-92CC-56082F3E072F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientDataBaseImplement", "ClientDataBaseImplement\ClientDataBaseImplement.csproj", "{4FB19656-B4A9-4070-BAD4-D9649DBEFB40}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChubykinaComponents", "ChubykinaComponents\ChubykinaComponents.csproj", "{335CABB5-5AC4-4688-92DD-5B91FEB16192}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsConventionLibrary", "PluginsConventionLibrary\PluginsConventionLibrary.csproj", "{5D395797-3AA9-41A7-A143-A0BBE28F3C5B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppByPlugins", "AppByPlugins\AppByPlugins.csproj", "{8EB2747B-F530-4BAF-9F0E-CD1A5624CC1C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F22A3AAE-6F8D-4AEB-91B1-E8303166B5FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F22A3AAE-6F8D-4AEB-91B1-E8303166B5FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F22A3AAE-6F8D-4AEB-91B1-E8303166B5FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F22A3AAE-6F8D-4AEB-91B1-E8303166B5FF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F589AB00-F69A-4826-BE33-662F14E39F25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F589AB00-F69A-4826-BE33-662F14E39F25}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F589AB00-F69A-4826-BE33-662F14E39F25}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F589AB00-F69A-4826-BE33-662F14E39F25}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9BE06619-49B5-4C59-984B-A70E7BF352D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9BE06619-49B5-4C59-984B-A70E7BF352D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9BE06619-49B5-4C59-984B-A70E7BF352D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9BE06619-49B5-4C59-984B-A70E7BF352D7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BF3640B7-0602-4D4A-95CF-51E2DD9E1A9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BF3640B7-0602-4D4A-95CF-51E2DD9E1A9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BF3640B7-0602-4D4A-95CF-51E2DD9E1A9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BF3640B7-0602-4D4A-95CF-51E2DD9E1A9D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8E8650C4-A930-442C-92CC-56082F3E072F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8E8650C4-A930-442C-92CC-56082F3E072F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8E8650C4-A930-442C-92CC-56082F3E072F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8E8650C4-A930-442C-92CC-56082F3E072F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4FB19656-B4A9-4070-BAD4-D9649DBEFB40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4FB19656-B4A9-4070-BAD4-D9649DBEFB40}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4FB19656-B4A9-4070-BAD4-D9649DBEFB40}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4FB19656-B4A9-4070-BAD4-D9649DBEFB40}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{335CABB5-5AC4-4688-92DD-5B91FEB16192}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{335CABB5-5AC4-4688-92DD-5B91FEB16192}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{335CABB5-5AC4-4688-92DD-5B91FEB16192}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{335CABB5-5AC4-4688-92DD-5B91FEB16192}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5D395797-3AA9-41A7-A143-A0BBE28F3C5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5D395797-3AA9-41A7-A143-A0BBE28F3C5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5D395797-3AA9-41A7-A143-A0BBE28F3C5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5D395797-3AA9-41A7-A143-A0BBE28F3C5B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8EB2747B-F530-4BAF-9F0E-CD1A5624CC1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8EB2747B-F530-4BAF-9F0E-CD1A5624CC1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8EB2747B-F530-4BAF-9F0E-CD1A5624CC1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8EB2747B-F530-4BAF-9F0E-CD1A5624CC1C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F36B68A2-46C2-4F08-98D8-0F0C0E014742}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
21
COP/ChubykinaComponents/ChubykinaComponents.csproj
Normal file
21
COP/ChubykinaComponents/ChubykinaComponents.csproj
Normal file
@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
<Version>$(VersionPrefix)1.0.3</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Exceptions\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Office.Interop.Excel" Version="15.0.4795.1001" />
|
||||
<PackageReference Include="MicrosoftOfficeCore" Version="15.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
58
COP/ChubykinaComponents/Components/UserCheckedListBox.Designer.cs
generated
Normal file
58
COP/ChubykinaComponents/Components/UserCheckedListBox.Designer.cs
generated
Normal file
@ -0,0 +1,58 @@
|
||||
namespace ChubykinaComponents.Components
|
||||
{
|
||||
partial class UserCheckedListBox
|
||||
{
|
||||
/// <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.checkedListBox = new System.Windows.Forms.CheckedListBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// checkedListBox
|
||||
//
|
||||
this.checkedListBox.FormattingEnabled = true;
|
||||
this.checkedListBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.checkedListBox.Name = "checkedListBox";
|
||||
this.checkedListBox.Size = new System.Drawing.Size(150, 114);
|
||||
this.checkedListBox.TabIndex = 0;
|
||||
this.checkedListBox.SelectedIndexChanged += new System.EventHandler(this.checkedListBox_SelectedIndexChanged);
|
||||
//
|
||||
// UserCheckedListBox
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.checkedListBox);
|
||||
this.Name = "UserCheckedListBox";
|
||||
this.Size = new System.Drawing.Size(150, 115);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckedListBox checkedListBox;
|
||||
}
|
||||
}
|
65
COP/ChubykinaComponents/Components/UserCheckedListBox.cs
Normal file
65
COP/ChubykinaComponents/Components/UserCheckedListBox.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 ChubykinaComponents.Components
|
||||
{
|
||||
public partial class UserCheckedListBox : UserControl
|
||||
{
|
||||
public UserCheckedListBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public string? selectedItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return checkedListBox.SelectedItem is null ? null : checkedListBox.SelectedItem.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && checkedListBox.Items.Contains(value)) {
|
||||
checkedListBox.SelectedItem = value;
|
||||
checkedListBox.SetItemChecked(checkedListBox.SelectedIndex, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event Action<string?> SelectedItemChange;
|
||||
|
||||
public void addItems(List<string> items)
|
||||
{
|
||||
foreach (string item in items)
|
||||
{
|
||||
checkedListBox.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
checkedListBox.Items.Clear();
|
||||
}
|
||||
|
||||
private void checkedListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (checkedListBox.CheckedItems.Count > 1)
|
||||
{
|
||||
foreach (int index in checkedListBox.CheckedIndices)
|
||||
{
|
||||
if (index != checkedListBox.SelectedIndex)
|
||||
{
|
||||
checkedListBox.SetItemChecked(index, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
SelectedItemChange?.Invoke(checkedListBox.SelectedItem.ToString());
|
||||
}
|
||||
}
|
||||
}
|
120
COP/ChubykinaComponents/Components/UserCheckedListBox.resx
Normal file
120
COP/ChubykinaComponents/Components/UserCheckedListBox.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
56
COP/ChubykinaComponents/Components/UserDatePicker.Designer.cs
generated
Normal file
56
COP/ChubykinaComponents/Components/UserDatePicker.Designer.cs
generated
Normal file
@ -0,0 +1,56 @@
|
||||
namespace ChubykinaComponents.Components
|
||||
{
|
||||
partial class UserDatePicker
|
||||
{
|
||||
/// <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.dateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
this.dateTimePicker.Location = new System.Drawing.Point(3, 3);
|
||||
this.dateTimePicker.Name = "dateTimePicker";
|
||||
this.dateTimePicker.Size = new System.Drawing.Size(250, 27);
|
||||
this.dateTimePicker.TabIndex = 0;
|
||||
this.dateTimePicker.ValueChanged += new System.EventHandler(this.dateTimePicker_ValueChanged);
|
||||
//
|
||||
// UserDatePicker
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.dateTimePicker);
|
||||
this.Name = "UserDatePicker";
|
||||
this.Size = new System.Drawing.Size(257, 38);
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DateTimePicker dateTimePicker;
|
||||
}
|
||||
}
|
80
COP/ChubykinaComponents/Components/UserDatePicker.cs
Normal file
80
COP/ChubykinaComponents/Components/UserDatePicker.cs
Normal file
@ -0,0 +1,80 @@
|
||||
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.Exceptions;
|
||||
|
||||
namespace ChubykinaComponents.Components
|
||||
{
|
||||
public partial class UserDatePicker : UserControl
|
||||
{
|
||||
public UserDatePicker()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public event Action<DateTime> DateChange;
|
||||
private bool lowBoundrySet = false;
|
||||
private bool highBoundrySet = false;
|
||||
|
||||
public bool BoundriesSet { get { return lowBoundrySet && highBoundrySet; } }
|
||||
|
||||
public DateTime? dateFrom
|
||||
{
|
||||
get
|
||||
{
|
||||
return lowBoundrySet ? dateTimePicker.MinDate : null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
dateTimePicker.MinDate = value.Value;
|
||||
lowBoundrySet = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? dateTo
|
||||
{
|
||||
get
|
||||
{
|
||||
return highBoundrySet ? dateTimePicker.MaxDate : null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
dateTimePicker.MaxDate = value.Value;
|
||||
highBoundrySet = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!lowBoundrySet || !highBoundrySet)
|
||||
{
|
||||
throw new DateBoundsNotSetException("Date bounds are not set.");
|
||||
}
|
||||
return dateTimePicker.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (lowBoundrySet && highBoundrySet && value.HasValue && value.Value >= dateFrom && value.Value <= dateTo) dateTimePicker.Value = value.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private void dateTimePicker_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
DateChange?.Invoke(dateTimePicker.Value);
|
||||
}
|
||||
}
|
||||
}
|
120
COP/ChubykinaComponents/Components/UserDatePicker.resx
Normal file
120
COP/ChubykinaComponents/Components/UserDatePicker.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>
|
55
COP/ChubykinaComponents/Components/UserTreeView.Designer.cs
generated
Normal file
55
COP/ChubykinaComponents/Components/UserTreeView.Designer.cs
generated
Normal file
@ -0,0 +1,55 @@
|
||||
namespace ChubykinaComponents.Components
|
||||
{
|
||||
partial class UserTreeView
|
||||
{
|
||||
/// <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.treeView = new System.Windows.Forms.TreeView();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// treeView
|
||||
//
|
||||
this.treeView.Location = new System.Drawing.Point(0, 0);
|
||||
this.treeView.Name = "treeView";
|
||||
this.treeView.Size = new System.Drawing.Size(295, 212);
|
||||
this.treeView.TabIndex = 0;
|
||||
//
|
||||
// UserTreeView
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.treeView);
|
||||
this.Name = "UserTreeView";
|
||||
this.Size = new System.Drawing.Size(295, 212);
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TreeView treeView;
|
||||
}
|
||||
}
|
95
COP/ChubykinaComponents/Components/UserTreeView.cs
Normal file
95
COP/ChubykinaComponents/Components/UserTreeView.cs
Normal file
@ -0,0 +1,95 @@
|
||||
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 static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace ChubykinaComponents.Components
|
||||
{
|
||||
public partial class UserTreeView : UserControl
|
||||
{
|
||||
public UserTreeView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private List<(string, bool)> hierarchy = new List<(string, bool)>();
|
||||
|
||||
public int SelectedNodeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return treeView.SelectedNode?.Index ?? -1;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (treeView.SelectedNode == null)
|
||||
treeView.SelectedNode = value >= 0 && value < treeView.Nodes.Count ? treeView.Nodes[value] : treeView.SelectedNode;
|
||||
else
|
||||
treeView.SelectedNode = value >= 0 && value < treeView.SelectedNode.Nodes.Count ? treeView.SelectedNode.Nodes[value] : treeView.SelectedNode;
|
||||
}
|
||||
}
|
||||
|
||||
public T? getSelecetedNodeValue<T>()
|
||||
{
|
||||
if (treeView.SelectedNode == null || treeView.SelectedNode.Nodes.Count > 0) return default(T);
|
||||
TreeNode? node = treeView.SelectedNode;
|
||||
var type = typeof(T);
|
||||
var properties = type.GetProperties();
|
||||
var item = Activator.CreateInstance(type);
|
||||
|
||||
while (node != null)
|
||||
{
|
||||
var property = properties.FirstOrDefault(x => x.Name == node.Name);
|
||||
if (property != null)
|
||||
{
|
||||
property.SetValue(item, Convert.ChangeType(node.Text, property.PropertyType));
|
||||
}
|
||||
node = node.Parent;
|
||||
}
|
||||
|
||||
return item != null ? (T)item : default(T);
|
||||
}
|
||||
|
||||
public void setHierarchy(List<(string, bool)> fields)
|
||||
{
|
||||
hierarchy = fields;
|
||||
}
|
||||
|
||||
public void addItems<T>(List<T> items)
|
||||
{
|
||||
var type = typeof(T);
|
||||
var properties = type.GetProperties();
|
||||
foreach (T item in items)
|
||||
{
|
||||
TreeNodeCollection nodes = treeView.Nodes;
|
||||
for (int i = 0; i < hierarchy.Count; i++)
|
||||
{
|
||||
var property = properties.FirstOrDefault(x => x.Name.Equals(hierarchy[i].Item1));
|
||||
if (property is not null)
|
||||
{
|
||||
var node = nodes.Find(property.Name, false).FirstOrDefault(x => x.Text == property.GetValue(item).ToString());
|
||||
if (node is not null && !hierarchy[i].Item2)
|
||||
{
|
||||
nodes = node.Nodes;
|
||||
}
|
||||
else
|
||||
{
|
||||
TreeNode newNode = nodes.Add(property.Name, property.GetValue(item).ToString());
|
||||
nodes = newNode.Nodes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void clear()
|
||||
{
|
||||
treeView.Nodes.Clear();
|
||||
}
|
||||
}
|
||||
}
|
120
COP/ChubykinaComponents/Components/UserTreeView.resx
Normal file
120
COP/ChubykinaComponents/Components/UserTreeView.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,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ChubykinaComponents.Exceptions
|
||||
{
|
||||
[Serializable]
|
||||
public class DateBoundsNotSetException : ApplicationException
|
||||
{
|
||||
public DateBoundsNotSetException() : base() { }
|
||||
public DateBoundsNotSetException(string message) : base(message) { }
|
||||
public DateBoundsNotSetException(string message, Exception exception) : base(message, exception) { }
|
||||
protected DateBoundsNotSetException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ChubykinaComponents.Exceptions
|
||||
{
|
||||
public class DateOutOfBoundsException : ApplicationException
|
||||
{
|
||||
public DateOutOfBoundsException() : base() { }
|
||||
public DateOutOfBoundsException(string message) : base(message) { }
|
||||
public DateOutOfBoundsException(string message, Exception exception) : base(message, exception) { }
|
||||
protected DateOutOfBoundsException(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 ChubykinaComponents.LogicalComponents
|
||||
{
|
||||
public enum DiagramLegendEnum
|
||||
{
|
||||
TopLeft = 0,
|
||||
TopRight = 1,
|
||||
BottomRight = 2,
|
||||
BottomLeft = 3,
|
||||
}
|
||||
}
|
36
COP/ChubykinaComponents/LogicalComponents/ExcelDiagramComponent.Designer.cs
generated
Normal file
36
COP/ChubykinaComponents/LogicalComponents/ExcelDiagramComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace ChubykinaComponents.LogicalComponents
|
||||
{
|
||||
partial class ExcelDiagramComponent
|
||||
{
|
||||
/// <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,117 @@
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
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 ChubykinaComponents.LogicalComponents
|
||||
{
|
||||
public partial class ExcelDiagramComponent : Component
|
||||
{
|
||||
public ExcelDiagramComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ExcelDiagramComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
public bool 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);
|
||||
try
|
||||
{
|
||||
Worksheet worksheet = (Worksheet)workbook.Worksheets.get_Item(1);
|
||||
|
||||
PropertyInfo? seriesName = typeof(T).GetProperty(seriesNameField);
|
||||
PropertyInfo? value = typeof(T).GetProperty(valueField);
|
||||
if (seriesName == null || value == null) throw new ArgumentException("Переданного свойства не существует");
|
||||
int columnCount = 2;
|
||||
foreach (var item in data)
|
||||
{
|
||||
var cell = worksheet.get_Range("A" + columnCount, "A" + columnCount);
|
||||
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);
|
||||
|
||||
cell = worksheet.get_Range("B" + columnCount, "B" + columnCount);
|
||||
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 = value.GetValue(item);
|
||||
|
||||
columnCount++;
|
||||
}
|
||||
|
||||
//header
|
||||
var excelcells = worksheet.get_Range("A1", "A1");
|
||||
excelcells.Font.Bold = true;
|
||||
excelcells.Font.Size = 14;
|
||||
excelcells.Font.Name = "Times New Roman";
|
||||
excelcells.ColumnWidth = 8;
|
||||
excelcells.RowHeight = 25;
|
||||
excelcells.HorizontalAlignment = Constants.xlCenter;
|
||||
excelcells.VerticalAlignment = Constants.xlCenter;
|
||||
excelcells.Value2 = title;
|
||||
|
||||
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 range = worksheet.get_Range($"A2", $"B{columnCount - 1}");
|
||||
chart.SetSourceData(range);
|
||||
chart.ChartType = XlChartType.xlPie;
|
||||
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);
|
||||
|
||||
object missing = System.Reflection.Missing.Value;
|
||||
workbook.SaveAs(path, XlFileFormat.xlOpenXMLWorkbook, missing, missing, false, false, XlSaveAsAccessMode.xlNoChange,
|
||||
XlSaveConflictResolution.xlUserResolution, true, missing, missing, missing);
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
22
COP/ChubykinaComponents/LogicalComponents/ExcelImageInfo.cs
Normal file
22
COP/ChubykinaComponents/LogicalComponents/ExcelImageInfo.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ChubykinaComponents.LogicalComponents
|
||||
{
|
||||
public class ExcelImageInfo
|
||||
{
|
||||
public ExcelImageInfo(string path, string title, string[] imagePaths)
|
||||
{
|
||||
this.path = path;
|
||||
this.title = title;
|
||||
this.imagePaths = imagePaths;
|
||||
}
|
||||
|
||||
public string path;
|
||||
public string title;
|
||||
public string[] imagePaths;
|
||||
}
|
||||
}
|
36
COP/ChubykinaComponents/LogicalComponents/ExcelImagesComponent.Designer.cs
generated
Normal file
36
COP/ChubykinaComponents/LogicalComponents/ExcelImagesComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace ChubykinaComponents.LogicalComponents
|
||||
{
|
||||
partial class ExcelImagesComponent
|
||||
{
|
||||
/// <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,77 @@
|
||||
using Microsoft.Office.Core;
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ChubykinaComponents.LogicalComponents
|
||||
{
|
||||
public partial class ExcelImagesComponent : Component
|
||||
{
|
||||
public ExcelImagesComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ExcelImagesComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
public bool createWithImages(ExcelImageInfo info)
|
||||
{
|
||||
if (string.IsNullOrEmpty(info.path) || string.IsNullOrEmpty(info.title) || info.imagePaths == null || info.imagePaths.Length == 0)
|
||||
{
|
||||
throw new ArgumentException("Не все поля заполнены.");
|
||||
}
|
||||
var excelApp = new Microsoft.Office.Interop.Excel.Application { SheetsInNewWorkbook = 1 };
|
||||
Workbook workbook = excelApp.Workbooks.Add(Type.Missing);
|
||||
try
|
||||
{
|
||||
//create
|
||||
Worksheet worksheet = (Worksheet)workbook.Worksheets.get_Item(1);
|
||||
|
||||
//header
|
||||
var excelcells = worksheet.get_Range("A1", "D1");
|
||||
excelcells.Merge(Type.Missing);
|
||||
excelcells.Font.Bold = true;
|
||||
excelcells.Font.Size = 14;
|
||||
excelcells.Font.Name = "Times New Roman";
|
||||
excelcells.ColumnWidth = 8;
|
||||
excelcells.RowHeight = 25;
|
||||
excelcells.HorizontalAlignment = Constants.xlCenter;
|
||||
excelcells.VerticalAlignment = Constants.xlCenter;
|
||||
excelcells.Value2 = info.title;
|
||||
|
||||
int topOffset = 25;
|
||||
foreach (string path in info.imagePaths)
|
||||
{
|
||||
Bitmap bm = new Bitmap(path);
|
||||
worksheet.Shapes.AddPicture2(path, MsoTriState.msoFalse, MsoTriState.msoCTrue, 0, topOffset, bm.Width, bm.Height, MsoPictureCompress.msoPictureCompressFalse);
|
||||
topOffset += bm.Height;
|
||||
bm.Dispose();
|
||||
}
|
||||
|
||||
//save
|
||||
object missing = System.Reflection.Missing.Value;
|
||||
workbook.SaveAs(info.path, XlFileFormat.xlOpenXMLWorkbook, missing, missing, false, false, XlSaveAsAccessMode.xlNoChange,
|
||||
XlSaveConflictResolution.xlUserResolution, true, missing, missing, missing);
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
37
COP/ChubykinaComponents/LogicalComponents/ExcelTableComponent.Designer.cs
generated
Normal file
37
COP/ChubykinaComponents/LogicalComponents/ExcelTableComponent.Designer.cs
generated
Normal file
@ -0,0 +1,37 @@
|
||||
namespace ChubykinaComponents.LogicalComponents
|
||||
{
|
||||
partial class ExcelTableComponent
|
||||
{
|
||||
/// <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();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
193
COP/ChubykinaComponents/LogicalComponents/ExcelTableComponent.cs
Normal file
193
COP/ChubykinaComponents/LogicalComponents/ExcelTableComponent.cs
Normal file
@ -0,0 +1,193 @@
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
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 ChubykinaComponents.LogicalComponents
|
||||
{
|
||||
public partial class ExcelTableComponent : UserControl
|
||||
{
|
||||
public ExcelTableComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ExcelTableComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
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 bool createWithTable<T>(string path, string title, List<(int, int)> merges, List<int> heights, List<(string, string)> headers, List<T> items)
|
||||
{
|
||||
if (merges.Count == 0 || heights.Count == 0 || headers.Count == 0 || items.Count == 0) throw new ArgumentException("Недостаточно данных");
|
||||
int[] cellsArray = new int[heights.Count];
|
||||
foreach (var merge in merges)
|
||||
{
|
||||
if (merge.Item1 >= merge.Item2) throw new ArgumentException("Неправильно заполнены объединения строк");
|
||||
for (int i = merge.Item1; i < merge.Item2; i++)
|
||||
{
|
||||
cellsArray[i]++;
|
||||
}
|
||||
}
|
||||
foreach (int cell in cellsArray)
|
||||
{
|
||||
if (cell > 1) throw new ArgumentException("Объединения заходят друг на друга");
|
||||
}
|
||||
|
||||
var excelApp = new Microsoft.Office.Interop.Excel.Application { SheetsInNewWorkbook = 1 };
|
||||
Workbook workbook = excelApp.Workbooks.Add(Type.Missing);
|
||||
try
|
||||
{
|
||||
//create
|
||||
Worksheet worksheet = (Worksheet)workbook.Worksheets.get_Item(1);
|
||||
|
||||
//header
|
||||
var excelcells = worksheet.get_Range("A1", "A1");
|
||||
excelcells.Font.Bold = true;
|
||||
excelcells.Font.Size = 14;
|
||||
excelcells.Font.Name = "Times New Roman";
|
||||
excelcells.ColumnWidth = 8;
|
||||
excelcells.RowHeight = 25;
|
||||
excelcells.HorizontalAlignment = Constants.xlCenter;
|
||||
excelcells.VerticalAlignment = Constants.xlCenter;
|
||||
excelcells.Value2 = title;
|
||||
|
||||
//checks
|
||||
List<Microsoft.Office.Interop.Excel.Range> ranges = new List<Microsoft.Office.Interop.Excel.Range>();
|
||||
foreach (var merge in merges)
|
||||
{
|
||||
ranges.Add(worksheet.get_Range("A" + (merge.Item1 + 2), "A" + (merge.Item2 + 2)));
|
||||
}
|
||||
|
||||
int rangeIndex = 0;
|
||||
int headerIndex = 0;
|
||||
List<FieldInfo> cellFields = new List<FieldInfo>();
|
||||
var type = typeof(T);
|
||||
for (int i = 0; i < heights.Count; i++)
|
||||
{
|
||||
if (cellsArray[i] == 1)
|
||||
{
|
||||
//work with merge
|
||||
if (!string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
|
||||
|
||||
var groupRange = ranges[rangeIndex];
|
||||
groupRange.Merge(Type.Missing);
|
||||
groupRange.Font.Bold = true;
|
||||
groupRange.Font.Size = 14;
|
||||
groupRange.Font.Name = "Times New Roman";
|
||||
groupRange.ColumnWidth = 20;
|
||||
groupRange.HorizontalAlignment = Constants.xlCenter;
|
||||
groupRange.VerticalAlignment = Constants.xlCenter;
|
||||
groupRange.Value2 = headers[headerIndex].Item2;
|
||||
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 field = type.GetField(headers[headerIndex].Item1);
|
||||
if (field == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
|
||||
//format header
|
||||
var range = worksheet.get_Range("B" + (i + 2), "B" + (i + 2));
|
||||
range.Font.Bold = true;
|
||||
range.Font.Size = 14;
|
||||
range.Font.Name = "Times New Roman";
|
||||
range.ColumnWidth = 20;
|
||||
range.RowHeight = heights[i];
|
||||
range.HorizontalAlignment = Constants.xlCenter;
|
||||
range.VerticalAlignment = Constants.xlCenter;
|
||||
range.Value2 = headers[headerIndex].Item2;
|
||||
|
||||
cellFields.Add(field);
|
||||
headerIndex++;
|
||||
}
|
||||
i--;
|
||||
rangeIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//work with cell
|
||||
if (string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
|
||||
var field = type.GetField(headers[headerIndex].Item1);
|
||||
if (field == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
|
||||
//format header
|
||||
var range = worksheet.get_Range("A" + (i + 2), "B" + (i + 2));
|
||||
range.Merge(Type.Missing);
|
||||
range.Font.Bold = true;
|
||||
range.Font.Size = 14;
|
||||
range.Font.Name = "Times New Roman";
|
||||
range.ColumnWidth = 40;
|
||||
range.RowHeight = heights[i];
|
||||
range.HorizontalAlignment = Constants.xlCenter;
|
||||
range.VerticalAlignment = Constants.xlCenter;
|
||||
range.Value2 = headers[headerIndex].Item2;
|
||||
|
||||
cellFields.Add(field);
|
||||
headerIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
int columnNum = 3;
|
||||
foreach (T item in items)
|
||||
{
|
||||
string column = GetExcelColumnName(columnNum);
|
||||
int rowNum = 2;
|
||||
foreach (var cellField in cellFields)
|
||||
{
|
||||
var range = worksheet.get_Range(column + rowNum, column + rowNum);
|
||||
range.Font.Size = 14;
|
||||
range.Font.Name = "Times New Roman";
|
||||
range.ColumnWidth = 20;
|
||||
range.HorizontalAlignment = Constants.xlCenter;
|
||||
range.VerticalAlignment = Constants.xlCenter;
|
||||
range.Value2 = cellField.FieldType == typeof(bool) ? ((bool)cellField.GetValue(item) ? "Да" : "Нет") : cellField.GetValue(item);
|
||||
|
||||
rowNum++;
|
||||
}
|
||||
columnNum++;
|
||||
}
|
||||
var borderRange = worksheet.get_Range("A2", GetExcelColumnName(columnNum - 1) + (headerIndex - 1));
|
||||
borderRange.Borders.LineStyle = XlLineStyle.xlContinuous;
|
||||
borderRange.Borders.Weight = 2d;
|
||||
|
||||
//save
|
||||
object missing = System.Reflection.Missing.Value;
|
||||
workbook.SaveAs(path, XlFileFormat.xlOpenXMLWorkbook, missing, missing, false, false, XlSaveAsAccessMode.xlNoChange,
|
||||
XlSaveConflictResolution.xlUserResolution, true, missing, missing, missing);
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
23
COP/ClientDataBaseImplement/ClientDataBaseImplement.csproj
Normal file
23
COP/ClientDataBaseImplement/ClientDataBaseImplement.csproj
Normal file
@ -0,0 +1,23 @@
|
||||
<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" />
|
||||
<ProjectReference Include="..\ClientsDataModels\ClientsDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
26
COP/ClientDataBaseImplement/ClientsDatabase.cs
Normal file
26
COP/ClientDataBaseImplement/ClientsDatabase.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ClientDataBaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClientDataBaseImplement
|
||||
{
|
||||
public class ClientsDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-0CI5KVE\SQLEXPRESS;Initial Catalog=ClientDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
public virtual DbSet<Category> Categories { set; get; }
|
||||
}
|
||||
}
|
85
COP/ClientDataBaseImplement/Implements/CategoryStorage.cs
Normal file
85
COP/ClientDataBaseImplement/Implements/CategoryStorage.cs
Normal file
@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.SearchModels;
|
||||
using ClientsContracts.StorageContracts;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ClientDataBaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Principal;
|
||||
|
||||
namespace ClientDataBaseImplement.Implements
|
||||
{
|
||||
public class CategoryStorage : ICategoryStorage
|
||||
{
|
||||
public List<CategoryViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ClientsDatabase();
|
||||
return context.Categories
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<CategoryViewModel> GetFilteredList(CategorySearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ClientsDatabase();
|
||||
return context.Categories
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public CategoryViewModel? GetElement(CategorySearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ClientsDatabase();
|
||||
return context.Categories
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public CategoryViewModel? Insert(CategoryBindingModel model)
|
||||
{
|
||||
var newCategory = Category.Create(model);
|
||||
if (newCategory == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ClientsDatabase();
|
||||
context.Categories.Add(newCategory);
|
||||
context.SaveChanges();
|
||||
return newCategory.GetViewModel;
|
||||
}
|
||||
public CategoryViewModel? Update(CategoryBindingModel model)
|
||||
{
|
||||
using var context = new ClientsDatabase();
|
||||
var component = context.Categories.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
public CategoryViewModel? Delete(CategoryBindingModel model)
|
||||
{
|
||||
using var context = new ClientsDatabase();
|
||||
var element = context.Categories.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Categories.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
92
COP/ClientDataBaseImplement/Implements/ClientStorage.cs
Normal file
92
COP/ClientDataBaseImplement/Implements/ClientStorage.cs
Normal file
@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.SearchModels;
|
||||
using ClientsContracts.StorageContracts;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ClientDataBaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Principal;
|
||||
|
||||
namespace ClientDataBaseImplement.Implements
|
||||
{
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
public List<ClientViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ClientsDatabase();
|
||||
return context.Clients
|
||||
.Include(x => x.Category)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new ClientsDatabase();
|
||||
return context.Clients
|
||||
.Include(x => x.Category)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new ClientsDatabase();
|
||||
return context.Clients
|
||||
.Include(x => x.Category)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
using var context = new ClientsDatabase();
|
||||
var newClient = Client.Create(context, model);
|
||||
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);
|
||||
context.SaveChanges();
|
||||
return client.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Delete(ClientBindingModel model)
|
||||
{
|
||||
using var context = new ClientsDatabase();
|
||||
var element = context.Clients
|
||||
.Include(x => x.Category)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Clients.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
87
COP/ClientDataBaseImplement/Migrations/20241028080342_InitialCreate.Designer.cs
generated
Normal file
87
COP/ClientDataBaseImplement/Migrations/20241028080342_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,87 @@
|
||||
// <auto-generated />
|
||||
using ClientDataBaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ClientDataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ClientsDatabase))]
|
||||
[Migration("20241028080342_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("ClientDataBaseImplement.Models.Category", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Categories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClientDataBaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CategoryId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Fio")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Photo")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CategoryId");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClientDataBaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.HasOne("ClientDataBaseImplement.Models.Category", "Category")
|
||||
.WithMany()
|
||||
.HasForeignKey("CategoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Category");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ClientDataBaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Categories",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Categories", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Fio = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
CategoryId = table.Column<int>(type: "int", nullable: false),
|
||||
Photo = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Clients_Categories_CategoryId",
|
||||
column: x => x.CategoryId,
|
||||
principalTable: "Categories",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Clients_CategoryId",
|
||||
table: "Clients",
|
||||
column: "CategoryId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Categories");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
// <auto-generated />
|
||||
using ClientDataBaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ClientDataBaseImplement.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("ClientDataBaseImplement.Models.Category", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Categories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClientDataBaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CategoryId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Fio")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Photo")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CategoryId");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClientDataBaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.HasOne("ClientDataBaseImplement.Models.Category", "Category")
|
||||
.WithMany()
|
||||
.HasForeignKey("CategoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Category");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
54
COP/ClientDataBaseImplement/Models/Category.cs
Normal file
54
COP/ClientDataBaseImplement/Models/Category.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using ClientsDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.ViewModels;
|
||||
|
||||
namespace ClientDataBaseImplement.Models
|
||||
{
|
||||
public class Category : ICategoryModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
|
||||
public static Category? Create(CategoryBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Category()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
};
|
||||
}
|
||||
public static Category? Create(CategoryViewModel? model)
|
||||
{
|
||||
return new Category()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
};
|
||||
}
|
||||
public void Update(CategoryBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Name = model.Name;
|
||||
}
|
||||
public CategoryViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
};
|
||||
}
|
||||
}
|
68
COP/ClientDataBaseImplement/Models/Client.cs
Normal file
68
COP/ClientDataBaseImplement/Models/Client.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using ClientsDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.ViewModels;
|
||||
|
||||
namespace ClientDataBaseImplement.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
{
|
||||
[Required]
|
||||
public string Fio { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; private set; }
|
||||
|
||||
public int CategoryId { get; set; }
|
||||
|
||||
public virtual Category Category { get; set; } = new();
|
||||
[Required]
|
||||
public string Photo { get; set; } = string.Empty;
|
||||
|
||||
public static Client? Create(ClientsDatabase context, ClientBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Client()
|
||||
{
|
||||
Id = model.Id,
|
||||
Fio = model.Fio,
|
||||
Email = model.Email,
|
||||
CategoryId = model.CategoryId,
|
||||
Category = context.Categories.First(x => x.Id == model.CategoryId),
|
||||
Photo = model.Photo,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ClientBindingModel? model, ClientsDatabase context)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Fio = model.Fio;
|
||||
CategoryId = model.CategoryId;
|
||||
Category = context.Categories.First(x => x.Id == model.CategoryId);
|
||||
Photo = model.Photo;
|
||||
}
|
||||
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Fio = Fio,
|
||||
Email = Email,
|
||||
CategoryId = CategoryId,
|
||||
CategoryName = Category.Name,
|
||||
Photo = Photo,
|
||||
};
|
||||
}
|
||||
}
|
92
COP/ClientsBusinessLogics/BusinessLogics/CategoryLogic.cs
Normal file
92
COP/ClientsBusinessLogics/BusinessLogics/CategoryLogic.cs
Normal file
@ -0,0 +1,92 @@
|
||||
using ClientsContracts.BusinessLogicContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ClientsContracts.StorageContracts;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ClientsContracts.SearchModels;
|
||||
using ClientsContracts.BindingModels;
|
||||
|
||||
namespace ClientsBusinessLogics.BusinessLogics
|
||||
{
|
||||
public class CategoryLogic : ICategoryLogic
|
||||
{
|
||||
private readonly ICategoryStorage _categoryStorage;
|
||||
|
||||
public CategoryLogic(ICategoryStorage categoryStorage)
|
||||
{
|
||||
_categoryStorage = categoryStorage;
|
||||
}
|
||||
|
||||
public List<CategoryViewModel>? ReadList(CategorySearchModel? model)
|
||||
{
|
||||
var list = model == null ? _categoryStorage.GetFullList() : _categoryStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public CategoryViewModel? ReadElement(CategorySearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
var element = _categoryStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(CategoryBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_categoryStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(CategoryBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_categoryStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(CategoryBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_categoryStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(CategoryBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия категории", nameof(model.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
96
COP/ClientsBusinessLogics/BusinessLogics/ClientLogic.cs
Normal file
96
COP/ClientsBusinessLogics/BusinessLogics/ClientLogic.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using ClientsContracts.BusinessLogicContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ClientsContracts.StorageContracts;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ClientsContracts.SearchModels;
|
||||
using ClientsContracts.BindingModels;
|
||||
|
||||
namespace ClientsBusinessLogics.BusinessLogics
|
||||
{
|
||||
public class ClientLogic : IClientLogic
|
||||
{
|
||||
private readonly IClientStorage _clientStorage;
|
||||
|
||||
public ClientLogic(IClientStorage clientStorage)
|
||||
{
|
||||
_clientStorage = clientStorage;
|
||||
}
|
||||
|
||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||
{
|
||||
var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
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 bool Create(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_clientStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_clientStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_clientStorage.Delete(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.Fio))
|
||||
{
|
||||
throw new ArgumentNullException("Нет имени клиента", nameof(model.Fio));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
throw new ArgumentNullException("Нет электронной почты пользователя", nameof(model.Email));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
13
COP/ClientsBusinessLogics/ClientsBusinessLogics.csproj
Normal file
13
COP/ClientsBusinessLogics/ClientsBusinessLogics.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="..\ClientsContracts\ClientsContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
16
COP/ClientsContracts/BindingModels/CategoryBindingModel.cs
Normal file
16
COP/ClientsContracts/BindingModels/CategoryBindingModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using ClientsDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClientsContracts.BindingModels
|
||||
{
|
||||
public class CategoryBindingModel : ICategoryModel
|
||||
{
|
||||
public string Name { get; set; } = String.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
22
COP/ClientsContracts/BindingModels/ClientBindingModel.cs
Normal file
22
COP/ClientsContracts/BindingModels/ClientBindingModel.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using ClientsDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClientsContracts.BindingModels
|
||||
{
|
||||
public class ClientBindingModel : IClientModel
|
||||
{
|
||||
public string Fio { get; set; } = string.Empty;
|
||||
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
|
||||
public int CategoryId { get; set; }
|
||||
|
||||
public string Photo { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ClientsContracts.SearchModels;
|
||||
using ClientsContracts.BindingModels;
|
||||
|
||||
namespace ClientsContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface ICategoryLogic
|
||||
{
|
||||
List<CategoryViewModel>? ReadList(CategorySearchModel? model);
|
||||
CategoryViewModel? ReadElement(CategorySearchModel model);
|
||||
bool Create(CategoryBindingModel model);
|
||||
bool Update(CategoryBindingModel model);
|
||||
bool Delete(CategoryBindingModel model);
|
||||
}
|
||||
}
|
20
COP/ClientsContracts/BusinessLogicContracts/IClientLogic.cs
Normal file
20
COP/ClientsContracts/BusinessLogicContracts/IClientLogic.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.SearchModels;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
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/CategorySearchModel.cs
Normal file
13
COP/ClientsContracts/SearchModels/CategorySearchModel.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 CategorySearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
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; }
|
||||
}
|
||||
}
|
21
COP/ClientsContracts/StorageContracts/ICategoryStorage.cs
Normal file
21
COP/ClientsContracts/StorageContracts/ICategoryStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.SearchModels;
|
||||
|
||||
namespace ClientsContracts.StorageContracts
|
||||
{
|
||||
public interface ICategoryStorage
|
||||
{
|
||||
List<CategoryViewModel> GetFullList();
|
||||
List<CategoryViewModel> GetFilteredList(CategorySearchModel model);
|
||||
CategoryViewModel? GetElement(CategorySearchModel model);
|
||||
CategoryViewModel? Insert(CategoryBindingModel model);
|
||||
CategoryViewModel? Update(CategoryBindingModel model);
|
||||
CategoryViewModel? Delete(CategoryBindingModel model);
|
||||
}
|
||||
}
|
21
COP/ClientsContracts/StorageContracts/IClientStorage.cs
Normal file
21
COP/ClientsContracts/StorageContracts/IClientStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.SearchModels;
|
||||
|
||||
namespace ClientsContracts.StorageContracts
|
||||
{
|
||||
public interface IClientStorage
|
||||
{
|
||||
List<ClientViewModel> GetFullList();
|
||||
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
|
||||
ClientViewModel? GetElement(ClientSearchModel model);
|
||||
ClientViewModel? Insert(ClientBindingModel model);
|
||||
ClientViewModel? Update(ClientBindingModel model);
|
||||
ClientViewModel? Delete(ClientBindingModel model);
|
||||
}
|
||||
}
|
17
COP/ClientsContracts/ViewModels/CategoryViewModel.cs
Normal file
17
COP/ClientsContracts/ViewModels/CategoryViewModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
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 CategoryViewModel : ICategoryModel
|
||||
{
|
||||
[DisplayName("Название")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
23
COP/ClientsContracts/ViewModels/ClientViewModel.cs
Normal file
23
COP/ClientsContracts/ViewModels/ClientViewModel.cs
Normal file
@ -0,0 +1,23 @@
|
||||
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 ClientViewModel : IClientModel
|
||||
{
|
||||
[DisplayName("ФИО")]
|
||||
public string Fio { get; set; } = string.Empty;
|
||||
[DisplayName("Электронная почта")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public int Id { get; set; }
|
||||
public int CategoryId { get; set; }
|
||||
public string CategoryName { get; set; } = string.Empty;
|
||||
public string Photo { 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>
|
7
COP/ClientsDataModels/IId.cs
Normal file
7
COP/ClientsDataModels/IId.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace ClientsDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
13
COP/ClientsDataModels/Models/ICategoryModel.cs
Normal file
13
COP/ClientsDataModels/Models/ICategoryModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClientsDataModels.Models
|
||||
{
|
||||
public interface ICategoryModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
16
COP/ClientsDataModels/Models/IClientModel.cs
Normal file
16
COP/ClientsDataModels/Models/IClientModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClientsDataModels.Models
|
||||
{
|
||||
public interface IClientModel : IId
|
||||
{
|
||||
string Fio { get; }
|
||||
string Email { get; }
|
||||
public int CategoryId { get; }
|
||||
public string Photo { get; }
|
||||
}
|
||||
}
|
16
COP/Components/Components.csproj
Normal file
16
COP/Components/Components.csproj
Normal file
@ -0,0 +1,16 @@
|
||||
<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="Microsoft.Office.Interop.Excel" Version="15.0.4795.1001" />
|
||||
<PackageReference Include="MicrosoftOfficeCore" Version="15.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
58
COP/Components/Components/UserCheckedListBox.Designer.cs
generated
Normal file
58
COP/Components/Components/UserCheckedListBox.Designer.cs
generated
Normal file
@ -0,0 +1,58 @@
|
||||
namespace Components.Components
|
||||
{
|
||||
partial class UserCheckedListBox
|
||||
{
|
||||
/// <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.checkedListBox = new System.Windows.Forms.CheckedListBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// checkedListBox
|
||||
//
|
||||
this.checkedListBox.FormattingEnabled = true;
|
||||
this.checkedListBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.checkedListBox.Name = "checkedListBox";
|
||||
this.checkedListBox.Size = new System.Drawing.Size(150, 114);
|
||||
this.checkedListBox.TabIndex = 0;
|
||||
this.checkedListBox.SelectedIndexChanged += new System.EventHandler(this.checkedListBox_SelectedIndexChanged);
|
||||
//
|
||||
// UserCheckedListBox
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.checkedListBox);
|
||||
this.Name = "UserCheckedListBox";
|
||||
this.Size = new System.Drawing.Size(150, 115);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckedListBox checkedListBox;
|
||||
}
|
||||
}
|
67
COP/Components/Components/UserCheckedListBox.cs
Normal file
67
COP/Components/Components/UserCheckedListBox.cs
Normal file
@ -0,0 +1,67 @@
|
||||
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 UserCheckedListBox : UserControl
|
||||
{
|
||||
public UserCheckedListBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public string? selectedItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return checkedListBox.SelectedItem is null ? null : checkedListBox.SelectedItem.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && checkedListBox.Items.Contains(value))
|
||||
{
|
||||
checkedListBox.SelectedItem = value;
|
||||
checkedListBox.SetItemChecked(checkedListBox.SelectedIndex, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event Action<string?> SelectedItemChange;
|
||||
|
||||
public void addItems(List<string> items)
|
||||
{
|
||||
foreach (string item in items)
|
||||
{
|
||||
checkedListBox.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
checkedListBox.Items.Clear();
|
||||
}
|
||||
|
||||
private void checkedListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (checkedListBox.CheckedItems.Count > 1)
|
||||
{
|
||||
foreach (int index in checkedListBox.CheckedIndices)
|
||||
{
|
||||
if (index != checkedListBox.SelectedIndex)
|
||||
{
|
||||
checkedListBox.SetItemChecked(index, false);
|
||||
checkedListBox.SetItemChecked(checkedListBox.SelectedIndex, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
SelectedItemChange?.Invoke(checkedListBox.SelectedItem.ToString());
|
||||
}
|
||||
}
|
||||
}
|
60
COP/Components/Components/UserCheckedListBox.resx
Normal file
60
COP/Components/Components/UserCheckedListBox.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>
|
56
COP/Components/Components/UserDatePicker.Designer.cs
generated
Normal file
56
COP/Components/Components/UserDatePicker.Designer.cs
generated
Normal file
@ -0,0 +1,56 @@
|
||||
namespace Components.Components
|
||||
{
|
||||
partial class UserDatePicker
|
||||
{
|
||||
/// <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.dateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
this.dateTimePicker.Location = new System.Drawing.Point(3, 3);
|
||||
this.dateTimePicker.Name = "dateTimePicker";
|
||||
this.dateTimePicker.Size = new System.Drawing.Size(250, 27);
|
||||
this.dateTimePicker.TabIndex = 0;
|
||||
this.dateTimePicker.ValueChanged += new System.EventHandler(this.dateTimePicker_ValueChanged);
|
||||
//
|
||||
// UserDatePicker
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.dateTimePicker);
|
||||
this.Name = "UserDatePicker";
|
||||
this.Size = new System.Drawing.Size(257, 38);
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DateTimePicker dateTimePicker;
|
||||
}
|
||||
}
|
80
COP/Components/Components/UserDatePicker.cs
Normal file
80
COP/Components/Components/UserDatePicker.cs
Normal file
@ -0,0 +1,80 @@
|
||||
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 Components.Exceptions;
|
||||
|
||||
namespace Components.Components
|
||||
{
|
||||
public partial class UserDatePicker : UserControl
|
||||
{
|
||||
public UserDatePicker()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public event Action<DateTime> DateChange;
|
||||
private bool lowBoundrySet = false;
|
||||
private bool highBoundrySet = false;
|
||||
|
||||
public bool BoundriesSet { get { return lowBoundrySet && highBoundrySet; } }
|
||||
|
||||
public DateTime? dateFrom
|
||||
{
|
||||
get
|
||||
{
|
||||
return lowBoundrySet ? dateTimePicker.MinDate : null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
dateTimePicker.MinDate = value.Value;
|
||||
lowBoundrySet = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? dateTo
|
||||
{
|
||||
get
|
||||
{
|
||||
return highBoundrySet ? dateTimePicker.MaxDate : null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
dateTimePicker.MaxDate = value.Value;
|
||||
highBoundrySet = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!lowBoundrySet || !highBoundrySet)
|
||||
{
|
||||
throw new DateBoundsNotSetException("Date bounds are not set.");
|
||||
}
|
||||
return dateTimePicker.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (lowBoundrySet && highBoundrySet && value.HasValue && value.Value >= dateFrom && value.Value <= dateTo) dateTimePicker.Value = value.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private void dateTimePicker_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
DateChange?.Invoke(dateTimePicker.Value);
|
||||
}
|
||||
}
|
||||
}
|
120
COP/Components/Components/UserDatePicker.resx
Normal file
120
COP/Components/Components/UserDatePicker.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>
|
55
COP/Components/Components/UserTreeView.Designer.cs
generated
Normal file
55
COP/Components/Components/UserTreeView.Designer.cs
generated
Normal file
@ -0,0 +1,55 @@
|
||||
namespace Components.Components
|
||||
{
|
||||
partial class UserTreeView
|
||||
{
|
||||
/// <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.treeView = new System.Windows.Forms.TreeView();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// treeView
|
||||
//
|
||||
this.treeView.Location = new System.Drawing.Point(0, 0);
|
||||
this.treeView.Name = "treeView";
|
||||
this.treeView.Size = new System.Drawing.Size(295, 212);
|
||||
this.treeView.TabIndex = 0;
|
||||
//
|
||||
// UserTreeView
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.treeView);
|
||||
this.Name = "UserTreeView";
|
||||
this.Size = new System.Drawing.Size(295, 212);
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TreeView treeView;
|
||||
}
|
||||
}
|
90
COP/Components/Components/UserTreeView.cs
Normal file
90
COP/Components/Components/UserTreeView.cs
Normal file
@ -0,0 +1,90 @@
|
||||
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 UserTreeView : UserControl
|
||||
{
|
||||
public UserTreeView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private List<(string, bool)> hierarchy = new List<(string, bool)>();
|
||||
|
||||
public int SelectedNodeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return treeView.SelectedNode?.Index ?? -1;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (treeView.SelectedNode == null) treeView.SelectedNode = value >= 0 && value < treeView.Nodes.Count ? treeView.Nodes[value] : treeView.SelectedNode;
|
||||
else treeView.SelectedNode = value >= 0 && value < treeView.SelectedNode.Nodes.Count ? treeView.SelectedNode.Nodes[value] : treeView.SelectedNode;
|
||||
}
|
||||
}
|
||||
|
||||
public T? getSelecetedNodeValue<T>()
|
||||
{
|
||||
if (treeView.SelectedNode == null || treeView.SelectedNode.Nodes.Count > 0) return default(T);
|
||||
|
||||
TreeNode? node = treeView.SelectedNode;
|
||||
|
||||
var type = typeof(T);
|
||||
var fields = type.GetFields();
|
||||
|
||||
var item = Activator.CreateInstance(type);
|
||||
|
||||
while (node != null)
|
||||
{
|
||||
var field = fields.FirstOrDefault(x => x.Name == node.Name);
|
||||
if (field != null)
|
||||
{
|
||||
field.SetValue(item, node.Text);
|
||||
}
|
||||
node = node.Parent;
|
||||
}
|
||||
|
||||
return item != null ? (T)item : default(T);
|
||||
}
|
||||
|
||||
public void setHierarchy(List<(string, bool)> fields)
|
||||
{
|
||||
hierarchy = fields;
|
||||
}
|
||||
|
||||
public void addItems<T>(List<T> items)
|
||||
{
|
||||
var type = typeof(T);
|
||||
var fields = type.GetFields();
|
||||
foreach (T item in items)
|
||||
{
|
||||
TreeNodeCollection nodes = treeView.Nodes;
|
||||
for (int i = 0; i < hierarchy.Count; i++)
|
||||
{
|
||||
var field = fields.FirstOrDefault(x => x.Name.Equals(hierarchy[i].Item1));
|
||||
if (field is not null)
|
||||
{
|
||||
var node = nodes.Find(field.Name, false).FirstOrDefault(x => x.Text == field.GetValue(item).ToString());
|
||||
if (node is not null && !hierarchy[i].Item2)
|
||||
{
|
||||
nodes = node.Nodes;
|
||||
}
|
||||
else
|
||||
{
|
||||
TreeNode newNode = nodes.Add(field.Name, field.GetValue(item).ToString());
|
||||
nodes = newNode.Nodes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
COP/Components/Components/UserTreeView.resx
Normal file
120
COP/Components/Components/UserTreeView.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>
|
18
COP/Components/Exceptions/DateBoundsNotSetException.cs
Normal file
18
COP/Components/Exceptions/DateBoundsNotSetException.cs
Normal file
@ -0,0 +1,18 @@
|
||||
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 DateBoundsNotSetException : ApplicationException
|
||||
{
|
||||
public DateBoundsNotSetException() : base() { }
|
||||
public DateBoundsNotSetException(string message) : base(message) { }
|
||||
public DateBoundsNotSetException(string message, Exception exception) : base(message, exception) { }
|
||||
protected DateBoundsNotSetException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
17
COP/Components/Exceptions/DateOutOfBoundsException.cs
Normal file
17
COP/Components/Exceptions/DateOutOfBoundsException.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Components.Exceptions
|
||||
{
|
||||
public class DateOutOfBoundsException : ApplicationException
|
||||
{
|
||||
public DateOutOfBoundsException() : base() { }
|
||||
public DateOutOfBoundsException(string message) : base(message) { }
|
||||
public DateOutOfBoundsException(string message, Exception exception) : base(message, exception) { }
|
||||
protected DateOutOfBoundsException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
16
COP/Components/LogicalComponents/DiagramLegendEnum.cs
Normal file
16
COP/Components/LogicalComponents/DiagramLegendEnum.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Components.LogicalComponents
|
||||
{
|
||||
public enum DiagramLegendEnum
|
||||
{
|
||||
TopLeft = 0,
|
||||
TopRight = 1,
|
||||
BottomRight = 2,
|
||||
BottomLeft = 3,
|
||||
}
|
||||
}
|
36
COP/Components/LogicalComponents/ExcelDiagramComponent.Designer.cs
generated
Normal file
36
COP/Components/LogicalComponents/ExcelDiagramComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace Components.LogicalComponents
|
||||
{
|
||||
partial class ExcelDiagramComponent
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
117
COP/Components/LogicalComponents/ExcelDiagramComponent.cs
Normal file
117
COP/Components/LogicalComponents/ExcelDiagramComponent.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
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 Components.LogicalComponents
|
||||
{
|
||||
public partial class ExcelDiagramComponent : Component
|
||||
{
|
||||
public ExcelDiagramComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ExcelDiagramComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
public bool 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);
|
||||
try
|
||||
{
|
||||
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 columnCount = 2;
|
||||
foreach (var item in data)
|
||||
{
|
||||
var cell = worksheet.get_Range("A" + columnCount, "A" + columnCount);
|
||||
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);
|
||||
|
||||
cell = worksheet.get_Range("B" + columnCount, "B" + columnCount);
|
||||
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 = value.GetValue(item);
|
||||
|
||||
columnCount++;
|
||||
}
|
||||
|
||||
//header
|
||||
var excelcells = worksheet.get_Range("A1", "A1");
|
||||
excelcells.Font.Bold = true;
|
||||
excelcells.Font.Size = 14;
|
||||
excelcells.Font.Name = "Times New Roman";
|
||||
excelcells.ColumnWidth = 8;
|
||||
excelcells.RowHeight = 25;
|
||||
excelcells.HorizontalAlignment = Constants.xlCenter;
|
||||
excelcells.VerticalAlignment = Constants.xlCenter;
|
||||
excelcells.Value2 = title;
|
||||
|
||||
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 range = worksheet.get_Range($"A2", $"B{columnCount - 1}");
|
||||
chart.SetSourceData(range);
|
||||
chart.ChartType = XlChartType.xlPie;
|
||||
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);
|
||||
|
||||
object missing = System.Reflection.Missing.Value;
|
||||
workbook.SaveAs(path, XlFileFormat.xlOpenXMLWorkbook, missing, missing, false, false, XlSaveAsAccessMode.xlNoChange,
|
||||
XlSaveConflictResolution.xlUserResolution, true, missing, missing, missing);
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
22
COP/Components/LogicalComponents/ExcelImageInfo.cs
Normal file
22
COP/Components/LogicalComponents/ExcelImageInfo.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Components.LogicalComponents
|
||||
{
|
||||
public class ExcelImageInfo
|
||||
{
|
||||
public ExcelImageInfo(string path, string title, string[] imagePaths)
|
||||
{
|
||||
this.path = path;
|
||||
this.title = title;
|
||||
this.imagePaths = imagePaths;
|
||||
}
|
||||
|
||||
public string path;
|
||||
public string title;
|
||||
public string[] imagePaths;
|
||||
}
|
||||
}
|
36
COP/Components/LogicalComponents/ExcelImagesComponent.Designer.cs
generated
Normal file
36
COP/Components/LogicalComponents/ExcelImagesComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace Components.LogicalComponents
|
||||
{
|
||||
partial class ExcelImagesComponent
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
77
COP/Components/LogicalComponents/ExcelImagesComponent.cs
Normal file
77
COP/Components/LogicalComponents/ExcelImagesComponent.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
using Microsoft.Office.Core;
|
||||
|
||||
namespace Components.LogicalComponents
|
||||
{
|
||||
public partial class ExcelImagesComponent : Component
|
||||
{
|
||||
public ExcelImagesComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ExcelImagesComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
public bool createWithImages(ExcelImageInfo info)
|
||||
{
|
||||
if (string.IsNullOrEmpty(info.path) || string.IsNullOrEmpty(info.title) || info.imagePaths == null || info.imagePaths.Length == 0)
|
||||
{
|
||||
throw new ArgumentException("Не все поля заполнены.");
|
||||
}
|
||||
var excelApp = new Microsoft.Office.Interop.Excel.Application { SheetsInNewWorkbook = 1 };
|
||||
Workbook workbook = excelApp.Workbooks.Add(Type.Missing);
|
||||
try
|
||||
{
|
||||
//create
|
||||
Worksheet worksheet = (Worksheet)workbook.Worksheets.get_Item(1);
|
||||
|
||||
//header
|
||||
var excelcells = worksheet.get_Range("A1", "D1");
|
||||
excelcells.Merge(Type.Missing);
|
||||
excelcells.Font.Bold = true;
|
||||
excelcells.Font.Size = 14;
|
||||
excelcells.Font.Name = "Times New Roman";
|
||||
excelcells.ColumnWidth = 8;
|
||||
excelcells.RowHeight = 25;
|
||||
excelcells.HorizontalAlignment = Constants.xlCenter;
|
||||
excelcells.VerticalAlignment = Constants.xlCenter;
|
||||
excelcells.Value2 = info.title;
|
||||
|
||||
int topOffset = 25;
|
||||
foreach (string path in info.imagePaths)
|
||||
{
|
||||
Bitmap bm = new Bitmap(path);
|
||||
worksheet.Shapes.AddPicture2(path, MsoTriState.msoFalse, MsoTriState.msoCTrue, 0, topOffset, bm.Width, bm.Height, MsoPictureCompress.msoPictureCompressFalse);
|
||||
topOffset += bm.Height;
|
||||
bm.Dispose();
|
||||
}
|
||||
|
||||
//save
|
||||
object missing = System.Reflection.Missing.Value;
|
||||
workbook.SaveAs(info.path, XlFileFormat.xlOpenXMLWorkbook, missing, missing, false, false, XlSaveAsAccessMode.xlNoChange,
|
||||
XlSaveConflictResolution.xlUserResolution, true, missing, missing, missing);
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
36
COP/Components/LogicalComponents/ExcelTableComponent.Designer.cs
generated
Normal file
36
COP/Components/LogicalComponents/ExcelTableComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace Components.LogicalComponents
|
||||
{
|
||||
partial class ExcelTableComponent
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
191
COP/Components/LogicalComponents/ExcelTableComponent.cs
Normal file
191
COP/Components/LogicalComponents/ExcelTableComponent.cs
Normal file
@ -0,0 +1,191 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Components.LogicalComponents
|
||||
{
|
||||
public partial class ExcelTableComponent : Component
|
||||
{
|
||||
public ExcelTableComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ExcelTableComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
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 bool createWithTable<T>(string path, string title, List<(int, int)> merges, List<int> heights, List<(string, string)> headers, List<T> items)
|
||||
{
|
||||
if (merges.Count == 0 || heights.Count == 0 || headers.Count == 0 || items.Count == 0) throw new ArgumentException("Недостаточно данных");
|
||||
int[] cellsArray = new int[heights.Count];
|
||||
foreach (var merge in merges)
|
||||
{
|
||||
if (merge.Item1 >= merge.Item2) throw new ArgumentException("Неправильно заполнены объединения строк");
|
||||
for (int i = merge.Item1; i < merge.Item2; i++)
|
||||
{
|
||||
cellsArray[i]++;
|
||||
}
|
||||
}
|
||||
foreach (int cell in cellsArray)
|
||||
{
|
||||
if (cell > 1) throw new ArgumentException("Объединения заходят друг на друга");
|
||||
}
|
||||
|
||||
var excelApp = new Microsoft.Office.Interop.Excel.Application { SheetsInNewWorkbook = 1 };
|
||||
Workbook workbook = excelApp.Workbooks.Add(Type.Missing);
|
||||
try
|
||||
{
|
||||
//create
|
||||
Worksheet worksheet = (Worksheet)workbook.Worksheets.get_Item(1);
|
||||
|
||||
//header
|
||||
var excelcells = worksheet.get_Range("A1", "A1");
|
||||
excelcells.Font.Bold = true;
|
||||
excelcells.Font.Size = 14;
|
||||
excelcells.Font.Name = "Times New Roman";
|
||||
excelcells.ColumnWidth = 8;
|
||||
excelcells.RowHeight = 25;
|
||||
excelcells.HorizontalAlignment = Constants.xlCenter;
|
||||
excelcells.VerticalAlignment = Constants.xlCenter;
|
||||
excelcells.Value2 = title;
|
||||
|
||||
//checks
|
||||
List<Microsoft.Office.Interop.Excel.Range> ranges = new List<Microsoft.Office.Interop.Excel.Range>();
|
||||
foreach (var merge in merges)
|
||||
{
|
||||
ranges.Add(worksheet.get_Range("A" + (merge.Item1 + 2), "A" + (merge.Item2 + 2)));
|
||||
}
|
||||
|
||||
int rangeIndex = 0;
|
||||
int headerIndex = 0;
|
||||
List<FieldInfo> cellFields = new List<FieldInfo>();
|
||||
var type = typeof(T);
|
||||
for (int i = 0; i < heights.Count; i++)
|
||||
{
|
||||
if (cellsArray[i] == 1)
|
||||
{
|
||||
//work with merge
|
||||
if (!string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
|
||||
|
||||
var groupRange = ranges[rangeIndex];
|
||||
groupRange.Merge(Type.Missing);
|
||||
groupRange.Font.Bold = true;
|
||||
groupRange.Font.Size = 14;
|
||||
groupRange.Font.Name = "Times New Roman";
|
||||
groupRange.ColumnWidth = 20;
|
||||
groupRange.HorizontalAlignment = Constants.xlCenter;
|
||||
groupRange.VerticalAlignment = Constants.xlCenter;
|
||||
groupRange.Value2 = headers[headerIndex].Item2;
|
||||
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 field = type.GetField(headers[headerIndex].Item1);
|
||||
if (field == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
|
||||
//format header
|
||||
var range = worksheet.get_Range("B" + (i + 2), "B" + (i + 2));
|
||||
range.Font.Bold = true;
|
||||
range.Font.Size = 14;
|
||||
range.Font.Name = "Times New Roman";
|
||||
range.ColumnWidth = 20;
|
||||
range.RowHeight = heights[i];
|
||||
range.HorizontalAlignment = Constants.xlCenter;
|
||||
range.VerticalAlignment = Constants.xlCenter;
|
||||
range.Value2 = headers[headerIndex].Item2;
|
||||
|
||||
cellFields.Add(field);
|
||||
headerIndex++;
|
||||
}
|
||||
i--;
|
||||
rangeIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//work with cell
|
||||
if (string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
|
||||
var field = type.GetField(headers[headerIndex].Item1);
|
||||
if (field == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
|
||||
//format header
|
||||
var range = worksheet.get_Range("A" + (i + 2), "B" + (i + 2));
|
||||
range.Merge(Type.Missing);
|
||||
range.Font.Bold = true;
|
||||
range.Font.Size = 14;
|
||||
range.Font.Name = "Times New Roman";
|
||||
range.ColumnWidth = 40;
|
||||
range.RowHeight = heights[i];
|
||||
range.HorizontalAlignment = Constants.xlCenter;
|
||||
range.VerticalAlignment = Constants.xlCenter;
|
||||
range.Value2 = headers[headerIndex].Item2;
|
||||
|
||||
cellFields.Add(field);
|
||||
headerIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
int columnNum = 3;
|
||||
foreach (T item in items)
|
||||
{
|
||||
string column = GetExcelColumnName(columnNum);
|
||||
int rowNum = 2;
|
||||
foreach (var cellField in cellFields)
|
||||
{
|
||||
var range = worksheet.get_Range(column + rowNum, column + rowNum);
|
||||
range.Font.Size = 14;
|
||||
range.Font.Name = "Times New Roman";
|
||||
range.ColumnWidth = 20;
|
||||
range.HorizontalAlignment = Constants.xlCenter;
|
||||
range.VerticalAlignment = Constants.xlCenter;
|
||||
range.Value2 = cellField.FieldType == typeof(bool) ? ((bool)cellField.GetValue(item) ? "Да" : "Нет") : cellField.GetValue(item);
|
||||
|
||||
rowNum++;
|
||||
}
|
||||
columnNum++;
|
||||
}
|
||||
var borderRange = worksheet.get_Range("A2", GetExcelColumnName(columnNum - 1) + (headerIndex - 1));
|
||||
borderRange.Borders.LineStyle = XlLineStyle.xlContinuous;
|
||||
borderRange.Borders.Weight = 2d;
|
||||
|
||||
//save
|
||||
object missing = System.Reflection.Missing.Value;
|
||||
workbook.SaveAs(path, XlFileFormat.xlOpenXMLWorkbook, missing, missing, false, false, XlSaveAsAccessMode.xlNoChange,
|
||||
XlSaveConflictResolution.xlUserResolution, true, missing, missing, missing);
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
65
COP/PluginsConventionLibrary/IPluginsConvention.cs
Normal file
65
COP/PluginsConventionLibrary/IPluginsConvention.cs
Normal file
@ -0,0 +1,65 @@
|
||||
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; }
|
||||
}
|
||||
}
|
20
COP/WinFormsTest/Department.cs
Normal file
20
COP/WinFormsTest/Department.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinFormsTest
|
||||
{
|
||||
public class Department
|
||||
{
|
||||
public string name;
|
||||
public int sells;
|
||||
|
||||
public Department(string name, int sells)
|
||||
{
|
||||
this.name = name;
|
||||
this.sells = sells;
|
||||
}
|
||||
}
|
||||
}
|
90
COP/WinFormsTest/FormCategories.Designer.cs
generated
Normal file
90
COP/WinFormsTest/FormCategories.Designer.cs
generated
Normal file
@ -0,0 +1,90 @@
|
||||
namespace WinFormsTest
|
||||
{
|
||||
partial class FormCategories
|
||||
{
|
||||
/// <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(613, 304);
|
||||
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;
|
||||
//
|
||||
// FormCategories
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.ClientSize = new System.Drawing.Size(613, 304);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormCategories";
|
||||
this.Text = "Категории";
|
||||
this.Load += new System.EventHandler(this.FormCategories_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn NameCol;
|
||||
private DataGridViewTextBoxColumn Id;
|
||||
}
|
||||
}
|
104
COP/WinFormsTest/FormCategories.cs
Normal file
104
COP/WinFormsTest/FormCategories.cs
Normal file
@ -0,0 +1,104 @@
|
||||
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 ClientsContracts.BindingModels;
|
||||
using ClientsContracts.BusinessLogicContracts;
|
||||
|
||||
namespace WinFormsTest
|
||||
{
|
||||
public partial class FormCategories : Form
|
||||
{
|
||||
private readonly ICategoryLogic _logic;
|
||||
private bool loading = false;
|
||||
|
||||
public FormCategories(ICategoryLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormCategories_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
loading = true;
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var interest in list)
|
||||
{
|
||||
int rowIndex = dataGridView.Rows.Add();
|
||||
dataGridView.Rows[rowIndex].Cells[0].Value = interest.Name;
|
||||
dataGridView.Rows[rowIndex].Cells[1].Value = interest.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 CategoryBindingModel { Id = Convert.ToInt32(dataGridView.Rows[e.RowIndex].Cells[1].Value), Name = name.ToString() });
|
||||
}
|
||||
else
|
||||
{
|
||||
var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
if (name is null) return;
|
||||
_logic.Create(new CategoryBindingModel { Id = 0, Name = name.ToString() });
|
||||
int newCategoryId = _logic.ReadList(null).ToList().Last().Id;
|
||||
dataGridView.Rows[e.RowIndex].Cells[1].Value = newCategoryId;
|
||||
}
|
||||
}
|
||||
|
||||
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 CategoryBindingModel { 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/WinFormsTest/FormCategories.resx
Normal file
120
COP/WinFormsTest/FormCategories.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>
|
169
COP/WinFormsTest/FormClient.Designer.cs
generated
Normal file
169
COP/WinFormsTest/FormClient.Designer.cs
generated
Normal file
@ -0,0 +1,169 @@
|
||||
namespace WinFormsTest
|
||||
{
|
||||
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.label1 = new System.Windows.Forms.Label();
|
||||
this.textBoxFio = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.mailControl = new BulatovaComponents.Components.MailControl();
|
||||
this.userCheckedListBox = new ChubykinaComponents.Components.UserCheckedListBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.buttonAvatar = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 20);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(42, 20);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "ФИО";
|
||||
//
|
||||
// textBoxFio
|
||||
//
|
||||
this.textBoxFio.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textBoxFio.Location = new System.Drawing.Point(12, 43);
|
||||
this.textBoxFio.Name = "textBoxFio";
|
||||
this.textBoxFio.Size = new System.Drawing.Size(389, 27);
|
||||
this.textBoxFio.TabIndex = 1;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(12, 90);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(51, 20);
|
||||
this.label3.TabIndex = 4;
|
||||
this.label3.Text = "Почта";
|
||||
//
|
||||
// mailControl
|
||||
//
|
||||
this.mailControl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.mailControl.Email = null;
|
||||
this.mailControl.Location = new System.Drawing.Point(12, 113);
|
||||
this.mailControl.Name = "mailControl";
|
||||
this.mailControl.Size = new System.Drawing.Size(389, 42);
|
||||
this.mailControl.TabIndex = 5;
|
||||
this.mailControl.validateEmailRegex = null;
|
||||
//
|
||||
// userCheckedListBox
|
||||
//
|
||||
this.userCheckedListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.userCheckedListBox.Location = new System.Drawing.Point(12, 181);
|
||||
this.userCheckedListBox.Name = "userCheckedListBox";
|
||||
this.userCheckedListBox.selectedItem = null;
|
||||
this.userCheckedListBox.Size = new System.Drawing.Size(389, 130);
|
||||
this.userCheckedListBox.TabIndex = 6;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(12, 158);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(82, 20);
|
||||
this.label4.TabIndex = 7;
|
||||
this.label4.Text = "Категории";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(12, 350);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonSave.TabIndex = 8;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(307, 350);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonCancel.TabIndex = 9;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
this.openFileDialog.FileName = "openFileDialog1";
|
||||
//
|
||||
// buttonAvatar
|
||||
//
|
||||
this.buttonAvatar.Location = new System.Drawing.Point(12, 304);
|
||||
this.buttonAvatar.Name = "buttonAvatar";
|
||||
this.buttonAvatar.Size = new System.Drawing.Size(389, 29);
|
||||
this.buttonAvatar.TabIndex = 10;
|
||||
this.buttonAvatar.Text = "Выбрать фото";
|
||||
this.buttonAvatar.UseVisualStyleBackColor = true;
|
||||
this.buttonAvatar.Click += new System.EventHandler(this.buttonAvatar_Click);
|
||||
//
|
||||
// FormClient
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(413, 392);
|
||||
this.Controls.Add(this.buttonAvatar);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.userCheckedListBox);
|
||||
this.Controls.Add(this.mailControl);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.textBoxFio);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Name = "FormClient";
|
||||
this.Text = "Клиент";
|
||||
this.Load += new System.EventHandler(this.FormClient_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private TextBox textBoxFio;
|
||||
private Label label3;
|
||||
private BulatovaComponents.Components.MailControl mailControl;
|
||||
private ChubykinaComponents.Components.UserCheckedListBox userCheckedListBox;
|
||||
private Label label4;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private Button buttonAvatar;
|
||||
}
|
||||
}
|
123
COP/WinFormsTest/FormClient.cs
Normal file
123
COP/WinFormsTest/FormClient.cs
Normal file
@ -0,0 +1,123 @@
|
||||
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 ClientsContracts.BusinessLogicContracts;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ClientsContracts.SearchModels;
|
||||
using ChubykinaComponents.Components;
|
||||
using ClientsContracts.BindingModels;
|
||||
|
||||
namespace WinFormsTest
|
||||
{
|
||||
public partial class FormClient : Form
|
||||
{
|
||||
private int? _id;
|
||||
private readonly IClientLogic _logic;
|
||||
private readonly ICategoryLogic _categoryLogic;
|
||||
private List<CategoryViewModel> _categories;
|
||||
private string? photo = null;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormClient(IClientLogic logic, ICategoryLogic categoryLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
_categoryLogic = categoryLogic;
|
||||
_categories = new List<CategoryViewModel>();
|
||||
}
|
||||
|
||||
private void FormClient_Load(object sender, EventArgs e)
|
||||
{
|
||||
_categories = _categoryLogic.ReadList(null);
|
||||
userCheckedListBox.addItems(_categories.Select(x => x.Name).ToList());
|
||||
mailControl.validateEmailRegex = new System.Text.RegularExpressions.Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
|
||||
mailControl.setTooltipText("name@example.com");
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new ClientSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxFio.Text = view.Fio;
|
||||
mailControl.Email = view.Email;
|
||||
photo = view.Photo;
|
||||
|
||||
userCheckedListBox.selectedItem = view.CategoryName;
|
||||
}
|
||||
}
|
||||
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(textBoxFio.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(mailControl.Email))
|
||||
{
|
||||
MessageBox.Show("Заполните почту или исправьте написание почты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (userCheckedListBox.selectedItem == null)
|
||||
{
|
||||
MessageBox.Show("Заполните категории", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (photo == null)
|
||||
{
|
||||
MessageBox.Show("Выберите фото", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var model = new ClientBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Fio = textBoxFio.Text,
|
||||
Email = mailControl.Email,
|
||||
CategoryId = _categories.First(x => x.Name == userCheckedListBox.selectedItem).Id,
|
||||
Photo = photo
|
||||
};
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAvatar_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() != DialogResult.Cancel)
|
||||
{
|
||||
photo = openFileDialog.FileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
63
COP/WinFormsTest/FormClient.resx
Normal file
63
COP/WinFormsTest/FormClient.resx
Normal file
@ -0,0 +1,63 @@
|
||||
<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="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
181
COP/WinFormsTest/FormMain.Designer.cs
generated
Normal file
181
COP/WinFormsTest/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,181 @@
|
||||
namespace WinFormsTest
|
||||
{
|
||||
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.controlDataTable = new ControlsLibraryNet60.Data.ControlDataTableTable();
|
||||
this.excelImagesComponent = new ChubykinaComponents.LogicalComponents.ExcelImagesComponent(this.components);
|
||||
this.wordTableComponentClient = new BulatovaComponents.NonVisualComponents.WordTableComponent(this.components);
|
||||
this.componentDocumentWithChartBarPdf = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarPdf(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 = 1;
|
||||
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(88, 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(92, 24);
|
||||
this.категорииToolStripMenuItem.Text = "Категории";
|
||||
this.категорииToolStripMenuItem.Click += new System.EventHandler(this.категорииToolStripMenuItem_Click);
|
||||
//
|
||||
// controlDataTable
|
||||
//
|
||||
this.controlDataTable.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.controlDataTable.Location = new System.Drawing.Point(0, 28);
|
||||
this.controlDataTable.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.controlDataTable.Name = "controlDataTable";
|
||||
this.controlDataTable.SelectedRowIndex = -1;
|
||||
this.controlDataTable.Size = new System.Drawing.Size(800, 422);
|
||||
this.controlDataTable.TabIndex = 2;
|
||||
//
|
||||
// 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.controlDataTable);
|
||||
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 ToolStripMenuItem удалитьToolStripMenuItem;
|
||||
private ToolStripMenuItem отчётыToolStripMenuItem;
|
||||
private ToolStripMenuItem документToolStripMenuItem;
|
||||
private ToolStripMenuItem документСТаблицейToolStripMenuItem;
|
||||
private ToolStripMenuItem документСДиаграммойToolStripMenuItem;
|
||||
private ToolStripMenuItem категорииToolStripMenuItem;
|
||||
private ControlsLibraryNet60.Data.ControlDataTableTable controlDataTable;
|
||||
private ChubykinaComponents.LogicalComponents.ExcelImagesComponent excelImagesComponent;
|
||||
private BulatovaComponents.NonVisualComponents.WordTableComponent wordTableComponentClient;
|
||||
private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarPdf componentDocumentWithChartBarPdf;
|
||||
}
|
||||
}
|
166
COP/WinFormsTest/FormMain.cs
Normal file
166
COP/WinFormsTest/FormMain.cs
Normal file
@ -0,0 +1,166 @@
|
||||
using ComponentsLibraryNet60.DocumentWithChart;
|
||||
using ComponentsLibraryNet60.Models;
|
||||
using ControlsLibraryNet60.Core;
|
||||
using ControlsLibraryNet60.Models;
|
||||
using ClientsContracts.BusinessLogicContracts;
|
||||
using ClientsContracts.BindingModels;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ChubykinaComponents.LogicalComponents;
|
||||
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 WinFormsTest
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private IClientLogic _logic;
|
||||
|
||||
public FormMain(IClientLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
controlDataTable.LoadColumns(new List<DataTableColumnConfig> {
|
||||
new DataTableColumnConfig { ColumnHeader = "", PropertyName = "Id", Visible = false, Width = 10},
|
||||
new DataTableColumnConfig { ColumnHeader = "ФИО", PropertyName = "Fio", Visible = true, Width = 200},
|
||||
new DataTableColumnConfig { ColumnHeader = "Выбранная категория", PropertyName = "CategoryName", Visible = true, Width = 200},
|
||||
new DataTableColumnConfig { ColumnHeader = "Email", PropertyName = "Email", Visible = true, Width = 200},
|
||||
});
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
}
|
||||
|
||||
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(FormCategories));
|
||||
if (service is FormCategories form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
controlDataTable.Clear();
|
||||
var clients = _logic.ReadList(null);
|
||||
if (clients != null)
|
||||
{
|
||||
controlDataTable.AddTable(clients);
|
||||
}
|
||||
}
|
||||
|
||||
private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClient));
|
||||
if (service is FormClient form)
|
||||
{
|
||||
form.Id = controlDataTable.GetSelectedObject<ClientViewModel>().Id;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
if (_logic.Delete(new ClientBindingModel { Id = controlDataTable.GetSelectedObject<ClientViewModel>().Id }))
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void документToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "Excel Files|*.xlsx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
|
||||
string path = saveFileDialog.FileName;
|
||||
List<string> photos = new List<string>();
|
||||
foreach (var client in _logic.ReadList(null))
|
||||
{
|
||||
photos.Add(client.Photo);
|
||||
}
|
||||
if (excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Фото", photos.ToArray()))) 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;
|
||||
string path = saveFileDialog.FileName;
|
||||
Dictionary<string, List<(int, double)>> data = new Dictionary<string, List<(int, double)>>();
|
||||
|
||||
data = _logic
|
||||
.ReadList(null)
|
||||
.GroupBy(x => x.CategoryName)
|
||||
.ToDictionary(x => x.Key, x => new List<(int, double)> { (0, x.Count()) });
|
||||
|
||||
componentDocumentWithChartBarPdf.CreateDoc(new ComponentDocumentWithChartConfig
|
||||
{
|
||||
Header = "Категории",
|
||||
FilePath = path,
|
||||
ChartTitle = "Категории",
|
||||
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
|
||||
Data = data,
|
||||
});
|
||||
|
||||
MessageBox.Show("Успех");
|
||||
}
|
||||
|
||||
private void документСТаблицейToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "Word Files|*.docx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
|
||||
string path = saveFileDialog.FileName;
|
||||
List<(int, int)> merges = new List<(int, int)> { (1, 2) };
|
||||
List<int> widths = new List<int> { 100, 100, 100, 100 };
|
||||
List<(string, string)> headers = new List<(string, string)> {
|
||||
("Id", "Идентификатор"),
|
||||
("", "Личные данные"),
|
||||
("Fio", "ФИО"),
|
||||
("Email", "Эл. почта"),
|
||||
("CategoryName", "Выбранная категория")
|
||||
};
|
||||
|
||||
wordTableComponentClient.createWithTable(path, "Список клиентов", merges, widths, headers, _logic.ReadList(null));
|
||||
MessageBox.Show("Документ создан");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
120
COP/WinFormsTest/FormMain.resx
Normal file
120
COP/WinFormsTest/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>
|
280
COP/WinFormsTest/FormTest.Designer.cs
generated
Normal file
280
COP/WinFormsTest/FormTest.Designer.cs
generated
Normal file
@ -0,0 +1,280 @@
|
||||
namespace WinFormsTest
|
||||
{
|
||||
partial class FormTest
|
||||
{
|
||||
/// <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.userCheckedListBox = new ChubykinaComponents.Components.UserCheckedListBox();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.buttonClear = new System.Windows.Forms.Button();
|
||||
this.buttonSelected = new System.Windows.Forms.Button();
|
||||
this.userDatePicker = new ChubykinaComponents.Components.UserDatePicker();
|
||||
this.buttonBoundries = new System.Windows.Forms.Button();
|
||||
this.buttonSetDate = new System.Windows.Forms.Button();
|
||||
this.buttonGetDate = new System.Windows.Forms.Button();
|
||||
this.userTreeView = new ChubykinaComponents.Components.UserTreeView();
|
||||
this.buttonSetHierarchy = new System.Windows.Forms.Button();
|
||||
this.buttonAddWorkers = new System.Windows.Forms.Button();
|
||||
this.buttonGetValue = new System.Windows.Forms.Button();
|
||||
this.buttonGetIndex = new System.Windows.Forms.Button();
|
||||
this.buttonSetIndex = new System.Windows.Forms.Button();
|
||||
this.buttonExcelDiagram = new System.Windows.Forms.Button();
|
||||
this.buttonExcelTable = new System.Windows.Forms.Button();
|
||||
this.buttonExcelImages = new System.Windows.Forms.Button();
|
||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.excelTableComponent = new ChubykinaComponents.LogicalComponents.ExcelTableComponent(this.components);
|
||||
this.excelDiagramComponent = new ChubykinaComponents.LogicalComponents.ExcelDiagramComponent(this.components);
|
||||
this.excelImagesComponent = new ChubykinaComponents.LogicalComponents.ExcelImagesComponent(this.components);
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// userCheckedListBox
|
||||
//
|
||||
this.userCheckedListBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.userCheckedListBox.Name = "userCheckedListBox";
|
||||
this.userCheckedListBox.selectedItem = null;
|
||||
this.userCheckedListBox.Size = new System.Drawing.Size(170, 134);
|
||||
this.userCheckedListBox.TabIndex = 0;
|
||||
this.userCheckedListBox.SelectedItemChange += new System.Action<string>(this.userCheckedListBox_SelectedItemChange);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(12, 143);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(150, 29);
|
||||
this.buttonAdd.TabIndex = 1;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||
//
|
||||
// buttonClear
|
||||
//
|
||||
this.buttonClear.Location = new System.Drawing.Point(12, 178);
|
||||
this.buttonClear.Name = "buttonClear";
|
||||
this.buttonClear.Size = new System.Drawing.Size(150, 29);
|
||||
this.buttonClear.TabIndex = 2;
|
||||
this.buttonClear.Text = "Очистить";
|
||||
this.buttonClear.UseVisualStyleBackColor = true;
|
||||
this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click);
|
||||
//
|
||||
// buttonSelected
|
||||
//
|
||||
this.buttonSelected.Location = new System.Drawing.Point(12, 213);
|
||||
this.buttonSelected.Name = "buttonSelected";
|
||||
this.buttonSelected.Size = new System.Drawing.Size(150, 48);
|
||||
this.buttonSelected.TabIndex = 3;
|
||||
this.buttonSelected.Text = "Выбранный элемент";
|
||||
this.buttonSelected.UseVisualStyleBackColor = true;
|
||||
this.buttonSelected.Click += new System.EventHandler(this.buttonSelected_Click);
|
||||
//
|
||||
// userDatePicker
|
||||
//
|
||||
this.userDatePicker.dateFrom = null;
|
||||
this.userDatePicker.dateTo = null;
|
||||
this.userDatePicker.Location = new System.Drawing.Point(188, 12);
|
||||
this.userDatePicker.Name = "userDatePicker";
|
||||
this.userDatePicker.Size = new System.Drawing.Size(275, 48);
|
||||
this.userDatePicker.TabIndex = 4;
|
||||
this.userDatePicker.DateChange += new System.Action<System.DateTime>(this.userDatePicker_DateChange);
|
||||
this.userDatePicker.AutoSizeChanged += new System.EventHandler(this.userDatePicker_DateChange);
|
||||
//
|
||||
// buttonBoundries
|
||||
//
|
||||
this.buttonBoundries.Location = new System.Drawing.Point(188, 143);
|
||||
this.buttonBoundries.Name = "buttonBoundries";
|
||||
this.buttonBoundries.Size = new System.Drawing.Size(254, 29);
|
||||
this.buttonBoundries.TabIndex = 5;
|
||||
this.buttonBoundries.Text = "Установить границы";
|
||||
this.buttonBoundries.UseVisualStyleBackColor = true;
|
||||
this.buttonBoundries.Click += new System.EventHandler(this.buttonBoundries_Click);
|
||||
//
|
||||
// buttonSetDate
|
||||
//
|
||||
this.buttonSetDate.Location = new System.Drawing.Point(188, 178);
|
||||
this.buttonSetDate.Name = "buttonSetDate";
|
||||
this.buttonSetDate.Size = new System.Drawing.Size(254, 29);
|
||||
this.buttonSetDate.TabIndex = 6;
|
||||
this.buttonSetDate.Text = "Установить значение";
|
||||
this.buttonSetDate.UseVisualStyleBackColor = true;
|
||||
this.buttonSetDate.Click += new System.EventHandler(this.buttonSetDate_Click);
|
||||
//
|
||||
// buttonGetDate
|
||||
//
|
||||
this.buttonGetDate.Location = new System.Drawing.Point(188, 213);
|
||||
this.buttonGetDate.Name = "buttonGetDate";
|
||||
this.buttonGetDate.Size = new System.Drawing.Size(254, 29);
|
||||
this.buttonGetDate.TabIndex = 7;
|
||||
this.buttonGetDate.Text = "Получить значение";
|
||||
this.buttonGetDate.UseVisualStyleBackColor = true;
|
||||
this.buttonGetDate.Click += new System.EventHandler(this.buttonGetDate_Click);
|
||||
//
|
||||
// userTreeView
|
||||
//
|
||||
this.userTreeView.Location = new System.Drawing.Point(469, 12);
|
||||
this.userTreeView.Name = "userTreeView";
|
||||
this.userTreeView.SelectedNodeIndex = -1;
|
||||
this.userTreeView.Size = new System.Drawing.Size(369, 249);
|
||||
this.userTreeView.TabIndex = 8;
|
||||
//
|
||||
// buttonSetHierarchy
|
||||
//
|
||||
this.buttonSetHierarchy.Location = new System.Drawing.Point(469, 257);
|
||||
this.buttonSetHierarchy.Name = "buttonSetHierarchy";
|
||||
this.buttonSetHierarchy.Size = new System.Drawing.Size(296, 29);
|
||||
this.buttonSetHierarchy.TabIndex = 9;
|
||||
this.buttonSetHierarchy.Text = "Установить иерархию";
|
||||
this.buttonSetHierarchy.UseVisualStyleBackColor = true;
|
||||
this.buttonSetHierarchy.Click += new System.EventHandler(this.buttonSetHierarchy_Click);
|
||||
//
|
||||
// buttonAddWorkers
|
||||
//
|
||||
this.buttonAddWorkers.Location = new System.Drawing.Point(469, 292);
|
||||
this.buttonAddWorkers.Name = "buttonAddWorkers";
|
||||
this.buttonAddWorkers.Size = new System.Drawing.Size(296, 29);
|
||||
this.buttonAddWorkers.TabIndex = 10;
|
||||
this.buttonAddWorkers.Text = "Добавить рабочих";
|
||||
this.buttonAddWorkers.UseVisualStyleBackColor = true;
|
||||
this.buttonAddWorkers.Click += new System.EventHandler(this.buttonAddWorkers_Click);
|
||||
//
|
||||
// buttonGetValue
|
||||
//
|
||||
this.buttonGetValue.Location = new System.Drawing.Point(469, 327);
|
||||
this.buttonGetValue.Name = "buttonGetValue";
|
||||
this.buttonGetValue.Size = new System.Drawing.Size(296, 29);
|
||||
this.buttonGetValue.TabIndex = 11;
|
||||
this.buttonGetValue.Text = "Получить значение";
|
||||
this.buttonGetValue.UseVisualStyleBackColor = true;
|
||||
this.buttonGetValue.Click += new System.EventHandler(this.buttonGetValue_Click);
|
||||
//
|
||||
// buttonGetIndex
|
||||
//
|
||||
this.buttonGetIndex.Location = new System.Drawing.Point(469, 362);
|
||||
this.buttonGetIndex.Name = "buttonGetIndex";
|
||||
this.buttonGetIndex.Size = new System.Drawing.Size(296, 29);
|
||||
this.buttonGetIndex.TabIndex = 12;
|
||||
this.buttonGetIndex.Text = "Получить индекс";
|
||||
this.buttonGetIndex.UseVisualStyleBackColor = true;
|
||||
this.buttonGetIndex.Click += new System.EventHandler(this.buttonGetIndex_Click);
|
||||
//
|
||||
// buttonSetIndex
|
||||
//
|
||||
this.buttonSetIndex.Location = new System.Drawing.Point(469, 397);
|
||||
this.buttonSetIndex.Name = "buttonSetIndex";
|
||||
this.buttonSetIndex.Size = new System.Drawing.Size(296, 29);
|
||||
this.buttonSetIndex.TabIndex = 13;
|
||||
this.buttonSetIndex.Text = "Установить индекс";
|
||||
this.buttonSetIndex.UseVisualStyleBackColor = true;
|
||||
this.buttonSetIndex.Click += new System.EventHandler(this.buttonSetIndex_Click);
|
||||
//
|
||||
// buttonExcelDiagram
|
||||
//
|
||||
this.buttonExcelDiagram.Location = new System.Drawing.Point(12, 407);
|
||||
this.buttonExcelDiagram.Name = "buttonExcelDiagram";
|
||||
this.buttonExcelDiagram.Size = new System.Drawing.Size(150, 29);
|
||||
this.buttonExcelDiagram.TabIndex = 19;
|
||||
this.buttonExcelDiagram.Text = "Excel (Диаграмма)";
|
||||
this.buttonExcelDiagram.UseVisualStyleBackColor = true;
|
||||
this.buttonExcelDiagram.Click += new System.EventHandler(this.buttonExcelDiagram_Click);
|
||||
//
|
||||
// buttonExcelTable
|
||||
//
|
||||
this.buttonExcelTable.Location = new System.Drawing.Point(168, 362);
|
||||
this.buttonExcelTable.Name = "buttonExcelTable";
|
||||
this.buttonExcelTable.Size = new System.Drawing.Size(128, 29);
|
||||
this.buttonExcelTable.TabIndex = 18;
|
||||
this.buttonExcelTable.Text = "Excel (Таблица)";
|
||||
this.buttonExcelTable.UseVisualStyleBackColor = true;
|
||||
this.buttonExcelTable.Click += new System.EventHandler(this.buttonExcelTable_Click);
|
||||
//
|
||||
// buttonExcelImages
|
||||
//
|
||||
this.buttonExcelImages.Location = new System.Drawing.Point(12, 362);
|
||||
this.buttonExcelImages.Name = "buttonExcelImages";
|
||||
this.buttonExcelImages.Size = new System.Drawing.Size(150, 29);
|
||||
this.buttonExcelImages.TabIndex = 17;
|
||||
this.buttonExcelImages.Text = "Excel (картинки)";
|
||||
this.buttonExcelImages.UseVisualStyleBackColor = true;
|
||||
this.buttonExcelImages.Click += new System.EventHandler(this.buttonExcelImages_Click);
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
this.openFileDialog.FileName = "openFileDialog";
|
||||
this.openFileDialog.Multiselect = true;
|
||||
//
|
||||
// FormTest
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(850, 450);
|
||||
this.Controls.Add(this.buttonExcelDiagram);
|
||||
this.Controls.Add(this.buttonExcelTable);
|
||||
this.Controls.Add(this.buttonExcelImages);
|
||||
this.Controls.Add(this.buttonSetIndex);
|
||||
this.Controls.Add(this.buttonGetIndex);
|
||||
this.Controls.Add(this.buttonGetValue);
|
||||
this.Controls.Add(this.buttonAddWorkers);
|
||||
this.Controls.Add(this.buttonSetHierarchy);
|
||||
this.Controls.Add(this.userTreeView);
|
||||
this.Controls.Add(this.buttonGetDate);
|
||||
this.Controls.Add(this.buttonSetDate);
|
||||
this.Controls.Add(this.buttonBoundries);
|
||||
this.Controls.Add(this.userDatePicker);
|
||||
this.Controls.Add(this.buttonSelected);
|
||||
this.Controls.Add(this.buttonClear);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.userCheckedListBox);
|
||||
this.Name = "FormTest";
|
||||
this.Text = "FormTest";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ChubykinaComponents.Components.UserCheckedListBox userCheckedListBox;
|
||||
private Button buttonAdd;
|
||||
private Button buttonClear;
|
||||
private Button buttonSelected;
|
||||
private ChubykinaComponents.Components.UserDatePicker userDatePicker;
|
||||
private Button buttonBoundries;
|
||||
private Button buttonSetDate;
|
||||
private Button buttonGetDate;
|
||||
private ChubykinaComponents.Components.UserTreeView userTreeView;
|
||||
private Button buttonSetHierarchy;
|
||||
private Button buttonAddWorkers;
|
||||
private Button buttonGetValue;
|
||||
private Button buttonGetIndex;
|
||||
private Button buttonSetIndex;
|
||||
private Button buttonExcelDiagram;
|
||||
private Button buttonExcelTable;
|
||||
private Button buttonExcelImages;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private ChubykinaComponents.LogicalComponents.ExcelTableComponent excelTableComponent;
|
||||
private ChubykinaComponents.LogicalComponents.ExcelDiagramComponent excelDiagramComponent;
|
||||
private ChubykinaComponents.LogicalComponents.ExcelImagesComponent excelImagesComponent;
|
||||
}
|
||||
}
|
188
COP/WinFormsTest/FormTest.cs
Normal file
188
COP/WinFormsTest/FormTest.cs
Normal file
@ -0,0 +1,188 @@
|
||||
using ChubykinaComponents.Exceptions;
|
||||
using ChubykinaComponents.LogicalComponents;
|
||||
using Microsoft.Office.Core;
|
||||
using Microsoft.VisualBasic.ApplicationServices;
|
||||
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 WinFormsTest
|
||||
{
|
||||
public partial class FormTest : Form
|
||||
{
|
||||
public FormTest()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new Random();
|
||||
List<string> items = new List<string>();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
items.Add("item" + random.Next(0, 10000));
|
||||
}
|
||||
userCheckedListBox.addItems(items);
|
||||
userCheckedListBox.selectedItem = items[1];
|
||||
}
|
||||
|
||||
private void userCheckedListBox_SelectedItemChange(string obj)
|
||||
{
|
||||
MessageBox.Show(obj, "Select event");
|
||||
}
|
||||
|
||||
private void buttonClear_Click(object sender, EventArgs e)
|
||||
{
|
||||
userCheckedListBox.clear();
|
||||
}
|
||||
|
||||
private void buttonSelected_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show(userCheckedListBox.selectedItem ?? "null", "By getter");
|
||||
}
|
||||
|
||||
private void buttonBoundries_Click(object sender, EventArgs e)
|
||||
{
|
||||
userDatePicker.dateFrom = new DateTime(1970, 01, 01);
|
||||
userDatePicker.dateTo = new DateTime(2010, 01, 01);
|
||||
}
|
||||
|
||||
private void buttonSetDate_Click(object sender, EventArgs e)
|
||||
{
|
||||
var result = MessageBox.Show("Установить значение в границах?", "Выбор", MessageBoxButtons.YesNo);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
userDatePicker.Value = new DateTime(2000, 01, 01);
|
||||
}
|
||||
else
|
||||
{
|
||||
userDatePicker.Value = new DateTime(1900, 01, 01);
|
||||
}
|
||||
}
|
||||
|
||||
private void userDatePicker_DateChange(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("ok");
|
||||
}
|
||||
|
||||
private void userDatePicker_DateChange(DateTime obj)
|
||||
{
|
||||
MessageBox.Show(obj.ToShortDateString(), "Date change event");
|
||||
}
|
||||
|
||||
private void buttonGetDate_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime? date = userDatePicker.Value;
|
||||
if (date.HasValue && date == new DateTime(2000, 01, 01))
|
||||
{
|
||||
MessageBox.Show(date.Value.ToShortDateString(), "Через свойство", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Дата не выбрана, дата выходит за пределы диапазона или диапазон не задан.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
catch (DateBoundsNotSetException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
catch (DateOutOfBoundsException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSetHierarchy_Click(object sender, EventArgs e)
|
||||
{
|
||||
userTreeView.setHierarchy(new List<(string, bool)>() { ("department", false), ("groupNumber", false), ("name", true) });
|
||||
}
|
||||
|
||||
private void buttonAddWorkers_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<Worker> workers = new List<Worker>();
|
||||
workers.Add(new Worker("Отдел 1", 1, "Иванов"));
|
||||
workers.Add(new Worker("Отдел 1", 1, "Петров"));
|
||||
workers.Add(new Worker("Отдел 1", 1, "Иванов"));
|
||||
workers.Add(new Worker("Отдел 1", 2, "Иванов"));
|
||||
workers.Add(new Worker("Отдел 2", 1, "Иванов"));
|
||||
workers.Add(new Worker("Отдел 2", 1, "Иванов"));
|
||||
workers.Add(new Worker("Отдел 2", 1, "Петров"));
|
||||
workers.Add(new Worker("Отдел 2", 2, "Иванов"));
|
||||
userTreeView.addItems(workers);
|
||||
}
|
||||
|
||||
private void buttonGetValue_Click(object sender, EventArgs e)
|
||||
{
|
||||
Worker? worker = userTreeView.getSelecetedNodeValue<Worker>();
|
||||
if (worker == null) return;
|
||||
MessageBox.Show(worker.department + ", номер группы: " + worker.groupNumber + ", " + worker.name);
|
||||
}
|
||||
|
||||
private void buttonGetIndex_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show(userTreeView.SelectedNodeIndex.ToString());
|
||||
}
|
||||
|
||||
private void buttonSetIndex_Click(object sender, EventArgs e)
|
||||
{
|
||||
userTreeView.SelectedNodeIndex = 0;
|
||||
}
|
||||
|
||||
private void buttonExcelImages_Click(object sender, EventArgs e)
|
||||
{
|
||||
var res = openFileDialog.ShowDialog(this);
|
||||
if (res != DialogResult.OK) return;
|
||||
var files = openFileDialog.FileNames;
|
||||
openFileDialog.Dispose();
|
||||
List<Bitmap> images = new List<Bitmap>();
|
||||
string path = "C:\\Users\\Полина\\source\\repos\\COP\\COP\\WinFormsTest\\test.xlsx";
|
||||
if (excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Header", files))) MessageBox.Show("Успех!");
|
||||
else MessageBox.Show("Ошибка, проверьте консоль");
|
||||
}
|
||||
|
||||
private void buttonExcelTable_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<OfficeWorker> workers = new List<OfficeWorker>();
|
||||
|
||||
workers.Add(new OfficeWorker(1, "Иванов", "Иван", 20, "Отдел продаж", "Бухгалтер", 25, "+7(834)234-03-49"));
|
||||
workers.Add(new OfficeWorker(1, "Петров", "Петр", 25, "Отдел продаж", "Менеджер", 20, "+7(834)123-03-49"));
|
||||
workers.Add(new OfficeWorker(1, "Сидоров", "Сергей", 27, "Отдел кадров", "HR", 2, "+7(834)593-03-49", true));
|
||||
string path = "C:\\Users\\Полина\\source\\repos\\COP\\COP\\WinFormsTest\\test2.xlsx";
|
||||
List<(int, int)> merges = new List<(int, int)>();
|
||||
merges.Add((1, 3));
|
||||
merges.Add((4, 6));
|
||||
List<int> heights = Enumerable.Repeat(20, 9).ToList();
|
||||
|
||||
List<(string, string)> headers = new List<(string, string)> { ("id", "id"), ("", "Личные данные"),
|
||||
("lastName", "Фамилия"), ("firstName", "Имя"),
|
||||
("age", "Возраст"), ("", "Работа"),
|
||||
("department", "Отдел"), ("position", "Должность"),
|
||||
("boxNumber", "Номер бокса"), ("phoneNumber", "Телефон"),
|
||||
("isInVacation", "В отпуске"), };
|
||||
|
||||
if (excelTableComponent.createWithTable(path, "test2", merges, heights, headers, workers)) MessageBox.Show("Успех");
|
||||
}
|
||||
|
||||
private void buttonExcelDiagram_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<Department> departments = new List<Department>();
|
||||
|
||||
departments.Add(new Department("Dep 1", 330));
|
||||
departments.Add(new Department("Dep 2", 500));
|
||||
departments.Add(new Department("Dep 3", 170));
|
||||
string path = "C:\\Users\\Полина\\source\\repos\\COP\\COP\\WinFormsTest\\test3.xlsx";
|
||||
if (excelDiagramComponent.createWithDiagram(path, "test3", "Продажи", DiagramLegendEnum.TopRight, departments, "name", "sells")) MessageBox.Show("Успех");
|
||||
else MessageBox.Show("Fail :(");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
72
COP/WinFormsTest/FormTest.resx
Normal file
72
COP/WinFormsTest/FormTest.resx
Normal file
@ -0,0 +1,72 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="excelTableComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>176, 17</value>
|
||||
</metadata>
|
||||
<metadata name="excelDiagramComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>380, 17</value>
|
||||
</metadata>
|
||||
<metadata name="excelImagesComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>606, 17</value>
|
||||
</metadata>
|
||||
</root>
|
34
COP/WinFormsTest/OfficeWorker.cs
Normal file
34
COP/WinFormsTest/OfficeWorker.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinFormsTest
|
||||
{
|
||||
public class OfficeWorker
|
||||
{
|
||||
public OfficeWorker(int id, string lastName, string firstName, int age, string department, string position, int boxNumber, string phoneNumber, bool isInVacation = false)
|
||||
{
|
||||
this.id = id;
|
||||
this.lastName = lastName;
|
||||
this.firstName = firstName;
|
||||
this.age = age;
|
||||
this.department = department;
|
||||
this.position = position;
|
||||
this.boxNumber = boxNumber;
|
||||
this.phoneNumber = phoneNumber;
|
||||
this.isInVacation = isInVacation;
|
||||
}
|
||||
|
||||
public int id;
|
||||
public string lastName;
|
||||
public string firstName;
|
||||
public int age;
|
||||
public string department;
|
||||
public string position;
|
||||
public int boxNumber;
|
||||
public string phoneNumber;
|
||||
public bool isInVacation;
|
||||
}
|
||||
}
|
175
COP/WinFormsTest/PluginsConvention.cs
Normal file
175
COP/WinFormsTest/PluginsConvention.cs
Normal file
@ -0,0 +1,175 @@
|
||||
using ClientsBusinessLogics.BusinessLogics;
|
||||
using ClientsContracts.BusinessLogicContracts;
|
||||
using ClientsContracts.StorageContracts;
|
||||
using ClientsContracts.ViewModels;
|
||||
using ClientDataBaseImplement.Implements;
|
||||
using BulatovaComponents.NonVisualComponents;
|
||||
using ChubykinaComponents.LogicalComponents;
|
||||
using ComponentsLibraryNet60.DocumentWithChart;
|
||||
using ComponentsLibraryNet60.Models;
|
||||
using ControlsLibraryNet60.Core;
|
||||
using ControlsLibraryNet60.Data;
|
||||
using ControlsLibraryNet60.Models;
|
||||
using PluginsConventionLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinFormsTest
|
||||
{
|
||||
public class PluginsConvention : IPluginsConvention
|
||||
{
|
||||
private readonly IClientLogic _clientLogic;
|
||||
private readonly ICategoryLogic _categoryLogic;
|
||||
private readonly ControlDataTableTable _controlDataTable;
|
||||
private readonly ExcelImagesComponent _excelImagesComponent;
|
||||
private readonly WordTableComponent _wordTableComponent;
|
||||
private readonly ComponentDocumentWithChartBarPdf _chartBar;
|
||||
public string PluginName { get; set; } = "LabWork_03_plugin";
|
||||
|
||||
public UserControl GetControl
|
||||
{
|
||||
get { return _controlDataTable; }
|
||||
}
|
||||
|
||||
public PluginsConvention()
|
||||
{
|
||||
_clientLogic = new ClientLogic(new ClientStorage());
|
||||
_categoryLogic = new CategoryLogic(new CategoryStorage());
|
||||
_excelImagesComponent = new();
|
||||
_wordTableComponent = new();
|
||||
_chartBar = new();
|
||||
_controlDataTable = new();
|
||||
}
|
||||
|
||||
public PluginsConventionElement GetElement
|
||||
{
|
||||
get
|
||||
{
|
||||
int Id = _controlDataTable.GetSelectedObject<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, _categoryLogic);
|
||||
}
|
||||
else
|
||||
{
|
||||
FormClient form = new FormClient(_clientLogic, _categoryLogic);
|
||||
form.Id = element.Id.GetHashCode();
|
||||
return form;
|
||||
}
|
||||
}
|
||||
|
||||
public Form GetThesaurus()
|
||||
{
|
||||
return new FormCategories(_categoryLogic);
|
||||
}
|
||||
|
||||
public bool DeleteElement(PluginsConventionElement element)
|
||||
{
|
||||
_clientLogic.Delete(
|
||||
new ClientsContracts.BindingModels.ClientBindingModel { Id = element.Id.GetHashCode() }
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ReloadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = _clientLogic.ReadList(null);
|
||||
if (client != null)
|
||||
{
|
||||
_controlDataTable.Clear();
|
||||
|
||||
_controlDataTable.LoadColumns(new List<DataTableColumnConfig> {
|
||||
new DataTableColumnConfig { ColumnHeader = "", PropertyName = "Id", Visible = false, Width = 10},
|
||||
new DataTableColumnConfig { ColumnHeader = "ФИО", PropertyName = "Fio", Visible = true, Width = 200},
|
||||
new DataTableColumnConfig { ColumnHeader = "Выбранная категория", PropertyName = "CategoryName", Visible = true, Width = 200},
|
||||
new DataTableColumnConfig { ColumnHeader = "Email", PropertyName = "Email", Visible = true, Width = 200},
|
||||
});
|
||||
|
||||
_controlDataTable.AddTable(client);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
ex.Message,
|
||||
"Ошибка",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
List<string> photos = new List<string>();
|
||||
foreach (var client in _clientLogic.ReadList(null))
|
||||
{
|
||||
photos.Add(client.Photo);
|
||||
}
|
||||
string path = saveDocument.FileName;
|
||||
if (_excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Фотографии", photos.ToArray())))
|
||||
{
|
||||
MessageBox.Show("Документ создан");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
string path = saveDocument.FileName;
|
||||
List<(int, int)> merges = new List<(int, int)> { (1, 2) };
|
||||
List<int> widths = new List<int> { 100, 100, 100, 100 };
|
||||
List<(string, string)> headers = new List<(string, string)> {
|
||||
("Id", "Идентификатор"),
|
||||
("", "Личные данные"),
|
||||
("Fio", "ФИО"),
|
||||
("Email", "Эл. почта"),
|
||||
("CategoryName", "Выбранная категория")
|
||||
};
|
||||
|
||||
_wordTableComponent.createWithTable(path, "Список клиентов", merges, widths, headers, _clientLogic.ReadList(null));
|
||||
MessageBox.Show("Документ создан");
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
|
||||
string path = saveDocument.FileName;
|
||||
Dictionary<string, List<(int, double)>> data = new Dictionary<string, List<(int, double)>>();
|
||||
|
||||
data = _clientLogic
|
||||
.ReadList(null)
|
||||
.GroupBy(x => x.CategoryName)
|
||||
.ToDictionary(x => x.Key, x => new List<(int, double)> { (0, x.Count()) });
|
||||
|
||||
_chartBar.CreateDoc(new ComponentDocumentWithChartConfig
|
||||
{
|
||||
Header = "Категории",
|
||||
FilePath = path,
|
||||
ChartTitle = "Категории",
|
||||
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
|
||||
Data = data,
|
||||
});
|
||||
|
||||
MessageBox.Show("Документ создан");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
39
COP/WinFormsTest/Program.cs
Normal file
39
COP/WinFormsTest/Program.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ClientsContracts.BusinessLogicContracts;
|
||||
using ClientsContracts.StorageContracts;
|
||||
using ClientsBusinessLogics.BusinessLogics;
|
||||
using ClientDataBaseImplement.Implements;
|
||||
|
||||
namespace WinFormsTest
|
||||
{
|
||||
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<ICategoryStorage, CategoryStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<ICategoryLogic, CategoryLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormClient>();
|
||||
services.AddTransient<FormCategories>();
|
||||
}
|
||||
}
|
||||
}
|
51
COP/WinFormsTest/WinFormsTest.csproj
Normal file
51
COP/WinFormsTest/WinFormsTest.csproj
Normal file
@ -0,0 +1,51 @@
|
||||
<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="BulatovaComponents" Version="1.0.1" />
|
||||
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
|
||||
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.20">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtrsansitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ChubykinaComponents\ChubykinaComponents.csproj" />
|
||||
<ProjectReference Include="..\ClientDataBaseImplement\ClientDataBaseImplement.csproj" />
|
||||
<ProjectReference Include="..\ClientsBusinessLogics\ClientsBusinessLogics.csproj" />
|
||||
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||
</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>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
22
COP/WinFormsTest/Worker.cs
Normal file
22
COP/WinFormsTest/Worker.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinFormsTest
|
||||
{
|
||||
public class Worker
|
||||
{
|
||||
public Worker(string department, int groupNumber, string name)
|
||||
{
|
||||
this.department = department;
|
||||
this.groupNumber = groupNumber;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public string department;
|
||||
public int groupNumber;
|
||||
public string name;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user