This commit is contained in:
Владимир Данилов
2024-12-12 22:05:42 +04:00
parent df6647c3b4
commit 1a3a93e44a
78 changed files with 882 additions and 378 deletions

View File

@@ -3,15 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataModels", "DataModels\DataModels.csproj", "{1A0D3060-AA07-4FE1-B35F-C50BDBD7DC11}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataModels", "DataModels\DataModels.csproj", "{1A0D3060-AA07-4FE1-B35F-C50BDBD7DC11}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinForms", "WinForms\WinForms.csproj", "{41510F7C-2870-4639-A9C0-21B45A670051}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinForms", "WinForms\WinForms.csproj", "{41510F7C-2870-4639-A9C0-21B45A670051}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BusinessLogic", "BusinessLogic\BusinessLogic.csproj", "{2F353788-82CB-41FB-9F30-0677595B324F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BusinessLogic", "BusinessLogic\BusinessLogic.csproj", "{2F353788-82CB-41FB-9F30-0677595B324F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contracts", "Contracts\Contracts.csproj", "{4E33A514-74DF-4249-BC9A-577A9DE2428A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{4E33A514-74DF-4249-BC9A-577A9DE2428A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{3E515C5F-ACF7-4980-B13F-4A2BC6E08D93}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{3E515C5F-ACF7-4980-B13F-4A2BC6E08D93}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginsConventionLibrary", "PluginsConventionLibrarys\PluginsConventionLibrary.csproj", "{802363FC-E4F5-4EEF-A41A-FF1195877C36}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -39,6 +41,10 @@ Global
{3E515C5F-ACF7-4980-B13F-4A2BC6E08D93}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E515C5F-ACF7-4980-B13F-4A2BC6E08D93}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E515C5F-ACF7-4980-B13F-4A2BC6E08D93}.Release|Any CPU.Build.0 = Release|Any CPU
{802363FC-E4F5-4EEF-A41A-FF1195877C36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{802363FC-E4F5-4EEF-A41A-FF1195877C36}.Debug|Any CPU.Build.0 = Debug|Any CPU
{802363FC-E4F5-4EEF-A41A-FF1195877C36}.Release|Any CPU.ActiveCfg = Release|Any CPU
{802363FC-E4F5-4EEF-A41A-FF1195877C36}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
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,7 @@
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</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<UseWindowsForms>true</UseWindowsForms>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,7 @@
namespace PluginsConventionLibrary
{
public class PluginsConventionSaveDocument
{
public string FileName { get; set; }
}
}

View File

@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
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,7 @@
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,7 @@
namespace PluginsConventionLibrary
{
public class PluginsConventionSaveDocument
{
public string FileName { get; set; }
}
}

View File

@@ -68,8 +68,8 @@ namespace WinForms
var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
if (name is null) return;
_logic.Create(new CityBindingModel { Id = 0, Name = name.ToString() });
int newInterestId = _logic.ReadList(null).ToList().Last().Id;
dataGridView.Rows[e.RowIndex].Cells[1].Value = newInterestId;
int newCityId = _logic.ReadList(null).ToList().Last().Id;
dataGridView.Rows[e.RowIndex].Cells[1].Value = newCityId;
}
}

View File

@@ -1,16 +1,14 @@
using System.Windows.Forms;
namespace WinForms
namespace WinForms
{
partial class FormMain
{
/// <summary>
/// Required designer variable.
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// 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)
@@ -25,131 +23,132 @@ namespace WinForms
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
menuStrip = new MenuStrip();
заказыToolStripMenuItem = new ToolStripMenuItem();
создатьToolStripMenuItem = new ToolStripMenuItem();
редактироватьToolStripMenuItem = new ToolStripMenuItem();
удалитьToolStripMenuItem = new ToolStripMenuItem();
отчётыToolStripMenuItem = new ToolStripMenuItem();
документToolStripMenuItem = new ToolStripMenuItem();
документСТаблицейToolStripMenuItem = new ToolStripMenuItem();
документСДиаграммойToolStripMenuItem = new ToolStripMenuItem();
выбранныеТоварыToolStripMenuItem = new ToolStripMenuItem();
controlDataTable = new ControlsLibraryNet60.Data.ControlDataTableTable();
tablepdf1 = new Components.NonVisual.TablePDF(components);
componentExcelWithTable1 = new PutincevLibrary.ComponentExcelWithTable(components);
componentDocumentWithChartLineWord1 = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartLineWord(components);
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.ImageScalingSize = new Size(18, 18);
menuStrip.Items.AddRange(new ToolStripItem[] { заказыToolStripMenuItem, отчётыToolStripMenuItem, выбранныеТоварыToolStripMenuItem });
menuStrip.Items.AddRange(new ToolStripItem[] { ControlsStripMenuItem, ActionsToolStripMenuItem, DocsToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Padding = new Padding(5, 2, 0, 2);
menuStrip.Size = new Size(853, 24);
menuStrip.Size = new Size(800, 24);
menuStrip.TabIndex = 0;
menuStrip.Text = "menuStrip";
menuStrip.Text = "Меню";
//
// заказыToolStripMenuItem
// ControlsStripMenuItem
//
заказыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { создатьToolStripMenuItem, редактироватьToolStripMenuItem, удалитьToolStripMenuItem });
заказыToolStripMenuItem.Name = аказыToolStripMenuItem";
заказыToolStripMenuItem.Size = new Size(63, 20);
заказыToolStripMenuItem.Text = "Аккаунт";
ControlsStripMenuItem.Name = "ControlsStripMenuItem";
ControlsStripMenuItem.Size = new Size(90, 20);
ControlsStripMenuItem.Text = "Компоненты";
//
// создатьToolStripMenuItem
// ActionsToolStripMenuItem
//
создатьToolStripMenuItem.Name = "создатьToolStripMenuItem";
создатьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
создатьToolStripMenuItem.Size = new Size(196, 22);
создатьToolStripMenuItem.Text = "Создать";
создатьToolStripMenuItem.Click += создатьToolStripMenuItem_Click;
ActionsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ThesaurusToolStripMenuItem, AddElementToolStripMenuItem, UpdElementToolStripMenuItem, DelElementToolStripMenuItem });
ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem";
ActionsToolStripMenuItem.Size = new Size(70, 20);
ActionsToolStripMenuItem.Text = "Действия";
//
// редактироватьToolStripMenuItem
// ThesaurusToolStripMenuItem
//
редактироватьToolStripMenuItem.Name = "редактироватьToolStripMenuItem";
редактироватьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U;
редактироватьToolStripMenuItem.Size = new Size(196, 22);
редактироватьToolStripMenuItem.Text = "Редактировать";
редактироватьToolStripMenuItem.Click += редактироватьToolStripMenuItem_Click;
ThesaurusToolStripMenuItem.Name = "ThesaurusToolStripMenuItem";
ThesaurusToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.I;
ThesaurusToolStripMenuItem.Size = new Size(180, 22);
ThesaurusToolStripMenuItem.Text = "Справочник";
ThesaurusToolStripMenuItem.Click += ThesaurusToolStripMenuItem_Click;
//
// удалитьToolStripMenuItem
// AddElementToolStripMenuItem
//
удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
удалитьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
удалитьToolStripMenuItem.Size = new Size(196, 22);
удалитьToolStripMenuItem.Text = "Удалить";
удалитьToolStripMenuItem.Click += удалитьToolStripMenuItem_Click;
AddElementToolStripMenuItem.Name = "AddElementToolStripMenuItem";
AddElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
AddElementToolStripMenuItem.Size = new Size(180, 22);
AddElementToolStripMenuItem.Text = "Добавить";
AddElementToolStripMenuItem.Click += AddElementToolStripMenuItem_Click;
//
// отчётыToolStripMenuItem
// UpdElementToolStripMenuItem
//
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { документToolStripMenuItem, документСТаблицейToolStripMenuItem, документСДиаграммойToolStripMenuItem });
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
отчётыToolStripMenuItem.Size = new Size(60, 20);
отчётыToolStripMenuItem.Text = "Отчёты";
UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
UpdElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U;
UpdElementToolStripMenuItem.Size = new Size(180, 22);
UpdElementToolStripMenuItem.Text = "Изменить";
UpdElementToolStripMenuItem.Click += UpdElementToolStripMenuItem_Click;
//
// документToolStripMenuItem
// DelElementToolStripMenuItem
//
документToolStripMenuItem.Name = "документToolStripMenuItem";
документToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
документToolStripMenuItem.Size = new Size(309, 22);
документToolStripMenuItem.Text = "Документ с простой таблицей";
документToolStripMenuItem.Click += GeneratePdfButton_Click;
DelElementToolStripMenuItem.Name = "DelElementToolStripMenuItem";
DelElementToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
DelElementToolStripMenuItem.Size = new Size(180, 22);
DelElementToolStripMenuItem.Text = "Удалить";
DelElementToolStripMenuItem.Click += DelElementToolStripMenuItem_Click;
//
// документСТаблицейToolStripMenuItem
// DocsToolStripMenuItem
//
документСТаблицейToolStripMenuItem.Name = "документСТаблицейToolStripMenuItem";
документСТаблицейToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
документСТаблицейToolStripMenuItem.Size = new Size(309, 22);
документСТаблицейToolStripMenuItem.Text = "Отчет по всем аккаунтам Excel";
документСТаблицейToolStripMenuItem.Click += GenerateExelButton_Click;
DocsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SimpleDocToolStripMenuItem, TableDocToolStripMenuItem, ChartDocToolStripMenuItem });
DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
DocsToolStripMenuItem.Size = new Size(82, 20);
DocsToolStripMenuItem.Text = "Документы";
//
// документСДиаграммойToolStripMenuItem
// SimpleDocToolStripMenuItem
//
документСДиаграммойToolStripMenuItem.Name = "документСДиаграммойToolStripMenuItem";
документСДиаграммойToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
документСДиаграммойToolStripMenuItem.Size = new Size(309, 22);
документСДиаграммойToolStripMenuItem.Text = "Документ с линейной диаграммой";
документСДиаграммойToolStripMenuItem.Click += GenerateWordButton_Click;
SimpleDocToolStripMenuItem.Name = "SimpleDocToolStripMenuItem";
SimpleDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
SimpleDocToolStripMenuItem.Size = new Size(232, 22);
SimpleDocToolStripMenuItem.Text = "Простой документ";
SimpleDocToolStripMenuItem.Click += SimpleDocToolStripMenuItem_Click;
//
// выбранныеТоварыToolStripMenuItem
// TableDocToolStripMenuItem
//
выбранныеТоварыToolStripMenuItem.Name = "выбранныеТоварыToolStripMenuItem";
выбранныеТоварыToolStripMenuItem.Size = new Size(130, 20);
выбранныеТоварыToolStripMenuItem.Text = "Города проживания";
выбранныеТоварыToolStripMenuItem.Click += выбранныеТоварыToolStripMenuItem_Click;
TableDocToolStripMenuItem.Name = "TableDocToolStripMenuItem";
TableDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
TableDocToolStripMenuItem.Size = new Size(232, 22);
TableDocToolStripMenuItem.Text = "Документ с таблицей";
TableDocToolStripMenuItem.Click += TableDocToolStripMenuItem_Click;
//
// controlDataTable
// ChartDocToolStripMenuItem
//
controlDataTable.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
controlDataTable.Location = new Point(13, 27);
controlDataTable.Margin = new Padding(4, 3, 4, 3);
controlDataTable.Name = "controlDataTable";
controlDataTable.SelectedRowIndex = -1;
controlDataTable.Size = new Size(827, 392);
controlDataTable.TabIndex = 1;
ChartDocToolStripMenuItem.Name = "ChartDocToolStripMenuItem";
ChartDocToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
ChartDocToolStripMenuItem.Size = new Size(232, 22);
ChartDocToolStripMenuItem.Text = "Диаграмма";
ChartDocToolStripMenuItem.Click += ChartDocToolStripMenuItem_Click;
//
// panelControl
//
panelControl.Dock = DockStyle.Fill;
panelControl.Location = new Point(0, 24);
panelControl.Name = "panelControl";
panelControl.Size = new Size(800, 426);
panelControl.TabIndex = 1;
//
// FormMain
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(853, 431);
Controls.Add(controlDataTable);
ClientSize = new Size(800, 450);
Controls.Add(panelControl);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Margin = new Padding(3, 2, 3, 2);
Name = "FormMain";
Text = "Аккаунты";
Load += FormMain_Load;
StartPosition = FormStartPosition.CenterScreen;
Text = "Главная форма";
WindowState = FormWindowState.Maximized;
KeyDown += FormMain_KeyDown;
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
@@ -157,19 +156,18 @@ namespace WinForms
}
#endregion
private MenuStrip menuStrip;
private ToolStripMenuItem заказыToolStripMenuItem;
private ToolStripMenuItem создатьToolStripMenuItem;
private ToolStripMenuItem редактироватьToolStripMenuItem;
private ToolStripMenuItem удалитьToolStripMenuItem;
private ToolStripMenuItem отчётыToolStripMenuItem;
private ToolStripMenuItem документToolStripMenuItem;
private ToolStripMenuItem документСТаблицейToolStripMenuItem;
private ToolStripMenuItem выбранныеТоварыToolStripMenuItem;
private ToolStripMenuItem документСДиаграммойToolStripMenuItem;
private ControlsLibraryNet60.Data.ControlDataTableTable controlDataTable;
private Components.NonVisual.TablePDF tablepdf1;
private PutincevLibrary.ComponentExcelWithTable componentExcelWithTable1;
private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartLineWord componentDocumentWithChartLineWord1;
private System.Windows.Forms.MenuStrip menuStrip;
private System.Windows.Forms.ToolStripMenuItem ControlsStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem DocsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem SimpleDocToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem TableDocToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ChartDocToolStripMenuItem;
private System.Windows.Forms.Panel panelControl;
private System.Windows.Forms.ToolStripMenuItem ActionsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ThesaurusToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem AddElementToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem UpdElementToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem DelElementToolStripMenuItem;
}
}
}

View File

@@ -1,285 +1,261 @@
using Components.NonVisual;
using Components.SaveToPdfHelpers;
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.ViewModels;
using ControlsLibraryNet60.Core;
using ControlsLibraryNet60.Models;
using PutincevLibrary;
using PutincevLibrary.Info;
using System.Text;
using ComponentsLibraryNet60.DocumentWithChart;
using ComponentsLibraryNet60.Models;
using PluginsConventionLibrary;
using System.Reflection;
namespace WinForms
{
public partial class FormMain : Form
{
private IAccountLogic _logic;
private readonly Dictionary<string, IPluginsConvention> _plugins;
public FormMain(IAccountLogic logic)
private string _selectedPlugin;
public FormMain()
{
InitializeComponent();
_logic = logic;
controlDataTable.LoadColumns(new List<DataTableColumnConfig>
{
new DataTableColumnConfig { ColumnHeader = "Идентификатор", PropertyName = "Id", Visible = true, Width = 100 },
new DataTableColumnConfig { ColumnHeader = "Логин", PropertyName = "Login", Visible = true, Width = 200 },
new DataTableColumnConfig { ColumnHeader = "Город проживания", PropertyName = "ResidenceCityName", Visible = true, Width = 150 },
new DataTableColumnConfig { ColumnHeader = "Последние попытки авторизации", PropertyName = "AccountStatusHistory", Visible = true, Width = 250 },
new DataTableColumnConfig { ColumnHeader = "Дата создания аккаунта", PropertyName = "AccountCreationDate", Visible = true, Width = 125 },
});
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
_plugins = new();
LoadPlugins();
_selectedPlugin = string.Empty;
}
private void LoadData()
private void LoadPlugins()
{
controlDataTable.Clear();
var accounts = _logic.ReadList(null);
if (accounts != null)
List<IPluginsConvention> pluginsList = GetPlugins();
foreach (var plugin in pluginsList)
{
var displayAccounts = accounts.Select(account => new
{
account.Id,
account.Login,
account.ResidenceCityName,
AccountStatusHistory = string.Join(", \n", account.AuthorizationAttemptsHistory),
account.AccountCreationDate
}).ToList();
controlDataTable.AddTable(displayAccounts);
}
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void создатьToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormAccount));
if (service is FormAccount form)
{
form.ShowDialog();
LoadData();
_plugins[plugin.PluginName] = plugin;
CreateMenuItem(plugin.PluginName);
}
}
private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
private List<IPluginsConvention> GetPlugins()
{
var service = Program.ServiceProvider?.GetService(typeof(FormAccount));
if (service is FormAccount form)
string currentDir = Environment.CurrentDirectory;
string pluginsDir = Directory.GetParent(currentDir).Parent.Parent.Parent.FullName + "/WinForms/Plugins";
string[] dllFiles = Directory.GetFiles(
pluginsDir,
"*.dll",
SearchOption.AllDirectories
);
List<IPluginsConvention> plugins = new();
foreach (string dllFile in dllFiles)
{
form._id = controlDataTable.GetSelectedObject<AccountViewModel>().Id;
if (form.ShowDialog() == DialogResult.OK)
try
{
LoadData();
}
}
}
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
{
var selectedAccount = controlDataTable.GetSelectedObject<AccountViewModel>();
if (selectedAccount == null)
{
MessageBox.Show("Не выбрана запись для удаления.");
return;
}
if (MessageBox.Show("Удалить запись?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
if (_logic.Delete(new AccountBindingModel { Id = selectedAccount.Id }))
{
LoadData();
MessageBox.Show("Запись успешно удалена.");
}
else
{
MessageBox.Show("Ошибка при удалении записи.");
}
}
}
private void GeneratePdfButton_Click(object sender, EventArgs e)
{
try
{
var accounts = _logic.ReadList(null);
var accountTables = new List<string[,]>();
foreach (var account in accounts)
{
int rowCount = account.AuthorizationAttemptsHistory.Count;
string[,] accountTable = new string[rowCount + 1, 4];
accountTable[0, 0] = "Попытки авторизаций";
accountTable[0, 1] = "Идентификатор аккаунта";
accountTable[0, 2] = "Город проживания";
accountTable[0, 3] = "Дата создания";
for (int i = 0; i < rowCount; i++)
Assembly assembly = Assembly.LoadFrom(dllFile);
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
accountTable[i + 1, 0] = account.AuthorizationAttemptsHistory[i].ToString("dd-MM-yyyy");
accountTable[i + 1, 1] = account.Id.ToString();
accountTable[i + 1, 2] = account.ResidenceCityName;
accountTable[i + 1, 3] = account.AccountCreationDate.ToString("dd-MM-yyyy");
}
accountTables.Add(accountTable);
}
using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog())
{
saveFileDialog.Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*";
saveFileDialog.Title = "Сохранить PDF-документ";
saveFileDialog.FileName = "Отчет1.pdf";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
var pdfData = new PdfDocumentData(
saveFileDialog.FileName,
"Отчет по попыткам авторизации аккаунтов",
accountTables
);
tablepdf1.GeneratePdf(pdfData);
MessageBox.Show("PDF-документ успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (typeof(IPluginsConvention).IsAssignableFrom(type) && !type.IsInterface)
{
if (Activator.CreateInstance(type) is IPluginsConvention plugin)
{
plugins.Add(plugin);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(
ex.Message
);
}
}
catch (Exception ex)
{
MessageBox.Show($"Произошла ошибка: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return plugins;
}
private void GenerateExelButton_Click(object sender, EventArgs e)
private void CreateMenuItem(string pluginName)
{
ComponentExcelWithTable table = new();
var accounts = _logic.ReadList(null);
if (accounts == null || accounts.Count == 0)
ToolStripMenuItem menuItem = new(pluginName);
menuItem.Click += (object? sender, EventArgs e) =>
{
UserControl userControl = _plugins[pluginName].GetControl;
if (userControl != null)
{
panelControl.Controls.Clear();
userControl.Dock = DockStyle.Fill;
_plugins[pluginName].ReloadData();
_selectedPlugin = pluginName;
panelControl.Controls.Add(userControl);
}
};
ControlsStripMenuItem.DropDownItems.Add(menuItem);
}
private void FormMain_KeyDown(object sender, KeyEventArgs e)
{
if (string.IsNullOrEmpty(_selectedPlugin) || !_plugins.ContainsKey(_selectedPlugin))
{
MessageBox.Show("Нет данных для отчета.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
Dictionary<string, (List<(string, string)>, List<int>)> headers = new()
if (!e.Control)
{
{ "Идентификатор аккаунта", (new List<(string, string)> { ("Id", "Идентификатор") }, new List<int> { 30 }) },
{ "Логин", (new List<(string, string)> { ("Login", "Логин") }, new List<int> { 30 }) },
{ "Информация", (new List<(string, string)> { ("ResidenceCityName", "Город проживания"), ("AccountCreationDate", "Дата создания") }, new List<int> { 25, 25 }) }
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"
};
string path = AppDomain.CurrentDomain.BaseDirectory + "OrderReport.xlsx";
using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog())
if (dialog.ShowDialog() == DialogResult.OK)
{
saveFileDialog.Title = "Сохранить Excel-документ";
saveFileDialog.FileName = "Отчет2.xlsx";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
try
{
path = saveFileDialog.FileName;
if (_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument() { FileName = dialog.FileName }))
{
MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show("Ïðîèçîøëà îøèáêà: " + ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
ExcelTableInfo<Contracts.ViewModels.AccountViewModel> info = new(path, "Отчет по аккаунтам", accounts, headers);
try
{
table.GenerateDocument(info);
MessageBox.Show("Сохарнено успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void GenerateWordButton_Click(object sender, EventArgs e)
private void CreateTableDoc()
{
var accounts = _logic.ReadList(null).Cast<AccountViewModel>().ToList();
var chartData = new Dictionary<string, List<(DateTime Date, int Count)>>();
foreach (var order in accounts)
using var dialog = new SaveFileDialog
{
if (!chartData.ContainsKey(order.ResidenceCityName))
{
chartData[order.ResidenceCityName] = new List<(DateTime Date, int Count)>();
}
var existingData = chartData[order.ResidenceCityName]
.FirstOrDefault(d => d.Date.Date == order.AccountCreationDate.Date);
if (existingData.Date == default)
{
chartData[order.ResidenceCityName].Add((order.AccountCreationDate.Date, 1));
}
else
{
int index = chartData[order.ResidenceCityName].FindIndex(d => d.Date.Date == order.AccountCreationDate.Date);
var updatedValue = chartData[order.ResidenceCityName][index];
chartData[order.ResidenceCityName][index] = (updatedValue.Date, updatedValue.Count + 1);
}
}
string filePath = "Отчет3.docx";
using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog())
{
saveFileDialog.Title = "Сохранить Word-документ";
saveFileDialog.FileName = "Отчет3.docx";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
filePath = saveFileDialog.FileName;
MessageBox.Show("Docx-документ успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
var config = new ComponentDocumentWithChartConfig
{
ChartTitle = "Отчет по аккаунтам",
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
Data = chartData.ToDictionary(
entry => entry.Key,
entry => entry.Value.Select(d => (DateTimeToInt(d.Date), (double)d.Count)).ToList()),
FilePath = filePath,
Header = "Заголовок аккаунта"
Filter = "Excel Files|*.xlsx"
};
var documentComponent = new ComponentDocumentWithChartLineWord();
documentComponent.CreateDoc(config);
MessageBox.Show("Документ создан успешно!");
}
private int DateTimeToInt(DateTime date)
{
return date.Day;
}
private void выбранныеТоварыToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCities));
if (service is FormCities form)
if (dialog.ShowDialog() == DialogResult.OK)
{
form.ShowDialog();
try
{
if (_plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument() { FileName = dialog.FileName }))
{
MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show("Ïðîèçîøëà îøèáêà: " + ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void CreateChartDoc()
{
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
if (_plugins[_selectedPlugin].CreateChartDocument(new PluginsConventionSaveDocument() { FileName = dialog.FileName }))
{
MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show("Ïðîèçîøëà îøèáêà: " + ex.Message, "Îøèáêà", 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();
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,264 @@
using BusinessLogic.BusinessLogics;
using Components;
using Components.NonVisual;
using Components.SaveToPdfHelpers;
using ComponentsLibraryNet60.DocumentWithChart;
using ComponentsLibraryNet60.Models;
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.ViewModels;
using ControlsLibraryNet60.Data;
using ControlsLibraryNet60.Models;
using DatabaseImplement.Implements;
using DocumentFormat.OpenXml.Office2013.Excel;
using PluginsConventionLibrary;
using PutincevLibrary;
using PutincevLibrary.Info;
using System.Text;
namespace WinForms
{
public class PluginsConvention : IPluginsConvention
{
private readonly IAccountLogic _accountLogic;
private readonly ICityLogic _cityLogic;
private readonly ControlDataTableTable _controlDataTableTable = new();
private readonly TablePDF _tablepdf = new();
private readonly ComponentExcelWithTable _componentExcelWithTable = new();
private readonly ComponentDocumentWithChartLineWord _componentDocumentWithChartLineWord = new();
public PluginsConvention()
{
_accountLogic = new AccountLogic(new AccountStorage());
_cityLogic = new CityLogic(new CityStorage());
ReloadData();
}
public string PluginName => "LabWork3 Plugin";
public UserControl GetControl => _controlDataTableTable;
public PluginsConventionElement GetElement
{
get
{
var selected = _controlDataTableTable.GetSelectedObject<AccountViewModel>()
?? throw new Exception("Не удалось получить выбранный элемент");
return new PluginsConventionAccount()
{
Id = IntToGuid(selected.Id),
Login = selected.Login,
AuthorizationAttemptsHistory = selected.AuthorizationAttemptsHistory.ToString(),
ResidenceCityName = selected.ResidenceCityName,
AccountCreationDate = selected.AccountCreationDate.ToString()
};
}
}
public Form GetForm(PluginsConventionElement element)
{
var formAccount = new FormAccount(_accountLogic, _cityLogic);
if (element != null)
{
formAccount.Id = element.Id.GetHashCode();
}
return formAccount;
}
public Form GetThesaurus()
{
return new FormCities(_cityLogic);
}
public bool DeleteElement(PluginsConventionElement element)
{
return _accountLogic.Delete(
new AccountBindingModel { Id = element.Id.GetHashCode() }
);
}
public void ReloadData()
{
try
{
var accounts = _accountLogic.ReadList(null) ?? throw new Exception("Не удалось получить список аккаунтов");
_controlDataTableTable.Clear();
_controlDataTableTable.LoadColumns(new List<DataTableColumnConfig>
{
new DataTableColumnConfig { ColumnHeader = "Идентификатор", PropertyName = "Id", Visible = true, Width = 100 },
new DataTableColumnConfig { ColumnHeader = "Логин", PropertyName = "Login", Visible = true, Width = 200 },
new DataTableColumnConfig { ColumnHeader = "Город проживания", PropertyName = "ResidenceCityName", Visible = true, Width = 150 },
new DataTableColumnConfig { ColumnHeader = "Последние попытки авторизации", PropertyName = "AccountStatusHistory", Visible = true, Width = 250 },
new DataTableColumnConfig { ColumnHeader = "Дата создания аккаунта", PropertyName = "AccountCreationDate", Visible = true, Width = 125 },
});
_controlDataTableTable.AddTable(accounts);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
{
try
{
var accounts = _accountLogic.ReadList(null);
var accountTables = new List<string[,]>();
foreach (var account in accounts)
{
int rowCount = account.AuthorizationAttemptsHistory.Count;
string[,] accountTable = new string[rowCount + 1, 4];
accountTable[0, 0] = "Попытки авторизаций";
accountTable[0, 1] = "Идентификатор аккаунта";
accountTable[0, 2] = "Город проживания";
accountTable[0, 3] = "Дата создания";
for (int i = 0; i < rowCount; i++)
{
accountTable[i + 1, 0] = account.AuthorizationAttemptsHistory[i].ToString("dd-MM-yyyy");
accountTable[i + 1, 1] = account.Id.ToString();
accountTable[i + 1, 2] = account.ResidenceCityName;
accountTable[i + 1, 3] = account.AccountCreationDate.ToString("dd-MM-yyyy");
}
accountTables.Add(accountTable);
}
var pdfData = new PdfDocumentData(
saveDocument.FileName,
"Отчет по заказам",
accountTables
);
var documentGenerator = new TablePDF();
documentGenerator.GeneratePdf(pdfData);
MessageBox.Show("PDF-документ успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
return true;
}
catch (Exception ex)
{
MessageBox.Show($"Произошла ошибка: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return false;
}
public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
{
ComponentExcelWithTable table = new();
var accounts = _accountLogic.ReadList(null);
if (accounts == null || accounts.Count == 0)
{
MessageBox.Show("Нет данных для отчета.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
Dictionary<string, (List<(string, string)>, List<int>)> headers = new()
{
{ "Идентификатор аккаунта", (new List<(string, string)> { ("Id", "Идентификатор") }, new List<int> { 30 }) },
{ "Логин", (new List<(string, string)> { ("Login", "Логин") }, new List<int> { 30 }) },
{ "Информация", (new List<(string, string)> { ("ResidenceCityName", "Город проживания"), ("AccountCreationDate", "Дата создания") }, new List<int> { 25, 25 }) }
};
ExcelTableInfo<Contracts.ViewModels.AccountViewModel> info = new(saveDocument.FileName, "Отчет по аккаунтам", accounts, headers);
try
{
table.GenerateDocument(info);
MessageBox.Show("Сохарнено успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
return true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return false;
}
public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
{
var accounts = _accountLogic.ReadList(null).Cast<AccountViewModel>().ToList();
var chartData = new Dictionary<string, List<(DateTime Date, int Count)>>();
foreach (var order in accounts)
{
if (!chartData.ContainsKey(order.ResidenceCityName))
{
chartData[order.ResidenceCityName] = new List<(DateTime Date, int Count)>();
}
var existingData = chartData[order.ResidenceCityName]
.FirstOrDefault(d => d.Date.Date == order.AccountCreationDate.Date);
if (existingData.Date == default)
{
chartData[order.ResidenceCityName].Add((order.AccountCreationDate.Date, 1));
}
else
{
int index = chartData[order.ResidenceCityName].FindIndex(d => d.Date.Date == order.AccountCreationDate.Date);
var updatedValue = chartData[order.ResidenceCityName][index];
chartData[order.ResidenceCityName][index] = (updatedValue.Date, updatedValue.Count + 1);
}
}
var config = new ComponentDocumentWithChartConfig
{
ChartTitle = "Отчет по аккаунтам",
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
Data = chartData.ToDictionary(
entry => entry.Key,
entry => entry.Value.Select(d => (DateTimeToInt(d.Date), (double)d.Count)).ToList()),
FilePath = saveDocument.FileName,
Header = "Заголовок аккаунта"
};
var documentComponent = new ComponentDocumentWithChartLineWord();
try{
documentComponent.CreateDoc(config);
MessageBox.Show("Документ создан успешно!");
return true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return false;
}
private int DateTimeToInt(DateTime date)
{
return date.Day;
}
private Guid IntToGuid(int value)
{
byte[] bytes = new byte[16];
BitConverter.GetBytes(value).CopyTo(bytes, 0);
return new Guid(bytes);
}
}
}

View File

@@ -0,0 +1,15 @@
using PluginsConventionLibrary;
namespace WinForms
{
public class PluginsConventionAccount : PluginsConventionElement
{
public string Login { get; set; } = string.Empty;
public string? AuthorizationAttemptsHistory { get; set; }
public string ResidenceCityName { get; set; } = string.Empty;
public string AccountCreationDate { get; set; } = string.Empty;
}
}

View File

@@ -1,17 +1,8 @@
using Contracts.BusinessLogicContracts;
using Contracts.StorageContracts;
using DatabaseImplement.Implements;
using BusinessLogic.BusinessLogics;
using System.Windows.Forms;
using Microsoft.Extensions.DependencyInjection;

namespace WinForms
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
@@ -21,21 +12,7 @@ namespace WinForms
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddTransient<ICityStorage, CityStorage>();
services.AddTransient<IAccountStorage, AccountStorage>();
services.AddTransient<ICityLogic, CityLogic>();
services.AddTransient<IAccountLogic, AccountLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormAccount>();
services.AddTransient<FormCities>();
Application.Run(new FormMain());
}
}
}

View File

@@ -23,6 +23,7 @@
<ProjectReference Include="..\BusinessLogic\BusinessLogic.csproj" />
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
<ProjectReference Include="..\PluginsConventionLibrarys\PluginsConventionLibrary.csproj" />
</ItemGroup>
</Project>

6
Lab3/test/Class1.cs Normal file
View File

@@ -0,0 +1,6 @@
namespace test
{
public class Class1
{
}
}

37
Lab3/test/UserControl1.Designer.cs generated Normal file
View File

@@ -0,0 +1,37 @@
namespace test
{
partial class UserControl1
{
/// <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();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

20
Lab3/test/UserControl1.cs Normal file
View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace test
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
}
}

10
Lab3/test/test.csproj Normal file
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>