yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
StaticMethod CanSave (KpiTracker owner, KpiLabel original, String name) as Boolean
{
  Description: 'Checks to see if a KpiLabel can be saved like this. Used in preconditions. Sets the FeedbackObject.'
  TextBody:
  [*
    val      := name.TrimBoth();
    feedback := FeedbackObject::LocalFeedback();
    isUnique := not exists( owner, Label, l, ( isnull( original ) 
                                               or l <> original ) 
                                         and l.Name() = val );
    
    if ( not feedback.CheckHard( isUnique ) )
    {
      feedback.AddHard( Translations::Kpi_Label_NameMustBeUnique( val ) );
    }
    
    if ( not feedback.CheckHard( val <> '' ) )
    {
      feedback.AddHard( Translations::Kpi_Label_NameCantBeEmpty() );
    }
    
    return feedback.IsAllowed();
  *]
}