hongji.li
2023-11-11 df5a7e1ad6835e78b2f9eb7428817b0c23b116bc
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
Quintiq file version 2.0
#parent: #root
Method OnOK () id:Method_DialogCreateEditPeriodSpec_OnOK
{
  #keys: '[139394.0.523469829]'
  Body:
  [*
    // On OK
    
    data := DataHolderDialogData.Data();
    isnew := isnull( data.WrappedInstance() );
    confirmation := true;
    isusedforplanning := RadioButtonGroupUseForPlanning.BoundValue() ="true";
    periodaligment := DateTimeSelectorPeriodAlignment.DateTime();
    timeunit := DropDownStringListTimeUnit.Text();
    nroftimeunit := ApplicationMacroPlanner.FormatStringToNumber( EditFieldNrOfTimeUnits.Text() );
    nrofhistoricalperiod := ApplicationMacroPlanner.FormatStringToNumber( EditFieldNrOfHistorialPeriods.Text() );
    nroffutureperiod := ApplicationMacroPlanner.FormatStringToNumber( EditFieldNrOfFuturePeriods.Text() );
    
    //may need to pop messagebox during create or edit
    if(  PeriodSpecification_MP::GetChangeOfPlanningPeriodsAtEdition(  data.MacroPlan(),
                                                                       data.WrappedInstance(),
                                                                       isusedforplanning,
                                                                       periodaligment,
                                                                       nroftimeunit,
                                                                       timeunit,
                                                                       nrofhistoricalperiod,
                                                                       nroffutureperiod, 
                                                                       isnew                                                                   
                                                                     ) )
    {
      confirmation := WebMessageBox::Warning( Translations::MP_PeriodSpecification_MP_ChangePlanningPeriodDefinition(),
                                              Translations::MP_Designer_YesNo(), true) =0;
    }     
    if ( confirmation )
    {
      if( isnew ) //new
      {
        periodspec := PeriodSpecification_MP::Create( EditFieldID.Text(),
                                                      MacroPlan,
                                                      timeunit,
                                                      nroftimeunit,
                                                      periodaligment,
                                                      nrofhistoricalperiod,
                                                      nroffutureperiod,
                                                      false, //isfromdb
                                                      isusedforplanning,
                                                      false //isdummyplanningperiod
                                                    );
        // Access the form, select new period spec
        DataHolderForm.Data().ListPeriodSpec().SelectByKey( periodspec.Key() );
      }
      else  //update
      {
        data.WrappedInstance().Update( EditFieldID.Text(),        // Read-only attribute wont be update during apply changes
                                       timeunit,
                                       nroftimeunit,
                                       periodaligment,
                                       nrofhistoricalperiod,
                                       nroffutureperiod,
                                       true, //synchronize
                                       false , //isfromdb
                                       isusedforplanning,
                                       true //iscleanupactuals
                                       );
      }
      this.Close();
    }
  *]
}