edit
This commit is contained in:
@@ -356,10 +356,14 @@
|
||||
<Separator/>
|
||||
<MenuItem Header="Отменить проверку"
|
||||
Command="{Binding ResetLineVerificationCommand}" />
|
||||
<MenuItem Header="Удалить"
|
||||
Command="{Binding DeleteSelectedLinesCommand}" />
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
<DataGrid.RowStyle>
|
||||
<Style TargetType="DataGridRow">
|
||||
<EventSetter Event="MouseDoubleClick"
|
||||
Handler="DocumentLineRow_MouseDoubleClick" />
|
||||
<EventSetter Event="PreviewMouseRightButtonDown"
|
||||
Handler="DocumentLineRow_PreviewMouseRightButtonDown" />
|
||||
</Style>
|
||||
|
||||
@@ -35,6 +35,19 @@ namespace XLAB
|
||||
}
|
||||
}
|
||||
|
||||
private void DocumentLineRow_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var row = sender as DataGridRow;
|
||||
if (row == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
row.IsSelected = true;
|
||||
row.Focus();
|
||||
_viewModel.TryEditVerificationFromDoubleClick(row.Item as PsvDocumentLine);
|
||||
}
|
||||
|
||||
private void DocumentGroupRow_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var row = sender as DataGridRow;
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace XLAB
|
||||
AddDocumentCommand = new RelayCommand(delegate { AddDocument(); }, delegate { return !IsBusy && !ShowClosedDocuments; });
|
||||
CloneLineVerificationCommand = new RelayCommand(delegate { CloneSelectedLineVerificationAsync(); }, delegate { return CanCloneSelectedLineVerification(); });
|
||||
DeleteDocumentCommand = new RelayCommand(delegate { DeleteDocumentAsync(); }, delegate { return !IsBusy && SelectedDocument != null; });
|
||||
DeleteSelectedLinesCommand = new RelayCommand(delegate { DeleteSelectedLinesAsync(); }, delegate { return CanDeleteSelectedLines(); });
|
||||
DeleteSelectedGroupsCommand = new RelayCommand(delegate { DeleteSelectedGroupsAsync(); }, delegate { return CanDeleteSelectedGroups(); });
|
||||
MarkLinePassedCommand = new RelayCommand(delegate { EditLineVerificationAsync(true); }, delegate { return CanEditSelectedLineVerification(); });
|
||||
MarkLineRejectedCommand = new RelayCommand(delegate { EditLineVerificationAsync(false); }, delegate { return CanEditSelectedLineVerification(); });
|
||||
@@ -140,6 +141,8 @@ namespace XLAB
|
||||
|
||||
public ICommand DeleteDocumentCommand { get; private set; }
|
||||
|
||||
public ICommand DeleteSelectedLinesCommand { get; private set; }
|
||||
|
||||
public ICommand DeleteSelectedGroupsCommand { get; private set; }
|
||||
|
||||
public string GroupDetailFilterText
|
||||
@@ -389,6 +392,12 @@ namespace XLAB
|
||||
&& GetDeleteTargetGroups().Count > 0;
|
||||
}
|
||||
|
||||
private bool CanDeleteSelectedLines()
|
||||
{
|
||||
return CanModifySelectedDocument()
|
||||
&& GetDeleteTargetLines().Count > 0;
|
||||
}
|
||||
|
||||
private bool CanPrintSelectedDocument()
|
||||
{
|
||||
return !IsBusy
|
||||
@@ -509,6 +518,14 @@ namespace XLAB
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool CanEditVerificationFromDoubleClick(PsvDocumentLine line)
|
||||
{
|
||||
return CanModifySelectedDocument()
|
||||
&& line != null
|
||||
&& line.IsPassed.HasValue
|
||||
&& HasVerificationData(line);
|
||||
}
|
||||
|
||||
private List<PsvDocumentLine> GetCheckedDocumentLines()
|
||||
{
|
||||
return DocumentLinesView.Cast<object>()
|
||||
@@ -550,6 +567,19 @@ namespace XLAB
|
||||
: new List<PsvDocumentLine> { SelectedDocumentLine };
|
||||
}
|
||||
|
||||
private List<PsvDocumentLine> GetDeleteTargetLines()
|
||||
{
|
||||
var checkedLines = GetCheckedDocumentLines();
|
||||
if (checkedLines.Count > 0)
|
||||
{
|
||||
return checkedLines;
|
||||
}
|
||||
|
||||
return SelectedDocumentLine == null
|
||||
? new List<PsvDocumentLine>()
|
||||
: new List<PsvDocumentLine> { SelectedDocumentLine };
|
||||
}
|
||||
|
||||
private List<PsvDocumentLine> GetCheckedCloneTargetLines(PsvDocumentLine sourceLine)
|
||||
{
|
||||
if (sourceLine == null)
|
||||
@@ -1142,6 +1172,22 @@ namespace XLAB
|
||||
EditLineVerificationCoreAsync(targetLines, isPassed);
|
||||
}
|
||||
|
||||
public void TryEditVerificationFromDoubleClick(PsvDocumentLine line)
|
||||
{
|
||||
if (line == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SelectedDocumentLine = line;
|
||||
if (!CanEditVerificationFromDoubleClick(line))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EditLineVerificationCoreAsync(new[] { line }, line.IsPassed.Value);
|
||||
}
|
||||
|
||||
private async void EditLineVerificationCoreAsync(IReadOnlyList<PsvDocumentLine> targetLines, bool isPassed)
|
||||
{
|
||||
IReadOnlyList<DocumentFormReference> documentForms;
|
||||
@@ -1455,6 +1501,114 @@ namespace XLAB
|
||||
});
|
||||
}
|
||||
|
||||
private void DeleteSelectedLinesAsync()
|
||||
{
|
||||
if (SelectedDocument == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var targetLines = GetDeleteTargetLines();
|
||||
if (targetLines.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_dialogService.Confirm(string.Format(
|
||||
"Удалить из ПСВ \"{0}\" строк приборов: {1}?",
|
||||
SelectedDocument.DocumentNumber,
|
||||
targetLines.Count)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedDocument = SelectedDocument;
|
||||
var selectedDocumentKey = selectedDocument.DocumentKey;
|
||||
var selectedDocumentNumber = selectedDocument.DocumentNumber;
|
||||
|
||||
RunBusyOperation(async delegate
|
||||
{
|
||||
var pendingLines = GetPendingLines(selectedDocument);
|
||||
var pendingLinesToRemove = pendingLines
|
||||
.Where(delegate(PsvDocumentLine line) { return targetLines.Any(delegate(PsvDocumentLine targetLine) { return ReferenceEquals(line, targetLine); }); })
|
||||
.ToList();
|
||||
|
||||
var persistedCardIds = targetLines
|
||||
.Where(delegate(PsvDocumentLine line) { return !line.IsPendingInsert; })
|
||||
.Select(delegate(PsvDocumentLine line) { return line.CardId; })
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
foreach (var pendingLine in pendingLinesToRemove)
|
||||
{
|
||||
pendingLines.Remove(pendingLine);
|
||||
}
|
||||
|
||||
var deletedPendingCount = pendingLinesToRemove.Count;
|
||||
var deletedResult = new DocumentGroupDeleteResult();
|
||||
|
||||
if (persistedCardIds.Count > 0)
|
||||
{
|
||||
deletedResult = await Task.Run(delegate
|
||||
{
|
||||
return _service.DeleteDocumentGroups(selectedDocumentNumber, persistedCardIds);
|
||||
});
|
||||
}
|
||||
|
||||
var remainingPendingCount = pendingLines.Count;
|
||||
var remainingPersistedCount = DocumentLines.Count(delegate(PsvDocumentLine line) { return !line.IsPendingInsert; }) - persistedCardIds.Count;
|
||||
|
||||
if (selectedDocument.IsDraft)
|
||||
{
|
||||
UpdateDocumentSummaryFromLines(selectedDocument, pendingLines);
|
||||
ApplyDocumentLines(pendingLines, SelectedDocumentGroup);
|
||||
DocumentsView.Refresh();
|
||||
DocumentStatusText = BuildDocumentStatusText(Documents.Count);
|
||||
}
|
||||
else if (remainingPersistedCount == 0 && remainingPendingCount > 0)
|
||||
{
|
||||
if (!_draftDocuments.Any(delegate(PsvDocumentSummary draft) { return draft.DocumentKey == selectedDocumentKey; }))
|
||||
{
|
||||
_draftDocuments.Add(selectedDocument);
|
||||
}
|
||||
|
||||
selectedDocument.IsDraft = true;
|
||||
UpdateDocumentSummaryFromLines(selectedDocument, pendingLines);
|
||||
await RefreshDocumentsCoreAsync(selectedDocumentKey, selectedDocumentNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
await RefreshDocumentsCoreAsync(selectedDocumentKey, selectedDocumentNumber);
|
||||
}
|
||||
|
||||
var messages = new List<string>();
|
||||
if (deletedPendingCount > 0)
|
||||
{
|
||||
messages.Add(string.Format("Удалено черновых строк: {0}.", deletedPendingCount));
|
||||
}
|
||||
|
||||
if (deletedResult.DeletedEkzMkFctvlCount > 0)
|
||||
{
|
||||
messages.Add(string.Format("Удалено строк EKZMKFCTVL: {0}.", deletedResult.DeletedEkzMkFctvlCount));
|
||||
}
|
||||
|
||||
if (deletedResult.DeletedEkzMkCount > 0)
|
||||
{
|
||||
messages.Add(string.Format("Удалено строк EKZMK: {0}.", deletedResult.DeletedEkzMkCount));
|
||||
}
|
||||
|
||||
if (deletedResult.DeletedDmsCount > 0)
|
||||
{
|
||||
messages.Add(string.Format("Удалено связанных DMS: {0}.", deletedResult.DeletedDmsCount));
|
||||
}
|
||||
|
||||
if (messages.Count > 0)
|
||||
{
|
||||
_dialogService.ShowInfo(string.Join(" ", messages.ToArray()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private bool DocumentExistsInCollections(string documentNumber, string excludeDocumentKey)
|
||||
{
|
||||
return Documents.Any(delegate(PsvDocumentSummary document)
|
||||
@@ -2055,6 +2209,7 @@ namespace XLAB
|
||||
((RelayCommand)AddDocumentCommand).RaiseCanExecuteChanged();
|
||||
((RelayCommand)CloneLineVerificationCommand).RaiseCanExecuteChanged();
|
||||
((RelayCommand)DeleteDocumentCommand).RaiseCanExecuteChanged();
|
||||
((RelayCommand)DeleteSelectedLinesCommand).RaiseCanExecuteChanged();
|
||||
((RelayCommand)DeleteSelectedGroupsCommand).RaiseCanExecuteChanged();
|
||||
((RelayCommand)MarkLinePassedCommand).RaiseCanExecuteChanged();
|
||||
((RelayCommand)MarkLineRejectedCommand).RaiseCanExecuteChanged();
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user