yanyuan
2023-11-10 143ef74e2eeee697ac8fda3d9032a790fbb4e146
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
Quintiq file version 2.0
#parent: #root
Method ImportData (
  internal[GUIComponent] parent
) id:Method_DialogUserImportProfile_ImportData
{
  #keys: '[132894.0.197566578]'
  Body:
  [*
    // Import data from excel
    // Create an import profile for import purpose
    
    if ( Dialog.DoModal( parent ) > 0 )
    {   
      path := EditorExcelPath.Text();
      Dialog.FormatPath( path );
      
      // Create a profile used to execute import
      data := MPSync.UserImportProfile( relnew,
                                        Name := 'temp',
                                        ExcelPath := path );
      Dialog.Data( data );
      
      try
      {
        Dialog.FindCreateAllImportObjectGroupInProfile();
        
        userimportprofiles := construct( UserImportProfiles );
        userimportprofiles.Add( data );
        Dialog.ExecuteProfiles( userimportprofiles );    
      }
      onerror
      {  
        errormessage := Translations::MPSync_Browser_Import_Excel_Warning();
        MessageBox::Warning( Application, errormessage, 'OK' );
      }
      
      // Delete the profile after executing import
      data.Delete();
    }
  *]
}