Statistiques
| Révision:

root / UnitIngredientEditionCopy.pas @ 1

Historique | Voir | Annoter | Télécharger (89,324 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
    procedure FormCreate(Sender: TObject);
148
    procedure CheckBoxMATClick(Sender: TObject);
149
    procedure CheckBoxCBClick(Sender: TObject);
150
    procedure CheckBoxMGClick(Sender: TObject);
151
    procedure CheckBoxMMClick(Sender: TObject);
152
    procedure CheckBoxNDFClick(Sender: TObject);
153
    procedure CheckBoxADFClick(Sender: TObject);
154
    procedure CheckBoxADLClick(Sender: TObject);
155
    procedure CheckBoxAmidonClick(Sender: TObject);
156
    procedure CheckBoxSucresClick(Sender: TObject);
157
    procedure ComboBoxProximalChange(Sender: TObject);
158
    procedure ValidateEditMATChange(Sender: TObject);
159
    procedure ComboBoxMineralsChange(Sender: TObject);
160
    procedure CheckBoxCaClick(Sender: TObject);
161
    procedure CheckBoxPClick(Sender: TObject);
162
    procedure CheckBoxdPphyClick(Sender: TObject);
163
    procedure CheckBoxdPClick(Sender: TObject);
164
    procedure ValidateEditPChange(Sender: TObject);
165
    procedure CheckBoxLysClick(Sender: TObject);
166
    procedure CheckBoxThrClick(Sender: TObject);
167
    procedure CheckBoxMetClick(Sender: TObject);
168
    procedure CheckBoxCysClick(Sender: TObject);
169
    procedure CheckBoxMetCysClick(Sender: TObject);
170
    procedure CheckBoxTrpClick(Sender: TObject);
171
    procedure CheckBoxIleClick(Sender: TObject);
172
    procedure CheckBoxValClick(Sender: TObject);
173
    procedure CheckBoxLeuClick(Sender: TObject);
174
    procedure CheckBoxPheClick(Sender: TObject);
175
    procedure CheckBoxTyrClick(Sender: TObject);
176
    procedure CheckBoxPheTyrClick(Sender: TObject);
177
    procedure CheckBoxHisClick(Sender: TObject);
178
    procedure CheckBoxArgClick(Sender: TObject);
179
    procedure CheckBoxAlaClick(Sender: TObject);
180
    procedure CheckBoxAspClick(Sender: TObject);
181
    procedure CheckBoxGluClick(Sender: TObject);
182
    procedure CheckBoxGlyClick(Sender: TObject);
183
    procedure CheckBoxSerClick(Sender: TObject);
184
    procedure CheckBoxProClick(Sender: TObject);
185
    procedure ComboBoxAAChange(Sender: TObject);
186
    procedure ButtonRenameClick(Sender: TObject);
187
    procedure ButtonCommentClick(Sender: TObject);
188
    procedure ButtonHelpClick(Sender: TObject);
189
    procedure ActionRenameExecute(Sender: TObject);
190
    procedure ActionCommentExecute(Sender: TObject);
191
    procedure ActionHelpExecute(Sender: TObject);
192
    procedure ActionOKExecute(Sender: TObject);
193
    procedure ActionCancelExecute(Sender: TObject);
194
    procedure NumEditKeyDown(Sender: TObject; var Key: Word;
195
      Shift: TShiftState);
196
    procedure NumEditKeyPress(Sender: TObject; var Key: Char);
197
  private
198
    { D?clarations priv?es }
199
    ProximalUnit, MineralsUnit, AAUnit: Integer;
200
    procedure EditActivate(Edit: TJvValidateEdit);
201
    procedure EditEmpty(Edit: TJvValidateEdit);
202
    procedure EditShow(Edit: TJvValidateEdit; const Value: Double);
203
    procedure DisableAA;
204
    procedure DisabledP;
205
    procedure EnableAA;
206
    procedure EnabledP;
207
  public
208
    { D?clarations publiques }
209
  end;
210

    
211
var
212
  FormIngredientEditionCopy: TFormIngredientEditionCopy;
213

    
214
implementation
215

    
216
{$R *.dfm}
217

    
218
uses
219
  UnitDeclaration, UnitOptions, UnitRename, UnitComment, UnitIngredientsList;
220

    
221
var
222
  VK_Separator: boolean;
223

    
224
procedure TFormIngredientEditionCopy.ActionCancelExecute(Sender: TObject);
225
begin
226
  ModalResult := mrCancel;
227
end;
228

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

    
261
procedure TFormIngredientEditionCopy.ActionHelpExecute(Sender: TObject);
262
begin
263
  Application.HelpContext(HelpContext);
264
end;
265

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

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

    
833
procedure TFormIngredientEditionCopy.ButtonCommentClick(Sender: TObject);
834
begin
835
  ActionCommentExecute(Sender);
836
end;
837

    
838
procedure TFormIngredientEditionCopy.ButtonHelpClick(Sender: TObject);
839
begin
840
  ActionHelpExecute(Sender);
841
end;
842

    
843
procedure TFormIngredientEditionCopy.ButtonRenameClick(Sender: TObject);
844
begin
845
  ActionRenameExecute(Sender);
846
end;
847

    
848
procedure TFormIngredientEditionCopy.CheckBoxADFClick(Sender: TObject);
849
begin
850
  if CheckBoxADF.Checked
851
  then // Activer la saisie
852
    EditActivate(ValidateEditADF)
853
  else // Afficher la valeur par d?faut
854
    with DataModuleDeclaration do
855
      if ClientDataSetInraAfzADF.IsNull
856
      then // Null
857
        EditEmpty(ValidateEditADF)
858
      else // Valeur du mod?le
859
        EditShow(ValidateEditADF, OutputProximal(ClientDataSetInraAfzADF.Value, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
860
end;
861

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

    
876
procedure TFormIngredientEditionCopy.CheckBoxAlaClick(Sender: TObject);
877
begin
878
  if CheckBoxAla.Checked
879
  then // Activer la saisie
880
    EditActivate(ValidateEditAla)
881
  else // Afficher la valeur par d?faut
882
    with DataModuleDeclaration do
883
      if ClientDataSetInraAfzAla.IsNull or (RapMAT = 0)
884
      then // Null
885
        EditEmpty(ValidateEditAla)
886
      else // Valeur du mod?le
887
        EditShow(ValidateEditAla, OutputAA(ClientDataSetInraAfzAla.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
888
end;
889

    
890
procedure TFormIngredientEditionCopy.CheckBoxAmidonClick(Sender: TObject);
891
begin
892
  if CheckBoxAmidon.Checked
893
  then // Activer la saisie
894
    EditActivate(ValidateEditAmidon)
895
  else // Afficher la valeur par d?faut
896
    with DataModuleDeclaration do
897
      if ClientDataSetInraAfzAmidon.IsNull
898
      then // Null
899
        EditEmpty(ValidateEditAmidon)
900
      else // Valeur du mod?le
901
        EditShow(ValidateEditAmidon, OutputProximal(ClientDataSetInraAfzAmidon.Value, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
902
end;
903

    
904
procedure TFormIngredientEditionCopy.CheckBoxArgClick(Sender: TObject);
905
begin
906
  if CheckBoxArg.Checked
907
  then // Activer la saisie
908
    EditActivate(ValidateEditArg)
909
  else // Afficher la valeur par d?faut
910
    with DataModuleDeclaration do
911
      if ClientDataSetInraAfzArg.IsNull or (RapMAT = 0)
912
      then // Null
913
        EditEmpty(ValidateEditArg)
914
      else // Valeur du mod?le
915
        EditShow(ValidateEditArg, OutputAA(ClientDataSetInraAfzArg.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
916
end;
917

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

    
932
procedure TFormIngredientEditionCopy.CheckBoxCaClick(Sender: TObject);
933
begin
934
  if CheckBoxCa.Checked
935
  then // Activer la saisie
936
    EditActivate(ValidateEditCa)
937
  else // Afficher la valeur par d?faut
938
    with DataModuleDeclaration do
939
      if ClientDataSetInraAfzCa.IsNull
940
      then // Null
941
        EditEmpty(ValidateEditCa)
942
      else // Valeur du mod?le
943
        EditShow(ValidateEditCa, OutputMinerals(ClientDataSetInraAfzCa.Value, RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2));
944
end;
945

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

    
960
procedure TFormIngredientEditionCopy.CheckBoxCysClick(Sender: TObject);
961
begin
962
  if CheckBoxCys.Checked
963
  then // Activer la saisie
964
    EditActivate(ValidateEditCys)
965
  else // Afficher la valeur par d?faut
966
    with DataModuleDeclaration do
967
      if ClientDataSetInraAfzCys.IsNull or (RapMAT = 0)
968
      then // Null
969
        EditEmpty(ValidateEditCys)
970
      else // Valeur du mod?le
971
        EditShow(ValidateEditCys, OutputAA(ClientDataSetInraAfzCys.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
972
end;
973

    
974
procedure TFormIngredientEditionCopy.CheckBoxdPClick(Sender: TObject);
975
begin
976
  if CheckBoxdP.Checked
977
  then // Activer la saisie
978
    EditActivate(ValidateEditdP)
979
  else // Afficher la valeur par d?faut
980
    if ValidateEditP.AsFloat = 0
981
    then // Null
982
      EditEmpty(ValidateEditdP)
983
    else // Valeur du mod?le
984
      with DataModuleDeclaration do
985
        if ClientDataSetInraAfzdP.IsNull
986
        then // Par d?faut dP = 20%
987
          EditShow(ValidateEditdP, 20)
988
        else // Valeur du mod?le
989
          EditShow(ValidateEditdP, ClientDataSetInraAfzdP.Value * 100);
990
end;
991

    
992
procedure TFormIngredientEditionCopy.CheckBoxdPphyClick(Sender: TObject);
993
begin
994
  if CheckBoxdPphy.Checked
995
  then // Activer la saisie
996
    EditActivate(ValidateEditdPphy)
997
  else // Afficher la valeur par d?faut
998
    if ValidateEditP.AsFloat = 0
999
    then // Null
1000
      EditEmpty(ValidateEditdPphy)
1001
    else // Valeur du mod?le
1002
      with DataModuleDeclaration do
1003
        if ClientDataSetInraAfzdPphy.IsNull
1004
        then // Par d?faut dPphy = dP
1005
          EditShow(ValidateEditdPphy, ValidateEditdP.AsFloat)
1006
        else // Valeur du mod?le
1007
          EditShow(ValidateEditdPphy, ClientDataSetInraAfzdPphy.Value * 100);
1008
end;
1009

    
1010
procedure TFormIngredientEditionCopy.CheckBoxGluClick(Sender: TObject);
1011
begin
1012
  if CheckBoxGlu.Checked
1013
  then // Activer la saisie
1014
    EditActivate(ValidateEditGlu)
1015
  else // Afficher la valeur par d?faut
1016
    with DataModuleDeclaration do
1017
      if ClientDataSetInraAfzGlu.IsNull or (RapMAT = 0)
1018
      then // Null
1019
        EditEmpty(ValidateEditGlu)
1020
      else // Valeur du mod?le
1021
        EditShow(ValidateEditGlu, OutputAA(ClientDataSetInraAfzGlu.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1022
end;
1023

    
1024
procedure TFormIngredientEditionCopy.CheckBoxGlyClick(Sender: TObject);
1025
begin
1026
  if CheckBoxGly.Checked
1027
  then // Activer la saisie
1028
    EditActivate(ValidateEditGly)
1029
  else // Afficher la valeur par d?faut
1030
    with DataModuleDeclaration do
1031
      if ClientDataSetInraAfzGly.IsNull or (RapMAT = 0)
1032
      then // Null
1033
        EditEmpty(ValidateEditGly)
1034
      else // Valeur du mod?le
1035
        EditShow(ValidateEditGly, OutputAA(ClientDataSetInraAfzGly.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1036
end;
1037

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

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

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

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

    
1094
procedure TFormIngredientEditionCopy.CheckBoxMATClick(Sender: TObject);
1095
begin
1096
  if CheckBoxMAT.Checked
1097
  then // Activer la saisie
1098
    EditActivate(ValidateEditMAT)
1099
  else // Afficher la valeur par d?faut
1100
    with DataModuleDeclaration do
1101
      if ClientDataSetInraAfzMAT.IsNull
1102
      then // Null
1103
      begin
1104
        RapMAT := 0;
1105
        EditEmpty(ValidateEditMAT);
1106
      end
1107
      else // Valeur du mod?le
1108
      begin
1109
        RapMAT := ClientDataSetInraAfzMAT.Value;
1110
        EditShow(ValidateEditMAT, OutputProximal(RapMAT, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
1111
      end;
1112
end;
1113

    
1114
procedure TFormIngredientEditionCopy.CheckBoxMetClick(Sender: TObject);
1115
begin
1116
  if CheckBoxMet.Checked
1117
  then // Activer la saisie
1118
    EditActivate(ValidateEditMet)
1119
  else // Afficher la valeur par d?faut
1120
    with DataModuleDeclaration do
1121
      if ClientDataSetInraAfzMet.IsNull or (RapMAT = 0)
1122
      then // Null
1123
        EditEmpty(ValidateEditMet)
1124
      else // Valeur du mod?le
1125
        EditShow(ValidateEditMet, OutputAA(ClientDataSetInraAfzMet.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1126
end;
1127

    
1128
procedure TFormIngredientEditionCopy.CheckBoxMetCysClick(Sender: TObject);
1129
begin
1130
  if CheckBoxMetCys.Checked
1131
  then // Activer la saisie
1132
    EditActivate(ValidateEditMetCys)
1133
  else // Afficher la valeur par d?faut
1134
    with DataModuleDeclaration do
1135
      if ClientDataSetInraAfzMetCys.IsNull or (RapMAT = 0)
1136
      then // Null
1137
        EditEmpty(ValidateEditMetCys)
1138
      else // Valeur du mod?le
1139
        EditShow(ValidateEditMetCys, OutputAA(ClientDataSetInraAfzMetCys.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1140
end;
1141

    
1142
procedure TFormIngredientEditionCopy.CheckBoxMGClick(Sender: TObject);
1143
begin
1144
  if CheckBoxMG.Checked
1145
  then // Activer la saisie
1146
    EditActivate(ValidateEditMG)
1147
  else // Afficher la valeur par d?faut
1148
    with DataModuleDeclaration do
1149
      if ClientDataSetInraAfzMG.IsNull
1150
      then // Null
1151
        EditEmpty(ValidateEditMG)
1152
      else // Valeur du mod?le
1153
        EditShow(ValidateEditMG, OutputProximal(ClientDataSetInraAfzMG.Value, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
1154
end;
1155

    
1156
procedure TFormIngredientEditionCopy.CheckBoxMMClick(Sender: TObject);
1157
begin
1158
  if CheckBoxMM.Checked
1159
  then // Activer la saisie
1160
    EditActivate(ValidateEditMM)
1161
  else // Afficher la valeur par d?faut
1162
    with DataModuleDeclaration do
1163
      if ClientDataSetInraAfzMM.IsNull
1164
      then // Null
1165
        EditEmpty(ValidateEditMM)
1166
      else // Valeur du mod?le
1167
        EditShow(ValidateEditMM, OutputProximal(ClientDataSetInraAfzMM.Value, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
1168
end;
1169

    
1170
procedure TFormIngredientEditionCopy.CheckBoxNDFClick(Sender: TObject);
1171
begin
1172
  if CheckBoxNDF.Checked
1173
  then // Activer la saisie
1174
    EditActivate(ValidateEditNDF)
1175
  else // Afficher la valeur par d?faut
1176
    with DataModuleDeclaration do
1177
      if ClientDataSetInraAfzNDF.IsNull
1178
      then // Null
1179
        EditEmpty(ValidateEditNDF)
1180
      else // Valeur du mod?le
1181
        EditShow(ValidateEditNDF, OutputProximal(ClientDataSetInraAfzNDF.Value, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
1182
end;
1183

    
1184
procedure TFormIngredientEditionCopy.CheckBoxPClick(Sender: TObject);
1185
begin
1186
  if CheckBoxP.Checked
1187
  then // Activer la saisie
1188
    EditActivate(ValidateEditP)
1189
  else // Afficher la valeur par d?faut
1190
    with DataModuleDeclaration do
1191
      if ClientDataSetInraAfzP.IsNull
1192
      then // Null
1193
      begin
1194
        EditEmpty(ValidateEditP);
1195
        // D?sactiver la saisie du phosphore digestible
1196
        DisabledP;
1197
      end
1198
      else // Valeur du mod?le
1199
        EditShow(ValidateEditP, OutputMinerals(ClientDataSetInraAfzP.Value, RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2));
1200
end;
1201

    
1202
procedure TFormIngredientEditionCopy.CheckBoxPheClick(Sender: TObject);
1203
begin
1204
  if CheckBoxPhe.Checked
1205
  then // Activer la saisie
1206
    EditActivate(ValidateEditPhe)
1207
  else // Afficher la valeur par d?faut
1208
    with DataModuleDeclaration do
1209
      if ClientDataSetInraAfzPhe.IsNull or (RapMAT = 0)
1210
      then // Null
1211
        EditEmpty(ValidateEditPhe)
1212
      else // Valeur du mod?le
1213
        EditShow(ValidateEditPhe, OutputAA(ClientDataSetInraAfzPhe.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1214
end;
1215

    
1216
procedure TFormIngredientEditionCopy.CheckBoxPheTyrClick(Sender: TObject);
1217
begin
1218
  if CheckBoxPheTyr.Checked
1219
  then // Activer la saisie
1220
    EditActivate(ValidateEditPheTyr)
1221
  else // Afficher la valeur par d?faut
1222
    with DataModuleDeclaration do
1223
      if ClientDataSetInraAfzPheTyr.IsNull or (RapMAT = 0)
1224
      then // Null
1225
        EditEmpty(ValidateEditPheTyr)
1226
      else // Valeur du mod?le
1227
        EditShow(ValidateEditPheTyr, OutputAA(ClientDataSetInraAfzPheTyr.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1228
end;
1229

    
1230
procedure TFormIngredientEditionCopy.CheckBoxProClick(Sender: TObject);
1231
begin
1232
  if CheckBoxPro.Checked
1233
  then // Activer la saisie
1234
    EditActivate(ValidateEditPro)
1235
  else // Afficher la valeur par d?faut
1236
    with DataModuleDeclaration do
1237
      if ClientDataSetInraAfzPro.IsNull or (RapMAT = 0)
1238
      then // Null
1239
        EditEmpty(ValidateEditPro)
1240
      else // Valeur du mod?le
1241
        EditShow(ValidateEditPro, OutputAA(ClientDataSetInraAfzPro.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1242
end;
1243

    
1244
procedure TFormIngredientEditionCopy.CheckBoxSerClick(Sender: TObject);
1245
begin
1246
  if CheckBoxSer.Checked
1247
  then // Activer la saisie
1248
    EditActivate(ValidateEditSer)
1249
  else // Afficher la valeur par d?faut
1250
    with DataModuleDeclaration do
1251
      if ClientDataSetInraAfzSer.IsNull or (RapMAT = 0)
1252
      then // Null
1253
        EditEmpty(ValidateEditSer)
1254
      else // Valeur du mod?le
1255
        EditShow(ValidateEditSer, OutputAA(ClientDataSetInraAfzSer.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1256
end;
1257

    
1258
procedure TFormIngredientEditionCopy.CheckBoxSucresClick(Sender: TObject);
1259
begin
1260
  if CheckBoxSucres.Checked
1261
  then // Activer la saisie
1262
    EditActivate(ValidateEditSucres)
1263
  else // Afficher la valeur par d?faut
1264
    with DataModuleDeclaration do
1265
      if ClientDataSetInraAfzSucres.IsNull
1266
      then // Null
1267
        EditEmpty(ValidateEditSucres)
1268
      else // Valeur du mod?le
1269
        EditShow(ValidateEditSucres, OutputProximal(ClientDataSetInraAfzSucres.Value, RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2));
1270
end;
1271

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

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

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

    
1314
procedure TFormIngredientEditionCopy.CheckBoxValClick(Sender: TObject);
1315
begin
1316
  if CheckBoxVal.Checked
1317
  then // Activer la saisie
1318
    EditActivate(ValidateEditVal)
1319
  else // Afficher la valeur par d?faut
1320
    with DataModuleDeclaration do
1321
      if ClientDataSetInraAfzVal.IsNull or (RapMAT = 0)
1322
      then // Null
1323
        EditEmpty(ValidateEditVal)
1324
      else // Valeur du mod?le
1325
        EditShow(ValidateEditVal, OutputAA(ClientDataSetInraAfzVal.Value, RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2));
1326
end;
1327

    
1328
procedure TFormIngredientEditionCopy.ComboBoxAAChange(Sender: TObject);
1329
begin
1330
  if ComboBoxAA.ItemIndex <> AAUnit
1331
  then // Changement d'unit?
1332
  begin
1333
    if ComboBoxAA.ItemIndex mod 2 = 0
1334
    then // %
1335
    begin
1336
      ValidateEditLys.DecimalPlaces := 2;
1337
      ValidateEditThr.DecimalPlaces := 2;
1338
      ValidateEditMet.DecimalPlaces := 2;
1339
      ValidateEditCys.DecimalPlaces := 2;
1340
      ValidateEditMetCys.DecimalPlaces := 2;
1341
      ValidateEditTrp.DecimalPlaces := 2;
1342
      ValidateEditIle.DecimalPlaces := 2;
1343
      ValidateEditVal.DecimalPlaces := 2;
1344
      ValidateEditLeu.DecimalPlaces := 2;
1345
      ValidateEditPhe.DecimalPlaces := 2;
1346
      ValidateEditTyr.DecimalPlaces := 2;
1347
      ValidateEditPheTyr.DecimalPlaces := 2;
1348
      ValidateEditHis.DecimalPlaces := 2;
1349
      ValidateEditArg.DecimalPlaces := 2;
1350
      ValidateEditAla.DecimalPlaces := 2;
1351
      ValidateEditAsp.DecimalPlaces := 2;
1352
      ValidateEditGlu.DecimalPlaces := 2;
1353
      ValidateEditGly.DecimalPlaces := 2;
1354
      ValidateEditSer.DecimalPlaces := 2;
1355
      ValidateEditPro.DecimalPlaces := 2;
1356
    end
1357
    else // g/kg
1358
    begin
1359
      ValidateEditLys.MaxValue := 1000;
1360
      ValidateEditThr.MaxValue := 1000;
1361
      ValidateEditMet.MaxValue := 1000;
1362
      ValidateEditCys.MaxValue := 1000;
1363
      ValidateEditMetCys.MaxValue := 1000;
1364
      ValidateEditTrp.MaxValue := 1000;
1365
      ValidateEditIle.MaxValue := 1000;
1366
      ValidateEditVal.MaxValue := 1000;
1367
      ValidateEditLeu.MaxValue := 1000;
1368
      ValidateEditPhe.MaxValue := 1000;
1369
      ValidateEditTyr.MaxValue := 1000;
1370
      ValidateEditPheTyr.MaxValue := 1000;
1371
      ValidateEditHis.MaxValue := 1000;
1372
      ValidateEditArg.MaxValue := 1000;
1373
      ValidateEditAla.MaxValue := 1000;
1374
      ValidateEditAsp.MaxValue := 1000;
1375
      ValidateEditGlu.MaxValue := 1000;
1376
      ValidateEditGly.MaxValue := 1000;
1377
      ValidateEditSer.MaxValue := 1000;
1378
      ValidateEditPro.MaxValue := 1000;
1379
    end;
1380
    if AAUnit <> -1
1381
    then
1382
      with DataModuleDeclaration do
1383
      begin
1384
        if CheckBoxLys.Checked
1385
        then // Conversion
1386
          ValidateEditLys.AsFloat := OutputAA(InputAA(ValidateEditLys.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1387
        else
1388
          CheckBoxLysClick(nil);
1389
        if CheckBoxThr.Checked
1390
        then // Conversion
1391
          ValidateEditThr.AsFloat := OutputAA(InputAA(ValidateEditThr.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1392
        else
1393
          CheckBoxThrClick(nil);
1394
        if CheckBoxMet.Checked
1395
        then // Conversion
1396
          ValidateEditMet.AsFloat := OutputAA(InputAA(ValidateEditMet.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1397
        else
1398
          CheckBoxMetClick(nil);
1399
        if CheckBoxCys.Checked
1400
        then // Conversion
1401
          ValidateEditCys.AsFloat := OutputAA(InputAA(ValidateEditCys.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1402
        else
1403
          CheckBoxCysClick(nil);
1404
        if CheckBoxMetCys.Checked
1405
        then // Conversion
1406
          ValidateEditMetCys.AsFloat := OutputAA(InputAA(ValidateEditMetCys.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1407
        else
1408
          CheckBoxMetCysClick(nil);
1409
        if CheckBoxTrp.Checked
1410
        then // Conversion
1411
          ValidateEditTrp.AsFloat := OutputAA(InputAA(ValidateEditTrp.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1412
        else
1413
          CheckBoxTrpClick(nil);
1414
        if CheckBoxIle.Checked
1415
        then // Conversion
1416
          ValidateEditIle.AsFloat := OutputAA(InputAA(ValidateEditIle.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1417
        else
1418
          CheckBoxIleClick(nil);
1419
        if CheckBoxVal.Checked
1420
        then // Conversion
1421
          ValidateEditVal.AsFloat := OutputAA(InputAA(ValidateEditVal.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1422
        else
1423
          CheckBoxValClick(nil);
1424
        if CheckBoxLeu.Checked
1425
        then // Conversion
1426
          ValidateEditLeu.AsFloat := OutputAA(InputAA(ValidateEditLeu.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1427
        else
1428
          CheckBoxLeuClick(nil);
1429
        if CheckBoxPhe.Checked
1430
        then // Conversion
1431
          ValidateEditPhe.AsFloat := OutputAA(InputAA(ValidateEditPhe.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1432
        else
1433
          CheckBoxPheClick(nil);
1434
        if CheckBoxTyr.Checked
1435
        then // Conversion
1436
          ValidateEditTyr.AsFloat := OutputAA(InputAA(ValidateEditTyr.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1437
        else
1438
          CheckBoxTyrClick(nil);
1439
        if CheckBoxPheTyr.Checked
1440
        then // Conversion
1441
          ValidateEditPheTyr.AsFloat := OutputAA(InputAA(ValidateEditPheTyr.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1442
        else
1443
          CheckBoxPheTyrClick(nil);
1444
        if CheckBoxHis.Checked
1445
        then // Conversion
1446
          ValidateEditHis.AsFloat := OutputAA(InputAA(ValidateEditHis.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1447
        else
1448
          CheckBoxHisClick(nil);
1449
        if CheckBoxArg.Checked
1450
        then // Conversion
1451
          ValidateEditArg.AsFloat := OutputAA(InputAA(ValidateEditArg.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1452
        else
1453
          CheckBoxArgClick(nil);
1454
        if CheckBoxAla.Checked
1455
        then // Conversion
1456
          ValidateEditAla.AsFloat := OutputAA(InputAA(ValidateEditAla.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1457
        else
1458
          CheckBoxAlaClick(nil);
1459
        if CheckBoxAsp.Checked
1460
        then // Conversion
1461
          ValidateEditAsp.AsFloat := OutputAA(InputAA(ValidateEditAsp.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1462
        else
1463
          CheckBoxAspClick(nil);
1464
        if CheckBoxGlu.Checked
1465
        then // Conversion
1466
          ValidateEditGlu.AsFloat := OutputAA(InputAA(ValidateEditGlu.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1467
        else
1468
          CheckBoxGluClick(nil);
1469
        if CheckBoxGly.Checked
1470
        then // Conversion
1471
          ValidateEditGly.AsFloat := OutputAA(InputAA(ValidateEditGly.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1472
        else
1473
          CheckBoxGlyClick(nil);
1474
        if CheckBoxSer.Checked
1475
        then // Conversion
1476
          ValidateEditSer.AsFloat := OutputAA(InputAA(ValidateEditSer.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1477
        else
1478
          CheckBoxSerClick(nil);
1479
        if CheckBoxPro.Checked
1480
        then // Conversion
1481
          ValidateEditPro.AsFloat := OutputAA(InputAA(ValidateEditPro.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2)
1482
        else
1483
          CheckBoxProClick(nil);
1484
      end;
1485
    if ComboBoxAA.ItemIndex mod 2 = 0
1486
    then // %
1487
    begin
1488
      ValidateEditLys.MaxValue := 100;
1489
      ValidateEditThr.MaxValue := 100;
1490
      ValidateEditMet.MaxValue := 100;
1491
      ValidateEditCys.MaxValue := 100;
1492
      ValidateEditMetCys.MaxValue := 100;
1493
      ValidateEditTrp.MaxValue := 100;
1494
      ValidateEditIle.MaxValue := 100;
1495
      ValidateEditVal.MaxValue := 100;
1496
      ValidateEditLeu.MaxValue := 100;
1497
      ValidateEditPhe.MaxValue := 100;
1498
      ValidateEditTyr.MaxValue := 100;
1499
      ValidateEditPheTyr.MaxValue := 100;
1500
      ValidateEditHis.MaxValue := 100;
1501
      ValidateEditArg.MaxValue := 100;
1502
      ValidateEditAla.MaxValue := 100;
1503
      ValidateEditAsp.MaxValue := 100;
1504
      ValidateEditGlu.MaxValue := 100;
1505
      ValidateEditGly.MaxValue := 100;
1506
      ValidateEditSer.MaxValue := 100;
1507
      ValidateEditPro.MaxValue := 100;
1508
    end
1509
    else // g/kg
1510
    begin
1511
      ValidateEditLys.DecimalPlaces := 1;
1512
      ValidateEditThr.DecimalPlaces := 1;
1513
      ValidateEditMet.DecimalPlaces := 1;
1514
      ValidateEditCys.DecimalPlaces := 1;
1515
      ValidateEditMetCys.DecimalPlaces := 1;
1516
      ValidateEditTrp.DecimalPlaces := 1;
1517
      ValidateEditIle.DecimalPlaces := 1;
1518
      ValidateEditVal.DecimalPlaces := 1;
1519
      ValidateEditLeu.DecimalPlaces := 1;
1520
      ValidateEditPhe.DecimalPlaces := 1;
1521
      ValidateEditTyr.DecimalPlaces := 1;
1522
      ValidateEditPheTyr.DecimalPlaces := 1;
1523
      ValidateEditHis.DecimalPlaces := 1;
1524
      ValidateEditArg.DecimalPlaces := 1;
1525
      ValidateEditAla.DecimalPlaces := 1;
1526
      ValidateEditAsp.DecimalPlaces := 1;
1527
      ValidateEditGlu.DecimalPlaces := 1;
1528
      ValidateEditGly.DecimalPlaces := 1;
1529
      ValidateEditSer.DecimalPlaces := 1;
1530
      ValidateEditPro.DecimalPlaces := 1;
1531
    end;
1532
    AAUnit := ComboBoxAA.ItemIndex;
1533
  end;
1534
end;
1535

    
1536
procedure TFormIngredientEditionCopy.ComboBoxMineralsChange(Sender: TObject);
1537
begin
1538
  if ComboBoxMinerals.ItemIndex <> MineralsUnit
1539
  then // Changement d'unit?
1540
  begin
1541
    if ComboBoxMinerals.ItemIndex mod 2 = 0
1542
    then // %
1543
    begin
1544
      ValidateEditCa.DecimalPlaces := 2;
1545
      ValidateEditP.DecimalPlaces := 2;
1546
    end
1547
    else // g/kg
1548
    begin
1549
      ValidateEditCa.MaxValue := 1000;
1550
      ValidateEditP.MaxValue := 1000;
1551
    end;
1552
    with DataModuleDeclaration do
1553
    begin
1554
      if CheckBoxCa.Checked
1555
      then // Conversion
1556
          ValidateEditCa.AsFloat := OutputMinerals(InputMinerals(ValidateEditCa.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2), RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2)
1557
      else
1558
        CheckBoxCaClick(nil);
1559
      if CheckBoxP.Checked
1560
      then // Conversion
1561
          ValidateEditP.AsFloat := OutputMinerals(InputMinerals(ValidateEditP.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2), RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2)
1562
      else
1563
        CheckBoxPClick(nil);
1564
    end;
1565
    if ComboBoxMinerals.ItemIndex mod 2 = 0
1566
    then // %
1567
    begin
1568
      ValidateEditCa.MaxValue := 100;
1569
      ValidateEditP.MaxValue := 100;
1570
    end
1571
    else // g/kg
1572
    begin
1573
      ValidateEditCa.DecimalPlaces := 1;
1574
      ValidateEditP.DecimalPlaces := 1;
1575
    end;
1576
    MineralsUnit := ComboBoxMinerals.ItemIndex;
1577
  end;
1578
end;
1579

    
1580
procedure TFormIngredientEditionCopy.ComboBoxProximalChange(Sender: TObject);
1581
begin
1582
  if ComboBoxProximal.ItemIndex <> ProximalUnit
1583
  then // Changement d'unit?
1584
  begin
1585
    if ComboBoxProximal.ItemIndex mod 2 = 0
1586
    then // %
1587
    begin
1588
      ValidateEditMM.DecimalPlaces := 2;
1589
      ValidateEditMAT.DecimalPlaces := 2;
1590
      ValidateEditMG.DecimalPlaces := 2;
1591
      ValidateEditCB.DecimalPlaces := 2;
1592
      ValidateEditNDF.DecimalPlaces := 2;
1593
      ValidateEditADF.DecimalPlaces := 2;
1594
      ValidateEditADL.DecimalPlaces := 2;
1595
      ValidateEditAmidon.DecimalPlaces := 2;
1596
      ValidateEditSucres.DecimalPlaces := 2;
1597
    end
1598
    else // g/kg
1599
    begin
1600
      ValidateEditMM.MaxValue := 1000;
1601
      ValidateEditMAT.MaxValue := 1000;
1602
      ValidateEditMG.MaxValue := 1000;
1603
      ValidateEditCB.MaxValue := 1000;
1604
      ValidateEditNDF.MaxValue := 1000;
1605
      ValidateEditADF.MaxValue := 1000;
1606
      ValidateEditADL.MaxValue := 1000;
1607
      ValidateEditAmidon.MaxValue := 1000;
1608
      ValidateEditSucres.MaxValue := 1000;
1609
    end;
1610
    if CheckBoxMM.Checked
1611
    then // Conversion
1612
      with DataModuleDeclaration do
1613
        ValidateEditMM.AsFloat := OutputProximal(InputProximal(ValidateEditMM.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1614
    else
1615
      CheckBoxMMClick(nil);
1616
    if CheckBoxMAT.Checked
1617
    then // Conversion
1618
      with DataModuleDeclaration do
1619
        ValidateEditMAT.AsFloat := OutputProximal(InputProximal(ValidateEditMAT.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1620
    else
1621
      CheckBoxMATClick(nil);
1622
    if CheckBoxMG.Checked
1623
    then // Conversion
1624
      with DataModuleDeclaration do
1625
        ValidateEditMG.AsFloat := OutputProximal(InputProximal(ValidateEditMG.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1626
    else
1627
      CheckBoxMGClick(nil);
1628
    if CheckBoxCB.Checked
1629
    then // Conversion
1630
      with DataModuleDeclaration do
1631
        ValidateEditCB.AsFloat := OutputProximal(InputProximal(ValidateEditCB.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1632
    else
1633
      CheckBoxCBClick(nil);
1634
    if CheckBoxNDF.Checked
1635
    then // Conversion
1636
      with DataModuleDeclaration do
1637
        ValidateEditNDF.AsFloat := OutputProximal(InputProximal(ValidateEditNDF.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1638
    else
1639
      CheckBoxNDFClick(nil);
1640
    if CheckBoxADF.Checked
1641
    then // Conversion
1642
      with DataModuleDeclaration do
1643
        ValidateEditADF.AsFloat := OutputProximal(InputProximal(ValidateEditADF.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1644
    else
1645
      CheckBoxADFClick(nil);
1646
    if CheckBoxADL.Checked
1647
    then // Conversion
1648
      with DataModuleDeclaration do
1649
        ValidateEditADL.AsFloat := OutputProximal(InputProximal(ValidateEditADL.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1650
    else
1651
      CheckBoxADLClick(nil);
1652
    if CheckBoxAmidon.Checked
1653
    then // Conversion
1654
      with DataModuleDeclaration do
1655
        ValidateEditAmidon.AsFloat := OutputProximal(InputProximal(ValidateEditAmidon.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1656
    else
1657
      CheckBoxAmidonClick(nil);
1658
    if CheckBoxSucres.Checked
1659
    then // Conversion
1660
      with DataModuleDeclaration do
1661
        ValidateEditSucres.AsFloat := OutputProximal(InputProximal(ValidateEditSucres.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2)
1662
    else
1663
      CheckBoxSucresClick(nil);
1664
    if ComboBoxProximal.ItemIndex mod 2 = 0
1665
    then // %
1666
    begin
1667
      ValidateEditMM.MaxValue := 100;
1668
      ValidateEditMAT.MaxValue := 100;
1669
      ValidateEditMG.MaxValue := 100;
1670
      ValidateEditCB.MaxValue := 100;
1671
      ValidateEditNDF.MaxValue := 100;
1672
      ValidateEditADF.MaxValue := 100;
1673
      ValidateEditADL.MaxValue := 100;
1674
      ValidateEditAmidon.MaxValue := 100;
1675
      ValidateEditSucres.MaxValue := 100;
1676
    end
1677
    else // g/kg
1678
    begin
1679
      ValidateEditMM.DecimalPlaces := 1;
1680
      ValidateEditMAT.DecimalPlaces := 1;
1681
      ValidateEditMG.DecimalPlaces := 1;
1682
      ValidateEditCB.DecimalPlaces := 1;
1683
      ValidateEditNDF.DecimalPlaces := 1;
1684
      ValidateEditADF.DecimalPlaces := 1;
1685
      ValidateEditADL.DecimalPlaces := 1;
1686
      ValidateEditAmidon.DecimalPlaces := 1;
1687
      ValidateEditSucres.DecimalPlaces := 1;
1688
    end;
1689
    ProximalUnit := ComboBoxProximal.ItemIndex;
1690
  end;
1691
end;
1692

    
1693
procedure TFormIngredientEditionCopy.DisableAA;
1694
begin
1695
  if CheckBoxLys.Checked
1696
  then
1697
    CheckBoxLys.Checked := False
1698
  else
1699
    CheckBoxLysClick(nil);
1700
  if CheckBoxThr.Checked
1701
  then
1702
    CheckBoxThr.Checked := False
1703
  else
1704
    CheckBoxThrClick(nil);
1705
  if CheckBoxMet.Checked
1706
  then
1707
    CheckBoxMet.Checked := False
1708
  else
1709
    CheckBoxMetClick(nil);
1710
  if CheckBoxCys.Checked
1711
  then
1712
    CheckBoxCys.Checked := False
1713
  else
1714
    CheckBoxCysClick(nil);
1715
  if CheckBoxMetCys.Checked
1716
  then
1717
    CheckBoxMetCys.Checked := False
1718
  else
1719
    CheckBoxMetCysClick(nil);
1720
  if CheckBoxTrp.Checked
1721
  then
1722
    CheckBoxTrp.Checked := False
1723
  else
1724
    CheckBoxTrpClick(nil);
1725
  if CheckBoxIle.Checked
1726
  then
1727
    CheckBoxIle.Checked := False
1728
  else
1729
    CheckBoxIleClick(nil);
1730
  if CheckBoxVal.Checked
1731
  then
1732
    CheckBoxVal.Checked := False
1733
  else
1734
    CheckBoxValClick(nil);
1735
  if CheckBoxLeu.Checked
1736
  then
1737
    CheckBoxLeu.Checked := False
1738
  else
1739
    CheckBoxLeuClick(nil);
1740
  if CheckBoxPhe.Checked
1741
  then
1742
    CheckBoxPhe.Checked := False
1743
  else
1744
    CheckBoxPheClick(nil);
1745
  if CheckBoxTyr.Checked
1746
  then
1747
    CheckBoxTyr.Checked := False
1748
  else
1749
    CheckBoxTyrClick(nil);
1750
  if CheckBoxPheTyr.Checked
1751
  then
1752
    CheckBoxPheTyr.Checked := False
1753
  else
1754
    CheckBoxPheTyrClick(nil);
1755
  if CheckBoxHis.Checked
1756
  then
1757
    CheckBoxHis.Checked := False
1758
  else
1759
    CheckBoxHisClick(nil);
1760
  if CheckBoxArg.Checked
1761
  then
1762
    CheckBoxArg.Checked := False
1763
  else
1764
    CheckBoxArgClick(nil);
1765
  if CheckBoxAla.Checked
1766
  then
1767
    CheckBoxAla.Checked := False
1768
  else
1769
    CheckBoxAlaClick(nil);
1770
  if CheckBoxAsp.Checked
1771
  then
1772
    CheckBoxAsp.Checked := False
1773
  else
1774
    CheckBoxAspClick(nil);
1775
  if CheckBoxGlu.Checked
1776
  then
1777
    CheckBoxGlu.Checked := False
1778
  else
1779
    CheckBoxGluClick(nil);
1780
  if CheckBoxGly.Checked
1781
  then
1782
    CheckBoxGly.Checked := False
1783
  else
1784
    CheckBoxGlyClick(nil);
1785
  if CheckBoxSer.Checked
1786
  then
1787
    CheckBoxSer.Checked := False
1788
  else
1789
    CheckBoxSerClick(nil);
1790
  if CheckBoxPro.Checked
1791
  then
1792
    CheckBoxPro.Checked := False
1793
  else
1794
    CheckBoxProClick(nil);
1795
  // Verrouillage
1796
  CheckBoxLys.Enabled := False;
1797
  CheckBoxThr.Enabled := False;
1798
  CheckBoxMet.Enabled := False;
1799
  CheckBoxCys.Enabled := False;
1800
  CheckBoxMetCys.Enabled := False;
1801
  CheckBoxTrp.Enabled := False;
1802
  CheckBoxIle.Enabled := False;
1803
  CheckBoxVal.Enabled := False;
1804
  CheckBoxLeu.Enabled := False;
1805
  CheckBoxPhe.Enabled := False;
1806
  CheckBoxTyr.Enabled := False;
1807
  CheckBoxPheTyr.Enabled := False;
1808
  CheckBoxHis.Enabled := False;
1809
  CheckBoxArg.Enabled := False;
1810
  CheckBoxAla.Enabled := False;
1811
  CheckBoxAsp.Enabled := False;
1812
  CheckBoxGlu.Enabled := False;
1813
  CheckBoxGly.Enabled := False;
1814
  CheckBoxSer.Enabled := False;
1815
  CheckBoxPro.Enabled := False;
1816
end;
1817

    
1818
procedure TFormIngredientEditionCopy.DisabledP;
1819
begin
1820
  if CheckBoxdPphy.Checked
1821
  then
1822
    CheckBoxdPphy.Checked := False
1823
  else
1824
    CheckBoxdPphyClick(nil);
1825
  if CheckBoxdP.Checked
1826
  then
1827
    CheckBoxdP.Checked := False
1828
  else
1829
    CheckBoxdPClick(nil);
1830
  // Verrouillage
1831
  CheckBoxdPphy.Enabled := False;
1832
  CheckBoxdP.Enabled := False;
1833
end;
1834

    
1835
procedure TFormIngredientEditionCopy.EnableAA;
1836
begin
1837
  CheckBoxLys.Enabled := True;
1838
  CheckBoxThr.Enabled := True;
1839
  CheckBoxMet.Enabled := True;
1840
  CheckBoxCys.Enabled := True;
1841
  CheckBoxMetCys.Enabled := True;
1842
  CheckBoxTrp.Enabled := True;
1843
  CheckBoxIle.Enabled := True;
1844
  CheckBoxVal.Enabled := True;
1845
  CheckBoxLeu.Enabled := True;
1846
  CheckBoxPhe.Enabled := True;
1847
  CheckBoxTyr.Enabled := True;
1848
  CheckBoxPheTyr.Enabled := True;
1849
  CheckBoxHis.Enabled := True;
1850
  CheckBoxArg.Enabled := True;
1851
  CheckBoxAla.Enabled := True;
1852
  CheckBoxAsp.Enabled := True;
1853
  CheckBoxGlu.Enabled := True;
1854
  CheckBoxGly.Enabled := True;
1855
  CheckBoxSer.Enabled := True;
1856
  CheckBoxPro.Enabled := True;
1857
end;
1858

    
1859
procedure TFormIngredientEditionCopy.EnabledP;
1860
begin
1861
  CheckBoxdPphy.Enabled := True;
1862
  CheckBoxdP.Enabled := True;
1863
end;
1864

    
1865
procedure TFormIngredientEditionCopy.EditActivate(Edit: TJvValidateEdit);
1866
begin
1867
  Edit.DisplayFormat := dfFloat;
1868
  Edit.Enabled := True;
1869
  ActiveControl := Edit;
1870
  Edit.SelectAll;
1871
end;
1872

    
1873
procedure TFormIngredientEditionCopy.EditEmpty(Edit: TJvValidateEdit);
1874
begin
1875
  Edit.DisplayFormat := dfNone;
1876
  Edit.Value := '';
1877
  Edit.Enabled := False;
1878
end;
1879

    
1880
procedure TFormIngredientEditionCopy.EditShow(Edit: TJvValidateEdit; const Value: Double);
1881
begin
1882
  Edit.DisplayFormat := dfFloat;
1883
  Edit.AsFloat := Value;
1884
  Edit.Enabled := False;
1885
end;
1886

    
1887
procedure TFormIngredientEditionCopy.FormCreate(Sender: TObject);
1888
var
1889
  i: Integer;
1890
begin
1891
  if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1
1892
  then
1893
    Font.Name := 'Arial Unicode MS';
1894
//  PanelButtons.Font.Size := PanelButtons.Font.Size + 2;
1895
  PanelButtons.Font.Style := [fsBold];
1896
  LabelName.Font.Style := [fsBold];
1897
  DBEditName.Font.Style := [fsBold];
1898
  TranslateComponent(Self);
1899
  with FormOptions do
1900
    LabelMS.Caption := Format('%s (%s)', [LabelMS.Caption, ComboBoxProximal.Items[Proximal]]);
1901
  for i := 0 to FormOptions.ComboBoxProximal.Items.Count - 1 do
1902
    ComboBoxProximal.Items.Add(Format('%s %s', [FormOptions.ComboBoxProximal.Items[i], _('DM')]));
1903
  ProximalUnit := -1;
1904
  ComboBoxProximal.ItemIndex := FormOptions.Proximal + 2 * FormOptions.Expression;
1905
  ComboBoxProximalChange(nil);
1906
  LabelBonus.Caption := LabelBonus.Caption + ' (%)';
1907
  for i := 0 to FormOptions.ComboBoxAA.Items.Count - 1 do
1908
    ComboBoxAA.Items.Add(Format('%s %s', [FormOptions.ComboBoxAA.Items[i], _('DM')]));
1909
  AAUnit := -1;
1910
  ComboBoxAA.ItemIndex := FormOptions.AA + 2 * FormOptions.Expression;
1911
  ComboBoxAAChange(nil);
1912
  for i := 0 to FormOptions.ComboBoxMinerals.Items.Count - 1 do
1913
    ComboBoxMinerals.Items.Add(Format('%s %s', [FormOptions.ComboBoxMinerals.Items[i], _('DM')]));
1914
  MineralsUnit := -1;
1915
  ComboBoxMinerals.ItemIndex := FormOptions.Minerals + 2 * FormOptions.Expression;
1916
  ComboBoxMineralsChange(nil);
1917
  LabeldP.Caption := LabeldP.Caption + ' (%)';
1918
  with DataModuleDeclaration do
1919
  begin
1920
    TableIngredients := DBUser.GetTable('SELECT * FROM Ingredients '
1921
      + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
1922
    ClientDataSetInraAfz.Locate('Id', ClientDataSetIngredientsModel.Value, []);
1923
    EditModel.Text := dgettext('InraAfz', ClientDataSetInraAfzName.Value);
1924
    // Analyse proximale
1925
    RapMS := TableIngredients.FieldAsDouble(TableIngredients.FieldIndex['MS']);
1926
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MM'])
1927
    then
1928
      CheckBoxMMClick(nil)
1929
    else
1930
    begin
1931
      CheckBoxMM.Checked := True;
1932
      ValidateEditMM.AsFloat := ClientDataSetIngredientsMM.Value;
1933
    end;
1934
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MAT'])
1935
    then
1936
      CheckBoxMATClick(nil)
1937
    else
1938
    begin
1939
      CheckBoxMAT.Checked := True;
1940
      RapMAT := TableIngredients.FieldAsDouble(TableIngredients.FieldIndex['MAT']);
1941
      ValidateEditMAT.AsFloat := ClientDataSetIngredientsMAT.Value;
1942
    end;
1943
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MG'])
1944
    then
1945
      CheckBoxMGClick(nil)
1946
    else
1947
    begin
1948
      CheckBoxMG.Checked := True;
1949
      ValidateEditMG.AsFloat := ClientDataSetIngredientsMG.Value;
1950
    end;
1951
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['CB'])
1952
    then
1953
      CheckBoxCBClick(nil)
1954
    else
1955
    begin
1956
      CheckBoxCB.Checked := True;
1957
      ValidateEditCB.AsFloat := ClientDataSetIngredientsCB.Value;
1958
    end;
1959
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['NDF'])
1960
    then
1961
      CheckBoxNDFClick(nil)
1962
    else
1963
    begin
1964
      CheckBoxNDF.Checked := True;
1965
      ValidateEditNDF.AsFloat := ClientDataSetIngredientsNDF.Value;
1966
    end;
1967
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['ADF'])
1968
    then
1969
      CheckBoxADFClick(nil)
1970
    else
1971
    begin
1972
      CheckBoxADF.Checked := True;
1973
      ValidateEditADF.AsFloat := ClientDataSetIngredientsADF.Value;
1974
    end;
1975
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['ADL'])
1976
    then
1977
      CheckBoxADLClick(nil)
1978
    else
1979
    begin
1980
      CheckBoxADL.Checked := True;
1981
      ValidateEditADL.AsFloat := ClientDataSetIngredientsADL.Value;
1982
    end;
1983
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Amidon'])
1984
    then
1985
      CheckBoxAmidonClick(nil)
1986
    else
1987
    begin
1988
      CheckBoxAmidon.Checked := True;
1989
      ValidateEditAmidon.AsFloat := ClientDataSetIngredientsAmidon.Value;
1990
    end;
1991
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Sucres'])
1992
    then
1993
      CheckBoxSucresClick(nil)
1994
    else
1995
    begin
1996
      CheckBoxSucres.Checked := True;
1997
      ValidateEditSucres.AsFloat := ClientDataSetIngredientsSucres.Value;
1998
    end;
1999
    // Energie
2000
    SpinEditBonus.Value := ClientDataSetIngredientsBonus.Value;
2001
    // Acides amin?s
2002
    if RapMAT = 0
2003
    then // D?sactiver la saisie des acides amin?s
2004
      DisableAA
2005
    else
2006
    begin
2007
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Lys'])
2008
      then
2009
        CheckBoxLysClick(nil)
2010
      else
2011
      begin
2012
        CheckBoxLys.Checked := True;
2013
        ValidateEditLys.AsFloat := ClientDataSetIngredientsLys.Value;
2014
      end;
2015
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Thr'])
2016
      then
2017
        CheckBoxThrClick(nil)
2018
      else
2019
      begin
2020
        CheckBoxThr.Checked := True;
2021
        ValidateEditThr.AsFloat := ClientDataSetIngredientsThr.Value;
2022
      end;
2023
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Met'])
2024
      then
2025
        CheckBoxMetClick(nil)
2026
      else
2027
      begin
2028
        CheckBoxMet.Checked := True;
2029
        ValidateEditMet.AsFloat := ClientDataSetIngredientsMet.Value;
2030
      end;
2031
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Cys'])
2032
      then
2033
        CheckBoxCysClick(nil)
2034
      else
2035
      begin
2036
        CheckBoxCys.Checked := True;
2037
        ValidateEditCys.AsFloat := ClientDataSetIngredientsCys.Value;
2038
      end;
2039
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MetCys'])
2040
      then
2041
        CheckBoxMetCysClick(nil)
2042
      else
2043
      begin
2044
        CheckBoxMetCys.Checked := True;
2045
        ValidateEditMetCys.AsFloat := ClientDataSetIngredientsMetCys.Value;
2046
      end;
2047
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Trp'])
2048
      then
2049
        CheckBoxTrpClick(nil)
2050
      else
2051
      begin
2052
        CheckBoxTrp.Checked := True;
2053
        ValidateEditTrp.AsFloat := ClientDataSetIngredientsTrp.Value;
2054
      end;
2055
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Ile'])
2056
      then
2057
        CheckBoxIleClick(nil)
2058
      else
2059
      begin
2060
        CheckBoxIle.Checked := True;
2061
        ValidateEditIle.AsFloat := ClientDataSetIngredientsIle.Value;
2062
      end;
2063
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Val'])
2064
      then
2065
        CheckBoxValClick(nil)
2066
      else
2067
      begin
2068
        CheckBoxVal.Checked := True;
2069
        ValidateEditVal.AsFloat := ClientDataSetIngredientsVal.Value;
2070
      end;
2071
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Leu'])
2072
      then
2073
        CheckBoxLeuClick(nil)
2074
      else
2075
      begin
2076
        CheckBoxLeu.Checked := True;
2077
        ValidateEditLeu.AsFloat := ClientDataSetIngredientsLeu.Value;
2078
      end;
2079
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Phe'])
2080
      then
2081
        CheckBoxPheClick(nil)
2082
      else
2083
      begin
2084
        CheckBoxPhe.Checked := True;
2085
        ValidateEditPhe.AsFloat := ClientDataSetIngredientsPhe.Value;
2086
      end;
2087
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Tyr'])
2088
      then
2089
        CheckBoxTyrClick(nil)
2090
      else
2091
      begin
2092
        CheckBoxTyr.Checked := True;
2093
        ValidateEditTyr.AsFloat := ClientDataSetIngredientsTyr.Value;
2094
      end;
2095
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['PheTyr'])
2096
      then
2097
        CheckBoxPheTyrClick(nil)
2098
      else
2099
      begin
2100
        CheckBoxPheTyr.Checked := True;
2101
        ValidateEditPheTyr.AsFloat := ClientDataSetIngredientsPheTyr.Value;
2102
      end;
2103
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['His'])
2104
      then
2105
        CheckBoxHisClick(nil)
2106
      else
2107
      begin
2108
        CheckBoxHis.Checked := True;
2109
        ValidateEditHis.AsFloat := ClientDataSetIngredientsHis.Value;
2110
      end;
2111
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Arg'])
2112
      then
2113
        CheckBoxArgClick(nil)
2114
      else
2115
      begin
2116
        CheckBoxArg.Checked := True;
2117
        ValidateEditArg.AsFloat := ClientDataSetIngredientsArg.Value;
2118
      end;
2119
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Ala'])
2120
      then
2121
        CheckBoxAlaClick(nil)
2122
      else
2123
      begin
2124
        CheckBoxAla.Checked := True;
2125
        ValidateEditAla.AsFloat := ClientDataSetIngredientsAla.Value;
2126
      end;
2127
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Asp'])
2128
      then
2129
        CheckBoxAspClick(nil)
2130
      else
2131
      begin
2132
        CheckBoxAsp.Checked := True;
2133
        ValidateEditAsp.AsFloat := ClientDataSetIngredientsAsp.Value;
2134
      end;
2135
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Glu'])
2136
      then
2137
        CheckBoxGluClick(nil)
2138
      else
2139
      begin
2140
        CheckBoxGlu.Checked := True;
2141
        ValidateEditGlu.AsFloat := ClientDataSetIngredientsGlu.Value;
2142
      end;
2143
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Gly'])
2144
      then
2145
        CheckBoxGlyClick(nil)
2146
      else
2147
      begin
2148
        CheckBoxGly.Checked := True;
2149
        ValidateEditGly.AsFloat := ClientDataSetIngredientsGly.Value;
2150
      end;
2151
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Ser'])
2152
      then
2153
        CheckBoxSerClick(nil)
2154
      else
2155
      begin
2156
        CheckBoxSer.Checked := True;
2157
        ValidateEditSer.AsFloat := ClientDataSetIngredientsSer.Value;
2158
      end;
2159
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Pro'])
2160
      then
2161
        CheckBoxProClick(nil)
2162
      else
2163
      begin
2164
        CheckBoxPro.Checked := True;
2165
        ValidateEditPro.AsFloat := ClientDataSetIngredientsPro.Value;
2166
      end;
2167
    end;
2168
    // Min?raux
2169
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Ca'])
2170
    then
2171
      CheckBoxCaClick(nil)
2172
    else
2173
    begin
2174
      CheckBoxCa.Checked := True;
2175
      ValidateEditCa.AsFloat := ClientDataSetIngredientsCa.Value;
2176
    end;
2177
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['P'])
2178
    then
2179
      CheckBoxPClick(nil)
2180
    else
2181
    begin
2182
      CheckBoxP.Checked := True;
2183
      ValidateEditP.AsFloat := ClientDataSetIngredientsP.Value;
2184
    end;
2185
    if ValidateEditP.AsFloat = 0
2186
    then // D?sactiver la saisie du phosphore digestible
2187
      DisabledP
2188
    else
2189
    begin
2190
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dP'])
2191
      then
2192
        CheckBoxdPClick(nil)
2193
      else
2194
      begin
2195
        CheckBoxdP.Checked := True;
2196
        ValidateEditdP.AsFloat := ClientDataSetIngredientsdP.Value;
2197
      end;
2198
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dPphy'])
2199
      then
2200
        CheckBoxdPphyClick(nil)
2201
      else
2202
      begin
2203
        CheckBoxdPphy.Checked := True;
2204
        ValidateEditdPphy.AsFloat := ClientDataSetIngredientsdPphy.Value;
2205
      end;
2206
    end;
2207
    TableIngredients.Free;
2208
  end;
2209
end;
2210

    
2211
procedure TFormIngredientEditionCopy.ValidateEditMATChange(Sender: TObject);
2212
begin
2213
  with DataModuleDeclaration do
2214
  begin
2215
    RapMAT := InputProximal(ValidateEditMAT.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2);
2216
    if RapMAT = 0
2217
    then // D?sactiver la saisie des acides amin?s
2218
      DisableAA
2219
    else // Activer la saisie des acides amin?s
2220
    begin
2221
      EnableAA;
2222
      // Recalculer les teneurs en acides amin?s
2223
      if CheckBoxLys.Checked
2224
      then // R?initialiser avec la valeur du mod?le
2225
        CheckBoxLys.Checked := False
2226
      else // R?afficher la valeur du mod?le
2227
        CheckBoxLysClick(nil);
2228
      if CheckBoxThr.Checked
2229
      then // R?initialiser avec la valeur du mod?le
2230
        CheckBoxThr.Checked := False
2231
      else // R?afficher la valeur du mod?le
2232
        CheckBoxThrClick(nil);
2233
      if CheckBoxMet.Checked
2234
      then // R?initialiser avec la valeur du mod?le
2235
        CheckBoxMet.Checked := False
2236
      else // R?afficher la valeur du mod?le
2237
        CheckBoxMetClick(nil);
2238
      if CheckBoxCys.Checked
2239
      then // R?initialiser avec la valeur du mod?le
2240
        CheckBoxCys.Checked := False
2241
      else // R?afficher la valeur du mod?le
2242
        CheckBoxCysClick(nil);
2243
      if CheckBoxMetCys.Checked
2244
      then // R?initialiser avec la valeur du mod?le
2245
        CheckBoxMetCys.Checked := False
2246
      else // R?afficher la valeur du mod?le
2247
        CheckBoxMetCysClick(nil);
2248
      if CheckBoxTrp.Checked
2249
      then // R?initialiser avec la valeur du mod?le
2250
        CheckBoxTrp.Checked := False
2251
      else // R?afficher la valeur du mod?le
2252
        CheckBoxTrpClick(nil);
2253
      if CheckBoxIle.Checked
2254
      then // R?initialiser avec la valeur du mod?le
2255
        CheckBoxIle.Checked := False
2256
      else // R?afficher la valeur du mod?le
2257
        CheckBoxIleClick(nil);
2258
      if CheckBoxVal.Checked
2259
      then // R?initialiser avec la valeur du mod?le
2260
        CheckBoxVal.Checked := False
2261
      else // R?afficher la valeur du mod?le
2262
        CheckBoxValClick(nil);
2263
      if CheckBoxLeu.Checked
2264
      then // R?initialiser avec la valeur du mod?le
2265
        CheckBoxLeu.Checked := False
2266
      else // R?afficher la valeur du mod?le
2267
        CheckBoxLeuClick(nil);
2268
      if CheckBoxPhe.Checked
2269
      then // R?initialiser avec la valeur du mod?le
2270
        CheckBoxPhe.Checked := False
2271
      else // R?afficher la valeur du mod?le
2272
        CheckBoxPheClick(nil);
2273
      if CheckBoxTyr.Checked
2274
      then // R?initialiser avec la valeur du mod?le
2275
        CheckBoxTyr.Checked := False
2276
      else // R?afficher la valeur du mod?le
2277
        CheckBoxTyrClick(nil);
2278
      if CheckBoxPheTyr.Checked
2279
      then // R?initialiser avec la valeur du mod?le
2280
        CheckBoxPheTyr.Checked := False
2281
      else // R?afficher la valeur du mod?le
2282
        CheckBoxPheTyrClick(nil);
2283
      if CheckBoxHis.Checked
2284
      then // R?initialiser avec la valeur du mod?le
2285
        CheckBoxHis.Checked := False
2286
      else // R?afficher la valeur du mod?le
2287
        CheckBoxHisClick(nil);
2288
      if CheckBoxArg.Checked
2289
      then // R?initialiser avec la valeur du mod?le
2290
        CheckBoxArg.Checked := False
2291
      else // R?afficher la valeur du mod?le
2292
        CheckBoxArgClick(nil);
2293
      if CheckBoxAla.Checked
2294
      then // R?initialiser avec la valeur du mod?le
2295
        CheckBoxAla.Checked := False
2296
      else // R?afficher la valeur du mod?le
2297
        CheckBoxAlaClick(nil);
2298
      if CheckBoxAsp.Checked
2299
      then // R?initialiser avec la valeur du mod?le
2300
        CheckBoxAsp.Checked := False
2301
      else // R?afficher la valeur du mod?le
2302
        CheckBoxAspClick(nil);
2303
      if CheckBoxGlu.Checked
2304
      then // R?initialiser avec la valeur du mod?le
2305
        CheckBoxGlu.Checked := False
2306
      else // R?afficher la valeur du mod?le
2307
        CheckBoxGluClick(nil);
2308
      if CheckBoxGly.Checked
2309
      then // R?initialiser avec la valeur du mod?le
2310
        CheckBoxGly.Checked := False
2311
      else // R?afficher la valeur du mod?le
2312
        CheckBoxGlyClick(nil);
2313
      if CheckBoxSer.Checked
2314
      then // R?initialiser avec la valeur du mod?le
2315
        CheckBoxSer.Checked := False
2316
      else // R?afficher la valeur du mod?le
2317
        CheckBoxSerClick(nil);
2318
      if CheckBoxPro.Checked
2319
      then // R?initialiser avec la valeur du mod?le
2320
        CheckBoxPro.Checked := False
2321
      else // R?afficher la valeur du mod?le
2322
        CheckBoxProClick(nil);
2323
    end;
2324
  end;
2325
end;
2326

    
2327
procedure TFormIngredientEditionCopy.ValidateEditPChange(Sender: TObject);
2328
begin
2329
  if ValidateEditP.AsFloat = 0
2330
  then // D?sactiver la saisie du phosphore digestible
2331
    DisabledP
2332
  else // Activer la saisie du phosphore digestible
2333
  begin
2334
    EnabledP;
2335
    if CheckBoxdP.Checked
2336
    then // R?initialiser avec la valeur du mod?le
2337
      CheckBoxdP.Checked := False
2338
    else // R?afficher la valeur du mod?le
2339
      CheckBoxdPClick(nil);
2340
    if CheckBoxdPphy.Checked
2341
    then // R?initialiser avec la valeur du mod?le
2342
      CheckBoxdPphy.Checked := False
2343
    else // R?afficher la valeur du mod?le
2344
      CheckBoxdPphyClick(nil);
2345
  end;
2346
end;
2347

    
2348
procedure TFormIngredientEditionCopy.NumEditKeyDown(Sender: TObject;
2349
  var Key: Word; Shift: TShiftState);
2350
begin
2351
  // D?tection de l'appui sur le s?parateur d?cimal du pav? num?rique
2352
  VK_Separator := (Key = VK_DECIMAL);
2353
end;
2354

    
2355
procedure TFormIngredientEditionCopy.NumEditKeyPress(Sender: TObject;
2356
  var Key: Char);
2357
begin
2358
  if VK_Separator then
2359
    // Renvoyer le s?parateur d?cimal des options r?gionales et linguistiques
2360
    Key := DecimalSeparator;
2361
end;
2362

    
2363
end.