Compare commits

...

19 Commits
main ... Lab4

Author SHA1 Message Date
dfe14daf48 лаба 4 готова 2024-11-05 22:56:43 +04:00
17be5cae35 обновил gitignore 2024-11-05 22:56:07 +04:00
9b3a6d5607 Сдал 2024-10-23 16:25:39 +04:00
e3da66cd20 Вроде готова 2024-10-23 15:53:54 +04:00
1719292030 Reapply "T.T x3"
This reverts commit f0ab159b0ab4f4d10a731a985515037b6c0e4270.
2024-10-22 20:05:35 +04:00
f0ab159b0a Revert "T.T x3"
This reverts commit 7b6abd796f16647f1a4cf8fdcaee5e68625c374e.
2024-10-22 20:04:09 +04:00
7b6abd796f T.T x3 2024-10-22 20:02:31 +04:00
80cd4e3eb9 T.T x2 2024-10-22 19:59:11 +04:00
48e9f2ec28 T.T 2024-10-22 19:58:21 +04:00
383f82d65e Остались формочки и storage типов 2024-10-06 17:23:42 +04:00
c0526f74fd Правочка 2024-09-23 11:32:32 +04:00
5cf9f7d900 Третий компонент 2024-09-22 23:39:25 +04:00
554852a6b8 Второй компонент 2024-09-22 21:28:04 +04:00
2caa860fb5 Первый компонентик есть ^.^ 2024-09-21 21:38:23 +04:00
d8ad4d290a Исправленная лаба 2024-09-21 20:18:23 +04:00
0d948ba72e правки на занятии 2024-09-06 17:40:13 +04:00
6b9f5e4ac7 Осталось заполнение grid (⁠╥⁠﹏⁠╥⁠) 2024-09-06 01:06:10 +04:00
47a5e5c726 Create ComboBox 2024-09-05 23:14:57 +04:00
16dee17c97 CreateComboBox 2024-09-05 21:27:41 +04:00
74 changed files with 4646 additions and 2 deletions

1
.gitignore vendored
View File

@ -398,3 +398,4 @@ FodyWeavers.xsd
# JetBrains Rider
*.sln.iml
/ComponentProgramming/PluginApp/plugins

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Contracts\Contracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,93 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicsContracts;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogics.BusinessLogics
{
public class OrganisationTypeLogic : IOrganisationTypeLogic
{
private readonly IOrganisationTypeStorage _orgTypeStorage;
public OrganisationTypeLogic(IOrganisationTypeStorage orgTypeStorage)
{
_orgTypeStorage = orgTypeStorage;
}
public List<OrganisationTypeViewModel>? ReadList(OrganisationTypeSearchModel? model)
{
var list = model == null ? _orgTypeStorage.GetFullList() : _orgTypeStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public OrganisationTypeViewModel? ReadElement(OrganisationTypeSearchModel? model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _orgTypeStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public bool Create(OrganisationTypeBindingModel model)
{
CheckModel(model);
if (_orgTypeStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(OrganisationTypeBindingModel model)
{
CheckModel(model);
if (_orgTypeStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(OrganisationTypeBindingModel model)
{
CheckModel(model, false);
if (_orgTypeStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(OrganisationTypeBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentException("Введите название типа", nameof(model.Name));
}
}
}
}

View File

@ -0,0 +1,102 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicsContracts;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogics.BusinessLogics
{
public class ProviderLogic : IProviderLogic
{
private readonly IProviderStorage _providerStorage;
public ProviderLogic(IProviderStorage providerStorage)
{
_providerStorage = providerStorage;
}
public List<ProviderViewModel>? ReadList(ProviderSearchModel? model)
{
var list = model == null ? _providerStorage.GetFullList() : _providerStorage.GetFilteredList(model);
if(list == null)
{
return null;
}
return list;
}
public ProviderViewModel? ReadElement(ProviderSearchModel? model)
{
if(model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _providerStorage.GetElement(model);
if(element == null)
{
return null;
}
return element;
}
public bool Create(ProviderBindingModel model)
{
CheckModel(model);
if(_providerStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Update(ProviderBindingModel model)
{
CheckModel(model);
if(_providerStorage.Update(model) == null)
{
return false;
}
return true;
}
public bool Delete(ProviderBindingModel model)
{
CheckModel(model, false);
if(_providerStorage.Delete(model) == null)
{
return false;
}
return true;
}
private void CheckModel(ProviderBindingModel model, bool withParams = true)
{
if(model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentException("Введите название поставщика", nameof(model.Name));
}
if (string.IsNullOrEmpty(model.FurnitureType))
{
throw new ArgumentException("Введите тип мебели", nameof(model.FurnitureType));
}
if (string.IsNullOrEmpty(model.OrganisationType))
{
throw new ArgumentException("Выберите тип организации", nameof(model.OrganisationType));
}
}
}
}

View File

@ -3,7 +3,21 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34714.143
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentProgramming", "ComponentProgramming\ComponentProgramming.csproj", "{97AC6509-906E-4688-9C6F-67406629A6CA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComponentProgramming", "ComponentProgramming\ComponentProgramming.csproj", "{97AC6509-906E-4688-9C6F-67406629A6CA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Forms", "Forms\Forms.csproj", "{A490A64E-3A3B-4782-B0DB-142543BDC6A5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contracts", "Contracts\Contracts.csproj", "{6D33E2A8-3992-4213-B563-E4E7FDC0F5AB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Models", "Models\Models.csproj", "{0770DB50-E976-4257-9DB5-8032D28881FC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BusinessLogics", "BusinessLogics\BusinessLogics.csproj", "{70711FA1-A2EC-4BF8-8798-8DCBBC8A7FB2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{3F0166B4-E2B0-4499-96EE-0FFFE57855BD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginsConventionLibrary", "PluginsConventionLibrary\PluginsConventionLibrary.csproj", "{7217DCA9-C8F6-4450-BBE2-6B8A5C9F93A3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginApp", "PluginApp\PluginApp.csproj", "{21C51500-53B5-4CD4-A6CA-46C66A040DEE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -15,6 +29,34 @@ Global
{97AC6509-906E-4688-9C6F-67406629A6CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97AC6509-906E-4688-9C6F-67406629A6CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97AC6509-906E-4688-9C6F-67406629A6CA}.Release|Any CPU.Build.0 = Release|Any CPU
{A490A64E-3A3B-4782-B0DB-142543BDC6A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A490A64E-3A3B-4782-B0DB-142543BDC6A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A490A64E-3A3B-4782-B0DB-142543BDC6A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A490A64E-3A3B-4782-B0DB-142543BDC6A5}.Release|Any CPU.Build.0 = Release|Any CPU
{6D33E2A8-3992-4213-B563-E4E7FDC0F5AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D33E2A8-3992-4213-B563-E4E7FDC0F5AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D33E2A8-3992-4213-B563-E4E7FDC0F5AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D33E2A8-3992-4213-B563-E4E7FDC0F5AB}.Release|Any CPU.Build.0 = Release|Any CPU
{0770DB50-E976-4257-9DB5-8032D28881FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0770DB50-E976-4257-9DB5-8032D28881FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0770DB50-E976-4257-9DB5-8032D28881FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0770DB50-E976-4257-9DB5-8032D28881FC}.Release|Any CPU.Build.0 = Release|Any CPU
{70711FA1-A2EC-4BF8-8798-8DCBBC8A7FB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70711FA1-A2EC-4BF8-8798-8DCBBC8A7FB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70711FA1-A2EC-4BF8-8798-8DCBBC8A7FB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70711FA1-A2EC-4BF8-8798-8DCBBC8A7FB2}.Release|Any CPU.Build.0 = Release|Any CPU
{3F0166B4-E2B0-4499-96EE-0FFFE57855BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F0166B4-E2B0-4499-96EE-0FFFE57855BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F0166B4-E2B0-4499-96EE-0FFFE57855BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F0166B4-E2B0-4499-96EE-0FFFE57855BD}.Release|Any CPU.Build.0 = Release|Any CPU
{7217DCA9-C8F6-4450-BBE2-6B8A5C9F93A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7217DCA9-C8F6-4450-BBE2-6B8A5C9F93A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7217DCA9-C8F6-4450-BBE2-6B8A5C9F93A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7217DCA9-C8F6-4450-BBE2-6B8A5C9F93A3}.Release|Any CPU.Build.0 = Release|Any CPU
{21C51500-53B5-4CD4-A6CA-46C66A040DEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21C51500-53B5-4CD4-A6CA-46C66A040DEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21C51500-53B5-4CD4-A6CA-46C66A040DEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21C51500-53B5-4CD4-A6CA-46C66A040DEE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,10 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,36 @@
namespace ComponentProgramming
{
partial class DiagramComponent
{
/// <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
}
}

View File

@ -0,0 +1,98 @@
using ComponentProgramming.Components.Models;
using PdfSharp.Pdf;
using PdfSharp;
using System.ComponentModel;
using PdfSharp.Drawing;
using PdfSharp.Charting;
using PdfSharp.UniversalAccessibility.Drawing;
namespace ComponentProgramming
{
public partial class DiagramComponent : Component
{
public DiagramComponent()
{
InitializeComponent();
}
public DiagramComponent(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateLineDiagram(string docPath, string title, string header, Dictionary<string, List<Double>> data, LegendAlign legendAlign = LegendAlign.top)
{
if (string.IsNullOrEmpty(docPath))
{
throw new ArgumentNullException("Введите путь до файла!");
}
if (string.IsNullOrEmpty(title))
{
throw new ArgumentNullException("Введите заголовок");
}
if (string.IsNullOrEmpty(header))
{
throw new ArgumentNullException("Введите заголовок для диаграммы");
}
if (data.Count == 0)
{
throw new ArgumentException("Нету данных");
}
Chart chart = new Chart(ChartType.Line);
//Задание легенды
chart.Legend.Docking = (DockingType)legendAlign;
chart.Legend.LineFormat.Visible = true;
//Добавление серий
foreach (var item in data)
{
Series series = chart.SeriesCollection.AddSeries();
series.Name = item.Key;
double[] vals = new double[item.Value.Count];
for (int i = 0; i < item.Value.Count; i++)
{
vals.SetValue(Convert.ToDouble(item.Value[i]), i);
}
series.Add(vals);
}
//Объявление осей
chart.XAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.HasMajorGridlines = true;
chart.PlotArea.LineFormat.Color = XColors.DarkGray;
chart.PlotArea.LineFormat.Width = 1;
chart.PlotArea.LineFormat.Visible = true;
chart.Legend.LineFormat.Visible = true;
ChartFrame chartFrame = new ChartFrame();
chartFrame.Location = new XPoint(50, 70);
chartFrame.Size = new XSize(500, 400);
chartFrame.Add(chart);
PdfDocument document = new PdfDocument(docPath);
PdfPage page = document.AddPage();
page.Size = PageSize.A4;
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Times New Roman", 14);
gfx.DrawString(title, font, XBrushes.Black, new XRect(20, 20, page.Width, page.Height), XStringFormats.TopLeft);
gfx.DrawString(header, font, XBrushes.Black, new XRect(20, 40, page.Width, page.Height), XStringFormats.TopCenter);
chartFrame.Draw(gfx);
document.Close();
}
}
}

View File

@ -0,0 +1,36 @@
namespace ComponentProgramming.Components
{
partial class LargeTextComponent
{
/// <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
}
}

View File

@ -0,0 +1,63 @@
using System.ComponentModel;
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
namespace ComponentProgramming.Components
{
public partial class LargeTextComponent : Component
{
private Document? _document;
private Section? _section;
public LargeTextComponent()
{
InitializeComponent();
}
public LargeTextComponent(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateDocument(string docPath, string title, List<string> rows)
{
if(string.IsNullOrEmpty(docPath))
{
throw new ArgumentNullException("Введите путь до файла!");
}
if(string.IsNullOrEmpty(title))
{
throw new ArgumentNullException("Введите заголовок");
}
if(rows.Count <= 0)
{
throw new ArgumentNullException("Нету данных для сохранения");
}
_document = new Document();
var style = _document.Styles["Normal"];
style.Font.Name = "Times New Roman";
style.Font.Size = 14;
_section = _document.AddSection();
var paragraph = _section.AddParagraph(title);
paragraph.Format.SpaceAfter = "0.1cm";
paragraph.Format.Font.Bold = true;
foreach (var row in rows)
{
_section.AddParagraph(row);
}
var renderer = new PdfDocumentRenderer(true);
renderer.Document = _document;
renderer.RenderDocument();
renderer.PdfDocument.Save(docPath);
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComponentProgramming.Components.Models
{
public class ColumnInfo
{
public string PropertyName;
public string Header;
public int Width;
public ColumnInfo(string propertyName, string header, int width)
{
PropertyName = propertyName;
Header = header;
Width = width;
}
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComponentProgramming.Components.Models
{
public enum LegendAlign
{
top,
bottom,
left,
right
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComponentProgramming.Components.Models
{
public class MergeCells
{
public string Header;
public int[] Indexes;
public MergeCells(string header, int[] indexes)
{
Header = header;
Indexes = indexes;
}
}
}

View File

@ -0,0 +1,36 @@
namespace ComponentProgramming.Components
{
partial class TableComponent
{
/// <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
}
}

View File

@ -0,0 +1,146 @@
using ComponentProgramming.Components.Models;
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComponentProgramming.Components
{
public partial class TableComponent : Component
{
private Document? _document;
private Section? _section;
public TableComponent()
{
InitializeComponent();
}
public TableComponent(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateTable<T>(string docPath, string title, List<MergeCells>? mergeCells, List<ColumnInfo> colInfo, List<T> data) where T : class, new()
{
if(string.IsNullOrEmpty(docPath))
{
throw new ArgumentNullException("Введите путь до файла!");
}
if (string.IsNullOrEmpty(title))
{
throw new ArgumentNullException("Введите заголовок");
}
if(colInfo == null)
{
throw new ArgumentNullException("Введите все заголовки");
}
if (data == null)
{
throw new ArgumentNullException("Нету информации для вывода");
}
_document = new Document();
var style = _document.Styles["Normal"];
style.Font.Name = "Times New Roman";
style.Font.Size = 14;
_section = _document.AddSection();
//Заголовок
var paragraph = _section.AddParagraph(title);
paragraph.Format.SpaceAfter = "0.3cm";
//Создание таблицы
var table = _section.AddTable();
table.Borders.Visible = true;
//Создание колонок
for(int i = 0; i < colInfo.Count; i++)
{
table.AddColumn(colInfo[i].Width);
}
//Создание строк
if(mergeCells != null)
{
table.AddRow();
}
var row = table.AddRow();
for (int i = 0; i < colInfo.Count; i++)
{
row[i].AddParagraph(colInfo[i].Header);
}
List<int> MergeColls = new List<int>();
//Объединение ячеек в строке
if(mergeCells != null)
{
foreach (var cell in mergeCells)
{
MergeColls.AddRange(cell.Indexes[1..]);
table.Rows[cell.Indexes[0]].Cells[cell.Indexes[1] - 1].MergeRight = cell.Indexes[2..].Length;
table.Rows[cell.Indexes[0]].Cells[cell.Indexes[1] - 1].AddParagraph(cell.Header);
}
}
int cellsCount = table.Rows[1].Cells.Count;
//Объединение ячеек в столбце
if (MergeColls.Count != 0)
{
for (int i = 0; i < cellsCount; i++)
{
var cell = table.Rows[0].Cells[i];
if (!MergeColls.Contains(i+1))
{
cell.MergeDown = 1;
cell.AddParagraph(colInfo[i].Header);
}
}
}
//Вывод данных
int rowData = 2;
foreach(var item in data)
{
var properties = item.GetType().GetProperties();
if(properties.Count() != cellsCount)
{
throw new Exception("Кол-во полей объекта не совпадает с кол-вом колонок");
}
for(int i = 0; i < properties.Count(); i++)
{
var property = properties[i];
var propValue = property.GetValue(item);
if (propValue == null) throw new Exception("Пустое поле");
if(property.Name == colInfo[i].PropertyName)
{
if (table.Rows.Count <= rowData) table.AddRow();
table.Rows[rowData].Cells[i].AddParagraph(propValue.ToString()!);
continue;
}
}
rowData++;
}
var renderer = new PdfDocumentRenderer(true);
renderer.Document = _document;
renderer.RenderDocument();
renderer.PdfDocument.Save(docPath);
}
}
}

View File

@ -0,0 +1,61 @@
namespace ComponentProgramming
{
partial class ControlComboBox
{
/// <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()
{
comboBoxElements = new ComboBox();
SuspendLayout();
//
// comboBoxElements
//
comboBoxElements.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboBoxElements.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxElements.FormattingEnabled = true;
comboBoxElements.Location = new Point(5, 4);
comboBoxElements.Margin = new Padding(3, 4, 3, 4);
comboBoxElements.Name = "comboBoxElements";
comboBoxElements.Size = new Size(194, 28);
comboBoxElements.TabIndex = 0;
comboBoxElements.SelectedIndexChanged += comboBoxElements_SelectedIndexChanged;
//
// ControlComboBox
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(comboBoxElements);
Margin = new Padding(3, 4, 3, 4);
Name = "ControlComboBox";
Size = new Size(202, 39);
ResumeLayout(false);
}
#endregion
private ComboBox comboBoxElements;
}
}

View File

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace ComponentProgramming
{
public partial class ControlComboBox : UserControl
{
private event EventHandler? _comboBoxChanged;
public string SelectedItem
{
get
{
if (comboBoxElements.SelectedItem == null)
{
return "";
}
return comboBoxElements.SelectedItem.ToString()!;
}
set
{
comboBoxElements.SelectedItem = value;
}
}
public event EventHandler ComboBoxChanged
{
add { _comboBoxChanged += value; }
remove { _comboBoxChanged -= value; }
}
public ControlComboBox()
{
InitializeComponent();
}
public ComboBox.ObjectCollection ComboBoxItems
{
get { return comboBoxElements.Items; }
}
public void ClearComboBox()
{
comboBoxElements.Items.Clear();
}
private void comboBoxElements_SelectedIndexChanged(object sender, EventArgs e)
{
_comboBoxChanged?.Invoke(this, e);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,58 @@
namespace ComponentProgramming
{
partial class ControlListBox
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
listBox = new ListBox();
SuspendLayout();
//
// listBox
//
listBox.Dock = DockStyle.Fill;
listBox.FormattingEnabled = true;
listBox.ItemHeight = 15;
listBox.Location = new Point(0, 0);
listBox.Name = "listBox";
listBox.Size = new Size(520, 312);
listBox.TabIndex = 0;
//
// ControlListBox
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(listBox);
Name = "ControlListBox";
Size = new Size(520, 312);
ResumeLayout(false);
}
#endregion
private ListBox listBox;
}
}

View File

@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ComponentProgramming
{
public partial class ControlListBox : UserControl
{
public ControlListBox()
{
InitializeComponent();
}
private string _templateString;
private string _startSymbol;
private string _endSymbol;
public void SetTemplateString(string templateString, string startSymbol, string endSymbol)
{
if(templateString != "" && startSymbol != "" && endSymbol != "")
{
_startSymbol = startSymbol;
_endSymbol = endSymbol;
_templateString = templateString;
}
else
{
throw new ArgumentNullException("Введите все значения");
}
}
public int GetIndex
{
get { return listBox.SelectedIndex; }
set
{
if(listBox.SelectedIndex != 0)
{
listBox.SelectedIndex = value;
}
}
}
public T? GetSelectedObject<T>() where T : class, new()
{
if(listBox.SelectedIndex == -1)
{
return null;
}
string row = listBox.SelectedItem!.ToString()!;
T obj = new T();
StringBuilder sb = new StringBuilder(row);
foreach (var prop in typeof(T).GetProperties())
{
if (!prop.CanWrite || prop.Name == "Id")
{
continue;
}
int borderOne = sb.ToString().IndexOf(_startSymbol);
if (borderOne == -1) break;
int borderTwo = sb.ToString().IndexOf(_endSymbol, borderOne + 1);
if (borderTwo == -1) break;
string propValue = sb.ToString(borderOne + 1, borderTwo - borderOne - 1);
sb.Remove(0, borderTwo + 1);
prop.SetValue(obj, Convert.ChangeType(propValue, prop.PropertyType));
}
return obj;
}
public void FillProp<T>(T dataObj, int rowIndex, string propName)
{
while (listBox.Items.Count <= rowIndex)
{
listBox.Items.Add(_templateString);
}
string row = listBox.Items[rowIndex].ToString()!;
PropertyInfo propInfo = dataObj!.GetType().GetProperty(propName)!;
if(propInfo != null)
{
object propValue = propInfo.GetValue(dataObj)!;
row = row.Replace($"{_startSymbol}{propName}{_endSymbol}", $"{_startSymbol}{propValue.ToString()}{_endSymbol}");
listBox.Items[rowIndex] = row;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,60 @@
namespace ComponentProgramming
{
partial class ControlTextBox
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
textBox = new TextBox();
SuspendLayout();
//
// textBox
//
textBox.Location = new Point(3, 4);
textBox.Margin = new Padding(3, 4, 3, 4);
textBox.Name = "textBox";
textBox.PlaceholderText = "+79063211213";
textBox.Size = new Size(133, 27);
textBox.TabIndex = 0;
textBox.TextChanged += textBox_TextChanged;
//
// ControlTextBox
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(textBox);
Margin = new Padding(3, 4, 3, 4);
Name = "ControlTextBox";
Size = new Size(138, 34);
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBox;
}
}

View File

@ -0,0 +1,75 @@
using ComponentProgramming.Control.Exceptions;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ComponentProgramming
{
public partial class ControlTextBox : UserControl
{
public ControlTextBox()
{
InitializeComponent();
}
private string? _numPuttern;
public string? NumPattern
{
get { return _numPuttern; }
set { _numPuttern = value!; }
}
public string? text
{
get
{
if (_numPuttern == null)
{
throw new NumberException("Стандарт не задан!");
}
Regex regex = new(_numPuttern);
if (regex.IsMatch(textBox.Text))
{
return textBox.Text;
}
else
{
throw new NumberException(textBox.Text + " не соответствует стандарту!");
}
}
set
{
if (_numPuttern == null)
{
return;
}
Regex regex = new(_numPuttern!);
if (regex.IsMatch(value!))
{
textBox.Text = value;
}
}
}
private event EventHandler? _textBoxChanged;
public event EventHandler TextBoxChanged
{
add { _textBoxChanged += value; }
remove { _textBoxChanged -= value; }
}
private void textBox_TextChanged(object sender, EventArgs e)
{
_textBoxChanged?.Invoke(this, e);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,71 @@
namespace ComponentProgramming.Control
{
partial class DateBoxWithNull
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
checkBoxNull = new CheckBox();
textBoxDate = new TextBox();
SuspendLayout();
//
// checkBoxNull
//
checkBoxNull.AutoSize = true;
checkBoxNull.Location = new Point(3, 6);
checkBoxNull.Name = "checkBoxNull";
checkBoxNull.Size = new Size(15, 14);
checkBoxNull.TabIndex = 0;
checkBoxNull.UseVisualStyleBackColor = true;
checkBoxNull.CheckedChanged += CheckBoxNull_CheckedChanged;
//
// textBoxDate
//
textBoxDate.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
textBoxDate.Location = new Point(24, 3);
textBoxDate.Name = "textBoxDate";
textBoxDate.Size = new Size(100, 23);
textBoxDate.TabIndex = 1;
textBoxDate.TextChanged += TextBoxDate_TextChanged;
//
// DateBoxWithNull
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(textBoxDate);
Controls.Add(checkBoxNull);
Name = "DateBoxWithNull";
Size = new Size(129, 30);
ResumeLayout(false);
PerformLayout();
}
#endregion
private CheckBox checkBoxNull;
private TextBox textBoxDate;
}
}

View File

@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
namespace ComponentProgramming.Control
{
public partial class DateBoxWithNull : UserControl
{
public event EventHandler? CombEvent;
public Exception? Error;
public DateBoxWithNull()
{
InitializeComponent();
}
public DateTime? Value
{
get
{
if (!checkBoxNull.Checked)
{
if (string.IsNullOrEmpty(textBoxDate.Text))
{
throw new Exception("Text box can't be empty, click checkbox if value must be empty!");
}
if (DateTime.TryParseExact(textBoxDate.Text, "dd/MM/yyyy", null, DateTimeStyles.None, out DateTime parsedDate))
{
return parsedDate;
}
else
{
throw new Exception($"Wrong format <{textBoxDate.Text}>!");
}
}
return null;
}
set
{
bool isNull = value is null;
checkBoxNull.Checked = isNull;
textBoxDate.Text = isNull ? string.Empty : value?.ToString("dd/MM/yyyy");
}
}
private void TextBoxDate_TextChanged(object sender, EventArgs e)
{
CombEvent?.Invoke(sender, e);
}
private void CheckBoxNull_CheckedChanged(object sender, EventArgs e)
{
textBoxDate.Enabled = !checkBoxNull.Checked;
CombEvent?.Invoke(sender, e);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComponentProgramming.Control.Exceptions
{
public class NumberException : Exception
{
public NumberException() { }
public NumberException(string message) : base(message)
{
}
}
}

View File

@ -0,0 +1,17 @@
using Models.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BindingModels
{
public class OrganisationTypeBindingModel : IOrganisationTypeModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,22 @@
using Models.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BindingModels
{
public class ProviderBindingModel : IProviderModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string FurnitureType { get; set; } = string.Empty;
public string OrganisationType { get; set; } = string.Empty;
public string? DateLastDelivery { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BusinessLogicsContracts
{
public interface IOrganisationTypeLogic
{
List<OrganisationTypeViewModel>? ReadList(OrganisationTypeSearchModel? model);
OrganisationTypeViewModel? ReadElement(OrganisationTypeSearchModel? model);
bool Create(OrganisationTypeBindingModel model);
bool Update(OrganisationTypeBindingModel model);
bool Delete(OrganisationTypeBindingModel model);
}
}

View File

@ -0,0 +1,22 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BusinessLogicsContracts
{
public interface IProviderLogic
{
List<ProviderViewModel>? ReadList(ProviderSearchModel? model);
ProviderViewModel? ReadElement (ProviderSearchModel? model);
bool Create(ProviderBindingModel model);
bool Update(ProviderBindingModel model);
bool Delete(ProviderBindingModel model);
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Models\Models.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.SearchModels
{
public class OrganisationTypeSearchModel
{
public string? Name { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.SearchModels
{
public class ProviderSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
public string? OrganisationType { get; set; }
public DateTime? DateLastDelivery { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.StorageContracts
{
public interface IOrganisationTypeStorage
{
List<OrganisationTypeViewModel> GetFullList();
List<OrganisationTypeViewModel> GetFilteredList(OrganisationTypeSearchModel model);
OrganisationTypeViewModel? GetElement(OrganisationTypeSearchModel model);
OrganisationTypeViewModel? Insert(OrganisationTypeBindingModel model);
OrganisationTypeViewModel? Update(OrganisationTypeBindingModel model);
OrganisationTypeViewModel? Delete(OrganisationTypeBindingModel model);
}
}

View File

@ -0,0 +1,22 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.StorageContracts
{
public interface IProviderStorage
{
List<ProviderViewModel> GetFullList();
List<ProviderViewModel> GetFilteredList(ProviderSearchModel model);
ProviderViewModel? GetElement(ProviderSearchModel model);
ProviderViewModel? Insert(ProviderBindingModel model);
ProviderViewModel? Update(ProviderBindingModel model);
ProviderViewModel? Delete(ProviderBindingModel model);
}
}

View File

@ -0,0 +1,19 @@
using Models.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.ViewModels
{
public class OrganisationTypeViewModel : IOrganisationTypeModel
{
public int Id { get; set; }
[DisplayName("Название типа")]
public string Name { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,28 @@
using Models.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.ViewModels
{
public class ProviderViewModel : IProviderModel
{
public int Id { get; set; }
[DisplayName("Название организации")]
public string Name { get; set; } = string.Empty;
[DisplayName("Перечернь производимой мебели")]
public string FurnitureType { get; set; } = string.Empty;
[DisplayName("Тип организации")]
public string OrganisationType { get; set; } = string.Empty;
[DisplayName("Дата последней доставки")]
public string? DateLastDelivery { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using DatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace DatabaseImplement
{
public class Database : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=EnterpriseDataBase;Integrated Security=True;MultipleActiveResultSets=True; TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
public virtual DbSet<Provider> Providers { get; set; }
public virtual DbSet<OrganisationType> OrganisationTypes { get; set; }
}
}

View File

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" 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>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BusinessLogics\BusinessLogics.csproj" />
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\Models\Models.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,76 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Implements
{
public class OrganisationTypeStorage : IOrganisationTypeStorage
{
public List<OrganisationTypeViewModel> GetFullList()
{
using var context = new Database();
return context.OrganisationTypes.Select(x => x.GetViewModel).ToList();
}
public List<OrganisationTypeViewModel> GetFilteredList(OrganisationTypeSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return new();
}
using var context = new Database();
return context.OrganisationTypes.Where(x => x.Name == model.Name).Select(x=> x.GetViewModel).ToList();
}
public OrganisationTypeViewModel? GetElement(OrganisationTypeSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return null;
}
using var context = new Database();
return context.OrganisationTypes.FirstOrDefault(x => x.Name == model.Name)?.GetViewModel;
}
public OrganisationTypeViewModel? Insert(OrganisationTypeBindingModel model)
{
var newType = OrganisationType.Create(model);
if(newType == null) return null;
using var context = new Database();
context.OrganisationTypes.Add(newType);
context.SaveChanges();
return newType.GetViewModel;
}
public OrganisationTypeViewModel? Update(OrganisationTypeBindingModel model)
{
using var context = new Database();
var type = context.OrganisationTypes.FirstOrDefault(x => x.Id == model.Id);
if(type == null) return null;
type.Update(model);
context.SaveChanges();
return type.GetViewModel;
}
public OrganisationTypeViewModel? Delete(OrganisationTypeBindingModel model)
{
using var context = new Database();
var element = context.OrganisationTypes.FirstOrDefault(x => x.Name == model.Name);
if(element != null)
{
context.OrganisationTypes.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,75 @@
using Contracts.BindingModels;
using Contracts.SearchModels;
using Contracts.StorageContracts;
using Contracts.ViewModels;
using DatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Implements
{
public class ProviderStorage : IProviderStorage
{
public List<ProviderViewModel> GetFullList()
{
using var context = new Database();
return context.Providers.Select(x => x.GetViewModel).ToList();
}
public List<ProviderViewModel> GetFilteredList(ProviderSearchModel model)
{
if (string.IsNullOrEmpty(model.OrganisationType))
{
return new();
}
using var context = new Database();
return context.Providers.Where(x => x.OrganisationType == model.OrganisationType).Select(x=> x.GetViewModel).ToList();
}
public ProviderViewModel? GetElement(ProviderSearchModel model)
{
if(!model.Id.HasValue)
{
return null;
}
using var context = new Database();
return context.Providers.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
}
public ProviderViewModel? Insert(ProviderBindingModel model)
{
var newProvider = Provider.Create(model);
if (newProvider == null) return null;
using var context = new Database();
context.Providers.Add(newProvider);
context.SaveChanges();
return newProvider.GetViewModel;
}
public ProviderViewModel? Update(ProviderBindingModel model)
{
using var context = new Database();
var provider = context.Providers.FirstOrDefault(x=> x.Id == model.Id);
if(provider == null) return null;
provider.Update(model);
context.SaveChanges();
return provider.GetViewModel;
}
public ProviderViewModel? Delete(ProviderBindingModel model)
{
using var context = new Database();
var element = context.Providers.FirstOrDefault(x=>x.Id == model.Id);
if(element != null)
{
context.Providers.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,74 @@
// <auto-generated />
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(Database))]
[Migration("20241022152445_InitMigration")]
partial class InitMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.OrganisationType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("OrganisationTypes");
});
modelBuilder.Entity("DatabaseImplement.Models.Provider", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("DateLastDelivery")
.HasColumnType("nvarchar(max)");
b.Property<string>("FurnitureType")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("OrganisationType")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Providers");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,53 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "OrganisationTypes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrganisationTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Providers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
FurnitureType = table.Column<string>(type: "nvarchar(max)", nullable: false),
OrganisationType = table.Column<string>(type: "nvarchar(max)", nullable: false),
DateLastDelivery = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Providers", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "OrganisationTypes");
migrationBuilder.DropTable(
name: "Providers");
}
}
}

View File

@ -0,0 +1,71 @@
// <auto-generated />
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(Database))]
partial class DatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.OrganisationType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("OrganisationTypes");
});
modelBuilder.Entity("DatabaseImplement.Models.Provider", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("DateLastDelivery")
.HasColumnType("nvarchar(max)");
b.Property<string>("FurnitureType")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("OrganisationType")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Providers");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,44 @@
using Contracts.BindingModels;
using Contracts.ViewModels;
using Models.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Models
{
public class OrganisationType : IOrganisationTypeModel
{
public int Id { get; private set; }
[Required]
public string Name { get; private set; } = string.Empty;
public static OrganisationType? Create(OrganisationTypeBindingModel model)
{
if(model == null) return null;
return new OrganisationType
{
Id = model.Id,
Name = model.Name,
};
}
public void Update(OrganisationTypeBindingModel model)
{
if (model == null) return;
Name = model.Name;
}
public OrganisationTypeViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
};
}
}

View File

@ -0,0 +1,61 @@
using Contracts.BindingModels;
using Contracts.ViewModels;
using Models.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Models
{
public class Provider : IProviderModel
{
public int Id { get; private set; }
[Required]
public string Name { get; private set; } = string.Empty;
[Required]
public string FurnitureType { get; private set; } = string.Empty;
[Required]
public string OrganisationType { get; private set; } = string.Empty;
public string? DateLastDelivery { get; private set; }
public static Provider? Create(ProviderBindingModel model)
{
if(model == null) return null;
return new Provider
{
Id = model.Id,
Name = model.Name,
FurnitureType = model.FurnitureType,
OrganisationType = model.OrganisationType,
DateLastDelivery = model.DateLastDelivery,
};
}
public void Update(ProviderBindingModel model)
{
if (model == null) return;
Name = model.Name;
FurnitureType = model.FurnitureType;
OrganisationType = model.OrganisationType;
DateLastDelivery = model.DateLastDelivery;
}
public ProviderViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
FurnitureType = FurnitureType,
OrganisationType = OrganisationType,
DateLastDelivery = DateLastDelivery,
};
}
}

View File

@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
<PackageReference Include="WinFormsLibrary" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ComponentProgramming\ComponentProgramming.csproj" />
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,137 @@
namespace Forms
{
partial class MainForm
{
/// <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();
controlDataTreeTable = new ControlsLibraryNet60.Data.ControlDataTreeTable();
contextMenuStrip1 = new ContextMenuStrip(components);
organisationTypesToolStripMenuItem = new ToolStripMenuItem();
addProviderToolStripMenuItem = new ToolStripMenuItem();
editProviderToolStripMenuItem = new ToolStripMenuItem();
deleteProviderToolStripMenuItem = new ToolStripMenuItem();
createPdfToolStripMenuItem = new ToolStripMenuItem();
createExcelToolStripMenuItem = new ToolStripMenuItem();
largeTextComponent = new ComponentProgramming.Components.LargeTextComponent(components);
componentDocumentWithTableMultiHeaderExcel = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderExcel(components);
createToolStripMenuItem = new ToolStripMenuItem();
componentDocumentWithChartPieWord = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieWord(components);
contextMenuStrip1.SuspendLayout();
SuspendLayout();
//
// controlDataTreeTable
//
controlDataTreeTable.ContextMenuStrip = contextMenuStrip1;
controlDataTreeTable.Location = new Point(13, 12);
controlDataTreeTable.Margin = new Padding(4, 3, 4, 3);
controlDataTreeTable.Name = "controlDataTreeTable";
controlDataTreeTable.Size = new Size(337, 382);
controlDataTreeTable.TabIndex = 1;
//
// contextMenuStrip1
//
contextMenuStrip1.Items.AddRange(new ToolStripItem[] { organisationTypesToolStripMenuItem, addProviderToolStripMenuItem, editProviderToolStripMenuItem, deleteProviderToolStripMenuItem, createPdfToolStripMenuItem, createExcelToolStripMenuItem, createToolStripMenuItem });
contextMenuStrip1.Name = "contextMenuStrip1";
contextMenuStrip1.Size = new Size(181, 180);
//
// organisationTypesToolStripMenuItem
//
organisationTypesToolStripMenuItem.Name = "organisationTypesToolStripMenuItem";
organisationTypesToolStripMenuItem.Size = new Size(173, 22);
organisationTypesToolStripMenuItem.Text = "Organisation types";
organisationTypesToolStripMenuItem.Click += organisationTypesToolStripMenuItem_Click;
//
// addProviderToolStripMenuItem
//
addProviderToolStripMenuItem.Name = "addProviderToolStripMenuItem";
addProviderToolStripMenuItem.Size = new Size(173, 22);
addProviderToolStripMenuItem.Text = "Add provider";
addProviderToolStripMenuItem.Click += addProviderToolStripMenuItem_Click;
//
// editProviderToolStripMenuItem
//
editProviderToolStripMenuItem.Name = "editProviderToolStripMenuItem";
editProviderToolStripMenuItem.Size = new Size(173, 22);
editProviderToolStripMenuItem.Text = "Edit provider";
editProviderToolStripMenuItem.Click += editProviderToolStripMenuItem_Click;
//
// deleteProviderToolStripMenuItem
//
deleteProviderToolStripMenuItem.Name = "deleteProviderToolStripMenuItem";
deleteProviderToolStripMenuItem.Size = new Size(173, 22);
deleteProviderToolStripMenuItem.Text = "Delete provider";
deleteProviderToolStripMenuItem.Click += deleteProviderToolStripMenuItem_Click;
//
// createPdfToolStripMenuItem
//
createPdfToolStripMenuItem.Name = "createPdfToolStripMenuItem";
createPdfToolStripMenuItem.Size = new Size(173, 22);
createPdfToolStripMenuItem.Text = "Create Pdf";
createPdfToolStripMenuItem.Click += createPdfToolStripMenuItem_Click;
//
// createExcelToolStripMenuItem
//
createExcelToolStripMenuItem.Name = "createExcelToolStripMenuItem";
createExcelToolStripMenuItem.Size = new Size(173, 22);
createExcelToolStripMenuItem.Text = "Create Excel";
createExcelToolStripMenuItem.Click += createExcelToolStripMenuItem_Click;
//
// createToolStripMenuItem
//
createToolStripMenuItem.Name = "createToolStripMenuItem";
createToolStripMenuItem.Size = new Size(180, 22);
createToolStripMenuItem.Text = "Create Word";
createToolStripMenuItem.Click += createToolStripMenuItem_Click;
//
// MainForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(358, 403);
Controls.Add(controlDataTreeTable);
Name = "MainForm";
Text = "Main Form";
contextMenuStrip1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private ControlsLibraryNet60.Data.ControlDataTreeTable controlDataTreeTable;
private ContextMenuStrip contextMenuStrip1;
private ToolStripMenuItem organisationTypesToolStripMenuItem;
private ToolStripMenuItem addProviderToolStripMenuItem;
private ToolStripMenuItem editProviderToolStripMenuItem;
private ToolStripMenuItem deleteProviderToolStripMenuItem;
private ComponentProgramming.Components.LargeTextComponent largeTextComponent;
private ToolStripMenuItem createPdfToolStripMenuItem;
private ToolStripMenuItem createExcelToolStripMenuItem;
private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderExcel componentDocumentWithTableMultiHeaderExcel;
private ToolStripMenuItem createToolStripMenuItem;
private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieWord componentDocumentWithChartPieWord;
}
}

View File

@ -0,0 +1,183 @@
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 ComponentsLibraryNet60;
using ComponentsLibraryNet60.Models;
using Contracts.BindingModels;
using Contracts.BusinessLogicsContracts;
using Contracts.ViewModels;
using ControlsLibraryNet60.Data;
using ControlsLibraryNet60.Models;
namespace Forms
{
public partial class MainForm : Form
{
private readonly IProviderLogic _logic;
private readonly IOrganisationTypeLogic _ologic;
public MainForm(IProviderLogic logic, IOrganisationTypeLogic ologic)
{
InitializeComponent();
_logic = logic;
_ologic = ologic;
TreeConfig();
LoadData();
}
private void TreeConfig()
{
DataTreeNodeConfig treeConfig = new();
treeConfig.NodeNames = new();
treeConfig.NodeNames.Enqueue("OrganisationType");
treeConfig.NodeNames.Enqueue("DateLastDelivery");
treeConfig.NodeNames.Enqueue("Id");
treeConfig.NodeNames.Enqueue("Name");
controlDataTreeTable.LoadConfig(treeConfig);
}
private void LoadData()
{
var list = _logic.ReadList(null);
if (list != null)
{
controlDataTreeTable.Clear();
controlDataTreeTable.AddTable(list);
}
}
private void organisationTypesToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(OrganisationTypeForm));
if (service is OrganisationTypeForm form)
{
form.ShowDialog();
}
}
private void addProviderToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(ProviderForm));
if (service is ProviderForm form)
{
form.ShowDialog();
}
LoadData();
}
private void editProviderToolStripMenuItem_Click(object sender, EventArgs e)
{
int id = Convert.ToInt32(controlDataTreeTable.GetSelectedObject<ProviderViewModel>()?.Id);
ProviderForm form = new ProviderForm(_logic, _ologic, id);
form.ShowDialog();
LoadData();
}
private void deleteProviderToolStripMenuItem_Click(object sender, EventArgs e)
{
var confirmResult = MessageBox.Show("Вы действительно хотите удалить запись?", "Подтвердите действие",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question
);
if (confirmResult == DialogResult.Yes)
{
_logic.Delete(new ProviderBindingModel
{
Id = Convert.ToInt32(controlDataTreeTable.GetSelectedObject<ProviderViewModel>()?.Id),
});
LoadData();
}
}
private void createPdfToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.ShowDialog();
string path = saveFileDialog.FileName + ".pdf";
var list = _logic.ReadList(null);
if (list != null)
{
List<string> strings = new List<string> { };
foreach (var item in list)
{
strings.Add($"{item.Name} : {item.FurnitureType}");
}
largeTextComponent.CreateDocument(path, $"Отчет за {DateTime.Now.Year}", strings);
MessageBox.Show("Отчет готов");
}
}
private void createExcelToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.ShowDialog();
string path = saveFileDialog.FileName + ".xlsx";
var list = _logic.ReadList(null);
var widths = new List<(int Column, int Row)> { (5, 5), (10, 5), (5, 5), (7, 5), (10, 5), };
var headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)> {
(0,0,"АЙДИ", "Id"),
(1,0,"Название", "Name"),
(2,0,"Перечень мебели", "FurnitureType"),
(3,0,"Тип организации", "OrganisationType"),
(4,0,"Дата последней доставки", "DateLastDelivery")
};
var conf = new ComponentDocumentWithTableHeaderDataConfig<ProviderViewModel>
{
FilePath = path,
Header = "Отчет по поставщикам",
ColumnsRowsDataCount = (list![0].GetType().GetProperties().Length, list.Count),
UseUnion = false,
ColumnsRowsWidth = widths,
Headers = headers,
Data = list,
};
componentDocumentWithTableMultiHeaderExcel.CreateDoc<ProviderViewModel>(conf);
MessageBox.Show("Отчет готов");
}
private void createToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.ShowDialog();
string path = saveFileDialog.FileName + ".docx";
var list = _logic.ReadList(null);
var data = new List<(int Date, double Value)> { };
string header = "График по поставщикам\n";
var chart = new Dictionary<string, List<(int Date, double Value)>> { };
int index = 1;
foreach (var type in _ologic.ReadList(null)!)
{
int sum = 0;
foreach(var item in list)
{
if(item.OrganisationType == type.Name)
{
sum++;
}
}
header += $"{index} - {type.Name}\n";
if (sum != 0) data.Add((index, sum));
index++;
}
chart.Add("ИП", data);
var conf = new ComponentDocumentWithChartConfig
{
FilePath = path,
Header = header,
ChartTitle = "Диаграмма по типам организаций",
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
Data = chart,
};
componentDocumentWithChartPieWord.CreateDoc(conf);
MessageBox.Show("Отчет готов");
}
}
}

View 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="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>132, 17</value>
</metadata>
<metadata name="largeTextComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>287, 17</value>
</metadata>
<metadata name="componentDocumentWithTableMultiHeaderExcel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>452, 17</value>
</metadata>
<metadata name="componentDocumentWithChartPieWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>769, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,74 @@
namespace Forms
{
partial class OrganisationTypeForm
{
/// <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();
Type = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.BackgroundColor = Color.White;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { Type });
dataGridView.GridColor = Color.Gray;
dataGridView.Location = new Point(12, 12);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersVisible = false;
dataGridView.Size = new Size(181, 286);
dataGridView.TabIndex = 0;
dataGridView.CellValueChanged += dataGridView_CellValueChanged;
dataGridView.KeyDown += dataGridView_KeyDown;
//
// Type
//
Type.HeaderText = "Organisation types";
Type.Name = "Type";
//
// OrganisationTypeForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(205, 308);
Controls.Add(dataGridView);
Name = "OrganisationTypeForm";
Text = "Types";
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private DataGridViewTextBoxColumn Type;
}
}

View File

@ -0,0 +1,93 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicsContracts;
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 Forms
{
public partial class OrganisationTypeForm : Form
{
private readonly IOrganisationTypeLogic _logic;
public OrganisationTypeForm(IOrganisationTypeLogic logic)
{
InitializeComponent();
_logic = logic;
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
foreach (var item in list)
{
dataGridView.Rows.Add(item.Name);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Insert)
{
for(int i = 0;i<dataGridView.Rows.Count;i++)
{
if (dataGridView.Rows[i].Cells[0].Value == null)
{
return;
}
}
dataGridView.Rows.Add();
}
else if(e.KeyCode == Keys.Delete)
{
if(MessageBox.Show("Удалить строку?", "Удаление",MessageBoxButtons.YesNo) == DialogResult.Yes)
{
var name = dataGridView.SelectedCells[0].Value.ToString();
if(name != null)
{
_logic.Delete(new OrganisationTypeBindingModel
{
Name = name,
});
dataGridView.Rows.RemoveAt(dataGridView.SelectedCells[0].RowIndex);
}
}
}
}
private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if(dataGridView.Rows.Count > 0) {
var name = dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString();
if (string.IsNullOrEmpty(name))
{
MessageBox.Show("Введите название!");
return;
}
_logic.Create(new OrganisationTypeBindingModel
{
Name = name,
});
}
}
}
}

View 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="Type.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,189 @@
using BusinessLogics.BusinessLogics;
using ComponentProgramming.Components;
using ComponentsLibraryNet60.Core;
using ComponentsLibraryNet60.DocumentWithChart;
using ComponentsLibraryNet60.DocumentWithTable;
using ComponentsLibraryNet60.Models;
using Contracts.BindingModels;
using Contracts.BusinessLogicsContracts;
using Contracts.ViewModels;
using ControlsLibraryNet60.Data;
using ControlsLibraryNet60.Models;
using DatabaseImplement.Implements;
using DocumentFormat.OpenXml.ExtendedProperties;
using Microsoft.EntityFrameworkCore.Diagnostics;
using PluginsConventionLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Forms
{
public class PluginsConvention : IPluginsConvention
{
private readonly IOrganisationTypeLogic _ologic;
private readonly IProviderLogic _plogic;
private readonly ControlDataTreeTable _controlDataTreeTable = new();
private readonly LargeTextComponent _largeTextComponent = new();
private readonly ComponentDocumentWithTableMultiHeaderExcel _componentDocumentWithTableMultiHeaderExcel = new();
private readonly ComponentDocumentWithChartPieWord _componentDocumentWithChartPieWord = new();
public PluginsConvention()
{
_ologic = new OrganisationTypeLogic(new OrganisationTypeStorage());
_plogic = new ProviderLogic(new ProviderStorage());
ReloadData();
}
public string PluginName => "PluginLab3";
public UserControl GetControl => _controlDataTreeTable;
public PluginsConventionElement GetElement
{
get
{
var selected = _controlDataTreeTable.GetSelectedObject<ProviderViewModel>();
if (selected == null) throw new Exception("Не удалось получить выбранный элемент");
byte[] bytes = new byte[16];
BitConverter.GetBytes(selected.Id).CopyTo(bytes, 0);
return new PluginsConventionProvider()
{
Id = new Guid(bytes),
Name = selected.Name,
DateLastDelivery = selected.DateLastDelivery,
FurnitureType = selected.FurnitureType,
OrganisationType = selected.OrganisationType,
};
}
}
public Form GetForm(PluginsConventionElement element)
{
var providerForm = new ProviderForm(_plogic,_ologic);
if(element != null)
{
providerForm = new ProviderForm(_plogic, _ologic, element.Id.GetHashCode());
}
return providerForm;
}
public Form GetThesaurus()
{
return new OrganisationTypeForm(_ologic);
}
public bool DeleteElement(PluginsConventionElement element)
{
return _plogic.Delete(new ProviderBindingModel
{
Id = element.Id.GetHashCode()
});
}
public void ReloadData()
{
DataTreeNodeConfig treeConfig = new();
treeConfig.NodeNames = new();
treeConfig.NodeNames.Enqueue("OrganisationType");
treeConfig.NodeNames.Enqueue("DateLastDelivery");
treeConfig.NodeNames.Enqueue("Id");
treeConfig.NodeNames.Enqueue("Name");
_controlDataTreeTable.LoadConfig(treeConfig);
var list = _plogic.ReadList(null);
if (list != null)
{
_controlDataTreeTable.Clear();
_controlDataTreeTable.AddTable(list);
}
}
public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
{
var list = _plogic.ReadList(null);
if (list != null)
{
List<string> strings = new List<string> { };
foreach (var item in list)
{
strings.Add($"{item.Name} : {item.FurnitureType}");
}
_largeTextComponent.CreateDocument(saveDocument.FileName, $"Отчет за {DateTime.Now.Year}", strings);
MessageBox.Show("Отчет готов");
return true;
}
return false;
}
public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
{
var list = _plogic.ReadList(null);
if (list != null)
{
var widths = new List<(int Column, int Row)> { (5, 5), (10, 5), (5, 5), (7, 5), (10, 5), };
var headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)> {
(0,0,"АЙДИ", "Id"),
(1,0,"Название", "Name"),
(2,0,"Перечень мебели", "FurnitureType"),
(3,0,"Тип организации", "OrganisationType"),
(4,0,"Дата последней доставки", "DateLastDelivery")
};
var conf = new ComponentDocumentWithTableHeaderDataConfig<ProviderViewModel>
{
FilePath = saveDocument.FileName,
Header = "Отчет по поставщикам",
ColumnsRowsDataCount = (list![0].GetType().GetProperties().Length, list.Count),
UseUnion = false,
ColumnsRowsWidth = widths,
Headers = headers,
Data = list,
};
_componentDocumentWithTableMultiHeaderExcel.CreateDoc<ProviderViewModel>(conf);
MessageBox.Show("Отчет готов");
return true;
}
return false;
}
public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
{
var list = _plogic.ReadList(null);
if (list != null)
{
var data = new List<(int Date, double Value)> { };
string header = "График по поставщикам\n";
var chart = new Dictionary<string, List<(int Date, double Value)>> { };
int index = 1;
foreach (var type in _ologic.ReadList(null)!)
{
int sum = 0;
foreach (var item in list)
{
if (item.OrganisationType == type.Name)
{
sum++;
}
}
header += $"{index} - {type.Name}\n";
if (sum != 0) data.Add((index, sum));
index++;
}
chart.Add("ИП", data);
var conf = new ComponentDocumentWithChartConfig
{
FilePath = saveDocument.FileName,
Header = header,
ChartTitle = "Диаграмма по типам организаций",
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
Data = chart,
};
_componentDocumentWithChartPieWord.CreateDoc(conf);
MessageBox.Show("Отчет готов");
return true;
}
return false;
}
}
}

View File

@ -0,0 +1,20 @@
using PluginsConventionLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Forms
{
public class PluginsConventionProvider : PluginsConventionElement
{
public string Name { get; set; } = string.Empty;
public string FurnitureType { get; set; } = string.Empty;
public string OrganisationType { get; set; } = string.Empty;
public string? DateLastDelivery { get; set; }
}
}

View File

@ -0,0 +1,43 @@
using BusinessLogics.BusinessLogics;
using Contracts.BusinessLogicsContracts;
using Contracts.StorageContracts;
using DatabaseImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Forms
{
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<MainForm>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddTransient<IOrganisationTypeStorage, OrganisationTypeStorage>();
services.AddTransient<IOrganisationTypeLogic, OrganisationTypeLogic>();
services.AddTransient<IProviderLogic, ProviderLogic>();
services.AddTransient<IProviderStorage, ProviderStorage>();
services.AddTransient<MainForm>();
services.AddTransient<OrganisationTypeForm>();
services.AddTransient<ProviderForm>();
}
}
}

View File

@ -0,0 +1,171 @@
namespace Forms
{
partial class ProviderForm
{
/// <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()
{
controlSelectedComboBoxList = new ControlsLibraryNet60.Selected.ControlSelectedComboBoxList();
textBoxName = new TextBox();
label1 = new Label();
textBoxFurnitureType = new TextBox();
label2 = new Label();
label3 = new Label();
label4 = new Label();
buttonAdd = new Button();
buttonCancel = new Button();
controlInputNullableDate = new ComponentProgramming.Control.DateBoxWithNull();
SuspendLayout();
//
// controlSelectedComboBoxList
//
controlSelectedComboBoxList.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
controlSelectedComboBoxList.Location = new Point(12, 119);
controlSelectedComboBoxList.Margin = new Padding(5, 3, 5, 3);
controlSelectedComboBoxList.Name = "controlSelectedComboBoxList";
controlSelectedComboBoxList.SelectedElement = "";
controlSelectedComboBoxList.Size = new Size(254, 24);
controlSelectedComboBoxList.TabIndex = 1;
controlSelectedComboBoxList.SelectedElementChange += OnInputChange;
//
// textBoxName
//
textBoxName.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
textBoxName.Location = new Point(12, 27);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(254, 23);
textBoxName.TabIndex = 2;
textBoxName.TextChanged += OnInputChange;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(12, 9);
label1.Name = "label1";
label1.Size = new Size(42, 15);
label1.TabIndex = 3;
label1.Text = "Name:";
//
// textBoxFurnitureType
//
textBoxFurnitureType.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
textBoxFurnitureType.Location = new Point(12, 73);
textBoxFurnitureType.Name = "textBoxFurnitureType";
textBoxFurnitureType.Size = new Size(254, 23);
textBoxFurnitureType.TabIndex = 4;
textBoxFurnitureType.TextChanged += OnInputChange;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(12, 55);
label2.Name = "label2";
label2.Size = new Size(84, 15);
label2.TabIndex = 5;
label2.Text = "Furniture type:";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(12, 101);
label3.Name = "label3";
label3.Size = new Size(104, 15);
label3.TabIndex = 6;
label3.Text = "Organisation type:";
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(12, 146);
label4.Name = "label4";
label4.Size = new Size(75, 15);
label4.TabIndex = 7;
label4.Text = "Last delivery:";
//
// buttonAdd
//
buttonAdd.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
buttonAdd.Location = new Point(12, 196);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 36);
buttonAdd.TabIndex = 8;
buttonAdd.Text = "Add";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
buttonCancel.Location = new Point(173, 196);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 36);
buttonCancel.TabIndex = 9;
buttonCancel.Text = "Cancel";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// controlInputNullableDate
//
controlInputNullableDate.Location = new Point(12, 165);
controlInputNullableDate.Name = "controlInputNullableDate";
controlInputNullableDate.Size = new Size(255, 30);
controlInputNullableDate.TabIndex = 10;
//
// ProviderForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(279, 241);
Controls.Add(controlInputNullableDate);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(label4);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(textBoxFurnitureType);
Controls.Add(label1);
Controls.Add(textBoxName);
Controls.Add(controlSelectedComboBoxList);
Name = "ProviderForm";
Text = "Create Provider";
FormClosing += ProviderForm_FormClosing;
ResumeLayout(false);
PerformLayout();
}
#endregion
private ControlsLibraryNet60.Selected.ControlSelectedComboBoxList controlSelectedComboBoxList;
private TextBox textBoxName;
private Label label1;
private TextBox textBoxFurnitureType;
private Label label2;
private Label label3;
private Label label4;
private Button buttonAdd;
private Button buttonCancel;
private ComponentProgramming.Control.DateBoxWithNull controlInputNullableDate;
}
}

View File

@ -0,0 +1,130 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicsContracts;
using Contracts.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;
namespace Forms
{
public partial class ProviderForm : Form
{
private int? _id;
private readonly IProviderLogic _pLogic;
private readonly IOrganisationTypeLogic _oLogic;
private bool isEdited;
public ProviderForm(IProviderLogic plogic, IOrganisationTypeLogic ologic, int? id = null)
{
InitializeComponent();
_pLogic = plogic;
_oLogic = ologic;
_id = id;
isEdited = false;
LoadData();
}
private void LoadData()
{
var list = _oLogic.ReadList(null);
if (list != null)
{
List<string> strList = new List<string>();
foreach (var item in list)
{
strList.Add(item.Name);
}
controlSelectedComboBoxList.AddList(strList);
}
if (_id.HasValue)
{
var view = _pLogic.ReadElement(new ProviderSearchModel
{
Id = _id.Value,
});
textBoxFurnitureType.Text = view.FurnitureType;
textBoxName.Text = view.Name;
if (view.DateLastDelivery != "Поставок не было") {
controlInputNullableDate.Value = Convert.ToDateTime(view.DateLastDelivery);
}
else
{
controlInputNullableDate.Value = null;
}
controlSelectedComboBoxList.SelectedElement = view!.OrganisationType;
isEdited = false;
}
}
private void OnInputChange(object sender, EventArgs e)
{
isEdited = true;
}
private void buttonAdd_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Заполните поле Название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxFurnitureType.Text))
{
MessageBox.Show("Заполните Перечень мебели ", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(controlSelectedComboBoxList.SelectedElement))
{
MessageBox.Show("Выберите Тип организации", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
isEdited = false;
try
{
var model = new ProviderBindingModel
{
Id = _id ?? 0,
Name = textBoxName.Text,
FurnitureType = textBoxFurnitureType.Text,
DateLastDelivery = controlInputNullableDate.Value.ToString() == "" ? "Поставок не было" : controlInputNullableDate.Value.ToString(),
OrganisationType = controlSelectedComboBoxList.SelectedElement
};
var OperationResult = _id.HasValue ? _pLogic.Update(model) : _pLogic.Create(model);
if (!OperationResult)
{
throw new Exception("Ошибка при создании поставщика.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ProviderForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (!isEdited) return;
var confirmResult = MessageBox.Show("Вы не сохранили изменения.\nВы действительно хотите выйти?", "Подтвердите действие",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question
);
if (confirmResult == DialogResult.No) e.Cancel = true;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models
{
public interface IId
{
int Id { get; }
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models.Models
{
public interface IOrganisationTypeModel: IId
{
string Name { get; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models.Models
{
public interface IProviderModel : IId
{
string Name { get;}
string FurnitureType { get;}
string OrganisationType { get; }
string? DateLastDelivery { get; }
}
}

View File

@ -0,0 +1,169 @@
namespace PluginApp
{
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()
{
menuStrip = new MenuStrip();
ControlsStripMenuItem = new ToolStripMenuItem();
ActionsToolStripMenuItem = new ToolStripMenuItem();
ThesaurusToolStripMenuItem = new ToolStripMenuItem();
AddElementToolStripMenuItem = new ToolStripMenuItem();
UpdElementToolStripMenuItem = new ToolStripMenuItem();
DelElementToolStripMenuItem = new ToolStripMenuItem();
DocsToolStripMenuItem = new ToolStripMenuItem();
SimpleDocToolStripMenuItem = new ToolStripMenuItem();
TableDocToolStripMenuItem = new ToolStripMenuItem();
ChartDocToolStripMenuItem = new ToolStripMenuItem();
panelControl = new Panel();
menuStrip.SuspendLayout();
SuspendLayout();
//
// menuStrip
//
menuStrip.Items.AddRange(new ToolStripItem[] { ControlsStripMenuItem, ActionsToolStripMenuItem, DocsToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(800, 24);
menuStrip.TabIndex = 0;
menuStrip.Text = "menuStrip1";
//
// ControlsStripMenuItem
//
ControlsStripMenuItem.Name = "ControlsStripMenuItem";
ControlsStripMenuItem.Size = new Size(90, 20);
ControlsStripMenuItem.Text = "Компоненты";
//
// ActionsToolStripMenuItem
//
ActionsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ThesaurusToolStripMenuItem, AddElementToolStripMenuItem, UpdElementToolStripMenuItem, DelElementToolStripMenuItem });
ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem";
ActionsToolStripMenuItem.Size = new Size(70, 20);
ActionsToolStripMenuItem.Text = "Действия";
//
// ThesaurusToolStripMenuItem
//
ThesaurusToolStripMenuItem.Name = "ThesaurusToolStripMenuItem";
ThesaurusToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.I;
ThesaurusToolStripMenuItem.Size = new Size(179, 22);
ThesaurusToolStripMenuItem.Text = "Справочник";
ThesaurusToolStripMenuItem.Click += ThesaurusToolStripMenuItem_Click;
//
// AddElementToolStripMenuItem
//
AddElementToolStripMenuItem.Name = "AddElementToolStripMenuItem";
AddElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
AddElementToolStripMenuItem.Size = new Size(179, 22);
AddElementToolStripMenuItem.Text = "Добавить";
AddElementToolStripMenuItem.Click += AddElementToolStripMenuItem_Click;
//
// UpdElementToolStripMenuItem
//
UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
UpdElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U;
UpdElementToolStripMenuItem.Size = new Size(179, 22);
UpdElementToolStripMenuItem.Text = "Изменить";
UpdElementToolStripMenuItem.Click += UpdElementToolStripMenuItem_Click;
//
// DelElementToolStripMenuItem
//
DelElementToolStripMenuItem.Name = "DelElementToolStripMenuItem";
DelElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
DelElementToolStripMenuItem.Size = new Size(179, 22);
DelElementToolStripMenuItem.Text = "Удалить";
DelElementToolStripMenuItem.Click += DelElementToolStripMenuItem_Click;
//
// DocsToolStripMenuItem
//
DocsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SimpleDocToolStripMenuItem, TableDocToolStripMenuItem, ChartDocToolStripMenuItem });
DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
DocsToolStripMenuItem.Size = new Size(82, 20);
DocsToolStripMenuItem.Text = "Документы";
//
// SimpleDocToolStripMenuItem
//
SimpleDocToolStripMenuItem.Name = "SimpleDocToolStripMenuItem";
SimpleDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
SimpleDocToolStripMenuItem.Size = new Size(232, 22);
SimpleDocToolStripMenuItem.Text = "Простой документ";
SimpleDocToolStripMenuItem.Click += SimpleDocToolStripMenuItem_Click;
//
// TableDocToolStripMenuItem
//
TableDocToolStripMenuItem.Name = "TableDocToolStripMenuItem";
TableDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
TableDocToolStripMenuItem.Size = new Size(232, 22);
TableDocToolStripMenuItem.Text = "Документ с таблицей";
TableDocToolStripMenuItem.Click += TableDocToolStripMenuItem_Click;
//
// ChartDocToolStripMenuItem
//
ChartDocToolStripMenuItem.Name = "ChartDocToolStripMenuItem";
ChartDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
ChartDocToolStripMenuItem.Size = new Size(232, 22);
ChartDocToolStripMenuItem.Text = "Диаграмма";
ChartDocToolStripMenuItem.Click += ChartDocToolStripMenuItem_Click;
//
// panelControl
//
panelControl.Location = new Point(0, 27);
panelControl.Name = "panelControl";
panelControl.Size = new Size(800, 424);
panelControl.TabIndex = 1;
//
// FormMain
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(panelControl);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormMain";
Text = "Основная форма";
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip;
private ToolStripMenuItem ControlsStripMenuItem;
private ToolStripMenuItem ActionsToolStripMenuItem;
private ToolStripMenuItem DocsToolStripMenuItem;
private ToolStripMenuItem SimpleDocToolStripMenuItem;
private ToolStripMenuItem TableDocToolStripMenuItem;
private ToolStripMenuItem ChartDocToolStripMenuItem;
private Panel panelControl;
private ToolStripMenuItem ThesaurusToolStripMenuItem;
private ToolStripMenuItem AddElementToolStripMenuItem;
private ToolStripMenuItem UpdElementToolStripMenuItem;
private ToolStripMenuItem DelElementToolStripMenuItem;
}
}

View File

@ -0,0 +1,216 @@
using PluginsConventionLibrary;
using System.Reflection;
namespace PluginApp
{
public partial class FormMain : Form
{
private readonly Dictionary<string, IPluginsConvention> _plugins;
private string _selectedPlugin;
public FormMain()
{
InitializeComponent();
_selectedPlugin = string.Empty;
_plugins = LoadPlugins();
}
private Dictionary<string, IPluginsConvention> LoadPlugins()
{
var plugins = new Dictionary<string, IPluginsConvention>();
string pluginsPath = Directory.GetParent(Directory.GetCurrentDirectory())!.Parent!.Parent!.FullName + "\\plugins";
string[] dllFiles = Directory.GetFiles(pluginsPath, "*.dll", SearchOption.AllDirectories);
if (!Directory.Exists(pluginsPath))
{
MessageBox.Show($"Îøèáêà ïîëó÷åíèÿ ïëàãèíîâ", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
return plugins;
}
foreach (var dll in dllFiles)
{
try
{
Assembly asmbly = Assembly.LoadFrom(dll);
Type[] types = asmbly.GetTypes();
foreach (var type in types)
{
if (typeof(IPluginsConvention).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract)
{
var plugin = (IPluginsConvention)Activator.CreateInstance(type)!;
plugins.Add(plugin.PluginName, plugin);
CreateStripMenuItem(plugin.PluginName);
}
}
}
catch
{
//MessageBox.Show($"Íåóäàëîñü çàãðóçèòü ïëàãèíû", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
return plugins;
}
private void CreateStripMenuItem(string pluginName)
{
var menuItem = new ToolStripMenuItem(pluginName);
menuItem.Click += (s, e) =>
{
_selectedPlugin = pluginName;
IPluginsConvention plugin = _plugins![pluginName];
if (plugin?.GetControl == null) throw new Exception("Íåóäàëîñü ïîëó÷èòü êîíòðîë");
UserControl userControl = plugin.GetControl;
panelControl.Controls.Clear();
plugin.ReloadData();
userControl.Dock = DockStyle.Fill;
panelControl.Controls.Add(userControl);
};
ControlsStripMenuItem.DropDownItems.Add(menuItem);
}
private void FormMain_KeyDown(object sender, KeyEventArgs e)
{
if (string.IsNullOrEmpty(_selectedPlugin) || !_plugins.ContainsKey(_selectedPlugin))
{
return;
}
if (!e.Control)
{
return;
}
switch (e.KeyCode)
{
case Keys.I:
ShowThesaurus();
break;
case Keys.A:
AddNewElement();
break;
case Keys.U:
UpdateElement();
break;
case Keys.D:
DeleteElement();
break;
case Keys.S:
CreateSimpleDoc();
break;
case Keys.T:
CreateTableDoc();
break;
case Keys.C:
CreateChartDoc();
break;
}
}
private void ShowThesaurus()
{
_plugins[_selectedPlugin].GetThesaurus().Show();
}
private void AddNewElement()
{
var form = _plugins[_selectedPlugin].GetForm(null);
if (form != null && form.ShowDialog() == DialogResult.OK)
{
_plugins[_selectedPlugin].ReloadData();
}
}
private void UpdateElement()
{
var element = _plugins[_selectedPlugin].GetElement;
if (element == null)
{
MessageBox.Show("Íåò âûáðàííîãî ýëåìåíòà", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
var form = _plugins[_selectedPlugin].GetForm(element);
if (form != null && form.ShowDialog() == DialogResult.OK)
{
_plugins[_selectedPlugin].ReloadData();
}
}
private void DeleteElement()
{
if (MessageBox.Show("Óäàëèòü âûáðàííûé ýëåìåíò", "Óäàëåíèå", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
var element = _plugins[_selectedPlugin].GetElement;
if (element == null)
{
MessageBox.Show("Íåò âûáðàííîãî ýëåìåíòà", "Îøèáêà",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (_plugins[_selectedPlugin].DeleteElement(element))
{
_plugins[_selectedPlugin].ReloadData();
}
}
private void CreateSimpleDoc()
{
using var dialog = new SaveFileDialog
{
Filter = "PDF Files|*.pdf"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
if (_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument() { FileName = dialog.FileName }))
{
MessageBox.Show("Äîêóìåíò ñîõðàíåí", "Ñîçäàíèå äîêóìåíòà", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Îøèáêà ïðè ñîçäàíèè äîêóìåíòà",
"Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void CreateTableDoc()
{
using var dialog = new SaveFileDialog
{
Filter = "Excel Files|*.xlsx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
if (_plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument() { FileName = dialog.FileName }))
{
MessageBox.Show("Äîêóìåíò ñîõðàíåí", "Ñîçäàíèå äîêóìåíòà", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Îøèáêà ïðè ñîçäàíèè äîêóìåíòà",
"Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
public void CreateChartDoc()
{
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
if (_plugins[_selectedPlugin].CreateChartDocument(new PluginsConventionSaveDocument() { FileName = dialog.FileName }))
{
MessageBox.Show("Äîêóìåíò ñîõðàíåí", "Ñîçäàíèå äîêóìåíòà", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Îøèáêà ïðè ñîçäàíèè äîêóìåíòà",
"Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ThesaurusToolStripMenuItem_Click(object sender, EventArgs e) => ShowThesaurus();
private void AddElementToolStripMenuItem_Click(object sender, EventArgs e) => AddNewElement();
private void UpdElementToolStripMenuItem_Click(object sender, EventArgs e) => UpdateElement();
private void DelElementToolStripMenuItem_Click(object sender, EventArgs e) => DeleteElement();
private void SimpleDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateSimpleDoc();
private void TableDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateTableDoc();
private void ChartDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateChartDoc();
}
}

View 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="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="plugins\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" 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>
</ItemGroup>
</Project>

View File

@ -0,0 +1,17 @@
namespace PluginApp
{
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());
}
}
}

View File

@ -0,0 +1,58 @@

namespace PluginsConventionLibrary
{
public interface IPluginsConvention
{
/// <summary>
/// Название плагина
/// </summary>
string PluginName { get; }
/// <summary>
/// Получение контрола для вывода набора данных
/// </summary>
UserControl GetControl { get; }
/// <summary>
/// Получение элемента, выбранного в контроле
/// </summary>
PluginsConventionElement GetElement { get; }
/// <summary>
/// Получение формы для создания/редактирования объекта
/// </summary>
/// <param name="element"></param>
/// <returns></returns>
Form GetForm(PluginsConventionElement element);
/// <summary>
/// Получение формы для работы со справочником
/// </summary>
/// <returns></returns>
Form GetThesaurus();
/// <summary>
/// Удаление элемента
/// /// </summary>
/// <param name="element"></param>
/// <returns></returns>
bool DeleteElement(PluginsConventionElement element);
/// <summary>
/// Обновление набора данных в контроле
/// </summary>
void ReloadData();
/// <summary>
/// Создание простого документа
/// </summary>
/// <param name="saveDocument"></param>
/// <returns></returns>
bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument);
/// <summary>
/// Создание простого документа
/// </summary>
/// <param name="saveDocument"></param>
/// <returns></returns>
bool CreateTableDocument(PluginsConventionSaveDocument saveDocument);
/// <summary>
/// Создание документа с диаграммой
/// </summary>
/// <param name="saveDocument"></param>
/// <returns></returns>
bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PluginsConventionLibrary
{
public class PluginsConventionElement
{
public Guid Id { get; set; }
}
}

View File

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PluginsConventionLibrary
{
public class PluginsConventionSaveDocument
{
public string FileName { get; set; }
}
}