Compare commits
18 Commits
main
...
LabWork_03
Author | SHA1 | Date | |
---|---|---|---|
|
c4734e7daf | ||
0261fdc093 | |||
|
280fcbba32 | ||
3704947e84 | |||
9de3a512ef | |||
c65bcbb792 | |||
462e8f8bb4 | |||
|
c3424531c1 | ||
c7b0db4fa3 | |||
a17f19981a | |||
bc128a354f | |||
4c0882df61 | |||
4a5e7f9c0d | |||
2bfe317437 | |||
c90b181d85 | |||
5b17be9211 | |||
82f6fc6e49 | |||
c5f307ec81 |
27
WinFormsProject/AppView/AppView.csproj
Normal file
27
WinFormsProject/AppView/AppView.csproj
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<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="ComponentsLibraryNet60" Version="1.0.0" />
|
||||||
|
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
|
||||||
|
<PackageReference Include="ExcelFormsLibrary" Version="1.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.14">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="PdfFormsLibrary" Version="1.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\DateBaseImplement\DateBaseImplement.csproj" />
|
||||||
|
<ProjectReference Include="..\WinFormsLibrary\WinFormsLibraryAA.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
141
WinFormsProject/AppView/FormMain.Designer.cs
generated
Normal file
141
WinFormsProject/AppView/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
namespace AppView
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
components = new System.ComponentModel.Container();
|
||||||
|
dataTable = new ControlsLibraryNet60.Data.ControlDataTableTable();
|
||||||
|
contextMenuStrip1 = new ContextMenuStrip(components);
|
||||||
|
создатьToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
изменитьToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
удалитьToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
справочникToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
сформирироватьWordToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
сформироватьPdfToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
сформироватьExcelToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
documentWithImage1 = new WinFormsLibrary.DocumentWithImage(components);
|
||||||
|
table2column1 = new WinFormsLibrary.Table2column(components);
|
||||||
|
componentDocumentWithChartBarExcel1 = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarExcel(components);
|
||||||
|
gistograma1 = new WinFormsLibrary.not_visual.Gistograma(components);
|
||||||
|
contextMenuStrip1.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataTable
|
||||||
|
//
|
||||||
|
dataTable.Location = new Point(13, 12);
|
||||||
|
dataTable.Margin = new Padding(4, 3, 4, 3);
|
||||||
|
dataTable.Name = "dataTable";
|
||||||
|
dataTable.SelectedRowIndex = -1;
|
||||||
|
dataTable.Size = new Size(774, 426);
|
||||||
|
dataTable.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// contextMenuStrip1
|
||||||
|
//
|
||||||
|
contextMenuStrip1.Items.AddRange(new ToolStripItem[] { создатьToolStripMenuItem, изменитьToolStripMenuItem, удалитьToolStripMenuItem, справочникToolStripMenuItem, сформирироватьWordToolStripMenuItem, сформироватьPdfToolStripMenuItem, сформироватьExcelToolStripMenuItem });
|
||||||
|
contextMenuStrip1.Name = "contextMenuStrip1";
|
||||||
|
contextMenuStrip1.Size = new Size(205, 158);
|
||||||
|
//
|
||||||
|
// создатьToolStripMenuItem
|
||||||
|
//
|
||||||
|
создатьToolStripMenuItem.Name = "создатьToolStripMenuItem";
|
||||||
|
создатьToolStripMenuItem.Size = new Size(204, 22);
|
||||||
|
создатьToolStripMenuItem.Text = "Создать";
|
||||||
|
создатьToolStripMenuItem.Click += создатьToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// изменитьToolStripMenuItem
|
||||||
|
//
|
||||||
|
изменитьToolStripMenuItem.Name = "изменитьToolStripMenuItem";
|
||||||
|
изменитьToolStripMenuItem.Size = new Size(204, 22);
|
||||||
|
изменитьToolStripMenuItem.Text = "Изменить";
|
||||||
|
изменитьToolStripMenuItem.Click += изменитьToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// удалитьToolStripMenuItem
|
||||||
|
//
|
||||||
|
удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
|
||||||
|
удалитьToolStripMenuItem.Size = new Size(204, 22);
|
||||||
|
удалитьToolStripMenuItem.Text = "Удалить";
|
||||||
|
удалитьToolStripMenuItem.Click += удалитьToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// справочникToolStripMenuItem
|
||||||
|
//
|
||||||
|
справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
|
||||||
|
справочникToolStripMenuItem.Size = new Size(204, 22);
|
||||||
|
справочникToolStripMenuItem.Text = "Справочник";
|
||||||
|
справочникToolStripMenuItem.Click += справочникToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// сформирироватьWordToolStripMenuItem
|
||||||
|
//
|
||||||
|
сформирироватьWordToolStripMenuItem.Name = "сформирироватьWordToolStripMenuItem";
|
||||||
|
сформирироватьWordToolStripMenuItem.Size = new Size(204, 22);
|
||||||
|
сформирироватьWordToolStripMenuItem.Text = "Сформирировать Word";
|
||||||
|
сформирироватьWordToolStripMenuItem.Click += сформирироватьWordToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// сформироватьPdfToolStripMenuItem
|
||||||
|
//
|
||||||
|
сформироватьPdfToolStripMenuItem.Name = "сформироватьPdfToolStripMenuItem";
|
||||||
|
сформироватьPdfToolStripMenuItem.Size = new Size(204, 22);
|
||||||
|
сформироватьPdfToolStripMenuItem.Text = "Сформировать Pdf";
|
||||||
|
сформироватьPdfToolStripMenuItem.Click += сформироватьPdfToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// сформироватьExcelToolStripMenuItem
|
||||||
|
//
|
||||||
|
сформироватьExcelToolStripMenuItem.Name = "сформироватьExcelToolStripMenuItem";
|
||||||
|
сформироватьExcelToolStripMenuItem.Size = new Size(204, 22);
|
||||||
|
сформироватьExcelToolStripMenuItem.Text = "Сформировать Excel";
|
||||||
|
сформироватьExcelToolStripMenuItem.Click += сформироватьExcelToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// FormMain
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(dataTable);
|
||||||
|
Name = "FormMain";
|
||||||
|
Text = "Главная форма";
|
||||||
|
Load += FormMain_Load;
|
||||||
|
contextMenuStrip1.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ControlsLibraryNet60.Data.ControlDataTableTable dataTable;
|
||||||
|
private ContextMenuStrip contextMenuStrip1;
|
||||||
|
private ToolStripMenuItem создатьToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem изменитьToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem удалитьToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem справочникToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem сформирироватьWordToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem сформироватьPdfToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem сформироватьExcelToolStripMenuItem;
|
||||||
|
private WinFormsLibrary.DocumentWithImage documentWithImage1;
|
||||||
|
private WinFormsLibrary.Table2column table2column1;
|
||||||
|
private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarExcel componentDocumentWithChartBarExcel1;
|
||||||
|
private WinFormsLibrary.not_visual.Gistograma gistograma1;
|
||||||
|
}
|
||||||
|
}
|
227
WinFormsProject/AppView/FormMain.cs
Normal file
227
WinFormsProject/AppView/FormMain.cs
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
using ComponentsLibraryNet60.Models;
|
||||||
|
using Contracts.StorageContracts;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using ControlsLibraryNet60.Data;
|
||||||
|
using ControlsLibraryNet60.Models;
|
||||||
|
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using WinFormsLibrary;
|
||||||
|
using WinFormsLibrary.not_visual;
|
||||||
|
using WinFormsLibrary.SupportClasses;
|
||||||
|
|
||||||
|
namespace AppView
|
||||||
|
{
|
||||||
|
public partial class FormMain : Form
|
||||||
|
{
|
||||||
|
private readonly IProviderStorage _providerStorage;
|
||||||
|
private readonly ITypeStorage _typeStorage;
|
||||||
|
|
||||||
|
public FormMain(IProviderStorage providerStorage, ITypeStorage typeStorage)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_providerStorage = providerStorage;
|
||||||
|
_typeStorage = typeStorage;
|
||||||
|
|
||||||
|
ContextMenuStrip = contextMenuStrip1;
|
||||||
|
|
||||||
|
List<DataTableColumnConfig> columns = new List<DataTableColumnConfig>()
|
||||||
|
{
|
||||||
|
new DataTableColumnConfig
|
||||||
|
{
|
||||||
|
ColumnHeader = "Id",
|
||||||
|
PropertyName = "Id",
|
||||||
|
Visible = false
|
||||||
|
},
|
||||||
|
new DataTableColumnConfig
|
||||||
|
{
|
||||||
|
ColumnHeader = "Íàçâàíèå",
|
||||||
|
PropertyName = "Name",
|
||||||
|
Visible = true
|
||||||
|
},
|
||||||
|
new DataTableColumnConfig
|
||||||
|
{
|
||||||
|
ColumnHeader = "Òèï èçäåëèé",
|
||||||
|
PropertyName = "Type",
|
||||||
|
Visible = true
|
||||||
|
},
|
||||||
|
new DataTableColumnConfig
|
||||||
|
{
|
||||||
|
ColumnHeader = "Òåëåôîí",
|
||||||
|
PropertyName = "Number",
|
||||||
|
Visible = true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
dataTable.LoadColumns(columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
var list = _providerStorage.GetFullList();
|
||||||
|
dataTable.Clear();
|
||||||
|
dataTable.AddTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ñîçäàòüToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormProvider));
|
||||||
|
if (!(service is FormProvider form)) return;
|
||||||
|
if (form.ShowDialog() == DialogResult.OK) LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void èçìåíèòüToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataTable.GetSelectedObject<ProviderViewModel>() == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormProvider));
|
||||||
|
if (service is FormProvider form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataTable.GetSelectedObject<ProviderViewModel>()?.Id);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void óäàëèòüToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (dataTable.GetSelectedObject<ProviderViewModel>() == null) return;
|
||||||
|
if (MessageBox.Show(
|
||||||
|
"Âû õîòèòå óäàëèòü âûáðàííûå ýëåìåíòû?",
|
||||||
|
"Âîïðîñ",
|
||||||
|
MessageBoxButtons.YesNo,
|
||||||
|
MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
_providerStorage.Delete(new(dataTable.GetSelectedObject<ProviderViewModel>()));
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ñïðàâî÷íèêToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormType));
|
||||||
|
if (service is FormType form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toolStripButton1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ñôîðìèðèðîâàòüWordToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string fileName = "";
|
||||||
|
using (var dialog = new SaveFileDialog { Filter = "docx|*.docx" })
|
||||||
|
{
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
fileName = dialog.FileName.ToString();
|
||||||
|
MessageBox.Show("Âûïîëíåíî", "Óñïåõ", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageClass info = new ImageClass();
|
||||||
|
|
||||||
|
var images = _providerStorage.GetFullList().Select(x => x.Logo).ToList();
|
||||||
|
|
||||||
|
info.Title = "Images";
|
||||||
|
info.Path = fileName;
|
||||||
|
info.Files = images;
|
||||||
|
|
||||||
|
documentWithImage1.CreateDocument(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ñôîðìèðîâàòüPdfToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||||
|
string fileName = "";
|
||||||
|
using (var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" })
|
||||||
|
{
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
fileName = dialog.FileName.ToString();
|
||||||
|
MessageBox.Show("Âûïîëíåíî", "Óñïåõ", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<ColumnDefinition> columnDefinitionsUp = new List<ColumnDefinition> {
|
||||||
|
new ColumnDefinition{Header = "#", PropertyName = "Id", Weight = 30},
|
||||||
|
new ColumnDefinition{Header = "Èíôîðìàöèÿ", PropertyName = "NumberType", Weight = 30},
|
||||||
|
new ColumnDefinition{Header = "", PropertyName = "NumberType", Weight = 30},
|
||||||
|
new ColumnDefinition{Header = "Íîìåð òåëåôîíà", PropertyName = "Number", Weight = 30},
|
||||||
|
};
|
||||||
|
List<ColumnDefinition> columnDefinitionsDown = new List<ColumnDefinition> {
|
||||||
|
new ColumnDefinition{Header = "#", PropertyName = "Id", Weight = 30},
|
||||||
|
new ColumnDefinition{Header = "Íàçâàíèå", PropertyName = "Name", Weight = 30},
|
||||||
|
new ColumnDefinition{Header = "Òèï èçäåëèÿ", PropertyName = "Type", Weight = 30},
|
||||||
|
new ColumnDefinition{Header = "-", PropertyName = "Number", Weight = 30},
|
||||||
|
};
|
||||||
|
|
||||||
|
var providers = _providerStorage.GetFullList();
|
||||||
|
|
||||||
|
List<int[]> mergedColums = new() { new int[] { 1, 2 } };
|
||||||
|
|
||||||
|
BigTable<ProviderViewModel> info = new(fileName, "Table", columnDefinitionsUp, columnDefinitionsDown, providers, mergedColums);
|
||||||
|
|
||||||
|
table2column1.CreateTable(info);
|
||||||
|
MessageBox.Show("Ãîòîâî");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ñôîðìèðîâàòüExcelToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string fileName = "";
|
||||||
|
using (var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" })
|
||||||
|
{
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
fileName = dialog.FileName.ToString();
|
||||||
|
MessageBox.Show("Âûïîëíåíî", "Óñïåõ", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var providers = _providerStorage.GetFullList();
|
||||||
|
|
||||||
|
var uniqueTypes = providers.Select(p => p.Type).Distinct();
|
||||||
|
|
||||||
|
List<ChartData> data = new List<ChartData>();
|
||||||
|
|
||||||
|
foreach (var uniqueType in uniqueTypes)
|
||||||
|
{
|
||||||
|
var typeProviders = providers.Where(p => p.Type == uniqueType).ToList();
|
||||||
|
|
||||||
|
var dataList = new List<double>();
|
||||||
|
|
||||||
|
// Èñïîëüçóåì Count() äëÿ ïîäñ÷åòà îáùåãî êîëè÷åñòâà ïîñòàâùèêîâ êàæäîãî òèïà
|
||||||
|
int totalCount = typeProviders.Count();
|
||||||
|
|
||||||
|
ChartData chData = new ChartData();
|
||||||
|
chData.SeriesName = uniqueType;
|
||||||
|
chData.Data = new double[] { totalCount };
|
||||||
|
|
||||||
|
data.Add(chData);
|
||||||
|
}
|
||||||
|
|
||||||
|
gistograma1.GenerateExcelChartDocument(fileName, "Ñâîäêà ïî òèïàì èçäåëèÿ.", "Êîëè÷åñòâî ïîñòàâùèêîâ äëÿ òîâàðîâ êàæäîãî òèïà", WinFormsLibrary.not_visual.LegendPosition.Bottom, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
75
WinFormsProject/AppView/FormMain.resx
Normal file
75
WinFormsProject/AppView/FormMain.resx
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="documentWithImage1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>172, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="table2column1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>345, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="componentDocumentWithChartBarExcel1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>478, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="gistograma1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>754, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
207
WinFormsProject/AppView/FormProvider.Designer.cs
generated
Normal file
207
WinFormsProject/AppView/FormProvider.Designer.cs
generated
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
namespace AppView
|
||||||
|
{
|
||||||
|
partial class FormProvider
|
||||||
|
{
|
||||||
|
/// <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.labelName = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||||
|
this.labelLogo = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxNumber = new System.Windows.Forms.TextBox();
|
||||||
|
this.labelType = new System.Windows.Forms.Label();
|
||||||
|
this.labelNumber = new System.Windows.Forms.Label();
|
||||||
|
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||||
|
this.dropDownList1 = new WinForm.DropDownList();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonType = new System.Windows.Forms.Button();
|
||||||
|
this.buttonImage = new System.Windows.Forms.Button();
|
||||||
|
this.ImgFile = new System.Windows.Forms.OpenFileDialog();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
this.labelName.AutoSize = true;
|
||||||
|
this.labelName.Location = new System.Drawing.Point(12, 9);
|
||||||
|
this.labelName.Name = "labelName";
|
||||||
|
this.labelName.Size = new System.Drawing.Size(59, 15);
|
||||||
|
this.labelName.TabIndex = 0;
|
||||||
|
this.labelName.Text = "Название";
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
this.textBoxName.Location = new System.Drawing.Point(12, 27);
|
||||||
|
this.textBoxName.Name = "textBoxName";
|
||||||
|
this.textBoxName.Size = new System.Drawing.Size(239, 23);
|
||||||
|
this.textBoxName.TabIndex = 1;
|
||||||
|
this.textBoxName.TabStop = false;
|
||||||
|
this.textBoxName.TextChanged += new System.EventHandler(this.OnInputChange);
|
||||||
|
//
|
||||||
|
// labelLogo
|
||||||
|
//
|
||||||
|
this.labelLogo.AutoSize = true;
|
||||||
|
this.labelLogo.Location = new System.Drawing.Point(12, 59);
|
||||||
|
this.labelLogo.Name = "labelLogo";
|
||||||
|
this.labelLogo.Size = new System.Drawing.Size(53, 15);
|
||||||
|
this.labelLogo.TabIndex = 2;
|
||||||
|
this.labelLogo.Text = "Логотип";
|
||||||
|
//
|
||||||
|
// textBoxNumber
|
||||||
|
//
|
||||||
|
this.textBoxNumber.Location = new System.Drawing.Point(12, 424);
|
||||||
|
this.textBoxNumber.Name = "textBoxNumber";
|
||||||
|
this.textBoxNumber.Size = new System.Drawing.Size(239, 23);
|
||||||
|
this.textBoxNumber.TabIndex = 4;
|
||||||
|
this.textBoxNumber.TabStop = false;
|
||||||
|
this.textBoxNumber.TextChanged += new System.EventHandler(this.OnInputChange);
|
||||||
|
//
|
||||||
|
// labelType
|
||||||
|
//
|
||||||
|
this.labelType.AutoSize = true;
|
||||||
|
this.labelType.Location = new System.Drawing.Point(12, 307);
|
||||||
|
this.labelType.Name = "labelType";
|
||||||
|
this.labelType.Size = new System.Drawing.Size(75, 15);
|
||||||
|
this.labelType.TabIndex = 5;
|
||||||
|
this.labelType.Text = "Тип изделий";
|
||||||
|
//
|
||||||
|
// labelNumber
|
||||||
|
//
|
||||||
|
this.labelNumber.AutoSize = true;
|
||||||
|
this.labelNumber.Location = new System.Drawing.Point(12, 406);
|
||||||
|
this.labelNumber.Name = "labelNumber";
|
||||||
|
this.labelNumber.Size = new System.Drawing.Size(101, 15);
|
||||||
|
this.labelNumber.TabIndex = 6;
|
||||||
|
this.labelNumber.Text = "Номер телефона";
|
||||||
|
//
|
||||||
|
// pictureBox1
|
||||||
|
//
|
||||||
|
this.pictureBox1.Location = new System.Drawing.Point(12, 77);
|
||||||
|
this.pictureBox1.Name = "pictureBox1";
|
||||||
|
this.pictureBox1.Size = new System.Drawing.Size(239, 159);
|
||||||
|
this.pictureBox1.TabIndex = 7;
|
||||||
|
this.pictureBox1.TabStop = false;
|
||||||
|
//
|
||||||
|
// dropDownList1
|
||||||
|
//
|
||||||
|
this.dropDownList1.Location = new System.Drawing.Point(12, 325);
|
||||||
|
this.dropDownList1.Name = "dropDownList1";
|
||||||
|
this.dropDownList1.Selected = "";
|
||||||
|
this.dropDownList1.Size = new System.Drawing.Size(239, 30);
|
||||||
|
this.dropDownList1.TabIndex = 8;
|
||||||
|
this.dropDownList1.TabStop = false;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(38, 471);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonSave.TabIndex = 9;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(146, 471);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonCancel.TabIndex = 10;
|
||||||
|
this.buttonCancel.Text = "Отменить";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||||
|
//
|
||||||
|
// buttonType
|
||||||
|
//
|
||||||
|
this.buttonType.Location = new System.Drawing.Point(109, 361);
|
||||||
|
this.buttonType.Name = "buttonType";
|
||||||
|
this.buttonType.Size = new System.Drawing.Size(142, 23);
|
||||||
|
this.buttonType.TabIndex = 11;
|
||||||
|
this.buttonType.TabStop = false;
|
||||||
|
this.buttonType.Text = "Редактировать типы";
|
||||||
|
this.buttonType.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonType.Click += new System.EventHandler(this.buttonType_Click);
|
||||||
|
//
|
||||||
|
// buttonImage
|
||||||
|
//
|
||||||
|
this.buttonImage.Location = new System.Drawing.Point(109, 242);
|
||||||
|
this.buttonImage.Name = "buttonImage";
|
||||||
|
this.buttonImage.Size = new System.Drawing.Size(142, 23);
|
||||||
|
this.buttonImage.TabIndex = 12;
|
||||||
|
this.buttonImage.TabStop = false;
|
||||||
|
this.buttonImage.Text = "Загрузить картинку";
|
||||||
|
this.buttonImage.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonImage.Click += new System.EventHandler(this.buttonImage_Click);
|
||||||
|
//
|
||||||
|
// ImgFile
|
||||||
|
//
|
||||||
|
this.ImgFile.FileName = "openFileDialog1";
|
||||||
|
//
|
||||||
|
// FormProvider
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(263, 509);
|
||||||
|
this.Controls.Add(this.buttonImage);
|
||||||
|
this.Controls.Add(this.buttonType);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.dropDownList1);
|
||||||
|
this.Controls.Add(this.pictureBox1);
|
||||||
|
this.Controls.Add(this.labelNumber);
|
||||||
|
this.Controls.Add(this.labelType);
|
||||||
|
this.Controls.Add(this.textBoxNumber);
|
||||||
|
this.Controls.Add(this.labelLogo);
|
||||||
|
this.Controls.Add(this.textBoxName);
|
||||||
|
this.Controls.Add(this.labelName);
|
||||||
|
this.Name = "FormProvider";
|
||||||
|
this.Text = "FormProvider";
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormProvider_FormClosing);
|
||||||
|
this.Load += new System.EventHandler(this.FormProvider_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelName;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private Label labelLogo;
|
||||||
|
private TextBox textBoxNumber;
|
||||||
|
private Label labelType;
|
||||||
|
private Label labelNumber;
|
||||||
|
private PictureBox pictureBox1;
|
||||||
|
private WinForm.DropDownList dropDownList1;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonType;
|
||||||
|
private Button buttonImage;
|
||||||
|
private OpenFileDialog ImgFile;
|
||||||
|
}
|
||||||
|
}
|
186
WinFormsProject/AppView/FormProvider.cs
Normal file
186
WinFormsProject/AppView/FormProvider.cs
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
using Contracts.StorageContracts;
|
||||||
|
using DocumentFormat.OpenXml.Vml;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using WinForm;
|
||||||
|
|
||||||
|
namespace AppView
|
||||||
|
{
|
||||||
|
public partial class FormProvider : Form
|
||||||
|
{
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
public readonly IProviderStorage _providerStorage;
|
||||||
|
public readonly ITypeStorage _typeStorage;
|
||||||
|
private bool isEdited;
|
||||||
|
private byte[] _logo = new byte[0];
|
||||||
|
|
||||||
|
public FormProvider(IProviderStorage providerStorage, ITypeStorage typeStorage)
|
||||||
|
{
|
||||||
|
_providerStorage = providerStorage;
|
||||||
|
_typeStorage = typeStorage;
|
||||||
|
isEdited = false;
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Image byteArrayToImage(byte[] byteArrayIn)
|
||||||
|
{
|
||||||
|
Image res = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MemoryStream ms = new MemoryStream(byteArrayIn, 0, byteArrayIn.Length);
|
||||||
|
ms.Write(byteArrayIn, 0, byteArrayIn.Length);
|
||||||
|
res = Image.FromStream(ms, true);//Exception occurs here
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormProvider_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
dropDownList1.ExplicitEvent += OnInputChange;
|
||||||
|
LoadData();
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var element = _providerStorage.GetElement(new ProviderSearchModel { Id = _id!.Value });
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
textBoxName.Text = element.Name;
|
||||||
|
_logo = element.Logo;
|
||||||
|
dropDownList1.Selected = element.Type;
|
||||||
|
textBoxNumber.Text = element.Number;
|
||||||
|
|
||||||
|
pictureBox1.Image = byteArrayToImage(_logo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении записи", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
var list = _typeStorage.GetFullList().Select(item => item.Name).ToList();
|
||||||
|
dropDownList1.Clear();
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
dropDownList1.ComboBoxItems.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_id != null)
|
||||||
|
{
|
||||||
|
var provider = _providerStorage.GetElement(new ProviderSearchModel() { Id = _id!.Value });
|
||||||
|
dropDownList1.Selected = provider!.Type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Название не указано.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_logo.Length == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите фото", "Ошибка");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(dropDownList1.Selected))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не выбран тип изделий.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Regex.IsMatch(textBoxNumber.Text, @"^\d-\d{3}-\d{3}-\d{2}-\d{2}$"))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Неправильный формат номера телефона.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isEdited = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new ProviderBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
Name = textBoxName.Text,
|
||||||
|
Logo = _logo,
|
||||||
|
Type = dropDownList1.Selected,
|
||||||
|
Number = textBoxNumber.Text
|
||||||
|
};
|
||||||
|
var action = _id.HasValue ? _providerStorage.Update(model) : _providerStorage.Insert(model);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonType_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormType));
|
||||||
|
if (service is FormType form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormProvider_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
if (!isEdited) return;
|
||||||
|
|
||||||
|
var confirmResult = MessageBox.Show(
|
||||||
|
"Имеются незафиксированные изменения." +
|
||||||
|
"\n" +
|
||||||
|
"Вы действительно хотите закрыть форму?",
|
||||||
|
"Подтвердите действие",
|
||||||
|
MessageBoxButtons.YesNo,
|
||||||
|
MessageBoxIcon.Question
|
||||||
|
);
|
||||||
|
if (confirmResult == DialogResult.No) e.Cancel = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonImage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (ImgFile.ShowDialog() != DialogResult.OK) return;
|
||||||
|
|
||||||
|
Image img = Image.FromFile(ImgFile.FileName);
|
||||||
|
using (MemoryStream mStream = new MemoryStream())
|
||||||
|
{
|
||||||
|
img.Save(mStream, img.RawFormat);
|
||||||
|
_logo = mStream.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
pictureBox1.Image = img;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnInputChange(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
isEdited = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
63
WinFormsProject/AppView/FormProvider.resx
Normal file
63
WinFormsProject/AppView/FormProvider.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="ImgFile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
65
WinFormsProject/AppView/FormType.Designer.cs
generated
Normal file
65
WinFormsProject/AppView/FormType.Designer.cs
generated
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
namespace AppView
|
||||||
|
{
|
||||||
|
partial class FormType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(367, 447);
|
||||||
|
this.dataGridView.TabIndex = 0;
|
||||||
|
this.dataGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellValueChanged);
|
||||||
|
this.dataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridView_KeyDown);
|
||||||
|
//
|
||||||
|
// FormType
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(367, 447);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "FormType";
|
||||||
|
this.Text = "FormType";
|
||||||
|
this.Load += new System.EventHandler(this.FormType_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
138
WinFormsProject/AppView/FormType.cs
Normal file
138
WinFormsProject/AppView/FormType.cs
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
using Contracts.StorageContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace AppView
|
||||||
|
{
|
||||||
|
public partial class FormType : Form
|
||||||
|
{
|
||||||
|
private readonly ITypeStorage _typeStorage;
|
||||||
|
|
||||||
|
public FormType(ITypeStorage typeStorage)
|
||||||
|
{
|
||||||
|
_typeStorage = typeStorage;
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormType_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var types = _typeStorage.GetFullList();
|
||||||
|
if (types != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = types;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Name"].Tag = "Название";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка загрузки типов.",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.KeyCode)
|
||||||
|
{
|
||||||
|
case Keys.Insert:
|
||||||
|
AddType();
|
||||||
|
e.Handled = true;
|
||||||
|
break;
|
||||||
|
case Keys.Delete:
|
||||||
|
RemoveType();
|
||||||
|
e.Handled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddType()
|
||||||
|
{
|
||||||
|
var list = _typeStorage.GetFullList();
|
||||||
|
list.Add(new());
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveType()
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
DialogResult result = MessageBox.Show(
|
||||||
|
"Вы уверены, что хотите удалить выбранные записи?",
|
||||||
|
"Подтверждение удаления",
|
||||||
|
MessageBoxButtons.YesNo,
|
||||||
|
MessageBoxIcon.Question);
|
||||||
|
if (result == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
foreach (DataGridViewRow row in dataGridView.SelectedRows)
|
||||||
|
{
|
||||||
|
if (!row.IsNewRow)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(row.Cells["Id"].Value);
|
||||||
|
var view = _typeStorage.GetElement(new TypeSearchModel { Id = id });
|
||||||
|
_typeStorage.Delete(new(view!));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.RowIndex >= 0)
|
||||||
|
{
|
||||||
|
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||||
|
int id = Convert.ToInt32(row.Cells["Id"].Value);
|
||||||
|
string? name = row.Cells["Name"].Value?.ToString();
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(name))
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
"Нельзя сохранить запись с пустым именем!",
|
||||||
|
"Ошибка",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error
|
||||||
|
);
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var model = new TypeBindingModel
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Name = name
|
||||||
|
};
|
||||||
|
if (model.Id == 0) _typeStorage.Insert(model);
|
||||||
|
else _typeStorage.Update(model);
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
WinFormsProject/AppView/FormType.resx
Normal file
60
WinFormsProject/AppView/FormType.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>
|
35
WinFormsProject/AppView/Program.cs
Normal file
35
WinFormsProject/AppView/Program.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using Contracts.StorageContracts;
|
||||||
|
using DateBaseImplement.Implements;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace AppView
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
ConfigureService(services);
|
||||||
|
_serviceProvider = services.BuildServiceProvider();
|
||||||
|
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureService(IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddTransient<IProviderStorage, ProviderStorage>();
|
||||||
|
services.AddTransient<ITypeStorage, TypeStorage>();
|
||||||
|
services.AddTransient<FormMain>();
|
||||||
|
services.AddTransient<FormProvider>();
|
||||||
|
services.AddTransient<FormType>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
using DataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ProviderBindingModel : IProviderModel
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Type { get; set; }
|
||||||
|
public byte[] Logo { get; set; }
|
||||||
|
public string Number { get; set; }
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public ProviderBindingModel() { }
|
||||||
|
|
||||||
|
public ProviderBindingModel(IProviderModel provider)
|
||||||
|
{
|
||||||
|
Id = provider.Id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
WinFormsProject/Contracts/BindingModels/TypeBindingModel.cs
Normal file
22
WinFormsProject/Contracts/BindingModels/TypeBindingModel.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using DataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.BindingModels
|
||||||
|
{
|
||||||
|
public class TypeBindingModel : ITypeModel
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public TypeBindingModel() { }
|
||||||
|
|
||||||
|
public TypeBindingModel(ITypeModel type)
|
||||||
|
{
|
||||||
|
Id = type.Id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
WinFormsProject/Contracts/Contracts.csproj
Normal file
13
WinFormsProject/Contracts/Contracts.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="..\DataModels\DataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.SearchModels
|
||||||
|
{
|
||||||
|
public class ProviderSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
13
WinFormsProject/Contracts/SearchModels/TypeSearchModel.cs
Normal file
13
WinFormsProject/Contracts/SearchModels/TypeSearchModel.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.SearchModels
|
||||||
|
{
|
||||||
|
public class TypeSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.StorageContracts
|
||||||
|
{
|
||||||
|
public interface IProviderStorage
|
||||||
|
{
|
||||||
|
List<ProviderViewModel> GetFullList();
|
||||||
|
ProviderViewModel? GetElement(ProviderSearchModel model);
|
||||||
|
List<ProviderViewModel> GetFilteredList(ProviderSearchModel model);
|
||||||
|
ProviderViewModel? Insert(ProviderBindingModel model);
|
||||||
|
ProviderViewModel? Update(ProviderBindingModel model);
|
||||||
|
ProviderViewModel? Delete(ProviderBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
20
WinFormsProject/Contracts/StorageContracts/ITypeStorage.cs
Normal file
20
WinFormsProject/Contracts/StorageContracts/ITypeStorage.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.StorageContracts
|
||||||
|
{
|
||||||
|
public interface ITypeStorage
|
||||||
|
{
|
||||||
|
List<TypeViewModel> GetFullList();
|
||||||
|
TypeViewModel? GetElement(TypeSearchModel model);
|
||||||
|
TypeViewModel? Insert(TypeBindingModel model);
|
||||||
|
TypeViewModel? Update(TypeBindingModel model);
|
||||||
|
TypeViewModel? Delete(TypeBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
18
WinFormsProject/Contracts/ViewModels/ProviderViewModel.cs
Normal file
18
WinFormsProject/Contracts/ViewModels/ProviderViewModel.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using DataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ProviderViewModel : IProviderModel
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Type { get; set; }
|
||||||
|
public byte[] Logo { get; set; }
|
||||||
|
public string Number { get; set; }
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
15
WinFormsProject/Contracts/ViewModels/TypeViewModel.cs
Normal file
15
WinFormsProject/Contracts/ViewModels/TypeViewModel.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using DataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.ViewModels
|
||||||
|
{
|
||||||
|
public class TypeViewModel : ITypeModel
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
9
WinFormsProject/DataModels/DataModels.csproj
Normal file
9
WinFormsProject/DataModels/DataModels.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>
|
13
WinFormsProject/DataModels/IId.cs
Normal file
13
WinFormsProject/DataModels/IId.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DataModels
|
||||||
|
{
|
||||||
|
public interface IId
|
||||||
|
{
|
||||||
|
int Id { get; }
|
||||||
|
}
|
||||||
|
}
|
16
WinFormsProject/DataModels/Models/IProviderModel.cs
Normal file
16
WinFormsProject/DataModels/Models/IProviderModel.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DataModels.Models
|
||||||
|
{
|
||||||
|
public interface IProviderModel : IId
|
||||||
|
{
|
||||||
|
string Name { get; set; }
|
||||||
|
string Type { get; set; }
|
||||||
|
byte[] Logo { get; set; }
|
||||||
|
string Number { get; set; }
|
||||||
|
}
|
||||||
|
}
|
13
WinFormsProject/DataModels/Models/ITypeModel.cs
Normal file
13
WinFormsProject/DataModels/Models/ITypeModel.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DataModels.Models
|
||||||
|
{
|
||||||
|
public interface ITypeModel : IId
|
||||||
|
{
|
||||||
|
string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
24
WinFormsProject/DateBaseImplement/DBContext.cs
Normal file
24
WinFormsProject/DateBaseImplement/DBContext.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using DateBaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DateBaseImplement
|
||||||
|
{
|
||||||
|
public class DBContext : DbContext
|
||||||
|
{
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
if (!optionsBuilder.IsConfigured)
|
||||||
|
optionsBuilder.UseNpgsql(@"Host=localhost;Port=5432;Database=COPArtyom;Username=courseuser;Password=courseuser");
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual DbSet<Provider> Providers { get; set; }
|
||||||
|
public virtual DbSet<Models.Type> Types { get; set; }
|
||||||
|
}
|
||||||
|
}
|
22
WinFormsProject/DateBaseImplement/DateBaseImplement.csproj
Normal file
22
WinFormsProject/DateBaseImplement/DateBaseImplement.csproj
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.14">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Contracts\Contracts.csproj" />
|
||||||
|
<ProjectReference Include="..\DataModels\DataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,73 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
using Contracts.StorageContracts;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using DateBaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DateBaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ProviderStorage : IProviderStorage
|
||||||
|
{
|
||||||
|
public ProviderViewModel? Insert(ProviderBindingModel model)
|
||||||
|
{
|
||||||
|
var newProvider = Provider.Create(model);
|
||||||
|
if (newProvider == null) return null;
|
||||||
|
|
||||||
|
using var context = new DBContext();
|
||||||
|
context.Providers.Add(newProvider);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newProvider.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProviderViewModel? Update(ProviderBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new DBContext();
|
||||||
|
var provider = context.Providers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (provider == null) return null;
|
||||||
|
provider.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return provider.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProviderViewModel? Delete(ProviderBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new DBContext();
|
||||||
|
var element = context.Providers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element == null) return null;
|
||||||
|
context.Providers.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProviderViewModel? GetElement(ProviderSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue) return null;
|
||||||
|
using var context = new DBContext();
|
||||||
|
return context.Providers
|
||||||
|
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?
|
||||||
|
.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ProviderViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new DBContext();
|
||||||
|
return context.Providers
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ProviderViewModel> GetFilteredList(ProviderSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new DBContext();
|
||||||
|
return context.Providers
|
||||||
|
.Where(x => model.Id.HasValue && x.Id == model.Id)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
62
WinFormsProject/DateBaseImplement/Implements/TypeStorage.cs
Normal file
62
WinFormsProject/DateBaseImplement/Implements/TypeStorage.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
using Contracts.StorageContracts;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DateBaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class TypeStorage : ITypeStorage
|
||||||
|
{
|
||||||
|
public TypeViewModel? Insert(TypeBindingModel model)
|
||||||
|
{
|
||||||
|
var newType = Models.Type.Create(model);
|
||||||
|
if (newType == null) return null;
|
||||||
|
using var context = new DBContext();
|
||||||
|
context.Types.Add(newType);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newType.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeViewModel? Update(TypeBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new DBContext();
|
||||||
|
var type = context.Types.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (type == null) return null;
|
||||||
|
type.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return type.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeViewModel? Delete(TypeBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new DBContext();
|
||||||
|
var type = context.Types.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (type == null) return null;
|
||||||
|
context.Types.Remove(type);
|
||||||
|
context.SaveChanges();
|
||||||
|
return type.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeViewModel? GetElement(TypeSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue) return null;
|
||||||
|
using var context = new DBContext();
|
||||||
|
return context.Types
|
||||||
|
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TypeViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new DBContext();
|
||||||
|
return context.Types
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
75
WinFormsProject/DateBaseImplement/Migrations/20231115184705_initMigration.Designer.cs
generated
Normal file
75
WinFormsProject/DateBaseImplement/Migrations/20231115184705_initMigration.Designer.cs
generated
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using DateBaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DateBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DBContext))]
|
||||||
|
[Migration("20231115184705_initMigration")]
|
||||||
|
partial class initMigration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.14")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("DateBaseImplement.Models.Provider", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<byte[]>("Logo")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Number")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Providers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DateBaseImplement.Models.Type", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Types");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DateBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class initMigration : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Providers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Logo = table.Column<byte[]>(type: "bytea", nullable: false),
|
||||||
|
Type = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Number = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Providers", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Types",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Types", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Providers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Types");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
75
WinFormsProject/DateBaseImplement/Migrations/20231214060747_initMigrationMax.Designer.cs
generated
Normal file
75
WinFormsProject/DateBaseImplement/Migrations/20231214060747_initMigrationMax.Designer.cs
generated
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using DateBaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DateBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DBContext))]
|
||||||
|
[Migration("20231214060747_initMigrationMax")]
|
||||||
|
partial class initMigrationMax
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.14")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("DateBaseImplement.Models.Provider", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<byte[]>("Logo")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Number")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Providers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DateBaseImplement.Models.Type", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Types");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DateBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class initMigrationMax : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using DateBaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DateBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DBContext))]
|
||||||
|
partial class DBContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.14")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("DateBaseImplement.Models.Provider", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<byte[]>("Logo")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Number")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Providers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DateBaseImplement.Models.Type", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Types");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
62
WinFormsProject/DateBaseImplement/Models/Provider.cs
Normal file
62
WinFormsProject/DateBaseImplement/Models/Provider.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using DataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DateBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Provider : IProviderModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public byte[] Logo { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Type { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Number { get; set; }
|
||||||
|
|
||||||
|
public static Provider? Create(ProviderBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return null;
|
||||||
|
|
||||||
|
return new Provider()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Type = model.Type,
|
||||||
|
Logo = model.Logo,
|
||||||
|
Number = model.Number,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ProviderBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return;
|
||||||
|
|
||||||
|
Name = model.Name;
|
||||||
|
Type = model.Type;
|
||||||
|
Logo = model.Logo;
|
||||||
|
Number = model.Number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProviderViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
Type = Type,
|
||||||
|
Logo = Logo,
|
||||||
|
Number = Number,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
42
WinFormsProject/DateBaseImplement/Models/Type.cs
Normal file
42
WinFormsProject/DateBaseImplement/Models/Type.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using DataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DateBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Type : ITypeModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public static Type? Create(TypeBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return null;
|
||||||
|
|
||||||
|
return new Type()
|
||||||
|
{
|
||||||
|
Name = model.Name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(TypeBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return;
|
||||||
|
Name = model.Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
36
WinFormsProject/WinFormsLibrary/CircleDiagram.Designer.cs
generated
Normal file
36
WinFormsProject/WinFormsLibrary/CircleDiagram.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
namespace WinFormsLibrary
|
||||||
|
{
|
||||||
|
partial class CircleDiagram
|
||||||
|
{
|
||||||
|
/// <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
|
||||||
|
}
|
||||||
|
}
|
105
WinFormsProject/WinFormsLibrary/CircleDiagram.cs
Normal file
105
WinFormsProject/WinFormsLibrary/CircleDiagram.cs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
using Aspose.Words.Drawing.Charts;
|
||||||
|
using Aspose.Words;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WinFormsLibrary.SupportClasses;
|
||||||
|
using Aspose.Words.Drawing;
|
||||||
|
|
||||||
|
namespace WinFormsLibrary
|
||||||
|
{
|
||||||
|
public partial class CircleDiagram : Component
|
||||||
|
{
|
||||||
|
public CircleDiagram()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CircleDiagram(IContainer container)
|
||||||
|
{
|
||||||
|
container.Add(this);
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddCircleDiagram(SimpleCircleDiagram simpleCircleDiagram)
|
||||||
|
{
|
||||||
|
if (!CheckData(simpleCircleDiagram.DataList))
|
||||||
|
{
|
||||||
|
throw new Exception("Данные не заполнены");
|
||||||
|
}
|
||||||
|
|
||||||
|
Document doc = new Document();
|
||||||
|
DocumentBuilder builder = new DocumentBuilder(doc);
|
||||||
|
|
||||||
|
Aspose.Words.Font font = builder.Font;
|
||||||
|
font.Size = 24;
|
||||||
|
font.Bold = true;
|
||||||
|
font.Color = Color.Black;
|
||||||
|
font.Name = "Times New Roman";
|
||||||
|
|
||||||
|
ParagraphFormat paragraphFormat = builder.ParagraphFormat;
|
||||||
|
paragraphFormat.FirstLineIndent = 8;
|
||||||
|
paragraphFormat.SpaceAfter = 24;
|
||||||
|
paragraphFormat.Alignment = ParagraphAlignment.Center;
|
||||||
|
paragraphFormat.KeepTogether = true;
|
||||||
|
|
||||||
|
builder.Writeln(simpleCircleDiagram.FileHeader);
|
||||||
|
|
||||||
|
Shape shape = builder.InsertChart(ChartType.Pie, 500, 270);
|
||||||
|
|
||||||
|
Chart chart = shape.Chart;
|
||||||
|
|
||||||
|
chart.Title.Text = simpleCircleDiagram.CircleDiagramName;
|
||||||
|
|
||||||
|
ChartSeries series = chart.Series[0];
|
||||||
|
|
||||||
|
ChartSeriesCollection seriesColl = chart.Series;
|
||||||
|
|
||||||
|
Console.WriteLine(seriesColl.Count);
|
||||||
|
|
||||||
|
seriesColl.Clear();
|
||||||
|
|
||||||
|
foreach (var data in simpleCircleDiagram.DataList)
|
||||||
|
{
|
||||||
|
int count = Math.Min(simpleCircleDiagram.NameData.Length, data.Data.Length);
|
||||||
|
|
||||||
|
// Создаем временный массив для данных и имен, содержащий только необходимое количество элементов.
|
||||||
|
string seriesNames = data.NameSeries;
|
||||||
|
double[] seriesData = data.Data.Take(count).ToArray();
|
||||||
|
string[] categoryNames = simpleCircleDiagram.NameData.Take(count).ToArray();
|
||||||
|
|
||||||
|
// Добавляем только непустые серии с данными в график.
|
||||||
|
if (seriesData.Length > 0)
|
||||||
|
{
|
||||||
|
seriesColl.Add(seriesNames, categoryNames, seriesData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ChartLegend legend = chart.Legend;
|
||||||
|
|
||||||
|
legend.Position = (LegendPosition)simpleCircleDiagram.AreaLegend;
|
||||||
|
|
||||||
|
legend.Overlay = true;
|
||||||
|
|
||||||
|
doc.Save(simpleCircleDiagram.FilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool CheckData(List<DataCircleDiagram> data)
|
||||||
|
{
|
||||||
|
foreach (var _data in data)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_data.NameSeries) || string.IsNullOrEmpty(_data.Data.ToString()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
6
WinFormsProject/WinFormsLibrary/Class1.cs
Normal file
6
WinFormsProject/WinFormsLibrary/Class1.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace WinFormsLibrary
|
||||||
|
{
|
||||||
|
public class Class1
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
58
WinFormsProject/WinFormsLibrary/CustomCheckedListBox.Designer.cs
generated
Normal file
58
WinFormsProject/WinFormsLibrary/CustomCheckedListBox.Designer.cs
generated
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
namespace WinFormsLibrary
|
||||||
|
{
|
||||||
|
partial class CustomCheckedListBox
|
||||||
|
{
|
||||||
|
/// <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(31, 16);
|
||||||
|
this.checkedListBox.Name = "checkedListBox";
|
||||||
|
this.checkedListBox.Size = new System.Drawing.Size(262, 94);
|
||||||
|
this.checkedListBox.TabIndex = 0;
|
||||||
|
this.checkedListBox.SelectedValueChanged += new System.EventHandler(this.checkedListBox_SelectedValueChanged);
|
||||||
|
//
|
||||||
|
// CustomCheckedListBox
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.Controls.Add(this.checkedListBox);
|
||||||
|
this.Name = "CustomCheckedListBox";
|
||||||
|
this.Size = new System.Drawing.Size(333, 141);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private CheckedListBox checkedListBox;
|
||||||
|
}
|
||||||
|
}
|
78
WinFormsProject/WinFormsLibrary/CustomCheckedListBox.cs
Normal file
78
WinFormsProject/WinFormsLibrary/CustomCheckedListBox.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
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 WinFormsLibrary
|
||||||
|
{
|
||||||
|
|
||||||
|
public partial class CustomCheckedListBox : UserControl
|
||||||
|
{
|
||||||
|
public CustomCheckedListBox()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
checkedListBox.Items.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckedListBox.ObjectCollection Items
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return checkedListBox.Items;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Selected
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (checkedListBox.SelectedItem != null)
|
||||||
|
{
|
||||||
|
return checkedListBox.SelectedItem.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
for (int i = 0; i < checkedListBox.Items.Count; ++i)
|
||||||
|
{
|
||||||
|
if (checkedListBox.Items[i].ToString() == value)
|
||||||
|
{
|
||||||
|
checkedListBox.SetItemChecked(i, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private EventHandler onValueChanged;
|
||||||
|
public event EventHandler ValueChanged
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
onValueChanged += value;
|
||||||
|
}
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
onValueChanged -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkedListBox_SelectedValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
onValueChanged?.Invoke(sender, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
WinFormsProject/WinFormsLibrary/CustomCheckedListBox.resx
Normal file
60
WinFormsProject/WinFormsLibrary/CustomCheckedListBox.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>
|
36
WinFormsProject/WinFormsLibrary/DocumentWithImage.Designer.cs
generated
Normal file
36
WinFormsProject/WinFormsLibrary/DocumentWithImage.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
namespace WinFormsLibrary
|
||||||
|
{
|
||||||
|
partial class DocumentWithImage
|
||||||
|
{
|
||||||
|
/// <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
|
||||||
|
}
|
||||||
|
}
|
145
WinFormsProject/WinFormsLibrary/DocumentWithImage.cs
Normal file
145
WinFormsProject/WinFormsLibrary/DocumentWithImage.cs
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
using DocumentFormat.OpenXml.Drawing;
|
||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
|
using A = DocumentFormat.OpenXml.Drawing;
|
||||||
|
using DW = DocumentFormat.OpenXml.Drawing.Wordprocessing;
|
||||||
|
using PIC = DocumentFormat.OpenXml.Drawing.Pictures;
|
||||||
|
using Paragraph = DocumentFormat.OpenXml.Wordprocessing.Paragraph;
|
||||||
|
using Text = DocumentFormat.OpenXml.Wordprocessing.Text;
|
||||||
|
using Run = DocumentFormat.OpenXml.Wordprocessing.Run;
|
||||||
|
using WinFormsLibrary.SupportClasses;
|
||||||
|
|
||||||
|
namespace WinFormsLibrary
|
||||||
|
{
|
||||||
|
public partial class DocumentWithImage : Component
|
||||||
|
{
|
||||||
|
private WordprocessingDocument? _wordDocument;
|
||||||
|
|
||||||
|
private Body? _docBody;
|
||||||
|
|
||||||
|
public DocumentWithImage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DocumentWithImage(IContainer container)
|
||||||
|
{
|
||||||
|
container.Add(this);
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateDocument(ImageClass imageClass)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(imageClass.Path) || string.IsNullOrEmpty(imageClass.Title) || imageClass.Files.Count == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Не все данные заполнены");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Создаем Word-документ
|
||||||
|
using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(imageClass.Path, WordprocessingDocumentType.Document))
|
||||||
|
{
|
||||||
|
MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
|
||||||
|
mainPart.Document = new Document();
|
||||||
|
Body body = new Body();
|
||||||
|
|
||||||
|
// Добавляем заголовок
|
||||||
|
Paragraph titleParagraph = new Paragraph(new Run(new Text(imageClass.Title)));
|
||||||
|
body.Append(titleParagraph);
|
||||||
|
|
||||||
|
// Добавляем изображения
|
||||||
|
mainPart.Document.Append(body);
|
||||||
|
|
||||||
|
foreach (byte[] imageData in imageClass.Files)
|
||||||
|
{
|
||||||
|
ImagePart imagePart = mainPart.AddImagePart(ImagePartType.Jpeg);
|
||||||
|
using (MemoryStream stream = new MemoryStream(imageData))
|
||||||
|
{
|
||||||
|
imagePart.FeedData(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
AddImageToBody(wordDocument, mainPart.GetIdOfPart(imagePart));
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Word-документ успешно создан в файле '{imageClass.Path}'.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddImageToBody(WordprocessingDocument wordDoc, string relationshipId)
|
||||||
|
{
|
||||||
|
var element = new Drawing(
|
||||||
|
new DW.Inline(
|
||||||
|
new DW.Extent() { Cx = 1990000L, Cy = 1792000L },
|
||||||
|
new DW.EffectExtent()
|
||||||
|
{
|
||||||
|
LeftEdge = 0L,
|
||||||
|
TopEdge = 0L,
|
||||||
|
RightEdge = 0L,
|
||||||
|
BottomEdge = 0L
|
||||||
|
},
|
||||||
|
new DW.DocProperties()
|
||||||
|
{
|
||||||
|
Id = (UInt32Value)1U,
|
||||||
|
Name = "Picture 1"
|
||||||
|
},
|
||||||
|
new DW.NonVisualGraphicFrameDrawingProperties(
|
||||||
|
new A.GraphicFrameLocks() { NoChangeAspect = true }),
|
||||||
|
new A.Graphic(
|
||||||
|
new A.GraphicData(
|
||||||
|
new PIC.Picture(
|
||||||
|
new PIC.NonVisualPictureProperties(
|
||||||
|
new PIC.NonVisualDrawingProperties()
|
||||||
|
{
|
||||||
|
Id = (UInt32Value)0U,
|
||||||
|
Name = "New Bitmap Image.jpg"
|
||||||
|
},
|
||||||
|
new PIC.NonVisualPictureDrawingProperties()),
|
||||||
|
new PIC.BlipFill(
|
||||||
|
new A.Blip(
|
||||||
|
new A.BlipExtensionList(
|
||||||
|
new A.BlipExtension()
|
||||||
|
{
|
||||||
|
Uri =
|
||||||
|
"{28A0092B-C50C-407E-A947-70E740481C1C}"
|
||||||
|
})
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Embed = relationshipId,
|
||||||
|
CompressionState =
|
||||||
|
A.BlipCompressionValues.Print
|
||||||
|
},
|
||||||
|
new A.Stretch(
|
||||||
|
new A.FillRectangle())),
|
||||||
|
new PIC.ShapeProperties(
|
||||||
|
new A.Transform2D(
|
||||||
|
new A.Offset() { X = 0L, Y = 0L },
|
||||||
|
new A.Extents() { Cx = 990000L, Cy = 792000L }),
|
||||||
|
new A.PresetGeometry(
|
||||||
|
new A.AdjustValueList()
|
||||||
|
)
|
||||||
|
{ Preset = A.ShapeTypeValues.Rectangle }))
|
||||||
|
)
|
||||||
|
{ Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" })
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DistanceFromTop = (UInt32Value)0U,
|
||||||
|
DistanceFromBottom = (UInt32Value)0U,
|
||||||
|
DistanceFromLeft = (UInt32Value)0U,
|
||||||
|
DistanceFromRight = (UInt32Value)0U,
|
||||||
|
EditId = "50D07946"
|
||||||
|
});
|
||||||
|
|
||||||
|
// Append the reference to the body. The element should be in
|
||||||
|
// a DocumentFormat.OpenXml.Wordprocessing.Run.
|
||||||
|
wordDoc.MainDocumentPart.Document.Body.AppendChild(new Paragraph(new Run(element)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
59
WinFormsProject/WinFormsLibrary/NumberTextBox.Designer.cs
generated
Normal file
59
WinFormsProject/WinFormsLibrary/NumberTextBox.Designer.cs
generated
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
namespace WinFormsLibrary
|
||||||
|
{
|
||||||
|
partial class NumberTextBox
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
numericUpDown = new NumericUpDown();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDown).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// numericUpDown
|
||||||
|
//
|
||||||
|
numericUpDown.Location = new Point(117, 37);
|
||||||
|
numericUpDown.Maximum = new decimal(new int[] { 110, 0, 0, 0 });
|
||||||
|
numericUpDown.Minimum = new decimal(new int[] { 50, 0, 0, int.MinValue });
|
||||||
|
numericUpDown.Name = "numericUpDown";
|
||||||
|
numericUpDown.Size = new Size(120, 23);
|
||||||
|
numericUpDown.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// NumberTextBox
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
Controls.Add(numericUpDown);
|
||||||
|
Name = "NumberTextBox";
|
||||||
|
Size = new Size(364, 106);
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDown).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private NumericUpDown numericUpDown;
|
||||||
|
}
|
||||||
|
}
|
92
WinFormsProject/WinFormsLibrary/NumberTextBox.cs
Normal file
92
WinFormsProject/WinFormsLibrary/NumberTextBox.cs
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
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 WinFormsLibrary
|
||||||
|
{
|
||||||
|
public partial class NumberTextBox : UserControl
|
||||||
|
{
|
||||||
|
public int? maxValue = null;
|
||||||
|
public int? minValue = null;
|
||||||
|
public string errorText = "";
|
||||||
|
|
||||||
|
public NumberTextBox()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int? MinValue
|
||||||
|
{
|
||||||
|
get { return minValue; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == null) return;
|
||||||
|
minValue = value;
|
||||||
|
numericUpDown.Minimum = (int)value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int? MaxValue
|
||||||
|
{
|
||||||
|
get { return maxValue; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == null) return;
|
||||||
|
maxValue = value;
|
||||||
|
numericUpDown.Maximum = (int)value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public decimal? Value
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
if (CheckRanges(numericUpDown.Value))
|
||||||
|
{
|
||||||
|
return numericUpDown.Value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (CheckRanges(value))
|
||||||
|
{
|
||||||
|
numericUpDown.Value = (decimal)value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool CheckRanges(decimal? value)
|
||||||
|
{
|
||||||
|
if (MinValue == null || MaxValue == null)
|
||||||
|
{
|
||||||
|
errorText = "Ошибка, диапазоны не заданы.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value < MinValue || value > MaxValue)
|
||||||
|
{
|
||||||
|
errorText = "Ошибка, значение не входит в заданный диапазон.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
errorText = "Ошибок нет.";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public event EventHandler DateChanged
|
||||||
|
{
|
||||||
|
add { numericUpDown.ValueChanged += value; }
|
||||||
|
remove { numericUpDown.ValueChanged -= value; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
WinFormsProject/WinFormsLibrary/NumberTextBox.resx
Normal file
60
WinFormsProject/WinFormsLibrary/NumberTextBox.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>
|
31
WinFormsProject/WinFormsLibrary/SupportClasses/BigTable.cs
Normal file
31
WinFormsProject/WinFormsLibrary/SupportClasses/BigTable.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WinFormsLibrary.SupportClasses
|
||||||
|
{
|
||||||
|
public class BigTable<T>
|
||||||
|
{
|
||||||
|
public string FilePath = string.Empty;
|
||||||
|
|
||||||
|
public string DocumentTitle = string.Empty;
|
||||||
|
|
||||||
|
public List<ColumnDefinition> ColumnDefinitions;
|
||||||
|
public List<ColumnDefinition> ColumnDefinitions2;
|
||||||
|
|
||||||
|
public List<T> Data;
|
||||||
|
|
||||||
|
public List<int[]> MergedColumns;
|
||||||
|
public BigTable(string filePath, string documentTitle, List<ColumnDefinition> columnDefinitions, List<ColumnDefinition> columnDefinitions2, List<T> data, List<int[]> mergedColumns)
|
||||||
|
{
|
||||||
|
FilePath = filePath;
|
||||||
|
DocumentTitle = documentTitle;
|
||||||
|
ColumnDefinitions = columnDefinitions;
|
||||||
|
Data = data;
|
||||||
|
MergedColumns = mergedColumns;
|
||||||
|
ColumnDefinitions2 = columnDefinitions2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WinFormsLibrary.SupportClasses
|
||||||
|
{
|
||||||
|
public class ColumnDefinition
|
||||||
|
{
|
||||||
|
public string Header;
|
||||||
|
public string PropertyName;
|
||||||
|
public double Weight;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WinFormsLibrary.SupportClasses
|
||||||
|
{
|
||||||
|
public class DataCircleDiagram
|
||||||
|
{
|
||||||
|
public string NameSeries { get; set; } = string.Empty;
|
||||||
|
public double[] Data { get; set; }
|
||||||
|
|
||||||
|
public DataCircleDiagram(string nameSeries, double[] data)
|
||||||
|
{
|
||||||
|
NameSeries = nameSeries;
|
||||||
|
Data = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WinFormsLibrary.SupportClasses.Enums
|
||||||
|
{
|
||||||
|
public enum EnumAreaLegend
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
|
||||||
|
Left,
|
||||||
|
|
||||||
|
Top,
|
||||||
|
|
||||||
|
Right,
|
||||||
|
|
||||||
|
Bottom,
|
||||||
|
|
||||||
|
TopRight
|
||||||
|
}
|
||||||
|
}
|
26
WinFormsProject/WinFormsLibrary/SupportClasses/ImageClass.cs
Normal file
26
WinFormsProject/WinFormsLibrary/SupportClasses/ImageClass.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WinFormsLibrary.SupportClasses
|
||||||
|
{
|
||||||
|
public class ImageClass
|
||||||
|
{
|
||||||
|
private string path;
|
||||||
|
private string title;
|
||||||
|
private List<byte[]> files;
|
||||||
|
public string Path { get { return path; } set { path = value; } }
|
||||||
|
public string Title { get { return title; } set { title = value; } }
|
||||||
|
public List<byte[]> Files { get { return files; } set { files = value; } }
|
||||||
|
public ImageClass() { }
|
||||||
|
|
||||||
|
public ImageClass(string filePath, string documentTitle, List<byte[]> textData)
|
||||||
|
{
|
||||||
|
Path = filePath;
|
||||||
|
Title = documentTitle;
|
||||||
|
Files = textData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WinFormsLibrary.SupportClasses.Enums;
|
||||||
|
|
||||||
|
namespace WinFormsLibrary.SupportClasses
|
||||||
|
{
|
||||||
|
public class SimpleCircleDiagram
|
||||||
|
{
|
||||||
|
public string FileHeader { get; set; } = string.Empty;
|
||||||
|
public string CircleDiagramName { get; set; } = string.Empty;
|
||||||
|
public List<DataCircleDiagram> DataList { get; set; } = new();
|
||||||
|
public string FilePath { get; set; } = string.Empty;
|
||||||
|
public EnumAreaLegend AreaLegend { get; set; }
|
||||||
|
public string[] NameData { get; set; }
|
||||||
|
public SimpleCircleDiagram(string filePath, string fileHeader, string circleDiagramName, EnumAreaLegend areaLegend, List<DataCircleDiagram> dataList)
|
||||||
|
{
|
||||||
|
FilePath = filePath;
|
||||||
|
FileHeader = fileHeader;
|
||||||
|
CircleDiagramName = circleDiagramName;
|
||||||
|
AreaLegend = areaLegend;
|
||||||
|
DataList = dataList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
WinFormsProject/WinFormsLibrary/SupportClasses/Student.cs
Normal file
27
WinFormsProject/WinFormsLibrary/SupportClasses/Student.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WinFormsLibrary.SupportClasses
|
||||||
|
{
|
||||||
|
public class Student
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Group { get; set; }
|
||||||
|
public string Faculty { get; set; }
|
||||||
|
public int Course { get; set; }
|
||||||
|
|
||||||
|
public Student(string name, string group, string faculty, int course)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
Group = group;
|
||||||
|
Faculty = faculty;
|
||||||
|
Course = course;
|
||||||
|
}
|
||||||
|
public Student()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
WinFormsProject/WinFormsLibrary/Table2column.Designer.cs
generated
Normal file
36
WinFormsProject/WinFormsLibrary/Table2column.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
namespace WinFormsLibrary
|
||||||
|
{
|
||||||
|
partial class Table2column
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Обязательная переменная конструктора.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Освободить все используемые ресурсы.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Код, автоматически созданный конструктором компонентов
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||||
|
/// содержимое этого метода с помощью редактора кода.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
components = new System.ComponentModel.Container();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
134
WinFormsProject/WinFormsLibrary/Table2column.cs
Normal file
134
WinFormsProject/WinFormsLibrary/Table2column.cs
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Aspose.Words;
|
||||||
|
using Aspose.Words.Tables;
|
||||||
|
using WinFormsLibrary.SupportClasses;
|
||||||
|
|
||||||
|
namespace WinFormsLibrary
|
||||||
|
{
|
||||||
|
public partial class Table2column : Component
|
||||||
|
{
|
||||||
|
public Table2column()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Table2column(IContainer container)
|
||||||
|
{
|
||||||
|
container.Add(this);
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateTable<T>(BigTable<T> bigTable)
|
||||||
|
{
|
||||||
|
if (bigTable.Data == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Не заданы все данные");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var columnDefinition in bigTable.ColumnDefinitions)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(columnDefinition.PropertyName))
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"Не задано свойство столбца: {columnDefinition.Header}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Document document = new Document();
|
||||||
|
DocumentBuilder builder = new DocumentBuilder(document);
|
||||||
|
|
||||||
|
Style titleStyle = builder.Document.Styles.Add(StyleType.Paragraph, "Title");
|
||||||
|
titleStyle.Font.Size = 16;
|
||||||
|
titleStyle.Font.Bold = true;
|
||||||
|
|
||||||
|
builder.ParagraphFormat.Style = titleStyle;
|
||||||
|
builder.Writeln(bigTable.DocumentTitle);
|
||||||
|
|
||||||
|
Table table = builder.StartTable();
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var columnDefinition in bigTable.ColumnDefinitions)
|
||||||
|
{
|
||||||
|
builder.InsertCell();
|
||||||
|
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition.Weight);
|
||||||
|
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
|
||||||
|
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
|
||||||
|
builder.Write(columnDefinition.Header);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var mergedColumn in bigTable.MergedColumns)
|
||||||
|
{
|
||||||
|
int startCellIndex = mergedColumn[0];
|
||||||
|
int endCellIndex = mergedColumn[mergedColumn.Length - 1];
|
||||||
|
|
||||||
|
for (int i = startCellIndex; i <= endCellIndex; i++)
|
||||||
|
{
|
||||||
|
table.Rows[0].Cells[i].CellFormat.HorizontalMerge = CellMerge.First;
|
||||||
|
table.Rows[0].Cells[i].CellFormat.VerticalMerge = CellMerge.First;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = startCellIndex + 1; i <= endCellIndex; i++)
|
||||||
|
{
|
||||||
|
table.Rows[0].Cells[i].CellFormat.HorizontalMerge = CellMerge.Previous;
|
||||||
|
table.Rows[0].Cells[i].CellFormat.VerticalMerge = CellMerge.First;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
builder.EndRow();
|
||||||
|
|
||||||
|
foreach (var columnDefinition2 in bigTable.ColumnDefinitions2)
|
||||||
|
{
|
||||||
|
builder.InsertCell();
|
||||||
|
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition2.Weight);
|
||||||
|
builder.Write(columnDefinition2.Header);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.EndRow();
|
||||||
|
|
||||||
|
int columnIndex;
|
||||||
|
foreach (var columnDefinition in bigTable.ColumnDefinitions)
|
||||||
|
{
|
||||||
|
string currentPropertyName = columnDefinition.PropertyName;
|
||||||
|
columnIndex = 0;
|
||||||
|
foreach (var columnDefinition2 in bigTable.ColumnDefinitions2)
|
||||||
|
{
|
||||||
|
string currentPropertyName1 = columnDefinition2.PropertyName;
|
||||||
|
|
||||||
|
if (currentPropertyName == currentPropertyName1)
|
||||||
|
{
|
||||||
|
table.Rows[0].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.First;
|
||||||
|
table.Rows[1].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.Previous;
|
||||||
|
|
||||||
|
}
|
||||||
|
columnIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var item in bigTable.Data)
|
||||||
|
{
|
||||||
|
foreach (var columnDefinition2 in bigTable.ColumnDefinitions2)
|
||||||
|
{
|
||||||
|
builder.InsertCell();
|
||||||
|
var propertyValue = item.GetType()
|
||||||
|
.GetProperty(columnDefinition2.PropertyName)?
|
||||||
|
.GetValue(item)?.ToString();
|
||||||
|
|
||||||
|
builder.Write(propertyValue ?? "");
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.EndRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.EndTable();
|
||||||
|
|
||||||
|
document.Save(bigTable.FilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
56
WinFormsProject/WinFormsLibrary/TreeClass.Designer.cs
generated
Normal file
56
WinFormsProject/WinFormsLibrary/TreeClass.Designer.cs
generated
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
namespace WinFormsLibrary
|
||||||
|
{
|
||||||
|
partial class TreeClass
|
||||||
|
{
|
||||||
|
/// <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(292, 224);
|
||||||
|
this.treeView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// TreeClass
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.Controls.Add(this.treeView);
|
||||||
|
this.Name = "TreeClass";
|
||||||
|
this.Size = new System.Drawing.Size(292, 224);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TreeView treeView;
|
||||||
|
}
|
||||||
|
}
|
133
WinFormsProject/WinFormsLibrary/TreeClass.cs
Normal file
133
WinFormsProject/WinFormsLibrary/TreeClass.cs
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection.Metadata.Ecma335;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
|
||||||
|
namespace WinFormsLibrary
|
||||||
|
{
|
||||||
|
public partial class TreeClass : UserControl
|
||||||
|
{
|
||||||
|
private List<string> hierarchy;
|
||||||
|
public bool hasError = false;
|
||||||
|
|
||||||
|
public TreeClass()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHierarchy(List<string> h)
|
||||||
|
{
|
||||||
|
hierarchy = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool hasValue(TreeNodeCollection nodes, string value)
|
||||||
|
{
|
||||||
|
foreach (TreeNode node in nodes)
|
||||||
|
{
|
||||||
|
if (node.Text == value) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool addData<T>(T t, string propertyName)
|
||||||
|
{
|
||||||
|
TreeNodeCollection current = treeView.Nodes;
|
||||||
|
TreeNode newNode = null;
|
||||||
|
|
||||||
|
foreach (string h in hierarchy)
|
||||||
|
{
|
||||||
|
if (h == propertyName)
|
||||||
|
{
|
||||||
|
var field = t.GetType().GetField(h);
|
||||||
|
|
||||||
|
if (field == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
string value = field.GetValue(t)?.ToString();
|
||||||
|
|
||||||
|
if (!hasValue(current, value))
|
||||||
|
{
|
||||||
|
newNode = current.Add(value); // Добавляем новый узел и сохраняем его в переменной newNode
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Аналогично добавляем новый узел и сохраняем его в переменной newNode
|
||||||
|
if (!hasValue(current, h))
|
||||||
|
{
|
||||||
|
newNode = current.Add(h);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Находим существующий узел с нужным значением
|
||||||
|
foreach (TreeNode child in current)
|
||||||
|
{
|
||||||
|
if (child.Text == h)
|
||||||
|
{
|
||||||
|
newNode = child;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
current = newNode.Nodes; // Переходим к дочерним узлам нового узла
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool setData<T>(T data, string propertyName)
|
||||||
|
{
|
||||||
|
bool status = addData<T>(data, propertyName);
|
||||||
|
if (!status) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T GetSelectedClass<T>() where T : new()
|
||||||
|
{
|
||||||
|
T res = default(T);
|
||||||
|
TreeNode node = treeView.SelectedNode;
|
||||||
|
|
||||||
|
if (node.Nodes.Count != 0)
|
||||||
|
{
|
||||||
|
hasError = true;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = hierarchy.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
hasError = true;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
var curr = res.GetType().GetField(hierarchy[i]);
|
||||||
|
if (curr == null)
|
||||||
|
{
|
||||||
|
hasError = true;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
curr.SetValue(res, node.Text);
|
||||||
|
node = node.Parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
WinFormsProject/WinFormsLibrary/TreeClass.resx
Normal file
60
WinFormsProject/WinFormsLibrary/TreeClass.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>
|
16
WinFormsProject/WinFormsLibrary/WinFormsLibraryAA.csproj
Normal file
16
WinFormsProject/WinFormsLibrary/WinFormsLibraryAA.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="Aspose.Words" Version="23.10.0" />
|
||||||
|
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
55
WinFormsProject/WinFormsProject.sln
Normal file
55
WinFormsProject/WinFormsProject.sln
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.3.32819.101
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsProject", "WinFormsProject\WinFormsProject.csproj", "{1FC6ABE3-DF27-453A-B2EE-FA17C71C9CF0}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsLibraryAA", "WinFormsLibrary\WinFormsLibraryAA.csproj", "{CF6B5601-DC60-48A2-8BDC-1CE32E3F6F15}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataModels", "DataModels\DataModels.csproj", "{23F0E442-0283-4192-A17B-D13D0C01C10D}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{6A196E6B-91D9-4873-9E5F-0D96D18A74F5}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DateBaseImplement", "DateBaseImplement\DateBaseImplement.csproj", "{F53D2EB4-F1EB-4C24-987C-CCC6BFC5FAD7}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppView", "AppView\AppView.csproj", "{294B81DD-546F-40AD-9BCE-0F51F1D17D1A}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{1FC6ABE3-DF27-453A-B2EE-FA17C71C9CF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1FC6ABE3-DF27-453A-B2EE-FA17C71C9CF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1FC6ABE3-DF27-453A-B2EE-FA17C71C9CF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1FC6ABE3-DF27-453A-B2EE-FA17C71C9CF0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{CF6B5601-DC60-48A2-8BDC-1CE32E3F6F15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{CF6B5601-DC60-48A2-8BDC-1CE32E3F6F15}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{CF6B5601-DC60-48A2-8BDC-1CE32E3F6F15}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{CF6B5601-DC60-48A2-8BDC-1CE32E3F6F15}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{23F0E442-0283-4192-A17B-D13D0C01C10D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{23F0E442-0283-4192-A17B-D13D0C01C10D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{23F0E442-0283-4192-A17B-D13D0C01C10D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{23F0E442-0283-4192-A17B-D13D0C01C10D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{6A196E6B-91D9-4873-9E5F-0D96D18A74F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6A196E6B-91D9-4873-9E5F-0D96D18A74F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6A196E6B-91D9-4873-9E5F-0D96D18A74F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6A196E6B-91D9-4873-9E5F-0D96D18A74F5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F53D2EB4-F1EB-4C24-987C-CCC6BFC5FAD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F53D2EB4-F1EB-4C24-987C-CCC6BFC5FAD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F53D2EB4-F1EB-4C24-987C-CCC6BFC5FAD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F53D2EB4-F1EB-4C24-987C-CCC6BFC5FAD7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{294B81DD-546F-40AD-9BCE-0F51F1D17D1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{294B81DD-546F-40AD-9BCE-0F51F1D17D1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{294B81DD-546F-40AD-9BCE-0F51F1D17D1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{294B81DD-546F-40AD-9BCE-0F51F1D17D1A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {2774D1CA-C461-4F94-89BF-C2FD28AC4024}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
97
WinFormsProject/WinFormsProject/Form1.Designer.cs
generated
Normal file
97
WinFormsProject/WinFormsProject/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
namespace WinFormsProject
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <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.customCheckedListBox1 = new WinFormsLibrary.CustomCheckedListBox();
|
||||||
|
this.Button_Fill = new System.Windows.Forms.Button();
|
||||||
|
this.Button_Clear = new System.Windows.Forms.Button();
|
||||||
|
this.Button_GetChosenValues = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// customCheckedListBox1
|
||||||
|
//
|
||||||
|
this.customCheckedListBox1.Location = new System.Drawing.Point(21, 21);
|
||||||
|
this.customCheckedListBox1.Name = "customCheckedListBox1";
|
||||||
|
this.customCheckedListBox1.Selected = "";
|
||||||
|
this.customCheckedListBox1.Size = new System.Drawing.Size(333, 141);
|
||||||
|
this.customCheckedListBox1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// Button_Fill
|
||||||
|
//
|
||||||
|
this.Button_Fill.Location = new System.Drawing.Point(130, 141);
|
||||||
|
this.Button_Fill.Name = "Button_Fill";
|
||||||
|
this.Button_Fill.Size = new System.Drawing.Size(106, 45);
|
||||||
|
this.Button_Fill.TabIndex = 1;
|
||||||
|
this.Button_Fill.Text = "Заполнить";
|
||||||
|
this.Button_Fill.UseVisualStyleBackColor = true;
|
||||||
|
this.Button_Fill.Click += new System.EventHandler(this.Button_Fill_Click);
|
||||||
|
//
|
||||||
|
// Button_Clear
|
||||||
|
//
|
||||||
|
this.Button_Clear.Location = new System.Drawing.Point(130, 206);
|
||||||
|
this.Button_Clear.Name = "Button_Clear";
|
||||||
|
this.Button_Clear.Size = new System.Drawing.Size(106, 53);
|
||||||
|
this.Button_Clear.TabIndex = 2;
|
||||||
|
this.Button_Clear.Text = "Очистить";
|
||||||
|
this.Button_Clear.UseVisualStyleBackColor = true;
|
||||||
|
this.Button_Clear.Click += new System.EventHandler(this.Button_Clear_Click);
|
||||||
|
//
|
||||||
|
// Button_GetChosenValues
|
||||||
|
//
|
||||||
|
this.Button_GetChosenValues.Location = new System.Drawing.Point(130, 277);
|
||||||
|
this.Button_GetChosenValues.Name = "Button_GetChosenValues";
|
||||||
|
this.Button_GetChosenValues.Size = new System.Drawing.Size(106, 52);
|
||||||
|
this.Button_GetChosenValues.TabIndex = 3;
|
||||||
|
this.Button_GetChosenValues.Text = "Выбранные значения";
|
||||||
|
this.Button_GetChosenValues.UseVisualStyleBackColor = true;
|
||||||
|
this.Button_GetChosenValues.Click += new System.EventHandler(this.Button_GetChosenValues_Click);
|
||||||
|
//
|
||||||
|
// Form1
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.Button_GetChosenValues);
|
||||||
|
this.Controls.Add(this.Button_Clear);
|
||||||
|
this.Controls.Add(this.Button_Fill);
|
||||||
|
this.Controls.Add(this.customCheckedListBox1);
|
||||||
|
this.Name = "Form1";
|
||||||
|
this.Text = "Form1";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private WinFormsLibrary.CustomCheckedListBox customCheckedListBox1;
|
||||||
|
private Button Button_Fill;
|
||||||
|
private Button Button_Clear;
|
||||||
|
private Button Button_GetChosenValues;
|
||||||
|
}
|
||||||
|
}
|
41
WinFormsProject/WinFormsProject/Form1.cs
Normal file
41
WinFormsProject/WinFormsProject/Form1.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
namespace WinFormsProject
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
List<string> list = new List<string> { "Ìàðàò", "Áóðàê", "Ðîâøàê" };
|
||||||
|
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
//customCheckedListBox1.FillCheckedListBox(list);
|
||||||
|
customCheckedListBox1.ValueChanged += CustomEventHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CustomEventHandler(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Çíà÷åíèå áûëî èçìåíåíî.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_Clear_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
customCheckedListBox1.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_Fill_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// customCheckedListBox1.FillCheckedListBox(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_GetChosenValues_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (customCheckedListBox1.Selected == null || customCheckedListBox1.Selected == "")
|
||||||
|
{
|
||||||
|
MessageBox.Show("Íåòó âûáðàííûõ ýëåìåíòîâ.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show(customCheckedListBox1.Selected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
WinFormsProject/WinFormsProject/Form1.resx
Normal file
60
WinFormsProject/WinFormsProject/Form1.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>
|
128
WinFormsProject/WinFormsProject/Form2.Designer.cs
generated
Normal file
128
WinFormsProject/WinFormsProject/Form2.Designer.cs
generated
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
namespace WinFormsProject
|
||||||
|
{
|
||||||
|
partial class Form2
|
||||||
|
{
|
||||||
|
/// <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.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
|
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.button2 = new System.Windows.Forms.Button();
|
||||||
|
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.button3 = new System.Windows.Forms.Button();
|
||||||
|
this.groupBox1.SuspendLayout();
|
||||||
|
this.groupBox2.SuspendLayout();
|
||||||
|
this.groupBox3.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
this.groupBox1.Controls.Add(this.button1);
|
||||||
|
this.groupBox1.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.groupBox1.Name = "groupBox1";
|
||||||
|
this.groupBox1.Size = new System.Drawing.Size(185, 71);
|
||||||
|
this.groupBox1.TabIndex = 0;
|
||||||
|
this.groupBox1.TabStop = false;
|
||||||
|
this.groupBox1.Text = "Работа с изображениями";
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
this.button1.Location = new System.Drawing.Point(56, 42);
|
||||||
|
this.button1.Name = "button1";
|
||||||
|
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.button1.TabIndex = 0;
|
||||||
|
this.button1.Text = "Создать";
|
||||||
|
this.button1.UseVisualStyleBackColor = true;
|
||||||
|
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||||
|
//
|
||||||
|
// groupBox2
|
||||||
|
//
|
||||||
|
this.groupBox2.Controls.Add(this.button2);
|
||||||
|
this.groupBox2.Location = new System.Drawing.Point(217, 12);
|
||||||
|
this.groupBox2.Name = "groupBox2";
|
||||||
|
this.groupBox2.Size = new System.Drawing.Size(185, 71);
|
||||||
|
this.groupBox2.TabIndex = 1;
|
||||||
|
this.groupBox2.TabStop = false;
|
||||||
|
this.groupBox2.Text = "Работа с таблицей";
|
||||||
|
//
|
||||||
|
// button2
|
||||||
|
//
|
||||||
|
this.button2.Location = new System.Drawing.Point(57, 42);
|
||||||
|
this.button2.Name = "button2";
|
||||||
|
this.button2.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.button2.TabIndex = 0;
|
||||||
|
this.button2.Text = "Создать";
|
||||||
|
this.button2.UseVisualStyleBackColor = true;
|
||||||
|
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||||
|
//
|
||||||
|
// groupBox3
|
||||||
|
//
|
||||||
|
this.groupBox3.Controls.Add(this.button3);
|
||||||
|
this.groupBox3.Location = new System.Drawing.Point(437, 12);
|
||||||
|
this.groupBox3.Name = "groupBox3";
|
||||||
|
this.groupBox3.Size = new System.Drawing.Size(185, 71);
|
||||||
|
this.groupBox3.TabIndex = 2;
|
||||||
|
this.groupBox3.TabStop = false;
|
||||||
|
this.groupBox3.Text = "Работа с диаграммой";
|
||||||
|
//
|
||||||
|
// button3
|
||||||
|
//
|
||||||
|
this.button3.Location = new System.Drawing.Point(56, 42);
|
||||||
|
this.button3.Name = "button3";
|
||||||
|
this.button3.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.button3.TabIndex = 0;
|
||||||
|
this.button3.Text = "Создать";
|
||||||
|
this.button3.UseVisualStyleBackColor = true;
|
||||||
|
this.button3.Click += new System.EventHandler(this.button3_Click);
|
||||||
|
//
|
||||||
|
// Form2
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(649, 95);
|
||||||
|
this.Controls.Add(this.groupBox3);
|
||||||
|
this.Controls.Add(this.groupBox2);
|
||||||
|
this.Controls.Add(this.groupBox1);
|
||||||
|
this.Name = "Form2";
|
||||||
|
this.Text = "Form2";
|
||||||
|
this.groupBox1.ResumeLayout(false);
|
||||||
|
this.groupBox2.ResumeLayout(false);
|
||||||
|
this.groupBox3.ResumeLayout(false);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private Button button1;
|
||||||
|
private GroupBox groupBox2;
|
||||||
|
private Button button2;
|
||||||
|
private GroupBox groupBox3;
|
||||||
|
private Button button3;
|
||||||
|
}
|
||||||
|
}
|
137
WinFormsProject/WinFormsProject/Form2.cs
Normal file
137
WinFormsProject/WinFormsProject/Form2.cs
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
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 WinFormsLibrary.SupportClasses.Enums;
|
||||||
|
using WinFormsLibrary.SupportClasses;
|
||||||
|
using WinFormsLibrary;
|
||||||
|
|
||||||
|
namespace WinFormsProject
|
||||||
|
{
|
||||||
|
public partial class Form2 : Form
|
||||||
|
{
|
||||||
|
private List<string> testArray;
|
||||||
|
DocumentWithImage documentWithImage;
|
||||||
|
Table2column table2column;
|
||||||
|
CircleDiagram circleDiagram;
|
||||||
|
|
||||||
|
public Form2()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
documentWithImage = new DocumentWithImage();
|
||||||
|
table2column = new Table2column();
|
||||||
|
circleDiagram = new CircleDiagram();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
/*testArray = new List<string>() {
|
||||||
|
"C:\\Users\\user\\Desktop\\images\\car_img1.png",
|
||||||
|
"C:\\Users\\user\\Desktop\\images\\car_img2.png",
|
||||||
|
};
|
||||||
|
|
||||||
|
//фильтрация файлов для диалогового окна
|
||||||
|
using var dialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "docx|*.docx"
|
||||||
|
};
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ImageClass imageClass = new(dialog.FileName, "Любой заголовок", testArray);
|
||||||
|
documentWithImage.CreateDocument(imageClass);
|
||||||
|
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button2_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
List<int[]> mergedColumns = new()
|
||||||
|
{
|
||||||
|
new int[] { 0, 1, 2 }
|
||||||
|
};
|
||||||
|
|
||||||
|
List<ColumnDefinition> columnDefinitions = new List<ColumnDefinition>
|
||||||
|
{
|
||||||
|
new ColumnDefinition { Header = "Образование", PropertyName = "Eduction", Weight = 35 },
|
||||||
|
new ColumnDefinition { Header = "", PropertyName = "Education1", Weight = 35 },
|
||||||
|
new ColumnDefinition { Header = "", PropertyName = "Education2", Weight = 10 },
|
||||||
|
new ColumnDefinition { Header = "Фамилия", PropertyName = "Name", Weight = 20 }
|
||||||
|
};
|
||||||
|
|
||||||
|
List<ColumnDefinition> columnDefinitions2 = new List<ColumnDefinition>
|
||||||
|
{
|
||||||
|
new ColumnDefinition { Header = "Группа", PropertyName = "Group", Weight = 35 },
|
||||||
|
new ColumnDefinition { Header = "Факультатив", PropertyName = "Faculty", Weight = 35 },
|
||||||
|
new ColumnDefinition { Header = "Курс", PropertyName = "Course", Weight = 10 },
|
||||||
|
new ColumnDefinition { Header = "Фамилия", PropertyName = "Name", Weight = 20 }
|
||||||
|
};
|
||||||
|
|
||||||
|
List<Student> data = new List<Student>
|
||||||
|
{
|
||||||
|
new Student { Group = "ПИбд-32", Faculty = "ФИСТ", Course = 3, Name = "Исмаилов" },
|
||||||
|
new Student { Group = "РТбд-11", Faculty = "РТФ", Course = 1, Name = "Чубриков" },
|
||||||
|
new Student { Group = "ЛМККбд-41", Faculty = "ГФ", Course = 4, Name = "Летунова" }
|
||||||
|
};
|
||||||
|
|
||||||
|
using var dialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "docx|*.docx"
|
||||||
|
};
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
BigTable<Student> bigTable = new(dialog.FileName, "Задание 2", columnDefinitions, columnDefinitions2, data, mergedColumns);
|
||||||
|
table2column.CreateTable(bigTable);
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button3_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//фильтрация файлов для диалогового окна
|
||||||
|
using var dialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "docx|*.docx"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
double[] profit1 = { 300, 324, 500 };
|
||||||
|
SimpleCircleDiagram simpleCircleDiagram = new(dialog.FileName, "Третье задание", "График прибыли", EnumAreaLegend.Right, new List<DataCircleDiagram> {
|
||||||
|
new DataCircleDiagram("Компания Первая", profit1)});
|
||||||
|
|
||||||
|
simpleCircleDiagram.NameData = new string[] { "Январь", "Февраль", "Март" };
|
||||||
|
|
||||||
|
circleDiagram.AddCircleDiagram(simpleCircleDiagram);
|
||||||
|
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
WinFormsProject/WinFormsProject/Form2.resx
Normal file
60
WinFormsProject/WinFormsProject/Form2.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>
|
17
WinFormsProject/WinFormsProject/Program.cs
Normal file
17
WinFormsProject/WinFormsProject/Program.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace WinFormsProject
|
||||||
|
{
|
||||||
|
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 Form2());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
WinFormsProject/WinFormsProject/WinFormsProject.csproj
Normal file
15
WinFormsProject/WinFormsProject/WinFormsProject.csproj
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<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>
|
||||||
|
<ProjectReference Include="..\WinFormsLibrary\WinFormsLibraryAA.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
Loading…
Reference in New Issue
Block a user