To Be Continued
parent
114de77f0d
commit
e7b75a0b73
|
|
@ -137,4 +137,21 @@ public class EquipmentRepository : BaseRepository<Equipment>, IDisposable
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ValidateInvNumber(string invNumber)
|
||||||
|
{
|
||||||
|
string sql = "select * from `Equipment` where InvNumber=@invNumber";
|
||||||
|
using(var mc = new MySqlCommand(sql, connection))
|
||||||
|
{
|
||||||
|
mc.Parameters.AddWithValue("@invNumber", invNumber);
|
||||||
|
using (var reader = mc.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -113,9 +113,9 @@ public partial class EmployeeEditingWindowViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
_currentWindow = window;
|
_currentWindow = window;
|
||||||
_currentWindow.ConfirmButton.Content = _isEditing ? "Изменить" : "Добавить";
|
_currentWindow.ConfirmButton.Content = _isEditing ? "Изменить" : "Добавить";
|
||||||
if (_isEditing)
|
if (!_isEditing)
|
||||||
{
|
{
|
||||||
|
_currentWindow.FireButton.IsVisible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using AvaloniaApplication14_Inventory_300326.Models.DataBase;
|
using AvaloniaApplication14_Inventory_300326.Models.DataBase;
|
||||||
using AvaloniaApplication14_Inventory_300326.Models.Factoryes;
|
using AvaloniaApplication14_Inventory_300326.Models.Factoryes;
|
||||||
using AvaloniaApplication14_Inventory_300326.Models.Models;
|
using AvaloniaApplication14_Inventory_300326.Models.Models;
|
||||||
|
|
@ -8,6 +9,8 @@ using AvaloniaApplication14_Inventory_300326.Views;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using MsBox.Avalonia;
|
||||||
|
using MsBox.Avalonia.Enums;
|
||||||
|
|
||||||
namespace AvaloniaApplication14_Inventory_300326.ViewModels;
|
namespace AvaloniaApplication14_Inventory_300326.ViewModels;
|
||||||
|
|
||||||
|
|
@ -26,11 +29,14 @@ public partial class EquipmentEditingWindowViewModel : ViewModelBase
|
||||||
[ObservableProperty] private DateTimeOffset? _date;
|
[ObservableProperty] private DateTimeOffset? _date;
|
||||||
[ObservableProperty] private decimal _cost;
|
[ObservableProperty] private decimal _cost;
|
||||||
[ObservableProperty] private bool _isWrittenOff;
|
[ObservableProperty] private bool _isWrittenOff;
|
||||||
|
[ObservableProperty] private string _isWrittenOffString;
|
||||||
[ObservableProperty] private Employee _currentEmployee;
|
[ObservableProperty] private Employee _currentEmployee;
|
||||||
[ObservableProperty] private ObservableCollection<Employee> _employees;
|
[ObservableProperty] private ObservableCollection<Employee> _employees;
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private void Confrm()
|
private async Task Confrm()
|
||||||
|
{
|
||||||
|
using (var repo = _serviceProvider.GetService<EquipmentRepository>())
|
||||||
{
|
{
|
||||||
_equipment.InvNumber = InvNumber;
|
_equipment.InvNumber = InvNumber;
|
||||||
_equipment.Date = Date;
|
_equipment.Date = Date;
|
||||||
|
|
@ -39,16 +45,30 @@ public partial class EquipmentEditingWindowViewModel : ViewModelBase
|
||||||
_equipment.CurrentEmployee = CurrentEmployee;
|
_equipment.CurrentEmployee = CurrentEmployee;
|
||||||
_equipment.Name = Name;
|
_equipment.Name = Name;
|
||||||
|
|
||||||
using (var repo = _serviceProvider.GetService<EquipmentRepository>())
|
|
||||||
{
|
|
||||||
if (_isEditing)
|
if (_isEditing)
|
||||||
{
|
{
|
||||||
repo.Update(_equipmentFactory.CreateFromVisual(_equipment));
|
repo.Update(_equipmentFactory.CreateFromVisual(_equipment));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (repo.ValidateInvNumber(InvNumber))
|
||||||
|
{
|
||||||
|
if (Cost>0)
|
||||||
{
|
{
|
||||||
repo.Add(_equipmentFactory.CreateFromVisual(_equipment));
|
repo.Add(_equipmentFactory.CreateFromVisual(_equipment));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var ErrorWin = MessageBoxManager.GetMessageBoxStandard("Ошибка", "Стоимость должна быть больше 0", ButtonEnum.Ok, Icon.Error);
|
||||||
|
await ErrorWin.ShowWindowDialogAsync(_currentWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var ErrorWin = MessageBoxManager.GetMessageBoxStandard("Ошибка", "Объект с таким инвентарным номером уже существует", ButtonEnum.Ok, Icon.Error);
|
||||||
|
await ErrorWin.ShowWindowDialogAsync(_currentWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_currentWindow.Close();
|
_currentWindow.Close();
|
||||||
}
|
}
|
||||||
|
|
@ -80,6 +100,7 @@ public partial class EquipmentEditingWindowViewModel : ViewModelBase
|
||||||
Date = _equipment.Date;
|
Date = _equipment.Date;
|
||||||
Cost = _equipment.Cost;
|
Cost = _equipment.Cost;
|
||||||
IsWrittenOff = _equipment.IsWrittenOff;
|
IsWrittenOff = _equipment.IsWrittenOff;
|
||||||
|
IsWrittenOffString = _equipment.IsWrittenOff?"Да":"Нет";
|
||||||
CurrentEmployee = _equipment.CurrentEmployee;
|
CurrentEmployee = _equipment.CurrentEmployee;
|
||||||
Employees = new ObservableCollection<Employee>();
|
Employees = new ObservableCollection<Employee>();
|
||||||
Employees.Add(CurrentEmployee);
|
Employees.Add(CurrentEmployee);
|
||||||
|
|
@ -102,10 +123,12 @@ public partial class EquipmentEditingWindowViewModel : ViewModelBase
|
||||||
if (_isEditing)
|
if (_isEditing)
|
||||||
{
|
{
|
||||||
_currentWindow.CurrentEmployeeBox.IsVisible = false;
|
_currentWindow.CurrentEmployeeBox.IsVisible = false;
|
||||||
|
_currentWindow.IsWrittenOffCheckBox.IsVisible = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_currentWindow.CurrentEmployeeLabel.IsVisible = false;
|
_currentWindow.CurrentEmployeeLabel.IsVisible = false;
|
||||||
|
_currentWindow.IsWrittenOffLabel.IsVisible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -43,9 +43,9 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
var equipment = new Equipment();
|
var equipment = new Equipment();
|
||||||
var EquipmentVm = ActivatorUtilities.CreateInstance<EquipmentEditingWindowViewModel>(_serviceProvider, equipment);
|
var equipmentVm = ActivatorUtilities.CreateInstance<EquipmentEditingWindowViewModel>(_serviceProvider, equipment);
|
||||||
var EquipmentWin = ActivatorUtilities.CreateInstance<EquipmentEditingWindow>(_serviceProvider, EquipmentVm);
|
var equipmentWin = ActivatorUtilities.CreateInstance<EquipmentEditingWindow>(_serviceProvider, equipmentVm);
|
||||||
await EquipmentWin.ShowDialog(_currentWindow);
|
await equipmentWin.ShowDialog(_currentWindow);
|
||||||
|
|
||||||
EquipmentViewModel.ShowTeches();
|
EquipmentViewModel.ShowTeches();
|
||||||
EquipmentViewModel.GetTeches();
|
EquipmentViewModel.GetTeches();
|
||||||
|
|
@ -54,15 +54,24 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||||
case 1:
|
case 1:
|
||||||
|
|
||||||
var employee = new Employee();
|
var employee = new Employee();
|
||||||
var EmployeeVm = ActivatorUtilities.CreateInstance<EmployeeEditingWindowViewModel>(_serviceProvider, employee);
|
var employeeVm = ActivatorUtilities.CreateInstance<EmployeeEditingWindowViewModel>(_serviceProvider, employee);
|
||||||
var EmployeeWin = ActivatorUtilities.CreateInstance<EmployeeEditingWindow>(_serviceProvider, EmployeeVm);
|
var employeeWin = ActivatorUtilities.CreateInstance<EmployeeEditingWindow>(_serviceProvider, employeeVm);
|
||||||
await EmployeeWin.ShowDialog(_currentWindow);
|
await employeeWin.ShowDialog(_currentWindow);
|
||||||
|
|
||||||
EmployeesViewModel.ShowEmployees();
|
EmployeesViewModel.ShowEmployees();
|
||||||
EmployeesViewModel.GetEmployees();
|
EmployeesViewModel.GetEmployees();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
|
var position = new Position();
|
||||||
|
var positionVm = ActivatorUtilities.CreateInstance<PositionEditingWindowViewModel>(_serviceProvider, position);
|
||||||
|
var positionWin = ActivatorUtilities.CreateInstance<PositionEditingWindow>(_serviceProvider, positionVm);
|
||||||
|
await positionWin.ShowDialog(_currentWindow);
|
||||||
|
|
||||||
|
PositionViewModel.ShowPositions();
|
||||||
|
PositionViewModel.GetPositions();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
|
using AvaloniaApplication14_Inventory_300326.Models.DataBase;
|
||||||
using AvaloniaApplication14_Inventory_300326.Models.Models;
|
using AvaloniaApplication14_Inventory_300326.Models.Models;
|
||||||
using AvaloniaApplication14_Inventory_300326.Views;
|
using AvaloniaApplication14_Inventory_300326.Views;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace AvaloniaApplication14_Inventory_300326.ViewModels;
|
namespace AvaloniaApplication14_Inventory_300326.ViewModels;
|
||||||
|
|
||||||
|
|
@ -11,24 +13,38 @@ public partial class PositionEditingWindowViewModel : ViewModelBase
|
||||||
private IServiceProvider _serviceProvider;
|
private IServiceProvider _serviceProvider;
|
||||||
private bool _isEditing;
|
private bool _isEditing;
|
||||||
private PositionEditingWindow _currentWindow;
|
private PositionEditingWindow _currentWindow;
|
||||||
|
private Position _position;
|
||||||
|
|
||||||
[ObservableProperty] private string _positionName;
|
[ObservableProperty] private string _positionName;
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private void Cancel()
|
private void Cancel()
|
||||||
{
|
{
|
||||||
|
_currentWindow.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private void Confirm()
|
private void Confirm()
|
||||||
{
|
{
|
||||||
|
_position.Name = PositionName;
|
||||||
|
using (var _positionRepository = _serviceProvider.GetService<PositionRepository>())
|
||||||
|
{
|
||||||
|
if (_isEditing)
|
||||||
|
{
|
||||||
|
_positionRepository.Update(_position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_positionRepository.Add(_position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_currentWindow.Close();
|
||||||
}
|
}
|
||||||
public PositionEditingWindowViewModel(IServiceProvider serviceProvider, Position position)
|
public PositionEditingWindowViewModel(IServiceProvider serviceProvider, Position position)
|
||||||
{
|
{
|
||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
_isEditing = !position.IsNew();
|
_isEditing = !position.IsNew();
|
||||||
|
_position = position;
|
||||||
if (_isEditing)
|
if (_isEditing)
|
||||||
{
|
{
|
||||||
PositionName = position.Name;
|
PositionName = position.Name;
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ public partial class PositionViewModel : ViewModelBase
|
||||||
|
|
||||||
public async Task DoubleTappedPositionDataGrid()
|
public async Task DoubleTappedPositionDataGrid()
|
||||||
{
|
{
|
||||||
var PositionVm = ActivatorUtilities.CreateInstance<PositionEditingWindowViewModel>(_serviceProvider, SelectedPosition);
|
var positionVm = ActivatorUtilities.CreateInstance<PositionEditingWindowViewModel>(_serviceProvider, SelectedPosition);
|
||||||
var win = ActivatorUtilities.CreateInstance<PositionEditingWindow>(_serviceProvider, PositionVm);
|
var win = ActivatorUtilities.CreateInstance<PositionEditingWindow>(_serviceProvider, positionVm);
|
||||||
await win.ShowDialog(_currentWindow);
|
await win.ShowDialog(_currentWindow);
|
||||||
ShowPositions();
|
ShowPositions();
|
||||||
GetPositions();
|
GetPositions();
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@
|
||||||
|
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<Label Content="Списано ли: "></Label>
|
<Label Content="Списано ли: "></Label>
|
||||||
<CheckBox IsChecked="{Binding IsWrittenOff}"></CheckBox>
|
<CheckBox x:Name="IsWrittenOffCheckBox" IsChecked="{Binding IsWrittenOff}"></CheckBox>
|
||||||
|
<Label x:Name="IsWrittenOffLabel" Content="{Binding IsWrittenOffString}"></Label>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
|
|
|
||||||
|
|
@ -41,16 +41,11 @@
|
||||||
<DataGridTextColumn Header="ФИО" Binding="{Binding FullName}"></DataGridTextColumn>
|
<DataGridTextColumn Header="ФИО" Binding="{Binding FullName}"></DataGridTextColumn>
|
||||||
<DataGridTextColumn Header="Должность" Binding="{Binding Position.Name}"></DataGridTextColumn>
|
<DataGridTextColumn Header="Должность" Binding="{Binding Position.Name}"></DataGridTextColumn>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
<DataGrid.ContextMenu>
|
|
||||||
<ContextMenu>
|
|
||||||
<Button Content="Уволить" Command="{Binding FireCommand}"></Button>
|
|
||||||
</ContextMenu>
|
|
||||||
</DataGrid.ContextMenu>
|
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|
||||||
<ScrollViewer Grid.Row="1" x:Name="ScrollViewerDataGridPos">
|
<ScrollViewer Grid.Row="1" x:Name="ScrollViewerDataGridPos">
|
||||||
<DataGrid x:Name="DataGridPositions" ItemsSource="{Binding PositionViewModel.Positions}" IsReadOnly="True">
|
<DataGrid x:Name="DataGridPositions" ItemsSource="{Binding PositionViewModel.Positions}" SelectedItem="{Binding PositionViewModel.SelectedPosition}" IsReadOnly="True">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="Название" Binding="{Binding Name}"></DataGridTextColumn>
|
<DataGridTextColumn Header="Название" Binding="{Binding Name}"></DataGridTextColumn>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
|
|
@ -59,7 +54,10 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="Операции">
|
<TabItem Header="Операции">
|
||||||
|
<StackPanel>
|
||||||
|
<Button Content="Передача техники"></Button>
|
||||||
|
<Button Content="Списание техники"></Button>
|
||||||
|
</StackPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="Отчеты">
|
<TabItem Header="Отчеты">
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,15 @@
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="AvaloniaApplication14_Inventory_300326.Views.PositionEditingWindow"
|
x:Class="AvaloniaApplication14_Inventory_300326.Views.PositionEditingWindow"
|
||||||
x:DataType="vm:PositionEditingWindowViewModel"
|
x:DataType="vm:PositionEditingWindowViewModel"
|
||||||
Title="PositionEditingWindow">
|
Title="PositionEditingWindow"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
SizeToContent="WidthAndHeight">
|
||||||
|
|
||||||
<Grid RowDefinitions="* *" ColumnDefinitions="* *">
|
<Grid RowDefinitions="Auto *" ColumnDefinitions="Auto *">
|
||||||
<Label Content="Название должности: "></Label>
|
<Label Content="Название должности: "></Label>
|
||||||
<TextBox Grid.Row="0" Grid.Column="1"></TextBox>
|
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding PositionName}"></TextBox>
|
||||||
<Button Grid.Row="1" Grid.Column="0" x:Name="ConfirmButton" Command="{Binding ConfirmCommand}"></Button>
|
<Button Grid.Row="1" Grid.Column="0" x:Name="ConfirmButton" Command="{Binding ConfirmCommand}"></Button>
|
||||||
<Button Grid.Row="1" Grid.Column="1" Command="{Binding CancelCommand}"></Button>
|
<Button Grid.Row="1" Grid.Column="1" Content="Закрыть" Command="{Binding CancelCommand}"></Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
</Window>
|
</Window>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using AvaloniaApplication14_Inventory_300326.ViewModels;
|
||||||
|
|
||||||
namespace AvaloniaApplication14_Inventory_300326.Views;
|
namespace AvaloniaApplication14_Inventory_300326.Views;
|
||||||
|
|
||||||
public partial class PositionEditingWindow : Window
|
public partial class PositionEditingWindow : Window
|
||||||
{
|
{
|
||||||
public PositionEditingWindow()
|
public PositionEditingWindow(PositionEditingWindowViewModel vm)
|
||||||
{
|
{
|
||||||
|
DataContext = vm;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
vm.SetWindow(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
|
|
@ -13,7 +13,7 @@ using System.Reflection;
|
||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("AvaloniaApplication14_Inventory_300326")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("AvaloniaApplication14_Inventory_300326")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+cca23316ccaf6ff854c560608fe74ea070bdd85a")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+114de77f0db0da5ab82bfb620f42bf9b0cec4498")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("AvaloniaApplication14_Inventory_300326")]
|
[assembly: System.Reflection.AssemblyProductAttribute("AvaloniaApplication14_Inventory_300326")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("AvaloniaApplication14_Inventory_300326")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("AvaloniaApplication14_Inventory_300326")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
63e3e38dd183c9ac63856099ca701d49eeb37cffc3fb48b85df28a550d81ee4f
|
fda96c39694f07179b132880ffdf1ac5e54167a8724825f882522f81db71ce13
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue