BankHandlers.cs
2.73 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
79
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using Sungero.Parties.Bank;
namespace Sungero.Parties
{
partial class BankServerHandlers
{
public override void BeforeSave(Sungero.Domain.BeforeSaveEventArgs e)
{
if (!string.IsNullOrEmpty(_obj.SWIFT))
{
var newSwift = _obj.SWIFT.Trim();
if (!_obj.SWIFT.Equals(newSwift, StringComparison.InvariantCultureIgnoreCase))
_obj.SWIFT = newSwift;
}
if (!string.IsNullOrEmpty(_obj.BIC))
{
var newBic = _obj.BIC.Trim();
if (!_obj.BIC.Equals(newBic, StringComparison.InvariantCultureIgnoreCase))
_obj.BIC = newBic;
}
if (!string.IsNullOrEmpty(_obj.CorrespondentAccount))
{
var newCorr = _obj.CorrespondentAccount.Trim();
if (!_obj.CorrespondentAccount.Equals(newCorr, StringComparison.InvariantCultureIgnoreCase))
_obj.CorrespondentAccount = newCorr;
}
// Проверить корректность SWIFT.
var checkSwiftErrorText = PublicFunctions.Bank.CheckSwift(_obj.SWIFT);
if (!string.IsNullOrEmpty(checkSwiftErrorText))
e.AddError(_obj.Info.Properties.SWIFT, checkSwiftErrorText);
if (_obj.Nonresident != true)
{
// Проверить корректность БИК.
var checkBicErrorText = PublicFunctions.Bank.CheckBicLength(_obj.BIC);
if (!string.IsNullOrEmpty(checkBicErrorText))
e.AddError(_obj.Info.Properties.BIC, checkBicErrorText);
// Проверить корректность корр. счета.
var checkCorrErrorText = PublicFunctions.Bank.CheckCorrLength(_obj.CorrespondentAccount);
if (!string.IsNullOrEmpty(checkCorrErrorText))
e.AddError(_obj.Info.Properties.CorrespondentAccount, checkCorrErrorText);
}
else
{
// Проверить корректность корр. счета для нерезидента.
var checkCorrErrorText = PublicFunctions.Bank.CheckCorrAccountForNonresident(_obj.CorrespondentAccount);
if (!string.IsNullOrEmpty(checkCorrErrorText))
e.AddError(_obj.Info.Properties.CorrespondentAccount, checkCorrErrorText);
}
base.BeforeSave(e);
}
}
partial class BankCreatingFromServerHandler
{
public override void CreatingFrom(Sungero.Domain.CreatingFromEventArgs e)
{
base.CreatingFrom(e);
e.Without(_info.Properties.IsSystem);
// При копировании системного банка комментарий не переносится.
if (_source.IsSystem == true)
e.Without(_info.Properties.Note);
}
}
}