diff --git a/EmployeeManagmentApp.sln b/EmployeeManagmentApp.sln index 628ce7c..bd57d1e 100644 --- a/EmployeeManagmentApp.sln +++ b/EmployeeManagmentApp.sln @@ -7,6 +7,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmployeeManagmentView", "Em EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmployeeManagmentContracts", "EmployeeManagmentContracts\EmployeeManagmentContracts.csproj", "{81DBCB6A-C1AD-4DC2-A016-C0ACB64AE2A7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmployeeManagmentBusinessLogic", "EmployeeManagmentBusinessLogic\EmployeeManagmentBusinessLogic.csproj", "{00B118F5-6A3C-4606-8947-88D0288AEFDB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmployeeManagmentDataModels", "EmployeeManagmentDataModels\EmployeeManagmentDataModels.csproj", "{C5293211-E924-4CFA-9DE5-69003D8C9F48}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +25,14 @@ Global {81DBCB6A-C1AD-4DC2-A016-C0ACB64AE2A7}.Debug|Any CPU.Build.0 = Debug|Any CPU {81DBCB6A-C1AD-4DC2-A016-C0ACB64AE2A7}.Release|Any CPU.ActiveCfg = Release|Any CPU {81DBCB6A-C1AD-4DC2-A016-C0ACB64AE2A7}.Release|Any CPU.Build.0 = Release|Any CPU + {00B118F5-6A3C-4606-8947-88D0288AEFDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00B118F5-6A3C-4606-8947-88D0288AEFDB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00B118F5-6A3C-4606-8947-88D0288AEFDB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00B118F5-6A3C-4606-8947-88D0288AEFDB}.Release|Any CPU.Build.0 = Release|Any CPU + {C5293211-E924-4CFA-9DE5-69003D8C9F48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5293211-E924-4CFA-9DE5-69003D8C9F48}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5293211-E924-4CFA-9DE5-69003D8C9F48}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5293211-E924-4CFA-9DE5-69003D8C9F48}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/EmployeeManagmentBusinessLogic/BusinessLogic/EmployeeLogic.cs b/EmployeeManagmentBusinessLogic/BusinessLogic/EmployeeLogic.cs new file mode 100644 index 0000000..b695b48 --- /dev/null +++ b/EmployeeManagmentBusinessLogic/BusinessLogic/EmployeeLogic.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentBusinessLogic.BusinessLogic +{ + public class EmployeeLogic : IEmployeeLogic + { + private readonly IEmployeeStorage _employeeStorage; + + public EmployeeLogic(IEmployeeStorage employeeStorage) + { + _employeeStorage = employeeStorage; + } + + public List GetEmployees(EmployeeSearchModel model) + { + var employees = model == null ? _employeeStorage.GetFullList() : _employeeStorage.GetFilteredList(model); + return employees.Select(e => new EmployeeViewModel + { + Id = e.Id, + NameJob = e.NameJob, + StartJob = e.StartJob, + EndJob = e.EndJob, + PartTimeJob = e.PartTimeJob, + Bid = e.Bid, + PhysicalPersonName = e.PhysicalPerson.Name + }).ToList(); + } + + public EmployeeViewModel? GetEmployeeById(int id) + { + var employee = _employeeStorage.GetElement(id); + return employee != null ? new EmployeeViewModel + { + Id = employee.Id, + NameJob = employee.NameJob, + StartJob = employee.StartJob, + EndJob = employee.EndJob, + PartTimeJob = employee.PartTimeJob, + Bid = employee.Bid, + PhysicalPersonName = employee.PhysicalPerson.Name + } : null; + } + + public void CreateOrUpdate(EmployeeBindingModel model) + { + if (model.Id.HasValue) + { + var existingEmployee = _employeeStorage.GetElement(model.Id.Value); + if (existingEmployee == null) + throw new Exception("Сотрудник не найден"); + + existingEmployee.NameJob = model.NameJob; + existingEmployee.StartJob = model.StartJob; + existingEmployee.EndJob = model.EndJob; + existingEmployee.PartTimeJob = model.PartTimeJob; + existingEmployee.Bid = model.Bid; + existingEmployee.PhysicalPersonId = model.PhysicalPersonId; + + _employeeStorage.Update(existingEmployee); + } + else + { + var newEmployee = new Employee + { + NameJob = model.NameJob, + StartJob = model.StartJob, + EndJob = model.EndJob, + PartTimeJob = model.PartTimeJob, + Bid = model.Bid, + PhysicalPersonId = model.PhysicalPersonId + }; + _employeeStorage.Insert(newEmployee); + } + } + + public void Delete(int id) + { + var employee = _employeeStorage.GetElement(id); + if (employee == null) + throw new Exception("Сотрудник не найден"); + _employeeStorage.Delete(id); + } + } +} diff --git a/EmployeeManagmentBusinessLogic/BusinessLogic/SalaryLogic.cs b/EmployeeManagmentBusinessLogic/BusinessLogic/SalaryLogic.cs new file mode 100644 index 0000000..99a0b2c --- /dev/null +++ b/EmployeeManagmentBusinessLogic/BusinessLogic/SalaryLogic.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentBusinessLogic.BusinessLogic +{ + public class SalaryLogic : ISalaryLogic + { + private readonly ISalaryStorage _salaryStorage; + + public SalaryLogic(ISalaryStorage salaryStorage) + { + _salaryStorage = salaryStorage; + } + + public List GetSalaries(SalarySearchModel model) + { + var salaries = model == null ? _salaryStorage.GetFullList() : _salaryStorage.GetFilteredList(model); + return salaries.Select(s => new SalaryViewModel + { + Id = s.Id, + CountHours = s.CountHours, + PriceHour = s.PriceHour, + Premium = s.Premium, + Date = s.Date, + Passed = s.Passed, + EmployeeName = s.Employee.NameJob + }).ToList(); + } + + public void CreateOrUpdate(SalaryBindingModel model) + { + if (model.Id.HasValue) + { + var existingSalary = _salaryStorage.GetElement(model.Id.Value); + if (existingSalary == null) + throw new Exception("Зарплата не найдена"); + + existingSalary.CountHours = model.CountHours; + existingSalary.PriceHour = model.PriceHour; + existingSalary.Premium = model.Premium; + existingSalary.Date = model.Date; + existingSalary.Passed = model.Passed; + existingSalary.EmployeeId = model.EmployeeId; + + _salaryStorage.Update(existingSalary); + } + else + { + var newSalary = new Salary + { + CountHours = model.CountHours, + PriceHour = model.PriceHour, + Premium = model.Premium, + Date = model.Date, + Passed = model.Passed, + EmployeeId = model.EmployeeId + }; + _salaryStorage.Insert(newSalary); + } + } + + public void Delete(int id) + { + var salary = _salaryStorage.GetElement(id); + if (salary == null) + throw new Exception("Зарплата не найдена"); + _salaryStorage.Delete(id); + } + } +} diff --git a/EmployeeManagmentBusinessLogic/BusinessLogic/VacationLogic.cs b/EmployeeManagmentBusinessLogic/BusinessLogic/VacationLogic.cs new file mode 100644 index 0000000..8587547 --- /dev/null +++ b/EmployeeManagmentBusinessLogic/BusinessLogic/VacationLogic.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentBusinessLogic.BusinessLogic +{ + public class VacationLogic : IVacationLogic + { + private readonly IVacationStorage _vacationStorage; + + public VacationLogic(IVacationStorage vacationStorage) + { + _vacationStorage = vacationStorage; + } + + public List GetVacations(VacationSearchModel model) + { + return _vacationStorage.GetFilteredList(model).Select(v => new VacationViewModel + { + Id = v.Id, + StartData = v.StartData, + EndData = v.EndData, + Passed = v.Passed, + EmployeeName = v.Employee.NameJob + }).ToList(); + } + + public void CreateOrUpdate(VacationBindingModel model) + { + if (model.Id.HasValue) + { + var existingVacation = _vacationStorage.GetElement(model.Id.Value); + if (existingVacation == null) + throw new Exception("Отпуск не найден"); + + existingVacation.StartData = model.StartData; + existingVacation.EndData = model.EndData; + existingVacation.Passed = model.Passed; + existingVacation.EmployeeId = model.EmployeeId; + + _vacationStorage.Update(existingVacation); + } + else + { + var newVacation = new Vacation + { + StartData = model.StartData, + EndData = model.EndData, + Passed = model.Passed, + EmployeeId = model.EmployeeId + }; + _vacationStorage.Insert(newVacation); + } + } + + public void Delete(int id) + { + _vacationStorage.Delete(id); + } + } +} diff --git a/EmployeeManagmentBusinessLogic/EmployeeManagmentBusinessLogic.csproj b/EmployeeManagmentBusinessLogic/EmployeeManagmentBusinessLogic.csproj new file mode 100644 index 0000000..fa71b7a --- /dev/null +++ b/EmployeeManagmentBusinessLogic/EmployeeManagmentBusinessLogic.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/EmployeeManagmentContracts/BindingModels/EmployeeBindingModel.cs b/EmployeeManagmentContracts/BindingModels/EmployeeBindingModel.cs new file mode 100644 index 0000000..47b4f46 --- /dev/null +++ b/EmployeeManagmentContracts/BindingModels/EmployeeBindingModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentContracts.BindingModels +{ + public class EmployeeBindingModel + { + public int? Id { get; set; } + public string NameJob { get; set; } = string.Empty; + public DateTime StartJob { get; set; } + public DateTime? EndJob { get; set; } + public string? PartTimeJob { get; set; } + public float Bid { get; set; } + public int PhysicalPersonId { get; set; } + } +} diff --git a/EmployeeManagmentContracts/BindingModels/SalaryBindingModel.cs b/EmployeeManagmentContracts/BindingModels/SalaryBindingModel.cs new file mode 100644 index 0000000..fd99d85 --- /dev/null +++ b/EmployeeManagmentContracts/BindingModels/SalaryBindingModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentContracts.BindingModels +{ + public class SalaryBindingModel + { + public int? Id { get; set; } + public int CountHours { get; set; } + public float PriceHour { get; set; } + public float? Premium { get; set; } + public DateTime? Date { get; set; } + public bool Passed { get; set; } + public int EmployeeId { get; set; } + } +} diff --git a/EmployeeManagmentContracts/BusinessLogicContracts/IEmployeeLogic.cs b/EmployeeManagmentContracts/BusinessLogicContracts/IEmployeeLogic.cs new file mode 100644 index 0000000..db7e6e9 --- /dev/null +++ b/EmployeeManagmentContracts/BusinessLogicContracts/IEmployeeLogic.cs @@ -0,0 +1,18 @@ +using EmployeeManagmentContracts.BindingModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentContracts.BusinessLogicContracts +{ + public interface IEmployeeLogic + { + List GetEmployees(EmployeeSearchModel model); + EmployeeViewModel? GetEmployeeById(int id); + void CreateOrUpdate(EmployeeBindingModel model); + void Delete(int id); + } + +} diff --git a/EmployeeManagmentContracts/BusinessLogicContracts/ISalaryLogic.cs b/EmployeeManagmentContracts/BusinessLogicContracts/ISalaryLogic.cs new file mode 100644 index 0000000..26a5007 --- /dev/null +++ b/EmployeeManagmentContracts/BusinessLogicContracts/ISalaryLogic.cs @@ -0,0 +1,18 @@ +using EmployeeManagmentContracts.BindingModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentContracts.BusinessLogicContracts +{ + public interface ISalaryLogic + { + List GetSalaries(SalarySearchModel model); + SalaryViewModel? GetSalaryById(int id); + void CreateOrUpdate(SalaryBindingModel model); + void Delete(int id); + } + +} diff --git a/EmployeeManagmentContracts/Class1.cs b/EmployeeManagmentContracts/Class1.cs deleted file mode 100644 index 4c47ca2..0000000 --- a/EmployeeManagmentContracts/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace EmployeeManagmentContracts -{ - public class Class1 - { - - } -} diff --git a/EmployeeManagmentContracts/SearchModels/EmployeeSearchModel.cs b/EmployeeManagmentContracts/SearchModels/EmployeeSearchModel.cs new file mode 100644 index 0000000..89611f5 --- /dev/null +++ b/EmployeeManagmentContracts/SearchModels/EmployeeSearchModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentContracts.SearchModels +{ + public class EmployeeSearchModel + { + public int? Id { get; set; } + public string? NameJob { get; set; } + public DateTime? StartDateFrom { get; set; } + public DateTime? StartDateTo { get; set; } + } +} diff --git a/EmployeeManagmentContracts/SearchModels/VacationSearchModel.cs b/EmployeeManagmentContracts/SearchModels/VacationSearchModel.cs new file mode 100644 index 0000000..3dbb532 --- /dev/null +++ b/EmployeeManagmentContracts/SearchModels/VacationSearchModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentContracts.SearchModels +{ + public class VacationSearchModel + { + public int? Id { get; set; } + public int? EmployeeId { get; set; } + public DateTime? StartData { get; set; } + public DateTime? EndData { get; set; } + } +} diff --git a/EmployeeManagmentContracts/StoragesContracts/IEmployeeStorage.cs b/EmployeeManagmentContracts/StoragesContracts/IEmployeeStorage.cs new file mode 100644 index 0000000..eab9abd --- /dev/null +++ b/EmployeeManagmentContracts/StoragesContracts/IEmployeeStorage.cs @@ -0,0 +1,19 @@ +using EmployeeManagmentContracts.SearchModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentContracts.StoragesContracts +{ + public interface IEmployeeStorage + { + List GetFullList(); + List GetFilteredList(EmployeeSearchModel model); + Employee? GetElement(int id); + void Insert(Employee employee); + void Update(Employee employee); + void Delete(int id); + } +} diff --git a/EmployeeManagmentContracts/StoragesContracts/ISalaryStorage.cs b/EmployeeManagmentContracts/StoragesContracts/ISalaryStorage.cs new file mode 100644 index 0000000..90765bf --- /dev/null +++ b/EmployeeManagmentContracts/StoragesContracts/ISalaryStorage.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentContracts.StoragesContracts +{ + public interface ISalaryStorage + { + List GetFullList(); + List GetFilteredList(SalarySearchModel model); + Salary? GetElement(int id); + void Insert(Salary salary); + void Update(Salary salary); + void Delete(int id); + } +} diff --git a/EmployeeManagmentContracts/ViewModels/EmployeeViewModel.cs b/EmployeeManagmentContracts/ViewModels/EmployeeViewModel.cs new file mode 100644 index 0000000..d81da75 --- /dev/null +++ b/EmployeeManagmentContracts/ViewModels/EmployeeViewModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentContracts.ViewModels +{ + public class EmployeeViewModel + { + public int Id { get; set; } + public string NameJob { get; set; } = string.Empty; + public DateTime StartJob { get; set; } + public DateTime? EndJob { get; set; } + public string? PartTimeJob { get; set; } + public float Bid { get; set; } + public string PhysicalPersonName { get; set; } = string.Empty; + } + +} diff --git a/EmployeeManagmentContracts/ViewModels/SalaryViewModel.cs b/EmployeeManagmentContracts/ViewModels/SalaryViewModel.cs new file mode 100644 index 0000000..1aa84dc --- /dev/null +++ b/EmployeeManagmentContracts/ViewModels/SalaryViewModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentContracts.ViewModels +{ + public class SalaryViewModel + { + public int Id { get; set; } + public int CountHours { get; set; } + public float PriceHour { get; set; } + public float? Premium { get; set; } + public DateTime? Date { get; set; } + public bool Passed { get; set; } + public string EmployeeName { get; set; } = string.Empty; + } +} diff --git a/EmployeeManagmentDataModels/EmployeeManagmentDataModels.csproj b/EmployeeManagmentDataModels/EmployeeManagmentDataModels.csproj new file mode 100644 index 0000000..fa71b7a --- /dev/null +++ b/EmployeeManagmentDataModels/EmployeeManagmentDataModels.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/EmployeeManagmentDataModels/Enums/JobType.cs b/EmployeeManagmentDataModels/Enums/JobType.cs new file mode 100644 index 0000000..f0af672 --- /dev/null +++ b/EmployeeManagmentDataModels/Enums/JobType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentDataModels.Enums +{ + public enum JobType + { + FullTime, // Полная занятость + PartTime, // Неполная занятость + Internship // Стажировка + } +} diff --git a/EmployeeManagmentDataModels/Enums/VacationStatus.cs b/EmployeeManagmentDataModels/Enums/VacationStatus.cs new file mode 100644 index 0000000..b0aeb1a --- /dev/null +++ b/EmployeeManagmentDataModels/Enums/VacationStatus.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentDataModels.Enums +{ + internal class VacationStatus + { + } +} diff --git a/EmployeeManagmentDataModels/Models/Employee.cs b/EmployeeManagmentDataModels/Models/Employee.cs new file mode 100644 index 0000000..8bffa70 --- /dev/null +++ b/EmployeeManagmentDataModels/Models/Employee.cs @@ -0,0 +1,25 @@ +using EmployeeManagmentDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentDataModels.Models +{ + public class Employee + { + public int Id { get; set; } + public string NameJob { get; set; } = string.Empty; + public DateTime StartJob { get; set; } + public DateTime? EndJob { get; set; } + public JobType PartTimeJob { get; set; } + public decimal Bid { get; set; } // Ставка + public int PhysicalPersonId { get; set; } + + // Связь с физическим лицом + public PhysicalPerson? PhysicalPerson { get; set; } + public List? Salaries { get; set; } + public List? Vacations { get; set; } + } +} diff --git a/EmployeeManagmentDataModels/Models/PhysicalPerson.cs b/EmployeeManagmentDataModels/Models/PhysicalPerson.cs new file mode 100644 index 0000000..fc9906d --- /dev/null +++ b/EmployeeManagmentDataModels/Models/PhysicalPerson.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentDataModels.Models +{ + public class PhysicalPerson + { + public int Id { get; set; } + public string Name { get; set; } = string.Empty; + public DateTime BirthDate { get; set; } + public string Address { get; set; } = string.Empty; + + // Связь с сотрудниками + public List? Employees { get; set; } + } +} diff --git a/EmployeeManagmentDataModels/Models/Salary.cs b/EmployeeManagmentDataModels/Models/Salary.cs new file mode 100644 index 0000000..ff8d55f --- /dev/null +++ b/EmployeeManagmentDataModels/Models/Salary.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentDataModels.Models +{ + public class Salary + { + public int Id { get; set; } + public int CountHours { get; set; } + public decimal PriceHour { get; set; } + public decimal Premium { get; set; } + public DateTime Date { get; set; } + public bool Passed { get; set; } + public int EmployeeId { get; set; } + + // Связь с сотрудником + public Employee? Employee { get; set; } + } +} diff --git a/EmployeeManagmentDataModels/Models/Vacation.cs b/EmployeeManagmentDataModels/Models/Vacation.cs new file mode 100644 index 0000000..27e297d --- /dev/null +++ b/EmployeeManagmentDataModels/Models/Vacation.cs @@ -0,0 +1,21 @@ +using EmployeeManagmentDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EmployeeManagmentDataModels.Models +{ + public class Vacation + { + public int Id { get; set; } + public DateTime StartData { get; set; } + public DateTime EndData { get; set; } + public VacationStatus Passed { get; set; } + public int EmployeeId { get; set; } + + // Связь с сотрудником + public Employee? Employee { get; set; } + } +} diff --git a/EmployeeManagmentView/MainWindow.xaml b/EmployeeManagmentView/MainWindow.xaml index dd1825b..cb91b5e 100644 --- a/EmployeeManagmentView/MainWindow.xaml +++ b/EmployeeManagmentView/MainWindow.xaml @@ -3,10 +3,31 @@ 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" - xmlns:local="clr-namespace:EmployeeManagmentView" mc:Ignorable="d" - Title="MainWindow" Height="450" Width="800"> + Title="Employee Management System" + Height="450" Width="800"> + + +