Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
bbc6991994 | ||
290b40fe1c | |||
34d262287b | |||
0261fdc093 | |||
|
280fcbba32 | ||
3704947e84 | |||
9de3a512ef | |||
c65bcbb792 | |||
462e8f8bb4 | |||
|
c3424531c1 | ||
c7b0db4fa3 | |||
a17f19981a | |||
bc128a354f | |||
4c0882df61 | |||
4a5e7f9c0d | |||
2bfe317437 | |||
c90b181d85 | |||
5b17be9211 | |||
82f6fc6e49 | |||
c5f307ec81 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -398,3 +398,4 @@ FodyWeavers.xsd
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
|
||||
*.dll
|
36
WinFormsProject/AppView/AppView.csproj
Normal file
36
WinFormsProject/AppView/AppView.csproj
Normal file
@ -0,0 +1,36 @@
|
||||
<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="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||
<ProjectReference Include="..\WinFormsLibrary\WinFormsLibraryAA.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="CreatePluginsFolder" BeforeTargets="PreBuildEvent" Condition="!Exists('$(SolutionDir)Plugins')">
|
||||
<MakeDir Directories="$(SolutionDir)Plugins" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CopyPlugins" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)Plugins\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</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);
|
||||
}
|
||||
}
|
||||
}
|
135
WinFormsProject/AppView/FormMain.resx
Normal file
135
WinFormsProject/AppView/FormMain.resx
Normal file
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<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>
|
246
WinFormsProject/AppView/PluginsConvention.cs
Normal file
246
WinFormsProject/AppView/PluginsConvention.cs
Normal file
@ -0,0 +1,246 @@
|
||||
using Contracts.StorageContracts;
|
||||
using Contracts.ViewModels;
|
||||
using ControlsLibraryNet60.Data;
|
||||
using ControlsLibraryNet60.Models;
|
||||
using DateBaseImplement.Implements;
|
||||
using PdfFormsLibrary;
|
||||
using PluginsConventionLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using WinFormsLibrary;
|
||||
using WinFormsLibrary.not_visual;
|
||||
using WinFormsLibrary.SupportClasses;
|
||||
|
||||
namespace AppView
|
||||
{
|
||||
public class PluginsConvention : IPluginsConvention
|
||||
{
|
||||
private readonly IProviderStorage _providerStorage;
|
||||
private readonly ITypeStorage _typeStorage;
|
||||
private readonly DocumentWithImage documentWithImage1;
|
||||
private readonly Table2column table2column1;
|
||||
private readonly Gistograma gistograma1;
|
||||
private readonly ControlDataTableTable DataTable = new ControlDataTableTable();
|
||||
|
||||
public string PluginName { get; set; } = "LabWork_03_plugin";
|
||||
|
||||
public UserControl GetControl
|
||||
{
|
||||
get
|
||||
{
|
||||
ReloadData();
|
||||
return DataTable;
|
||||
}
|
||||
}
|
||||
|
||||
public PluginsConventionElement GetElement
|
||||
{
|
||||
get
|
||||
{
|
||||
var provider = DataTable.GetSelectedObject<ProviderViewModel>();
|
||||
int id = -1;
|
||||
if (provider != null)
|
||||
{
|
||||
id = Convert.ToInt32(provider.Id);
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[16];
|
||||
|
||||
BitConverter.GetBytes(id).CopyTo(bytes, 0);
|
||||
|
||||
return new()
|
||||
{
|
||||
Id = new Guid(bytes)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public PluginsConvention()
|
||||
{
|
||||
_providerStorage = new ProviderStorage();
|
||||
_typeStorage = new TypeStorage();
|
||||
documentWithImage1 = new();
|
||||
table2column1 = new();
|
||||
gistograma1 = new();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public Form GetForm(PluginsConventionElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return new FormProvider(_providerStorage, _typeStorage);
|
||||
}
|
||||
else
|
||||
{
|
||||
FormProvider form = new FormProvider(_providerStorage, _typeStorage);
|
||||
form.Id = element.Id.GetHashCode();
|
||||
return form;
|
||||
}
|
||||
}
|
||||
|
||||
public Form GetThesaurus()
|
||||
{
|
||||
return new FormType(_typeStorage);
|
||||
}
|
||||
|
||||
public bool DeleteElement(PluginsConventionElement element)
|
||||
{
|
||||
_providerStorage.Delete(
|
||||
new(element.Id.GetHashCode())
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ReloadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _providerStorage.GetFullList();
|
||||
DataTable.Clear();
|
||||
DataTable.AddTable(list);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
ex.Message,
|
||||
"Ошибка",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CreateWordDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
try
|
||||
{
|
||||
ImageClass info = new ImageClass();
|
||||
|
||||
var images = _providerStorage.GetFullList().Select(x => x.Logo).ToList();
|
||||
|
||||
info.Title = "Images";
|
||||
info.Path = saveDocument.FileName;
|
||||
info.Files = images;
|
||||
|
||||
documentWithImage1.CreateDocument(info);
|
||||
MessageBox.Show("Готово");
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MessageBox.Show(e.Message, "Ошибка");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
|
||||
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(saveDocument.FileName, "Table", columnDefinitionsUp, columnDefinitionsDown, providers, mergedColums);
|
||||
|
||||
table2column1.CreateTable(info);
|
||||
MessageBox.Show("Готово");
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MessageBox.Show(e.Message, "Ошибка");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
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(saveDocument.FileName, "Сводка по типам изделия.", "Количество поставщиков для товаров каждого типа", WinFormsLibrary.not_visual.LegendPosition.Bottom, data);
|
||||
MessageBox.Show("Готово");
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MessageBox.Show(e.Message, "Ошибка");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
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,31 @@
|
||||
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;
|
||||
}
|
||||
|
||||
public ProviderBindingModel(int id)
|
||||
{
|
||||
Id = 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");
|
||||
}
|
||||
}
|
||||
}
|
@ -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,
|
||||
};
|
||||
}
|
||||
}
|
BIN
WinFormsProject/Plugins/AppView.dll
Normal file
BIN
WinFormsProject/Plugins/AppView.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/Aspose.Words.Pdf2Word.dll
Normal file
BIN
WinFormsProject/Plugins/Aspose.Words.Pdf2Word.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/Aspose.Words.dll
Normal file
BIN
WinFormsProject/Plugins/Aspose.Words.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/BouncyCastle.Cryptography.dll
Normal file
BIN
WinFormsProject/Plugins/BouncyCastle.Cryptography.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/ComponentsLibraryNet60.dll
Normal file
BIN
WinFormsProject/Plugins/ComponentsLibraryNet60.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/Contracts.dll
Normal file
BIN
WinFormsProject/Plugins/Contracts.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/ControlsLibraryNet60.dll
Normal file
BIN
WinFormsProject/Plugins/ControlsLibraryNet60.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/DataModels.dll
Normal file
BIN
WinFormsProject/Plugins/DataModels.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/DateBaseImplement.dll
Normal file
BIN
WinFormsProject/Plugins/DateBaseImplement.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/DocumentFormat.OpenXml.dll
Normal file
BIN
WinFormsProject/Plugins/DocumentFormat.OpenXml.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/EPPlus.Interfaces.dll
Normal file
BIN
WinFormsProject/Plugins/EPPlus.Interfaces.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/EPPlus.System.Drawing.dll
Normal file
BIN
WinFormsProject/Plugins/EPPlus.System.Drawing.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/EPPlus.dll
Normal file
BIN
WinFormsProject/Plugins/EPPlus.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/Enums.NET.dll
Normal file
BIN
WinFormsProject/Plugins/Enums.NET.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/ExcelFormsLibrary.dll
Normal file
BIN
WinFormsProject/Plugins/ExcelFormsLibrary.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/Humanizer.dll
Normal file
BIN
WinFormsProject/Plugins/Humanizer.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/ICSharpCode.SharpZipLib.dll
Normal file
BIN
WinFormsProject/Plugins/ICSharpCode.SharpZipLib.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/MathNet.Numerics.dll
Normal file
BIN
WinFormsProject/Plugins/MathNet.Numerics.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
WinFormsProject/Plugins/Microsoft.EntityFrameworkCore.Design.dll
Normal file
BIN
WinFormsProject/Plugins/Microsoft.EntityFrameworkCore.Design.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
WinFormsProject/Plugins/Microsoft.EntityFrameworkCore.dll
Normal file
BIN
WinFormsProject/Plugins/Microsoft.EntityFrameworkCore.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
WinFormsProject/Plugins/Microsoft.Extensions.Caching.Memory.dll
Normal file
BIN
WinFormsProject/Plugins/Microsoft.Extensions.Caching.Memory.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
WinFormsProject/Plugins/Microsoft.Extensions.Configuration.dll
Normal file
BIN
WinFormsProject/Plugins/Microsoft.Extensions.Configuration.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
WinFormsProject/Plugins/Microsoft.Extensions.DependencyModel.dll
Normal file
BIN
WinFormsProject/Plugins/Microsoft.Extensions.DependencyModel.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
WinFormsProject/Plugins/Microsoft.Extensions.Logging.dll
Normal file
BIN
WinFormsProject/Plugins/Microsoft.Extensions.Logging.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/Microsoft.Extensions.Options.dll
Normal file
BIN
WinFormsProject/Plugins/Microsoft.Extensions.Options.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/Microsoft.Extensions.Primitives.dll
Normal file
BIN
WinFormsProject/Plugins/Microsoft.Extensions.Primitives.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/Microsoft.IO.RecyclableMemoryStream.dll
Normal file
BIN
WinFormsProject/Plugins/Microsoft.IO.RecyclableMemoryStream.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/MigraDoc.DocumentObjectModel.dll
Normal file
BIN
WinFormsProject/Plugins/MigraDoc.DocumentObjectModel.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/MigraDoc.Rendering.dll
Normal file
BIN
WinFormsProject/Plugins/MigraDoc.Rendering.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/Mono.TextTemplating.dll
Normal file
BIN
WinFormsProject/Plugins/Mono.TextTemplating.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/NPOI.Core.dll
Normal file
BIN
WinFormsProject/Plugins/NPOI.Core.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/NPOI.OOXML.dll
Normal file
BIN
WinFormsProject/Plugins/NPOI.OOXML.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/NPOI.OpenXml4Net.dll
Normal file
BIN
WinFormsProject/Plugins/NPOI.OpenXml4Net.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/NPOI.OpenXmlFormats.dll
Normal file
BIN
WinFormsProject/Plugins/NPOI.OpenXmlFormats.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
WinFormsProject/Plugins/Npgsql.dll
Normal file
BIN
WinFormsProject/Plugins/Npgsql.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/OxyPlot.WindowsForms.dll
Normal file
BIN
WinFormsProject/Plugins/OxyPlot.WindowsForms.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/OxyPlot.dll
Normal file
BIN
WinFormsProject/Plugins/OxyPlot.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/PdfFormsLibrary.dll
Normal file
BIN
WinFormsProject/Plugins/PdfFormsLibrary.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/PdfSharp.Charting.dll
Normal file
BIN
WinFormsProject/Plugins/PdfSharp.Charting.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/PdfSharp.dll
Normal file
BIN
WinFormsProject/Plugins/PdfSharp.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/PluginsConventionLibrary.dll
Normal file
BIN
WinFormsProject/Plugins/PluginsConventionLibrary.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/SixLabors.Fonts.dll
Normal file
BIN
WinFormsProject/Plugins/SixLabors.Fonts.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/SixLabors.ImageSharp.dll
Normal file
BIN
WinFormsProject/Plugins/SixLabors.ImageSharp.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/SkiaSharp.dll
Normal file
BIN
WinFormsProject/Plugins/SkiaSharp.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/System.Security.Cryptography.Pkcs.dll
Normal file
BIN
WinFormsProject/Plugins/System.Security.Cryptography.Pkcs.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/System.Security.Cryptography.Xml.dll
Normal file
BIN
WinFormsProject/Plugins/System.Security.Cryptography.Xml.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/System.Text.Encodings.Web.dll
Normal file
BIN
WinFormsProject/Plugins/System.Text.Encodings.Web.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/System.Text.Json.dll
Normal file
BIN
WinFormsProject/Plugins/System.Text.Json.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/WinFormsLibraryAA.dll
Normal file
BIN
WinFormsProject/Plugins/WinFormsLibraryAA.dll
Normal file
Binary file not shown.
BIN
WinFormsProject/Plugins/libs.XSSFWookbook.dll
Normal file
BIN
WinFormsProject/Plugins/libs.XSSFWookbook.dll
Normal file
Binary file not shown.
@ -0,0 +1,23 @@
|
||||
using ControlsLibraryNet60.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary
|
||||
{
|
||||
public interface IPluginsConvention
|
||||
{
|
||||
string PluginName { get; }
|
||||
UserControl GetControl { get; }
|
||||
PluginsConventionElement GetElement { get; }
|
||||
Form GetForm(PluginsConventionElement element);
|
||||
Form GetThesaurus();
|
||||
bool DeleteElement(PluginsConventionElement element);
|
||||
void ReloadData();
|
||||
bool CreateWordDocument(PluginsConventionSaveDocument saveDocument);
|
||||
bool CreateTableDocument(PluginsConventionSaveDocument saveDocument);
|
||||
bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginsConventionLibrary
|
||||
{
|
||||
public class PluginsConventionElement
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user