edit
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<Solution>
|
||||
<Project Path="XLAB.DATA/XLAB.DATA.csproj" />
|
||||
<Project Path="XLAB/XLAB.csproj" />
|
||||
<Project Path="XLAB.DATA/XLAB.DATA.csproj" Id="ae0e35d7-dfa4-4150-9889-255043b232bb" />
|
||||
<Project Path="XLAB/XLAB.csproj" Id="b8daab84-777a-4274-8452-e602db1af587" />
|
||||
</Solution>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
|
||||
namespace XLAB
|
||||
@@ -6,6 +7,13 @@ namespace XLAB
|
||||
{
|
||||
DocumentEditorResult ShowCreateDocumentDialog(DocumentEditorResult seed);
|
||||
|
||||
IReadOnlyList<AvailableInstrumentItem> ShowInstrumentPickerDialog(string customerName, IReadOnlyList<AvailableInstrumentItem> instruments);
|
||||
|
||||
VerificationEditResult ShowVerificationDialog(
|
||||
VerificationEditSeed seed,
|
||||
IReadOnlyList<PersonReference> verifiers,
|
||||
IReadOnlyList<DocumentFormReference> documentForms);
|
||||
|
||||
bool Confirm(string message);
|
||||
|
||||
void ShowError(string message);
|
||||
@@ -34,6 +42,29 @@ namespace XLAB
|
||||
return result.HasValue && result.Value ? viewModel.ToResult() : null;
|
||||
}
|
||||
|
||||
public IReadOnlyList<AvailableInstrumentItem> ShowInstrumentPickerDialog(string customerName, IReadOnlyList<AvailableInstrumentItem> instruments)
|
||||
{
|
||||
var viewModel = new SelectInstrumentsWindowViewModel(customerName, instruments);
|
||||
var window = new SelectInstrumentsWindow(viewModel);
|
||||
window.Owner = _owner;
|
||||
|
||||
var result = window.ShowDialog();
|
||||
return result.HasValue && result.Value ? viewModel.GetSelectedItems() : null;
|
||||
}
|
||||
|
||||
public VerificationEditResult ShowVerificationDialog(
|
||||
VerificationEditSeed seed,
|
||||
IReadOnlyList<PersonReference> verifiers,
|
||||
IReadOnlyList<DocumentFormReference> documentForms)
|
||||
{
|
||||
var viewModel = new VerificationEditWindowViewModel(seed, verifiers, documentForms);
|
||||
var window = new VerificationEditWindow(viewModel);
|
||||
window.Owner = _owner;
|
||||
|
||||
var result = window.ShowDialog();
|
||||
return result.HasValue && result.Value ? viewModel.ToResult() : null;
|
||||
}
|
||||
|
||||
public bool Confirm(string message)
|
||||
{
|
||||
return MessageBox.Show(_owner, message, "ПСВ", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes;
|
||||
|
||||
@@ -157,12 +157,15 @@
|
||||
Margin="0,0,8,6"
|
||||
VerticalAlignment="Center"
|
||||
Text="Заказчик" />
|
||||
<TextBox Grid.Row="1"
|
||||
<ComboBox Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="3"
|
||||
Margin="0,0,12,6"
|
||||
IsReadOnly="True"
|
||||
Text="{Binding HeaderCustomerName, Mode=OneWay}" />
|
||||
ItemsSource="{Binding Customers}"
|
||||
DisplayMemberPath="CustomerName"
|
||||
SelectedValuePath="CustomerId"
|
||||
SelectedValue="{Binding SelectedCustomerId, Mode=TwoWay}"
|
||||
IsEnabled="{Binding IsCustomerEditable}" />
|
||||
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.Column="4"
|
||||
@@ -191,6 +194,12 @@
|
||||
CanUserAddRows="False"
|
||||
IsReadOnly="True"
|
||||
HeadersVisibility="Column">
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
|
||||
<MenuItem Header="Выбрать по заводским номерам"
|
||||
Command="{Binding OpenInstrumentPickerCommand}" />
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Тип"
|
||||
Width="180"
|
||||
@@ -236,10 +245,28 @@
|
||||
|
||||
<DataGrid Grid.Row="1"
|
||||
ItemsSource="{Binding DocumentLinesView}"
|
||||
SelectedItem="{Binding SelectedDocumentLine, Mode=TwoWay}"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
IsReadOnly="True"
|
||||
HeadersVisibility="Column">
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
|
||||
<MenuItem Header="Годен"
|
||||
Command="{Binding MarkLinePassedCommand}" />
|
||||
<MenuItem Header="Забракован"
|
||||
Command="{Binding MarkLineRejectedCommand}" />
|
||||
<Separator/>
|
||||
<MenuItem Header="Отменить проверку"
|
||||
Command="{Binding ResetLineVerificationCommand}" />
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
<DataGrid.RowStyle>
|
||||
<Style TargetType="DataGridRow">
|
||||
<EventSetter Event="PreviewMouseRightButtonDown"
|
||||
Handler="DocumentLineRow_PreviewMouseRightButtonDown" />
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Зав. №"
|
||||
Width="120"
|
||||
|
||||
@@ -25,6 +25,16 @@ namespace XLAB
|
||||
}
|
||||
}
|
||||
|
||||
private void DocumentLineRow_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var row = sender as DataGridRow;
|
||||
if (row != null)
|
||||
{
|
||||
row.IsSelected = true;
|
||||
row.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
private async void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await _viewModel.InitializeAsync();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -14,32 +14,115 @@ namespace XLAB
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class PsvDocumentSummary
|
||||
public sealed class CustomerReference
|
||||
{
|
||||
public string DocumentNumber { get; set; }
|
||||
|
||||
public DateTime? AcceptedOn { get; set; }
|
||||
|
||||
public DateTime? IssuedOn { get; set; }
|
||||
|
||||
public string DepartmentName { get; set; }
|
||||
public int CustomerId { get; set; }
|
||||
|
||||
public string CustomerName { get; set; }
|
||||
|
||||
public int ItemCount { get; set; }
|
||||
public override string ToString()
|
||||
{
|
||||
return CustomerName ?? string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public int IssuedCount { get; set; }
|
||||
public sealed class PsvDocumentSummary : ObservableObject
|
||||
{
|
||||
private DateTime? _acceptedOn;
|
||||
private string _customerName;
|
||||
private int? _customerId;
|
||||
private string _departmentName;
|
||||
private string _documentKey;
|
||||
private string _documentNumber;
|
||||
private int _failedCount;
|
||||
private bool _isDraft;
|
||||
private int _issuedCount;
|
||||
private DateTime? _issuedOn;
|
||||
private int _itemCount;
|
||||
private int _passedCount;
|
||||
|
||||
public int PassedCount { get; set; }
|
||||
|
||||
public int FailedCount { get; set; }
|
||||
|
||||
public bool IsDraft { get; set; }
|
||||
public DateTime? AcceptedOn
|
||||
{
|
||||
get { return _acceptedOn; }
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _acceptedOn, value))
|
||||
{
|
||||
OnPropertyChanged("AcceptedMonthGroup");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string AcceptedMonthGroup
|
||||
{
|
||||
get { return AcceptedOn.HasValue ? AcceptedOn.Value.ToString("yyyy-MM") : "Без даты"; }
|
||||
}
|
||||
|
||||
public string CustomerName
|
||||
{
|
||||
get { return _customerName; }
|
||||
set { SetProperty(ref _customerName, value); }
|
||||
}
|
||||
|
||||
public int? CustomerId
|
||||
{
|
||||
get { return _customerId; }
|
||||
set { SetProperty(ref _customerId, value); }
|
||||
}
|
||||
|
||||
public string DepartmentName
|
||||
{
|
||||
get { return _departmentName; }
|
||||
set { SetProperty(ref _departmentName, value); }
|
||||
}
|
||||
|
||||
public string DocumentKey
|
||||
{
|
||||
get { return _documentKey; }
|
||||
set { SetProperty(ref _documentKey, value); }
|
||||
}
|
||||
|
||||
public string DocumentNumber
|
||||
{
|
||||
get { return _documentNumber; }
|
||||
set { SetProperty(ref _documentNumber, value); }
|
||||
}
|
||||
|
||||
public int FailedCount
|
||||
{
|
||||
get { return _failedCount; }
|
||||
set { SetProperty(ref _failedCount, value); }
|
||||
}
|
||||
|
||||
public bool IsDraft
|
||||
{
|
||||
get { return _isDraft; }
|
||||
set { SetProperty(ref _isDraft, value); }
|
||||
}
|
||||
|
||||
public int IssuedCount
|
||||
{
|
||||
get { return _issuedCount; }
|
||||
set { SetProperty(ref _issuedCount, value); }
|
||||
}
|
||||
|
||||
public DateTime? IssuedOn
|
||||
{
|
||||
get { return _issuedOn; }
|
||||
set { SetProperty(ref _issuedOn, value); }
|
||||
}
|
||||
|
||||
public int ItemCount
|
||||
{
|
||||
get { return _itemCount; }
|
||||
set { SetProperty(ref _itemCount, value); }
|
||||
}
|
||||
|
||||
public int PassedCount
|
||||
{
|
||||
get { return _passedCount; }
|
||||
set { SetProperty(ref _passedCount, value); }
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class PsvDocumentLine
|
||||
@@ -76,16 +159,36 @@ namespace XLAB
|
||||
|
||||
public bool? IsPassed { get; set; }
|
||||
|
||||
public DateTime? VerificationPerformedOn { get; set; }
|
||||
|
||||
public int? VerifierId { get; set; }
|
||||
|
||||
public string VerifierName { get; set; }
|
||||
|
||||
public string StickerNumber { get; set; }
|
||||
|
||||
public int? VerificationDocumentFormId { get; set; }
|
||||
|
||||
public int? VerificationDocumentLinkTypeId { get; set; }
|
||||
|
||||
public string VerificationDocumentNumber { get; set; }
|
||||
|
||||
public DateTime? VerificationDocumentDate { get; set; }
|
||||
|
||||
public string RejectionReason { get; set; }
|
||||
|
||||
public string Notes { get; set; }
|
||||
|
||||
public bool IsPendingInsert { get; set; }
|
||||
|
||||
public string DuplicateKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return BuildDuplicateKey(InstrumentType, RangeText, RegistryNumber, SerialNumber);
|
||||
}
|
||||
}
|
||||
|
||||
public string ResultText
|
||||
{
|
||||
get
|
||||
@@ -116,6 +219,20 @@ namespace XLAB
|
||||
return string.Format("{0} от {1:d}", VerificationDocumentNumber, VerificationDocumentDate.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public static string BuildDuplicateKey(string instrumentType, string rangeText, string registryNumber, string serialNumber)
|
||||
{
|
||||
return string.Join("|",
|
||||
NormalizeKeyPart(instrumentType),
|
||||
NormalizeKeyPart(rangeText),
|
||||
NormalizeKeyPart(registryNumber),
|
||||
NormalizeKeyPart(serialNumber));
|
||||
}
|
||||
|
||||
private static string NormalizeKeyPart(string value)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(value) ? string.Empty : value.Trim().ToUpperInvariant();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class PsvDocumentGroupSummary
|
||||
@@ -147,37 +264,69 @@ namespace XLAB
|
||||
{
|
||||
private bool _isSelected;
|
||||
|
||||
public string AccuracyText { get; set; }
|
||||
|
||||
public string CustomerName { get; set; }
|
||||
|
||||
public bool HasTemplate { get; set; }
|
||||
|
||||
public int InstrumentId { get; set; }
|
||||
|
||||
public string InstrumentName { get; set; }
|
||||
|
||||
public string InstrumentType { get; set; }
|
||||
|
||||
public string InventoryNumber { get; set; }
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return _isSelected; }
|
||||
set { SetProperty(ref _isSelected, value); }
|
||||
}
|
||||
|
||||
public int InstrumentId { get; set; }
|
||||
public DateTime? LastAcceptedOn { get; set; }
|
||||
|
||||
public int TypeSizeId { get; set; }
|
||||
|
||||
public string SerialNumber { get; set; }
|
||||
|
||||
public string InventoryNumber { get; set; }
|
||||
|
||||
public string CustomerName { get; set; }
|
||||
|
||||
public string InstrumentType { get; set; }
|
||||
|
||||
public string InstrumentName { get; set; }
|
||||
public string LastDocumentNumber { get; set; }
|
||||
|
||||
public string MeasurementArea { get; set; }
|
||||
|
||||
public string RangeText { get; set; }
|
||||
|
||||
public string AccuracyText { get; set; }
|
||||
public string RegistryNumber { get; set; }
|
||||
|
||||
public string LastDocumentNumber { get; set; }
|
||||
|
||||
public DateTime? LastAcceptedOn { get; set; }
|
||||
public string SerialNumber { get; set; }
|
||||
|
||||
public string TemplateSource { get; set; }
|
||||
|
||||
public int TypeSizeId { get; set; }
|
||||
}
|
||||
|
||||
public sealed class PersonReference
|
||||
{
|
||||
public int PersonId { get; set; }
|
||||
|
||||
public string FullName { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return FullName ?? string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class DocumentFormReference
|
||||
{
|
||||
public int DocumentFormId { get; set; }
|
||||
|
||||
public int LinkTypeId { get; set; }
|
||||
|
||||
public string DocumentKindName { get; set; }
|
||||
|
||||
public string DocumentFormName { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return DocumentFormName ?? string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class DocumentEditorResult
|
||||
@@ -189,6 +338,44 @@ namespace XLAB
|
||||
public DateTime? IssuedOn { get; set; }
|
||||
}
|
||||
|
||||
public sealed class VerificationEditSeed
|
||||
{
|
||||
public DocumentFormReference DocumentForm { get; set; }
|
||||
|
||||
public bool IsPassed { get; set; }
|
||||
|
||||
public string RejectionReason { get; set; }
|
||||
|
||||
public string StickerNumber { get; set; }
|
||||
|
||||
public DateTime? VerificationDate { get; set; }
|
||||
|
||||
public string VerificationDocumentNumber { get; set; }
|
||||
|
||||
public int? VerifierId { get; set; }
|
||||
}
|
||||
|
||||
public sealed class VerificationEditResult
|
||||
{
|
||||
public int DocumentFormId { get; set; }
|
||||
|
||||
public int DocumentLinkTypeId { get; set; }
|
||||
|
||||
public bool IsPassed { get; set; }
|
||||
|
||||
public string RejectionReason { get; set; }
|
||||
|
||||
public string StickerNumber { get; set; }
|
||||
|
||||
public DateTime VerificationDate { get; set; }
|
||||
|
||||
public string VerificationDocumentNumber { get; set; }
|
||||
|
||||
public int VerifierId { get; set; }
|
||||
|
||||
public string VerifierName { get; set; }
|
||||
}
|
||||
|
||||
internal sealed class DocumentDeleteResult
|
||||
{
|
||||
public int DeletedEkzMkFctvlCount { get; set; }
|
||||
@@ -198,62 +385,75 @@ namespace XLAB
|
||||
public int DeletedDmsCount { get; set; }
|
||||
}
|
||||
|
||||
internal sealed class DocumentSaveResult
|
||||
{
|
||||
public string DocumentNumber { get; set; }
|
||||
|
||||
public int InsertedEkzMkCount { get; set; }
|
||||
|
||||
public int SkippedDuplicateCount { get; set; }
|
||||
|
||||
public int SkippedWithoutTemplateCount { get; set; }
|
||||
|
||||
public int UpdatedEkzMkCount { get; set; }
|
||||
}
|
||||
|
||||
internal sealed class EkzMkTemplate
|
||||
{
|
||||
public int? IdSpmu { get; set; }
|
||||
public string Dpznmp { get; set; }
|
||||
|
||||
public int? IdGrsi { get; set; }
|
||||
public string Hrtcmp { get; set; }
|
||||
|
||||
public int? IdKsprl { get; set; }
|
||||
|
||||
public int? IdSpvdmc { get; set; }
|
||||
public int? IdEkzetl { get; set; }
|
||||
|
||||
public int IdFrpd { get; set; }
|
||||
|
||||
public int? IdSpmpob { get; set; }
|
||||
public int? IdGrsi { get; set; }
|
||||
|
||||
public int? IdKsp { get; set; }
|
||||
|
||||
public int? IdKsprl { get; set; }
|
||||
|
||||
public int? IdPrsn { get; set; }
|
||||
|
||||
public int? IdSpkmmk { get; set; }
|
||||
public int? IdPrsnpr { get; set; }
|
||||
|
||||
public int? IdSpvdkl { get; set; }
|
||||
public int? IdPrsnsd { get; set; }
|
||||
|
||||
public int? IdPrsnvd { get; set; }
|
||||
|
||||
public int? IdPrsnvy { get; set; }
|
||||
|
||||
public int? IdSpkmmk { get; set; }
|
||||
|
||||
public int? IdSpmpob { get; set; }
|
||||
|
||||
public int? IdSpmu { get; set; }
|
||||
|
||||
public int? IdSpssmp { get; set; }
|
||||
|
||||
public int? IdSptsmp { get; set; }
|
||||
|
||||
public int? IdSpvdkl { get; set; }
|
||||
|
||||
public int? IdSpvdsbmk { get; set; }
|
||||
|
||||
public int? IdSpvdmc { get; set; }
|
||||
|
||||
public decimal? NcSrmk { get; set; }
|
||||
|
||||
public decimal? Nrvrmmp { get; set; }
|
||||
|
||||
public decimal? Nrvrmndmp { get; set; }
|
||||
|
||||
public int Prmk { get; set; }
|
||||
|
||||
public string SourceDescription { get; set; }
|
||||
|
||||
public decimal? Stmk { get; set; }
|
||||
|
||||
public decimal? Stmkdp { get; set; }
|
||||
|
||||
public decimal? NcSrmk { get; set; }
|
||||
|
||||
public int? IdPrsnsd { get; set; }
|
||||
|
||||
public int? IdPrsnpr { get; set; }
|
||||
|
||||
public int? IdPrsnvy { get; set; }
|
||||
|
||||
public int? IdSptsmp { get; set; }
|
||||
|
||||
public int? IdSpssmp { get; set; }
|
||||
|
||||
public decimal? Nrvrmndmp { get; set; }
|
||||
|
||||
public decimal? Nrvrmmp { get; set; }
|
||||
|
||||
public decimal? Vrmkfk { get; set; }
|
||||
|
||||
public int? IdKsp { get; set; }
|
||||
|
||||
public string Dpznmp { get; set; }
|
||||
|
||||
public string Hrtcmp { get; set; }
|
||||
|
||||
public int? IdSpvdsbmk { get; set; }
|
||||
|
||||
public int? IdEkzetl { get; set; }
|
||||
|
||||
public string SourceDescription { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
82
XLAB/SelectInstrumentsWindow.xaml
Normal file
82
XLAB/SelectInstrumentsWindow.xaml
Normal file
@@ -0,0 +1,82 @@
|
||||
<Window x:Class="XLAB.SelectInstrumentsWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="Выбор приборов"
|
||||
Height="720"
|
||||
Width="1120"
|
||||
MinHeight="520"
|
||||
MinWidth="900"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<Grid Margin="12">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock FontWeight="SemiBold"
|
||||
Text="{Binding CustomerName, StringFormat=Заказчик: {0}}" />
|
||||
|
||||
<StackPanel Grid.Row="1"
|
||||
Margin="0,8,0,8"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock Width="150"
|
||||
Margin="0,0,8,0"
|
||||
VerticalAlignment="Center"
|
||||
Text="Поиск по таблице" />
|
||||
<TextBox Width="320"
|
||||
Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</StackPanel>
|
||||
|
||||
<DataGrid Grid.Row="2"
|
||||
ItemsSource="{Binding InstrumentsView}"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
HeadersVisibility="Column">
|
||||
<DataGrid.Columns>
|
||||
<DataGridCheckBoxColumn Header=""
|
||||
Width="42"
|
||||
Binding="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<DataGridTextColumn Header="Номер госреестра"
|
||||
Width="120"
|
||||
Binding="{Binding RegistryNumber}" />
|
||||
<DataGridTextColumn Header="Наименование"
|
||||
Width="240"
|
||||
Binding="{Binding InstrumentName}" />
|
||||
<DataGridTextColumn Header="Тип"
|
||||
Width="150"
|
||||
Binding="{Binding InstrumentType}" />
|
||||
<DataGridTextColumn Header="Диапазон"
|
||||
Width="180"
|
||||
Binding="{Binding RangeText}" />
|
||||
<DataGridTextColumn Header="Характеристики"
|
||||
Width="160"
|
||||
Binding="{Binding AccuracyText}" />
|
||||
<DataGridTextColumn Header="Заводской номер"
|
||||
Width="130"
|
||||
Binding="{Binding SerialNumber}" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<TextBlock Grid.Row="3"
|
||||
Margin="0,8,0,0"
|
||||
Foreground="DimGray"
|
||||
Text="{Binding StatusText}" />
|
||||
|
||||
<StackPanel Grid.Row="4"
|
||||
Margin="0,12,0,0"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right">
|
||||
<Button Width="90"
|
||||
Margin="0,0,8,0"
|
||||
IsDefault="True"
|
||||
Command="{Binding ConfirmCommand}"
|
||||
Content="Добавить" />
|
||||
<Button Width="90"
|
||||
Command="{Binding CancelCommand}"
|
||||
Content="Отмена" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
20
XLAB/SelectInstrumentsWindow.xaml.cs
Normal file
20
XLAB/SelectInstrumentsWindow.xaml.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace XLAB
|
||||
{
|
||||
public partial class SelectInstrumentsWindow : Window
|
||||
{
|
||||
internal SelectInstrumentsWindow(SelectInstrumentsWindowViewModel viewModel)
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = viewModel;
|
||||
viewModel.CloseRequested += ViewModelOnCloseRequested;
|
||||
}
|
||||
|
||||
private void ViewModelOnCloseRequested(object sender, bool? dialogResult)
|
||||
{
|
||||
DialogResult = dialogResult;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
129
XLAB/SelectInstrumentsWindowViewModel.cs
Normal file
129
XLAB/SelectInstrumentsWindowViewModel.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace XLAB
|
||||
{
|
||||
internal sealed class SelectInstrumentsWindowViewModel : ObservableObject
|
||||
{
|
||||
private string _searchText;
|
||||
private string _statusText;
|
||||
|
||||
public SelectInstrumentsWindowViewModel(string customerName, IReadOnlyList<AvailableInstrumentItem> instruments)
|
||||
{
|
||||
CustomerName = customerName ?? string.Empty;
|
||||
Instruments = new ObservableCollection<AvailableInstrumentItem>(instruments ?? new List<AvailableInstrumentItem>());
|
||||
InstrumentsView = System.Windows.Data.CollectionViewSource.GetDefaultView(Instruments);
|
||||
InstrumentsView.Filter = FilterInstruments;
|
||||
|
||||
foreach (var instrument in Instruments)
|
||||
{
|
||||
instrument.PropertyChanged += InstrumentOnPropertyChanged;
|
||||
}
|
||||
|
||||
ConfirmCommand = new RelayCommand(Confirm);
|
||||
CancelCommand = new RelayCommand(Cancel);
|
||||
UpdateStatus();
|
||||
}
|
||||
|
||||
public event EventHandler<bool?> CloseRequested;
|
||||
|
||||
public ICommand CancelCommand { get; private set; }
|
||||
|
||||
public ICommand ConfirmCommand { get; private set; }
|
||||
|
||||
public string CustomerName { get; private set; }
|
||||
|
||||
public ObservableCollection<AvailableInstrumentItem> Instruments { get; private set; }
|
||||
|
||||
public ICollectionView InstrumentsView { get; private set; }
|
||||
|
||||
public string SearchText
|
||||
{
|
||||
get { return _searchText; }
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _searchText, value))
|
||||
{
|
||||
InstrumentsView.Refresh();
|
||||
UpdateStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string StatusText
|
||||
{
|
||||
get { return _statusText; }
|
||||
private set { SetProperty(ref _statusText, value); }
|
||||
}
|
||||
|
||||
public IReadOnlyList<AvailableInstrumentItem> GetSelectedItems()
|
||||
{
|
||||
return Instruments.Where(delegate(AvailableInstrumentItem item) { return item.IsSelected; }).ToList();
|
||||
}
|
||||
|
||||
private void Cancel(object parameter)
|
||||
{
|
||||
RaiseCloseRequested(false);
|
||||
}
|
||||
|
||||
private void Confirm(object parameter)
|
||||
{
|
||||
RaiseCloseRequested(true);
|
||||
}
|
||||
|
||||
private bool FilterInstruments(object item)
|
||||
{
|
||||
var instrument = item as AvailableInstrumentItem;
|
||||
if (instrument == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(SearchText))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return Contains(instrument.RegistryNumber, SearchText)
|
||||
|| Contains(instrument.InstrumentName, SearchText)
|
||||
|| Contains(instrument.InstrumentType, SearchText)
|
||||
|| Contains(instrument.RangeText, SearchText)
|
||||
|| Contains(instrument.AccuracyText, SearchText)
|
||||
|| Contains(instrument.SerialNumber, SearchText);
|
||||
}
|
||||
|
||||
private void InstrumentOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "IsSelected")
|
||||
{
|
||||
UpdateStatus();
|
||||
}
|
||||
}
|
||||
|
||||
private static bool Contains(string source, string searchText)
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(source)
|
||||
&& source.IndexOf(searchText, StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
}
|
||||
|
||||
private void RaiseCloseRequested(bool? dialogResult)
|
||||
{
|
||||
var handler = CloseRequested;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, dialogResult);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateStatus()
|
||||
{
|
||||
var visibleCount = InstrumentsView.Cast<object>().Count();
|
||||
var selectedCount = Instruments.Count(delegate(AvailableInstrumentItem item) { return item.IsSelected; });
|
||||
StatusText = string.Format("Всего: {0}. По фильтру: {1}. Выбрано: {2}.", Instruments.Count, visibleCount, selectedCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
122
XLAB/VerificationEditWindow.xaml
Normal file
122
XLAB/VerificationEditWindow.xaml
Normal file
@@ -0,0 +1,122 @@
|
||||
<Window x:Class="XLAB.VerificationEditWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="{Binding Title}"
|
||||
Height="360"
|
||||
Width="520"
|
||||
MinHeight="320"
|
||||
MinWidth="480"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="NoResize">
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="170" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Margin="0,0,12,8"
|
||||
VerticalAlignment="Center"
|
||||
Text="Дата поверки" />
|
||||
<DatePicker Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,0,8"
|
||||
SelectedDate="{Binding VerificationDate, Mode=TwoWay}"
|
||||
SelectedDateFormat="Short" />
|
||||
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Margin="0,0,12,8"
|
||||
VerticalAlignment="Center"
|
||||
Text="Поверитель" />
|
||||
<ComboBox Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,0,8"
|
||||
ItemsSource="{Binding Verifiers}"
|
||||
DisplayMemberPath="FullName"
|
||||
SelectedValuePath="PersonId"
|
||||
SelectedValue="{Binding SelectedVerifierId, Mode=TwoWay}" />
|
||||
|
||||
<TextBlock Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Margin="0,0,12,8"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding DocumentFormCaption}" />
|
||||
<ComboBox Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,0,8"
|
||||
ItemsSource="{Binding DocumentForms}"
|
||||
DisplayMemberPath="DocumentFormName"
|
||||
SelectedItem="{Binding SelectedDocumentForm, Mode=TwoWay}" />
|
||||
|
||||
<TextBlock Grid.Row="3"
|
||||
Grid.Column="0"
|
||||
Margin="0,0,12,8"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding DocumentNumberCaption}" />
|
||||
<TextBox Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,0,8"
|
||||
Text="{Binding VerificationDocumentNumber, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBlock Grid.Row="4"
|
||||
Grid.Column="0"
|
||||
Margin="0,0,12,8"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="{Binding StickerVisibility}"
|
||||
Text="Номер наклейки" />
|
||||
<TextBox Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,0,8"
|
||||
Visibility="{Binding StickerVisibility}"
|
||||
Text="{Binding StickerNumber, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBlock Grid.Row="5"
|
||||
Grid.Column="0"
|
||||
Margin="0,0,12,8"
|
||||
VerticalAlignment="Top"
|
||||
Visibility="{Binding RejectionReasonVisibility}"
|
||||
Text="Причина непригодности" />
|
||||
<TextBox Grid.Row="5"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,0,8"
|
||||
MinHeight="72"
|
||||
AcceptsReturn="True"
|
||||
TextWrapping="Wrap"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
Visibility="{Binding RejectionReasonVisibility}"
|
||||
Text="{Binding RejectionReason, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<TextBlock Grid.Row="6"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="0,8,0,0"
|
||||
Foreground="Firebrick"
|
||||
Text="{Binding ValidationMessage}" />
|
||||
|
||||
<StackPanel Grid.Row="7"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="0,12,0,0"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right">
|
||||
<Button Width="100"
|
||||
Margin="0,0,8,0"
|
||||
IsDefault="True"
|
||||
Command="{Binding ConfirmCommand}"
|
||||
Content="Сохранить" />
|
||||
<Button Width="90"
|
||||
Command="{Binding CancelCommand}"
|
||||
Content="Отмена" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
20
XLAB/VerificationEditWindow.xaml.cs
Normal file
20
XLAB/VerificationEditWindow.xaml.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace XLAB
|
||||
{
|
||||
public partial class VerificationEditWindow : Window
|
||||
{
|
||||
internal VerificationEditWindow(VerificationEditWindowViewModel viewModel)
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = viewModel;
|
||||
viewModel.CloseRequested += ViewModelOnCloseRequested;
|
||||
}
|
||||
|
||||
private void ViewModelOnCloseRequested(object sender, bool? dialogResult)
|
||||
{
|
||||
DialogResult = dialogResult;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
210
XLAB/VerificationEditWindowViewModel.cs
Normal file
210
XLAB/VerificationEditWindowViewModel.cs
Normal file
@@ -0,0 +1,210 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace XLAB
|
||||
{
|
||||
internal sealed class VerificationEditWindowViewModel : ObservableObject
|
||||
{
|
||||
private string _rejectionReason;
|
||||
private DocumentFormReference _selectedDocumentForm;
|
||||
private int? _selectedVerifierId;
|
||||
private string _stickerNumber;
|
||||
private string _validationMessage;
|
||||
private DateTime? _verificationDate;
|
||||
private string _verificationDocumentNumber;
|
||||
|
||||
public VerificationEditWindowViewModel(
|
||||
VerificationEditSeed seed,
|
||||
IReadOnlyList<PersonReference> verifiers,
|
||||
IReadOnlyList<DocumentFormReference> documentForms)
|
||||
{
|
||||
if (seed == null)
|
||||
{
|
||||
throw new ArgumentNullException("seed");
|
||||
}
|
||||
|
||||
IsPassed = seed.IsPassed;
|
||||
Verifiers = new ObservableCollection<PersonReference>(verifiers ?? new List<PersonReference>());
|
||||
DocumentForms = new ObservableCollection<DocumentFormReference>(documentForms ?? new List<DocumentFormReference>());
|
||||
|
||||
VerificationDate = seed.VerificationDate ?? DateTime.Today;
|
||||
SelectedVerifierId = seed.VerifierId;
|
||||
StickerNumber = seed.StickerNumber ?? string.Empty;
|
||||
VerificationDocumentNumber = seed.VerificationDocumentNumber ?? string.Empty;
|
||||
RejectionReason = seed.RejectionReason ?? string.Empty;
|
||||
|
||||
if (seed.DocumentForm != null)
|
||||
{
|
||||
SelectedDocumentForm = DocumentForms.FirstOrDefault(delegate(DocumentFormReference item)
|
||||
{
|
||||
return item.DocumentFormId == seed.DocumentForm.DocumentFormId;
|
||||
});
|
||||
}
|
||||
|
||||
if (SelectedDocumentForm == null && DocumentForms.Count > 0)
|
||||
{
|
||||
SelectedDocumentForm = DocumentForms[0];
|
||||
}
|
||||
|
||||
ConfirmCommand = new RelayCommand(Confirm);
|
||||
CancelCommand = new RelayCommand(Cancel);
|
||||
}
|
||||
|
||||
public event EventHandler<bool?> CloseRequested;
|
||||
|
||||
public ICommand CancelCommand { get; private set; }
|
||||
|
||||
public ICommand ConfirmCommand { get; private set; }
|
||||
|
||||
public ObservableCollection<DocumentFormReference> DocumentForms { get; private set; }
|
||||
|
||||
public string DocumentNumberCaption
|
||||
{
|
||||
get { return IsPassed ? "Номер свидетельства" : "Номер извещения"; }
|
||||
}
|
||||
|
||||
public string DocumentFormCaption
|
||||
{
|
||||
get { return IsPassed ? "Форма свидетельства" : "Форма извещения"; }
|
||||
}
|
||||
|
||||
public bool IsPassed { get; private set; }
|
||||
|
||||
public Visibility RejectionReasonVisibility
|
||||
{
|
||||
get { return IsPassed ? Visibility.Collapsed : Visibility.Visible; }
|
||||
}
|
||||
|
||||
public string RejectionReason
|
||||
{
|
||||
get { return _rejectionReason; }
|
||||
set { SetProperty(ref _rejectionReason, value); }
|
||||
}
|
||||
|
||||
public DocumentFormReference SelectedDocumentForm
|
||||
{
|
||||
get { return _selectedDocumentForm; }
|
||||
set { SetProperty(ref _selectedDocumentForm, value); }
|
||||
}
|
||||
|
||||
public int? SelectedVerifierId
|
||||
{
|
||||
get { return _selectedVerifierId; }
|
||||
set { SetProperty(ref _selectedVerifierId, value); }
|
||||
}
|
||||
|
||||
public Visibility StickerVisibility
|
||||
{
|
||||
get { return IsPassed ? Visibility.Visible : Visibility.Collapsed; }
|
||||
}
|
||||
|
||||
public string StickerNumber
|
||||
{
|
||||
get { return _stickerNumber; }
|
||||
set { SetProperty(ref _stickerNumber, value); }
|
||||
}
|
||||
|
||||
public string Title
|
||||
{
|
||||
get { return IsPassed ? "Результат поверки: годен" : "Результат поверки: забракован"; }
|
||||
}
|
||||
|
||||
public string ValidationMessage
|
||||
{
|
||||
get { return _validationMessage; }
|
||||
private set { SetProperty(ref _validationMessage, value); }
|
||||
}
|
||||
|
||||
public DateTime? VerificationDate
|
||||
{
|
||||
get { return _verificationDate; }
|
||||
set { SetProperty(ref _verificationDate, value); }
|
||||
}
|
||||
|
||||
public string VerificationDocumentNumber
|
||||
{
|
||||
get { return _verificationDocumentNumber; }
|
||||
set { SetProperty(ref _verificationDocumentNumber, value); }
|
||||
}
|
||||
|
||||
public ObservableCollection<PersonReference> Verifiers { get; private set; }
|
||||
|
||||
public VerificationEditResult ToResult()
|
||||
{
|
||||
var verifier = Verifiers.FirstOrDefault(delegate(PersonReference item)
|
||||
{
|
||||
return item.PersonId == SelectedVerifierId;
|
||||
});
|
||||
|
||||
return new VerificationEditResult
|
||||
{
|
||||
DocumentFormId = SelectedDocumentForm == null ? 0 : SelectedDocumentForm.DocumentFormId,
|
||||
DocumentLinkTypeId = SelectedDocumentForm == null ? 0 : SelectedDocumentForm.LinkTypeId,
|
||||
IsPassed = IsPassed,
|
||||
RejectionReason = string.IsNullOrWhiteSpace(RejectionReason) ? string.Empty : RejectionReason.Trim(),
|
||||
StickerNumber = string.IsNullOrWhiteSpace(StickerNumber) ? string.Empty : StickerNumber.Trim(),
|
||||
VerificationDate = VerificationDate.HasValue ? VerificationDate.Value : DateTime.Today,
|
||||
VerificationDocumentNumber = string.IsNullOrWhiteSpace(VerificationDocumentNumber) ? string.Empty : VerificationDocumentNumber.Trim(),
|
||||
VerifierId = SelectedVerifierId.GetValueOrDefault(),
|
||||
VerifierName = verifier == null ? string.Empty : verifier.FullName
|
||||
};
|
||||
}
|
||||
|
||||
private void Cancel(object parameter)
|
||||
{
|
||||
RaiseCloseRequested(false);
|
||||
}
|
||||
|
||||
private void Confirm(object parameter)
|
||||
{
|
||||
if (!VerificationDate.HasValue)
|
||||
{
|
||||
ValidationMessage = "Укажите дату поверки.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SelectedVerifierId.HasValue)
|
||||
{
|
||||
ValidationMessage = "Выберите поверителя.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(VerificationDocumentNumber) && SelectedDocumentForm == null)
|
||||
{
|
||||
ValidationMessage = "Выберите форму документа.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsPassed)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(RejectionReason))
|
||||
{
|
||||
ValidationMessage = "Укажите причину непригодности.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(VerificationDocumentNumber))
|
||||
{
|
||||
ValidationMessage = "Укажите номер извещения о непригодности.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ValidationMessage = string.Empty;
|
||||
RaiseCloseRequested(true);
|
||||
}
|
||||
|
||||
private void RaiseCloseRequested(bool? dialogResult)
|
||||
{
|
||||
var handler = CloseRequested;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, dialogResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,6 +81,24 @@
|
||||
<Compile Include="MvvmInfrastructure.cs" />
|
||||
<Compile Include="PsvDataService.cs" />
|
||||
<Compile Include="PsvModels.cs" />
|
||||
<Page Include="SelectInstrumentsWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="SelectInstrumentsWindow.xaml.cs">
|
||||
<DependentUpon>SelectInstrumentsWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SelectInstrumentsWindowViewModel.cs" />
|
||||
<Page Include="VerificationEditWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="VerificationEditWindow.xaml.cs">
|
||||
<DependentUpon>VerificationEditWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="VerificationEditWindowViewModel.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
|
||||
Reference in New Issue
Block a user