Вроде готова
This commit is contained in:
parent
1719292030
commit
e3da66cd20
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<TargetFramework>net8.0-windows7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
@ -24,7 +24,7 @@ namespace ComponentProgramming.Components
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateDocument(string docPath, string title, string[] rows)
|
||||
public void CreateDocument(string docPath, string title, List<string> rows)
|
||||
{
|
||||
if(string.IsNullOrEmpty(docPath))
|
||||
{
|
||||
@ -34,7 +34,7 @@ namespace ComponentProgramming.Components
|
||||
{
|
||||
throw new ArgumentNullException("Введите заголовок");
|
||||
}
|
||||
if(rows.Length <= 0)
|
||||
if(rows.Count <= 0)
|
||||
{
|
||||
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>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
@ -16,10 +16,12 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
|
||||
<PackageReference Include="WinFormsLibrary" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ComponentProgramming\ComponentProgramming.csproj" />
|
||||
<ProjectReference Include="..\Contracts\Contracts.csproj" />
|
||||
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
52
ComponentProgramming/Forms/MainForm.Designer.cs
generated
52
ComponentProgramming/Forms/MainForm.Designer.cs
generated
@ -34,6 +34,13 @@
|
||||
organisationTypesToolStripMenuItem = new ToolStripMenuItem();
|
||||
addProviderToolStripMenuItem = 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();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -48,31 +55,59 @@
|
||||
//
|
||||
// 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.Size = new Size(181, 92);
|
||||
contextMenuStrip1.Size = new Size(181, 180);
|
||||
//
|
||||
// organisationTypesToolStripMenuItem
|
||||
//
|
||||
organisationTypesToolStripMenuItem.Name = "organisationTypesToolStripMenuItem";
|
||||
organisationTypesToolStripMenuItem.Size = new Size(180, 22);
|
||||
organisationTypesToolStripMenuItem.Size = new Size(173, 22);
|
||||
organisationTypesToolStripMenuItem.Text = "Organisation types";
|
||||
organisationTypesToolStripMenuItem.Click += organisationTypesToolStripMenuItem_Click;
|
||||
//
|
||||
// addProviderToolStripMenuItem
|
||||
//
|
||||
addProviderToolStripMenuItem.Name = "addProviderToolStripMenuItem";
|
||||
addProviderToolStripMenuItem.Size = new Size(180, 22);
|
||||
addProviderToolStripMenuItem.Size = new Size(173, 22);
|
||||
addProviderToolStripMenuItem.Text = "Add provider";
|
||||
addProviderToolStripMenuItem.Click += addProviderToolStripMenuItem_Click;
|
||||
//
|
||||
// editProviderToolStripMenuItem
|
||||
//
|
||||
editProviderToolStripMenuItem.Name = "editProviderToolStripMenuItem";
|
||||
editProviderToolStripMenuItem.Size = new Size(180, 22);
|
||||
editProviderToolStripMenuItem.Size = new Size(173, 22);
|
||||
editProviderToolStripMenuItem.Text = "Edit provider";
|
||||
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
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
@ -91,5 +126,12 @@
|
||||
private ToolStripMenuItem organisationTypesToolStripMenuItem;
|
||||
private ToolStripMenuItem addProviderToolStripMenuItem;
|
||||
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.Windows.Forms;
|
||||
using ComponentsLibraryNet60;
|
||||
using ComponentsLibraryNet60.Models;
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.BusinessLogicsContracts;
|
||||
using Contracts.ViewModels;
|
||||
using ControlsLibraryNet60.Data;
|
||||
@ -19,18 +21,18 @@ namespace Forms
|
||||
{
|
||||
|
||||
private readonly IProviderLogic _logic;
|
||||
private readonly IOrganisationTypeLogic _ologic;
|
||||
|
||||
public MainForm(IProviderLogic logic)
|
||||
public MainForm(IProviderLogic logic, IOrganisationTypeLogic ologic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
_ologic = ologic;
|
||||
TreeConfig();
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
private void TreeConfig()
|
||||
{
|
||||
DataTreeNodeConfig treeConfig = new();
|
||||
treeConfig.NodeNames = new();
|
||||
@ -40,6 +42,14 @@ namespace Forms
|
||||
treeConfig.NodeNames.Enqueue("Name");
|
||||
|
||||
controlDataTreeTable.LoadConfig(treeConfig);
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
controlDataTreeTable.Clear();
|
||||
controlDataTreeTable.AddTable(list);
|
||||
}
|
||||
}
|
||||
@ -63,17 +73,108 @@ namespace Forms
|
||||
}
|
||||
|
||||
private void editProviderToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ProviderForm));
|
||||
if(service is ProviderForm form)
|
||||
{
|
||||
int id = Convert.ToInt32(controlDataTreeTable.GetSelectedObject<ProviderViewModel>()?.Id);
|
||||
form.Id = id;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
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)
|
||||
{
|
||||
_logic.Delete(new ProviderBindingModel
|
||||
{
|
||||
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">
|
||||
<value>132, 17</value>
|
||||
</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>
|
@ -51,7 +51,7 @@
|
||||
//
|
||||
// Type
|
||||
//
|
||||
Type.HeaderText = "Тип организации";
|
||||
Type.HeaderText = "Organisation types";
|
||||
Type.Name = "Type";
|
||||
//
|
||||
// OrganisationTypeForm
|
||||
@ -61,7 +61,7 @@
|
||||
ClientSize = new Size(205, 308);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "OrganisationTypeForm";
|
||||
Text = "Справочник";
|
||||
Text = "Types";
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
35
ComponentProgramming/Forms/ProviderForm.Designer.cs
generated
35
ComponentProgramming/Forms/ProviderForm.Designer.cs
generated
@ -28,7 +28,6 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
controlInputNullableDate = new ControlsLibraryNet60.Input.ControlInputNullableDate();
|
||||
controlSelectedComboBoxList = new ControlsLibraryNet60.Selected.ControlSelectedComboBoxList();
|
||||
textBoxName = new TextBox();
|
||||
label1 = new Label();
|
||||
@ -38,27 +37,19 @@
|
||||
label4 = new Label();
|
||||
buttonAdd = new Button();
|
||||
buttonCancel = new Button();
|
||||
controlInputNullableDate = new ComponentProgramming.Control.DateBoxWithNull();
|
||||
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.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
controlSelectedComboBoxList.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
controlSelectedComboBoxList.Location = new Point(12, 119);
|
||||
controlSelectedComboBoxList.Margin = new Padding(5, 3, 5, 3);
|
||||
controlSelectedComboBoxList.Name = "controlSelectedComboBoxList";
|
||||
controlSelectedComboBoxList.SelectedElement = "";
|
||||
controlSelectedComboBoxList.Size = new Size(254, 24);
|
||||
controlSelectedComboBoxList.TabIndex = 1;
|
||||
controlSelectedComboBoxList.SelectedElementChange += OnInputChange;
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
@ -67,6 +58,7 @@
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(254, 23);
|
||||
textBoxName.TabIndex = 2;
|
||||
textBoxName.TextChanged += OnInputChange;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
@ -84,6 +76,7 @@
|
||||
textBoxFurnitureType.Name = "textBoxFurnitureType";
|
||||
textBoxFurnitureType.Size = new Size(254, 23);
|
||||
textBoxFurnitureType.TabIndex = 4;
|
||||
textBoxFurnitureType.TextChanged += OnInputChange;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
@ -115,7 +108,7 @@
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonAdd.Location = new Point(12, 193);
|
||||
buttonAdd.Location = new Point(12, 196);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(94, 36);
|
||||
buttonAdd.TabIndex = 8;
|
||||
@ -126,18 +119,27 @@
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCancel.Location = new Point(173, 193);
|
||||
buttonCancel.Location = new Point(173, 196);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 36);
|
||||
buttonCancel.TabIndex = 9;
|
||||
buttonCancel.Text = "Cancel";
|
||||
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
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(279, 241);
|
||||
Controls.Add(controlInputNullableDate);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(label4);
|
||||
@ -147,16 +149,14 @@
|
||||
Controls.Add(label1);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(controlSelectedComboBoxList);
|
||||
Controls.Add(controlInputNullableDate);
|
||||
Name = "ProviderForm";
|
||||
Text = "Create Provider";
|
||||
FormClosing += ProviderForm_FormClosing;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ControlsLibraryNet60.Input.ControlInputNullableDate controlInputNullableDate;
|
||||
private ControlsLibraryNet60.Selected.ControlSelectedComboBoxList controlSelectedComboBoxList;
|
||||
private TextBox textBoxName;
|
||||
private Label label1;
|
||||
@ -166,5 +166,6 @@
|
||||
private Label label4;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCancel;
|
||||
private ComponentProgramming.Control.DateBoxWithNull controlInputNullableDate;
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.BusinessLogicsContracts;
|
||||
using Contracts.SearchModels;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -17,17 +16,17 @@ namespace Forms
|
||||
public partial class ProviderForm : Form
|
||||
{
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
private readonly IProviderLogic _pLogic;
|
||||
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();
|
||||
_pLogic = plogic;
|
||||
_oLogic = ologic;
|
||||
//isEdited = false;
|
||||
_id = id;
|
||||
isEdited = false;
|
||||
LoadData();
|
||||
}
|
||||
|
||||
@ -49,13 +48,22 @@ namespace Forms
|
||||
{
|
||||
Id = _id.Value,
|
||||
});
|
||||
textBoxFurnitureType.Text = view.FurnitureType;
|
||||
textBoxName.Text = view.Name;
|
||||
if (view.DateLastDelivery != "Поставок не было") controlInputNullableDate.Value = Convert.ToDateTime(view.DateLastDelivery);
|
||||
controlSelectedComboBoxList.SelectedElement = view!.OrganisationType;
|
||||
isEdited = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnInputChange(object sender, EventArgs e)
|
||||
{
|
||||
isEdited = true;
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(string.IsNullOrEmpty(textBoxName.Text))
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
@ -65,21 +73,23 @@ namespace Forms
|
||||
MessageBox.Show("Заполните Перечень мебели ", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if(string.IsNullOrEmpty(controlSelectedComboBoxList.SelectedElement))
|
||||
if (string.IsNullOrEmpty(controlSelectedComboBoxList.SelectedElement))
|
||||
{
|
||||
MessageBox.Show("Выберите Тип организации", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
var s = controlInputNullableDate.Value.ToString();
|
||||
isEdited = false;
|
||||
try
|
||||
{
|
||||
var OperationResult = _pLogic.Create(new ProviderBindingModel
|
||||
var model = new ProviderBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Name = textBoxName.Text,
|
||||
FurnitureType = textBoxFurnitureType.Text,
|
||||
DateLastDelivery = controlInputNullableDate.Value.ToString() == "" ? "No date" : controlInputNullableDate.Value.ToString(),
|
||||
DateLastDelivery = controlInputNullableDate.Value.ToString() == "" ? "Поставок не было" : controlInputNullableDate.Value.ToString(),
|
||||
OrganisationType = controlSelectedComboBoxList.SelectedElement
|
||||
});
|
||||
};
|
||||
var OperationResult = _id.HasValue ? _pLogic.Update(model) : _pLogic.Create(model);
|
||||
if (!OperationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при создании поставщика.");
|
||||
@ -93,5 +103,22 @@ namespace Forms
|
||||
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