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,141 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.ComponentModel;
using System.Xml.Linq;
using Microsoft.Win32;
using System.IO;
using XLIMS.MVVM.Base;
using XLIMS.CONTRACT;
using XLIMS.DATA.Models;
namespace XLIMS.PSV.ViewModels
{
public class BadViewModel : ViewModelBase
{
#region Constructor
public BadViewModel(ILimsService limsService, DataSet data)
{
_limsService = limsService;
_currentData = data;
if (_currentData.Gdn == null)
{
_povDoc = new DocumentSet() { Division = _currentData.Device.Division,Name="Извещение" };
_currentData.DocumentPov = _povDoc;
}
else if (_currentData.DocumentPov != null) _povDoc = _currentData.DocumentPov;
LoadDataAsync();
}
#endregion //Constructor
#region Fields
private readonly ILimsService _limsService;
private DataSet _currentData;
private bool _isValid;
private PersonalSet _currentPersonal;
private DocumentSet _povDoc;
private BookSet _currentBook;
#endregion //Fields
#region Properties
public string Title => $"{_currentData.Device.Tip} №{_currentData.Device.Serial} {_currentData.Device.Name}";
public ObservableCollection<PersonalSet> AllPersonals { get; set; }
public ObservableCollection<BookSet> AllBooks { get; set; }
public BookSet CurrentBook
{
get => _currentBook;
set { _currentBook = value; OnPropertyChanged(); }
}
public PersonalSet CurrentPersonal
{
get => _currentPersonal;
set
{
_currentPersonal = value;
if (_currentPersonal != null) { _currentData.Person = _currentPersonal.Person; }
OnPropertyChanged();
}
}
public DateTime? PovDate
{
get => _currentData.Date;
set
{
_currentData.Date = value;
OnPropertyChanged();
}
}
public string Reason
{
get => _currentData.Reason;
set
{
_currentData.Reason = value;
OnPropertyChanged();
}
}
public string Number
{
get => _povDoc.Number;
set
{
_povDoc.Number = value;
OnPropertyChanged();
}
}
public DateTime? DocDate
{
get => _povDoc.DocDate;
set
{
_povDoc.DocDate = value;
OnPropertyChanged();
}
}
private async Task LoadDataAsync()
{
var personalTask = await _limsService.Personals.GetAllAsync();
var bookTask=await _limsService.Books.GetAllAsync();
AllPersonals=new ObservableCollection<PersonalSet>(personalTask);
AllBooks=new ObservableCollection<BookSet>(bookTask);
OnPropertyChanged(nameof(AllPersonals));
OnPropertyChanged(nameof(AllBooks));
}
private async Task SaveAsync()
{
if (_currentData.Gdn == null)
{
_currentData.Gdn = false;
await _limsService.Datas.UpdateAsync(_currentData);
var result = MessageBox.Show("Распечатать извещение?", "Внимание!", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
try
{
//await Task.Run(() => new Izv(_newDMS, _repository).Print());
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}
}
else { await _limsService.Datas.UpdateAsync(_currentData); }
}
#endregion //properties
#region Commands
public ICommand SaveCommand => new AsyncRelayCommand(SaveAsync, () => CurrentPersonal != null && !string.IsNullOrEmpty(Number));
#endregion //Commands
#region IDataErrorInfo
#endregion
}
}