Формируется отчет для сотрудников
This commit is contained in:
parent
f8e8a0cc2b
commit
c36d12c9dd
@ -7,6 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
@ -99,10 +99,17 @@
|
|||||||
<!-- Кнопка для добавления сотрудника -->
|
<!-- Кнопка для добавления сотрудника -->
|
||||||
<Button Grid.Row="3" Grid.ColumnSpan="2" Content="Добавить сотрудника"
|
<Button Grid.Row="3" Grid.ColumnSpan="2" Content="Добавить сотрудника"
|
||||||
Width="250" Height="40"
|
Width="250" Height="40"
|
||||||
Margin="0,10"
|
Margin="20,10,0,0"
|
||||||
Style="{StaticResource RoundedButtonStyle}"
|
Style="{StaticResource RoundedButtonStyle}"
|
||||||
Click="SaveButton_Click"
|
Click="SaveButton_Click"
|
||||||
Background="#004890" Foreground="#FFFFFF" HorizontalAlignment="Center"/>
|
Background="#004890" Foreground="#FFFFFF" HorizontalAlignment="Left"/>
|
||||||
|
<Button Grid.Row="3" Grid.ColumnSpan="2" Content="Сформировать договор"
|
||||||
|
Width="250" Height="40"
|
||||||
|
Margin="0,10,20,0"
|
||||||
|
Style="{StaticResource RoundedButtonStyle}"
|
||||||
|
Click="GenerateContractButton_Click"
|
||||||
|
Background="#004890" Foreground="#FFFFFF" HorizontalAlignment="Right"/>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
using EmployeeManagmentBusinessLogic.BusinessLogic;
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
using EmployeeManagmentBusinessLogic.BusinessLogic;
|
||||||
using EmployeeManagmentContracts.BusinessLogicContracts;
|
using EmployeeManagmentContracts.BusinessLogicContracts;
|
||||||
using EmployeeManagmentContracts.ViewModels;
|
using EmployeeManagmentContracts.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
@ -9,11 +12,10 @@ using System.Threading.Tasks;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
using System.IO;
|
||||||
|
|
||||||
namespace EmployeeManagmentView.Employee
|
namespace EmployeeManagmentView.Employee
|
||||||
{
|
{
|
||||||
@ -123,6 +125,88 @@ namespace EmployeeManagmentView.Employee
|
|||||||
e.Handled = !char.IsDigit(e.Text, 0);
|
e.Handled = !char.IsDigit(e.Text, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void CreateEmploymentContract(string filePath, string employeeName, string jobTitle, DateTime startDate, DateTime? endDate, decimal hourlyRate, string partTimeInfo)
|
||||||
|
{
|
||||||
|
using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(filePath, WordprocessingDocumentType.Document))
|
||||||
|
{
|
||||||
|
// Добавление основной части документа
|
||||||
|
MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
|
||||||
|
mainPart.Document = new Document();
|
||||||
|
Body body = new Body();
|
||||||
|
|
||||||
|
// Заголовок
|
||||||
|
body.Append(new Paragraph(
|
||||||
|
new Run(
|
||||||
|
new Text("Трудовой договор"))
|
||||||
|
{
|
||||||
|
RunProperties = new RunProperties
|
||||||
|
{
|
||||||
|
Bold = new Bold(),
|
||||||
|
FontSize = new FontSize { Val = "28" }
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Информация о сотруднике
|
||||||
|
body.Append(new Paragraph(new Run(new Text($"Сотрудник: {employeeName}"))));
|
||||||
|
body.Append(new Paragraph(new Run(new Text($"Должность: {jobTitle}"))));
|
||||||
|
body.Append(new Paragraph(new Run(new Text($"Дата начала работы: {startDate:dd.MM.yyyy}"))));
|
||||||
|
|
||||||
|
if (endDate.HasValue)
|
||||||
|
{
|
||||||
|
body.Append(new Paragraph(new Run(new Text($"Дата окончания работы: {endDate:dd.MM.yyyy}"))));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
body.Append(new Paragraph(new Run(new Text("Дата окончания работы: бессрочный договор"))));
|
||||||
|
}
|
||||||
|
|
||||||
|
body.Append(new Paragraph(new Run(new Text($"Ставка: {hourlyRate:C} рублей в час"))));
|
||||||
|
body.Append(new Paragraph(new Run(new Text($"Совместительство: {partTimeInfo}"))));
|
||||||
|
|
||||||
|
// Заключение
|
||||||
|
body.Append(new Paragraph(new Run(new Text("Договор подписан обеими сторонами."))));
|
||||||
|
|
||||||
|
// Привязка тела документа
|
||||||
|
mainPart.Document.Append(body);
|
||||||
|
mainPart.Document.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GenerateContractButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
// Проверка данных
|
||||||
|
if (string.IsNullOrWhiteSpace(JobNameTextBox.Text) ||
|
||||||
|
!StartDatePicker.SelectedDate.HasValue ||
|
||||||
|
string.IsNullOrWhiteSpace(BidTextBox.Text) ||
|
||||||
|
string.IsNullOrWhiteSpace(PhysicalPersonComboBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Пожалуйста, заполните все обязательные поля.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Получение данных
|
||||||
|
string employeeName = PhysicalPersonComboBox.Text;
|
||||||
|
string jobTitle = JobNameTextBox.Text;
|
||||||
|
DateTime startDate = StartDatePicker.SelectedDate.Value;
|
||||||
|
DateTime? endDate = EndDatePicker.SelectedDate;
|
||||||
|
decimal hourlyRate = decimal.Parse(BidTextBox.Text);
|
||||||
|
string partTimeInfo = PartTimeJobTextBox.Text;
|
||||||
|
|
||||||
|
// Путь сохранения
|
||||||
|
string filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Трудовой_договор.docx");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Генерация документа
|
||||||
|
CreateEmploymentContract(filePath, employeeName, jobTitle, startDate, endDate, hourlyRate, partTimeInfo);
|
||||||
|
MessageBox.Show($"Договор успешно создан по адресу:\n{filePath}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"Ошибка при создании документа: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void TelephoneTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
private void TelephoneTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
var textBox = sender as TextBox;
|
var textBox = sender as TextBox;
|
||||||
|
@ -114,7 +114,6 @@ namespace EmployeeManagmentView.Employee.Salary
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void TelephoneTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
private void TelephoneTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||||
{
|
{
|
||||||
e.Handled = !char.IsDigit(e.Text, 0);
|
e.Handled = !char.IsDigit(e.Text, 0);
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
Loading…
Reference in New Issue
Block a user