форма со справочником для выбора
This commit is contained in:
parent
6f8592a884
commit
6f971d1327
10
CustomComboBox/BindingModels/BindingModels.csproj
Normal file
10
CustomComboBox/BindingModels/BindingModels.csproj
Normal 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>
|
14
CustomComboBox/BusinessLogic/BusinessLogic.csproj
Normal file
14
CustomComboBox/BusinessLogic/BusinessLogic.csproj
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Contracts\Contracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
91
CustomComboBox/BusinessLogic/JobTypeLogic.cs
Normal file
91
CustomComboBox/BusinessLogic/JobTypeLogic.cs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.BusinessLogicContracts;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
using Contracts.StorageContracts;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BusinessLogic
|
||||||
|
{
|
||||||
|
public class JobTypeLogic: IJobTypeLogic
|
||||||
|
{
|
||||||
|
private readonly IJobTypeStorage _jobTypeStorage;
|
||||||
|
|
||||||
|
public JobTypeLogic(IJobTypeStorage jobTypeStorage)
|
||||||
|
{
|
||||||
|
_jobTypeStorage = jobTypeStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<JobTypeViewModel>? ReadList(JobTypeSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _jobTypeStorage.GetFullList() : _jobTypeStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JobTypeViewModel? ReadElement(JobTypeSearchModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
var element = _jobTypeStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(JobTypeBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_jobTypeStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(JobTypeBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_jobTypeStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(JobTypeBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_jobTypeStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(JobTypeBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Введите название должности");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
98
CustomComboBox/BusinessLogic/WorkerLogic.cs
Normal file
98
CustomComboBox/BusinessLogic/WorkerLogic.cs
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
using Contracts.BusinessLogicContracts;
|
||||||
|
using Contracts.StorageContracts;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Contracts.BindingModels;
|
||||||
|
|
||||||
|
namespace BusinessLogic
|
||||||
|
{
|
||||||
|
public class WorkerLogic : IWorkerLogic
|
||||||
|
{
|
||||||
|
private readonly IWorkerStorage _workerStorage;
|
||||||
|
public WorkerLogic(IWorkerStorage workerStorage)
|
||||||
|
{
|
||||||
|
_workerStorage = workerStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WorkerViewModel>? ReadList(WorkerSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _workerStorage.GetFullList() : _workerStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkerViewModel? ReadElement(WorkerSearchModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
var element = _workerStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_workerStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_workerStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_workerStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(WorkerBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Введите ФИО");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Autobiography))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Введите автобиографию");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.JobType))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Выберите должность");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Models;
|
||||||
|
|
||||||
|
namespace Contracts.BindingModels
|
||||||
|
{
|
||||||
|
public class JobTypeBindingModel: IJobTypeModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
18
CustomComboBox/Contracts/BindingModels/WorkerBindingModel.cs
Normal file
18
CustomComboBox/Contracts/BindingModels/WorkerBindingModel.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.BindingModels
|
||||||
|
{
|
||||||
|
public class WorkerBindingModel: IWorkerModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public string Autobiography { get; set; } = string.Empty;
|
||||||
|
public string? DateAdvance { get; set; }
|
||||||
|
public string JobType { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IJobTypeLogic
|
||||||
|
{
|
||||||
|
List<JobTypeViewModel>? ReadList(JobTypeSearchModel? model);
|
||||||
|
JobTypeViewModel? ReadElement (JobTypeSearchModel? model);
|
||||||
|
bool Create(JobTypeBindingModel model);
|
||||||
|
bool Update(JobTypeBindingModel model);
|
||||||
|
bool Delete(JobTypeBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IWorkerLogic
|
||||||
|
{
|
||||||
|
List<WorkerViewModel>? ReadList(WorkerSearchModel? model);
|
||||||
|
WorkerViewModel? ReadElement(WorkerSearchModel? model);
|
||||||
|
bool Create(WorkerBindingModel model);
|
||||||
|
bool Update(WorkerBindingModel model);
|
||||||
|
bool Delete(WorkerBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
14
CustomComboBox/Contracts/Contracts.csproj
Normal file
14
CustomComboBox/Contracts/Contracts.csproj
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Models\Models.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
13
CustomComboBox/Contracts/SearchModels/JobTypeSearchModel.cs
Normal file
13
CustomComboBox/Contracts/SearchModels/JobTypeSearchModel.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.SearchModels
|
||||||
|
{
|
||||||
|
public class JobTypeSearchModel
|
||||||
|
{
|
||||||
|
public string? Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
17
CustomComboBox/Contracts/SearchModels/WorkerSearchModel.cs
Normal file
17
CustomComboBox/Contracts/SearchModels/WorkerSearchModel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.SearchModels
|
||||||
|
{
|
||||||
|
public class WorkerSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public string? Autobiography { get; set; }
|
||||||
|
public string? DateAdvance { get; set; }
|
||||||
|
public string? JobType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
21
CustomComboBox/Contracts/StorageContracts/IJobTypeStorage.cs
Normal file
21
CustomComboBox/Contracts/StorageContracts/IJobTypeStorage.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.StorageContracts
|
||||||
|
{
|
||||||
|
public interface IJobTypeStorage
|
||||||
|
{
|
||||||
|
List<JobTypeViewModel> GetFullList();
|
||||||
|
List<JobTypeViewModel> GetFilteredList(JobTypeSearchModel model);
|
||||||
|
JobTypeViewModel? GetElement(JobTypeSearchModel model);
|
||||||
|
JobTypeViewModel? Insert(JobTypeBindingModel model);
|
||||||
|
JobTypeViewModel? Update(JobTypeBindingModel model);
|
||||||
|
JobTypeViewModel? Delete(JobTypeBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
22
CustomComboBox/Contracts/StorageContracts/IWorkerStorage.cs
Normal file
22
CustomComboBox/Contracts/StorageContracts/IWorkerStorage.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.StorageContracts
|
||||||
|
{
|
||||||
|
public interface IWorkerStorage
|
||||||
|
{
|
||||||
|
List<WorkerViewModel> GetFullList();
|
||||||
|
List<WorkerViewModel> GetFilteredList(WorkerSearchModel model);
|
||||||
|
WorkerViewModel? GetElement(WorkerSearchModel model);
|
||||||
|
|
||||||
|
WorkerViewModel? Insert(WorkerBindingModel model);
|
||||||
|
WorkerViewModel? Update(WorkerBindingModel model);
|
||||||
|
WorkerViewModel? Delete(WorkerBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
17
CustomComboBox/Contracts/ViewModels/JobTypeViewModel.cs
Normal file
17
CustomComboBox/Contracts/ViewModels/JobTypeViewModel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.ViewModels
|
||||||
|
{
|
||||||
|
public class JobTypeViewModel: IJobTypeModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Должность")]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
23
CustomComboBox/Contracts/ViewModels/WorkerViewModel.cs
Normal file
23
CustomComboBox/Contracts/ViewModels/WorkerViewModel.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Contracts.ViewModels
|
||||||
|
{
|
||||||
|
public class WorkerViewModel: IWorkerModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("ФИО")]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Автобиография")]
|
||||||
|
public string Autobiography { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Должность")]
|
||||||
|
public string JobType { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Дата повышения квалификации")]
|
||||||
|
public string? DateAdvance { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BarsukovComponents", "..\Co
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp", "TestApp\TestApp.csproj", "{BF4A0F84-CD73-443C-A480-B54A9A0B7867}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp", "TestApp\TestApp.csproj", "{BF4A0F84-CD73-443C-A480-B54A9A0B7867}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Models", "Models\Models.csproj", "{8334B55D-6509-476C-B43E-5753D21A3A7A}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contracts", "Contracts\Contracts.csproj", "{ACCDF1FF-335F-4ABC-9771-4CAA4EA42D00}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{8334B55D-6509-476C-B43E-5753D21A3A7A} = {8334B55D-6509-476C-B43E-5753D21A3A7A}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BusinessLogic", "BusinessLogic\BusinessLogic.csproj", "{3D6084D7-4D23-4202-9B05-AE0EB73D01A8}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{D78462A7-BA09-4E15-856A-B1D688B138CC}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -21,6 +32,22 @@ Global
|
|||||||
{BF4A0F84-CD73-443C-A480-B54A9A0B7867}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{BF4A0F84-CD73-443C-A480-B54A9A0B7867}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{BF4A0F84-CD73-443C-A480-B54A9A0B7867}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{BF4A0F84-CD73-443C-A480-B54A9A0B7867}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{BF4A0F84-CD73-443C-A480-B54A9A0B7867}.Release|Any CPU.Build.0 = Release|Any CPU
|
{BF4A0F84-CD73-443C-A480-B54A9A0B7867}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{8334B55D-6509-476C-B43E-5753D21A3A7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{8334B55D-6509-476C-B43E-5753D21A3A7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{8334B55D-6509-476C-B43E-5753D21A3A7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{8334B55D-6509-476C-B43E-5753D21A3A7A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{ACCDF1FF-335F-4ABC-9771-4CAA4EA42D00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{ACCDF1FF-335F-4ABC-9771-4CAA4EA42D00}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{ACCDF1FF-335F-4ABC-9771-4CAA4EA42D00}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{ACCDF1FF-335F-4ABC-9771-4CAA4EA42D00}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3D6084D7-4D23-4202-9B05-AE0EB73D01A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3D6084D7-4D23-4202-9B05-AE0EB73D01A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3D6084D7-4D23-4202-9B05-AE0EB73D01A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3D6084D7-4D23-4202-9B05-AE0EB73D01A8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D78462A7-BA09-4E15-856A-B1D688B138CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D78462A7-BA09-4E15-856A-B1D688B138CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D78462A7-BA09-4E15-856A-B1D688B138CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D78462A7-BA09-4E15-856A-B1D688B138CC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
26
CustomComboBox/DatabaseImplement/Database.cs
Normal file
26
CustomComboBox/DatabaseImplement/Database.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using DatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DatabaseImplement
|
||||||
|
{
|
||||||
|
public class Database: DbContext
|
||||||
|
{
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
if (optionsBuilder.IsConfigured == false)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseNpgsql(@"Host=localhost;Database=WorkersDatabase;Username=postgres;Password=postgres");
|
||||||
|
}
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||||
|
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||||
|
}
|
||||||
|
public virtual DbSet<Worker> Workers { get; set; }
|
||||||
|
public virtual DbSet<JobType> JobTypes { get; set; }
|
||||||
|
}
|
||||||
|
}
|
25
CustomComboBox/DatabaseImplement/DatabaseImplement.csproj
Normal file
25
CustomComboBox/DatabaseImplement/DatabaseImplement.csproj
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BusinessLogic\BusinessLogic.csproj" />
|
||||||
|
<ProjectReference Include="..\Contracts\Contracts.csproj" />
|
||||||
|
<ProjectReference Include="..\Models\Models.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,81 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
using Contracts.StorageContracts;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using DatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class JobTypeStorage: IJobTypeStorage
|
||||||
|
{
|
||||||
|
public List<JobTypeViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
return context.JobTypes
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
public List<JobTypeViewModel> GetFilteredList(JobTypeSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
return context.JobTypes
|
||||||
|
.Where(x => x.Name == model.Name)
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
public JobTypeViewModel? GetElement(JobTypeSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
return context.JobTypes
|
||||||
|
.FirstOrDefault(x => x.Name == model.Name)?.GetViewModel;
|
||||||
|
}
|
||||||
|
public JobTypeViewModel? Insert(JobTypeBindingModel model)
|
||||||
|
{
|
||||||
|
var newType = JobType.Create(model);
|
||||||
|
if (newType == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
context.JobTypes.Add(newType);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newType.GetViewModel;
|
||||||
|
}
|
||||||
|
public JobTypeViewModel? Update(JobTypeBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
var type = context.JobTypes.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (type == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
type.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return type.GetViewModel;
|
||||||
|
}
|
||||||
|
public JobTypeViewModel? Delete(JobTypeBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
var element = context.JobTypes.FirstOrDefault(x => x.Name == model.Name);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.JobTypes.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
78
CustomComboBox/DatabaseImplement/Implements/WorkerStorage.cs
Normal file
78
CustomComboBox/DatabaseImplement/Implements/WorkerStorage.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
using Contracts.StorageContracts;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using DatabaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class WorkerStorage: IWorkerStorage
|
||||||
|
{
|
||||||
|
public List<WorkerViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
return context.Workers.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
public List<WorkerViewModel> GetFilteredList(WorkerSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
return context.Workers
|
||||||
|
.Where(x => x.JobType == model.JobType)
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
public WorkerViewModel GetElement(WorkerSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
return context.Workers.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||||
|
}
|
||||||
|
public WorkerViewModel? Insert(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
var newType = Worker.Create(model);
|
||||||
|
if (newType == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new Database();
|
||||||
|
context.Workers.Add(newType);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newType.GetViewModel;
|
||||||
|
}
|
||||||
|
public WorkerViewModel? Update(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
var type = context.Workers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (type == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
type.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return type.GetViewModel;
|
||||||
|
}
|
||||||
|
public WorkerViewModel? Delete(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new Database();
|
||||||
|
var element = context.Workers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.Workers.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
75
CustomComboBox/DatabaseImplement/Migrations/20241111171158_try2.Designer.cs
generated
Normal file
75
CustomComboBox/DatabaseImplement/Migrations/20241111171158_try2.Designer.cs
generated
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using DatabaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(Database))]
|
||||||
|
[Migration("20241111171158_try2")]
|
||||||
|
partial class try2
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.10")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.JobType", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("JobTypes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Worker", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Autobiography")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("DateAdvance")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("JobType")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Workers");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class try2 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "JobTypes",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_JobTypes", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Workers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Autobiography = table.Column<string>(type: "text", nullable: false),
|
||||||
|
DateAdvance = table.Column<string>(type: "text", nullable: false),
|
||||||
|
JobType = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Workers", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "JobTypes");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Workers");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using DatabaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(Database))]
|
||||||
|
partial class DatabaseModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.10")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.JobType", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("JobTypes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DatabaseImplement.Models.Worker", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Autobiography")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("DateAdvance")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("JobType")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Workers");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
CustomComboBox/DatabaseImplement/Models/JobType.cs
Normal file
44
CustomComboBox/DatabaseImplement/Models/JobType.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class JobType: IJobTypeModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
public static JobType? Create(JobTypeBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new JobType
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(JobTypeBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Name = model.Name;
|
||||||
|
}
|
||||||
|
public JobTypeViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
59
CustomComboBox/DatabaseImplement/Models/Worker.cs
Normal file
59
CustomComboBox/DatabaseImplement/Models/Worker.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Worker: IWorkerModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Autobiography { get; private set; } = string.Empty;
|
||||||
|
public string DateAdvance { get; private set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string JobType { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public static Worker? Create(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Worker
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Autobiography = model.Autobiography,
|
||||||
|
DateAdvance = model.DateAdvance,
|
||||||
|
JobType = model.JobType,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Name = model.Name;
|
||||||
|
Autobiography = model.Autobiography;
|
||||||
|
DateAdvance = model.DateAdvance;
|
||||||
|
JobType = model.JobType;
|
||||||
|
}
|
||||||
|
public WorkerViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
Autobiography = Autobiography,
|
||||||
|
DateAdvance = DateAdvance,
|
||||||
|
JobType = JobType,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
13
CustomComboBox/Models/IId.cs
Normal file
13
CustomComboBox/Models/IId.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Models
|
||||||
|
{
|
||||||
|
public interface IId
|
||||||
|
{
|
||||||
|
int Id { get; }
|
||||||
|
}
|
||||||
|
}
|
13
CustomComboBox/Models/IJobTypeModel.cs
Normal file
13
CustomComboBox/Models/IJobTypeModel.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Models
|
||||||
|
{
|
||||||
|
public interface IJobTypeModel: IId
|
||||||
|
{
|
||||||
|
string Name { get; }
|
||||||
|
}
|
||||||
|
}
|
16
CustomComboBox/Models/IWorkerModel.cs
Normal file
16
CustomComboBox/Models/IWorkerModel.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Models
|
||||||
|
{
|
||||||
|
public interface IWorkerModel: IId
|
||||||
|
{
|
||||||
|
string Name { get; }
|
||||||
|
string Autobiography { get; }
|
||||||
|
string? DateAdvance { get; }
|
||||||
|
string JobType { get; }
|
||||||
|
}
|
||||||
|
}
|
10
CustomComboBox/Models/Models.csproj
Normal file
10
CustomComboBox/Models/Models.csproj
Normal 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>
|
79
CustomComboBox/TestApp/FormJobType.Designer.cs
generated
Normal file
79
CustomComboBox/TestApp/FormJobType.Designer.cs
generated
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
partial class FormJobType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
Title = new DataGridViewTextBoxColumn();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AllowUserToAddRows = false;
|
||||||
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Columns.AddRange(new DataGridViewColumn[] { Title });
|
||||||
|
dataGridView.Location = new Point(12, 12);
|
||||||
|
dataGridView.MultiSelect = false;
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.Size = new Size(257, 426);
|
||||||
|
dataGridView.TabIndex = 0;
|
||||||
|
dataGridView.CellBeginEdit += dataGridView_CellBeginEdit;
|
||||||
|
dataGridView.CellValueChanged += dataGridView_CellValueChanged;
|
||||||
|
dataGridView.KeyDown += dataGridView_KeyDown;
|
||||||
|
//
|
||||||
|
// Title
|
||||||
|
//
|
||||||
|
Title.HeaderText = "Название";
|
||||||
|
Title.MinimumWidth = 6;
|
||||||
|
Title.Name = "Title";
|
||||||
|
Title.Width = 125;
|
||||||
|
//
|
||||||
|
// FormJobType
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(275, 450);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormJobType";
|
||||||
|
Text = "FormJobType";
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private DataGridViewTextBoxColumn Title;
|
||||||
|
}
|
||||||
|
}
|
120
CustomComboBox/TestApp/FormJobType.cs
Normal file
120
CustomComboBox/TestApp/FormJobType.cs
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.SearchModels;
|
||||||
|
using Contracts.BusinessLogicContracts;
|
||||||
|
using Contracts.StorageContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
public partial class FormJobType : Form
|
||||||
|
{
|
||||||
|
private readonly IJobTypeLogic _logic;
|
||||||
|
private string OldName = string.Empty;
|
||||||
|
public FormJobType(IJobTypeLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(item.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.KeyCode == Keys.Insert)
|
||||||
|
{
|
||||||
|
for (int i = 0; i<dataGridView.Rows.Count; i++)
|
||||||
|
{
|
||||||
|
if (dataGridView.Rows[i].Cells[0].Value == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dataGridView.Rows.Add();
|
||||||
|
}
|
||||||
|
else if (e.KeyCode == Keys.Delete)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить строку?", "Удаление", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
var name = dataGridView.SelectedCells[0].Value.ToString();
|
||||||
|
if (name != null)
|
||||||
|
{
|
||||||
|
_logic.Delete(new JobTypeBindingModel
|
||||||
|
{
|
||||||
|
Name = name,
|
||||||
|
});
|
||||||
|
dataGridView.Rows.RemoveAt(dataGridView.SelectedCells[0].RowIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.Rows.Count > 0)
|
||||||
|
{
|
||||||
|
var name = dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString();
|
||||||
|
if (string.IsNullOrEmpty(name))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Введите название!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e.RowIndex >= dataGridView.Rows.Count || string.IsNullOrEmpty(OldName))
|
||||||
|
{
|
||||||
|
_logic.Create(new JobTypeBindingModel
|
||||||
|
{
|
||||||
|
Name = name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var element = _logic.ReadElement(new JobTypeSearchModel { Name = OldName });
|
||||||
|
_logic.Update(new JobTypeBindingModel
|
||||||
|
{
|
||||||
|
Id = element.Id,
|
||||||
|
Name = name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//_logic.Create(new JobTypeBindingModel
|
||||||
|
//{
|
||||||
|
// Name = name,
|
||||||
|
//});
|
||||||
|
//var elem = _logic.ReadElement(new JobTypeSearchModel { Name = name });
|
||||||
|
//MessageBox.Show(elem.Name + " " + elem.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dataGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.Rows[e.RowIndex].Cells[0].Value != null)
|
||||||
|
{
|
||||||
|
OldName = dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
123
CustomComboBox/TestApp/FormJobType.resx
Normal file
123
CustomComboBox/TestApp/FormJobType.resx
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="Title.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
129
CustomComboBox/TestApp/FormMain.Designer.cs
generated
Normal file
129
CustomComboBox/TestApp/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
partial class FormMain
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
menuStrip1 = new MenuStrip();
|
||||||
|
menuToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
jobTypesToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
addWorkerToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
editWorkerToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
deleteWorkerToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
pdfToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
excelToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
wordToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
menuStrip1.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// menuStrip1
|
||||||
|
//
|
||||||
|
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||||
|
menuStrip1.Items.AddRange(new ToolStripItem[] { menuToolStripMenuItem });
|
||||||
|
menuStrip1.Location = new Point(0, 0);
|
||||||
|
menuStrip1.Name = "menuStrip1";
|
||||||
|
menuStrip1.Size = new Size(800, 28);
|
||||||
|
menuStrip1.TabIndex = 1;
|
||||||
|
menuStrip1.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// menuToolStripMenuItem
|
||||||
|
//
|
||||||
|
menuToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { jobTypesToolStripMenuItem, addWorkerToolStripMenuItem, editWorkerToolStripMenuItem, deleteWorkerToolStripMenuItem, pdfToolStripMenuItem, excelToolStripMenuItem, wordToolStripMenuItem });
|
||||||
|
menuToolStripMenuItem.Name = "menuToolStripMenuItem";
|
||||||
|
menuToolStripMenuItem.Size = new Size(60, 24);
|
||||||
|
menuToolStripMenuItem.Text = "menu";
|
||||||
|
//
|
||||||
|
// jobTypesToolStripMenuItem
|
||||||
|
//
|
||||||
|
jobTypesToolStripMenuItem.Name = "jobTypesToolStripMenuItem";
|
||||||
|
jobTypesToolStripMenuItem.Size = new Size(224, 26);
|
||||||
|
jobTypesToolStripMenuItem.Text = "job types";
|
||||||
|
jobTypesToolStripMenuItem.Click += jobTypesToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// addWorkerToolStripMenuItem
|
||||||
|
//
|
||||||
|
addWorkerToolStripMenuItem.Name = "addWorkerToolStripMenuItem";
|
||||||
|
addWorkerToolStripMenuItem.Size = new Size(224, 26);
|
||||||
|
addWorkerToolStripMenuItem.Text = "add worker";
|
||||||
|
//
|
||||||
|
// editWorkerToolStripMenuItem
|
||||||
|
//
|
||||||
|
editWorkerToolStripMenuItem.Name = "editWorkerToolStripMenuItem";
|
||||||
|
editWorkerToolStripMenuItem.Size = new Size(224, 26);
|
||||||
|
editWorkerToolStripMenuItem.Text = "edit worker";
|
||||||
|
//
|
||||||
|
// deleteWorkerToolStripMenuItem
|
||||||
|
//
|
||||||
|
deleteWorkerToolStripMenuItem.Name = "deleteWorkerToolStripMenuItem";
|
||||||
|
deleteWorkerToolStripMenuItem.Size = new Size(224, 26);
|
||||||
|
deleteWorkerToolStripMenuItem.Text = "delete worker";
|
||||||
|
//
|
||||||
|
// pdfToolStripMenuItem
|
||||||
|
//
|
||||||
|
pdfToolStripMenuItem.Name = "pdfToolStripMenuItem";
|
||||||
|
pdfToolStripMenuItem.Size = new Size(224, 26);
|
||||||
|
pdfToolStripMenuItem.Text = "pdf";
|
||||||
|
//
|
||||||
|
// excelToolStripMenuItem
|
||||||
|
//
|
||||||
|
excelToolStripMenuItem.Name = "excelToolStripMenuItem";
|
||||||
|
excelToolStripMenuItem.Size = new Size(224, 26);
|
||||||
|
excelToolStripMenuItem.Text = "excel";
|
||||||
|
//
|
||||||
|
// wordToolStripMenuItem
|
||||||
|
//
|
||||||
|
wordToolStripMenuItem.Name = "wordToolStripMenuItem";
|
||||||
|
wordToolStripMenuItem.Size = new Size(224, 26);
|
||||||
|
wordToolStripMenuItem.Text = "word";
|
||||||
|
//
|
||||||
|
// FormMain
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(menuStrip1);
|
||||||
|
MainMenuStrip = menuStrip1;
|
||||||
|
Name = "FormMain";
|
||||||
|
Text = "FormMain";
|
||||||
|
menuStrip1.ResumeLayout(false);
|
||||||
|
menuStrip1.PerformLayout();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private MenuStrip menuStrip1;
|
||||||
|
private ToolStripMenuItem menuToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem jobTypesToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem addWorkerToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem editWorkerToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem deleteWorkerToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem pdfToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem excelToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem wordToolStripMenuItem;
|
||||||
|
}
|
||||||
|
}
|
35
CustomComboBox/TestApp/FormMain.cs
Normal file
35
CustomComboBox/TestApp/FormMain.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using Contracts.BusinessLogicContracts;
|
||||||
|
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 TestApp
|
||||||
|
{
|
||||||
|
public partial class FormMain : Form
|
||||||
|
{
|
||||||
|
private readonly IWorkerLogic _workerLogic;
|
||||||
|
private readonly IJobTypeLogic _jobTypeLogic;
|
||||||
|
public FormMain(IWorkerLogic workerLogic, IJobTypeLogic jobTypeLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_workerLogic = workerLogic;
|
||||||
|
_jobTypeLogic = jobTypeLogic;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void jobTypesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormJobType));
|
||||||
|
if (service is FormJobType form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
123
CustomComboBox/TestApp/FormMain.resx
Normal file
123
CustomComboBox/TestApp/FormMain.resx
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
@ -1,17 +1,35 @@
|
|||||||
|
using BusinessLogic;
|
||||||
|
using Contracts.BusinessLogicContracts;
|
||||||
|
using Contracts.StorageContracts;
|
||||||
|
using DatabaseImplement.Implements;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System.Drawing.Printing;
|
||||||
|
|
||||||
namespace TestApp
|
namespace TestApp
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
/// <summary>
|
private static ServiceProvider? _serviceProvider;
|
||||||
/// The main entry point for the application.
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||||
/// </summary>
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new Form1());
|
var services = new ServiceCollection();
|
||||||
|
ConfigureServices(services);
|
||||||
|
_serviceProvider = services.BuildServiceProvider();
|
||||||
|
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||||
|
}
|
||||||
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddTransient<IJobTypeStorage, JobTypeStorage>();
|
||||||
|
services.AddTransient<IJobTypeLogic, JobTypeLogic>();
|
||||||
|
services.AddTransient<IWorkerLogic, WorkerLogic>();
|
||||||
|
services.AddTransient<IWorkerStorage, WorkerStorage>();
|
||||||
|
services.AddTransient<FormMain>();
|
||||||
|
services.AddTransient<FormJobType>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,8 +8,19 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="BelianinComponents" Version="1.0.0" />
|
||||||
|
<PackageReference Include="KryukovLib" Version="1.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Components\BarsukovComponents.csproj" />
|
<ProjectReference Include="..\..\Components\BarsukovComponents.csproj" />
|
||||||
|
<ProjectReference Include="..\Contracts\Contracts.csproj" />
|
||||||
|
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user