IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 Delphi Discussion :

Choses à ne surtout pas faire dans vos applications [Débat]


Sujet :

Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Expert éminent
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    14 086
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 14 086
    Par défaut
    Tient, je me posais la question sur un code qu'un jour j'aurais à maintenir !
    Cela ressemble à ton cas !

    En fait dans la même unité, j'ai la CANPF que tu as expliqué
    Mais je crois qu'il y en a une deuxième !

    Alors cette CANPF potentielle, c'est que la même fonction gère tous les TAction.OnExecute et TAction.OnUpdate de tous ou une parte des TAction de la fiche !

    Tous les écrans de ce développeur sont comme cela,
    jusqu'à présent, j'ai conservé sa façon de faire dans ses modules pour être raccord avec l'existant même si ça ne me plait pas
    Dans mes modules, je fait un gestionnaire séparé pour chaque.

    Personnellement, je trouve cela pénible, car faut chercher le bon else if à modifier
    alors que l'on aurait un gestionnaire par instance de TAction, je trouve cela plus rapide depuis l'IDE
    mais il y aurait certes une 30aine de fonctions, certains pourraient trouver ça plus lourd

    Mais ce n'est pas parce que cela ne plait pas que c'est une CANPF !
    D'où ma demande d'avis !

    Est-ce que l'exemple qui suit est une CANPF

    Voici un 1er exemple, encore celui-là il n'est pas trop vilain, cela fait appel à des méthodes à l'intérieur
    Plus bas, j'ai un autre exemple où c'est beaucoup de code pour chaque action

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    119
    120
    121
    procedure TPreSortingDetailForm.actActionExecute(ASender: TObject);
    begin
      FDMDetailPreSorting.ValidateSession();
      if ASender=actApplyFilters then
      begin
        CheckRequiredFilter();
        if not FDMDetailPreSorting.IsFilterNoWaitMode() then
          ApplyFilters()
        else
          ApplyFiltersNoWait();
      end
      else if ASender=actClearFilters then
      begin
        ClearFilters();
        ClearFilterGrid();
      end
    //  else if ASender=actCancelFilters then
    //  begin
    //    CancelFilters();
    //  end
      else if ASender=actInverseFilteredChecked then
      begin
        InverseFilteredCheck();
      end
      else if ASender=actUncheckAllFiltered then
      begin
        UncheckAllFiltered();
      end
      else if ASender=actInverseSelectedChecked then
      begin
        InverseSelectedCheck();
      end
      else if ASender=actUncheckAllSelected then
      begin
        UncheckAllSelected();
      end
      else if ASender=actAddContainer then
      begin
        AddFilteredCheckedContainers();
      end
      else if ASender=actDeleteContainer then
      begin
        DeleteSelectedCheckedContainers();
      end
      else if ASender=actSaveSession then
      begin
        SaveSession();
      end
      else if ASender=actSendToMachine then
      begin
        SendSessionToMachine();
      end
      else if ASender=actCancelSession then
      begin
        CancelSession();
      end
      else if ASender=actPrintPicking then
      begin
        PrintSessionPicking();
      end
      else if ASender=actGoToFMList then
      begin
        GotoFMList();
      end
      else if (ASender=actClearContainerType)or(ASender=actClearContainerNature)
        or(ASender=actClearMark)or(ASender=actClearContainerRayon) then
      begin
        if ASender=actClearContainerType then
        begin
          TComponentHelper.ClearCheckComboBoxCheckedItem(cxChkCmbxContainerType);
          cxChkCmbxContainerType.EditModified := True;
        end
        else if ASender=actClearContainerRayon then
        begin
          TComponentHelper.ClearCheckComboBoxCheckedItem(cxChkCmbxContainerRayon);
          cxChkCmbxContainerRayon.EditModified := True;
        end
        else if ASender=actClearContainerNature then
        begin
          TComponentHelper.ClearCheckComboBoxCheckedItem(cxChkCmbxContainerNature);
          cxChkCmbxContainerNature.EditModified := True;
        end
        else if ASender=actClearMark then
        begin
          TComponentHelper.ClearCheckComboBoxCheckedItem(cxChkCmbxContainerMark);
          cxChkCmbxContainerMark.EditModified := True;
        end;
      end
      else if (ASender=actExportObjectsGrid) then
      begin
        TComponentHelper.ExportCxGridToExcel(cxContainerDetailsGrid, 'ListeObjets',
          TPath.GetTempPath(),True);
      end
      else if ASender=actExportFiltersGrid then
      begin
        TComponentHelper.ExportCxGridToExcel(cxFilteredContainerGrid,
          'ListeContenantsFiltres',TPath.GetTempPath(),True);
      end
      else if ASender=actExportSelectedGrid then
      begin
        TComponentHelper.ExportCxGridToExcel(cxSelectedContainerGrid,
          'ListeContenantSelectionnes',TPath.GetTempPath(),True);
      end
      else if ASender=actExportFallsGrid then
      begin
        TComponentHelper.ExportCxGridToExcel(cxFallOutGrid, 'ListeChutes',
          TPath.GetTempPath(),True);
      end
      else if ASender=actSetContainer then
      begin
        AddSetContainer();
      end
      else if ASender=actSetContainerRefusedHelp then
      begin
        AidSetContainerRefusedHelp();
      end
      else if ASender=actSearchObject then
      begin
        SearchObject();
      end;
    end;

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    procedure TPreSortingDetailForm.actActionUpdate(ASender: TObject);
    var
      LEnabled, LOldEditModified: Boolean;
      LCodeSessionStatus: Integer;
    begin
      LEnabled := False;
     
      if FDataUpdating then
        Exit;
     
      if not FDMDetailPresorting.DtSrcWavesSession.DataSet.Active then
      begin
        LEnabled := False;
        if ASender is TAction then
        begin
          if (ASender as TAction).Enabled<>LEnabled then
            (ASender as TAction).Enabled := LEnabled;
        end;
        Exit;
      end;
     
      LCodeSessionStatus := FDMDetailPreSorting.DtSrcWavesSession.DataSet.FieldByName(FIELD_SS_N_STATUT).AsInteger;
      if (ASender=actClearFilters)or(ASender=actApplyFilters)or(ASender=actAddContainer)
        or(ASender=actInverseFilteredChecked)or(ASender=actUncheckAllFiltered) then
    //    or(ASender=actCancelFilters) then
      begin
        LEnabled := Assigned(cxFilteredContainerGridDBTableView1.DataController.DataSource);
        if LEnabled then
          LEnabled := Assigned(cxFilteredContainerGridDBTableView1.DataController.DataSource.DataSet);
     
        if LEnabled then
        begin
          if ((ASender=actAddContainer)or(ASender=actInverseFilteredChecked)
            or(ASender=actUncheckAllFiltered)) then
          begin
            LEnabled := not cxFilteredContainerGridDBTableView1.ViewData.IsEmpty();
            if LEnabled then
            begin
              if ASender=actAddContainer then
                LEnabled := (FDetailState in [dtlModify,dtlCreate])and(IsFilteredContainerGridChecked())
                  and(LCodeSessionStatus=CODE_SESSION_STATUS_CONSTITUTION);
            end;
    //      end
    //      else if ASender=actCancelFilters then
    //      begin
    //        LEnabled := FDMDetailPreSorting.IsApplyingFilters();
          end;
        end;
      end
      else if (ASender=actDeleteContainer)or(ASender=actSaveSession)or(ASender=actInverseSelectedChecked)
        or(ASender=actSendToMachine)or(ASender=actPrintPicking)or(ASender=actUncheckAllSelected) then
      begin
        LEnabled := Assigned(cxSelectedContainerGridDBTableView1.DataController.DataSource);
        if LEnabled then
          LEnabled := Assigned(cxSelectedContainerGridDBTableView1.DataController.DataSource.DataSet);
        if LEnabled then
          LEnabled := not cxSelectedContainerGridDBTableView1.ViewData.IsEmpty();
     
        if LEnabled then
        begin
          if (ASender=actDeleteContainer)or(ASender=actSaveSession)or(ASender=actSendToMachine) then
            LEnabled := FDetailState in [dtlModify,dtlCreate];
          if LEnabled then
          begin
            if (ASender=actDeleteContainer)or(ASender=actInverseSelectedChecked)
              or(ASender=actUncheckAllSelected) then
            begin
              LEnabled := LCodeSessionStatus=CODE_SESSION_STATUS_CONSTITUTION;
              if LEnabled and (ASender=actDeleteContainer) then
                LEnabled := IsSelectedContainerChecked();
            end
            else if (ASender=actSaveSession)or(ASender=actSendToMachine) then
            begin
              if ASender=actSaveSession then
              begin
                LEnabled := (LCodeSessionStatus=CODE_SESSION_STATUS_CONSTITUTION)
                  and FDetailModified;
              end
              else if ASender=actSendToMachine then
              begin
                LEnabled := (LCodeSessionStatus in [CODE_SESSION_STATUS_CONSTITUTION,
                  CODE_SESSION_STATUS_MACHINEREJECT])and(not FSessionSended);
              end;
            end
            else if (ASender=actPrintPicking) then
            begin
              LEnabled := LCodeSessionStatus in [CODE_SESSION_STATUS_SOUBMITTOMACHINE,
                CODE_SESSION_STATUS_MACHINEACK,CODE_SESSION_STATUS_MAP_ACTIVE,
                CODE_SESSION_STATUS_MAP_FINISHED];
     
              if LEnabled then
              begin
                LEnabled := Assigned(cxSelectedContainerGridDBTableView1.DataController.DataSource)
                  and(Assigned(cxSelectedContainerGridDBTableView1.DataController.DataSource.DataSet))
                  and(not cxSelectedContainerGridDBTableView1.ViewData.IsEmpty());
              end;
            end;
          end;
        end;
      end
      else if (ASender=actClearContainerType)or(ASender=actClearContainerNature)
        or(ASender=actClearMark)or(ASender=actClearContainerRayon) then
      begin
        if ASender=actClearContainerType then
        begin
          LOldEditModified := cxChkCmbxContainerType.EditModified;
          LEnabled := cxChkCmbxContainerType.Text<>'';
          if actClearContainerType.Enabled<>LEnabled then
            actClearContainerType.Enabled := LEnabled;
          cxChkCmbxContainerType.EditModified := LOldEditModified;
          Exit;
        end
        else if ASender=actClearContainerRayon then
        begin
          LOldEditModified := cxChkCmbxContainerRayon.EditModified;
          LEnabled := cxChkCmbxContainerRayon.Text<>'';
          if actClearContainerRayon.Enabled<>LEnabled then
            actClearContainerRayon.Enabled := LEnabled;
          cxChkCmbxContainerRayon.EditModified := LOldEditModified;
          Exit;
        end
        else if ASender=actClearContainerNature then
        begin
          LOldEditModified := cxChkCmbxContainerNature.EditModified;
          LEnabled := cxChkCmbxContainerNature.Text<>'';
          if actClearContainerNature.Enabled<>LEnabled then
            actClearContainerNature.Enabled := LEnabled;
          cxChkCmbxContainerNature.EditModified := LOldEditModified;
          Exit;
        end
        else if ASender=actClearMark then
        begin
          LOldEditModified := cxChkCmbxContainerMark.EditModified;
          LEnabled := cxChkCmbxContainerMark.Text<>'';
          if actClearMark.Enabled<>LEnabled then
            actClearMark.Enabled := LEnabled;
          cxChkCmbxContainerMark.EditModified := LOldEditModified;
          Exit;
        end;
      end
      else if (ASender=actExportObjectsGrid)or(ASender=actSearchObject) then
      begin
        LEnabled := Assigned(cxContainerDetailsGridDBTableView1.DataController.DataSource)
          and(Assigned(cxContainerDetailsGridDBTableView1.DataController.DataSource.DataSet))
          and(not cxContainerDetailsGridDBTableView1.ViewData.IsEmpty());
      end
      else if ASender=actExportFiltersGrid then
      begin
        LEnabled := Assigned(cxFilteredContainerGridDBTableView1.DataController.DataSource)
          and(Assigned(cxFilteredContainerGridDBTableView1.DataController.DataSource.DataSet))
          and(not cxFilteredContainerGridDBTableView1.ViewData.IsEmpty());
      end
      else if ASender=actExportSelectedGrid then
      begin
        LEnabled := Assigned(cxSelectedContainerGridDBTableView1.DataController.DataSource)
          and(Assigned(cxSelectedContainerGridDBTableView1.DataController.DataSource.DataSet))
          and(not cxSelectedContainerGridDBTableView1.ViewData.IsEmpty());
      end
      else if ASender=actExportFallsGrid then
      begin
        LEnabled := Assigned(cxFallOutGridDBTableView1.DataController.DataSource)
          and(Assigned(cxFallOutGridDBTableView1.DataController.DataSource.DataSet))
          and(not cxFallOutGridDBTableView1.ViewData.IsEmpty());
      end
      else if (ASender=actGoToFMList)or(ASender=actCancelSession) then
      begin
        LEnabled := True;
      end
      else if (ASender=actSetContainer) or (ASender=actSetContainerRefusedHelp) then
      begin
        LEnabled := FDetailState in [dtlModify,dtlCreate];
        if LEnabled then
          LEnabled := (LCodeSessionStatus=CODE_SESSION_STATUS_CONSTITUTION);
        if LEnabled then
          LEnabled := edtSetContainer.Text<>'';
      end;
     
      if ASender is TAction then
      begin
        if (ASender as TAction).Enabled <> LEnabled then
        begin
          (ASender as TAction).Enabled := LEnabled;
        end;
      end;
    end;

    Comme je le disais, celui-là n'est pas le pire dans le genre,
    en voici un autre qui pour moi est une triple-CANPF dont Antipattern - Ancre de bateau
    le code gère toutes les actions d'un sous-menu Impression contenant une douzaine de rapports différents
    mais j'ai de la chance, je n'ai jamais à maintenir ce module

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    procedure TAdminCentralInventoryExtendedFormDetail.actEditReportExecute(
      ASender: TObject);
    var
      LDoSave: Boolean;
      LCursor: TCursor;
    begin
      inherited;
      LCursor := Screen.Cursor;
      Screen.Cursor := crHourGlass;
      try
      if (ASender=actPrintResearch)or(ASender=actSaveResearch) then
      begin
        ppDBPipelineReport.DataSource := DtSrcObjDemarked;
        DtSrcObjDemarked.DataSet.DisableControls();
        try
          ppLabel5.Caption := cbbMHO_CH_CODE.Text;
          ppLabel6.Caption := edtMHO_CH_NOM.Text;
          ppLabel9.Caption := edtPIN_N_NUMINVEN.Text;
          ppLabel3.Caption := edtPIN_N_NUMINVEN.Text;
          ppMemo1.Lines.Text := cxMmPIN_CH_DESCRIPTION.Text;
          if (PreInventaire.SIN_CH_CODESTATUT=CODESTATUS_CLOSED)and(edtIN_N_NUMINVEN.Text<>'') then
          begin
            ppLabel11.Visible := True;
            ppLabel12.Visible := True;
            ppLabel12.Caption := edtIN_N_NUMINVEN.Text;
            ppLblEtatData.Caption := 'Démarque confirmé';
            SvDlg.Title := 'Editer le rapport de Démarques confirmé';
            ppLabel14.Visible := True;
            ppLabel17.Visible := True;
            ppLabel17.Caption := DateTimeToStr(PreInventaire.PIN_DT_REQDEMARQUE);
          end
          else
          begin
            ppLabel11.Visible := False;
            ppLabel12.Visible := False;
            ppLblEtatData.Caption := 'Démarque potentiel';
            SvDlg.Title := 'Editer le rapport de Démarque potentiel';
            ppLabel14.Visible := False;
            ppLabel17.Visible := False;
          end;
          ppLabel27.Caption := edtSUPERVISEUR.Text;
          ppLabel15.Caption := DateTimeToStr(PreInventaire.PIN_DT_CREATION);
     
          ppReportDemarque.ArchiveFileName := '';
          ppReportDemarque.AllowPrintToArchive := False;
     
          if ASender=actPrintResearch then
          begin
            //ppReportDemarque.DeviceType := 'Screen';
            ppReportDemarque.DeviceType := 'Printer';
            ppReportDemarque.TextFileName := '';
            ppReportDemarque.AllowPrintToFile := False;
            ppReportDemarque.ShowPrintDialog := True;
            //ppReportDemarque.ShowPrintDialog := False;
            ppReportDemarque.Print();
          end
          else
          begin
            ppReportDemarque.DeviceType := 'PDF';
            SvDlg.FileName := Format('Recherche_Inv%d',[PreInventaire.PIN_N_NUMINVEN]);
            if SvDlg.Execute() then
            begin
              LDoSave := True;
              if FileExists(SvDlg.FileName) then
                LDoSave := MessageDlg(Format('Le fichier %s existe déjà !'+sLineBreak+
                  'Voulez-vous l''écraser ?',[SvDlg.FileName]), mtConfirmation,
                  [mbYes, mbCancel], 0)=mrYes;
     
              if LDoSave then
              begin
                ppReportDemarque.TextFileName := SvDlg.FileName;
                ppReportDemarque.AllowPrintToFile := True;
                ppReportDemarque.ShowPrintDialog := False;
                ppReportDemarque.Print();
              end;
            end;
          end;
        finally
          DtSrcObjDemarked.DataSet.EnableControls();
        end;
      end
      else if (ASender=actEditReportExpected)or(ASender=actPrintReportExpected) then
      begin
        ppDBPipelineReport.DataSource := DtSrcObjPreInvent;
        DtSrcObjPreInvent.DataSet.DisableControls();
        try
          ppLabel43.Caption := cbbMHO_CH_CODE.Text;
          ppLabel44.Caption := edtMHO_CH_NOM.Text;
          ppLabel28.Caption := edtPIN_N_NUMINVEN.Text;
          ppLabel46.Caption := edtPIN_N_NUMINVEN.Text;
          ppMemo2.Lines.Text := cxMmPIN_CH_DESCRIPTION.Text;
          ppLabel25.Caption := 'Stock avant inv.';
          SvDlg.Title := 'Editer le rapport de Stock avant inventaire';
          if (PreInventaire.SIN_CH_CODESTATUT=CODESTATUS_CLOSED)and(edtIN_N_NUMINVEN.Text<>'') then
          begin
            ppLabel47.Visible := True;
            ppLabel48.Visible := True;
            ppLabel48.Caption := edtIN_N_NUMINVEN.Text;
            ppLabel52.Visible := True;
            ppLabel50.Visible := True;
            ppLabel52.Caption := DateTimeToStr(PreInventaire.PIN_DT_REQDEMARQUE);
          end
          else
          begin
            ppLabel52.Visible := False;
            ppLabel50.Visible := False;
            ppLabel47.Visible := False;
            ppLabel48.Visible := False;
          end;
          ppLabel55.Caption := edtSUPERVISEUR.Text;
          ppLabel51.Caption := DateTimeToStr(PreInventaire.PIN_DT_CREATION);
     
          ppReportExpected.ArchiveFileName := '';
          ppReportExpected.AllowPrintToArchive := False;
     
          if ASender=actEditReportExpected then
          begin
            ppReportExpected.DeviceType := 'PDF';
            SvDlg.FileName := Format('ADM_Stock_avant_inventaire%d.PDF',[PreInventaire.PIN_N_NUMINVEN]);
            if SvDlg.Execute() then
            begin
              LDoSave := True;
              if FileExists(SvDlg.FileName) then
                LDoSave := MessageDlg(Format('Le fichier %s existe déjà !'+sLineBreak+
                  'Voulez-vous l''écraser ?',[SvDlg.FileName]), mtConfirmation,
                  [mbYes, mbCancel], 0)=mrYes;
     
              if LDoSave then
              begin
                ppReportExpected.TextFileName := SvDlg.FileName;
                ppReportExpected.AllowPrintToFile := True;
                ppReportExpected.ShowPrintDialog := False;
                ppReportExpected.Print();
              end;
            end;
          end
          else
          begin
            //ppReportExpected.DeviceType := 'Screen';
            ppReportExpected.DeviceType := 'Printer';
            ppReportExpected.TextFileName := '';
            ppReportExpected.AllowPrintToFile := False;
            ppReportExpected.ShowPrintDialog := True;
            ppReportExpected.Print();
          end;
        finally
          DtSrcObjPreInvent.DataSet.EnableControls();
        end;
      end
      else if (ASender=actEditReportInventNExpected)or(ASender=actPrintReportExpectedNInventoried) then
      begin
        ppDBPipelineReport.DataSource := DtSrcInventNExpected;
        DtSrcInventNExpected.DataSet.DisableControls();
        try
          ppLabel91.Caption := cbbMHO_CH_CODE.Text;
          ppLabel92.Caption := edtMHO_CH_NOM.Text;
          ppLabel68.Caption := edtPIN_N_NUMINVEN.Text;
          ppLabel94.Caption := edtPIN_N_NUMINVEN.Text;
          ppMemo3.Lines.Text := cxMmPIN_CH_DESCRIPTION.Text;
          SvDlg.Title := 'Editer le rapport de Stock après inventaire';
          if (PreInventaire.SIN_CH_CODESTATUT=CODESTATUS_CLOSED)and(edtIN_N_NUMINVEN.Text<>'') then
          begin
            ppLabel95.Visible := True;
            ppLabel96.Visible := True;
            ppLabel96.Caption := edtIN_N_NUMINVEN.Text;
            ppLabel67.Caption := 'Stock après inv. confirmé';
            ppLabel98.Visible := True;
            ppLabel100.Caption := DateTimeToStr(PreInventaire.PIN_DT_REQDEMARQUE);
          end
          else
          begin
            ppLabel95.Visible := False;
            ppLabel96.Visible := False;
            ppLabel25.Caption := 'Stock après inv. potentiel';
            ppLabel98.Visible := False;
            ppLabel100.Visible := False;
          end;
          ppLabel102.Caption := edtSUPERVISEUR.Text;
          ppLabel99.Caption := DateTimeToStr(PreInventaire.PIN_DT_CREATION);
     
          ppReportInventNExpected.ArchiveFileName := '';
          ppReportInventNExpected.AllowPrintToArchive := False;
     
          if ASender=actEditReportInventNExpected then
          begin
            ppReportInventNExpected.DeviceType := 'PDF';
            SvDlg.FileName := Format('ADM_Stock_apres_inventaire%d.PDF',[PreInventaire.PIN_N_NUMINVEN]);
            if SvDlg.Execute() then
            begin
              LDoSave := True;
              if FileExists(SvDlg.FileName) then
                LDoSave := MessageDlg(Format('Le fichier %s existe déjà !'+sLineBreak+
                  'Voulez-vous l''écraser ?',[SvDlg.FileName]), mtConfirmation,
                  [mbYes, mbCancel], 0)=mrYes;
     
              if LDoSave then
              begin
                ppReportInventNExpected.TextFileName := SvDlg.FileName;
                ppReportInventNExpected.AllowPrintToFile := True;
                ppReportInventNExpected.ShowPrintDialog := False;
                ppReportInventNExpected.Print();
              end;
            end;
          end
          else
          begin
            //ppReportInventNExpected.DeviceType := 'Screen';
            ppReportInventNExpected.DeviceType := 'Printer';
            ppReportInventNExpected.TextFileName := '';
            ppReportInventNExpected.AllowPrintToFile := False;
            ppReportInventNExpected.ShowPrintDialog := True;
            ppReportInventNExpected.Print();
          end;
        finally
          DtSrcInventNExpected.DataSet.EnableControls();
        end;
      end
      else if (ASender=actEditReportHorsTT)or(ASender=actPrintReportHorsTT) then
      begin
        ppDBPipelineReport.DataSource := DtSrcHorsTT;
        DtSrcHorsTT.DataSet.DisableControls();
        try
          ppLabel91.Caption := cbbMHO_CH_CODE.Text;
          ppLabel92.Caption := edtMHO_CH_NOM.Text;
          ppLabel68.Caption := edtPIN_N_NUMINVEN.Text;
          ppLabel94.Caption := edtPIN_N_NUMINVEN.Text;
          ppMemo3.Lines.Text := cxMmPIN_CH_DESCRIPTION.Text;
          SvDlg.Title := 'Editer le rapport de Hors Stock Hors Requête';
          if (PreInventaire.SIN_CH_CODESTATUT=CODESTATUS_CLOSED)and(edtIN_N_NUMINVEN.Text<>'') then
          begin
            ppLabel95.Visible := True;
            ppLabel96.Visible := True;
            ppLabel96.Caption := edtIN_N_NUMINVEN.Text;
            ppLabel67.Caption := 'Hors stk. hors req. confirmé';
            ppLabel98.Visible := True;
            ppLabel100.Caption := DateTimeToStr(PreInventaire.PIN_DT_REQDEMARQUE);
          end
          else
          begin
            ppLabel95.Visible := False;
            ppLabel96.Visible := False;
            ppLabel25.Caption := 'Hors stk. hors req. potentiel';
            ppLabel98.Visible := False;
            ppLabel100.Visible := False;
          end;
          ppLabel102.Caption := edtSUPERVISEUR.Text;
          ppLabel99.Caption := DateTimeToStr(PreInventaire.PIN_DT_CREATION);
     
          ppReportInventNExpected.ArchiveFileName := '';
          ppReportInventNExpected.AllowPrintToArchive := False;
     
          if ASender=actEditReportHorsTT then
          begin
            ppReportInventNExpected.DeviceType := 'PDF';
            SvDlg.FileName := Format('ADM_HorsRequeteHorsStock_inventaire%d.PDF',[PreInventaire.PIN_N_NUMINVEN]);
            if SvDlg.Execute() then
            begin
              LDoSave := True;
              if FileExists(SvDlg.FileName) then
                LDoSave := MessageDlg(Format('Le fichier %s existe déjà !'+sLineBreak+
                  'Voulez-vous l''écraser ?',[SvDlg.FileName]), mtConfirmation,
                  [mbYes, mbCancel], 0)=mrYes;
     
              if LDoSave then
              begin
                ppReportInventNExpected.TextFileName := SvDlg.FileName;
                ppReportInventNExpected.AllowPrintToFile := True;
                ppReportInventNExpected.ShowPrintDialog := False;
                ppReportInventNExpected.Print();
              end;
            end;
          end
          else
          begin
            //ppReportInventNExpected.DeviceType := 'Screen';
            ppReportInventNExpected.DeviceType := 'Printer';
            ppReportInventNExpected.TextFileName := '';
            ppReportInventNExpected.AllowPrintToFile := False;
            ppReportInventNExpected.ShowPrintDialog := True;
            ppReportInventNExpected.Print();
          end;
        finally
          DtSrcHorsTT.DataSet.EnableControls();
        end;
      end
      else if (ASender=actEditReportNotInventoried)or(ASender=actPrintReportNotInventoried) then
      begin
        ppDBPipelineReport.DataSource := DtSrcObjDemarked;
        DtSrcObjDemarked.DataSet.DisableControls();
        try
          ppLabel43.Caption := cbbMHO_CH_CODE.Text;
          ppLabel44.Caption := edtMHO_CH_NOM.Text;
          ppLabel28.Caption := edtPIN_N_NUMINVEN.Text;
          ppLabel46.Caption := edtPIN_N_NUMINVEN.Text;
          ppMemo2.Lines.Text := cxMmPIN_CH_DESCRIPTION.Text;
          SvDlg.Title := 'Editer le rapport de Stock démarque';
          if (PreInventaire.SIN_CH_CODESTATUT=CODESTATUS_CLOSED)and(edtIN_N_NUMINVEN.Text<>'') then
          begin
            ppLabel11.Visible := True;
            ppLabel12.Visible := True;
            ppLabel48.Caption := edtIN_N_NUMINVEN.Text;
            ppLabel52.Visible := True;
            ppLabel50.Visible := True;
            ppLabel52.Caption := DateTimeToStr(PreInventaire.PIN_DT_REQDEMARQUE);
            ppLabel25.Caption := 'Stock démarque confirmé';
          end
          else
          begin
            ppLabel11.Visible := False;
            ppLabel12.Visible := False;
            ppLabel52.Visible := False;
            ppLabel50.Visible := False;
            ppLabel25.Caption := 'Stock démarque potentiel';
          end;
          ppLabel55.Caption := edtSUPERVISEUR.Text;
          ppLabel51.Caption := DateTimeToStr(PreInventaire.PIN_DT_CREATION);
     
          ppReportExpected.ArchiveFileName := '';
          ppReportExpected.AllowPrintToArchive := False;
     
          if ASender=actEditReportNotInventoried then
          begin
    //        ppReportExpected.DefaultFileDeviceType := 'XLSReport';
    //        ppReportExpected.DeviceType := 'XLSReport';
            ppReportExpected.DeviceType := 'PDF';
    //        SvDlg.FileName := Format('ADM_Stock_demarque_inventaire%d.xls',[PreInventaire.PIN_N_NUMINVEN]);
            SvDlg.FileName := Format('ADM_Stock_demarque_inventaire%d.PDF',[PreInventaire.PIN_N_NUMINVEN]);
            if SvDlg.Execute() then
            begin
              LDoSave := True;
              if FileExists(SvDlg.FileName) then
                LDoSave := MessageDlg(Format('Le fichier %s existe déjà !'+sLineBreak+
                  'Voulez-vous l''écraser ?',[SvDlg.FileName]), mtConfirmation,
                  [mbYes, mbCancel], 0)=mrYes;
     
              if LDoSave then
              begin
                ppReportExpected.TextFileName := SvDlg.FileName;
                ppReportExpected.AllowPrintToFile := True;
                ppReportExpected.ShowPrintDialog := False;
                ppReportExpected.Print();
              end;
            end;
          end
          else
          begin
    //        ppReportExpected.DefaultFileDeviceType := 'XLSReport';
    //        ppReportExpected.DeviceType := 'Screen';
    //        ppReportExpected.ShowPrintDialog := False;
            ppReportExpected.DeviceType := 'Printer';
            ppReportExpected.TextFileName := '';
            ppReportExpected.AllowPrintToFile := False;
            ppReportExpected.ShowPrintDialog := True;
            ppReportExpected.Print();
          end;
        finally
          DtSrcObjDemarked.DataSet.EnableControls();
        end;
      end
      else if (ASender=actEditReportAnomalie)or(ASender=actPrintReportAnomalie) then
      begin
        ppDBPipelineReport.DataSource := DtSrcAnomalie;
        DtSrcAnomalie.DataSet.DisableControls();
        try
          ppLabel43.Caption := cbbMHO_CH_CODE.Text;
          ppLabel44.Caption := edtMHO_CH_NOM.Text;
          ppLabel28.Caption := edtPIN_N_NUMINVEN.Text;
          ppLabel46.Caption := edtPIN_N_NUMINVEN.Text;
          ppMemo2.Lines.Text := cxMmPIN_CH_DESCRIPTION.Text;
          SvDlg.Title := 'Editer le rapport de Stock anomalie';
          if (PreInventaire.SIN_CH_CODESTATUT=CODESTATUS_CLOSED)and(edtIN_N_NUMINVEN.Text<>'') then
          begin
            ppLabel11.Visible := True;
            ppLabel12.Visible := True;
            ppLabel48.Caption := edtIN_N_NUMINVEN.Text;
            ppLabel52.Visible := True;
            ppLabel50.Visible := True;
            ppLabel52.Caption := DateTimeToStr(PreInventaire.PIN_DT_REQDEMARQUE);
            ppLabel25.Caption := 'Stock anomalie confirmé';
          end
          else
          begin
            ppLabel11.Visible := False;
            ppLabel12.Visible := False;
            ppLabel52.Visible := False;
            ppLabel50.Visible := False;
            ppLabel25.Caption := 'Stock anomalie potentiel';
          end;
          ppLabel55.Caption := edtSUPERVISEUR.Text;
          ppLabel51.Caption := DateTimeToStr(PreInventaire.PIN_DT_CREATION);
     
          ppReportExpected.ArchiveFileName := '';
          ppReportExpected.AllowPrintToArchive := False;
     
          if ASender=actEditReportNotInventoried then
          begin
            ppReportExpected.DeviceType := 'PDF';
            SvDlg.FileName := Format('ADM_Stock_anomalie_inventaire%d.PDF',[PreInventaire.PIN_N_NUMINVEN]);
            if SvDlg.Execute() then
            begin
              LDoSave := True;
              if FileExists(SvDlg.FileName) then
                LDoSave := MessageDlg(Format('Le fichier %s existe déjà !'+sLineBreak+
                  'Voulez-vous l''écraser ?',[SvDlg.FileName]), mtConfirmation,
                  [mbYes, mbCancel], 0)=mrYes;
     
              if LDoSave then
              begin
                ppReportExpected.TextFileName := SvDlg.FileName;
                ppReportExpected.AllowPrintToFile := True;
                ppReportExpected.ShowPrintDialog := False;
                ppReportExpected.Print();
              end;
            end;
          end
          else
          begin
            //ppReportExpected.DeviceType := 'Screen';
            ppReportExpected.DeviceType := 'Printer';
            ppReportExpected.TextFileName := '';
            ppReportExpected.AllowPrintToFile := False;
            ppReportExpected.ShowPrintDialog := True;
            ppReportExpected.Print();
          end;
        finally
          DtSrcAnomalie.DataSet.EnableControls();
        end;
      end
      else if (ASender=actEditReportRejected)or(ASender=actPrintReportRejected) then
      begin
        ppDBPipelineReport.DataSource := DtSrcObjRejected;
        DtSrcObjRejected.DataSet.DisableControls();
        try
          ppLabel91.Caption := cbbMHO_CH_CODE.Text;
          ppLabel92.Caption := edtMHO_CH_NOM.Text;
          ppLabel68.Caption := edtPIN_N_NUMINVEN.Text;
          ppLabel94.Caption := edtPIN_N_NUMINVEN.Text;
          ppMemo3.Lines.Text := cxMmPIN_CH_DESCRIPTION.Text;
          SvDlg.Title := 'Editer le rapport de Stock rejeté';
          if (PreInventaire.SIN_CH_CODESTATUT=CODESTATUS_CLOSED)and(edtIN_N_NUMINVEN.Text<>'') then
          begin
            ppLabel95.Visible := True;
            ppLabel96.Visible := True;
            ppLabel96.Caption := edtIN_N_NUMINVEN.Text;
            ppLabel67.Caption := 'Stock rejeté confirmé';
            ppLabel98.Visible := True;
            ppLabel100.Caption := DateTimeToStr(PreInventaire.PIN_DT_REQDEMARQUE);
          end
          else
          begin
            ppLabel95.Visible := False;
            ppLabel96.Visible := False;
            ppLabel25.Caption := 'Stock rejeté potentiel';
            ppLabel98.Visible := False;
            ppLabel100.Visible := False;
          end;
          ppLabel102.Caption := edtSUPERVISEUR.Text;
          ppLabel99.Caption := DateTimeToStr(PreInventaire.PIN_DT_CREATION);
     
          ppReportInventNExpected.ArchiveFileName := '';
          ppReportInventNExpected.AllowPrintToArchive := False;
     
          if ASender=actEditReportRejected then
          begin
            ppReportInventNExpected.DeviceType := 'PDF';
            SvDlg.FileName := Format('ADM_Stock_rejete_inventaire%d.PDF',[PreInventaire.PIN_N_NUMINVEN]);
            if SvDlg.Execute() then
            begin
              LDoSave := True;
              if FileExists(SvDlg.FileName) then
                LDoSave := MessageDlg(Format('Le fichier %s existe déjà !'+sLineBreak+
                  'Voulez-vous l''écraser ?',[SvDlg.FileName]), mtConfirmation,
                  [mbYes, mbCancel], 0)=mrYes;
     
              if LDoSave then
              begin
                ppReportInventNExpected.TextFileName := SvDlg.FileName;
                ppReportInventNExpected.AllowPrintToFile := True;
                ppReportInventNExpected.ShowPrintDialog := False;
                ppReportInventNExpected.Print();
              end;
            end;
          end
          else
          begin
            //ppReportInventNExpected.DeviceType := 'Screen';
            ppReportInventNExpected.DeviceType := 'Printer';
            ppReportInventNExpected.TextFileName := '';
            ppReportInventNExpected.AllowPrintToFile := False;
            ppReportInventNExpected.ShowPrintDialog := True;
            ppReportInventNExpected.Print();
          end;
        finally
          DtSrcObjRejected.DataSet.EnableControls();
        end;
      end
      else if (ASender=actEditReportCadrage)or(ASender=actPrintReportCadre) then
      begin
        ppDBPipelineCadre.DataSource := DtSrcCadrage;
        DtSrcCadrage.DataSet.DisableControls();
        try
          ppLabel109.Caption := cbbMHO_CH_CODE.Text;
          ppLabel110.Caption := edtMHO_CH_NOM.Text;
          ppLabel112.Caption := edtPIN_N_NUMINVEN.Text;
          ppLabel124.Caption := edtPIN_N_NUMINVEN.Text;
          ppMemo4.Lines.Text := cxMmPIN_CH_DESCRIPTION.Text;
          SvDlg.Title := 'Editer le rapport de Cadrage';
          if (PreInventaire.SIN_CH_CODESTATUT=CODESTATUS_CLOSED)and(edtIN_N_NUMINVEN.Text<>'') then
          begin
            ppLabel116.Visible := True;
            ppLabel118.Visible := True;
            ppLabel114.Caption := edtIN_N_NUMINVEN.Text;
            ppLabel123.Caption := 'Cadrage confirmé';
            ppLabel113.Visible := True;
            ppLabel118.Caption := DateTimeToStr(PreInventaire.PIN_DT_REQDEMARQUE);
          end
          else
          begin
            ppLabel116.Visible := False;
            ppLabel118.Visible := False;
            ppLabel123.Caption := 'Cadrage potentiel';
            ppLabel113.Visible := False;
            ppLabel114.Visible := False;
          end;
          ppLabel120.Caption := edtSUPERVISEUR.Text;
          ppLabel117.Caption := DateTimeToStr(PreInventaire.PIN_DT_CREATION);
     
          ppReportCadre.ArchiveFileName := '';
          ppReportCadre.AllowPrintToArchive := False;
     
          if ASender=actEditReportCadrage then
          begin
            ppReportCadre.DeviceType := 'PDF';
            SvDlg.FileName := Format('ADM_Cadrage_inventaire%d.PDF',[PreInventaire.PIN_N_NUMINVEN]);
            if SvDlg.Execute() then
            begin
              LDoSave := True;
              if FileExists(SvDlg.FileName) then
                LDoSave := MessageDlg(Format('Le fichier %s existe déjà !'+sLineBreak+
                  'Voulez-vous l''écraser ?',[SvDlg.FileName]), mtConfirmation,
                  [mbYes, mbCancel], 0)=mrYes;
     
              if LDoSave then
              begin
                ppReportCadre.TextFileName := SvDlg.FileName;
                ppReportCadre.AllowPrintToFile := True;
                ppReportCadre.ShowPrintDialog := False;
                ppReportCadre.Print();
              end;
            end;
          end
          else
          begin
            ppReportCadre.DeviceType := 'Screen';
            ppReportCadre.ShowPrintDialog := False;
            //ppReportCadre.DeviceType := 'Printer';
            ppReportCadre.TextFileName := '';
            ppReportCadre.AllowPrintToFile := False;
            //ppReportCadre.ShowPrintDialog := True;
            ppReportCadre.Print();
          end;
     
    //      ppLabel145.Caption := edtPIN_N_NUMINVEN.Text;
    //      ppLabel126.Caption := edtPIN_N_NUMINVEN.Text;
    //      ppLabel133.Caption := edtPIN_N_NUMINVEN.Text;
    //      ppLabel147.Caption := 'Cadrage';
    //      ppLabel128.Caption := 'Cadrage';
    //      ppLabel130.Caption := cbbMHO_CH_CODE.Text;
    //      ppLabel131.Caption := edtMHO_CH_NOM.Text;
    //      ppLabel141.Caption := edtSUPERVISEUR.Text;
    //      ppMemo5.Lines.Text := cxMmPIN_CH_DESCRIPTION.Lines.Text;
    //      ppLabel138.Caption := DateToStr(PreInventaire.PIN_DT_CREATION);
    //      SvDlg.Title := 'Editer le rapport de Cadrage';
    //      if (PreInventaire.SIN_CH_CODESTATUT=CODESTATUS_CLOSED)and(edtIN_N_NUMINVEN.Text<>'') then
    //      begin
    //        ppLabel134.Visible := True;
    //        ppLabel135.Visible := True;
    //        ppLabel135.Caption := edtIN_N_NUMINVEN.Text;
    //      end
    //      else
    //      begin
    //        ppLabel134.Visible := False;
    //        ppLabel135.Visible := False;
    //      end;
    //      ppReportCadreTest.ArchiveFileName := '';
    //      ppReportCadreTest.AllowPrintToArchive := False;
    //
    //      if ASender=actEditReportCadrage then
    //      begin
    //        ppReportCadreTest.DeviceType := 'PDF';
    //        SvDlg.FileName := Format('ADM_Cadrage_inventaire%d.PDF',[PreInventaire.PIN_N_NUMINVEN]);
    //        if SvDlg.Execute() then
    //        begin
    //          LDoSave := True;
    //          if FileExists(SvDlg.FileName) then
    //            LDoSave := MessageDlg(Format('Le fichier %s existe déjà !'+sLineBreak+
    //              'Voulez-vous l''écraser ?',[SvDlg.FileName]), mtConfirmation,
    //              [mbYes, mbCancel], 0)=mrYes;
    //
    //          if LDoSave then
    //          begin
    //            ppReportCadreTest.TextFileName := SvDlg.FileName;
    //            ppReportCadreTest.AllowPrintToFile := True;
    //            ppReportCadreTest.ShowPrintDialog := False;
    //            ppReportCadreTest.Print();
    //          end;
    //        end;
    //      end
    //      else
    //      begin
    //        ppReportCadreTest.DeviceType := 'Screen';
    //        ppReportCadreTest.ShowPrintDialog := False;
    //        //ppReportCadreTest.DeviceType := 'Printer';
    //        ppReportCadreTest.TextFileName := '';
    //        ppReportCadreTest.AllowPrintToFile := False;
    //        //ppReportCadreTest.ShowPrintDialog := True;
    //        ppReportCadreTest.Print();
    //      end;
     
        finally
          DtSrcCadrage.DataSet.EnableControls();
        end;
      end;
      finally
        Screen.Cursor := LCursor;
      end;
    end;
    Donc comme je le mentionnais dans la même unité,
    il y a aussi la CANPF évoqué par Paul TOTH, c'est à dire de l'appel abusif d'un gestionnaire Click() et pas qu'une fois mais plutôt 40 fois !
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
        if cxTbShtMissing.TabVisible then
        Begin
          //stock démarqué
          cxPgCtrl.ActivePage := cxTbShtMissing;
          if cxPgCtrl.Properties.CustomButtons.Buttons[BUTTON_LOADALL].Visible then
            cxPgCtrlTcxPageControlPropertiesTcxPCCustomButtonsButtons0Click(NIL)     --- ICI
          else if LLoadAll then
            PreInventaire.HODemObjPreInventList.Refresh();
          actEditReportNotInventoried.Execute();
        End;
        if cxTbShtRejected.TabVisible then
        begin
          //rejeté
          cxPgCtrl.ActivePage := cxTbShtRejected;
          if cxPgCtrl.Properties.CustomButtons.Buttons[BUTTON_LOADALL].Visible then
            cxPgCtrlTcxPageControlPropertiesTcxPCCustomButtonsButtons0Click(NIL)    --- ICI
          else if LLoadAll then
            PreInventaire.HORejObjPreInventList.Refresh();
          actEditReportRejected.Execute();
        end;
        if cxTbShtAnomalie.TabVisible then
        begin
          //Anomalie
          cxPgCtrl.ActivePage := cxTbShtAnomalie;
          if cxPgCtrl.Properties.CustomButtons.Buttons[BUTTON_LOADALL].Visible then
            cxPgCtrlTcxPageControlPropertiesTcxPCCustomButtonsButtons0Click(NIL)   --- ICI
          else if LLoadAll then
            PreInventaire.HOAnomalie.Refresh();
          actEditReportAnomalie.Execute();
    Et évidemment, le ...Click contient un tas de code, toujours toute la logique en brut dans les gestionnaires alors que des méthodes privées seraient plus élégant
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    procedure TAdminCentralInventoryExtendedFormDetail.cxPgCtrlTcxPageControlPropertiesTcxPCCustomButtonsButtons0Click(
      ASender: TObject);
    var
      LCursor: TCursor;
      LView: TcxGridDBTableView;
      LDtSrc: TDataSource;
      LQuery: TOraQuery;
    begin
      inherited;
     
      LQuery := NIL;
      LView := NIL;
      LDtSrc := NIL;
      if cxPgCtrl.ActivePage=cxTbShtExpected then
      begin
        LQuery := PreInventaire.HOObjPreInventList;
        LDtSrc := DtSrcObjPreInvent;
        LView := cxGrdObjPreInventDBTableView1;
      end
      else if cxPgCtrl.ActivePage=cxTbShtInventoried then
      begin
        LQuery := PreInventaire.HORecensePreInvList;
        LDtSrc := DtSrcObjInventoried;
        LView := cxGrdObjInventoriedDBTableView1;
      end
      else if cxPgCtrl.ActivePage=cxTbShtInventoriedNExpected then
      begin
        LQuery := PreInventaire.HOInventObjPreInventList;
        LDtSrc := DtSrcInventNExpected;
        LView := cxGridInventNExpectedDBTableView;
      end
      else if cxPgCtrl.ActivePage=cxTbShtMissing then
      begin
        LQuery := PreInventaire.HODemObjPreInventList;
        LDtSrc := DtSrcObjDemarked;
        LView := cxGrdObjDemarkedDBTableView1;
      end
      else if cxPgCtrl.ActivePage=cxTbShtRejected then
      begin
        LQuery := PreInventaire.HORejObjPreInventList;
        LDtSrc := DtSrcObjRejected;
        LView := cxGrdObjRejectedDBTableView1;
      end
      else if cxPgCtrl.ActivePage=cxtbShtHorsReqHorsStock then
      begin
        LQuery := PreInventaire.HOHorsReqHorsStockList;
        LDtSrc := DtSrcHorsTT;
        LView := cxGridHorsTTDBTableView;
      end
      else if cxPgCtrl.ActivePage=cxTbShtHorsStock then
      begin
        LQuery := PreInventaire.HOHorsStockList;
        LDtSrc := DtSrcHorsReq;
        LView := cxGridHorsStockDBTableView;
      end;
     
      if (LView<>NIL)and(LQuery<>NIL)and(LDtSrc<>NIL) then
      begin
        LCursor := Screen.Cursor;
        Screen.Cursor := crSQLWait;
        try
          LView.BeginUpdate();
          try
            LView.DataController.DataSource := NIL;
            LQuery.FetchAll := True;
            LView.DataController.DataModeController.GridMode := False;
            LView.DataController.DataModeController.GridModeBufferCount := 0;
            LView.DataController.DataSource := LDtSrc;
            //LQuery.Refresh();
            LView.OptionsCustomize.ColumnFiltering := True;
            LView.OptionsCustomize.ColumnGrouping := True;
            LView.OptionsCustomize.ColumnSorting := True;
            LView.OptionsView.GroupByBox := True;
            LView.OptionsView.Footer := True;
            LView.OptionsView.GroupFooters := gfAlwaysVisible;
            LView.FilterBox.Visible := fvAlways;
            LView.FilterBox.CustomizeDialog := True;
            LView.FilterBox.Position := fpTop;
          finally
            LView.EndUpdate();
          end;
          cxPgCtrl.Properties.CustomButtons.Buttons[BUTTON_LOADALL].Visible :=
            not LQuery.FetchAll;
        finally
          Screen.Cursor := LCursor;
        end;
      end;
    end;
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  2. #2
    Expert éminent
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Par défaut
    Salut,

    oui je pense que tout cela est à éviter

    quand tu as un "if Sender = btSendMail" tu peux croire que c'est lisible...jusqu'au jour ou tu veux simuler l'envoie de mail depuis une autre partie du code et tu te retrouves à appeler "Form2.Action1Execute(Form2.btSendMail)" car c'est le seul moyen de lui faire exécuter le code correctement.

    de plus ces méthodes sont bien trop longues ... je n'utilise jamais le coldFolding pour m'assurer d'éviter cela justement

    et les if/then/else imbriqués comme ça c'est toujours un peu casse gueule.

    mais je te rejoins sur un point, quand tu reprends un développement, tu ne peux pas juste tout réécrire par ce que ce n'est pas beau
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

Discussions similaires

  1. [Freeware] Mettez un "Live Update" dans vos applications
    Par Hexanium dans le forum Mon programme
    Réponses: 10
    Dernier message: 18/07/2010, 03h34
  2. [Logging] Que tracez-vous dans vos applications ?
    Par le Daoud dans le forum Langages de programmation
    Réponses: 4
    Dernier message: 10/03/2006, 14h36

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo