diff --git a/ClosePsv.docx b/ClosePsv.docx
new file mode 100644
index 0000000..eab67f3
Binary files /dev/null and b/ClosePsv.docx differ
diff --git a/Izv.docx b/Izv.docx
new file mode 100644
index 0000000..0d16b6f
Binary files /dev/null and b/Izv.docx differ
diff --git a/OpenPsv.docx b/OpenPsv.docx
new file mode 100644
index 0000000..3cfd7b9
Binary files /dev/null and b/OpenPsv.docx differ
diff --git a/Svid.docx b/Svid.docx
new file mode 100644
index 0000000..22746b9
Binary files /dev/null and b/Svid.docx differ
diff --git a/XLAB/MainWindow.xaml b/XLAB/MainWindow.xaml
index 7d477f8..1b87b4a 100644
--- a/XLAB/MainWindow.xaml
+++ b/XLAB/MainWindow.xaml
@@ -65,6 +65,8 @@
+
@@ -296,6 +298,8 @@
+
diff --git a/XLAB/MainWindowViewModel.cs b/XLAB/MainWindowViewModel.cs
index 7467beb..17029aa 100644
--- a/XLAB/MainWindowViewModel.cs
+++ b/XLAB/MainWindowViewModel.cs
@@ -14,6 +14,7 @@ namespace XLAB
private readonly List _draftDocuments;
private readonly IDialogService _dialogService;
private readonly Dictionary> _pendingLinesByDocumentKey;
+ private readonly PsvPrintService _printService;
private readonly PsvDataService _service;
private string _documentFilterText;
private string _documentNumberEditor;
@@ -33,6 +34,7 @@ namespace XLAB
{
_service = service;
_dialogService = dialogService;
+ _printService = new PsvPrintService();
_draftDocuments = new List();
_pendingLinesByDocumentKey = new Dictionary>(StringComparer.OrdinalIgnoreCase);
@@ -55,6 +57,8 @@ namespace XLAB
MarkLineRejectedCommand = new RelayCommand(delegate { EditLineVerificationAsync(false); }, delegate { return CanEditSelectedLineVerification(); });
OpenInstrumentPickerCommand = new RelayCommand(delegate { OpenInstrumentPickerAsync(); }, delegate { return !IsBusy && SelectedDocument != null && SelectedDocument.CustomerId.HasValue; });
OpenInstrumentTypePickerCommand = new RelayCommand(delegate { OpenInstrumentTypePickerAsync(); }, delegate { return !IsBusy && SelectedDocument != null && SelectedDocument.CustomerId.HasValue; });
+ PrintDocumentCommand = new RelayCommand(delegate { PrintSelectedDocumentAsync(); }, delegate { return CanPrintSelectedDocument(); });
+ PrintVerificationDocumentCommand = new RelayCommand(delegate { PrintSelectedVerificationDocumentAsync(); }, delegate { return CanPrintSelectedVerificationDocument(); });
RefreshDocumentsCommand = new RelayCommand(delegate { RefreshDocumentsAsync(null, null); }, delegate { return !IsBusy; });
ResetLineVerificationCommand = new RelayCommand(delegate { ResetSelectedLineVerificationAsync(); }, delegate { return CanResetSelectedLineVerification(); });
SaveDocumentHeaderCommand = new RelayCommand(delegate { SaveDocumentAsync(); }, delegate { return CanSaveDocument(); });
@@ -175,6 +179,10 @@ namespace XLAB
public ICommand OpenInstrumentTypePickerCommand { get; private set; }
+ public ICommand PrintDocumentCommand { get; private set; }
+
+ public ICommand PrintVerificationDocumentCommand { get; private set; }
+
public ICommand RefreshDocumentsCommand { get; private set; }
public ICommand ResetLineVerificationCommand { get; private set; }
@@ -328,6 +336,13 @@ namespace XLAB
&& GetDeleteTargetGroups().Count > 0;
}
+ private bool CanPrintSelectedDocument()
+ {
+ return !IsBusy
+ && SelectedDocument != null
+ && !SelectedDocument.IsDraft;
+ }
+
private bool CanEditSelectedLineVerification()
{
var targetLines = GetVerificationTargetLines();
@@ -341,6 +356,11 @@ namespace XLAB
return !IsBusy && CanUseLineAsCloneSource(SelectedDocumentLine);
}
+ private bool CanPrintSelectedVerificationDocument()
+ {
+ return !IsBusy && HasPrintableVerificationDocument(SelectedDocumentLine);
+ }
+
private bool CanResetSelectedLineVerification()
{
var targetLines = GetVerificationTargetLines();
@@ -391,6 +411,31 @@ namespace XLAB
return true;
}
+ private static bool HasPrintableVerificationDocument(PsvDocumentLine line)
+ {
+ if (line == null || !line.IsPassed.HasValue)
+ {
+ return false;
+ }
+
+ if (string.IsNullOrWhiteSpace(line.VerificationDocumentNumber))
+ {
+ return false;
+ }
+
+ if (!line.VerificationPerformedOn.HasValue && !line.VerificationDocumentDate.HasValue)
+ {
+ return false;
+ }
+
+ if (!line.IsPassed.Value && string.IsNullOrWhiteSpace(line.RejectionReason))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
private List GetCheckedDocumentLines()
{
return DocumentLinesView.Cast