Compare commits
16 Commits
main
...
Lab3_Volko
Author | SHA1 | Date | |
---|---|---|---|
83136c5c25 | |||
3cc2a7e154 | |||
4c409b841d | |||
fb17f2b58d | |||
7b0038a08f | |||
242c5e4b58 | |||
36513dcb02 | |||
0bf36059e1 | |||
3ba5fd8046 | |||
4865ee8da9 | |||
160b7dc88a | |||
66702ee864 | |||
cca38e76c1 | |||
5f19fb8329 | |||
c44986349c | |||
52a0e50af6 |
@ -1,4 +1,2 @@
|
||||
# KOP_PIbd-33_Volkov_N.A._Tikhonenkov_A.E.
|
||||
# KOP_PIbd-33_Volkov_N.A.-Var21
|
||||
|
||||
Волков Н.А. - Вариант 20
|
||||
Тихоненков А.Е. - Вариант 21
|
7
VolkovLabs/InternetShopDataModels/IId.cs
Normal file
7
VolkovLabs/InternetShopDataModels/IId.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace InternetShopOrdersDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
16
VolkovLabs/InternetShopDataModels/Models/IOrderModel.cs
Normal file
16
VolkovLabs/InternetShopDataModels/Models/IOrderModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersDataModels.Models
|
||||
{
|
||||
public interface IOrderModel : IId
|
||||
{
|
||||
string Fullname { get; }
|
||||
public string OrderImage { get; }
|
||||
public int SelectedItemId { get; }
|
||||
string Email { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersDataModels.Models
|
||||
{
|
||||
public interface ISelectedItemModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
173
VolkovLabs/InternetShopOrdersApp/FormMain.Designer.cs
generated
Normal file
173
VolkovLabs/InternetShopOrdersApp/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,173 @@
|
||||
namespace InternetShopOrdersApp
|
||||
{
|
||||
partial class FormMain
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
menuStrip = new MenuStrip();
|
||||
заказыToolStripMenuItem = new ToolStripMenuItem();
|
||||
создатьToolStripMenuItem = new ToolStripMenuItem();
|
||||
редактироватьToolStripMenuItem = new ToolStripMenuItem();
|
||||
удалитьToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
||||
документToolStripMenuItem = new ToolStripMenuItem();
|
||||
документСТаблицейToolStripMenuItem = new ToolStripMenuItem();
|
||||
документСДиаграммойToolStripMenuItem = new ToolStripMenuItem();
|
||||
выбранныеТоварыToolStripMenuItem = new ToolStripMenuItem();
|
||||
controlDataTable = new ControlsLibraryNet60.Data.ControlDataTableTable();
|
||||
excelImagesComponent = new WinFormsLibraryVolkov.NonVisualComponents.ExcelImagesComponent(components);
|
||||
componentHistogramToPdf = new FormLibrary.ComponentHistogramToPdf(components);
|
||||
componentDocumentWithTableHeaderRowWord = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableHeaderRowWord(components);
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(18, 18);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { заказыToolStripMenuItem, отчётыToolStripMenuItem, выбранныеТоварыToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(800, 27);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "menuStrip";
|
||||
//
|
||||
// заказыToolStripMenuItem
|
||||
//
|
||||
заказыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { создатьToolStripMenuItem, редактироватьToolStripMenuItem, удалитьToolStripMenuItem });
|
||||
заказыToolStripMenuItem.Name = "заказыToolStripMenuItem";
|
||||
заказыToolStripMenuItem.Size = new Size(68, 23);
|
||||
заказыToolStripMenuItem.Text = "Заказы";
|
||||
//
|
||||
// создатьToolStripMenuItem
|
||||
//
|
||||
создатьToolStripMenuItem.Name = "создатьToolStripMenuItem";
|
||||
создатьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
|
||||
создатьToolStripMenuItem.Size = new Size(231, 24);
|
||||
создатьToolStripMenuItem.Text = "Создать";
|
||||
создатьToolStripMenuItem.Click += создатьToolStripMenuItem_Click;
|
||||
//
|
||||
// редактироватьToolStripMenuItem
|
||||
//
|
||||
редактироватьToolStripMenuItem.Name = "редактироватьToolStripMenuItem";
|
||||
редактироватьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U;
|
||||
редактироватьToolStripMenuItem.Size = new Size(231, 24);
|
||||
редактироватьToolStripMenuItem.Text = "Редактировать";
|
||||
редактироватьToolStripMenuItem.Click += редактироватьToolStripMenuItem_Click;
|
||||
//
|
||||
// удалитьToolStripMenuItem
|
||||
//
|
||||
удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
|
||||
удалитьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
|
||||
удалитьToolStripMenuItem.Size = new Size(231, 24);
|
||||
удалитьToolStripMenuItem.Text = "Удалить";
|
||||
удалитьToolStripMenuItem.Click += удалитьToolStripMenuItem_Click;
|
||||
//
|
||||
// отчётыToolStripMenuItem
|
||||
//
|
||||
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { документToolStripMenuItem, документСТаблицейToolStripMenuItem, документСДиаграммойToolStripMenuItem });
|
||||
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
||||
отчётыToolStripMenuItem.Size = new Size(71, 23);
|
||||
отчётыToolStripMenuItem.Text = "Отчёты";
|
||||
//
|
||||
// документToolStripMenuItem
|
||||
//
|
||||
документToolStripMenuItem.Name = "документToolStripMenuItem";
|
||||
документToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||
документToolStripMenuItem.Size = new Size(326, 24);
|
||||
документToolStripMenuItem.Text = "Документ с простой таблицей";
|
||||
документToolStripMenuItem.Click += документToolStripMenuItem_Click;
|
||||
//
|
||||
// документСТаблицейToolStripMenuItem
|
||||
//
|
||||
документСТаблицейToolStripMenuItem.Name = "документСТаблицейToolStripMenuItem";
|
||||
документСТаблицейToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
|
||||
документСТаблицейToolStripMenuItem.Size = new Size(326, 24);
|
||||
документСТаблицейToolStripMenuItem.Text = "Отчет по всем заказам";
|
||||
документСТаблицейToolStripMenuItem.Click += документСТаблицейToolStripMenuItem_Click;
|
||||
//
|
||||
// документСДиаграммойToolStripMenuItem
|
||||
//
|
||||
документСДиаграммойToolStripMenuItem.Name = "документСДиаграммойToolStripMenuItem";
|
||||
документСДиаграммойToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
|
||||
документСДиаграммойToolStripMenuItem.Size = new Size(326, 24);
|
||||
документСДиаграммойToolStripMenuItem.Text = "Документ с гистограммой";
|
||||
документСДиаграммойToolStripMenuItem.Click += документСДиаграммойToolStripMenuItem_Click;
|
||||
//
|
||||
// выбранныеТоварыToolStripMenuItem
|
||||
//
|
||||
выбранныеТоварыToolStripMenuItem.Name = "выбранныеТоварыToolStripMenuItem";
|
||||
выбранныеТоварыToolStripMenuItem.Size = new Size(147, 23);
|
||||
выбранныеТоварыToolStripMenuItem.Text = "Выбранные товары";
|
||||
выбранныеТоварыToolStripMenuItem.Click += выбранныеТоварыToolStripMenuItem_Click;
|
||||
//
|
||||
// controlDataTable
|
||||
//
|
||||
controlDataTable.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
controlDataTable.AutoSize = true;
|
||||
controlDataTable.Location = new Point(0, 31);
|
||||
controlDataTable.Margin = new Padding(4, 4, 4, 4);
|
||||
controlDataTable.Name = "controlDataTable";
|
||||
controlDataTable.SelectedRowIndex = -1;
|
||||
controlDataTable.Size = new Size(800, 420);
|
||||
controlDataTable.TabIndex = 1;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 19F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(controlDataTable);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormMain";
|
||||
Text = "Заказы";
|
||||
Load += FormMain_Load;
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem заказыToolStripMenuItem;
|
||||
private ToolStripMenuItem создатьToolStripMenuItem;
|
||||
private ToolStripMenuItem редактироватьToolStripMenuItem;
|
||||
private ToolStripMenuItem удалитьToolStripMenuItem;
|
||||
private ToolStripMenuItem отчётыToolStripMenuItem;
|
||||
private ToolStripMenuItem документToolStripMenuItem;
|
||||
private ToolStripMenuItem документСТаблицейToolStripMenuItem;
|
||||
private ToolStripMenuItem выбранныеТоварыToolStripMenuItem;
|
||||
private ToolStripMenuItem документСДиаграммойToolStripMenuItem;
|
||||
private ControlsLibraryNet60.Data.ControlDataTableTable controlDataTable;
|
||||
private WinFormsLibraryVolkov.NonVisualComponents.ExcelImagesComponent excelImagesComponent;
|
||||
private FormLibrary.ComponentHistogramToPdf componentHistogramToPdf;
|
||||
private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableHeaderRowWord componentDocumentWithTableHeaderRowWord;
|
||||
}
|
||||
}
|
206
VolkovLabs/InternetShopOrdersApp/FormMain.cs
Normal file
206
VolkovLabs/InternetShopOrdersApp/FormMain.cs
Normal file
@ -0,0 +1,206 @@
|
||||
using InternetShopOrdersBusinessLogic.BusinessLogics;
|
||||
using InternetShopOrdersContracts.BusinessLogicContracts;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
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 ControlsLibraryNet60.Models;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using WinFormsLibraryVolkov.NonVisualComponents;
|
||||
using ComponentsLibraryNet60.Core;
|
||||
using ComponentsLibraryNet60.DocumentWithTable;
|
||||
using ComponentsLibraryNet60.Models;
|
||||
using OxyPlot.Legends;
|
||||
using FormLibrary.HelperClasses;
|
||||
using FormLibrary;
|
||||
using System.Diagnostics;
|
||||
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace InternetShopOrdersApp
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private IOrderLogic _logic;
|
||||
|
||||
public FormMain(IOrderLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
controlDataTable.LoadColumns(new List<DataTableColumnConfig>
|
||||
{
|
||||
new DataTableColumnConfig { ColumnHeader = "", PropertyName = "Id", Visible = false, Width = 10 },
|
||||
new DataTableColumnConfig { ColumnHeader = "ФИО заказчика", PropertyName = "Fullname", Visible = true, Width = 200 },
|
||||
new DataTableColumnConfig { ColumnHeader = "Выбранный товар", PropertyName = "SelectedItemName", Visible = true, Width = 200 },
|
||||
new DataTableColumnConfig { ColumnHeader = "Электронная почта", PropertyName = "Email", Visible = true, Width = 200 },
|
||||
});
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
controlDataTable.Clear();
|
||||
var orders = _logic.ReadList(null);
|
||||
if (orders != null)
|
||||
{
|
||||
controlDataTable.AddTable(orders);
|
||||
}
|
||||
}
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void создатьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormOrder));
|
||||
if (service is FormOrder form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormOrder));
|
||||
if (service is FormOrder form)
|
||||
{
|
||||
form.Id = controlDataTable.GetSelectedObject<OrderViewModel>().Id;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
if (_logic.Delete(new OrderBindingModel { Id = controlDataTable.GetSelectedObject<OrderViewModel>().Id }))
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void документToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
|
||||
{
|
||||
saveFileDialog.Filter = "Excel Workbook (*.xlsx)|*.xlsx";
|
||||
saveFileDialog.Title = "Сохранить Excel файл";
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
List<string> orderImages = new List<string>();
|
||||
foreach (var order in _logic.ReadList(null))
|
||||
{
|
||||
orderImages.Add(order.OrderImage);
|
||||
}
|
||||
string path = saveFileDialog.FileName;
|
||||
excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Фотокарточки заказов", orderImages.ToArray()));
|
||||
}
|
||||
MessageBox.Show("Excel успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
private void выбранныеТоварыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSelectedItems));
|
||||
if (service is FormSelectedItems form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void документСТаблицейToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
|
||||
{
|
||||
saveFileDialog.Filter = "Word Document (*.docx)|*.docx";
|
||||
saveFileDialog.Title = "Сохранить Word файл";
|
||||
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var orders = _logic.ReadList(null);
|
||||
componentDocumentWithTableHeaderRowWord.CreateDoc(new ComponentDocumentWithTableHeaderDataConfig<OrderViewModel>
|
||||
{
|
||||
FilePath = saveFileDialog.FileName,
|
||||
Header = "Заказы",
|
||||
UseUnion = true,
|
||||
ColumnsRowsWidth = new List<(int, int)> { (5, 0), (10, 0), (10, 0), (10, 0) },
|
||||
ColumnUnion = new List<(int StartIndex, int Count)> { (1, 2) },
|
||||
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
|
||||
{
|
||||
(0, 0, "Id", "Id"),
|
||||
(1, 0, "Личные данные", ""),
|
||||
(1, 1, "ФИО заказчика", "Fullname"),
|
||||
(2, 1, "Электронная почта", "Email"),
|
||||
(3, 0, "Выбранный товар", "SelectedItemName"),
|
||||
},
|
||||
Data = orders
|
||||
});
|
||||
|
||||
MessageBox.Show("Word файл был успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void документСДиаграммойToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
|
||||
{
|
||||
saveFileDialog.Filter = "PDF Document (*.pdf)|*.pdf";
|
||||
saveFileDialog.Title = "Сохранить PDF файл";
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
var histogramGenerator = new ComponentHistogramToPdf();
|
||||
|
||||
var orders = _logic.ReadList(null);
|
||||
|
||||
var itemCounts = new Dictionary<string, int>();
|
||||
foreach (var order in orders)
|
||||
{
|
||||
if (!itemCounts.ContainsKey(order.SelectedItemName))
|
||||
{
|
||||
itemCounts[order.SelectedItemName] = 0;
|
||||
}
|
||||
itemCounts[order.SelectedItemName]++;
|
||||
}
|
||||
|
||||
var sortedItemCounts = itemCounts.OrderBy(kvp => kvp.Key).ToList();
|
||||
|
||||
var chartData = sortedItemCounts.Select(kvp => new ChartData
|
||||
{
|
||||
SeriesName = kvp.Key, // Название товара
|
||||
Data = new Dictionary<string, double> { { kvp.Key, kvp.Value } }
|
||||
}).ToList();
|
||||
|
||||
string filePath = saveFileDialog.FileName;
|
||||
|
||||
histogramGenerator.CreateHistogramPdf(filePath, "", "Диаграмма заказов", OxyPlot.Legends.LegendPosition.BottomCenter, chartData);
|
||||
|
||||
MessageBox.Show("PDF успешно сгенерирован!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Ошибка: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
135
VolkovLabs/InternetShopOrdersApp/FormMain.resx
Normal file
135
VolkovLabs/InternetShopOrdersApp/FormMain.resx
Normal file
@ -0,0 +1,135 @@
|
||||
<?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="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="excelImagesComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>138, 17</value>
|
||||
</metadata>
|
||||
<metadata name="componentHistogramToPdf.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>734, 22</value>
|
||||
</metadata>
|
||||
<metadata name="componentDocumentWithTableHeaderRowWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>328, 20</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>177</value>
|
||||
</metadata>
|
||||
</root>
|
163
VolkovLabs/InternetShopOrdersApp/FormOrder.Designer.cs
generated
Normal file
163
VolkovLabs/InternetShopOrdersApp/FormOrder.Designer.cs
generated
Normal file
@ -0,0 +1,163 @@
|
||||
namespace InternetShopOrdersApp
|
||||
{
|
||||
partial class FormOrder
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelFIO = new Label();
|
||||
textBoxFIO = new TextBox();
|
||||
labelMail = new Label();
|
||||
labelSelectedItem = new Label();
|
||||
customSelectedCheckedListBox = new WinFormsLibraryVolkov.CustomSelectedCheckedListBox();
|
||||
buttonOrderPic = new Button();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
openFileDialog = new OpenFileDialog();
|
||||
mailControl = new NevaevaLibrary.MailControl();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelFIO
|
||||
//
|
||||
labelFIO.AutoSize = true;
|
||||
labelFIO.Location = new Point(12, 9);
|
||||
labelFIO.Name = "labelFIO";
|
||||
labelFIO.Size = new Size(107, 19);
|
||||
labelFIO.TabIndex = 0;
|
||||
labelFIO.Text = "ФИО заказчика";
|
||||
//
|
||||
// textBoxFIO
|
||||
//
|
||||
textBoxFIO.Location = new Point(12, 31);
|
||||
textBoxFIO.Name = "textBoxFIO";
|
||||
textBoxFIO.Size = new Size(471, 26);
|
||||
textBoxFIO.TabIndex = 1;
|
||||
//
|
||||
// labelMail
|
||||
//
|
||||
labelMail.AutoSize = true;
|
||||
labelMail.Location = new Point(12, 228);
|
||||
labelMail.Name = "labelMail";
|
||||
labelMail.Size = new Size(132, 19);
|
||||
labelMail.TabIndex = 2;
|
||||
labelMail.Text = "Электронная почта";
|
||||
//
|
||||
// labelSelectedItem
|
||||
//
|
||||
labelSelectedItem.AutoSize = true;
|
||||
labelSelectedItem.Location = new Point(12, 79);
|
||||
labelSelectedItem.Name = "labelSelectedItem";
|
||||
labelSelectedItem.Size = new Size(124, 19);
|
||||
labelSelectedItem.TabIndex = 4;
|
||||
labelSelectedItem.Text = "Выбранный товар";
|
||||
//
|
||||
// customSelectedCheckedListBox
|
||||
//
|
||||
customSelectedCheckedListBox.Location = new Point(12, 102);
|
||||
customSelectedCheckedListBox.Margin = new Padding(3, 4, 3, 4);
|
||||
customSelectedCheckedListBox.Name = "customSelectedCheckedListBox";
|
||||
customSelectedCheckedListBox.SelectedElement = "";
|
||||
customSelectedCheckedListBox.Size = new Size(196, 122);
|
||||
customSelectedCheckedListBox.TabIndex = 5;
|
||||
//
|
||||
// buttonOrderPic
|
||||
//
|
||||
buttonOrderPic.Location = new Point(12, 331);
|
||||
buttonOrderPic.Name = "buttonOrderPic";
|
||||
buttonOrderPic.Size = new Size(471, 26);
|
||||
buttonOrderPic.TabIndex = 6;
|
||||
buttonOrderPic.Text = "Выбрать фото заказа";
|
||||
buttonOrderPic.UseVisualStyleBackColor = true;
|
||||
buttonOrderPic.Click += buttonOrderPic_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(388, 412);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(95, 26);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отменить";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(12, 412);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(107, 26);
|
||||
buttonSave.TabIndex = 8;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
openFileDialog.FileName = "openFileDialog";
|
||||
openFileDialog.Multiselect = true;
|
||||
//
|
||||
// mailControl
|
||||
//
|
||||
mailControl.Email = null;
|
||||
mailControl.Location = new Point(12, 250);
|
||||
mailControl.Name = "mailControl";
|
||||
mailControl.Size = new Size(280, 37);
|
||||
mailControl.TabIndex = 9;
|
||||
mailControl.validateEmailRegex = null;
|
||||
//
|
||||
// FormOrder
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 19F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(495, 450);
|
||||
Controls.Add(mailControl);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonOrderPic);
|
||||
Controls.Add(customSelectedCheckedListBox);
|
||||
Controls.Add(labelSelectedItem);
|
||||
Controls.Add(labelMail);
|
||||
Controls.Add(textBoxFIO);
|
||||
Controls.Add(labelFIO);
|
||||
Name = "FormOrder";
|
||||
Text = "Заказ";
|
||||
Load += FormOrder_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelFIO;
|
||||
private TextBox textBoxFIO;
|
||||
private Label labelMail;
|
||||
private Label labelSelectedItem;
|
||||
private WinFormsLibraryVolkov.CustomSelectedCheckedListBox customSelectedCheckedListBox;
|
||||
private Button buttonOrderPic;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private NevaevaLibrary.MailControl mailControl;
|
||||
}
|
||||
}
|
116
VolkovLabs/InternetShopOrdersApp/FormOrder.cs
Normal file
116
VolkovLabs/InternetShopOrdersApp/FormOrder.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.BusinessLogicContracts;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Diagnostics;
|
||||
using NevaevaLibrary;
|
||||
|
||||
namespace InternetShopOrdersApp
|
||||
{
|
||||
public partial class FormOrder : Form
|
||||
{
|
||||
private int? _id;
|
||||
private readonly IOrderLogic _logic;
|
||||
private readonly ISelectedItemLogic _selectedItemLogic;
|
||||
private List<SelectedItemViewModel> _selectedItems;
|
||||
private string? orderImage = null;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormOrder(IOrderLogic logic, ISelectedItemLogic selectedItemLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
_selectedItemLogic = selectedItemLogic;
|
||||
_selectedItems = new List<SelectedItemViewModel>();
|
||||
}
|
||||
|
||||
private void FormOrder_Load(object sender, EventArgs e)
|
||||
{
|
||||
_selectedItems = _selectedItemLogic.ReadList(null);
|
||||
customSelectedCheckedListBox.PopulateList(_selectedItems.Select(x => x.Name).ToList());
|
||||
mailControl.validateEmailRegex = new System.Text.RegularExpressions.Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
|
||||
mailControl.setTooltipText("name@example.com");
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new OrderSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxFIO.Text = view.Fullname;
|
||||
customSelectedCheckedListBox.SelectedElement = view.SelectedItemName;
|
||||
mailControl.Email = view.Email;
|
||||
orderImage = view.OrderImage;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxFIO.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните ФИО заказчика", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
if (customSelectedCheckedListBox.SelectedElement == null)
|
||||
{
|
||||
MessageBox.Show("Укажите выбранные товары", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
if (orderImage == null)
|
||||
{
|
||||
MessageBox.Show("Выберите фото заказа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
if (string.IsNullOrEmpty(mailControl.Email))
|
||||
{
|
||||
MessageBox.Show("Не указана почта, либо она не соответствует шаблону.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var model = new OrderBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Fullname = textBoxFIO.Text,
|
||||
OrderImage = orderImage,
|
||||
SelectedItemId = _selectedItems.First(x => x.Name == customSelectedCheckedListBox.SelectedElement).Id,
|
||||
Email = mailControl.Email,
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Возникла ошибка при сохранении. Дополнительная информация в логах");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Успешное сохранение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonOrderPic_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() != DialogResult.Cancel)
|
||||
{
|
||||
orderImage = openFileDialog.FileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
123
VolkovLabs/InternetShopOrdersApp/FormOrder.resx
Normal file
123
VolkovLabs/InternetShopOrdersApp/FormOrder.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="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
84
VolkovLabs/InternetShopOrdersApp/FormSelectedItems.Designer.cs
generated
Normal file
84
VolkovLabs/InternetShopOrdersApp/FormSelectedItems.Designer.cs
generated
Normal file
@ -0,0 +1,84 @@
|
||||
namespace InternetShopOrdersApp
|
||||
{
|
||||
partial class FormSelectedItems
|
||||
{
|
||||
/// <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();
|
||||
NameCol = new DataGridViewTextBoxColumn();
|
||||
Id = new DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { NameCol, Id });
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 47;
|
||||
dataGridView.Size = new Size(800, 356);
|
||||
dataGridView.TabIndex = 0;
|
||||
dataGridView.CellValueChanged += dataGridView_CellValueChanged;
|
||||
dataGridView.UserDeletingRow += dataGridView_UserDeletingRow;
|
||||
dataGridView.KeyUp += dataGridView_KeyUp;
|
||||
//
|
||||
// NameCol
|
||||
//
|
||||
NameCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
NameCol.HeaderText = "Название товара";
|
||||
NameCol.MinimumWidth = 6;
|
||||
NameCol.Name = "NameCol";
|
||||
//
|
||||
// Id
|
||||
//
|
||||
Id.HeaderText = "Id";
|
||||
Id.MinimumWidth = 6;
|
||||
Id.Name = "Id";
|
||||
Id.Visible = false;
|
||||
Id.Width = 125;
|
||||
//
|
||||
// FormSelectedItems
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 19F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 356);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormSelectedItems";
|
||||
Text = "Выбранные товары";
|
||||
Load += FormSelectedItems_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn NameCol;
|
||||
private DataGridViewTextBoxColumn Id;
|
||||
}
|
||||
}
|
104
VolkovLabs/InternetShopOrdersApp/FormSelectedItems.cs
Normal file
104
VolkovLabs/InternetShopOrdersApp/FormSelectedItems.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.BusinessLogicContracts;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
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 InternetShopOrdersApp
|
||||
{
|
||||
public partial class FormSelectedItems : Form
|
||||
{
|
||||
private readonly ISelectedItemLogic _logic;
|
||||
private bool loading = false;
|
||||
|
||||
public FormSelectedItems(ISelectedItemLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
loading = true;
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var selectedItem in list)
|
||||
{
|
||||
int rowIndex = dataGridView.Rows.Add();
|
||||
dataGridView.Rows[rowIndex].Cells[0].Value = selectedItem.Name;
|
||||
dataGridView.Rows[rowIndex].Cells[1].Value = selectedItem.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void FormSelectedItems_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (loading || e.RowIndex < 0 || e.ColumnIndex != 0) return;
|
||||
if (dataGridView.Rows[e.RowIndex].Cells[1].Value != null && !string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[1].Value.ToString()))
|
||||
{
|
||||
var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
if (name is null) return;
|
||||
_logic.Update(new SelectedItemBindingModel { Id = Convert.ToInt32(dataGridView.Rows[e.RowIndex].Cells[1].Value), Name = name.ToString() });
|
||||
}
|
||||
else
|
||||
{
|
||||
var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
if (name is null) return;
|
||||
_logic.Create(new SelectedItemBindingModel { Id = 0, Name = name.ToString() });
|
||||
int newInterestId = _logic.ReadList(null).ToList().Last().Id;
|
||||
dataGridView.Rows[e.RowIndex].Cells[1].Value = newInterestId;
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Insert:
|
||||
dataGridView.Rows.Add();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteRows(DataGridViewSelectedRowCollection rows)
|
||||
{
|
||||
for (int i = 0; i < rows.Count; i++)
|
||||
{
|
||||
DataGridViewRow row = rows[i];
|
||||
if (!_logic.Delete(new SelectedItemBindingModel { Id = Convert.ToInt32(row.Cells[1].Value) })) continue;
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
|
||||
{
|
||||
e.Cancel = true;
|
||||
if (dataGridView.SelectedRows == null) return;
|
||||
if (MessageBox.Show("Удалить записи?", "Подтвердите действие", MessageBoxButtons.YesNo) == DialogResult.No) return;
|
||||
deleteRows(dataGridView.SelectedRows);
|
||||
}
|
||||
}
|
||||
}
|
126
VolkovLabs/InternetShopOrdersApp/FormSelectedItems.resx
Normal file
126
VolkovLabs/InternetShopOrdersApp/FormSelectedItems.resx
Normal file
@ -0,0 +1,126 @@
|
||||
<?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="NameCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -0,0 +1,30 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<OutputType>WinExe</OutputType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
|
||||
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
|
||||
<PackageReference Include="FormLibrary" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
|
||||
<PackageReference Include="NevaevaLibrary" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\InternetShopOrdersBusinessLogic\InternetShopOrdersBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\InternetShopOrdersContracts\InternetShopOrdersContracts.csproj" />
|
||||
<ProjectReference Include="..\InternetShopOrdersDatabaseImplement\InternetShopOrdersDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\WinFormsLibraryVolkov\WinFormsLibraryVolkov.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
41
VolkovLabs/InternetShopOrdersApp/Program.cs
Normal file
41
VolkovLabs/InternetShopOrdersApp/Program.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using InternetShopOrdersBusinessLogic.BusinessLogics;
|
||||
using InternetShopOrdersContracts.BusinessLogicContracts;
|
||||
using InternetShopOrdersContracts.StorageContracts;
|
||||
using InternetShopOrdersDatabaseImplement.Implements;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
|
||||
namespace InternetShopOrdersApp
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddTransient<ISelectedItemStorage, SelectedItemStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<ISelectedItemLogic, SelectedItemLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormOrder>();
|
||||
services.AddTransient<FormSelectedItems>();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.BusinessLogicContracts;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.StorageContracts;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
|
||||
namespace InternetShopOrdersBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class OrderLogic : IOrderLogic
|
||||
{
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
|
||||
public OrderLogic(IOrderStorage orderStorage)
|
||||
{
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public OrderViewModel? ReadElement(OrderSearchModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
var element = _orderStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_orderStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_orderStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Fullname))
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО заказчика", nameof(model.Fullname));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
throw new ArgumentNullException("Нет электронной почты заказчика", nameof(model.Email));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.BusinessLogicContracts;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.StorageContracts;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
|
||||
namespace InternetShopOrdersBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class SelectedItemLogic : ISelectedItemLogic
|
||||
{
|
||||
private readonly ISelectedItemStorage _selectedItemStorage;
|
||||
|
||||
public SelectedItemLogic(ISelectedItemStorage selectedItemStorage)
|
||||
{
|
||||
_selectedItemStorage = selectedItemStorage;
|
||||
}
|
||||
|
||||
public List<SelectedItemViewModel>? ReadList(SelectedItemSearchModel? model)
|
||||
{
|
||||
var list = model == null ? _selectedItemStorage.GetFullList() : _selectedItemStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public SelectedItemViewModel? ReadElement(SelectedItemSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
var element = _selectedItemStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(SelectedItemBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_selectedItemStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(SelectedItemBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_selectedItemStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(SelectedItemBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_selectedItemStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(SelectedItemBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия выбранного товара", nameof(model.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\InternetShopOrdersContracts\InternetShopOrdersContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,13 @@
|
||||
using InternetShopOrdersDataModels.Models;
|
||||
|
||||
namespace InternetShopOrdersContracts.BindingModels
|
||||
{
|
||||
public class OrderBindingModel : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Fullname { get; set; } = string.Empty;
|
||||
public string OrderImage { get; set; }
|
||||
public int SelectedItemId { get; set; }
|
||||
public string Email { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using InternetShopOrdersDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.BindingModels
|
||||
{
|
||||
public class SelectedItemBindingModel : ISelectedItemModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = String.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IOrderLogic
|
||||
{
|
||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||
bool Create(OrderBindingModel model);
|
||||
bool Update(OrderBindingModel model);
|
||||
bool Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface ISelectedItemLogic
|
||||
{
|
||||
List<SelectedItemViewModel>? ReadList(SelectedItemSearchModel? model);
|
||||
SelectedItemViewModel? ReadElement(SelectedItemSearchModel model);
|
||||
bool Create(SelectedItemBindingModel model);
|
||||
bool Update(SelectedItemBindingModel model);
|
||||
bool Delete(SelectedItemBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\InternetShopDataModels\InternetShopDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.SearchModels
|
||||
{
|
||||
public class OrderSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.SearchModels
|
||||
{
|
||||
public class SelectedItemSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.StorageContracts
|
||||
{
|
||||
public interface IOrderStorage
|
||||
{
|
||||
List<OrderViewModel> GetFullList();
|
||||
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
||||
OrderViewModel? GetElement(OrderSearchModel model);
|
||||
OrderViewModel? Insert(OrderBindingModel model);
|
||||
OrderViewModel? Update(OrderBindingModel model);
|
||||
OrderViewModel? Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.StorageContracts
|
||||
{
|
||||
public interface ISelectedItemStorage
|
||||
{
|
||||
List<SelectedItemViewModel> GetFullList();
|
||||
List<SelectedItemViewModel> GetFilteredList(SelectedItemSearchModel model);
|
||||
SelectedItemViewModel? GetElement(SelectedItemSearchModel model);
|
||||
SelectedItemViewModel? Insert(SelectedItemBindingModel model);
|
||||
SelectedItemViewModel? Update(SelectedItemBindingModel model);
|
||||
SelectedItemViewModel? Delete(SelectedItemBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using InternetShopOrdersDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("ФИО заказчика")]
|
||||
public string Fullname { get; set; } = string.Empty;
|
||||
|
||||
public string OrderImage { get; set; } = string.Empty;
|
||||
|
||||
public int SelectedItemId { get; set; }
|
||||
public string SelectedItemName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Электронная почта")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using InternetShopOrdersDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.ViewModels
|
||||
{
|
||||
public class SelectedItemViewModel : ISelectedItemModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.StorageContracts;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using InternetShopOrdersDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Principal;
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new OrdersDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.SelectedItem)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new OrdersDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.SelectedItem)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new OrdersDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.SelectedItem)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
using var context = new OrdersDatabase();
|
||||
var newOrder = Orders.Create(context, model);
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return newOrder.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
using var context = new OrdersDatabase();
|
||||
var Order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (Order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Order.Update(model, context);
|
||||
context.SaveChanges();
|
||||
return Order.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new OrdersDatabase();
|
||||
var element = context.Orders
|
||||
.Include(x => x.SelectedItem)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Orders.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.StorageContracts;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using InternetShopOrdersDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement.Implements
|
||||
{
|
||||
public class SelectedItemStorage : ISelectedItemStorage
|
||||
{
|
||||
public List<SelectedItemViewModel> GetFullList()
|
||||
{
|
||||
using var context = new OrdersDatabase();
|
||||
return context.SelectedItems
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<SelectedItemViewModel> GetFilteredList(SelectedItemSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new OrdersDatabase();
|
||||
return context.SelectedItems
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public SelectedItemViewModel? GetElement(SelectedItemSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new OrdersDatabase();
|
||||
return context.SelectedItems
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public SelectedItemViewModel? Insert(SelectedItemBindingModel model)
|
||||
{
|
||||
var newSelectedItem = SelectedItem.Create(model);
|
||||
if (newSelectedItem == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new OrdersDatabase();
|
||||
context.SelectedItems.Add(newSelectedItem);
|
||||
context.SaveChanges();
|
||||
return newSelectedItem.GetViewModel;
|
||||
}
|
||||
public SelectedItemViewModel? Update(SelectedItemBindingModel model)
|
||||
{
|
||||
using var context = new OrdersDatabase();
|
||||
var component = context.SelectedItems.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
public SelectedItemViewModel? Delete(SelectedItemBindingModel model)
|
||||
{
|
||||
using var context = new OrdersDatabase();
|
||||
var element = context.SelectedItems.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.SelectedItems.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\InternetShopOrdersContracts\InternetShopOrdersContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
87
VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241016152345_InitialMig.Designer.cs
generated
Normal file
87
VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241016152345_InitialMig.Designer.cs
generated
Normal file
@ -0,0 +1,87 @@
|
||||
// <auto-generated />
|
||||
using InternetShopOrdersDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(OrdersDatabase))]
|
||||
[Migration("20241016152345_InitialMig")]
|
||||
partial class InitialMig
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.10")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("InternetShopOrdersDatabaseImplement.Models.Orders", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Fullname")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("OrderImage")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("SelectedItemId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SelectedItemId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternetShopOrdersDatabaseImplement.Models.SelectedItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SelectedItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternetShopOrdersDatabaseImplement.Models.Orders", b =>
|
||||
{
|
||||
b.HasOne("InternetShopOrdersDatabaseImplement.Models.SelectedItem", "SelectedItem")
|
||||
.WithMany()
|
||||
.HasForeignKey("SelectedItemId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("SelectedItem");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialMig : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SelectedItems",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SelectedItems", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Fullname = table.Column<string>(type: "text", nullable: false),
|
||||
Email = table.Column<string>(type: "text", nullable: false),
|
||||
SelectedItemId = table.Column<int>(type: "integer", nullable: false),
|
||||
OrderImage = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_SelectedItems_SelectedItemId",
|
||||
column: x => x.SelectedItemId,
|
||||
principalTable: "SelectedItems",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_SelectedItemId",
|
||||
table: "Orders",
|
||||
column: "SelectedItemId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SelectedItems");
|
||||
}
|
||||
}
|
||||
}
|
87
VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241111112246_SecondMig.Designer.cs
generated
Normal file
87
VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241111112246_SecondMig.Designer.cs
generated
Normal file
@ -0,0 +1,87 @@
|
||||
// <auto-generated />
|
||||
using InternetShopOrdersDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(OrdersDatabase))]
|
||||
[Migration("20241111112246_SecondMig")]
|
||||
partial class SecondMig
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.10")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("InternetShopOrdersDatabaseImplement.Models.Orders", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Fullname")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("OrderImage")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("SelectedItemId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SelectedItemId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternetShopOrdersDatabaseImplement.Models.SelectedItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SelectedItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternetShopOrdersDatabaseImplement.Models.Orders", b =>
|
||||
{
|
||||
b.HasOne("InternetShopOrdersDatabaseImplement.Models.SelectedItem", "SelectedItem")
|
||||
.WithMany()
|
||||
.HasForeignKey("SelectedItemId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("SelectedItem");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class SecondMig : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
// <auto-generated />
|
||||
using InternetShopOrdersDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(OrdersDatabase))]
|
||||
partial class OrdersDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.10")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("InternetShopOrdersDatabaseImplement.Models.Orders", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Fullname")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("OrderImage")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("SelectedItemId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SelectedItemId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternetShopOrdersDatabaseImplement.Models.SelectedItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SelectedItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("InternetShopOrdersDatabaseImplement.Models.Orders", b =>
|
||||
{
|
||||
b.HasOne("InternetShopOrdersDatabaseImplement.Models.SelectedItem", "SelectedItem")
|
||||
.WithMany()
|
||||
.HasForeignKey("SelectedItemId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("SelectedItem");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using InternetShopOrdersDataModels.Models;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement.Models
|
||||
{
|
||||
public class Orders : IOrderModel
|
||||
{
|
||||
[Required]
|
||||
public string Fullname { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; private set; }
|
||||
|
||||
public int SelectedItemId { get; set; }
|
||||
|
||||
public virtual SelectedItem SelectedItem { get; set; } = new();
|
||||
|
||||
[Required]
|
||||
public string OrderImage { get; set; } = string.Empty;
|
||||
|
||||
public static Orders? Create(OrdersDatabase context, OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Orders()
|
||||
{
|
||||
Id = model.Id,
|
||||
Fullname = model.Fullname,
|
||||
Email = model.Email,
|
||||
SelectedItemId = model.SelectedItemId,
|
||||
SelectedItem = context.SelectedItems.First(x => x.Id == model.SelectedItemId),
|
||||
OrderImage = model.OrderImage,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel? model, OrdersDatabase context)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Fullname = model.Fullname;
|
||||
SelectedItemId = model.SelectedItemId;
|
||||
Email = model.Email;
|
||||
SelectedItem = context.SelectedItems.First(x => x.Id == model.SelectedItemId);
|
||||
OrderImage = model.OrderImage;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Fullname = Fullname,
|
||||
Email = Email,
|
||||
SelectedItemId = SelectedItemId,
|
||||
SelectedItemName = SelectedItem.Name,
|
||||
OrderImage = OrderImage,
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using InternetShopOrdersDataModels.Models;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement.Models
|
||||
{
|
||||
public class SelectedItem : ISelectedItemModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
|
||||
public static SelectedItem? Create(SelectedItemBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new SelectedItem()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
};
|
||||
}
|
||||
public static SelectedItem? Create(SelectedItemViewModel? model)
|
||||
{
|
||||
return new SelectedItem()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
};
|
||||
}
|
||||
public void Update(SelectedItemBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Name = model.Name;
|
||||
}
|
||||
public SelectedItemViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using InternetShopOrdersDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement
|
||||
{
|
||||
public class OrdersDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
=> optionsBuilder.UseNpgsql("Host=localhost;Database=InternetShopOrdersDB;Username=postgres;Password=postgres");
|
||||
|
||||
public virtual DbSet<Orders> Orders { set; get; }
|
||||
public virtual DbSet<SelectedItem> SelectedItems { set; get; }
|
||||
}
|
||||
}
|
BIN
VolkovLabs/NuGetPackages.7z
Normal file
BIN
VolkovLabs/NuGetPackages.7z
Normal file
Binary file not shown.
61
VolkovLabs/VolkovLabs.sln
Normal file
61
VolkovLabs/VolkovLabs.sln
Normal file
@ -0,0 +1,61 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34723.18
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsLibraryVolkov", "WinFormsLibraryVolkov\WinFormsLibraryVolkov.csproj", "{80044A4D-FF3B-4CA9-AA16-4E4E2520B60C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsTestApp", "WinFormsTestApp\WinFormsTestApp.csproj", "{10C4BDA8-E7E7-4B43-8F9E-6549C5C40646}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InternetShopOrdersBusinessLogic", "InternetShopOrdersBusinessLogic\InternetShopOrdersBusinessLogic.csproj", "{30B57BEC-D1B0-411A-87B2-3E138A20DC8E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InternetShopOrdersContracts", "InternetShopOrdersContracts\InternetShopOrdersContracts.csproj", "{8883886C-DDAC-43DC-885F-4A9B2FBE007E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InternetShopOrdersDatabaseImplement", "InternetShopOrdersDatabaseImplement\InternetShopOrdersDatabaseImplement.csproj", "{3F616681-9757-4B12-9931-CC7B6872FD5F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InternetShopDataModels", "InternetShopDataModels\InternetShopDataModels.csproj", "{1CEB87FB-BA72-491C-9125-0B3527EF612E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InternetShopOrdersApp", "InternetShopOrdersApp\InternetShopOrdersApp.csproj", "{13A6EC26-C739-4891-964C-4A0E5E8D43C3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{80044A4D-FF3B-4CA9-AA16-4E4E2520B60C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{80044A4D-FF3B-4CA9-AA16-4E4E2520B60C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{80044A4D-FF3B-4CA9-AA16-4E4E2520B60C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{80044A4D-FF3B-4CA9-AA16-4E4E2520B60C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{10C4BDA8-E7E7-4B43-8F9E-6549C5C40646}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{10C4BDA8-E7E7-4B43-8F9E-6549C5C40646}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{10C4BDA8-E7E7-4B43-8F9E-6549C5C40646}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{10C4BDA8-E7E7-4B43-8F9E-6549C5C40646}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{30B57BEC-D1B0-411A-87B2-3E138A20DC8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{30B57BEC-D1B0-411A-87B2-3E138A20DC8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{30B57BEC-D1B0-411A-87B2-3E138A20DC8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{30B57BEC-D1B0-411A-87B2-3E138A20DC8E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8883886C-DDAC-43DC-885F-4A9B2FBE007E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8883886C-DDAC-43DC-885F-4A9B2FBE007E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8883886C-DDAC-43DC-885F-4A9B2FBE007E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8883886C-DDAC-43DC-885F-4A9B2FBE007E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3F616681-9757-4B12-9931-CC7B6872FD5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3F616681-9757-4B12-9931-CC7B6872FD5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3F616681-9757-4B12-9931-CC7B6872FD5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3F616681-9757-4B12-9931-CC7B6872FD5F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1CEB87FB-BA72-491C-9125-0B3527EF612E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1CEB87FB-BA72-491C-9125-0B3527EF612E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1CEB87FB-BA72-491C-9125-0B3527EF612E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1CEB87FB-BA72-491C-9125-0B3527EF612E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{13A6EC26-C739-4891-964C-4A0E5E8D43C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{13A6EC26-C739-4891-964C-4A0E5E8D43C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{13A6EC26-C739-4891-964C-4A0E5E8D43C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{13A6EC26-C739-4891-964C-4A0E5E8D43C3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {07EF6063-AD68-403B-A72B-B19E4B920CD0}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinFormsLibraryVolkov.Exceptions
|
||||
{
|
||||
[Serializable]
|
||||
public class DateBoundsNotSetException: ApplicationException
|
||||
{
|
||||
public DateBoundsNotSetException() : base() { }
|
||||
public DateBoundsNotSetException(string message) : base(message) { }
|
||||
public DateBoundsNotSetException(string message, Exception exception) : base(message, exception){ }
|
||||
protected DateBoundsNotSetException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinFormsLibraryVolkov.Exceptions
|
||||
{
|
||||
public class DateOutOfBoundsException : ApplicationException
|
||||
{
|
||||
public DateOutOfBoundsException() : base() { }
|
||||
public DateOutOfBoundsException(string message) : base(message) { }
|
||||
public DateOutOfBoundsException(string message, Exception exception) : base(message, exception) { }
|
||||
protected DateOutOfBoundsException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinFormsLibraryVolkov.NonVisualComponents
|
||||
{
|
||||
public enum DiagramLegendEnum
|
||||
{
|
||||
TopLeft = 0,
|
||||
TopRight = 1,
|
||||
BottomRight = 2,
|
||||
BottomLeft = 3,
|
||||
}
|
||||
}
|
36
VolkovLabs/WinFormsLibraryVolkov/NonVisualComponents/ExcelDiagramComponent.Designer.cs
generated
Normal file
36
VolkovLabs/WinFormsLibraryVolkov/NonVisualComponents/ExcelDiagramComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace WinFormsLibraryVolkov.NonVisualComponents
|
||||
{
|
||||
partial class ExcelDiagramComponent
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinFormsLibraryVolkov.NonVisualComponents
|
||||
{
|
||||
[ToolboxItem(true)]
|
||||
public partial class ExcelDiagramComponent : Component
|
||||
{
|
||||
public ExcelDiagramComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ExcelDiagramComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public bool createWithDiagram<T>(string path, string title, string diagramTitle, DiagramLegendEnum diagramLegendAnchor, List<T> data, string seriesNameField, string valueField)
|
||||
{
|
||||
var excelApp = new Microsoft.Office.Interop.Excel.Application { SheetsInNewWorkbook = 1 };
|
||||
Workbook workbook = excelApp.Workbooks.Add(Type.Missing);
|
||||
try
|
||||
{
|
||||
Worksheet worksheet = (Worksheet)workbook.Worksheets.get_Item(1);
|
||||
|
||||
FieldInfo? seriesName = typeof(T).GetField(seriesNameField);
|
||||
FieldInfo? value = typeof(T).GetField(valueField);
|
||||
if (seriesName == null || value == null) throw new ArgumentException("Переданного поля не существует");
|
||||
int columnCount = 2;
|
||||
foreach(var item in data)
|
||||
{
|
||||
var cell = worksheet.get_Range("A" + columnCount, "A" + columnCount);
|
||||
cell.Font.Size = 14;
|
||||
cell.Font.Name = "Times New Roman";
|
||||
cell.ColumnWidth = 8;
|
||||
cell.RowHeight = 25;
|
||||
cell.HorizontalAlignment = Constants.xlCenter;
|
||||
cell.VerticalAlignment = Constants.xlCenter;
|
||||
cell.Value2 = seriesName.GetValue(item);
|
||||
|
||||
cell = worksheet.get_Range("B" + columnCount, "B" + columnCount);
|
||||
cell.Font.Size = 14;
|
||||
cell.Font.Name = "Times New Roman";
|
||||
cell.ColumnWidth = 8;
|
||||
cell.RowHeight = 25;
|
||||
cell.HorizontalAlignment = Constants.xlCenter;
|
||||
cell.VerticalAlignment = Constants.xlCenter;
|
||||
cell.Value2 = value.GetValue(item);
|
||||
|
||||
columnCount++;
|
||||
}
|
||||
|
||||
//header
|
||||
var excelcells = worksheet.get_Range("A1", "A1");
|
||||
excelcells.Font.Bold = true;
|
||||
excelcells.Font.Size = 14;
|
||||
excelcells.Font.Name = "Times New Roman";
|
||||
excelcells.ColumnWidth = 8;
|
||||
excelcells.RowHeight = 25;
|
||||
excelcells.HorizontalAlignment = Constants.xlCenter;
|
||||
excelcells.VerticalAlignment = Constants.xlCenter;
|
||||
excelcells.Value2 = title;
|
||||
|
||||
var charts = worksheet.ChartObjects() as ChartObjects;
|
||||
int chartWidth = 300;
|
||||
int chartHeight = 300;
|
||||
var chartObject = charts.Add(250, 10, chartWidth, chartHeight);
|
||||
var chart = chartObject.Chart;
|
||||
var range = worksheet.get_Range($"A2", $"B{columnCount - 1}");
|
||||
chart.SetSourceData(range);
|
||||
chart.ChartType = XlChartType.xlPie;
|
||||
switch (diagramLegendAnchor)
|
||||
{
|
||||
case DiagramLegendEnum.TopLeft:
|
||||
chart.Legend.Top = 0;
|
||||
chart.Legend.Left = 0;
|
||||
break;
|
||||
case DiagramLegendEnum.TopRight:
|
||||
chart.Legend.Top = 0;
|
||||
chart.Legend.Left = chartWidth - chart.Legend.Width;
|
||||
break;
|
||||
case DiagramLegendEnum.BottomLeft:
|
||||
chart.Legend.Top = chartHeight - chart.Legend.Height;
|
||||
chart.Legend.Left = 0;
|
||||
break;
|
||||
case DiagramLegendEnum.BottomRight:
|
||||
chart.Legend.Top = chartHeight - chart.Legend.Height;
|
||||
chart.Legend.Left = chartWidth - chart.Legend.Width;
|
||||
break;
|
||||
}
|
||||
chart.ChartWizard(Source: range, Title: diagramTitle);
|
||||
|
||||
object missing = System.Reflection.Missing.Value;
|
||||
workbook.SaveAs(path, XlFileFormat.xlOpenXMLWorkbook, missing, missing, false, false, XlSaveAsAccessMode.xlNoChange,
|
||||
XlSaveConflictResolution.xlUserResolution, true, missing, missing, missing);
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinFormsLibraryVolkov.NonVisualComponents
|
||||
{
|
||||
public class ExcelImageInfo
|
||||
{
|
||||
public ExcelImageInfo(string path, string title, string[] imagePaths)
|
||||
{
|
||||
this.path = path;
|
||||
this.title = title;
|
||||
this.imagePaths = imagePaths;
|
||||
}
|
||||
|
||||
public string path;
|
||||
public string title;
|
||||
public string[] imagePaths;
|
||||
}
|
||||
}
|
36
VolkovLabs/WinFormsLibraryVolkov/NonVisualComponents/ExcelImagesComponent.Designer.cs
generated
Normal file
36
VolkovLabs/WinFormsLibraryVolkov/NonVisualComponents/ExcelImagesComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace WinFormsLibraryVolkov.NonVisualComponents
|
||||
{
|
||||
partial class ExcelImagesComponent
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
using Microsoft.Office.Core;
|
||||
|
||||
namespace WinFormsLibraryVolkov.NonVisualComponents
|
||||
{
|
||||
public partial class ExcelImagesComponent : Component
|
||||
{
|
||||
public ExcelImagesComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ExcelImagesComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public bool createWithImages(ExcelImageInfo info)
|
||||
{
|
||||
var excelApp = new Microsoft.Office.Interop.Excel.Application { SheetsInNewWorkbook = 1 };
|
||||
Workbook workbook = excelApp.Workbooks.Add(Type.Missing);
|
||||
try
|
||||
{
|
||||
//create
|
||||
Worksheet worksheet = (Worksheet)workbook.Worksheets.get_Item(1);
|
||||
|
||||
//header
|
||||
var excelcells = worksheet.get_Range("A1", "D1");
|
||||
excelcells.Merge(Type.Missing);
|
||||
excelcells.Font.Bold = true;
|
||||
excelcells.Font.Size = 14;
|
||||
excelcells.Font.Name = "Times New Roman";
|
||||
excelcells.ColumnWidth = 8;
|
||||
excelcells.RowHeight = 25;
|
||||
excelcells.HorizontalAlignment = Constants.xlCenter;
|
||||
excelcells.VerticalAlignment = Constants.xlCenter;
|
||||
excelcells.Value2 = info.title;
|
||||
|
||||
int topOffset = 25;
|
||||
foreach (string path in info.imagePaths)
|
||||
{
|
||||
Bitmap bm = new Bitmap(path);
|
||||
worksheet.Shapes.AddPicture2(path, MsoTriState.msoFalse, MsoTriState.msoCTrue, 0, topOffset, bm.Width, bm.Height, MsoPictureCompress.msoPictureCompressFalse);
|
||||
topOffset += bm.Height;
|
||||
bm.Dispose();
|
||||
}
|
||||
|
||||
//save
|
||||
object missing = System.Reflection.Missing.Value;
|
||||
workbook.SaveAs(info.path, XlFileFormat.xlOpenXMLWorkbook, missing, missing, false, false, XlSaveAsAccessMode.xlNoChange,
|
||||
XlSaveConflictResolution.xlUserResolution, true, missing, missing, missing);
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
36
VolkovLabs/WinFormsLibraryVolkov/NonVisualComponents/ExcelTableComponent.Designer.cs
generated
Normal file
36
VolkovLabs/WinFormsLibraryVolkov/NonVisualComponents/ExcelTableComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace WinFormsLibraryVolkov.NonVisualComponents
|
||||
{
|
||||
partial class ExcelTableComponent
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
@ -0,0 +1,193 @@
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data.Common;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinFormsLibraryVolkov.NonVisualComponents
|
||||
{
|
||||
public partial class ExcelTableComponent : Component
|
||||
{
|
||||
public ExcelTableComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ExcelTableComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private string GetExcelColumnName(int columnNumber)
|
||||
{
|
||||
string columnName = "";
|
||||
|
||||
while (columnNumber > 0)
|
||||
{
|
||||
int modulo = (columnNumber - 1) % 26;
|
||||
columnName = Convert.ToChar('A' + modulo) + columnName;
|
||||
columnNumber = (columnNumber - modulo) / 26;
|
||||
}
|
||||
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public bool createWithTable<T>(string path, string title, List<(int, int)> merges, List<int> heights, List<(string, string)> headers, List<T> items)
|
||||
{
|
||||
if (merges.Count == 0 || heights.Count == 0 || headers.Count == 0 || items.Count == 0) throw new ArgumentException("Недостаточно данных");
|
||||
int[] cellsArray = new int[heights.Count];
|
||||
foreach (var merge in merges)
|
||||
{
|
||||
if (merge.Item1 >= merge.Item2) throw new ArgumentException("Неправильно заполнены объединения строк");
|
||||
for (int i = merge.Item1; i < merge.Item2; i++)
|
||||
{
|
||||
cellsArray[i]++;
|
||||
}
|
||||
}
|
||||
foreach (int cell in cellsArray)
|
||||
{
|
||||
if (cell > 1) throw new ArgumentException("Объединения заходят друг на друга");
|
||||
}
|
||||
|
||||
var excelApp = new Microsoft.Office.Interop.Excel.Application { SheetsInNewWorkbook = 1 };
|
||||
Workbook workbook = excelApp.Workbooks.Add(Type.Missing);
|
||||
try
|
||||
{
|
||||
//create
|
||||
Worksheet worksheet = (Worksheet)workbook.Worksheets.get_Item(1);
|
||||
|
||||
//header
|
||||
var excelcells = worksheet.get_Range("A1", "A1");
|
||||
excelcells.Font.Bold = true;
|
||||
excelcells.Font.Size = 14;
|
||||
excelcells.Font.Name = "Times New Roman";
|
||||
excelcells.ColumnWidth = 8;
|
||||
excelcells.RowHeight = 25;
|
||||
excelcells.HorizontalAlignment = Constants.xlCenter;
|
||||
excelcells.VerticalAlignment = Constants.xlCenter;
|
||||
excelcells.Value2 = title;
|
||||
|
||||
//checks
|
||||
List<Microsoft.Office.Interop.Excel.Range> ranges = new List<Microsoft.Office.Interop.Excel.Range>();
|
||||
foreach (var merge in merges)
|
||||
{
|
||||
ranges.Add(worksheet.get_Range("A" + (merge.Item1 + 2), "A" + (merge.Item2 + 2)));
|
||||
}
|
||||
|
||||
int rangeIndex = 0;
|
||||
int headerIndex = 0;
|
||||
List<FieldInfo> cellFields = new List<FieldInfo>();
|
||||
var type = typeof(T);
|
||||
for (int i = 0; i < heights.Count; i++)
|
||||
{
|
||||
if (cellsArray[i] == 1)
|
||||
{
|
||||
//work with merge
|
||||
if (!string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
|
||||
|
||||
var groupRange = ranges[rangeIndex];
|
||||
groupRange.Merge(Type.Missing);
|
||||
groupRange.Font.Bold = true;
|
||||
groupRange.Font.Size = 14;
|
||||
groupRange.Font.Name = "Times New Roman";
|
||||
groupRange.ColumnWidth = 20;
|
||||
groupRange.HorizontalAlignment = Constants.xlCenter;
|
||||
groupRange.VerticalAlignment = Constants.xlCenter;
|
||||
groupRange.Value2 = headers[headerIndex].Item2;
|
||||
headerIndex++;
|
||||
|
||||
//work with cells in merge
|
||||
for (; i <= merges[rangeIndex].Item2; i++)
|
||||
{
|
||||
//work with cell
|
||||
if (string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
|
||||
var field = type.GetField(headers[headerIndex].Item1);
|
||||
if (field == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
|
||||
//format header
|
||||
var range = worksheet.get_Range("B" + (i + 2), "B" + (i + 2));
|
||||
range.Font.Bold = true;
|
||||
range.Font.Size = 14;
|
||||
range.Font.Name = "Times New Roman";
|
||||
range.ColumnWidth = 20;
|
||||
range.RowHeight = heights[i];
|
||||
range.HorizontalAlignment = Constants.xlCenter;
|
||||
range.VerticalAlignment = Constants.xlCenter;
|
||||
range.Value2 = headers[headerIndex].Item2;
|
||||
|
||||
cellFields.Add(field);
|
||||
headerIndex++;
|
||||
}
|
||||
i--;
|
||||
rangeIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//work with cell
|
||||
if (string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
|
||||
var field = type.GetField(headers[headerIndex].Item1);
|
||||
if (field == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
|
||||
//format header
|
||||
var range = worksheet.get_Range("A" + (i + 2), "B" + (i + 2));
|
||||
range.Merge(Type.Missing);
|
||||
range.Font.Bold = true;
|
||||
range.Font.Size = 14;
|
||||
range.Font.Name = "Times New Roman";
|
||||
range.ColumnWidth = 40;
|
||||
range.RowHeight = heights[i];
|
||||
range.HorizontalAlignment = Constants.xlCenter;
|
||||
range.VerticalAlignment = Constants.xlCenter;
|
||||
range.Value2 = headers[headerIndex].Item2;
|
||||
|
||||
cellFields.Add(field);
|
||||
headerIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
int columnNum = 3;
|
||||
foreach (T item in items)
|
||||
{
|
||||
string column = GetExcelColumnName(columnNum);
|
||||
int rowNum = 2;
|
||||
foreach (var cellField in cellFields)
|
||||
{
|
||||
var range = worksheet.get_Range(column + rowNum, column + rowNum);
|
||||
range.Font.Size = 14;
|
||||
range.Font.Name = "Times New Roman";
|
||||
range.ColumnWidth = 20;
|
||||
range.HorizontalAlignment = Constants.xlCenter;
|
||||
range.VerticalAlignment = Constants.xlCenter;
|
||||
range.Value2 = cellField.FieldType == typeof(bool) ? ((bool) cellField.GetValue(item) ? "Да" : "Нет") : cellField.GetValue(item);
|
||||
|
||||
rowNum++;
|
||||
}
|
||||
columnNum++;
|
||||
}
|
||||
var borderRange = worksheet.get_Range("A2", GetExcelColumnName(columnNum-1) + (headerIndex - 1));
|
||||
borderRange.Borders.LineStyle = XlLineStyle.xlContinuous;
|
||||
borderRange.Borders.Weight = 2d;
|
||||
|
||||
//save
|
||||
object missing = System.Reflection.Missing.Value;
|
||||
workbook.SaveAs(path, XlFileFormat.xlOpenXMLWorkbook, missing, missing, false, false, XlSaveAsAccessMode.xlNoChange,
|
||||
XlSaveConflictResolution.xlUserResolution, true, missing, missing, missing);
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
workbook.Close();
|
||||
excelApp.Quit();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
59
VolkovLabs/WinFormsLibraryVolkov/VisualComponents/CustomInputRangeDate.Designer.cs
generated
Normal file
59
VolkovLabs/WinFormsLibraryVolkov/VisualComponents/CustomInputRangeDate.Designer.cs
generated
Normal file
@ -0,0 +1,59 @@
|
||||
namespace WinFormsLibraryVolkov
|
||||
{
|
||||
partial class CustomInputRangeDate
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dateTimePicker = new DateTimePicker();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(3, 3);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(142, 23);
|
||||
dateTimePicker.TabIndex = 0;
|
||||
dateTimePicker.ValueChanged += dateTimePicker_ValueChanged;
|
||||
dateTimePicker.Enter += dateTimePicker_Enter;
|
||||
dateTimePicker.MaxDate = new DateTime(2024, 12, 31, 0, 0, 0, 0);
|
||||
dateTimePicker.MinDate = new DateTime(2004, 1, 11, 0, 0, 0, 0);
|
||||
//
|
||||
// CustomInputRangeDate
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(dateTimePicker);
|
||||
Name = "CustomInputRangeDate";
|
||||
Size = new Size(148, 231);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DateTimePicker dateTimePicker;
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
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 ToolTip = System.Windows.Forms.ToolTip;
|
||||
|
||||
namespace WinFormsLibraryVolkov
|
||||
{
|
||||
public partial class CustomInputRangeDate : UserControl
|
||||
{
|
||||
private EventHandler _changeEvent;
|
||||
|
||||
// Диапазон
|
||||
private string example;
|
||||
|
||||
// 2 публичных поля для настройки границ диапазона
|
||||
public DateTime MinDate { get; set; }
|
||||
public DateTime MaxDate { get; set; }
|
||||
|
||||
public CustomInputRangeDate()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
//Ошибка
|
||||
public string Error { get; protected set; } = string.Empty;
|
||||
|
||||
//Публичное свойство для установки и получения введенного значения(set, get).
|
||||
//При получении проводиться проверка,
|
||||
//если введенное значение не входит в диапазон, возвращать
|
||||
//значение null, а в отдельное поле выводить текст ошибки.При
|
||||
//установке должна проводиться проверка, если передаваемое
|
||||
//значение не входит в диапазон, то не заполнять поле компонента.
|
||||
public DateTime Date
|
||||
{
|
||||
get
|
||||
{
|
||||
if (MinDate == null || MaxDate == null)
|
||||
{
|
||||
throw new ArgumentException("Диапазон не задан");
|
||||
}
|
||||
if (dateTimePicker.Value >= MinDate && dateTimePicker.Value <= MaxDate)
|
||||
{
|
||||
return dateTimePicker.Value;
|
||||
}
|
||||
throw new ArgumentException($"Введенная дана лежит вне диапазона {MinDate.ToShortDateString()} - {MaxDate.ToShortDateString()}");
|
||||
}
|
||||
set
|
||||
{
|
||||
if (MinDate == null || MaxDate == null)
|
||||
{
|
||||
Error = "Диапазон не задан";
|
||||
}
|
||||
if (value >= MinDate && value <= MaxDate)
|
||||
{
|
||||
dateTimePicker.Value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dateTimePicker_Enter(object sender, EventArgs e)
|
||||
{
|
||||
ToolTip tt = new ToolTip();
|
||||
example = "Введите дату от " + MinDate.ToShortDateString() + " до " + MaxDate.ToShortDateString();
|
||||
tt.Show(example, dateTimePicker, 30, -20, 1000);
|
||||
}
|
||||
|
||||
private void dateTimePicker_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
_changeEvent?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
//Cобытие, вызываемое при смене значения.
|
||||
public event EventHandler ChangeEvent
|
||||
{
|
||||
add
|
||||
{
|
||||
_changeEvent += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_changeEvent -= value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
58
VolkovLabs/WinFormsLibraryVolkov/VisualComponents/CustomSelectedCheckedListBox.Designer.cs
generated
Normal file
58
VolkovLabs/WinFormsLibraryVolkov/VisualComponents/CustomSelectedCheckedListBox.Designer.cs
generated
Normal file
@ -0,0 +1,58 @@
|
||||
namespace WinFormsLibraryVolkov
|
||||
{
|
||||
partial class CustomSelectedCheckedListBox
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
checkedListBox = new CheckedListBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// checkedListBox
|
||||
//
|
||||
checkedListBox.FormattingEnabled = true;
|
||||
checkedListBox.Location = new Point(3, 1);
|
||||
checkedListBox.Name = "checkedListBox";
|
||||
checkedListBox.Size = new Size(144, 148);
|
||||
checkedListBox.TabIndex = 0;
|
||||
checkedListBox.Dock = DockStyle.Fill;
|
||||
checkedListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.checkedListBox_ItemCheck);
|
||||
checkedListBox.SelectedIndexChanged += new System.EventHandler(this.checkedListBox_SelectedIndexChanged);
|
||||
//
|
||||
// SelectionListBox
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(checkedListBox);
|
||||
Name = "SelectionListBox";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckedListBox checkedListBox;
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
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 WinFormsLibraryVolkov
|
||||
{
|
||||
public partial class CustomSelectedCheckedListBox : UserControl
|
||||
{
|
||||
public event EventHandler _changeEvent;
|
||||
|
||||
public CustomSelectedCheckedListBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
// Метод для заполнения списка строками
|
||||
public void PopulateList(List<string> items)
|
||||
{
|
||||
if (items == null)
|
||||
throw new ArgumentNullException(nameof(items));
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
checkedListBox.Items.Add(item, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Cобытие, вызываемое при смене значения в CheckedListBox
|
||||
public event EventHandler ChangeEvent
|
||||
{
|
||||
add
|
||||
{
|
||||
_changeEvent += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_changeEvent -= value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Метод для очистки списка
|
||||
public void ClearList()
|
||||
{
|
||||
checkedListBox.Items.Clear();
|
||||
}
|
||||
|
||||
// Публичное свойство для получения и установки выбранного значения
|
||||
public string SelectedElement
|
||||
{
|
||||
get
|
||||
{
|
||||
return (checkedListBox.SelectedIndex > -1 && checkedListBox.GetItemChecked(checkedListBox.SelectedIndex)) ? checkedListBox.SelectedItem.ToString() : string.Empty;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (checkedListBox.Items.Contains(value))
|
||||
{
|
||||
int selectedIndex = checkedListBox.Items.IndexOf(value);
|
||||
checkedListBox.SelectedItem = value;
|
||||
checkedListBox.SetItemChecked(selectedIndex, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Обработчик изменения состояния элементов
|
||||
private void checkedListBox_ItemCheck(object sender, ItemCheckEventArgs e)
|
||||
{
|
||||
if (e.NewValue == CheckState.Checked && checkedListBox.CheckedItems.Count > 0)
|
||||
{
|
||||
checkedListBox.ItemCheck -= checkedListBox_ItemCheck;
|
||||
checkedListBox.SetItemChecked(checkedListBox.CheckedIndices[0], value: false);
|
||||
checkedListBox.ItemCheck += checkedListBox_ItemCheck;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkedListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
_changeEvent?.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>
|
55
VolkovLabs/WinFormsLibraryVolkov/VisualComponents/CustomTreeCell.Designer.cs
generated
Normal file
55
VolkovLabs/WinFormsLibraryVolkov/VisualComponents/CustomTreeCell.Designer.cs
generated
Normal file
@ -0,0 +1,55 @@
|
||||
namespace WinFormsLibraryVolkov
|
||||
{
|
||||
partial class CustomTreeCell
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
treeView = new TreeView();
|
||||
SuspendLayout();
|
||||
//
|
||||
// treeView
|
||||
//
|
||||
treeView.Location = new Point(3, 3);
|
||||
treeView.Name = "treeView";
|
||||
treeView.Size = new Size(447, 189);
|
||||
treeView.TabIndex = 0;
|
||||
//
|
||||
// CustomTreeCell
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(treeView);
|
||||
Name = "CustomTreeCell";
|
||||
Size = new Size(453, 195);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TreeView treeView;
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using WinFormsLibraryVolkov.VisualComponents;
|
||||
|
||||
namespace WinFormsLibraryVolkov
|
||||
{
|
||||
public partial class CustomTreeCell : UserControl
|
||||
{
|
||||
public CustomTreeCell()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
treeView.Nodes.Clear();
|
||||
}
|
||||
|
||||
//Публичное свойство для установки и получения индекса выбранной ветки(set, get).
|
||||
protected DataTreeNodeConfig Levels { get; set; }
|
||||
|
||||
public void LoadConfig(DataTreeNodeConfig levels)
|
||||
{
|
||||
if (levels != null)
|
||||
{
|
||||
Levels = levels;
|
||||
}
|
||||
}
|
||||
|
||||
// Метод для добавления элемента в дерево
|
||||
public void AddCell<T>(int columnIndex, T element)
|
||||
{
|
||||
if (Levels == null) throw new ArgumentException("Levels равен null");
|
||||
if (element == null) throw new ArgumentException("element равен null");
|
||||
if (columnIndex < 0) throw new ArgumentException("индекс колонки < 0");
|
||||
if (columnIndex > Levels.NodeNames.Count) throw new ArgumentException("Индекс колонки > чем общее кол-во");
|
||||
|
||||
TreeNodeCollection treeNodeCollection = treeView.Nodes;
|
||||
int num = 0;
|
||||
foreach (string nodeName in Levels.NodeNames)
|
||||
{
|
||||
// Получение значения свойства или поля
|
||||
PropertyInfo property = element.GetType().GetProperty(nodeName);
|
||||
string text = property?.GetValue(element, null)?.ToString() ?? nodeName;
|
||||
|
||||
TreeNode treeNode = null;
|
||||
foreach (TreeNode item in treeNodeCollection)
|
||||
{
|
||||
if (item.Text == text)
|
||||
{
|
||||
treeNode = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Если узел не найден, добавляем новый
|
||||
treeNodeCollection = (treeNode == null) ? treeNodeCollection.Add(text).Nodes : treeNode.Nodes;
|
||||
|
||||
if (num >= columnIndex)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
public T GetSelectedObject<T>() where T : class, new()
|
||||
{
|
||||
if (treeView.SelectedNode == null) throw new ArgumentException("treeView.SelectedNode == null");
|
||||
if (Levels == null) throw new ArgumentException("Levels равен null");
|
||||
if (treeView.SelectedNode.Nodes.Count > 0) throw new ArgumentException("treeView.SelectedNode.Nodes.Count > 0");
|
||||
|
||||
T val = new T();
|
||||
TreeNode treeNode = treeView.SelectedNode;
|
||||
int i = Levels.NodeNames.ToArray().Length - 1; // Получаем массив из очереди
|
||||
while (treeNode != null && i >= 0)
|
||||
{
|
||||
PropertyInfo property = val.GetType().GetProperty(Levels.NodeNames.ToArray()[i]); // Обращаемся к массиву
|
||||
if (property != null)
|
||||
{
|
||||
property.SetValue(val, Convert.ChangeType(treeNode.Text, property.PropertyType));
|
||||
}
|
||||
treeNode = treeNode.Parent;
|
||||
i--;
|
||||
}
|
||||
if (i >= 0)
|
||||
{
|
||||
return null; // Не все свойства объекта установлены
|
||||
}
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinFormsLibraryVolkov.VisualComponents
|
||||
{
|
||||
public class DataTreeNodeConfig
|
||||
{
|
||||
public Queue<string> NodeNames { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<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>
|
||||
<COMReference Include="Microsoft.Office.Interop.Excel">
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<VersionMinor>9</VersionMinor>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<Guid>00020813-0000-0000-c000-000000000046</Guid>
|
||||
<Lcid>0</Lcid>
|
||||
<Isolated>false</Isolated>
|
||||
<EmbedInteropTypes>true</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
<COMReference Include="Microsoft.Office.Core">
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<VersionMinor>8</VersionMinor>
|
||||
<VersionMajor>2</VersionMajor>
|
||||
<Guid>2df8d04c-5bfa-101b-bde5-00aa0044de52</Guid>
|
||||
<Lcid>0</Lcid>
|
||||
<Isolated>false</Isolated>
|
||||
<EmbedInteropTypes>true</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
20
VolkovLabs/WinFormsTestApp/Department.cs
Normal file
20
VolkovLabs/WinFormsTestApp/Department.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinFormsTestApp
|
||||
{
|
||||
public class Department
|
||||
{
|
||||
public string name;
|
||||
public int sells;
|
||||
|
||||
public Department(string name, int sells)
|
||||
{
|
||||
this.name = name;
|
||||
this.sells = sells;
|
||||
}
|
||||
}
|
||||
}
|
401
VolkovLabs/WinFormsTestApp/FormMain.Designer.cs
generated
Normal file
401
VolkovLabs/WinFormsTestApp/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,401 @@
|
||||
using WinFormsLibraryVolkov;
|
||||
|
||||
namespace WinFormsTestApp
|
||||
{
|
||||
partial class FormMain
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
buttonCheck = new Button();
|
||||
labelCheckValue = new Label();
|
||||
groupBoxInput = new GroupBox();
|
||||
customInputRangeDate = new CustomInputRangeDate();
|
||||
groupBoxSelected = new GroupBox();
|
||||
customSelectedCheckedListBox = new CustomSelectedCheckedListBox();
|
||||
buttonGetSelected = new Button();
|
||||
labelSelectedValue = new Label();
|
||||
buttonClear = new Button();
|
||||
buttonAdd = new Button();
|
||||
textBoxAdd = new TextBox();
|
||||
groupBoxData = new GroupBox();
|
||||
customTreeCell = new CustomTreeCell();
|
||||
labelTransportType = new Label();
|
||||
labelModel = new Label();
|
||||
labelRegNum = new Label();
|
||||
buttonGetFromTree = new Button();
|
||||
buttonAddToTree = new Button();
|
||||
comboBoxTransportType = new ComboBox();
|
||||
textBoxModel = new TextBox();
|
||||
textBoxRegNumber = new TextBox();
|
||||
tabControl = new TabControl();
|
||||
Visual = new TabPage();
|
||||
NonVisual = new TabPage();
|
||||
buttonExcelDiagram = new Button();
|
||||
buttonExcelImages = new Button();
|
||||
buttonExcelTables = new Button();
|
||||
excelTableComponent = new WinFormsLibraryVolkov.NonVisualComponents.ExcelTableComponent(components);
|
||||
excelImagesComponent = new WinFormsLibraryVolkov.NonVisualComponents.ExcelImagesComponent(components);
|
||||
excelDiagramComponent = new WinFormsLibraryVolkov.NonVisualComponents.ExcelDiagramComponent(components);
|
||||
openFileDialog = new OpenFileDialog();
|
||||
groupBoxInput.SuspendLayout();
|
||||
groupBoxSelected.SuspendLayout();
|
||||
groupBoxData.SuspendLayout();
|
||||
tabControl.SuspendLayout();
|
||||
Visual.SuspendLayout();
|
||||
NonVisual.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonCheck
|
||||
//
|
||||
buttonCheck.Location = new Point(169, 22);
|
||||
buttonCheck.Name = "buttonCheck";
|
||||
buttonCheck.Size = new Size(126, 23);
|
||||
buttonCheck.TabIndex = 1;
|
||||
buttonCheck.Text = "Check";
|
||||
buttonCheck.UseVisualStyleBackColor = true;
|
||||
buttonCheck.Click += buttonCheck_Click;
|
||||
//
|
||||
// labelCheckValue
|
||||
//
|
||||
labelCheckValue.AutoSize = true;
|
||||
labelCheckValue.Location = new Point(30, 111);
|
||||
labelCheckValue.Name = "labelCheckValue";
|
||||
labelCheckValue.Size = new Size(65, 15);
|
||||
labelCheckValue.TabIndex = 2;
|
||||
labelCheckValue.Text = "Enter value";
|
||||
//
|
||||
// groupBoxInput
|
||||
//
|
||||
groupBoxInput.Controls.Add(labelCheckValue);
|
||||
groupBoxInput.Controls.Add(buttonCheck);
|
||||
groupBoxInput.Controls.Add(customInputRangeDate);
|
||||
groupBoxInput.Location = new Point(6, 6);
|
||||
groupBoxInput.Name = "groupBoxInput";
|
||||
groupBoxInput.Size = new Size(311, 190);
|
||||
groupBoxInput.TabIndex = 9;
|
||||
groupBoxInput.TabStop = false;
|
||||
groupBoxInput.Text = "Input";
|
||||
//
|
||||
// customInputRangeDate
|
||||
//
|
||||
customInputRangeDate.Location = new Point(15, 22);
|
||||
customInputRangeDate.MaxDate = new DateTime(0L);
|
||||
customInputRangeDate.MinDate = new DateTime(0L);
|
||||
customInputRangeDate.Name = "customInputRangeDate";
|
||||
customInputRangeDate.Size = new Size(148, 231);
|
||||
customInputRangeDate.TabIndex = 3;
|
||||
//
|
||||
// groupBoxSelected
|
||||
//
|
||||
groupBoxSelected.Controls.Add(customSelectedCheckedListBox);
|
||||
groupBoxSelected.Controls.Add(buttonGetSelected);
|
||||
groupBoxSelected.Controls.Add(labelSelectedValue);
|
||||
groupBoxSelected.Controls.Add(buttonClear);
|
||||
groupBoxSelected.Controls.Add(buttonAdd);
|
||||
groupBoxSelected.Controls.Add(textBoxAdd);
|
||||
groupBoxSelected.Location = new Point(324, 6);
|
||||
groupBoxSelected.Name = "groupBoxSelected";
|
||||
groupBoxSelected.Size = new Size(311, 190);
|
||||
groupBoxSelected.TabIndex = 10;
|
||||
groupBoxSelected.TabStop = false;
|
||||
groupBoxSelected.Text = "Selected";
|
||||
//
|
||||
// customSelectedCheckedListBox
|
||||
//
|
||||
customSelectedCheckedListBox.Location = new Point(6, 22);
|
||||
customSelectedCheckedListBox.Name = "customSelectedCheckedListBox";
|
||||
customSelectedCheckedListBox.SelectedElement = "";
|
||||
customSelectedCheckedListBox.Size = new Size(150, 150);
|
||||
customSelectedCheckedListBox.TabIndex = 15;
|
||||
//
|
||||
// buttonGetSelected
|
||||
//
|
||||
buttonGetSelected.Location = new Point(174, 139);
|
||||
buttonGetSelected.Name = "buttonGetSelected";
|
||||
buttonGetSelected.Size = new Size(100, 23);
|
||||
buttonGetSelected.TabIndex = 14;
|
||||
buttonGetSelected.Text = "Get Selected";
|
||||
buttonGetSelected.UseVisualStyleBackColor = true;
|
||||
buttonGetSelected.Click += buttonGetSelected_Click;
|
||||
//
|
||||
// labelSelectedValue
|
||||
//
|
||||
labelSelectedValue.AutoSize = true;
|
||||
labelSelectedValue.Location = new Point(178, 111);
|
||||
labelSelectedValue.Name = "labelSelectedValue";
|
||||
labelSelectedValue.Size = new Size(82, 15);
|
||||
labelSelectedValue.TabIndex = 11;
|
||||
labelSelectedValue.Text = "Selected value";
|
||||
//
|
||||
// buttonClear
|
||||
//
|
||||
buttonClear.Location = new Point(174, 81);
|
||||
buttonClear.Name = "buttonClear";
|
||||
buttonClear.Size = new Size(100, 23);
|
||||
buttonClear.TabIndex = 13;
|
||||
buttonClear.Text = "Clear";
|
||||
buttonClear.UseVisualStyleBackColor = true;
|
||||
buttonClear.Click += buttonClear_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(174, 52);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(100, 23);
|
||||
buttonAdd.TabIndex = 12;
|
||||
buttonAdd.Text = "Add or Select";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// textBoxAdd
|
||||
//
|
||||
textBoxAdd.Location = new Point(162, 23);
|
||||
textBoxAdd.Name = "textBoxAdd";
|
||||
textBoxAdd.Size = new Size(140, 23);
|
||||
textBoxAdd.TabIndex = 11;
|
||||
//
|
||||
// groupBoxData
|
||||
//
|
||||
groupBoxData.Controls.Add(customTreeCell);
|
||||
groupBoxData.Controls.Add(labelTransportType);
|
||||
groupBoxData.Controls.Add(labelModel);
|
||||
groupBoxData.Controls.Add(labelRegNum);
|
||||
groupBoxData.Controls.Add(buttonGetFromTree);
|
||||
groupBoxData.Controls.Add(buttonAddToTree);
|
||||
groupBoxData.Controls.Add(comboBoxTransportType);
|
||||
groupBoxData.Controls.Add(textBoxModel);
|
||||
groupBoxData.Controls.Add(textBoxRegNumber);
|
||||
groupBoxData.Location = new Point(6, 202);
|
||||
groupBoxData.Name = "groupBoxData";
|
||||
groupBoxData.Size = new Size(629, 230);
|
||||
groupBoxData.TabIndex = 11;
|
||||
groupBoxData.TabStop = false;
|
||||
groupBoxData.Text = "Data";
|
||||
//
|
||||
// customTreeCell
|
||||
//
|
||||
customTreeCell.Location = new Point(0, 23);
|
||||
customTreeCell.Name = "customTreeCell";
|
||||
customTreeCell.Size = new Size(413, 195);
|
||||
customTreeCell.TabIndex = 9;
|
||||
//
|
||||
// labelTransportType
|
||||
//
|
||||
labelTransportType.AutoSize = true;
|
||||
labelTransportType.Location = new Point(432, 116);
|
||||
labelTransportType.Name = "labelTransportType";
|
||||
labelTransportType.Size = new Size(93, 15);
|
||||
labelTransportType.TabIndex = 8;
|
||||
labelTransportType.Text = "Тип транспорта";
|
||||
//
|
||||
// labelModel
|
||||
//
|
||||
labelModel.AutoSize = true;
|
||||
labelModel.Location = new Point(432, 72);
|
||||
labelModel.Name = "labelModel";
|
||||
labelModel.Size = new Size(50, 15);
|
||||
labelModel.TabIndex = 7;
|
||||
labelModel.Text = "Модель";
|
||||
//
|
||||
// labelRegNum
|
||||
//
|
||||
labelRegNum.AutoSize = true;
|
||||
labelRegNum.Location = new Point(432, 28);
|
||||
labelRegNum.Name = "labelRegNum";
|
||||
labelRegNum.Size = new Size(146, 15);
|
||||
labelRegNum.TabIndex = 6;
|
||||
labelRegNum.Text = "Регистрационный номер";
|
||||
//
|
||||
// buttonGetFromTree
|
||||
//
|
||||
buttonGetFromTree.Location = new Point(432, 195);
|
||||
buttonGetFromTree.Name = "buttonGetFromTree";
|
||||
buttonGetFromTree.Size = new Size(188, 23);
|
||||
buttonGetFromTree.TabIndex = 5;
|
||||
buttonGetFromTree.Text = "Get Selected";
|
||||
buttonGetFromTree.UseVisualStyleBackColor = true;
|
||||
buttonGetFromTree.Click += buttonGetFromTree_Click;
|
||||
//
|
||||
// buttonAddToTree
|
||||
//
|
||||
buttonAddToTree.Location = new Point(432, 166);
|
||||
buttonAddToTree.Name = "buttonAddToTree";
|
||||
buttonAddToTree.Size = new Size(188, 23);
|
||||
buttonAddToTree.TabIndex = 4;
|
||||
buttonAddToTree.Text = "Add";
|
||||
buttonAddToTree.UseVisualStyleBackColor = true;
|
||||
buttonAddToTree.Click += buttonAddToTree_Click;
|
||||
//
|
||||
// comboBoxTransportType
|
||||
//
|
||||
comboBoxTransportType.FormattingEnabled = true;
|
||||
comboBoxTransportType.Location = new Point(432, 134);
|
||||
comboBoxTransportType.Name = "comboBoxTransportType";
|
||||
comboBoxTransportType.Size = new Size(188, 23);
|
||||
comboBoxTransportType.TabIndex = 3;
|
||||
//
|
||||
// textBoxModel
|
||||
//
|
||||
textBoxModel.Location = new Point(432, 90);
|
||||
textBoxModel.Name = "textBoxModel";
|
||||
textBoxModel.Size = new Size(188, 23);
|
||||
textBoxModel.TabIndex = 2;
|
||||
//
|
||||
// textBoxRegNumber
|
||||
//
|
||||
textBoxRegNumber.Location = new Point(432, 46);
|
||||
textBoxRegNumber.Name = "textBoxRegNumber";
|
||||
textBoxRegNumber.Size = new Size(188, 23);
|
||||
textBoxRegNumber.TabIndex = 1;
|
||||
//
|
||||
// tabControl
|
||||
//
|
||||
tabControl.Controls.Add(Visual);
|
||||
tabControl.Controls.Add(NonVisual);
|
||||
tabControl.Location = new Point(12, 12);
|
||||
tabControl.Name = "tabControl";
|
||||
tabControl.SelectedIndex = 0;
|
||||
tabControl.Size = new Size(653, 466);
|
||||
tabControl.TabIndex = 12;
|
||||
//
|
||||
// Visual
|
||||
//
|
||||
Visual.Controls.Add(groupBoxData);
|
||||
Visual.Controls.Add(groupBoxInput);
|
||||
Visual.Controls.Add(groupBoxSelected);
|
||||
Visual.Location = new Point(4, 24);
|
||||
Visual.Name = "Visual";
|
||||
Visual.Padding = new Padding(3);
|
||||
Visual.Size = new Size(645, 438);
|
||||
Visual.TabIndex = 0;
|
||||
Visual.Text = "Visual";
|
||||
Visual.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// NonVisual
|
||||
//
|
||||
NonVisual.Controls.Add(buttonExcelDiagram);
|
||||
NonVisual.Controls.Add(buttonExcelImages);
|
||||
NonVisual.Controls.Add(buttonExcelTables);
|
||||
NonVisual.Location = new Point(4, 24);
|
||||
NonVisual.Name = "NonVisual";
|
||||
NonVisual.Size = new Size(645, 438);
|
||||
NonVisual.TabIndex = 1;
|
||||
NonVisual.Text = "NonVisual";
|
||||
NonVisual.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonExcelDiagram
|
||||
//
|
||||
buttonExcelDiagram.Location = new Point(446, 126);
|
||||
buttonExcelDiagram.Name = "buttonExcelDiagram";
|
||||
buttonExcelDiagram.Size = new Size(177, 148);
|
||||
buttonExcelDiagram.TabIndex = 2;
|
||||
buttonExcelDiagram.Text = "Excel (диаграмма)";
|
||||
buttonExcelDiagram.UseVisualStyleBackColor = true;
|
||||
buttonExcelDiagram.Click += buttonExcelDiagram_Click;
|
||||
//
|
||||
// buttonExcelImages
|
||||
//
|
||||
buttonExcelImages.Location = new Point(38, 126);
|
||||
buttonExcelImages.Name = "buttonExcelImages";
|
||||
buttonExcelImages.Size = new Size(177, 148);
|
||||
buttonExcelImages.TabIndex = 1;
|
||||
buttonExcelImages.Text = "Excel (картинки)";
|
||||
buttonExcelImages.UseVisualStyleBackColor = true;
|
||||
buttonExcelImages.Click += buttonExcelImages_Click;
|
||||
//
|
||||
// buttonExcelTables
|
||||
//
|
||||
buttonExcelTables.Location = new Point(242, 126);
|
||||
buttonExcelTables.Name = "buttonExcelTables";
|
||||
buttonExcelTables.Size = new Size(177, 148);
|
||||
buttonExcelTables.TabIndex = 0;
|
||||
buttonExcelTables.Text = "Excel (таблица)";
|
||||
buttonExcelTables.UseVisualStyleBackColor = true;
|
||||
buttonExcelTables.Click += buttonExcelTables_Click;
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
openFileDialog.FileName = "openFileDialog1";
|
||||
openFileDialog.Filter = "Image Files|*.jpg;*.jpeg;*png";
|
||||
openFileDialog.Multiselect = true;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(675, 486);
|
||||
Controls.Add(tabControl);
|
||||
Name = "FormMain";
|
||||
Text = "FormMain";
|
||||
groupBoxInput.ResumeLayout(false);
|
||||
groupBoxInput.PerformLayout();
|
||||
groupBoxSelected.ResumeLayout(false);
|
||||
groupBoxSelected.PerformLayout();
|
||||
groupBoxData.ResumeLayout(false);
|
||||
groupBoxData.PerformLayout();
|
||||
tabControl.ResumeLayout(false);
|
||||
Visual.ResumeLayout(false);
|
||||
NonVisual.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonCheck;
|
||||
private Label labelCheckValue;
|
||||
private GroupBox groupBoxInput;
|
||||
private GroupBox groupBoxSelected;
|
||||
private Button buttonGetSelected;
|
||||
private Label labelSelectedValue;
|
||||
private Button buttonClear;
|
||||
private Button buttonAdd;
|
||||
private TextBox textBoxAdd;
|
||||
private GroupBox groupBoxData;
|
||||
private Button buttonGetFromTree;
|
||||
private Button buttonAddToTree;
|
||||
private ComboBox comboBoxTransportType;
|
||||
private TextBox textBoxModel;
|
||||
private TextBox textBoxRegNumber;
|
||||
private Label labelTransportType;
|
||||
private Label labelModel;
|
||||
private Label labelRegNum;
|
||||
private TabControl tabControl;
|
||||
private TabPage Visual;
|
||||
private TabPage NonVisual;
|
||||
private Button buttonExcelDiagram;
|
||||
private Button buttonExcelImages;
|
||||
private Button buttonExcelTables;
|
||||
private WinFormsLibraryVolkov.NonVisualComponents.ExcelTableComponent excelTableComponent;
|
||||
private WinFormsLibraryVolkov.NonVisualComponents.ExcelImagesComponent excelImagesComponent;
|
||||
private WinFormsLibraryVolkov.NonVisualComponents.ExcelDiagramComponent excelDiagramComponent;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private CustomInputRangeDate customInputRangeDate;
|
||||
private CustomSelectedCheckedListBox customSelectedCheckedListBox;
|
||||
private CustomTreeCell customTreeCell;
|
||||
}
|
||||
}
|
167
VolkovLabs/WinFormsTestApp/FormMain.cs
Normal file
167
VolkovLabs/WinFormsTestApp/FormMain.cs
Normal file
@ -0,0 +1,167 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using WinFormsLibraryVolkov.VisualComponents;
|
||||
using WinFormsLibraryVolkov.NonVisualComponents;
|
||||
using WinFormsLibraryVolkov.Exceptions;
|
||||
|
||||
namespace WinFormsTestApp
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
readonly List<Transport> transports = new()
|
||||
{
|
||||
new Transport { Id = 1, Fuel="Авиакеросин", Mileage=239000, Owner="Аэрофлот", Price=70000000, State="Эксплуатируется", RegNumber = "EW-009EC", TransportType = "Воздушный транспорт", Model = "Ан-30" },
|
||||
new Transport { Id = 2, Fuel="Авиакеросин", Mileage=452005, Owner="Азимут", Price=95000000, State="Не эксплуатируется", RegNumber = "EW-987ZY", TransportType = "Воздушный транспорт", Model = "Ан-28" },
|
||||
new Transport { Id = 3, Fuel="Мазут", Mileage=790222, Owner="ВМФ США", Price=100000000, State="Эксплуатируется", RegNumber = "SSH-988", TransportType = "Морской транспорт", Model = "авианосец 'Нимиц'" },
|
||||
new Transport { Id = 4, Fuel="92", Mileage=105777, Owner="Ползунова Татьяна Михайловна",State="Не эксплуатируется", Price=400000, RegNumber = "B901AУ74", TransportType = "Наземный транспорт", Model = "Renault Logan" },
|
||||
new Transport { Id = 5, Fuel="Газ", Mileage=66782, Owner="Аветесян Сергей Георгиевич", State="Эксплуатируется", Price=160000, RegNumber = "Р187КН73", TransportType = "Наземный транспорт", Model = "Daewoo Matiz" },
|
||||
};
|
||||
public FormMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
var list = new List<string>() { "Значение 1", "Значение 2", "Значение 3", "Значение 4", "Значение 5" };
|
||||
customSelectedCheckedListBox.PopulateList(list);
|
||||
|
||||
comboBoxTransportType.Items.Add("Наземный транспорт");
|
||||
comboBoxTransportType.Items.Add("Воздушный транспорт");
|
||||
comboBoxTransportType.Items.Add("Морской транспорт");
|
||||
|
||||
var nodeNames = new Queue<string>();
|
||||
nodeNames.Enqueue("TransportType");
|
||||
nodeNames.Enqueue("Model");
|
||||
nodeNames.Enqueue("RegNumber");
|
||||
var treeConfig = new DataTreeNodeConfig { NodeNames = nodeNames };
|
||||
|
||||
customTreeCell.LoadConfig(treeConfig);
|
||||
|
||||
int counter = 0;
|
||||
foreach (var transport in transports)
|
||||
{
|
||||
|
||||
customTreeCell.AddCell(0, transport);
|
||||
customTreeCell.AddCell(1, transport);
|
||||
customTreeCell.AddCell(2, transport);
|
||||
customTreeCell.AddCell(3, transport);
|
||||
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCheck_Click(object sender, EventArgs e)
|
||||
{
|
||||
labelCheckValue.Text = customInputRangeDate.Date.ToString();
|
||||
if (labelCheckValue.Text == "")
|
||||
{
|
||||
labelCheckValue.Text = customInputRangeDate.Error;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
string newItem = textBoxAdd.Text.Trim();
|
||||
|
||||
if (!string.IsNullOrEmpty(newItem))
|
||||
{
|
||||
var itemsToAdd = new List<string> { newItem };
|
||||
|
||||
// Добавляем новый элемент в список
|
||||
customSelectedCheckedListBox.PopulateList(itemsToAdd);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Введите элемент для добавления.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonClear_Click(object sender, EventArgs e)
|
||||
{
|
||||
customSelectedCheckedListBox.ClearList();
|
||||
}
|
||||
|
||||
private void buttonGetSelected_Click(object sender, EventArgs e)
|
||||
{
|
||||
labelSelectedValue.Text = customSelectedCheckedListBox.SelectedElement;
|
||||
if (labelSelectedValue.Text == "")
|
||||
{
|
||||
labelSelectedValue.Text = "Значение \nне выбрано";
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAddToTree_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (textBoxRegNumber.Text == null || textBoxModel.Text == null || comboBoxTransportType.SelectedItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
customTreeCell.AddCell<Transport>(2, new(textBoxRegNumber.Text, comboBoxTransportType.SelectedItem.ToString(), textBoxModel.Text));
|
||||
customTreeCell.Update();
|
||||
}
|
||||
|
||||
private void buttonGetFromTree_Click(object sender, EventArgs e)
|
||||
{
|
||||
Transport tp = customTreeCell.GetSelectedObject<Transport>();
|
||||
if (tp == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
textBoxRegNumber.Text = tp.RegNumber;
|
||||
textBoxModel.Text = tp.Model;
|
||||
comboBoxTransportType.SelectedItem = tp.TransportType;
|
||||
}
|
||||
|
||||
private void buttonExcelDiagram_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<Department> departments = new List<Department>();
|
||||
|
||||
departments.Add(new Department("Dep 1", 330));
|
||||
departments.Add(new Department("Dep 2", 500));
|
||||
departments.Add(new Department("Dep 3", 170));
|
||||
string path = AppDomain.CurrentDomain.BaseDirectory + "DiagramTesting.xlsx";
|
||||
if (excelDiagramComponent.createWithDiagram(path, "DiagramTest", "Продажи", DiagramLegendEnum.TopRight, departments, "name", "sells")) MessageBox.Show("Успех");
|
||||
else MessageBox.Show("Fail :(");
|
||||
}
|
||||
|
||||
private void buttonExcelTables_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<OfficeWorker> workers = new List<OfficeWorker>();
|
||||
|
||||
workers.Add(new OfficeWorker(1, "Иванов", "Иван", 20, "Отдел продаж", "Бухгалтер", 25, "+7(834)234-03-49"));
|
||||
workers.Add(new OfficeWorker(1, "Петров", "Петр", 25, "Отдел продаж", "Менеджер", 20, "+7(834)123-03-49"));
|
||||
workers.Add(new OfficeWorker(1, "Сидоров", "Сергей", 27, "Отдел кадров", "HR", 2, "+7(834)593-03-49", true));
|
||||
string path = AppDomain.CurrentDomain.BaseDirectory + "ExcelTableTesting.xlsx";
|
||||
List<(int, int)> merges = new List<(int, int)>();
|
||||
merges.Add((1, 3));
|
||||
merges.Add((4, 6));
|
||||
List<int> heights = Enumerable.Repeat(20, 9).ToList();
|
||||
|
||||
List<(string, string)> headers = new List<(string, string)> { ("id", "id"), ("", "Личные данные"),
|
||||
("lastName", "Фамилия"), ("firstName", "Имя"),
|
||||
("age", "Возраст"), ("", "Работа"),
|
||||
("department", "Отдел"), ("position", "Должность"),
|
||||
("boxNumber", "Номер бокса"), ("phoneNumber", "Телефон"),
|
||||
("isInVacation", "В отпуске"), };
|
||||
|
||||
if (excelTableComponent.createWithTable(path, "ExcelTable", merges, heights, headers, workers)) MessageBox.Show("Успех");
|
||||
}
|
||||
|
||||
private void buttonExcelImages_Click(object sender, EventArgs e)
|
||||
{
|
||||
var res = openFileDialog.ShowDialog(this);
|
||||
if (res != DialogResult.OK) return;
|
||||
var files = openFileDialog.FileNames;
|
||||
openFileDialog.Dispose();
|
||||
List<Bitmap> images = new List<Bitmap>();
|
||||
string path = AppDomain.CurrentDomain.BaseDirectory + "ImageTesting.xlsx";
|
||||
if (excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Header", files))) MessageBox.Show("Успех!");
|
||||
else MessageBox.Show("Ошибка, проверьте консоль");
|
||||
}
|
||||
}
|
||||
}
|
132
VolkovLabs/WinFormsTestApp/FormMain.resx
Normal file
132
VolkovLabs/WinFormsTestApp/FormMain.resx
Normal file
@ -0,0 +1,132 @@
|
||||
<?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="excelTableComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="excelImagesComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>195, 17</value>
|
||||
</metadata>
|
||||
<metadata name="excelDiagramComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>384, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>574, 17</value>
|
||||
</metadata>
|
||||
</root>
|
34
VolkovLabs/WinFormsTestApp/OfficeWorker.cs
Normal file
34
VolkovLabs/WinFormsTestApp/OfficeWorker.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinFormsTestApp
|
||||
{
|
||||
public class OfficeWorker
|
||||
{
|
||||
public OfficeWorker(int id, string lastName, string firstName, int age, string department, string position, int boxNumber, string phoneNumber, bool isInVacation = false)
|
||||
{
|
||||
this.id = id;
|
||||
this.lastName = lastName;
|
||||
this.firstName = firstName;
|
||||
this.age = age;
|
||||
this.department = department;
|
||||
this.position = position;
|
||||
this.boxNumber = boxNumber;
|
||||
this.phoneNumber = phoneNumber;
|
||||
this.isInVacation = isInVacation;
|
||||
}
|
||||
|
||||
public int id;
|
||||
public string lastName;
|
||||
public string firstName;
|
||||
public int age;
|
||||
public string department;
|
||||
public string position;
|
||||
public int boxNumber;
|
||||
public string phoneNumber;
|
||||
public bool isInVacation;
|
||||
}
|
||||
}
|
17
VolkovLabs/WinFormsTestApp/Program.cs
Normal file
17
VolkovLabs/WinFormsTestApp/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace WinFormsTestApp
|
||||
{
|
||||
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 FormMain());
|
||||
}
|
||||
}
|
||||
}
|
37
VolkovLabs/WinFormsTestApp/Transport.cs
Normal file
37
VolkovLabs/WinFormsTestApp/Transport.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinFormsTestApp
|
||||
{
|
||||
public class Transport
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string RegNumber { get; set; }
|
||||
|
||||
public string State { get; set; }
|
||||
|
||||
public int Mileage { get; set; }
|
||||
|
||||
public int Price { get; set; }
|
||||
|
||||
public string TransportType { get; set; }
|
||||
|
||||
public string Model { get; set; }
|
||||
|
||||
public string Owner { get; set; }
|
||||
|
||||
public string Fuel { get; set; }
|
||||
|
||||
public Transport(string regNumber, string transportType, string model)
|
||||
{
|
||||
RegNumber = regNumber;
|
||||
TransportType = transportType;
|
||||
Model = model;
|
||||
}
|
||||
public Transport() { }
|
||||
}
|
||||
}
|
15
VolkovLabs/WinFormsTestApp/WinFormsTestApp.csproj
Normal file
15
VolkovLabs/WinFormsTestApp/WinFormsTestApp.csproj
Normal file
@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WinFormsLibraryVolkov\WinFormsLibraryVolkov.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user