CounterpartyDocumentSharedFunctions.cs
2.7 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
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using Sungero.Docflow.CounterpartyDocument;
namespace Sungero.Docflow.Shared
{
partial class CounterpartyDocumentFunctions
{
public override List<Parties.ICounterparty> GetCounterparties()
{
if (_obj.Counterparty == null)
return null;
return new List<Parties.ICounterparty> { _obj.Counterparty };
}
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 (documentKind != null)
name += documentKind.ShortName + " ";
var counterparty = _obj.Counterparty;
if (counterparty != null)
name += counterparty.Name + " ";
if (!string.IsNullOrWhiteSpace(_obj.RegistrationNumber))
name += Sungero.Docflow.OfficialDocuments.Resources.Number + _obj.RegistrationNumber;
if (_obj.RegistrationDate != null)
name += Sungero.Docflow.OfficialDocuments.Resources.DateFrom + _obj.RegistrationDate.Value.ToString("d");
if (!string.IsNullOrWhiteSpace(_obj.Subject))
name += " " + _obj.Subject;
name = Docflow.PublicFunctions.Module.TrimSpecialSymbols(name);
_obj.Name = Docflow.PublicFunctions.OfficialDocument.AddClosingQuote(name, _obj);
}
}
/// <summary>
/// Изменение состояния документа для ненумеруемых документов.
/// </summary>
public override void SetLifeCycleState()
{
// Не изменять статус при сохранении.
}
public override void RefreshDocumentForm()
{
base.RefreshDocumentForm();
var isNotNumerableType = _obj.DocumentKind == null || _obj.DocumentKind.NumberingType == Docflow.DocumentKind.NumberingType.NotNumerable;
_obj.State.Properties.BusinessUnit.IsVisible = !isNotNumerableType;
_obj.State.Properties.Department.IsVisible = !isNotNumerableType;
_obj.State.Properties.Assignee.IsVisible = false;
_obj.State.Properties.PreparedBy.IsVisible = false;
_obj.State.Properties.OurSignatory.IsVisible = false;
}
}
}