Compare commits
No commits in common. "LabWork_03" and "main" have entirely different histories.
LabWork_03
...
main
@ -1,28 +0,0 @@
|
||||
<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.13">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="WinFormsLibrary" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Contracts\Contracts.csproj" />
|
||||
<ProjectReference Include="..\DataBaseImplement\DataBaseImplement.csproj" />
|
||||
<ProjectReference Include="..\PdfFormsLibrary\PdfFormsLibrary.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
149
WinForm/AppView/FormMain.Designer.cs
generated
149
WinForm/AppView/FormMain.Designer.cs
generated
@ -1,149 +0,0 @@
|
||||
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);
|
||||
circleDiagram = new WinFormsLibrary.CircleDiagram(components);
|
||||
componentWithSettings = new WinFormsLibrary.not_visual.ComponentWithSettings(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.Dock = DockStyle.Fill;
|
||||
controlDataTreeCell.Location = new Point(0, 0);
|
||||
controlDataTreeCell.Margin = new Padding(4, 3, 4, 3);
|
||||
controlDataTreeCell.Name = "controlDataTreeCell";
|
||||
controlDataTreeCell.Size = new Size(820, 450);
|
||||
controlDataTreeCell.TabIndex = 1;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(820, 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;
|
||||
private WinFormsLibrary.CircleDiagram circleDiagram;
|
||||
private WinFormsLibrary.not_visual.ComponentWithSettings componentWithSettings;
|
||||
}
|
||||
}
|
@ -1,327 +0,0 @@
|
||||
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;
|
||||
using WinFormsLibrary.SupportClasses;
|
||||
using WinFormsLibrary.SupportClasses.Enums;
|
||||
using DataBaseImplement.Models;
|
||||
using WinFormsLibrary.not_visual;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
var columnConfigs = new List<ColumnConfig>
|
||||
{
|
||||
new ColumnConfig { Width = 50f, PropertyName = "Id" },
|
||||
new ColumnConfig { Width = 50f, PropertyName = "Name" },
|
||||
new ColumnConfig { Width = 50f, PropertyName = "Type" },
|
||||
new ColumnConfig { Width = 70f, PropertyName = "SupplyDateTime" },
|
||||
};
|
||||
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "Excel Files|*.xlsx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
componentWithSettings.GenerateExcelDocument(saveFileDialog.FileName, "Отчет по всем поставщикам", columnConfigs, 25f, 35f, providersList);
|
||||
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(),
|
||||
});
|
||||
|
||||
List<double> results = new();
|
||||
List<string> names = new();
|
||||
|
||||
foreach (var provider in providersList)
|
||||
{
|
||||
results.Add(provider.Count);
|
||||
names.Add(provider.Type);
|
||||
}
|
||||
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "Word Files|*.docx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
SimpleCircleDiagram simpleCircleDiagram = new(saveFileDialog.FileName, "Круговая диаграмма", "Количество поставщиков в разрезе типа организации",
|
||||
EnumAreaLegend.Right, new() { new DataCircleDiagram("Типы организации", results.ToArray()) });
|
||||
simpleCircleDiagram.NameData = names.ToArray();
|
||||
try
|
||||
{
|
||||
//componentDocumentWithChartPieWord.CreateDoc(config);
|
||||
circleDiagram.AddCircleDiagram(simpleCircleDiagram);
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
<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>
|
||||
<metadata name="circleDiagram.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>456, 54</value>
|
||||
</metadata>
|
||||
<metadata name="componentWithSettings.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>582, 54</value>
|
||||
</metadata>
|
||||
</root>
|
278
WinForm/AppView/FormProvider.Designer.cs
generated
278
WinForm/AppView/FormProvider.Designer.cs
generated
@ -1,278 +0,0 @@
|
||||
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();
|
||||
customTextBox1 = new WinFormsLibrary.CustomTextBox();
|
||||
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.Right;
|
||||
buttonType.Location = new Point(220, 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(customTextBox1);
|
||||
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, 57);
|
||||
panelDate.TabIndex = 6;
|
||||
//
|
||||
// customTextBox1
|
||||
//
|
||||
customTextBox1.DateValue = null;
|
||||
customTextBox1.Location = new Point(112, 13);
|
||||
customTextBox1.Name = "customTextBox1";
|
||||
customTextBox1.Size = new Size(235, 31);
|
||||
customTextBox1.TabIndex = 1;
|
||||
//
|
||||
// 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.Right;
|
||||
buttonSave.Location = new Point(194, 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, 273);
|
||||
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, 358);
|
||||
Controls.Add(panelButtons);
|
||||
Controls.Add(panelDate);
|
||||
Controls.Add(panelType);
|
||||
Controls.Add(panelFurniture);
|
||||
Controls.Add(panelName);
|
||||
MaximumSize = new Size(900, 500);
|
||||
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 Label labelDate;
|
||||
private Button buttonSave;
|
||||
private Panel panelButtons;
|
||||
private Button buttonCancel;
|
||||
private Button buttonType;
|
||||
private WinForm.DropDownList dropDownList;
|
||||
private WinFormsLibrary.CustomTextBox customTextBox;
|
||||
private WinFormsLibrary.CustomTextBox customTextBox1;
|
||||
}
|
||||
}
|
@ -1,158 +0,0 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StoragesContracts;
|
||||
using Contracts.ViewModels;
|
||||
|
||||
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)
|
||||
{
|
||||
customTextBox1.ValueChanged += 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;
|
||||
customTextBox1.DateValue = 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 = (customTextBox1.DateValue != null) ?
|
||||
DateTime.SpecifyKind((DateTime)customTextBox1.DateValue, DateTimeKind.Utc)
|
||||
: customTextBox1.DateValue,
|
||||
};
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
66
WinForm/AppView/FormType.Designer.cs
generated
66
WinForm/AppView/FormType.Designer.cs
generated
@ -1,66 +0,0 @@
|
||||
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";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Редактирование типов организаций";
|
||||
Load += FormType_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
@ -1,145 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,35 +0,0 @@
|
||||
using Contracts.StoragesContracts;
|
||||
using DataBaseImplement.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>();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
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 string Furniture { get; set; }
|
||||
public DateTime? SupplyDate { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
|
||||
public ProviderBindingModel() { }
|
||||
|
||||
public ProviderBindingModel(IProviderModel provider)
|
||||
{
|
||||
Id = provider.Id;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<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>
|
@ -1,13 +0,0 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
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.StoragesContracts
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
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.StoragesContracts
|
||||
{
|
||||
public interface ITypeStorage
|
||||
{
|
||||
List<TypeViewModel> GetFullList();
|
||||
TypeViewModel? GetElement(TypeSearchModel model);
|
||||
TypeViewModel? Insert(TypeBindingModel model);
|
||||
TypeViewModel? Update(TypeBindingModel model);
|
||||
TypeViewModel? Delete(TypeBindingModel model);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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 string Furniture { get; set; }
|
||||
public DateTime? SupplyDate { get; set; }
|
||||
public string? SupplyDateTime { get; set; }
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
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; }
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using DataBaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace DataBaseImplement
|
||||
{
|
||||
public class DBContext:DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if(!optionsBuilder.IsConfigured)
|
||||
optionsBuilder.UseNpgsql(@"Host=localhost;Port=5432;Database=COP;Username=courseuser;Password=courseuser");
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
||||
public virtual DbSet<Provider> Providers { get; set; }
|
||||
public virtual DbSet<Models.Type> Types { get; set; }
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.13" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.13">
|
||||
<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>
|
@ -1,89 +0,0 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StoragesContracts;
|
||||
using Contracts.ViewModels;
|
||||
using DataBaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataBaseImplement.Implements
|
||||
{
|
||||
public class ProviderStorage : IProviderStorage
|
||||
{
|
||||
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> 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();
|
||||
}
|
||||
|
||||
public List<ProviderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new DBContext();
|
||||
return context.Providers
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
using Contracts.StoragesContracts;
|
||||
using Contracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataBaseImplement.Implements
|
||||
{
|
||||
public class TypeStorage : ITypeStorage
|
||||
{
|
||||
public TypeViewModel? Delete(TypeBindingModel model)
|
||||
{
|
||||
using var context = new DBContext();
|
||||
var element = context.Types.FirstOrDefault(x => x.Id == x.Id);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.Types.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.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();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using DataBaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(DBContext))]
|
||||
[Migration("20231101203036_InitMig")]
|
||||
partial class InitMig
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.13")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("DataBaseImplement.Models.Provider", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Furniture")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime?>("SupplyDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Providers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DataBaseImplement.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
|
||||
}
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DataBaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitMig : 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),
|
||||
Type = table.Column<string>(type: "text", nullable: false),
|
||||
Furniture = table.Column<string>(type: "text", nullable: false),
|
||||
SupplyDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
||||
},
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using DataBaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(DBContext))]
|
||||
partial class DBContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.13")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("DataBaseImplement.Models.Provider", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Furniture")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime?>("SupplyDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Providers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DataBaseImplement.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
|
||||
}
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
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 DataBaseImplement.Models
|
||||
{
|
||||
public class Provider : IProviderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
public string Type { get; set; }
|
||||
[Required]
|
||||
public string Furniture { get; set; }
|
||||
public DateTime? SupplyDate { get; set; } = DateTime.MinValue;
|
||||
|
||||
public static Provider? Create(ProviderBindingModel model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
return new Provider()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Type = model.Type,
|
||||
Furniture = model.Furniture,
|
||||
SupplyDate = model.SupplyDate,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ProviderBindingModel model)
|
||||
{
|
||||
if (model == null) return;
|
||||
Name = model.Name;
|
||||
Type = model.Type;
|
||||
Furniture = model.Furniture;
|
||||
SupplyDate = model.SupplyDate;
|
||||
}
|
||||
|
||||
public ProviderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Type = Type,
|
||||
Furniture = Furniture,
|
||||
SupplyDate = SupplyDate,
|
||||
};
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
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 DataBaseImplement.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()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(TypeBindingModel? model)
|
||||
{
|
||||
if (model == null) return;
|
||||
Name = model.Name;
|
||||
}
|
||||
|
||||
public TypeViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
};
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
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; }
|
||||
string Furniture { get; set; }
|
||||
DateTime? SupplyDate { get; set; }
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
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; }
|
||||
}
|
||||
}
|
58
WinForm/PdfFormsLibrary/DropDownList.Designer.cs
generated
58
WinForm/PdfFormsLibrary/DropDownList.Designer.cs
generated
@ -1,58 +0,0 @@
|
||||
namespace WinForm
|
||||
{
|
||||
partial class DropDownList
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
comboBox = new ComboBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// comboBox
|
||||
//
|
||||
comboBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
comboBox.FormattingEnabled = true;
|
||||
comboBox.Location = new Point(3, 3);
|
||||
comboBox.Name = "comboBox";
|
||||
comboBox.Size = new Size(244, 23);
|
||||
comboBox.TabIndex = 0;
|
||||
comboBox.SelectedValueChanged += ComboBox_SelectedValueChanged;
|
||||
//
|
||||
// DropDownList
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(comboBox);
|
||||
Name = "DropDownList";
|
||||
Size = new Size(250, 30);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBox;
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
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 WinForm
|
||||
{
|
||||
public partial class DropDownList : UserControl
|
||||
{
|
||||
public DropDownList()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
comboBox.Items.Clear();
|
||||
}
|
||||
|
||||
public string Selected
|
||||
{
|
||||
get
|
||||
{
|
||||
if (comboBox.Items.Count == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if (comboBox.SelectedItem == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return comboBox.SelectedItem.ToString()!;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (comboBox.Items.Contains(value))
|
||||
{
|
||||
comboBox.SelectedItem = value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ComboBox.ObjectCollection ComboBoxItems
|
||||
{
|
||||
get { return comboBox.Items; }
|
||||
}
|
||||
|
||||
private EventHandler _explicitEvent;
|
||||
public event EventHandler ExplicitEvent
|
||||
{
|
||||
add
|
||||
{
|
||||
_explicitEvent += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_explicitEvent -= value;
|
||||
}
|
||||
}
|
||||
|
||||
private void ComboBox_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
_explicitEvent?.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,57 +0,0 @@
|
||||
using OxyPlot.Legends;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PdfFormsLibrary.Helpers
|
||||
{
|
||||
public class LegendSettingsAttribute : Attribute
|
||||
{
|
||||
public LegendPosition Position { get; }
|
||||
public LegendPlacement Placement { get; }
|
||||
|
||||
public LegendSettingsAttribute(LegendPosition position, LegendPlacement placement)
|
||||
{
|
||||
Position = position;
|
||||
Placement = placement;
|
||||
}
|
||||
}
|
||||
|
||||
public enum DiagramLegendPosition
|
||||
{
|
||||
[LegendSettings(LegendPosition.LeftTop, LegendPlacement.Outside)]
|
||||
TopLeftOutside,
|
||||
[LegendSettings(LegendPosition.TopCenter, LegendPlacement.Outside)]
|
||||
TopCenterOutside,
|
||||
[LegendSettings(LegendPosition.RightTop, LegendPlacement.Outside)]
|
||||
TopRightOutside,
|
||||
[LegendSettings(LegendPosition.LeftMiddle, LegendPlacement.Outside)]
|
||||
MiddleLeftOutside,
|
||||
[LegendSettings(LegendPosition.RightMiddle, LegendPlacement.Outside)]
|
||||
MiddleRightOutside,
|
||||
[LegendSettings(LegendPosition.BottomLeft, LegendPlacement.Outside)]
|
||||
BottomLeftOutside,
|
||||
[LegendSettings(LegendPosition.BottomCenter, LegendPlacement.Outside)]
|
||||
BottomCenterOutside,
|
||||
[LegendSettings(LegendPosition.BottomRight, LegendPlacement.Outside)]
|
||||
BottomRightOutside,
|
||||
[LegendSettings(LegendPosition.LeftTop, LegendPlacement.Inside)]
|
||||
TopLeftInside,
|
||||
[LegendSettings(LegendPosition.TopCenter, LegendPlacement.Inside)]
|
||||
TopCenterInside,
|
||||
[LegendSettings(LegendPosition.RightTop, LegendPlacement.Inside)]
|
||||
TopRightInside,
|
||||
[LegendSettings(LegendPosition.LeftMiddle, LegendPlacement.Inside)]
|
||||
MiddleLeftInside,
|
||||
[LegendSettings(LegendPosition.RightMiddle, LegendPlacement.Inside)]
|
||||
MiddleRightInside,
|
||||
[LegendSettings(LegendPosition.BottomLeft, LegendPlacement.Inside)]
|
||||
BottomLeftInside,
|
||||
[LegendSettings(LegendPosition.BottomCenter, LegendPlacement.Inside)]
|
||||
BottomCenterInside,
|
||||
[LegendSettings(LegendPosition.BottomRight, LegendPlacement.Inside)]
|
||||
BottomRightInside,
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PdfFormsLibrary.Helpers
|
||||
{
|
||||
public class PdfWithDiagramData
|
||||
{
|
||||
public string FilePath { get; set; } = string.Empty;
|
||||
public string DocumentTitle { get; set; } = string.Empty;
|
||||
public string DiagramName { get; set; } = string.Empty;
|
||||
public DiagramLegendPosition LegendPosition { get; set; } = DiagramLegendPosition.BottomCenterOutside;
|
||||
public List<PdfWithDiagramSeries> Series { get; set; } = new();
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PdfFormsLibrary.Helpers
|
||||
{
|
||||
public class PdfWithDiagramSeries
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public List<(double, double)> Data { get; set; } = new();
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PdfFormsLibrary.Helpers
|
||||
{
|
||||
public class PdfWithTableData<T>
|
||||
{
|
||||
public string FilePath { get; set; } = string.Empty;
|
||||
public string DocumentTitle { get; set; } = string.Empty;
|
||||
public List<PdfWithTableHeader> TableHeader { get; set; } = new();
|
||||
public List<T> TableData { get; set; } = new();
|
||||
public List<string> Props { get; set; } = new();
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PdfFormsLibrary.Helpers
|
||||
{
|
||||
public class PdfWithTableHeader
|
||||
{
|
||||
public string? ColumnName { get; set; } = string.Empty;
|
||||
public int ColumnWidth { get; set; } = 100;
|
||||
public List<PdfWithTableSubHeader> SubColumns { get; set; } = new List<PdfWithTableSubHeader>();
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PdfFormsLibrary.Helpers
|
||||
{
|
||||
public class PdfWithTableSubHeader
|
||||
{
|
||||
public string? ColumnName { get; set; } = string.Empty;
|
||||
public int ColumnWidth { get; set; } = 100;
|
||||
}
|
||||
}
|
57
WinForm/PdfFormsLibrary/ListBoxValues.Designer.cs
generated
57
WinForm/PdfFormsLibrary/ListBoxValues.Designer.cs
generated
@ -1,57 +0,0 @@
|
||||
namespace WinForm
|
||||
{
|
||||
partial class ListBoxValues
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
listBox = new ListBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// listBox
|
||||
//
|
||||
listBox.FormattingEnabled = true;
|
||||
listBox.ItemHeight = 15;
|
||||
listBox.Location = new Point(3, 3);
|
||||
listBox.Name = "listBox";
|
||||
listBox.Size = new Size(194, 154);
|
||||
listBox.TabIndex = 0;
|
||||
//
|
||||
// ListBoxValues
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(listBox);
|
||||
Name = "ListBoxValues";
|
||||
Size = new Size(200, 160);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ListBox listBox;
|
||||
}
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WinForm
|
||||
{
|
||||
public partial class ListBoxValues : UserControl
|
||||
{
|
||||
private string layoutString;
|
||||
private string startSymbol;
|
||||
private string endSymbol;
|
||||
|
||||
public ListBoxValues()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void SetLayoutInfo(string layout, string startS, string endS)
|
||||
{
|
||||
if (layout == null || startS == null || endS == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
layoutString = layout;
|
||||
startSymbol = startS;
|
||||
endSymbol = endS;
|
||||
}
|
||||
|
||||
public int SelectedIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
if (listBox.SelectedIndex == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return listBox.SelectedIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (listBox.SelectedItems.Count != 0)
|
||||
{
|
||||
listBox.SelectedIndex = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public T GetObjectFromStr<T>() where T : class, new()
|
||||
{
|
||||
if (listBox.SelectedIndex == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string row = listBox.SelectedItem.ToString()!;
|
||||
T curObject = new T();
|
||||
StringBuilder sb = new StringBuilder(row);
|
||||
foreach (var property in typeof(T).GetProperties())
|
||||
{
|
||||
if (!property.CanWrite)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int borderOne = sb.ToString().IndexOf(startSymbol);
|
||||
if (borderOne == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
int borderTwo = sb.ToString().IndexOf(endSymbol, borderOne + 1);
|
||||
if (borderTwo == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
string propertyValue = sb.ToString(borderOne + 1, borderTwo - borderOne - 1);
|
||||
sb.Remove(0, borderTwo + 1);
|
||||
property.SetValue(curObject, Convert.ChangeType(propertyValue, property.PropertyType));
|
||||
}
|
||||
return curObject;
|
||||
}
|
||||
|
||||
public void FillProperty<T>(T dataObject, int rowIndex, string propertyName)
|
||||
{
|
||||
if (layoutString == null || startSymbol == null || endSymbol == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (listBox.Items.Count <= rowIndex)
|
||||
{
|
||||
listBox.Items.Add(layoutString);
|
||||
}
|
||||
|
||||
string row = listBox.Items[rowIndex].ToString();
|
||||
PropertyInfo propertyInfo = dataObject.GetType().GetProperty(propertyName);
|
||||
|
||||
if (propertyInfo != null)
|
||||
{
|
||||
object propertyValue = propertyInfo.GetValue(dataObject);
|
||||
row = row.Replace($"{startSymbol}{propertyName}{endSymbol}", propertyValue.ToString());
|
||||
listBox.Items[rowIndex] = row;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
60
WinForm/PdfFormsLibrary/NumberTextBox.Designer.cs
generated
60
WinForm/PdfFormsLibrary/NumberTextBox.Designer.cs
generated
@ -1,60 +0,0 @@
|
||||
namespace WinForm
|
||||
{
|
||||
partial class NumberTextBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
textBox = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// textBox
|
||||
//
|
||||
textBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
textBox.Location = new Point(3, 3);
|
||||
textBox.Name = "textBox";
|
||||
textBox.Size = new Size(254, 23);
|
||||
textBox.TabIndex = 2;
|
||||
textBox.TextChanged += TextBox_TextChanged;
|
||||
textBox.Enter += TextBox_Enter;
|
||||
//
|
||||
// NumberTextBox
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(textBox);
|
||||
Name = "NumberTextBox";
|
||||
Size = new Size(260, 29);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox numberTextBox;
|
||||
private TextBox textBox;
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WinForm
|
||||
{
|
||||
public partial class NumberTextBox : UserControl
|
||||
{
|
||||
//Шаблон для textbox
|
||||
private string? pattern;
|
||||
private string example = "+7XXXXXXXXXX";
|
||||
|
||||
public NumberTextBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
//Публичное свойство для получения и заполнения шаблона
|
||||
public string? Pattern
|
||||
{
|
||||
get { return pattern; }
|
||||
set { pattern = value; }
|
||||
}
|
||||
|
||||
public string? TextBoxValue
|
||||
{
|
||||
get
|
||||
{
|
||||
if (new Regex(Pattern).IsMatch(textBox.Text))
|
||||
{
|
||||
return textBox.Text;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (new Regex(Pattern).IsMatch(value))
|
||||
{
|
||||
textBox.Text = value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Метод для заполнения примера
|
||||
public void SetExample(string str)
|
||||
{
|
||||
if (new Regex(Pattern).IsMatch(str))
|
||||
{
|
||||
example = str;
|
||||
}
|
||||
}
|
||||
|
||||
private void TextBox_Enter(object sender, EventArgs e)
|
||||
{
|
||||
int VisibleTime = 3000;
|
||||
ToolTip tt = new ToolTip();
|
||||
tt.Show(example, textBox, 0, 25, VisibleTime);
|
||||
}
|
||||
|
||||
private EventHandler _explicitEvent;
|
||||
public event EventHandler ExplicitEvent
|
||||
{
|
||||
add
|
||||
{
|
||||
_explicitEvent += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_explicitEvent -= value;
|
||||
}
|
||||
}
|
||||
|
||||
private void TextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
_explicitEvent?.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<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>
|
@ -1,17 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OxyPlot.Core" Version="2.1.2" />
|
||||
<PackageReference Include="OxyPlot.WindowsForms" Version="2.1.2" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,36 +0,0 @@
|
||||
namespace PdfFormsLibrary
|
||||
{
|
||||
partial class PdfGeneratorControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.Rendering;
|
||||
using PdfSharp.Fonts;
|
||||
using PdfSharp.Pdf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PdfFormsLibrary
|
||||
{
|
||||
public partial class PdfGeneratorControl : Component
|
||||
{
|
||||
public PdfGeneratorControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public PdfGeneratorControl(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void GeneratePdf(string filePath, string documentTitle, List<string> textData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(filePath) || string.IsNullOrEmpty(documentTitle) || textData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Document document = new Document();
|
||||
|
||||
Section section = document.AddSection();
|
||||
|
||||
Paragraph title = section.AddParagraph(documentTitle);
|
||||
title.Format.Font.Bold = true;
|
||||
|
||||
foreach (var item in textData)
|
||||
{
|
||||
Paragraph paragraph = section.AddParagraph();
|
||||
paragraph.AddText(item);
|
||||
}
|
||||
|
||||
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true, PdfFontEmbedding.Always);
|
||||
pdfRenderer.Document = document;
|
||||
pdfRenderer.RenderDocument();
|
||||
pdfRenderer.PdfDocument.Save(filePath);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
namespace PdfFormsLibrary
|
||||
{
|
||||
partial class PdfGeneratorLinearDiagram
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.Rendering;
|
||||
using OxyPlot;
|
||||
using OxyPlot.Axes;
|
||||
using OxyPlot.Legends;
|
||||
using OxyPlot.Series;
|
||||
using OxyPlot.WindowsForms;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using PdfFormsLibrary.Helpers;
|
||||
|
||||
namespace PdfFormsLibrary
|
||||
{
|
||||
public partial class PdfGeneratorLinearDiagram : Component
|
||||
{
|
||||
public PdfGeneratorLinearDiagram()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public PdfGeneratorLinearDiagram(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void GeneratePdfDocumentWithChart(PdfWithDiagramData pdfDiagram)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pdfDiagram.FilePath) || string.IsNullOrEmpty(pdfDiagram.DocumentTitle)
|
||||
|| string.IsNullOrEmpty(pdfDiagram.DiagramName) || pdfDiagram.Series == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var plotModel = new PlotModel { Title = pdfDiagram.DiagramName };
|
||||
|
||||
var xAxis = new LinearAxis { Position = AxisPosition.Bottom };
|
||||
var yAxis = new LinearAxis { Position = AxisPosition.Left };
|
||||
plotModel.Axes.Add(xAxis);
|
||||
plotModel.Axes.Add(yAxis);
|
||||
|
||||
foreach (var item in pdfDiagram.Series)
|
||||
{
|
||||
var singleSeries = new LineSeries { Title = item.Name };
|
||||
foreach (var coordinates in item.Data)
|
||||
{
|
||||
singleSeries.Points.Add(new DataPoint(coordinates.Item1, coordinates.Item2));
|
||||
}
|
||||
plotModel.Series.Add(singleSeries);
|
||||
}
|
||||
|
||||
var fieldInfo = typeof(DiagramLegendPosition).GetField(pdfDiagram.LegendPosition.ToString());
|
||||
var attribute = fieldInfo?.GetCustomAttribute<LegendSettingsAttribute>();
|
||||
|
||||
plotModel.Legends.Add(new Legend()
|
||||
{
|
||||
LegendTitle = "Легенда",
|
||||
LegendPlacement = attribute.Placement,
|
||||
LegendPosition = attribute.Position,
|
||||
});
|
||||
plotModel.IsLegendVisible = true;
|
||||
|
||||
var document = new Document();
|
||||
document.Info.Title = pdfDiagram.DocumentTitle;
|
||||
|
||||
var section = document.AddSection();
|
||||
section.PageSetup.TopMargin = "1cm";
|
||||
|
||||
var image = new PngExporter { Width = 600, Height = 400 }.ExportToBitmap(plotModel);
|
||||
image.Save("temp.png");
|
||||
|
||||
var chartImage = section.AddImage("temp.png");
|
||||
chartImage.LockAspectRatio = true;
|
||||
chartImage.Width = "15cm";
|
||||
chartImage.Height = "10cm";
|
||||
|
||||
var pdfRenderer = new PdfDocumentRenderer(true);
|
||||
pdfRenderer.Document = document;
|
||||
pdfRenderer.RenderDocument();
|
||||
pdfRenderer.PdfDocument.Save(pdfDiagram.FilePath);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
namespace PdfFormsLibrary
|
||||
{
|
||||
partial class PdfTableGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
using PdfSharp.Pdf;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using MigraDoc.Rendering;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using PdfFormsLibrary.Helpers;
|
||||
|
||||
namespace PdfFormsLibrary
|
||||
{
|
||||
public partial class PdfTableGenerator : Component
|
||||
{
|
||||
private int fontSize = 14;
|
||||
|
||||
public PdfTableGenerator()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public PdfTableGenerator(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void GeneratePdf<T>(PdfWithTableData<T> pdfTable)
|
||||
{
|
||||
if (pdfTable == null || string.IsNullOrEmpty(pdfTable.FilePath)
|
||||
|| string.IsNullOrEmpty(pdfTable.DocumentTitle) || pdfTable.TableHeader == null)
|
||||
{
|
||||
throw new ArgumentException("Недостаточно данных для создания PDF-документа.");
|
||||
}
|
||||
Document document = new Document();
|
||||
Section section = document.AddSection();
|
||||
|
||||
Paragraph title = section.AddParagraph(pdfTable.DocumentTitle);
|
||||
title.Format.Font.Bold = true;
|
||||
title.Format.Alignment = ParagraphAlignment.Center;
|
||||
|
||||
Table table = section.AddTable();
|
||||
table.Borders.Visible = true;
|
||||
|
||||
foreach (var column in pdfTable.TableHeader)
|
||||
{
|
||||
if (column.SubColumns.Count > 0)
|
||||
{
|
||||
foreach(var sub in column.SubColumns)
|
||||
{
|
||||
Column newsub = table.AddColumn();
|
||||
newsub.Width = sub.ColumnWidth;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
Column newcolumn = table.AddColumn();
|
||||
newcolumn.Width = column.ColumnWidth;
|
||||
}
|
||||
|
||||
CreateTableHeader(table, pdfTable.TableHeader);
|
||||
|
||||
CreateTableData(table, pdfTable);
|
||||
|
||||
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);
|
||||
pdfRenderer.Document = document;
|
||||
pdfRenderer.RenderDocument();
|
||||
pdfRenderer.PdfDocument.Save(pdfTable.FilePath);
|
||||
}
|
||||
|
||||
public void CreateTableHeader(Table table, List<PdfWithTableHeader> headerInfo)
|
||||
{
|
||||
Row headerRow1 = table.AddRow();
|
||||
Row headerRow2 = table.AddRow();
|
||||
|
||||
foreach (Row headerRow in new Row[] { headerRow1, headerRow2 })
|
||||
{
|
||||
headerRow.HeadingFormat = true;
|
||||
headerRow.Format.Alignment = ParagraphAlignment.Center;
|
||||
headerRow.Format.Font.Bold = true;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
foreach (var column in headerInfo)
|
||||
{
|
||||
int rowSpan = Math.Max(1, column.SubColumns.Count);
|
||||
|
||||
if (column.SubColumns.Count > 0)
|
||||
{
|
||||
headerRow1.Cells[i].MergeRight = rowSpan - 1;
|
||||
|
||||
for (int j = 0; j < column.SubColumns.Count; j++)
|
||||
{
|
||||
headerRow2.Cells[i + j].AddParagraph(column.SubColumns[j].ColumnName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
headerRow1.Cells[i].MergeDown = rowSpan;
|
||||
}
|
||||
|
||||
headerRow1.Cells[i].AddParagraph(column.ColumnName);
|
||||
i += rowSpan;
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateTableData<T>(Table table, PdfWithTableData<T> data)
|
||||
{
|
||||
if (data == null || data.TableData == null)
|
||||
return;
|
||||
|
||||
foreach (var rowData in data.TableData)
|
||||
{
|
||||
Row newrow = table.AddRow();
|
||||
int i = 0;
|
||||
foreach (var column in data.Props)
|
||||
{
|
||||
try
|
||||
{
|
||||
object cellValue = typeof(T).GetProperty(column).GetValue(rowData);
|
||||
string cellText = cellValue?.ToString() ?? string.Empty;
|
||||
newrow.Cells[i].AddParagraph(cellText);
|
||||
++i;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,17 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.33424.131
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinForm", "WinForm\WinForm.csproj", "{79A863DB-93E6-44C2-AB0F-DE0D19BE72DC}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataModels", "DataModels\DataModels.csproj", "{D468732D-BA49-4D2C-8854-DD4FDA8FDC1D}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{B90EEDCA-96C8-4E5C-9C5B-7F663023802D}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataBaseImplement", "DataBaseImplement\DataBaseImplement.csproj", "{E94AC3C7-A9BB-4262-9C87-5DF8E03B643B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppView", "AppView\AppView.csproj", "{9BD73EC6-6B32-4CBB-8D04-9D4650562846}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdfFormsLibrary", "PdfFormsLibrary\PdfFormsLibrary.csproj", "{2BFDA66F-E786-4C74-8D3A-054C6D1FDF7D}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinForm", "WinForm\WinForm.csproj", "{79A863DB-93E6-44C2-AB0F-DE0D19BE72DC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -25,26 +15,6 @@ Global
|
||||
{79A863DB-93E6-44C2-AB0F-DE0D19BE72DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{79A863DB-93E6-44C2-AB0F-DE0D19BE72DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{79A863DB-93E6-44C2-AB0F-DE0D19BE72DC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D468732D-BA49-4D2C-8854-DD4FDA8FDC1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D468732D-BA49-4D2C-8854-DD4FDA8FDC1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D468732D-BA49-4D2C-8854-DD4FDA8FDC1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D468732D-BA49-4D2C-8854-DD4FDA8FDC1D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B90EEDCA-96C8-4E5C-9C5B-7F663023802D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B90EEDCA-96C8-4E5C-9C5B-7F663023802D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B90EEDCA-96C8-4E5C-9C5B-7F663023802D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B90EEDCA-96C8-4E5C-9C5B-7F663023802D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E94AC3C7-A9BB-4262-9C87-5DF8E03B643B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E94AC3C7-A9BB-4262-9C87-5DF8E03B643B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E94AC3C7-A9BB-4262-9C87-5DF8E03B643B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E94AC3C7-A9BB-4262-9C87-5DF8E03B643B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9BD73EC6-6B32-4CBB-8D04-9D4650562846}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9BD73EC6-6B32-4CBB-8D04-9D4650562846}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9BD73EC6-6B32-4CBB-8D04-9D4650562846}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9BD73EC6-6B32-4CBB-8D04-9D4650562846}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2BFDA66F-E786-4C74-8D3A-054C6D1FDF7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2BFDA66F-E786-4C74-8D3A-054C6D1FDF7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2BFDA66F-E786-4C74-8D3A-054C6D1FDF7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2BFDA66F-E786-4C74-8D3A-054C6D1FDF7D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinForm
|
||||
{
|
||||
public class ExampleClass
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Book { get; set; }
|
||||
public string Genre { get; set; }
|
||||
public string Author { get; set; }
|
||||
|
||||
public ExampleClass(int Id, string Book, string Genre, string Author)
|
||||
{
|
||||
this.Id = Id;
|
||||
this.Book = Book;
|
||||
this.Genre = Genre;
|
||||
this.Author = Author;
|
||||
}
|
||||
}
|
||||
}
|
39
WinForm/WinForm/Form1.Designer.cs
generated
Normal file
39
WinForm/WinForm/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
||||
namespace WinForm
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
10
WinForm/WinForm/Form1.cs
Normal file
10
WinForm/WinForm/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace WinForm
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
153
WinForm/WinForm/FormNoGraphics.Designer.cs
generated
153
WinForm/WinForm/FormNoGraphics.Designer.cs
generated
@ -1,153 +0,0 @@
|
||||
namespace WinForm
|
||||
{
|
||||
partial class FormNoGraphics
|
||||
{
|
||||
/// <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();
|
||||
pdfGeneratorControl = new PdfFormsLibrary.PdfGeneratorControl(components);
|
||||
groupBoxPdfText = new GroupBox();
|
||||
buttonSaveDiagram = new Button();
|
||||
buttonSaveTable = new Button();
|
||||
buttonSaveFile = new Button();
|
||||
richTextBox = new RichTextBox();
|
||||
labelBigText = new Label();
|
||||
labelTitle = new Label();
|
||||
textBoxTitle = new TextBox();
|
||||
pdfTableGenerator = new PdfFormsLibrary.PdfTableGenerator(components);
|
||||
pdfGeneratorLinearDiagram = new PdfFormsLibrary.PdfGeneratorLinearDiagram(components);
|
||||
groupBoxPdfText.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxPdfText
|
||||
//
|
||||
groupBoxPdfText.Controls.Add(buttonSaveDiagram);
|
||||
groupBoxPdfText.Controls.Add(buttonSaveTable);
|
||||
groupBoxPdfText.Controls.Add(buttonSaveFile);
|
||||
groupBoxPdfText.Controls.Add(richTextBox);
|
||||
groupBoxPdfText.Controls.Add(labelBigText);
|
||||
groupBoxPdfText.Controls.Add(labelTitle);
|
||||
groupBoxPdfText.Controls.Add(textBoxTitle);
|
||||
groupBoxPdfText.Location = new Point(12, 12);
|
||||
groupBoxPdfText.Name = "groupBoxPdfText";
|
||||
groupBoxPdfText.Size = new Size(328, 369);
|
||||
groupBoxPdfText.TabIndex = 0;
|
||||
groupBoxPdfText.TabStop = false;
|
||||
groupBoxPdfText.Text = "Работа с большим текстом pdf";
|
||||
//
|
||||
// buttonSaveDiagram
|
||||
//
|
||||
buttonSaveDiagram.Location = new Point(41, 319);
|
||||
buttonSaveDiagram.Name = "buttonSaveDiagram";
|
||||
buttonSaveDiagram.Size = new Size(226, 23);
|
||||
buttonSaveDiagram.TabIndex = 7;
|
||||
buttonSaveDiagram.Text = "Сохранить Диаграмму в PDF";
|
||||
buttonSaveDiagram.UseVisualStyleBackColor = true;
|
||||
buttonSaveDiagram.Click += ButtonSaveDiagram_Click;
|
||||
//
|
||||
// buttonSaveTable
|
||||
//
|
||||
buttonSaveTable.Location = new Point(41, 290);
|
||||
buttonSaveTable.Name = "buttonSaveTable";
|
||||
buttonSaveTable.Size = new Size(226, 23);
|
||||
buttonSaveTable.TabIndex = 6;
|
||||
buttonSaveTable.Text = "Сохранить Таблицу в PDF";
|
||||
buttonSaveTable.UseVisualStyleBackColor = true;
|
||||
buttonSaveTable.Click += ButtonSaveTable_Click;
|
||||
//
|
||||
// buttonSaveFile
|
||||
//
|
||||
buttonSaveFile.Location = new Point(41, 261);
|
||||
buttonSaveFile.Name = "buttonSaveFile";
|
||||
buttonSaveFile.Size = new Size(226, 23);
|
||||
buttonSaveFile.TabIndex = 4;
|
||||
buttonSaveFile.Text = "Сохранить Текст в PDF";
|
||||
buttonSaveFile.UseVisualStyleBackColor = true;
|
||||
buttonSaveFile.Click += ButtonSaveFile_Click;
|
||||
//
|
||||
// richTextBox
|
||||
//
|
||||
richTextBox.Location = new Point(41, 56);
|
||||
richTextBox.Name = "richTextBox";
|
||||
richTextBox.Size = new Size(268, 199);
|
||||
richTextBox.TabIndex = 3;
|
||||
richTextBox.Text = "";
|
||||
//
|
||||
// labelBigText
|
||||
//
|
||||
labelBigText.AutoSize = true;
|
||||
labelBigText.Location = new Point(6, 56);
|
||||
labelBigText.Name = "labelBigText";
|
||||
labelBigText.Size = new Size(28, 15);
|
||||
labelBigText.TabIndex = 2;
|
||||
labelBigText.Text = "Text";
|
||||
//
|
||||
// labelTitle
|
||||
//
|
||||
labelTitle.AutoSize = true;
|
||||
labelTitle.Location = new Point(6, 25);
|
||||
labelTitle.Name = "labelTitle";
|
||||
labelTitle.Size = new Size(29, 15);
|
||||
labelTitle.TabIndex = 1;
|
||||
labelTitle.Text = "Title";
|
||||
//
|
||||
// textBoxTitle
|
||||
//
|
||||
textBoxTitle.Location = new Point(41, 22);
|
||||
textBoxTitle.Name = "textBoxTitle";
|
||||
textBoxTitle.Size = new Size(268, 23);
|
||||
textBoxTitle.TabIndex = 0;
|
||||
//
|
||||
// FormNoGraphics
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(351, 393);
|
||||
Controls.Add(groupBoxPdfText);
|
||||
Name = "FormNoGraphics";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Form";
|
||||
groupBoxPdfText.ResumeLayout(false);
|
||||
groupBoxPdfText.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PdfFormsLibrary.PdfGeneratorControl pdfGeneratorControl;
|
||||
private GroupBox groupBoxPdfText;
|
||||
private Label labelTitle;
|
||||
private TextBox textBoxTitle;
|
||||
private Button buttonSaveFile;
|
||||
private RichTextBox richTextBox;
|
||||
private Label labelBigText;
|
||||
private PdfFormsLibrary.PdfTableGenerator pdfTableGenerator;
|
||||
private Button buttonSaveDiagram;
|
||||
private Button buttonSaveTable;
|
||||
private PdfFormsLibrary.PdfGeneratorLinearDiagram pdfGeneratorLinearDiagram;
|
||||
}
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
using PdfFormsLibrary.Helpers;
|
||||
|
||||
namespace WinForm
|
||||
{
|
||||
public partial class FormNoGraphics : Form
|
||||
{
|
||||
public FormNoGraphics()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private List<(double, double)> GenerateRandomData(int count)
|
||||
{
|
||||
Random random = new Random();
|
||||
var data = new List<(double, double)>();
|
||||
for (int i = 1; i <= count; i++)
|
||||
{
|
||||
data.Add((i, random.NextDouble() * 50));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private List<ExampleClass> GenerateRandomClass(int count)
|
||||
{
|
||||
string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
Random random = new Random();
|
||||
List<ExampleClass> returnedList = new List<ExampleClass>();
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
char[] stringChars = new char[10];
|
||||
for (int j = 0; j < 10; ++j)
|
||||
{
|
||||
stringChars[j] = chars[random.Next(chars.Length)];
|
||||
}
|
||||
returnedList.Add(new ExampleClass(i, new string(stringChars), new string(stringChars), new string(stringChars)));
|
||||
}
|
||||
return returnedList;
|
||||
}
|
||||
|
||||
private string SavePath()
|
||||
{
|
||||
string filePath = string.Empty;
|
||||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||
saveFileDialog.Filter = "PDF Files|*.pdf";
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
filePath = saveFileDialog.FileName;
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
private void ButtonSaveFile_Click(object sender, EventArgs e)
|
||||
{
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
pdfGeneratorControl.GeneratePdf(SavePath(), textBoxTitle.Text, richTextBox.Lines.ToList());
|
||||
MessageBox.Show("PDF-äîêóìåíò óñïåøíî ñîõðàíåí.", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
private void ButtonSaveTable_Click(object sender, EventArgs e)
|
||||
{
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
PdfWithTableData<ExampleClass> tableData = new();
|
||||
List<PdfWithTableHeader> tableHeader = new()
|
||||
{
|
||||
new PdfWithTableHeader()
|
||||
{
|
||||
ColumnName="Id",
|
||||
ColumnWidth=50
|
||||
},
|
||||
new PdfWithTableHeader()
|
||||
{
|
||||
ColumnName="Book",
|
||||
ColumnWidth=100
|
||||
},
|
||||
new PdfWithTableHeader()
|
||||
{
|
||||
ColumnName="Params",
|
||||
ColumnWidth=250,
|
||||
SubColumns = new()
|
||||
{
|
||||
new (){ ColumnName="Genre", ColumnWidth=125},
|
||||
new (){ ColumnName="Author", ColumnWidth=125}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
tableData.TableHeader = tableHeader;
|
||||
tableData.Props = new List<string> { "Id", "Book", "Genre", "Author" };
|
||||
tableData.TableData = GenerateRandomClass(5);
|
||||
|
||||
tableData.DocumentTitle = textBoxTitle.Text;
|
||||
tableData.FilePath = SavePath();
|
||||
pdfTableGenerator.GeneratePdf(tableData);
|
||||
MessageBox.Show("PDF-äîêóìåíò óñïåøíî ñîõðàíåí.", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
private void ButtonSaveDiagram_Click(object sender, EventArgs e)
|
||||
{
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
PdfWithDiagramData diagramData = new();
|
||||
|
||||
diagramData.DocumentTitle = textBoxTitle.Text;
|
||||
diagramData.DiagramName = textBoxTitle.Text;
|
||||
diagramData.LegendPosition = DiagramLegendPosition.BottomCenterOutside;
|
||||
diagramData.Series = new(){
|
||||
new()
|
||||
{
|
||||
Name = "Ðÿä-1",
|
||||
Data = GenerateRandomData(5)
|
||||
},
|
||||
new()
|
||||
{
|
||||
Name = "Ðÿä-2",
|
||||
Data = GenerateRandomData(5)
|
||||
}
|
||||
};
|
||||
diagramData.FilePath = SavePath();
|
||||
try
|
||||
{
|
||||
pdfGeneratorLinearDiagram.GeneratePdfDocumentWithChart(diagramData);
|
||||
MessageBox.Show("PDF-äîêóìåíò ñîçäàí.", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"PDF-äîêóìåíòà íå ñîçäàí: {ex.Message}", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ namespace WinForm
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormNoGraphics());
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
@ -8,8 +8,4 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PdfFormsLibrary\PdfFormsLibrary.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,9 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user