Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9a7d832f3 | ||
|
|
424ef89446 | ||
|
|
b98ed5c3af | ||
|
|
60f5141fe7 | ||
|
|
a887e43aba | ||
|
|
a29a9928ea | ||
|
|
af6c379c97 |
54
KOP/EnterpriseBusinessLogic/BusinessLogics/EmployeeLogic.cs
Normal file
54
KOP/EnterpriseBusinessLogic/BusinessLogics/EmployeeLogic.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
using EnterpriseContracts.BindingModels;
|
||||||
|
using EnterpriseContracts.BusinessLogicContracts;
|
||||||
|
using EnterpriseContracts.StorageContracts;
|
||||||
|
using EnterpriseContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace EnterpriseBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class EmployeeLogic : IEmployeeLogic
|
||||||
|
{
|
||||||
|
private readonly IEmployeeStorage _empStorage;
|
||||||
|
|
||||||
|
public EmployeeLogic(IEmployeeStorage empStorage)
|
||||||
|
{
|
||||||
|
_empStorage = empStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EmployeeViewModel> Read(EmployeeBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return _empStorage.GetFullList();
|
||||||
|
}
|
||||||
|
return model.Id.HasValue
|
||||||
|
? new List<EmployeeViewModel> { _empStorage.GetElement(model) }
|
||||||
|
: _empStorage.GetFilteredList(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateOrUpdate(EmployeeBindingModel model)
|
||||||
|
{
|
||||||
|
var element = _empStorage.GetElement(new EmployeeBindingModel
|
||||||
|
{
|
||||||
|
Id = model.Id
|
||||||
|
});
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
_empStorage.Update(model);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_empStorage.Insert(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(EmployeeBindingModel model)
|
||||||
|
{
|
||||||
|
var element = _empStorage.GetElement(new EmployeeBindingModel { Id = model.Id });
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Id don't exists");
|
||||||
|
}
|
||||||
|
_empStorage.Delete(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
using EnterpriseContracts.BindingModels;
|
||||||
|
using EnterpriseContracts.BusinessLogicContracts;
|
||||||
|
using EnterpriseContracts.StorageContracts;
|
||||||
|
using EnterpriseContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace EnterpriseBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class SubdivisionLogic : ISubdivisionLogic
|
||||||
|
{
|
||||||
|
private readonly ISubdivisionStorage _subdivisionStorage;
|
||||||
|
|
||||||
|
public SubdivisionLogic(ISubdivisionStorage subdivisionStorage)
|
||||||
|
{
|
||||||
|
_subdivisionStorage = subdivisionStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SubdivisionViewModel> Read(SubdivisionBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return _subdivisionStorage.GetFullList();
|
||||||
|
}
|
||||||
|
return model.Id != 0 ?
|
||||||
|
new List<SubdivisionViewModel> { _subdivisionStorage.GetElement(model) } :
|
||||||
|
_subdivisionStorage.GetFilteredList(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateOrUpdate(SubdivisionBindingModel model)
|
||||||
|
{
|
||||||
|
var element = _subdivisionStorage.GetElement(new SubdivisionBindingModel
|
||||||
|
{
|
||||||
|
Name = model.Name
|
||||||
|
});
|
||||||
|
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new Exception("This name is exists!");
|
||||||
|
}
|
||||||
|
if (model.Id != 0)
|
||||||
|
{
|
||||||
|
_subdivisionStorage.Update(model);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_subdivisionStorage.Insert(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(SubdivisionBindingModel model)
|
||||||
|
{
|
||||||
|
var element = _subdivisionStorage.GetElement(new SubdivisionBindingModel { Id = model.Id });
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_subdivisionStorage.Delete(model);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
7
KOP/EnterpriseBusinessLogic/Class1.cs
Normal file
7
KOP/EnterpriseBusinessLogic/Class1.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace EnterpriseBusinessLogic
|
||||||
|
{
|
||||||
|
public class Class1
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
14
KOP/EnterpriseBusinessLogic/EnterpriseBusinessLogic.csproj
Normal file
14
KOP/EnterpriseBusinessLogic/EnterpriseBusinessLogic.csproj
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\EnterpriseContracts\EnterpriseContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\EnterpriseDataBaseImplement\EnterpriseDataBaseImplement.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace EnterpriseContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class EmployeeBindingModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string Fio { get; set; } = string.Empty;
|
||||||
|
public int Experience { get; set; }
|
||||||
|
public string Subdivision { get; set; } = string.Empty;
|
||||||
|
public string Posts { get; set; } = string.Empty;
|
||||||
|
public (int, int)? ExperienceStep { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace EnterpriseContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class SubdivisionBindingModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using EnterpriseContracts.BindingModels;
|
||||||
|
using EnterpriseContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace EnterpriseContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IEmployeeLogic
|
||||||
|
{
|
||||||
|
List<EmployeeViewModel> Read(EmployeeBindingModel? model);
|
||||||
|
void CreateOrUpdate(EmployeeBindingModel model);
|
||||||
|
void Delete(EmployeeBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using EnterpriseContracts.BindingModels;
|
||||||
|
using EnterpriseContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace EnterpriseContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface ISubdivisionLogic
|
||||||
|
{
|
||||||
|
List<SubdivisionViewModel> Read(SubdivisionBindingModel? model);
|
||||||
|
void CreateOrUpdate(SubdivisionBindingModel model);
|
||||||
|
bool Delete(SubdivisionBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
||||||
9
KOP/EnterpriseContracts/EnterpriseContracts.csproj
Normal file
9
KOP/EnterpriseContracts/EnterpriseContracts.csproj
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
15
KOP/EnterpriseContracts/StorageContracts/IEmployeeStorage.cs
Normal file
15
KOP/EnterpriseContracts/StorageContracts/IEmployeeStorage.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using EnterpriseContracts.BindingModels;
|
||||||
|
using EnterpriseContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace EnterpriseContracts.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using EnterpriseContracts.BindingModels;
|
||||||
|
using EnterpriseContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace EnterpriseContracts.StorageContracts
|
||||||
|
{
|
||||||
|
public interface ISubdivisionStorage
|
||||||
|
{
|
||||||
|
List<SubdivisionViewModel> GetFullList();
|
||||||
|
List<SubdivisionViewModel> GetFilteredList(SubdivisionBindingModel model);
|
||||||
|
SubdivisionViewModel? GetElement(SubdivisionBindingModel? model);
|
||||||
|
void Insert(SubdivisionBindingModel model);
|
||||||
|
void Update(SubdivisionBindingModel model);
|
||||||
|
void Delete(SubdivisionBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
KOP/EnterpriseContracts/ViewModels/EmployeeViewModel.cs
Normal file
13
KOP/EnterpriseContracts/ViewModels/EmployeeViewModel.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
namespace EnterpriseContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class EmployeeViewModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Fio { get; set; } = string.Empty;
|
||||||
|
public int Experience { get; set; }
|
||||||
|
public string Subdivision { get; set; } = string.Empty;
|
||||||
|
public string Posts { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public EmployeeViewModel() { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace EnterpriseContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class SubdivisionViewModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
21
KOP/EnterpriseDataBaseImplement/EnterpriseDataBase.cs
Normal file
21
KOP/EnterpriseDataBaseImplement/EnterpriseDataBase.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using EnterpriseDataBaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace EnterpriseDataBaseImplement
|
||||||
|
{
|
||||||
|
public class EnterpriseDataBase : DbContext
|
||||||
|
{
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
if (!optionsBuilder.IsConfigured)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-2EI1EJE\SQLEXPRESS;Initial Catalog=EnterpriseDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
|
}
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual DbSet<Employee> Employees { set; get; }
|
||||||
|
public virtual DbSet<Subdivision> Subdivisions { set; get; }
|
||||||
|
public virtual DbSet<EmployeePosts> EmployeePosts { set; get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.12" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.12" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.12">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\EnterpriseContracts\EnterpriseContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
102
KOP/EnterpriseDataBaseImplement/Implements/EmployeeStorage.cs
Normal file
102
KOP/EnterpriseDataBaseImplement/Implements/EmployeeStorage.cs
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
using EnterpriseContracts.BindingModels;
|
||||||
|
using EnterpriseContracts.StorageContracts;
|
||||||
|
using EnterpriseContracts.ViewModels;
|
||||||
|
using EnterpriseDataBaseImplement.Models;
|
||||||
|
|
||||||
|
namespace EnterpriseDataBaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class EmployeeStorage : IEmployeeStorage
|
||||||
|
{
|
||||||
|
public List<EmployeeViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
var context = new EnterpriseDataBase();
|
||||||
|
return context.Employees
|
||||||
|
.ToList()
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EmployeeViewModel> GetFilteredList(EmployeeBindingModel model)
|
||||||
|
{
|
||||||
|
var context = new EnterpriseDataBase();
|
||||||
|
if (!model.ExperienceStep.HasValue)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
return context.Employees
|
||||||
|
.Where(x => model.ExperienceStep.Value.Item1 <= x.Experience &&
|
||||||
|
model.ExperienceStep.Value.Item2 >= x.Experience)
|
||||||
|
.ToList()
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmployeeViewModel? GetElement(EmployeeBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null || !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new EnterpriseDataBase();
|
||||||
|
var x = context.Employees
|
||||||
|
.ToList()
|
||||||
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
return x?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(EmployeeBindingModel model)
|
||||||
|
{
|
||||||
|
var context = new EnterpriseDataBase();
|
||||||
|
var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var x = Employee.Create(model);
|
||||||
|
context.Employees.Add(x);
|
||||||
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(EmployeeBindingModel model)
|
||||||
|
{
|
||||||
|
var context = new EnterpriseDataBase();
|
||||||
|
var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var x = context.Employees.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (x == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Not found");
|
||||||
|
}
|
||||||
|
x.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(EmployeeBindingModel model)
|
||||||
|
{
|
||||||
|
var context = new EnterpriseDataBase();
|
||||||
|
var x = context.Employees.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (x != null)
|
||||||
|
{
|
||||||
|
context.Employees.Remove(x);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Id isn't exists");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
using EnterpriseContracts.BindingModels;
|
||||||
|
using EnterpriseContracts.StorageContracts;
|
||||||
|
using EnterpriseContracts.ViewModels;
|
||||||
|
using EnterpriseDataBaseImplement.Models;
|
||||||
|
|
||||||
|
namespace EnterpriseDataBaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class SubdivisionStorage : ISubdivisionStorage
|
||||||
|
{
|
||||||
|
public List<SubdivisionViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
var context = new EnterpriseDataBase();
|
||||||
|
return context.Subdivisions
|
||||||
|
.ToList()
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SubdivisionViewModel> GetFilteredList(SubdivisionBindingModel model)
|
||||||
|
{
|
||||||
|
var context = new EnterpriseDataBase();
|
||||||
|
return context.Subdivisions
|
||||||
|
.Where(x => x.Name.Contains(model.Name))
|
||||||
|
.ToList()
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubdivisionViewModel? GetElement(SubdivisionBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new EnterpriseDataBase();
|
||||||
|
var x = context.Subdivisions
|
||||||
|
.ToList()
|
||||||
|
.FirstOrDefault(rec => rec.Name == model.Name || rec.Id == model.Id);
|
||||||
|
return x?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(SubdivisionBindingModel model)
|
||||||
|
{
|
||||||
|
var context = new EnterpriseDataBase();
|
||||||
|
var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var x = Subdivision.Create(model);
|
||||||
|
context.Subdivisions.Add(x);
|
||||||
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(SubdivisionBindingModel model)
|
||||||
|
{
|
||||||
|
var context = new EnterpriseDataBase();
|
||||||
|
var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var x = context.Subdivisions.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (x == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Not found");
|
||||||
|
}
|
||||||
|
x.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(SubdivisionBindingModel model)
|
||||||
|
{
|
||||||
|
var context = new EnterpriseDataBase();
|
||||||
|
var x = context.Subdivisions.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (x != null)
|
||||||
|
{
|
||||||
|
context.Subdivisions.Remove(x);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Id isn't exists");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
74
KOP/EnterpriseDataBaseImplement/Migrations/20240915172215_InitialCreate.Designer.cs
generated
Normal file
74
KOP/EnterpriseDataBaseImplement/Migrations/20240915172215_InitialCreate.Designer.cs
generated
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using EnterpriseDataBaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace EnterpriseDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(EnterpriseDataBase))]
|
||||||
|
[Migration("20240915172215_InitialCreate")]
|
||||||
|
partial class InitialCreate
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.12")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("EnterpriseDataBaseImplement.Models.Employee", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Experience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Fio")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Posts")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Subdivision")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Employees");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EnterpriseDataBaseImplement.Models.Subdivision", 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("Subdivisions");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace EnterpriseDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class InitialCreate : 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"),
|
||||||
|
Fio = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Experience = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Posts = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Subdivision = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Employees", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Subdivisions",
|
||||||
|
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_Subdivisions", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Employees");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Subdivisions");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using EnterpriseDataBaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace EnterpriseDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(EnterpriseDataBase))]
|
||||||
|
partial class EnterpriseDataBaseModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.12")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("EnterpriseDataBaseImplement.Models.Employee", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Experience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Fio")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Posts")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Subdivision")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Employees");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("EnterpriseDataBaseImplement.Models.Subdivision", 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("Subdivisions");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
61
KOP/EnterpriseDataBaseImplement/Models/Employee.cs
Normal file
61
KOP/EnterpriseDataBaseImplement/Models/Employee.cs
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
using EnterpriseContracts.BindingModels;
|
||||||
|
using EnterpriseContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace EnterpriseDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Employee
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Fio { get; set; } = string.Empty;
|
||||||
|
public int Experience { get; set; }
|
||||||
|
public string Posts { get; set; } = string.Empty;
|
||||||
|
public string Subdivision { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public static Employee? Create(EmployeeBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Fio = model.Fio,
|
||||||
|
Experience = model.Experience,
|
||||||
|
Posts = model.Posts,
|
||||||
|
Subdivision = model.Subdivision
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Employee Create(EmployeeViewModel model)
|
||||||
|
{
|
||||||
|
return new Employee
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Fio = model.Fio,
|
||||||
|
Experience = model.Experience,
|
||||||
|
Posts = model.Posts,
|
||||||
|
Subdivision = model.Subdivision
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(EmployeeBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Posts = model.Posts;
|
||||||
|
Subdivision = model.Subdivision;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmployeeViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Fio = Fio,
|
||||||
|
Experience = Experience,
|
||||||
|
Subdivision = Subdivision,
|
||||||
|
Posts = Posts,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
20
KOP/EnterpriseDataBaseImplement/Models/EmployeePosts.cs
Normal file
20
KOP/EnterpriseDataBaseImplement/Models/EmployeePosts.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EnterpriseDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class EmployeePosts
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int EmployeeId { get; set; }
|
||||||
|
public string Posts { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public virtual Employee? Employee { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
55
KOP/EnterpriseDataBaseImplement/Models/Subdivision.cs
Normal file
55
KOP/EnterpriseDataBaseImplement/Models/Subdivision.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
using EnterpriseContracts.BindingModels;
|
||||||
|
using EnterpriseContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace EnterpriseDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Subdivision
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public static Subdivision? Create(SubdivisionBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Subdivision? Create(SubdivisionViewModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(SubdivisionBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
Name = model.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubdivisionViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
65
KOP/Ivanov_App/Directory.Designer.cs
generated
Normal file
65
KOP/Ivanov_App/Directory.Designer.cs
generated
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
namespace Ivanov_App
|
||||||
|
{
|
||||||
|
partial class Directory
|
||||||
|
{
|
||||||
|
/// <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.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(414, 261);
|
||||||
|
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);
|
||||||
|
//
|
||||||
|
// Directory
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(414, 261);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "Directory";
|
||||||
|
this.Text = "Directory";
|
||||||
|
this.Load += new System.EventHandler(this.Directory_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
||||||
127
KOP/Ivanov_App/Directory.cs
Normal file
127
KOP/Ivanov_App/Directory.cs
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
using EnterpriseContracts.BindingModels;
|
||||||
|
using EnterpriseContracts.BusinessLogicContracts;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace Ivanov_App
|
||||||
|
{
|
||||||
|
public partial class Directory : Form
|
||||||
|
{
|
||||||
|
private readonly ISubdivisionLogic _logicS;
|
||||||
|
BindingList<SubdivisionBindingModel> list;
|
||||||
|
|
||||||
|
public Directory(ISubdivisionLogic logicS)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logicS = logicS;
|
||||||
|
dataGridView.AllowUserToDeleteRows = true;
|
||||||
|
list = new BindingList<SubdivisionBindingModel>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list1 = _logicS.Read(null);
|
||||||
|
list.Clear();
|
||||||
|
foreach (var item in list1)
|
||||||
|
{
|
||||||
|
list.Add(new()
|
||||||
|
{
|
||||||
|
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, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Directory_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)
|
||||||
|
{
|
||||||
|
_logicS.CreateOrUpdate(new()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(dataGridView.CurrentRow.Cells[0].Value),
|
||||||
|
Name = (string)dataGridView.CurrentRow.Cells[1].EditedFormattedValue
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logicS.CreateOrUpdate(new()
|
||||||
|
{
|
||||||
|
Name = (string)dataGridView.CurrentRow.Cells[1].EditedFormattedValue
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Empty name", "Error", 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());
|
||||||
|
dataGridView.DataSource = new List<SubdivisionBindingModel>(list);
|
||||||
|
dataGridView.CurrentCell = dataGridView.Rows[0].Cells[1];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dataGridView.Rows[^1].Cells[1].Value != null)
|
||||||
|
{
|
||||||
|
list.Add(new());
|
||||||
|
dataGridView.DataSource = new List<SubdivisionBindingModel>(list);
|
||||||
|
dataGridView.CurrentCell = dataGridView.Rows[^1].Cells[1];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (e.KeyData == Keys.Delete)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Confirm deleting", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logicS.Delete(new()
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
throw new Exception("Error on delete");
|
||||||
|
}
|
||||||
|
dataGridView.Rows.RemoveAt(dataGridView.SelectedRows[0].Index);
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
169
KOP/Ivanov_App/EmployerForm.Designer.cs
generated
Normal file
169
KOP/Ivanov_App/EmployerForm.Designer.cs
generated
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
namespace Ivanov_App
|
||||||
|
{
|
||||||
|
partial class EmployerForm
|
||||||
|
{
|
||||||
|
/// <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.textBoxFio = new System.Windows.Forms.TextBox();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.customInputRangeNumber = new MyCustomComponents.CustomInputRangeNumber();
|
||||||
|
this.dropDownList = new CustomComponent.DropDownList();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxPosts = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonCreate = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// textBoxFio
|
||||||
|
//
|
||||||
|
this.textBoxFio.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.textBoxFio.Location = new System.Drawing.Point(41, 6);
|
||||||
|
this.textBoxFio.Name = "textBoxFio";
|
||||||
|
this.textBoxFio.Size = new System.Drawing.Size(284, 23);
|
||||||
|
this.textBoxFio.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(12, 9);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(23, 15);
|
||||||
|
this.label1.TabIndex = 1;
|
||||||
|
this.label1.Text = "Fio";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(12, 43);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(64, 15);
|
||||||
|
this.label2.TabIndex = 2;
|
||||||
|
this.label2.Text = "Experience";
|
||||||
|
//
|
||||||
|
// customInputRangeNumber
|
||||||
|
//
|
||||||
|
this.customInputRangeNumber.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.customInputRangeNumber.AutoSize = true;
|
||||||
|
this.customInputRangeNumber.AutoValidate = System.Windows.Forms.AutoValidate.Disable;
|
||||||
|
this.customInputRangeNumber.CausesValidation = false;
|
||||||
|
this.customInputRangeNumber.Location = new System.Drawing.Point(82, 35);
|
||||||
|
this.customInputRangeNumber.MaxValue = null;
|
||||||
|
this.customInputRangeNumber.MinValue = null;
|
||||||
|
this.customInputRangeNumber.Name = "customInputRangeNumber";
|
||||||
|
this.customInputRangeNumber.Size = new System.Drawing.Size(243, 31);
|
||||||
|
this.customInputRangeNumber.TabIndex = 3;
|
||||||
|
this.customInputRangeNumber.Value = null;
|
||||||
|
//
|
||||||
|
// 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(82, 72);
|
||||||
|
this.dropDownList.Name = "dropDownList";
|
||||||
|
this.dropDownList.SelectedValue = "";
|
||||||
|
this.dropDownList.Size = new System.Drawing.Size(243, 29);
|
||||||
|
this.dropDownList.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.Location = new System.Drawing.Point(12, 78);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(68, 15);
|
||||||
|
this.label3.TabIndex = 5;
|
||||||
|
this.label3.Text = "Subdivision";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
this.label4.AutoSize = true;
|
||||||
|
this.label4.Location = new System.Drawing.Point(12, 109);
|
||||||
|
this.label4.Name = "label4";
|
||||||
|
this.label4.Size = new System.Drawing.Size(35, 15);
|
||||||
|
this.label4.TabIndex = 6;
|
||||||
|
this.label4.Text = "Posts";
|
||||||
|
//
|
||||||
|
// textBoxPosts
|
||||||
|
//
|
||||||
|
this.textBoxPosts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.textBoxPosts.Location = new System.Drawing.Point(53, 107);
|
||||||
|
this.textBoxPosts.Name = "textBoxPosts";
|
||||||
|
this.textBoxPosts.Size = new System.Drawing.Size(272, 23);
|
||||||
|
this.textBoxPosts.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
this.buttonCreate.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.buttonCreate.Location = new System.Drawing.Point(12, 141);
|
||||||
|
this.buttonCreate.Name = "buttonCreate";
|
||||||
|
this.buttonCreate.Size = new System.Drawing.Size(313, 26);
|
||||||
|
this.buttonCreate.TabIndex = 8;
|
||||||
|
this.buttonCreate.Text = "Create";
|
||||||
|
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
|
||||||
|
//
|
||||||
|
// EmployerForm
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(337, 179);
|
||||||
|
this.Controls.Add(this.buttonCreate);
|
||||||
|
this.Controls.Add(this.textBoxPosts);
|
||||||
|
this.Controls.Add(this.label4);
|
||||||
|
this.Controls.Add(this.label3);
|
||||||
|
this.Controls.Add(this.dropDownList);
|
||||||
|
this.Controls.Add(this.customInputRangeNumber);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.textBoxFio);
|
||||||
|
this.Name = "EmployerForm";
|
||||||
|
this.Text = "EmployerForm";
|
||||||
|
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.EmployerForm_FormClosed);
|
||||||
|
this.Load += new System.EventHandler(this.EmployerForm_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox textBoxFio;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private MyCustomComponents.CustomInputRangeNumber customInputRangeNumber;
|
||||||
|
private CustomComponent.DropDownList dropDownList;
|
||||||
|
private Label label3;
|
||||||
|
private Label label4;
|
||||||
|
private TextBox textBoxPosts;
|
||||||
|
private Button buttonCreate;
|
||||||
|
}
|
||||||
|
}
|
||||||
103
KOP/Ivanov_App/EmployerForm.cs
Normal file
103
KOP/Ivanov_App/EmployerForm.cs
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
using DocumentFormat.OpenXml.InkML;
|
||||||
|
using EnterpriseContracts.BindingModels;
|
||||||
|
using EnterpriseContracts.BusinessLogicContracts;
|
||||||
|
using EnterpriseContracts.ViewModels;
|
||||||
|
using EnterpriseDataBaseImplement;
|
||||||
|
using EnterpriseDataBaseImplement.Models;
|
||||||
|
using System.Data;
|
||||||
|
|
||||||
|
namespace Ivanov_App
|
||||||
|
{
|
||||||
|
public partial class EmployerForm : Form
|
||||||
|
{
|
||||||
|
private readonly IEmployeeLogic _logic;
|
||||||
|
private readonly ISubdivisionLogic _logicS;
|
||||||
|
public int? Id { get; set; }
|
||||||
|
|
||||||
|
public EmployerForm(IEmployeeLogic logic, ISubdivisionLogic logicS)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
_logicS = logicS;
|
||||||
|
customInputRangeNumber.MinValue = 1;
|
||||||
|
customInputRangeNumber.MaxValue = 30;
|
||||||
|
customInputRangeNumber.Value = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.CreateOrUpdate(new EmployeeBindingModel
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Fio = textBoxFio.Text,
|
||||||
|
Subdivision = dropDownList.SelectedValue,
|
||||||
|
Posts = textBoxPosts.Text,
|
||||||
|
Experience = (int)customInputRangeNumber.Value
|
||||||
|
});
|
||||||
|
|
||||||
|
var context = new EnterpriseDataBase();
|
||||||
|
|
||||||
|
var employee = context.Employees.FirstOrDefault(e => e.Fio == textBoxFio.Text);
|
||||||
|
|
||||||
|
if (employee == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Employee not found or not created.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var employeePosts = new EmployeePosts
|
||||||
|
{
|
||||||
|
EmployeeId = employee.Id,
|
||||||
|
Posts = textBoxPosts.Text
|
||||||
|
};
|
||||||
|
|
||||||
|
context.EmployeePosts.Add(employeePosts);
|
||||||
|
context.SaveChanges();
|
||||||
|
|
||||||
|
MessageBox.Show("Successfully created employee and associated posts.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void EmployerForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
List<SubdivisionViewModel>? viewS = _logicS.Read(null);
|
||||||
|
|
||||||
|
if (viewS != null)
|
||||||
|
{
|
||||||
|
dropDownList.Items.AddRange(viewS.Select(x => x.Name).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
EmployeeViewModel? view = _logic.Read(new EmployeeBindingModel { Id = Id.Value })?[0];
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxFio.Text = view.Fio;
|
||||||
|
dropDownList.SelectedValue = view.Subdivision;
|
||||||
|
customInputRangeNumber.Value = view.Experience;
|
||||||
|
textBoxPosts.Text = view.Posts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EmployerForm_FormClosed(object sender, FormClosedEventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
KOP/Ivanov_App/EmployerForm.resx
Normal file
120
KOP/Ivanov_App/EmployerForm.resx
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
231
KOP/Ivanov_App/Form.Designer.cs
generated
231
KOP/Ivanov_App/Form.Designer.cs
generated
@@ -1,231 +0,0 @@
|
|||||||
namespace Ivanov_App
|
|
||||||
{
|
|
||||||
partial class Form
|
|
||||||
{
|
|
||||||
/// <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();
|
|
||||||
ItemList = new Ivanov_visual_components.ItemList();
|
|
||||||
ButtonListClear = new Button();
|
|
||||||
ButtonLoadList = new Button();
|
|
||||||
dateBoxWithNull = new Ivanov_visual_components.DateBoxWithNull();
|
|
||||||
ButtonGetValue = new Button();
|
|
||||||
ButtonSetValue = new Button();
|
|
||||||
itemTable = new Ivanov_visual_components.ItemTable();
|
|
||||||
ButtonClear = new Button();
|
|
||||||
textBoxEvent = new TextBox();
|
|
||||||
ButtonAdd = new Button();
|
|
||||||
ButtonSel = new Button();
|
|
||||||
this.excelTable = new Ivanov_components.ExcelTable(this.components);
|
|
||||||
this.buttonExcel = new System.Windows.Forms.Button();
|
|
||||||
this.excelSaveHeader = new System.Windows.Forms.Button();
|
|
||||||
this.SaveBar = new System.Windows.Forms.Button();
|
|
||||||
this.excelWithCustomTable = new Ivanov_components.ExcelWithCustomTable(this.components);
|
|
||||||
this.excelGistogram = new Ivanov_components.ExcelGistogram(this.components);
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// ItemList
|
|
||||||
//
|
|
||||||
this.ItemList.Location = new System.Drawing.Point(12, 12);
|
|
||||||
this.ItemList.Name = "ItemList";
|
|
||||||
this.ItemList.SelectedElement = "";
|
|
||||||
this.ItemList.Size = new System.Drawing.Size(210, 212);
|
|
||||||
this.ItemList.TabIndex = 0;
|
|
||||||
this.ItemList.ChangeEvent += new System.EventHandler(this.ItemList_ChangeEvent);
|
|
||||||
//
|
|
||||||
// ButtonListClear
|
|
||||||
//
|
|
||||||
this.ButtonListClear.Location = new System.Drawing.Point(12, 230);
|
|
||||||
this.ButtonListClear.Name = "ButtonListClear";
|
|
||||||
this.ButtonListClear.Size = new System.Drawing.Size(210, 23);
|
|
||||||
this.ButtonListClear.TabIndex = 1;
|
|
||||||
this.ButtonListClear.Text = "List Clear";
|
|
||||||
this.ButtonListClear.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonListClear.Click += new System.EventHandler(this.ButtonListClear_Click);
|
|
||||||
//
|
|
||||||
// ButtonLoadList
|
|
||||||
//
|
|
||||||
this.ButtonLoadList.Location = new System.Drawing.Point(12, 259);
|
|
||||||
this.ButtonLoadList.Name = "ButtonLoadList";
|
|
||||||
this.ButtonLoadList.Size = new System.Drawing.Size(210, 23);
|
|
||||||
this.ButtonLoadList.TabIndex = 2;
|
|
||||||
this.ButtonLoadList.Text = "Load List";
|
|
||||||
this.ButtonLoadList.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonLoadList.Click += new System.EventHandler(this.ButtonLoadList_Click);
|
|
||||||
//
|
|
||||||
// dateBoxWithNull
|
|
||||||
//
|
|
||||||
this.dateBoxWithNull.BackColor = System.Drawing.SystemColors.ControlLight;
|
|
||||||
this.dateBoxWithNull.Location = new System.Drawing.Point(228, 12);
|
|
||||||
this.dateBoxWithNull.Name = "dateBoxWithNull";
|
|
||||||
this.dateBoxWithNull.Size = new System.Drawing.Size(147, 29);
|
|
||||||
this.dateBoxWithNull.TabIndex = 3;
|
|
||||||
this.dateBoxWithNull.Value = null;
|
|
||||||
this.dateBoxWithNull.CheckBoxEvent += new System.EventHandler(this.dateBoxWithNull1_CheckBoxEvent);
|
|
||||||
this.dateBoxWithNull.ChangeEvent += new System.EventHandler(this.dateBoxWithNull1_ChangeEvent);
|
|
||||||
//
|
|
||||||
// ButtonGetValue
|
|
||||||
//
|
|
||||||
this.ButtonGetValue.Location = new System.Drawing.Point(228, 47);
|
|
||||||
this.ButtonGetValue.Name = "ButtonGetValue";
|
|
||||||
this.ButtonGetValue.Size = new System.Drawing.Size(147, 23);
|
|
||||||
this.ButtonGetValue.TabIndex = 4;
|
|
||||||
this.ButtonGetValue.Text = "Get Value";
|
|
||||||
this.ButtonGetValue.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonGetValue.Click += new System.EventHandler(this.ButtonGetValue_Click);
|
|
||||||
//
|
|
||||||
// ButtonSetValue
|
|
||||||
//
|
|
||||||
this.ButtonSetValue.Location = new System.Drawing.Point(228, 76);
|
|
||||||
this.ButtonSetValue.Name = "ButtonSetValue";
|
|
||||||
this.ButtonSetValue.Size = new System.Drawing.Size(147, 23);
|
|
||||||
this.ButtonSetValue.TabIndex = 5;
|
|
||||||
this.ButtonSetValue.Text = "Set Value";
|
|
||||||
this.ButtonSetValue.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonSetValue.Click += new System.EventHandler(this.ButtonSetValue_Click);
|
|
||||||
//
|
|
||||||
// itemTable
|
|
||||||
//
|
|
||||||
this.itemTable.Location = new System.Drawing.Point(381, 12);
|
|
||||||
this.itemTable.Name = "itemTable";
|
|
||||||
this.itemTable.Size = new System.Drawing.Size(548, 426);
|
|
||||||
this.itemTable.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// ButtonClear
|
|
||||||
//
|
|
||||||
this.ButtonClear.Location = new System.Drawing.Point(935, 12);
|
|
||||||
this.ButtonClear.Name = "ButtonClear";
|
|
||||||
this.ButtonClear.Size = new System.Drawing.Size(94, 23);
|
|
||||||
this.ButtonClear.TabIndex = 7;
|
|
||||||
this.ButtonClear.Text = "Table clear";
|
|
||||||
this.ButtonClear.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonClear.Click += new System.EventHandler(this.ButtonClear_Click);
|
|
||||||
//
|
|
||||||
// textBoxEvent
|
|
||||||
//
|
|
||||||
this.textBoxEvent.Location = new System.Drawing.Point(228, 105);
|
|
||||||
this.textBoxEvent.Name = "textBoxEvent";
|
|
||||||
this.textBoxEvent.Size = new System.Drawing.Size(147, 23);
|
|
||||||
this.textBoxEvent.TabIndex = 8;
|
|
||||||
//
|
|
||||||
// ButtonAdd
|
|
||||||
//
|
|
||||||
this.ButtonAdd.Location = new System.Drawing.Point(935, 41);
|
|
||||||
this.ButtonAdd.Name = "ButtonAdd";
|
|
||||||
this.ButtonAdd.Size = new System.Drawing.Size(94, 23);
|
|
||||||
this.ButtonAdd.TabIndex = 9;
|
|
||||||
this.ButtonAdd.Text = "Table Add";
|
|
||||||
this.ButtonAdd.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
|
||||||
//
|
|
||||||
// ButtonSel
|
|
||||||
//
|
|
||||||
this.ButtonSel.Location = new System.Drawing.Point(935, 70);
|
|
||||||
this.ButtonSel.Name = "ButtonSel";
|
|
||||||
this.ButtonSel.Size = new System.Drawing.Size(94, 23);
|
|
||||||
this.ButtonSel.TabIndex = 10;
|
|
||||||
this.ButtonSel.Text = "Get Value";
|
|
||||||
this.ButtonSel.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonSel.Click += new System.EventHandler(this.ButtonSel_Click);
|
|
||||||
//
|
|
||||||
// buttonExcel
|
|
||||||
//
|
|
||||||
this.buttonExcel.Location = new System.Drawing.Point(12, 415);
|
|
||||||
this.buttonExcel.Name = "buttonExcel";
|
|
||||||
this.buttonExcel.Size = new System.Drawing.Size(75, 23);
|
|
||||||
this.buttonExcel.TabIndex = 11;
|
|
||||||
this.buttonExcel.Text = "Excel Save";
|
|
||||||
this.buttonExcel.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonExcel.Click += new System.EventHandler(this.buttonExcel_Click);
|
|
||||||
//
|
|
||||||
// excelSaveHeader
|
|
||||||
//
|
|
||||||
this.excelSaveHeader.Location = new System.Drawing.Point(93, 415);
|
|
||||||
this.excelSaveHeader.Name = "excelSaveHeader";
|
|
||||||
this.excelSaveHeader.Size = new System.Drawing.Size(129, 23);
|
|
||||||
this.excelSaveHeader.TabIndex = 12;
|
|
||||||
this.excelSaveHeader.Text = "Save With Header";
|
|
||||||
this.excelSaveHeader.UseVisualStyleBackColor = true;
|
|
||||||
this.excelSaveHeader.Click += new System.EventHandler(this.excelSaveHeader_Click);
|
|
||||||
//
|
|
||||||
// SaveBar
|
|
||||||
//
|
|
||||||
this.SaveBar.Location = new System.Drawing.Point(228, 415);
|
|
||||||
this.SaveBar.Name = "SaveBar";
|
|
||||||
this.SaveBar.Size = new System.Drawing.Size(147, 23);
|
|
||||||
this.SaveBar.TabIndex = 13;
|
|
||||||
this.SaveBar.Text = "Save Bar";
|
|
||||||
this.SaveBar.UseVisualStyleBackColor = true;
|
|
||||||
this.SaveBar.Click += new System.EventHandler(this.SaveBar_Click);
|
|
||||||
//
|
|
||||||
// Form
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(1041, 450);
|
|
||||||
Controls.Add(SaveBar);
|
|
||||||
Controls.Add(excelSaveHeader);
|
|
||||||
Controls.Add(buttonExcel);
|
|
||||||
Controls.Add(ButtonSel);
|
|
||||||
Controls.Add(ButtonAdd);
|
|
||||||
Controls.Add(textBoxEvent);
|
|
||||||
Controls.Add(ButtonClear);
|
|
||||||
Controls.Add(itemTable);
|
|
||||||
Controls.Add(ButtonSetValue);
|
|
||||||
Controls.Add(ButtonGetValue);
|
|
||||||
Controls.Add(dateBoxWithNull);
|
|
||||||
Controls.Add(ButtonLoadList);
|
|
||||||
Controls.Add(ButtonListClear);
|
|
||||||
Controls.Add(ItemList);
|
|
||||||
Margin = new Padding(6);
|
|
||||||
Name = "Form";
|
|
||||||
Text = "Form1";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Ivanov_visual_components.ItemList ItemList;
|
|
||||||
private Button ButtonListClear;
|
|
||||||
private Button ButtonLoadList;
|
|
||||||
private Ivanov_visual_components.DateBoxWithNull dateBoxWithNull;
|
|
||||||
private Button ButtonGetValue;
|
|
||||||
private Button ButtonSetValue;
|
|
||||||
private Ivanov_visual_components.ItemTable itemTable;
|
|
||||||
private Button ButtonClear;
|
|
||||||
private TextBox textBoxEvent;
|
|
||||||
private Button ButtonAdd;
|
|
||||||
private Button ButtonSel;
|
|
||||||
private Ivanov_components.ExcelTable excelTable;
|
|
||||||
private Button buttonExcel;
|
|
||||||
private Button excelSaveHeader;
|
|
||||||
private Button SaveBar;
|
|
||||||
private Ivanov_components.ExcelWithCustomTable excelWithCustomTable;
|
|
||||||
private Ivanov_components.ExcelGistogram excelGistogram;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
using Ivanov_components.Models;
|
|
||||||
using Microsoft.VisualBasic.Devices;
|
|
||||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Header;
|
|
||||||
|
|
||||||
namespace Ivanov_App
|
|
||||||
{
|
|
||||||
public partial class Form : System.Windows.Forms.Form
|
|
||||||
{
|
|
||||||
public Form()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
CreateList();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1 компонент
|
|
||||||
|
|
||||||
private void CreateList()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 10; i++)
|
|
||||||
{
|
|
||||||
ItemList.Items.Add($"Item-{i}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonListClear_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
ItemList.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonLoadList_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CreateList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ItemList_ChangeEvent(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
object? selectedItem = ItemList.SelectedElement;
|
|
||||||
MessageBox.Show($"Change selected item {selectedItem?.ToString()}");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2 компонент
|
|
||||||
|
|
||||||
private void dateBoxWithNull1_ChangeEvent(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
textBoxEvent.Text = "TextBox change";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void dateBoxWithNull1_CheckBoxEvent(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
textBoxEvent.Text = "CheckBox change";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonGetValue_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
MessageBox.Show($"Value is {dateBoxWithNull.Value}");
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool EmptyFill = false;
|
|
||||||
|
|
||||||
private void ButtonSetValue_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (EmptyFill)
|
|
||||||
{
|
|
||||||
dateBoxWithNull.Value = DateTime.Now;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dateBoxWithNull.Value = null;
|
|
||||||
}
|
|
||||||
EmptyFill = !EmptyFill;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3 компонент
|
|
||||||
|
|
||||||
readonly List<Student> students = new()
|
|
||||||
{
|
|
||||||
new Student { Id = 0, Name = "Петя", Surname = "Петров", Course = 1 },
|
|
||||||
new Student { Id = 1, Name = "Ваня", Surname = "Пупкин", Course = 2 },
|
|
||||||
new Student { Id = 2, Name = "Женя", Surname = "Львов", Course = 3 },
|
|
||||||
new Student { Id = 3, Name = "Коля", Surname = "Серов", Course = 4 },
|
|
||||||
new Student { Id = 4, Name = "Максим", Surname = "Ершов", Course = 5 }
|
|
||||||
};
|
|
||||||
|
|
||||||
private void CreateTable()
|
|
||||||
{
|
|
||||||
itemTable.ConfigColumn(new()
|
|
||||||
{
|
|
||||||
ColumnsCount = 4,
|
|
||||||
NameColumn = new string[] { "Id", "Name", "Surname", "Course" },
|
|
||||||
Width = new int[] { 10, 150, 250, 200 },
|
|
||||||
Visible = new bool[] { false, true, true, true, true },
|
|
||||||
PropertiesObject = new string[] { "Id", "Name", "Surname", "Course" }
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (Student computer in students)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
itemTable.AddItem(computer, computer.Id, i);
|
|
||||||
itemTable.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CreateTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonClear_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
itemTable.ClearDataGrid();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Student? computer = itemTable.GetSelectedObjectInRow<Student>();
|
|
||||||
if (computer is null) return;
|
|
||||||
MessageBox.Show($"{computer.Id}-{computer.Name}-{computer.Surname}-{computer.Course}");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2 лаба
|
|
||||||
|
|
||||||
private void buttonExcel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
((Control)sender).BackColor = Color.White;
|
|
||||||
excelTable.CreateDoc(new Ivanov_components.Models.TableConfig
|
|
||||||
{
|
|
||||||
FilePath = "table.xlsx",
|
|
||||||
Header = "Example",
|
|
||||||
Data = new List<string[,]>
|
|
||||||
{
|
|
||||||
new string[,] {
|
|
||||||
{ "1", "1", "1" },
|
|
||||||
{ "1", "2", "2" },
|
|
||||||
{ "1", "3", "3" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
((Control)sender).BackColor = Color.Green;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void excelSaveHeader_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
((Control)sender).BackColor = Color.White;
|
|
||||||
excelWithCustomTable.CreateDoc(new Ivanov_components.Models.TableWithHeaderConfig<Student>
|
|
||||||
{
|
|
||||||
FilePath = "header.xlsx",
|
|
||||||
Header = "Students",
|
|
||||||
ColumnsRowsWidth = new List<(int Column, int Row)> { (5, 5), (10, 5), (10, 0), (5, 0), (7, 0) },
|
|
||||||
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
|
|
||||||
{
|
|
||||||
(0, 0, "Id", "Id"),
|
|
||||||
(1, 0, "Name", "Name"),
|
|
||||||
(2, 0, "Surname", "Surname"),
|
|
||||||
(3, 0, "Course", "Course"),
|
|
||||||
},
|
|
||||||
Data = students,
|
|
||||||
NullReplace = "Çàëóïêà)"
|
|
||||||
});
|
|
||||||
((Control)sender).BackColor = Color.Green;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveBar_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
((Control)sender).BackColor = Color.White;
|
|
||||||
var rnd = new Random();
|
|
||||||
excelGistogram.CreateDoc(new ChartConfig
|
|
||||||
{
|
|
||||||
FilePath = "bar.xlsx",
|
|
||||||
Header = "Chart",
|
|
||||||
ChartTitle = "BarChart",
|
|
||||||
LegendLocation = Ivanov_components.Models.Location.Top,
|
|
||||||
Data = new Dictionary<string, List<(string Name, double Value)>>
|
|
||||||
{
|
|
||||||
{ "Series 1", new() { ("Один", rnd.Next()), ("Два", rnd.Next()), ("Три", rnd.Next()) } }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
((Control)sender).BackColor = Color.Green;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
173
KOP/Ivanov_App/FormMain.Designer.cs
generated
Normal file
173
KOP/Ivanov_App/FormMain.Designer.cs
generated
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
namespace Ivanov_App
|
||||||
|
{
|
||||||
|
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.listBoxMany = new CustomComponent.ListBoxMany();
|
||||||
|
this.excelTable = new Ivanov_components.ExcelTable(this.components);
|
||||||
|
this.componentDiagramToPdf = new CustomComponent.ComponentDiagramToPdf(this.components);
|
||||||
|
this.wordWithTable = new MyCustomComponent.WordWithTable(this.components);
|
||||||
|
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||||
|
this.actionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.createEmployerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.editEmployerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.deleteEmployerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.excelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.wordToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.pdfToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.directoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.menuStrip1.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// listBoxMany
|
||||||
|
//
|
||||||
|
this.listBoxMany.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||||
|
this.listBoxMany.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.listBoxMany.Location = new System.Drawing.Point(0, 24);
|
||||||
|
this.listBoxMany.Name = "listBoxMany";
|
||||||
|
this.listBoxMany.SelectedIndex = -1;
|
||||||
|
this.listBoxMany.Size = new System.Drawing.Size(895, 453);
|
||||||
|
this.listBoxMany.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// menuStrip1
|
||||||
|
//
|
||||||
|
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.actionToolStripMenuItem,
|
||||||
|
this.directoryToolStripMenuItem});
|
||||||
|
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.menuStrip1.Name = "menuStrip1";
|
||||||
|
this.menuStrip1.Size = new System.Drawing.Size(895, 24);
|
||||||
|
this.menuStrip1.TabIndex = 2;
|
||||||
|
this.menuStrip1.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// actionToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.actionToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.createEmployerToolStripMenuItem,
|
||||||
|
this.editEmployerToolStripMenuItem,
|
||||||
|
this.deleteEmployerToolStripMenuItem,
|
||||||
|
this.excelToolStripMenuItem,
|
||||||
|
this.wordToolStripMenuItem,
|
||||||
|
this.pdfToolStripMenuItem});
|
||||||
|
this.actionToolStripMenuItem.Name = "actionToolStripMenuItem";
|
||||||
|
this.actionToolStripMenuItem.Size = new System.Drawing.Size(54, 20);
|
||||||
|
this.actionToolStripMenuItem.Text = "Action";
|
||||||
|
//
|
||||||
|
// createEmployerToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.createEmployerToolStripMenuItem.Name = "createEmployerToolStripMenuItem";
|
||||||
|
this.createEmployerToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
|
||||||
|
this.createEmployerToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
|
||||||
|
this.createEmployerToolStripMenuItem.Text = "Create Employer";
|
||||||
|
this.createEmployerToolStripMenuItem.Click += new System.EventHandler(this.CreateEmployerToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// editEmployerToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.editEmployerToolStripMenuItem.Name = "editEmployerToolStripMenuItem";
|
||||||
|
this.editEmployerToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U)));
|
||||||
|
this.editEmployerToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
|
||||||
|
this.editEmployerToolStripMenuItem.Text = "Edit Employer";
|
||||||
|
this.editEmployerToolStripMenuItem.Click += new System.EventHandler(this.EditEmployerToolStripMenuItem_Click_1);
|
||||||
|
//
|
||||||
|
// deleteEmployerToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.deleteEmployerToolStripMenuItem.Name = "deleteEmployerToolStripMenuItem";
|
||||||
|
this.deleteEmployerToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D)));
|
||||||
|
this.deleteEmployerToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
|
||||||
|
this.deleteEmployerToolStripMenuItem.Text = "Delete Employer";
|
||||||
|
this.deleteEmployerToolStripMenuItem.Click += new System.EventHandler(this.DeleteEmployerToolStripMenuItem_Click_1);
|
||||||
|
//
|
||||||
|
// excelToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.excelToolStripMenuItem.Name = "excelToolStripMenuItem";
|
||||||
|
this.excelToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||||
|
this.excelToolStripMenuItem.Size = new System.Drawing.Size(203, 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.T)));
|
||||||
|
this.wordToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
|
||||||
|
this.wordToolStripMenuItem.Text = "Word";
|
||||||
|
this.wordToolStripMenuItem.Click += new System.EventHandler(this.WordToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// pdfToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.pdfToolStripMenuItem.Name = "pdfToolStripMenuItem";
|
||||||
|
this.pdfToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
|
||||||
|
this.pdfToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
|
||||||
|
this.pdfToolStripMenuItem.Text = "Pdf";
|
||||||
|
this.pdfToolStripMenuItem.Click += new System.EventHandler(this.PdfToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// directoryToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.directoryToolStripMenuItem.Checked = true;
|
||||||
|
this.directoryToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
|
this.directoryToolStripMenuItem.Name = "directoryToolStripMenuItem";
|
||||||
|
this.directoryToolStripMenuItem.Size = new System.Drawing.Size(67, 20);
|
||||||
|
this.directoryToolStripMenuItem.Text = "Directory";
|
||||||
|
this.directoryToolStripMenuItem.Click += new System.EventHandler(this.DirectoryToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// FormMain
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(895, 477);
|
||||||
|
this.Controls.Add(this.listBoxMany);
|
||||||
|
this.Controls.Add(this.menuStrip1);
|
||||||
|
this.MainMenuStrip = this.menuStrip1;
|
||||||
|
this.Name = "FormMain";
|
||||||
|
this.Text = "Bazunov Application";
|
||||||
|
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||||
|
this.menuStrip1.ResumeLayout(false);
|
||||||
|
this.menuStrip1.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private MyCustomComponents.CustomTreeCell customTreeCell1;
|
||||||
|
private CustomComponent.ListBoxMany listBoxMany;
|
||||||
|
private Ivanov_components.ExcelTable excelTable;
|
||||||
|
private CustomComponent.ComponentDiagramToPdf componentDiagramToPdf;
|
||||||
|
private MyCustomComponent.WordWithTable wordWithTable;
|
||||||
|
private MenuStrip menuStrip1;
|
||||||
|
private ToolStripMenuItem actionToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem createEmployerToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem editEmployerToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem deleteEmployerToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem excelToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem wordToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem pdfToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem directoryToolStripMenuItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
220
KOP/Ivanov_App/FormMain.cs
Normal file
220
KOP/Ivanov_App/FormMain.cs
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
using EnterpriseContracts.BindingModels;
|
||||||
|
using EnterpriseContracts.BusinessLogicContracts;
|
||||||
|
using EnterpriseContracts.ViewModels;
|
||||||
|
using EnterpriseDataBaseImplement;
|
||||||
|
using MyCustomComponent;
|
||||||
|
using MyCustomComponents.Models;
|
||||||
|
using System.Data;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace Ivanov_App
|
||||||
|
{
|
||||||
|
public partial class FormMain : Form
|
||||||
|
{
|
||||||
|
private readonly IEmployeeLogic _LogicE;
|
||||||
|
private readonly ISubdivisionLogic _LogicS;
|
||||||
|
public FormMain(IEmployeeLogic logicE, ISubdivisionLogic logicS)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_LogicE = logicE;
|
||||||
|
_LogicS = logicS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DropComponents()
|
||||||
|
{
|
||||||
|
Controls.Clear();
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string> originalStrings = new();
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DropComponents();
|
||||||
|
listBoxMany.SetLayout("{Id} {Subdivision} {Fio} {Experience}", "{", "}");
|
||||||
|
|
||||||
|
var list = _LogicE.Read(null) ?? throw new Exception("Error on read");
|
||||||
|
originalStrings.Clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < list.Count; i++)
|
||||||
|
{
|
||||||
|
string originalString = $"{list[i].Subdivision} {list[i].Id} {list[i].Fio} {list[i].Experience}";
|
||||||
|
originalStrings.Add(originalString);
|
||||||
|
|
||||||
|
listBoxMany.AddItemInList(list[i], i, "Id");
|
||||||
|
listBoxMany.AddItemInList(list[i], i, "Subdivision");
|
||||||
|
listBoxMany.AddItemInList(list[i], i, "Fio");
|
||||||
|
listBoxMany.AddItemInList(list[i], i, "Experience");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateEmployerToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var form = Program.Container.Resolve<EmployerForm>();
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EditEmployerToolStripMenuItem_Click_1(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var form = Program.Container.Resolve<EmployerForm>();
|
||||||
|
form.Id = Convert.ToInt32(listBoxMany.GetItemFromList<EmployeeViewModel>().Id);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeleteEmployerToolStripMenuItem_Click_1(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Delete record", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
var ent = listBoxMany.GetItemFromList<EmployeeViewModel>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(ent.Id);
|
||||||
|
_LogicE.Delete(new EmployeeBindingModel { Id = id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExcelToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string fileName = "";
|
||||||
|
using (var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" })
|
||||||
|
{
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
fileName = dialog.FileName.ToString();
|
||||||
|
MessageBox.Show("Success", "Ready", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var context = new EnterpriseDataBase();
|
||||||
|
|
||||||
|
var employeeId = listBoxMany.GetItemFromList<EmployeeViewModel>().Id;
|
||||||
|
|
||||||
|
var employee = context.Employees.FirstOrDefault(e => e.Id == employeeId);
|
||||||
|
|
||||||
|
if (employee == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Сотрудник не найден.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var lastFivePosts = context.EmployeePosts.Where(p => p.EmployeeId == employeeId).OrderByDescending(p => p.Id)
|
||||||
|
.Take(5).Select(p => p.Posts).ToArray();
|
||||||
|
|
||||||
|
var Data = new string[1, 5];
|
||||||
|
for (int i = 0; i < lastFivePosts.Length; i++)
|
||||||
|
{
|
||||||
|
Data[0, i] = lastFivePosts[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = lastFivePosts.Length; i < 5; i++)
|
||||||
|
{
|
||||||
|
Data[0, i] = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
excelTable.CreateDoc(new Ivanov_components.Models.TableConfig
|
||||||
|
{
|
||||||
|
FilePath = fileName,
|
||||||
|
Header = "Последние 5 должностей",
|
||||||
|
Data = new List<string[,]> { Data }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WordToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string fileName = "";
|
||||||
|
using (var dialog = new SaveFileDialog { Filter = "docx|*.docx" })
|
||||||
|
{
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
fileName = dialog.FileName.ToString();
|
||||||
|
MessageBox.Show("Success", "Ready", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var list = _LogicE.Read(null);
|
||||||
|
var wordWithTable = new WordWithTable();
|
||||||
|
wordWithTable.CreateDoc(new WordWithTableDataConfig<EmployeeViewModel>
|
||||||
|
{
|
||||||
|
FilePath = fileName,
|
||||||
|
Header = "Table:",
|
||||||
|
UseUnion = true,
|
||||||
|
ColumnsRowsWidth = new List<(int, int)> { (0, 5), (0, 5), (0, 10), (0, 10) },
|
||||||
|
ColumnUnion = new List<(int StartIndex, int Count)> { (2, 2) },
|
||||||
|
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
|
||||||
|
{
|
||||||
|
(0, 0, "Id", "Id"),
|
||||||
|
(1, 0, "Fio", "Fio"),
|
||||||
|
(2, 0, "Work", ""),
|
||||||
|
(2, 1, "Subdivision", "Subdivision"),
|
||||||
|
(3, 1, "Experience", "Experience"),
|
||||||
|
},
|
||||||
|
Data = list
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PdfToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string fileName = "";
|
||||||
|
using (var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" })
|
||||||
|
{
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
fileName = dialog.FileName.ToString();
|
||||||
|
MessageBox.Show("Success", "Ready", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var listEmp = _LogicE.Read(null);
|
||||||
|
var listSubd = _LogicS.Read(null);
|
||||||
|
var Data = new Dictionary<string, List<(string Name, double Value)>>();
|
||||||
|
foreach (var item in listSubd)
|
||||||
|
{
|
||||||
|
var listSorted = listEmp.Where(x => x.Subdivision.Equals(item.Name));
|
||||||
|
var x = (
|
||||||
|
listSorted.Where(y => y.Experience >= 1 && y.Experience < 5).Count(),
|
||||||
|
listSorted.Where(y => y.Experience >= 5 && y.Experience < 10).Count(),
|
||||||
|
listSorted.Where(y => y.Experience >= 10 && y.Experience < 20).Count(),
|
||||||
|
listSorted.Where(y => y.Experience >= 20 && y.Experience < 30).Count());
|
||||||
|
Data.Add(item.Name, new() { ("1-5", x.Item1), ("5-10", x.Item2), ("10-20", x.Item3), ("20-30", x.Item4) });
|
||||||
|
}
|
||||||
|
componentDiagramToPdf.CreateDoc(new()
|
||||||
|
{
|
||||||
|
FilePath = fileName,
|
||||||
|
Header = "Chart",
|
||||||
|
ChartTitle = "Chart",
|
||||||
|
Data = Data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DirectoryToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var form = Program.Container.Resolve<Directory>();
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
KOP/Ivanov_App/FormMain.resx
Normal file
120
KOP/Ivanov_App/FormMain.resx
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
@@ -6,11 +6,26 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Ivanov_components\Ivanov_components.csproj" />
|
<PackageReference Include="CustomComponent" Version="1.0.0" />
|
||||||
<ProjectReference Include="..\Ivanov_visual_components\Ivanov_visual_components.csproj" />
|
<PackageReference Include="Ivanov_components" Version="1.0.0" />
|
||||||
|
<PackageReference Include="Ivanov_visual_components" Version="1.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.11">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="MyCustomComponent" Version="1.0.0" />
|
||||||
|
<PackageReference Include="MyCustomComponents" Version="1.0.0" />
|
||||||
|
<PackageReference Include="Unity" Version="5.11.10" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\EnterpriseBusinessLogic\EnterpriseBusinessLogic.csproj" />
|
||||||
|
<ProjectReference Include="..\EnterpriseContracts\EnterpriseContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\EnterpriseDataBaseImplement\EnterpriseDataBaseImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,17 +1,40 @@
|
|||||||
|
using EnterpriseBusinessLogic.BusinessLogics;
|
||||||
|
using EnterpriseContracts.BusinessLogicContracts;
|
||||||
|
using EnterpriseContracts.StorageContracts;
|
||||||
|
using EnterpriseDataBaseImplement.Implements;
|
||||||
|
using Unity.Lifetime;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
namespace Ivanov_App
|
namespace Ivanov_App
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
/// <summary>
|
private static IUnityContainer? container = null;
|
||||||
/// The main entry point for the application.
|
public static IUnityContainer Container { get { container ??= BuildUnityContainer(); return container; } }
|
||||||
/// </summary>
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||||
// see https://aka.ms/applicationconfiguration.
|
Application.EnableVisualStyles();
|
||||||
ApplicationConfiguration.Initialize();
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new Form());
|
Application.Run(Container.Resolve<FormMain>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IUnityContainer BuildUnityContainer()
|
||||||
|
{
|
||||||
|
var currentContainer = new UnityContainer();
|
||||||
|
|
||||||
|
currentContainer.RegisterType<IEmployeeStorage, EmployeeStorage>(new HierarchicalLifetimeManager());
|
||||||
|
currentContainer.RegisterType<ISubdivisionStorage, SubdivisionStorage>(new HierarchicalLifetimeManager());
|
||||||
|
|
||||||
|
currentContainer.RegisterType<IEmployeeLogic, EmployeeLogic>(new HierarchicalLifetimeManager());
|
||||||
|
currentContainer.RegisterType<ISubdivisionLogic, SubdivisionLogic>(new HierarchicalLifetimeManager());
|
||||||
|
|
||||||
|
currentContainer.RegisterType<EmployerForm>();
|
||||||
|
currentContainer.RegisterType<Directory>();
|
||||||
|
|
||||||
|
return currentContainer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Ivanov_App
|
|
||||||
{
|
|
||||||
public class Student
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string Name { get; set; } = string.Empty;
|
|
||||||
public string Surname { get; set; } = string.Empty;
|
|
||||||
public int Course { get; set; }
|
|
||||||
|
|
||||||
public Student(int id, string name, string surname, int course)
|
|
||||||
{
|
|
||||||
Id = id;
|
|
||||||
Name = name;
|
|
||||||
Surname = surname;
|
|
||||||
Course = course;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Student() { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,10 +5,11 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
28
KOP/KOP.sln
28
KOP/KOP.sln
@@ -3,11 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.10.35122.118
|
VisualStudioVersion = 17.10.35122.118
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ivanov_visual_components", "Ivanov_visual_components\Ivanov_visual_components.csproj", "{3FEAB427-D75C-442E-B5FE-6285202B442C}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ivanov_App", "Ivanov_App\Ivanov_App.csproj", "{64CD7137-E0BF-4F35-8F33-B07AFED1393F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ivanov_App", "Ivanov_App\Ivanov_App.csproj", "{64CD7137-E0BF-4F35-8F33-B07AFED1393F}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnterpriseContracts", "EnterpriseContracts\EnterpriseContracts.csproj", "{196E0D33-EA70-42F0-AF4F-BD66843AB836}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ivanov_components", "Ivanov_components\Ivanov_components.csproj", "{E162208D-662D-4419-9B33-A61189E0CC20}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnterpriseBusinessLogic", "EnterpriseBusinessLogic\EnterpriseBusinessLogic.csproj", "{45AFE8E1-F8F4-4D8C-8385-00E2C370EB3C}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnterpriseDataBaseImplement", "EnterpriseDataBaseImplement\EnterpriseDataBaseImplement.csproj", "{FAFF75D4-135E-40E3-BC83-A3B41C3D167E}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -15,18 +17,22 @@ Global
|
|||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{3FEAB427-D75C-442E-B5FE-6285202B442C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{3FEAB427-D75C-442E-B5FE-6285202B442C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{3FEAB427-D75C-442E-B5FE-6285202B442C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{3FEAB427-D75C-442E-B5FE-6285202B442C}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{64CD7137-E0BF-4F35-8F33-B07AFED1393F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{64CD7137-E0BF-4F35-8F33-B07AFED1393F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{64CD7137-E0BF-4F35-8F33-B07AFED1393F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{64CD7137-E0BF-4F35-8F33-B07AFED1393F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{64CD7137-E0BF-4F35-8F33-B07AFED1393F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{64CD7137-E0BF-4F35-8F33-B07AFED1393F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{64CD7137-E0BF-4F35-8F33-B07AFED1393F}.Release|Any CPU.Build.0 = Release|Any CPU
|
{64CD7137-E0BF-4F35-8F33-B07AFED1393F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{E162208D-662D-4419-9B33-A61189E0CC20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{196E0D33-EA70-42F0-AF4F-BD66843AB836}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{E162208D-662D-4419-9B33-A61189E0CC20}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{196E0D33-EA70-42F0-AF4F-BD66843AB836}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E162208D-662D-4419-9B33-A61189E0CC20}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{196E0D33-EA70-42F0-AF4F-BD66843AB836}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E162208D-662D-4419-9B33-A61189E0CC20}.Release|Any CPU.Build.0 = Release|Any CPU
|
{196E0D33-EA70-42F0-AF4F-BD66843AB836}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{45AFE8E1-F8F4-4D8C-8385-00E2C370EB3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{45AFE8E1-F8F4-4D8C-8385-00E2C370EB3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{45AFE8E1-F8F4-4D8C-8385-00E2C370EB3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{45AFE8E1-F8F4-4D8C-8385-00E2C370EB3C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{FAFF75D4-135E-40E3-BC83-A3B41C3D167E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FAFF75D4-135E-40E3-BC83-A3B41C3D167E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FAFF75D4-135E-40E3-BC83-A3B41C3D167E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{FAFF75D4-135E-40E3-BC83-A3B41C3D167E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Reference in New Issue
Block a user