From 79a181b7896d5e6555fcf5928044d4d89066f5bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F?= <Илья@WIN-RANNDDD> Date: Tue, 22 Oct 2024 19:42:03 +0400 Subject: [PATCH] lab3 ready --- COP/COP.sln | 34 ++- .../BusinessLogics/AccountLogic.cs | 78 +++++++ .../BusinessLogics/RoleLogic.cs | 74 ++++++ .../PortalAccountsBusinessLogic.csproj | 13 ++ .../BindingModels/AccountBindingModel.cs | 17 ++ .../BindingModels/RoleBindingModel.cs | 11 + .../BusinessLogicsContracts/IAccountLogic.cs | 19 ++ .../BusinessLogicsContracts/IRoleLogic.cs | 19 ++ .../PortalAccountsContracts.csproj | 13 ++ .../SearchModels/AccountSearchModel.cs | 11 + .../SearchModels/RoleSearchModel.cs | 9 + .../StoragesContracts/IAccountStorage.cs | 21 ++ .../StoragesContracts/IRoleStorage.cs | 21 ++ .../ViewModels/AccountViewModel.cs | 26 +++ .../ViewModels/RoleViewModel.cs | 13 ++ COP/PortalAccountsDataModels/IId.cs | 7 + .../Models/IAccountModel.cs | 13 ++ .../Models/IRoleModel.cs | 7 + .../PortalAccountsDataModels.csproj | 9 + .../Implements/AccountStorage.cs | 98 ++++++++ .../Implements/RoleStorage.cs | 84 +++++++ .../Models/Account.cs | 62 +++++ .../Models/Role.cs | 48 ++++ .../PortalAccountsDatabase.cs | 23 ++ .../PortalAccountsDatabaseImplement.csproj | 23 ++ .../FormAccount.Designer.cs | 178 +++++++++++++++ COP/PortalAccountsView/FormAccount.cs | 139 +++++++++++ COP/PortalAccountsView/FormAccount.resx | 120 ++++++++++ COP/PortalAccountsView/FormMain.Designer.cs | 179 +++++++++++++++ COP/PortalAccountsView/FormMain.cs | 215 ++++++++++++++++++ COP/PortalAccountsView/FormMain.resx | 132 +++++++++++ COP/PortalAccountsView/FormRoles.Designer.cs | 87 +++++++ COP/PortalAccountsView/FormRoles.cs | 99 ++++++++ COP/PortalAccountsView/FormRoles.resx | 126 ++++++++++ .../PortalAccountsView.csproj | 29 +++ COP/PortalAccountsView/Program.cs | 41 ++++ COP/RodionovLibrary/RodionovLibrary.csproj | 1 + .../ComboBoxControl.Designer.cs | 7 +- .../ListBoxControl.Designer.cs | 7 +- .../TextBoxControl.Designer.cs | 3 +- 40 files changed, 2104 insertions(+), 12 deletions(-) create mode 100644 COP/PortalAccountsBusinessLogic/BusinessLogics/AccountLogic.cs create mode 100644 COP/PortalAccountsBusinessLogic/BusinessLogics/RoleLogic.cs create mode 100644 COP/PortalAccountsBusinessLogic/PortalAccountsBusinessLogic.csproj create mode 100644 COP/PortalAccountsContracts/BindingModels/AccountBindingModel.cs create mode 100644 COP/PortalAccountsContracts/BindingModels/RoleBindingModel.cs create mode 100644 COP/PortalAccountsContracts/BusinessLogicsContracts/IAccountLogic.cs create mode 100644 COP/PortalAccountsContracts/BusinessLogicsContracts/IRoleLogic.cs create mode 100644 COP/PortalAccountsContracts/PortalAccountsContracts.csproj create mode 100644 COP/PortalAccountsContracts/SearchModels/AccountSearchModel.cs create mode 100644 COP/PortalAccountsContracts/SearchModels/RoleSearchModel.cs create mode 100644 COP/PortalAccountsContracts/StoragesContracts/IAccountStorage.cs create mode 100644 COP/PortalAccountsContracts/StoragesContracts/IRoleStorage.cs create mode 100644 COP/PortalAccountsContracts/ViewModels/AccountViewModel.cs create mode 100644 COP/PortalAccountsContracts/ViewModels/RoleViewModel.cs create mode 100644 COP/PortalAccountsDataModels/IId.cs create mode 100644 COP/PortalAccountsDataModels/Models/IAccountModel.cs create mode 100644 COP/PortalAccountsDataModels/Models/IRoleModel.cs create mode 100644 COP/PortalAccountsDataModels/PortalAccountsDataModels.csproj create mode 100644 COP/PortalAccountsDatabaseImplement/Implements/AccountStorage.cs create mode 100644 COP/PortalAccountsDatabaseImplement/Implements/RoleStorage.cs create mode 100644 COP/PortalAccountsDatabaseImplement/Models/Account.cs create mode 100644 COP/PortalAccountsDatabaseImplement/Models/Role.cs create mode 100644 COP/PortalAccountsDatabaseImplement/PortalAccountsDatabase.cs create mode 100644 COP/PortalAccountsDatabaseImplement/PortalAccountsDatabaseImplement.csproj create mode 100644 COP/PortalAccountsView/FormAccount.Designer.cs create mode 100644 COP/PortalAccountsView/FormAccount.cs create mode 100644 COP/PortalAccountsView/FormAccount.resx create mode 100644 COP/PortalAccountsView/FormMain.Designer.cs create mode 100644 COP/PortalAccountsView/FormMain.cs create mode 100644 COP/PortalAccountsView/FormMain.resx create mode 100644 COP/PortalAccountsView/FormRoles.Designer.cs create mode 100644 COP/PortalAccountsView/FormRoles.cs create mode 100644 COP/PortalAccountsView/FormRoles.resx create mode 100644 COP/PortalAccountsView/PortalAccountsView.csproj create mode 100644 COP/PortalAccountsView/Program.cs diff --git a/COP/COP.sln b/COP/COP.sln index cae8f2e..f3baea6 100644 --- a/COP/COP.sln +++ b/COP/COP.sln @@ -3,9 +3,19 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.11.35222.181 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RodionovLibrary", "RodionovLibrary\RodionovLibrary.csproj", "{F586414D-01E1-499C-A77B-C6A4B0882B0E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RodionovLibrary", "RodionovLibrary\RodionovLibrary.csproj", "{F586414D-01E1-499C-A77B-C6A4B0882B0E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinForms", "WinForms\WinForms.csproj", "{E160EBCF-4BD1-4049-ADD6-597332133952}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinForms", "WinForms\WinForms.csproj", "{E160EBCF-4BD1-4049-ADD6-597332133952}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortalAccountsContracts", "PortalAccountsContracts\PortalAccountsContracts.csproj", "{F18747FB-607B-42E4-AA8E-86A7E2FFBD28}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortalAccountsDataModels", "PortalAccountsDataModels\PortalAccountsDataModels.csproj", "{4DFB6049-FCE4-42F3-B611-BAEE5156EA9C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortalAccountsBusinessLogic", "PortalAccountsBusinessLogic\PortalAccountsBusinessLogic.csproj", "{06D98752-0805-4CE4-AE5A-0EC14694D7D9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortalAccountsDatabaseImplement", "PortalAccountsDatabaseImplement\PortalAccountsDatabaseImplement.csproj", "{0D3E5B70-5816-4AF6-AA94-95EA34EEC9FE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortalAccountsView", "PortalAccountsView\PortalAccountsView.csproj", "{0304D12E-0F97-4C82-BB88-4E4784DEC81C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -21,6 +31,26 @@ Global {E160EBCF-4BD1-4049-ADD6-597332133952}.Debug|Any CPU.Build.0 = Debug|Any CPU {E160EBCF-4BD1-4049-ADD6-597332133952}.Release|Any CPU.ActiveCfg = Release|Any CPU {E160EBCF-4BD1-4049-ADD6-597332133952}.Release|Any CPU.Build.0 = Release|Any CPU + {F18747FB-607B-42E4-AA8E-86A7E2FFBD28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F18747FB-607B-42E4-AA8E-86A7E2FFBD28}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F18747FB-607B-42E4-AA8E-86A7E2FFBD28}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F18747FB-607B-42E4-AA8E-86A7E2FFBD28}.Release|Any CPU.Build.0 = Release|Any CPU + {4DFB6049-FCE4-42F3-B611-BAEE5156EA9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4DFB6049-FCE4-42F3-B611-BAEE5156EA9C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4DFB6049-FCE4-42F3-B611-BAEE5156EA9C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4DFB6049-FCE4-42F3-B611-BAEE5156EA9C}.Release|Any CPU.Build.0 = Release|Any CPU + {06D98752-0805-4CE4-AE5A-0EC14694D7D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {06D98752-0805-4CE4-AE5A-0EC14694D7D9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {06D98752-0805-4CE4-AE5A-0EC14694D7D9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {06D98752-0805-4CE4-AE5A-0EC14694D7D9}.Release|Any CPU.Build.0 = Release|Any CPU + {0D3E5B70-5816-4AF6-AA94-95EA34EEC9FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0D3E5B70-5816-4AF6-AA94-95EA34EEC9FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0D3E5B70-5816-4AF6-AA94-95EA34EEC9FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0D3E5B70-5816-4AF6-AA94-95EA34EEC9FE}.Release|Any CPU.Build.0 = Release|Any CPU + {0304D12E-0F97-4C82-BB88-4E4784DEC81C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0304D12E-0F97-4C82-BB88-4E4784DEC81C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0304D12E-0F97-4C82-BB88-4E4784DEC81C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0304D12E-0F97-4C82-BB88-4E4784DEC81C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/COP/PortalAccountsBusinessLogic/BusinessLogics/AccountLogic.cs b/COP/PortalAccountsBusinessLogic/BusinessLogics/AccountLogic.cs new file mode 100644 index 0000000..efae1a6 --- /dev/null +++ b/COP/PortalAccountsBusinessLogic/BusinessLogics/AccountLogic.cs @@ -0,0 +1,78 @@ +using PortalAccountsContracts.BindingModels; +using PortalAccountsContracts.BusinessLogicsContracts; +using PortalAccountsContracts.SearchModels; +using PortalAccountsContracts.StoragesContracts; +using PortalAccountsContracts.ViewModels; + +namespace PortalAccountsBusinessLogic.BusinessLogics +{ + public class AccountLogic : IAccountLogic + { + private readonly IAccountStorage _accountStorage; + + public AccountLogic(IAccountStorage AccountStorage) + { + _accountStorage = AccountStorage; + } + + public List? ReadList(AccountSearchModel? model) + { + return model == null ? _accountStorage.GetFullList() : _accountStorage.GetFilteredList(model); + } + + public AccountViewModel? ReadElement(AccountSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + return _accountStorage.GetElement(model); + } + + public bool Create(AccountBindingModel model) + { + CheckModel(model); + return _accountStorage.Insert(model) != null; + } + + public bool Update(AccountBindingModel model) + { + CheckModel(model); + return _accountStorage.Update(model) != null; + } + + public bool Delete(AccountBindingModel model) + { + CheckModel(model, false); + return _accountStorage.Delete(model) != null; + } + + private void CheckModel(AccountBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.Login)) + { + throw new ArgumentNullException("Нет логина у аккаунта", nameof(model.Login)); + } + if (model.RoleId <= 0) + { + throw new ArgumentNullException("Некорректный идентификатор роли", nameof(model.RoleId)); + } + var element = _accountStorage.GetElement(new AccountSearchModel + { + Login = model.Login + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Аккаунт с таким логином уже есть"); + } + } + } +} \ No newline at end of file diff --git a/COP/PortalAccountsBusinessLogic/BusinessLogics/RoleLogic.cs b/COP/PortalAccountsBusinessLogic/BusinessLogics/RoleLogic.cs new file mode 100644 index 0000000..c9be732 --- /dev/null +++ b/COP/PortalAccountsBusinessLogic/BusinessLogics/RoleLogic.cs @@ -0,0 +1,74 @@ +using PortalAccountsContracts.BindingModels; +using PortalAccountsContracts.BusinessLogicsContracts; +using PortalAccountsContracts.SearchModels; +using PortalAccountsContracts.StoragesContracts; +using PortalAccountsContracts.ViewModels; + +namespace PortalAccountsBusinessLogic.BusinessLogics +{ + public class RoleLogic : IRoleLogic + { + private readonly IRoleStorage _roleStorage; + + public RoleLogic(IRoleStorage RoleStorage) + { + _roleStorage = RoleStorage; + } + + public List? ReadList(RoleSearchModel? model) + { + return model == null ? _roleStorage.GetFullList() : _roleStorage.GetFilteredList(model); + } + + public RoleViewModel? ReadElement(RoleSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + return _roleStorage.GetElement(model); + } + + public bool Create(RoleBindingModel model) + { + CheckModel(model); + return _roleStorage.Insert(model) != null; + } + + public bool Update(RoleBindingModel model) + { + CheckModel(model); + return _roleStorage.Update(model) != null; + } + + public bool Delete(RoleBindingModel model) + { + CheckModel(model, false); + return _roleStorage.Delete(model) != null; + } + + private void CheckModel(RoleBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.Name)) + { + throw new ArgumentNullException("Нет названия роли", nameof(model.Name)); + } + var element = _roleStorage.GetElement(new RoleSearchModel + { + Name = model.Name + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Роль с таким названием уже есть"); + } + } + } +} \ No newline at end of file diff --git a/COP/PortalAccountsBusinessLogic/PortalAccountsBusinessLogic.csproj b/COP/PortalAccountsBusinessLogic/PortalAccountsBusinessLogic.csproj new file mode 100644 index 0000000..5691a38 --- /dev/null +++ b/COP/PortalAccountsBusinessLogic/PortalAccountsBusinessLogic.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/COP/PortalAccountsContracts/BindingModels/AccountBindingModel.cs b/COP/PortalAccountsContracts/BindingModels/AccountBindingModel.cs new file mode 100644 index 0000000..25770d7 --- /dev/null +++ b/COP/PortalAccountsContracts/BindingModels/AccountBindingModel.cs @@ -0,0 +1,17 @@ +using PortalAccountsDataModels.Models; + +namespace PortalAccountsContracts.BindingModels +{ + public class AccountBindingModel : IAccountModel + { + public int Id { get; set; } + + public string Login { get; set; } = string.Empty; + + public string? Warnings { get; set; } + + public int RoleId { get; set; } + + public double? Rating { get; set; } + } +} diff --git a/COP/PortalAccountsContracts/BindingModels/RoleBindingModel.cs b/COP/PortalAccountsContracts/BindingModels/RoleBindingModel.cs new file mode 100644 index 0000000..1fa25af --- /dev/null +++ b/COP/PortalAccountsContracts/BindingModels/RoleBindingModel.cs @@ -0,0 +1,11 @@ +using PortalAccountsDataModels.Models; + +namespace PortalAccountsContracts.BindingModels +{ + public class RoleBindingModel : IRoleModel + { + public int Id { get; set; } + + public string Name { get; set; } = string.Empty; + } +} diff --git a/COP/PortalAccountsContracts/BusinessLogicsContracts/IAccountLogic.cs b/COP/PortalAccountsContracts/BusinessLogicsContracts/IAccountLogic.cs new file mode 100644 index 0000000..1d3418a --- /dev/null +++ b/COP/PortalAccountsContracts/BusinessLogicsContracts/IAccountLogic.cs @@ -0,0 +1,19 @@ +using PortalAccountsContracts.BindingModels; +using PortalAccountsContracts.SearchModels; +using PortalAccountsContracts.ViewModels; + +namespace PortalAccountsContracts.BusinessLogicsContracts +{ + public interface IAccountLogic + { + List? ReadList(AccountSearchModel? model); + + AccountViewModel? ReadElement(AccountSearchModel model); + + bool Create(AccountBindingModel model); + + bool Update(AccountBindingModel model); + + bool Delete(AccountBindingModel model); + } +} \ No newline at end of file diff --git a/COP/PortalAccountsContracts/BusinessLogicsContracts/IRoleLogic.cs b/COP/PortalAccountsContracts/BusinessLogicsContracts/IRoleLogic.cs new file mode 100644 index 0000000..09f8909 --- /dev/null +++ b/COP/PortalAccountsContracts/BusinessLogicsContracts/IRoleLogic.cs @@ -0,0 +1,19 @@ +using PortalAccountsContracts.BindingModels; +using PortalAccountsContracts.SearchModels; +using PortalAccountsContracts.ViewModels; + +namespace PortalAccountsContracts.BusinessLogicsContracts +{ + public interface IRoleLogic + { + List? ReadList(RoleSearchModel? model); + + RoleViewModel? ReadElement(RoleSearchModel model); + + bool Create(RoleBindingModel model); + + bool Update(RoleBindingModel model); + + bool Delete(RoleBindingModel model); + } +} \ No newline at end of file diff --git a/COP/PortalAccountsContracts/PortalAccountsContracts.csproj b/COP/PortalAccountsContracts/PortalAccountsContracts.csproj new file mode 100644 index 0000000..a92b076 --- /dev/null +++ b/COP/PortalAccountsContracts/PortalAccountsContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/COP/PortalAccountsContracts/SearchModels/AccountSearchModel.cs b/COP/PortalAccountsContracts/SearchModels/AccountSearchModel.cs new file mode 100644 index 0000000..9f012ee --- /dev/null +++ b/COP/PortalAccountsContracts/SearchModels/AccountSearchModel.cs @@ -0,0 +1,11 @@ +namespace PortalAccountsContracts.SearchModels +{ + public class AccountSearchModel + { + public int? Id { get; set; } + + public string? Login { get; set; } + + public int? RoleId { get; set; } + } +} diff --git a/COP/PortalAccountsContracts/SearchModels/RoleSearchModel.cs b/COP/PortalAccountsContracts/SearchModels/RoleSearchModel.cs new file mode 100644 index 0000000..bf60f49 --- /dev/null +++ b/COP/PortalAccountsContracts/SearchModels/RoleSearchModel.cs @@ -0,0 +1,9 @@ +namespace PortalAccountsContracts.SearchModels +{ + public class RoleSearchModel + { + public int? Id { get; set; } + + public string? Name { get; set; } + } +} diff --git a/COP/PortalAccountsContracts/StoragesContracts/IAccountStorage.cs b/COP/PortalAccountsContracts/StoragesContracts/IAccountStorage.cs new file mode 100644 index 0000000..dfd9845 --- /dev/null +++ b/COP/PortalAccountsContracts/StoragesContracts/IAccountStorage.cs @@ -0,0 +1,21 @@ +using PortalAccountsContracts.BindingModels; +using PortalAccountsContracts.SearchModels; +using PortalAccountsContracts.ViewModels; + +namespace PortalAccountsContracts.StoragesContracts +{ + public interface IAccountStorage + { + List GetFullList(); + + List GetFilteredList(AccountSearchModel model); + + AccountViewModel? GetElement(AccountSearchModel model); + + AccountViewModel? Insert(AccountBindingModel model); + + AccountViewModel? Update(AccountBindingModel model); + + AccountViewModel? Delete(AccountBindingModel model); + } +} \ No newline at end of file diff --git a/COP/PortalAccountsContracts/StoragesContracts/IRoleStorage.cs b/COP/PortalAccountsContracts/StoragesContracts/IRoleStorage.cs new file mode 100644 index 0000000..10a678a --- /dev/null +++ b/COP/PortalAccountsContracts/StoragesContracts/IRoleStorage.cs @@ -0,0 +1,21 @@ +using PortalAccountsContracts.BindingModels; +using PortalAccountsContracts.SearchModels; +using PortalAccountsContracts.ViewModels; + +namespace PortalAccountsContracts.StoragesContracts +{ + public interface IRoleStorage + { + List GetFullList(); + + List GetFilteredList(RoleSearchModel model); + + RoleViewModel? GetElement(RoleSearchModel model); + + RoleViewModel? Insert(RoleBindingModel model); + + RoleViewModel? Update(RoleBindingModel model); + + RoleViewModel? Delete(RoleBindingModel model); + } +} \ No newline at end of file diff --git a/COP/PortalAccountsContracts/ViewModels/AccountViewModel.cs b/COP/PortalAccountsContracts/ViewModels/AccountViewModel.cs new file mode 100644 index 0000000..f0524b0 --- /dev/null +++ b/COP/PortalAccountsContracts/ViewModels/AccountViewModel.cs @@ -0,0 +1,26 @@ +using PortalAccountsDataModels.Models; +using System.ComponentModel; + +namespace PortalAccountsContracts.ViewModels +{ + public class AccountViewModel : IAccountModel + { + public int Id { get; set; } + + [DisplayName("Логин")] + public string Login { get; set; } = string.Empty; + + [DisplayName("Предупреждения")] + public string? Warnings { get; set; } + + public int RoleId { get; set; } + + [DisplayName("Роль")] + public string RoleName { get; set; } = string.Empty; + + [DisplayName("Рейтинг")] + public double? Rating { get; set; } + + public string OutputRating { get; set; } = string.Empty; + } +} diff --git a/COP/PortalAccountsContracts/ViewModels/RoleViewModel.cs b/COP/PortalAccountsContracts/ViewModels/RoleViewModel.cs new file mode 100644 index 0000000..8141535 --- /dev/null +++ b/COP/PortalAccountsContracts/ViewModels/RoleViewModel.cs @@ -0,0 +1,13 @@ +using PortalAccountsDataModels.Models; +using System.ComponentModel; + +namespace PortalAccountsContracts.ViewModels +{ + public class RoleViewModel : IRoleModel + { + public int Id { get; set; } + + [DisplayName("Название роли")] + public string Name { get; set; } = string.Empty; + } +} diff --git a/COP/PortalAccountsDataModels/IId.cs b/COP/PortalAccountsDataModels/IId.cs new file mode 100644 index 0000000..d745687 --- /dev/null +++ b/COP/PortalAccountsDataModels/IId.cs @@ -0,0 +1,7 @@ +namespace PortalAccountsDataModels +{ + public interface IId + { + int Id { get; } + } +} \ No newline at end of file diff --git a/COP/PortalAccountsDataModels/Models/IAccountModel.cs b/COP/PortalAccountsDataModels/Models/IAccountModel.cs new file mode 100644 index 0000000..653b3a4 --- /dev/null +++ b/COP/PortalAccountsDataModels/Models/IAccountModel.cs @@ -0,0 +1,13 @@ +namespace PortalAccountsDataModels.Models +{ + public interface IAccountModel : IId + { + string Login { get; } + + string? Warnings { get; } + + int RoleId { get; } + + double? Rating { get; } + } +} diff --git a/COP/PortalAccountsDataModels/Models/IRoleModel.cs b/COP/PortalAccountsDataModels/Models/IRoleModel.cs new file mode 100644 index 0000000..0445d6f --- /dev/null +++ b/COP/PortalAccountsDataModels/Models/IRoleModel.cs @@ -0,0 +1,7 @@ +namespace PortalAccountsDataModels.Models +{ + public interface IRoleModel : IId + { + string Name { get; } + } +} diff --git a/COP/PortalAccountsDataModels/PortalAccountsDataModels.csproj b/COP/PortalAccountsDataModels/PortalAccountsDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/COP/PortalAccountsDataModels/PortalAccountsDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/COP/PortalAccountsDatabaseImplement/Implements/AccountStorage.cs b/COP/PortalAccountsDatabaseImplement/Implements/AccountStorage.cs new file mode 100644 index 0000000..7bd1e41 --- /dev/null +++ b/COP/PortalAccountsDatabaseImplement/Implements/AccountStorage.cs @@ -0,0 +1,98 @@ +using PortalAccountsContracts.BindingModels; +using PortalAccountsContracts.SearchModels; +using PortalAccountsContracts.StoragesContracts; +using PortalAccountsContracts.ViewModels; +using PortalAccountsDatabaseImplement.Models; +using Microsoft.EntityFrameworkCore; + +namespace PortalAccountsDatabaseImplement.Implements +{ + public class AccountStorage : IAccountStorage + { + public List GetFullList() + { + using var context = new PortalAccountsDatabase(); + return context.Accounts + .Include(x => x.Role) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFilteredList(AccountSearchModel model) + { + using var context = new PortalAccountsDatabase(); + if (model.RoleId.HasValue) + { + return context.Accounts + .Include(x => x.Role) + .Where(x => x.RoleId == model.RoleId) + .Select(x => x.GetViewModel) + .ToList(); + } + return new(); + } + + public AccountViewModel? GetElement(AccountSearchModel model) + { + if (string.IsNullOrEmpty(model.Login) && !model.Id.HasValue) + { + return null; + } + using var context = new PortalAccountsDatabase(); + return context.Accounts + .Include(x => x.Role) + .FirstOrDefault(x => !string.IsNullOrEmpty(model.Login) && x.Login == model.Login || + model.Id.HasValue && x.Id == model.Id) + ?.GetViewModel; + } + + public AccountViewModel? Insert(AccountBindingModel model) + { + var newAccount = Account.Create(model); + if (newAccount == null) + { + return null; + } + using var context = new PortalAccountsDatabase(); + context.Accounts.Add(newAccount); + context.SaveChanges(); + return context.Accounts + .Include(x => x.Role) + .FirstOrDefault(x => x.Id == newAccount.Id) + ?.GetViewModel; + } + + public AccountViewModel? Update(AccountBindingModel model) + { + using var context = new PortalAccountsDatabase(); + var account = context.Accounts.FirstOrDefault(x => x.Id == model.Id); + if (account == null) + { + return null; + } + account.Update(model); + context.SaveChanges(); + return context.Accounts + .Include(x => x.Role) + .FirstOrDefault(x => x.Id == model.Id) + ?.GetViewModel; + } + + public AccountViewModel? Delete(AccountBindingModel model) + { + using var context = new PortalAccountsDatabase(); + var element = context.Accounts.FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + var deletedElement = context.Accounts + .Include(x => x.Role) + .FirstOrDefault(x => x.Id == model.Id) + ?.GetViewModel; + context.Accounts.Remove(element); + context.SaveChanges(); + return deletedElement; + } + return null; + } + } +} \ No newline at end of file diff --git a/COP/PortalAccountsDatabaseImplement/Implements/RoleStorage.cs b/COP/PortalAccountsDatabaseImplement/Implements/RoleStorage.cs new file mode 100644 index 0000000..5b88fbb --- /dev/null +++ b/COP/PortalAccountsDatabaseImplement/Implements/RoleStorage.cs @@ -0,0 +1,84 @@ +using PortalAccountsContracts.BindingModels; +using PortalAccountsContracts.SearchModels; +using PortalAccountsContracts.StoragesContracts; +using PortalAccountsContracts.ViewModels; +using PortalAccountsDatabaseImplement.Models; + +namespace PortalAccountsDatabaseImplement.Implements +{ + public class RoleStorage : IRoleStorage + { + public List GetFullList() + { + using var context = new PortalAccountsDatabase(); + return context.Roles + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFilteredList(RoleSearchModel model) + { + if (string.IsNullOrEmpty(model.Name)) + { + return new(); + } + using var context = new PortalAccountsDatabase(); + return context.Roles + .Where(x => x.Name.Contains(model.Name)) + .Select(x => x.GetViewModel) + .ToList(); + } + + public RoleViewModel? GetElement(RoleSearchModel model) + { + if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue) + { + return null; + } + using var context = new PortalAccountsDatabase(); + return context.Roles + .FirstOrDefault(x => !string.IsNullOrEmpty(model.Name) && x.Name == model.Name || + model.Id.HasValue && x.Id == model.Id) + ?.GetViewModel; + } + + public RoleViewModel? Insert(RoleBindingModel model) + { + var newRole = Role.Create(model); + if (newRole == null) + { + return null; + } + using var context = new PortalAccountsDatabase(); + context.Roles.Add(newRole); + context.SaveChanges(); + return newRole.GetViewModel; + } + + public RoleViewModel? Update(RoleBindingModel model) + { + using var context = new PortalAccountsDatabase(); + var role = context.Roles.FirstOrDefault(x => x.Id == model.Id); + if (role == null) + { + return null; + } + role.Update(model); + context.SaveChanges(); + return role.GetViewModel; + } + + public RoleViewModel? Delete(RoleBindingModel model) + { + using var context = new PortalAccountsDatabase(); + var element = context.Roles.FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.Roles.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + } +} diff --git a/COP/PortalAccountsDatabaseImplement/Models/Account.cs b/COP/PortalAccountsDatabaseImplement/Models/Account.cs new file mode 100644 index 0000000..3a59bce --- /dev/null +++ b/COP/PortalAccountsDatabaseImplement/Models/Account.cs @@ -0,0 +1,62 @@ +using PortalAccountsContracts.BindingModels; +using PortalAccountsContracts.ViewModels; +using PortalAccountsDataModels.Models; +using System.ComponentModel.DataAnnotations; + +namespace PortalAccountsDatabaseImplement.Models +{ + public class Account : IAccountModel + { + public int Id { get; private set; } + + [Required] + public string Login { get; set; } = string.Empty; + + public string? Warnings { get; set; } + + [Required] + public int RoleId { get; set; } + + public double? Rating { get; set; } + + public virtual Role Role { get; set; } + + public static Account? Create(AccountBindingModel? model) + { + if (model == null) + { + return null; + } + return new Account() + { + Id = model.Id, + Login = model.Login, + Warnings = model.Warnings, + RoleId = model.RoleId, + Rating = model.Rating + }; + } + + public void Update(AccountBindingModel? model) + { + if (model == null) + { + return; + } + Login = model.Login; + Warnings = model.Warnings; + RoleId = model.RoleId; + Rating = model.Rating; + } + + public AccountViewModel GetViewModel => new() + { + Id = Id, + Login = Login, + Warnings = Warnings, + RoleId = RoleId, + RoleName = Role.Name ?? string.Empty, + Rating = Rating + }; + } +} diff --git a/COP/PortalAccountsDatabaseImplement/Models/Role.cs b/COP/PortalAccountsDatabaseImplement/Models/Role.cs new file mode 100644 index 0000000..c64a144 --- /dev/null +++ b/COP/PortalAccountsDatabaseImplement/Models/Role.cs @@ -0,0 +1,48 @@ +using PortalAccountsContracts.BindingModels; +using PortalAccountsContracts.ViewModels; +using PortalAccountsDataModels.Models; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace PortalAccountsDatabaseImplement.Models +{ + public class Role : IRoleModel + { + public int Id { get; private set; } + + [Required] + public string Name { get; private set; } = string.Empty; + + [ForeignKey("RoleId")] + public virtual List Accounts { get; set; } = new(); + + public static Role? Create(RoleBindingModel model) + { + if (model == null) + { + return null; + } + return new Role() + { + Id = model.Id, + Name = model.Name + }; + } + + public void Update(RoleBindingModel model) + { + if (model == null) + { + return; + } + Name = model.Name; + } + + public RoleViewModel GetViewModel => new() + { + Id = Id, + Name = Name + }; + } +} + diff --git a/COP/PortalAccountsDatabaseImplement/PortalAccountsDatabase.cs b/COP/PortalAccountsDatabaseImplement/PortalAccountsDatabase.cs new file mode 100644 index 0000000..792240d --- /dev/null +++ b/COP/PortalAccountsDatabaseImplement/PortalAccountsDatabase.cs @@ -0,0 +1,23 @@ +using PortalAccountsDatabaseImplement.Models; +using Microsoft.EntityFrameworkCore; + +namespace PortalAccountsDatabaseImplement +{ + public class PortalAccountsDatabase : DbContext + { + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (optionsBuilder.IsConfigured == false) + { + optionsBuilder.UseNpgsql(@"Host=localhost;Database=portal_accounts_database;Username=postgres;Password=bythop423956"); + } + base.OnConfiguring(optionsBuilder); + AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); + AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true); + } + + public virtual DbSet Accounts { set; get; } + + public virtual DbSet Roles { set; get; } + } +} \ No newline at end of file diff --git a/COP/PortalAccountsDatabaseImplement/PortalAccountsDatabaseImplement.csproj b/COP/PortalAccountsDatabaseImplement/PortalAccountsDatabaseImplement.csproj new file mode 100644 index 0000000..16b48f4 --- /dev/null +++ b/COP/PortalAccountsDatabaseImplement/PortalAccountsDatabaseImplement.csproj @@ -0,0 +1,23 @@ + + + + net6.0 + enable + enable + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + diff --git a/COP/PortalAccountsView/FormAccount.Designer.cs b/COP/PortalAccountsView/FormAccount.Designer.cs new file mode 100644 index 0000000..9d7854d --- /dev/null +++ b/COP/PortalAccountsView/FormAccount.Designer.cs @@ -0,0 +1,178 @@ +namespace PortalAccountsView +{ + partial class FormAccount + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + controlInputRating = new ControlsLibraryNet60.Input.ControlInputNullableDouble(); + textBoxLogin = new TextBox(); + textBoxWarnings = new TextBox(); + buttonSave = new Button(); + labelLogin = new Label(); + labelWarnings = new Label(); + labelRating = new Label(); + labelRole = new Label(); + comboBoxControlRole = new RodionovLibrary.VisualComponents.ComboBoxControl(); + buttonCancel = new Button(); + SuspendLayout(); + // + // controlInputRating + // + controlInputRating.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + controlInputRating.Location = new Point(8, 197); + controlInputRating.Margin = new Padding(4, 6, 4, 6); + controlInputRating.Name = "controlInputRating"; + controlInputRating.Size = new Size(329, 27); + controlInputRating.TabIndex = 0; + controlInputRating.Value = null; + // + // textBoxLogin + // + textBoxLogin.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxLogin.Location = new Point(15, 86); + textBoxLogin.Margin = new Padding(3, 2, 3, 2); + textBoxLogin.Name = "textBoxLogin"; + textBoxLogin.Size = new Size(323, 23); + textBoxLogin.TabIndex = 2; + textBoxLogin.TextChanged += TextBoxLogin_TextChanged; + // + // textBoxWarnings + // + textBoxWarnings.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxWarnings.Location = new Point(15, 143); + textBoxWarnings.Margin = new Padding(3, 2, 3, 2); + textBoxWarnings.Name = "textBoxWarnings"; + textBoxWarnings.Size = new Size(323, 23); + textBoxWarnings.TabIndex = 3; + textBoxWarnings.TextChanged += TextBoxWarnings_TextChanged; + // + // buttonSave + // + buttonSave.Location = new Point(25, 232); + buttonSave.Margin = new Padding(3, 2, 3, 2); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(92, 27); + buttonSave.TabIndex = 8; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // labelLogin + // + labelLogin.AutoSize = true; + labelLogin.Location = new Point(15, 64); + labelLogin.Name = "labelLogin"; + labelLogin.Size = new Size(41, 15); + labelLogin.TabIndex = 4; + labelLogin.Text = "Логин"; + // + // labelWarnings + // + labelWarnings.AutoSize = true; + labelWarnings.Location = new Point(15, 120); + labelWarnings.Name = "labelWarnings"; + labelWarnings.Size = new Size(102, 15); + labelWarnings.TabIndex = 5; + labelWarnings.Text = "Предупреждения"; + // + // labelRating + // + labelRating.AutoSize = true; + labelRating.Location = new Point(19, 174); + labelRating.Name = "labelRating"; + labelRating.Size = new Size(51, 15); + labelRating.TabIndex = 6; + labelRating.Text = "Рейтинг"; + // + // labelRole + // + labelRole.AutoSize = true; + labelRole.Location = new Point(18, 12); + labelRole.Name = "labelRole"; + labelRole.Size = new Size(34, 15); + labelRole.TabIndex = 7; + labelRole.Text = "Роль"; + // + // comboBoxControlRole + // + comboBoxControlRole.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxControlRole.Location = new Point(15, 33); + comboBoxControlRole.Margin = new Padding(3, 2, 3, 2); + comboBoxControlRole.Name = "comboBoxControlRole"; + comboBoxControlRole.SelectedValue = ""; + comboBoxControlRole.Size = new Size(327, 26); + comboBoxControlRole.TabIndex = 8; + // + // buttonCancel + // + buttonCancel.Location = new Point(147, 232); + buttonCancel.Margin = new Padding(3, 2, 3, 2); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(92, 27); + buttonCancel.TabIndex = 9; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormAccount + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(357, 272); + Controls.Add(buttonCancel); + Controls.Add(comboBoxControlRole); + Controls.Add(labelRole); + Controls.Add(labelRating); + Controls.Add(labelWarnings); + Controls.Add(labelLogin); + Controls.Add(buttonSave); + Controls.Add(textBoxWarnings); + Controls.Add(textBoxLogin); + Controls.Add(controlInputRating); + Margin = new Padding(3, 2, 3, 2); + Name = "FormAccount"; + Text = "Аккаунт"; + FormClosing += FormAccount_FormClosing; + Load += FormAccount_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ControlsLibraryNet60.Input.ControlInputNullableDouble controlInputRating; + private TextBox textBoxLogin; + private TextBox textBoxWarnings; + private Button buttonSave; + private Label labelLogin; + private Label labelWarnings; + private Label labelRating; + private Label labelRole; + private RodionovLibrary.VisualComponents.ComboBoxControl comboBoxControlRole; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/COP/PortalAccountsView/FormAccount.cs b/COP/PortalAccountsView/FormAccount.cs new file mode 100644 index 0000000..81985d1 --- /dev/null +++ b/COP/PortalAccountsView/FormAccount.cs @@ -0,0 +1,139 @@ +using PortalAccountsContracts.BindingModels; +using PortalAccountsContracts.BusinessLogicsContracts; +using PortalAccountsContracts.SearchModels; +using PortalAccountsContracts.ViewModels; +using System.Data; + +namespace PortalAccountsView +{ + public partial class FormAccount : Form + { + private int? _id; + + private bool _isModified = false; + + private readonly IAccountLogic _logic; + + private readonly IRoleLogic _roleLogic; + + private List _roles; + + public int Id { set { _id = value; } } + + public FormAccount(IAccountLogic logic, IRoleLogic roleLogic) + { + InitializeComponent(); + _logic = logic; + _roleLogic = roleLogic; + _roles = new List(); + comboBoxControlRole.ValueChanged += (_, _) => _isModified = true; + controlInputRating.ElementChanged += (_, _) => _isModified = true; + } + + private void FormAccount_Load(object sender, EventArgs e) + { + _roles = _roleLogic.ReadList(null) ?? throw new Exception("Не удалось получить список ролей"); + comboBoxControlRole.AddItems(_roles.Select(x => x.Name).ToList()); + if (_id.HasValue) + { + try + { + var account = _logic.ReadElement(new AccountSearchModel { Id = _id.Value }); + if (account != null) + { + textBoxLogin.Text = account.Login; + textBoxWarnings.Text = account.Warnings; + controlInputRating.Value = account.Rating; + comboBoxControlRole.SelectedValue = account.RoleName; + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + if (_isModified) + { + var result = MessageBox.Show( + "У вас есть несохранённые изменения. Вы действительно хотите закрыть форму?", + "Предупреждение", + MessageBoxButtons.YesNo, + MessageBoxIcon.Warning + ); + + if (result == DialogResult.No) + return; + } + + DialogResult = DialogResult.Cancel; + Close(); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxLogin.Text)) + { + MessageBox.Show("Заполните логин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(comboBoxControlRole.SelectedValue)) + { + MessageBox.Show("Выберите роль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try + { + var model = new AccountBindingModel + { + Id = _id ?? 0, + Login = textBoxLogin.Text, + Warnings = textBoxWarnings.Text, + Rating = controlInputRating.Value, + RoleId = _roles.First(x => x.Name == comboBoxControlRole.SelectedValue).Id, + }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении"); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void TextBoxLogin_TextChanged(object sender, EventArgs e) + { + _isModified = true; + } + + private void TextBoxWarnings_TextChanged(object sender, EventArgs e) + { + _isModified = true; + } + + private void FormAccount_FormClosing(object sender, FormClosingEventArgs e) + { + if (!_isModified) + return; + + var result = MessageBox.Show( + "У вас есть несохранённые изменения. Вы действительно хотите закрыть форму?", + "Предупреждение", + MessageBoxButtons.YesNo, + MessageBoxIcon.Warning + ); + + if (result == DialogResult.No) + e.Cancel = true; + } + } +} diff --git a/COP/PortalAccountsView/FormAccount.resx b/COP/PortalAccountsView/FormAccount.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/COP/PortalAccountsView/FormAccount.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/COP/PortalAccountsView/FormMain.Designer.cs b/COP/PortalAccountsView/FormMain.Designer.cs new file mode 100644 index 0000000..b4fb45c --- /dev/null +++ b/COP/PortalAccountsView/FormMain.Designer.cs @@ -0,0 +1,179 @@ +namespace PortalAccountsView +{ + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + controlDataTreeTable = new ControlsLibraryNet60.Data.ControlDataTreeTable(); + wordLongTextComponent = new RodionovLibrary.NonVisualComponents.WordLongTextComponent(components); + componentDocumentWithTableMultiHeaderPdf = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderPdf(components); + componentDocumentWithChartPieExcel = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieExcel(components); + 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(); + menuStrip.SuspendLayout(); + SuspendLayout(); + // + // controlDataTreeTable + // + this.controlDataTreeTable.Dock = System.Windows.Forms.DockStyle.Fill; + this.controlDataTreeTable.Location = new System.Drawing.Point(0, 28); + this.controlDataTreeTable.Name = "controlDataTreeTable"; + this.controlDataTreeTable.Size = new System.Drawing.Size(800, 422); + this.controlDataTreeTable.TabIndex = 1; + // + // menuStrip + // + this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20); + this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.аккаунтыToolStripMenuItem, + this.отчётыToolStripMenuItem, + this.ролиToolStripMenuItem}); + this.menuStrip.Location = new System.Drawing.Point(0, 0); + this.menuStrip.Name = "menuStrip"; + this.menuStrip.Size = new System.Drawing.Size(800, 28); + this.menuStrip.TabIndex = 0; + this.menuStrip.Text = "Контекстное меню"; + // + // аккаунтыToolStripMenuItem + // + this.аккаунтыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.создатьToolStripMenuItem, + this.редактироватьToolStripMenuItem, + this.удалитьToolStripMenuItem}); + this.аккаунтыToolStripMenuItem.Name = "аккаунтыToolStripMenuItem"; + this.аккаунтыToolStripMenuItem.Size = new System.Drawing.Size(88, 24); + this.аккаунтыToolStripMenuItem.Text = "Аккаунты"; + // + // создатьToolStripMenuItem + // + this.создатьToolStripMenuItem.Name = "создатьToolStripMenuItem"; + this.создатьToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A))); + this.создатьToolStripMenuItem.Size = new System.Drawing.Size(246, 26); + this.создатьToolStripMenuItem.Text = "Создать"; + this.создатьToolStripMenuItem.Click += new System.EventHandler(this.СоздатьToolStripMenuItem_Click); + // + // редактироватьToolStripMenuItem + // + this.редактироватьToolStripMenuItem.Name = "редактироватьToolStripMenuItem"; + this.редактироватьToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U))); + this.редактироватьToolStripMenuItem.Size = new System.Drawing.Size(246, 26); + this.редактироватьToolStripMenuItem.Text = "Редактировать"; + this.редактироватьToolStripMenuItem.Click += new System.EventHandler(this.РедактироватьToolStripMenuItem_Click); + // + // удалитьToolStripMenuItem + // + this.удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem"; + this.удалитьToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D))); + this.удалитьToolStripMenuItem.Size = new System.Drawing.Size(246, 26); + this.удалитьToolStripMenuItem.Text = "Удалить"; + this.удалитьToolStripMenuItem.Click += new System.EventHandler(this.УдалитьToolStripMenuItem_Click); + // + // отчётыToolStripMenuItem + // + this.отчётыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.документСТекстомToolStripMenuItem, + this.документСТаблицейToolStripMenuItem, + this.документСДиаграммойToolStripMenuItem}); + this.отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; + this.отчётыToolStripMenuItem.Size = new System.Drawing.Size(73, 24); + this.отчётыToolStripMenuItem.Text = "Отчёты"; + // + // документСТекстомToolStripMenuItem + // + this.документСТекстомToolStripMenuItem.Name = "документСТекстомToolStripMenuItem"; + this.документСТекстомToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); + this.документСТекстомToolStripMenuItem.Size = new System.Drawing.Size(313, 26); + this.документСТекстомToolStripMenuItem.Text = "Документ с текстом"; + this.документСТекстомToolStripMenuItem.Click += new System.EventHandler(this.ДокументСТекстомToolStripMenuItem_Click); + // + // документСТаблицейToolStripMenuItem + // + this.документСТаблицейToolStripMenuItem.Name = "документСТаблицейToolStripMenuItem"; + this.документСТаблицейToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T))); + this.документСТаблицейToolStripMenuItem.Size = new System.Drawing.Size(313, 26); + this.документСТаблицейToolStripMenuItem.Text = "Документ с таблицей"; + this.документСТаблицейToolStripMenuItem.Click += new System.EventHandler(this.ДокументСТаблицейToolStripMenuItem_Click); + // + // документСДиаграммойToolStripMenuItem + // + this.документСДиаграммойToolStripMenuItem.Name = "документСДиаграммойToolStripMenuItem"; + this.документСДиаграммойToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); + this.документСДиаграммойToolStripMenuItem.Size = new System.Drawing.Size(313, 26); + this.документСДиаграммойToolStripMenuItem.Text = "Документ с диаграммой"; + this.документСДиаграммойToolStripMenuItem.Click += new System.EventHandler(this.ДокументСДиаграммойToolStripMenuItem_Click); + // + // ролиToolStripMenuItem + // + this.ролиToolStripMenuItem.Name = "ролиToolStripMenuItem"; + this.ролиToolStripMenuItem.Size = new System.Drawing.Size(57, 24); + this.ролиToolStripMenuItem.Text = "Роли"; + this.ролиToolStripMenuItem.Click += new System.EventHandler(this.РолиToolStripMenuItem_Click); + // + // FormMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.controlDataTreeTable); + this.Controls.Add(this.menuStrip); + this.MainMenuStrip = this.menuStrip; + this.Name = "FormMain"; + this.Text = "Основная форма (аккаунты)"; + this.Load += new System.EventHandler(this.FormMain_Load); + this.menuStrip.ResumeLayout(false); + this.menuStrip.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + } + + #endregion + + private ControlsLibraryNet60.Data.ControlDataTreeTable controlDataTreeTable; + private RodionovLibrary.NonVisualComponents.WordLongTextComponent wordLongTextComponent; + private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderPdf componentDocumentWithTableMultiHeaderPdf; + private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieExcel componentDocumentWithChartPieExcel; + 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; + } +} diff --git a/COP/PortalAccountsView/FormMain.cs b/COP/PortalAccountsView/FormMain.cs new file mode 100644 index 0000000..a98e724 --- /dev/null +++ b/COP/PortalAccountsView/FormMain.cs @@ -0,0 +1,215 @@ +using ComponentsLibraryNet60.Models; +using ControlsLibraryNet60.Models; +using PortalAccountsContracts.BindingModels; +using PortalAccountsContracts.BusinessLogicsContracts; +using PortalAccountsContracts.ViewModels; +using RodionovLibrary.NonVisualComponents.HelperModels; + +namespace PortalAccountsView +{ + public partial class FormMain : Form + { + private readonly IAccountLogic _logic; + + public FormMain(IAccountLogic logic) + { + InitializeComponent(); + + _logic = logic; + + var nodeNames = new Queue(); + nodeNames.Enqueue("RoleName"); + nodeNames.Enqueue("OutputRating"); + nodeNames.Enqueue("Id"); + nodeNames.Enqueue("Login"); + controlDataTreeTable.LoadConfig(new DataTreeNodeConfig { NodeNames = nodeNames }); + } + + private void ToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormRoles)); + if (service is FormRoles form) + { + form.ShowDialog(); + } + } + + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + + private void LoadData() + { + controlDataTreeTable.Clear(); + var accounts = _logic.ReadList(null); + if (accounts != null) + { + foreach (var account in accounts) + { + account.OutputRating = account.Rating?.ToString() ?? ""; + } + controlDataTreeTable.AddTable(accounts); + } + } + + private void ToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormAccount)); + if (service is FormAccount form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void ToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormAccount)); + if (service is FormAccount form) + { + var selected = controlDataTreeTable.GetSelectedObject(); + if (selected == null) + return; + form.Id = selected.Id; + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void ToolStripMenuItem_Click(object sender, EventArgs e) + { + var selected = controlDataTreeTable.GetSelectedObject(); + if (selected == null) + return; + if (MessageBox.Show(" ?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + if (_logic.Delete(new AccountBindingModel { Id = selected.Id })) + { + LoadData(); + } + } + } + + private void ToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog + { + Filter = "docx|*.docx" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + var accounts = _logic.ReadList(null) ?? throw new Exception(" "); + List paragraphs = new(); + foreach (var account in accounts) + { + if (account.Rating == null) + { + paragraphs.Add($"{account.Login}: {(string.IsNullOrWhiteSpace(account.Warnings) ? " " : account.Warnings)}"); + } + } + wordLongTextComponent.CreateWordText(new WordLongTextInfo() + { + FileName = dialog.FileName, + Title = " ", + Paragraphs = paragraphs.ToArray() + }); + MessageBox.Show("!"); + } + catch (Exception ex) + { + MessageBox.Show(" : " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void ToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog + { + Filter = "Excel Files|*.xlsx" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + var accounts = _logic.ReadList(null) ?? throw new Exception(" "); + var roleMapping = new List(); + var data = new Dictionary> + { + { + "", + accounts + .Where(x => x.Rating != null) + .GroupBy(x => x.RoleName) + .Select((group, index) => + { + roleMapping.Add($"{group.Key} - {index + 1}"); + + return (Date: index + 1, Value: (double)group.Count()); + }) + .ToList() + } + }; + componentDocumentWithChartPieExcel.CreateDoc(new ComponentDocumentWithChartConfig + { + FilePath = dialog.FileName, + Header = $" ({string.Join(", ", roleMapping)})", + ChartTitle = " ", + LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom, + Data = data + }); + MessageBox.Show("!"); + } + catch (Exception ex) + { + MessageBox.Show(" : " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void ToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog + { + Filter = "PDF Files|*.pdf" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + var accounts = _logic.ReadList(null) ?? throw new Exception(" "); + foreach (var account in accounts) + { + account.OutputRating = account.Rating?.ToString() ?? ""; + } + componentDocumentWithTableMultiHeaderPdf.CreateDoc(new ComponentDocumentWithTableHeaderDataConfig + { + FilePath = dialog.FileName, + Header = " ", + ColumnsRowsWidth = new List<(int, int)> { (10, 10), (10, 10), (10, 10), (10, 10)}, // + Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)> + { + (0, 0, "Id", "Id"), + (1, 0, "", "Login"), + (2, 0, "", "RoleName"), + (3, 0, "", "OutputRating") + }, + Data = accounts + }); + MessageBox.Show("!"); + } + catch (Exception ex) + { + MessageBox.Show(" : " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} diff --git a/COP/PortalAccountsView/FormMain.resx b/COP/PortalAccountsView/FormMain.resx new file mode 100644 index 0000000..6ce2af4 --- /dev/null +++ b/COP/PortalAccountsView/FormMain.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 210, 17 + + + 518, 17 + + + 787, 17 + + \ No newline at end of file diff --git a/COP/PortalAccountsView/FormRoles.Designer.cs b/COP/PortalAccountsView/FormRoles.Designer.cs new file mode 100644 index 0000000..b51488a --- /dev/null +++ b/COP/PortalAccountsView/FormRoles.Designer.cs @@ -0,0 +1,87 @@ +namespace PortalAccountsView +{ + partial class FormRoles + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridView = new DataGridView(); + Id = new DataGridViewTextBoxColumn(); + NameCol = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.BackgroundColor = SystemColors.ControlLightLight; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { Id, NameCol }); + dataGridView.Dock = System.Windows.Forms.DockStyle.Fill; + dataGridView.Location = new System.Drawing.Point(0, 0); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new System.Drawing.Size(800, 450); + dataGridView.TabIndex = 0; + dataGridView.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridView_CellValueChanged); + dataGridView.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.DataGridView_UserDeletingRow); + dataGridView.KeyUp += new System.Windows.Forms.KeyEventHandler(this.DataGridView_KeyUp); + // + // Id + // + Id.HeaderText = "Id"; + Id.MinimumWidth = 6; + Id.Name = "Id"; + Id.Visible = false; + Id.Width = 125; + // + // Name + // + NameCol.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + NameCol.HeaderText = "Название"; + NameCol.MinimumWidth = 6; + NameCol.Name = "Name"; + // + // FormRoles + // + AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + ClientSize = new System.Drawing.Size(800, 450); + Controls.Add(dataGridView); + Name = "FormRoles"; + Text = "FormRoles"; + Load += new System.EventHandler(this.FormRoles_Load); + ((System.ComponentModel.ISupportInitialize)(dataGridView)).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private DataGridViewTextBoxColumn Id; + private DataGridViewTextBoxColumn NameCol; + } +} \ No newline at end of file diff --git a/COP/PortalAccountsView/FormRoles.cs b/COP/PortalAccountsView/FormRoles.cs new file mode 100644 index 0000000..4f74a9a --- /dev/null +++ b/COP/PortalAccountsView/FormRoles.cs @@ -0,0 +1,99 @@ +using PortalAccountsContracts.BindingModels; +using PortalAccountsContracts.BusinessLogicsContracts; + +namespace PortalAccountsView +{ + public partial class FormRoles : Form + { + private readonly IRoleLogic _logic; + + private bool dataLoading = false; + + public FormRoles(IRoleLogic logic) + { + InitializeComponent(); + _logic = logic; + } + + private void FormRoles_Load(object sender, EventArgs e) + { + LoadData(); + } + + private void LoadData() + { + dataLoading = true; + try + { + var list = _logic.ReadList(null); + if (list != null) + { + foreach (var role in list) + { + int rowIndex = dataGridView.Rows.Add(); + dataGridView.Rows[rowIndex].Cells[0].Value = role.Name; + dataGridView.Rows[rowIndex].Cells[1].Value = role.Id; + } + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + finally + { + dataLoading = false; + } + } + + private void DataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) + { + if (dataLoading || e.RowIndex < 0 || e.ColumnIndex != 0) + return; + if (dataGridView.Rows[e.RowIndex].Cells[1].Value != null && !string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[1].Value.ToString())) + { + var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; + if (name is null) return; + _logic.Update(new RoleBindingModel { Id = Convert.ToInt32(dataGridView.Rows[e.RowIndex].Cells[1].Value), Name = name.ToString() }); + } + else + { + var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; + if (name is null) + return; + _logic.Create(new RoleBindingModel { Id = 0, Name = name.ToString() }); + var list = _logic.ReadList(null) ?? throw new Exception("Не удалось получить список ролей"); + int newRoleId = list.Last().Id; + dataGridView.Rows[e.RowIndex].Cells[1].Value = newRoleId; + } + } + + private void DataGridView_KeyUp(object sender, KeyEventArgs e) + { + switch (e.KeyCode) + { + case Keys.Insert: + dataGridView.Rows.Add(); + break; + } + } + + private void DeleteRows(DataGridViewSelectedRowCollection rows) + { + for (int i = 0; i < rows.Count; i++) + { + DataGridViewRow row = rows[i]; + if (!_logic.Delete(new RoleBindingModel { Id = Convert.ToInt32(row.Cells[1].Value) })) continue; + dataGridView.Rows.Remove(row); + } + } + + private void DataGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) + { + e.Cancel = true; + if (dataGridView.SelectedRows == null) return; + if (MessageBox.Show("Удалить записи?", "Подтвердите действие", MessageBoxButtons.YesNo) == DialogResult.No) return; + DeleteRows(dataGridView.SelectedRows); + } + } +} diff --git a/COP/PortalAccountsView/FormRoles.resx b/COP/PortalAccountsView/FormRoles.resx new file mode 100644 index 0000000..9d0eaa3 --- /dev/null +++ b/COP/PortalAccountsView/FormRoles.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + \ No newline at end of file diff --git a/COP/PortalAccountsView/PortalAccountsView.csproj b/COP/PortalAccountsView/PortalAccountsView.csproj new file mode 100644 index 0000000..cd605b7 --- /dev/null +++ b/COP/PortalAccountsView/PortalAccountsView.csproj @@ -0,0 +1,29 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + \ No newline at end of file diff --git a/COP/PortalAccountsView/Program.cs b/COP/PortalAccountsView/Program.cs new file mode 100644 index 0000000..d799a8c --- /dev/null +++ b/COP/PortalAccountsView/Program.cs @@ -0,0 +1,41 @@ +using PortalAccountsBusinessLogic.BusinessLogics; +using PortalAccountsContracts.BusinessLogicsContracts; +using PortalAccountsContracts.StoragesContracts; +using PortalAccountsDatabaseImplement.Implements; +using Microsoft.Extensions.DependencyInjection; + +namespace PortalAccountsView +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; + [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()); + } + + private static void ConfigureServices(ServiceCollection services) + { + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + } + } + +} \ No newline at end of file diff --git a/COP/RodionovLibrary/RodionovLibrary.csproj b/COP/RodionovLibrary/RodionovLibrary.csproj index 20d916e..72e232a 100644 --- a/COP/RodionovLibrary/RodionovLibrary.csproj +++ b/COP/RodionovLibrary/RodionovLibrary.csproj @@ -5,6 +5,7 @@ enable true enable + True diff --git a/COP/RodionovLibrary/VisualComponents/ComboBoxControl.Designer.cs b/COP/RodionovLibrary/VisualComponents/ComboBoxControl.Designer.cs index 7954e0f..45e9dc6 100644 --- a/COP/RodionovLibrary/VisualComponents/ComboBoxControl.Designer.cs +++ b/COP/RodionovLibrary/VisualComponents/ComboBoxControl.Designer.cs @@ -33,10 +33,11 @@ // // comboBox // + comboBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; comboBox.FormattingEnabled = true; comboBox.Location = new Point(1, 0); comboBox.Name = "comboBox"; - comboBox.Size = new Size(181, 23); + comboBox.Size = new Size(323, 23); comboBox.TabIndex = 0; comboBox.SelectedIndexChanged += ComboBox_SelectedIndexChanged; // @@ -44,11 +45,9 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - AutoSize = true; - AutoSizeMode = AutoSizeMode.GrowAndShrink; Controls.Add(comboBox); Name = "ComboBoxControl"; - Size = new Size(185, 26); + Size = new Size(327, 26); ResumeLayout(false); } diff --git a/COP/RodionovLibrary/VisualComponents/ListBoxControl.Designer.cs b/COP/RodionovLibrary/VisualComponents/ListBoxControl.Designer.cs index f5b8e96..0dfbb81 100644 --- a/COP/RodionovLibrary/VisualComponents/ListBoxControl.Designer.cs +++ b/COP/RodionovLibrary/VisualComponents/ListBoxControl.Designer.cs @@ -33,22 +33,21 @@ // // listBox // + listBox.Dock = DockStyle.Fill; listBox.FormattingEnabled = true; listBox.ItemHeight = 15; listBox.Location = new Point(0, 0); listBox.Name = "listBox"; - listBox.Size = new Size(564, 364); + listBox.Size = new Size(567, 367); listBox.TabIndex = 0; // // ListBoxControl // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - AutoSize = true; - AutoSizeMode = AutoSizeMode.GrowAndShrink; Controls.Add(listBox); Name = "ListBoxControl"; - Size = new Size(564, 150); + Size = new Size(567, 367); ResumeLayout(false); } diff --git a/COP/RodionovLibrary/VisualComponents/TextBoxControl.Designer.cs b/COP/RodionovLibrary/VisualComponents/TextBoxControl.Designer.cs index b6716f7..3b661c0 100644 --- a/COP/RodionovLibrary/VisualComponents/TextBoxControl.Designer.cs +++ b/COP/RodionovLibrary/VisualComponents/TextBoxControl.Designer.cs @@ -35,6 +35,7 @@ // // textBox // + textBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; textBox.Location = new Point(0, 0); textBox.Name = "textBox"; textBox.Size = new Size(213, 23); @@ -46,8 +47,6 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - AutoSize = true; - AutoSizeMode = AutoSizeMode.GrowAndShrink; Controls.Add(textBox); Name = "TextBoxControl"; Size = new Size(216, 26);