2-я лаба, переделываю проект под 3-ю лабу (убираю формы из 2-й лабы)
This commit is contained in:
parent
d488814497
commit
be1ac80865
55
Labs.sln
Normal file
55
Labs.sln
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.7.34024.191
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChernyshevComponents", "Labs\ChernyshevComponents.csproj", "{5E935B01-E502-4B11-AE28-5B0F25C5A19B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test App", "Test App\Test App.csproj", "{0BEACE73-1EF7-4828-941E-7BAE7F11BB48}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{56FFBB07-9CD0-4D82-9B18-A389CD0A5663} = {56FFBB07-9CD0-4D82-9B18-A389CD0A5663}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OnlineShopDatabase", "OnlineStoreDatabase\OnlineShopDatabase.csproj", "{56FFBB07-9CD0-4D82-9B18-A389CD0A5663}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{B3AFF161-1512-4116-AD85-DC74AAD16FAB} = {B3AFF161-1512-4116-AD85-DC74AAD16FAB}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OnlineShopContracts", "OnlineShopContracts\OnlineShopContracts.csproj", "{B3AFF161-1512-4116-AD85-DC74AAD16FAB}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OnlineShopForms", "OnlineShopForms\OnlineShopForms.csproj", "{2501629F-2092-43E6-A15D-B0D722C7B456}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5E935B01-E502-4B11-AE28-5B0F25C5A19B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5E935B01-E502-4B11-AE28-5B0F25C5A19B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5E935B01-E502-4B11-AE28-5B0F25C5A19B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5E935B01-E502-4B11-AE28-5B0F25C5A19B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0BEACE73-1EF7-4828-941E-7BAE7F11BB48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0BEACE73-1EF7-4828-941E-7BAE7F11BB48}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0BEACE73-1EF7-4828-941E-7BAE7F11BB48}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0BEACE73-1EF7-4828-941E-7BAE7F11BB48}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{56FFBB07-9CD0-4D82-9B18-A389CD0A5663}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{56FFBB07-9CD0-4D82-9B18-A389CD0A5663}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{56FFBB07-9CD0-4D82-9B18-A389CD0A5663}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{56FFBB07-9CD0-4D82-9B18-A389CD0A5663}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B3AFF161-1512-4116-AD85-DC74AAD16FAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B3AFF161-1512-4116-AD85-DC74AAD16FAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B3AFF161-1512-4116-AD85-DC74AAD16FAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B3AFF161-1512-4116-AD85-DC74AAD16FAB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2501629F-2092-43E6-A15D-B0D722C7B456}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2501629F-2092-43E6-A15D-B0D722C7B456}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2501629F-2092-43E6-A15D-B0D722C7B456}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2501629F-2092-43E6-A15D-B0D722C7B456}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {0A48440F-B805-4D6D-B08E-A68C6765F5D7}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
28
Labs/ChernyshevComponents.csproj
Normal file
28
Labs/ChernyshevComponents.csproj
Normal file
@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspose.Words" Version="23.12.0" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.17" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.17" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.17">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.17" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.17">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
59
Labs/DropDownList.Designer.cs
generated
Normal file
59
Labs/DropDownList.Designer.cs
generated
Normal file
@ -0,0 +1,59 @@
|
||||
namespace Labs
|
||||
{
|
||||
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.Dock = DockStyle.Fill;
|
||||
comboBox.FormattingEnabled = true;
|
||||
comboBox.Location = new Point(0, 0);
|
||||
comboBox.Name = "comboBox";
|
||||
comboBox.Size = new Size(247, 28);
|
||||
comboBox.TabIndex = 0;
|
||||
comboBox.SelectedIndexChanged += comboBox_SelectedIndexChanged;
|
||||
//
|
||||
// DropDownList
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
AutoSize = true;
|
||||
Controls.Add(comboBox);
|
||||
Name = "DropDownList";
|
||||
Size = new Size(247, 37);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBox;
|
||||
}
|
||||
}
|
68
Labs/DropDownList.cs
Normal file
68
Labs/DropDownList.cs
Normal file
@ -0,0 +1,68 @@
|
||||
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 Labs
|
||||
{
|
||||
public partial class DropDownList : UserControl
|
||||
{
|
||||
public DropDownList()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
//метод заполнения
|
||||
public void Fill(List<string> lines)
|
||||
{
|
||||
Clear();
|
||||
foreach (string line in lines)
|
||||
{
|
||||
comboBox.Items.Add(line);
|
||||
}
|
||||
}
|
||||
|
||||
//метод очистки
|
||||
public void Clear()
|
||||
{
|
||||
comboBox.Items.Clear();
|
||||
}
|
||||
|
||||
|
||||
//св-во для получения/установки выбранного значения (строчки)
|
||||
public string? SelectedLine
|
||||
{
|
||||
//если строка была выбрана, возвращает её; иначе - пустую строку
|
||||
get => comboBox.SelectedItem?.ToString() ?? string.Empty;
|
||||
set
|
||||
{
|
||||
comboBox.SelectedIndex = comboBox.Items.IndexOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
//событие, вызываемое при смене значения
|
||||
|
||||
private EventHandler onLineChanged;
|
||||
public event EventHandler LineChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
onLineChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
onLineChanged -= value;
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
onLineChanged?.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
120
Labs/DropDownList.resx
Normal file
120
Labs/DropDownList.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
53
Labs/HelperClasses/Remover.cs
Normal file
53
Labs/HelperClasses/Remover.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Labs.HelperClasses
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс для удаления напоминаний о Aspose
|
||||
/// </summary>
|
||||
public class Remover
|
||||
{
|
||||
public Remover() { }
|
||||
public void Remove(string filePath) {
|
||||
using (WordprocessingDocument document = WordprocessingDocument.Open(filePath, true))
|
||||
{
|
||||
var mainPart = document.MainDocumentPart;
|
||||
|
||||
//Удаление красного текста от aspose
|
||||
//удаление 1-го красного текста
|
||||
var textsToRemove = mainPart.Document.Body.Descendants<DocumentFormat.OpenXml.Wordprocessing.Text>()
|
||||
.Where(t => t.Text.Contains("Evaluation Only. Created with Aspose.Words. Copyright 2003-2023 Aspose Pty Ltd."))
|
||||
.ToList();
|
||||
foreach (var text in textsToRemove)
|
||||
{
|
||||
text.Remove();
|
||||
}
|
||||
|
||||
// Удаление нижнего колонтитула (2-го красного текста)
|
||||
var footerParts = document.MainDocumentPart.FooterParts;
|
||||
foreach (var footerPart in footerParts)
|
||||
{
|
||||
footerPart.Footer.RemoveAllChildren<DocumentFormat.OpenXml.Wordprocessing.Paragraph>();
|
||||
footerPart.Footer.RemoveAllChildren<DocumentFormat.OpenXml.Wordprocessing.Table>();
|
||||
footerPart.Footer.RemoveAllChildren<DocumentFormat.OpenXml.Wordprocessing.Picture>();
|
||||
}
|
||||
|
||||
// Удаление вотермарки
|
||||
foreach (var headerPart in mainPart.HeaderParts)
|
||||
{
|
||||
foreach (var drawing in headerPart.Header.Descendants<DocumentFormat.OpenXml.Wordprocessing.Drawing>().ToList())
|
||||
{
|
||||
drawing.Remove();
|
||||
}
|
||||
}
|
||||
document.Save();
|
||||
document.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
24
Labs/HelperClasses/WordBigText/WordBigTextConfig.cs
Normal file
24
Labs/HelperClasses/WordBigText/WordBigTextConfig.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using DocumentFormat.OpenXml.ExtendedProperties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Labs.HelperClasses.WordBigText
|
||||
{
|
||||
public class WordBigTextConfig
|
||||
{
|
||||
public string FilePath = string.Empty;
|
||||
|
||||
public string DocumentTitle = string.Empty;
|
||||
|
||||
public string[] Paragraphs;
|
||||
public WordBigTextConfig(string filePath, string documentTitle, string[] text)
|
||||
{
|
||||
FilePath = filePath;
|
||||
DocumentTitle = documentTitle;
|
||||
Paragraphs = text;
|
||||
}
|
||||
}
|
||||
}
|
17
Labs/HelperClasses/WordLineChart/LegendLocation.cs
Normal file
17
Labs/HelperClasses/WordLineChart/LegendLocation.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Labs.HelperClasses.WordLineChart
|
||||
{
|
||||
public enum LegendLocation
|
||||
{
|
||||
None,
|
||||
Left,
|
||||
Right,
|
||||
Top,
|
||||
Bottom
|
||||
}
|
||||
}
|
30
Labs/HelperClasses/WordLineChart/LineChartSeria.cs
Normal file
30
Labs/HelperClasses/WordLineChart/LineChartSeria.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Labs.HelperClasses.WordLineChart
|
||||
{
|
||||
/// <summary>
|
||||
/// Cерия (1 ломаная на графике))
|
||||
/// </summary>
|
||||
public class LineChartSeria
|
||||
{
|
||||
/// <summary>
|
||||
/// Имя серии (что конкретно представлено ломаной)
|
||||
/// </summary>
|
||||
public string SeriaName = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Данные (значения ломаной)
|
||||
/// </summary>
|
||||
public double[] Data;
|
||||
|
||||
public LineChartSeria(string seria, double[] data)
|
||||
{
|
||||
SeriaName = seria;
|
||||
Data = data;
|
||||
}
|
||||
}
|
||||
}
|
51
Labs/HelperClasses/WordLineChart/WordLineChartConfig.cs
Normal file
51
Labs/HelperClasses/WordLineChart/WordLineChartConfig.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Labs.HelperClasses.WordLineChart
|
||||
{
|
||||
public class WordLineChartConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Путь до файла
|
||||
/// </summary>
|
||||
public string FilePath = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Заголовок документа
|
||||
/// </summary>
|
||||
public string DocumentTitle = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Заголовок диаграммы
|
||||
/// </summary>
|
||||
public string LineChartTitle = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Расположение легенды диаграммы
|
||||
/// </summary>
|
||||
public LegendLocation LegendLocation;
|
||||
|
||||
/// <summary>
|
||||
/// Данные для диаграммы
|
||||
/// </summary>
|
||||
public List<LineChartSeria> Data;
|
||||
|
||||
/// <summary>
|
||||
/// Категории (подписи (ключевые точки) по горизонтали)
|
||||
/// </summary>
|
||||
public string[] Categories;
|
||||
|
||||
public WordLineChartConfig(string filePath, string documentTitle, string lineChartTitle, LegendLocation legendLocation, List<LineChartSeria> data, string[] categories)
|
||||
{
|
||||
FilePath = filePath;
|
||||
DocumentTitle = documentTitle;
|
||||
LineChartTitle = lineChartTitle;
|
||||
LegendLocation = legendLocation;
|
||||
Data = data;
|
||||
Categories = categories;
|
||||
}
|
||||
}
|
||||
}
|
33
Labs/HelperClasses/WordTable/CellMergeInfo.cs
Normal file
33
Labs/HelperClasses/WordTable/CellMergeInfo.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Labs.HelperClasses.WordTable
|
||||
{
|
||||
public class CellMergeInfo
|
||||
{
|
||||
public int StartCell;
|
||||
public int EndCell;
|
||||
|
||||
public CellMergeInfo(int startCell, int endCell)
|
||||
{
|
||||
if (startCell < 0 || endCell < 0 || startCell == endCell)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("Неверные индексы ячеек");
|
||||
}
|
||||
|
||||
if (endCell < startCell)
|
||||
{
|
||||
StartCell = endCell;
|
||||
EndCell = startCell;
|
||||
}
|
||||
else
|
||||
{
|
||||
StartCell = startCell;
|
||||
EndCell = endCell;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
33
Labs/HelperClasses/WordTable/ColumnProperties.cs
Normal file
33
Labs/HelperClasses/WordTable/ColumnProperties.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Labs.HelperClasses.WordTable
|
||||
{
|
||||
public class ColumnProperties
|
||||
{
|
||||
//заголовок столбца в 1-й строке
|
||||
public string Header1;
|
||||
|
||||
//заголовок столбца во 2-й строке (необязательный)
|
||||
public string? Header2;
|
||||
//свойство, кот. хранится в столбце
|
||||
public string PropertyName;
|
||||
//ширина столбца
|
||||
public double Width;
|
||||
|
||||
public ColumnProperties(string propertyName, double width, string header1, string? header2 = null)
|
||||
{
|
||||
Header1 = header1;
|
||||
//мб if не нужен
|
||||
if (header2 != null)
|
||||
{
|
||||
Header2 = header2;
|
||||
}
|
||||
PropertyName = propertyName;
|
||||
Width = width;
|
||||
}
|
||||
}
|
||||
}
|
33
Labs/HelperClasses/WordTable/WordTableConfig.cs
Normal file
33
Labs/HelperClasses/WordTable/WordTableConfig.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Labs.HelperClasses.WordTable
|
||||
{
|
||||
public class WordTableConfig<T>
|
||||
{
|
||||
public string FilePath = string.Empty;
|
||||
|
||||
public string DocumentTitle = string.Empty;
|
||||
|
||||
|
||||
//инфа о столбцах (ширина, заголовки в 1-й и 2-й строке, имя свойства для вставки значения)
|
||||
public List<ColumnProperties> ColumnsProperties;
|
||||
|
||||
//объединённые ячейки (только в 1 строке)
|
||||
public List<CellMergeInfo> MergedCells;
|
||||
|
||||
public List<T> Data;
|
||||
|
||||
public WordTableConfig(string filePath, string documentTitle, List<ColumnProperties> columnsProperties, List<CellMergeInfo> mergedCells, List<T> data)
|
||||
{
|
||||
FilePath = filePath;
|
||||
DocumentTitle = documentTitle;
|
||||
ColumnsProperties = columnsProperties;
|
||||
MergedCells = mergedCells;
|
||||
Data = data;
|
||||
}
|
||||
}
|
||||
}
|
59
Labs/MailTextBox.Designer.cs
generated
Normal file
59
Labs/MailTextBox.Designer.cs
generated
Normal file
@ -0,0 +1,59 @@
|
||||
namespace Labs
|
||||
{
|
||||
partial class MailTextBox
|
||||
{
|
||||
/// <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.Location = new Point(3, 0);
|
||||
textBox.Name = "textBox";
|
||||
textBox.Size = new Size(247, 27);
|
||||
textBox.TabIndex = 0;
|
||||
textBox.TextChanged += textBox_TextChanged;
|
||||
textBox.Enter += textBox_Enter;
|
||||
//
|
||||
// MailTextBox
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
AutoSize = true;
|
||||
Controls.Add(textBox);
|
||||
Name = "MailTextBox";
|
||||
Size = new Size(333, 150);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBox;
|
||||
}
|
||||
}
|
118
Labs/MailTextBox.cs
Normal file
118
Labs/MailTextBox.cs
Normal file
@ -0,0 +1,118 @@
|
||||
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 Labs
|
||||
{
|
||||
public partial class MailTextBox : UserControl
|
||||
{
|
||||
public MailTextBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
Template = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$";
|
||||
}
|
||||
|
||||
//пример корректного ввода для ToolTip
|
||||
private string example = "something@gmail.com";
|
||||
|
||||
public void setExample(string example)
|
||||
{
|
||||
Regex regex = new Regex(Template);
|
||||
if (regex.IsMatch(example))
|
||||
{
|
||||
this.example = example;
|
||||
}
|
||||
}
|
||||
|
||||
//шаблон поля ввода
|
||||
private string template;
|
||||
|
||||
//св-во для работы с шаблоном поля ввода
|
||||
public string? Template
|
||||
{
|
||||
get { return template; }
|
||||
set { template = value; }
|
||||
}
|
||||
|
||||
//св-во для введённого значения в textbox
|
||||
public string TextValue
|
||||
{
|
||||
get
|
||||
{
|
||||
//если не задан шаблон
|
||||
if (Template == null)
|
||||
{
|
||||
throw new TemplateIsNotDefinedException();
|
||||
}
|
||||
Regex regex = new Regex(Template);
|
||||
//если не соответствует шаблону
|
||||
if (!regex.IsMatch(textBox.Text))
|
||||
{
|
||||
throw new DoesNotMatchTemplateException();
|
||||
}
|
||||
return textBox.Text;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
//если задан шаблон
|
||||
if (Template != null)
|
||||
{
|
||||
Regex regex = new Regex(Template);
|
||||
//если соответствует шаблону
|
||||
if (regex.IsMatch(value))
|
||||
{
|
||||
textBox.Text = value;
|
||||
}
|
||||
}
|
||||
//если не задан шаблон, ничего не вывести
|
||||
else
|
||||
{
|
||||
textBox.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class TemplateIsNotDefinedException : Exception
|
||||
{
|
||||
public TemplateIsNotDefinedException() : base("Шаблон текста не задан") { }
|
||||
}
|
||||
|
||||
private class DoesNotMatchTemplateException : Exception
|
||||
{
|
||||
public DoesNotMatchTemplateException() : base("Текст не соответствует шаблону") { }
|
||||
}
|
||||
|
||||
private void textBox_Enter(object sender, EventArgs e)
|
||||
{
|
||||
ToolTip tooltip = new ToolTip();
|
||||
tooltip.Show(example, textBox, 0, -30, 2500);
|
||||
}
|
||||
|
||||
|
||||
private EventHandler onTextChanged;
|
||||
public event EventHandler TextChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
onTextChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
onTextChanged -= value;
|
||||
}
|
||||
}
|
||||
|
||||
private void textBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
onTextChanged?.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
120
Labs/MailTextBox.resx
Normal file
120
Labs/MailTextBox.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
59
Labs/ObjectsListBox.Designer.cs
generated
Normal file
59
Labs/ObjectsListBox.Designer.cs
generated
Normal file
@ -0,0 +1,59 @@
|
||||
namespace Labs
|
||||
{
|
||||
partial class ObjectsListBox
|
||||
{
|
||||
/// <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.Dock = DockStyle.Fill;
|
||||
listBox.FormattingEnabled = true;
|
||||
listBox.ItemHeight = 20;
|
||||
listBox.Location = new Point(0, 0);
|
||||
listBox.Name = "listBox";
|
||||
listBox.Size = new Size(416, 257);
|
||||
listBox.TabIndex = 0;
|
||||
//
|
||||
// ObjectsListBox
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
AutoSize = true;
|
||||
Controls.Add(listBox);
|
||||
Name = "ObjectsListBox";
|
||||
Size = new Size(416, 257);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ListBox listBox;
|
||||
}
|
||||
}
|
187
Labs/ObjectsListBox.cs
Normal file
187
Labs/ObjectsListBox.cs
Normal file
@ -0,0 +1,187 @@
|
||||
using DocumentFormat.OpenXml.ExtendedProperties;
|
||||
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.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.ComponentModel.Design.ObjectSelectorEditor;
|
||||
|
||||
namespace Labs
|
||||
{
|
||||
public partial class ObjectsListBox : UserControl
|
||||
{
|
||||
public ObjectsListBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
//макетная строка
|
||||
private string templateLine;
|
||||
|
||||
//начальный символ для поиска свойств
|
||||
private char startSymbol;
|
||||
|
||||
//конечный символ для поиска свойств
|
||||
private char endSymbol;
|
||||
|
||||
public void SetTemplateInfo(string template, char start, char end)
|
||||
{
|
||||
if (template == null || start == null || end == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
templateLine = template;
|
||||
startSymbol = start;
|
||||
endSymbol = end;
|
||||
}
|
||||
|
||||
|
||||
//свойство для получения/установки индекса выбранной строки
|
||||
public int SelectedIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return listBox.SelectedIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (listBox.SelectedItems.Count != 0)
|
||||
{
|
||||
listBox.SelectedIndex = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//параметризованный метод для получения объекта из выбранной строки
|
||||
//T - класс, у которого есть пустой конструктор для возмож-ти создания экземпляра без параметров
|
||||
public T GetObjectFromLine<T>() where T : class, new()
|
||||
{
|
||||
string SelectedLine = "";
|
||||
|
||||
if (listBox.SelectedIndex != -1)
|
||||
{
|
||||
SelectedLine = listBox.SelectedItem.ToString();
|
||||
}
|
||||
char[] symbols = { startSymbol, endSymbol };
|
||||
|
||||
//слова из шаблонной строки
|
||||
string[] wordsInTemplate = templateLine.Split(symbols, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
//постоянные слова
|
||||
List<string> constantWords = new List<string>();
|
||||
|
||||
//заполнение списка постоянных слов из шаблонной строки (с самого первого каждые 2 слова)
|
||||
for (int i = 1; i < wordsInTemplate.Length; i+=2)
|
||||
{
|
||||
constantWords.Add(wordsInTemplate[i]);
|
||||
}
|
||||
|
||||
//индексы постоянных слов
|
||||
List<int> startsOfConstant = new List<int>();
|
||||
string curString = SelectedLine;
|
||||
|
||||
int curIndex = 0;
|
||||
foreach (string constantWord in constantWords)
|
||||
{
|
||||
//Нахождение const слова целиком с текущего индекса curIndex (в подстроке, начин. с curIndex)
|
||||
int indexOfConstant = curString.IndexOf(constantWord, curIndex);
|
||||
startsOfConstant.Add(indexOfConstant);
|
||||
curIndex = indexOfConstant + constantWord.Length;
|
||||
}
|
||||
|
||||
//Слова, являющиеся значениями полей
|
||||
List<string> values = new List<string>();
|
||||
|
||||
curIndex = 0;
|
||||
int j = 0;
|
||||
//прохожу по всей строке и списку постоянных слов
|
||||
while (curIndex < SelectedLine.Length && j < constantWords.Count)
|
||||
{
|
||||
//если индекс до индекса j-го по счёту константного слова, т.е. это слово-значение
|
||||
if (curIndex < startsOfConstant[j])
|
||||
{
|
||||
//подстрока с текущего индекса длиной в слово (= индекс след. константного - текущий индекс)
|
||||
string value = SelectedLine.Substring(curIndex, startsOfConstant[j] - curIndex);
|
||||
//если строка не пустая (не null и не одни пробелы)
|
||||
if (!string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
//добавить её и убрать лишние пробелы перед значением и после (могут быть, могут не быть)
|
||||
values.Add(value.TrimStart().TrimEnd());
|
||||
}
|
||||
}
|
||||
//проходим константное слово
|
||||
curIndex = startsOfConstant[j] + constantWords[j].Length;
|
||||
//отслеживаем следующее конст. слово
|
||||
j++;
|
||||
}
|
||||
//Если текущий индекс получился не последний, а все постоянные слова закончились, значит до конца строки - значение
|
||||
if (curIndex < SelectedLine.Length)
|
||||
{
|
||||
values.Add(SelectedLine.Substring(curIndex).TrimStart().TrimEnd());
|
||||
}
|
||||
|
||||
|
||||
//Названия свойств из шаблона
|
||||
List<string> propertyNames = new List<string>();
|
||||
for (int i = 0; i < wordsInTemplate.Length; i+=2)
|
||||
{
|
||||
propertyNames.Add(wordsInTemplate[i]);
|
||||
}
|
||||
|
||||
//Создание нужного объекта. Получение его типа для присваивание ему полученных ранее значений
|
||||
T curObject = new T();
|
||||
Type curType = curObject.GetType();
|
||||
|
||||
for (int i = 0; i < propertyNames.Count; i++)
|
||||
{
|
||||
//получение свойства объекта
|
||||
PropertyInfo propertyInfo = curType.GetProperty(propertyNames[i]);
|
||||
//получение значения свойства из списка полученных значений
|
||||
string curVal = values[i];
|
||||
propertyInfo.SetValue(curObject, Convert.ChangeType(curVal, propertyInfo.PropertyType));
|
||||
}
|
||||
|
||||
return curObject;
|
||||
}
|
||||
|
||||
//параметризованный метод заполнения списка, у которого в передаваемых параметрах идет список объектов некого класса
|
||||
public void Fill<T>(List<T> objects)
|
||||
{
|
||||
//если макетрная строка/пограничные символы не указаны
|
||||
if (templateLine == null || startSymbol == null || endSymbol == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//если в строке нет пограничных символов
|
||||
if (!templateLine.Contains(startSymbol) || !templateLine.Contains(endSymbol))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//каждый объект в переданном списке (каждая строчка в конечном списке)
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
//строка, которая будет отображаться в (сначала похожа на шаблон, потом заполняются значения)
|
||||
string str = templateLine;
|
||||
|
||||
//каждое св-во объекта (в 1 строчке)
|
||||
foreach (var prop in obj.GetType().GetProperties())
|
||||
{
|
||||
//как выглядит место, куда надо вставить значение в шаблонной строке (обозначенное начальным и конечным символом, названием свойства)
|
||||
string str1 = $"{startSymbol}" + $"{prop.Name}" + $"{endSymbol}";
|
||||
|
||||
//в шаблонной строке на помеченное место вставляем его значение
|
||||
str = str.Replace(str1, prop.GetValue(obj).ToString());
|
||||
}
|
||||
listBox.Items.Add(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Labs/ObjectsListBox.resx
Normal file
120
Labs/ObjectsListBox.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
36
Labs/WordBigText.Designer.cs
generated
Normal file
36
Labs/WordBigText.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace Labs
|
||||
{
|
||||
partial class WordBigText
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
107
Labs/WordBigText.cs
Normal file
107
Labs/WordBigText.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.ExtendedProperties;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using Labs.HelperClasses.WordBigText;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Labs
|
||||
{
|
||||
public partial class WordBigText : Component
|
||||
{
|
||||
private WordprocessingDocument? _wordDocument;
|
||||
|
||||
private Body? _docBody;
|
||||
|
||||
public WordBigText()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordBigText(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
public void CreateWord(WordBigTextConfig config)
|
||||
{
|
||||
if (string.IsNullOrEmpty(config.FilePath) || string.IsNullOrEmpty(config.DocumentTitle) || config.Paragraphs == null || config.Paragraphs.Length <= 0)
|
||||
{
|
||||
throw new ArgumentException("Не заполнены все параметры для создания");
|
||||
}
|
||||
// Создание пустого word файла
|
||||
_wordDocument = WordprocessingDocument.Create(config.FilePath, WordprocessingDocumentType.Document);
|
||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = new Document();
|
||||
_docBody = mainPart.Document.AppendChild(new Body());
|
||||
|
||||
//Создание заголовка
|
||||
|
||||
//Св-ва заголовка
|
||||
ParagraphProperties paragraphProperties = new ParagraphProperties();
|
||||
|
||||
//выравнивание по середине
|
||||
paragraphProperties.AppendChild(new Justification
|
||||
{
|
||||
Val = JustificationValues.Center
|
||||
});
|
||||
|
||||
Paragraph header = new Paragraph();
|
||||
header.AppendChild(paragraphProperties);
|
||||
|
||||
// Добавление текста заголовка
|
||||
Run run = new Run();
|
||||
|
||||
// Свойства абзаца (заголовка) через RunProperties
|
||||
RunProperties runProperties = new RunProperties();
|
||||
//сам шрифт в 2 раза меньше
|
||||
runProperties.AppendChild(new FontSize { Val = "48" });
|
||||
runProperties.AppendChild(new Bold());
|
||||
run.AppendChild(runProperties);
|
||||
|
||||
run.AppendChild(new Text(config.DocumentTitle));
|
||||
header.AppendChild(run);
|
||||
|
||||
// Заголовок в тело документа
|
||||
_docBody.AppendChild(header);
|
||||
|
||||
|
||||
// Добавление основного текста
|
||||
foreach (var par in config.Paragraphs)
|
||||
{
|
||||
ParagraphProperties paragraphProperties2 = new ParagraphProperties();
|
||||
// Выравнивание по ширине
|
||||
paragraphProperties2.AppendChild(new Justification
|
||||
{
|
||||
Val = JustificationValues.Both
|
||||
});
|
||||
|
||||
Paragraph paragraph = new Paragraph();
|
||||
paragraph.AppendChild(paragraphProperties2);
|
||||
|
||||
Run run2 = new Run();
|
||||
|
||||
// Свойства шрифта через RunProperties
|
||||
RunProperties runProperties2 = new RunProperties();
|
||||
//сам шрифт в 2 раза меньше
|
||||
runProperties2.AppendChild(new FontSize { Val = "32" });
|
||||
run2.AppendChild(runProperties2);
|
||||
|
||||
run2.AppendChild(new Text(par));
|
||||
paragraph.AppendChild(run2);
|
||||
_docBody.AppendChild(paragraph);
|
||||
}
|
||||
_wordDocument.Save();
|
||||
_wordDocument.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
36
Labs/WordLineChart.Designer.cs
generated
Normal file
36
Labs/WordLineChart.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace Labs
|
||||
{
|
||||
partial class WordLineChart
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
104
Labs/WordLineChart.cs
Normal file
104
Labs/WordLineChart.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using Aspose.Words;
|
||||
using Aspose.Words.Drawing.Charts;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using Labs.HelperClasses;
|
||||
using Labs.HelperClasses.WordLineChart;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Labs
|
||||
{
|
||||
public partial class WordLineChart : Component
|
||||
{
|
||||
public WordLineChart()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordLineChart(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateLineChart(WordLineChartConfig config)
|
||||
{
|
||||
// Проверка наличия заголовка, пути и названия диаграммы
|
||||
if (string.IsNullOrEmpty(config.LineChartTitle) || string.IsNullOrEmpty(config.FilePath) || string.IsNullOrEmpty(config.DocumentTitle))
|
||||
{
|
||||
throw new ArgumentException("Были переданы пустые параметры");
|
||||
}
|
||||
//Проверка, что данные не пустые
|
||||
foreach (var _data in config.Data)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_data.SeriaName) || string.IsNullOrEmpty(_data.Data.ToString()))
|
||||
{
|
||||
throw new ArgumentException("Были переданы пустые данные");
|
||||
}
|
||||
}
|
||||
|
||||
Document doc = new Document();
|
||||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||||
|
||||
//Стиль для заголовка док-а
|
||||
Style titleStyle = builder.Document.Styles.Add(StyleType.Paragraph, "Title");
|
||||
titleStyle.Font.Size = 16;
|
||||
titleStyle.Font.Bold = true;
|
||||
titleStyle.ParagraphFormat.SpaceAfter = 12;
|
||||
|
||||
// Добавление заголовка документа
|
||||
builder.ParagraphFormat.Style = titleStyle;
|
||||
builder.Writeln(config.DocumentTitle);
|
||||
|
||||
// Вставка диаграммы
|
||||
Aspose.Words.Drawing.Shape chartShape = builder.InsertChart(ChartType.Line, 500, 300);
|
||||
Chart chart = chartShape.Chart;
|
||||
|
||||
// Заголовок диаграммы
|
||||
chart.Title.Text = config.LineChartTitle;
|
||||
|
||||
//Расположение легенды
|
||||
switch (config.LegendLocation)
|
||||
{
|
||||
case LegendLocation.Left:
|
||||
//LegendPosition - класс Aspose
|
||||
chart.Legend.Position = LegendPosition.Left;
|
||||
break;
|
||||
case LegendLocation.Top:
|
||||
chart.Legend.Position = LegendPosition.Top;
|
||||
break;
|
||||
case LegendLocation.Right:
|
||||
chart.Legend.Position = LegendPosition.Right;
|
||||
break;
|
||||
case LegendLocation.Bottom:
|
||||
chart.Legend.Position = LegendPosition.Bottom;
|
||||
break;
|
||||
}
|
||||
|
||||
//chart.Legend.Position = (Aspose.Words.Drawing.Charts.LegendPosition)config.LegendLocation;
|
||||
|
||||
ChartSeriesCollection seriesColl = chart.Series;
|
||||
seriesColl.Clear();
|
||||
// Заполнение сериями и подписями снизу
|
||||
foreach (var diagramDatas in config.Data)
|
||||
{
|
||||
ChartSeries seria = seriesColl.Add(diagramDatas.SeriaName, config.Categories, diagramDatas.Data);
|
||||
|
||||
// Настройка маркера
|
||||
seria.Marker.Symbol = MarkerSymbol.Circle; // круг
|
||||
seria.Marker.Size = 4; // размер
|
||||
}
|
||||
|
||||
// Сохранение док-а
|
||||
doc.Save(config.FilePath);
|
||||
//Удаление вотермарки и текста от Aspose
|
||||
new Remover().Remove(config.FilePath);
|
||||
}
|
||||
}
|
||||
}
|
36
Labs/WordTable.Designer.cs
generated
Normal file
36
Labs/WordTable.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace Labs
|
||||
{
|
||||
partial class WordTable
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
202
Labs/WordTable.cs
Normal file
202
Labs/WordTable.cs
Normal file
@ -0,0 +1,202 @@
|
||||
using Aspose.Words;
|
||||
using Aspose.Words.Drawing;
|
||||
using Aspose.Words.Replacing;
|
||||
using Aspose.Words.Tables;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using Labs.HelperClasses;
|
||||
using Labs.HelperClasses.WordTable;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Labs
|
||||
{
|
||||
public partial class WordTable : Component
|
||||
{
|
||||
public WordTable()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordTable(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateWordTable<T>(WordTableConfig<T> config)
|
||||
{
|
||||
if (config == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//проверка на заполненность данных о столбцах (заголовок, хранящееся св-во, ширина)
|
||||
foreach (var colProp in config.ColumnsProperties)
|
||||
{
|
||||
if (colProp.Header1 == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(colProp.PropertyName))
|
||||
{
|
||||
throw new ArgumentException($"Не задано свойство для столбца");
|
||||
}
|
||||
if (colProp.Width <= 0)
|
||||
{
|
||||
throw new ArgumentException($"Неверная ширина для столбца");
|
||||
}
|
||||
}
|
||||
|
||||
//Проверка на то, что объединённые ячейки не пересекаются
|
||||
if (config.MergedCells.Count() >= 2)
|
||||
{
|
||||
var sortedCells = config.MergedCells.OrderBy(cell => cell.StartCell).ToList();
|
||||
for (int i = 1; i < sortedCells.Count; i++)
|
||||
{
|
||||
// если текущий StartCell меньше или равен предыдущему EndCell, то есть пересечение
|
||||
if (sortedCells[i].StartCell <= sortedCells[i - 1].EndCell)
|
||||
{
|
||||
throw new ArgumentException("Объединённые ячейки пересекаются");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Создание пустого word файла
|
||||
Document doc = new Document();
|
||||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||||
|
||||
builder.PageSetup.Orientation = Aspose.Words.Orientation.Landscape;
|
||||
|
||||
//стиль для заголовка
|
||||
Style titleStyle = builder.Document.Styles.Add(StyleType.Paragraph, "Title");
|
||||
titleStyle.Font.Size = 16;
|
||||
titleStyle.Font.Bold = true;
|
||||
titleStyle.ParagraphFormat.Alignment = ParagraphAlignment.Left;
|
||||
titleStyle.ParagraphFormat.SpaceAfter = 12;
|
||||
//titleStyle.ParagraphFormat.WordWrap = true;
|
||||
|
||||
//написание заголовка первой строкой
|
||||
builder.ParagraphFormat.Style = titleStyle;
|
||||
builder.Writeln(config.DocumentTitle);
|
||||
|
||||
#region СОЗДАНИЕ САМОЙ ТАБЛИЦЫ
|
||||
Table table = builder.StartTable();
|
||||
|
||||
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
|
||||
|
||||
#region ПЕРВАЯ СТРОКА ЗАГОЛОВКОВ
|
||||
//вставка ячеек 1-й строки шапки
|
||||
foreach (var colProp in config.ColumnsProperties)
|
||||
{
|
||||
builder.InsertCell();
|
||||
builder.CellFormat.Width = colProp.Width;
|
||||
builder.CellFormat.WrapText = true;
|
||||
//builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(colProp.Width);
|
||||
|
||||
//выравнивания
|
||||
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
|
||||
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
|
||||
// Устанавливаем стиль текста
|
||||
builder.Font.Size = 14; // Размер текста
|
||||
builder.Font.Bold = true; // Жирный текст
|
||||
//МБ Writeln
|
||||
builder.Write(colProp.Header1);
|
||||
}
|
||||
|
||||
|
||||
//объединение ячеек в 1 строке
|
||||
foreach (var mergedCell in config.MergedCells)
|
||||
{
|
||||
int startCellIndex = mergedCell.StartCell;
|
||||
int endCellIndex = mergedCell.EndCell;
|
||||
|
||||
//Начало объединения
|
||||
table.Rows[0].Cells[startCellIndex].CellFormat.HorizontalMerge = CellMerge.First;
|
||||
//Все след. ячейки объединяются последовательно с предыдущей
|
||||
for (int i = startCellIndex+1; i <= endCellIndex; i++)
|
||||
{
|
||||
table.Rows[0].Cells[i].CellFormat.HorizontalMerge = CellMerge.Previous;
|
||||
}
|
||||
}
|
||||
//переход на след. строку
|
||||
builder.EndRow();
|
||||
#endregion
|
||||
|
||||
#region ВТОРАЯ СТРОКА ЗАГОЛОВКОВ
|
||||
|
||||
int index = 0;
|
||||
//вставка ячеек 2-й строки шапки
|
||||
foreach (var colProp in config.ColumnsProperties)
|
||||
{
|
||||
builder.InsertCell();
|
||||
builder.CellFormat.Width = colProp.Width;
|
||||
//builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(colProp.Width);
|
||||
|
||||
//выравнивания
|
||||
//builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
|
||||
//builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
|
||||
|
||||
|
||||
//Если ячейка сверху не объединена по горизонтали (в 1 строке), объединить с ней
|
||||
if (table.Rows[0].Cells[index].CellFormat.HorizontalMerge == CellMerge.None)
|
||||
{
|
||||
table.Rows[0].Cells[index].CellFormat.VerticalMerge = CellMerge.First;
|
||||
table.Rows[1].Cells[index].CellFormat.VerticalMerge = CellMerge.Previous;
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.Write(colProp.Header2);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
//переход на след. строку
|
||||
builder.EndRow();
|
||||
builder.EndTable();
|
||||
#endregion
|
||||
|
||||
#region ОСНОВНАЯ ЧАСТЬ ТАБЛИЦЫ (С ДАННЫМИ)
|
||||
|
||||
table = builder.StartTable();
|
||||
builder.Font.Bold = false;
|
||||
//для каждой записи (1 объекта)
|
||||
foreach (var rowData in config.Data)
|
||||
{
|
||||
//для каждого столбца
|
||||
foreach (var colProp in config.ColumnsProperties)
|
||||
{
|
||||
//свойство класса, которое хранится в столбце
|
||||
builder.InsertCell();
|
||||
builder.CellFormat.Width = colProp.Width;
|
||||
builder.CellFormat.WrapText = true;
|
||||
var propertyValue = rowData.GetType()
|
||||
.GetProperty(colProp.PropertyName)?
|
||||
.GetValue(rowData)?.ToString();
|
||||
|
||||
builder.Write(propertyValue ?? "");
|
||||
}
|
||||
//переход на новую строку
|
||||
builder.EndRow();
|
||||
}
|
||||
builder.EndTable();
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
//сохранение док-а
|
||||
doc.Save(config.FilePath);
|
||||
|
||||
new Remover().Remove(config.FilePath);
|
||||
|
||||
}
|
||||
private void RemoveDrawings(IEnumerable<DocumentFormat.OpenXml.Wordprocessing.Drawing> drawings)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
23
OnlineShopContracts/BindingModels/OrderBindingModel.cs
Normal file
23
OnlineShopContracts/BindingModels/OrderBindingModel.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnlineShopContracts.BindingModels
|
||||
{
|
||||
public class OrderBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string FIO { get; set; }
|
||||
|
||||
//!!!МБ изменить на список строк
|
||||
public string Description { get; set; }
|
||||
|
||||
public string Status { get; set; }
|
||||
|
||||
public double? Sum { get; set; }
|
||||
}
|
||||
}
|
14
OnlineShopContracts/BindingModels/StatusBindingModel.cs
Normal file
14
OnlineShopContracts/BindingModels/StatusBindingModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnlineShopContracts.BindingModels
|
||||
{
|
||||
public class StatusBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
14
OnlineShopContracts/OnlineShopContracts.csproj
Normal file
14
OnlineShopContracts/OnlineShopContracts.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.17" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
28
OnlineShopContracts/ViewModels/OrderViewModel.cs
Normal file
28
OnlineShopContracts/ViewModels/OrderViewModel.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnlineShopContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel
|
||||
{
|
||||
[DisplayName("Идентификатор")]
|
||||
public int? Id { get; set; }
|
||||
|
||||
[DisplayName("ФИО заказчика")]
|
||||
public string FIO { get; set; }
|
||||
|
||||
//!!!МБ изменить на список строк
|
||||
[DisplayName("Описание товаров")]
|
||||
public string Description { get; set; }
|
||||
|
||||
[DisplayName("Статус заказа")]
|
||||
public string Status { get; set; }
|
||||
|
||||
[DisplayName("Сумма заказа")]
|
||||
public double? Sum { get; set; }
|
||||
}
|
||||
}
|
14
OnlineShopContracts/ViewModels/StatusViewModel.cs
Normal file
14
OnlineShopContracts/ViewModels/StatusViewModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnlineShopContracts.ViewModels
|
||||
{
|
||||
public class StatusViewModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
39
OnlineShopForms/FormMain.Designer.cs
generated
Normal file
39
OnlineShopForms/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
||||
namespace OnlineShopForms
|
||||
{
|
||||
partial class FormMain
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "FormMain";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
20
OnlineShopForms/FormMain.cs
Normal file
20
OnlineShopForms/FormMain.cs
Normal file
@ -0,0 +1,20 @@
|
||||
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 OnlineShopForms
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
public FormMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
120
OnlineShopForms/FormMain.resx
Normal file
120
OnlineShopForms/FormMain.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
65
OnlineShopForms/FormStatuses.Designer.cs
generated
Normal file
65
OnlineShopForms/FormStatuses.Designer.cs
generated
Normal file
@ -0,0 +1,65 @@
|
||||
namespace OnlineShopForms
|
||||
{
|
||||
partial class FormStatuses
|
||||
{
|
||||
/// <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.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Fill;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.Size = new Size(250, 450);
|
||||
dataGridView.TabIndex = 0;
|
||||
dataGridView.CellEndEdit += dataGridView_CellEndEdit;
|
||||
dataGridView.KeyDown += dataGridView_KeyDown;
|
||||
//
|
||||
// FormStatuses
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(250, 450);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormStatuses";
|
||||
Text = "FormStatuses";
|
||||
Load += FormStatuses_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
119
OnlineShopForms/FormStatuses.cs
Normal file
119
OnlineShopForms/FormStatuses.cs
Normal file
@ -0,0 +1,119 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using OnlineShopContracts.BindingModels;
|
||||
using OnlineShopContracts.ViewModels;
|
||||
using OnlineShopDatabase.Storages;
|
||||
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 OnlineShopForms
|
||||
{
|
||||
public partial class FormStatuses : Form
|
||||
{
|
||||
private readonly StatusStorage _storage;
|
||||
List<StatusViewModel> list;
|
||||
|
||||
public FormStatuses()
|
||||
{
|
||||
InitializeComponent();
|
||||
_storage = new StatusStorage();
|
||||
}
|
||||
|
||||
private void FormStatuses_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
list = _storage.GetFullList();
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyData == Keys.Insert)
|
||||
{
|
||||
list.Add(new StatusViewModel());
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.CurrentCell = dataGridView.Rows[dataGridView.Rows.Count - 1].Cells[1];
|
||||
}
|
||||
else if (e.KeyData == Keys.Delete)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
if (!_storage.Delete(new StatusBindingModel() { Id = id }))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении");
|
||||
}
|
||||
|
||||
dataGridView.Rows.RemoveAt(dataGridView.SelectedRows[0].Index);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//конец редактирования названия статуса (ячейки)
|
||||
private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
//то, что введено в ячейке
|
||||
string statusName = (string)dataGridView.CurrentRow.Cells[1].Value;
|
||||
|
||||
//если в ячейке есть текст (строка непустая)
|
||||
if (!string.IsNullOrEmpty(statusName))
|
||||
{
|
||||
//если есть id, то надо обновить
|
||||
if (dataGridView.CurrentRow.Cells[0].Value != null)
|
||||
{
|
||||
_storage.Update(new StatusBindingModel()
|
||||
{
|
||||
Name = (string)dataGridView.CurrentRow.Cells[1].EditedFormattedValue
|
||||
});
|
||||
}
|
||||
//если нет id, значит надо создать запись
|
||||
else
|
||||
{
|
||||
_storage.Insert(new StatusBindingModel()
|
||||
{
|
||||
Name = (string)dataGridView.CurrentRow.Cells[1].EditedFormattedValue
|
||||
});
|
||||
}
|
||||
}
|
||||
//если строка пустая
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Введена пустая строка", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
OnlineShopForms/FormStatuses.resx
Normal file
120
OnlineShopForms/FormStatuses.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
14
OnlineShopForms/OnlineShopForms.csproj
Normal file
14
OnlineShopForms/OnlineShopForms.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OnlineStoreDatabase\OnlineShopDatabase.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
76
OnlineStoreDatabase/Migrations/20241101095226_InitialCreate.Designer.cs
generated
Normal file
76
OnlineStoreDatabase/Migrations/20241101095226_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,76 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using OnlineShopDatabase;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace OnlineShopDatabase.Migrations
|
||||
{
|
||||
[DbContext(typeof(OnlineShopDatabase))]
|
||||
[Migration("20241101095226_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.17")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("OnlineShopDatabase.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double?>("Sum")
|
||||
.IsRequired()
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OnlineShopDatabase.Models.Status", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Statuses");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace OnlineShopDatabase.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
FIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Status = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Sum = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Statuses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Statuses", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Statuses");
|
||||
}
|
||||
}
|
||||
}
|
75
OnlineStoreDatabase/Migrations/20241101095556_SumNull.Designer.cs
generated
Normal file
75
OnlineStoreDatabase/Migrations/20241101095556_SumNull.Designer.cs
generated
Normal file
@ -0,0 +1,75 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using OnlineShopDatabase;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace OnlineShopDatabase.Migrations
|
||||
{
|
||||
[DbContext(typeof(OnlineShopDatabase))]
|
||||
[Migration("20241101095556_SumNull")]
|
||||
partial class SumNull
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.17")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("OnlineShopDatabase.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double?>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OnlineShopDatabase.Models.Status", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Statuses");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
36
OnlineStoreDatabase/Migrations/20241101095556_SumNull.cs
Normal file
36
OnlineStoreDatabase/Migrations/20241101095556_SumNull.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace OnlineShopDatabase.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class SumNull : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<double>(
|
||||
name: "Sum",
|
||||
table: "Orders",
|
||||
type: "float",
|
||||
nullable: true,
|
||||
oldClrType: typeof(double),
|
||||
oldType: "float");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<double>(
|
||||
name: "Sum",
|
||||
table: "Orders",
|
||||
type: "float",
|
||||
nullable: false,
|
||||
defaultValue: 0.0,
|
||||
oldClrType: typeof(double),
|
||||
oldType: "float",
|
||||
oldNullable: true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using OnlineShopDatabase;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace OnlineShopDatabase.Migrations
|
||||
{
|
||||
[DbContext(typeof(OnlineShopDatabase))]
|
||||
partial class OnlineShopDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.17")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("OnlineShopDatabase.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double?>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("OnlineShopDatabase.Models.Status", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Statuses");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
64
OnlineStoreDatabase/Models/Order.cs
Normal file
64
OnlineStoreDatabase/Models/Order.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using OnlineShopContracts.BindingModels;
|
||||
using OnlineShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnlineShopDatabase.Models
|
||||
{
|
||||
public class Order
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string FIO { get; set; }
|
||||
|
||||
//!!!МБ изменить на список строк
|
||||
[Required]
|
||||
public string Description { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Status { get; set; }
|
||||
|
||||
public double? Sum { get; set; }
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
FIO = FIO,
|
||||
Description = Description,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
};
|
||||
public static Order? Create(OrderBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Order()
|
||||
{
|
||||
Id = model.Id.Value,
|
||||
FIO = model.FIO,
|
||||
Description = model.Description,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FIO = model.FIO;
|
||||
Description = model.Description;
|
||||
Sum = model.Sum;
|
||||
Status = model.Status;
|
||||
}
|
||||
}
|
||||
}
|
48
OnlineStoreDatabase/Models/Status.cs
Normal file
48
OnlineStoreDatabase/Models/Status.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using OnlineShopContracts.BindingModels;
|
||||
using OnlineShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnlineShopDatabase.Models
|
||||
{
|
||||
public class Status
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
public StatusViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
};
|
||||
|
||||
public static Status? Create(StatusBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Status()
|
||||
{
|
||||
Id = model.Id.Value,
|
||||
Name = model.Name
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(StatusBindingModel model)
|
||||
{
|
||||
if (model == null || string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Name = model.Name;
|
||||
}
|
||||
}
|
||||
}
|
22
OnlineStoreDatabase/OnlineShopDatabase.cs
Normal file
22
OnlineStoreDatabase/OnlineShopDatabase.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OnlineShopDatabase.Models;
|
||||
|
||||
namespace OnlineShopDatabase
|
||||
{
|
||||
public class OnlineShopDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-1I7RVNF\SQLEXPRESS;Initial Catalog=OnlineShopDatabase;Integrated Security=True;MultipleActiveResultSets=True; TrustServerCertificate=True");
|
||||
}
|
||||
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
|
||||
public virtual DbSet<Status> Statuses { set; get; }
|
||||
}
|
||||
}
|
20
OnlineStoreDatabase/OnlineShopDatabase.csproj
Normal file
20
OnlineStoreDatabase/OnlineShopDatabase.csproj
Normal file
@ -0,0 +1,20 @@
|
||||
<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.17" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.17" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.17" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OnlineShopContracts\OnlineShopContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
134
OnlineStoreDatabase/Storages/OrderStorage.cs
Normal file
134
OnlineStoreDatabase/Storages/OrderStorage.cs
Normal file
@ -0,0 +1,134 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OnlineShopContracts.BindingModels;
|
||||
using OnlineShopContracts.ViewModels;
|
||||
using OnlineShopDatabase.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace OnlineShopDatabase.Storages
|
||||
{
|
||||
public class OrderStorage
|
||||
{
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new OnlineShopDatabase();
|
||||
return context.Orders.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderBindingModel model)
|
||||
{
|
||||
using var context = new OnlineShopDatabase();
|
||||
//либо поиск по ФИО заказчика
|
||||
if (!string.IsNullOrEmpty(model.FIO))
|
||||
{
|
||||
return context.Orders
|
||||
.Where(x => x.FIO == model.FIO)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
//либо по статусу заказа
|
||||
else if (!string.IsNullOrEmpty(model.Status))
|
||||
{
|
||||
return context.Orders
|
||||
.Where(x => x.Status == model.Status)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
//либо по стоимости
|
||||
else if (model.Sum.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Where(x => x.Sum == model.Sum)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
||||
//получение по id заказа
|
||||
public OrderViewModel? GetElement(OrderBindingModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new OnlineShopDatabase();
|
||||
return context.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public bool Insert(OrderBindingModel model)
|
||||
{
|
||||
var newOrder = Order.Create(model);
|
||||
|
||||
if (newOrder == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
using var context = new OnlineShopDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
transaction.Rollback();
|
||||
return false;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Update(OrderBindingModel model)
|
||||
{
|
||||
using var context = new OnlineShopDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
throw new Exception("Заказ не найден");
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new OnlineShopDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var order = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
throw new Exception("Заказ не найден");
|
||||
}
|
||||
context.Orders.Remove(order);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
115
OnlineStoreDatabase/Storages/StatusStorage.cs
Normal file
115
OnlineStoreDatabase/Storages/StatusStorage.cs
Normal file
@ -0,0 +1,115 @@
|
||||
using OnlineShopContracts.BindingModels;
|
||||
using OnlineShopContracts.ViewModels;
|
||||
using OnlineShopDatabase.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnlineShopDatabase.Storages
|
||||
{
|
||||
public class StatusStorage
|
||||
{
|
||||
public List<StatusViewModel> GetFullList()
|
||||
{
|
||||
using var context = new OnlineShopDatabase();
|
||||
return context.Statuses.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public List<StatusViewModel> GetFilteredList(StatusBindingModel model)
|
||||
{
|
||||
using var context = new OnlineShopDatabase();
|
||||
//поиск по названию статуса
|
||||
if (!string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return context.Statuses
|
||||
.Where(x => x.Name == model.Name)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
||||
//получение по id статуса
|
||||
public StatusViewModel? GetElement(StatusBindingModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new OnlineShopDatabase();
|
||||
return context.Statuses.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public bool Insert(StatusBindingModel model)
|
||||
{
|
||||
var newStatus = Status.Create(model);
|
||||
|
||||
if (newStatus == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
using var context = new OnlineShopDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
context.Statuses.Add(newStatus);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
transaction.Rollback();
|
||||
return false;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Update(StatusBindingModel model)
|
||||
{
|
||||
using var context = new OnlineShopDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var status = context.Statuses.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (status == null)
|
||||
{
|
||||
throw new Exception("Статус не найден");
|
||||
}
|
||||
status.Update(model);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Delete(StatusBindingModel model)
|
||||
{
|
||||
using var context = new OnlineShopDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var status = context.Statuses.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (status == null)
|
||||
{
|
||||
throw new Exception("Статус не найден");
|
||||
}
|
||||
context.Statuses.Remove(status);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
211
Test App/Form1.Designer.cs
generated
Normal file
211
Test App/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,211 @@
|
||||
namespace Test_App
|
||||
{
|
||||
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()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
dropDownList = new Labs.DropDownList();
|
||||
mailTextBox = new Labs.MailTextBox();
|
||||
buttonClear = new Button();
|
||||
buttonSelected = new Button();
|
||||
label1 = new Label();
|
||||
buttonCheck = new Button();
|
||||
buttonHint = new Button();
|
||||
textBoxHint = new TextBox();
|
||||
buttonFill = new Button();
|
||||
buttonGetObject = new Button();
|
||||
objectsListBox = new Labs.ObjectsListBox();
|
||||
labelWorker = new Label();
|
||||
buttonList = new Button();
|
||||
wordBigText1 = new Labs.WordBigText(components);
|
||||
SuspendLayout();
|
||||
//
|
||||
// dropDownList
|
||||
//
|
||||
dropDownList.AutoSize = true;
|
||||
dropDownList.Location = new Point(12, 12);
|
||||
dropDownList.Name = "dropDownList";
|
||||
dropDownList.SelectedLine = "";
|
||||
dropDownList.Size = new Size(306, 46);
|
||||
dropDownList.TabIndex = 0;
|
||||
//
|
||||
// mailTextBox
|
||||
//
|
||||
mailTextBox.AutoSize = true;
|
||||
mailTextBox.Location = new Point(2, 179);
|
||||
mailTextBox.Name = "mailTextBox";
|
||||
mailTextBox.Size = new Size(316, 38);
|
||||
mailTextBox.TabIndex = 1;
|
||||
mailTextBox.Template = null;
|
||||
//
|
||||
// buttonClear
|
||||
//
|
||||
buttonClear.Location = new Point(11, 100);
|
||||
buttonClear.Name = "buttonClear";
|
||||
buttonClear.Size = new Size(94, 29);
|
||||
buttonClear.TabIndex = 3;
|
||||
buttonClear.Text = "Очистить";
|
||||
buttonClear.UseVisualStyleBackColor = true;
|
||||
buttonClear.Click += buttonClear_Click;
|
||||
//
|
||||
// buttonSelected
|
||||
//
|
||||
buttonSelected.Location = new Point(112, 83);
|
||||
buttonSelected.Name = "buttonSelected";
|
||||
buttonSelected.Size = new Size(179, 29);
|
||||
buttonSelected.TabIndex = 4;
|
||||
buttonSelected.Text = "Выбранный элемент:";
|
||||
buttonSelected.UseVisualStyleBackColor = true;
|
||||
buttonSelected.Click += buttonSelected_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(297, 87);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(154, 20);
|
||||
label1.TabIndex = 5;
|
||||
label1.Text = "Выбранный элемент";
|
||||
//
|
||||
// buttonCheck
|
||||
//
|
||||
buttonCheck.Location = new Point(46, 223);
|
||||
buttonCheck.Name = "buttonCheck";
|
||||
buttonCheck.Size = new Size(154, 29);
|
||||
buttonCheck.TabIndex = 6;
|
||||
buttonCheck.Text = "Проверить почту";
|
||||
buttonCheck.UseVisualStyleBackColor = true;
|
||||
buttonCheck.Click += buttonCheck_Click;
|
||||
//
|
||||
// buttonHint
|
||||
//
|
||||
buttonHint.Location = new Point(47, 313);
|
||||
buttonHint.Name = "buttonHint";
|
||||
buttonHint.Size = new Size(154, 51);
|
||||
buttonHint.TabIndex = 7;
|
||||
buttonHint.Text = "Задать подсказку для почты";
|
||||
buttonHint.UseVisualStyleBackColor = true;
|
||||
buttonHint.Click += buttonHint_Click;
|
||||
//
|
||||
// textBoxHint
|
||||
//
|
||||
textBoxHint.Location = new Point(33, 280);
|
||||
textBoxHint.Name = "textBoxHint";
|
||||
textBoxHint.Size = new Size(188, 27);
|
||||
textBoxHint.TabIndex = 8;
|
||||
//
|
||||
// buttonFill
|
||||
//
|
||||
buttonFill.Location = new Point(701, 255);
|
||||
buttonFill.Name = "buttonFill";
|
||||
buttonFill.Size = new Size(94, 29);
|
||||
buttonFill.TabIndex = 9;
|
||||
buttonFill.Text = "Заполнить";
|
||||
buttonFill.UseVisualStyleBackColor = true;
|
||||
buttonFill.Click += buttonFill_Click;
|
||||
//
|
||||
// buttonGetObject
|
||||
//
|
||||
buttonGetObject.Location = new Point(663, 329);
|
||||
buttonGetObject.Name = "buttonGetObject";
|
||||
buttonGetObject.Size = new Size(175, 29);
|
||||
buttonGetObject.TabIndex = 10;
|
||||
buttonGetObject.Text = "Получить сотрудника:";
|
||||
buttonGetObject.UseVisualStyleBackColor = true;
|
||||
buttonGetObject.Click += buttonGetObject_Click;
|
||||
//
|
||||
// objectsListBox
|
||||
//
|
||||
objectsListBox.AutoSize = true;
|
||||
objectsListBox.Location = new Point(466, 12);
|
||||
objectsListBox.Name = "objectsListBox";
|
||||
objectsListBox.SelectedIndex = -1;
|
||||
objectsListBox.Size = new Size(597, 237);
|
||||
objectsListBox.TabIndex = 11;
|
||||
//
|
||||
// labelWorker
|
||||
//
|
||||
labelWorker.AutoSize = true;
|
||||
labelWorker.Location = new Point(663, 378);
|
||||
labelWorker.Name = "labelWorker";
|
||||
labelWorker.Size = new Size(168, 20);
|
||||
labelWorker.TabIndex = 12;
|
||||
labelWorker.Text = "Выбранный сотрудник";
|
||||
//
|
||||
// buttonList
|
||||
//
|
||||
buttonList.Location = new Point(12, 64);
|
||||
buttonList.Name = "buttonList";
|
||||
buttonList.Size = new Size(94, 29);
|
||||
buttonList.TabIndex = 13;
|
||||
buttonList.Text = "Заполнить";
|
||||
buttonList.UseVisualStyleBackColor = true;
|
||||
buttonList.Click += buttonList_Click;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1075, 620);
|
||||
Controls.Add(buttonList);
|
||||
Controls.Add(labelWorker);
|
||||
Controls.Add(objectsListBox);
|
||||
Controls.Add(buttonGetObject);
|
||||
Controls.Add(buttonFill);
|
||||
Controls.Add(textBoxHint);
|
||||
Controls.Add(buttonHint);
|
||||
Controls.Add(buttonCheck);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonSelected);
|
||||
Controls.Add(buttonClear);
|
||||
Controls.Add(mailTextBox);
|
||||
Controls.Add(dropDownList);
|
||||
Name = "Form1";
|
||||
Text = "Form1";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Labs.DropDownList dropDownList;
|
||||
private Labs.MailTextBox mailTextBox;
|
||||
private Button buttonClear;
|
||||
private Button buttonSelected;
|
||||
private Label label1;
|
||||
private Button buttonCheck;
|
||||
private Button buttonHint;
|
||||
private TextBox textBoxHint;
|
||||
private Button buttonFill;
|
||||
private Button buttonGetObject;
|
||||
private Labs.ObjectsListBox objectsListBox;
|
||||
private Label labelWorker;
|
||||
private Button buttonList;
|
||||
private Labs.WordBigText wordBigText1;
|
||||
}
|
||||
}
|
89
Test App/Form1.cs
Normal file
89
Test App/Form1.cs
Normal file
@ -0,0 +1,89 @@
|
||||
namespace Test_App
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
//ñïèñîê ëÿ êîìïîíåíòà 1
|
||||
List<string> list;
|
||||
|
||||
//ñïèñîê äëÿ êîìïîíåíòà 3
|
||||
List<TestClass> list2;
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
list = new List<string>() { "Çíà÷åíèå 1", "Çíà÷åíèå 2", "Çíà÷åíèå 3", "Çíà÷åíèå 4", "Çíà÷åíèå 5" };
|
||||
|
||||
dropDownList.LineChanged += dropDownList_LineChanged;
|
||||
//ðåãóëÿðêà (øàáëîí äëÿ ïîëÿ ââîäà)
|
||||
|
||||
|
||||
//äëÿ 3-ãî êîìïîíåíòà
|
||||
TestClass worker1 = new TestClass("×åðíûøåâ ßí Àëåêñàíäðîâè÷", 15, "Äåïàðòàìåíò 1");
|
||||
TestClass worker2 = new TestClass("Çàìÿòèí Åâãåíèé Èâàíîâè÷", 7, "Äåïàðòàìåíò 2");
|
||||
TestClass worker3 = new TestClass("Òîëñòîé Ëåâ Íèêîëàåâè÷", 1, "Äåïàðòàìåíò 3");
|
||||
|
||||
list2 = new List<TestClass>() { worker1, worker2, worker3 };
|
||||
|
||||
|
||||
objectsListBox.SetTemplateInfo("<FIO>; ðàáîòàåò <workExperience>, ëåò â <department>", '<', '>');
|
||||
//objectsListBox.SetTemplateInfo("Ñåãîäíÿ ìû èãðàåì c <FIO>: â <workExperience>, ñáîð â <department>", '<', '>');
|
||||
}
|
||||
|
||||
private void dropDownList_LineChanged(object sender, EventArgs e)
|
||||
{
|
||||
label1.Text = dropDownList.SelectedLine;
|
||||
}
|
||||
|
||||
private void buttonClear_Click(object sender, EventArgs e)
|
||||
{
|
||||
dropDownList.Clear();
|
||||
}
|
||||
|
||||
private void buttonSelected_Click(object sender, EventArgs e)
|
||||
{
|
||||
label1.Text = dropDownList.SelectedLine;
|
||||
}
|
||||
|
||||
private void buttonCheck_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
MessageBox.Show(mailTextBox.TextValue + " ïîäõîäèò");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonHint_Click(object sender, EventArgs e)
|
||||
{
|
||||
mailTextBox.setExample(textBoxHint.Text);
|
||||
}
|
||||
|
||||
private void buttonFill_Click(object sender, EventArgs e)
|
||||
{
|
||||
objectsListBox.Fill(list2);
|
||||
}
|
||||
|
||||
private void buttonGetObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (objectsListBox.SelectedIndex == -1)
|
||||
{
|
||||
MessageBox.Show("Âûáåðèòå ñîòðóäíèêà");
|
||||
}
|
||||
else
|
||||
{
|
||||
var worker = objectsListBox.GetObjectFromLine<TestClass>();
|
||||
string workerStr = worker.FIO + "\n" + worker.workExperience.ToString() + "\n" + worker.department;
|
||||
labelWorker.Text = workerStr;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonList_Click(object sender, EventArgs e)
|
||||
{
|
||||
dropDownList.Fill(list);
|
||||
dropDownList.SelectedLine = "Çíà÷åíèå 4";
|
||||
}
|
||||
}
|
||||
}
|
123
Test App/Form1.resx
Normal file
123
Test App/Form1.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="wordBigText1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
92
Test App/FormWord.Designer.cs
generated
Normal file
92
Test App/FormWord.Designer.cs
generated
Normal file
@ -0,0 +1,92 @@
|
||||
namespace Test_App
|
||||
{
|
||||
partial class FormWord
|
||||
{
|
||||
/// <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();
|
||||
buttonBigText = new Button();
|
||||
wordBigText = new Labs.WordBigText(components);
|
||||
buttonTable = new Button();
|
||||
wordTable = new Labs.WordTable(components);
|
||||
wordLineChart = new Labs.WordLineChart(components);
|
||||
buttonLineChart = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonBigText
|
||||
//
|
||||
buttonBigText.Location = new Point(26, 37);
|
||||
buttonBigText.Name = "buttonBigText";
|
||||
buttonBigText.Size = new Size(144, 69);
|
||||
buttonBigText.TabIndex = 0;
|
||||
buttonBigText.Text = "Документ с большим текстом";
|
||||
buttonBigText.UseVisualStyleBackColor = true;
|
||||
buttonBigText.Click += buttonBigText_Click;
|
||||
//
|
||||
// buttonTable
|
||||
//
|
||||
buttonTable.Location = new Point(176, 37);
|
||||
buttonTable.Name = "buttonTable";
|
||||
buttonTable.Size = new Size(147, 69);
|
||||
buttonTable.TabIndex = 1;
|
||||
buttonTable.Text = "Документ с таблицей";
|
||||
buttonTable.UseVisualStyleBackColor = true;
|
||||
buttonTable.Click += buttonTable_Click;
|
||||
//
|
||||
// buttonLineChart
|
||||
//
|
||||
buttonLineChart.Location = new Point(329, 37);
|
||||
buttonLineChart.Name = "buttonLineChart";
|
||||
buttonLineChart.Size = new Size(147, 69);
|
||||
buttonLineChart.TabIndex = 2;
|
||||
buttonLineChart.Text = "Документ с линейной диаграммой";
|
||||
buttonLineChart.UseVisualStyleBackColor = true;
|
||||
buttonLineChart.Click += buttonLineChart_Click;
|
||||
//
|
||||
// FormWord
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(501, 153);
|
||||
Controls.Add(buttonLineChart);
|
||||
Controls.Add(buttonTable);
|
||||
Controls.Add(buttonBigText);
|
||||
Name = "FormWord";
|
||||
Text = "FormWord";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonBigText;
|
||||
private Labs.WordBigText wordBigText;
|
||||
private Button buttonTable;
|
||||
private Labs.WordTable wordTable;
|
||||
private Labs.WordLineChart wordLineChart;
|
||||
private Button buttonLineChart;
|
||||
}
|
||||
}
|
135
Test App/FormWord.cs
Normal file
135
Test App/FormWord.cs
Normal file
@ -0,0 +1,135 @@
|
||||
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||
using Labs;
|
||||
using Labs.HelperClasses.WordBigText;
|
||||
using Labs.HelperClasses.WordLineChart;
|
||||
using Labs.HelperClasses.WordTable;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
|
||||
|
||||
namespace Test_App
|
||||
{
|
||||
public partial class FormWord : Form
|
||||
{
|
||||
private string[] bigText = { "Проведите местных радиоведущих По и Манро через шесть похожих на короткометражки эпизодов сверъестественной странности и обжигающего сюжета", "Вы окажетесь в эпицентре лондонского ограбления и выберете своё приключение в интерактивном кинофильме с меняющейся историей, ведущей к одной из семи концовок.", "Вы решаете судьбу Ника, актера-неудачника, который борется за судьбоносный денежный приз" };
|
||||
|
||||
#region ДАННЫЕ ДЛЯ ТАБЛИЦЫ
|
||||
//Объединённые ячейки
|
||||
List<CellMergeInfo> mergedCells = new List<CellMergeInfo>
|
||||
{
|
||||
new CellMergeInfo(1, 3),
|
||||
new CellMergeInfo(5, 6)
|
||||
};
|
||||
|
||||
//Сами данные
|
||||
List<TestClass2> tableData = new List<TestClass2>
|
||||
{
|
||||
new TestClass2(1, "Ян", "Чернышев", 49, true, "Департамент 1", "Руководитель"),
|
||||
new TestClass2(2, "Евгений", "Замятин", 71, false, "Департамент 2", "Писатель"),
|
||||
new TestClass2(3, "Клеменс", "Кёринг", 37, false, "Департамент 3", "Актёр озвучки")
|
||||
};
|
||||
|
||||
//Настройки столбцов
|
||||
List<ColumnProperties> colProps = new List<ColumnProperties>{
|
||||
new ColumnProperties("Id", 10, "Id"),
|
||||
new ColumnProperties("FirstName", 25, "Личные данные", "Имя"),
|
||||
new ColumnProperties("LastName", 35, "Личные данные", "Фамилия"),
|
||||
new ColumnProperties("Age", 10, "Личные данные", "Возраст"),
|
||||
new ColumnProperties("HasCar", 10, "Машина"),
|
||||
new ColumnProperties("Department", 20, "Работа", "Подразделение"),
|
||||
new ColumnProperties("Post", 20, "Работа", "Должность")
|
||||
};
|
||||
#endregion
|
||||
|
||||
#region ДАННЫЕ ДЛЯ ДИАГРАММЫ
|
||||
//2, 16, 30 сентября
|
||||
double[] data1 = { 132, 550, 550 }; //Late Shift
|
||||
double[] data2 = { 295, 295, 590 }; //Ten Dates
|
||||
double[] data3 = { 74, 287, 287 }; //She Sees Red
|
||||
|
||||
|
||||
#endregion
|
||||
public FormWord()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
private void buttonBigText_Click(object sender, EventArgs e)
|
||||
{
|
||||
var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "docx|*.docx"
|
||||
};
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
WordBigTextConfig config = new(dialog.FileName, "Описание игр из steam", bigText);
|
||||
wordBigText.CreateWord(config);
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonTable_Click(object sender, EventArgs e)
|
||||
{
|
||||
var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "docx|*.docx"
|
||||
};
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
WordTableConfig<TestClass2> config = new(dialog.FileName, "Таблица ворд", colProps, mergedCells, tableData);
|
||||
wordTable.CreateWordTable(config);
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void buttonLineChart_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "docx|*.docx"
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
WordLineChartConfig chart = new WordLineChartConfig(dialog.FileName, "Цена FMV игр в Steam", "Данные за сентябрь", LegendLocation.Bottom, new List<LineChartSeria> {
|
||||
new LineChartSeria("Late Shift", data1),
|
||||
new LineChartSeria("Ten Dates", data2),
|
||||
new LineChartSeria("She Sees Red", data3)
|
||||
},
|
||||
new string[] { "2.09.24", "16.09.24", "30.09.24" });
|
||||
wordLineChart.CreateLineChart(chart);
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
129
Test App/FormWord.resx
Normal file
129
Test App/FormWord.resx
Normal file
@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="wordBigText.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>156, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordLineChart.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>281, 17</value>
|
||||
</metadata>
|
||||
</root>
|
18
Test App/Program.cs
Normal file
18
Test App/Program.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace Test_App
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
//Application.Run(new Form1());
|
||||
Application.Run(new FormWord());
|
||||
}
|
||||
}
|
||||
}
|
34
Test App/Test App.csproj
Normal file
34
Test App/Test App.csproj
Normal file
@ -0,0 +1,34 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<RootNamespace>Test_App</RootNamespace>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspose.Words" Version="23.12.0" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.17" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.17" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.17">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.17" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.17">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Labs\ChernyshevComponents.csproj" />
|
||||
<ProjectReference Include="..\OnlineStoreDatabase\OnlineShopDatabase.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
25
Test App/TestClass.cs
Normal file
25
Test App/TestClass.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Test_App
|
||||
{
|
||||
public class TestClass
|
||||
{
|
||||
public string FIO { get; set; }
|
||||
|
||||
public int workExperience { get; set; }
|
||||
|
||||
public string department { get; set; }
|
||||
|
||||
public TestClass() { }
|
||||
public TestClass(string FIO, int workExperience, string department)
|
||||
{
|
||||
this.FIO = FIO;
|
||||
this.workExperience = workExperience;
|
||||
this.department = department;
|
||||
}
|
||||
}
|
||||
}
|
36
Test App/TestClass2.cs
Normal file
36
Test App/TestClass2.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Test_App
|
||||
{
|
||||
public class TestClass2
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
//имя
|
||||
public string FirstName { get; private set; }
|
||||
//фамилия
|
||||
public string LastName { get; private set; }
|
||||
//возраст
|
||||
public int Age { get; private set; }
|
||||
//есть ли машина
|
||||
public bool HasCar { get; private set; }
|
||||
//подразделение
|
||||
public string Department { get; private set; }
|
||||
//должность
|
||||
public string Post { get; private set; }
|
||||
|
||||
public TestClass2(int id, string firstName, string lastName, int age, bool hasCar, string department, string post)
|
||||
{
|
||||
Id = id;
|
||||
FirstName = firstName;
|
||||
LastName = lastName;
|
||||
Age = age;
|
||||
HasCar = hasCar;
|
||||
Department = department;
|
||||
Post = post;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user