вроде всё сделала, нет сил проверять
This commit is contained in:
parent
d346f6d13f
commit
64d1d192e6
@ -3,9 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34723.18
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Components", "Components.csproj", "{0E0FD0F8-FAD2-4C5F-9F4E-E53516BCB322}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Components", "Components.csproj", "{0E0FD0F8-FAD2-4C5F-9F4E-E53516BCB322}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormTest", "..\FormTest\FormTest.csproj", "{EB2A68E5-EF5C-48B2-90DF-E5CA53F65202}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FormTest", "..\FormTest\FormTest.csproj", "{EB2A68E5-EF5C-48B2-90DF-E5CA53F65202}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmployeesView", "..\EmployeesView\EmployeesView.csproj", "{B5FD4B5D-633F-44AD-B053-E6580DC81C62}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmployeeLogic", "..\EmployeeLogic\EmployeeLogic.csproj", "{526F24BD-B78A-4438-9AB7-C1A17DBB1295}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmployeesContracts", "..\EmployeesContracts\EmployeesContracts.csproj", "{2C1D8FF8-1097-41F4-AF5F-954C9AC93433}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmployeesDatabaseImplement", "..\EmployeesDatabaseImplement\EmployeesDatabaseImplement.csproj", "{79336B31-79AD-4BA9-9249-AECADC90E7C2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -21,6 +29,22 @@ Global
|
||||
{EB2A68E5-EF5C-48B2-90DF-E5CA53F65202}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EB2A68E5-EF5C-48B2-90DF-E5CA53F65202}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EB2A68E5-EF5C-48B2-90DF-E5CA53F65202}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B5FD4B5D-633F-44AD-B053-E6580DC81C62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B5FD4B5D-633F-44AD-B053-E6580DC81C62}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B5FD4B5D-633F-44AD-B053-E6580DC81C62}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B5FD4B5D-633F-44AD-B053-E6580DC81C62}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{526F24BD-B78A-4438-9AB7-C1A17DBB1295}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{526F24BD-B78A-4438-9AB7-C1A17DBB1295}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{526F24BD-B78A-4438-9AB7-C1A17DBB1295}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{526F24BD-B78A-4438-9AB7-C1A17DBB1295}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2C1D8FF8-1097-41F4-AF5F-954C9AC93433}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2C1D8FF8-1097-41F4-AF5F-954C9AC93433}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2C1D8FF8-1097-41F4-AF5F-954C9AC93433}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2C1D8FF8-1097-41F4-AF5F-954C9AC93433}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{79336B31-79AD-4BA9-9249-AECADC90E7C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{79336B31-79AD-4BA9-9249-AECADC90E7C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{79336B31-79AD-4BA9-9249-AECADC90E7C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{79336B31-79AD-4BA9-9249-AECADC90E7C2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -5,6 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
68
EmployeeLogic/BusinessLogics/EmployeeLogic.cs
Normal file
68
EmployeeLogic/BusinessLogics/EmployeeLogic.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using EmployeesContracts.BindingModels;
|
||||
using EmployeesContracts.BusinessLogicsContracts;
|
||||
using EmployeesContracts.StorageContracts;
|
||||
using EmployeesContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EmployeeLogic.BusinessLogics
|
||||
{
|
||||
public class EmployeeLogic : IEmployeeLogic
|
||||
{
|
||||
private readonly IEmployeeStorage _employeeStorage;
|
||||
|
||||
public EmployeeLogic(IEmployeeStorage employeeStorage)
|
||||
{
|
||||
_employeeStorage = employeeStorage;
|
||||
}
|
||||
public void CreateOrUpdate(EmployeeBindingModel model)
|
||||
{
|
||||
var element = _employeeStorage.GetElement(
|
||||
new EmployeeBindingModel
|
||||
{
|
||||
Autobiography = model.Autobiography,
|
||||
Name = model.Name,
|
||||
Post = model.Post,
|
||||
Upgrade = model.Upgrade
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new Exception("Сотрудник с таким именем уже существует");
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_employeeStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_employeeStorage.Insert(model);
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(EmployeeBindingModel model)
|
||||
{
|
||||
var element = _employeeStorage.GetElement(new EmployeeBindingModel { Id = model.Id });
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Сотрудник не найден");
|
||||
}
|
||||
_employeeStorage.Delete(model);
|
||||
}
|
||||
|
||||
public List<EmployeeViewModel> Read(EmployeeBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return _employeeStorage.GetFullList();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<EmployeeViewModel> { _employeeStorage.GetElement(model) };
|
||||
}
|
||||
return _employeeStorage.GetFilteredList(model);
|
||||
}
|
||||
}
|
||||
}
|
66
EmployeeLogic/BusinessLogics/PostLogic.cs
Normal file
66
EmployeeLogic/BusinessLogics/PostLogic.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using EmployeesContracts.BindingModels;
|
||||
using EmployeesContracts.BusinessLogicsContracts;
|
||||
using EmployeesContracts.StorageContracts;
|
||||
using EmployeesContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EmployeeLogic.BusinessLogics
|
||||
{
|
||||
public class PostLogic : IPostLogic
|
||||
{
|
||||
private readonly IPostStorage _postStorage;
|
||||
|
||||
public PostLogic(IPostStorage postStorage)
|
||||
{
|
||||
_postStorage = postStorage;
|
||||
}
|
||||
|
||||
public void CreateOrUpdate(PostBindingModel model)
|
||||
{
|
||||
var element = _postStorage.GetElement(
|
||||
new PostBindingModel
|
||||
{
|
||||
Name = model.Name
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new Exception("Такая должность уже существует");
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_postStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_postStorage.Insert(model);
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(PostBindingModel model)
|
||||
{
|
||||
var element = _postStorage.GetElement(new PostBindingModel { Id = model.Id });
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Должность не найдена");
|
||||
}
|
||||
_postStorage.Delete(model);
|
||||
}
|
||||
|
||||
public List<PostViewModel> Read(PostBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return _postStorage.GetFullList();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<PostViewModel> { _postStorage.GetElement(model) };
|
||||
}
|
||||
return _postStorage.GetFilteredList(model);
|
||||
}
|
||||
}
|
||||
}
|
14
EmployeeLogic/EmployeeLogic.csproj
Normal file
14
EmployeeLogic/EmployeeLogic.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EmployeesContracts\EmployeesContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
21
EmployeesContracts/BindingModels/EmployeeBindingModel.cs
Normal file
21
EmployeesContracts/BindingModels/EmployeeBindingModel.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EmployeesContracts.BindingModels
|
||||
{
|
||||
public class EmployeeBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Autobiography { get; set; }
|
||||
|
||||
public string Post { get; set; }
|
||||
|
||||
public DateTime? Upgrade { get; set; }
|
||||
}
|
||||
}
|
15
EmployeesContracts/BindingModels/PostBindingModel.cs
Normal file
15
EmployeesContracts/BindingModels/PostBindingModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EmployeesContracts.BindingModels
|
||||
{
|
||||
public class PostBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
17
EmployeesContracts/BusinessLogicsContracts/IEmployeeLogic.cs
Normal file
17
EmployeesContracts/BusinessLogicsContracts/IEmployeeLogic.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using EmployeesContracts.BindingModels;
|
||||
using EmployeesContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EmployeesContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IEmployeeLogic
|
||||
{
|
||||
List<EmployeeViewModel> Read(EmployeeBindingModel model);
|
||||
void CreateOrUpdate(EmployeeBindingModel model);
|
||||
void Delete(EmployeeBindingModel model);
|
||||
}
|
||||
}
|
17
EmployeesContracts/BusinessLogicsContracts/IPostLogic.cs
Normal file
17
EmployeesContracts/BusinessLogicsContracts/IPostLogic.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using EmployeesContracts.BindingModels;
|
||||
using EmployeesContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EmployeesContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IPostLogic
|
||||
{
|
||||
List<PostViewModel> Read(PostBindingModel model);
|
||||
void CreateOrUpdate(PostBindingModel model);
|
||||
void Delete(PostBindingModel model);
|
||||
}
|
||||
}
|
14
EmployeesContracts/EmployeesContracts.csproj
Normal file
14
EmployeesContracts/EmployeesContracts.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\COP_7\Components.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
21
EmployeesContracts/StorageContracts/IEmployeeStorage.cs
Normal file
21
EmployeesContracts/StorageContracts/IEmployeeStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using EmployeesContracts.BindingModels;
|
||||
using EmployeesContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EmployeesContracts.StorageContracts
|
||||
{
|
||||
public interface IEmployeeStorage
|
||||
{
|
||||
List<EmployeeViewModel> GetFullList();
|
||||
List<EmployeeViewModel> GetFilteredList(EmployeeBindingModel model);
|
||||
EmployeeViewModel GetElement(EmployeeBindingModel model);
|
||||
|
||||
void Insert(EmployeeBindingModel model);
|
||||
void Update(EmployeeBindingModel model);
|
||||
void Delete(EmployeeBindingModel model);
|
||||
}
|
||||
}
|
21
EmployeesContracts/StorageContracts/IPostStorage.cs
Normal file
21
EmployeesContracts/StorageContracts/IPostStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using EmployeesContracts.BindingModels;
|
||||
using EmployeesContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EmployeesContracts.StorageContracts
|
||||
{
|
||||
public interface IPostStorage
|
||||
{
|
||||
List<PostViewModel> GetFullList();
|
||||
List<PostViewModel> GetFilteredList(PostBindingModel model);
|
||||
PostViewModel GetElement(PostBindingModel model);
|
||||
|
||||
void Insert(PostBindingModel model);
|
||||
void Update(PostBindingModel model);
|
||||
void Delete(PostBindingModel model);
|
||||
}
|
||||
}
|
24
EmployeesContracts/ViewModels/EmployeeViewModel.cs
Normal file
24
EmployeesContracts/ViewModels/EmployeeViewModel.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EmployeesContracts.ViewModels
|
||||
{
|
||||
public class EmployeeViewModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
[DisplayName("Название")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DisplayName("Автобиография")]
|
||||
public string Autobiography { get; set; }
|
||||
[DisplayName("Должность")]
|
||||
public string Post { get; set; }
|
||||
[DisplayName("Дата повышения квалификации")]
|
||||
public DateTime? Upgrade { get; set; }
|
||||
}
|
||||
}
|
15
EmployeesContracts/ViewModels/PostViewModel.cs
Normal file
15
EmployeesContracts/ViewModels/PostViewModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EmployeesContracts.ViewModels
|
||||
{
|
||||
public class PostViewModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
21
EmployeesDatabaseImplement/EmployeesDatabase.cs
Normal file
21
EmployeesDatabaseImplement/EmployeesDatabase.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using EmployeesDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EmployeesDatabaseImplement
|
||||
{
|
||||
public class EmployeesDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-6QDRI0N\SQLEXPRESS;Initial Catalog=DatabaseEmployees;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
||||
public virtual DbSet<Employee> Employees { set; get; }
|
||||
|
||||
public virtual DbSet<Post> Posts { set; get; }
|
||||
}
|
||||
}
|
27
EmployeesDatabaseImplement/EmployeesDatabaseImplement.csproj
Normal file
27
EmployeesDatabaseImplement/EmployeesDatabaseImplement.csproj
Normal file
@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.11" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.11" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.11">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EmployeesContracts\EmployeesContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
125
EmployeesDatabaseImplement/Implements/EmployeeStorage.cs
Normal file
125
EmployeesDatabaseImplement/Implements/EmployeeStorage.cs
Normal file
@ -0,0 +1,125 @@
|
||||
using EmployeesContracts.BindingModels;
|
||||
using EmployeesContracts.StorageContracts;
|
||||
using EmployeesContracts.ViewModels;
|
||||
using EmployeesDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EmployeesDatabaseImplement.Implements
|
||||
{
|
||||
public class EmployeeStorage : IEmployeeStorage
|
||||
{
|
||||
public void Delete(EmployeeBindingModel model)
|
||||
{
|
||||
var context = new EmployeesDatabase();
|
||||
var employee = context.Employees.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (employee != null)
|
||||
{
|
||||
context.Employees.Remove(employee);
|
||||
context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Сотрудник не найден");
|
||||
}
|
||||
}
|
||||
|
||||
public EmployeeViewModel GetElement(EmployeeBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new EmployeesDatabase();
|
||||
var employee = context.Employees
|
||||
.ToList()
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
return employee != null ? CreateModel(employee) : null;
|
||||
}
|
||||
|
||||
public List<EmployeeViewModel> GetFilteredList(EmployeeBindingModel model)
|
||||
{
|
||||
var context = new EmployeesDatabase();
|
||||
return context.Employees
|
||||
.Where(employee => employee.Name.Contains(model.Name) && employee.Post.Contains(model.Post))
|
||||
.ToList()
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<EmployeeViewModel> GetFullList()
|
||||
{
|
||||
using (var context = new EmployeesDatabase())
|
||||
{
|
||||
return context.Employees
|
||||
.ToList()
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public void Insert(EmployeeBindingModel model)
|
||||
{
|
||||
var context = new EmployeesDatabase();
|
||||
var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
context.Employees.Add(CreateModel(model, new Employee()));
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(EmployeeBindingModel model)
|
||||
{
|
||||
var context = new EmployeesDatabase();
|
||||
var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var employee = context.Employees.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (employee == null)
|
||||
{
|
||||
throw new Exception("Сотрудник не найден");
|
||||
}
|
||||
CreateModel(model, employee);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private static Employee CreateModel(EmployeeBindingModel model, Employee employee)
|
||||
{
|
||||
employee.Upgrade = model.Upgrade;
|
||||
employee.Name = model.Name;
|
||||
employee.Post = model.Post;
|
||||
employee.Autobiography = model.Autobiography;
|
||||
|
||||
return employee;
|
||||
}
|
||||
|
||||
private EmployeeViewModel CreateModel(Employee employee)
|
||||
{
|
||||
return new EmployeeViewModel
|
||||
{
|
||||
Id = employee.Id,
|
||||
Upgrade = employee.Upgrade,
|
||||
Name = employee.Name,
|
||||
Post = employee.Post,
|
||||
Autobiography = employee.Autobiography
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
120
EmployeesDatabaseImplement/Implements/PostStorage.cs
Normal file
120
EmployeesDatabaseImplement/Implements/PostStorage.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using EmployeesContracts.BindingModels;
|
||||
using EmployeesContracts.StorageContracts;
|
||||
using EmployeesContracts.ViewModels;
|
||||
using EmployeesDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EmployeesDatabaseImplement.Implements
|
||||
{
|
||||
public class PostStorage : IPostStorage
|
||||
{
|
||||
public void Delete(PostBindingModel model)
|
||||
{
|
||||
var context = new EmployeesDatabase();
|
||||
var post = context.Posts.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (post != null)
|
||||
{
|
||||
context.Posts.Remove(post);
|
||||
context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Должность не найдена");
|
||||
}
|
||||
}
|
||||
|
||||
public PostViewModel GetElement(PostBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new EmployeesDatabase();
|
||||
|
||||
var post = context.Posts
|
||||
.ToList()
|
||||
.FirstOrDefault(rec => rec.Id == model.Id || rec.Name == model.Name);
|
||||
return post != null ? CreateModel(post) : null;
|
||||
}
|
||||
|
||||
|
||||
public List<PostViewModel> GetFilteredList(PostBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new EmployeesDatabase();
|
||||
return context.Posts
|
||||
.Where(rec => rec.Name.Contains(model.Name))
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<PostViewModel> GetFullList()
|
||||
{
|
||||
using var context = new EmployeesDatabase();
|
||||
return context.Posts
|
||||
.Select(CreateModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public void Insert(PostBindingModel model)
|
||||
{
|
||||
var context = new EmployeesDatabase();
|
||||
var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
context.Posts.Add(CreateModel(model, new Post()));
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(PostBindingModel model)
|
||||
{
|
||||
var context = new EmployeesDatabase();
|
||||
var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var post = context.Posts.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (post == null)
|
||||
{
|
||||
throw new Exception("Должность не найдена");
|
||||
}
|
||||
CreateModel(model, post);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private static Post CreateModel(PostBindingModel model, Post post)
|
||||
{
|
||||
post.Name = model.Name;
|
||||
return post;
|
||||
}
|
||||
|
||||
private static PostViewModel CreateModel(Post post)
|
||||
{
|
||||
return new PostViewModel
|
||||
{
|
||||
Id = post.Id,
|
||||
Name = post.Name
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
75
EmployeesDatabaseImplement/Migrations/20241028190655_Initial.Designer.cs
generated
Normal file
75
EmployeesDatabaseImplement/Migrations/20241028190655_Initial.Designer.cs
generated
Normal file
@ -0,0 +1,75 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using EmployeesDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EmployeesDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(EmployeesDatabase))]
|
||||
[Migration("20241028190655_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.11")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("EmployeesDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Autobiography")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Post")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime?>("Upgrade")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EmployeesDatabaseImplement.Models.Post", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Posts");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EmployeesDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Employees",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Autobiography = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Post = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Upgrade = table.Column<DateTime>(type: "datetime2", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Employees", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Posts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Posts", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Employees");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Posts");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using EmployeesDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace EmployeesDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(EmployeesDatabase))]
|
||||
partial class EmployeesDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.11")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("EmployeesDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Autobiography")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Post")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime?>("Upgrade")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("EmployeesDatabaseImplement.Models.Post", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Posts");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
25
EmployeesDatabaseImplement/Models/Employee.cs
Normal file
25
EmployeesDatabaseImplement/Models/Employee.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EmployeesDatabaseImplement.Models
|
||||
{
|
||||
public class Employee
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Autobiography { get; set; }
|
||||
[Required]
|
||||
public string Post { get; set; }
|
||||
|
||||
public DateTime? Upgrade { get; set; }
|
||||
|
||||
}
|
||||
}
|
17
EmployeesDatabaseImplement/Models/Post.cs
Normal file
17
EmployeesDatabaseImplement/Models/Post.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EmployeesDatabaseImplement.Models
|
||||
{
|
||||
public class Post
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
29
EmployeesView/EmployeesView.csproj
Normal file
29
EmployeesView/EmployeesView.csproj
Normal file
@ -0,0 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
|
||||
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.11" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.11">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.11" />
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
<PackageReference Include="WinFormsLibrary1" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EmployeeLogic\EmployeeLogic.csproj" />
|
||||
<ProjectReference Include="..\EmployeesDatabaseImplement\EmployeesDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
197
EmployeesView/FormEmployee.Designer.cs
generated
Normal file
197
EmployeesView/FormEmployee.Designer.cs
generated
Normal file
@ -0,0 +1,197 @@
|
||||
namespace EmployeesView
|
||||
{
|
||||
partial class FormEmployee
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.LabelFIO = new System.Windows.Forms.Label();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.dropDownList = new Components.DropDownList();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.textBoxAutobiography = new System.Windows.Forms.TextBox();
|
||||
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.checkBox = new System.Windows.Forms.CheckBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// LabelFIO
|
||||
//
|
||||
this.LabelFIO.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.LabelFIO.AutoSize = true;
|
||||
this.LabelFIO.Location = new System.Drawing.Point(13, 10);
|
||||
this.LabelFIO.Name = "LabelFIO";
|
||||
this.LabelFIO.Size = new System.Drawing.Size(34, 15);
|
||||
this.LabelFIO.TabIndex = 0;
|
||||
this.LabelFIO.Text = "ФИО";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textBoxName.Location = new System.Drawing.Point(13, 31);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(374, 23);
|
||||
this.textBoxName.TabIndex = 1;
|
||||
//
|
||||
// dropDownList
|
||||
//
|
||||
this.dropDownList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.dropDownList.Location = new System.Drawing.Point(12, 81);
|
||||
this.dropDownList.Name = "dropDownList";
|
||||
this.dropDownList.SelectedItem = "";
|
||||
this.dropDownList.Size = new System.Drawing.Size(374, 29);
|
||||
this.dropDownList.TabIndex = 2;
|
||||
this.dropDownList.Load += new System.EventHandler(this.FormEmployee_Load);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 61);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(69, 15);
|
||||
this.label1.TabIndex = 3;
|
||||
this.label1.Text = "Должность";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(13, 111);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(94, 15);
|
||||
this.label2.TabIndex = 4;
|
||||
this.label2.Text = "Автобиография";
|
||||
//
|
||||
// textBoxAutobiography
|
||||
//
|
||||
this.textBoxAutobiography.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textBoxAutobiography.Location = new System.Drawing.Point(13, 131);
|
||||
this.textBoxAutobiography.Name = "textBoxAutobiography";
|
||||
this.textBoxAutobiography.Size = new System.Drawing.Size(374, 23);
|
||||
this.textBoxAutobiography.TabIndex = 5;
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
this.dateTimePicker.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.dateTimePicker.Location = new System.Drawing.Point(13, 179);
|
||||
this.dateTimePicker.Name = "dateTimePicker";
|
||||
this.dateTimePicker.Size = new System.Drawing.Size(374, 23);
|
||||
this.dateTimePicker.TabIndex = 6;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(13, 159);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(185, 15);
|
||||
this.label3.TabIndex = 7;
|
||||
this.label3.Text = "Дата повышения квалификаций";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonSave.Location = new System.Drawing.Point(12, 233);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(373, 23);
|
||||
this.buttonSave.TabIndex = 8;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonCancel.Location = new System.Drawing.Point(12, 262);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(373, 23);
|
||||
this.buttonCancel.TabIndex = 9;
|
||||
this.buttonCancel.Text = "Отменить";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// checkBox
|
||||
//
|
||||
this.checkBox.AutoSize = true;
|
||||
this.checkBox.Location = new System.Drawing.Point(13, 208);
|
||||
this.checkBox.Name = "checkBox";
|
||||
this.checkBox.Size = new System.Drawing.Size(179, 19);
|
||||
this.checkBox.TabIndex = 10;
|
||||
this.checkBox.Text = "Квалификация не пройдена";
|
||||
this.checkBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormEmployee
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(399, 299);
|
||||
this.Controls.Add(this.checkBox);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.dateTimePicker);
|
||||
this.Controls.Add(this.textBoxAutobiography);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.dropDownList);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.LabelFIO);
|
||||
this.Name = "FormEmployee";
|
||||
this.Text = "FormEmployee";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label LabelFIO;
|
||||
private TextBox textBoxName;
|
||||
private Components.DropDownList dropDownList;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private TextBox textBoxAutobiography;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private Label label3;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private CheckBox checkBox;
|
||||
}
|
||||
}
|
119
EmployeesView/FormEmployee.cs
Normal file
119
EmployeesView/FormEmployee.cs
Normal file
@ -0,0 +1,119 @@
|
||||
using EmployeesContracts.BindingModels;
|
||||
using EmployeesContracts.BusinessLogicsContracts;
|
||||
using EmployeesContracts.ViewModels;
|
||||
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 EmployeesView
|
||||
{
|
||||
public partial class FormEmployee : Form
|
||||
{
|
||||
public int Id { set { id = value; } }
|
||||
|
||||
private readonly IEmployeeLogic _logic;
|
||||
private readonly IPostLogic _logicS;
|
||||
|
||||
private int? id;
|
||||
|
||||
public FormEmployee(IEmployeeLogic logic, IPostLogic logicS)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
_logicS = logicS;
|
||||
}
|
||||
|
||||
private void FormEmployee_Load(object sender, EventArgs e)
|
||||
{
|
||||
List<PostViewModel> viewS = _logicS.Read(null);
|
||||
if (viewS != null)
|
||||
{
|
||||
foreach (PostViewModel s in viewS)
|
||||
{
|
||||
dropDownList.ComboBoxItems.Add(s.Name);
|
||||
}
|
||||
}
|
||||
if (id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
EmployeeViewModel view = _logic.Read(new EmployeeBindingModel { Id = id.Value })?[0];
|
||||
if (view != null)
|
||||
{
|
||||
textBoxAutobiography.Text = view.Autobiography;
|
||||
textBoxName.Text = view.Name;
|
||||
dropDownList.SelectedItem = view.Post;
|
||||
if (view.Upgrade != null)
|
||||
{
|
||||
dateTimePicker.Value = (DateTime)view.Upgrade;
|
||||
}
|
||||
else
|
||||
{
|
||||
dateTimePicker.Value = DateTime.Now;
|
||||
checkBox.Checked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(dropDownList.SelectedItem))
|
||||
{
|
||||
MessageBox.Show("Выберите должность", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (textBoxAutobiography.Text == null)
|
||||
{
|
||||
MessageBox.Show("Заполните автобиографию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
DateTime? upgrade = dateTimePicker.Value;
|
||||
if (checkBox.Checked == true)
|
||||
{
|
||||
upgrade = null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_logic.CreateOrUpdate(new EmployeeBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Autobiography = textBoxAutobiography.Text,
|
||||
Name = textBoxName.Text,
|
||||
Post = dropDownList.SelectedItem,
|
||||
Upgrade = upgrade
|
||||
});
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
EmployeesView/FormEmployee.resx
Normal file
60
EmployeesView/FormEmployee.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
193
EmployeesView/FormMain.Designer.cs
generated
Normal file
193
EmployeesView/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,193 @@
|
||||
using ComponentsLibraryNet60.DocumentWithChart;
|
||||
|
||||
namespace EmployeesView
|
||||
{
|
||||
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()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.действияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.добавитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.изменитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.удалитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.документыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.документВPDFToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.отчетВEXCELToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.диаграммаВWordToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.должностьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.controlDataTreeCell = new ControlsLibraryNet60.Data.ControlDataTreeCell();
|
||||
this.componentTextToPDF = new Components.TextToPDF();
|
||||
this.excelWithCustomTable = new WinFormsLibrary1.ExcelWithCustomTable(this.components);
|
||||
this.componentDocumentWithChartPieWord = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieWord(components);
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.действияToolStripMenuItem,
|
||||
this.документыToolStripMenuItem,
|
||||
this.справочникиToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(800, 24);
|
||||
this.menuStrip1.TabIndex = 0;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// действия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(70, 20);
|
||||
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(180, 22);
|
||||
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(180, 22);
|
||||
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(180, 22);
|
||||
this.удалитьToolStripMenuItem.Text = "Удалить";
|
||||
this.удалитьToolStripMenuItem.Click += new System.EventHandler(this.удалитьToolStripMenuItem_Click);
|
||||
//
|
||||
// документыToolStripMenuItem
|
||||
//
|
||||
this.документыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.документВPDFToolStripMenuItem,
|
||||
this.отчетВEXCELToolStripMenuItem,
|
||||
this.диаграммаВWordToolStripMenuItem});
|
||||
this.документыToolStripMenuItem.Name = "документыToolStripMenuItem";
|
||||
this.документыToolStripMenuItem.Size = new System.Drawing.Size(82, 20);
|
||||
this.документыToolStripMenuItem.Text = "Документы";
|
||||
//
|
||||
// документВPDFToolStripMenuItem
|
||||
//
|
||||
this.документВPDFToolStripMenuItem.Name = "документВPDFToolStripMenuItem";
|
||||
this.документВPDFToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||
this.документВPDFToolStripMenuItem.Size = new System.Drawing.Size(220, 22);
|
||||
this.документВPDFToolStripMenuItem.Text = "Документ в PDF";
|
||||
this.документВPDFToolStripMenuItem.Click += new System.EventHandler(this.документВPDFToolStripMenuItem_Click);
|
||||
//
|
||||
// отчетВEXCELToolStripMenuItem
|
||||
//
|
||||
this.отчетВEXCELToolStripMenuItem.Name = "отчетВEXCELToolStripMenuItem";
|
||||
this.отчетВEXCELToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T)));
|
||||
this.отчетВEXCELToolStripMenuItem.Size = new System.Drawing.Size(220, 22);
|
||||
this.отчетВEXCELToolStripMenuItem.Text = "Отчет в Excel";
|
||||
this.отчетВEXCELToolStripMenuItem.Click += new System.EventHandler(this.отчетВEXCELToolStripMenuItem_Click);
|
||||
//
|
||||
// диаграммаВWordToolStripMenuItem
|
||||
//
|
||||
this.диаграммаВWordToolStripMenuItem.Name = "диаграммаВWordToolStripMenuItem";
|
||||
this.диаграммаВWordToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
|
||||
this.диаграммаВWordToolStripMenuItem.Size = new System.Drawing.Size(220, 22);
|
||||
this.диаграммаВWordToolStripMenuItem.Text = "Диаграмма в Word";
|
||||
this.диаграммаВWordToolStripMenuItem.Click += new System.EventHandler(this.диаграммаВWordToolStripMenuItem_Click);
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.должностьToolStripMenuItem});
|
||||
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
||||
this.справочникиToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// должностьToolStripMenuItem
|
||||
//
|
||||
this.должностьToolStripMenuItem.Name = "должностьToolStripMenuItem";
|
||||
this.должностьToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.должностьToolStripMenuItem.Text = "Должность";
|
||||
this.должностьToolStripMenuItem.Click += new System.EventHandler(this.должностьToolStripMenuItem_Click);
|
||||
//
|
||||
// controlDataTreeCell
|
||||
//
|
||||
this.controlDataTreeCell.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.controlDataTreeCell.Location = new System.Drawing.Point(12, 27);
|
||||
this.controlDataTreeCell.Name = "controlDataTreeCell";
|
||||
this.controlDataTreeCell.Size = new System.Drawing.Size(776, 411);
|
||||
this.controlDataTreeCell.TabIndex = 1;
|
||||
this.controlDataTreeCell.Load += new System.EventHandler(this.FormMain_Load);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.controlDataTreeCell);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "FormMain";
|
||||
this.Text = "FormMain";
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem действияToolStripMenuItem;
|
||||
private ToolStripMenuItem добавитьToolStripMenuItem;
|
||||
private ToolStripMenuItem изменитьToolStripMenuItem;
|
||||
private ToolStripMenuItem удалитьToolStripMenuItem;
|
||||
private ToolStripMenuItem документыToolStripMenuItem;
|
||||
private ToolStripMenuItem документВPDFToolStripMenuItem;
|
||||
private ToolStripMenuItem отчетВEXCELToolStripMenuItem;
|
||||
private ToolStripMenuItem диаграммаВWordToolStripMenuItem;
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem должностьToolStripMenuItem;
|
||||
private ControlsLibraryNet60.Data.ControlDataTreeCell controlDataTreeCell;
|
||||
private Components.TextToPDF componentTextToPDF;
|
||||
private WinFormsLibrary1.ExcelWithCustomTable excelWithCustomTable;
|
||||
private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieWord componentDocumentWithChartPieWord;
|
||||
}
|
||||
}
|
260
EmployeesView/FormMain.cs
Normal file
260
EmployeesView/FormMain.cs
Normal file
@ -0,0 +1,260 @@
|
||||
using WinFormsLibrary1.Models;
|
||||
using ComponentsLibraryNet60.Models;
|
||||
using ControlsLibraryNet60.Models;
|
||||
using EmployeesContracts.BindingModels;
|
||||
using EmployeesContracts.BusinessLogicsContracts;
|
||||
using EmployeesContracts.ViewModels;
|
||||
using EmployeesDatabaseImplement.Models;
|
||||
using Components;
|
||||
using COP_7.Components.Models;
|
||||
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 Unity;
|
||||
using ComponentsLibraryNet60.DocumentWithChart;
|
||||
|
||||
namespace EmployeesView
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly IEmployeeLogic _employeeLogic;
|
||||
private readonly IPostLogic _postLogic;
|
||||
|
||||
public FormMain(IEmployeeLogic employeeLogic, IPostLogic postLogic)
|
||||
{
|
||||
_employeeLogic = employeeLogic;
|
||||
_postLogic = postLogic;
|
||||
InitializeComponent();
|
||||
|
||||
var nodeNames = new Queue<string>();
|
||||
nodeNames.Enqueue("Post");
|
||||
nodeNames.Enqueue("Id");
|
||||
nodeNames.Enqueue("Upgrade");
|
||||
nodeNames.Enqueue("Name");
|
||||
var treeConfig = new DataTreeNodeConfig { NodeNames = nodeNames };
|
||||
|
||||
|
||||
controlDataTreeCell.LoadConfig(treeConfig);
|
||||
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
controlDataTreeCell.Clear();
|
||||
var list = _employeeLogic.Read(null);
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var book in list)
|
||||
{
|
||||
controlDataTreeCell.AddCell<EmployeeViewModel>(3, book);
|
||||
}
|
||||
controlDataTreeCell.Update();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddNewElement()
|
||||
{
|
||||
var form = Program.Container.Resolve<FormEmployee>();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateElement()
|
||||
{
|
||||
var form = Program.Container.Resolve<FormEmployee>();
|
||||
var selectedEmployee = controlDataTreeCell.GetSelectedObject<Employee>();
|
||||
if (selectedEmployee != null)
|
||||
{
|
||||
form.Id = Convert.ToInt32(selectedEmployee.Id);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Обработка ситуации, когда объект Employee не выбран
|
||||
MessageBox.Show("Выберите сотрудника для редактирования");
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteElement()
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(controlDataTreeCell.GetSelectedObject<Employee>().Id);
|
||||
try
|
||||
{
|
||||
_employeeLogic.Delete(new EmployeeBindingModel { Id = id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateWord()
|
||||
{
|
||||
string fileName = "";
|
||||
using (var dialog = new SaveFileDialog { Filter = "docx|*.docx" })
|
||||
{
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = dialog.FileName.ToString();
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
var positions = _postLogic.Read(null).Select(p => p.Name).ToList();
|
||||
var employees = _employeeLogic.Read(null);
|
||||
var employeeCounts = positions.Select(p =>
|
||||
{
|
||||
int count = employees.Count(e => e.Post != p && e.Upgrade == null);
|
||||
return (Date: p, Value: count);
|
||||
}).ToList();
|
||||
|
||||
// Преобразуем список в нужный формат
|
||||
var list2D = new Dictionary<string, List<(int Date, double Value)>>()
|
||||
{
|
||||
{ "Не прошедшие повышение", employeeCounts.Select(x => (Date: int.Parse(x.Date), Value: (double)x.Value)).ToList() }
|
||||
};
|
||||
|
||||
componentDocumentWithChartPieWord.CreateDoc(new ComponentDocumentWithChartConfig
|
||||
{
|
||||
FilePath = fileName,
|
||||
Header = "Диаграмма",
|
||||
ChartTitle = "Круговая диаграмма",
|
||||
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
|
||||
Data = list2D
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void CreateExcel()
|
||||
{
|
||||
string fileName = "";
|
||||
using (var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" })
|
||||
{
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = dialog.FileName.ToString();
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
var employees = _employeeLogic.Read(null);
|
||||
string FilePatht = fileName;
|
||||
string Headert = "Заголовое";
|
||||
List<(int Column, int Row)>? ColumnsRowsWidtht = new() { (5, 5), (10, 5), (10, 0), (5, 0), (7, 0) };
|
||||
List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>? Headerst = new()
|
||||
{
|
||||
(0, 0, "Id", "Id"),
|
||||
(1, 0, "Имя", "Name"),
|
||||
(2, 0, "Описание", "Post"),
|
||||
(3, 0, "Категория", "Upgrade"),
|
||||
(4, 0, "Автобиография", "Autobiography")
|
||||
};
|
||||
List<EmployeeViewModel>? Datat = employees;
|
||||
excelWithCustomTable.CreateDoc(new TableWithHeaderConfig<EmployeeViewModel>
|
||||
{
|
||||
FilePath = FilePatht,
|
||||
Header = Headert,
|
||||
ColumnsRowsWidth = ColumnsRowsWidtht,
|
||||
Headers = Headerst,
|
||||
Data = Datat,
|
||||
NullReplace = "не проходил"
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void CreatePdf()
|
||||
{
|
||||
string fileName = "";
|
||||
using (var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" })
|
||||
{
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
fileName = dialog.FileName.ToString();
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
List<string> tables = new List<string>();
|
||||
var list = _employeeLogic.Read(null);
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var employee in list)
|
||||
{
|
||||
if (employee.Upgrade != null)
|
||||
{
|
||||
string row = $"ФИО: {employee.Name} Автобиография: {employee.Autobiography}";
|
||||
tables.Add(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Используем метод CreateDocument из TextToPDF
|
||||
var textToPDF = new TextToPDF();
|
||||
textToPDF.CreateDocument(fileName, "Формировать документ в Pdf по сотрудникам, проходившим квалификацию (в каждой строке текст с информацией: ФИО и автобиография)", tables.ToArray());
|
||||
}
|
||||
|
||||
private void добавитьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddNewElement();
|
||||
}
|
||||
|
||||
private void должностьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = Program.Container.Resolve<FormPost>();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
private void изменитьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
UpdateElement();
|
||||
}
|
||||
|
||||
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
DeleteElement();
|
||||
}
|
||||
|
||||
private void документВPDFToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreatePdf();
|
||||
}
|
||||
|
||||
private void отчетВEXCELToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateExcel();
|
||||
}
|
||||
|
||||
private void диаграммаВWordToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateWord();
|
||||
}
|
||||
}
|
||||
}
|
72
EmployeesView/FormMain.resx
Normal file
72
EmployeesView/FormMain.resx
Normal file
@ -0,0 +1,72 @@
|
||||
<root>
|
||||
<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>
|
||||
<metadata name="componentTextToPDF.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>132, 17</value>
|
||||
</metadata>
|
||||
<metadata name="excelWithCustomTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>301, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordWithDiagram.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>477, 17</value>
|
||||
</metadata>
|
||||
</root>
|
67
EmployeesView/FormPost.Designer.cs
generated
Normal file
67
EmployeesView/FormPost.Designer.cs
generated
Normal file
@ -0,0 +1,67 @@
|
||||
namespace EmployeesView
|
||||
{
|
||||
partial class FormPost
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(236, 217);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
this.dataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellEndEdit);
|
||||
this.dataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridView_KeyDown);
|
||||
//
|
||||
// FormPost
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(260, 241);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormPost";
|
||||
this.Text = "FormPost";
|
||||
this.Load += new System.EventHandler(this.FormPost_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
117
EmployeesView/FormPost.cs
Normal file
117
EmployeesView/FormPost.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using EmployeesContracts.BindingModels;
|
||||
using EmployeesContracts.BusinessLogicsContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace EmployeesView
|
||||
{
|
||||
public partial class FormPost : Form
|
||||
{
|
||||
private readonly IPostLogic postLogic;
|
||||
BindingList<PostBindingModel> list;
|
||||
public FormPost(IPostLogic _postLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
postLogic = _postLogic;
|
||||
list = new BindingList<PostBindingModel>();
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list1 = postLogic.Read(null);
|
||||
list.Clear();
|
||||
foreach (var item in list1)
|
||||
{
|
||||
list.Add(new PostBindingModel
|
||||
{
|
||||
Id = item.Id,
|
||||
Name = item.Name,
|
||||
});
|
||||
}
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns[0].Visible = false;
|
||||
dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void FormPost_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
var typeName = (string)dataGridView.CurrentRow.Cells[1].Value;
|
||||
if (!string.IsNullOrEmpty(typeName))
|
||||
{
|
||||
if (dataGridView.CurrentRow.Cells[0].Value != null)
|
||||
{
|
||||
postLogic.CreateOrUpdate(new PostBindingModel()
|
||||
{
|
||||
Id = Convert.ToInt32(dataGridView.CurrentRow.Cells[0].Value),
|
||||
Name = (string)dataGridView.CurrentRow.Cells[1].EditedFormattedValue
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
postLogic.CreateOrUpdate(new PostBindingModel()
|
||||
{
|
||||
Name = (string)dataGridView.CurrentRow.Cells[1].EditedFormattedValue
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Введена пустая строка", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyData == Keys.Insert)
|
||||
{
|
||||
if (dataGridView.Rows.Count == 0)
|
||||
{
|
||||
list.Add(new PostBindingModel());
|
||||
dataGridView.DataSource = new BindingList<PostBindingModel>(list);
|
||||
dataGridView.CurrentCell = dataGridView.Rows[0].Cells[1];
|
||||
return;
|
||||
}
|
||||
if (dataGridView.Rows[dataGridView.Rows.Count - 1].Cells[1].Value != null)
|
||||
{
|
||||
list.Add(new PostBindingModel());
|
||||
dataGridView.DataSource = new BindingList<PostBindingModel>(list);
|
||||
dataGridView.CurrentCell = dataGridView.Rows[dataGridView.Rows.Count - 1].Cells[1];
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (e.KeyData == Keys.Delete)
|
||||
{
|
||||
if (MessageBox.Show("Удалить выбранный элемент", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
postLogic.Delete(new PostBindingModel() { Id = (int)dataGridView.CurrentRow.Cells[0].Value });
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
EmployeesView/FormPost.resx
Normal file
60
EmployeesView/FormPost.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
39
EmployeesView/Program.cs
Normal file
39
EmployeesView/Program.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using EmployeesContracts.BusinessLogicsContracts;
|
||||
using EmployeesContracts.StorageContracts;
|
||||
using EmployeesDatabaseImplement.Implements;
|
||||
using Unity;
|
||||
using Unity.Lifetime;
|
||||
|
||||
namespace EmployeesView
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static IUnityContainer container = null;
|
||||
public static IUnityContainer Container { get { if (container == null) { container = BuildUnityContainer(); } return container; } }
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(Container.Resolve<FormMain>());
|
||||
}
|
||||
|
||||
private static IUnityContainer BuildUnityContainer()
|
||||
{
|
||||
var currentContainer = new UnityContainer();
|
||||
|
||||
currentContainer.RegisterType<IEmployeeStorage, EmployeeStorage>(new HierarchicalLifetimeManager());
|
||||
currentContainer.RegisterType<IPostStorage, PostStorage>(new HierarchicalLifetimeManager());
|
||||
|
||||
currentContainer.RegisterType<IEmployeeLogic, EmployeeLogic.BusinessLogics.EmployeeLogic>(new HierarchicalLifetimeManager());
|
||||
currentContainer.RegisterType<IPostLogic, EmployeeLogic.BusinessLogics.PostLogic>(new HierarchicalLifetimeManager());
|
||||
|
||||
return currentContainer;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user