Сделал половину дезигн изменений
This commit is contained in:
parent
7b0a8dd3d6
commit
69726bde25
@ -16,6 +16,8 @@ namespace EmployeeManagmentContracts.ViewModels
|
||||
public float Bid { get; set; }
|
||||
public int? PhysicalPersonsId { get; set; }
|
||||
public string? PhysicalPersonName { get; set; }
|
||||
// Новое свойство для отображения комбинированного текста
|
||||
public string DisplayText => $"{NameJob} ({PhysicalPersonName})";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,5 +14,15 @@ namespace EmployeeManagmentContracts.ViewModels
|
||||
public bool Passed { get; set; }
|
||||
public int? EmployeeId { get; set; }
|
||||
public string? EmployeeName { get; set; } = string.Empty;
|
||||
|
||||
public string DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
return $"{EmployeeName} ({StartData:dd.MM.yyyy} - {EndData:dd.MM.yyyy})";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace EmployeeManagmentDataBaseImplement.Implements
|
||||
PartTimeJob = e.PartTimeJob,
|
||||
Bid = e.Bid,
|
||||
PhysicalPersonsId = e.PhisicalPersonsId,
|
||||
PhysicalPersonName = $"{e.PhisicalPerson.Surname} {e.PhisicalPerson.Name}"
|
||||
PhysicalPersonName = $"{e.PhisicalPerson.Surname} {e.PhisicalPerson.Name} {e.PhisicalPerson.Patronymic} "
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
@ -48,7 +48,7 @@ namespace EmployeeManagmentDataBaseImplement.Implements
|
||||
PartTimeJob = e.PartTimeJob,
|
||||
Bid = e.Bid,
|
||||
PhysicalPersonsId = e.PhisicalPersonsId,
|
||||
PhysicalPersonName = $"{e.PhisicalPerson.Surname} {e.PhisicalPerson.Name}"
|
||||
PhysicalPersonName = $"{e.PhisicalPerson.Surname} {e.PhisicalPerson.Name} {e.PhisicalPerson.Patronymic}",
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
@ -71,7 +71,7 @@ namespace EmployeeManagmentDataBaseImplement.Implements
|
||||
Bid = entity.Bid,
|
||||
PhysicalPersonsId = entity.PhisicalPersonsId,
|
||||
PhysicalPersonName = entity.PhisicalPerson != null
|
||||
? $"{entity.PhisicalPerson.Surname} {entity.PhisicalPerson.Name}"
|
||||
? $"{entity.PhisicalPerson.Surname} {entity.PhisicalPerson.Name} {entity.PhisicalPerson.Patronymic} "
|
||||
: "Не указано" // Обработка отсутствующего физического лица
|
||||
};
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace EmployeeManagmentDataBaseImplement.Implements
|
||||
EndData = v.EndData,
|
||||
Passed = v.Passed,
|
||||
EmployeeId = v.EmployeesId,
|
||||
EmployeeName = v.Employee != null ? $"{v.Employee.PhisicalPerson.Surname} {v.Employee.PhisicalPerson.Name}" : "Не указано"
|
||||
EmployeeName = v.Employee != null ? $"{v.Employee.PhisicalPerson.Surname} {v.Employee.PhisicalPerson.Name} {v.Employee.PhisicalPerson.Patronymic} ({v.Employee.NameJob})" : "Не указано"
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
@ -44,7 +44,7 @@ namespace EmployeeManagmentDataBaseImplement.Implements
|
||||
EndData = v.EndData,
|
||||
Passed = v.Passed,
|
||||
EmployeeId = v.EmployeesId,
|
||||
EmployeeName = v.Employee != null ? $"{v.Employee.PhisicalPerson.Surname} {v.Employee.PhisicalPerson.Name}" : "Не указано"
|
||||
EmployeeName = v.Employee != null ? $"{v.Employee.PhisicalPerson.Surname} {v.Employee.PhisicalPerson.Name} {v.Employee.PhisicalPerson.Patronymic} ({v.Employee.NameJob})" : "Не указано"
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
@ -63,7 +63,7 @@ namespace EmployeeManagmentDataBaseImplement.Implements
|
||||
EndData = entity.EndData,
|
||||
Passed = entity.Passed,
|
||||
EmployeeId = entity.EmployeesId,
|
||||
EmployeeName = entity.Employee != null ? $"{entity.Employee.PhisicalPerson.Surname} {entity.Employee.PhisicalPerson.Name}" : "Не указано"
|
||||
EmployeeName = entity.Employee != null ? $"{entity.Employee.PhisicalPerson.Surname} {entity.Employee.PhisicalPerson.Name} {entity.Employee.PhisicalPerson.Patronymic} ({entity.Employee.NameJob})" : "Не указано"
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" />
|
||||
<PackageReference Include="PresentationFramework" Version="4.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace EmployeeManagmentDataModels.Enums
|
||||
{
|
||||
public class BooleanToSalaryConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is bool booleanValue)
|
||||
{
|
||||
return booleanValue ? "Заплачено" : "Не заплачено";
|
||||
}
|
||||
return "Неизвестно";
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException("Обратное преобразование не поддерживается.");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace EmployeeManagmentDataModels.Enums
|
||||
{
|
||||
public class BooleanToVacationConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is bool booleanValue)
|
||||
{
|
||||
return booleanValue ? "Завершен" : "Не завершено";
|
||||
}
|
||||
return "Неизвестно";
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException("Обратное преобразование не поддерживается.");
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
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">
|
||||
|
@ -38,7 +38,9 @@
|
||||
Width="250" Height="40"
|
||||
Style="{StaticResource RoundedTextBoxStyle}"
|
||||
Margin="0,5"
|
||||
ToolTip="Введите название должности" HorizontalAlignment="Center"/>
|
||||
ToolTip="Введите название должности" HorizontalAlignment="Center"
|
||||
PreviewTextInput="NameTextBox_PreviewTextInput"
|
||||
TextChanged="NameTextBox_TextChanged"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Поле для даты начала работы -->
|
||||
@ -66,7 +68,9 @@
|
||||
Width="250" Height="40"
|
||||
Style="{StaticResource RoundedTextBoxStyle}"
|
||||
Margin="0,5"
|
||||
ToolTip="Введите почасовую ставку" HorizontalAlignment="Center"/>
|
||||
ToolTip="Введите почасовую ставку" HorizontalAlignment="Center"
|
||||
PreviewTextInput="DecimalTextBox_PreviewTextInput"
|
||||
TextChanged="DecimalTextBox_TextChanged"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Поле для физического лица -->
|
||||
@ -86,7 +90,9 @@
|
||||
Width="250" Height="40"
|
||||
Style="{StaticResource RoundedTextBoxStyle}"
|
||||
Margin="0,5"
|
||||
ToolTip="Введите почасовую ставку" HorizontalAlignment="Center"/>
|
||||
ToolTip="Введите почасовую ставку" HorizontalAlignment="Center"
|
||||
PreviewTextInput="NameTextBox_PreviewTextInput"
|
||||
TextChanged="NameTextBox_TextChanged"/>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
|
@ -43,10 +43,115 @@ namespace EmployeeManagmentView.Employee
|
||||
|
||||
var persons = _phisicalPersonLogic.GetFullList();
|
||||
PhysicalPersonComboBox.ItemsSource = persons;
|
||||
PhysicalPersonComboBox.DisplayMemberPath = "Name";
|
||||
PhysicalPersonComboBox.DisplayMemberPath = "FullNameWithBirthday";
|
||||
PhysicalPersonComboBox.SelectedValuePath = "Id";
|
||||
}
|
||||
|
||||
private void NameTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
// Разрешаем только буквы
|
||||
e.Handled = !char.IsLetter(e.Text, 0);
|
||||
}
|
||||
|
||||
private void NameTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Получаем текущий текст
|
||||
string currentText = textBox.Text;
|
||||
|
||||
// Если текст не пустой, преобразуем первую букву в заглавную, а остальные в строчные
|
||||
if (!string.IsNullOrEmpty(currentText))
|
||||
{
|
||||
// Разбиваем строку по пробелам, чтобы обрабатывать каждое слово отдельно
|
||||
var words = currentText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
for (int i = 0; i < words.Length; i++)
|
||||
{
|
||||
// Преобразуем первую букву в заглавную, а остальные в строчные
|
||||
words[i] = char.ToUpper(words[i][0]) + words[i].Substring(1).ToLower();
|
||||
}
|
||||
|
||||
// Объединяем слова обратно в строку и обновляем текст
|
||||
textBox.Text = string.Join(" ", words);
|
||||
|
||||
// Устанавливаем курсор в конец текста
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
}
|
||||
}
|
||||
|
||||
// Проверка на ввод только чисел и одной запятой
|
||||
private void DecimalTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Разрешаем только цифры и запятую
|
||||
e.Handled = !(char.IsDigit(e.Text, 0) || e.Text == ",");
|
||||
|
||||
// Проверка на количество запятых
|
||||
if (e.Text == "," && textBox.Text.Contains(","))
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Ограничение на 2 знака после запятой
|
||||
private void DecimalTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Получаем текущий текст
|
||||
string currentText = textBox.Text;
|
||||
|
||||
// Проверяем наличие запятой
|
||||
int commaIndex = currentText.IndexOf(',');
|
||||
|
||||
if (commaIndex != -1 && currentText.Length - commaIndex > 3)
|
||||
{
|
||||
// Обрезаем текст до двух знаков после запятой
|
||||
textBox.Text = currentText.Substring(0, commaIndex + 3);
|
||||
textBox.SelectionStart = textBox.Text.Length; // Устанавливаем курсор в конец текста
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void TelephoneTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
e.Handled = !char.IsDigit(e.Text, 0);
|
||||
}
|
||||
|
||||
private void TelephoneTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Удаляем все символы, кроме цифр
|
||||
string rawInput = new string(textBox.Text.Where(char.IsDigit).ToArray());
|
||||
|
||||
// Добавляем "7" по умолчанию
|
||||
if (!rawInput.StartsWith("7"))
|
||||
rawInput = "7" + rawInput;
|
||||
|
||||
if (rawInput.Length > 11) rawInput = rawInput.Substring(0, 11);
|
||||
|
||||
// Форматируем как +7 (XXX) XXX-XX-XX
|
||||
if (rawInput.Length <= 1)
|
||||
textBox.Text = "+7 ";
|
||||
else if (rawInput.Length <= 4)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1)}";
|
||||
else if (rawInput.Length <= 7)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4)}";
|
||||
else if (rawInput.Length <= 9)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4, 3)}-{rawInput.Substring(7)}";
|
||||
else
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4, 3)}-{rawInput.Substring(7, 2)}-{rawInput.Substring(9)}";
|
||||
|
||||
// Устанавливаем курсор в конец
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
}
|
||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
|
@ -77,7 +77,9 @@
|
||||
<StackPanel Grid.Row="0" Grid.Column="0" Margin="10">
|
||||
<Label Content="Название работы" Foreground="White" HorizontalAlignment="Center"/>
|
||||
<TextBox x:Name="JobNameTextBox" Width="250" Height="40"
|
||||
Style="{StaticResource RoundedTextBoxStyle}" ToolTip="Введите название работы" />
|
||||
Style="{StaticResource RoundedTextBoxStyle}" ToolTip="Введите название работы"
|
||||
PreviewTextInput="NameTextBox_PreviewTextInput"
|
||||
TextChanged="NameTextBox_TextChanged"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" Margin="10">
|
||||
<Label Content="Дата начала работы" Foreground="White" HorizontalAlignment="Center"/>
|
||||
@ -90,14 +92,18 @@
|
||||
ToolTip="Выберите дату окончания" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" Margin="10">
|
||||
<Label Content="Частичная занятость" Foreground="White" HorizontalAlignment="Center"/>
|
||||
<Label Content="Совместительство" Foreground="White" HorizontalAlignment="Center"/>
|
||||
<TextBox x:Name="PartTimeTextBox" Width="250" Height="40"
|
||||
Style="{StaticResource RoundedTextBoxStyle}" ToolTip="Укажите частичную занятость" />
|
||||
Style="{StaticResource RoundedTextBoxStyle}" ToolTip="Укажите частичную занятость"
|
||||
PreviewTextInput="NameTextBox_PreviewTextInput"
|
||||
TextChanged="NameTextBox_TextChanged"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="2" Grid.Column="0" Margin="10">
|
||||
<Label Content="Ставка" Foreground="White" HorizontalAlignment="Center"/>
|
||||
<TextBox x:Name="BidTextBox" Width="250" Height="40"
|
||||
Style="{StaticResource RoundedTextBoxStyle}" ToolTip="Введите ставку" />
|
||||
Style="{StaticResource RoundedTextBoxStyle}" ToolTip="Введите ставку"
|
||||
PreviewTextInput="NameTextBox_PreviewTextInput"
|
||||
TextChanged="NameTextBox_TextChanged"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="2" Grid.Column="1" Margin="10">
|
||||
<Label Content="Физическое лицо" Foreground="White" HorizontalAlignment="Center"/>
|
||||
|
@ -38,11 +38,20 @@ namespace EmployeeManagmentView.Employee
|
||||
private void LoadEmployees()
|
||||
{
|
||||
_employees = _employeeLogic.GetFullList();
|
||||
|
||||
// Заполняем комбинированное свойство, если нужно
|
||||
foreach (var employee in _employees)
|
||||
{
|
||||
var physicalPerson = _physicalPersonLogic.GetElement(employee.PhysicalPersonsId ?? 0);
|
||||
employee.PhysicalPersonName = physicalPerson?.FullNameWithBirthday;
|
||||
}
|
||||
|
||||
EmployeeComboBox.ItemsSource = _employees;
|
||||
EmployeeComboBox.DisplayMemberPath = "NameJob";
|
||||
EmployeeComboBox.DisplayMemberPath = "DisplayText"; // Используем новое свойство
|
||||
EmployeeComboBox.SelectedValuePath = "Id";
|
||||
}
|
||||
|
||||
|
||||
private void LoadPhysicalPersons()
|
||||
{
|
||||
var physicalPersons = _physicalPersonLogic.GetFullList();
|
||||
@ -59,6 +68,7 @@ namespace EmployeeManagmentView.Employee
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void LoadEmployee(int employeeId)
|
||||
{
|
||||
var employee = _employeeLogic.GetElement(employeeId);
|
||||
@ -84,6 +94,78 @@ namespace EmployeeManagmentView.Employee
|
||||
EmployeeComboBox.ItemsSource = filteredEmployees;
|
||||
}
|
||||
|
||||
private void NameTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
// Разрешаем только буквы
|
||||
e.Handled = !char.IsLetter(e.Text, 0);
|
||||
}
|
||||
|
||||
private void NameTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Получаем текущий текст
|
||||
string currentText = textBox.Text;
|
||||
|
||||
// Если текст не пустой, преобразуем первую букву в заглавную, а остальные в строчные
|
||||
if (!string.IsNullOrEmpty(currentText))
|
||||
{
|
||||
// Разбиваем строку по пробелам, чтобы обрабатывать каждое слово отдельно
|
||||
var words = currentText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
for (int i = 0; i < words.Length; i++)
|
||||
{
|
||||
// Преобразуем первую букву в заглавную, а остальные в строчные
|
||||
words[i] = char.ToUpper(words[i][0]) + words[i].Substring(1).ToLower();
|
||||
}
|
||||
|
||||
// Объединяем слова обратно в строку и обновляем текст
|
||||
textBox.Text = string.Join(" ", words);
|
||||
|
||||
// Устанавливаем курсор в конец текста
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void TelephoneTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
e.Handled = !char.IsDigit(e.Text, 0);
|
||||
}
|
||||
|
||||
private void TelephoneTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Удаляем все символы, кроме цифр
|
||||
string rawInput = new string(textBox.Text.Where(char.IsDigit).ToArray());
|
||||
|
||||
// Добавляем "7" по умолчанию
|
||||
if (!rawInput.StartsWith("7"))
|
||||
rawInput = "7" + rawInput;
|
||||
|
||||
if (rawInput.Length > 11) rawInput = rawInput.Substring(0, 11);
|
||||
|
||||
// Форматируем как +7 (XXX) XXX-XX-XX
|
||||
if (rawInput.Length <= 1)
|
||||
textBox.Text = "+7 ";
|
||||
else if (rawInput.Length <= 4)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1)}";
|
||||
else if (rawInput.Length <= 7)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4)}";
|
||||
else if (rawInput.Length <= 9)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4, 3)}-{rawInput.Substring(7)}";
|
||||
else
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4, 3)}-{rawInput.Substring(7, 2)}-{rawInput.Substring(9)}";
|
||||
|
||||
// Устанавливаем курсор в конец
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (EmployeeComboBox.SelectedValue is int selectedEmployeeId)
|
||||
|
@ -93,7 +93,7 @@ namespace EmployeeManagmentView.Employee
|
||||
}
|
||||
}
|
||||
|
||||
var viewWindow = new ViewEmployeeWindow(_employeeLogic, _salaryLogic, _vacationLogic);
|
||||
var viewWindow = new ViewEmployeeWindow(_employeeLogic, _salaryLogic, _vacationLogic, _phisicalPersonLogic);
|
||||
viewWindow.Show();
|
||||
}
|
||||
}
|
||||
|
@ -39,21 +39,26 @@
|
||||
<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="Введите количество часов" />
|
||||
Margin="0,5" ToolTip="Введите количество часов"
|
||||
PreviewTextInput="NumericTextBox_PreviewTextInput"/>
|
||||
</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="Введите ставку" />
|
||||
Margin="0,5" ToolTip="Введите ставку"
|
||||
PreviewTextInput="DecimalTextBox_PreviewTextInput"
|
||||
TextChanged="DecimalTextBox_TextChanged"/>
|
||||
</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="Введите премию (если есть)" />
|
||||
Margin="0,5" ToolTip="Введите премию (если есть)"
|
||||
PreviewTextInput="DecimalTextBox_PreviewTextInput"
|
||||
TextChanged="DecimalTextBox_TextChanged"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Поле для даты -->
|
||||
|
@ -24,15 +24,131 @@ namespace EmployeeManagmentView.Employee.Salary
|
||||
|
||||
private readonly ISalaryLogic _salaryLogic;
|
||||
private readonly IEmployeeLogic _employeeLogic;
|
||||
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
|
||||
|
||||
public AddSalaryWindow(ISalaryLogic salaryLogic, IEmployeeLogic employeeLogic)
|
||||
public AddSalaryWindow(ISalaryLogic salaryLogic, IEmployeeLogic employeeLogic, IPhisicalPersonLogic phisicalPersonLogic)
|
||||
{
|
||||
_salaryLogic = salaryLogic;
|
||||
_employeeLogic = employeeLogic;
|
||||
_phisicalPersonLogic = phisicalPersonLogic;
|
||||
InitializeComponent();
|
||||
LoadEmployees();
|
||||
}
|
||||
|
||||
private void NameTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
// Разрешаем только буквы
|
||||
e.Handled = !char.IsLetter(e.Text, 0);
|
||||
}
|
||||
|
||||
private void NameTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Получаем текущий текст
|
||||
string currentText = textBox.Text;
|
||||
|
||||
// Если текст не пустой, преобразуем первую букву в заглавную, а остальные в строчные
|
||||
if (!string.IsNullOrEmpty(currentText))
|
||||
{
|
||||
// Разбиваем строку по пробелам, чтобы обрабатывать каждое слово отдельно
|
||||
var words = currentText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
for (int i = 0; i < words.Length; i++)
|
||||
{
|
||||
// Преобразуем первую букву в заглавную, а остальные в строчные
|
||||
words[i] = char.ToUpper(words[i][0]) + words[i].Substring(1).ToLower();
|
||||
}
|
||||
|
||||
// Объединяем слова обратно в строку и обновляем текст
|
||||
textBox.Text = string.Join(" ", words);
|
||||
|
||||
// Устанавливаем курсор в конец текста
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
}
|
||||
}
|
||||
|
||||
// Проверка на ввод только чисел и одной запятой
|
||||
private void DecimalTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Разрешаем только цифры и запятую
|
||||
e.Handled = !(char.IsDigit(e.Text, 0) || e.Text == ",");
|
||||
|
||||
// Проверка на количество запятых
|
||||
if (e.Text == "," && textBox.Text.Contains(","))
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void NumericTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
||||
{
|
||||
// Разрешаем ввод только цифр и запятой
|
||||
e.Handled = !char.IsDigit(e.Text, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Ограничение на 2 знака после запятой
|
||||
private void DecimalTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Получаем текущий текст
|
||||
string currentText = textBox.Text;
|
||||
|
||||
// Проверяем наличие запятой
|
||||
int commaIndex = currentText.IndexOf(',');
|
||||
|
||||
if (commaIndex != -1 && currentText.Length - commaIndex > 3)
|
||||
{
|
||||
// Обрезаем текст до двух знаков после запятой
|
||||
textBox.Text = currentText.Substring(0, commaIndex + 3);
|
||||
textBox.SelectionStart = textBox.Text.Length; // Устанавливаем курсор в конец текста
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void TelephoneTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
e.Handled = !char.IsDigit(e.Text, 0);
|
||||
}
|
||||
|
||||
private void TelephoneTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Удаляем все символы, кроме цифр
|
||||
string rawInput = new string(textBox.Text.Where(char.IsDigit).ToArray());
|
||||
|
||||
// Добавляем "7" по умолчанию
|
||||
if (!rawInput.StartsWith("7"))
|
||||
rawInput = "7" + rawInput;
|
||||
|
||||
if (rawInput.Length > 11) rawInput = rawInput.Substring(0, 11);
|
||||
|
||||
// Форматируем как +7 (XXX) XXX-XX-XX
|
||||
if (rawInput.Length <= 1)
|
||||
textBox.Text = "+7 ";
|
||||
else if (rawInput.Length <= 4)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1)}";
|
||||
else if (rawInput.Length <= 7)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4)}";
|
||||
else if (rawInput.Length <= 9)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4, 3)}-{rawInput.Substring(7)}";
|
||||
else
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4, 3)}-{rawInput.Substring(7, 2)}-{rawInput.Substring(9)}";
|
||||
|
||||
// Устанавливаем курсор в конец
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
}
|
||||
|
||||
private void LoadEmployees()
|
||||
{
|
||||
var employees = _employeeLogic.GetFullList();
|
||||
|
@ -51,15 +51,20 @@
|
||||
|
||||
<StackPanel Grid.Row="0" Grid.Column="0" Margin="10">
|
||||
<Label Content="Часы работы" Foreground="White" HorizontalAlignment="Center"/>
|
||||
<TextBox x:Name="CountHoursTextBox" Width="250" Height="40" Style="{StaticResource RoundedTextBoxStyle}" />
|
||||
<TextBox x:Name="CountHoursTextBox" Width="250" Height="40" Style="{StaticResource RoundedTextBoxStyle}"
|
||||
PreviewTextInput="NumericTextBox_PreviewTextInput"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" Margin="10">
|
||||
<Label Content="Ставка за час" Foreground="White" HorizontalAlignment="Center"/>
|
||||
<TextBox x:Name="PriceHourTextBox" Width="250" Height="40" Style="{StaticResource RoundedTextBoxStyle}" />
|
||||
<TextBox x:Name="PriceHourTextBox" Width="250" Height="40" Style="{StaticResource RoundedTextBoxStyle}"
|
||||
PreviewTextInput="DecimalTextBox_PreviewTextInput"
|
||||
TextChanged="DecimalTextBox_TextChanged"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Margin="10">
|
||||
<Label Content="Премия" Foreground="White" HorizontalAlignment="Center"/>
|
||||
<TextBox x:Name="PremiumTextBox" Width="250" Height="40" Style="{StaticResource RoundedTextBoxStyle}" />
|
||||
<TextBox x:Name="PremiumTextBox" Width="250" Height="40" Style="{StaticResource RoundedTextBoxStyle}"
|
||||
PreviewTextInput="DecimalTextBox_PreviewTextInput"
|
||||
TextChanged="DecimalTextBox_TextChanged"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" Margin="10">
|
||||
<Label Content="Дата" Foreground="White" HorizontalAlignment="Center"/>
|
||||
|
@ -23,13 +23,15 @@ namespace EmployeeManagmentView.Employee.Salary
|
||||
{
|
||||
private readonly ISalaryLogic _salaryLogic; // Логика для работы с зарплатами
|
||||
private readonly IEmployeeLogic _employeeLogic; // Логика для работы с сотрудниками
|
||||
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
|
||||
private List<SalaryViewModel> _salaries;
|
||||
private List<EmployeeViewModel> _employees; // Список сотрудников
|
||||
|
||||
public EditSalaryWindow(ISalaryLogic salaryLogic, IEmployeeLogic employeeLogic)
|
||||
public EditSalaryWindow(ISalaryLogic salaryLogic, IEmployeeLogic employeeLogic, IPhisicalPersonLogic phisicalPersonLogic)
|
||||
{
|
||||
_salaryLogic = salaryLogic;
|
||||
_employeeLogic = employeeLogic;
|
||||
_phisicalPersonLogic = phisicalPersonLogic;
|
||||
InitializeComponent();
|
||||
LoadSalaries();
|
||||
}
|
||||
@ -77,6 +79,120 @@ namespace EmployeeManagmentView.Employee.Salary
|
||||
SalaryComboBox.ItemsSource = filteredSalaries;
|
||||
}
|
||||
|
||||
private void NameTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
// Разрешаем только буквы
|
||||
e.Handled = !char.IsLetter(e.Text, 0);
|
||||
}
|
||||
|
||||
private void NameTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Получаем текущий текст
|
||||
string currentText = textBox.Text;
|
||||
|
||||
// Если текст не пустой, преобразуем первую букву в заглавную, а остальные в строчные
|
||||
if (!string.IsNullOrEmpty(currentText))
|
||||
{
|
||||
// Разбиваем строку по пробелам, чтобы обрабатывать каждое слово отдельно
|
||||
var words = currentText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
for (int i = 0; i < words.Length; i++)
|
||||
{
|
||||
// Преобразуем первую букву в заглавную, а остальные в строчные
|
||||
words[i] = char.ToUpper(words[i][0]) + words[i].Substring(1).ToLower();
|
||||
}
|
||||
|
||||
// Объединяем слова обратно в строку и обновляем текст
|
||||
textBox.Text = string.Join(" ", words);
|
||||
|
||||
// Устанавливаем курсор в конец текста
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
}
|
||||
}
|
||||
|
||||
// Проверка на ввод только чисел и одной запятой
|
||||
private void DecimalTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Разрешаем только цифры и запятую
|
||||
e.Handled = !(char.IsDigit(e.Text, 0) || e.Text == ",");
|
||||
|
||||
// Проверка на количество запятых
|
||||
if (e.Text == "," && textBox.Text.Contains(","))
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void NumericTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
||||
{
|
||||
// Разрешаем ввод только цифр и запятой
|
||||
e.Handled = !char.IsDigit(e.Text, 0);
|
||||
}
|
||||
|
||||
|
||||
// Ограничение на 2 знака после запятой
|
||||
private void DecimalTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Получаем текущий текст
|
||||
string currentText = textBox.Text;
|
||||
|
||||
// Проверяем наличие запятой
|
||||
int commaIndex = currentText.IndexOf(',');
|
||||
|
||||
if (commaIndex != -1 && currentText.Length - commaIndex > 3)
|
||||
{
|
||||
// Обрезаем текст до двух знаков после запятой
|
||||
textBox.Text = currentText.Substring(0, commaIndex + 3);
|
||||
textBox.SelectionStart = textBox.Text.Length; // Устанавливаем курсор в конец текста
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void TelephoneTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
e.Handled = !char.IsDigit(e.Text, 0);
|
||||
}
|
||||
|
||||
private void TelephoneTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Удаляем все символы, кроме цифр
|
||||
string rawInput = new string(textBox.Text.Where(char.IsDigit).ToArray());
|
||||
|
||||
// Добавляем "7" по умолчанию
|
||||
if (!rawInput.StartsWith("7"))
|
||||
rawInput = "7" + rawInput;
|
||||
|
||||
if (rawInput.Length > 11) rawInput = rawInput.Substring(0, 11);
|
||||
|
||||
// Форматируем как +7 (XXX) XXX-XX-XX
|
||||
if (rawInput.Length <= 1)
|
||||
textBox.Text = "+7 ";
|
||||
else if (rawInput.Length <= 4)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1)}";
|
||||
else if (rawInput.Length <= 7)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4)}";
|
||||
else if (rawInput.Length <= 9)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4, 3)}-{rawInput.Substring(7)}";
|
||||
else
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4, 3)}-{rawInput.Substring(7, 2)}-{rawInput.Substring(9)}";
|
||||
|
||||
// Устанавливаем курсор в конец
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
|
@ -26,12 +26,14 @@ namespace EmployeeManagmentView.Employee.Salary
|
||||
|
||||
private readonly ISalaryLogic _salaryLogic;
|
||||
private readonly IEmployeeLogic _employeeLogic;
|
||||
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
|
||||
|
||||
public SalaryManagementWindow(ISalaryLogic salaryLogic, IEmployeeLogic employeeLogic)
|
||||
public SalaryManagementWindow(ISalaryLogic salaryLogic, IEmployeeLogic employeeLogic, IPhisicalPersonLogic phisicalPersonLogic)
|
||||
{
|
||||
|
||||
_salaryLogic = salaryLogic;
|
||||
_employeeLogic = employeeLogic;
|
||||
_phisicalPersonLogic = phisicalPersonLogic;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
@ -47,7 +49,7 @@ namespace EmployeeManagmentView.Employee.Salary
|
||||
}
|
||||
}
|
||||
|
||||
var addWindow = new AddSalaryWindow(_salaryLogic, _employeeLogic);
|
||||
var addWindow = new AddSalaryWindow(_salaryLogic, _employeeLogic, _phisicalPersonLogic);
|
||||
addWindow.Show();
|
||||
}
|
||||
|
||||
@ -77,7 +79,7 @@ namespace EmployeeManagmentView.Employee.Salary
|
||||
}
|
||||
}
|
||||
|
||||
var editWindow = new EditSalaryWindow(_salaryLogic, _employeeLogic);
|
||||
var editWindow = new EditSalaryWindow(_salaryLogic, _employeeLogic, _phisicalPersonLogic);
|
||||
editWindow.Show();
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,15 @@
|
||||
<Window x:Class="EmployeeManagmentView.Employee.Salary.ViewSalaryWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:EmployeeManagmentDataModels.Enums;assembly=EmployeeManagmentDataModels"
|
||||
Title="Управление зарплатами"
|
||||
Height="600" Width="800"
|
||||
ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Background="#0D2D4F">
|
||||
|
||||
<Window.Resources>
|
||||
<local:BooleanToSalaryConverter x:Key="BooleanToSalaryConverter" />
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<!-- Заголовок окна -->
|
||||
<TextBlock Text="Список зарплат"
|
||||
@ -34,8 +37,9 @@
|
||||
<DataGridTextColumn Header="Цена за час" Binding="{Binding PriceHour, StringFormat={}{0:F2}}" Width="*" />
|
||||
<DataGridTextColumn Header="Премия" Binding="{Binding Premium, StringFormat={}{0:F2}}" Width="*" />
|
||||
<DataGridTextColumn Header="Дата" Binding="{Binding Date, StringFormat=dd.MM.yyyy}" Width="*" />
|
||||
<DataGridTextColumn Header="Заврешен" Binding="{Binding Passed}" Width="*" />
|
||||
<DataGridTextColumn Header="Сотрудник" Binding="{Binding EmployeeName}" Width="*" />
|
||||
<DataGridTextColumn Header="Оплачено" Binding="{Binding Passed, Converter={StaticResource BooleanToSalaryConverter}}" Width="*" />
|
||||
<DataGridTextColumn Header="Работа" Binding="{Binding EmployeeName}" Width="*" />
|
||||
<DataGridTextColumn Header="Физ. лицо" Binding="{Binding PhysicalPersonName}" Width="*" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
using EmployeeManagmentContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -39,6 +40,7 @@ namespace EmployeeManagmentView.Employee.Salary
|
||||
SalariesDataGrid.ItemsSource = _allSalaries;
|
||||
}
|
||||
|
||||
|
||||
private void SearchTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
|
||||
{
|
||||
string query = SearchTextBox.Text.ToLower();
|
||||
|
@ -4,6 +4,7 @@ using EmployeeManagmentContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.AccessControl;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@ -25,23 +26,103 @@ namespace EmployeeManagmentView.Employee.Vacation
|
||||
|
||||
private readonly IVacationLogic _vacationLogic;
|
||||
private readonly IEmployeeLogic _employeeLogic;
|
||||
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
|
||||
private List<EmployeeViewModel> _employees;
|
||||
|
||||
public AddVacationWindow(IVacationLogic vacationLogic, IEmployeeLogic employeeLogic)
|
||||
public AddVacationWindow(IVacationLogic vacationLogic, IEmployeeLogic employeeLogic, IPhisicalPersonLogic phisicalPersonLogic)
|
||||
{
|
||||
_vacationLogic = vacationLogic;
|
||||
_employeeLogic = employeeLogic;
|
||||
_phisicalPersonLogic = phisicalPersonLogic;
|
||||
InitializeComponent();
|
||||
LoadEmployees();
|
||||
}
|
||||
|
||||
private void LoadEmployees()
|
||||
{
|
||||
var employees = _employeeLogic.GetFullList();
|
||||
EmployeeComboBox.ItemsSource = employees;
|
||||
EmployeeComboBox.DisplayMemberPath = "NameJob";
|
||||
_employees = _employeeLogic.GetFullList();
|
||||
|
||||
// Заполняем комбинированное свойство, если нужно
|
||||
foreach (var employee in _employees)
|
||||
{
|
||||
var physicalPerson = _phisicalPersonLogic.GetElement(employee.PhysicalPersonsId ?? 0);
|
||||
employee.PhysicalPersonName = physicalPerson?.FullNameWithBirthday;
|
||||
}
|
||||
|
||||
EmployeeComboBox.ItemsSource = _employees;
|
||||
EmployeeComboBox.DisplayMemberPath = "DisplayText"; // Используем новое свойство
|
||||
EmployeeComboBox.SelectedValuePath = "Id";
|
||||
}
|
||||
|
||||
private void NameTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
// Разрешаем только буквы
|
||||
e.Handled = !char.IsLetter(e.Text, 0);
|
||||
}
|
||||
|
||||
private void NameTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Получаем текущий текст
|
||||
string currentText = textBox.Text;
|
||||
|
||||
// Если текст не пустой, преобразуем первую букву в заглавную, а остальные в строчные
|
||||
if (!string.IsNullOrEmpty(currentText))
|
||||
{
|
||||
// Разбиваем строку по пробелам, чтобы обрабатывать каждое слово отдельно
|
||||
var words = currentText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
for (int i = 0; i < words.Length; i++)
|
||||
{
|
||||
// Преобразуем первую букву в заглавную, а остальные в строчные
|
||||
words[i] = char.ToUpper(words[i][0]) + words[i].Substring(1).ToLower();
|
||||
}
|
||||
|
||||
// Объединяем слова обратно в строку и обновляем текст
|
||||
textBox.Text = string.Join(" ", words);
|
||||
|
||||
// Устанавливаем курсор в конец текста
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void TelephoneTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
e.Handled = !char.IsDigit(e.Text, 0);
|
||||
}
|
||||
|
||||
private void TelephoneTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Удаляем все символы, кроме цифр
|
||||
string rawInput = new string(textBox.Text.Where(char.IsDigit).ToArray());
|
||||
|
||||
// Добавляем "7" по умолчанию
|
||||
if (!rawInput.StartsWith("7"))
|
||||
rawInput = "7" + rawInput;
|
||||
|
||||
if (rawInput.Length > 11) rawInput = rawInput.Substring(0, 11);
|
||||
|
||||
// Форматируем как +7 (XXX) XXX-XX-XX
|
||||
if (rawInput.Length <= 1)
|
||||
textBox.Text = "+7 ";
|
||||
else if (rawInput.Length <= 4)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1)}";
|
||||
else if (rawInput.Length <= 7)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4)}";
|
||||
else if (rawInput.Length <= 9)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4, 3)}-{rawInput.Substring(7)}";
|
||||
else
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4, 3)}-{rawInput.Substring(7, 2)}-{rawInput.Substring(9)}";
|
||||
|
||||
// Устанавливаем курсор в конец
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
}
|
||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
|
@ -3,6 +3,7 @@ using EmployeeManagmentContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.AccessControl;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@ -23,13 +24,15 @@ namespace EmployeeManagmentView.Employee.Vacation
|
||||
{
|
||||
private readonly IVacationLogic _vacationLogic; // Логика для работы с отпусками
|
||||
private readonly IEmployeeLogic _employeeLogic; // Логика для работы с сотрудниками
|
||||
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
|
||||
private List<VacationViewModel> _vacations;
|
||||
private List<EmployeeViewModel> _employees; // Список сотрудников
|
||||
|
||||
public EditVacationWindow(IVacationLogic vacationLogic, IEmployeeLogic employeeLogic)
|
||||
public EditVacationWindow(IVacationLogic vacationLogic, IEmployeeLogic employeeLogic, IPhisicalPersonLogic phisicalPersonLogic)
|
||||
{
|
||||
_vacationLogic = vacationLogic;
|
||||
_employeeLogic = employeeLogic;
|
||||
_phisicalPersonLogic = phisicalPersonLogic;
|
||||
InitializeComponent();
|
||||
LoadVacations();
|
||||
}
|
||||
@ -76,6 +79,75 @@ namespace EmployeeManagmentView.Employee.Vacation
|
||||
VacationComboBox.ItemsSource = filteredVacations;
|
||||
}
|
||||
|
||||
private void NameTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
// Разрешаем только буквы
|
||||
e.Handled = !char.IsLetter(e.Text, 0);
|
||||
}
|
||||
|
||||
private void NameTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Получаем текущий текст
|
||||
string currentText = textBox.Text;
|
||||
|
||||
// Если текст не пустой, преобразуем первую букву в заглавную, а остальные в строчные
|
||||
if (!string.IsNullOrEmpty(currentText))
|
||||
{
|
||||
// Разбиваем строку по пробелам, чтобы обрабатывать каждое слово отдельно
|
||||
var words = currentText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
for (int i = 0; i < words.Length; i++)
|
||||
{
|
||||
// Преобразуем первую букву в заглавную, а остальные в строчные
|
||||
words[i] = char.ToUpper(words[i][0]) + words[i].Substring(1).ToLower();
|
||||
}
|
||||
|
||||
// Объединяем слова обратно в строку и обновляем текст
|
||||
textBox.Text = string.Join(" ", words);
|
||||
|
||||
// Устанавливаем курсор в конец текста
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void TelephoneTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
e.Handled = !char.IsDigit(e.Text, 0);
|
||||
}
|
||||
|
||||
private void TelephoneTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Удаляем все символы, кроме цифр
|
||||
string rawInput = new string(textBox.Text.Where(char.IsDigit).ToArray());
|
||||
|
||||
// Добавляем "7" по умолчанию
|
||||
if (!rawInput.StartsWith("7"))
|
||||
rawInput = "7" + rawInput;
|
||||
|
||||
if (rawInput.Length > 11) rawInput = rawInput.Substring(0, 11);
|
||||
|
||||
// Форматируем как +7 (XXX) XXX-XX-XX
|
||||
if (rawInput.Length <= 1)
|
||||
textBox.Text = "+7 ";
|
||||
else if (rawInput.Length <= 4)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1)}";
|
||||
else if (rawInput.Length <= 7)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4)}";
|
||||
else if (rawInput.Length <= 9)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4, 3)}-{rawInput.Substring(7)}";
|
||||
else
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4, 3)}-{rawInput.Substring(7, 2)}-{rawInput.Substring(9)}";
|
||||
|
||||
// Устанавливаем курсор в конец
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
}
|
||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
|
@ -24,12 +24,14 @@ namespace EmployeeManagmentView.Employee.Vacation
|
||||
|
||||
private readonly IVacationLogic _vacationLogic;
|
||||
private readonly IEmployeeLogic _employeeLogic;
|
||||
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
|
||||
|
||||
public VacationManagementWindow(IVacationLogic vacationLogic, IEmployeeLogic employeeLogic)
|
||||
public VacationManagementWindow(IVacationLogic vacationLogic, IEmployeeLogic employeeLogic, IPhisicalPersonLogic phisicalPersonLogic)
|
||||
{
|
||||
|
||||
_vacationLogic = vacationLogic;
|
||||
_employeeLogic = employeeLogic;
|
||||
_phisicalPersonLogic = phisicalPersonLogic;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
@ -45,7 +47,7 @@ namespace EmployeeManagmentView.Employee.Vacation
|
||||
}
|
||||
}
|
||||
|
||||
var addWindow = new AddVacationWindow(_vacationLogic, _employeeLogic);
|
||||
var addWindow = new AddVacationWindow(_vacationLogic, _employeeLogic, _phisicalPersonLogic);
|
||||
addWindow.Show();
|
||||
}
|
||||
|
||||
@ -75,7 +77,7 @@ namespace EmployeeManagmentView.Employee.Vacation
|
||||
}
|
||||
}
|
||||
|
||||
var editWindow = new EditVacationWindow(_vacationLogic, _employeeLogic);
|
||||
var editWindow = new EditVacationWindow(_vacationLogic, _employeeLogic, _phisicalPersonLogic);
|
||||
editWindow.Show();
|
||||
}
|
||||
|
||||
@ -90,7 +92,7 @@ namespace EmployeeManagmentView.Employee.Vacation
|
||||
}
|
||||
}
|
||||
|
||||
var viewWindow = new ViewVacationWindow(_vacationLogic);
|
||||
var viewWindow = new ViewVacationWindow(_vacationLogic, _employeeLogic, _phisicalPersonLogic);
|
||||
viewWindow.Show();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
<Window x:Class="EmployeeManagmentView.Employee.Vacation.ViewVacationWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:EmployeeManagmentDataModels.Enums;assembly=EmployeeManagmentDataModels"
|
||||
Title="Управление отпусками"
|
||||
Height="600" Width="800"
|
||||
ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Background="#0D2D4F">
|
||||
|
||||
<Window.Resources>
|
||||
<local:BooleanToVacationConverter x:Key="BooleanToVacationConverter" />
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<!-- Заголовок окна -->
|
||||
<TextBlock Text="Список отпусков"
|
||||
@ -32,8 +35,8 @@
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Дата начала" Binding="{Binding StartData, StringFormat=dd.MM.yyyy}" Width="*" />
|
||||
<DataGridTextColumn Header="Дата окончания" Binding="{Binding EndData, StringFormat=dd.MM.yyyy}" Width="*" />
|
||||
<DataGridTextColumn Header="Заврешен" Binding="{Binding Passed}" Width="*" />
|
||||
<DataGridTextColumn Header="Сотрудник" Binding="{Binding EmployeeName}" Width="*" />
|
||||
<DataGridTextColumn Header="Заврешен" Binding="{Binding Passed, Converter={StaticResource BooleanToVacationConverter}}" Width="*" />
|
||||
<DataGridTextColumn Header="Работник" Binding="{Binding EmployeeName}" Width="*" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using EmployeeManagmentContracts.BusinessLogicContracts;
|
||||
using EmployeeManagmentBusinessLogic.BusinessLogic;
|
||||
using EmployeeManagmentContracts.BusinessLogicContracts;
|
||||
using EmployeeManagmentContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -23,11 +24,16 @@ namespace EmployeeManagmentView.Employee.Vacation
|
||||
{
|
||||
|
||||
private readonly IVacationLogic _vacationLogic;
|
||||
private readonly IEmployeeLogic _employeeLogic;
|
||||
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
|
||||
private IEnumerable<VacationViewModel> _allVacations;
|
||||
private List<EmployeeViewModel> _employees;
|
||||
|
||||
public ViewVacationWindow(IVacationLogic vacationLogic)
|
||||
public ViewVacationWindow(IVacationLogic vacationLogic, IEmployeeLogic employeeLogic, IPhisicalPersonLogic phisicalPersonLogic)
|
||||
{
|
||||
_vacationLogic = vacationLogic;
|
||||
_employeeLogic = employeeLogic;
|
||||
_phisicalPersonLogic = phisicalPersonLogic;
|
||||
InitializeComponent();
|
||||
LoadVacations();
|
||||
}
|
||||
@ -38,6 +44,7 @@ namespace EmployeeManagmentView.Employee.Vacation
|
||||
VacationsDataGrid.ItemsSource = _allVacations;
|
||||
}
|
||||
|
||||
|
||||
private void SearchTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
|
||||
{
|
||||
string query = SearchTextBox.Text.ToLower();
|
||||
|
@ -28,13 +28,16 @@ namespace EmployeeManagmentView.Employee
|
||||
private readonly IEmployeeLogic _employeeLogic;
|
||||
private readonly ISalaryLogic _salaryLogic;
|
||||
private readonly IVacationLogic _vacationLogic;
|
||||
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
|
||||
private IEnumerable<EmployeeViewModel> _allEmployees; // Список сотрудников для фильтрации
|
||||
private List<EmployeeViewModel> _employees;
|
||||
|
||||
public ViewEmployeeWindow(IEmployeeLogic employeeLogic, ISalaryLogic salaryLogic, IVacationLogic vacationLogic)
|
||||
public ViewEmployeeWindow(IEmployeeLogic employeeLogic, ISalaryLogic salaryLogic, IVacationLogic vacationLogic, IPhisicalPersonLogic phisicalPersonLogic)
|
||||
{
|
||||
_employeeLogic = employeeLogic;
|
||||
_salaryLogic = salaryLogic;
|
||||
_vacationLogic = vacationLogic;
|
||||
_phisicalPersonLogic = phisicalPersonLogic;
|
||||
InitializeComponent();
|
||||
LoadEmployees();
|
||||
}
|
||||
@ -43,6 +46,9 @@ namespace EmployeeManagmentView.Employee
|
||||
{
|
||||
_allEmployees = _employeeLogic.GetFullList(); // Загрузка всех данных
|
||||
EmployeesDataGrid.ItemsSource = _allEmployees;
|
||||
|
||||
_employees = _employeeLogic.GetFullList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -86,7 +92,7 @@ namespace EmployeeManagmentView.Employee
|
||||
}
|
||||
}
|
||||
|
||||
var salaryWindow = new SalaryManagementWindow(_salaryLogic, _employeeLogic);
|
||||
var salaryWindow = new SalaryManagementWindow(_salaryLogic, _employeeLogic, _phisicalPersonLogic);
|
||||
salaryWindow.Show();
|
||||
}
|
||||
|
||||
@ -105,7 +111,7 @@ namespace EmployeeManagmentView.Employee
|
||||
}
|
||||
}
|
||||
|
||||
var vacationWindow = new VacationManagementWindow(_vacationLogic, _employeeLogic);
|
||||
var vacationWindow = new VacationManagementWindow(_vacationLogic, _employeeLogic, _phisicalPersonLogic);
|
||||
vacationWindow.Show();
|
||||
}
|
||||
}
|
||||
|
@ -77,17 +77,23 @@
|
||||
<StackPanel Grid.Row="0" Grid.Column="0" Margin="10">
|
||||
<Label Content="Имя" Foreground="White" HorizontalAlignment="Center"/>
|
||||
<TextBox x:Name="NameTextBox" Width="250" Height="40"
|
||||
Style="{StaticResource RoundedTextBoxStyle}" ToolTip="Введите имя" />
|
||||
Style="{StaticResource RoundedTextBoxStyle}" ToolTip="Введите имя"
|
||||
PreviewTextInput="NameTextBox_PreviewTextInput"
|
||||
TextChanged="NameTextBox_TextChanged"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" Margin="10">
|
||||
<Label Content="Фамилия" Foreground="White" HorizontalAlignment="Center"/>
|
||||
<TextBox x:Name="SurnameTextBox" Width="250" Height="40"
|
||||
Style="{StaticResource RoundedTextBoxStyle}" ToolTip="Введите фамилию" />
|
||||
Style="{StaticResource RoundedTextBoxStyle}" ToolTip="Введите фамилию"
|
||||
PreviewTextInput="NameTextBox_PreviewTextInput"
|
||||
TextChanged="NameTextBox_TextChanged"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Margin="10" >
|
||||
<Label Content="Отчество" Foreground="White" HorizontalAlignment="Center"/>
|
||||
<TextBox x:Name="PatronomicTextBox" Width="250" Height="40"
|
||||
Style="{StaticResource RoundedTextBoxStyle}" ToolTip="Введите отчество" />
|
||||
Style="{StaticResource RoundedTextBoxStyle}" ToolTip="Введите отчество"
|
||||
PreviewTextInput="NameTextBox_PreviewTextInput"
|
||||
TextChanged="NameTextBox_TextChanged"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" Margin="10">
|
||||
<Label Content="Дата рождения" Foreground="White" HorizontalAlignment="Center"/>
|
||||
@ -109,7 +115,9 @@
|
||||
<StackPanel Grid.Row="3" Grid.Column="0" Margin="10">
|
||||
<Label Content="Телефон" Foreground="White" HorizontalAlignment="Center"/>
|
||||
<TextBox x:Name="TelephoneTextBox" Width="250" Height="40"
|
||||
Style="{StaticResource RoundedTextBoxStyle}" ToolTip="Введите номер телефона" />
|
||||
Style="{StaticResource RoundedTextBoxStyle}" ToolTip="Введите номер телефона"
|
||||
PreviewTextInput="TelephoneTextBox_PreviewTextInput"
|
||||
TextChanged="TelephoneTextBox_TextChanged"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
|
@ -62,6 +62,76 @@ namespace EmployeeManagmentView.PhysicalPerson
|
||||
}
|
||||
}
|
||||
|
||||
private void NameTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
// Разрешаем только буквы
|
||||
e.Handled = !char.IsLetter(e.Text, 0);
|
||||
}
|
||||
|
||||
private void NameTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Получаем текущий текст
|
||||
string currentText = textBox.Text;
|
||||
|
||||
// Если текст не пустой, преобразуем первую букву в заглавную, а остальные в строчные
|
||||
if (!string.IsNullOrEmpty(currentText))
|
||||
{
|
||||
// Разбиваем строку по пробелам, чтобы обрабатывать каждое слово отдельно
|
||||
var words = currentText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
for (int i = 0; i < words.Length; i++)
|
||||
{
|
||||
// Преобразуем первую букву в заглавную, а остальные в строчные
|
||||
words[i] = char.ToUpper(words[i][0]) + words[i].Substring(1).ToLower();
|
||||
}
|
||||
|
||||
// Объединяем слова обратно в строку и обновляем текст
|
||||
textBox.Text = string.Join(" ", words);
|
||||
|
||||
// Устанавливаем курсор в конец текста
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void TelephoneTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
|
||||
{
|
||||
e.Handled = !char.IsDigit(e.Text, 0);
|
||||
}
|
||||
|
||||
private void TelephoneTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
// Удаляем все символы, кроме цифр
|
||||
string rawInput = new string(textBox.Text.Where(char.IsDigit).ToArray());
|
||||
|
||||
// Добавляем "7" по умолчанию
|
||||
if (!rawInput.StartsWith("7"))
|
||||
rawInput = "7" + rawInput;
|
||||
|
||||
if (rawInput.Length > 11) rawInput = rawInput.Substring(0, 11);
|
||||
|
||||
// Форматируем как +7 (XXX) XXX-XX-XX
|
||||
if (rawInput.Length <= 1)
|
||||
textBox.Text = "+7 ";
|
||||
else if (rawInput.Length <= 4)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1)}";
|
||||
else if (rawInput.Length <= 7)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4)}";
|
||||
else if (rawInput.Length <= 9)
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4, 3)}-{rawInput.Substring(7)}";
|
||||
else
|
||||
textBox.Text = $"+7 ({rawInput.Substring(1, 3)}) {rawInput.Substring(4, 3)}-{rawInput.Substring(7, 2)}-{rawInput.Substring(9)}";
|
||||
|
||||
// Устанавливаем курсор в конец
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
}
|
||||
|
||||
|
||||
// Фильтрация списка физических лиц по всем полям
|
||||
private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user