Statistiques
| Révision:

root / UnitIngredientsList.pas @ 6

Historique | Voir | Annoter | Télécharger (22,596 ko)

1 1 avalancogn
unit UnitIngredientsList;
2
3
interface
4
5
uses
6
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7
  Dialogs, StdCtrls, ComCtrls, ExtCtrls, DB, DBGrids, Grids, ActnList, ImgList,
8
  ToolWin, Buttons, JvDBUltimGrid, JvExDBGrids, JvDBGrid, gnugettext,
9
  JvExStdCtrls, JvButton, JvCtrls;
10
11
type
12
  TFormIngredientsList = class(TForm)
13
    PageControlLists: TPageControl;
14
    TabSheetProximal: TTabSheet;
15
    TabSheetEnergy: TTabSheet;
16
    TabSheetAATot: TTabSheet;
17
    TabSheetAADig: TTabSheet;
18
    DBGridProximal: TDBGrid;
19
    DBGridEnergy: TDBGrid;
20
    DBGridAATot: TDBGrid;
21
    DBGridAADig: TDBGrid;
22
    TabSheetEnergyUtilization: TTabSheet;
23
    DBGridRatios: TDBGrid;
24
    TabSheetMinerals: TTabSheet;
25
    DBGridMinerals: TDBGrid;
26
    TabSheetAA_MAT: TTabSheet;
27
    TabSheetdAA: TTabSheet;
28
    DBGridAA_MAT: TDBGrid;
29
    DBGriddAA: TDBGrid;
30
    TabSheetMS: TTabSheet;
31
    DBGridMS: TDBGrid;
32
    TabSheetdP: TTabSheet;
33
    DBGriddP: TDBGrid;
34
    SplitterList: TSplitter;
35
    ImageListIcons: TImageList;
36
    ActionListButtons: TActionList;
37
    ActionView: TAction;
38
    ActionCreate: TAction;
39
    ActionHelp: TAction;
40
    ActionClose: TAction;
41
    LabelWarning: TLabel;
42
    GroupBoxFilters: TGroupBox;
43
    LabelFilteredClass: TLabel;
44
    LabelFilteredDatabase: TLabel;
45
    LabelFilteredName: TLabel;
46
    ComboBoxClass: TComboBox;
47
    ComboBoxDatabase: TComboBox;
48
    EditName: TEdit;
49
    CheckBoxClass: TCheckBox;
50
    CheckBoxDatabase: TCheckBox;
51
    CheckBoxName: TCheckBox;
52
    PanelButtons: TPanel;
53
    PanelName: TPanel;
54
    DBGridName: TDBGrid;
55
    JvImgBtnView: TJvImgBtn;
56
    JvImgBtnCreate: TJvImgBtn;
57
    JvImgBtnHelp: TJvImgBtn;
58
    JvImgBtnClose: TJvImgBtn;
59 6 avalancogn
    TabSheetBE: TTabSheet;
60
    DBGridBE: TDBGrid;
61 1 avalancogn
    procedure FormCreate(Sender: TObject);
62
    procedure ComboBoxClassChange(Sender: TObject);
63
    procedure DBGridTitleClick(Column: TColumn);
64
    procedure DBGridDrawColumnCell(Sender: TObject; const Rect: TRect;
65
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
66
    procedure EditNameChange(Sender: TObject);
67
    procedure CheckBoxFilterClick(Sender: TObject);
68
    procedure PageControlListsChange(Sender: TObject);
69
    procedure FormDestroy(Sender: TObject);
70
    procedure DBGridDblClick(Sender: TObject);
71
    procedure FormShow(Sender: TObject);
72
    procedure ComboBoxDatabaseChange(Sender: TObject);
73
    procedure SplitterListMoved(Sender: TObject);
74
    procedure FormResize(Sender: TObject);
75
    procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
76
    procedure ActionViewExecute(Sender: TObject);
77
    procedure ActionCreateExecute(Sender: TObject);
78
    procedure ActionHelpExecute(Sender: TObject);
79
    procedure ActionCloseExecute(Sender: TObject);
80
  private
81
    { D?clarations priv?es }
82
    DBGridNameOldWindowProc: TWndMethod;
83
    DBGridMSOldWindowProc: TWndMethod;
84
    DBGridProximalOldWindowProc: TWndMethod;
85
    DBGridRatiosOldWindowProc: TWndMethod;
86
    DBGridEnergyOldWindowProc: TWndMethod;
87
    DBGridAATotOldWindowProc: TWndMethod;
88
    DBGridAA_MATOldWindowProc: TWndMethod;
89
    DBGriddAAOldWindowProc: TWndMethod;
90
    DBGridAADigOldWindowProc: TWndMethod;
91
    DBGridMineralsOldWindowProc: TWndMethod;
92
    DBGriddPOldWindowProc: TWndMethod;
93
    Procedure DBGridNameNewWindowProc(var Msg: TMessage);
94
    Procedure DBGridMSNewWindowProc(var Msg: TMessage);
95
    Procedure DBGridProximalNewWindowProc(var Msg: TMessage);
96
    Procedure DBGridRatiosNewWindowProc(var Msg: TMessage);
97
    Procedure DBGridEnergyNewWindowProc(var Msg: TMessage);
98
    Procedure DBGridAATotNewWindowProc(var Msg: TMessage);
99
    Procedure DBGridAA_MATNewWindowProc(var Msg: TMessage);
100
    Procedure DBGriddAANewWindowProc(var Msg: TMessage);
101
    Procedure DBGridAADigNewWindowProc(var Msg: TMessage);
102
    Procedure DBGridMineralsNewWindowProc(var Msg: TMessage);
103
    Procedure DBGriddPNewWindowProc(var Msg: TMessage);
104
  public
105
    { D?clarations publiques }
106
  end;
107
108
var
109
  FormIngredientsList: TFormIngredientsList;
110
111
implementation
112
113
{$R *.dfm}
114
115
uses
116
  UnitDeclaration, UnitOptions, UnitIngredientCreation, UnitIngredientDetail;
117
118
procedure TFormIngredientsList.ActionCloseExecute(Sender: TObject);
119
begin
120
  ModalResult := mrClose;
121
end;
122
123
procedure TFormIngredientsList.ActionCreateExecute(Sender: TObject);
124
begin
125
  FormIngredientCreation := TFormIngredientCreation.Create(nil);
126
  try
127
    // D?sactiver les filtres
128
    CheckBoxClass.Checked := False;
129
    CheckBoxDatabase.Checked := False;
130
    CheckBoxName.Checked := False;
131
    if FormIngredientCreation.ShowModal = mrOk
132
    then
133
    begin
134
      FormIngredientDetail := TFormIngredientDetail.Create(nil);
135
      try
136
        // Modifier le nouvel enregistrement
137
        FormIngredientDetail.ActionModifyExecute(Sender);
138
        FormIngredientDetail.ShowModal;
139
      finally
140
        FormIngredientDetail.Release;
141
      end;
142
    end;
143
  finally
144
    FormIngredientCreation.Release;
145
  end;
146
end;
147
148
procedure TFormIngredientsList.ActionHelpExecute(Sender: TObject);
149
begin
150
  Application.HelpContext(HelpContext);
151
end;
152
153
procedure TFormIngredientsList.ActionViewExecute(Sender: TObject);
154
begin
155
  if DataModuleDeclaration.ClientDataSetIngredients.RecordCount = 0
156
  then // Aucun enregistrement affich? (filtres)
157
    Exit;
158
  FormIngredientDetail := TFormIngredientDetail.Create(nil);
159
  try
160
    FormIngredientDetail.ShowModal;
161
  finally
162
    FormIngredientDetail.Release;
163
  end;
164
end;
165
166
procedure TFormIngredientsList.CheckBoxFilterClick(Sender: TObject);
167
var
168
  Id, User: Integer;
169
begin
170
  if CheckBoxClass.Checked
171
  then
172
  begin
173
    LabelFilteredClass.Caption := _('Enabled');
174
    LabelFilteredClass.Font.Color := clGreen;
175
  end
176
  else
177
  begin
178
    LabelFilteredClass.Caption := _('Disabled');
179
    LabelFilteredClass.Font.Color := clRed;
180
  end;
181
  ComboBoxClass.Enabled := CheckBoxClass.Checked;
182
  if CheckBoxDatabase.Checked
183
  then
184
  begin
185
    LabelFilteredDatabase.Caption := _('Enabled');
186
    LabelFilteredDatabase.Font.Color := clGreen;
187
  end
188
  else
189
  begin
190
    LabelFilteredDatabase.Caption := _('Disabled');
191
    LabelFilteredDatabase.Font.Color := clRed;
192
  end;
193
  ComboBoxDatabase.Enabled := CheckBoxDatabase.Checked;
194
  if CheckBoxName.Checked
195
  then
196
  begin
197
    LabelFilteredName.Caption := _('Enabled');
198
    LabelFilteredName.Font.Color := clGreen;
199
  end
200
  else
201
  begin
202
    LabelFilteredName.Caption := _('Disabled');
203
    LabelFilteredName.Font.Color := clRed;
204
  end;
205
  EditName.Enabled := CheckBoxName.Checked;
206
  with DataModuleDeclaration do
207
  begin
208
    Id := ClientDataSetIngredientsId.Value;
209
    if ClientDataSetIngredientsUser.Value
210
    then
211
      User := 1
212
    else
213
      User := 0;
214
    ClientDataSetIngredients.Filtered := False;
215
    FilterOnClass := CheckBoxClass.Checked;
216
    FilteredClass := ComboBoxClass.ItemIndex + 1;
217
    FilterOnDatabase := CheckBoxDatabase.Checked;
218
    FilteredDatabase := ComboBoxDatabase.ItemIndex + 1;
219
    FilterOnName := CheckBoxName.Checked;
220
    FilteredName := Trim(EditName.Text);
221
    if (FilterOnClass and (FilteredClass <> 0))
222
    or (FilterOnDatabase and (FilteredDatabase <> 0))
223
    or (FilterOnName and (FilteredName <> ''))
224
    then
225
      ClientDataSetIngredients.Filtered := True;
226
    ClientDataSetIngredients.Locate('Id;User', VarArrayOf([Id, User]), [])
227
  end;
228
end;
229
230
procedure TFormIngredientsList.ComboBoxClassChange(Sender: TObject);
231
begin
232
  if CheckBoxClass.Checked
233
  then
234
    CheckBoxFilterClick(nil);
235
end;
236
237
procedure TFormIngredientsList.ComboBoxDatabaseChange(Sender: TObject);
238
begin
239
  if CheckBoxDatabase.Checked
240
  then
241
    CheckBoxFilterClick(nil);
242
end;
243
244
procedure TFormIngredientsList.DBGridDblClick(Sender: TObject);
245
begin
246
//  ButtonViewClick(nil);
247
  ActionViewExecute(nil);
248
end;
249
250
procedure TFormIngredientsList.DBGridDrawColumnCell(Sender: TObject;
251
  const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
252
begin
253
  with Sender as TDBGrid do
254
  begin
255
    if Column.FieldName = DataModuleDeclaration.ClientDataSetIngredients.IndexFieldNames
256
    then // Colonne tri?e
257
      Canvas.Font.Style := Canvas.Font.Style + [fsBold];
258
    if Column.FieldName = 'Name'
259
    then // Couleur particuli?re pour indiquer la base d'origine
260
      if gdSelected in State
261
      then // Cellule courante
262
      begin
263
        if DataModuleDeclaration.ClientDataSetIngredientsUser.Value
264
        then // User
265
          Canvas.Font.Color := clWebPaleTurquoise
266
        else // InraAfz
267
          Canvas.Font.Color := clWebLightPink;
268
        Canvas.Brush.Color := clWebGray;
269
      end
270
      else // Cellule normale
271
      begin
272
        Canvas.Font.Color := clWebBlack;
273
        if DataModuleDeclaration.ClientDataSetIngredientsUser.Value
274
        then // User
275
          Canvas.Brush.Color := clWebPaleTurquoise
276
        else // InraAfz
277
          Canvas.Brush.Color := clWebLightPink;
278
      end
279
    else // Valeurs
280
    begin
281
      if gdSelected in State
282
      then // Cellule courante
283
      begin
284
        Canvas.Font.Color := clWebWhite;
285
        Canvas.Brush.Color := clWebGray;
286
      end
287
      else
288
      begin
289
        Canvas.Font.Color := clWebBlack;
290
        Canvas.Brush.Color := clWebLightGrey;
291
      end;
292
      if ((Sender = DBGridProximal) and (Column.FieldName <> 'MS2'))
293
      or (Sender = DBGridMinerals)
294
      then
295
        with DataModuleDeclaration do
296
          if ClientDataSetIngredientsUser.Value
297
          then // User
298
          begin
299
            TableIngredients := DBUser.GetTable('SELECT * FROM Ingredients '
300
              + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
301
            if TableIngredients.FieldIsNull(TableIngredients.FieldIndex[Column.FieldName])
302
            then // Valeur h?rit?e du mod?le
303
            begin
304
              Canvas.Font.Style := Canvas.Font.Style + [fsItalic];
305
              if gdSelected in State
306
              then // Cellule courante
307
                Canvas.Font.Color := clWebSilver
308
              else
309
                Canvas.Font.Color := clWebDimGray;
310
            end;
311
            TableIngredients.Free;
312
          end;
313
    end;
314
    DefaultDrawColumnCell(Rect, DataCol, Column, State);
315
  end;
316
end;
317
318
procedure TFormIngredientsList.DBGridNameNewWindowProc(var Msg: TMessage);
319
begin
320
  if Msg.Msg = WM_MOUSEWHEEL
321
  then // Interception de l'?v?nement WM_MOUSEWHEEL
322
    if SmallInt(Msg.WParamHi) < 0
323
    then
324
      DataModuleDeclaration.ClientDataSetIngredients.Next
325
    else
326
      DataModuleDeclaration.ClientDataSetIngredients.Prior
327
  else // Traitement des autres messages
328
  begin
329
    if Msg.Msg = WM_NCCALCSIZE
330
    then // Forcer l'affichage des ascenseurs
331
      ShowScrollBar(DBGridName.Handle, SB_BOTH, True);
332
    DBGridNameOldWindowProc(Msg);
333
  end;
334
end;
335
336
procedure TFormIngredientsList.DBGridMSNewWindowProc(var Msg: TMessage);
337
begin
338
  if Msg.Msg = WM_MOUSEWHEEL
339
  then // Interception de l'?v?nement WM_MOUSEWHEEL
340
    if SmallInt(Msg.WParamHi) < 0
341
    then
342
      DataModuleDeclaration.ClientDataSetIngredients.Next
343
    else
344
      DataModuleDeclaration.ClientDataSetIngredients.Prior
345
  else // Traitement des autres messages
346
  begin
347
    if Msg.Msg = WM_NCCALCSIZE
348
    then // Forcer l'affichage des ascenseurs
349
      ShowScrollBar(DBGridMS.Handle, SB_BOTH, True);
350
    DBGridMSOldWindowProc(Msg);
351
  end;
352
end;
353
354
procedure TFormIngredientsList.DBGridProximalNewWindowProc(var Msg: TMessage);
355
begin
356
  if Msg.Msg = WM_MOUSEWHEEL
357
  then // Interception de l'?v?nement WM_MOUSEWHEEL
358
    if SmallInt(Msg.WParamHi) < 0
359
    then
360
      DataModuleDeclaration.ClientDataSetIngredients.Next
361
    else
362
      DataModuleDeclaration.ClientDataSetIngredients.Prior
363
  else // Traitement des autres messages
364
  begin
365
    if Msg.Msg = WM_NCCALCSIZE
366
    then // Forcer l'affichage des ascenseurs
367
      ShowScrollBar(DBGridProximal.Handle, SB_BOTH, True);
368
    DBGridProximalOldWindowProc(Msg);
369
  end;
370
end;
371
372
procedure TFormIngredientsList.DBGridRatiosNewWindowProc(var Msg: TMessage);
373
begin
374
  if Msg.Msg = WM_MOUSEWHEEL
375
  then // Interception de l'?v?nement WM_MOUSEWHEEL
376
    if SmallInt(Msg.WParamHi) < 0
377
    then
378
      DataModuleDeclaration.ClientDataSetIngredients.Next
379
    else
380
      DataModuleDeclaration.ClientDataSetIngredients.Prior
381
  else // Traitement des autres messages
382
  begin
383
    if Msg.Msg = WM_NCCALCSIZE
384
    then // Forcer l'affichage des ascenseurs
385
      ShowScrollBar(DBGridRatios.Handle, SB_BOTH, True);
386
    DBGridRatiosOldWindowProc(Msg);
387
  end;
388
end;
389
390
procedure TFormIngredientsList.DBGridEnergyNewWindowProc(var Msg: TMessage);
391
begin
392
  if Msg.Msg = WM_MOUSEWHEEL
393
  then // Interception de l'?v?nement WM_MOUSEWHEEL
394
    if SmallInt(Msg.WParamHi) < 0
395
    then
396
      DataModuleDeclaration.ClientDataSetIngredients.Next
397
    else
398
      DataModuleDeclaration.ClientDataSetIngredients.Prior
399
  else // Traitement des autres messages
400
  begin
401
    if Msg.Msg = WM_NCCALCSIZE
402
    then // Forcer l'affichage des ascenseurs
403
      ShowScrollBar(DBGridEnergy.Handle, SB_BOTH, True);
404
    DBGridEnergyOldWindowProc(Msg);
405
  end;
406
end;
407
408
procedure TFormIngredientsList.DBGridAATotNewWindowProc(var Msg: TMessage);
409
begin
410
  if Msg.Msg = WM_MOUSEWHEEL
411
  then // Interception de l'?v?nement WM_MOUSEWHEEL
412
    if SmallInt(Msg.WParamHi) < 0
413
    then
414
      DataModuleDeclaration.ClientDataSetIngredients.Next
415
    else
416
      DataModuleDeclaration.ClientDataSetIngredients.Prior
417
  else // Traitement des autres messages
418
  begin
419
    if Msg.Msg = WM_NCCALCSIZE
420
    then // Forcer l'affichage des ascenseurs
421
      ShowScrollBar(DBGridAATot.Handle, SB_BOTH, True);
422
    DBGridAATotOldWindowProc(Msg);
423
  end;
424
end;
425
426
procedure TFormIngredientsList.DBGridAA_MATNewWindowProc(var Msg: TMessage);
427
begin
428
  if Msg.Msg = WM_MOUSEWHEEL
429
  then // Interception de l'?v?nement WM_MOUSEWHEEL
430
    if SmallInt(Msg.WParamHi) < 0
431
    then
432
      DataModuleDeclaration.ClientDataSetIngredients.Next
433
    else
434
      DataModuleDeclaration.ClientDataSetIngredients.Prior
435
  else // Traitement des autres messages
436
  begin
437
    if Msg.Msg = WM_NCCALCSIZE
438
    then // Forcer l'affichage des ascenseurs
439
      ShowScrollBar(DBGridAA_MAT.Handle, SB_BOTH, True);
440
    DBGridAA_MATOldWindowProc(Msg);
441
  end;
442
end;
443
444
procedure TFormIngredientsList.DBGriddAANewWindowProc(var Msg: TMessage);
445
begin
446
  if Msg.Msg = WM_MOUSEWHEEL
447
  then // Interception de l'?v?nement WM_MOUSEWHEEL
448
    if SmallInt(Msg.WParamHi) < 0
449
    then
450
      DataModuleDeclaration.ClientDataSetIngredients.Next
451
    else
452
      DataModuleDeclaration.ClientDataSetIngredients.Prior
453
  else // Traitement des autres messages
454
  begin
455
    if Msg.Msg = WM_NCCALCSIZE
456
    then // Forcer l'affichage des ascenseurs
457
      ShowScrollBar(DBGriddAA.Handle, SB_BOTH, True);
458
    DBGriddAAOldWindowProc(Msg);
459
  end;
460
end;
461
462
procedure TFormIngredientsList.DBGridAADigNewWindowProc(var Msg: TMessage);
463
begin
464
  if Msg.Msg = WM_MOUSEWHEEL
465
  then // Interception de l'?v?nement WM_MOUSEWHEEL
466
    if SmallInt(Msg.WParamHi) < 0
467
    then
468
      DataModuleDeclaration.ClientDataSetIngredients.Next
469
    else
470
      DataModuleDeclaration.ClientDataSetIngredients.Prior
471
  else // Traitement des autres messages
472
  begin
473
    if Msg.Msg = WM_NCCALCSIZE
474
    then // Forcer l'affichage des ascenseurs
475
      ShowScrollBar(DBGridAADig.Handle, SB_BOTH, True);
476
    DBGridAADigOldWindowProc(Msg);
477
  end;
478
end;
479
480
procedure TFormIngredientsList.DBGridMineralsNewWindowProc(var Msg: TMessage);
481
begin
482
  if Msg.Msg = WM_MOUSEWHEEL
483
  then // Interception de l'?v?nement WM_MOUSEWHEEL
484
    if SmallInt(Msg.WParamHi) < 0
485
    then
486
      DataModuleDeclaration.ClientDataSetIngredients.Next
487
    else
488
      DataModuleDeclaration.ClientDataSetIngredients.Prior
489
  else // Traitement des autres messages
490
  begin
491
    if Msg.Msg = WM_NCCALCSIZE
492
    then // Forcer l'affichage des ascenseurs
493
      ShowScrollBar(DBGridMinerals.Handle, SB_BOTH, True);
494
    DBGridMineralsOldWindowProc(Msg);
495
  end;
496
end;
497
498
procedure TFormIngredientsList.DBGriddPNewWindowProc(var Msg: TMessage);
499
begin
500
  if Msg.Msg = WM_MOUSEWHEEL
501
  then // Interception de l'?v?nement WM_MOUSEWHEEL
502
    if SmallInt(Msg.WParamHi) < 0
503
    then
504
      DataModuleDeclaration.ClientDataSetIngredients.Next
505
    else
506
      DataModuleDeclaration.ClientDataSetIngredients.Prior
507
  else // Traitement des autres messages
508
  begin
509
    if Msg.Msg = WM_NCCALCSIZE
510
    then // Forcer l'affichage des ascenseurs
511
      ShowScrollBar(DBGriddP.Handle, SB_BOTH, True);
512
    DBGriddPOldWindowProc(Msg);
513
  end;
514
end;
515
516
procedure TFormIngredientsList.DBGridTitleClick(Column: TColumn);
517
begin
518
  with DataModuleDeclaration.ClientDataSetIngredients do
519
    if IndexFieldNames = Column.FieldName
520
    then // C'est d?j? l'index => tri selon le nom
521
      IndexFieldNames := 'Name'
522
    else
523
      IndexFieldNames := Column.FieldName;
524
end;
525
526
procedure TFormIngredientsList.EditNameChange(Sender: TObject);
527
begin
528
  if CheckBoxName.Checked
529
  then
530
    CheckBoxFilterClick(nil);
531
end;
532
533
procedure TFormIngredientsList.FormCreate(Sender: TObject);
534
var
535
  ProximalUnit, EnergyUnit, AAUnit, MineralsUnit: String;
536
begin
537
  if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1
538
  then
539
    Font.Name := 'Arial Unicode MS';
540
//  PanelButtons.Font.Size := PanelButtons.Font.Size + 2;
541
  PanelButtons.Font.Style := [fsBold];
542
  LabelWarning.Font.Style := [fsItalic];
543
  LabelFilteredClass.Font.Color := clRed;
544
  LabelFilteredDatabase.Font.Color := clRed;
545
  LabelFilteredName.Font.Color := clRed;
546
  TranslateComponent(Self);
547
  with FormOptions do
548
    if Expression = 0
549
    then // sur frais
550
    begin
551
      ProximalUnit := ComboBoxProximal.Items[Proximal];
552
      EnergyUnit := ComboBoxEnergy.Items[Energy];
553
      AAUnit := ComboBoxAA.Items[AA];
554
      MineralsUnit := ComboBoxMinerals.Items[Minerals];
555
    end
556
    else // sur mati?re s?che
557
    begin
558
      ProximalUnit := Format('%s %s', [ComboBoxProximal.Items[Proximal], _('DM')]);
559
      EnergyUnit := Format('%s %s', [ComboBoxEnergy.Items[Energy], _('DM')]);
560
      AAUnit := Format('%s %s', [ComboBoxAA.Items[AA], _('DM')]);
561
      MineralsUnit := Format('%s %s', [ComboBoxMinerals.Items[Minerals], _('DM')]);
562
    end;
563
  with FormOptions do
564 5 avalancogn
    TabSheetMS.Caption := Format('%s (%s)', [TabSheetMS.Caption, ComboBoxProximal.Items[Proximal]]);
565
  TabSheetProximal.Caption := Format('%s (%s)', [TabSheetProximal.Caption, ProximalUnit]);
566
  TabSheetEnergy.Caption := Format('%s (%s)', [TabSheetEnergy.Caption, EnergyUnit]);
567
  TabSheetEnergyUtilization.Caption := Format('%s (%%)', [TabSheetEnergyUtilization.Caption]);
568
  TabSheetAATot.Caption := Format('%s (%s)', [TabSheetAATot.Caption, AAUnit]);
569
  TabSheetAA_MAT.Caption := Format('%s (%%)', [TabSheetAA_MAT.Caption]);
570
  TabSheetdAA.Caption := Format('%s (%%)', [TabSheetdAA.Caption]);
571
  TabSheetAADig.Caption := Format('%s (%s)', [TabSheetAADig.Caption, AAUnit]);
572
  TabSheetMinerals.Caption := Format('%s (%s)', [TabSheetMinerals.Caption, MineralsUnit]);
573
  TabSheetdP.Caption := Format('%s (%%)', [TabSheetdP.Caption]);
574 6 avalancogn
  if FormOptions.Expression = 0
575
  then // sur frais
576
    TabSheetBE.Caption := Format('%s (%s)', [TabSheetBE.Caption, _('mEq/kg')])
577
  else // sur mati?re s?che
578
    TabSheetBE.Caption := Format('%s (%s %s)', [TabSheetBE.Caption, _('mEq/kg'), _('DM')]);
579 1 avalancogn
  with DataModuleDeclaration do
580
  begin
581
    // Classes
582
    ClientDataSetClasses.First;
583
    while not ClientDataSetClasses.Eof do
584
    begin
585
      ComboBoxClass.Items.Add(ClientDataSetClassesName.Value);
586
      ClientDataSetClasses.Next;
587
    end;
588
  end;
589
  // Sauvegarder la WndProc actuelle du DBGrid
590
  DBGridNameOldWindowProc := DBGridName.WindowProc;
591
  DBGridMSOldWindowProc := DBGridMS.WindowProc;
592
  DBGridProximalOldWindowProc := DBGridProximal.WindowProc;
593
  DBGridRatiosOldWindowProc := DBGridRatios.WindowProc;
594
  DBGridEnergyOldWindowProc := DBGridEnergy.WindowProc;
595
  DBGridAATotOldWindowProc := DBGridAATot.WindowProc;
596
  DBGridAA_MATOldWindowProc := DBGridAA_MAT.WindowProc;
597
  DBGriddAAOldWindowProc := DBGriddAA.WindowProc;
598
  DBGridAADigOldWindowProc := DBGridAADig.WindowProc;
599
  DBGridMineralsOldWindowProc := DBGridMinerals.WindowProc;
600
  DBGriddPOldWindowProc := DBGriddP.WindowProc;
601
  // Affecter une nouvelle proc?dure de fen?tre
602
  DBGridName.WindowProc := DBGridNameNewWindowProc;
603
  DBGridMS.WindowProc := DBGridMSNewWindowProc;
604
  DBGridProximal.WindowProc := DBGridProximalNewWindowProc;
605
  DBGridRatios.WindowProc := DBGridRatiosNewWindowProc;
606
  DBGridEnergy.WindowProc := DBGridEnergyNewWindowProc;
607
  DBGridAATot.WindowProc := DBGridAATotNewWindowProc;
608
  DBGridAA_MAT.WindowProc := DBGridAA_MATNewWindowProc;
609
  DBGriddAA.WindowProc := DBGriddAANewWindowProc;
610
  DBGridAADig.WindowProc := DBGridAADigNewWindowProc;
611
  DBGridMinerals.WindowProc := DBGridMineralsNewWindowProc;
612
  DBGriddP.WindowProc := DBGriddPNewWindowProc;
613
end;
614
615
procedure TFormIngredientsList.FormDestroy(Sender: TObject);
616
begin
617
  with DataModuleDeclaration do
618
  begin
619
    ClientDataSetIngredients.Filtered := False;
620
    FilterOnClass := False;
621
    FilterOnDatabase := False;
622
    FilterOnName := False;
623
  end;
624
end;
625
626
procedure TFormIngredientsList.FormResize(Sender: TObject);
627
begin
628
  // Adaptater la position et la taille de la liste des noms
629
  DBGridName.Top := TabSheetMS.Top;
630
  case PageControlLists.ActivePageIndex of
631
    0: DBGridName.Height := DBGridMS.Height;
632
    1: DBGridName.Height := DBGridProximal.Height;
633
    2: DBGridName.Height := DBGridRatios.Height;
634
    3: DBGridName.Height := DBGridEnergy.Height;
635
    4: DBGridName.Height := DBGridAATot.Height;
636
    5: DBGridName.Height := DBGridAA_MAT.Height;
637
    6: DBGridName.Height := DBGriddAA.Height;
638
    7: DBGridName.Height := DBGridAADig.Height;
639
    8: DBGridName.Height := DBGridMinerals.Height;
640
    9: DBGridName.Height := DBGriddP.Height;
641
  end;
642
end;
643
644
procedure TFormIngredientsList.FormShow(Sender: TObject);
645
begin
646
  with DataModuleDeclaration do
647
    ClientDataSetIngredients.First;
648
  PageControlLists.ActivePageIndex := 0;
649
  PageControlListsChange(nil);
650
end;
651
652
procedure TFormIngredientsList.PageControlListsChange(Sender: TObject);
653
begin
654
  // Activer la liste de l'onglet s?lectionn?
655
  case PageControlLists.ActivePageIndex of
656
    0: ActiveControl := DBGridMS;
657
    1: ActiveControl := DBGridProximal;
658
    2: ActiveControl := DBGridRatios;
659
    3: ActiveControl := DBGridEnergy;
660
    4: ActiveControl := DBGridAATot;
661
    5: ActiveControl := DBGridAA_MAT;
662
    6: ActiveControl := DBGriddAA;
663
    7: ActiveControl := DBGridAADig;
664
    8: ActiveControl := DBGridMinerals;
665
    9: ActiveControl := DBGriddP;
666
  end;
667
  FormResize(nil);
668
end;
669
670
procedure TFormIngredientsList.SplitterListMoved(Sender: TObject);
671
begin
672
  FormResize(nil);
673
end;
674
675
procedure TFormIngredientsList.WMSysCommand(var Message: TWMSysCommand);
676
begin
677
  if Message.CmdType = SC_MINIMIZE
678
  then
679
    Application.Minimize
680
  else
681
    inherited;
682
end;
683
684
end.