Statistiques
| Révision:

root / UnitIngredientEditionOriginal.pas @ 12

Historique | Voir | Annoter | Télécharger (104,356 ko)

1 1 avalancogn
unit UnitIngredientEditionOriginal;
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, JvExStdCtrls, JvEdit, JvValidateEdit, JvExMask, JvSpin, JvExControls,
9
  JvEnterTab, gnugettext, JvButton, JvCtrls;
10
11
type
12
  TFormIngredientEditionOriginal = class(TForm)
13
    GroupBoxProximal: TGroupBox;
14
    GroupBoxAA: TGroupBox;
15
    ValidateEditMAT: TJvValidateEdit;
16
    ValidateEditCB: TJvValidateEdit;
17
    ValidateEditMG: TJvValidateEdit;
18
    ValidateEditMM: TJvValidateEdit;
19
    ValidateEditNDF: TJvValidateEdit;
20
    ValidateEditADF: TJvValidateEdit;
21
    ValidateEditADL: TJvValidateEdit;
22
    ValidateEditAmidon: TJvValidateEdit;
23
    ValidateEditSucres: TJvValidateEdit;
24
    CheckBoxMAT: TCheckBox;
25
    CheckBoxCB: TCheckBox;
26
    CheckBoxMG: TCheckBox;
27
    CheckBoxMM: TCheckBox;
28
    CheckBoxNDF: TCheckBox;
29
    CheckBoxADF: TCheckBox;
30
    CheckBoxADL: TCheckBox;
31
    CheckBoxAmidon: TCheckBox;
32
    CheckBoxSucres: TCheckBox;
33
    ValidateEditLys: TJvValidateEdit;
34
    CheckBoxLys: TCheckBox;
35
    ValidateEditThr: TJvValidateEdit;
36
    CheckBoxThr: TCheckBox;
37
    ValidateEditMet: TJvValidateEdit;
38
    CheckBoxMet: TCheckBox;
39
    ValidateEditCys: TJvValidateEdit;
40
    CheckBoxCys: TCheckBox;
41
    ValidateEditMetCys: TJvValidateEdit;
42
    CheckBoxMetCys: TCheckBox;
43
    ValidateEditTrp: TJvValidateEdit;
44
    CheckBoxTrp: TCheckBox;
45
    ValidateEditIle: TJvValidateEdit;
46
    CheckBoxIle: TCheckBox;
47
    ValidateEditVal: TJvValidateEdit;
48
    CheckBoxVal: TCheckBox;
49
    ValidateEditLeu: TJvValidateEdit;
50
    CheckBoxLeu: TCheckBox;
51
    ValidateEditPhe: TJvValidateEdit;
52
    CheckBoxPhe: TCheckBox;
53
    ValidateEditTyr: TJvValidateEdit;
54
    CheckBoxTyr: TCheckBox;
55
    ValidateEditPheTyr: TJvValidateEdit;
56
    CheckBoxPheTyr: TCheckBox;
57
    ValidateEditHis: TJvValidateEdit;
58
    CheckBoxHis: TCheckBox;
59
    ValidateEditArg: TJvValidateEdit;
60
    CheckBoxArg: TCheckBox;
61
    ValidateEditAla: TJvValidateEdit;
62
    CheckBoxAla: TCheckBox;
63
    ValidateEditAsp: TJvValidateEdit;
64
    CheckBoxAsp: TCheckBox;
65
    ValidateEditGlu: TJvValidateEdit;
66
    CheckBoxGlu: TCheckBox;
67
    ValidateEditGly: TJvValidateEdit;
68
    CheckBoxGly: TCheckBox;
69
    ValidateEditSer: TJvValidateEdit;
70
    CheckBoxSer: TCheckBox;
71
    ValidateEditPro: TJvValidateEdit;
72
    CheckBoxPro: TCheckBox;
73
    GroupBoxEnergy: TGroupBox;
74
    ValidateEditEB: TJvValidateEdit;
75
    CheckBoxEB: TCheckBox;
76
    SpinEditBonus: TJvSpinEdit;
77
    GroupBoxMinerals: TGroupBox;
78
    ValidateEditCa: TJvValidateEdit;
79
    CheckBoxCa: TCheckBox;
80
    ValidateEditP: TJvValidateEdit;
81
    CheckBoxP: TCheckBox;
82
    ValidateEditdPphy: TJvValidateEdit;
83
    CheckBoxdPphy: TCheckBox;
84
    ValidateEditdP: TJvValidateEdit;
85
    CheckBoxdP: TCheckBox;
86
    DBEditName: TDBEdit;
87
    DBEditClass: TDBEdit;
88
    DBEditMS: TDBEdit;
89
    EnterAsTab: TJvEnterAsTab;
90
    ValidateEditdLys: TJvValidateEdit;
91
    CheckBoxdLys: TCheckBox;
92
    ValidateEditdThr: TJvValidateEdit;
93
    CheckBoxdThr: TCheckBox;
94
    ValidateEditdMet: TJvValidateEdit;
95
    CheckBoxdMet: TCheckBox;
96
    ValidateEditdCys: TJvValidateEdit;
97
    CheckBoxdCys: TCheckBox;
98
    ValidateEditdMetCys: TJvValidateEdit;
99
    CheckBoxdMetCys: TCheckBox;
100
    ValidateEditdTrp: TJvValidateEdit;
101
    CheckBoxdTrp: TCheckBox;
102
    ValidateEditdIle: TJvValidateEdit;
103
    CheckBoxdIle: TCheckBox;
104
    ValidateEditdVal: TJvValidateEdit;
105
    CheckBoxdVal: TCheckBox;
106
    ValidateEditdLeu: TJvValidateEdit;
107
    CheckBoxdLeu: TCheckBox;
108
    ValidateEditdPhe: TJvValidateEdit;
109
    CheckBoxdPhe: TCheckBox;
110
    ValidateEditdTyr: TJvValidateEdit;
111
    CheckBoxdTyr: TCheckBox;
112
    ValidateEditdPheTyr: TJvValidateEdit;
113
    CheckBoxdPheTyr: TCheckBox;
114
    ValidateEditdHis: TJvValidateEdit;
115
    CheckBoxdHis: TCheckBox;
116
    ValidateEditdArg: TJvValidateEdit;
117
    CheckBoxdArg: TCheckBox;
118
    ValidateEditdAla: TJvValidateEdit;
119
    CheckBoxdAla: TCheckBox;
120
    ValidateEditdAsp: TJvValidateEdit;
121
    CheckBoxdAsp: TCheckBox;
122
    ValidateEditdGlu: TJvValidateEdit;
123
    CheckBoxdGlu: TCheckBox;
124
    ValidateEditdGly: TJvValidateEdit;
125
    CheckBoxdGly: TCheckBox;
126
    ValidateEditdSer: TJvValidateEdit;
127
    CheckBoxdSer: TCheckBox;
128
    ValidateEditdPro: TJvValidateEdit;
129
    CheckBoxdPro: TCheckBox;
130
    PanelButtons: TPanel;
131
    PanelMain: TPanel;
132
    PanelHeader: TPanel;
133
    ImageListIcons: TImageList;
134
    ActionListButtons: TActionList;
135
    ActionRename: TAction;
136
    ActionComment: TAction;
137
    ActionHelp: TAction;
138
    ActionOK: TAction;
139
    ActionCancel: TAction;
140
    LabelWarning: TLabel;
141
    LabelBonus: TLabel;
142
    LabelEB: TLabel;
143
    LabelCa: TLabel;
144
    LabelP: TLabel;
145
    LabeldP: TLabel;
146
    LabelFarine: TLabel;
147
    LabelGranule: TLabel;
148
    LabelMAT: TLabel;
149
    LabelCB: TLabel;
150
    LabelMG: TLabel;
151
    LabelMM: TLabel;
152
    LabelNDF: TLabel;
153
    LabelADF: TLabel;
154
    LabelADL: TLabel;
155
    LabelAmidon: TLabel;
156
    LabelSucres: TLabel;
157
    LabelLys: TLabel;
158
    LabelTyr: TLabel;
159
    LabelThr: TLabel;
160
    LabelPheTyr: TLabel;
161
    LabelMet: TLabel;
162
    LabelHis: TLabel;
163
    LabelCys: TLabel;
164
    LabelArg: TLabel;
165
    LabelMetCys: TLabel;
166
    LabelAla: TLabel;
167
    LabelTrp: TLabel;
168
    LabelAsp: TLabel;
169
    LabelIle: TLabel;
170
    LabelGlu: TLabel;
171
    LabelVal: TLabel;
172
    LabelGly: TLabel;
173
    LabelLeu: TLabel;
174
    LabelSer: TLabel;
175
    LabelPhe: TLabel;
176
    LabelPro: TLabel;
177
    LabeldAA: TLabel;
178
    LabelAATot: TLabel;
179
    LabelClass: TLabel;
180
    LabelMS: TLabel;
181
    LabelName: TLabel;
182
    ComboBoxEnergy: TComboBox;
183
    ComboBoxMinerals: TComboBox;
184
    ComboBoxProximal: TComboBox;
185
    ComboBoxAA: TComboBox;
186
    JvImgBtnCancel: TJvImgBtn;
187
    JvImgBtnOK: TJvImgBtn;
188
    JvImgBtnHelp: TJvImgBtn;
189
    JvImgBtnRename: TJvImgBtn;
190
    JvImgBtnComment: TJvImgBtn;
191 3 avalancogn
    LabelNa: TLabel;
192
    ValidateEditNa: TJvValidateEdit;
193
    CheckBoxNa: TCheckBox;
194
    LabelK: TLabel;
195
    ValidateEditK: TJvValidateEdit;
196
    CheckBoxK: TCheckBox;
197
    LabelCl: TLabel;
198
    ValidateEditCl: TJvValidateEdit;
199
    CheckBoxCl: TCheckBox;
200 1 avalancogn
    procedure FormCreate(Sender: TObject);
201
    procedure CheckBoxMATClick(Sender: TObject);
202
    procedure CheckBoxCBClick(Sender: TObject);
203
    procedure CheckBoxMGClick(Sender: TObject);
204
    procedure CheckBoxMMClick(Sender: TObject);
205
    procedure CheckBoxNDFClick(Sender: TObject);
206
    procedure CheckBoxADFClick(Sender: TObject);
207
    procedure CheckBoxADLClick(Sender: TObject);
208
    procedure CheckBoxAmidonClick(Sender: TObject);
209
    procedure CheckBoxSucresClick(Sender: TObject);
210
    procedure CheckBoxEBClick(Sender: TObject);
211
    procedure CheckBoxLysClick(Sender: TObject);
212
    procedure CheckBoxThrClick(Sender: TObject);
213
    procedure CheckBoxMetClick(Sender: TObject);
214
    procedure CheckBoxCysClick(Sender: TObject);
215
    procedure CheckBoxMetCysClick(Sender: TObject);
216
    procedure CheckBoxTrpClick(Sender: TObject);
217
    procedure CheckBoxIleClick(Sender: TObject);
218
    procedure CheckBoxValClick(Sender: TObject);
219
    procedure CheckBoxLeuClick(Sender: TObject);
220
    procedure CheckBoxPheClick(Sender: TObject);
221
    procedure CheckBoxTyrClick(Sender: TObject);
222
    procedure CheckBoxPheTyrClick(Sender: TObject);
223
    procedure CheckBoxHisClick(Sender: TObject);
224
    procedure CheckBoxArgClick(Sender: TObject);
225
    procedure CheckBoxAlaClick(Sender: TObject);
226
    procedure CheckBoxAspClick(Sender: TObject);
227
    procedure CheckBoxGluClick(Sender: TObject);
228
    procedure CheckBoxGlyClick(Sender: TObject);
229
    procedure CheckBoxSerClick(Sender: TObject);
230
    procedure CheckBoxProClick(Sender: TObject);
231
    procedure ComboBoxProximalChange(Sender: TObject);
232
    procedure ComboBoxEnergyChange(Sender: TObject);
233
    procedure ComboBoxAAChange(Sender: TObject);
234
    procedure ValidateEditMATChange(Sender: TObject);
235
    procedure ComboBoxMineralsChange(Sender: TObject);
236
    procedure CheckBoxCaClick(Sender: TObject);
237
    procedure CheckBoxPClick(Sender: TObject);
238
    procedure CheckBoxdPphyClick(Sender: TObject);
239
    procedure CheckBoxdPClick(Sender: TObject);
240
    procedure ValidateEditPChange(Sender: TObject);
241
    procedure ButtonRenameClick(Sender: TObject);
242
    procedure ButtonCommentClick(Sender: TObject);
243
    procedure CheckBoxdLysClick(Sender: TObject);
244
    procedure CheckBoxdThrClick(Sender: TObject);
245
    procedure CheckBoxdMetClick(Sender: TObject);
246
    procedure CheckBoxdCysClick(Sender: TObject);
247
    procedure CheckBoxdMetCysClick(Sender: TObject);
248
    procedure CheckBoxdTrpClick(Sender: TObject);
249
    procedure CheckBoxdIleClick(Sender: TObject);
250
    procedure CheckBoxdValClick(Sender: TObject);
251
    procedure CheckBoxdLeuClick(Sender: TObject);
252
    procedure CheckBoxdPheClick(Sender: TObject);
253
    procedure CheckBoxdTyrClick(Sender: TObject);
254
    procedure CheckBoxdPheTyrClick(Sender: TObject);
255
    procedure CheckBoxdHisClick(Sender: TObject);
256
    procedure CheckBoxdArgClick(Sender: TObject);
257
    procedure CheckBoxdAlaClick(Sender: TObject);
258
    procedure CheckBoxdAspClick(Sender: TObject);
259
    procedure CheckBoxdGluClick(Sender: TObject);
260
    procedure CheckBoxdGlyClick(Sender: TObject);
261
    procedure CheckBoxdSerClick(Sender: TObject);
262
    procedure CheckBoxdProClick(Sender: TObject);
263
    procedure ButtonHelpClick(Sender: TObject);
264
    procedure ActionRenameExecute(Sender: TObject);
265
    procedure ActionCommentExecute(Sender: TObject);
266
    procedure ActionHelpExecute(Sender: TObject);
267
    procedure ActionOKExecute(Sender: TObject);
268
    procedure ActionCancelExecute(Sender: TObject);
269
    procedure NumEditKeyDown(Sender: TObject; var Key: Word;
270
      Shift: TShiftState);
271
    procedure NumEditKeyPress(Sender: TObject; var Key: Char);
272 3 avalancogn
    procedure CheckBoxNaClick(Sender: TObject);
273
    procedure CheckBoxKClick(Sender: TObject);
274
    procedure CheckBoxClClick(Sender: TObject);
275 1 avalancogn
  private
276
    { D?clarations priv?es }
277
    ProximalUnit, EnergyUnit, MineralsUnit, AAUnit: Integer;
278
    procedure EditActivate(Edit: TJvValidateEdit);
279
    procedure EditEmpty(Edit: TJvValidateEdit);
280
    procedure EditShow(Edit: TJvValidateEdit; const Value: Double);
281
    procedure DisableAA;
282
    procedure DisabledP;
283
    procedure EnableAA;
284
    procedure EnabledP;
285
  public
286
    { D?clarations publiques }
287
  end;
288
289
var
290
  FormIngredientEditionOriginal: TFormIngredientEditionOriginal;
291
292
implementation
293
294
{$R *.dfm}
295
296
uses
297
  UnitDeclaration, UnitOptions, UnitRename, UnitComment, UnitIngredientsList;
298
299
var
300
  VK_Separator: boolean;
301
302
procedure TFormIngredientEditionOriginal.ActionCancelExecute(Sender: TObject);
303
begin
304
  ModalResult := mrCancel;
305
end;
306
307
procedure TFormIngredientEditionOriginal.ActionCommentExecute(Sender: TObject);
308
begin
309
  FormComment := TFormComment.Create(nil);
310
  try
311
//    FormComment.Caption := ButtonComment.Hint;
312
    FormComment.Name := DataModuleDeclaration.ClientDataSetIngredientsName.Value;
313
    FormComment.OldComment := DataModuleDeclaration.ClientDataSetIngredientsDefinition.Value;
314
    if (FormComment.ShowModal = mrOk) and (FormComment.NewComment <> FormComment.OldComment)
315
    then // Commenter
316
      with DataModuleDeclaration do
317
      begin
318
        DBUser.BeginTransaction;
319
        try
320
          DBUser.ExecSQL('UPDATE Ingredients '
321
            + Format('SET Definition = %s ', [QuotedStr(FormComment.NewComment)])
322
            + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
323
          DBUser.Commit;
324
        except
325
          DBUser.RollBack;
326
          MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitIngredientEditionOriginal', 'ActionCommentExecute', 'DBUser (UPDATE Ingredients)']), mtError, [mbOK], 0);
327
          Exit;
328
        end;
329
        // Commenter dans ClientDataSetIngredients
330
        ClientDataSetIngredients.Edit;
331
        ClientDataSetIngredientsDefinition.Value := FormComment.NewComment;
332
        ClientDataSetIngredients.Post;
333
      end;
334
  finally
335
    FormComment.Release;
336
  end;
337
end;
338
339
procedure TFormIngredientEditionOriginal.ActionHelpExecute(Sender: TObject);
340
begin
341
  Application.HelpContext(HelpContext);
342
end;
343
344
procedure TFormIngredientEditionOriginal.ActionOKExecute(Sender: TObject);
345
var
346
  Nb: Integer;
347
  MM, MAT, MG, Fibre, Amidon, Sucres, CB, NDF, ADF, AASum: Double;
348
  USFormatSettings: TFormatSettings;
349
begin
350
  with DataModuleDeclaration do
351
  begin
352
    // V?rifier la saisie
353
    if not CheckBoxMM.Checked
354
    then
355
    begin
356
      MessageDlg(_('You must specify an ash value for this ingredient.'), mtError, [mbOK], 0);
357
      ActiveControl := CheckBoxMM;
358
      Exit;
359
    end;
360
    if not CheckBoxMAT.Checked
361
    then
362
    begin
363
      MessageDlg(_('You must specify a crude protein value for this ingredient.'), mtError, [mbOK], 0);
364
      ActiveControl := CheckBoxMAT;
365
      Exit;
366
    end;
367
    if not CheckBoxMG.Checked and not CheckBoxEB.Checked
368
    then
369
    begin
370
      MessageDlg(_('You must specify a crude fat value or a gross energy value for this ingredient.'), mtError, [mbOK], 0);
371
      ActiveControl := CheckBoxMG;
372
      Exit;
373
    end;
374
    if not CheckBoxCB.Checked and not CheckBoxNDF.Checked and not CheckBoxADF.Checked
375
    then
376
    begin
377
      MessageDlg(_('You must specify a fiber value (crude fiber, NDF or ADF) for this ingredient.'), mtError, [mbOK], 0);
378
      ActiveControl := CheckBoxCB;
379
      Exit;
380
    end;
381
    if CheckBoxMM.Checked
382
    then
383
      MM := InputProximal(ValidateEditMM.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)
384
    else
385
      MM := 0;
386
    if CheckBoxMAT.Checked
387
    then
388
      MAT := InputProximal(ValidateEditMAT.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)
389
    else
390
      MAT := 0;
391
    if CheckBoxMG.Checked
392
    then
393
      MG := InputProximal(ValidateEditMG.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)
394
    else
395
      MG := 0;
396
    Nb := 0;
397
    if CheckBoxCB.Checked
398
    then
399
    begin
400
      CB := InputProximal(ValidateEditCB.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2);
401
      Inc(Nb);
402
    end
403
    else
404
      CB := 0;
405
    if CheckBoxNDF.Checked
406
    then
407
    begin
408
      NDF := InputProximal(ValidateEditNDF.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2);
409
      Inc(Nb);
410
    end
411
    else
412
      NDF := 0;
413
    if CheckBoxADF.Checked
414
    then
415
    begin
416
      ADF := InputProximal(ValidateEditADF.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2);
417
      Inc(Nb);
418
    end
419
    else
420
      ADF := 0;
421
    if Nb = 0
422
    then
423
      Fibre := 0
424
    else // Moyenne des ?quations significatives
425
      Fibre := (CB * NDF_CB + NDF + ADF * NDF_ADF) / Nb;
426
    if CheckBoxAmidon.Checked
427
    then
428
      Amidon := InputProximal(ValidateEditAmidon.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)
429
    else
430
      Amidon := 0;
431
    if CheckBoxSucres.Checked
432
    then
433
      Sucres := InputProximal(ValidateEditSucres.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)
434
    else
435
      Sucres := 0;
436 10 avalancogn
    if MM + MAT + MG + Fibre + Amidon + Sucres > MAX_SUM
437 1 avalancogn
    then
438
      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
439
      then
440
        Exit;
441
    AASum := 0;
442
    if CheckBoxLys.Checked
443
    then
444
      AASum := AASum + InputAA(ValidateEditLys.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
445
    if CheckBoxThr.Checked
446
    then
447
      AASum := AASum + InputAA(ValidateEditThr.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
448
    if CheckBoxMet.Checked
449
    then
450
      AASum := AASum + InputAA(ValidateEditMet.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
451
    if CheckBoxCys.Checked
452
    then
453
      AASum := AASum + InputAA(ValidateEditCys.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
454
    if CheckBoxTrp.Checked
455
    then
456
      AASum := AASum + InputAA(ValidateEditTrp.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
457
    if CheckBoxIle.Checked
458
    then
459
      AASum := AASum + InputAA(ValidateEditIle.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
460
    if CheckBoxVal.Checked
461
    then
462
      AASum := AASum + InputAA(ValidateEditVal.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
463
    if CheckBoxLeu.Checked
464
    then
465
      AASum := AASum + InputAA(ValidateEditLeu.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
466
    if CheckBoxPhe.Checked
467
    then
468
      AASum := AASum + InputAA(ValidateEditPhe.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
469
    if CheckBoxTyr.Checked
470
    then
471
      AASum := AASum + InputAA(ValidateEditTyr.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
472
    if CheckBoxHis.Checked
473
    then
474
      AASum := AASum + InputAA(ValidateEditHis.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
475
    if CheckBoxArg.Checked
476
    then
477
      AASum := AASum + InputAA(ValidateEditArg.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
478
    if CheckBoxAla.Checked
479
    then
480
      AASum := AASum + InputAA(ValidateEditAla.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
481
    if CheckBoxAsp.Checked
482
    then
483
      AASum := AASum + InputAA(ValidateEditAsp.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
484
    if CheckBoxGlu.Checked
485
    then
486
      AASum := AASum + InputAA(ValidateEditGlu.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
487
    if CheckBoxGly.Checked
488
    then
489
      AASum := AASum + InputAA(ValidateEditGly.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
490
    if CheckBoxSer.Checked
491
    then
492
      AASum := AASum + InputAA(ValidateEditSer.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
493
    if CheckBoxPro.Checked
494
    then
495
      AASum := AASum + InputAA(ValidateEditPro.AsFloat, RapMAT,RapMS, AAUnit div 2, AAUnit mod 2);
496
    if AASum > 1.1
497
    then
498
      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
499
      then
500
      begin
501
        Exit;
502
      end;
503
    // Modifier la mati?re premi?re
504
    GetLocaleFormatSettings(1033, USFormatSettings);
505
    DBUser.BeginTransaction;
506
    try
507
      // Analyse proximale
508
      if CheckBoxMM.Checked
509
      then
510
        DBUser.ExecSQL('UPDATE Ingredients '
511
          + Format('SET MM = %.15f ', [InputProximal(ValidateEditMM.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
512
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
513
      else
514
        DBUser.ExecSQL('UPDATE Ingredients '
515
          + 'SET MM = null '
516
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
517
      if CheckBoxMAT.Checked
518
      then
519
        DBUser.ExecSQL('UPDATE Ingredients '
520
          + Format('SET MAT = %.15f ', [InputProximal(ValidateEditMAT.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
521
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
522
      else
523
        DBUser.ExecSQL('UPDATE Ingredients '
524
          + 'SET MAT = null '
525
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
526
      if CheckBoxMG.Checked
527
      then
528
        DBUser.ExecSQL('UPDATE Ingredients '
529
          + Format('SET MG = %.15f ', [InputProximal(ValidateEditMG.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
530
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
531
      else
532
        DBUser.ExecSQL('UPDATE Ingredients '
533
          + 'SET MG = null '
534
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
535
      if CheckBoxCB.Checked
536
      then
537
        DBUser.ExecSQL('UPDATE Ingredients '
538
          + Format('SET CB = %.15f ', [InputProximal(ValidateEditCB.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
539
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
540
      else
541
        DBUser.ExecSQL('UPDATE Ingredients '
542
          + 'SET CB = null '
543
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
544
      if CheckBoxNDF.Checked
545
      then
546
        DBUser.ExecSQL('UPDATE Ingredients '
547
          + Format('SET NDF = %.15f ', [InputProximal(ValidateEditNDF.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
548
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
549
      else
550
        DBUser.ExecSQL('UPDATE Ingredients '
551
          + 'SET NDF = null '
552
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
553
      if CheckBoxADF.Checked
554
      then
555
        DBUser.ExecSQL('UPDATE Ingredients '
556
          + Format('SET ADF = %.15f ', [InputProximal(ValidateEditADF.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
557
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
558
      else
559
        DBUser.ExecSQL('UPDATE Ingredients '
560
          + 'SET ADF = null '
561
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
562
      if CheckBoxADL.Checked
563
      then
564
        DBUser.ExecSQL('UPDATE Ingredients '
565
          + Format('SET ADL = %.15f ', [InputProximal(ValidateEditADL.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
566
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
567
      else
568
        DBUser.ExecSQL('UPDATE Ingredients '
569
          + 'SET ADL = null '
570
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
571
      if CheckBoxAmidon.Checked
572
      then
573
        DBUser.ExecSQL('UPDATE Ingredients '
574
          + Format('SET Amidon = %.15f ', [InputProximal(ValidateEditAmidon.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
575
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
576
      else
577
        DBUser.ExecSQL('UPDATE Ingredients '
578
          + 'SET Amidon = null '
579
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
580
      if CheckBoxSucres.Checked
581
      then
582
        DBUser.ExecSQL('UPDATE Ingredients '
583
          + Format('SET Sucres = %.15f ', [InputProximal(ValidateEditSucres.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2)], USFormatSettings)
584
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
585
      else
586
        DBUser.ExecSQL('UPDATE Ingredients '
587
          + 'SET Sucres = null '
588
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
589
      // Energie
590
      if CheckBoxEB.Checked
591
      then
592
        DBUser.ExecSQL('UPDATE Ingredients '
593
          + Format('SET EB = %.15f ', [InputEnergy(ValidateEditEB.AsFloat, RapMS, EnergyUnit div 2, EnergyUnit mod 2)], USFormatSettings)
594
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
595
      else
596
        DBUser.ExecSQL('UPDATE Ingredients '
597
          + 'SET EB = null '
598
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
599
      DBUser.ExecSQL('UPDATE Ingredients '
600
        + Format('SET Bonus = %.3f ', [SpinEditBonus.Value / 100], USFormatSettings)
601
        + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
602
      // Acides amin?s
603
      if CheckBoxLys.Checked
604
      then
605
        DBUser.ExecSQL('UPDATE Ingredients '
606
          + Format('SET Lys = %.15f ', [InputAA(ValidateEditLys.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
607
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
608
      else
609
        DBUser.ExecSQL('UPDATE Ingredients '
610
          + 'SET Lys = null '
611
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
612
      if CheckBoxThr.Checked
613
      then
614
        DBUser.ExecSQL('UPDATE Ingredients '
615
          + Format('SET Thr = %.15f ', [InputAA(ValidateEditThr.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
616
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
617
      else
618
        DBUser.ExecSQL('UPDATE Ingredients '
619
          + 'SET Thr = null '
620
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
621
      if CheckBoxMet.Checked
622
      then
623
        DBUser.ExecSQL('UPDATE Ingredients '
624
          + Format('SET Met = %.15f ', [InputAA(ValidateEditMet.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
625
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
626
      else
627
        DBUser.ExecSQL('UPDATE Ingredients '
628
          + 'SET Met = null '
629
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
630
      if CheckBoxCys.Checked
631
      then
632
        DBUser.ExecSQL('UPDATE Ingredients '
633
          + Format('SET Cys = %.15f ', [InputAA(ValidateEditCys.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
634
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
635
      else
636
        DBUser.ExecSQL('UPDATE Ingredients '
637
          + 'SET Cys = null '
638
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
639
      if CheckBoxMetCys.Checked
640
      then
641
        DBUser.ExecSQL('UPDATE Ingredients '
642
          + Format('SET MetCys = %.15f ', [InputAA(ValidateEditMetCys.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
643
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
644
      else
645
        DBUser.ExecSQL('UPDATE Ingredients '
646
          + 'SET MetCys = null '
647
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
648
      if CheckBoxTrp.Checked
649
      then
650
        DBUser.ExecSQL('UPDATE Ingredients '
651
          + Format('SET Trp = %.15f ', [InputAA(ValidateEditTrp.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
652
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
653
      else
654
        DBUser.ExecSQL('UPDATE Ingredients '
655
          + 'SET Trp = null '
656
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
657
      if CheckBoxIle.Checked
658
      then
659
        DBUser.ExecSQL('UPDATE Ingredients '
660
          + Format('SET Ile = %.15f ', [InputAA(ValidateEditIle.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
661
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
662
      else
663
        DBUser.ExecSQL('UPDATE Ingredients '
664
          + 'SET Ile = null '
665
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
666
      if CheckBoxVal.Checked
667
      then
668
        DBUser.ExecSQL('UPDATE Ingredients '
669
          + Format('SET Val = %.15f ', [InputAA(ValidateEditVal.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
670
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
671
      else
672
        DBUser.ExecSQL('UPDATE Ingredients '
673
          + 'SET Val = null '
674
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
675
      if CheckBoxLeu.Checked
676
      then
677
        DBUser.ExecSQL('UPDATE Ingredients '
678
          + Format('SET Leu = %.15f ', [InputAA(ValidateEditLeu.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
679
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
680
      else
681
        DBUser.ExecSQL('UPDATE Ingredients '
682
          + 'SET Leu = null '
683
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
684
      if CheckBoxPhe.Checked
685
      then
686
        DBUser.ExecSQL('UPDATE Ingredients '
687
          + Format('SET Phe = %.15f ', [InputAA(ValidateEditPhe.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
688
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
689
      else
690
        DBUser.ExecSQL('UPDATE Ingredients '
691
          + 'SET Phe = null '
692
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
693
      if CheckBoxTyr.Checked
694
      then
695
        DBUser.ExecSQL('UPDATE Ingredients '
696
          + Format('SET Tyr = %.15f ', [InputAA(ValidateEditTyr.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
697
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
698
      else
699
        DBUser.ExecSQL('UPDATE Ingredients '
700
          + 'SET Tyr = null '
701
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
702
      if CheckBoxPheTyr.Checked
703
      then
704
        DBUser.ExecSQL('UPDATE Ingredients '
705
          + Format('SET PheTyr = %.15f ', [InputAA(ValidateEditPheTyr.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
706
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
707
      else
708
        DBUser.ExecSQL('UPDATE Ingredients '
709
          + 'SET PheTyr = null '
710
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
711
      if CheckBoxHis.Checked
712
      then
713
        DBUser.ExecSQL('UPDATE Ingredients '
714
          + Format('SET His = %.15f ', [InputAA(ValidateEditHis.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
715
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
716
      else
717
        DBUser.ExecSQL('UPDATE Ingredients '
718
          + 'SET His = null '
719
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
720
      if CheckBoxArg.Checked
721
      then
722
        DBUser.ExecSQL('UPDATE Ingredients '
723
          + Format('SET Arg = %.15f ', [InputAA(ValidateEditArg.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
724
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
725
      else
726
        DBUser.ExecSQL('UPDATE Ingredients '
727
          + 'SET Arg = null '
728
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
729
      if CheckBoxAla.Checked
730
      then
731
        DBUser.ExecSQL('UPDATE Ingredients '
732
          + Format('SET Ala = %.15f ', [InputAA(ValidateEditAla.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
733
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
734
      else
735
        DBUser.ExecSQL('UPDATE Ingredients '
736
          + 'SET Ala = null '
737
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
738
      if CheckBoxAsp.Checked
739
      then
740
        DBUser.ExecSQL('UPDATE Ingredients '
741
          + Format('SET Asp = %.15f ', [InputAA(ValidateEditAsp.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
742
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
743
      else
744
        DBUser.ExecSQL('UPDATE Ingredients '
745
          + 'SET Asp = null '
746
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
747
      if CheckBoxGlu.Checked
748
      then
749
        DBUser.ExecSQL('UPDATE Ingredients '
750
          + Format('SET Glu = %.15f ', [InputAA(ValidateEditGlu.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
751
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
752
      else
753
        DBUser.ExecSQL('UPDATE Ingredients '
754
          + 'SET Glu = null '
755
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
756
      if CheckBoxGly.Checked
757
      then
758
        DBUser.ExecSQL('UPDATE Ingredients '
759
          + Format('SET Gly = %.15f ', [InputAA(ValidateEditGly.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
760
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
761
      else
762
        DBUser.ExecSQL('UPDATE Ingredients '
763
          + 'SET Gly = null '
764
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
765
      if CheckBoxSer.Checked
766
      then
767
        DBUser.ExecSQL('UPDATE Ingredients '
768
          + Format('SET Ser = %.15f ', [InputAA(ValidateEditSer.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
769
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
770
      else
771
        DBUser.ExecSQL('UPDATE Ingredients '
772
          + 'SET Ser = null '
773
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
774
      if CheckBoxPro.Checked
775
      then
776
        DBUser.ExecSQL('UPDATE Ingredients '
777
          + Format('SET Pro = %.15f ', [InputAA(ValidateEditPro.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2)], USFormatSettings)
778
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
779
      else
780
        DBUser.ExecSQL('UPDATE Ingredients '
781
          + 'SET Pro = null '
782
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
783
      if CheckBoxdLys.Checked
784
      then
785
        DBUser.ExecSQL('UPDATE Ingredients '
786
          + Format('SET dLys = %.15f ', [ValidateEditdLys.AsFloat / 100], USFormatSettings)
787
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
788
      else
789
        DBUser.ExecSQL('UPDATE Ingredients '
790
          + 'SET dLys = null '
791
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
792
      if CheckBoxdThr.Checked
793
      then
794
        DBUser.ExecSQL('UPDATE Ingredients '
795
          + Format('SET dThr = %.15f ', [ValidateEditdThr.AsFloat / 100], USFormatSettings)
796
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
797
      else
798
        DBUser.ExecSQL('UPDATE Ingredients '
799
          + 'SET dThr = null '
800
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
801
      if CheckBoxdMet.Checked
802
      then
803
        DBUser.ExecSQL('UPDATE Ingredients '
804
          + Format('SET dMet = %.15f ', [ValidateEditdMet.AsFloat / 100], USFormatSettings)
805
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
806
      else
807
        DBUser.ExecSQL('UPDATE Ingredients '
808
          + 'SET dMet = null '
809
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
810
      if CheckBoxdCys.Checked
811
      then
812
        DBUser.ExecSQL('UPDATE Ingredients '
813
          + Format('SET dCys = %.15f ', [ValidateEditdCys.AsFloat / 100], USFormatSettings)
814
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
815
      else
816
        DBUser.ExecSQL('UPDATE Ingredients '
817
          + 'SET dCys = null '
818
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
819
      if CheckBoxdMetCys.Checked
820
      then
821
        DBUser.ExecSQL('UPDATE Ingredients '
822
          + Format('SET dMetCys = %.15f ', [ValidateEditdMetCys.AsFloat / 100], USFormatSettings)
823
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
824
      else
825
        DBUser.ExecSQL('UPDATE Ingredients '
826
          + 'SET dMetCys = null '
827
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
828
      if CheckBoxdTrp.Checked
829
      then
830
        DBUser.ExecSQL('UPDATE Ingredients '
831
          + Format('SET dTrp = %.15f ', [ValidateEditdTrp.AsFloat / 100], USFormatSettings)
832
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
833
      else
834
        DBUser.ExecSQL('UPDATE Ingredients '
835
          + 'SET dTrp = null '
836
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
837
      if CheckBoxdIle.Checked
838
      then
839
        DBUser.ExecSQL('UPDATE Ingredients '
840
          + Format('SET dIle = %.15f ', [ValidateEditdIle.AsFloat / 100], USFormatSettings)
841
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
842
      else
843
        DBUser.ExecSQL('UPDATE Ingredients '
844
          + 'SET dIle = null '
845
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
846
      if CheckBoxdVal.Checked
847
      then
848
        DBUser.ExecSQL('UPDATE Ingredients '
849
          + Format('SET dVal = %.15f ', [ValidateEditdVal.AsFloat / 100], USFormatSettings)
850
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
851
      else
852
        DBUser.ExecSQL('UPDATE Ingredients '
853
          + 'SET dVal = null '
854
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
855
      if CheckBoxdLeu.Checked
856
      then
857
        DBUser.ExecSQL('UPDATE Ingredients '
858
          + Format('SET dLeu = %.15f ', [ValidateEditdLeu.AsFloat / 100], USFormatSettings)
859
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
860
      else
861
        DBUser.ExecSQL('UPDATE Ingredients '
862
          + 'SET dLeu = null '
863
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
864
      if CheckBoxdPhe.Checked
865
      then
866
        DBUser.ExecSQL('UPDATE Ingredients '
867
          + Format('SET dPhe = %.15f ', [ValidateEditdPhe.AsFloat / 100], USFormatSettings)
868
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
869
      else
870
        DBUser.ExecSQL('UPDATE Ingredients '
871
          + 'SET dPhe = null '
872
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
873
      if CheckBoxdTyr.Checked
874
      then
875
        DBUser.ExecSQL('UPDATE Ingredients '
876
          + Format('SET dTyr = %.15f ', [ValidateEditdTyr.AsFloat / 100], USFormatSettings)
877
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
878
      else
879
        DBUser.ExecSQL('UPDATE Ingredients '
880
          + 'SET dTyr = null '
881
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
882
      if CheckBoxdPheTyr.Checked
883
      then
884
        DBUser.ExecSQL('UPDATE Ingredients '
885
          + Format('SET dPheTyr = %.15f ', [ValidateEditdPheTyr.AsFloat / 100], USFormatSettings)
886
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
887
      else
888
        DBUser.ExecSQL('UPDATE Ingredients '
889
          + 'SET dPheTyr = null '
890
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
891
      if CheckBoxdHis.Checked
892
      then
893
        DBUser.ExecSQL('UPDATE Ingredients '
894
          + Format('SET dHis = %.15f ', [ValidateEditdHis.AsFloat / 100], USFormatSettings)
895
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
896
      else
897
        DBUser.ExecSQL('UPDATE Ingredients '
898
          + 'SET dHis = null '
899
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
900
      if CheckBoxdArg.Checked
901
      then
902
        DBUser.ExecSQL('UPDATE Ingredients '
903
          + Format('SET dArg = %.15f ', [ValidateEditdArg.AsFloat / 100], USFormatSettings)
904
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
905
      else
906
        DBUser.ExecSQL('UPDATE Ingredients '
907
          + 'SET dArg = null '
908
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
909
      if CheckBoxdAla.Checked
910
      then
911
        DBUser.ExecSQL('UPDATE Ingredients '
912
          + Format('SET dAla = %.15f ', [ValidateEditdAla.AsFloat / 100], USFormatSettings)
913
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
914
      else
915
        DBUser.ExecSQL('UPDATE Ingredients '
916
          + 'SET dAla = null '
917
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
918
      if CheckBoxdAsp.Checked
919
      then
920
        DBUser.ExecSQL('UPDATE Ingredients '
921
          + Format('SET dAsp = %.15f ', [ValidateEditdAsp.AsFloat / 100], USFormatSettings)
922
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
923
      else
924
        DBUser.ExecSQL('UPDATE Ingredients '
925
          + 'SET dAsp = null '
926
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
927
      if CheckBoxdGlu.Checked
928
      then
929
        DBUser.ExecSQL('UPDATE Ingredients '
930
          + Format('SET dGlu = %.15f ', [ValidateEditdGlu.AsFloat / 100], USFormatSettings)
931
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
932
      else
933
        DBUser.ExecSQL('UPDATE Ingredients '
934
          + 'SET dGlu = null '
935
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
936
      if CheckBoxdGly.Checked
937
      then
938
        DBUser.ExecSQL('UPDATE Ingredients '
939
          + Format('SET dGly = %.15f ', [ValidateEditdGly.AsFloat / 100], USFormatSettings)
940
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
941
      else
942
        DBUser.ExecSQL('UPDATE Ingredients '
943
          + 'SET dGly = null '
944
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
945
      if CheckBoxdSer.Checked
946
      then
947
        DBUser.ExecSQL('UPDATE Ingredients '
948
          + Format('SET dSer = %.15f ', [ValidateEditdSer.AsFloat / 100], USFormatSettings)
949
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
950
      else
951
        DBUser.ExecSQL('UPDATE Ingredients '
952
          + 'SET dSer = null '
953
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
954
      if CheckBoxdPro.Checked
955
      then
956
        DBUser.ExecSQL('UPDATE Ingredients '
957
          + Format('SET dPro = %.15f ', [ValidateEditdPro.AsFloat / 100], USFormatSettings)
958
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
959
      else
960
        DBUser.ExecSQL('UPDATE Ingredients '
961
          + 'SET dPro = null '
962
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
963
      // Min?raux
964
      if CheckBoxCa.Checked
965
      then
966
        DBUser.ExecSQL('UPDATE Ingredients '
967
          + Format('SET Ca = %.15f ', [InputMinerals(ValidateEditCa.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2)], USFormatSettings)
968
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
969
      else
970
        DBUser.ExecSQL('UPDATE Ingredients '
971
          + 'SET Ca = null '
972
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
973
      if CheckBoxP.Checked
974
      then
975
        DBUser.ExecSQL('UPDATE Ingredients '
976
          + Format('SET P = %.15f ', [InputMinerals(ValidateEditP.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2)], USFormatSettings)
977
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
978
      else
979
        DBUser.ExecSQL('UPDATE Ingredients '
980
          + 'SET P = null '
981
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
982 3 avalancogn
      if CheckBoxNa.Checked
983
      then
984
        DBUser.ExecSQL('UPDATE Ingredients '
985
          + Format('SET Na = %.15f ', [InputMinerals(ValidateEditNa.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2)], USFormatSettings)
986
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
987
      else
988
        DBUser.ExecSQL('UPDATE Ingredients '
989
          + 'SET Ca = null '
990
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
991
      if CheckBoxK.Checked
992
      then
993
        DBUser.ExecSQL('UPDATE Ingredients '
994
          + Format('SET K = %.15f ', [InputMinerals(ValidateEditK.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2)], USFormatSettings)
995
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
996
      else
997
        DBUser.ExecSQL('UPDATE Ingredients '
998
          + 'SET Ca = null '
999
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
1000
      if CheckBoxCl.Checked
1001
      then
1002
        DBUser.ExecSQL('UPDATE Ingredients '
1003
          + Format('SET Cl = %.15f ', [InputMinerals(ValidateEditCl.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2)], USFormatSettings)
1004
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
1005
      else
1006
        DBUser.ExecSQL('UPDATE Ingredients '
1007
          + 'SET Ca = null '
1008
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
1009 1 avalancogn
      if CheckBoxdP.Checked
1010
      then
1011
        DBUser.ExecSQL('UPDATE Ingredients '
1012
          + Format('SET dP = %.15f ', [ValidateEditdP.AsFloat / 100], USFormatSettings)
1013
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
1014
      else
1015
        DBUser.ExecSQL('UPDATE Ingredients '
1016
          + 'SET dP = null '
1017
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
1018
      if CheckBoxdPphy.Checked
1019
      then
1020
        DBUser.ExecSQL('UPDATE Ingredients '
1021
          + Format('SET dPphy = %.15f ', [ValidateEditdPphy.AsFloat / 100], USFormatSettings)
1022
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]))
1023
      else
1024
        DBUser.ExecSQL('UPDATE Ingredients '
1025
          + 'SET dPphy = null '
1026
          + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
1027
      DBUser.Commit;
1028
    except
1029
      DBUser.RollBack;
1030
      MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitIngredientEditionOriginal', 'ActionOKExecute', 'DBUser (UPDATE Ingredients)']), mtError, [mbOK], 0);
1031
      Exit;
1032
    end;
1033
    // Calculer les valeurs de ClientDataSetIngredients
1034
    Application.ProcessMessages;
1035
    TableIngredients := DBUser.GetTable('SELECT * FROM Ingredients '
1036
      + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
1037
    ClientDataSetIngredients.Edit;
1038
    try
1039
      CalcOriginal;
1040
      ClientDataSetIngredients.Post;
1041
    except
1042
      ClientDataSetIngredients.Cancel;
1043
      MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitIngredientEditionOriginal', 'ActionOKExecute', 'ClientDataSetIngredients']), mtError, [mbOK], 0);
1044
      Exit;
1045
    end;
1046
    TableIngredients.Free;
1047
  end;
1048
  ModalResult := mrOk;
1049
end;
1050
1051
procedure TFormIngredientEditionOriginal.ActionRenameExecute(Sender: TObject);
1052
begin
1053
  FormRename := TFormRename.Create(nil);
1054
  try
1055
    FormIngredientsList.CheckBoxName.Checked := False; // D?sactiver le filtre sur le nom
1056
//    FormRename.Caption := ButtonRename.Hint;
1057
    FormRename.OldName := DataModuleDeclaration.ClientDataSetIngredientsName.Value;
1058
    FormRename.NameList.Assign(DataModuleDeclaration.UserList);
1059
    if (FormRename.ShowModal = mrOk) and (FormRename.NewName <> FormRename.OldName)
1060
    then // Renommer
1061
      with DataModuleDeclaration do
1062
      begin
1063
        DBUser.BeginTransaction;
1064
        try
1065
          DBUser.ExecSQL('UPDATE Ingredients '
1066
            + Format('SET Name = %s ', [QuotedStr(FormRename.NewName)])
1067
            + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
1068
          DBUser.Commit;
1069
        except
1070
          DBUser.RollBack;
1071
          MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitIngredientEditionOriginal', 'ActionRenameExecute', 'DBUser (UPDATE Ingredients)']), mtError, [mbOK], 0);
1072
          Exit;
1073
        end;
1074
        // Renommer dans ClientDataSetIngredients
1075
        ClientDataSetIngredients.Edit;
1076
        ClientDataSetIngredientsName.Value := FormRename.NewName;
1077
        ClientDataSetIngredients.Post;
1078
        // Modifier le nom dans la liste des mati?res premi?res utilisateur
1079
        UserList[UserList.IndexOf(FormRename.OldName)] := FormRename.NewName;
1080
        // R?percuter le changement dans ClientDataSetComposition
1081
        ClientDataSetComposition.Filter := Format('Ingredient = %d and User', [ClientDataSetIngredientsId.Value]);
1082
        ClientDataSetComposition.Filtered := True;
1083
        try
1084
          ClientDataSetComposition.First;
1085
          while not ClientDataSetComposition.Eof do
1086
          begin
1087
            ClientDataSetComposition.Edit;
1088
            try
1089
              ClientDataSetCompositionIngredientName.Value := FormRename.NewName;
1090
              ClientDataSetComposition.Post;
1091
            except
1092
              ClientDataSetComposition.Cancel;
1093
            end;
1094
            ClientDataSetComposition.Next;
1095
          end;
1096
        finally
1097
          ClientDataSetComposition.Filtered := False;
1098
          ClientDataSetComposition.Filter := '';
1099
        end;
1100
      end;
1101
  finally
1102
    FormRename.Release;
1103
  end;
1104
end;
1105
1106
procedure TFormIngredientEditionOriginal.ButtonCommentClick(Sender: TObject);
1107
begin
1108
  ActionCommentExecute(Sender);
1109
end;
1110
1111
procedure TFormIngredientEditionOriginal.ButtonHelpClick(Sender: TObject);
1112
begin
1113
  ActionHelpExecute(Sender);
1114
end;
1115
1116
procedure TFormIngredientEditionOriginal.ButtonRenameClick(Sender: TObject);
1117
begin
1118
  ActionRenameExecute(Sender);
1119
end;
1120
1121
procedure TFormIngredientEditionOriginal.CheckBoxADFClick(Sender: TObject);
1122
begin
1123
  if CheckBoxADF.Checked
1124
  then // Activer la saisie
1125
    EditActivate(ValidateEditADF)
1126
  else // Valeur inconnue
1127
    EditEmpty(ValidateEditADF);
1128
end;
1129
1130
procedure TFormIngredientEditionOriginal.CheckBoxADLClick(Sender: TObject);
1131
begin
1132
  if CheckBoxADL.Checked
1133
  then // Activer la saisie
1134
    EditActivate(ValidateEditADL)
1135
  else // Valeur inconnue
1136
    EditEmpty(ValidateEditADL);
1137
end;
1138
1139
procedure TFormIngredientEditionOriginal.CheckBoxAlaClick(Sender: TObject);
1140
begin
1141
  if CheckBoxAla.Checked
1142
  then // Activer la saisie
1143
    EditActivate(ValidateEditAla)
1144
  else // Valeur inconnue
1145
    EditEmpty(ValidateEditAla);
1146
end;
1147
1148
procedure TFormIngredientEditionOriginal.CheckBoxAmidonClick(Sender: TObject);
1149
begin
1150
  if CheckBoxAmidon.Checked
1151
  then // Activer la saisie
1152
    EditActivate(ValidateEditAmidon)
1153
  else // Valeur inconnue
1154
    EditEmpty(ValidateEditAmidon);
1155
end;
1156
1157
procedure TFormIngredientEditionOriginal.CheckBoxArgClick(Sender: TObject);
1158
begin
1159
  if CheckBoxArg.Checked
1160
  then // Activer la saisie
1161
    EditActivate(ValidateEditArg)
1162
  else // Valeur inconnue
1163
    EditEmpty(ValidateEditArg);
1164
end;
1165
1166
procedure TFormIngredientEditionOriginal.CheckBoxAspClick(Sender: TObject);
1167
begin
1168
  if CheckBoxAsp.Checked
1169
  then // Activer la saisie
1170
    EditActivate(ValidateEditAsp)
1171
  else // Valeur inconnue
1172
    EditEmpty(ValidateEditAsp);
1173
end;
1174
1175
procedure TFormIngredientEditionOriginal.CheckBoxCaClick(Sender: TObject);
1176
begin
1177
  if CheckBoxCa.Checked
1178
  then // Activer la saisie
1179
    EditActivate(ValidateEditCa)
1180
  else // Valeur inconnue
1181
    EditEmpty(ValidateEditCa);
1182
end;
1183
1184
procedure TFormIngredientEditionOriginal.CheckBoxCBClick(Sender: TObject);
1185
begin
1186
  if CheckBoxCB.Checked
1187
  then // Activer la saisie
1188
    EditActivate(ValidateEditCB)
1189
  else // Valeur inconnue
1190
    EditEmpty(ValidateEditCB);
1191
end;
1192
1193 3 avalancogn
procedure TFormIngredientEditionOriginal.CheckBoxClClick(Sender: TObject);
1194
begin
1195
  if CheckBoxCl.Checked
1196
  then // Activer la saisie
1197
    EditActivate(ValidateEditCl)
1198
  else // Valeur inconnue
1199
    EditEmpty(ValidateEditCl);
1200
end;
1201
1202 1 avalancogn
procedure TFormIngredientEditionOriginal.CheckBoxCysClick(Sender: TObject);
1203
begin
1204
  if CheckBoxCys.Checked
1205
  then // Activer la saisie
1206
    EditActivate(ValidateEditCys)
1207
  else // Valeur inconnue
1208
    EditEmpty(ValidateEditCys);
1209
end;
1210
1211
procedure TFormIngredientEditionOriginal.CheckBoxdAlaClick(Sender: TObject);
1212
begin
1213
  if CheckBoxdAla.Checked
1214
  then // Activer la saisie
1215
    EditActivate(ValidateEditdAla)
1216
  else // Afficher la valeur par d?faut
1217
    EditShow(ValidateEditdAla, dAla * 100);
1218
end;
1219
1220
procedure TFormIngredientEditionOriginal.CheckBoxdArgClick(Sender: TObject);
1221
begin
1222
  if CheckBoxdArg.Checked
1223
  then // Activer la saisie
1224
    EditActivate(ValidateEditdArg)
1225
  else // Afficher la valeur par d?faut
1226
    EditShow(ValidateEditdArg, dArg * 100);
1227
end;
1228
1229
procedure TFormIngredientEditionOriginal.CheckBoxdAspClick(Sender: TObject);
1230
begin
1231
  if CheckBoxdAsp.Checked
1232
  then // Activer la saisie
1233
    EditActivate(ValidateEditdAsp)
1234
  else // Afficher la valeur par d?faut
1235
    EditShow(ValidateEditdAsp, dAsp * 100);
1236
end;
1237
1238
procedure TFormIngredientEditionOriginal.CheckBoxdCysClick(Sender: TObject);
1239
begin
1240
  if CheckBoxdCys.Checked
1241
  then // Activer la saisie
1242
    EditActivate(ValidateEditdCys)
1243
  else // Afficher la valeur par d?faut
1244
    EditShow(ValidateEditdCys, dCys * 100);
1245
end;
1246
1247
procedure TFormIngredientEditionOriginal.CheckBoxdGluClick(Sender: TObject);
1248
begin
1249
  if CheckBoxdGlu.Checked
1250
  then // Activer la saisie
1251
    EditActivate(ValidateEditdGlu)
1252
  else // Afficher la valeur par d?faut
1253
    EditShow(ValidateEditdGlu, dGlu * 100);
1254
end;
1255
1256
procedure TFormIngredientEditionOriginal.CheckBoxdGlyClick(Sender: TObject);
1257
begin
1258
  if CheckBoxdGly.Checked
1259
  then // Activer la saisie
1260
    EditActivate(ValidateEditdGly)
1261
  else // Afficher la valeur par d?faut
1262
    EditShow(ValidateEditdGly, dGly * 100);
1263
end;
1264
1265
procedure TFormIngredientEditionOriginal.CheckBoxdHisClick(Sender: TObject);
1266
begin
1267
  if CheckBoxdHis.Checked
1268
  then // Activer la saisie
1269
    EditActivate(ValidateEditdHis)
1270
  else // Afficher la valeur par d?faut
1271
    EditShow(ValidateEditdHis, dHis * 100);
1272
end;
1273
1274
procedure TFormIngredientEditionOriginal.CheckBoxdIleClick(Sender: TObject);
1275
begin
1276
  if CheckBoxdIle.Checked
1277
  then // Activer la saisie
1278
    EditActivate(ValidateEditdIle)
1279
  else // Afficher la valeur par d?faut
1280
    EditShow(ValidateEditdIle, dIle * 100);
1281
end;
1282
1283
procedure TFormIngredientEditionOriginal.CheckBoxdLeuClick(Sender: TObject);
1284
begin
1285
  if CheckBoxdLeu.Checked
1286
  then // Activer la saisie
1287
    EditActivate(ValidateEditdLeu)
1288
  else // Afficher la valeur par d?faut
1289
    EditShow(ValidateEditdLeu, dLeu * 100);
1290
end;
1291
1292
procedure TFormIngredientEditionOriginal.CheckBoxdLysClick(Sender: TObject);
1293
begin
1294
  if CheckBoxdLys.Checked
1295
  then // Activer la saisie
1296
    EditActivate(ValidateEditdLys)
1297
  else // Afficher la valeur par d?faut
1298
    EditShow(ValidateEditdLys, dLys * 100);
1299
end;
1300
1301
procedure TFormIngredientEditionOriginal.CheckBoxdMetClick(Sender: TObject);
1302
begin
1303
  if CheckBoxdMet.Checked
1304
  then // Activer la saisie
1305
    EditActivate(ValidateEditdMet)
1306
  else // Afficher la valeur par d?faut
1307
    EditShow(ValidateEditdMet, dMet * 100);
1308
end;
1309
1310
procedure TFormIngredientEditionOriginal.CheckBoxdMetCysClick(Sender: TObject);
1311
begin
1312
  if CheckBoxdMetCys.Checked
1313
  then // Activer la saisie
1314
    EditActivate(ValidateEditdMetCys)
1315
  else // Afficher la valeur par d?faut
1316
    EditShow(ValidateEditdMetCys, dMetCys * 100);
1317
end;
1318
1319
procedure TFormIngredientEditionOriginal.CheckBoxdPClick(Sender: TObject);
1320
begin
1321
  if CheckBoxdP.Checked
1322
  then // Activer la saisie
1323
    EditActivate(ValidateEditdP)
1324
  else // Afficher la valeur par d?faut
1325
    if ValidateEditP.AsFloat = 0
1326
    then // Null
1327
      EditEmpty(ValidateEditdP)
1328
    else // Par d?faut dP = 20%
1329
      EditShow(ValidateEditdP, 20);
1330
end;
1331
1332
procedure TFormIngredientEditionOriginal.CheckBoxdPheClick(Sender: TObject);
1333
begin
1334
  if CheckBoxdPhe.Checked
1335
  then // Activer la saisie
1336
    EditActivate(ValidateEditdPhe)
1337
  else // Afficher la valeur par d?faut
1338
    EditShow(ValidateEditdPhe, dPhe * 100);
1339
end;
1340
1341
procedure TFormIngredientEditionOriginal.CheckBoxdPheTyrClick(Sender: TObject);
1342
begin
1343
  if CheckBoxdPheTyr.Checked
1344
  then // Activer la saisie
1345
    EditActivate(ValidateEditdPheTyr)
1346
  else // Afficher la valeur par d?faut
1347
    EditShow(ValidateEditdPheTyr, dPheTyr * 100);
1348
end;
1349
1350
procedure TFormIngredientEditionOriginal.CheckBoxdPphyClick(Sender: TObject);
1351
begin
1352
  if CheckBoxdPphy.Checked
1353
  then // Activer la saisie
1354
    EditActivate(ValidateEditdPphy)
1355
  else // Afficher la valeur par d?faut
1356
    if ValidateEditP.AsFloat = 0
1357
    then // Null
1358
      EditEmpty(ValidateEditdPphy)
1359
    else // Par d?faut dPphy = dP
1360
      EditShow(ValidateEditdPphy, ValidateEditdP.AsFloat);
1361
end;
1362
1363
procedure TFormIngredientEditionOriginal.CheckBoxdProClick(Sender: TObject);
1364
begin
1365
  if CheckBoxdPro.Checked
1366
  then // Activer la saisie
1367
    EditActivate(ValidateEditdPro)
1368
  else // Afficher la valeur par d?faut
1369
    EditShow(ValidateEditdPro, dPro * 100);
1370
end;
1371
1372
procedure TFormIngredientEditionOriginal.CheckBoxdSerClick(Sender: TObject);
1373
begin
1374
  if CheckBoxdSer.Checked
1375
  then // Activer la saisie
1376
    EditActivate(ValidateEditdSer)
1377
  else // Afficher la valeur par d?faut
1378
    EditShow(ValidateEditdSer, dSer * 100);
1379
end;
1380
1381
procedure TFormIngredientEditionOriginal.CheckBoxdThrClick(Sender: TObject);
1382
begin
1383
  if CheckBoxdThr.Checked
1384
  then // Activer la saisie
1385
    EditActivate(ValidateEditdThr)
1386
  else // Afficher la valeur par d?faut
1387
    EditShow(ValidateEditdThr, dThr * 100);
1388
end;
1389
1390
procedure TFormIngredientEditionOriginal.CheckBoxdTrpClick(Sender: TObject);
1391
begin
1392
  if CheckBoxdTrp.Checked
1393
  then // Activer la saisie
1394
    EditActivate(ValidateEditdTrp)
1395
  else // Afficher la valeur par d?faut
1396
    EditShow(ValidateEditdTrp, dTrp * 100);
1397
end;
1398
1399
procedure TFormIngredientEditionOriginal.CheckBoxdTyrClick(Sender: TObject);
1400
begin
1401
  if CheckBoxdTyr.Checked
1402
  then // Activer la saisie
1403
    EditActivate(ValidateEditdTyr)
1404
  else // Afficher la valeur par d?faut
1405
    EditShow(ValidateEditdTyr, dTyr * 100);
1406
end;
1407
1408
procedure TFormIngredientEditionOriginal.CheckBoxdValClick(Sender: TObject);
1409
begin
1410
  if CheckBoxdVal.Checked
1411
  then // Activer la saisie
1412
    EditActivate(ValidateEditdVal)
1413
  else // Afficher la valeur par d?faut
1414
    EditShow(ValidateEditdVal, dVal * 100);
1415
end;
1416
1417
procedure TFormIngredientEditionOriginal.CheckBoxEBClick(Sender: TObject);
1418
begin
1419
  if CheckBoxEB.Checked
1420
  then // Activer la saisie
1421
    EditActivate(ValidateEditEB)
1422
  else // Valeur inconnue
1423
    EditEmpty(ValidateEditEB);
1424
end;
1425
1426
procedure TFormIngredientEditionOriginal.CheckBoxGluClick(Sender: TObject);
1427
begin
1428
  if CheckBoxGlu.Checked
1429
  then // Activer la saisie
1430
    EditActivate(ValidateEditGlu)
1431
  else // Valeur inconnue
1432
    EditEmpty(ValidateEditGlu);
1433
end;
1434
1435
procedure TFormIngredientEditionOriginal.CheckBoxGlyClick(Sender: TObject);
1436
begin
1437
  if CheckBoxGly.Checked
1438
  then // Activer la saisie
1439
    EditActivate(ValidateEditGly)
1440
  else // Valeur inconnue
1441
    EditEmpty(ValidateEditGly);
1442
end;
1443
1444
procedure TFormIngredientEditionOriginal.CheckBoxHisClick(Sender: TObject);
1445
begin
1446
  if CheckBoxHis.Checked
1447
  then // Activer la saisie
1448
    EditActivate(ValidateEditHis)
1449
  else // Valeur inconnue
1450
    EditEmpty(ValidateEditHis);
1451
end;
1452
1453
procedure TFormIngredientEditionOriginal.CheckBoxIleClick(Sender: TObject);
1454
begin
1455
  if CheckBoxIle.Checked
1456
  then // Activer la saisie
1457
    EditActivate(ValidateEditIle)
1458
  else // Valeur inconnue
1459
    EditEmpty(ValidateEditIle);
1460
end;
1461
1462 3 avalancogn
procedure TFormIngredientEditionOriginal.CheckBoxKClick(Sender: TObject);
1463
begin
1464
  if CheckBoxK.Checked
1465
  then // Activer la saisie
1466
    EditActivate(ValidateEditK)
1467
  else // Valeur inconnue
1468
    EditEmpty(ValidateEditK);
1469
end;
1470
1471 1 avalancogn
procedure TFormIngredientEditionOriginal.CheckBoxLeuClick(Sender: TObject);
1472
begin
1473
  if CheckBoxLeu.Checked
1474
  then // Activer la saisie
1475
    EditActivate(ValidateEditLeu)
1476
  else // Valeur inconnue
1477
    EditEmpty(ValidateEditLeu);
1478
end;
1479
1480
procedure TFormIngredientEditionOriginal.CheckBoxLysClick(Sender: TObject);
1481
begin
1482
  if CheckBoxLys.Checked
1483
  then // Activer la saisie
1484
    EditActivate(ValidateEditLys)
1485
  else // Valeur inconnue
1486
    EditEmpty(ValidateEditLys);
1487
end;
1488
1489
procedure TFormIngredientEditionOriginal.CheckBoxMATClick(Sender: TObject);
1490
begin
1491
  if CheckBoxMAT.Checked
1492
  then // Activer la saisie
1493
    EditActivate(ValidateEditMAT)
1494
  else // Valeur inconnue
1495
  begin
1496
    DataModuleDeclaration.RapMAT := 0;
1497
    EditEmpty(ValidateEditMAT);
1498
    // D?sactiver la saisie des acides amin?s
1499
    DisableAA;
1500
  end;
1501
end;
1502
1503
procedure TFormIngredientEditionOriginal.CheckBoxMetClick(Sender: TObject);
1504
begin
1505
  if CheckBoxMet.Checked
1506
  then // Activer la saisie
1507
    EditActivate(ValidateEditMet)
1508
  else // Valeur inconnue
1509
    EditEmpty(ValidateEditMet);
1510
end;
1511
1512
procedure TFormIngredientEditionOriginal.CheckBoxMetCysClick(Sender: TObject);
1513
begin
1514
  if CheckBoxMetCys.Checked
1515
  then // Activer la saisie
1516
    EditActivate(ValidateEditMetCys)
1517
  else // Valeur inconnue
1518
    EditEmpty(ValidateEditMetCys);
1519
end;
1520
1521
procedure TFormIngredientEditionOriginal.CheckBoxMGClick(Sender: TObject);
1522
begin
1523
  if CheckBoxMG.Checked
1524
  then // Activer la saisie
1525
    EditActivate(ValidateEditMG)
1526
  else // Valeur inconnue
1527
    EditEmpty(ValidateEditMG);
1528
end;
1529
1530
procedure TFormIngredientEditionOriginal.CheckBoxMMClick(Sender: TObject);
1531
begin
1532
  if CheckBoxMM.Checked
1533
  then // Activer la saisie
1534
    EditActivate(ValidateEditMM)
1535
  else // Valeur inconnue
1536
    EditEmpty(ValidateEditMM);
1537
end;
1538
1539 3 avalancogn
procedure TFormIngredientEditionOriginal.CheckBoxNaClick(Sender: TObject);
1540
begin
1541
  if CheckBoxNa.Checked
1542
  then // Activer la saisie
1543
    EditActivate(ValidateEditNa)
1544
  else // Valeur inconnue
1545
    EditEmpty(ValidateEditNa);
1546
end;
1547
1548 1 avalancogn
procedure TFormIngredientEditionOriginal.CheckBoxNDFClick(Sender: TObject);
1549
begin
1550
  if CheckBoxNDF.Checked
1551
  then // Activer la saisie
1552
    EditActivate(ValidateEditNDF)
1553
  else // Valeur inconnue
1554
    EditEmpty(ValidateEditNDF);
1555
end;
1556
1557
procedure TFormIngredientEditionOriginal.CheckBoxPClick(Sender: TObject);
1558
begin
1559
  if CheckBoxP.Checked
1560
  then // Activer la saisie
1561
    EditActivate(ValidateEditP)
1562
  else // Valeur inconnue
1563
  begin
1564
    EditEmpty(ValidateEditP);
1565
    // D?sactiver la saisie du phosphore digestible
1566
    DisabledP;
1567
  end;
1568
end;
1569
1570
procedure TFormIngredientEditionOriginal.CheckBoxPheClick(Sender: TObject);
1571
begin
1572
  if CheckBoxPhe.Checked
1573
  then // Activer la saisie
1574
    EditActivate(ValidateEditPhe)
1575
  else // Valeur inconnue
1576
    EditEmpty(ValidateEditPhe);
1577
end;
1578
1579
procedure TFormIngredientEditionOriginal.CheckBoxPheTyrClick(Sender: TObject);
1580
begin
1581
  if CheckBoxPheTyr.Checked
1582
  then // Activer la saisie
1583
    EditActivate(ValidateEditPheTyr)
1584
  else // Valeur inconnue
1585
    EditEmpty(ValidateEditPheTyr);
1586
end;
1587
1588
procedure TFormIngredientEditionOriginal.CheckBoxProClick(Sender: TObject);
1589
begin
1590
  if CheckBoxPro.Checked
1591
  then // Activer la saisie
1592
    EditActivate(ValidateEditPro)
1593
  else // Valeur inconnue
1594
    EditEmpty(ValidateEditPro);
1595
end;
1596
1597
procedure TFormIngredientEditionOriginal.CheckBoxSerClick(Sender: TObject);
1598
begin
1599
  if CheckBoxSer.Checked
1600
  then // Activer la saisie
1601
    EditActivate(ValidateEditSer)
1602
  else // Valeur inconnue
1603
    EditEmpty(ValidateEditSer);
1604
end;
1605
1606
procedure TFormIngredientEditionOriginal.CheckBoxSucresClick(Sender: TObject);
1607
begin
1608
  if CheckBoxSucres.Checked
1609
  then // Activer la saisie
1610
    EditActivate(ValidateEditSucres)
1611
  else // Valeur inconnue
1612
    EditEmpty(ValidateEditSucres);
1613
end;
1614
1615
procedure TFormIngredientEditionOriginal.CheckBoxThrClick(Sender: TObject);
1616
begin
1617
  if CheckBoxThr.Checked
1618
  then // Activer la saisie
1619
    EditActivate(ValidateEditThr)
1620
  else // Valeur inconnue
1621
    EditEmpty(ValidateEditThr);
1622
end;
1623
1624
procedure TFormIngredientEditionOriginal.CheckBoxTrpClick(Sender: TObject);
1625
begin
1626
  if CheckBoxTrp.Checked
1627
  then // Activer la saisie
1628
    EditActivate(ValidateEditTrp)
1629
  else // Valeur inconnue
1630
    EditEmpty(ValidateEditTrp);
1631
end;
1632
1633
procedure TFormIngredientEditionOriginal.CheckBoxTyrClick(Sender: TObject);
1634
begin
1635
  if CheckBoxTyr.Checked
1636
  then // Activer la saisie
1637
    EditActivate(ValidateEditTyr)
1638
  else // Valeur inconnue
1639
    EditEmpty(ValidateEditTyr);
1640
end;
1641
1642
procedure TFormIngredientEditionOriginal.CheckBoxValClick(Sender: TObject);
1643
begin
1644
  if CheckBoxVal.Checked
1645
  then // Activer la saisie
1646
    EditActivate(ValidateEditVal)
1647
  else // Valeur inconnue
1648
    EditEmpty(ValidateEditVal);
1649
end;
1650
1651
procedure TFormIngredientEditionOriginal.ComboBoxAAChange(Sender: TObject);
1652
begin
1653
  if ComboBoxAA.ItemIndex <> AAUnit
1654
  then // Changement d'unit?
1655
  begin
1656
    if ComboBoxAA.ItemIndex mod 2 = 0
1657
    then // %
1658
    begin
1659
      ValidateEditLys.DecimalPlaces := 2;
1660
      ValidateEditThr.DecimalPlaces := 2;
1661
      ValidateEditMet.DecimalPlaces := 2;
1662
      ValidateEditCys.DecimalPlaces := 2;
1663
      ValidateEditMetCys.DecimalPlaces := 2;
1664
      ValidateEditTrp.DecimalPlaces := 2;
1665
      ValidateEditIle.DecimalPlaces := 2;
1666
      ValidateEditVal.DecimalPlaces := 2;
1667
      ValidateEditLeu.DecimalPlaces := 2;
1668
      ValidateEditPhe.DecimalPlaces := 2;
1669
      ValidateEditTyr.DecimalPlaces := 2;
1670
      ValidateEditPheTyr.DecimalPlaces := 2;
1671
      ValidateEditHis.DecimalPlaces := 2;
1672
      ValidateEditArg.DecimalPlaces := 2;
1673
      ValidateEditAla.DecimalPlaces := 2;
1674
      ValidateEditAsp.DecimalPlaces := 2;
1675
      ValidateEditGlu.DecimalPlaces := 2;
1676
      ValidateEditGly.DecimalPlaces := 2;
1677
      ValidateEditSer.DecimalPlaces := 2;
1678
      ValidateEditPro.DecimalPlaces := 2;
1679
    end
1680
    else // g/kg
1681
    begin
1682
      ValidateEditLys.MaxValue := 1000;
1683
      ValidateEditThr.MaxValue := 1000;
1684
      ValidateEditMet.MaxValue := 1000;
1685
      ValidateEditCys.MaxValue := 1000;
1686
      ValidateEditMetCys.MaxValue := 1000;
1687
      ValidateEditTrp.MaxValue := 1000;
1688
      ValidateEditIle.MaxValue := 1000;
1689
      ValidateEditVal.MaxValue := 1000;
1690
      ValidateEditLeu.MaxValue := 1000;
1691
      ValidateEditPhe.MaxValue := 1000;
1692
      ValidateEditTyr.MaxValue := 1000;
1693
      ValidateEditPheTyr.MaxValue := 1000;
1694
      ValidateEditHis.MaxValue := 1000;
1695
      ValidateEditArg.MaxValue := 1000;
1696
      ValidateEditAla.MaxValue := 1000;
1697
      ValidateEditAsp.MaxValue := 1000;
1698
      ValidateEditGlu.MaxValue := 1000;
1699
      ValidateEditGly.MaxValue := 1000;
1700
      ValidateEditSer.MaxValue := 1000;
1701
      ValidateEditPro.MaxValue := 1000;
1702
    end;
1703
    if AAUnit <> -1
1704
    then
1705
      with DataModuleDeclaration do
1706
      begin
1707
        if CheckBoxLys.Checked
1708
        then // Conversion
1709
          ValidateEditLys.AsFloat := OutputAA(InputAA(ValidateEditLys.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1710
        if CheckBoxThr.Checked
1711
        then // Conversion
1712
          ValidateEditThr.AsFloat := OutputAA(InputAA(ValidateEditThr.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1713
        if CheckBoxMet.Checked
1714
        then // Conversion
1715
          ValidateEditMet.AsFloat := OutputAA(InputAA(ValidateEditMet.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1716
        if CheckBoxCys.Checked
1717
        then // Conversion
1718
          ValidateEditCys.AsFloat := OutputAA(InputAA(ValidateEditCys.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1719
        if CheckBoxMetCys.Checked
1720
        then // Conversion
1721
          ValidateEditMetCys.AsFloat := OutputAA(InputAA(ValidateEditMetCys.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1722
        if CheckBoxTrp.Checked
1723
        then // Conversion
1724
          ValidateEditTrp.AsFloat := OutputAA(InputAA(ValidateEditTrp.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1725
        if CheckBoxIle.Checked
1726
        then // Conversion
1727
          ValidateEditIle.AsFloat := OutputAA(InputAA(ValidateEditIle.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1728
        if CheckBoxVal.Checked
1729
        then // Conversion
1730
          ValidateEditVal.AsFloat := OutputAA(InputAA(ValidateEditVal.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1731
        if CheckBoxLeu.Checked
1732
        then // Conversion
1733
          ValidateEditLeu.AsFloat := OutputAA(InputAA(ValidateEditLeu.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1734
        if CheckBoxPhe.Checked
1735
        then // Conversion
1736
          ValidateEditPhe.AsFloat := OutputAA(InputAA(ValidateEditPhe.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1737
        if CheckBoxTyr.Checked
1738
        then // Conversion
1739
          ValidateEditTyr.AsFloat := OutputAA(InputAA(ValidateEditTyr.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1740
        if CheckBoxPheTyr.Checked
1741
        then // Conversion
1742
          ValidateEditPheTyr.AsFloat := OutputAA(InputAA(ValidateEditPheTyr.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1743
        if CheckBoxHis.Checked
1744
        then // Conversion
1745
          ValidateEditHis.AsFloat := OutputAA(InputAA(ValidateEditHis.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1746
        if CheckBoxArg.Checked
1747
        then // Conversion
1748
          ValidateEditArg.AsFloat := OutputAA(InputAA(ValidateEditArg.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1749
        if CheckBoxAla.Checked
1750
        then // Conversion
1751
          ValidateEditAla.AsFloat := OutputAA(InputAA(ValidateEditAla.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1752
        if CheckBoxAsp.Checked
1753
        then // Conversion
1754
          ValidateEditAsp.AsFloat := OutputAA(InputAA(ValidateEditAsp.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1755
        if CheckBoxGlu.Checked
1756
        then // Conversion
1757
          ValidateEditGlu.AsFloat := OutputAA(InputAA(ValidateEditGlu.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1758
        if CheckBoxGly.Checked
1759
        then // Conversion
1760
          ValidateEditGly.AsFloat := OutputAA(InputAA(ValidateEditGly.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1761
        if CheckBoxSer.Checked
1762
        then // Conversion
1763
          ValidateEditSer.AsFloat := OutputAA(InputAA(ValidateEditSer.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1764
        if CheckBoxPro.Checked
1765
        then // Conversion
1766
          ValidateEditPro.AsFloat := OutputAA(InputAA(ValidateEditPro.AsFloat, RapMAT, RapMS, AAUnit div 2, AAUnit mod 2), RapMAT, RapMS, ComboBoxAA.ItemIndex div 2, ComboBoxAA.ItemIndex mod 2);
1767
      end;
1768
    if ComboBoxAA.ItemIndex mod 2 = 0
1769
    then // %
1770
    begin
1771
      ValidateEditLys.MaxValue := 100;
1772
      ValidateEditThr.MaxValue := 100;
1773
      ValidateEditMet.MaxValue := 100;
1774
      ValidateEditCys.MaxValue := 100;
1775
      ValidateEditMetCys.MaxValue := 100;
1776
      ValidateEditTrp.MaxValue := 100;
1777
      ValidateEditIle.MaxValue := 100;
1778
      ValidateEditVal.MaxValue := 100;
1779
      ValidateEditLeu.MaxValue := 100;
1780
      ValidateEditPhe.MaxValue := 100;
1781
      ValidateEditTyr.MaxValue := 100;
1782
      ValidateEditPheTyr.MaxValue := 100;
1783
      ValidateEditHis.MaxValue := 100;
1784
      ValidateEditArg.MaxValue := 100;
1785
      ValidateEditAla.MaxValue := 100;
1786
      ValidateEditAsp.MaxValue := 100;
1787
      ValidateEditGlu.MaxValue := 100;
1788
      ValidateEditGly.MaxValue := 100;
1789
      ValidateEditSer.MaxValue := 100;
1790
      ValidateEditPro.MaxValue := 100;
1791
    end
1792
    else // g/kg
1793
    begin
1794
      ValidateEditLys.DecimalPlaces := 1;
1795
      ValidateEditThr.DecimalPlaces := 1;
1796
      ValidateEditMet.DecimalPlaces := 1;
1797
      ValidateEditCys.DecimalPlaces := 1;
1798
      ValidateEditMetCys.DecimalPlaces := 1;
1799
      ValidateEditTrp.DecimalPlaces := 1;
1800
      ValidateEditIle.DecimalPlaces := 1;
1801
      ValidateEditVal.DecimalPlaces := 1;
1802
      ValidateEditLeu.DecimalPlaces := 1;
1803
      ValidateEditPhe.DecimalPlaces := 1;
1804
      ValidateEditTyr.DecimalPlaces := 1;
1805
      ValidateEditPheTyr.DecimalPlaces := 1;
1806
      ValidateEditHis.DecimalPlaces := 1;
1807
      ValidateEditArg.DecimalPlaces := 1;
1808
      ValidateEditAla.DecimalPlaces := 1;
1809
      ValidateEditAsp.DecimalPlaces := 1;
1810
      ValidateEditGlu.DecimalPlaces := 1;
1811
      ValidateEditGly.DecimalPlaces := 1;
1812
      ValidateEditSer.DecimalPlaces := 1;
1813
      ValidateEditPro.DecimalPlaces := 1;
1814
    end;
1815
    AAUnit := ComboBoxAA.ItemIndex;
1816
  end;
1817
end;
1818
1819
procedure TFormIngredientEditionOriginal.ComboBoxEnergyChange(Sender: TObject);
1820
begin
1821
  if ComboBoxEnergy.ItemIndex <> EnergyUnit
1822
  then // Changement d'unit?
1823
  begin
1824
    if ComboBoxEnergy.ItemIndex mod 2 = 0
1825
    then // MJ/kg
1826
      ValidateEditEB.DecimalPlaces := 2;
1827
    if CheckBoxEB.Checked
1828
    then // Conversion
1829
      with DataModuleDeclaration do
1830
        ValidateEditEB.AsFloat := OutputEnergy(InputEnergy(ValidateEditEB.AsFloat, RapMS, EnergyUnit div 2, EnergyUnit mod 2), RapMS, ComboBoxEnergy.ItemIndex div 2, ComboBoxEnergy.ItemIndex mod 2);
1831
    if ComboBoxEnergy.ItemIndex mod 2 = 1
1832
    then // kcal/kg
1833
      ValidateEditEB.DecimalPlaces := 0;
1834
    EnergyUnit := ComboBoxEnergy.ItemIndex;
1835
  end;
1836
end;
1837
1838
procedure TFormIngredientEditionOriginal.ComboBoxMineralsChange(Sender: TObject);
1839
begin
1840
  if ComboBoxMinerals.ItemIndex <> MineralsUnit
1841
  then // Changement d'unit?
1842
  begin
1843
    if ComboBoxMinerals.ItemIndex mod 2 = 0
1844
    then // %
1845
    begin
1846
      ValidateEditCa.DecimalPlaces := 2;
1847
      ValidateEditP.DecimalPlaces := 2;
1848 3 avalancogn
      ValidateEditNa.DecimalPlaces := 2;
1849
      ValidateEditK.DecimalPlaces := 2;
1850
      ValidateEditCl.DecimalPlaces := 2;
1851 1 avalancogn
    end
1852
    else // g/kg
1853
    begin
1854
      ValidateEditCa.MaxValue := 1000;
1855
      ValidateEditP.MaxValue := 1000;
1856 3 avalancogn
      ValidateEditNa.MaxValue := 1000;
1857
      ValidateEditK.MaxValue := 1000;
1858
      ValidateEditCl.MaxValue := 1000;
1859 1 avalancogn
    end;
1860
    with DataModuleDeclaration do
1861
    begin
1862
      if CheckBoxCa.Checked
1863
      then // Conversion
1864
        ValidateEditCa.AsFloat := OutputMinerals(InputMinerals(ValidateEditCa.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2), RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2);
1865
      if CheckBoxP.Checked
1866
      then // Conversion
1867
        ValidateEditP.AsFloat := OutputMinerals(InputMinerals(ValidateEditP.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2), RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2);
1868 3 avalancogn
      if CheckBoxNa.Checked
1869
      then // Conversion
1870
        ValidateEditNa.AsFloat := OutputMinerals(InputMinerals(ValidateEditNa.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2), RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2);
1871
      if CheckBoxK.Checked
1872
      then // Conversion
1873
        ValidateEditK.AsFloat := OutputMinerals(InputMinerals(ValidateEditK.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2), RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2);
1874
      if CheckBoxCl.Checked
1875
      then // Conversion
1876
        ValidateEditCl.AsFloat := OutputMinerals(InputMinerals(ValidateEditCl.AsFloat, RapMS, MineralsUnit div 2, MineralsUnit mod 2), RapMS, ComboBoxMinerals.ItemIndex div 2, ComboBoxMinerals.ItemIndex mod 2);
1877 1 avalancogn
    end;
1878
    if ComboBoxMinerals.ItemIndex mod 2 = 0
1879
    then // %
1880
    begin
1881
      ValidateEditCa.MaxValue := 100;
1882
      ValidateEditP.MaxValue := 100;
1883 3 avalancogn
      ValidateEditNa.MaxValue := 100;
1884
      ValidateEditK.MaxValue := 100;
1885
      ValidateEditCl.MaxValue := 100;
1886 1 avalancogn
    end
1887
    else // g/kg
1888
    begin
1889
      ValidateEditCa.DecimalPlaces := 1;
1890
      ValidateEditP.DecimalPlaces := 1;
1891 3 avalancogn
      ValidateEditNa.DecimalPlaces := 1;
1892
      ValidateEditK.DecimalPlaces := 1;
1893
      ValidateEditCl.DecimalPlaces := 1;
1894 1 avalancogn
    end;
1895
    MineralsUnit := ComboBoxMinerals.ItemIndex;
1896
  end;
1897
end;
1898
1899
procedure TFormIngredientEditionOriginal.ComboBoxProximalChange(Sender: TObject);
1900
begin
1901
  if ComboBoxProximal.ItemIndex <> ProximalUnit
1902
  then // Changement d'unit?
1903
  begin
1904
    if ComboBoxProximal.ItemIndex mod 2 = 0
1905
    then // %
1906
    begin
1907
      ValidateEditMM.DecimalPlaces := 2;
1908
      ValidateEditMAT.DecimalPlaces := 2;
1909
      ValidateEditMG.DecimalPlaces := 2;
1910
      ValidateEditCB.DecimalPlaces := 2;
1911
      ValidateEditNDF.DecimalPlaces := 2;
1912
      ValidateEditADF.DecimalPlaces := 2;
1913
      ValidateEditADL.DecimalPlaces := 2;
1914
      ValidateEditAmidon.DecimalPlaces := 2;
1915
      ValidateEditSucres.DecimalPlaces := 2;
1916
    end
1917
    else // g/kg
1918
    begin
1919
      ValidateEditMM.MaxValue := 1000;
1920
      ValidateEditMAT.MaxValue := 1000;
1921
      ValidateEditMG.MaxValue := 1000;
1922
      ValidateEditCB.MaxValue := 1000;
1923
      ValidateEditNDF.MaxValue := 1000;
1924
      ValidateEditADF.MaxValue := 1000;
1925
      ValidateEditADL.MaxValue := 1000;
1926
      ValidateEditAmidon.MaxValue := 1000;
1927
      ValidateEditSucres.MaxValue := 1000;
1928
    end;
1929
    with DataModuleDeclaration do
1930
    begin
1931
      if CheckBoxMM.Checked
1932
      then // Conversion
1933
        ValidateEditMM.AsFloat := OutputProximal(InputProximal(ValidateEditMM.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2);
1934
      if CheckBoxMAT.Checked
1935
      then // Conversion
1936
        ValidateEditMAT.AsFloat := OutputProximal(InputProximal(ValidateEditMAT.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2);
1937
      if CheckBoxMG.Checked
1938
      then // Conversion
1939
        ValidateEditMG.AsFloat := OutputProximal(InputProximal(ValidateEditMG.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2);
1940
      if CheckBoxCB.Checked
1941
      then // Conversion
1942
        ValidateEditCB.AsFloat := OutputProximal(InputProximal(ValidateEditCB.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2);
1943
      if CheckBoxNDF.Checked
1944
      then // Conversion
1945
        ValidateEditNDF.AsFloat := OutputProximal(InputProximal(ValidateEditNDF.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2);
1946
      if CheckBoxADF.Checked
1947
      then // Conversion
1948
        ValidateEditADF.AsFloat := OutputProximal(InputProximal(ValidateEditADF.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2);
1949
      if CheckBoxADL.Checked
1950
      then // Conversion
1951
        ValidateEditADL.AsFloat := OutputProximal(InputProximal(ValidateEditADL.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2);
1952
      if CheckBoxAmidon.Checked
1953
      then // Conversion
1954
        ValidateEditAmidon.AsFloat := OutputProximal(InputProximal(ValidateEditAmidon.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2);
1955
      if CheckBoxSucres.Checked
1956
      then // Conversion
1957
        ValidateEditSucres.AsFloat := OutputProximal(InputProximal(ValidateEditSucres.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2), RapMS, ComboBoxProximal.ItemIndex div 2, ComboBoxProximal.ItemIndex mod 2);
1958
    end;
1959
    if ComboBoxProximal.ItemIndex mod 2 = 0
1960
    then // %
1961
    begin
1962
      ValidateEditMM.MaxValue := 100;
1963
      ValidateEditMAT.MaxValue := 100;
1964
      ValidateEditMG.MaxValue := 100;
1965
      ValidateEditCB.MaxValue := 100;
1966
      ValidateEditNDF.MaxValue := 100;
1967
      ValidateEditADF.MaxValue := 100;
1968
      ValidateEditADL.MaxValue := 100;
1969
      ValidateEditAmidon.MaxValue := 100;
1970
      ValidateEditSucres.MaxValue := 100;
1971
    end
1972
    else // g/kg
1973
    begin
1974
      ValidateEditMM.DecimalPlaces := 1;
1975
      ValidateEditMAT.DecimalPlaces := 1;
1976
      ValidateEditMG.DecimalPlaces := 1;
1977
      ValidateEditCB.DecimalPlaces := 1;
1978
      ValidateEditNDF.DecimalPlaces := 1;
1979
      ValidateEditADF.DecimalPlaces := 1;
1980
      ValidateEditADL.DecimalPlaces := 1;
1981
      ValidateEditAmidon.DecimalPlaces := 1;
1982
      ValidateEditSucres.DecimalPlaces := 1;
1983
    end;
1984
    ProximalUnit := ComboBoxProximal.ItemIndex;
1985
  end;
1986
end;
1987
1988
procedure TFormIngredientEditionOriginal.DisableAA;
1989
begin
1990
  CheckBoxLys.Checked := False;
1991
  CheckBoxThr.Checked := False;
1992
  CheckBoxMet.Checked := False;
1993
  CheckBoxCys.Checked := False;
1994
  CheckBoxMetCys.Checked := False;
1995
  CheckBoxTrp.Checked := False;
1996
  CheckBoxIle.Checked := False;
1997
  CheckBoxVal.Checked := False;
1998
  CheckBoxLeu.Checked := False;
1999
  CheckBoxPhe.Checked := False;
2000
  CheckBoxTyr.Checked := False;
2001
  CheckBoxPheTyr.Checked := False;
2002
  CheckBoxHis.Checked := False;
2003
  CheckBoxArg.Checked := False;
2004
  CheckBoxAla.Checked := False;
2005
  CheckBoxAsp.Checked := False;
2006
  CheckBoxGlu.Checked := False;
2007
  CheckBoxGly.Checked := False;
2008
  CheckBoxSer.Checked := False;
2009
  CheckBoxPro.Checked := False;
2010
  CheckBoxdLys.Checked := False;
2011
  CheckBoxdThr.Checked := False;
2012
  CheckBoxdMet.Checked := False;
2013
  CheckBoxdCys.Checked := False;
2014
  CheckBoxdMetCys.Checked := False;
2015
  CheckBoxdTrp.Checked := False;
2016
  CheckBoxdIle.Checked := False;
2017
  CheckBoxdVal.Checked := False;
2018
  CheckBoxdLeu.Checked := False;
2019
  CheckBoxdPhe.Checked := False;
2020
  CheckBoxdTyr.Checked := False;
2021
  CheckBoxdPheTyr.Checked := False;
2022
  CheckBoxdHis.Checked := False;
2023
  CheckBoxdArg.Checked := False;
2024
  CheckBoxdAla.Checked := False;
2025
  CheckBoxdAsp.Checked := False;
2026
  CheckBoxdGlu.Checked := False;
2027
  CheckBoxdGly.Checked := False;
2028
  CheckBoxdSer.Checked := False;
2029
  CheckBoxdPro.Checked := False;
2030
  // Verrouillage
2031
  CheckBoxLys.Enabled := False;
2032
  CheckBoxThr.Enabled := False;
2033
  CheckBoxMet.Enabled := False;
2034
  CheckBoxCys.Enabled := False;
2035
  CheckBoxMetCys.Enabled := False;
2036
  CheckBoxTrp.Enabled := False;
2037
  CheckBoxIle.Enabled := False;
2038
  CheckBoxVal.Enabled := False;
2039
  CheckBoxLeu.Enabled := False;
2040
  CheckBoxPhe.Enabled := False;
2041
  CheckBoxTyr.Enabled := False;
2042
  CheckBoxPheTyr.Enabled := False;
2043
  CheckBoxHis.Enabled := False;
2044
  CheckBoxArg.Enabled := False;
2045
  CheckBoxAla.Enabled := False;
2046
  CheckBoxAsp.Enabled := False;
2047
  CheckBoxGlu.Enabled := False;
2048
  CheckBoxGly.Enabled := False;
2049
  CheckBoxSer.Enabled := False;
2050
  CheckBoxPro.Enabled := False;
2051
  CheckBoxdLys.Enabled := False;
2052
  CheckBoxdThr.Enabled := False;
2053
  CheckBoxdMet.Enabled := False;
2054
  CheckBoxdCys.Enabled := False;
2055
  CheckBoxdMetCys.Enabled := False;
2056
  CheckBoxdTrp.Enabled := False;
2057
  CheckBoxdIle.Enabled := False;
2058
  CheckBoxdVal.Enabled := False;
2059
  CheckBoxdLeu.Enabled := False;
2060
  CheckBoxdPhe.Enabled := False;
2061
  CheckBoxdTyr.Enabled := False;
2062
  CheckBoxdPheTyr.Enabled := False;
2063
  CheckBoxdHis.Enabled := False;
2064
  CheckBoxdArg.Enabled := False;
2065
  CheckBoxdAla.Enabled := False;
2066
  CheckBoxdAsp.Enabled := False;
2067
  CheckBoxdGlu.Enabled := False;
2068
  CheckBoxdGly.Enabled := False;
2069
  CheckBoxdSer.Enabled := False;
2070
  CheckBoxdPro.Enabled := False;
2071
end;
2072
2073
procedure TFormIngredientEditionOriginal.DisabledP;
2074
begin
2075
  if CheckBoxdPphy.Checked
2076
  then
2077
    CheckBoxdPphy.Checked := False
2078
  else
2079
    CheckBoxdPphyClick(nil);
2080
  if CheckBoxdP.Checked
2081
  then
2082
    CheckBoxdP.Checked := False
2083
  else
2084
    CheckBoxdPClick(nil);
2085
  // Verrouillage
2086
  CheckBoxdPphy.Enabled := False;
2087
  CheckBoxdP.Enabled := False;
2088
end;
2089
2090
procedure TFormIngredientEditionOriginal.EnableAA;
2091
begin
2092
  CheckBoxLys.Enabled := True;
2093
  CheckBoxThr.Enabled := True;
2094
  CheckBoxMet.Enabled := True;
2095
  CheckBoxCys.Enabled := True;
2096
  CheckBoxMetCys.Enabled := True;
2097
  CheckBoxTrp.Enabled := True;
2098
  CheckBoxIle.Enabled := True;
2099
  CheckBoxVal.Enabled := True;
2100
  CheckBoxLeu.Enabled := True;
2101
  CheckBoxPhe.Enabled := True;
2102
  CheckBoxTyr.Enabled := True;
2103
  CheckBoxPheTyr.Enabled := True;
2104
  CheckBoxHis.Enabled := True;
2105
  CheckBoxArg.Enabled := True;
2106
  CheckBoxAla.Enabled := True;
2107
  CheckBoxAsp.Enabled := True;
2108
  CheckBoxGlu.Enabled := True;
2109
  CheckBoxGly.Enabled := True;
2110
  CheckBoxSer.Enabled := True;
2111
  CheckBoxPro.Enabled := True;
2112
  CheckBoxdLys.Enabled := True;
2113
  CheckBoxdThr.Enabled := True;
2114
  CheckBoxdMet.Enabled := True;
2115
  CheckBoxdCys.Enabled := True;
2116
  CheckBoxdMetCys.Enabled := True;
2117
  CheckBoxdTrp.Enabled := True;
2118
  CheckBoxdIle.Enabled := True;
2119
  CheckBoxdVal.Enabled := True;
2120
  CheckBoxdLeu.Enabled := True;
2121
  CheckBoxdPhe.Enabled := True;
2122
  CheckBoxdTyr.Enabled := True;
2123
  CheckBoxdPheTyr.Enabled := True;
2124
  CheckBoxdHis.Enabled := True;
2125
  CheckBoxdArg.Enabled := True;
2126
  CheckBoxdAla.Enabled := True;
2127
  CheckBoxdAsp.Enabled := True;
2128
  CheckBoxdGlu.Enabled := True;
2129
  CheckBoxdGly.Enabled := True;
2130
  CheckBoxdSer.Enabled := True;
2131
  CheckBoxdPro.Enabled := True;
2132
end;
2133
2134
procedure TFormIngredientEditionOriginal.EnabledP;
2135
begin
2136
  CheckBoxdPphy.Enabled := True;
2137
  CheckBoxdP.Enabled := True;
2138
end;
2139
2140
procedure TFormIngredientEditionOriginal.EditActivate(Edit: TJvValidateEdit);
2141
begin
2142
  Edit.DisplayFormat := dfFloat;
2143
  Edit.Enabled := True;
2144
  ActiveControl := Edit;
2145
  Edit.SelectAll;
2146
end;
2147
2148
procedure TFormIngredientEditionOriginal.EditEmpty(Edit: TJvValidateEdit);
2149
begin
2150
  Edit.DisplayFormat := dfNone;
2151
  Edit.Value := '';
2152
  Edit.Enabled := False;
2153
end;
2154
2155
procedure TFormIngredientEditionOriginal.EditShow(Edit: TJvValidateEdit; const Value: Double);
2156
begin
2157
  Edit.DisplayFormat := dfFloat;
2158
  Edit.AsFloat := Value;
2159
  Edit.Enabled := False;
2160
end;
2161
2162
procedure TFormIngredientEditionOriginal.FormCreate(Sender: TObject);
2163
var
2164
  i: Integer;
2165
begin
2166
  if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1
2167
  then
2168
    Font.Name := 'Arial Unicode MS';
2169
//  PanelButtons.Font.Size := PanelButtons.Font.Size + 2;
2170
  PanelButtons.Font.Style := [fsBold];
2171
  LabelName.Font.Style := [fsBold];
2172
  DBEditName.Font.Style := [fsBold];
2173
  LabelWarning.Font.Color := clRed;
2174
  TranslateComponent(Self);
2175
  with FormOptions do
2176
    LabelMS.Caption := Format('%s (%s)', [LabelMS.Caption, ComboBoxProximal.Items[Proximal]]);
2177
  for i := 0 to FormOptions.ComboBoxProximal.Items.Count - 1 do
2178
    ComboBoxProximal.Items.Add(Format('%s %s', [FormOptions.ComboBoxProximal.Items[i], _('DM')]));
2179
  ProximalUnit := -1;
2180
  ComboBoxProximal.ItemIndex := FormOptions.Proximal + 2 * FormOptions.Expression;
2181
  ComboBoxProximalChange(nil);
2182
  for i := 0 to FormOptions.ComboBoxEnergy.Items.Count - 1 do
2183
    ComboBoxEnergy.Items.Add(Format('%s %s', [FormOptions.ComboBoxEnergy.Items[i], _('DM')]));
2184
  EnergyUnit := -1;
2185
  ComboBoxEnergy.ItemIndex := FormOptions.Energy + 2 * FormOptions.Expression;
2186
  ComboBoxEnergyChange(nil);
2187
  LabelBonus.Caption := LabelBonus.Caption + ' (%)';
2188
  for i := 0 to FormOptions.ComboBoxAA.Items.Count - 1 do
2189
    ComboBoxAA.Items.Add(Format('%s %s', [FormOptions.ComboBoxAA.Items[i], _('DM')]));
2190
  AAUnit := -1;
2191
  ComboBoxAA.ItemIndex := FormOptions.AA + 2 * FormOptions.Expression;
2192
  ComboBoxAAChange(nil);
2193
  LabeldAA.Caption := LabeldAA.Caption + ' (%)';
2194
  for i := 0 to FormOptions.ComboBoxMinerals.Items.Count - 1 do
2195
    ComboBoxMinerals.Items.Add(Format('%s %s', [FormOptions.ComboBoxMinerals.Items[i], _('DM')]));
2196
  MineralsUnit := -1;
2197
  ComboBoxMinerals.ItemIndex := FormOptions.Minerals + 2 * FormOptions.Expression;
2198
  ComboBoxMineralsChange(nil);
2199
  LabeldP.Caption := LabeldP.Caption + ' (%)';
2200
  with DataModuleDeclaration do
2201
  begin
2202
    TableIngredients := DBUser.GetTable('SELECT * FROM Ingredients '
2203
      + Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
2204
    // Analyse proximale
2205
    RapMS := TableIngredients.FieldAsDouble(TableIngredients.FieldIndex['MS']);
2206
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MM'])
2207
    then
2208
      CheckBoxMMClick(nil)
2209
    else
2210
    begin
2211
      CheckBoxMM.Checked := True;
2212
      ValidateEditMM.AsFloat := ClientDataSetIngredientsMM.Value;
2213
    end;
2214
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MAT'])
2215
    then
2216
      CheckBoxMATClick(nil)
2217
    else
2218
    begin
2219
      CheckBoxMAT.Checked := True;
2220
      RapMAT := TableIngredients.FieldAsDouble(TableIngredients.FieldIndex['MAT']);
2221
      ValidateEditMAT.AsFloat := ClientDataSetIngredientsMAT.Value;
2222
    end;
2223
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MG'])
2224
    then
2225
      CheckBoxMGClick(nil)
2226
    else
2227
    begin
2228
      CheckBoxMG.Checked := True;
2229
      ValidateEditMG.AsFloat := ClientDataSetIngredientsMG.Value;
2230
    end;
2231
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['CB'])
2232
    then
2233
      CheckBoxCBClick(nil)
2234
    else
2235
    begin
2236
      CheckBoxCB.Checked := True;
2237
      ValidateEditCB.AsFloat := ClientDataSetIngredientsCB.Value;
2238
    end;
2239
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['NDF'])
2240
    then
2241
      CheckBoxNDFClick(nil)
2242
    else
2243
    begin
2244
      CheckBoxNDF.Checked := True;
2245
      ValidateEditNDF.AsFloat := ClientDataSetIngredientsNDF.Value;
2246
    end;
2247
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['ADF'])
2248
    then
2249
      CheckBoxADFClick(nil)
2250
    else
2251
    begin
2252
      CheckBoxADF.Checked := True;
2253
      ValidateEditADF.AsFloat := ClientDataSetIngredientsADF.Value;
2254
    end;
2255
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['ADL'])
2256
    then
2257
      CheckBoxADLClick(nil)
2258
    else
2259
    begin
2260
      CheckBoxADL.Checked := True;
2261
      ValidateEditADL.AsFloat := ClientDataSetIngredientsADL.Value;
2262
    end;
2263
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Amidon'])
2264
    then
2265
      CheckBoxAmidonClick(nil)
2266
    else
2267
    begin
2268
      CheckBoxAmidon.Checked := True;
2269
      ValidateEditAmidon.AsFloat := ClientDataSetIngredientsAmidon.Value;
2270
    end;
2271
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Sucres'])
2272
    then
2273
      CheckBoxSucresClick(nil)
2274
    else
2275
    begin
2276
      CheckBoxSucres.Checked := True;
2277
      ValidateEditSucres.AsFloat := ClientDataSetIngredientsSucres.Value;
2278
    end;
2279
    // Energie
2280
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['EB'])
2281
    then
2282
      CheckBoxEBClick(nil)
2283
    else
2284
    begin
2285
      CheckBoxEB.Checked := True;
2286
      ValidateEditEB.AsFloat := ClientDataSetIngredientsEB.Value;
2287
    end;
2288
    SpinEditBonus.Value := ClientDataSetIngredientsBonus.Value;
2289
    // Acides amin?s
2290
    if RapMAT = 0
2291
    then // D?sactiver la saisie des acides amin?s
2292
      DisableAA
2293
    else
2294
    begin
2295
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Lys'])
2296
      then
2297
        CheckBoxLysClick(nil)
2298
      else
2299
      begin
2300
        CheckBoxLys.Checked := True;
2301
        ValidateEditLys.AsFloat := ClientDataSetIngredientsLys.Value;
2302
      end;
2303
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Thr'])
2304
      then
2305
        CheckBoxThrClick(nil)
2306
      else
2307
      begin
2308
        CheckBoxThr.Checked := True;
2309
        ValidateEditThr.AsFloat := ClientDataSetIngredientsThr.Value;
2310
      end;
2311
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Met'])
2312
      then
2313
        CheckBoxMetClick(nil)
2314
      else
2315
      begin
2316
        CheckBoxMet.Checked := True;
2317
        ValidateEditMet.AsFloat := ClientDataSetIngredientsMet.Value;
2318
      end;
2319
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Cys'])
2320
      then
2321
        CheckBoxCysClick(nil)
2322
      else
2323
      begin
2324
        CheckBoxCys.Checked := True;
2325
        ValidateEditCys.AsFloat := ClientDataSetIngredientsCys.Value;
2326
      end;
2327
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MetCys'])
2328
      then
2329
        CheckBoxMetCysClick(nil)
2330
      else
2331
      begin
2332
        CheckBoxMetCys.Checked := True;
2333
        ValidateEditMetCys.AsFloat := ClientDataSetIngredientsMetCys.Value;
2334
      end;
2335
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Trp'])
2336
      then
2337
        CheckBoxTrpClick(nil)
2338
      else
2339
      begin
2340
        CheckBoxTrp.Checked := True;
2341
        ValidateEditTrp.AsFloat := ClientDataSetIngredientsTrp.Value;
2342
      end;
2343
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Ile'])
2344
      then
2345
        CheckBoxIleClick(nil)
2346
      else
2347
      begin
2348
        CheckBoxIle.Checked := True;
2349
        ValidateEditIle.AsFloat := ClientDataSetIngredientsIle.Value;
2350
      end;
2351
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Val'])
2352
      then
2353
        CheckBoxValClick(nil)
2354
      else
2355
      begin
2356
        CheckBoxVal.Checked := True;
2357
        ValidateEditVal.AsFloat := ClientDataSetIngredientsVal.Value;
2358
      end;
2359
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Leu'])
2360
      then
2361
        CheckBoxLeuClick(nil)
2362
      else
2363
      begin
2364
        CheckBoxLeu.Checked := True;
2365
        ValidateEditLeu.AsFloat := ClientDataSetIngredientsLeu.Value;
2366
      end;
2367
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Phe'])
2368
      then
2369
        CheckBoxPheClick(nil)
2370
      else
2371
      begin
2372
        CheckBoxPhe.Checked := True;
2373
        ValidateEditPhe.AsFloat := ClientDataSetIngredientsPhe.Value;
2374
      end;
2375
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Tyr'])
2376
      then
2377
        CheckBoxTyrClick(nil)
2378
      else
2379
      begin
2380
        CheckBoxTyr.Checked := True;
2381
        ValidateEditTyr.AsFloat := ClientDataSetIngredientsTyr.Value;
2382
      end;
2383
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['PheTyr'])
2384
      then
2385
        CheckBoxPheTyrClick(nil)
2386
      else
2387
      begin
2388
        CheckBoxPheTyr.Checked := True;
2389
        ValidateEditPheTyr.AsFloat := ClientDataSetIngredientsPheTyr.Value;
2390
      end;
2391
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['His'])
2392
      then
2393
        CheckBoxHisClick(nil)
2394
      else
2395
      begin
2396
        CheckBoxHis.Checked := True;
2397
        ValidateEditHis.AsFloat := ClientDataSetIngredientsHis.Value;
2398
      end;
2399
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Arg'])
2400
      then
2401
        CheckBoxArgClick(nil)
2402
      else
2403
      begin
2404
        CheckBoxArg.Checked := True;
2405
        ValidateEditArg.AsFloat := ClientDataSetIngredientsArg.Value;
2406
      end;
2407
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Ala'])
2408
      then
2409
        CheckBoxAlaClick(nil)
2410
      else
2411
      begin
2412
        CheckBoxAla.Checked := True;
2413
        ValidateEditAla.AsFloat := ClientDataSetIngredientsAla.Value;
2414
      end;
2415
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Asp'])
2416
      then
2417
        CheckBoxAspClick(nil)
2418
      else
2419
      begin
2420
        CheckBoxAsp.Checked := True;
2421
        ValidateEditAsp.AsFloat := ClientDataSetIngredientsAsp.Value;
2422
      end;
2423
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Glu'])
2424
      then
2425
        CheckBoxGluClick(nil)
2426
      else
2427
      begin
2428
        CheckBoxGlu.Checked := True;
2429
        ValidateEditGlu.AsFloat := ClientDataSetIngredientsGlu.Value;
2430
      end;
2431
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Gly'])
2432
      then
2433
        CheckBoxGlyClick(nil)
2434
      else
2435
      begin
2436
        CheckBoxGly.Checked := True;
2437
        ValidateEditGly.AsFloat := ClientDataSetIngredientsGly.Value;
2438
      end;
2439
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Ser'])
2440
      then
2441
        CheckBoxSerClick(nil)
2442
      else
2443
      begin
2444
        CheckBoxSer.Checked := True;
2445
        ValidateEditSer.AsFloat := ClientDataSetIngredientsSer.Value;
2446
      end;
2447
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Pro'])
2448
      then
2449
        CheckBoxProClick(nil)
2450
      else
2451
      begin
2452
        CheckBoxPro.Checked := True;
2453
        ValidateEditPro.AsFloat := ClientDataSetIngredientsPro.Value;
2454
      end;
2455
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dLys'])
2456
      then
2457
        CheckBoxdLysClick(nil)
2458
      else
2459
      begin
2460
        CheckBoxdLys.Checked := True;
2461
        ValidateEditdLys.AsFloat := ClientDataSetIngredientsdLys.Value;
2462
      end;
2463
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dThr'])
2464
      then
2465
        CheckBoxdThrClick(nil)
2466
      else
2467
      begin
2468
        CheckBoxdThr.Checked := True;
2469
        ValidateEditdThr.AsFloat := ClientDataSetIngredientsdThr.Value;
2470
      end;
2471
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dMet'])
2472
      then
2473
        CheckBoxdMetClick(nil)
2474
      else
2475
      begin
2476
        CheckBoxdMet.Checked := True;
2477
        ValidateEditdMet.AsFloat := ClientDataSetIngredientsdMet.Value;
2478
      end;
2479
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dCys'])
2480
      then
2481
        CheckBoxdCysClick(nil)
2482
      else
2483
      begin
2484
        CheckBoxdCys.Checked := True;
2485
        ValidateEditdCys.AsFloat := ClientDataSetIngredientsdCys.Value;
2486
      end;
2487
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dMetCys'])
2488
      then
2489
        CheckBoxdMetCysClick(nil)
2490
      else
2491
      begin
2492
        CheckBoxdMetCys.Checked := True;
2493
        ValidateEditdMetCys.AsFloat := ClientDataSetIngredientsdMetCys.Value;
2494
      end;
2495
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dTrp'])
2496
      then
2497
        CheckBoxdTrpClick(nil)
2498
      else
2499
      begin
2500
        CheckBoxdTrp.Checked := True;
2501
        ValidateEditdTrp.AsFloat := ClientDataSetIngredientsdTrp.Value;
2502
      end;
2503
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dIle'])
2504
      then
2505
        CheckBoxdIleClick(nil)
2506
      else
2507
      begin
2508
        CheckBoxdIle.Checked := True;
2509
        ValidateEditdIle.AsFloat := ClientDataSetIngredientsdIle.Value;
2510
      end;
2511
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dVal'])
2512
      then
2513
        CheckBoxdValClick(nil)
2514
      else
2515
      begin
2516
        CheckBoxdVal.Checked := True;
2517
        ValidateEditdVal.AsFloat := ClientDataSetIngredientsdVal.Value;
2518
      end;
2519
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dLeu'])
2520
      then
2521
        CheckBoxdLeuClick(nil)
2522
      else
2523
      begin
2524
        CheckBoxdLeu.Checked := True;
2525
        ValidateEditdLeu.AsFloat := ClientDataSetIngredientsdLeu.Value;
2526
      end;
2527
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dPhe'])
2528
      then
2529
        CheckBoxdPheClick(nil)
2530
      else
2531
      begin
2532
        CheckBoxdPhe.Checked := True;
2533
        ValidateEditdPhe.AsFloat := ClientDataSetIngredientsdPhe.Value;
2534
      end;
2535
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dTyr'])
2536
      then
2537
        CheckBoxdTyrClick(nil)
2538
      else
2539
      begin
2540
        CheckBoxdTyr.Checked := True;
2541
        ValidateEditdTyr.AsFloat := ClientDataSetIngredientsdTyr.Value;
2542
      end;
2543
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dPheTyr'])
2544
      then
2545
        CheckBoxdPheTyrClick(nil)
2546
      else
2547
      begin
2548
        CheckBoxdPheTyr.Checked := True;
2549
        ValidateEditdPheTyr.AsFloat := ClientDataSetIngredientsdPheTyr.Value;
2550
      end;
2551
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dHis'])
2552
      then
2553
        CheckBoxdHisClick(nil)
2554
      else
2555
      begin
2556
        CheckBoxdHis.Checked := True;
2557
        ValidateEditdHis.AsFloat := ClientDataSetIngredientsdHis.Value;
2558
      end;
2559
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dArg'])
2560
      then
2561
        CheckBoxdArgClick(nil)
2562
      else
2563
      begin
2564
        CheckBoxdArg.Checked := True;
2565
        ValidateEditdArg.AsFloat := ClientDataSetIngredientsdArg.Value;
2566
      end;
2567
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dAla'])
2568
      then
2569
        CheckBoxdAlaClick(nil)
2570
      else
2571
      begin
2572
        CheckBoxdAla.Checked := True;
2573
        ValidateEditdAla.AsFloat := ClientDataSetIngredientsdAla.Value;
2574
      end;
2575
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dAsp'])
2576
      then
2577
        CheckBoxdAspClick(nil)
2578
      else
2579
      begin
2580
        CheckBoxdAsp.Checked := True;
2581
        ValidateEditdAsp.AsFloat := ClientDataSetIngredientsdAsp.Value;
2582
      end;
2583
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dGlu'])
2584
      then
2585
        CheckBoxdGluClick(nil)
2586
      else
2587
      begin
2588
        CheckBoxdGlu.Checked := True;
2589
        ValidateEditdGlu.AsFloat := ClientDataSetIngredientsdGlu.Value;
2590
      end;
2591
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dGly'])
2592
      then
2593
        CheckBoxdGlyClick(nil)
2594
      else
2595
      begin
2596
        CheckBoxdGly.Checked := True;
2597
        ValidateEditdGly.AsFloat := ClientDataSetIngredientsdGly.Value;
2598
      end;
2599
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dSer'])
2600
      then
2601
        CheckBoxdSerClick(nil)
2602
      else
2603
      begin
2604
        CheckBoxdSer.Checked := True;
2605
        ValidateEditdSer.AsFloat := ClientDataSetIngredientsdSer.Value;
2606
      end;
2607
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dPro'])
2608
      then
2609
        CheckBoxdProClick(nil)
2610
      else
2611
      begin
2612
        CheckBoxdPro.Checked := True;
2613
        ValidateEditdPro.AsFloat := ClientDataSetIngredientsdPro.Value;
2614
      end;
2615
    end;
2616
    // Min?raux
2617
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Ca'])
2618
    then
2619
      CheckBoxCaClick(nil)
2620
    else
2621
    begin
2622
      CheckBoxCa.Checked := True;
2623
      ValidateEditCa.AsFloat := ClientDataSetIngredientsCa.Value;
2624
    end;
2625
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['P'])
2626
    then
2627
      CheckBoxPClick(nil)
2628
    else
2629
    begin
2630
      CheckBoxP.Checked := True;
2631
      ValidateEditP.AsFloat := ClientDataSetIngredientsP.Value;
2632
    end;
2633 3 avalancogn
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Na'])
2634
    then
2635
      CheckBoxNaClick(nil)
2636
    else
2637
    begin
2638
      CheckBoxNa.Checked := True;
2639
      ValidateEditNa.AsFloat := ClientDataSetIngredientsNa.Value;
2640
    end;
2641
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['K'])
2642
    then
2643
      CheckBoxKClick(nil)
2644
    else
2645
    begin
2646
      CheckBoxK.Checked := True;
2647
      ValidateEditK.AsFloat := ClientDataSetIngredientsK.Value;
2648
    end;
2649
    if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Cl'])
2650
    then
2651
      CheckBoxClClick(nil)
2652
    else
2653
    begin
2654
      CheckBoxCl.Checked := True;
2655
      ValidateEditCl.AsFloat := ClientDataSetIngredientsCl.Value;
2656
    end;
2657 1 avalancogn
    if ValidateEditP.AsFloat = 0
2658
    then // D?sactiver la saisie du phosphore digestible
2659
      DisabledP
2660
    else
2661
    begin
2662
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dP'])
2663
      then
2664
        CheckBoxdPClick(nil)
2665
      else
2666
      begin
2667
        CheckBoxdP.Checked := True;
2668
        ValidateEditdP.AsFloat := ClientDataSetIngredientsdP.Value;
2669
      end;
2670
      if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dPphy'])
2671
      then
2672
        CheckBoxdPphyClick(nil)
2673
      else
2674
      begin
2675
        CheckBoxdPphy.Checked := True;
2676
        ValidateEditdPphy.AsFloat := ClientDataSetIngredientsdPphy.Value;
2677
      end;
2678
    end;
2679
    TableIngredients.Free;
2680
  end;
2681
end;
2682
2683
procedure TFormIngredientEditionOriginal.ValidateEditMATChange(Sender: TObject);
2684
var
2685
  OldMAT, NewMAT: Double;
2686
begin
2687
  with DataModuleDeclaration do
2688
  begin
2689
    OldMAT := RapMAT;
2690
    NewMAT := InputProximal(ValidateEditMAT.AsFloat, RapMS, ProximalUnit div 2, ProximalUnit mod 2);
2691
    if NewMAT = 0
2692
    then // D?sactiver la saisie des acides amin?s
2693
      DisableAA
2694
    else // Activer la saisie des acides amin?s
2695
    begin
2696
      EnableAA;
2697
      // Recalculer les teneurs en acides amin?s
2698
      if NewMAT <> OldMAT
2699
      then
2700
      begin
2701
        if CheckBoxLys.Checked
2702
        then
2703
          ValidateEditLys.AsFloat := ValidateEditLys.AsFloat / OldMAT * NewMAT;
2704
        if CheckBoxThr.Checked
2705
        then
2706
          ValidateEditThr.AsFloat := ValidateEditThr.AsFloat / OldMAT * NewMAT;
2707
        if CheckBoxMet.Checked
2708
        then
2709
          ValidateEditMet.AsFloat := ValidateEditMet.AsFloat / OldMAT * NewMAT;
2710
        if CheckBoxCys.Checked
2711
        then
2712
          ValidateEditCys.AsFloat := ValidateEditCys.AsFloat / OldMAT * NewMAT;
2713
        if CheckBoxMetCys.Checked
2714
        then
2715
          ValidateEditMetCys.AsFloat := ValidateEditMetCys.AsFloat / OldMAT * NewMAT;
2716
        if CheckBoxTrp.Checked
2717
        then
2718
          ValidateEditTrp.AsFloat := ValidateEditTrp.AsFloat / OldMAT * NewMAT;
2719
        if CheckBoxIle.Checked
2720
        then
2721
          ValidateEditIle.AsFloat := ValidateEditIle.AsFloat / OldMAT * NewMAT;
2722
        if CheckBoxVal.Checked
2723
        then
2724
          ValidateEditVal.AsFloat := ValidateEditVal.AsFloat / OldMAT * NewMAT;
2725
        if CheckBoxLeu.Checked
2726
        then
2727
          ValidateEditLeu.AsFloat := ValidateEditLeu.AsFloat / OldMAT * NewMAT;
2728
        if CheckBoxPhe.Checked
2729
        then
2730
          ValidateEditPhe.AsFloat := ValidateEditPhe.AsFloat / OldMAT * NewMAT;
2731
        if CheckBoxTyr.Checked
2732
        then
2733
          ValidateEditTyr.AsFloat := ValidateEditTyr.AsFloat / OldMAT * NewMAT;
2734
        if CheckBoxPheTyr.Checked
2735
        then
2736
          ValidateEditPheTyr.AsFloat := ValidateEditPheTyr.AsFloat / OldMAT * NewMAT;
2737
        if CheckBoxHis.Checked
2738
        then
2739
          ValidateEditHis.AsFloat := ValidateEditHis.AsFloat / OldMAT * NewMAT;
2740
        if CheckBoxArg.Checked
2741
        then
2742
          ValidateEditArg.AsFloat := ValidateEditArg.AsFloat / OldMAT * NewMAT;
2743
        if CheckBoxAla.Checked
2744
        then
2745
          ValidateEditAla.AsFloat := ValidateEditAla.AsFloat / OldMAT * NewMAT;
2746
        if CheckBoxAsp.Checked
2747
        then
2748
          ValidateEditAsp.AsFloat := ValidateEditAsp.AsFloat / OldMAT * NewMAT;
2749
        if CheckBoxGlu.Checked
2750
        then
2751
          ValidateEditGlu.AsFloat := ValidateEditGlu.AsFloat / OldMAT * NewMAT;
2752
        if CheckBoxGly.Checked
2753
        then
2754
          ValidateEditGly.AsFloat := ValidateEditGly.AsFloat / OldMAT * NewMAT;
2755
        if CheckBoxSer.Checked
2756
        then
2757
          ValidateEditSer.AsFloat := ValidateEditSer.AsFloat / OldMAT * NewMAT;
2758
        if CheckBoxPro.Checked
2759
        then
2760
          ValidateEditPro.AsFloat := ValidateEditPro.AsFloat / OldMAT * NewMAT;
2761
        RapMAT := NewMAT;
2762
      end;
2763
    end;
2764
  end;
2765
end;
2766
2767
procedure TFormIngredientEditionOriginal.ValidateEditPChange(Sender: TObject);
2768
begin
2769
  if ValidateEditP.AsFloat = 0
2770
  then // D?sactiver la saisie du phosphore digestible
2771
    DisabledP
2772
  else // Activer la saisie du phosphore digestible
2773
  begin
2774
    EnabledP;
2775
    if CheckBoxdP.Checked
2776
    then // R?initialiser avec la valeur du mod?le
2777
      CheckBoxdP.Checked := False
2778
    else // R?afficher la valeur du mod?le
2779
      CheckBoxdPClick(nil);
2780
    if CheckBoxdPphy.Checked
2781
    then // R?initialiser avec la valeur du mod?le
2782
      CheckBoxdPphy.Checked := False
2783
    else // R?afficher la valeur du mod?le
2784
      CheckBoxdPphyClick(nil);
2785
  end;
2786
end;
2787
2788
procedure TFormIngredientEditionOriginal.NumEditKeyDown(Sender: TObject;
2789
  var Key: Word; Shift: TShiftState);
2790
begin
2791
  // D?tection de l'appui sur le s?parateur d?cimal du pav? num?rique
2792
  VK_Separator := (Key = VK_DECIMAL);
2793
end;
2794
2795
procedure TFormIngredientEditionOriginal.NumEditKeyPress(Sender: TObject;
2796
  var Key: Char);
2797
begin
2798
  if VK_Separator then
2799
    // Renvoyer le s?parateur d?cimal des options r?gionales et linguistiques
2800
    Key := DecimalSeparator;
2801
end;
2802
2803
end.