BusinessUnitHandlers.cs
4.03 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Sungero.Company.BusinessUnit;
using Sungero.Core;
using Sungero.CoreEntities;
using Sungero.Parties;
namespace Sungero.Company
{
  partial class BusinessUnitClientHandlers
  {
    public virtual void TRRCValueInput(Sungero.Presentation.StringValueInputEventArgs e)
    {
      if (_obj.Nonresident != true)
      {
        var errorMessage = Parties.PublicFunctions.CompanyBase.CheckTRRC(e.NewValue);
        if (!string.IsNullOrEmpty(errorMessage))
          e.AddError(errorMessage);
      }
    }
    public virtual void NonresidentValueInput(Sungero.Presentation.BooleanValueInputEventArgs e)
    {
      if (e.NewValue != true)
      {
        var errorMessage = Parties.PublicFunctions.Counterparty.CheckTin(_obj.TIN, true);
        if (!string.IsNullOrEmpty(errorMessage))
          e.AddError(_obj.Info.Properties.TIN, errorMessage);
        
        errorMessage = Parties.PublicFunctions.CompanyBase.CheckTRRC(_obj.TRRC);
        if (!string.IsNullOrEmpty(errorMessage))
          e.AddError(_obj.Info.Properties.TRRC, errorMessage);
        errorMessage = Functions.BusinessUnit.CheckPsrnLength(_obj, _obj.PSRN);
        if (!string.IsNullOrEmpty(errorMessage))
          e.AddError(_obj.Info.Properties.PSRN, errorMessage);
        
        errorMessage = Functions.BusinessUnit.CheckNceoLength(_obj, _obj.NCEO);
        if (!string.IsNullOrEmpty(errorMessage))
          e.AddError(_obj.Info.Properties.NCEO, errorMessage);
      }
    }
    public virtual void CodeValueInput(Sungero.Presentation.StringValueInputEventArgs e)
    {
      if (string.IsNullOrWhiteSpace(e.NewValue) || e.NewValue == e.OldValue)
        return;
      
      // Использование пробелов в середине кода запрещено.
      var newCode = e.NewValue.Trim();
      if (Regex.IsMatch(newCode, @"\s"))
        e.AddError(Company.Resources.NoSpacesInCode);
    }
    public override void Showing(Sungero.Presentation.FormShowingEventArgs e)
    {
      if (_obj.State.IsInserted && _obj.CEO != null)
        e.AddInformation(_obj.Info.Properties.CEO, BusinessUnits.Resources.SingatureSettingWillBeCreated);
    }
    
    public virtual void CEOValueInput(Sungero.Company.Client.BusinessUnitCEOValueInputEventArgs e)
    {
      if (!Equals(e.NewValue, _obj.State.Properties.CEO.OriginalValue))
      {
        var info = e.NewValue != null
          ? BusinessUnits.Resources.SingatureSettingWillBeCreated
          : BusinessUnits.Resources.SingatureSettingWillBeClosed;
        e.AddInformation(info);
      }
    }
    public virtual void AccountValueInput(Sungero.Presentation.StringValueInputEventArgs e)
    {
      var result = Parties.PublicFunctions.Counterparty.CheckAccountLength(e.NewValue);
      if (!string.IsNullOrEmpty(result))
        e.AddError(result);
    }
    public virtual void NCEOValueInput(Sungero.Presentation.StringValueInputEventArgs e)
    {
      if (_obj.Nonresident != true)
      {
        var result = Functions.BusinessUnit.CheckNceoLength(_obj, e.NewValue);
        if (!string.IsNullOrEmpty(result))
          e.AddError(result);
      }
    }
    public virtual void PSRNValueInput(Sungero.Presentation.StringValueInputEventArgs e)
    {
      if (_obj.Nonresident != true)
      {
        var result = Functions.BusinessUnit.CheckPsrnLength(_obj, e.NewValue);
        if (!string.IsNullOrEmpty(result))
          e.AddError(result);
      }
    }
    public virtual void TINValueInput(Sungero.Presentation.StringValueInputEventArgs e)
    {
      if (_obj.Nonresident != true)
      {
        var result = Parties.PublicFunctions.Counterparty.CheckTin(e.NewValue, true);
        if (!string.IsNullOrEmpty(result))
          e.AddError(result);
      }
    }
    public virtual void EmailValueInput(Sungero.Presentation.StringValueInputEventArgs e)
    {
      if (!string.IsNullOrWhiteSpace(e.NewValue) && !Parties.PublicFunctions.Module.EmailIsValid(e.NewValue))
        e.AddWarning(Parties.Resources.WrongEmailFormat);
    }
  }
}