PowerOfAttorneyBaseSharedFunctions.cs
3.27 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
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using Sungero.Docflow.PowerOfAttorneyBase;
namespace Sungero.Docflow.Shared
{
partial class PowerOfAttorneyBaseFunctions
{
public override void ChangeDocumentPropertiesAccess(bool isEnabled, bool isRepeatRegister)
{
base.ChangeDocumentPropertiesAccess(isEnabled, isRepeatRegister);
// Поле "Действует по" доступно для редактирования при изменении реквизитов и для доверенностей в разработке.
var isDraft = _obj.LifeCycleState == Docflow.PowerOfAttorney.LifeCycleState.Draft;
_obj.State.Properties.ValidTill.IsEnabled = isDraft || isEnabled;
_obj.State.Properties.ValidFrom.IsEnabled = isDraft || isEnabled;
// При перерегистрации "Кому выдана" недоступно, если в формате номера журнала есть код подразделения.
var documentRegister = _obj.DocumentRegister;
var departmentCodeIncludedInNumber = isRepeatRegister && documentRegister != null &&
documentRegister.NumberFormatItems.Any(n => n.Element == DocumentRegisterNumberFormatItems.Element.DepartmentCode);
_obj.State.Properties.IssuedTo.IsEnabled = isEnabled && !departmentCodeIncludedInNumber;
}
public override void FillName()
{
var documentKind = _obj.DocumentKind;
if (documentKind != null && !documentKind.GenerateDocumentName.Value && _obj.Name == Docflow.Resources.DocumentNameAutotext)
_obj.Name = string.Empty;
if (documentKind == null || !documentKind.GenerateDocumentName.Value)
return;
var name = string.Empty;
/* Имя в формате:
<Вид документа> №<номер> от <дата> для <Кому выдана> "<содержание>".
*/
using (TenantInfo.Culture.SwitchTo())
{
if (!string.IsNullOrWhiteSpace(_obj.RegistrationNumber))
name += OfficialDocuments.Resources.Number + _obj.RegistrationNumber;
if (_obj.RegistrationDate != null)
name += OfficialDocuments.Resources.DateFrom + _obj.RegistrationDate.Value.ToString("d");
if (_obj.IssuedTo != null)
name += PowerOfAttorneyBases.Resources.DocumentnameFor + Company.PublicFunctions.Employee.GetShortName(_obj.IssuedTo, DeclensionCase.Genitive, true);
if (!string.IsNullOrWhiteSpace(_obj.Subject))
name += " \"" + _obj.Subject + "\"";
}
if (string.IsNullOrWhiteSpace(name))
name = Docflow.Resources.DocumentNameAutotext;
else if (documentKind != null)
name = documentKind.ShortName + name;
name = Functions.Module.TrimSpecialSymbols(name);
_obj.Name = Functions.OfficialDocument.AddClosingQuote(name, _obj);
}
public override void ChangeRegistrationPaneVisibility(bool needShow, bool repeatRegister)
{
base.ChangeRegistrationPaneVisibility(needShow, repeatRegister);
_obj.State.Properties.ExecutionState.IsVisible = false;
_obj.State.Properties.ControlExecutionState.IsVisible = false;
}
}
}