Добавление запрлпаты и отпусков
This commit is contained in:
parent
1cca9432eb
commit
41e4e00fd2
@ -1,16 +1,16 @@
|
|||||||
using EmployeeManagmentContracts.BindingModels;
|
using EmployeeManagmentContracts.BusinessLogicContracts;
|
||||||
using EmployeeManagmentContracts.BusinessLogicContracts;
|
|
||||||
using EmployeeManagmentContracts.SearchModels;
|
using EmployeeManagmentContracts.SearchModels;
|
||||||
using EmployeeManagmentContracts.StoragesContracts;
|
|
||||||
using EmployeeManagmentContracts.ViewModels;
|
using EmployeeManagmentContracts.ViewModels;
|
||||||
using EmployeeManagmentDataBaseImplement.Implements;
|
using EmployeeManagmentContracts.StoragesContracts;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace EmployeeManagmentBusinessLogic.BusinessLogic
|
namespace EmployeeManagmentBusinessLogic.BusinessLogic
|
||||||
{
|
{
|
||||||
public class SalaryLogic : ISalaryLogic
|
public class SalaryLogic : ISalaryLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger<SalaryLogic> _logger;
|
||||||
private readonly ISalaryStorage _salaryStorage;
|
private readonly ISalaryStorage _salaryStorage;
|
||||||
|
|
||||||
public SalaryLogic(ILogger<SalaryLogic> logger, ISalaryStorage salaryStorage)
|
public SalaryLogic(ILogger<SalaryLogic> logger, ISalaryStorage salaryStorage)
|
||||||
@ -19,34 +19,51 @@ namespace EmployeeManagmentBusinessLogic.BusinessLogic
|
|||||||
_salaryStorage = salaryStorage;
|
_salaryStorage = salaryStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SalaryViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return _salaryStorage.GetFullList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SalaryViewModel> GetFilteredList(SalarySearchModel model)
|
||||||
|
{
|
||||||
|
return _salaryStorage.GetFilteredList(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SalaryViewModel? GetElement(int id)
|
||||||
|
{
|
||||||
|
return _salaryStorage.GetElement(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(SalaryViewModel model)
|
||||||
|
{
|
||||||
|
if (model.EmployeeId == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Сотрудник обязательно должен быть указан.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_salaryStorage.Insert(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(SalaryViewModel model)
|
||||||
|
{
|
||||||
|
var element = _salaryStorage.GetElement(model.Id);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Зарплата не найдена.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_salaryStorage.Update(model);
|
||||||
|
}
|
||||||
|
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var element = _salaryStorage.GetElement(id);
|
||||||
}
|
if (element == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Зарплата не найдена.");
|
||||||
|
}
|
||||||
|
|
||||||
public PhisicalPersonViewModel? GetElement(int id)
|
_salaryStorage.Delete(id);
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
using EmployeeManagmentContracts.BindingModels;
|
using EmployeeManagmentContracts.BusinessLogicContracts;
|
||||||
using EmployeeManagmentContracts.BusinessLogicContracts;
|
|
||||||
using EmployeeManagmentContracts.SearchModels;
|
using EmployeeManagmentContracts.SearchModels;
|
||||||
using EmployeeManagmentContracts.StoragesContracts;
|
|
||||||
using EmployeeManagmentContracts.ViewModels;
|
using EmployeeManagmentContracts.ViewModels;
|
||||||
using EmployeeManagmentDataBaseImplement.Implements;
|
using EmployeeManagmentContracts.StoragesContracts;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace EmployeeManagmentBusinessLogic.BusinessLogic
|
namespace EmployeeManagmentBusinessLogic.BusinessLogic
|
||||||
{
|
{
|
||||||
public class VacationLogic : IVacationLogic
|
public class VacationLogic : IVacationLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger<VacationLogic> _logger;
|
||||||
private readonly IVacationStorage _vacationStorage;
|
private readonly IVacationStorage _vacationStorage;
|
||||||
|
|
||||||
public VacationLogic(ILogger<VacationLogic> logger, IVacationStorage vacationStorage)
|
public VacationLogic(ILogger<VacationLogic> logger, IVacationStorage vacationStorage)
|
||||||
@ -19,34 +19,51 @@ namespace EmployeeManagmentBusinessLogic.BusinessLogic
|
|||||||
_vacationStorage = vacationStorage;
|
_vacationStorage = vacationStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<VacationViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return _vacationStorage.GetFullList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<VacationViewModel> GetFilteredList(VacationSearchModel model)
|
||||||
|
{
|
||||||
|
return _vacationStorage.GetFilteredList(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VacationViewModel? GetElement(int id)
|
||||||
|
{
|
||||||
|
return _vacationStorage.GetElement(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(VacationViewModel model)
|
||||||
|
{
|
||||||
|
if (model.EmployeeId == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Сотрудник обязательно должен быть указан.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_vacationStorage.Insert(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(VacationViewModel model)
|
||||||
|
{
|
||||||
|
var element = _vacationStorage.GetElement(model.Id);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Отпуск не найден.");
|
||||||
|
}
|
||||||
|
|
||||||
|
_vacationStorage.Update(model);
|
||||||
|
}
|
||||||
|
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var element = _vacationStorage.GetElement(id);
|
||||||
}
|
if (element == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Отпуск не найден.");
|
||||||
|
}
|
||||||
|
|
||||||
public PhisicalPersonViewModel? GetElement(int id)
|
_vacationStorage.Delete(id);
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,11 @@ namespace EmployeeManagmentContracts.BusinessLogicContracts
|
|||||||
{
|
{
|
||||||
public interface ISalaryLogic
|
public interface ISalaryLogic
|
||||||
{
|
{
|
||||||
List<PhisicalPersonViewModel> GetFullList();
|
List<SalaryViewModel> GetFullList();
|
||||||
List<PhisicalPersonViewModel> GetFilteredList(PhisicalPersonSearchModel model);
|
List<SalaryViewModel> GetFilteredList(SalarySearchModel model);
|
||||||
PhisicalPersonViewModel? GetElement(int id);
|
SalaryViewModel? GetElement(int id);
|
||||||
void Insert(PhisicalPersonViewModel model);
|
void Insert(SalaryViewModel model);
|
||||||
void Update(PhisicalPersonViewModel model);
|
void Update(SalaryViewModel model);
|
||||||
void Delete(int id);
|
void Delete(int id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,11 +11,11 @@ namespace EmployeeManagmentContracts.BusinessLogicContracts
|
|||||||
{
|
{
|
||||||
public interface IVacationLogic
|
public interface IVacationLogic
|
||||||
{
|
{
|
||||||
List<PhisicalPersonViewModel> GetFullList();
|
List<VacationViewModel> GetFullList();
|
||||||
List<PhisicalPersonViewModel> GetFilteredList(EmployeeSearchModel model);
|
List<VacationViewModel> GetFilteredList(VacationSearchModel model);
|
||||||
PhisicalPersonViewModel? GetElement(int id);
|
VacationViewModel? GetElement(int id);
|
||||||
void Insert(PhisicalPersonViewModel model);
|
void Insert(VacationViewModel model);
|
||||||
void Update(PhisicalPersonViewModel model);
|
void Update(VacationViewModel model);
|
||||||
void Delete(int id);
|
void Delete(int id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@ namespace EmployeeManagmentContracts.ViewModels
|
|||||||
public float? Premium { get; set; }
|
public float? Premium { get; set; }
|
||||||
public DateTime? Date { get; set; }
|
public DateTime? Date { get; set; }
|
||||||
public bool Passed { get; set; }
|
public bool Passed { get; set; }
|
||||||
public string EmployeeName { get; set; } = string.Empty;
|
|
||||||
|
public int? EmployeeId { get; set; }
|
||||||
|
public string? EmployeeName { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ namespace EmployeeManagmentContracts.ViewModels
|
|||||||
public DateTime StartData { get; set; }
|
public DateTime StartData { get; set; }
|
||||||
public DateTime EndData { get; set; }
|
public DateTime EndData { get; set; }
|
||||||
public bool Passed { get; set; }
|
public bool Passed { get; set; }
|
||||||
public string EmployeeName { get; set; } = string.Empty;
|
public int? EmployeeId { get; set; }
|
||||||
|
public string? EmployeeName { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,44 +1,125 @@
|
|||||||
using EmployeeManagmentContracts.SearchModels;
|
using EmployeeManagmentContracts.SearchModels;
|
||||||
using EmployeeManagmentContracts.StoragesContracts;
|
using EmployeeManagmentContracts.StoragesContracts;
|
||||||
using EmployeeManagmentContracts.ViewModels;
|
using EmployeeManagmentContracts.ViewModels;
|
||||||
|
using EmployeeManagmentDataBaseImplement.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace EmployeeManagmentDataBaseImplement.Implements
|
namespace EmployeeManagmentDataBaseImplement.Implements
|
||||||
{
|
{
|
||||||
public class SalaryStorage : ISalaryStorage
|
public class SalaryStorage : ISalaryStorage
|
||||||
{
|
{
|
||||||
public void Delete(int id)
|
public List<SalaryViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new EmployeeManagementDbContext();
|
||||||
}
|
|
||||||
|
|
||||||
public SalaryViewModel? GetElement(int id)
|
return context.Salaries
|
||||||
{
|
.Select(s => new SalaryViewModel
|
||||||
throw new NotImplementedException();
|
{
|
||||||
|
Id = s.Id,
|
||||||
|
CountHours = s.CountHours,
|
||||||
|
PriceHour = s.PriceHour,
|
||||||
|
Premium = s.Premium,
|
||||||
|
Date = s.Data,
|
||||||
|
Passed = s.Passed,
|
||||||
|
EmployeeId = s.EmployeesId,
|
||||||
|
EmployeeName = s.Employee != null ? $"{s.Employee.PhisicalPerson.Surname} {s.Employee.PhisicalPerson.Name}" : "Не указано"
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SalaryViewModel> GetFilteredList(SalarySearchModel model)
|
public List<SalaryViewModel> GetFilteredList(SalarySearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new EmployeeManagementDbContext();
|
||||||
|
|
||||||
|
if (model == null) return new List<SalaryViewModel>();
|
||||||
|
|
||||||
|
return context.Salaries
|
||||||
|
.Where(s =>
|
||||||
|
(!model.Date.HasValue || s.Data >= model.Date))
|
||||||
|
.Select(s => new SalaryViewModel
|
||||||
|
{
|
||||||
|
Id = s.Id,
|
||||||
|
CountHours = s.CountHours,
|
||||||
|
PriceHour = s.PriceHour,
|
||||||
|
Premium = s.Premium,
|
||||||
|
Date = s.Data,
|
||||||
|
Passed = s.Passed,
|
||||||
|
EmployeeId = s.EmployeesId,
|
||||||
|
EmployeeName = s.Employee != null ? $"{s.Employee.PhisicalPerson.Surname} {s.Employee.PhisicalPerson.Name}" : "Не указано"
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SalaryViewModel> GetFullList()
|
public SalaryViewModel? GetElement(int id)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new EmployeeManagementDbContext();
|
||||||
|
|
||||||
|
var entity = context.Salaries
|
||||||
|
.FirstOrDefault(s => s.Id == id);
|
||||||
|
|
||||||
|
return entity == null ? null : new SalaryViewModel
|
||||||
|
{
|
||||||
|
Id = entity.Id,
|
||||||
|
CountHours = entity.CountHours,
|
||||||
|
PriceHour = entity.PriceHour,
|
||||||
|
Premium = entity.Premium,
|
||||||
|
Date = entity.Data,
|
||||||
|
Passed = entity.Passed,
|
||||||
|
EmployeeId = entity.EmployeesId,
|
||||||
|
EmployeeName = entity.Employee != null ? $"{entity.Employee.PhisicalPerson.Surname} {entity.Employee.PhisicalPerson.Name}" : "Не указано"
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Insert(SalaryViewModel model)
|
public void Insert(SalaryViewModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new EmployeeManagementDbContext();
|
||||||
|
|
||||||
|
var newSalary = new Salary
|
||||||
|
{
|
||||||
|
CountHours = model.CountHours,
|
||||||
|
PriceHour = model.PriceHour,
|
||||||
|
Premium = model.Premium,
|
||||||
|
Data = model.Date,
|
||||||
|
Passed = model.Passed,
|
||||||
|
EmployeesId = model.EmployeeId
|
||||||
|
};
|
||||||
|
|
||||||
|
context.Salaries.Add(newSalary);
|
||||||
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(SalaryViewModel model)
|
public void Update(SalaryViewModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new EmployeeManagementDbContext();
|
||||||
|
|
||||||
|
var entity = context.Salaries.FirstOrDefault(s => s.Id == model.Id);
|
||||||
|
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
entity.CountHours = model.CountHours;
|
||||||
|
entity.PriceHour = model.PriceHour;
|
||||||
|
entity.Premium = model.Premium;
|
||||||
|
entity.Data = model.Date;
|
||||||
|
entity.Passed = model.Passed;
|
||||||
|
entity.EmployeesId = model.EmployeeId;
|
||||||
|
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(int id)
|
||||||
|
{
|
||||||
|
using var context = new EmployeeManagementDbContext();
|
||||||
|
|
||||||
|
var entity = context.Salaries.FirstOrDefault(s => s.Id == id);
|
||||||
|
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
context.Salaries.Remove(entity);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,44 +1,116 @@
|
|||||||
using EmployeeManagmentContracts.SearchModels;
|
using EmployeeManagmentContracts.SearchModels;
|
||||||
using EmployeeManagmentContracts.StoragesContracts;
|
using EmployeeManagmentContracts.StoragesContracts;
|
||||||
using EmployeeManagmentContracts.ViewModels;
|
using EmployeeManagmentContracts.ViewModels;
|
||||||
|
using EmployeeManagmentDataBaseImplement.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace EmployeeManagmentDataBaseImplement.Implements
|
namespace EmployeeManagmentDataBaseImplement.Implements
|
||||||
{
|
{
|
||||||
public class VacationStorage : IVacationStorage
|
public class VacationStorage : IVacationStorage
|
||||||
{
|
{
|
||||||
public void Delete(int id)
|
public List<VacationViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new EmployeeManagementDbContext();
|
||||||
}
|
|
||||||
|
|
||||||
public VacationViewModel? GetElement(int id)
|
return context.Vacations
|
||||||
{
|
.Select(v => new VacationViewModel
|
||||||
throw new NotImplementedException();
|
{
|
||||||
|
Id = v.Id,
|
||||||
|
StartData = v.StartData,
|
||||||
|
EndData = v.EndData,
|
||||||
|
Passed = v.Passed,
|
||||||
|
EmployeeId = v.EmployeesId,
|
||||||
|
EmployeeName = v.Employee != null ? $"{v.Employee.PhisicalPerson.Surname} {v.Employee.PhisicalPerson.Name}" : "Не указано"
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<VacationViewModel> GetFilteredList(VacationSearchModel model)
|
public List<VacationViewModel> GetFilteredList(VacationSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new EmployeeManagementDbContext();
|
||||||
|
|
||||||
|
if (model == null) return new List<VacationViewModel>();
|
||||||
|
|
||||||
|
return context.Vacations
|
||||||
|
.Where(v =>
|
||||||
|
(!model.StartData.HasValue || v.StartData >= model.StartData) &&
|
||||||
|
(!model.EndData.HasValue || v.EndData <= model.EndData))
|
||||||
|
.Select(v => new VacationViewModel
|
||||||
|
{
|
||||||
|
Id = v.Id,
|
||||||
|
StartData = v.StartData,
|
||||||
|
EndData = v.EndData,
|
||||||
|
Passed = v.Passed,
|
||||||
|
EmployeeId = v.EmployeesId,
|
||||||
|
EmployeeName = v.Employee != null ? $"{v.Employee.PhisicalPerson.Surname} {v.Employee.PhisicalPerson.Name}" : "Не указано"
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<VacationViewModel> GetFullList()
|
public VacationViewModel? GetElement(int id)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new EmployeeManagementDbContext();
|
||||||
|
|
||||||
|
var entity = context.Vacations
|
||||||
|
.FirstOrDefault(v => v.Id == id);
|
||||||
|
|
||||||
|
return entity == null ? null : new VacationViewModel
|
||||||
|
{
|
||||||
|
Id = entity.Id,
|
||||||
|
StartData = entity.StartData,
|
||||||
|
EndData = entity.EndData,
|
||||||
|
Passed = entity.Passed,
|
||||||
|
EmployeeId = entity.EmployeesId,
|
||||||
|
EmployeeName = entity.Employee != null ? $"{entity.Employee.PhisicalPerson.Surname} {entity.Employee.PhisicalPerson.Name}" : "Не указано"
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Insert(VacationViewModel model)
|
public void Insert(VacationViewModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new EmployeeManagementDbContext();
|
||||||
|
|
||||||
|
var newVacation = new Vacation
|
||||||
|
{
|
||||||
|
StartData = model.StartData,
|
||||||
|
EndData = model.EndData,
|
||||||
|
Passed = model.Passed,
|
||||||
|
EmployeesId = model.EmployeeId
|
||||||
|
};
|
||||||
|
|
||||||
|
context.Vacations.Add(newVacation);
|
||||||
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(VacationViewModel model)
|
public void Update(VacationViewModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using var context = new EmployeeManagementDbContext();
|
||||||
|
|
||||||
|
var entity = context.Vacations.FirstOrDefault(v => v.Id == model.Id);
|
||||||
|
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
entity.StartData = model.StartData;
|
||||||
|
entity.EndData = model.EndData;
|
||||||
|
entity.Passed = model.Passed;
|
||||||
|
entity.EmployeesId = model.EmployeeId;
|
||||||
|
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(int id)
|
||||||
|
{
|
||||||
|
using var context = new EmployeeManagementDbContext();
|
||||||
|
|
||||||
|
var entity = context.Vacations.FirstOrDefault(v => v.Id == id);
|
||||||
|
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
context.Vacations.Remove(entity);
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,74 @@
|
|||||||
<Window x:Class="EmployeeManagmentView.Employee.Salary.AddSalaryWindow"
|
<Window x:Class="EmployeeManagmentView.Employee.Salary.AddSalaryWindow"
|
||||||
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:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
Title="Добавление зарплаты"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
Height="500" Width="600"
|
||||||
xmlns:local="clr-namespace:EmployeeManagmentView.Employee.Salary"
|
ResizeMode="NoResize"
|
||||||
mc:Ignorable="d"
|
WindowStartupLocation="CenterScreen"
|
||||||
Title="AddSalaryWindow" Height="450" Width="800">
|
Background="#0D2D4F">
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
|
<TextBlock Text="Добавление зарплаты"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Top"
|
||||||
|
FontSize="18" FontWeight="Bold"
|
||||||
|
Foreground="#FFFFFF"
|
||||||
|
Margin="0,20,0,0" />
|
||||||
|
|
||||||
|
<Grid Margin="0,60">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<!-- Поле для сотрудника -->
|
||||||
|
<StackPanel Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="0,10">
|
||||||
|
<Label Content="Сотрудник" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
|
<ComboBox x:Name="EmployeeComboBox" Width="400" Height="40"
|
||||||
|
Background="White" Margin="0,5"
|
||||||
|
ToolTip="Выберите сотрудника" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Поле для количества часов -->
|
||||||
|
<StackPanel Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" Margin="0,10">
|
||||||
|
<Label Content="Количество часов" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
|
<TextBox x:Name="HoursTextBox" Width="200" Height="40"
|
||||||
|
Margin="0,5" ToolTip="Введите количество часов" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Поле для ставки -->
|
||||||
|
<StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" Margin="0,10">
|
||||||
|
<Label Content="Цена за час" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
|
<TextBox x:Name="PriceTextBox" Width="200" Height="40"
|
||||||
|
Margin="0,5" ToolTip="Введите ставку" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Поле для премии -->
|
||||||
|
<StackPanel Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" Margin="0,10">
|
||||||
|
<Label Content="Премия" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
|
<TextBox x:Name="PremiumTextBox" Width="200" Height="40"
|
||||||
|
Margin="0,5" ToolTip="Введите премию (если есть)" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Поле для даты -->
|
||||||
|
<StackPanel Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center" Margin="0,10">
|
||||||
|
<Label Content="Дата" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
|
<DatePicker x:Name="DatePicker" Width="200" Height="40"
|
||||||
|
Margin="0,5" ToolTip="Выберите дату выплаты" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<Button Grid.Row="4" Grid.ColumnSpan="2" Content="Сохранить"
|
||||||
|
Width="200" Height="40"
|
||||||
|
Background="#004890" Foreground="White"
|
||||||
|
Margin="0,10"
|
||||||
|
Click="SaveButton_Click" HorizontalAlignment="Center"/>
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
@ -23,11 +23,45 @@ namespace EmployeeManagmentView.Employee.Salary
|
|||||||
{
|
{
|
||||||
|
|
||||||
private readonly ISalaryLogic _salaryLogic;
|
private readonly ISalaryLogic _salaryLogic;
|
||||||
|
private readonly IEmployeeLogic _employeeLogic;
|
||||||
|
|
||||||
public AddSalaryWindow(ISalaryLogic salaryLogic)
|
public AddSalaryWindow(ISalaryLogic salaryLogic, IEmployeeLogic employeeLogic)
|
||||||
{
|
{
|
||||||
_salaryLogic = salaryLogic;
|
_salaryLogic = salaryLogic;
|
||||||
|
_employeeLogic = employeeLogic;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
LoadEmployees();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadEmployees()
|
||||||
|
{
|
||||||
|
var employees = _employeeLogic.GetFullList();
|
||||||
|
EmployeeComboBox.ItemsSource = employees;
|
||||||
|
EmployeeComboBox.DisplayMemberPath = "NameJob";
|
||||||
|
EmployeeComboBox.SelectedValuePath = "Id";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var salary = new SalaryViewModel
|
||||||
|
{
|
||||||
|
CountHours = int.Parse(HoursTextBox.Text),
|
||||||
|
PriceHour = float.Parse(PriceTextBox.Text),
|
||||||
|
Premium = string.IsNullOrEmpty(PremiumTextBox.Text) ? null : float.Parse(PremiumTextBox.Text),
|
||||||
|
Date = DatePicker.SelectedDate.Value.ToUniversalTime(),
|
||||||
|
EmployeeId = (int?)EmployeeComboBox.SelectedValue
|
||||||
|
};
|
||||||
|
|
||||||
|
_salaryLogic.Insert(salary);
|
||||||
|
MessageBox.Show("Зарплата успешно сохранена!");
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"Ошибка: {ex.Message}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,14 +25,15 @@ namespace EmployeeManagmentView.Employee.Salary
|
|||||||
{
|
{
|
||||||
|
|
||||||
private readonly ISalaryLogic _salaryLogic;
|
private readonly ISalaryLogic _salaryLogic;
|
||||||
|
private readonly IEmployeeLogic _employeeLogic;
|
||||||
|
|
||||||
public SalaryManagementWindow(ISalaryLogic salaryLogic)
|
public SalaryManagementWindow(ISalaryLogic salaryLogic, IEmployeeLogic employeeLogic)
|
||||||
{
|
{
|
||||||
|
|
||||||
_salaryLogic = salaryLogic;
|
_salaryLogic = salaryLogic;
|
||||||
|
_employeeLogic = employeeLogic;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenAddSalaryWindow(object sender, RoutedEventArgs e)
|
private void OpenAddSalaryWindow(object sender, RoutedEventArgs e)
|
||||||
@ -46,7 +47,7 @@ namespace EmployeeManagmentView.Employee.Salary
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var addWindow = new AddSalaryWindow(_salaryLogic);
|
var addWindow = new AddSalaryWindow(_salaryLogic, _employeeLogic);
|
||||||
addWindow.Show();
|
addWindow.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,65 @@
|
|||||||
<Window x:Class="EmployeeManagmentView.Employee.Vacation.AddVacationWindow"
|
<Window x:Class="EmployeeManagmentView.Employee.Vacation.AddVacationWindow"
|
||||||
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:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
Title="Добавление отпуска"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
Height="500" Width="600"
|
||||||
xmlns:local="clr-namespace:EmployeeManagmentView.Employee.Vacation"
|
ResizeMode="NoResize"
|
||||||
mc:Ignorable="d"
|
WindowStartupLocation="CenterScreen"
|
||||||
Title="AddVacationWindow" Height="450" Width="800">
|
Background="#0D2D4F">
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
|
<TextBlock Text="Добавление отпуска"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Top"
|
||||||
|
FontSize="18" FontWeight="Bold"
|
||||||
|
Foreground="#FFFFFF"
|
||||||
|
Margin="0,20,0,0" />
|
||||||
|
|
||||||
|
<Grid Margin="0,60">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<!-- Поле для сотрудника -->
|
||||||
|
<StackPanel Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="0,10">
|
||||||
|
<Label Content="Сотрудник" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
|
<ComboBox x:Name="EmployeeComboBox" Width="400" Height="40"
|
||||||
|
Background="White" Margin="0,5"
|
||||||
|
ToolTip="Выберите сотрудника" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Поле для начала отпуска -->
|
||||||
|
<StackPanel Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" Margin="0,10">
|
||||||
|
<Label Content="Дата начала" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
|
<DatePicker x:Name="StartDatePicker" Width="200" Height="40"
|
||||||
|
Margin="0,5" ToolTip="Выберите дату начала отпуска" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Поле для окончания отпуска -->
|
||||||
|
<StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" Margin="0,10">
|
||||||
|
<Label Content="Дата окончания" Foreground="White" HorizontalAlignment="Center"/>
|
||||||
|
<DatePicker x:Name="EndDatePicker" Width="200" Height="40"
|
||||||
|
Margin="0,5" ToolTip="Выберите дату окончания отпуска" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Чекбокс для отметки пройденного отпуска -->
|
||||||
|
<StackPanel Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="0,10">
|
||||||
|
<CheckBox x:Name="PassedCheckBox" Content="Отпуск завершен" Foreground="White"
|
||||||
|
FontSize="14" VerticalAlignment="Center"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<Button Grid.Row="3" Grid.ColumnSpan="2" Content="Сохранить"
|
||||||
|
Width="200" Height="40"
|
||||||
|
Background="#004890" Foreground="White"
|
||||||
|
Margin="0,10"
|
||||||
|
Click="SaveButton_Click" HorizontalAlignment="Center"/>
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
@ -1,5 +1,6 @@
|
|||||||
using EmployeeManagmentBusinessLogic.BusinessLogic;
|
using EmployeeManagmentBusinessLogic.BusinessLogic;
|
||||||
using EmployeeManagmentContracts.BusinessLogicContracts;
|
using EmployeeManagmentContracts.BusinessLogicContracts;
|
||||||
|
using EmployeeManagmentContracts.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -23,11 +24,44 @@ namespace EmployeeManagmentView.Employee.Vacation
|
|||||||
{
|
{
|
||||||
|
|
||||||
private readonly IVacationLogic _vacationLogic;
|
private readonly IVacationLogic _vacationLogic;
|
||||||
|
private readonly IEmployeeLogic _employeeLogic;
|
||||||
|
|
||||||
public AddVacationWindow(IVacationLogic vacationLogic)
|
public AddVacationWindow(IVacationLogic vacationLogic, IEmployeeLogic employeeLogic)
|
||||||
{
|
{
|
||||||
_vacationLogic = vacationLogic;
|
_vacationLogic = vacationLogic;
|
||||||
|
_employeeLogic = employeeLogic;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
LoadEmployees();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadEmployees()
|
||||||
|
{
|
||||||
|
var employees = _employeeLogic.GetFullList();
|
||||||
|
EmployeeComboBox.ItemsSource = employees;
|
||||||
|
EmployeeComboBox.DisplayMemberPath = "NameJob";
|
||||||
|
EmployeeComboBox.SelectedValuePath = "Id";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var vacation = new VacationViewModel
|
||||||
|
{
|
||||||
|
StartData = StartDatePicker.SelectedDate.Value.ToUniversalTime(),
|
||||||
|
EndData = EndDatePicker.SelectedDate.Value.ToUniversalTime(),
|
||||||
|
Passed = PassedCheckBox.IsChecked ?? false,
|
||||||
|
EmployeeId = (int?)EmployeeComboBox.SelectedValue
|
||||||
|
};
|
||||||
|
|
||||||
|
_vacationLogic.Insert(vacation);
|
||||||
|
MessageBox.Show("Отпуск успешно сохранен!");
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"Ошибка: {ex.Message}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,15 @@ namespace EmployeeManagmentView.Employee.Vacation
|
|||||||
{
|
{
|
||||||
|
|
||||||
private readonly IVacationLogic _vacationLogic;
|
private readonly IVacationLogic _vacationLogic;
|
||||||
|
private readonly IEmployeeLogic _employeeLogic;
|
||||||
|
|
||||||
public VacationManagementWindow(IVacationLogic vacationLogic)
|
public VacationManagementWindow(IVacationLogic vacationLogic, IEmployeeLogic employeeLogic)
|
||||||
{
|
{
|
||||||
|
|
||||||
_vacationLogic = vacationLogic;
|
_vacationLogic = vacationLogic;
|
||||||
|
_employeeLogic = employeeLogic;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenAddVacationWindow(object sender, RoutedEventArgs e)
|
private void OpenAddVacationWindow(object sender, RoutedEventArgs e)
|
||||||
@ -44,7 +45,7 @@ namespace EmployeeManagmentView.Employee.Vacation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var addWindow = new AddVacationWindow(_vacationLogic);
|
var addWindow = new AddVacationWindow(_vacationLogic, _employeeLogic);
|
||||||
addWindow.Show();
|
addWindow.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ namespace EmployeeManagmentView.Employee
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var salaryWindow = new SalaryManagementWindow(_salaryLogic);
|
var salaryWindow = new SalaryManagementWindow(_salaryLogic, _employeeLogic);
|
||||||
salaryWindow.Show();
|
salaryWindow.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ namespace EmployeeManagmentView.Employee
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var vacationWindow = new VacationManagementWindow(_vacationLogic);
|
var vacationWindow = new VacationManagementWindow(_vacationLogic, _employeeLogic);
|
||||||
vacationWindow.Show();
|
vacationWindow.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user