Statistiques
| Révision:

root / UnitIngredientEditionCopy.pas @ 15

Historique | Voir | Annoter | Télécharger (92,505 ko)

1
unit UnitIngredientEditionCopy;
2

    
3
interface
4

    
5
uses
6
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7
  Dialogs, StdCtrls, ComCtrls, ExtCtrls, DBCtrls, Mask, ToolWin, ActnList,
8
  ImgList, JvEdit, JvValidateEdit, JvExStdCtrls, JvExMask, JvSpin, JvExControls,
9
  JvEnterTab, gnugettext, JvButton, JvCtrls;
10

    
11
type
12
  TFormIngredientEditionCopy = class(TForm)
13
    ImageListIcons: TImageList;
14
    ActionListButtons: TActionList;
15
    ActionHelp: TAction;
16
    ActionRename: TAction;
17
    ActionComment: TAction;
18
    ActionOK: TAction;
19
    ActionCancel: TAction;
20
    PanelHeader: TPanel;
21
    EnterAsTab: TJvEnterAsTab;
22
    LabelClass: TLabel;
23
    LabelModel: TLabel;
24
    LabelMS: TLabel;
25
    LabelName: TLabel;
26
    DBEditClass: TDBEdit;
27
    DBEditMS: TDBEdit;
28
    DBEditName: TDBEdit;
29
    EditModel: TEdit;
30
    PanelMain: TPanel;
31
    GroupBoxEnergy: TGroupBox;
32
    LabelBonus: TLabel;
33
    SpinEditBonus: TJvSpinEdit;
34
    GroupBoxMinerals: TGroupBox;
35
    LabelCa: TLabel;
36
    LabelP: TLabel;
37
    LabeldP: TLabel;
38
    LabelFarine: TLabel;
39
    LabelGranule: TLabel;
40
    ValidateEditCa: TJvValidateEdit;
41
    ValidateEditP: TJvValidateEdit;
42
    ValidateEditdPphy: TJvValidateEdit;
43
    ValidateEditdP: TJvValidateEdit;
44
    ComboBoxMinerals: TComboBox;
45
    GroupBoxProximal: TGroupBox;
46
    LabelMAT: TLabel;
47
    LabelCB: TLabel;
48
    LabelMG: TLabel;
49
    LabelMM: TLabel;
50
    LabelNDF: TLabel;
51
    LabelADF: TLabel;
52
    LabelADL: TLabel;
53
    LabelAmidon: TLabel;
54
    LabelSucres: TLabel;
55
    ValidateEditMAT: TJvValidateEdit;
56
    ValidateEditCB: TJvValidateEdit;
57
    ValidateEditMG: TJvValidateEdit;
58
    ValidateEditMM: TJvValidateEdit;
59
    ValidateEditNDF: TJvValidateEdit;
60
    ValidateEditADF: TJvValidateEdit;
61
    ValidateEditADL: TJvValidateEdit;
62
    ValidateEditAmidon: TJvValidateEdit;
63
    ValidateEditSucres: TJvValidateEdit;
64
    ComboBoxProximal: TComboBox;
65
    GroupBoxAA: TGroupBox;
66
    LabelLys: TLabel;
67
    LabelTyr: TLabel;
68
    LabelThr: TLabel;
69
    LabelPheTyr: TLabel;
70
    LabelMet: TLabel;
71
    LabelHis: TLabel;
72
    LabelCys: TLabel;
73
    LabelArg: TLabel;
74
    LabelMetCys: TLabel;
75
    LabelAla: TLabel;
76
    LabelTrp: TLabel;
77
    LabelAsp: TLabel;
78
    LabelIle: TLabel;
79
    LabelGlu: TLabel;
80
    LabelVal: TLabel;
81
    LabelGly: TLabel;
82
    LabelLeu: TLabel;
83
    LabelSer: TLabel;
84
    LabelPhe: TLabel;
85
    LabelPro: TLabel;
86
    LabelAATot: TLabel;
87
    ValidateEditLys: TJvValidateEdit;
88
    ValidateEditThr: TJvValidateEdit;
89
    ValidateEditMet: TJvValidateEdit;
90
    ValidateEditCys: TJvValidateEdit;
91
    ValidateEditMetCys: TJvValidateEdit;
92
    ValidateEditTrp: TJvValidateEdit;
93
    ValidateEditIle: TJvValidateEdit;
94
    ValidateEditVal: TJvValidateEdit;
95
    ValidateEditLeu: TJvValidateEdit;
96
    ValidateEditPhe: TJvValidateEdit;
97
    ValidateEditTyr: TJvValidateEdit;
98
    ValidateEditPheTyr: TJvValidateEdit;
99
    ValidateEditHis: TJvValidateEdit;
100
    ValidateEditArg: TJvValidateEdit;
101
    ValidateEditAla: TJvValidateEdit;
102
    ValidateEditAsp: TJvValidateEdit;
103
    ValidateEditGlu: TJvValidateEdit;
104
    ValidateEditGly: TJvValidateEdit;
105
    ValidateEditSer: TJvValidateEdit;
106
    ValidateEditPro: TJvValidateEdit;
107
    ComboBoxAA: TComboBox;
108
    PanelButtons: TPanel;
109
    CheckBoxCa: TCheckBox;
110
    CheckBoxP: TCheckBox;
111
    CheckBoxdPphy: TCheckBox;
112
    CheckBoxdP: TCheckBox;
113
    CheckBoxMAT: TCheckBox;
114
    CheckBoxCB: TCheckBox;
115
    CheckBoxMG: TCheckBox;
116
    CheckBoxMM: TCheckBox;
117
    CheckBoxNDF: TCheckBox;
118
    CheckBoxADF: TCheckBox;
119
    CheckBoxADL: TCheckBox;
120
    CheckBoxAmidon: TCheckBox;
121
    CheckBoxSucres: TCheckBox;
122
    CheckBoxLys: TCheckBox;
123
    CheckBoxThr: TCheckBox;
124
    CheckBoxMet: TCheckBox;
125
    CheckBoxCys: TCheckBox;
126
    CheckBoxMetCys: TCheckBox;
127
    CheckBoxTrp: TCheckBox;
128
    CheckBoxIle: TCheckBox;
129
    CheckBoxVal: TCheckBox;
130
    CheckBoxLeu: TCheckBox;
131
    CheckBoxPhe: TCheckBox;
132
    CheckBoxTyr: TCheckBox;
133
    CheckBoxPheTyr: TCheckBox;
134
    CheckBoxHis: TCheckBox;
135
    CheckBoxArg: TCheckBox;
136
    CheckBoxAla: TCheckBox;
137
    CheckBoxAsp: TCheckBox;
138
    CheckBoxGlu: TCheckBox;
139
    CheckBoxGly: TCheckBox;
140
    CheckBoxSer: TCheckBox;
141
    CheckBoxPro: TCheckBox;
142
    JvImgBtnCancel: TJvImgBtn;
143
    JvImgBtnOK: TJvImgBtn;
144
    JvImgBtnHelp: TJvImgBtn;
145
    JvImgBtnRename: TJvImgBtn;
146
    JvImgBtnComment: TJvImgBtn;
147
    ValidateEditNa: TJvValidateEdit;
148
    CheckBoxCl: TCheckBox;
149
    ValidateEditCl: TJvValidateEdit;
150
    LabelCl: TLabel;
151
    CheckBoxK: TCheckBox;
152
    ValidateEditK: TJvValidateEdit;
153
    LabelK: TLabel;
154
    CheckBoxNa: TCheckBox;
155
    LabelNa: TLabel;
156
    procedure FormCreate(Sender: TObject);
157
    procedure CheckBoxMATClick(Sender: TObject);
158
    procedure CheckBoxCBClick(Sender: TObject);
159
    procedure CheckBoxMGClick(Sender: TObject);
160
    procedure CheckBoxMMClick(Sender: TObject);
161
    procedure CheckBoxNDFClick(Sender: TObject);
162
    procedure CheckBoxADFClick(Sender: TObject);
163
    procedure CheckBoxADLClick(Sender: TObject);
164
    procedure CheckBoxAmidonClick(Sender: TObject);
165
    procedure CheckBoxSucresClick(Sender: TObject);
166
    procedure ComboBoxProximalChange(Sender: TObject);
167
    procedure ValidateEditMATChange(Sender: TObject);
168
    procedure ComboBoxMineralsChange(Sender: TObject);
169
    procedure CheckBoxCaClick(Sender: TObject);
170
    procedure CheckBoxPClick(Sender: TObject);
171
    procedure CheckBoxdPphyClick(Sender: TObject);
172
    procedure CheckBoxdPClick(Sender: TObject);
173
    procedure ValidateEditPChange(Sender: TObject);
174
    procedure CheckBoxLysClick(Sender: TObject);
175
    procedure CheckBoxThrClick(Sender: TObject);
176
    procedure CheckBoxMetClick(Sender: TObject);
177
    procedure CheckBoxCysClick(Sender: TObject);
178
    procedure CheckBoxMetCysClick(Sender: TObject);
179
    procedure CheckBoxTrpClick(Sender: TObject);
180
    procedure CheckBoxIleClick(Sender: TObject);
181
    procedure CheckBoxValClick(Sender: TObject);
182
    procedure CheckBoxLeuClick(Sender: TObject);
183
    procedure CheckBoxPheClick(Sender: TObject);
184
    procedure CheckBoxTyrClick(Sender: TObject);
185
    procedure CheckBoxPheTyrClick(Sender: TObject);
186
    procedure CheckBoxHisClick(Sender: TObject);
187
    procedure CheckBoxArgClick(Sender: TObject);
188
    procedure CheckBoxAlaClick(Sender: TObject);
189
    procedure CheckBoxAspClick(Sender: TObject);
190
    procedure CheckBoxGluClick(Sender: TObject);
191
    procedure CheckBoxGlyClick(Sender: TObject);
192
    procedure CheckBoxSerClick(Sender: TObject);
193
    procedure CheckBoxProClick(Sender: TObject);
194
    procedure ComboBoxAAChange(Sender: TObject);
195
    procedure ButtonRenameClick(Sender: TObject);
196
    procedure ButtonCommentClick(Sender: TObject);
197
    procedure ButtonHelpClick(Sender: TObject);
198
    procedure ActionRenameExecute(Sender: TObject);
199
    procedure ActionCommentExecute(Sender: TObject);
200
    procedure ActionHelpExecute(Sender: TObject);
201
    procedure ActionOKExecute(Sender: TObject);
202
    procedure ActionCancelExecute(Sender: TObject);
203
    procedure NumEditKeyDown(Sender: TObject; var Key: Word;
204
      Shift: TShiftState);
205
    procedure NumEditKeyPress(Sender: TObject; var Key: Char);
206
    procedure CheckBoxNaClick(Sender: TObject);
207
    procedure CheckBoxKClick(Sender: TObject);
208
    procedure CheckBoxClClick(Sender: TObject);
209
  private
210
    { D?clarations priv?es }
211
    ProximalUnit, MineralsUnit, AAUnit: Integer;
212
    procedure EditActivate(Edit: TJvValidateEdit);
213
    procedure EditEmpty(Edit: TJvValidateEdit);
214
    procedure EditShow(Edit: TJvValidateEdit; const Value: Double);
215
    procedure DisableAA;
216
    procedure DisabledP;
217
    procedure EnableAA;
218
    procedure EnabledP;
219
  public
220
    { D?clarations publiques }
221
  end;
222

    
223
var
224
  FormIngredientEditionCopy: TFormIngredientEditionCopy;
225

    
226
implementation
227

    
228
{$R *.dfm}
229

    
230
uses
231
  UnitDeclaration, UnitOptions, UnitRename, UnitComment, UnitIngredientsList;
232

    
233
var
234
  VK_Separator: boolean;
235

    
236
procedure TFormIngredientEditionCopy.ActionCancelExecute(Sender: TObject);
237
begin
238
  ModalResult := mrCancel;
239
end;
240

    
241
procedure TFormIngredientEditionCopy.ActionCommentExecute(Sender: TObject);
242
begin
243
  FormComment := TFormComment.Create(nil);
244
  try
245
//    FormComment.Caption := ButtonComment.Hint;
246
    FormComment.Name := DataModuleDeclaration.ClientDataSetIngredientsName.Value;
247
    FormComment.OldComment := DataModuleDeclaration.ClientDataSetIngredientsDefinition.Value;
248
    if (FormComment.ShowModal = mrOk) and (FormComment.NewComment <> FormComment.OldComment)
249
    then // Commenter
250
      with DataModuleDeclaration do
251
      begin
252
        DBUser.BeginTransaction;
253
        try
254
          DBUser.ExecSQL('UPDATE Ingredients '
255
            + Format('SET Definition = %s ', [QuotedStr(FormComment.NewComment)])
256
            + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
257
          DBUser.Commit;
258
        except
259
          DBUser.RollBack;
260
          MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitIngredientEditionCopy', 'ActionCommentExecute', 'DBUser (UPDATE Ingredients)']), mtError, [mbOK], 0);
261
          Exit;
262
        end;
263
        // Commenter dans ClientDataSetIngredients
264
        ClientDataSetIngredients.Edit;
265
        ClientDataSetIngredientsDefinition.Value := FormComment.NewComment;
266
        ClientDataSetIngredients.Post;
267
      end;
268
  finally
269
    FormComment.Release;
270
  end;
271
end;
272

    
273
procedure TFormIngredientEditionCopy.ActionHelpExecute(Sender: TObject);
274
begin
275
  Application.HelpContext(HelpContext);
276
end;
277

    
278
procedure TFormIngredientEditionCopy.ActionOKExecute(Sender: TObject);
279
var
280
  Nb: Integer;
281
  MM, MAT, MG, Fibre, Amidon, Sucres, CB, NDF, ADF, CoefNDF_CB, CoefNDF_ADF, AASum: Double;
282
  USFormatSettings: TFormatSettings;
283
begin
284
  with DataModuleDeclaration do
285
  begin
286
    // V?rifier la saisie
287
    if CheckBoxMM.Checked
288
    then
289
      MM := InputProximal(ValidateEditMM.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)
290
    else
291
      MM := ClientDataSetInraAfzMM.Value;
292
    if CheckBoxMAT.Checked
293
    then
294
      MAT := InputProximal(ValidateEditMAT.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)
295
    else
296
      MAT := ClientDataSetInraAfzMAT.Value;
297
    if CheckBoxMG.Checked
298
    then
299
      MG := InputProximal(ValidateEditMG.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)
300
    else
301
      MG := ClientDataSetInraAfzMG.Value;
302
    Nb := 0;
303
    if CheckBoxCB.Checked
304
    then
305
    begin
306
      CB := InputProximal(ValidateEditCB.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2);
307
      Inc(Nb);
308
    end
309
    else
310
      CB := 0;
311
    if CheckBoxNDF.Checked
312
    then
313
    begin
314
      NDF := InputProximal(ValidateEditNDF.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2);
315
      Inc(Nb);
316
    end
317
    else
318
      NDF := 0;
319
    if CheckBoxADF.Checked
320
    then
321
    begin
322
      ADF := InputProximal(ValidateEditADF.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2);
323
      Inc(Nb);
324
    end
325
    else
326
      ADF := 0;
327
    if Nb = 0
328
    then
329
      Fibre := ClientDataSetInraAfzNDF.Value
330
    else // Moyenne des ?quations significatives
331
    begin
332
      if (ClientDataSetInraAfzNDF.Value = 0) or (ClientDataSetInraAfzCB.Value = 0)
333
      then // Utiliser le coefficient g?n?rique
334
        CoefNDF_CB := NDF_CB
335
      else
336
        CoefNDF_CB := ClientDataSetInraAfzNDF.Value / ClientDataSetInraAfzCB.Value;
337
      if (ClientDataSetInraAfzNDF.Value = 0) or (ClientDataSetInraAfzADF.Value = 0)
338
      then // Utiliser le coefficient g?n?rique
339
        CoefNDF_ADF := NDF_ADF
340
      else
341
        CoefNDF_ADF := ClientDataSetInraAfzNDF.Value / ClientDataSetInraAfzADF.Value;
342
      Fibre := (CB * CoefNDF_CB + NDF + ADF * CoefNDF_ADF) / Nb;
343
    end;
344
    if CheckBoxAmidon.Checked
345
    then
346
      Amidon := InputProximal(ValidateEditAmidon.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)
347
    else
348
      Amidon := ClientDataSetInraAfzAmidon.Value;
349
    if CheckBoxSucres.Checked
350
    then
351
      Sucres := InputProximal(ValidateEditSucres.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)
352
    else
353
      Sucres := ClientDataSetInraAfzSucres.Value;
354
    if MM + MAT + MG + Fibre + Amidon + Sucres > MAX_SUM
355
    then
356
      if MessageDlg(_('The sum of nutrients is estimated to more than 100% of the dry matter.' + sLineBreak + 'Are you sure you want to continue?'), mtError, [mbYes, mbNo], 0) <> mrYes
357
      then
358
        Exit;
359
    AASum := 0;
360
    if CheckBoxLys.Checked
361
    then
362
      AASum := AASum + InputAA(ValidateEditLys.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
363
    else
364
      AASum := AASum + ClientDataSetInraAfzLys.Value;
365
    if CheckBoxThr.Checked
366
    then
367
      AASum := AASum + InputAA(ValidateEditThr.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
368
    else
369
      AASum := AASum + ClientDataSetInraAfzThr.Value;
370
    if CheckBoxMet.Checked
371
    then
372
      AASum := AASum + InputAA(ValidateEditMet.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
373
    else
374
      AASum := AASum + ClientDataSetInraAfzMet.Value;
375
    if CheckBoxCys.Checked
376
    then
377
      AASum := AASum + InputAA(ValidateEditCys.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
378
    else
379
      AASum := AASum + ClientDataSetInraAfzCys.Value;
380
    if CheckBoxTrp.Checked
381
    then
382
      AASum := AASum + InputAA(ValidateEditTrp.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
383
    else
384
      AASum := AASum + ClientDataSetInraAfzTrp.Value;
385
    if CheckBoxIle.Checked
386
    then
387
      AASum := AASum + InputAA(ValidateEditIle.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
388
    else
389
      AASum := AASum + ClientDataSetInraAfzIle.Value;
390
    if CheckBoxVal.Checked
391
    then
392
      AASum := AASum + InputAA(ValidateEditVal.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
393
    else
394
      AASum := AASum + ClientDataSetInraAfzVal.Value;
395
    if CheckBoxLeu.Checked
396
    then
397
      AASum := AASum + InputAA(ValidateEditLeu.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
398
    else
399
      AASum := AASum + ClientDataSetInraAfzLeu.Value;
400
    if CheckBoxPhe.Checked
401
    then
402
      AASum := AASum + InputAA(ValidateEditPhe.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
403
    else
404
      AASum := AASum + ClientDataSetInraAfzPhe.Value;
405
    if CheckBoxTyr.Checked
406
    then
407
      AASum := AASum + InputAA(ValidateEditTyr.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
408
    else
409
      AASum := AASum + ClientDataSetInraAfzTyr.Value;
410
    if CheckBoxHis.Checked
411
    then
412
      AASum := AASum + InputAA(ValidateEditHis.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
413
    else
414
      AASum := AASum + ClientDataSetInraAfzHis.Value;
415
    if CheckBoxArg.Checked
416
    then
417
      AASum := AASum + InputAA(ValidateEditArg.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
418
    else
419
      AASum := AASum + ClientDataSetInraAfzArg.Value;
420
    if CheckBoxAla.Checked
421
    then
422
      AASum := AASum + InputAA(ValidateEditAla.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
423
    else
424
      AASum := AASum + ClientDataSetInraAfzAla.Value;
425
    if CheckBoxAsp.Checked
426
    then
427
      AASum := AASum + InputAA(ValidateEditAsp.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
428
    else
429
      AASum := AASum + ClientDataSetInraAfzAsp.Value;
430
    if CheckBoxGlu.Checked
431
    then
432
      AASum := AASum + InputAA(ValidateEditGlu.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
433
    else
434
      AASum := AASum + ClientDataSetInraAfzGlu.Value;
435
    if CheckBoxGly.Checked
436
    then
437
      AASum := AASum + InputAA(ValidateEditGly.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
438
    else
439
      AASum := AASum + ClientDataSetInraAfzGly.Value;
440
    if CheckBoxSer.Checked
441
    then
442
      AASum := AASum + InputAA(ValidateEditSer.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
443
    else
444
      AASum := AASum + ClientDataSetInraAfzSer.Value;
445
    if CheckBoxPro.Checked
446
    then
447
      AASum := AASum + InputAA(ValidateEditPro.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2)
448
    else
449
      AASum := AASum + ClientDataSetInraAfzPro.Value;
450
    if AASum > 1.1
451
    then
452
      if MessageDlg(_('The sum of total amino acids is more than the crude protein.' + sLineBreak + 'Are you sure you want to continue?'), mtError, [mbYes, mbNo], 0) <> mrYes
453
      then
454
      begin
455
//        Action := caNone;
456
        Exit;
457
      end;
458
    // Modifier la mati?re premi?re
459
    GetLocaleFormatSettings(1033, USFormatSettings);
460
    DBUser.BeginTransaction;
461
    try
462
      // Analyse proximale
463
      if CheckBoxMM.Checked
464
      then
465
        DBUser.ExecSQL('UPDATE Ingredients '
466
          + Format('SET MM = %.15f ', [InputProximal(ValidateEditMM.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
467
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
468
      else
469
        DBUser.ExecSQL('UPDATE Ingredients '
470
          + 'SET MM = null '
471
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
472
      if CheckBoxMAT.Checked
473
      then
474
        DBUser.ExecSQL('UPDATE Ingredients '
475
          + Format('SET MAT = %.15f ', [InputProximal(ValidateEditMAT.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
476
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
477
      else
478
        DBUser.ExecSQL('UPDATE Ingredients '
479
          + 'SET MAT = null '
480
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
481
      if CheckBoxMG.Checked
482
      then
483
        DBUser.ExecSQL('UPDATE Ingredients '
484
          + Format('SET MG = %.15f ', [InputProximal(ValidateEditMG.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
485
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
486
      else
487
        DBUser.ExecSQL('UPDATE Ingredients '
488
          + 'SET MG = null '
489
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
490
      if CheckBoxCB.Checked
491
      then
492
        DBUser.ExecSQL('UPDATE Ingredients '
493
          + Format('SET CB = %.15f ', [InputProximal(ValidateEditCB.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
494
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
495
      else
496
        DBUser.ExecSQL('UPDATE Ingredients '
497
          + 'SET CB = null '
498
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
499
      if CheckBoxNDF.Checked
500
      then
501
        DBUser.ExecSQL('UPDATE Ingredients '
502
          + Format('SET NDF = %.15f ', [InputProximal(ValidateEditNDF.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
503
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
504
      else
505
        DBUser.ExecSQL('UPDATE Ingredients '
506
          + 'SET NDF = null '
507
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
508
      if CheckBoxADF.Checked
509
      then
510
        DBUser.ExecSQL('UPDATE Ingredients '
511
          + Format('SET ADF = %.15f ', [InputProximal(ValidateEditADF.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
512
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
513
      else
514
        DBUser.ExecSQL('UPDATE Ingredients '
515
          + 'SET ADF = null '
516
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
517
      if CheckBoxADL.Checked
518
      then
519
        DBUser.ExecSQL('UPDATE Ingredients '
520
          + Format('SET ADL = %.15f ', [InputProximal(ValidateEditADL.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
521
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
522
      else
523
        DBUser.ExecSQL('UPDATE Ingredients '
524
          + 'SET ADL = null '
525
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
526
      if CheckBoxAmidon.Checked
527
      then
528
        DBUser.ExecSQL('UPDATE Ingredients '
529
          + Format('SET Amidon = %.15f ', [InputProximal(ValidateEditAmidon.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
530
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
531
      else
532
        DBUser.ExecSQL('UPDATE Ingredients '
533
          + 'SET Amidon = null '
534
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
535
      if CheckBoxSucres.Checked
536
      then
537
        DBUser.ExecSQL('UPDATE Ingredients '
538
          + Format('SET Sucres = %.15f ', [InputProximal(ValidateEditSucres.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
539
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
540
      else
541
        DBUser.ExecSQL('UPDATE Ingredients '
542
          + 'SET Sucres = null '
543
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
544
      // Energie
545
      DBUser.ExecSQL('UPDATE Ingredients '
546
        + Format('SET Bonus = %.15f ', [SpinEditBonus.Value / 100], USFormatSettings)
547
        + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
548
      // Acides amin?s
549
      if CheckBoxLys.Checked
550
      then
551
        DBUser.ExecSQL('UPDATE Ingredients '
552
          + Format('SET Lys = %.15f ', [InputAA(ValidateEditLys.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
553
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
554
      else
555
        DBUser.ExecSQL('UPDATE Ingredients '
556
          + 'SET Lys = null '
557
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
558
      if CheckBoxThr.Checked
559
      then
560
        DBUser.ExecSQL('UPDATE Ingredients '
561
          + Format('SET Thr = %.15f ', [InputAA(ValidateEditThr.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
562
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
563
      else
564
        DBUser.ExecSQL('UPDATE Ingredients '
565
          + 'SET Thr = null '
566
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
567
      if CheckBoxMet.Checked
568
      then
569
        DBUser.ExecSQL('UPDATE Ingredients '
570
          + Format('SET Met = %.15f ', [InputAA(ValidateEditMet.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
571
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
572
      else
573
        DBUser.ExecSQL('UPDATE Ingredients '
574
          + 'SET Met = null '
575
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
576
      if CheckBoxCys.Checked
577
      then
578
        DBUser.ExecSQL('UPDATE Ingredients '
579
          + Format('SET Cys = %.15f ', [InputAA(ValidateEditCys.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
580
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
581
      else
582
        DBUser.ExecSQL('UPDATE Ingredients '
583
          + 'SET Cys = null '
584
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
585
      if CheckBoxMetCys.Checked
586
      then
587
        DBUser.ExecSQL('UPDATE Ingredients '
588
          + Format('SET MetCys = %.15f ', [InputAA(ValidateEditMetCys.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
589
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
590
      else
591
        DBUser.ExecSQL('UPDATE Ingredients '
592
          + 'SET MetCys = null '
593
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
594
      if CheckBoxTrp.Checked
595
      then
596
        DBUser.ExecSQL('UPDATE Ingredients '
597
          + Format('SET Trp = %.15f ', [InputAA(ValidateEditTrp.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
598
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
599
      else
600
        DBUser.ExecSQL('UPDATE Ingredients '
601
          + 'SET Trp = null '
602
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
603
      if CheckBoxIle.Checked
604
      then
605
        DBUser.ExecSQL('UPDATE Ingredients '
606
          + Format('SET Ile = %.15f ', [InputAA(ValidateEditIle.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
607
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
608
      else
609
        DBUser.ExecSQL('UPDATE Ingredients '
610
          + 'SET Ile = null '
611
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
612
      if CheckBoxVal.Checked
613
      then
614
        DBUser.ExecSQL('UPDATE Ingredients '
615
          + Format('SET Val = %.15f ', [InputAA(ValidateEditVal.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
616
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
617
      else
618
        DBUser.ExecSQL('UPDATE Ingredients '
619
          + 'SET Val = null '
620
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
621
      if CheckBoxLeu.Checked
622
      then
623
        DBUser.ExecSQL('UPDATE Ingredients '
624
          + Format('SET Leu = %.15f ', [InputAA(ValidateEditLeu.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
625
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
626
      else
627
        DBUser.ExecSQL('UPDATE Ingredients '
628
          + 'SET Leu = null '
629
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
630
      if CheckBoxPhe.Checked
631
      then
632
        DBUser.ExecSQL('UPDATE Ingredients '
633
          + Format('SET Phe = %.15f ', [InputAA(ValidateEditPhe.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
634
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
635
      else
636
        DBUser.ExecSQL('UPDATE Ingredients '
637
          + 'SET Phe = null '
638
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
639
      if CheckBoxTyr.Checked
640
      then
641
        DBUser.ExecSQL('UPDATE Ingredients '
642
          + Format('SET Tyr = %.15f ', [InputAA(ValidateEditTyr.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
643
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
644
      else
645
        DBUser.ExecSQL('UPDATE Ingredients '
646
          + 'SET Tyr = null '
647
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
648
      if CheckBoxPheTyr.Checked
649
      then
650
        DBUser.ExecSQL('UPDATE Ingredients '
651
          + Format('SET PheTyr = %.15f ', [InputAA(ValidateEditPheTyr.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
652
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
653
      else
654
        DBUser.ExecSQL('UPDATE Ingredients '
655
          + 'SET PheTyr = null '
656
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
657
      if CheckBoxHis.Checked
658
      then
659
        DBUser.ExecSQL('UPDATE Ingredients '
660
          + Format('SET His = %.15f ', [InputAA(ValidateEditHis.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
661
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
662
      else
663
        DBUser.ExecSQL('UPDATE Ingredients '
664
          + 'SET His = null '
665
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
666
      if CheckBoxArg.Checked
667
      then
668
        DBUser.ExecSQL('UPDATE Ingredients '
669
          + Format('SET Arg = %.15f ', [InputAA(ValidateEditArg.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
670
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
671
      else
672
        DBUser.ExecSQL('UPDATE Ingredients '
673
          + 'SET Arg = null '
674
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
675
      if CheckBoxAla.Checked
676
      then
677
        DBUser.ExecSQL('UPDATE Ingredients '
678
          + Format('SET Ala = %.15f ', [InputAA(ValidateEditAla.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
679
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
680
      else
681
        DBUser.ExecSQL('UPDATE Ingredients '
682
          + 'SET Ala = null '
683
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
684
      if CheckBoxAsp.Checked
685
      then
686
        DBUser.ExecSQL('UPDATE Ingredients '
687
          + Format('SET Asp = %.15f ', [InputAA(ValidateEditAsp.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
688
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
689
      else
690
        DBUser.ExecSQL('UPDATE Ingredients '
691
          + 'SET Asp = null '
692
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
693
      if CheckBoxGlu.Checked
694
      then
695
        DBUser.ExecSQL('UPDATE Ingredients '
696
          + Format('SET Glu = %.15f ', [InputAA(ValidateEditGlu.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
697
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
698
      else
699
        DBUser.ExecSQL('UPDATE Ingredients '
700
          + 'SET Glu = null '
701
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
702
      if CheckBoxGly.Checked
703
      then
704
        DBUser.ExecSQL('UPDATE Ingredients '
705
          + Format('SET Gly = %.15f ', [InputAA(ValidateEditGly.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
706
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
707
      else
708
        DBUser.ExecSQL('UPDATE Ingredients '
709
          + 'SET Gly = null '
710
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
711
      if CheckBoxSer.Checked
712
      then
713
        DBUser.ExecSQL('UPDATE Ingredients '
714
          + Format('SET Ser = %.15f ', [InputAA(ValidateEditSer.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
715
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
716
      else
717
        DBUser.ExecSQL('UPDATE Ingredients '
718
          + 'SET Ser = null '
719
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
720
      if CheckBoxPro.Checked
721
      then
722
        DBUser.ExecSQL('UPDATE Ingredients '
723
          + Format('SET Pro = %.15f ', [InputAA(ValidateEditPro.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
724
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
725
      else
726
        DBUser.ExecSQL('UPDATE Ingredients '
727
          + 'SET Pro = null '
728
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
729
      // Min?raux
730
      if CheckBoxCa.Checked
731
      then
732
        DBUser.ExecSQL('UPDATE Ingredients '
733
          + Format('SET Ca = %.15f ', [InputMinerals(ValidateEditCa.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2)], USFormatSettings)
734
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
735
      else
736
        DBUser.ExecSQL('UPDATE Ingredients '
737
          + 'SET Ca = null '
738
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
739
      if CheckBoxP.Checked
740
      then
741
        DBUser.ExecSQL('UPDATE Ingredients '
742
          + Format('SET P = %.15f ', [InputMinerals(ValidateEditP.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2)], USFormatSettings)
743
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
744
      else
745
        DBUser.ExecSQL('UPDATE Ingredients '
746
          + 'SET P = null '
747
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
748
      // TODO: Na, K and Cl
749
      if CheckBoxdP.Checked
750
      then
751
        DBUser.ExecSQL('UPDATE Ingredients '
752
          + Format('SET dP = %.15f ', [ValidateEditdP.AsFloat / 100], USFormatSettings)
753
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
754
      else
755
        DBUser.ExecSQL('UPDATE Ingredients '
756
          + 'SET dP = null '
757
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
758
      if CheckBoxdPphy.Checked
759
      then
760
        DBUser.ExecSQL('UPDATE Ingredients '
761
          + Format('SET dPphy = %.15f ', [ValidateEditdPphy.AsFloat / 100], USFormatSettings)
762
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
763
      else
764
        DBUser.ExecSQL('UPDATE Ingredients '
765
          + 'SET dPphy = null '
766
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
767
      DBUser.Commit;
768
    except
769
      DBUser.RollBack;
770
      MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitIngredientEditionCopy', 'ActionOKExecute', 'DBUser (UPDATE Ingredients)']), mtError, [mbOK], 0);
771
      Exit;
772
    end;
773
    // Calculer les valeurs de ClientDataSetIngredients
774
    Application.ProcessMessages;
775
    TableIngredients := DBUser.GetTable('SELECT * FROM Ingredients '
776
      + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
777
    ClientDataSetIngredients.Edit;
778
    try
779
      CalcCopy;
780
      ClientDataSetIngredients.Post;
781
    except
782
      ClientDataSetIngredients.Cancel;
783
      MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitIngredientEditionCopy', 'ActionOKExecute', 'ClientDataSetIngredients']), mtError, [mbOK], 0);
784
      Exit;
785
    end;
786
    TableIngredients.Free;
787
  end;
788
  ModalResult := mrOk;
789
end;
790

    
791
procedure TFormIngredientEditionCopy.ActionRenameExecute(Sender: TObject);
792
begin
793
  FormRename := TFormRename.Create(nil);
794
  try
795
    FormIngredientsList.CheckBoxName.Checked := False; // D?sactiver le filtre sur le nom
796
//    FormRename.Caption := ButtonRename.Hint;
797
    FormRename.OldName := DataModuleDeclaration.ClientDataSetIngredientsName.Value;
798
    FormRename.NameList.Assign(DataModuleDeclaration.UserList);
799
    if (FormRename.ShowModal = mrOk) and (FormRename.NewName <> FormRename.OldName)
800
    then // Renommer
801
      with DataModuleDeclaration do
802
      begin
803
        DBUser.BeginTransaction;
804
        try
805
          DBUser.ExecSQL('UPDATE Ingredients '
806
            + Format('SET Name = %s ', [QuotedStr(FormRename.NewName)])
807
            + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
808
          DBUser.Commit;
809
        except
810
          DBUser.RollBack;
811
          MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitIngredientEditionCopy', 'ActionRenameExecute', 'DBUser (UPDATE Ingredients)']), mtError, [mbOK], 0);
812
          Exit;
813
        end;
814
        // Renommer dans ClientDataSetIngredients
815
        ClientDataSetIngredients.Edit;
816
        ClientDataSetIngredientsName.Value := FormRename.NewName;
817
        ClientDataSetIngredients.Post;
818
        // Modifier le nom dans la liste des mati?res premi?res utilisateur
819
        UserList[UserList.IndexOf(FormRename.OldName)] := FormRename.NewName;
820
        // R?percuter le changement dans ClientDataSetComposition
821
        ClientDataSetComposition.Filter := Format('Ingredient = %d and User', [ClientDataSetIngredientsId.Value]);
822
        ClientDataSetComposition.Filtered := True;
823
        try
824
          ClientDataSetComposition.First;
825
          while not ClientDataSetComposition.Eof do
826
          begin
827
            ClientDataSetComposition.Edit;
828
            try
829
              ClientDataSetCompositionIngredientName.Value := FormRename.NewName;
830
              ClientDataSetComposition.Post;
831
            except
832
              ClientDataSetComposition.Cancel;
833
            end;
834
            ClientDataSetComposition.Next;
835
          end;
836
        finally
837
          ClientDataSetComposition.Filtered := False;
838
          ClientDataSetComposition.Filter := '';
839
        end;
840
      end;
841
  finally
842
    FormRename.Release;
843
  end;
844
end;
845

    
846
procedure TFormIngredientEditionCopy.ButtonCommentClick(Sender: TObject);
847
begin
848
  ActionCommentExecute(Sender);
849
end;
850

    
851
procedure TFormIngredientEditionCopy.ButtonHelpClick(Sender: TObject);
852
begin
853
  ActionHelpExecute(Sender);
854
end;
855

    
856
procedure TFormIngredientEditionCopy.ButtonRenameClick(Sender: TObject);
857
begin
858
  ActionRenameExecute(Sender);
859
end;
860

    
861
procedure TFormIngredientEditionCopy.CheckBoxADFClick(Sender: TObject);
862
begin
863
  if CheckBoxADF.Checked
864
  then // Activer la saisie
865
    EditActivate(ValidateEditADF)
866
  else // Afficher la valeur par d?faut
867
    with DataModuleDeclaration do
868
      if ClientDataSetInraAfzADF.IsNull
869
      then // Null
870
        EditEmpty(ValidateEditADF)
871
      else // Valeur du mod?le
872
        EditShow(ValidateEditADF, OutputProximal(ClientDataSetInraAfzADF.Value, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
873
end;
874

    
875
procedure TFormIngredientEditionCopy.CheckBoxADLClick(Sender: TObject);
876
begin
877
  if CheckBoxADL.Checked
878
  then // Activer la saisie
879
    EditActivate(ValidateEditADL)
880
  else // Afficher la valeur par d?faut
881
    with DataModuleDeclaration do
882
      if ClientDataSetInraAfzADL.IsNull
883
      then // Null
884
        EditEmpty(ValidateEditADL)
885
      else // Valeur du mod?le
886
        EditShow(ValidateEditADL, OutputProximal(ClientDataSetInraAfzADL.Value, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
887
end;
888

    
889
procedure TFormIngredientEditionCopy.CheckBoxAlaClick(Sender: TObject);
890
begin
891
  if CheckBoxAla.Checked
892
  then // Activer la saisie
893
    EditActivate(ValidateEditAla)
894
  else // Afficher la valeur par d?faut
895
    with DataModuleDeclaration do
896
      if ClientDataSetInraAfzAla.IsNull or (RapMAT = 0)
897
      then // Null
898
        EditEmpty(ValidateEditAla)
899
      else // Valeur du mod?le
900
        EditShow(ValidateEditAla, OutputAA(ClientDataSetInraAfzAla.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
901
end;
902

    
903
procedure TFormIngredientEditionCopy.CheckBoxAmidonClick(Sender: TObject);
904
begin
905
  if CheckBoxAmidon.Checked
906
  then // Activer la saisie
907
    EditActivate(ValidateEditAmidon)
908
  else // Afficher la valeur par d?faut
909
    with DataModuleDeclaration do
910
      if ClientDataSetInraAfzAmidon.IsNull
911
      then // Null
912
        EditEmpty(ValidateEditAmidon)
913
      else // Valeur du mod?le
914
        EditShow(ValidateEditAmidon, OutputProximal(ClientDataSetInraAfzAmidon.Value, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
915
end;
916

    
917
procedure TFormIngredientEditionCopy.CheckBoxArgClick(Sender: TObject);
918
begin
919
  if CheckBoxArg.Checked
920
  then // Activer la saisie
921
    EditActivate(ValidateEditArg)
922
  else // Afficher la valeur par d?faut
923
    with DataModuleDeclaration do
924
      if ClientDataSetInraAfzArg.IsNull or (RapMAT = 0)
925
      then // Null
926
        EditEmpty(ValidateEditArg)
927
      else // Valeur du mod?le
928
        EditShow(ValidateEditArg, OutputAA(ClientDataSetInraAfzArg.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
929
end;
930

    
931
procedure TFormIngredientEditionCopy.CheckBoxAspClick(Sender: TObject);
932
begin
933
  if CheckBoxAsp.Checked
934
  then // Activer la saisie
935
    EditActivate(ValidateEditAsp)
936
  else // Afficher la valeur par d?faut
937
    with DataModuleDeclaration do
938
      if ClientDataSetInraAfzAsp.IsNull or (RapMAT = 0)
939
      then // Null
940
        EditEmpty(ValidateEditAsp)
941
      else // Valeur du mod?le
942
        EditShow(ValidateEditAsp, OutputAA(ClientDataSetInraAfzAsp.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
943
end;
944

    
945
procedure TFormIngredientEditionCopy.CheckBoxCaClick(Sender: TObject);
946
begin
947
  if CheckBoxCa.Checked
948
  then // Activer la saisie
949
    EditActivate(ValidateEditCa)
950
  else // Afficher la valeur par d?faut
951
    with DataModuleDeclaration do
952
      if ClientDataSetInraAfzCa.IsNull
953
      then // Null
954
        EditEmpty(ValidateEditCa)
955
      else // Valeur du mod?le
956
        EditShow(ValidateEditCa, OutputMinerals(ClientDataSetInraAfzCa.Value, RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2));
957
end;
958

    
959
procedure TFormIngredientEditionCopy.CheckBoxCBClick(Sender: TObject);
960
begin
961
  if CheckBoxCB.Checked
962
  then // Activer la saisie
963
    EditActivate(ValidateEditCB)
964
  else // Afficher la valeur par d?faut
965
    with DataModuleDeclaration do
966
      if ClientDataSetInraAfzCB.IsNull
967
      then // Null
968
        EditEmpty(ValidateEditCB)
969
      else // Valeur du mod?le
970
        EditShow(ValidateEditCB, OutputProximal(ClientDataSetInraAfzCB.Value, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
971
end;
972

    
973
procedure TFormIngredientEditionCopy.CheckBoxClClick(Sender: TObject);
974
begin
975
  if CheckBoxCl.Checked
976
  then // Activer la saisie
977
    EditActivate(ValidateEditCl)
978
  else // Afficher la valeur par d?faut
979
    with DataModuleDeclaration do
980
      if ClientDataSetInraAfzCl.IsNull
981
      then // Null
982
        EditEmpty(ValidateEditCl)
983
      else // Valeur du mod?le
984
        EditShow(ValidateEditCl, OutputMinerals(ClientDataSetInraAfzCl.Value, RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2));
985
end;
986

    
987
procedure TFormIngredientEditionCopy.CheckBoxCysClick(Sender: TObject);
988
begin
989
  if CheckBoxCys.Checked
990
  then // Activer la saisie
991
    EditActivate(ValidateEditCys)
992
  else // Afficher la valeur par d?faut
993
    with DataModuleDeclaration do
994
      if ClientDataSetInraAfzCys.IsNull or (RapMAT = 0)
995
      then // Null
996
        EditEmpty(ValidateEditCys)
997
      else // Valeur du mod?le
998
        EditShow(ValidateEditCys, OutputAA(ClientDataSetInraAfzCys.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
999
end;
1000

    
1001
procedure TFormIngredientEditionCopy.CheckBoxdPClick(Sender: TObject);
1002
begin
1003
  if CheckBoxdP.Checked
1004
  then // Activer la saisie
1005
    EditActivate(ValidateEditdP)
1006
  else // Afficher la valeur par d?faut
1007
    if ValidateEditP.AsFloat = 0
1008
    then // Null
1009
      EditEmpty(ValidateEditdP)
1010
    else // Valeur du mod?le
1011
      with DataModuleDeclaration do
1012
        if ClientDataSetInraAfzdP.IsNull
1013
        then // Par d?faut dP = 20%
1014
          EditShow(ValidateEditdP, 20)
1015
        else // Valeur du mod?le
1016
          EditShow(ValidateEditdP, ClientDataSetInraAfzdP.Value * 100);
1017
end;
1018

    
1019
procedure TFormIngredientEditionCopy.CheckBoxdPphyClick(Sender: TObject);
1020
begin
1021
  if CheckBoxdPphy.Checked
1022
  then // Activer la saisie
1023
    EditActivate(ValidateEditdPphy)
1024
  else // Afficher la valeur par d?faut
1025
    if ValidateEditP.AsFloat = 0
1026
    then // Null
1027
      EditEmpty(ValidateEditdPphy)
1028
    else // Valeur du mod?le
1029
      with DataModuleDeclaration do
1030
        if ClientDataSetInraAfzdPphy.IsNull
1031
        then // Par d?faut dPphy = dP
1032
          EditShow(ValidateEditdPphy, ValidateEditdP.AsFloat)
1033
        else // Valeur du mod?le
1034
          EditShow(ValidateEditdPphy, ClientDataSetInraAfzdPphy.Value * 100);
1035
end;
1036

    
1037
procedure TFormIngredientEditionCopy.CheckBoxGluClick(Sender: TObject);
1038
begin
1039
  if CheckBoxGlu.Checked
1040
  then // Activer la saisie
1041
    EditActivate(ValidateEditGlu)
1042
  else // Afficher la valeur par d?faut
1043
    with DataModuleDeclaration do
1044
      if ClientDataSetInraAfzGlu.IsNull or (RapMAT = 0)
1045
      then // Null
1046
        EditEmpty(ValidateEditGlu)
1047
      else // Valeur du mod?le
1048
        EditShow(ValidateEditGlu, OutputAA(ClientDataSetInraAfzGlu.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1049
end;
1050

    
1051
procedure TFormIngredientEditionCopy.CheckBoxGlyClick(Sender: TObject);
1052
begin
1053
  if CheckBoxGly.Checked
1054
  then // Activer la saisie
1055
    EditActivate(ValidateEditGly)
1056
  else // Afficher la valeur par d?faut
1057
    with DataModuleDeclaration do
1058
      if ClientDataSetInraAfzGly.IsNull or (RapMAT = 0)
1059
      then // Null
1060
        EditEmpty(ValidateEditGly)
1061
      else // Valeur du mod?le
1062
        EditShow(ValidateEditGly, OutputAA(ClientDataSetInraAfzGly.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1063
end;
1064

    
1065
procedure TFormIngredientEditionCopy.CheckBoxHisClick(Sender: TObject);
1066
begin
1067
  if CheckBoxHis.Checked
1068
  then // Activer la saisie
1069
    EditActivate(ValidateEditHis)
1070
  else // Afficher la valeur par d?faut
1071
    with DataModuleDeclaration do
1072
      if ClientDataSetInraAfzHis.IsNull or (RapMAT = 0)
1073
      then // Null
1074
        EditEmpty(ValidateEditHis)
1075
      else // Valeur du mod?le
1076
        EditShow(ValidateEditHis, OutputAA(ClientDataSetInraAfzHis.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1077
end;
1078

    
1079
procedure TFormIngredientEditionCopy.CheckBoxIleClick(Sender: TObject);
1080
begin
1081
  if CheckBoxIle.Checked
1082
  then // Activer la saisie
1083
    EditActivate(ValidateEditIle)
1084
  else // Afficher la valeur par d?faut
1085
    with DataModuleDeclaration do
1086
      if ClientDataSetInraAfzIle.IsNull or (RapMAT = 0)
1087
      then // Null
1088
        EditEmpty(ValidateEditIle)
1089
      else // Valeur du mod?le
1090
        EditShow(ValidateEditIle, OutputAA(ClientDataSetInraAfzIle.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1091
end;
1092

    
1093
procedure TFormIngredientEditionCopy.CheckBoxKClick(Sender: TObject);
1094
begin
1095
  if CheckBoxK.Checked
1096
  then // Activer la saisie
1097
    EditActivate(ValidateEditK)
1098
  else // Afficher la valeur par d?faut
1099
    with DataModuleDeclaration do
1100
      if ClientDataSetInraAfzK.IsNull
1101
      then // Null
1102
        EditEmpty(ValidateEditK)
1103
      else // Valeur du mod?le
1104
        EditShow(ValidateEditK, OutputMinerals(ClientDataSetInraAfzK.Value, RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2));
1105
end;
1106

    
1107
procedure TFormIngredientEditionCopy.CheckBoxLeuClick(Sender: TObject);
1108
begin
1109
  if CheckBoxLeu.Checked
1110
  then // Activer la saisie
1111
    EditActivate(ValidateEditLeu)
1112
  else // Afficher la valeur par d?faut
1113
    with DataModuleDeclaration do
1114
      if ClientDataSetInraAfzLeu.IsNull or (RapMAT = 0)
1115
      then // Null
1116
        EditEmpty(ValidateEditLeu)
1117
      else // Valeur du mod?le
1118
        EditShow(ValidateEditLeu, OutputAA(ClientDataSetInraAfzLeu.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1119
end;
1120

    
1121
procedure TFormIngredientEditionCopy.CheckBoxLysClick(Sender: TObject);
1122
begin
1123
  if CheckBoxLys.Checked
1124
  then // Activer la saisie
1125
    EditActivate(ValidateEditLys)
1126
  else // Afficher la valeur par d?faut
1127
    with DataModuleDeclaration do
1128
      if ClientDataSetInraAfzLys.IsNull or (RapMAT = 0)
1129
      then // Null
1130
        EditEmpty(ValidateEditLys)
1131
      else // Valeur du mod?le
1132
        EditShow(ValidateEditLys, OutputAA(ClientDataSetInraAfzLys.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1133
end;
1134

    
1135
procedure TFormIngredientEditionCopy.CheckBoxMATClick(Sender: TObject);
1136
begin
1137
  if CheckBoxMAT.Checked
1138
  then // Activer la saisie
1139
    EditActivate(ValidateEditMAT)
1140
  else // Afficher la valeur par d?faut
1141
    with DataModuleDeclaration do
1142
      if ClientDataSetInraAfzMAT.IsNull
1143
      then // Null
1144
      begin
1145
        RapMAT := 0;
1146
        EditEmpty(ValidateEditMAT);
1147
      end
1148
      else // Valeur du mod?le
1149
      begin
1150
        RapMAT := ClientDataSetInraAfzMAT.Value;
1151
        EditShow(ValidateEditMAT, OutputProximal(RapMAT, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
1152
      end;
1153
end;
1154

    
1155
procedure TFormIngredientEditionCopy.CheckBoxMetClick(Sender: TObject);
1156
begin
1157
  if CheckBoxMet.Checked
1158
  then // Activer la saisie
1159
    EditActivate(ValidateEditMet)
1160
  else // Afficher la valeur par d?faut
1161
    with DataModuleDeclaration do
1162
      if ClientDataSetInraAfzMet.IsNull or (RapMAT = 0)
1163
      then // Null
1164
        EditEmpty(ValidateEditMet)
1165
      else // Valeur du mod?le
1166
        EditShow(ValidateEditMet, OutputAA(ClientDataSetInraAfzMet.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1167
end;
1168

    
1169
procedure TFormIngredientEditionCopy.CheckBoxMetCysClick(Sender: TObject);
1170
begin
1171
  if CheckBoxMetCys.Checked
1172
  then // Activer la saisie
1173
    EditActivate(ValidateEditMetCys)
1174
  else // Afficher la valeur par d?faut
1175
    with DataModuleDeclaration do
1176
      if ClientDataSetInraAfzMetCys.IsNull or (RapMAT = 0)
1177
      then // Null
1178
        EditEmpty(ValidateEditMetCys)
1179
      else // Valeur du mod?le
1180
        EditShow(ValidateEditMetCys, OutputAA(ClientDataSetInraAfzMetCys.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1181
end;
1182

    
1183
procedure TFormIngredientEditionCopy.CheckBoxMGClick(Sender: TObject);
1184
begin
1185
  if CheckBoxMG.Checked
1186
  then // Activer la saisie
1187
    EditActivate(ValidateEditMG)
1188
  else // Afficher la valeur par d?faut
1189
    with DataModuleDeclaration do
1190
      if ClientDataSetInraAfzMG.IsNull
1191
      then // Null
1192
        EditEmpty(ValidateEditMG)
1193
      else // Valeur du mod?le
1194
        EditShow(ValidateEditMG, OutputProximal(ClientDataSetInraAfzMG.Value, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
1195
end;
1196

    
1197
procedure TFormIngredientEditionCopy.CheckBoxMMClick(Sender: TObject);
1198
begin
1199
  if CheckBoxMM.Checked
1200
  then // Activer la saisie
1201
    EditActivate(ValidateEditMM)
1202
  else // Afficher la valeur par d?faut
1203
    with DataModuleDeclaration do
1204
      if ClientDataSetInraAfzMM.IsNull
1205
      then // Null
1206
        EditEmpty(ValidateEditMM)
1207
      else // Valeur du mod?le
1208
        EditShow(ValidateEditMM, OutputProximal(ClientDataSetInraAfzMM.Value, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
1209
end;
1210

    
1211
procedure TFormIngredientEditionCopy.CheckBoxNaClick(Sender: TObject);
1212
begin
1213
  if CheckBoxNa.Checked
1214
  then // Activer la saisie
1215
    EditActivate(ValidateEditNa)
1216
  else // Afficher la valeur par d?faut
1217
    with DataModuleDeclaration do
1218
      if ClientDataSetInraAfzNa.IsNull
1219
      then // Null
1220
        EditEmpty(ValidateEditNa)
1221
      else // Valeur du mod?le
1222
        EditShow(ValidateEditNa, OutputMinerals(ClientDataSetInraAfzNa.Value, RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2));
1223
end;
1224

    
1225
procedure TFormIngredientEditionCopy.CheckBoxNDFClick(Sender: TObject);
1226
begin
1227
  if CheckBoxNDF.Checked
1228
  then // Activer la saisie
1229
    EditActivate(ValidateEditNDF)
1230
  else // Afficher la valeur par d?faut
1231
    with DataModuleDeclaration do
1232
      if ClientDataSetInraAfzNDF.IsNull
1233
      then // Null
1234
        EditEmpty(ValidateEditNDF)
1235
      else // Valeur du mod?le
1236
        EditShow(ValidateEditNDF, OutputProximal(ClientDataSetInraAfzNDF.Value, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
1237
end;
1238

    
1239
procedure TFormIngredientEditionCopy.CheckBoxPClick(Sender: TObject);
1240
begin
1241
  if CheckBoxP.Checked
1242
  then // Activer la saisie
1243
    EditActivate(ValidateEditP)
1244
  else // Afficher la valeur par d?faut
1245
    with DataModuleDeclaration do
1246
      if ClientDataSetInraAfzP.IsNull
1247
      then // Null
1248
      begin
1249
        EditEmpty(ValidateEditP);
1250
        // D?sactiver la saisie du phosphore digestible
1251
        DisabledP;
1252
      end
1253
      else // Valeur du mod?le
1254
        EditShow(ValidateEditP, OutputMinerals(ClientDataSetInraAfzP.Value, RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2));
1255
end;
1256

    
1257
procedure TFormIngredientEditionCopy.CheckBoxPheClick(Sender: TObject);
1258
begin
1259
  if CheckBoxPhe.Checked
1260
  then // Activer la saisie
1261
    EditActivate(ValidateEditPhe)
1262
  else // Afficher la valeur par d?faut
1263
    with DataModuleDeclaration do
1264
      if ClientDataSetInraAfzPhe.IsNull or (RapMAT = 0)
1265
      then // Null
1266
        EditEmpty(ValidateEditPhe)
1267
      else // Valeur du mod?le
1268
        EditShow(ValidateEditPhe, OutputAA(ClientDataSetInraAfzPhe.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1269
end;
1270

    
1271
procedure TFormIngredientEditionCopy.CheckBoxPheTyrClick(Sender: TObject);
1272
begin
1273
  if CheckBoxPheTyr.Checked
1274
  then // Activer la saisie
1275
    EditActivate(ValidateEditPheTyr)
1276
  else // Afficher la valeur par d?faut
1277
    with DataModuleDeclaration do
1278
      if ClientDataSetInraAfzPheTyr.IsNull or (RapMAT = 0)
1279
      then // Null
1280
        EditEmpty(ValidateEditPheTyr)
1281
      else // Valeur du mod?le
1282
        EditShow(ValidateEditPheTyr, OutputAA(ClientDataSetInraAfzPheTyr.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1283
end;
1284

    
1285
procedure TFormIngredientEditionCopy.CheckBoxProClick(Sender: TObject);
1286
begin
1287
  if CheckBoxPro.Checked
1288
  then // Activer la saisie
1289
    EditActivate(ValidateEditPro)
1290
  else // Afficher la valeur par d?faut
1291
    with DataModuleDeclaration do
1292
      if ClientDataSetInraAfzPro.IsNull or (RapMAT = 0)
1293
      then // Null
1294
        EditEmpty(ValidateEditPro)
1295
      else // Valeur du mod?le
1296
        EditShow(ValidateEditPro, OutputAA(ClientDataSetInraAfzPro.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1297
end;
1298

    
1299
procedure TFormIngredientEditionCopy.CheckBoxSerClick(Sender: TObject);
1300
begin
1301
  if CheckBoxSer.Checked
1302
  then // Activer la saisie
1303
    EditActivate(ValidateEditSer)
1304
  else // Afficher la valeur par d?faut
1305
    with DataModuleDeclaration do
1306
      if ClientDataSetInraAfzSer.IsNull or (RapMAT = 0)
1307
      then // Null
1308
        EditEmpty(ValidateEditSer)
1309
      else // Valeur du mod?le
1310
        EditShow(ValidateEditSer, OutputAA(ClientDataSetInraAfzSer.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1311
end;
1312

    
1313
procedure TFormIngredientEditionCopy.CheckBoxSucresClick(Sender: TObject);
1314
begin
1315
  if CheckBoxSucres.Checked
1316
  then // Activer la saisie
1317
    EditActivate(ValidateEditSucres)
1318
  else // Afficher la valeur par d?faut
1319
    with DataModuleDeclaration do
1320
      if ClientDataSetInraAfzSucres.IsNull
1321
      then // Null
1322
        EditEmpty(ValidateEditSucres)
1323
      else // Valeur du mod?le
1324
        EditShow(ValidateEditSucres, OutputProximal(ClientDataSetInraAfzSucres.Value, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
1325
end;
1326

    
1327
procedure TFormIngredientEditionCopy.CheckBoxThrClick(Sender: TObject);
1328
begin
1329
  if CheckBoxThr.Checked
1330
  then // Activer la saisie
1331
    EditActivate(ValidateEditThr)
1332
  else // Afficher la valeur par d?faut
1333
    with DataModuleDeclaration do
1334
      if ClientDataSetInraAfzThr.IsNull or (RapMAT = 0)
1335
      then // Null
1336
        EditEmpty(ValidateEditThr)
1337
      else // Valeur du mod?le
1338
        EditShow(ValidateEditThr, OutputAA(ClientDataSetInraAfzThr.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1339
end;
1340

    
1341
procedure TFormIngredientEditionCopy.CheckBoxTrpClick(Sender: TObject);
1342
begin
1343
  if CheckBoxTrp.Checked
1344
  then // Activer la saisie
1345
    EditActivate(ValidateEditTrp)
1346
  else // Afficher la valeur par d?faut
1347
    with DataModuleDeclaration do
1348
      if ClientDataSetInraAfzTrp.IsNull or (RapMAT = 0)
1349
      then // Null
1350
        EditEmpty(ValidateEditTrp)
1351
      else // Valeur du mod?le
1352
        EditShow(ValidateEditTrp, OutputAA(ClientDataSetInraAfzTrp.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1353
end;
1354

    
1355
procedure TFormIngredientEditionCopy.CheckBoxTyrClick(Sender: TObject);
1356
begin
1357
  if CheckBoxTyr.Checked
1358
  then // Activer la saisie
1359
    EditActivate(ValidateEditTyr)
1360
  else // Afficher la valeur par d?faut
1361
    with DataModuleDeclaration do
1362
      if ClientDataSetInraAfzTyr.IsNull or (RapMAT = 0)
1363
      then // Null
1364
        EditEmpty(ValidateEditTyr)
1365
      else // Valeur du mod?le
1366
        EditShow(ValidateEditTyr, OutputAA(ClientDataSetInraAfzTyr.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1367
end;
1368

    
1369
procedure TFormIngredientEditionCopy.CheckBoxValClick(Sender: TObject);
1370
begin
1371
  if CheckBoxVal.Checked
1372
  then // Activer la saisie
1373
    EditActivate(ValidateEditVal)
1374
  else // Afficher la valeur par d?faut
1375
    with DataModuleDeclaration do
1376
      if ClientDataSetInraAfzVal.IsNull or (RapMAT = 0)
1377
      then // Null
1378
        EditEmpty(ValidateEditVal)
1379
      else // Valeur du mod?le
1380
        EditShow(ValidateEditVal, OutputAA(ClientDataSetInraAfzVal.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1381
end;
1382

    
1383
procedure TFormIngredientEditionCopy.ComboBoxAAChange(Sender: TObject);
1384
begin
1385
  if ComboBoxAA.ItemIndex <> AAUnit
1386
  then // Changement d'unit?
1387
  begin
1388
    if ComboBoxAA.ItemIndex mod 2 = 0
1389
    then // %
1390
    begin
1391
      ValidateEditLys.DecimalPlaces := 2;
1392
      ValidateEditThr.DecimalPlaces := 2;
1393
      ValidateEditMet.DecimalPlaces := 2;
1394
      ValidateEditCys.DecimalPlaces := 2;
1395
      ValidateEditMetCys.DecimalPlaces := 2;
1396
      ValidateEditTrp.DecimalPlaces := 2;
1397
      ValidateEditIle.DecimalPlaces := 2;
1398
      ValidateEditVal.DecimalPlaces := 2;
1399
      ValidateEditLeu.DecimalPlaces := 2;
1400
      ValidateEditPhe.DecimalPlaces := 2;
1401
      ValidateEditTyr.DecimalPlaces := 2;
1402
      ValidateEditPheTyr.DecimalPlaces := 2;
1403
      ValidateEditHis.DecimalPlaces := 2;
1404
      ValidateEditArg.DecimalPlaces := 2;
1405
      ValidateEditAla.DecimalPlaces := 2;
1406
      ValidateEditAsp.DecimalPlaces := 2;
1407
      ValidateEditGlu.DecimalPlaces := 2;
1408
      ValidateEditGly.DecimalPlaces := 2;
1409
      ValidateEditSer.DecimalPlaces := 2;
1410
      ValidateEditPro.DecimalPlaces := 2;
1411
    end
1412
    else // g/kg
1413
    begin
1414
      ValidateEditLys.MaxValue := 1000;
1415
      ValidateEditThr.MaxValue := 1000;
1416
      ValidateEditMet.MaxValue := 1000;
1417
      ValidateEditCys.MaxValue := 1000;
1418
      ValidateEditMetCys.MaxValue := 1000;
1419
      ValidateEditTrp.MaxValue := 1000;
1420
      ValidateEditIle.MaxValue := 1000;
1421
      ValidateEditVal.MaxValue := 1000;
1422
      ValidateEditLeu.MaxValue := 1000;
1423
      ValidateEditPhe.MaxValue := 1000;
1424
      ValidateEditTyr.MaxValue := 1000;
1425
      ValidateEditPheTyr.MaxValue := 1000;
1426
      ValidateEditHis.MaxValue := 1000;
1427
      ValidateEditArg.MaxValue := 1000;
1428
      ValidateEditAla.MaxValue := 1000;
1429
      ValidateEditAsp.MaxValue := 1000;
1430
      ValidateEditGlu.MaxValue := 1000;
1431
      ValidateEditGly.MaxValue := 1000;
1432
      ValidateEditSer.MaxValue := 1000;
1433
      ValidateEditPro.MaxValue := 1000;
1434
    end;
1435
    if AAUnit <> -1
1436
    then
1437
      with DataModuleDeclaration do
1438
      begin
1439
        if CheckBoxLys.Checked
1440
        then // Conversion
1441
          ValidateEditLys.AsFloat := OutputAA(InputAA(ValidateEditLys.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1442
        else
1443
          CheckBoxLysClick(nil);
1444
        if CheckBoxThr.Checked
1445
        then // Conversion
1446
          ValidateEditThr.AsFloat := OutputAA(InputAA(ValidateEditThr.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1447
        else
1448
          CheckBoxThrClick(nil);
1449
        if CheckBoxMet.Checked
1450
        then // Conversion
1451
          ValidateEditMet.AsFloat := OutputAA(InputAA(ValidateEditMet.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1452
        else
1453
          CheckBoxMetClick(nil);
1454
        if CheckBoxCys.Checked
1455
        then // Conversion
1456
          ValidateEditCys.AsFloat := OutputAA(InputAA(ValidateEditCys.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1457
        else
1458
          CheckBoxCysClick(nil);
1459
        if CheckBoxMetCys.Checked
1460
        then // Conversion
1461
          ValidateEditMetCys.AsFloat := OutputAA(InputAA(ValidateEditMetCys.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1462
        else
1463
          CheckBoxMetCysClick(nil);
1464
        if CheckBoxTrp.Checked
1465
        then // Conversion
1466
          ValidateEditTrp.AsFloat := OutputAA(InputAA(ValidateEditTrp.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1467
        else
1468
          CheckBoxTrpClick(nil);
1469
        if CheckBoxIle.Checked
1470
        then // Conversion
1471
          ValidateEditIle.AsFloat := OutputAA(InputAA(ValidateEditIle.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1472
        else
1473
          CheckBoxIleClick(nil);
1474
        if CheckBoxVal.Checked
1475
        then // Conversion
1476
          ValidateEditVal.AsFloat := OutputAA(InputAA(ValidateEditVal.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1477
        else
1478
          CheckBoxValClick(nil);
1479
        if CheckBoxLeu.Checked
1480
        then // Conversion
1481
          ValidateEditLeu.AsFloat := OutputAA(InputAA(ValidateEditLeu.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1482
        else
1483
          CheckBoxLeuClick(nil);
1484
        if CheckBoxPhe.Checked
1485
        then // Conversion
1486
          ValidateEditPhe.AsFloat := OutputAA(InputAA(ValidateEditPhe.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1487
        else
1488
          CheckBoxPheClick(nil);
1489
        if CheckBoxTyr.Checked
1490
        then // Conversion
1491
          ValidateEditTyr.AsFloat := OutputAA(InputAA(ValidateEditTyr.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1492
        else
1493
          CheckBoxTyrClick(nil);
1494
        if CheckBoxPheTyr.Checked
1495
        then // Conversion
1496
          ValidateEditPheTyr.AsFloat := OutputAA(InputAA(ValidateEditPheTyr.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1497
        else
1498
          CheckBoxPheTyrClick(nil);
1499
        if CheckBoxHis.Checked
1500
        then // Conversion
1501
          ValidateEditHis.AsFloat := OutputAA(InputAA(ValidateEditHis.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1502
        else
1503
          CheckBoxHisClick(nil);
1504
        if CheckBoxArg.Checked
1505
        then // Conversion
1506
          ValidateEditArg.AsFloat := OutputAA(InputAA(ValidateEditArg.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1507
        else
1508
          CheckBoxArgClick(nil);
1509
        if CheckBoxAla.Checked
1510
        then // Conversion
1511
          ValidateEditAla.AsFloat := OutputAA(InputAA(ValidateEditAla.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1512
        else
1513
          CheckBoxAlaClick(nil);
1514
        if CheckBoxAsp.Checked
1515
        then // Conversion
1516
          ValidateEditAsp.AsFloat := OutputAA(InputAA(ValidateEditAsp.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1517
        else
1518
          CheckBoxAspClick(nil);
1519
        if CheckBoxGlu.Checked
1520
        then // Conversion
1521
          ValidateEditGlu.AsFloat := OutputAA(InputAA(ValidateEditGlu.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1522
        else
1523
          CheckBoxGluClick(nil);
1524
        if CheckBoxGly.Checked
1525
        then // Conversion
1526
          ValidateEditGly.AsFloat := OutputAA(InputAA(ValidateEditGly.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1527
        else
1528
          CheckBoxGlyClick(nil);
1529
        if CheckBoxSer.Checked
1530
        then // Conversion
1531
          ValidateEditSer.AsFloat := OutputAA(InputAA(ValidateEditSer.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1532
        else
1533
          CheckBoxSerClick(nil);
1534
        if CheckBoxPro.Checked
1535
        then // Conversion
1536
          ValidateEditPro.AsFloat := OutputAA(InputAA(ValidateEditPro.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1537
        else
1538
          CheckBoxProClick(nil);
1539
      end;
1540
    if ComboBoxAA.ItemIndex mod 2 = 0
1541
    then // %
1542
    begin
1543
      ValidateEditLys.MaxValue := 100;
1544
      ValidateEditThr.MaxValue := 100;
1545
      ValidateEditMet.MaxValue := 100;
1546
      ValidateEditCys.MaxValue := 100;
1547
      ValidateEditMetCys.MaxValue := 100;
1548
      ValidateEditTrp.MaxValue := 100;
1549
      ValidateEditIle.MaxValue := 100;
1550
      ValidateEditVal.MaxValue := 100;
1551
      ValidateEditLeu.MaxValue := 100;
1552
      ValidateEditPhe.MaxValue := 100;
1553
      ValidateEditTyr.MaxValue := 100;
1554
      ValidateEditPheTyr.MaxValue := 100;
1555
      ValidateEditHis.MaxValue := 100;
1556
      ValidateEditArg.MaxValue := 100;
1557
      ValidateEditAla.MaxValue := 100;
1558
      ValidateEditAsp.MaxValue := 100;
1559
      ValidateEditGlu.MaxValue := 100;
1560
      ValidateEditGly.MaxValue := 100;
1561
      ValidateEditSer.MaxValue := 100;
1562
      ValidateEditPro.MaxValue := 100;
1563
    end
1564
    else // g/kg
1565
    begin
1566
      ValidateEditLys.DecimalPlaces := 1;
1567
      ValidateEditThr.DecimalPlaces := 1;
1568
      ValidateEditMet.DecimalPlaces := 1;
1569
      ValidateEditCys.DecimalPlaces := 1;
1570
      ValidateEditMetCys.DecimalPlaces := 1;
1571
      ValidateEditTrp.DecimalPlaces := 1;
1572
      ValidateEditIle.DecimalPlaces := 1;
1573
      ValidateEditVal.DecimalPlaces := 1;
1574
      ValidateEditLeu.DecimalPlaces := 1;
1575
      ValidateEditPhe.DecimalPlaces := 1;
1576
      ValidateEditTyr.DecimalPlaces := 1;
1577
      ValidateEditPheTyr.DecimalPlaces := 1;
1578
      ValidateEditHis.DecimalPlaces := 1;
1579
      ValidateEditArg.DecimalPlaces := 1;
1580
      ValidateEditAla.DecimalPlaces := 1;
1581
      ValidateEditAsp.DecimalPlaces := 1;
1582
      ValidateEditGlu.DecimalPlaces := 1;
1583
      ValidateEditGly.DecimalPlaces := 1;
1584
      ValidateEditSer.DecimalPlaces := 1;
1585
      ValidateEditPro.DecimalPlaces := 1;
1586
    end;
1587
    AAUnit := ComboBoxAA.ItemIndex;
1588
  end;
1589
end;
1590

    
1591
procedure TFormIngredientEditionCopy.ComboBoxMineralsChange(Sender: TObject);
1592
begin
1593
  if ComboBoxMinerals.ItemIndex <> MineralsUnit
1594
  then // Changement d'unit?
1595
  begin
1596
    if ComboBoxMinerals.ItemIndex mod 2 = 0
1597
    then // %
1598
    begin
1599
      ValidateEditCa.DecimalPlaces := 2;
1600
      ValidateEditP.DecimalPlaces := 2;
1601
      ValidateEditNa.DecimalPlaces := 2;
1602
      ValidateEditK.DecimalPlaces := 2;
1603
      ValidateEditCl.DecimalPlaces := 2;
1604
    end
1605
    else // g/kg
1606
    begin
1607
      ValidateEditCa.MaxValue := 1000;
1608
      ValidateEditP.MaxValue := 1000;
1609
      ValidateEditNa.MaxValue := 1000;
1610
      ValidateEditK.MaxValue := 1000;
1611
      ValidateEditCl.MaxValue := 1000;
1612
    end;
1613
    with DataModuleDeclaration do
1614
    begin
1615
      if CheckBoxCa.Checked
1616
      then // Conversion
1617
          ValidateEditCa.AsFloat := OutputMinerals(InputMinerals(ValidateEditCa.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2), RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2)
1618
      else
1619
        CheckBoxCaClick(nil);
1620
      if CheckBoxP.Checked
1621
      then // Conversion
1622
          ValidateEditP.AsFloat := OutputMinerals(InputMinerals(ValidateEditP.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2), RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2)
1623
      else
1624
        CheckBoxPClick(nil);
1625
    end;
1626

    
1627
    if ComboBoxMinerals.ItemIndex mod 2 = 0
1628
    then // %
1629
    begin
1630
      ValidateEditCa.MaxValue := 100;
1631
      ValidateEditP.MaxValue := 100;
1632
      ValidateEditNa.MaxValue := 100;
1633
      ValidateEditK.MaxValue := 100;
1634
      ValidateEditCl.MaxValue := 100;
1635
    end
1636
    else // g/kg
1637
    begin
1638
      ValidateEditCa.DecimalPlaces := 1;
1639
      ValidateEditP.DecimalPlaces := 1;
1640
      ValidateEditNa.DecimalPlaces := 1;
1641
      ValidateEditK.DecimalPlaces := 1;
1642
      ValidateEditCl.DecimalPlaces := 1;
1643
    end;
1644
    MineralsUnit := ComboBoxMinerals.ItemIndex;
1645
  end;
1646
end;
1647

    
1648
procedure TFormIngredientEditionCopy.ComboBoxProximalChange(Sender: TObject);
1649
begin
1650
  if ComboBoxProximal.ItemIndex <> ProximalUnit
1651
  then // Changement d'unit?
1652
  begin
1653
    if ComboBoxProximal.ItemIndex mod 2 = 0
1654
    then // %
1655
    begin
1656
      ValidateEditMM.DecimalPlaces := 2;
1657
      ValidateEditMAT.DecimalPlaces := 2;
1658
      ValidateEditMG.DecimalPlaces := 2;
1659
      ValidateEditCB.DecimalPlaces := 2;
1660
      ValidateEditNDF.DecimalPlaces := 2;
1661
      ValidateEditADF.DecimalPlaces := 2;
1662
      ValidateEditADL.DecimalPlaces := 2;
1663
      ValidateEditAmidon.DecimalPlaces := 2;
1664
      ValidateEditSucres.DecimalPlaces := 2;
1665
    end
1666
    else // g/kg
1667
    begin
1668
      ValidateEditMM.MaxValue := 1000;
1669
      ValidateEditMAT.MaxValue := 1000;
1670
      ValidateEditMG.MaxValue := 1000;
1671
      ValidateEditCB.MaxValue := 1000;
1672
      ValidateEditNDF.MaxValue := 1000;
1673
      ValidateEditADF.MaxValue := 1000;
1674
      ValidateEditADL.MaxValue := 1000;
1675
      ValidateEditAmidon.MaxValue := 1000;
1676
      ValidateEditSucres.MaxValue := 1000;
1677
    end;
1678
    if CheckBoxMM.Checked
1679
    then // Conversion
1680
      with DataModuleDeclaration do
1681
        ValidateEditMM.AsFloat := OutputProximal(InputProximal(ValidateEditMM.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1682
    else
1683
      CheckBoxMMClick(nil);
1684
    if CheckBoxMAT.Checked
1685
    then // Conversion
1686
      with DataModuleDeclaration do
1687
        ValidateEditMAT.AsFloat := OutputProximal(InputProximal(ValidateEditMAT.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1688
    else
1689
      CheckBoxMATClick(nil);
1690
    if CheckBoxMG.Checked
1691
    then // Conversion
1692
      with DataModuleDeclaration do
1693
        ValidateEditMG.AsFloat := OutputProximal(InputProximal(ValidateEditMG.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1694
    else
1695
      CheckBoxMGClick(nil);
1696
    if CheckBoxCB.Checked
1697
    then // Conversion
1698
      with DataModuleDeclaration do
1699
        ValidateEditCB.AsFloat := OutputProximal(InputProximal(ValidateEditCB.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1700
    else
1701
      CheckBoxCBClick(nil);
1702
    if CheckBoxNDF.Checked
1703
    then // Conversion
1704
      with DataModuleDeclaration do
1705
        ValidateEditNDF.AsFloat := OutputProximal(InputProximal(ValidateEditNDF.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1706
    else
1707
      CheckBoxNDFClick(nil);
1708
    if CheckBoxADF.Checked
1709
    then // Conversion
1710
      with DataModuleDeclaration do
1711
        ValidateEditADF.AsFloat := OutputProximal(InputProximal(ValidateEditADF.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1712
    else
1713
      CheckBoxADFClick(nil);
1714
    if CheckBoxADL.Checked
1715
    then // Conversion
1716
      with DataModuleDeclaration do
1717
        ValidateEditADL.AsFloat := OutputProximal(InputProximal(ValidateEditADL.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1718
    else
1719
      CheckBoxADLClick(nil);
1720
    if CheckBoxAmidon.Checked
1721
    then // Conversion
1722
      with DataModuleDeclaration do
1723
        ValidateEditAmidon.AsFloat := OutputProximal(InputProximal(ValidateEditAmidon.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1724
    else
1725
      CheckBoxAmidonClick(nil);
1726
    if CheckBoxSucres.Checked
1727
    then // Conversion
1728
      with DataModuleDeclaration do
1729
        ValidateEditSucres.AsFloat := OutputProximal(InputProximal(ValidateEditSucres.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1730
    else
1731
      CheckBoxSucresClick(nil);
1732
    if ComboBoxProximal.ItemIndex mod 2 = 0
1733
    then // %
1734
    begin
1735
      ValidateEditMM.MaxValue := 100;
1736
      ValidateEditMAT.MaxValue := 100;
1737
      ValidateEditMG.MaxValue := 100;
1738
      ValidateEditCB.MaxValue := 100;
1739
      ValidateEditNDF.MaxValue := 100;
1740
      ValidateEditADF.MaxValue := 100;
1741
      ValidateEditADL.MaxValue := 100;
1742
      ValidateEditAmidon.MaxValue := 100;
1743
      ValidateEditSucres.MaxValue := 100;
1744
    end
1745
    else // g/kg
1746
    begin
1747
      ValidateEditMM.DecimalPlaces := 1;
1748
      ValidateEditMAT.DecimalPlaces := 1;
1749
      ValidateEditMG.DecimalPlaces := 1;
1750
      ValidateEditCB.DecimalPlaces := 1;
1751
      ValidateEditNDF.DecimalPlaces := 1;
1752
      ValidateEditADF.DecimalPlaces := 1;
1753
      ValidateEditADL.DecimalPlaces := 1;
1754
      ValidateEditAmidon.DecimalPlaces := 1;
1755
      ValidateEditSucres.DecimalPlaces := 1;
1756
    end;
1757
    ProximalUnit := ComboBoxProximal.ItemIndex;
1758
  end;
1759
end;
1760

    
1761
procedure TFormIngredientEditionCopy.DisableAA;
1762
begin
1763
  if CheckBoxLys.Checked
1764
  then
1765
    CheckBoxLys.Checked := False
1766
  else
1767
    CheckBoxLysClick(nil);
1768
  if CheckBoxThr.Checked
1769
  then
1770
    CheckBoxThr.Checked := False
1771
  else
1772
    CheckBoxThrClick(nil);
1773
  if CheckBoxMet.Checked
1774
  then
1775
    CheckBoxMet.Checked := False
1776
  else
1777
    CheckBoxMetClick(nil);
1778
  if CheckBoxCys.Checked
1779
  then
1780
    CheckBoxCys.Checked := False
1781
  else
1782
    CheckBoxCysClick(nil);
1783
  if CheckBoxMetCys.Checked
1784
  then
1785
    CheckBoxMetCys.Checked := False
1786
  else
1787
    CheckBoxMetCysClick(nil);
1788
  if CheckBoxTrp.Checked
1789
  then
1790
    CheckBoxTrp.Checked := False
1791
  else
1792
    CheckBoxTrpClick(nil);
1793
  if CheckBoxIle.Checked
1794
  then
1795
    CheckBoxIle.Checked := False
1796
  else
1797
    CheckBoxIleClick(nil);
1798
  if CheckBoxVal.Checked
1799
  then
1800
    CheckBoxVal.Checked := False
1801
  else
1802
    CheckBoxValClick(nil);
1803
  if CheckBoxLeu.Checked
1804
  then
1805
    CheckBoxLeu.Checked := False
1806
  else
1807
    CheckBoxLeuClick(nil);
1808
  if CheckBoxPhe.Checked
1809
  then
1810
    CheckBoxPhe.Checked := False
1811
  else
1812
    CheckBoxPheClick(nil);
1813
  if CheckBoxTyr.Checked
1814
  then
1815
    CheckBoxTyr.Checked := False
1816
  else
1817
    CheckBoxTyrClick(nil);
1818
  if CheckBoxPheTyr.Checked
1819
  then
1820
    CheckBoxPheTyr.Checked := False
1821
  else
1822
    CheckBoxPheTyrClick(nil);
1823
  if CheckBoxHis.Checked
1824
  then
1825
    CheckBoxHis.Checked := False
1826
  else
1827
    CheckBoxHisClick(nil);
1828
  if CheckBoxArg.Checked
1829
  then
1830
    CheckBoxArg.Checked := False
1831
  else
1832
    CheckBoxArgClick(nil);
1833
  if CheckBoxAla.Checked
1834
  then
1835
    CheckBoxAla.Checked := False
1836
  else
1837
    CheckBoxAlaClick(nil);
1838
  if CheckBoxAsp.Checked
1839
  then
1840
    CheckBoxAsp.Checked := False
1841
  else
1842
    CheckBoxAspClick(nil);
1843
  if CheckBoxGlu.Checked
1844
  then
1845
    CheckBoxGlu.Checked := False
1846
  else
1847
    CheckBoxGluClick(nil);
1848
  if CheckBoxGly.Checked
1849
  then
1850
    CheckBoxGly.Checked := False
1851
  else
1852
    CheckBoxGlyClick(nil);
1853
  if CheckBoxSer.Checked
1854
  then
1855
    CheckBoxSer.Checked := False
1856
  else
1857
    CheckBoxSerClick(nil);
1858
  if CheckBoxPro.Checked
1859
  then
1860
    CheckBoxPro.Checked := False
1861
  else
1862
    CheckBoxProClick(nil);
1863
  // Verrouillage
1864
  CheckBoxLys.Enabled := False;
1865
  CheckBoxThr.Enabled := False;
1866
  CheckBoxMet.Enabled := False;
1867
  CheckBoxCys.Enabled := False;
1868
  CheckBoxMetCys.Enabled := False;
1869
  CheckBoxTrp.Enabled := False;
1870
  CheckBoxIle.Enabled := False;
1871
  CheckBoxVal.Enabled := False;
1872
  CheckBoxLeu.Enabled := False;
1873
  CheckBoxPhe.Enabled := False;
1874
  CheckBoxTyr.Enabled := False;
1875
  CheckBoxPheTyr.Enabled := False;
1876
  CheckBoxHis.Enabled := False;
1877
  CheckBoxArg.Enabled := False;
1878
  CheckBoxAla.Enabled := False;
1879
  CheckBoxAsp.Enabled := False;
1880
  CheckBoxGlu.Enabled := False;
1881
  CheckBoxGly.Enabled := False;
1882
  CheckBoxSer.Enabled := False;
1883
  CheckBoxPro.Enabled := False;
1884
end;
1885

    
1886
procedure TFormIngredientEditionCopy.DisabledP;
1887
begin
1888
  if CheckBoxdPphy.Checked
1889
  then
1890
    CheckBoxdPphy.Checked := False
1891
  else
1892
    CheckBoxdPphyClick(nil);
1893
  if CheckBoxdP.Checked
1894
  then
1895
    CheckBoxdP.Checked := False
1896
  else
1897
    CheckBoxdPClick(nil);
1898
  // Verrouillage
1899
  CheckBoxdPphy.Enabled := False;
1900
  CheckBoxdP.Enabled := False;
1901
end;
1902

    
1903
procedure TFormIngredientEditionCopy.EnableAA;
1904
begin
1905
  CheckBoxLys.Enabled := True;
1906
  CheckBoxThr.Enabled := True;
1907
  CheckBoxMet.Enabled := True;
1908
  CheckBoxCys.Enabled := True;
1909
  CheckBoxMetCys.Enabled := True;
1910
  CheckBoxTrp.Enabled := True;
1911
  CheckBoxIle.Enabled := True;
1912
  CheckBoxVal.Enabled := True;
1913
  CheckBoxLeu.Enabled := True;
1914
  CheckBoxPhe.Enabled := True;
1915
  CheckBoxTyr.Enabled := True;
1916
  CheckBoxPheTyr.Enabled := True;
1917
  CheckBoxHis.Enabled := True;
1918
  CheckBoxArg.Enabled := True;
1919
  CheckBoxAla.Enabled := True;
1920
  CheckBoxAsp.Enabled := True;
1921
  CheckBoxGlu.Enabled := True;
1922
  CheckBoxGly.Enabled := True;
1923
  CheckBoxSer.Enabled := True;
1924
  CheckBoxPro.Enabled := True;
1925
end;
1926

    
1927
procedure TFormIngredientEditionCopy.EnabledP;
1928
begin
1929
  CheckBoxdPphy.Enabled := True;
1930
  CheckBoxdP.Enabled := True;
1931
end;
1932

    
1933
procedure TFormIngredientEditionCopy.EditActivate(Edit: TJvValidateEdit);
1934
begin
1935
  Edit.DisplayFormat := dfFloat;
1936
  Edit.Enabled := True;
1937
  ActiveControl := Edit;
1938
  Edit.SelectAll;
1939
end;
1940

    
1941
procedure TFormIngredientEditionCopy.EditEmpty(Edit: TJvValidateEdit);
1942
begin
1943
  Edit.DisplayFormat := dfNone;
1944
  Edit.Value := '';
1945
  Edit.Enabled := False;
1946
end;
1947

    
1948
procedure TFormIngredientEditionCopy.EditShow(Edit: TJvValidateEdit; const Value: Double);
1949
begin
1950
  Edit.DisplayFormat := dfFloat;
1951
  Edit.AsFloat := Value;
1952
  Edit.Enabled := False;
1953
end;
1954

    
1955
procedure TFormIngredientEditionCopy.FormCreate(Sender: TObject);
1956
var
1957
  i: Integer;
1958
begin
1959
  if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1
1960
  then
1961
    Font.Name := 'Arial Unicode MS';
1962
//  PanelButtons.Font.Size := PanelButtons.Font.Size + 2;
1963
  PanelButtons.Font.Style := [fsBold];
1964
  LabelName.Font.Style := [fsBold];
1965
  DBEditName.Font.Style := [fsBold];
1966
  TranslateComponent(Self);
1967
  with FormOptions do
1968
    LabelMS.Caption := Format('%s (%s)', [LabelMS.Caption, ComboBoxProximal.Items[Proximal]]);
1969
  for i := 0 to FormOptions.ComboBoxProximal.Items.Count - 1 do
1970
    ComboBoxProximal.Items.Add(Format('%s %s', [FormOptions.ComboBoxProximal.Items[i], _('DM')]));
1971
  ProximalUnit := -1;
1972
  ComboBoxProximal.ItemIndex := FormOptions.Proximal + 2 * FormOptions.Expression;
1973
  ComboBoxProximalChange(nil);
1974
  LabelBonus.Caption := LabelBonus.Caption + ' (%)';
1975
  for i := 0 to FormOptions.ComboBoxAA.Items.Count - 1 do
1976
    ComboBoxAA.Items.Add(Format('%s %s', [FormOptions.ComboBoxAA.Items[i], _('DM')]));
1977
  AAUnit := -1;
1978
  ComboBoxAA.ItemIndex := FormOptions.AA + 2 * FormOptions.Expression;
1979
  ComboBoxAAChange(nil);
1980
  for i := 0 to FormOptions.ComboBoxMinerals.Items.Count - 1 do
1981
    ComboBoxMinerals.Items.Add(Format('%s %s', [FormOptions.ComboBoxMinerals.Items[i], _('DM')]));
1982
  MineralsUnit := -1;
1983
  ComboBoxMinerals.ItemIndex := FormOptions.Minerals + 2 * FormOptions.Expression;
1984
  ComboBoxMineralsChange(nil);
1985
  LabeldP.Caption := LabeldP.Caption + ' (%)';
1986
  with DataModuleDeclaration do
1987
  begin
1988
    TableIngredients := DBUser.GetTable('SELECT * FROM Ingredients '
1989
      + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
1990
    ClientDataSetInraAfz.Locate('Id', ClientDataSetIngredientsModel.Value, []);
1991
    EditModel.Text := dgettext('InraAfz', WideString(ClientDataSetInraAfzName.Value));
1992
    // Analyse proximale
1993
    RapMS := TableIngredients.FieldAsDouble(TableIngredients.FieldIndex['MS']);
1994
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MM'])
1995
    then
1996
      CheckBoxMMClick(nil)
1997
    else
1998
    begin
1999
      CheckBoxMM.Checked := True;
2000
      ValidateEditMM.AsFloat := ClientDataSetIngredientsMM.Value;
2001
    end;
2002
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MAT'])
2003
    then
2004
      CheckBoxMATClick(nil)
2005
    else
2006
    begin
2007
      CheckBoxMAT.Checked := True;
2008
      RapMAT := TableIngredients.FieldAsDouble(TableIngredients.FieldIndex['MAT']);
2009
      ValidateEditMAT.AsFloat := ClientDataSetIngredientsMAT.Value;
2010
    end;
2011
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MG'])
2012
    then
2013
      CheckBoxMGClick(nil)
2014
    else
2015
    begin
2016
      CheckBoxMG.Checked := True;
2017
      ValidateEditMG.AsFloat := ClientDataSetIngredientsMG.Value;
2018
    end;
2019
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['CB'])
2020
    then
2021
      CheckBoxCBClick(nil)
2022
    else
2023
    begin
2024
      CheckBoxCB.Checked := True;
2025
      ValidateEditCB.AsFloat := ClientDataSetIngredientsCB.Value;
2026
    end;
2027
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['NDF'])
2028
    then
2029
      CheckBoxNDFClick(nil)
2030
    else
2031
    begin
2032
      CheckBoxNDF.Checked := True;
2033
      ValidateEditNDF.AsFloat := ClientDataSetIngredientsNDF.Value;
2034
    end;
2035
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['ADF'])
2036
    then
2037
      CheckBoxADFClick(nil)
2038
    else
2039
    begin
2040
      CheckBoxADF.Checked := True;
2041
      ValidateEditADF.AsFloat := ClientDataSetIngredientsADF.Value;
2042
    end;
2043
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['ADL'])
2044
    then
2045
      CheckBoxADLClick(nil)
2046
    else
2047
    begin
2048
      CheckBoxADL.Checked := True;
2049
      ValidateEditADL.AsFloat := ClientDataSetIngredientsADL.Value;
2050
    end;
2051
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Amidon'])
2052
    then
2053
      CheckBoxAmidonClick(nil)
2054
    else
2055
    begin
2056
      CheckBoxAmidon.Checked := True;
2057
      ValidateEditAmidon.AsFloat := ClientDataSetIngredientsAmidon.Value;
2058
    end;
2059
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Sucres'])
2060
    then
2061
      CheckBoxSucresClick(nil)
2062
    else
2063
    begin
2064
      CheckBoxSucres.Checked := True;
2065
      ValidateEditSucres.AsFloat := ClientDataSetIngredientsSucres.Value;
2066
    end;
2067
    // Energie
2068
    SpinEditBonus.Value := ClientDataSetIngredientsBonus.Value;
2069
    // Acides amin?s
2070
    if RapMAT = 0
2071
    then // D?sactiver la saisie des acides amin?s
2072
      DisableAA
2073
    else
2074
    begin
2075
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Lys'])
2076
      then
2077
        CheckBoxLysClick(nil)
2078
      else
2079
      begin
2080
        CheckBoxLys.Checked := True;
2081
        ValidateEditLys.AsFloat := ClientDataSetIngredientsLys.Value;
2082
      end;
2083
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Thr'])
2084
      then
2085
        CheckBoxThrClick(nil)
2086
      else
2087
      begin
2088
        CheckBoxThr.Checked := True;
2089
        ValidateEditThr.AsFloat := ClientDataSetIngredientsThr.Value;
2090
      end;
2091
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Met'])
2092
      then
2093
        CheckBoxMetClick(nil)
2094
      else
2095
      begin
2096
        CheckBoxMet.Checked := True;
2097
        ValidateEditMet.AsFloat := ClientDataSetIngredientsMet.Value;
2098
      end;
2099
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Cys'])
2100
      then
2101
        CheckBoxCysClick(nil)
2102
      else
2103
      begin
2104
        CheckBoxCys.Checked := True;
2105
        ValidateEditCys.AsFloat := ClientDataSetIngredientsCys.Value;
2106
      end;
2107
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MetCys'])
2108
      then
2109
        CheckBoxMetCysClick(nil)
2110
      else
2111
      begin
2112
        CheckBoxMetCys.Checked := True;
2113
        ValidateEditMetCys.AsFloat := ClientDataSetIngredientsMetCys.Value;
2114
      end;
2115
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Trp'])
2116
      then
2117
        CheckBoxTrpClick(nil)
2118
      else
2119
      begin
2120
        CheckBoxTrp.Checked := True;
2121
        ValidateEditTrp.AsFloat := ClientDataSetIngredientsTrp.Value;
2122
      end;
2123
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Ile'])
2124
      then
2125
        CheckBoxIleClick(nil)
2126
      else
2127
      begin
2128
        CheckBoxIle.Checked := True;
2129
        ValidateEditIle.AsFloat := ClientDataSetIngredientsIle.Value;
2130
      end;
2131
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Val'])
2132
      then
2133
        CheckBoxValClick(nil)
2134
      else
2135
      begin
2136
        CheckBoxVal.Checked := True;
2137
        ValidateEditVal.AsFloat := ClientDataSetIngredientsVal.Value;
2138
      end;
2139
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Leu'])
2140
      then
2141
        CheckBoxLeuClick(nil)
2142
      else
2143
      begin
2144
        CheckBoxLeu.Checked := True;
2145
        ValidateEditLeu.AsFloat := ClientDataSetIngredientsLeu.Value;
2146
      end;
2147
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Phe'])
2148
      then
2149
        CheckBoxPheClick(nil)
2150
      else
2151
      begin
2152
        CheckBoxPhe.Checked := True;
2153
        ValidateEditPhe.AsFloat := ClientDataSetIngredientsPhe.Value;
2154
      end;
2155
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Tyr'])
2156
      then
2157
        CheckBoxTyrClick(nil)
2158
      else
2159
      begin
2160
        CheckBoxTyr.Checked := True;
2161
        ValidateEditTyr.AsFloat := ClientDataSetIngredientsTyr.Value;
2162
      end;
2163
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['PheTyr'])
2164
      then
2165
        CheckBoxPheTyrClick(nil)
2166
      else
2167
      begin
2168
        CheckBoxPheTyr.Checked := True;
2169
        ValidateEditPheTyr.AsFloat := ClientDataSetIngredientsPheTyr.Value;
2170
      end;
2171
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['His'])
2172
      then
2173
        CheckBoxHisClick(nil)
2174
      else
2175
      begin
2176
        CheckBoxHis.Checked := True;
2177
        ValidateEditHis.AsFloat := ClientDataSetIngredientsHis.Value;
2178
      end;
2179
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Arg'])
2180
      then
2181
        CheckBoxArgClick(nil)
2182
      else
2183
      begin
2184
        CheckBoxArg.Checked := True;
2185
        ValidateEditArg.AsFloat := ClientDataSetIngredientsArg.Value;
2186
      end;
2187
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Ala'])
2188
      then
2189
        CheckBoxAlaClick(nil)
2190
      else
2191
      begin
2192
        CheckBoxAla.Checked := True;
2193
        ValidateEditAla.AsFloat := ClientDataSetIngredientsAla.Value;
2194
      end;
2195
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Asp'])
2196
      then
2197
        CheckBoxAspClick(nil)
2198
      else
2199
      begin
2200
        CheckBoxAsp.Checked := True;
2201
        ValidateEditAsp.AsFloat := ClientDataSetIngredientsAsp.Value;
2202
      end;
2203
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Glu'])
2204
      then
2205
        CheckBoxGluClick(nil)
2206
      else
2207
      begin
2208
        CheckBoxGlu.Checked := True;
2209
        ValidateEditGlu.AsFloat := ClientDataSetIngredientsGlu.Value;
2210
      end;
2211
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Gly'])
2212
      then
2213
        CheckBoxGlyClick(nil)
2214
      else
2215
      begin
2216
        CheckBoxGly.Checked := True;
2217
        ValidateEditGly.AsFloat := ClientDataSetIngredientsGly.Value;
2218
      end;
2219
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Ser'])
2220
      then
2221
        CheckBoxSerClick(nil)
2222
      else
2223
      begin
2224
        CheckBoxSer.Checked := True;
2225
        ValidateEditSer.AsFloat := ClientDataSetIngredientsSer.Value;
2226
      end;
2227
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Pro'])
2228
      then
2229
        CheckBoxProClick(nil)
2230
      else
2231
      begin
2232
        CheckBoxPro.Checked := True;
2233
        ValidateEditPro.AsFloat := ClientDataSetIngredientsPro.Value;
2234
      end;
2235
    end;
2236
    // Min?raux
2237
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Ca'])
2238
    then
2239
      CheckBoxCaClick(nil)
2240
    else
2241
    begin
2242
      CheckBoxCa.Checked := True;
2243
      ValidateEditCa.AsFloat := ClientDataSetIngredientsCa.Value;
2244
    end;
2245
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['P'])
2246
    then
2247
      CheckBoxPClick(nil)
2248
    else
2249
    begin
2250
      CheckBoxP.Checked := True;
2251
      ValidateEditP.AsFloat := ClientDataSetIngredientsP.Value;
2252
    end;
2253
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Na'])
2254
    then
2255
      CheckBoxNaClick(nil)
2256
    else
2257
    begin
2258
      CheckBoxNa.Checked := True;
2259
      ValidateEditNa.AsFloat := ClientDataSetIngredientsNa.Value;
2260
    end;
2261
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['K'])
2262
    then
2263
      CheckBoxKClick(nil)
2264
    else
2265
    begin
2266
      CheckBoxK.Checked := True;
2267
      ValidateEditK.AsFloat := ClientDataSetIngredientsK.Value;
2268
    end;
2269
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Cl'])
2270
    then
2271
      CheckBoxClClick(nil)
2272
    else
2273
    begin
2274
      CheckBoxCl.Checked := True;
2275
      ValidateEditCl.AsFloat := ClientDataSetIngredientsCl.Value;
2276
    end;
2277
    if ValidateEditP.AsFloat = 0
2278
    then // D?sactiver la saisie du phosphore digestible
2279
      DisabledP
2280
    else
2281
    begin
2282
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dP'])
2283
      then
2284
        CheckBoxdPClick(nil)
2285
      else
2286
      begin
2287
        CheckBoxdP.Checked := True;
2288
        ValidateEditdP.AsFloat := ClientDataSetIngredientsdP.Value;
2289
      end;
2290
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dPphy'])
2291
      then
2292
        CheckBoxdPphyClick(nil)
2293
      else
2294
      begin
2295
        CheckBoxdPphy.Checked := True;
2296
        ValidateEditdPphy.AsFloat := ClientDataSetIngredientsdPphy.Value;
2297
      end;
2298
    end;
2299
    TableIngredients.Free;
2300
  end;
2301
end;
2302

    
2303
procedure TFormIngredientEditionCopy.ValidateEditMATChange(Sender: TObject);
2304
begin
2305
  with DataModuleDeclaration do
2306
  begin
2307
    RapMAT := InputProximal(ValidateEditMAT.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2);
2308
    if RapMAT = 0
2309
    then // D?sactiver la saisie des acides amin?s
2310
      DisableAA
2311
    else // Activer la saisie des acides amin?s
2312
    begin
2313
      EnableAA;
2314
      // Recalculer les teneurs en acides amin?s
2315
      if CheckBoxLys.Checked
2316
      then // R?initialiser avec la valeur du mod?le
2317
        CheckBoxLys.Checked := False
2318
      else // R?afficher la valeur du mod?le
2319
        CheckBoxLysClick(nil);
2320
      if CheckBoxThr.Checked
2321
      then // R?initialiser avec la valeur du mod?le
2322
        CheckBoxThr.Checked := False
2323
      else // R?afficher la valeur du mod?le
2324
        CheckBoxThrClick(nil);
2325
      if CheckBoxMet.Checked
2326
      then // R?initialiser avec la valeur du mod?le
2327
        CheckBoxMet.Checked := False
2328
      else // R?afficher la valeur du mod?le
2329
        CheckBoxMetClick(nil);
2330
      if CheckBoxCys.Checked
2331
      then // R?initialiser avec la valeur du mod?le
2332
        CheckBoxCys.Checked := False
2333
      else // R?afficher la valeur du mod?le
2334
        CheckBoxCysClick(nil);
2335
      if CheckBoxMetCys.Checked
2336
      then // R?initialiser avec la valeur du mod?le
2337
        CheckBoxMetCys.Checked := False
2338
      else // R?afficher la valeur du mod?le
2339
        CheckBoxMetCysClick(nil);
2340
      if CheckBoxTrp.Checked
2341
      then // R?initialiser avec la valeur du mod?le
2342
        CheckBoxTrp.Checked := False
2343
      else // R?afficher la valeur du mod?le
2344
        CheckBoxTrpClick(nil);
2345
      if CheckBoxIle.Checked
2346
      then // R?initialiser avec la valeur du mod?le
2347
        CheckBoxIle.Checked := False
2348
      else // R?afficher la valeur du mod?le
2349
        CheckBoxIleClick(nil);
2350
      if CheckBoxVal.Checked
2351
      then // R?initialiser avec la valeur du mod?le
2352
        CheckBoxVal.Checked := False
2353
      else // R?afficher la valeur du mod?le
2354
        CheckBoxValClick(nil);
2355
      if CheckBoxLeu.Checked
2356
      then // R?initialiser avec la valeur du mod?le
2357
        CheckBoxLeu.Checked := False
2358
      else // R?afficher la valeur du mod?le
2359
        CheckBoxLeuClick(nil);
2360
      if CheckBoxPhe.Checked
2361
      then // R?initialiser avec la valeur du mod?le
2362
        CheckBoxPhe.Checked := False
2363
      else // R?afficher la valeur du mod?le
2364
        CheckBoxPheClick(nil);
2365
      if CheckBoxTyr.Checked
2366
      then // R?initialiser avec la valeur du mod?le
2367
        CheckBoxTyr.Checked := False
2368
      else // R?afficher la valeur du mod?le
2369
        CheckBoxTyrClick(nil);
2370
      if CheckBoxPheTyr.Checked
2371
      then // R?initialiser avec la valeur du mod?le
2372
        CheckBoxPheTyr.Checked := False
2373
      else // R?afficher la valeur du mod?le
2374
        CheckBoxPheTyrClick(nil);
2375
      if CheckBoxHis.Checked
2376
      then // R?initialiser avec la valeur du mod?le
2377
        CheckBoxHis.Checked := False
2378
      else // R?afficher la valeur du mod?le
2379
        CheckBoxHisClick(nil);
2380
      if CheckBoxArg.Checked
2381
      then // R?initialiser avec la valeur du mod?le
2382
        CheckBoxArg.Checked := False
2383
      else // R?afficher la valeur du mod?le
2384
        CheckBoxArgClick(nil);
2385
      if CheckBoxAla.Checked
2386
      then // R?initialiser avec la valeur du mod?le
2387
        CheckBoxAla.Checked := False
2388
      else // R?afficher la valeur du mod?le
2389
        CheckBoxAlaClick(nil);
2390
      if CheckBoxAsp.Checked
2391
      then // R?initialiser avec la valeur du mod?le
2392
        CheckBoxAsp.Checked := False
2393
      else // R?afficher la valeur du mod?le
2394
        CheckBoxAspClick(nil);
2395
      if CheckBoxGlu.Checked
2396
      then // R?initialiser avec la valeur du mod?le
2397
        CheckBoxGlu.Checked := False
2398
      else // R?afficher la valeur du mod?le
2399
        CheckBoxGluClick(nil);
2400
      if CheckBoxGly.Checked
2401
      then // R?initialiser avec la valeur du mod?le
2402
        CheckBoxGly.Checked := False
2403
      else // R?afficher la valeur du mod?le
2404
        CheckBoxGlyClick(nil);
2405
      if CheckBoxSer.Checked
2406
      then // R?initialiser avec la valeur du mod?le
2407
        CheckBoxSer.Checked := False
2408
      else // R?afficher la valeur du mod?le
2409
        CheckBoxSerClick(nil);
2410
      if CheckBoxPro.Checked
2411
      then // R?initialiser avec la valeur du mod?le
2412
        CheckBoxPro.Checked := False
2413
      else // R?afficher la valeur du mod?le
2414
        CheckBoxProClick(nil);
2415
    end;
2416
  end;
2417
end;
2418

    
2419
procedure TFormIngredientEditionCopy.ValidateEditPChange(Sender: TObject);
2420
begin
2421
  if ValidateEditP.AsFloat = 0
2422
  then // D?sactiver la saisie du phosphore digestible
2423
    DisabledP
2424
  else // Activer la saisie du phosphore digestible
2425
  begin
2426
    EnabledP;
2427
    if CheckBoxdP.Checked
2428
    then // R?initialiser avec la valeur du mod?le
2429
      CheckBoxdP.Checked := False
2430
    else // R?afficher la valeur du mod?le
2431
      CheckBoxdPClick(nil);
2432
    if CheckBoxdPphy.Checked
2433
    then // R?initialiser avec la valeur du mod?le
2434
      CheckBoxdPphy.Checked := False
2435
    else // R?afficher la valeur du mod?le
2436
      CheckBoxdPphyClick(nil);
2437
  end;
2438
end;
2439

    
2440
procedure TFormIngredientEditionCopy.NumEditKeyDown(Sender: TObject;
2441
  var Key: Word; Shift: TShiftState);
2442
begin
2443
  // D?tection de l'appui sur le s?parateur d?cimal du pav? num?rique
2444
  VK_Separator := (Key = VK_DECIMAL);
2445
end;
2446

    
2447
procedure TFormIngredientEditionCopy.NumEditKeyPress(Sender: TObject;
2448
  var Key: Char);
2449
begin
2450
  if VK_Separator then
2451
    // Renvoyer le s?parateur d?cimal des options r?gionales et linguistiques
2452
    Key := DecimalSeparator;
2453
end;
2454

    
2455
end.