ConsolidatedInventoryClientFunctions.cs
3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using DirRX.Storage.ConsolidatedInventory;
namespace DirRX.Storage.Client
{
partial class ConsolidatedInventoryFunctions
{
/// <summary>
/// Отобразить диалог для включения выбранных дел в сводную опись.
/// </summary>
/// <returns>Сообщение об ошибке, либо пустая строка.</returns>
[Public]
public virtual string AddCaseFilesDialog()
{
// Получить список дел для включения в сводную опись.
var isPaper = _obj.Type != DirRX.Storage.ConsolidatedInventory.Type.ElectronicPerm && _obj.Type != DirRX.Storage.ConsolidatedInventory.Type.ElectronicTemp;
var query = PublicFunctions.Module.Remote.GetCaseFilesToInventory().Where(x => x.LTAIsPaperDirRX == isPaper);
if (query.Any())
{
// Отобразить диалог выбора дел. Включить выбранные дела в опись.
var dialog = Dialogs.CreateInputDialog(Resources.AddCaseFilesToInventoryDialogTitle);
var caseFileSelector = dialog.AddSelectMany(Resources.CaseFilesLabel, true, DirRX.LongTermArchive.CaseFiles.Null)
.From(query.ToArray());
if (query.Count() == 1)
caseFileSelector.Value = query.Take(1).AsEnumerable();
var year = dialog.AddInteger(Resources.YearLabel, true, Calendar.Today.Year);
dialog.SetOnRefresh((arg) =>
{
if (year.Value.HasValue)
{
var error = Storage.PublicFunctions.Module.Remote.LaterApprovedAnnualSectionsExists(_obj, year.Value.Value);
if (error != string.Empty)
{
arg.AddError(error);
return;
}
var annualSection = Storage.Functions.Module.Remote.GetAnnualSection(_obj, year.Value.Value);
if (annualSection != null)
arg.AddWarning(ConsolidatedInventories.Resources.ReformAnnualSectionMessageFormat(annualSection.Name));
}
});
if (dialog.Show() == DialogButtons.Ok)
{
if (caseFileSelector.Value.Count() + _obj.CasesNumber > Constants.Module.MaxCaseFilesNumber)
return ConsolidatedInventories.Resources.WarningCaseFilesTooMuch;
foreach (var caseFile in caseFileSelector.Value)
if (!DirRX.LongTermArchive.PublicFunctions.CaseFile.UpdateConsInventory(caseFile, _obj, year.Value, string.Empty))
return ConsolidatedInventories.Resources.WarningCanNotUpdateCaseFileFormat(caseFile.DisplayValue);
}
}
else
return ConsolidatedInventories.Resources.WarningCaseFilesNotFound;
return string.Empty;
}
}
}