Работает на Эговых компонентах

This commit is contained in:
maxnes3 2023-11-02 02:24:20 +04:00
parent 54da80ac79
commit 4fb672e0af
15 changed files with 1361 additions and 187 deletions

View File

@ -9,6 +9,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.13"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.13">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@ -1,39 +0,0 @@
namespace AppView
{
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.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace AppView
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

144
WinForm/AppView/FormMain.Designer.cs generated Normal file
View File

@ -0,0 +1,144 @@
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();
contextMenuStrip = new ContextMenuStrip(components);
addProviderItem = new ToolStripMenuItem();
editProviderItem = new ToolStripMenuItem();
removeProviderItem = new ToolStripMenuItem();
getSimpleDocumentItem = new ToolStripMenuItem();
getTableDocumentItem = new ToolStripMenuItem();
getDiagramDocumentItem = new ToolStripMenuItem();
открытьСправочникToolStripMenuItem = new ToolStripMenuItem();
controlDataTreeCell = new ControlsLibraryNet60.Data.ControlDataTreeCell();
componentDocumentWithTableMultiHeaderExcel = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderExcel(components);
componentDocumentWithChartPieWord = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieWord(components);
componentDocumentWithChartBarWord = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarWord(components);
pdfGeneratorControl = new PdfFormsLibrary.PdfGeneratorControl(components);
contextMenuStrip.SuspendLayout();
SuspendLayout();
//
// contextMenuStrip
//
contextMenuStrip.Items.AddRange(new ToolStripItem[] { addProviderItem, editProviderItem, removeProviderItem, getSimpleDocumentItem, getTableDocumentItem, getDiagramDocumentItem, открытьСправочникToolStripMenuItem });
contextMenuStrip.Name = "contextMenuStrip1";
contextMenuStrip.Size = new Size(265, 158);
contextMenuStrip.Text = "Меню";
//
// addProviderItem
//
addProviderItem.DisplayStyle = ToolStripItemDisplayStyle.Text;
addProviderItem.Name = "addProviderItem";
addProviderItem.Size = new Size(264, 22);
addProviderItem.Text = "Добавить";
addProviderItem.Click += AddProviderItem_Click;
//
// editProviderItem
//
editProviderItem.Name = "editProviderItem";
editProviderItem.Size = new Size(264, 22);
editProviderItem.Text = "Изменить";
editProviderItem.Click += EditProviderItem_Click;
//
// removeProviderItem
//
removeProviderItem.Name = "removeProviderItem";
removeProviderItem.Size = new Size(264, 22);
removeProviderItem.Text = "Удалить";
removeProviderItem.Click += RemoveProviderItem_Click;
//
// getSimpleDocumentItem
//
getSimpleDocumentItem.Name = "getSimpleDocumentItem";
getSimpleDocumentItem.Size = new Size(264, 22);
getSimpleDocumentItem.Text = "Получить простой документ";
getSimpleDocumentItem.Click += GetSimpleDocumentItem_Click;
//
// getTableDocumentItem
//
getTableDocumentItem.Name = "getTableDocumentItem";
getTableDocumentItem.Size = new Size(264, 22);
getTableDocumentItem.Text = "Получить документ с таблицей";
getTableDocumentItem.Click += GetTableDocumentItem_Click;
//
// getDiagramDocumentItem
//
getDiagramDocumentItem.Name = "getDiagramDocumentItem";
getDiagramDocumentItem.Size = new Size(264, 22);
getDiagramDocumentItem.Text = "Получить документ с диаграммой";
getDiagramDocumentItem.Click += GetDiagramDocumentItem_Click;
//
// открытьСправочникToolStripMenuItem
//
открытьСправочникToolStripMenuItem.Name = "открытьСправочникToolStripMenuItem";
открытьСправочникToolStripMenuItem.Size = new Size(264, 22);
открытьСправочникToolStripMenuItem.Text = "Открыть справочник";
открытьСправочникToolStripMenuItem.Click += OpenListToolStripMenuItem_Click;
//
// controlDataTreeCell
//
controlDataTreeCell.ContextMenuStrip = contextMenuStrip;
controlDataTreeCell.Location = new Point(0, 0);
controlDataTreeCell.Margin = new Padding(4, 3, 4, 3);
controlDataTreeCell.Name = "controlDataTreeCell";
controlDataTreeCell.Size = new Size(618, 450);
controlDataTreeCell.TabIndex = 1;
//
// FormMain
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(618, 450);
Controls.Add(controlDataTreeCell);
KeyPreview = true;
Name = "FormMain";
StartPosition = FormStartPosition.CenterScreen;
Text = "Основная форма";
Load += FormMain_Load;
contextMenuStrip.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private ContextMenuStrip contextMenuStrip;
private ToolStripMenuItem addProviderItem;
private ToolStripMenuItem editProviderItem;
private ToolStripMenuItem removeProviderItem;
private ToolStripMenuItem getSimpleDocumentItem;
private ToolStripMenuItem getTableDocumentItem;
private ToolStripMenuItem getDiagramDocumentItem;
private ControlsLibraryNet60.Data.ControlDataTreeCell controlDataTreeCell;
private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderExcel componentDocumentWithTableMultiHeaderExcel;
private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieWord componentDocumentWithChartPieWord;
private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarWord componentDocumentWithChartBarWord;
private ToolStripMenuItem открытьСправочникToolStripMenuItem;
private PdfFormsLibrary.PdfGeneratorControl pdfGeneratorControl;
}
}

349
WinForm/AppView/FormMain.cs Normal file
View File

@ -0,0 +1,349 @@
using ComponentsLibraryNet60.Core;
using ComponentsLibraryNet60.Models;
using Contracts.StoragesContracts;
using Contracts.ViewModels;
using ControlsLibraryNet60.Models;
using DataBaseImplement.Implements;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
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 System.Windows.Forms.VisualStyles;
using PdfFormsLibrary;
using PdfFormsLibrary.Helpers;
namespace AppView
{
public partial class FormMain : Form
{
private readonly IProviderStorage _providerStorage;
private readonly ITypeStorage _typeStorage;
public FormMain(
IProviderStorage providerStorage,
ITypeStorage typeStorage
)
{
_providerStorage = providerStorage;
_typeStorage = typeStorage;
InitializeComponent();
KeyDown += new KeyEventHandler(FormMain_KeyDown);
}
private void FormMain_Load(
object sender,
EventArgs e
)
{
LoadData();
}
private void LoadData()
{
try
{
var providers = _providerStorage.GetFullList();
if (providers != null)
{
controlDataTreeCell.Clear();
TreeColumnConfiguration();
if (providers.Count > 0) AddTreeData(providers);
}
}
catch (Exception ex)
{
MessageBox.Show(
ex.Message,
"Ошибка",
MessageBoxButtons.OK,
MessageBoxIcon.Error
);
}
}
private void TreeColumnConfiguration()
{
DataTreeNodeConfig treeConfig = new();
treeConfig.NodeNames = new();
treeConfig.NodeNames.Enqueue("Type");
treeConfig.NodeNames.Enqueue("SupplyDateTime");
treeConfig.NodeNames.Enqueue("Id");
treeConfig.NodeNames.Enqueue("Name");
controlDataTreeCell.LoadConfig(treeConfig);
}
private void AddTreeData(List<ProviderViewModel> providers)
{
int numOfProperties = typeof(ProviderViewModel).GetProperties().Length;
for (int i = 0; i < providers.Count; ++i)
{
providers[i].SupplyDateTime = providers[i].SupplyDate.ToString();
for (int j = 0; j < numOfProperties; ++j)
{
controlDataTreeCell.AddCell(j, providers[i]);
}
}
}
private void AddProviderItem_Click(
object sender,
EventArgs e
)
{
var service = Program.ServiceProvider?.GetService(typeof(FormProvider));
if (service is FormProvider form)
{
form.ShowDialog();
LoadData();
}
}
private void EditProviderItem_Click(object sender, EventArgs e)
{
if (controlDataTreeCell.GetSelectedObject<ProviderViewModel>() == null)
{
return;
}
else
{
var service = Program.ServiceProvider?.GetService(typeof(FormProvider));
if (service is FormProvider form)
{
form.Id = Convert.ToInt32(controlDataTreeCell.GetSelectedObject<ProviderViewModel>()?.Id);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void RemoveProviderItem_Click(object sender, EventArgs e)
{
if (controlDataTreeCell.GetSelectedObject<ProviderViewModel>() == null) return;
if (MessageBox.Show(
"Вы хотите удалить выбранный элементы?",
"Вопрос",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
_providerStorage.Delete(new(controlDataTreeCell.GetSelectedObject<ProviderViewModel>()));
LoadData();
}
}
private void GetSimpleDocumentItem_Click(object sender, EventArgs e)
{
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
SaveFileDialog saveFileDialog = new()
{
Filter = "PDF Files|*.pdf"
};
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
string filePath = saveFileDialog.FileName;
string documentTitle = "Поставщики";
List<string> textData = new();
foreach (var provider in _providerStorage.GetFullList())
{
textData.Add(provider.Name + ": " + provider.Furniture);
}
try
{
pdfGeneratorControl.GeneratePdf(filePath, documentTitle, textData);
MessageBox.Show("PDF-документ успешно сохранен.", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(
$"Ошибка при создании PDF-документа: {ex.Message}",
"Ошибка",
MessageBoxButtons.OK,
MessageBoxIcon.Error
);
}
}
}
private void GetTableDocumentItem_Click(object sender, EventArgs e)
{
List<ProviderViewModel> providersList = _providerStorage.GetFullList();
foreach (var provider in providersList)
{
if (provider.SupplyDate == null)
{
provider.SupplyDateTime = "Поставок не было";
provider.SupplyDate = DateTime.MinValue;
continue;
}
provider.SupplyDateTime = provider.SupplyDate.ToString();
}
ComponentDocumentWithTableHeaderDataConfig<ProviderViewModel> config = new()
{
Data = providersList,
Headers = new()
{
(0, 0, "Идентификатор", "Id"),
(1, 0, "Название", "Name"),
(2, 0, "Тип организации", "Type"),
(3, 0, "Дата поставки", "SupplyDateTime"),
},
Header = "Отчет по всем поставщикам",
UseUnion = false,
ColumnsRowsWidth = new()
{
(10,10),
(10,10),
(10,10),
(10,10),
},
ColumnsRowsDataCount = new()
};
SaveFileDialog saveFileDialog = new()
{
Filter = "Excel Files|*.xlsx"
};
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
config.FilePath = saveFileDialog.FileName;
try
{
componentDocumentWithTableMultiHeaderExcel.CreateDoc(config);
MessageBox.Show(
"Excel-документ успешно сохранен.",
"Успех",
MessageBoxButtons.OK,
MessageBoxIcon.Information
);
}
catch (Exception ex)
{
MessageBox.Show(
$"Ошибка при создании Excel-документа: {ex.Message}",
"Ошибка",
MessageBoxButtons.OK,
MessageBoxIcon.Error
);
}
}
}
private void GetDiagramDocumentItem_Click(object sender, EventArgs e)
{
var providersList = _providerStorage
.GetFullList()
.Where(item => item.SupplyDate?.Year == DateTime.Now.Year)
.GroupBy(item => item.Type)
.Select(group => new
{
Type = group.Key,
Date = group.Select(item => item.SupplyDate),
Count = (double)group.Count(),
});
var resultData = new List<(int, double)>();
foreach (var provider in providersList)
{
resultData.Add((DateTime.Now.Year, provider.Count));
}
ComponentDocumentWithChartConfig config = new()
{
ChartTitle = "Количество поставщиков в разрезе типа организации",
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
Header = "Круговая диаграмма",
Data = new()
{
{ "Тип организации", resultData },
},
};
SaveFileDialog saveFileDialog = new()
{
Filter = "Word Files|*.docx"
};
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
config.FilePath = saveFileDialog.FileName;
try
{
componentDocumentWithChartPieWord.CreateDoc(config);
MessageBox.Show(
"Word-документ успешно сохранен.",
"Успех",
MessageBoxButtons.OK,
MessageBoxIcon.Information
);
}
catch (Exception ex)
{
MessageBox.Show(
$"Ошибка при создании Word-документа: {ex.Message}",
"Ошибка",
MessageBoxButtons.OK,
MessageBoxIcon.Error
);
}
}
}
private void FormMain_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control)
{
switch (e.KeyCode)
{
case Keys.A:
AddProviderItem_Click(sender, e);
break;
case Keys.U:
EditProviderItem_Click(sender, e);
break;
case Keys.D:
RemoveProviderItem_Click(sender, e);
break;
case Keys.S:
GetSimpleDocumentItem_Click(sender, e);
break;
case Keys.T:
GetTableDocumentItem_Click(sender, e);
break;
case Keys.C:
GetDiagramDocumentItem_Click(sender, e);
break;
case Keys.M:
OpenListToolStripMenuItem_Click(sender, e);
break;
}
}
}
private void OpenListToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormType));
if (service is FormType form)
{
form.ShowDialog();
LoadData();
}
}
}
}

View 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="contextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="componentDocumentWithTableMultiHeaderExcel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>328, 17</value>
</metadata>
<metadata name="componentDocumentWithChartPieWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>923, 17</value>
</metadata>
<metadata name="componentDocumentWithChartBarWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 54</value>
</metadata>
<metadata name="pdfGeneratorControl.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>291, 54</value>
</metadata>
</root>

279
WinForm/AppView/FormProvider.Designer.cs generated Normal file
View File

@ -0,0 +1,279 @@
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()
{
labelProviderName = new Label();
textBoxName = new TextBox();
panelName = new Panel();
panelFurniture = new Panel();
textBoxFurniture = new TextBox();
labelFurniture = new Label();
panelType = new Panel();
buttonType = new Button();
dropDownList = new WinForm.DropDownList();
labelType = new Label();
panelDate = new Panel();
controlInputNullableDate = new ControlsLibraryNet60.Input.ControlInputNullableDate();
labelDate = new Label();
buttonSave = new Button();
panelButtons = new Panel();
buttonCancel = new Button();
panelName.SuspendLayout();
panelFurniture.SuspendLayout();
panelType.SuspendLayout();
panelDate.SuspendLayout();
panelButtons.SuspendLayout();
SuspendLayout();
//
// labelProviderName
//
labelProviderName.AutoSize = true;
labelProviderName.Dock = DockStyle.Top;
labelProviderName.Location = new Point(10, 10);
labelProviderName.Name = "labelProviderName";
labelProviderName.Size = new Size(59, 15);
labelProviderName.TabIndex = 0;
labelProviderName.Text = "Название";
//
// textBoxName
//
textBoxName.Dock = DockStyle.Top;
textBoxName.Location = new Point(10, 25);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(340, 23);
textBoxName.TabIndex = 1;
textBoxName.TextChanged += OnInputChange;
//
// panelName
//
panelName.AutoSize = true;
panelName.Controls.Add(textBoxName);
panelName.Controls.Add(labelProviderName);
panelName.Dock = DockStyle.Top;
panelName.Location = new Point(0, 0);
panelName.Margin = new Padding(0);
panelName.Name = "panelName";
panelName.Padding = new Padding(10);
panelName.Size = new Size(360, 58);
panelName.TabIndex = 2;
//
// panelFurniture
//
panelFurniture.AutoSize = true;
panelFurniture.Controls.Add(textBoxFurniture);
panelFurniture.Controls.Add(labelFurniture);
panelFurniture.Dock = DockStyle.Top;
panelFurniture.Location = new Point(0, 58);
panelFurniture.Margin = new Padding(0);
panelFurniture.Name = "panelFurniture";
panelFurniture.Padding = new Padding(10);
panelFurniture.Size = new Size(360, 58);
panelFurniture.TabIndex = 3;
//
// textBoxFurniture
//
textBoxFurniture.Dock = DockStyle.Top;
textBoxFurniture.Location = new Point(10, 25);
textBoxFurniture.Name = "textBoxFurniture";
textBoxFurniture.Size = new Size(340, 23);
textBoxFurniture.TabIndex = 1;
textBoxFurniture.TextChanged += OnInputChange;
//
// labelFurniture
//
labelFurniture.AutoSize = true;
labelFurniture.Dock = DockStyle.Top;
labelFurniture.Location = new Point(10, 10);
labelFurniture.Name = "labelFurniture";
labelFurniture.Size = new Size(50, 15);
labelFurniture.TabIndex = 0;
labelFurniture.Text = "Мебель";
//
// panelType
//
panelType.AutoSize = true;
panelType.Controls.Add(buttonType);
panelType.Controls.Add(dropDownList);
panelType.Controls.Add(labelType);
panelType.Dock = DockStyle.Top;
panelType.Location = new Point(0, 116);
panelType.Margin = new Padding(0);
panelType.Name = "panelType";
panelType.Padding = new Padding(10);
panelType.Size = new Size(360, 100);
panelType.TabIndex = 4;
//
// buttonType
//
buttonType.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
buttonType.Location = new Point(115, 64);
buttonType.Name = "buttonType";
buttonType.Size = new Size(127, 23);
buttonType.TabIndex = 2;
buttonType.Text = "Редактировать типы";
buttonType.UseVisualStyleBackColor = true;
buttonType.Click += ButtonTypeForm_Click;
//
// dropDownList
//
dropDownList.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dropDownList.Location = new Point(10, 28);
dropDownList.Name = "dropDownList";
dropDownList.Selected = "";
dropDownList.Size = new Size(340, 30);
dropDownList.TabIndex = 1;
//
// labelType
//
labelType.AutoSize = true;
labelType.Dock = DockStyle.Top;
labelType.Location = new Point(10, 10);
labelType.Name = "labelType";
labelType.Size = new Size(101, 15);
labelType.TabIndex = 0;
labelType.Text = "Тип организации";
//
// panelDate
//
panelDate.AutoSize = true;
panelDate.Controls.Add(controlInputNullableDate);
panelDate.Controls.Add(labelDate);
panelDate.Dock = DockStyle.Top;
panelDate.Location = new Point(0, 216);
panelDate.Margin = new Padding(0);
panelDate.Name = "panelDate";
panelDate.Padding = new Padding(10);
panelDate.Size = new Size(360, 58);
panelDate.TabIndex = 6;
//
// controlInputNullableDate
//
controlInputNullableDate.Dock = DockStyle.Top;
controlInputNullableDate.Location = new Point(10, 25);
controlInputNullableDate.Margin = new Padding(4, 3, 4, 3);
controlInputNullableDate.Name = "controlInputNullableDate";
controlInputNullableDate.Size = new Size(340, 23);
controlInputNullableDate.TabIndex = 1;
controlInputNullableDate.Value = null;
//
// labelDate
//
labelDate.AutoSize = true;
labelDate.Dock = DockStyle.Top;
labelDate.Location = new Point(10, 10);
labelDate.Name = "labelDate";
labelDate.Size = new Size(85, 15);
labelDate.TabIndex = 0;
labelDate.Text = "Дата поставки";
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonSave.Location = new Point(10, 7);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 7;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// panelButtons
//
panelButtons.AutoSize = true;
panelButtons.Controls.Add(buttonCancel);
panelButtons.Controls.Add(buttonSave);
panelButtons.Dock = DockStyle.Top;
panelButtons.Location = new Point(0, 274);
panelButtons.Margin = new Padding(0);
panelButtons.Name = "panelButtons";
panelButtons.Padding = new Padding(10);
panelButtons.Size = new Size(360, 64);
panelButtons.TabIndex = 8;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Location = new Point(275, 7);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 8;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormProvider
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(360, 311);
Controls.Add(panelButtons);
Controls.Add(panelDate);
Controls.Add(panelType);
Controls.Add(panelFurniture);
Controls.Add(panelName);
MaximumSize = new Size(900, 350);
MinimumSize = new Size(200, 350);
Name = "FormProvider";
StartPosition = FormStartPosition.CenterScreen;
Text = "Редактирование";
FormClosing += FormProvider_FormClosing;
Load += FormProvider_Load;
panelName.ResumeLayout(false);
panelName.PerformLayout();
panelFurniture.ResumeLayout(false);
panelFurniture.PerformLayout();
panelType.ResumeLayout(false);
panelType.PerformLayout();
panelDate.ResumeLayout(false);
panelDate.PerformLayout();
panelButtons.ResumeLayout(false);
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelProviderName;
private TextBox textBoxName;
private Panel panelName;
private Panel panelFurniture;
private TextBox textBoxFurniture;
private Label labelFurniture;
private Panel panelType;
private Label labelType;
private Panel panelDate;
private ControlsLibraryNet60.Input.ControlInputNullableDate controlInputNullableDate;
private Label labelDate;
private Button buttonSave;
private Panel panelButtons;
private Button buttonCancel;
private Button buttonType;
private WinForm.DropDownList dropDownList;
}
}

View File

@ -0,0 +1,159 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.StoragesContracts;
using Contracts.ViewModels;
using DocumentFormat.OpenXml.VariantTypes;
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;
public FormProvider(IProviderStorage providerStorage, ITypeStorage typeStorage)
{
_providerStorage = providerStorage;
_typeStorage = typeStorage;
isEdited = false;
InitializeComponent();
}
private void FormProvider_Load(object sender, EventArgs e)
{
controlInputNullableDate.ElementChanged += OnInputChange;
dropDownList.ExplicitEvent += OnInputChange;
LoadData();
if (_id.HasValue)
{
try
{
var element = _providerStorage.GetElement(new ProviderSearchModel
{
Id = _id.Value,
});
if (element != null)
{
textBoxName.Text = element.Name;
textBoxFurniture.Text = element.Furniture;
dropDownList.Selected = element.Type;
controlInputNullableDate.Value = element.SupplyDate;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении записи", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void LoadData()
{
try
{
var strings = _typeStorage.GetFullList().Select(item => item.Name).ToList();
dropDownList.Clear();
foreach (var item in strings)
{
dropDownList.ComboBoxItems.Add(item);
}
if (_id.HasValue)
{
var view = _providerStorage.GetElement(new ProviderSearchModel
{
Id = _id!.Value
});
dropDownList.Selected = view!.Type;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка загрузки формы", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void OnInputChange(object sender, EventArgs e)
{
isEdited = true;
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Название не указано");
return;
}
if (string.IsNullOrEmpty(textBoxFurniture.Text))
{
MessageBox.Show("Перечень мебели не указан");
return;
}
if (string.IsNullOrEmpty(dropDownList.Selected))
{
MessageBox.Show("Тип предприятия не выбран");
return;
}
isEdited = false;
try
{
var model = new ProviderBindingModel
{
Id = _id ?? 0,
Name = textBoxName.Text,
Furniture = textBoxFurniture.Text,
Type = dropDownList.Selected,
SupplyDate = (controlInputNullableDate.Value != null) ?
DateTime.SpecifyKind((DateTime)controlInputNullableDate.Value, DateTimeKind.Utc)
: controlInputNullableDate.Value,
};
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 ButtonTypeForm_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;
}
}
}

View 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>

65
WinForm/AppView/FormType.Designer.cs generated Normal file
View 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()
{
dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(355, 306);
dataGridView.TabIndex = 0;
dataGridView.CellValueChanged += DataGridView_CellValueChanged;
dataGridView.KeyDown += DataGridView_KeyDown;
//
// FormType
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(355, 306);
Controls.Add(dataGridView);
Name = "FormType";
Text = "Редактирование типов организаций";
Load += FormType_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
}
}

145
WinForm/AppView/FormType.cs Normal file
View File

@ -0,0 +1,145 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.StoragesContracts;
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 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();
}
}
}
}
}

View 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>

View File

@ -1,7 +1,13 @@
using Contracts.StoragesContracts;
using DataBaseImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
namespace AppView namespace AppView
{ {
internal static class Program internal static class Program
{ {
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
@ -11,7 +17,19 @@ namespace AppView
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new Form1()); 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>();
} }
} }
} }

View File

@ -29,43 +29,30 @@
private void InitializeComponent() private void InitializeComponent()
{ {
comboBox = new ComboBox(); comboBox = new ComboBox();
labelTitle = new Label();
SuspendLayout(); SuspendLayout();
// //
// comboBox // comboBox
// //
comboBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
comboBox.FormattingEnabled = true; comboBox.FormattingEnabled = true;
comboBox.Location = new Point(13, 39); comboBox.Location = new Point(3, 3);
comboBox.Name = "comboBox"; comboBox.Name = "comboBox";
comboBox.Size = new Size(232, 23); comboBox.Size = new Size(244, 23);
comboBox.TabIndex = 0; comboBox.TabIndex = 0;
comboBox.SelectedValueChanged += ComboBox_SelectedValueChanged; comboBox.SelectedValueChanged += ComboBox_SelectedValueChanged;
// //
// labelTitle
//
labelTitle.AutoSize = true;
labelTitle.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelTitle.Location = new Point(13, 11);
labelTitle.Name = "labelTitle";
labelTitle.Size = new Size(133, 15);
labelTitle.TabIndex = 1;
labelTitle.Text = "Выпадающий список";
//
// DropDownList // DropDownList
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
Controls.Add(labelTitle);
Controls.Add(comboBox); Controls.Add(comboBox);
Name = "DropDownList"; Name = "DropDownList";
Size = new Size(260, 80); Size = new Size(250, 30);
ResumeLayout(false); ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion
private ComboBox comboBox; private ComboBox comboBox;
private Label labelTitle;
} }
} }