diff --git a/EmployeeManagmentBusinessLogic/BusinessLogic/PhisicalPersonLogic.cs b/EmployeeManagmentBusinessLogic/BusinessLogic/PhisicalPersonLogic.cs index bd92558..8185cef 100644 --- a/EmployeeManagmentBusinessLogic/BusinessLogic/PhisicalPersonLogic.cs +++ b/EmployeeManagmentBusinessLogic/BusinessLogic/PhisicalPersonLogic.cs @@ -9,115 +9,68 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using EmployeeManagmentContracts.StoragesContracts; +using Microsoft.Extensions.Logging; +using EmployeeManagmentDataBaseImplement.Implements; namespace EmployeeManagmentBusinessLogic.BusinessLogic { public class PhisicalPersonLogic : IPhisicalPersonLogic { - private readonly EmployeeManagementDbContext _context; + private readonly ILogger<PhisicalPersonLogic> _logger; + private readonly IPhisicalPersonStorage _phisicalPersonStorage; - public PhisicalPersonLogic(EmployeeManagementDbContext context) + public PhisicalPersonLogic(ILogger<PhisicalPersonLogic> logger, IPhisicalPersonStorage phisicalPersonStorage) { - _context = context; + _logger = logger; + _phisicalPersonStorage = phisicalPersonStorage; } - public void CreateOrUpdate(PhisicalPersonBindingModel model) + public List<PhisicalPersonViewModel> GetFullList() { - PhisicalPerson? person = _context.PhysicalPersons - .FirstOrDefault(p => p.Id == model.Id); + return _phisicalPersonStorage.GetFullList(); + } - if (person == null) + public List<PhisicalPersonViewModel> GetFilteredList(PhisicalPersonSearchModel model) + { + return _phisicalPersonStorage.GetFilteredList(model); + } + + public PhisicalPersonViewModel? GetElement(int id) + { + return _phisicalPersonStorage.GetElement(id); + } + + public void Insert(PhisicalPersonViewModel model) + { + if (string.IsNullOrWhiteSpace(model.Name) || string.IsNullOrWhiteSpace(model.Surname)) { - // Создание нового - person = new PhisicalPerson - { - Name = model.Name, - Surname = model.Surname, - Patronymic = model.Patronomic, - Birthday = model.Birthday, - Gender = model.Gender, - Address = model.Address, - Telephone = model.Telephone - }; - _context.PhysicalPersons.Add(person); - } - else - { - // Обновление существующего - person.Name = model.Name; - person.Surname = model.Surname; - person.Patronymic = model.Patronomic; - person.Birthday = model.Birthday; - person.Gender = model.Gender; - person.Address = model.Address; - person.Telephone = model.Telephone; + throw new ArgumentException("Имя и фамилия обязательны для заполнения."); } - _context.SaveChanges(); + _phisicalPersonStorage.Insert(model); + } + + public void Update(PhisicalPersonViewModel model) + { + var element = _phisicalPersonStorage.GetElement(model.Id); + if (element == null) + { + throw new ArgumentException("Элемент не найден."); + } + + _phisicalPersonStorage.Update(model); } public void Delete(int id) { - var person = _context.PhysicalPersons.FirstOrDefault(p => p.Id == id); - if (person != null) + var element = _phisicalPersonStorage.GetElement(id); + if (element == null) { - _context.PhysicalPersons.Remove(person); - _context.SaveChanges(); - } - } - - public PhisicalPersonViewModel? GetPhisicalPersonById(int id) - { - var person = _context.PhysicalPersons - .Where(p => p.Id == id) - .Select(p => new PhisicalPersonViewModel - { - Id = p.Id, - Name = p.Name, - Surname = p.Surname, - Patronomic = p.Patronymic, - Birthday = p.Birthday, - Gender = p.Gender, - Address = p.Address, - Telephone = p.Telephone - }) - .FirstOrDefault(); - - return person; - } - - public List<PhisicalPersonViewModel> GetPhisicalPersons(PhisicalPersonSearchModel model) - { - var query = _context.PhysicalPersons.AsQueryable(); - - if (!string.IsNullOrEmpty(model.Name)) - { - query = query.Where(p => p.Name.Contains(model.Name)); + throw new ArgumentException("Элемент не найден."); } - if (!string.IsNullOrEmpty(model.Surname)) - { - query = query.Where(p => p.Surname.Contains(model.Surname)); - } - - if (!string.IsNullOrEmpty(model.Patronomic)) - { - query = query.Where(p => p.Patronymic.Contains(model.Patronomic)); - } - - return query - .Select(p => new PhisicalPersonViewModel - { - Id = p.Id, - Name = p.Name, - Surname = p.Surname, - Patronomic = p.Patronymic, - Birthday = p.Birthday, - Gender = p.Gender, - Address = p.Address, - Telephone = p.Telephone - }) - .ToList(); + _phisicalPersonStorage.Delete(id); } } } diff --git a/EmployeeManagmentBusinessLogic/BusinessLogic/SalaryLogic.cs b/EmployeeManagmentBusinessLogic/BusinessLogic/SalaryLogic.cs index 245c06b..c9d3a3f 100644 --- a/EmployeeManagmentBusinessLogic/BusinessLogic/SalaryLogic.cs +++ b/EmployeeManagmentBusinessLogic/BusinessLogic/SalaryLogic.cs @@ -3,14 +3,20 @@ using EmployeeManagmentContracts.BusinessLogicContracts; using EmployeeManagmentContracts.SearchModels; using EmployeeManagmentContracts.StoragesContracts; using EmployeeManagmentContracts.ViewModels; +using EmployeeManagmentDataBaseImplement.Implements; +using Microsoft.Extensions.Logging; namespace EmployeeManagmentBusinessLogic.BusinessLogic { public class SalaryLogic : ISalaryLogic { - public void CreateOrUpdate(SalaryBindingModel model) + private readonly ILogger _logger; + private readonly ISalaryStorage _salaryStorage; + + public SalaryLogic(ILogger<SalaryLogic> logger, ISalaryStorage salaryStorage) { - throw new NotImplementedException(); + _logger = logger; + _salaryStorage = salaryStorage; } public void Delete(int id) @@ -18,12 +24,27 @@ namespace EmployeeManagmentBusinessLogic.BusinessLogic throw new NotImplementedException(); } - public List<SalaryViewModel> GetSalaries(SalarySearchModel model) + public PhisicalPersonViewModel? GetElement(int id) { throw new NotImplementedException(); } - public SalaryViewModel? GetSalaryById(int id) + public List<PhisicalPersonViewModel> GetFilteredList(PhisicalPersonSearchModel model) + { + throw new NotImplementedException(); + } + + public List<PhisicalPersonViewModel> GetFullList() + { + throw new NotImplementedException(); + } + + public void Insert(PhisicalPersonViewModel model) + { + throw new NotImplementedException(); + } + + public void Update(PhisicalPersonViewModel model) { throw new NotImplementedException(); } diff --git a/EmployeeManagmentBusinessLogic/BusinessLogic/VacationLogic.cs b/EmployeeManagmentBusinessLogic/BusinessLogic/VacationLogic.cs index 2fc1f7a..589f194 100644 --- a/EmployeeManagmentBusinessLogic/BusinessLogic/VacationLogic.cs +++ b/EmployeeManagmentBusinessLogic/BusinessLogic/VacationLogic.cs @@ -3,14 +3,20 @@ using EmployeeManagmentContracts.BusinessLogicContracts; using EmployeeManagmentContracts.SearchModels; using EmployeeManagmentContracts.StoragesContracts; using EmployeeManagmentContracts.ViewModels; +using EmployeeManagmentDataBaseImplement.Implements; +using Microsoft.Extensions.Logging; namespace EmployeeManagmentBusinessLogic.BusinessLogic { public class VacationLogic : IVacationLogic { - public void CreateOrUpdate(VacationBindingModel model) + private readonly ILogger _logger; + private readonly IVacationStorage _vacationStorage; + + public VacationLogic(ILogger<VacationLogic> logger, IVacationStorage vacationStorage) { - throw new NotImplementedException(); + _logger = logger; + _vacationStorage = vacationStorage; } public void Delete(int id) @@ -18,12 +24,27 @@ namespace EmployeeManagmentBusinessLogic.BusinessLogic throw new NotImplementedException(); } - public VacationViewModel? GetVacationById(int id) + public PhisicalPersonViewModel? GetElement(int id) { throw new NotImplementedException(); } - public List<VacationViewModel> GetVacations(VacationSearchModel model) + public List<PhisicalPersonViewModel> GetFilteredList(EmployeeSearchModel model) + { + throw new NotImplementedException(); + } + + public List<PhisicalPersonViewModel> GetFullList() + { + throw new NotImplementedException(); + } + + public void Insert(PhisicalPersonViewModel model) + { + throw new NotImplementedException(); + } + + public void Update(PhisicalPersonViewModel model) { throw new NotImplementedException(); } diff --git a/EmployeeManagmentContracts/BusinessLogicContracts/IPhisicalPersonLogic.cs b/EmployeeManagmentContracts/BusinessLogicContracts/IPhisicalPersonLogic.cs index 6e723b6..92447da 100644 --- a/EmployeeManagmentContracts/BusinessLogicContracts/IPhisicalPersonLogic.cs +++ b/EmployeeManagmentContracts/BusinessLogicContracts/IPhisicalPersonLogic.cs @@ -11,9 +11,11 @@ namespace EmployeeManagmentContracts.BusinessLogicContracts { public interface IPhisicalPersonLogic { - List<PhisicalPersonViewModel> GetPhisicalPersons(PhisicalPersonSearchModel model); - PhisicalPersonViewModel? GetPhisicalPersonById(int id); - void CreateOrUpdate(PhisicalPersonBindingModel model); + List<PhisicalPersonViewModel> GetFullList(); + List<PhisicalPersonViewModel> GetFilteredList(PhisicalPersonSearchModel model); + PhisicalPersonViewModel? GetElement(int id); + void Insert(PhisicalPersonViewModel model); + void Update(PhisicalPersonViewModel model); void Delete(int id); } } diff --git a/EmployeeManagmentContracts/BusinessLogicContracts/ISalaryLogic.cs b/EmployeeManagmentContracts/BusinessLogicContracts/ISalaryLogic.cs index f43d593..8501144 100644 --- a/EmployeeManagmentContracts/BusinessLogicContracts/ISalaryLogic.cs +++ b/EmployeeManagmentContracts/BusinessLogicContracts/ISalaryLogic.cs @@ -11,9 +11,11 @@ namespace EmployeeManagmentContracts.BusinessLogicContracts { public interface ISalaryLogic { - List<SalaryViewModel> GetSalaries(SalarySearchModel model); - SalaryViewModel? GetSalaryById(int id); - void CreateOrUpdate(SalaryBindingModel model); + List<PhisicalPersonViewModel> GetFullList(); + List<PhisicalPersonViewModel> GetFilteredList(PhisicalPersonSearchModel model); + PhisicalPersonViewModel? GetElement(int id); + void Insert(PhisicalPersonViewModel model); + void Update(PhisicalPersonViewModel model); void Delete(int id); } diff --git a/EmployeeManagmentContracts/BusinessLogicContracts/IVacationLogic.cs b/EmployeeManagmentContracts/BusinessLogicContracts/IVacationLogic.cs index 0cd9b60..2c2570e 100644 --- a/EmployeeManagmentContracts/BusinessLogicContracts/IVacationLogic.cs +++ b/EmployeeManagmentContracts/BusinessLogicContracts/IVacationLogic.cs @@ -11,9 +11,11 @@ namespace EmployeeManagmentContracts.BusinessLogicContracts { public interface IVacationLogic { - List<VacationViewModel> GetVacations(VacationSearchModel model); - VacationViewModel? GetVacationById(int id); - void CreateOrUpdate(VacationBindingModel model); + List<PhisicalPersonViewModel> GetFullList(); + List<PhisicalPersonViewModel> GetFilteredList(EmployeeSearchModel model); + PhisicalPersonViewModel? GetElement(int id); + void Insert(PhisicalPersonViewModel model); + void Update(PhisicalPersonViewModel model); void Delete(int id); } } diff --git a/EmployeeManagmentContracts/ViewModels/PhisicalPersonViewModel.cs b/EmployeeManagmentContracts/ViewModels/PhisicalPersonViewModel.cs index f9f1a09..b5fca96 100644 --- a/EmployeeManagmentContracts/ViewModels/PhisicalPersonViewModel.cs +++ b/EmployeeManagmentContracts/ViewModels/PhisicalPersonViewModel.cs @@ -11,7 +11,7 @@ namespace EmployeeManagmentContracts.ViewModels public int Id { get; set; } public string Name { get; set; } = string.Empty; public string Surname { get; set; } = string.Empty; - public string Patronomic { get; set; } = string.Empty; + public string Patronymic { get; set; } = string.Empty; public DateTime Birthday { get; set; } public string Gender { get; set; } = string.Empty; public string Address { get; set; } = string.Empty; diff --git a/EmployeeManagmentDataBaseImplement/Implements/PhisicalPersonStorage.cs b/EmployeeManagmentDataBaseImplement/Implements/PhisicalPersonStorage.cs index d9b2d4a..1c5f103 100644 --- a/EmployeeManagmentDataBaseImplement/Implements/PhisicalPersonStorage.cs +++ b/EmployeeManagmentDataBaseImplement/Implements/PhisicalPersonStorage.cs @@ -2,6 +2,7 @@ using EmployeeManagmentContracts.SearchModels; using EmployeeManagmentContracts.StoragesContracts; using EmployeeManagmentContracts.ViewModels; +using EmployeeManagmentDataBaseImplement.Models; using System; using System.Collections.Generic; using System.Linq; @@ -12,34 +13,117 @@ namespace EmployeeManagmentDataBaseImplement.Implements { public class PhisicalPersonStorage : IPhisicalPersonStorage { - public void Delete(int id) - { - throw new NotImplementedException(); - } - - public PhisicalPersonViewModel? GetElement(int id) - { - throw new NotImplementedException(); - } - - public List<PhisicalPersonViewModel> GetFilteredList(PhisicalPersonSearchModel model) - { - throw new NotImplementedException(); - } - + // Метод для получения полного списка public List<PhisicalPersonViewModel> GetFullList() { - throw new NotImplementedException(); + using var context = new EmployeeManagementDbContext(); + + return context.PhysicalPersons + .Select(p => new PhisicalPersonViewModel + { + Id = p.Id, + Name = p.Name, + Surname = p.Surname, + Patronymic = p.Patronymic, + Birthday = p.Birthday, + Gender = p.Gender, + Address = p.Address, + Telephone = p.Telephone + }).ToList(); } + // Метод для получения отфильтрованного списка + public List<PhisicalPersonViewModel> GetFilteredList(PhisicalPersonSearchModel model) + { + using var context = new EmployeeManagementDbContext(); + + if (model == null) return new List<PhisicalPersonViewModel>(); + + return context.PhysicalPersons + .Where(p => p.Surname.Contains(model.Surname ?? string.Empty)) + .Select(p => new PhisicalPersonViewModel + { + Id = p.Id, + Name = p.Name, + Surname = p.Surname, + Patronymic = p.Patronymic, + Birthday = p.Birthday, + Gender = p.Gender, + Address = p.Address, + Telephone = p.Telephone + }).ToList(); + } + + // Метод для получения одного элемента по ID + public PhisicalPersonViewModel? GetElement(int id) + { + using var context = new EmployeeManagementDbContext(); + + var entity = context.PhysicalPersons.FirstOrDefault(p => p.Id == id); + return entity == null ? null : new PhisicalPersonViewModel + { + Id = entity.Id, + Name = entity.Name, + Surname = entity.Surname, + Patronymic = entity.Patronymic, + Birthday = entity.Birthday, + Gender = entity.Gender, + Address = entity.Address, + Telephone = entity.Telephone + }; + } + + // Метод для добавления нового физического лица public void Insert(PhisicalPersonViewModel model) { - throw new NotImplementedException(); + using var context = new EmployeeManagementDbContext(); + + var newPerson = new PhisicalPerson + { + Name = model.Name, + Surname = model.Surname, + Patronymic = model.Patronymic, + Birthday = model.Birthday, + Gender = model.Gender, + Address = model.Address, + Telephone = model.Telephone + }; + + context.PhysicalPersons.Add(newPerson); + context.SaveChanges(); } + // Метод для обновления физического лица public void Update(PhisicalPersonViewModel model) { - throw new NotImplementedException(); + using var context = new EmployeeManagementDbContext(); + + var entity = context.PhysicalPersons.FirstOrDefault(p => p.Id == model.Id); + if (entity != null) + { + entity.Name = model.Name; + entity.Surname = model.Surname; + entity.Patronymic = model.Patronymic; + entity.Birthday = model.Birthday; + entity.Gender = model.Gender; + entity.Address = model.Address; + entity.Telephone = model.Telephone; + + context.SaveChanges(); + } + } + + // Метод для удаления физического лица + public void Delete(int id) + { + using var context = new EmployeeManagementDbContext(); + + var entity = context.PhysicalPersons.FirstOrDefault(p => p.Id == id); + if (entity != null) + { + context.PhysicalPersons.Remove(entity); + context.SaveChanges(); + } } } } diff --git a/EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.Designer.cs b/EmployeeManagmentDataBaseImplement/Migrations/20241126175607_Init.Designer.cs similarity index 90% rename from EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.Designer.cs rename to EmployeeManagmentDataBaseImplement/Migrations/20241126175607_Init.Designer.cs index dc8bd25..49f1eb5 100644 --- a/EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.Designer.cs +++ b/EmployeeManagmentDataBaseImplement/Migrations/20241126175607_Init.Designer.cs @@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace EmployeeManagmentDataBaseImplement.Migrations { [DbContext(typeof(EmployeeManagementDbContext))] - [Migration("20241124115213_InitMigration")] - partial class InitMigration + [Migration("20241126175607_Init")] + partial class Init { /// <inheritdoc /> protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -46,7 +46,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations b.Property<string>("PartTimeJob") .HasColumnType("text"); - b.Property<int>("PhisicalPersonsId") + b.Property<int?>("PhisicalPersonsId") .HasColumnType("integer"); b.Property<DateTime?>("StartJob") @@ -112,7 +112,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations b.Property<DateTime?>("Data") .HasColumnType("timestamp with time zone"); - b.Property<int>("EmployeesId") + b.Property<int?>("EmployeesId") .HasColumnType("integer"); b.Property<bool>("Passed") @@ -139,7 +139,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int>("EmployeesId") + b.Property<int?>("EmployeesId") .HasColumnType("integer"); b.Property<DateTime>("EndData") @@ -162,9 +162,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.HasOne("EmployeeManagmentDataBaseImplement.Models.PhisicalPerson", "PhisicalPerson") .WithMany("Employees") - .HasForeignKey("PhisicalPersonsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("PhisicalPersonsId"); b.Navigation("PhisicalPerson"); }); @@ -173,9 +171,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.HasOne("EmployeeManagmentDataBaseImplement.Models.Employee", "Employee") .WithMany("Salaries") - .HasForeignKey("EmployeesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("EmployeesId"); b.Navigation("Employee"); }); @@ -184,9 +180,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.HasOne("EmployeeManagmentDataBaseImplement.Models.Employee", "Employee") .WithMany("Vacations") - .HasForeignKey("EmployeesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("EmployeesId"); b.Navigation("Employee"); }); diff --git a/EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.cs b/EmployeeManagmentDataBaseImplement/Migrations/20241126175607_Init.cs similarity index 92% rename from EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.cs rename to EmployeeManagmentDataBaseImplement/Migrations/20241126175607_Init.cs index 74efa7b..96c27e0 100644 --- a/EmployeeManagmentDataBaseImplement/Migrations/20241124115213_InitMigration.cs +++ b/EmployeeManagmentDataBaseImplement/Migrations/20241126175607_Init.cs @@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace EmployeeManagmentDataBaseImplement.Migrations { /// <inheritdoc /> - public partial class InitMigration : Migration + public partial class Init : Migration { /// <inheritdoc /> protected override void Up(MigrationBuilder migrationBuilder) @@ -42,7 +42,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations EndJob = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), PartTimeJob = table.Column<string>(type: "text", nullable: true), Bid = table.Column<float>(type: "real", nullable: false), - PhisicalPersonsId = table.Column<int>(type: "integer", nullable: false) + PhisicalPersonsId = table.Column<int>(type: "integer", nullable: true) }, constraints: table => { @@ -51,8 +51,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations name: "FK_Employees_PhysicalPersons_PhisicalPersonsId", column: x => x.PhisicalPersonsId, principalTable: "PhysicalPersons", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); }); migrationBuilder.CreateTable( @@ -66,7 +65,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations Premium = table.Column<float>(type: "real", nullable: true), Data = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), Passed = table.Column<bool>(type: "boolean", nullable: false), - EmployeesId = table.Column<int>(type: "integer", nullable: false) + EmployeesId = table.Column<int>(type: "integer", nullable: true) }, constraints: table => { @@ -75,8 +74,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations name: "FK_Salaries_Employees_EmployeesId", column: x => x.EmployeesId, principalTable: "Employees", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); }); migrationBuilder.CreateTable( @@ -88,7 +86,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations StartData = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), EndData = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), Passed = table.Column<bool>(type: "boolean", nullable: false), - EmployeesId = table.Column<int>(type: "integer", nullable: false) + EmployeesId = table.Column<int>(type: "integer", nullable: true) }, constraints: table => { @@ -97,8 +95,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations name: "FK_Vacations_Employees_EmployeesId", column: x => x.EmployeesId, principalTable: "Employees", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); }); migrationBuilder.CreateIndex( diff --git a/EmployeeManagmentDataBaseImplement/Migrations/EmployeeManagementDbContextModelSnapshot.cs b/EmployeeManagmentDataBaseImplement/Migrations/EmployeeManagementDbContextModelSnapshot.cs index f7d9ffe..7e2ec9b 100644 --- a/EmployeeManagmentDataBaseImplement/Migrations/EmployeeManagementDbContextModelSnapshot.cs +++ b/EmployeeManagmentDataBaseImplement/Migrations/EmployeeManagementDbContextModelSnapshot.cs @@ -43,7 +43,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations b.Property<string>("PartTimeJob") .HasColumnType("text"); - b.Property<int>("PhisicalPersonsId") + b.Property<int?>("PhisicalPersonsId") .HasColumnType("integer"); b.Property<DateTime?>("StartJob") @@ -109,7 +109,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations b.Property<DateTime?>("Data") .HasColumnType("timestamp with time zone"); - b.Property<int>("EmployeesId") + b.Property<int?>("EmployeesId") .HasColumnType("integer"); b.Property<bool>("Passed") @@ -136,7 +136,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); - b.Property<int>("EmployeesId") + b.Property<int?>("EmployeesId") .HasColumnType("integer"); b.Property<DateTime>("EndData") @@ -159,9 +159,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.HasOne("EmployeeManagmentDataBaseImplement.Models.PhisicalPerson", "PhisicalPerson") .WithMany("Employees") - .HasForeignKey("PhisicalPersonsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("PhisicalPersonsId"); b.Navigation("PhisicalPerson"); }); @@ -170,9 +168,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.HasOne("EmployeeManagmentDataBaseImplement.Models.Employee", "Employee") .WithMany("Salaries") - .HasForeignKey("EmployeesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("EmployeesId"); b.Navigation("Employee"); }); @@ -181,9 +177,7 @@ namespace EmployeeManagmentDataBaseImplement.Migrations { b.HasOne("EmployeeManagmentDataBaseImplement.Models.Employee", "Employee") .WithMany("Vacations") - .HasForeignKey("EmployeesId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("EmployeesId"); b.Navigation("Employee"); }); diff --git a/EmployeeManagmentDataBaseImplement/Models/Employee.cs b/EmployeeManagmentDataBaseImplement/Models/Employee.cs index 826a117..23429bd 100644 --- a/EmployeeManagmentDataBaseImplement/Models/Employee.cs +++ b/EmployeeManagmentDataBaseImplement/Models/Employee.cs @@ -20,7 +20,7 @@ namespace EmployeeManagmentDataBaseImplement.Models public float Bid { get; set; } [ForeignKey("PhisicalPerson")] - public int PhisicalPersonsId { get; set; } + public int? PhisicalPersonsId { get; set; } public PhisicalPerson? PhisicalPerson { get; set; } public List<Salary> Salaries { get; set; } = new(); diff --git a/EmployeeManagmentDataBaseImplement/Models/Salary.cs b/EmployeeManagmentDataBaseImplement/Models/Salary.cs index d3c9304..54c90fd 100644 --- a/EmployeeManagmentDataBaseImplement/Models/Salary.cs +++ b/EmployeeManagmentDataBaseImplement/Models/Salary.cs @@ -21,7 +21,7 @@ namespace EmployeeManagmentDataBaseImplement.Models public bool Passed { get; set; } [ForeignKey("Employee")] - public int EmployeesId { get; set; } + public int? EmployeesId { get; set; } public Employee? Employee { get; set; } } } diff --git a/EmployeeManagmentDataBaseImplement/Models/Vacation.cs b/EmployeeManagmentDataBaseImplement/Models/Vacation.cs index bec2b39..0e01422 100644 --- a/EmployeeManagmentDataBaseImplement/Models/Vacation.cs +++ b/EmployeeManagmentDataBaseImplement/Models/Vacation.cs @@ -19,7 +19,7 @@ namespace EmployeeManagmentDataBaseImplement.Models public bool Passed { get; set; } [ForeignKey("Employee")] - public int EmployeesId { get; set; } + public int? EmployeesId { get; set; } public Employee? Employee { get; set; } } } diff --git a/EmployeeManagmentDataModels/Models/IEmployee.cs b/EmployeeManagmentDataModels/Models/IEmployee.cs index f19e68d..c840229 100644 --- a/EmployeeManagmentDataModels/Models/IEmployee.cs +++ b/EmployeeManagmentDataModels/Models/IEmployee.cs @@ -15,6 +15,6 @@ namespace EmployeeManagmentDataModels.Models DateTime? EndJob { get; set; } string? PartTimeJob { get; set; } float Bid { get; set; } - int PhisicalPersonsId { get; set; } + int? PhisicalPersonsId { get; set; } } } diff --git a/EmployeeManagmentDataModels/Models/ISalary.cs b/EmployeeManagmentDataModels/Models/ISalary.cs index 6dcdabc..ba9efd9 100644 --- a/EmployeeManagmentDataModels/Models/ISalary.cs +++ b/EmployeeManagmentDataModels/Models/ISalary.cs @@ -14,6 +14,6 @@ namespace EmployeeManagmentDataModels.Models float? Premium { get; set; } DateTime? Data { get; set; } bool Passed { get; set; } - int EmployeesId { get; set; } + int? EmployeesId { get; set; } } } diff --git a/EmployeeManagmentDataModels/Models/IVacation.cs b/EmployeeManagmentDataModels/Models/IVacation.cs index 4dc0f87..9503a8c 100644 --- a/EmployeeManagmentDataModels/Models/IVacation.cs +++ b/EmployeeManagmentDataModels/Models/IVacation.cs @@ -13,6 +13,6 @@ namespace EmployeeManagmentDataModels.Models DateTime StartData { get; set; } DateTime EndData { get; set; } bool Passed { get; set; } - int EmployeesId { get; set; } + int? EmployeesId { get; set; } } } diff --git a/EmployeeManagmentView/App.xaml b/EmployeeManagmentView/App.xaml index dac89bc..a468742 100644 --- a/EmployeeManagmentView/App.xaml +++ b/EmployeeManagmentView/App.xaml @@ -2,6 +2,101 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Application.Resources> - + <!-- Стиль для закругленных кнопок --> + <Style x:Key="RoundedButtonStyle" TargetType="Button"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="Button"> + <Grid> + <!-- Тень кнопки --> + <Border Background="{TemplateBinding Background}" + CornerRadius="15" + BorderBrush="Transparent" + BorderThickness="0" + x:Name="ButtonBorder"> + <Border.Effect> + <DropShadowEffect Color="Black" BlurRadius="10" ShadowDepth="2" Opacity="0.4" /> + </Border.Effect> + <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> + </Border> + </Grid> + <ControlTemplate.Triggers> + <!-- Анимация цвета при наведении --> + <Trigger Property="IsMouseOver" Value="True"> + <Trigger.EnterActions> + <BeginStoryboard> + <Storyboard> + <ColorAnimation Storyboard.TargetName="ButtonBorder" + Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" + To="#0066CC" Duration="0:0:0.2" /> + </Storyboard> + </BeginStoryboard> + </Trigger.EnterActions> + <Trigger.ExitActions> + <BeginStoryboard> + <Storyboard> + <ColorAnimation Storyboard.TargetName="ButtonBorder" + Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" + To="#004890" Duration="0:0:0.2" /> + </Storyboard> + </BeginStoryboard> + </Trigger.ExitActions> + </Trigger> + + <!-- Анимация сжатия при нажатии --> + <Trigger Property="IsPressed" Value="True"> + <Setter Property="RenderTransform" TargetName="ButtonBorder"> + <Setter.Value> + <ScaleTransform ScaleX="0.95" ScaleY="0.95" /> + </Setter.Value> + </Setter> + <Setter TargetName="ButtonBorder" Property="Effect"> + <Setter.Value> + <DropShadowEffect Color="Black" BlurRadius="15" ShadowDepth="0" Opacity="0.6" /> + </Setter.Value> + </Setter> + </Trigger> + </ControlTemplate.Triggers> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <!-- Стиль для закругленного TextBox --> + <Style x:Key="RoundedTextBoxStyle" TargetType="TextBox"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="TextBox"> + <Border Background="White" + CornerRadius="15" + BorderBrush="Gray" + BorderThickness="1"> + <ScrollViewer Margin="5" x:Name="PART_ContentHost"/> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <!-- Стиль для закругленного ComboBox --> + <Style x:Key="RoundedComboBoxStyle" TargetType="ComboBox"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="ComboBox"> + <Border Background="White" + CornerRadius="15" + BorderBrush="Gray" + BorderThickness="1"> + <Grid> + <ToggleButton Grid.Column="2" Focusable="False" + ClickMode="Press" /> + <ContentPresenter /> + </Grid> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + </Application.Resources> </Application> diff --git a/EmployeeManagmentView/App.xaml.cs b/EmployeeManagmentView/App.xaml.cs index b7ae8b3..68cbf54 100644 --- a/EmployeeManagmentView/App.xaml.cs +++ b/EmployeeManagmentView/App.xaml.cs @@ -47,11 +47,11 @@ namespace EmployeeManagmentView services.AddTransient<IPhisicalPersonLogic, PhisicalPersonLogic>(); services.AddTransient<IEmployeeLogic, EmployeeLogic>(); + services.AddTransient<ISalaryLogic, SalaryLogic>(); + services.AddTransient<IVacationLogic, VacationLogic>(); services.AddTransient<MainWindow>(); - services.AddTransient<EmployeesWindow>(); - services.AddTransient<SalariesWindow>(); - services.AddTransient<VacationsWindow>(); + } diff --git a/EmployeeManagmentView/EmployeesWindow.xaml b/EmployeeManagmentView/EmployeesWindow.xaml deleted file mode 100644 index d7487bb..0000000 --- a/EmployeeManagmentView/EmployeesWindow.xaml +++ /dev/null @@ -1,8 +0,0 @@ -<Window x:Class="EmployeeManagmentView.EmployeesWindow" - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - Title="Employees" Height="450" Width="800"> - <Grid> - <TextBlock Text="Список сотрудников" HorizontalAlignment="Center" VerticalAlignment="Center"/> - </Grid> -</Window> diff --git a/EmployeeManagmentView/EmployeesWindow.xaml.cs b/EmployeeManagmentView/EmployeesWindow.xaml.cs deleted file mode 100644 index 02752bb..0000000 --- a/EmployeeManagmentView/EmployeesWindow.xaml.cs +++ /dev/null @@ -1,29 +0,0 @@ -using EmployeeManagmentBusinessLogic.BusinessLogic; -using EmployeeManagmentContracts.BusinessLogicContracts; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; - -namespace EmployeeManagmentView -{ - /// <summary> - /// Логика взаимодействия для EmployeesWindow.xaml - /// </summary> - public partial class EmployeesWindow : Window - { - public EmployeesWindow() - { - InitializeComponent(); - } - } -} diff --git a/EmployeeManagmentView/MainWindow.xaml b/EmployeeManagmentView/MainWindow.xaml index 55a6cbf..587d67f 100644 --- a/EmployeeManagmentView/MainWindow.xaml +++ b/EmployeeManagmentView/MainWindow.xaml @@ -1,32 +1,26 @@ <Window x:Class="EmployeeManagmentView.MainWindow" - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - mc:Ignorable="d" - Title="Employee Management System" - Height="450" Width="800"> + Title="Отдел кадров УлГТУ" Height="450" Width="800" Background="#0D2D4F"> + + <Grid> - <StackPanel> - <TextBlock Text="Система управления сотрудниками" - FontSize="24" - FontWeight="Bold" - Margin="10"/> - <Button Content="Просмотр сотрудников" - Width="200" - Height="40" - Margin="10" - Click="ViewEmployees_Click"/> - <Button Content="Управление зарплатами" - Width="200" - Height="40" - Margin="10" - Click="ManageSalaries_Click"/> - <Button Content="Управление отпусками" - Width="200" - Height="40" - Margin="10" - Click="ManageVacations_Click"/> + <!-- Заголовок --> + <TextBlock Text="Отдел кадров УлГТУ" + HorizontalAlignment="Center" VerticalAlignment="Top" + FontSize="24" FontWeight="Bold" + Foreground="#FFFFFF" Margin="0,20,0,0" /> + + <!-- Центральный StackPanel --> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,40"> + <!-- Кнопка 1 --> + <Button Content="Работа с сотрудниками" Width="200" Height="50" Margin="0,10" + Background="#004890" Foreground="#FFFFFF" FontSize="16" + Style="{StaticResource RoundedButtonStyle}"/> + <!-- Кнопка 2 --> + <Button Content="Работа с физ. лицами" Width="200" Height="50" Margin="0,10" + Background="#004890" Foreground="#FFFFFF" FontSize="16" + Style="{StaticResource RoundedButtonStyle}" Click="OpenPhysicalPersonManagementWindow"/> </StackPanel> </Grid> -</Window> +</Window> \ No newline at end of file diff --git a/EmployeeManagmentView/MainWindow.xaml.cs b/EmployeeManagmentView/MainWindow.xaml.cs index c428579..fbc8a22 100644 --- a/EmployeeManagmentView/MainWindow.xaml.cs +++ b/EmployeeManagmentView/MainWindow.xaml.cs @@ -1,6 +1,7 @@ using EmployeeManagmentBusinessLogic.BusinessLogic; using EmployeeManagmentContracts.BusinessLogicContracts; using EmployeeManagmentContracts.ViewModels; +using EmployeeManagmentView.PhysicalPerson; using System.Windows; namespace EmployeeManagmentView @@ -9,33 +10,22 @@ namespace EmployeeManagmentView { private readonly IEmployeeLogic _employeeLogic; + private readonly IPhisicalPersonLogic _phisicalPersonLogic; // Constructor with Dependency Injection - public MainWindow(IEmployeeLogic employeeLogic) + public MainWindow(IEmployeeLogic employeeLogic, IPhisicalPersonLogic phisicalPersonLogic) { _employeeLogic = employeeLogic; + _phisicalPersonLogic = phisicalPersonLogic; InitializeComponent(); } - private void ViewEmployees_Click(object sender, RoutedEventArgs e) + private void OpenPhysicalPersonManagementWindow(object sender, RoutedEventArgs e) { - // Логика для открытия окна просмотра сотрудников - var employeesWindow = new EmployeesWindow(); - employeesWindow.Show(); + + var physicalPersonWindow = new PhysicalPersonManagementWindow(_phisicalPersonLogic); + physicalPersonWindow.Show(); } - private void ManageSalaries_Click(object sender, RoutedEventArgs e) - { - // Логика для открытия окна управления зарплатами - var salariesWindow = new SalariesWindow(); - salariesWindow.Show(); - } - - private void ManageVacations_Click(object sender, RoutedEventArgs e) - { - // Логика для открытия окна управления отпусками - var vacationsWindow = new VacationsWindow(); - vacationsWindow.Show(); - } } } diff --git a/EmployeeManagmentView/PhysicalPerson/AddPhysicalPersonWindow.xaml b/EmployeeManagmentView/PhysicalPerson/AddPhysicalPersonWindow.xaml new file mode 100644 index 0000000..0c5a007 --- /dev/null +++ b/EmployeeManagmentView/PhysicalPerson/AddPhysicalPersonWindow.xaml @@ -0,0 +1,76 @@ +<Window x:Class="EmployeeManagmentView.PhysicalPerson.AddPhysicalPersonWindow" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + Title="Добавление физического лица" + Height="600" Width="400" + ResizeMode="NoResize" + WindowStartupLocation="CenterScreen" + Background="#0D2D4F"> + + <Grid> + <!-- Заголовок окна --> + <TextBlock Text="Добавление физического лица" + HorizontalAlignment="Center" VerticalAlignment="Top" + FontSize="18" FontWeight="Bold" + Foreground="#FFFFFF" + Margin="0,20,0,0" /> + + <!-- Стек элементов для ввода данных --> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10"> + <!-- Поле для имени --> + <TextBox x:Name="NameTextBox" + Width="250" Height="40" + Style="{StaticResource RoundedTextBoxStyle}" + Margin="0,10" + ToolTip="Введите имя" /> + + <!-- Поле для фамилии --> + <TextBox x:Name="SurnameTextBox" + Width="250" Height="40" + Style="{StaticResource RoundedTextBoxStyle}" + Margin="0,10" + ToolTip="Введите фамилию" /> + + <!-- Поле для отчества --> + <TextBox x:Name="PatronomicTextBox" + Width="250" Height="40" + Style="{StaticResource RoundedTextBoxStyle}" + Margin="0,10" + ToolTip="Введите отчество" /> + + <!-- Поле для выбора даты рождения --> + <DatePicker x:Name="BirthdayPicker" + Width="250" Height="40" + Margin="0,10" + ToolTip="Выберите дату рождения" /> + + <!-- Поле для выбора пола --> + <TextBox x:Name="GenderTextBox" + Width="250" Height="40" + Style="{StaticResource RoundedTextBoxStyle}" + Margin="0,10" + ToolTip="Введите пол" /> + + <!-- Поле для адреса --> + <TextBox x:Name="AddressTextBox" + Width="250" Height="40" + Style="{StaticResource RoundedTextBoxStyle}" + Margin="0,10" + ToolTip="Введите адрес" /> + + <!-- Поле для телефона --> + <TextBox x:Name="TelephoneTextBox" + Width="250" Height="40" + Style="{StaticResource RoundedTextBoxStyle}" + Margin="0,10" + ToolTip="Введите номер телефона" /> + + <!-- Кнопка для добавления физического лица --> + <Button Content="Добавить физическое лицо" + Width="250" Height="40" + Margin="0,10" + Style="{StaticResource RoundedButtonStyle}" + Click="SaveButton_Click"/> + </StackPanel> + </Grid> +</Window> diff --git a/EmployeeManagmentView/PhysicalPerson/AddPhysicalPersonWindow.xaml.cs b/EmployeeManagmentView/PhysicalPerson/AddPhysicalPersonWindow.xaml.cs new file mode 100644 index 0000000..40f98c7 --- /dev/null +++ b/EmployeeManagmentView/PhysicalPerson/AddPhysicalPersonWindow.xaml.cs @@ -0,0 +1,65 @@ +using EmployeeManagmentBusinessLogic.BusinessLogic; +using EmployeeManagmentContracts.BusinessLogicContracts; +using EmployeeManagmentContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace EmployeeManagmentView.PhysicalPerson +{ + /// <summary> + /// Логика взаимодействия для AddPhysicalPersonWindow.xaml + /// </summary> + public partial class AddPhysicalPersonWindow : Window + { + private readonly IPhisicalPersonLogic _phisicalPersonLogic; + + public AddPhysicalPersonWindow(IPhisicalPersonLogic phisicalPersonLogic) + { + _phisicalPersonLogic = phisicalPersonLogic; + InitializeComponent(); + } + + private void SaveButton_Click(object sender, RoutedEventArgs e) + { + try + { + // Создаем модель и заполняем её значениями из элементов интерфейса + var model = new PhisicalPersonViewModel + { + Name = NameTextBox.Text, + Surname = SurnameTextBox.Text, + Patronymic = PatronomicTextBox.Text, + Birthday = BirthdayPicker.SelectedDate.Value.ToUniversalTime(), // Проверка на null не нужна, так как поле обязательное + Gender = GenderTextBox.Text, + Address = AddressTextBox.Text, + Telephone = TelephoneTextBox.Text + }; + + // Вызываем метод Insert из бизнес-логики для добавления данных в базу + _phisicalPersonLogic.Insert(model); + + // Показываем сообщение об успешном добавлении + MessageBox.Show("Данные успешно сохранены!"); + + // Закрываем окно + this.Close(); + } + catch (Exception ex) + { + // В случае ошибки показываем сообщение об ошибке + MessageBox.Show($"Ошибка: {ex.Message}"); + } + } + } +} diff --git a/EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml b/EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml new file mode 100644 index 0000000..32444db --- /dev/null +++ b/EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml @@ -0,0 +1,44 @@ +<Window x:Class="EmployeeManagmentView.PhysicalPerson.PhysicalPersonManagementWindow" +xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + Title="Управление физическими лицами" + Height="300" Width="400" + ResizeMode="NoResize" + WindowStartupLocation="CenterScreen" + Background="#0D2D4F"> + <Grid> + <!-- Заголовок окна --> + <TextBlock Text="Управление физическими лицами" + HorizontalAlignment="Center" VerticalAlignment="Top" + FontSize="18" FontWeight="Bold" + Foreground="#FFFFFF" + Margin="0,20,0,0" /> + + <!-- Стек кнопок --> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <!-- Кнопка "Удаление физического лица" --> + <Button Content="Удаление физического лица" + Width="250" Height="40" + Margin="0,0,0,10" + Style="{StaticResource RoundedButtonStyle}" /> + + <!-- Кнопка "Добавление физического лица" --> + <Button Content="Добавление физического лица" + Width="250" Height="40" + Margin="0,0,0,10" + Style="{StaticResource RoundedButtonStyle}" + Click="OpenAddPhysicalPersonWindow"/> + + <!-- Кнопка "Редактирование физического лица" --> + <Button Content="Редактирование физического лица" + Width="250" Height="40" + Margin="0,0,0,10" + Style="{StaticResource RoundedButtonStyle}" /> + + <!-- Кнопка "Просмотр физических лиц" --> + <Button Content="Просмотр физических лиц" + Width="250" Height="40" + Style="{StaticResource RoundedButtonStyle}" /> + </StackPanel> + </Grid> +</Window> diff --git a/EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml.cs b/EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml.cs new file mode 100644 index 0000000..7eb7248 --- /dev/null +++ b/EmployeeManagmentView/PhysicalPerson/PhysicalPersonManagementWindow.xaml.cs @@ -0,0 +1,38 @@ +using EmployeeManagmentContracts.BusinessLogicContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace EmployeeManagmentView.PhysicalPerson +{ + /// <summary> + /// Логика взаимодействия для PhysicalPersonManagementWindow.xaml + /// </summary> + public partial class PhysicalPersonManagementWindow : Window + { + private readonly IPhisicalPersonLogic _phisicalPersonLogic; + + // Constructor with Dependency Injection + public PhysicalPersonManagementWindow(IPhisicalPersonLogic phisicalPersonLogic) + { + _phisicalPersonLogic = phisicalPersonLogic; + InitializeComponent(); + } + + private void OpenAddPhysicalPersonWindow(object sender, RoutedEventArgs e) + { + var physicalPersonWindow = new AddPhysicalPersonWindow(_phisicalPersonLogic); + physicalPersonWindow.Show(); + } + } +} diff --git a/EmployeeManagmentView/SalariesWindow.xaml b/EmployeeManagmentView/SalariesWindow.xaml deleted file mode 100644 index 2e4b01d..0000000 --- a/EmployeeManagmentView/SalariesWindow.xaml +++ /dev/null @@ -1,8 +0,0 @@ -<Window x:Class="EmployeeManagmentView.SalariesWindow" - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - Title="Salaries" Height="450" Width="800"> - <Grid> - <TextBlock Text="Управление зарплатами" HorizontalAlignment="Center" VerticalAlignment="Center"/> - </Grid> -</Window> diff --git a/EmployeeManagmentView/SalariesWindow.xaml.cs b/EmployeeManagmentView/SalariesWindow.xaml.cs deleted file mode 100644 index 757b4fa..0000000 --- a/EmployeeManagmentView/SalariesWindow.xaml.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; - -namespace EmployeeManagmentView -{ - /// <summary> - /// Логика взаимодействия для SalariesWindow.xaml - /// </summary> - public partial class SalariesWindow : Window - { - public SalariesWindow() - { - InitializeComponent(); - } - } -} diff --git a/EmployeeManagmentView/VacationsWindow.xaml b/EmployeeManagmentView/VacationsWindow.xaml deleted file mode 100644 index dca1565..0000000 --- a/EmployeeManagmentView/VacationsWindow.xaml +++ /dev/null @@ -1,8 +0,0 @@ -<Window x:Class="EmployeeManagmentView.VacationsWindow" - xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - Title="Vacations" Height="450" Width="800"> - <Grid> - <TextBlock Text="Управление отпусками" HorizontalAlignment="Center" VerticalAlignment="Center"/> - </Grid> -</Window> diff --git a/EmployeeManagmentView/VacationsWindow.xaml.cs b/EmployeeManagmentView/VacationsWindow.xaml.cs deleted file mode 100644 index 961887c..0000000 --- a/EmployeeManagmentView/VacationsWindow.xaml.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; - -namespace EmployeeManagmentView -{ - /// <summary> - /// Логика взаимодействия для VacationsWindow.xaml - /// </summary> - public partial class VacationsWindow : Window - { - public VacationsWindow() - { - InitializeComponent(); - } - } -}