first edit

This commit is contained in:
Курнат Андрей
2026-01-31 16:11:36 +03:00
commit f0e11d6379
148 changed files with 6986 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

View File

@@ -0,0 +1,11 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:XLIMS.TPRZ.ViewModels"
xmlns:v="clr-namespace:XLIMS.TPRZ.Views">
<DataTemplate DataType="{x:Type vm:TipViewModel}">
<v:TipView/>
</DataTemplate>
<DataTemplate DataType="{x:Type vm:TprzViewModel}">
<v:TprzView/>
</DataTemplate>
</ResourceDictionary>

View File

@@ -0,0 +1,183 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Windows.Input;
using XLIMS.CONTRACT;
using XLIMS.DATA.Models;
using XLIMS.MVVM.Base;
using XLIMS.TPRZ.Views;
namespace XLIMS.TPRZ.ViewModels
{
public class MainViewModel : ViewModelBase,IActivityViewModel
{
#region Constructor
public MainViewModel(ILimsService limsService, IDialogService dialogService)
{
_limsService = limsService;
_dialogService = dialogService;
_limsService.Spois.SetChanged += OnSpoisChanged;
_limsService.Tips.SetChanged += OnTipsChanged;
_limsService.Tprzs.SetChanged += OnTprzsChanged;
LoadSpoiAsync();
}
#endregion //Constructor
#region Events
private async void OnSpoisChanged()
{
await LoadSpoiAsync();
}
private async void OnTipsChanged()
{
await LoadTipAsync();
}
private async void OnTprzsChanged()
{
await LoadTprzAsync();
}
#endregion //Events
#region Fields
private readonly IDialogService _dialogService;
private readonly ILimsService _limsService;
private bool _isLoading;
private TipViewModel _currentTip;
private TprzViewModel _currentTprz;
private Spoi _currentSpoi;
#endregion //Fields
#region Properties
public string Title => "ТПРМ";
public object View => new MainView();
public ObservableCollection<Spoi> AllSpois { get; set; } = new();
public ObservableCollection<TipViewModel> AllTips { get; set; } = new();
public ObservableCollection<TprzViewModel> AllTprzs { get; set; } = new();
public Spoi CurrentSpoi
{
get => _currentSpoi;
set
{
_currentSpoi = value;
if (_currentSpoi != null) LoadTipAsync();
OnPropertyChanged();
}
}
public TipViewModel CurrentTip
{
get => _currentTip;
set
{
_currentTip = value;
if (_currentTip != null) LoadTprzAsync();
OnPropertyChanged();
}
}
public TprzViewModel CurrentTprz
{
get => _currentTprz;
set { _currentTprz = value; OnPropertyChanged(); }
}
public bool IsLoading
{
get => _isLoading;
set { _isLoading = value; OnPropertyChanged(); }
}
#endregion //Properties
#region Methods
public async Task LoadSpoiAsync()
{
IsLoading = true;
try
{
// Параллельная загрузка данных из разных доменов через подсервисы
var spoisTask = await _limsService.Spois.GetAllAsync();
AllSpois = new ObservableCollection<Spoi>(spoisTask);
OnPropertyChanged(nameof(AllSpois));
}
finally
{
IsLoading = false;
}
}
public async Task LoadTipAsync()
{
IsLoading = true;
try
{
// Параллельная загрузка данных из разных доменов через подсервисы
var tipsTask = await _limsService.Tips.GetAllAsync();
AllTips = new ObservableCollection<TipViewModel>(tipsTask.Where(e=>e.Idspoi==CurrentSpoi.Id).Select(s=>new TipViewModel(_limsService,null,s)));
OnPropertyChanged(nameof(AllTips));
}
finally
{
IsLoading = false;
}
}
public async Task LoadTprzAsync()
{
IsLoading = true;
try
{
// Параллельная загрузка данных из разных доменов через подсервисы
var tprzsTask = await _limsService.Tprzs.GetAllAsync();
AllTprzs = new ObservableCollection<TprzViewModel>(tprzsTask.Where(e=>e.Idtip==CurrentTip.Id).Select(s => new TprzViewModel(_limsService,0,s)));
OnPropertyChanged(nameof(AllTprzs));
}
finally
{
IsLoading = false;
}
}
private void AddTip()
{
_dialogService.ShowDialog(new TipViewModel(_limsService,CurrentSpoi));
}
private void EditTip()
{
_dialogService.ShowDialog(CurrentTip);
}
private async Task DelTipAsync()
{
await CurrentTip.Remove();
AllTips.Remove(CurrentTip);
OnPropertyChanged(nameof(AllTips));
}
private void AddTprz()
{
_dialogService.ShowDialog(new TprzViewModel(_limsService,CurrentTip.Id));
}
private void EditTprz()
{
_dialogService.ShowDialog(CurrentTprz);
}
private async Task DelTprzAsync()
{
await CurrentTprz.Remove();
AllTprzs.Remove(CurrentTprz);
OnPropertyChanged(nameof(AllTprzs));
}
#endregion //Methods
#region Commands
public ICommand AddTipCommand => new RelayCommand(p => AddTip(),p=>CurrentSpoi!=null);
public ICommand EditTipCommand => new RelayCommand(p => EditTip(), p => CurrentTip != null);
public ICommand DelTipCommand => new AsyncRelayCommand(DelTipAsync, () => CurrentTip != null);
public ICommand AddTprzCommand => new RelayCommand(p => AddTprz(),p=>CurrentTip!=null);
public ICommand EditTprzCommand => new RelayCommand(p => EditTprz(), p => CurrentTprz != null);
public ICommand DelTprzCommand => new AsyncRelayCommand(DelTprzAsync, () => CurrentTprz != null);
#endregion //Commands
}
}

View File

@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Windows.Input;
using XLIMS.CONTRACT;
using XLIMS.DATA.Models;
using XLIMS.MVVM.Base;
namespace XLIMS.TPRZ.ViewModels
{
public class TipViewModel : ViewModelBase
{
#region Constructor
public TipViewModel(ILimsService limsService,Spoi spoi, Tip tip = null)
{
_limsService = limsService;
if (tip != null) _tip = tip;
else _tip = new Tip() {IdspoiNavigation=spoi };
LoadSpnmtpAsync();
}
#endregion //Constructor
#region Events
#endregion //Events
#region Fields
private readonly ILimsService _limsService;
private readonly Tip _tip;
private Spnmtp _currentSpnmtp;
#endregion //Fields
#region Properties
public ObservableCollection<Spnmtp> AllSpnmtps { get; set; } = new();
public Spnmtp CurrentSpnmtp
{
get=> _currentSpnmtp;
set
{
_currentSpnmtp = value;
if (_currentSpnmtp != null) _tip.IdspnmtpNavigation = _currentSpnmtp;
OnPropertyChanged();
}
}
public string? Tp
{
get => _tip.Tp;
set { _tip.Tp = value; OnPropertyChanged(); }
}
public int Id => _tip.Id;
#endregion //Properties
#region Methods
public async Task LoadSpnmtpAsync()
{
try
{
// Параллельная загрузка данных из разных доменов через подсервисы
var spnmtpsTask = await _limsService.Spnmtps.GetAllAsync();
AllSpnmtps = new ObservableCollection<Spnmtp>(spnmtpsTask);
OnPropertyChanged(nameof(AllSpnmtps));
}
finally
{
}
}
private async Task SaveAsync()
{
if (_tip.Id == 0) await _limsService.Tips.AddAsync(_tip);
else await _limsService.Tips.UpdateAsync(_tip);
}
public async Task Remove()
{
await _limsService.Tips.RemoveAsync(_tip);
}
#endregion //Methods
#region Commands
public ICommand SaveCommand => new AsyncRelayCommand(SaveAsync);
#endregion //Commands
}
}

View File

@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Windows.Input;
using XLIMS.CONTRACT;
using XLIMS.DATA.Models;
using XLIMS.MVVM.Base;
namespace XLIMS.TPRZ.ViewModels
{
public class TprzViewModel : ViewModelBase
{
#region Constructor
public TprzViewModel(ILimsService limsService, int idtip, Tprz tprz = null)
{
_limsService = limsService;
if (tprz != null) _tprz = tprz;
else _tprz = new Tprz() { Idtip = idtip };
}
#endregion //Constructor
#region Events
#endregion //Events
#region Fields
private readonly ILimsService _limsService;
private readonly Tprz _tprz;
private Spnmtp _currentSpnmtp;
#endregion //Fields
#region Properties
public string? Dpzn
{
get => _tprz.Dpzn;
set { _tprz.Dpzn = value; OnPropertyChanged(); }
}
public string? Hrtc
{
get => _tprz.Hrtc;
set { _tprz.Hrtc = value; OnPropertyChanged(); }
}
#endregion //Properties
#region Methods
private async Task SaveAsync()
{
if (_tprz.Id == 0) await _limsService.Tprzs.AddAsync(_tprz);
else await _limsService.Tprzs.UpdateAsync(_tprz);
}
public async Task Remove()
{
await _limsService.Tprzs.RemoveAsync(_tprz);
}
#endregion //Methods
#region Commands
public ICommand SaveCommand => new AsyncRelayCommand(SaveAsync);
#endregion //Commands
}
}

View File

@@ -0,0 +1,8 @@
<UserControl x:Class="XLIMS.TPRZ.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Grid>
<TextBlock Text="{Binding Title}"/>
</Grid>
</UserControl>

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace XLIMS.TPRZ.Views
{
/// <summary>
/// Логика взаимодействия для MainView.xaml
/// </summary>
public partial class MainView : UserControl
{
public MainView()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,16 @@
<UserControl x:Class="XLIMS.TPRZ.Views.TipView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<ComboBox ItemsSource="{Binding AllSpnmtps}"
SelectedItem="{Binding CurrentSpnmtp,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="Nmtp" Grid.Row="0" Margin="3"/>
<TextBox Text="{Binding Tp,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Margin="3"/>
</Grid>
</UserControl>

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace XLIMS.TPRZ.Views
{
/// <summary>
/// Логика взаимодействия для TipView.xaml
/// </summary>
public partial class TipView : UserControl
{
public TipView()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,8 @@
<UserControl x:Class="XLIMS.TPRZ.Views.TprzView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Grid>
<TextBox Text="{Binding Dpzn,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</UserControl>

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace XLIMS.TPRZ.Views
{
/// <summary>
/// Логика взаимодействия для TprzView.xaml
/// </summary>
public partial class TprzView : UserControl
{
public TprzView()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,42 @@
<Window
x:Class="XLIMS.TPRZ.Windows.EditWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="{Binding Title}"
DataContext="{Binding}"
ShowInTaskbar="True"
SizeToContent="WidthAndHeight"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
WindowStyle="ToolWindow">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Resources/CoreDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<DockPanel LastChildFill="True">
<DockPanel
Margin="10"
DockPanel.Dock="Bottom"
LastChildFill="False">
<Button
Width="85"
Click="Button_Click_1"
Command="{Binding CancelCommand}"
Content="Отмена"
DockPanel.Dock="Right"
IsCancel="True" />
<Button
Width="85"
Margin="0,0,10,0"
Click="Button_Click_2"
Command="{Binding SaveCommand}"
Content="ОК"
DockPanel.Dock="Right"
IsDefault="True" />
</DockPanel>
<ContentControl Content="{Binding}" />
</DockPanel>
</Window>

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace XLIMS.TPRZ.Windows
{
/// <summary>
/// Логика взаимодействия для EditWindow.xaml
/// </summary>
public partial class EditWindow : Window
{
public EditWindow()
{
InitializeComponent();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
DialogResult = false;
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
DialogResult = true;
}
}
}

View File

@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\XLIMS.CONTRACT\XLIMS.CONTRACT.csproj" />
<ProjectReference Include="..\XLIMS.DATA\XLIMS.DATA.csproj" />
<ProjectReference Include="..\XLIMS.MVVM\XLIMS.MVVM.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Views\TipView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\TprzView.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
</Project>