Вроде готова
This commit is contained in:
parent
1719292030
commit
e3da66cd20
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0-windows</TargetFramework>
|
<TargetFramework>net8.0-windows7.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
@ -24,7 +24,7 @@ namespace ComponentProgramming.Components
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateDocument(string docPath, string title, string[] rows)
|
public void CreateDocument(string docPath, string title, List<string> rows)
|
||||||
{
|
{
|
||||||
if(string.IsNullOrEmpty(docPath))
|
if(string.IsNullOrEmpty(docPath))
|
||||||
{
|
{
|
||||||
@ -34,7 +34,7 @@ namespace ComponentProgramming.Components
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("Введите заголовок");
|
throw new ArgumentNullException("Введите заголовок");
|
||||||
}
|
}
|
||||||
if(rows.Length <= 0)
|
if(rows.Count <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нету данных для сохранения");
|
throw new ArgumentNullException("Нету данных для сохранения");
|
||||||
}
|
}
|
||||||
|
71
ComponentProgramming/ComponentProgramming/Control/DateBoxWithNull.Designer.cs
generated
Normal file
71
ComponentProgramming/ComponentProgramming/Control/DateBoxWithNull.Designer.cs
generated
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
namespace ComponentProgramming.Control
|
||||||
|
{
|
||||||
|
partial class DateBoxWithNull
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
checkBoxNull = new CheckBox();
|
||||||
|
textBoxDate = new TextBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// checkBoxNull
|
||||||
|
//
|
||||||
|
checkBoxNull.AutoSize = true;
|
||||||
|
checkBoxNull.Location = new Point(3, 6);
|
||||||
|
checkBoxNull.Name = "checkBoxNull";
|
||||||
|
checkBoxNull.Size = new Size(15, 14);
|
||||||
|
checkBoxNull.TabIndex = 0;
|
||||||
|
checkBoxNull.UseVisualStyleBackColor = true;
|
||||||
|
checkBoxNull.CheckedChanged += CheckBoxNull_CheckedChanged;
|
||||||
|
//
|
||||||
|
// textBoxDate
|
||||||
|
//
|
||||||
|
textBoxDate.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
textBoxDate.Location = new Point(24, 3);
|
||||||
|
textBoxDate.Name = "textBoxDate";
|
||||||
|
textBoxDate.Size = new Size(100, 23);
|
||||||
|
textBoxDate.TabIndex = 1;
|
||||||
|
textBoxDate.TextChanged += TextBoxDate_TextChanged;
|
||||||
|
//
|
||||||
|
// DateBoxWithNull
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
Controls.Add(textBoxDate);
|
||||||
|
Controls.Add(checkBoxNull);
|
||||||
|
Name = "DateBoxWithNull";
|
||||||
|
Size = new Size(129, 30);
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private CheckBox checkBoxNull;
|
||||||
|
private TextBox textBoxDate;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Windows.Forms.VisualStyles;
|
||||||
|
|
||||||
|
namespace ComponentProgramming.Control
|
||||||
|
{
|
||||||
|
public partial class DateBoxWithNull : UserControl
|
||||||
|
{
|
||||||
|
public event EventHandler? CombEvent;
|
||||||
|
|
||||||
|
public Exception? Error;
|
||||||
|
|
||||||
|
public DateBoxWithNull()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTime? Value
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!checkBoxNull.Checked)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxDate.Text))
|
||||||
|
{
|
||||||
|
throw new Exception("Text box can't be empty, click checkbox if value must be empty!");
|
||||||
|
}
|
||||||
|
if (DateTime.TryParseExact(textBoxDate.Text, "dd/MM/yyyy", null, DateTimeStyles.None, out DateTime parsedDate))
|
||||||
|
{
|
||||||
|
return parsedDate;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"Wrong format <{textBoxDate.Text}>!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
bool isNull = value is null;
|
||||||
|
checkBoxNull.Checked = isNull;
|
||||||
|
textBoxDate.Text = isNull ? string.Empty : value?.ToString("dd/MM/yyyy");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TextBoxDate_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CombEvent?.Invoke(sender, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckBoxNull_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
textBoxDate.Enabled = !checkBoxNull.Checked;
|
||||||
|
CombEvent?.Invoke(sender, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
@ -7,7 +7,6 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
@ -16,10 +16,12 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
|
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
|
||||||
|
<PackageReference Include="WinFormsLibrary" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\ComponentProgramming\ComponentProgramming.csproj" />
|
<ProjectReference Include="..\ComponentProgramming\ComponentProgramming.csproj" />
|
||||||
|
<ProjectReference Include="..\Contracts\Contracts.csproj" />
|
||||||
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
|
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
52
ComponentProgramming/Forms/MainForm.Designer.cs
generated
52
ComponentProgramming/Forms/MainForm.Designer.cs
generated
@ -34,6 +34,13 @@
|
|||||||
organisationTypesToolStripMenuItem = new ToolStripMenuItem();
|
organisationTypesToolStripMenuItem = new ToolStripMenuItem();
|
||||||
addProviderToolStripMenuItem = new ToolStripMenuItem();
|
addProviderToolStripMenuItem = new ToolStripMenuItem();
|
||||||
editProviderToolStripMenuItem = new ToolStripMenuItem();
|
editProviderToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
deleteProviderToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
createPdfToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
createExcelToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
largeTextComponent = new ComponentProgramming.Components.LargeTextComponent(components);
|
||||||
|
componentDocumentWithTableMultiHeaderExcel = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderExcel(components);
|
||||||
|
createToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
componentDocumentWithChartPieWord = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieWord(components);
|
||||||
contextMenuStrip1.SuspendLayout();
|
contextMenuStrip1.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -48,31 +55,59 @@
|
|||||||
//
|
//
|
||||||
// contextMenuStrip1
|
// contextMenuStrip1
|
||||||
//
|
//
|
||||||
contextMenuStrip1.Items.AddRange(new ToolStripItem[] { organisationTypesToolStripMenuItem, addProviderToolStripMenuItem, editProviderToolStripMenuItem });
|
contextMenuStrip1.Items.AddRange(new ToolStripItem[] { organisationTypesToolStripMenuItem, addProviderToolStripMenuItem, editProviderToolStripMenuItem, deleteProviderToolStripMenuItem, createPdfToolStripMenuItem, createExcelToolStripMenuItem, createToolStripMenuItem });
|
||||||
contextMenuStrip1.Name = "contextMenuStrip1";
|
contextMenuStrip1.Name = "contextMenuStrip1";
|
||||||
contextMenuStrip1.Size = new Size(181, 92);
|
contextMenuStrip1.Size = new Size(181, 180);
|
||||||
//
|
//
|
||||||
// organisationTypesToolStripMenuItem
|
// organisationTypesToolStripMenuItem
|
||||||
//
|
//
|
||||||
organisationTypesToolStripMenuItem.Name = "organisationTypesToolStripMenuItem";
|
organisationTypesToolStripMenuItem.Name = "organisationTypesToolStripMenuItem";
|
||||||
organisationTypesToolStripMenuItem.Size = new Size(180, 22);
|
organisationTypesToolStripMenuItem.Size = new Size(173, 22);
|
||||||
organisationTypesToolStripMenuItem.Text = "Organisation types";
|
organisationTypesToolStripMenuItem.Text = "Organisation types";
|
||||||
organisationTypesToolStripMenuItem.Click += organisationTypesToolStripMenuItem_Click;
|
organisationTypesToolStripMenuItem.Click += organisationTypesToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// addProviderToolStripMenuItem
|
// addProviderToolStripMenuItem
|
||||||
//
|
//
|
||||||
addProviderToolStripMenuItem.Name = "addProviderToolStripMenuItem";
|
addProviderToolStripMenuItem.Name = "addProviderToolStripMenuItem";
|
||||||
addProviderToolStripMenuItem.Size = new Size(180, 22);
|
addProviderToolStripMenuItem.Size = new Size(173, 22);
|
||||||
addProviderToolStripMenuItem.Text = "Add provider";
|
addProviderToolStripMenuItem.Text = "Add provider";
|
||||||
addProviderToolStripMenuItem.Click += addProviderToolStripMenuItem_Click;
|
addProviderToolStripMenuItem.Click += addProviderToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// editProviderToolStripMenuItem
|
// editProviderToolStripMenuItem
|
||||||
//
|
//
|
||||||
editProviderToolStripMenuItem.Name = "editProviderToolStripMenuItem";
|
editProviderToolStripMenuItem.Name = "editProviderToolStripMenuItem";
|
||||||
editProviderToolStripMenuItem.Size = new Size(180, 22);
|
editProviderToolStripMenuItem.Size = new Size(173, 22);
|
||||||
editProviderToolStripMenuItem.Text = "Edit provider";
|
editProviderToolStripMenuItem.Text = "Edit provider";
|
||||||
editProviderToolStripMenuItem.Click += editProviderToolStripMenuItem_Click;
|
editProviderToolStripMenuItem.Click += editProviderToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// deleteProviderToolStripMenuItem
|
||||||
|
//
|
||||||
|
deleteProviderToolStripMenuItem.Name = "deleteProviderToolStripMenuItem";
|
||||||
|
deleteProviderToolStripMenuItem.Size = new Size(173, 22);
|
||||||
|
deleteProviderToolStripMenuItem.Text = "Delete provider";
|
||||||
|
deleteProviderToolStripMenuItem.Click += deleteProviderToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// createPdfToolStripMenuItem
|
||||||
|
//
|
||||||
|
createPdfToolStripMenuItem.Name = "createPdfToolStripMenuItem";
|
||||||
|
createPdfToolStripMenuItem.Size = new Size(173, 22);
|
||||||
|
createPdfToolStripMenuItem.Text = "Create Pdf";
|
||||||
|
createPdfToolStripMenuItem.Click += createPdfToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// createExcelToolStripMenuItem
|
||||||
|
//
|
||||||
|
createExcelToolStripMenuItem.Name = "createExcelToolStripMenuItem";
|
||||||
|
createExcelToolStripMenuItem.Size = new Size(173, 22);
|
||||||
|
createExcelToolStripMenuItem.Text = "Create Excel";
|
||||||
|
createExcelToolStripMenuItem.Click += createExcelToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// createToolStripMenuItem
|
||||||
|
//
|
||||||
|
createToolStripMenuItem.Name = "createToolStripMenuItem";
|
||||||
|
createToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
createToolStripMenuItem.Text = "Create Word";
|
||||||
|
createToolStripMenuItem.Click += createToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
@ -91,5 +126,12 @@
|
|||||||
private ToolStripMenuItem organisationTypesToolStripMenuItem;
|
private ToolStripMenuItem organisationTypesToolStripMenuItem;
|
||||||
private ToolStripMenuItem addProviderToolStripMenuItem;
|
private ToolStripMenuItem addProviderToolStripMenuItem;
|
||||||
private ToolStripMenuItem editProviderToolStripMenuItem;
|
private ToolStripMenuItem editProviderToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem deleteProviderToolStripMenuItem;
|
||||||
|
private ComponentProgramming.Components.LargeTextComponent largeTextComponent;
|
||||||
|
private ToolStripMenuItem createPdfToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem createExcelToolStripMenuItem;
|
||||||
|
private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderExcel componentDocumentWithTableMultiHeaderExcel;
|
||||||
|
private ToolStripMenuItem createToolStripMenuItem;
|
||||||
|
private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieWord componentDocumentWithChartPieWord;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,6 +8,8 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using ComponentsLibraryNet60;
|
using ComponentsLibraryNet60;
|
||||||
|
using ComponentsLibraryNet60.Models;
|
||||||
|
using Contracts.BindingModels;
|
||||||
using Contracts.BusinessLogicsContracts;
|
using Contracts.BusinessLogicsContracts;
|
||||||
using Contracts.ViewModels;
|
using Contracts.ViewModels;
|
||||||
using ControlsLibraryNet60.Data;
|
using ControlsLibraryNet60.Data;
|
||||||
@ -19,27 +21,35 @@ namespace Forms
|
|||||||
{
|
{
|
||||||
|
|
||||||
private readonly IProviderLogic _logic;
|
private readonly IProviderLogic _logic;
|
||||||
|
private readonly IOrganisationTypeLogic _ologic;
|
||||||
|
|
||||||
public MainForm(IProviderLogic logic)
|
public MainForm(IProviderLogic logic, IOrganisationTypeLogic ologic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
|
_ologic = ologic;
|
||||||
|
TreeConfig();
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void TreeConfig()
|
||||||
|
{
|
||||||
|
DataTreeNodeConfig treeConfig = new();
|
||||||
|
treeConfig.NodeNames = new();
|
||||||
|
treeConfig.NodeNames.Enqueue("OrganisationType");
|
||||||
|
treeConfig.NodeNames.Enqueue("DateLastDelivery");
|
||||||
|
treeConfig.NodeNames.Enqueue("Id");
|
||||||
|
treeConfig.NodeNames.Enqueue("Name");
|
||||||
|
|
||||||
|
controlDataTreeTable.LoadConfig(treeConfig);
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadData()
|
private void LoadData()
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
var list = _logic.ReadList(null);
|
||||||
if (list != null)
|
if (list != null)
|
||||||
{
|
{
|
||||||
DataTreeNodeConfig treeConfig = new();
|
controlDataTreeTable.Clear();
|
||||||
treeConfig.NodeNames = new();
|
|
||||||
treeConfig.NodeNames.Enqueue("OrganisationType");
|
|
||||||
treeConfig.NodeNames.Enqueue("DateLastDelivery");
|
|
||||||
treeConfig.NodeNames.Enqueue("Id");
|
|
||||||
treeConfig.NodeNames.Enqueue("Name");
|
|
||||||
|
|
||||||
controlDataTreeTable.LoadConfig(treeConfig);
|
|
||||||
controlDataTreeTable.AddTable(list);
|
controlDataTreeTable.AddTable(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,16 +74,107 @@ namespace Forms
|
|||||||
|
|
||||||
private void editProviderToolStripMenuItem_Click(object sender, EventArgs e)
|
private void editProviderToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(ProviderForm));
|
int id = Convert.ToInt32(controlDataTreeTable.GetSelectedObject<ProviderViewModel>()?.Id);
|
||||||
if(service is ProviderForm form)
|
ProviderForm form = new ProviderForm(_logic, _ologic, id);
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteProviderToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var confirmResult = MessageBox.Show("Вы действительно хотите удалить запись?", "Подтвердите действие",
|
||||||
|
MessageBoxButtons.YesNo,
|
||||||
|
MessageBoxIcon.Question
|
||||||
|
);
|
||||||
|
|
||||||
|
if (confirmResult == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(controlDataTreeTable.GetSelectedObject<ProviderViewModel>()?.Id);
|
_logic.Delete(new ProviderBindingModel
|
||||||
form.Id = id;
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
{
|
||||||
LoadData();
|
Id = Convert.ToInt32(controlDataTreeTable.GetSelectedObject<ProviderViewModel>()?.Id),
|
||||||
}
|
});
|
||||||
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createPdfToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||||
|
saveFileDialog.ShowDialog();
|
||||||
|
string path = saveFileDialog.FileName + ".pdf";
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
List<string> strings = new List<string> { };
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
strings.Add($"{item.Name} : {item.FurnitureType}");
|
||||||
|
}
|
||||||
|
largeTextComponent.CreateDocument(path, $"Отчет за {DateTime.Now.Year}", strings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createExcelToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||||
|
saveFileDialog.ShowDialog();
|
||||||
|
string path = saveFileDialog.FileName + ".xlsx";
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
var widths = new List<(int Column, int Row)> { (5, 5), (10, 5), (5, 5), (7, 5), (10, 5), };
|
||||||
|
var headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)> {
|
||||||
|
(0,0,"АЙДИ", "Id"),
|
||||||
|
(1,0,"Название", "Name"),
|
||||||
|
(2,0,"Перечень мебели", "FurnitureType"),
|
||||||
|
(3,0,"Тип организации", "OrganisationType"),
|
||||||
|
(4,0,"Дата последней доставки", "DateLastDelivery")
|
||||||
|
};
|
||||||
|
var conf = new ComponentDocumentWithTableHeaderDataConfig<ProviderViewModel>
|
||||||
|
{
|
||||||
|
FilePath = path,
|
||||||
|
Header = "Отчет по поставщикам",
|
||||||
|
ColumnsRowsDataCount = (list![0].GetType().GetProperties().Length, list.Count),
|
||||||
|
UseUnion = false,
|
||||||
|
ColumnsRowsWidth = widths,
|
||||||
|
Headers = headers,
|
||||||
|
Data = list,
|
||||||
|
};
|
||||||
|
componentDocumentWithTableMultiHeaderExcel.CreateDoc<ProviderViewModel>(conf);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||||
|
saveFileDialog.ShowDialog();
|
||||||
|
string path = saveFileDialog.FileName + ".docx";
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
var data = new List<(int Date, double Value)> { };
|
||||||
|
string header = "График по поставщикам\n";
|
||||||
|
var chart = new Dictionary<string, List<(int Date, double Value)>> { };
|
||||||
|
int index = 1;
|
||||||
|
foreach (var type in _ologic.ReadList(null)!)
|
||||||
|
{
|
||||||
|
int sum = 0;
|
||||||
|
foreach(var item in list)
|
||||||
|
{
|
||||||
|
if(item.OrganisationType == type.Name)
|
||||||
|
{
|
||||||
|
sum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
header += $"{index} - {type.Name}\n";
|
||||||
|
if (sum != 0) data.Add((index, sum));
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
chart.Add("ИП", data);
|
||||||
|
var conf = new ComponentDocumentWithChartConfig
|
||||||
|
{
|
||||||
|
FilePath = path,
|
||||||
|
Header = header,
|
||||||
|
ChartTitle = "Диаграмма по типам организаций",
|
||||||
|
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
|
||||||
|
Data = chart,
|
||||||
|
};
|
||||||
|
componentDocumentWithChartPieWord.CreateDoc(conf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,4 +120,13 @@
|
|||||||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>132, 17</value>
|
<value>132, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="largeTextComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>287, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="componentDocumentWithTableMultiHeaderExcel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>452, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="componentDocumentWithChartPieWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>769, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
@ -51,7 +51,7 @@
|
|||||||
//
|
//
|
||||||
// Type
|
// Type
|
||||||
//
|
//
|
||||||
Type.HeaderText = "Тип организации";
|
Type.HeaderText = "Organisation types";
|
||||||
Type.Name = "Type";
|
Type.Name = "Type";
|
||||||
//
|
//
|
||||||
// OrganisationTypeForm
|
// OrganisationTypeForm
|
||||||
@ -61,7 +61,7 @@
|
|||||||
ClientSize = new Size(205, 308);
|
ClientSize = new Size(205, 308);
|
||||||
Controls.Add(dataGridView);
|
Controls.Add(dataGridView);
|
||||||
Name = "OrganisationTypeForm";
|
Name = "OrganisationTypeForm";
|
||||||
Text = "Справочник";
|
Text = "Types";
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
35
ComponentProgramming/Forms/ProviderForm.Designer.cs
generated
35
ComponentProgramming/Forms/ProviderForm.Designer.cs
generated
@ -28,7 +28,6 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
controlInputNullableDate = new ControlsLibraryNet60.Input.ControlInputNullableDate();
|
|
||||||
controlSelectedComboBoxList = new ControlsLibraryNet60.Selected.ControlSelectedComboBoxList();
|
controlSelectedComboBoxList = new ControlsLibraryNet60.Selected.ControlSelectedComboBoxList();
|
||||||
textBoxName = new TextBox();
|
textBoxName = new TextBox();
|
||||||
label1 = new Label();
|
label1 = new Label();
|
||||||
@ -38,27 +37,19 @@
|
|||||||
label4 = new Label();
|
label4 = new Label();
|
||||||
buttonAdd = new Button();
|
buttonAdd = new Button();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
|
controlInputNullableDate = new ComponentProgramming.Control.DateBoxWithNull();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// controlInputNullableDate
|
|
||||||
//
|
|
||||||
controlInputNullableDate.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
controlInputNullableDate.Location = new Point(12, 164);
|
|
||||||
controlInputNullableDate.Margin = new Padding(4, 3, 4, 3);
|
|
||||||
controlInputNullableDate.Name = "controlInputNullableDate";
|
|
||||||
controlInputNullableDate.Size = new Size(254, 23);
|
|
||||||
controlInputNullableDate.TabIndex = 0;
|
|
||||||
controlInputNullableDate.Value = null;
|
|
||||||
//
|
|
||||||
// controlSelectedComboBoxList
|
// controlSelectedComboBoxList
|
||||||
//
|
//
|
||||||
controlSelectedComboBoxList.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
controlSelectedComboBoxList.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
controlSelectedComboBoxList.Location = new Point(12, 119);
|
controlSelectedComboBoxList.Location = new Point(12, 119);
|
||||||
controlSelectedComboBoxList.Margin = new Padding(5, 3, 5, 3);
|
controlSelectedComboBoxList.Margin = new Padding(5, 3, 5, 3);
|
||||||
controlSelectedComboBoxList.Name = "controlSelectedComboBoxList";
|
controlSelectedComboBoxList.Name = "controlSelectedComboBoxList";
|
||||||
controlSelectedComboBoxList.SelectedElement = "";
|
controlSelectedComboBoxList.SelectedElement = "";
|
||||||
controlSelectedComboBoxList.Size = new Size(254, 24);
|
controlSelectedComboBoxList.Size = new Size(254, 24);
|
||||||
controlSelectedComboBoxList.TabIndex = 1;
|
controlSelectedComboBoxList.TabIndex = 1;
|
||||||
|
controlSelectedComboBoxList.SelectedElementChange += OnInputChange;
|
||||||
//
|
//
|
||||||
// textBoxName
|
// textBoxName
|
||||||
//
|
//
|
||||||
@ -67,6 +58,7 @@
|
|||||||
textBoxName.Name = "textBoxName";
|
textBoxName.Name = "textBoxName";
|
||||||
textBoxName.Size = new Size(254, 23);
|
textBoxName.Size = new Size(254, 23);
|
||||||
textBoxName.TabIndex = 2;
|
textBoxName.TabIndex = 2;
|
||||||
|
textBoxName.TextChanged += OnInputChange;
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
@ -84,6 +76,7 @@
|
|||||||
textBoxFurnitureType.Name = "textBoxFurnitureType";
|
textBoxFurnitureType.Name = "textBoxFurnitureType";
|
||||||
textBoxFurnitureType.Size = new Size(254, 23);
|
textBoxFurnitureType.Size = new Size(254, 23);
|
||||||
textBoxFurnitureType.TabIndex = 4;
|
textBoxFurnitureType.TabIndex = 4;
|
||||||
|
textBoxFurnitureType.TextChanged += OnInputChange;
|
||||||
//
|
//
|
||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
@ -115,7 +108,7 @@
|
|||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
buttonAdd.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
buttonAdd.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
buttonAdd.Location = new Point(12, 193);
|
buttonAdd.Location = new Point(12, 196);
|
||||||
buttonAdd.Name = "buttonAdd";
|
buttonAdd.Name = "buttonAdd";
|
||||||
buttonAdd.Size = new Size(94, 36);
|
buttonAdd.Size = new Size(94, 36);
|
||||||
buttonAdd.TabIndex = 8;
|
buttonAdd.TabIndex = 8;
|
||||||
@ -126,18 +119,27 @@
|
|||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
buttonCancel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
buttonCancel.Location = new Point(173, 193);
|
buttonCancel.Location = new Point(173, 196);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(94, 36);
|
buttonCancel.Size = new Size(94, 36);
|
||||||
buttonCancel.TabIndex = 9;
|
buttonCancel.TabIndex = 9;
|
||||||
buttonCancel.Text = "Cancel";
|
buttonCancel.Text = "Cancel";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// controlInputNullableDate
|
||||||
|
//
|
||||||
|
controlInputNullableDate.Location = new Point(12, 165);
|
||||||
|
controlInputNullableDate.Name = "controlInputNullableDate";
|
||||||
|
controlInputNullableDate.Size = new Size(255, 30);
|
||||||
|
controlInputNullableDate.TabIndex = 10;
|
||||||
//
|
//
|
||||||
// ProviderForm
|
// ProviderForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(279, 241);
|
ClientSize = new Size(279, 241);
|
||||||
|
Controls.Add(controlInputNullableDate);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonAdd);
|
Controls.Add(buttonAdd);
|
||||||
Controls.Add(label4);
|
Controls.Add(label4);
|
||||||
@ -147,16 +149,14 @@
|
|||||||
Controls.Add(label1);
|
Controls.Add(label1);
|
||||||
Controls.Add(textBoxName);
|
Controls.Add(textBoxName);
|
||||||
Controls.Add(controlSelectedComboBoxList);
|
Controls.Add(controlSelectedComboBoxList);
|
||||||
Controls.Add(controlInputNullableDate);
|
|
||||||
Name = "ProviderForm";
|
Name = "ProviderForm";
|
||||||
Text = "Create Provider";
|
Text = "Create Provider";
|
||||||
|
FormClosing += ProviderForm_FormClosing;
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private ControlsLibraryNet60.Input.ControlInputNullableDate controlInputNullableDate;
|
|
||||||
private ControlsLibraryNet60.Selected.ControlSelectedComboBoxList controlSelectedComboBoxList;
|
private ControlsLibraryNet60.Selected.ControlSelectedComboBoxList controlSelectedComboBoxList;
|
||||||
private TextBox textBoxName;
|
private TextBox textBoxName;
|
||||||
private Label label1;
|
private Label label1;
|
||||||
@ -166,5 +166,6 @@
|
|||||||
private Label label4;
|
private Label label4;
|
||||||
private Button buttonAdd;
|
private Button buttonAdd;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
|
private ComponentProgramming.Control.DateBoxWithNull controlInputNullableDate;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
using Contracts.BindingModels;
|
using Contracts.BindingModels;
|
||||||
using Contracts.BusinessLogicsContracts;
|
using Contracts.BusinessLogicsContracts;
|
||||||
using Contracts.SearchModels;
|
using Contracts.SearchModels;
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -17,17 +16,17 @@ namespace Forms
|
|||||||
public partial class ProviderForm : Form
|
public partial class ProviderForm : Form
|
||||||
{
|
{
|
||||||
private int? _id;
|
private int? _id;
|
||||||
public int Id { set { _id = value; } }
|
|
||||||
private readonly IProviderLogic _pLogic;
|
private readonly IProviderLogic _pLogic;
|
||||||
private readonly IOrganisationTypeLogic _oLogic;
|
private readonly IOrganisationTypeLogic _oLogic;
|
||||||
//private bool isEdited;
|
private bool isEdited;
|
||||||
|
|
||||||
public ProviderForm(IProviderLogic plogic, IOrganisationTypeLogic ologic)
|
public ProviderForm(IProviderLogic plogic, IOrganisationTypeLogic ologic, int? id = null)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_pLogic = plogic;
|
_pLogic = plogic;
|
||||||
_oLogic = ologic;
|
_oLogic = ologic;
|
||||||
//isEdited = false;
|
_id = id;
|
||||||
|
isEdited = false;
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,13 +48,22 @@ namespace Forms
|
|||||||
{
|
{
|
||||||
Id = _id.Value,
|
Id = _id.Value,
|
||||||
});
|
});
|
||||||
|
textBoxFurnitureType.Text = view.FurnitureType;
|
||||||
|
textBoxName.Text = view.Name;
|
||||||
|
if (view.DateLastDelivery != "Поставок не было") controlInputNullableDate.Value = Convert.ToDateTime(view.DateLastDelivery);
|
||||||
controlSelectedComboBoxList.SelectedElement = view!.OrganisationType;
|
controlSelectedComboBoxList.SelectedElement = view!.OrganisationType;
|
||||||
|
isEdited = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnInputChange(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
isEdited = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if(string.IsNullOrEmpty(textBoxName.Text))
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Заполните поле Название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Заполните поле Название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
@ -65,21 +73,23 @@ namespace Forms
|
|||||||
MessageBox.Show("Заполните Перечень мебели ", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Заполните Перечень мебели ", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(string.IsNullOrEmpty(controlSelectedComboBoxList.SelectedElement))
|
if (string.IsNullOrEmpty(controlSelectedComboBoxList.SelectedElement))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Выберите Тип организации", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Выберите Тип организации", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var s = controlInputNullableDate.Value.ToString();
|
isEdited = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var OperationResult = _pLogic.Create(new ProviderBindingModel
|
var model = new ProviderBindingModel
|
||||||
{
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
Name = textBoxName.Text,
|
Name = textBoxName.Text,
|
||||||
FurnitureType = textBoxFurnitureType.Text,
|
FurnitureType = textBoxFurnitureType.Text,
|
||||||
DateLastDelivery = controlInputNullableDate.Value.ToString() == "" ? "No date" : controlInputNullableDate.Value.ToString(),
|
DateLastDelivery = controlInputNullableDate.Value.ToString() == "" ? "Поставок не было" : controlInputNullableDate.Value.ToString(),
|
||||||
OrganisationType = controlSelectedComboBoxList.SelectedElement
|
OrganisationType = controlSelectedComboBoxList.SelectedElement
|
||||||
});
|
};
|
||||||
|
var OperationResult = _id.HasValue ? _pLogic.Update(model) : _pLogic.Create(model);
|
||||||
if (!OperationResult)
|
if (!OperationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при создании поставщика.");
|
throw new Exception("Ошибка при создании поставщика.");
|
||||||
@ -93,5 +103,22 @@ namespace Forms
|
|||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ProviderForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
if (!isEdited) return;
|
||||||
|
var confirmResult = MessageBox.Show("Вы не сохранили изменения.\nВы действительно хотите выйти?", "Подтвердите действие",
|
||||||
|
MessageBoxButtons.YesNo,
|
||||||
|
MessageBoxIcon.Question
|
||||||
|
);
|
||||||
|
|
||||||
|
if (confirmResult == DialogResult.No) e.Cancel = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user