Statistiques
| Révision:

root / UFMatiere.pas @ 3

Historique | Voir | Annoter | Télécharger (135,416 ko)

1 3 avalancogn
unit UFMatiere ;
2
3
interface
4
5
uses
6
  Windows, Forms, Classes, Controls, StdCtrls, Buttons, ComCtrls, ExtCtrls,
7
  PBNumEdit, JvEnterTab, JvExControls;
8
9
type
10
  TFMatiere = class(TForm)
11
    GBMatiere: TGroupBox;
12
    CBMatiere: TComboBox;
13
    SBAdd: TSpeedButton;
14
    SBDel: TSpeedButton;
15
    SBRename: TSpeedButton;
16
    SBComment: TSpeedButton;
17
    PC: TPageControl;
18
    TSElem: TTabSheet;
19
    TSAA: TTabSheet;
20
    TSAG: TTabSheet;
21
    TSMineraux: TTabSheet;
22
    GBTFecale: TGroupBox;
23
    GBEnergie: TGroupBox;
24
    LMS: TLabel;
25
    LMM: TLabel;
26
    LMO: TLabel;
27
    LLip: TLabel;
28
    LMAT: TLabel;
29
    LAmidon: TLabel;
30
    LCB: TLabel;
31
    LEB: TLabel;
32
    LSucres: TLabel;
33
    LNDF: TLabel;
34
    LADF: TLabel;
35
    LADL: TLabel;
36
    LED: TLabel;
37
    LEM: TLabel;
38
    LEN: TLabel;
39
    LEDsEB: TLabel;
40
    LENsEM: TLabel;
41
    LEVal_C: TLabel;
42
    LEVal_T: TLabel;
43
    CBCorrCUD: TCheckBox;
44
    RBED: TRadioButton;
45
    RBEM: TRadioButton;
46
    RBEN: TRadioButton;
47
    TSFibres: TTabSheet;
48
    LParois: TLabel;
49
    PBTMS: TPBNumEdit;
50
    PBTMM: TPBNumEdit;
51
    PBTMO: TPBNumEdit;
52
    PBTLip: TPBNumEdit;
53
    PBTMAT: TPBNumEdit;
54
    PBTAmidon: TPBNumEdit;
55
    PBTSucres: TPBNumEdit;
56
    GBdFecale: TGroupBox;
57
    LdFecale_C: TLabel;
58
    LdFecale_T: TLabel;
59
    PBdMO_C: TPBNumEdit;
60
    PBdLip_C: TPBNumEdit;
61
    PBdMAT_C: TPBNumEdit;
62
    PBdSucres_C: TPBNumEdit;
63
    PBdLip_T: TPBNumEdit;
64
    PBdMAT_T: TPBNumEdit;
65
    PBdAmidon_T: TPBNumEdit;
66
    PBdSucres_T: TPBNumEdit;
67
    GBEVal: TGroupBox;
68
    BGERap: TGroupBox;
69
    GBFecale: TGroupBox;
70
    LERap_C: TLabel;
71
    LERap_T: TLabel;
72
    LCorrCUD: TLabel;
73
    CBAAsMAT: TCheckBox;
74
    PBEB_C: TPBNumEdit;
75
    PBED_C: TPBNumEdit;
76
    PBEM_C: TPBNumEdit;
77
    PBEN_C: TPBNumEdit;
78
    PBEDsEB_C: TPBNumEdit;
79
    PBENsEM_C: TPBNumEdit;
80
    PBEB_T: TPBNumEdit;
81
    PBED_T: TPBNumEdit;
82
    PBEM_T: TPBNumEdit;
83
    PBEN_T: TPBNumEdit;
84
    PBEDsEB_T: TPBNumEdit;
85
    PBENsEM_T: TPBNumEdit;
86
    PBCB: TPBNumEdit;
87
    PBNDF: TPBNumEdit;
88
    PBADF: TPBNumEdit;
89
    PBADL: TPBNumEdit;
90
    PBParois: TPBNumEdit;
91
    LLys: TLabel;
92
    LMet: TLabel;
93
    LCys: TLabel;
94
    LTrp: TLabel;
95
    LThr: TLabel;
96
    LPhe: TLabel;
97
    LTyr: TLabel;
98
    LLeu: TLabel;
99
    LIle: TLabel;
100
    LVal: TLabel;
101
    LHis: TLabel;
102
    LArg: TLabel;
103
    PBTMAT2: TPBNumEdit;
104
    PBTLys: TPBNumEdit;
105
    PBTMet: TPBNumEdit;
106
    PBTCys: TPBNumEdit;
107
    PBTTrp: TPBNumEdit;
108
    PBTThr: TPBNumEdit;
109
    PBTPhe: TPBNumEdit;
110
    PBTTyr: TPBNumEdit;
111
    PBTLeu: TPBNumEdit;
112
    PBTIle: TPBNumEdit;
113
    PBTArg: TPBNumEdit;
114
    PBTHis: TPBNumEdit;
115
    PBTVal: TPBNumEdit;
116
    LCa: TLabel;
117
    LP: TLabel;
118
    LZn: TLabel;
119
    LCu: TLabel;
120
    LMg: TLabel;
121
    LCl: TLabel;
122
    LK: TLabel;
123
    LNa: TLabel;
124
    LFe: TLabel;
125
    LMn: TLabel;
126
    PBC6C8C10_0: TPBNumEdit;
127
    PBC12_0: TPBNumEdit;
128
    PBC14_0: TPBNumEdit;
129
    PBC16_0: TPBNumEdit;
130
    PBC18_0: TPBNumEdit;
131
    PBC20_0: TPBNumEdit;
132
    PBC22_0: TPBNumEdit;
133
    PBC24_0: TPBNumEdit;
134
    PBC22_1: TPBNumEdit;
135
    PBC22_6: TPBNumEdit;
136
    PBAG: TPBNumEdit;
137
    PBCa: TPBNumEdit;
138
    PBP: TPBNumEdit;
139
    PBCu: TPBNumEdit;
140
    PBZn: TPBNumEdit;
141
    PBMg: TPBNumEdit;
142
    PBCl: TPBNumEdit;
143
    PBK: TPBNumEdit;
144
    PBNa: TPBNumEdit;
145
    PBMn: TPBNumEdit;
146
    PBFe: TPBNumEdit;
147
    PBPhytase: TPBNumEdit;
148
    PBPdigG: TPBNumEdit;
149
    LPhytase: TLabel;
150
    LC12: TLabel;
151
    LC16: TLabel;
152
    LC14: TLabel;
153
    LC18: TLabel;
154
    LC20: TLabel;
155
    LC22: TLabel;
156
    LC24: TLabel;
157
    PBC16_1: TPBNumEdit;
158
    PBC18_1: TPBNumEdit;
159
    PBC18_2: TPBNumEdit;
160
    PBC18_3: TPBNumEdit;
161
    PBC18_4: TPBNumEdit;
162
    PBC20_1: TPBNumEdit;
163
    PBC20_4: TPBNumEdit;
164
    PBC20_5: TPBNumEdit;
165
    PBC22_5: TPBNumEdit;
166
    LC6C8C10: TLabel;
167
    LAG: TLabel;
168
    LActPhyt: TLabel;
169
    PBActPhytE: TPBNumEdit;
170
    LCasP: TLabel;
171
    PBCasP: TPBNumEdit;
172
    PBdMATStd: TPBNumEdit;
173
    PBdLysStd: TPBNumEdit;
174
    PBdMetStd: TPBNumEdit;
175
    PBdCysStd: TPBNumEdit;
176
    PBdTrpStd: TPBNumEdit;
177
    PBdThrStd: TPBNumEdit;
178
    PBdPheStd: TPBNumEdit;
179
    PBdTyrStd: TPBNumEdit;
180
    PBdLeuStd: TPBNumEdit;
181
    PBdIleStd: TPBNumEdit;
182
    PBdValStd: TPBNumEdit;
183
    PBdHisStd: TPBNumEdit;
184
    PBdArgStd: TPBNumEdit;
185
    LMAT2: TLabel;
186
    GBTAG: TGroupBox;
187
    PBProtLysStd: TPBNumEdit;
188
    PBProtMetStd: TPBNumEdit;
189
    PBProtCysStd: TPBNumEdit;
190
    PBProtTrpStd: TPBNumEdit;
191
    PBProtThrStd: TPBNumEdit;
192
    PBProtPheStd: TPBNumEdit;
193
    PBProtTyrStd: TPBNumEdit;
194
    PBProtLeuStd: TPBNumEdit;
195
    PBProtIleStd: TPBNumEdit;
196
    PBProtValStd: TPBNumEdit;
197
    PBProtHisStd: TPBNumEdit;
198
    PBProtArgStd: TPBNumEdit;
199
    GBFibres: TGroupBox;
200
    PBPtot: TPBNumEdit;
201
    LPdig: TLabel;
202
    LPtot: TLabel;
203
    GBP: TGroupBox;
204
    GBMacro: TGroupBox;
205
    GBOligo: TGroupBox;
206
    GBTOligo: TGroupBox;
207
    GBTMacro: TGroupBox;
208
    LS: TLabel;
209
    PBS: TPBNumEdit;
210
    LBilanCA: TLabel;
211
    PBBilanCA: TPBNumEdit;
212
    LBilanE: TLabel;
213
    PBBilanE: TPBNumEdit;
214
    GBAGtot: TGroupBox;
215
    GBAG0: TGroupBox;
216
    GBAG1: TGroupBox;
217
    GBAG2: TGroupBox;
218
    GBAG3: TGroupBox;
219
    GBAG4: TGroupBox;
220
    GBAG5: TGroupBox;
221
    GBAG6: TGroupBox;
222
    LCtot: TLabel;
223
    PBCtot_0: TPBNumEdit;
224
    PBCtot_1: TPBNumEdit;
225
    PBCtot_2: TPBNumEdit;
226
    PBCtot_3: TPBNumEdit;
227
    PBCtot_4: TPBNumEdit;
228
    PBCtot_5: TPBNumEdit;
229
    PBCtot_6: TPBNumEdit;
230
    PBC24_tot: TPBNumEdit;
231
    PBC22_tot: TPBNumEdit;
232
    PBC20_tot: TPBNumEdit;
233
    PBC18_tot: TPBNumEdit;
234
    PBC16_tot: TPBNumEdit;
235
    PBC14_tot: TPBNumEdit;
236
    PBC12_tot: TPBNumEdit;
237
    PBC6C8C10_tot: TPBNumEdit;
238
    PBCtot_tot: TPBNumEdit;
239
    LLip2: TLabel;
240
    PBLip2: TPBNumEdit;
241
    LSatur: TLabel;
242
    PBSatur: TPBNumEdit;
243
    LMono: TLabel;
244
    PBMono: TPBNumEdit;
245
    LPoly: TLabel;
246
    PBPoly: TPBNumEdit;
247
    LO6sO3: TLabel;
248
    PBO6sO3: TPBNumEdit;
249
    GBAA: TGroupBox;
250
    GBTAA: TGroupBox;
251
    GBdAA: TGroupBox;
252
    GBProt: TGroupBox;
253
    PBdMATApp: TPBNumEdit;
254
    PBdLysApp: TPBNumEdit;
255
    PBdMetApp: TPBNumEdit;
256
    PBdCysApp: TPBNumEdit;
257
    PBdTrpApp: TPBNumEdit;
258
    PBdThrApp: TPBNumEdit;
259
    PBdPheApp: TPBNumEdit;
260
    PBdTyrApp: TPBNumEdit;
261
    PBdLeuApp: TPBNumEdit;
262
    PBdIleApp: TPBNumEdit;
263
    PBdValApp: TPBNumEdit;
264
    PBdHisApp: TPBNumEdit;
265
    PBdArgApp: TPBNumEdit;
266
    PBProtLysTot: TPBNumEdit;
267
    PBProtMetTot: TPBNumEdit;
268
    PBProtCysTot: TPBNumEdit;
269
    PBProtTrpTot: TPBNumEdit;
270
    PBProtThrTot: TPBNumEdit;
271
    PBProtPheTot: TPBNumEdit;
272
    PBProtTyrTot: TPBNumEdit;
273
    PBProtLeuTot: TPBNumEdit;
274
    PBProtIleTot: TPBNumEdit;
275
    PBProtValTot: TPBNumEdit;
276
    PBProtHisTot: TPBNumEdit;
277
    PBProtArgTot: TPBNumEdit;
278
    LdAAStd: TLabel;
279
    LdAAApp: TLabel;
280
    LProtStd: TLabel;
281
    LProtTot: TLabel;
282
    GBCompAA: TGroupBox;
283
    GBMetCys: TGroupBox;
284
    GBTrp: TGroupBox;
285
    GBPheTyr: TGroupBox;
286
    GBEAA: TGroupBox;
287
    LTMetCys: TLabel;
288
    PBTMetCys: TPBNumEdit;
289
    LdMetCys: TLabel;
290
    PBdMetCysStd: TPBNumEdit;
291
    LProtMetCys: TLabel;
292
    PBProtMetCysStd: TPBNumEdit;
293
    LTPheTyr: TLabel;
294
    PBTPheTyr: TPBNumEdit;
295
    LdPheTyr: TLabel;
296
    PBdPheTyrStd: TPBNumEdit;
297
    LProtPheTyr: TLabel;
298
    PBProtPheTyrStd: TPBNumEdit;
299
    LTrpTot: TLabel;
300
    PBTrpTot: TPBNumEdit;
301
    LTrpStd: TLabel;
302
    PBTrpStd: TPBNumEdit;
303
    LEAATot: TLabel;
304
    PBEAATot: TPBNumEdit;
305
    LEAAStd: TLabel;
306
    PBEAAStd: TPBNumEdit;
307
    PBSe: TPBNumEdit;
308
    PBI: TPBNumEdit;
309
    PBMb: TPBNumEdit;
310
    PBCo: TPBNumEdit;
311
    LCo: TLabel;
312
    LSe: TLabel;
313
    LI: TLabel;
314
    LMb: TLabel;
315
    CBAAsLys: TCheckBox;
316
    PBdMO_T: TPBNumEdit;
317
    PBdAmidon_C: TPBNumEdit;
318
    LBRap: TListBox;
319
    LBDig: TListBox;
320
    LBdCompo: TListBox;
321
    LBdAA: TListBox;
322
    LBTCompo: TListBox;
323
    LBTAA: TListBox;
324
    LBTAG: TListBox;
325
    LBTMacro: TListBox;
326
    LBTOligo: TListBox;
327
    LBTFibres: TListBox;
328
    PBPdigF: TPBNumEdit;
329
    PBActPhytM: TPBNumEdit;
330
    LPdigF: TLabel;
331
    LActPhytM: TLabel;
332
    LActPhytE: TLabel;
333
    LPdigG: TLabel;
334
    SBSave: TSpeedButton;
335
    SBPrint: TSpeedButton;
336
    PBProtMetCysTot: TPBNumEdit;
337
    PBdMetCysApp: TPBNumEdit;
338
    PBProtPheTyrTot: TPBNumEdit;
339
    PBdPheTyrApp: TPBNumEdit;
340
    LResidu: TLabel;
341
    PBTResidu: TPBNumEdit;
342
    PBdResidu_C: TPBNumEdit;
343
    PBdResidu_T: TPBNumEdit;
344
    JvEnterAsTab: TJvEnterAsTab;
345
    procedure FormShow(Sender: TObject);
346
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
347
    procedure FormDeactivate(Sender: TObject);
348
    procedure CBMatiereChange(Sender: TObject);
349
    procedure SBAddClick(Sender: TObject);
350
    procedure SBDelClick(Sender: TObject);
351
    procedure SBRenameClick(Sender: TObject);
352
    procedure SBCommentClick(Sender: TObject);
353
    procedure CBCorrCUDClick(Sender: TObject);
354
    procedure RBEDClick(Sender: TObject);
355
    procedure RBEMClick(Sender: TObject);
356
    procedure RBENClick(Sender: TObject);
357
    procedure LEDClick(Sender: TObject);
358
    procedure LEMClick(Sender: TObject);
359
    procedure LENClick(Sender: TObject);
360
    procedure LCorrCUDClick(Sender: TObject);
361
    procedure CBAAsLysClick(Sender: TObject);
362
    procedure PBTMSChange(Sender: TObject);
363
    procedure PBTMMChange(Sender: TObject);
364
    procedure PBTLipChange(Sender: TObject);
365
    procedure PBTMATChange(Sender: TObject);
366
    procedure PBTAmidonChange(Sender: TObject);
367
    procedure PBTSucresChange(Sender: TObject);
368
    procedure PBdMO_CChange(Sender: TObject);
369
    procedure PBdLip_CChange(Sender: TObject);
370
    procedure PBdMAT_CChange(Sender: TObject);
371
    procedure PBdMO_TChange(Sender: TObject);
372
    procedure PBdLip_TChange(Sender: TObject);
373
    procedure PBdMAT_TChange(Sender: TObject);
374
    procedure PBED_CChange(Sender: TObject);
375
    procedure PBEM_CChange(Sender: TObject);
376
    procedure PBEN_CChange(Sender: TObject);
377
    procedure PBED_TChange(Sender: TObject);
378
    procedure PBEM_TChange(Sender: TObject);
379
    procedure PBEN_TChange(Sender: TObject);
380
    procedure PBCBChange(Sender: TObject);
381
    procedure PBTLysChange(Sender: TObject);
382
    procedure PBTMetChange(Sender: TObject);
383
    procedure PBTCysChange(Sender: TObject);
384
    procedure PBTTrpChange(Sender: TObject);
385
    procedure PBTThrChange(Sender: TObject);
386
    procedure PBTPheChange(Sender: TObject);
387
    procedure PBTTyrChange(Sender: TObject);
388
    procedure PBTLeuChange(Sender: TObject);
389
    procedure PBTIleChange(Sender: TObject);
390
    procedure PBTValChange(Sender: TObject);
391
    procedure PBTHisChange(Sender: TObject);
392
    procedure PBTArgChange(Sender: TObject);
393
    procedure PBdMATStdChange(Sender: TObject);
394
    procedure PBdLysStdChange(Sender: TObject);
395
    procedure PBdMetStdChange(Sender: TObject);
396
    procedure PBdCysStdChange(Sender: TObject);
397
    procedure PBdTrpStdChange(Sender: TObject);
398
    procedure PBdThrStdChange(Sender: TObject);
399
    procedure PBdPheStdChange(Sender: TObject);
400
    procedure PBdTyrStdChange(Sender: TObject);
401
    procedure PBdLeuStdChange(Sender: TObject);
402
    procedure PBdIleStdChange(Sender: TObject);
403
    procedure PBdValStdChange(Sender: TObject);
404
    procedure PBdHisStdChange(Sender: TObject);
405
    procedure PBdArgStdChange(Sender: TObject);
406
    procedure PBC6C8C10_0Change(Sender: TObject);
407
    procedure PBC12_0Change(Sender: TObject);
408
    procedure PBC14_0Change(Sender: TObject);
409
    procedure PBC16_0Change(Sender: TObject);
410
    procedure PBC16_1Change(Sender: TObject);
411
    procedure PBC18_0Change(Sender: TObject);
412
    procedure PBC18_1Change(Sender: TObject);
413
    procedure PBC18_2Change(Sender: TObject);
414
    procedure PBC18_3Change(Sender: TObject);
415
    procedure PBC18_4Change(Sender: TObject);
416
    procedure PBC20_0Change(Sender: TObject);
417
    procedure PBC20_1Change(Sender: TObject);
418
    procedure PBC20_4Change(Sender: TObject);
419
    procedure PBC20_5Change(Sender: TObject);
420
    procedure PBC22_0Change(Sender: TObject);
421
    procedure PBC22_1Change(Sender: TObject);
422
    procedure PBC22_5Change(Sender: TObject);
423
    procedure PBC22_6Change(Sender: TObject);
424
    procedure PBC24_0Change(Sender: TObject);
425
    procedure PBCaChange(Sender: TObject);
426
    procedure PBPChange(Sender: TObject);
427
    procedure PBNaChange(Sender: TObject);
428
    procedure PBKChange(Sender: TObject);
429
    procedure PBMgChange(Sender: TObject);
430
    procedure PBClChange(Sender: TObject);
431
    procedure PBSChange(Sender: TObject);
432
    procedure PBCuChange(Sender: TObject);
433
    procedure PBZnChange(Sender: TObject);
434
    procedure PBMnChange(Sender: TObject);
435
    procedure PBFeChange(Sender: TObject);
436
    procedure PBSeChange(Sender: TObject);
437
    procedure PBCoChange(Sender: TObject);
438
    procedure PBMbChange(Sender: TObject);
439
    procedure PBIChange(Sender: TObject);
440
    procedure PBPdigGChange(Sender: TObject);
441
    procedure PBPhytaseChange(Sender: TObject);
442
    procedure PBActPhytEChange(Sender: TObject);
443
    procedure PBNDFChange(Sender: TObject);
444
    procedure PBADFChange(Sender: TObject);
445
    procedure PBADLChange(Sender: TObject);
446
    procedure PBParoisChange(Sender: TObject);
447
    procedure PBAGChange(Sender: TObject);
448
    procedure PBTMSExit(Sender: TObject);
449
    procedure PBTMMExit(Sender: TObject);
450
    procedure PBTMATExit(Sender: TObject);
451
    procedure PBTLysExit(Sender: TObject);
452
    procedure PBED_CExit(Sender: TObject);
453
    procedure PBEM_CExit(Sender: TObject);
454
    procedure PBEN_CExit(Sender: TObject);
455
    procedure PBED_TExit(Sender: TObject);
456
    procedure PBEM_TExit(Sender: TObject);
457
    procedure PBEN_TExit(Sender: TObject);
458
    procedure FormActivate(Sender: TObject);
459
    procedure PBPdigFChange(Sender: TObject);
460
    procedure PBActPhytMChange(Sender: TObject);
461
    procedure SBSaveClick(Sender: TObject);
462
    procedure SBPrintClick(Sender: TObject);
463
    procedure FormCreate(Sender: TObject);
464
  private
465
    { D?clarations priv?es }
466
    Update, Modified : boolean ;
467
    RapMS : double ;
468
    procedure Save ;
469
    procedure CalculTMO ;
470
    procedure CalculResidu ;
471
    procedure CalculEnergie ;
472
    procedure CalculDigEDCrois ;
473
    procedure CalculDigEMCrois ;
474
    procedure CalculDigENCrois ;
475
    procedure CalculDigEDTruie ;
476
    procedure CalculDigEMTruie ;
477
    procedure CalculDigENTruie ;
478
    procedure CalculAA ;
479
    procedure CalculAG ;
480
    procedure CalculMineraux ;
481
    procedure AffichTFecale ;
482
    procedure AffichdFecale ;
483
    procedure AffichResidu ;
484
    procedure AffichEnergie ;
485
    procedure AffichTAA ;
486
    procedure AffichdAA ;
487
    procedure AffichTAG ;
488
    procedure AffichTMineraux ;
489
    procedure AffichTFibres ;
490
  public
491
    { D?clarations publiques }
492
    IdxMatiere : integer ;
493
    procedure AjustCaption ;
494
    procedure AjustDecimals ;
495
    procedure AjustEnabled ;
496
  end;
497
498
var
499
  FMatiere: TFMatiere;
500
501
implementation
502
503
uses
504
  Dialogs, SysUtils, gnugettext, UVariables, UStrings, UInit, UUtil, UFindRec,
505
  UFWarning, UFCommentMat, UFRapportMat;
506
507
{$R *.dfm}
508
509
{ TFMatiere }
510
511
procedure TFMatiere.FormCreate(Sender: TObject);
512
begin
513
  if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1
514
  then
515
    Font.Name := 'Arial Unicode MS';
516
  TranslateComponent(Self);
517
  Constraints.MinWidth := 744 + (Width - ClientWidth);
518
  Width := Constraints.MinWidth ;
519
  Constraints.MinHeight := 463 + (Height - ClientHeight);
520
  Height := Constraints.MinHeight;
521
end;
522
523
procedure TFMatiere.FormShow (Sender : TObject) ;
524
begin
525
  AjustCaption ;
526
  AjustDecimals ;
527
  Modified := FALSE ;
528
  StringsMatiere (CBMatiere.Items, 0, TRUE, TRUE) ;
529
  SBAdd.Enabled := IsComplete or (ListMatiere.Count < NumMatInraAfz + 10) ;
530
  SBSave.Enabled := IsComplete or IsEducation ;
531
  IdxMatiere := -1 ;
532
//  CBMatiereChange (nil) ;
533
end ;
534
535
procedure TFMatiere.FormClose (Sender : TObject ; var Action : TCloseAction) ;
536
begin
537
  if Modified then Save ;
538
  Action := caFree ;
539
  NumWinMatiere := -1 ;
540
end ;
541
542
procedure TFMatiere.FormActivate (Sender : TObject) ;
543
var
544
  i : integer ;
545
begin
546
//  if IdxMatiere <> -1
547
//  then
548
//    PMatiere := ListMatiere[IdxMatiere] ;
549
  CBMatiereChange (nil) ;
550
551
  for i := 0 to PC.PageCount - 1 do
552
    PC.Pages[i].Enabled := IsComplete or IsEducation or IsEvaluation ;
553
end ;
554
555
procedure TFMatiere.FormDeactivate (Sender : TObject) ;
556
begin
557
  if Modified then Save ;
558
end ;
559
560
procedure TFMatiere.Save ;
561
var
562
  s : string ;
563
begin
564
  Modified := FALSE ;
565
  if IsComplete or IsEducation
566
  then
567
    if MessageDlg (Caption + sLineBreak + MsgSave, mtConfirmation, [mbYes, mbNo], 0) = mrYes
568
    then
569
    begin
570
      SaveMatiere ;
571
      if not MatiereValid (PMatiere)
572
      then
573
        MessageDlg(Format (MsgInvalidData, [Caption, PMatiere.Nom]), mtWarning, [mbOK], 0) ;
574
    end
575
    else
576
    begin
577
      LoadMatiere ;
578
      s := CBMatiere.Text ;
579
      StringsMatiere (CBMatiere.Items, 0, TRUE, TRUE) ;
580
      if FindIdxMatiere (s) = -1
581
      then
582
      begin
583
        IdxMatiere := -1 ;
584
        CBMatiereChange (nil) ;
585
      end
586
      else
587
        CBMatiere.ItemIndex := CBMatiere.Items.IndexOf (s) ;
588
    end ;
589
end ;
590
591
// Adaptation des libell?s par rapport ? la configuration
592
procedure TFMatiere.AjustCaption;
593
begin
594
  Hint := Format(_('Chemical composition (%s)'), [LBRap.Items[ConfRap]]);
595
  GBTFecale.Caption := Format('%s (%s)', [_('Content'), LBTCompo.Items[ConfTCompo]]);
596
  GBdFecale.Caption := Format('%s (%s)', [LBDig.Items[ConfDig], LBdCompo.Items[ConfdCompo]]);
597
  GBTAA.Caption := Format('%s (%s)', [_('Content'), LBTAA.Items[ConfTAA]]);
598
  GBdAA.Caption := Format('%s (%s)', [LBDig.Items[ConfDig], LBdAA.Items[ConfdAA]]);
599
  GBTAG.Caption := Format('%s (%s)', [_('Content'), LBTAG.Items[ConfTAG]]);
600
  GBTMacro.Caption := Format('%s (%s)', [_('Content'), LBTMacro.Items[ConfTMacro]]);
601
  GBTOligo.Caption := Format('%s (%s)', [_('Content'), LBTOligo.Items[ConfTOligo]]);
602
  LPtot.Caption := Format('%s (%s)', [_('Total phosphorus'), LBTMacro.Items[ConfTMacro]]);
603
  LPdig.Caption := Format('%s (%s)', [_('Digestible phosphorus'), LBTMacro.Items[ConfTMacro]]);
604
  GBFibres.Caption := Format('%s (%s)', [_('Content'), LBTFibres.Items[ConfTFibres]]);
605
  if ConfDig = 0
606
  then // CUD
607
  begin
608
    LdMetCys.Caption := _('Std. digestibility');
609
    LdPheTyr.Caption := _('Std. digestibility');
610
  end
611
  else // Teneur digestible
612
  begin
613
    LdMetCys.Caption := _('Std. dig. content');
614
    LdPheTyr.Caption := _('Std. dig. content');
615
  end;
616
end;
617
618
// Ajustement du nombre de d?cimales en fonction de la configuration
619
procedure TFMatiere.AjustDecimals;
620
begin
621
  Update := TRUE;
622
  // Composition ?l?mentaire
623
  if ConfTCompo = 0
624
  then // g/kg
625
    PBTMS.Decimals := 1
626
  else // %
627
    PBTMS.Decimals := 2;
628
  PBTMM.Decimals := PBTMS.Decimals;
629
  PBTMO.Decimals := PBTMS.Decimals;
630
  PBTLip.Decimals := PBTMS.Decimals;
631
  PBTMAT.Decimals := PBTMS.Decimals;
632
  PBTAmidon.Decimals := PBTMS.Decimals;
633
  PBTSucres.Decimals := PBTMS.Decimals;
634
  PBTResidu.Decimals := PBTMS.Decimals;
635
  if (ConfDig = 0)
636
  then // CUD
637
    PBdMO_C.Decimals := 1
638
  else // Teneur digestible
639
    if ConfdCompo = 0
640
    then // g/kg
641
      PBdMO_C.Decimals := 1
642
    else // %
643
      PBdMO_C.Decimals := 2;
644
  PBdLip_C.Decimals := PBdMO_C.Decimals;
645
  PBdMAT_C.Decimals := PBdMO_C.Decimals;
646
  PBdAmidon_C.Decimals := PBdMO_C.Decimals;
647
  PBdSucres_C.Decimals := PBdMO_C.Decimals;
648
  PBdResidu_C.Decimals := PBdMO_C.Decimals;
649
  PBdMO_T.Decimals := PBdMO_C.Decimals;
650
  PBdLip_T.Decimals := PBdMO_C.Decimals;
651
  PBdMAT_T.Decimals := PBdMO_C.Decimals;
652
  PBdAmidon_T.Decimals := PBdMO_C.Decimals;
653
  PBdSucres_T.Decimals := PBdMO_C.Decimals;
654
  PBdResidu_T.Decimals := PBdMO_C.Decimals;
655
  // Acides amin?s
656
  if ConfTAA = 1
657
  then // %
658
    PBTMAT2.Decimals := 3
659
  else // %MAT ou g/kg
660
    PBTMAT2.Decimals := 2;
661
  PBTLys.Decimals := PBTMAT2.Decimals;
662
  PBTMet.Decimals := PBTMAT2.Decimals;
663
  PBTCys.Decimals := PBTMAT2.Decimals;
664
  PBTTrp.Decimals := PBTMAT2.Decimals;
665
  PBTThr.Decimals := PBTMAT2.Decimals;
666
  PBTPhe.Decimals := PBTMAT2.Decimals;
667
  PBTTyr.Decimals := PBTMAT2.Decimals;
668
  PBTLeu.Decimals := PBTMAT2.Decimals;
669
  PBTIle.Decimals := PBTMAT2.Decimals;
670
  PBTVal.Decimals := PBTMAT2.Decimals;
671
  PBTHis.Decimals := PBTMAT2.Decimals;
672
  PBTArg.Decimals := PBTMAT2.Decimals;
673
  PBTMetCys.Decimals := PBTMAT2.Decimals;
674
  PBTPheTyr.Decimals := PBTMAT2.Decimals;
675
  if ConfDig = 0
676
  then // CUD
677
    PBdMATStd.Decimals := 1
678
  else // Teneur digestible
679
    if ConfdAA = 0
680
    then // g/kg
681
      PBdMATStd.Decimals := 2
682
    else // %
683
      PBdMATStd.Decimals := 3;
684
  PBdLysStd.Decimals := PBdMATStd.Decimals;
685
  PBdMetStd.Decimals := PBdMATStd.Decimals;
686
  PBdCysStd.Decimals := PBdMATStd.Decimals;
687
  PBdTrpStd.Decimals := PBdMATStd.Decimals;
688
  PBdThrStd.Decimals := PBdMATStd.Decimals;
689
  PBdPheStd.Decimals := PBdMATStd.Decimals;
690
  PBdTyrStd.Decimals := PBdMATStd.Decimals;
691
  PBdLeuStd.Decimals := PBdMATStd.Decimals;
692
  PBdIleStd.Decimals := PBdMATStd.Decimals;
693
  PBdValStd.Decimals := PBdMATStd.Decimals;
694
  PBdHisStd.Decimals := PBdMATStd.Decimals;
695
  PBdArgStd.Decimals := PBdMATStd.Decimals;
696
  PBdMATApp.Decimals := PBdMATStd.Decimals;
697
  PBdLysApp.Decimals := PBdMATStd.Decimals;
698
  PBdMetApp.Decimals := PBdMATStd.Decimals;
699
  PBdCysApp.Decimals := PBdMATStd.Decimals;
700
  PBdTrpApp.Decimals := PBdMATStd.Decimals;
701
  PBdThrApp.Decimals := PBdMATStd.Decimals;
702
  PBdPheApp.Decimals := PBdMATStd.Decimals;
703
  PBdTyrApp.Decimals := PBdMATStd.Decimals;
704
  PBdLeuApp.Decimals := PBdMATStd.Decimals;
705
  PBdIleApp.Decimals := PBdMATStd.Decimals;
706
  PBdValApp.Decimals := PBdMATStd.Decimals;
707
  PBdHisApp.Decimals := PBdMATStd.Decimals;
708
  PBdArgApp.Decimals := PBdMATStd.Decimals;
709
  PBdMetCysStd.Decimals := PBdMATStd.Decimals;
710
  PBdMetCysApp.Decimals := PBdMATStd.Decimals;
711
  PBdPheTyrStd.Decimals := PBdMATStd.Decimals;
712
  PBdPheTyrApp.Decimals := PBdMATStd.Decimals;
713
  // Acides gras
714
  case ConfTAG of
715
    0: // g/kg
716
      PBC6C8C10_0.Decimals := 2;
717
    1: // %
718
      PBC6C8C10_0.Decimals := 3;
719
    else // % acides gras
720
      PBC6C8C10_0.Decimals := 1;
721
  end;
722
  PBC12_0.Decimals := PBC6C8C10_0.Decimals;
723
  PBC14_0.Decimals := PBC6C8C10_0.Decimals;
724
  PBC16_0.Decimals := PBC6C8C10_0.Decimals;
725
  PBC16_1.Decimals := PBC6C8C10_0.Decimals;
726
  PBC18_0.Decimals := PBC6C8C10_0.Decimals;
727
  PBC18_1.Decimals := PBC6C8C10_0.Decimals;
728
  PBC18_2.Decimals := PBC6C8C10_0.Decimals;
729
  PBC18_3.Decimals := PBC6C8C10_0.Decimals;
730
  PBC18_4.Decimals := PBC6C8C10_0.Decimals;
731
  PBC20_0.Decimals := PBC6C8C10_0.Decimals;
732
  PBC20_1.Decimals := PBC6C8C10_0.Decimals;
733
  PBC20_4.Decimals := PBC6C8C10_0.Decimals;
734
  PBC20_5.Decimals := PBC6C8C10_0.Decimals;
735
  PBC22_0.Decimals := PBC6C8C10_0.Decimals;
736
  PBC22_1.Decimals := PBC6C8C10_0.Decimals;
737
  PBC22_5.Decimals := PBC6C8C10_0.Decimals;
738
  PBC22_6.Decimals := PBC6C8C10_0.Decimals;
739
  PBC24_0.Decimals := PBC6C8C10_0.Decimals;
740
  PBC6C8C10_tot.Decimals := PBC6C8C10_0.Decimals;
741
  PBC12_tot.Decimals := PBC6C8C10_0.Decimals;
742
  PBC14_tot.Decimals := PBC6C8C10_0.Decimals;
743
  PBC16_tot.Decimals := PBC6C8C10_0.Decimals;
744
  PBC18_tot.Decimals := PBC6C8C10_0.Decimals;
745
  PBC20_tot.Decimals := PBC6C8C10_0.Decimals;
746
  PBC22_tot.Decimals := PBC6C8C10_0.Decimals;
747
  PBC24_tot.Decimals := PBC6C8C10_0.Decimals;
748
  PBCtot_tot.Decimals := PBC6C8C10_0.Decimals;
749
  PBCtot_0.Decimals := PBC6C8C10_0.Decimals;
750
  PBCtot_1.Decimals := PBC6C8C10_0.Decimals;
751
  PBCtot_2.Decimals := PBC6C8C10_0.Decimals;
752
  PBCtot_3.Decimals := PBC6C8C10_0.Decimals;
753
  PBCtot_4.Decimals := PBC6C8C10_0.Decimals;
754
  PBCtot_5.Decimals := PBC6C8C10_0.Decimals;
755
  PBCtot_6.Decimals := PBC6C8C10_0.Decimals;
756
  // Min?raux
757
  if ConfTMacro = 0
758
  then // g/kg
759
    PBCa.Decimals := 2
760
  else // %
761
    PBCa.Decimals := 3;
762
  PBP.Decimals := PBCa.Decimals;
763
  PBNa.Decimals := PBCa.Decimals;
764
  PBK.Decimals := PBCa.Decimals;
765
  PBMg.Decimals := PBCa.Decimals;
766
  PBCl.Decimals := PBCa.Decimals;
767
  PBS.Decimals := PBCa.Decimals;
768
  if ConfTOligo = 0
769
  then // mg/kg
770
    PBCu.Decimals := 2
771
  else // %
772
    PBCu.Decimals := 6;
773
  PBZn.Decimals := PBCu.Decimals;
774
  PBMn.Decimals := PBCu.Decimals;
775
  PBFe.Decimals := PBCu.Decimals;
776
  PBSe.Decimals := PBCu.Decimals;
777
  PBCo.Decimals := PBCu.Decimals;
778
  PBMb.Decimals := PBCu.Decimals;
779
  PBI.Decimals := PBCu.Decimals;
780
  PBPtot.Decimals := PBCa.Decimals;
781
  PBPdigG.Decimals := PBCa.Decimals;
782
  PBPdigF.Decimals := PBCa.Decimals;
783
  // Fibres
784
  if ConfTFibres = 0
785
  then // g/kg
786
    PBCB.Decimals := 1
787
  else // %
788
    PBCB.Decimals := 2;
789
  PBNDF.Decimals := PBCB.Decimals;
790
  PBADF.Decimals := PBCB.Decimals;
791
  PBADL.Decimals := PBCB.Decimals;
792
  PBParois.Decimals := PBCB.Decimals;
793
  Update := FALSE;
794
end;
795
796
// Activation (ou non) des champs de saisie
797
procedure TFMatiere.AjustEnabled ;
798
begin
799
  if IdxMatiere < NumMatInraAfz
800
  then
801
    SBDel.Enabled := FALSE
802
  else
803
    SBDel.Enabled := TRUE ;
804
  SBRename.Enabled := SBDel.Enabled ;
805
  SBComment.Enabled := SBDel.Enabled ;
806
  SBSave.Enabled := SBDel.Enabled ;
807
  if IdxMatiere = -1
808
  then
809
    SBPrint.Enabled := FALSE
810
  else
811
    SBPrint.Enabled := TRUE ;
812
  if PC.Visible
813
  then
814
  begin
815
    PBTMS.Enabled := SBDel.Enabled ;
816
    // Composition ?l?mentaire
817
    if (PMatiere.CC.MS = 0) or (PMatiere.Num < 0)
818
    then
819
      PBTMM.Enabled := FALSE
820
    else
821
      PBTMM.Enabled := TRUE ;
822
    PBTLip.Enabled := PBTMM.Enabled ;
823
    PBTMAT.Enabled := PBTMM.Enabled ;
824
    PBTAmidon.Enabled := PBTMM.Enabled ;
825
    PBTSucres.Enabled := PBTMM.Enabled ;
826
    CBAAsMAT.Enabled := PBTMM.Enabled ;
827
    CBCorrCUD.Enabled := PBTMM.Enabled ;
828
    PBdMO_C.Enabled := CBCorrCUD.Enabled and not CBCorrCUD.Checked ;
829
    PBdLip_C.Enabled := PBdMO_C.Enabled ;
830
    PBdMAT_C.Enabled := PBdMO_C.Enabled ;
831
    PBdMO_T.Enabled := PBdMO_C.Enabled ;
832
    PBdLip_T.Enabled := PBdLip_C.Enabled ;
833
    PBdMAT_T.Enabled := PBdMAT_C.Enabled ;
834
    RBED.Enabled := CBCorrCUD.Enabled and CBCorrCUD.Checked ;
835
    RBEM.Enabled := RBED.Enabled ;
836
    RBEN.Enabled := RBED.Enabled ;
837
    PBED_C.Enabled := RBED.Enabled and RBED.Checked ;
838
    PBED_T.Enabled := PBED_C.Enabled ;
839
    PBEM_C.Enabled := RBEM.Enabled and RBEM.Checked ;
840
    PBEM_T.Enabled := PBEM_C.Enabled ;
841
    PBEN_C.Enabled := RBEN.Enabled and RBEN.Checked ;
842
    PBEN_T.Enabled := PBEN_C.Enabled ;
843
    // Acides amin?s
844
    PBTLys.Enabled := PBTMM.Enabled ;
845
    PBTMet.Enabled := PBTMM.Enabled and not CBAAsLys.Checked ;
846
    PBTCys.Enabled := PBTMet.Enabled ;
847
    PBTTrp.Enabled := PBTMet.Enabled ;
848
    PBTThr.Enabled := PBTMet.Enabled ;
849
    PBTPhe.Enabled := PBTMet.Enabled ;
850
    PBTTyr.Enabled := PBTMet.Enabled ;
851
    PBTLeu.Enabled := PBTMet.Enabled ;
852
    PBTIle.Enabled := PBTMet.Enabled ;
853
    PBTVal.Enabled := PBTMet.Enabled ;
854
    PBTHis.Enabled := PBTMet.Enabled ;
855
    PBTArg.Enabled := PBTMet.Enabled ;
856
    PBdMATStd.Enabled := PBTMM.Enabled ;
857
    PBdLysStd.Enabled := PBTMM.Enabled ;
858
    PBdMetStd.Enabled := PBTMM.Enabled ;
859
    PBdCysStd.Enabled := PBTMM.Enabled ;
860
    PBdTrpStd.Enabled := PBTMM.Enabled ;
861
    PBdThrStd.Enabled := PBTMM.Enabled ;
862
    PBdPheStd.Enabled := PBTMM.Enabled ;
863
    PBdTyrStd.Enabled := PBTMM.Enabled ;
864
    PBdLeuStd.Enabled := PBTMM.Enabled ;
865
    PBdIleStd.Enabled := PBTMM.Enabled ;
866
    PBdValStd.Enabled := PBTMM.Enabled ;
867
    PBdHisStd.Enabled := PBTMM.Enabled ;
868
    PBdArgStd.Enabled := PBTMM.Enabled ;
869
    CBAAsLys.Enabled := PBTMM.Enabled ;
870
    // Acides gras
871
    PBC6C8C10_0.Enabled := PBTMM.Enabled ;
872
    PBC12_0.Enabled := PBTMM.Enabled ;
873
    PBC14_0.Enabled := PBTMM.Enabled ;
874
    PBC16_0.Enabled := PBTMM.Enabled ;
875
    PBC16_1.Enabled := PBTMM.Enabled ;
876
    PBC18_0.Enabled := PBTMM.Enabled ;
877
    PBC18_1.Enabled := PBTMM.Enabled ;
878
    PBC18_2.Enabled := PBTMM.Enabled ;
879
    PBC18_3.Enabled := PBTMM.Enabled ;
880
    PBC18_4.Enabled := PBTMM.Enabled ;
881
    PBC20_0.Enabled := PBTMM.Enabled ;
882
    PBC20_1.Enabled := PBTMM.Enabled ;
883
    PBC20_4.Enabled := PBTMM.Enabled ;
884
    PBC20_5.Enabled := PBTMM.Enabled ;
885
    PBC22_0.Enabled := PBTMM.Enabled ;
886
    PBC22_1.Enabled := PBTMM.Enabled ;
887
    PBC22_5.Enabled := PBTMM.Enabled ;
888
    PBC22_6.Enabled := PBTMM.Enabled ;
889
    PBC24_0.Enabled := PBTMM.Enabled ;
890
    PBAG.Enabled := PBTMM.Enabled ;
891
    // Min?raux
892
    PBCa.Enabled := PBTMM.Enabled ;
893
    PBP.Enabled := PBTMM.Enabled ;
894
    PBNa.Enabled := PBTMM.Enabled ;
895
    PBK.Enabled := PBTMM.Enabled ;
896
    PBMg.Enabled := PBTMM.Enabled ;
897
    PBCl.Enabled := PBTMM.Enabled ;
898
    PBS.Enabled := PBTMM.Enabled ;
899
    PBCu.Enabled := PBTMM.Enabled ;
900
    PBZn.Enabled := PBTMM.Enabled ;
901
    PBMn.Enabled := PBTMM.Enabled ;
902
    PBFe.Enabled := PBTMM.Enabled ;
903
    PBSe.Enabled := PBTMM.Enabled ;
904
    PBCo.Enabled := PBTMM.Enabled ;
905
    PBMb.Enabled := PBTMM.Enabled ;
906
    PBI.Enabled := PBTMM.Enabled ;
907
    PBPdigG.Enabled := PBTMM.Enabled ;
908
    PBPdigF.Enabled := PBTMM.Enabled ;
909
    PBPhytase.Enabled := PBTMM.Enabled ;
910
    PBActPhytE.Enabled := PBTMM.Enabled ;
911
    PBActPhytM.Enabled := PBTMM.Enabled ;
912
    // Fibres
913
    PBCB.Enabled := PBTMM.Enabled ;
914
    PBNDF.Enabled := PBTMM.Enabled ;
915
    PBADF.Enabled := PBTMM.Enabled ;
916
    PBADL.Enabled := PBTMM.Enabled ;
917
    PBParois.Enabled := PBTMM.Enabled ;
918
  end ;
919
end ;
920
921
procedure TFMatiere.CBMatiereChange (Sender : TObject) ;
922
begin
923
  if (IdxMatiere <> -1)
924
  and ((PMatiere.Num > 0) and (CBMatiere.Text <> PMatiere.Nom)
925
    or (PMatiere.Num < 0) and (CBMatiere.Text <> dgettext('InraAfz', PMatiere.Nom)))
926
  then
927
    if Modified then Save ;
928
  IdxMatiere := FindIdxMatiere (CBMatiere.Text) ;
929
  if IdxMatiere = -1
930
  then // Pas d'enregistrement
931
  begin
932
    CBMatiere.Repaint ;
933
    PC.ActivePageIndex := 0 ;
934
    PC.Visible := FALSE ;
935
    AjustEnabled ;
936
  end
937
  else // Affichage de l'enregistrement
938
  begin
939
    PC.Visible := TRUE ;
940
    PMatiere := ListMatiere[IdxMatiere] ;
941
    with PMatiere^ do
942
//      CBMatiere.Hint := Memo ;
943
      if Num > 0
944
      then // Mati?re premi?re utilisateur
945
        CBMatiere.Hint := Memo
946
      else // Mati?re premi?re INRA-AFZ (traduction)
947
        if Memo <> ''
948
        then
949
          CBMatiere.Hint := dgettext('InraAfz', Memo)
950
        else
951
          CBMatiere.Hint := '';
952
    with PMatiere.CC do
953
      if ConfRap = 0
954
      then // sur frais
955
        RapMS := MS / 1000
956
      else // sur mati?re s?che
957
        RapMS := 1 ;
958
    AjustEnabled ;
959
    Update := TRUE ;
960
    // Certaines donn?es calcul?es sont stock?es...
961
    // On les recalcule tout de m?me avant de les afficher !
962
    CalculTMO ;
963
    CalculResidu ;
964
    CalculEnergie ;
965
    // Composition ?l?mentaire
966
    AffichTFecale ;
967
    AffichdFecale ;
968
    AffichResidu ;
969
    AffichEnergie ;
970
    // Acides amin?s
971
    AffichTAA ;
972
    AffichdAA ;
973
    CalculAA ;
974
    // Acides gras
975
    with PMatiere.CC do
976
      PBLip2.AsFloat := Lip * RapMS ;
977
    with PMatiere.CC do
978
      PBAG.AsFloat := AGsLip ;
979
    AffichTAG ;
980
    CalculAG ;
981
    // Min?raux
982
    AffichTMineraux ;
983
    CalculMineraux ;
984
    // Fibres
985
    AffichTFibres ;
986
    // Champs calcul?s
987
    Update := FALSE ;
988
    CBAAsMAT.Checked := TRUE ;
989
    CBCorrCUD.Checked := FALSE ;
990
  end ;
991
end ;
992
993
procedure TFMatiere.SBAddClick (Sender : TObject) ;
994
var
995
  i, n, q : integer ;
996
  s : string ;
997
  ok : boolean ;
998
  PBackup : PRecMatiere ;
999
begin
1000
  if Modified then Save ;
1001
  if IdxMatiere = -1
1002
  then
1003
    q := mrNo
1004
  else
1005
    q := MessageDlg (MsgCopy, mtConfirmation, [mbYes, mbNo], 0) ;
1006
  // saisie du nouveau nom
1007
  s := '' ;
1008
  repeat
1009
    if InputQuery (FMatiere.Caption, MsgName, s)
1010
    then // V?rification du nom
1011
    begin
1012
      s := Trim (s) ; // Suppression des espaces au d?but et ? la fin
1013
      if s = ''
1014
      then // Pas de nom
1015
      begin
1016
        ok := FALSE ;
1017
        MessageDlg (MsgNameEmpty, mtWarning, [mbOk], 0) ;
1018
      end
1019
      else
1020
        if Length (s) > 35
1021
        then // Nom trop long
1022
        begin
1023
          ok := FALSE ;
1024
          MessageDlg (Format (MsgNameTooLarge, [35]), mtWarning, [mbOk], 0) ;
1025
          s := Copy (s, 1, 35) ;
1026
        end
1027
        else
1028
        begin
1029
          ok := TRUE ;
1030
          i := 0 ;
1031
          while ok and (i < ListMatiere.Count) do
1032
          begin
1033
            PMatiere := ListMatiere[i] ;
1034
            if PMatiere.Nom = s
1035
            then // Nom d?j? utilis?
1036
            begin
1037
              ok := FALSE ;
1038
              MessageDlg (MsgNameExists, mtWarning, [mbOk], 0) ;
1039
            end
1040
            else
1041
              Inc (i) ;
1042
          end ;
1043
        end ;
1044
    end
1045
    else // Annulation
1046
    begin
1047
      s := '' ;
1048
      if (IdxMatiere <> -1)
1049
      then
1050
        PMatiere := ListMatiere[IdxMatiere] ;
1051
      ok := TRUE ;
1052
    end ;
1053
  until ok ;
1054
  if s <> ''
1055
  then // Cr?ation du nouvel enregistrement
1056
  begin
1057
    // recherche du premier num?ro libre
1058
    n := 0 ;
1059
    repeat
1060
      Inc (n) ;
1061
      ok := TRUE ;
1062
      i := NumMatInraAfz ;
1063
      while ok and (i < ListMatiere.Count) do
1064
      begin
1065
        PMatiere := ListMatiere[i] ;
1066
        if PMatiere.Num = n
1067
        then
1068
          ok := FALSE
1069
        else
1070
          Inc (i) ;
1071
      end ;
1072
    until ok ;
1073
    New (PMatiere) ;
1074
    with PMatiere^ do
1075
    begin
1076
      Nom := s ;
1077
      Num := n ;
1078
      if q = mrYes
1079
      then
1080
      begin
1081
        PBackup := ListMatiere[IdxMatiere] ;
1082
        Memo := PBackup.Memo ;
1083
        Typ := PBackup.Typ ;
1084
        CC := PBackup.CC ;
1085
        for i := 0 to 12 do
1086
          AAtotal[i] := PBackup.AATotal[i] ;
1087
        for i := 0 to 12 do
1088
          CUDAA[i] := PBackup.CUDAA[i] ;
1089
      end
1090
      else
1091
      begin
1092
        Memo := '' ;
1093
        Typ := 0 ;
1094
        CC := CCVide ;
1095
        for i := 0 to 12 do
1096
          AAtotal[i] := 0 ;
1097
        for i := 0 to 12 do
1098
          CUDAA[i] := 0 ;
1099
      end ;
1100
    end ;
1101
    ListMatiere.Add (PMatiere) ;
1102
    CBMatiere.Items.Add (PMatiere.Nom) ;
1103
    CBMatiere.ItemIndex := CBMatiere.Items.IndexOf (PMatiere.Nom) ;
1104
    CBMatiereChange (nil) ;
1105
    Modified := TRUE ;
1106
    SBAdd.Enabled := IsComplete or (ListMatiere.Count < NumMatInraAfz + 10) ;
1107
    SBCommentClick (nil) ;
1108
  end ;
1109
end ;
1110
1111
procedure TFMatiere.SBDelClick (Sender : TObject) ;
1112
begin
1113
  if MatiereUsed (PMatiere.Num)
1114
  then // Enregistrement utilis?
1115
    MessageDlg (MsgDelErr, mtWarning, [mbOk], 0)
1116
  else // Suppression de l'enregistrement
1117
    if MessageDlg (MsgDel, mtConfirmation, [mbYes, mbNo], 0) = mrYes
1118
    then
1119
    begin
1120
      Dispose (PMatiere) ;
1121
      ListMatiere.Delete (IdxMatiere) ;
1122
      SaveMatiere ; // Sauvegarde !
1123
      Modified := FALSE ;
1124
      CBMatiere.DeleteSelected ;
1125
      IdxMatiere := -1 ;
1126
      CBMatiere.ItemIndex := -1 ;
1127
      CBMatiereChange (nil) ;
1128
      SBAdd.Enabled := IsComplete or (ListMatiere.Count < NumMatInraAfz + 10) ;
1129
    end ;
1130
end ;
1131
1132
procedure TFMatiere.SBRenameClick (Sender : TObject) ;
1133
var
1134
  i : integer ;
1135
  s : string ;
1136
  ok : boolean ;
1137
begin
1138
  // Saisie du nouveau nom
1139
  s := CBMatiere.Text ;
1140
  repeat
1141
    if InputQuery (FMatiere.Caption, MsgRename, s) and (s <> CBMatiere.Text)
1142
    then // V?rification du nom
1143
    begin
1144
      s := Trim (s) ; // Suppression des espaces au d?but et ? la fin
1145
      if s = ''
1146
      then // Pas de nom
1147
      begin
1148
        ok := FALSE ;
1149
        MessageDlg (MsgNameEmpty, mtWarning, [mbOk], 0) ;
1150
      end
1151
      else
1152
        if Length (s) > 35
1153
        then // Nom trop long
1154
        begin
1155
          ok := FALSE ;
1156
          MessageDlg (Format (MsgNameTooLarge, [35]), mtWarning, [mbOk], 0) ;
1157
          s := Copy (s, 1, 35) ;
1158
        end
1159
        else
1160
        begin
1161
          ok := TRUE ;
1162
          i := 0 ;
1163
          while ok and (i < ListMatiere.Count) do
1164
          begin
1165
            PMatiere := ListMatiere[i] ;
1166
            if PMatiere.Nom = s
1167
            then // Nom d?j? utilis?
1168
            begin
1169
              ok := FALSE ;
1170
              MessageDlg (MsgNameExists, mtWarning, [mbOk], 0) ;
1171
            end
1172
            else
1173
              Inc (i) ;
1174
          end ;
1175
        end ;
1176
    end
1177
    else // Annulation
1178
    begin
1179
      s := '' ;
1180
      ok := TRUE ;
1181
    end ;
1182
  until ok ;
1183
  PMatiere := ListMatiere[IdxMatiere] ;
1184
  if s <> ''
1185
  then // Renommer l'enregistrement
1186
  begin
1187
    PMatiere.Nom := s ;
1188
    Modified := TRUE ;
1189
    StringsMatiere (CBMatiere.Items, 0, TRUE, TRUE) ;
1190
    CBMatiere.ItemIndex := CBMatiere.Items.IndexOf (s) ;
1191
  end ;
1192
end ;
1193
1194
procedure TFMatiere.SBCommentClick (Sender : TObject) ;
1195
begin
1196
  // Saisie du commentaire
1197
  FCommentMat := TFCommentMat.Create (Self) ;
1198
  with FCommentMat do
1199
  begin
1200
    Memo.Text := PMatiere.Memo ;
1201
    CBType.ItemIndex := PMatiere.Typ ;
1202
    if ShowModal = mrOk
1203
    then // Commenter l'enregistrement
1204
    begin
1205
      PMatiere.Memo := Memo.Text ;
1206
      PMatiere.Typ := CBType.ItemIndex ;
1207
      Modified := TRUE ;
1208
      CBMatiere.Hint := PMatiere.Memo ;
1209
    end ;
1210
    Release ;
1211
  end ;
1212
end ;
1213
1214
procedure TFMatiere.SBSaveClick (Sender : TObject) ;
1215
begin
1216
  SaveMatiere ;
1217
  if not MatiereValid (PMatiere)
1218
  then
1219
    MessageDlg(Format (MsgInvalidData, [Caption, PMatiere.Nom]), mtWarning, [mbOK], 0) ;
1220
  Modified := FALSE ;
1221
end ;
1222
1223
procedure TFMatiere.SBPrintClick (Sender : TObject) ;
1224
begin
1225
  FRapportMat := TFRapportMat.Create (Self) ;
1226
  FRapportMat.ShowModal ;
1227
  FRapportMat.Release ;
1228
end ;
1229
1230
////////////////////////////////////////////////////////////////////////////////
1231
// Composition ?l?mentaire
1232
////////////////////////////////////////////////////////////////////////////////
1233
1234
// Mati?re organique = Mati?re s?che - Mati?res min?rales
1235
procedure TFMatiere.CalculTMO ;
1236
begin
1237
  with PMatiere.CC do
1238
    MO := 1000 - MM ;
1239
  // Affichage de la valeur
1240
  if ConfTCompo = 0
1241
  then // g/kg
1242
    with PMatiere.CC do
1243
      PBTMO.AsFloat := MO * RapMS
1244
  else // %
1245
    with PMatiere.CC do
1246
      PBTMO.AsFloat := MO / 1000 * 100 * RapMS ;
1247
end ;
1248
1249
procedure TFMatiere.CalculResidu ;
1250
begin
1251
  with PMatiere.CC do
1252
  begin
1253
    // R?sidu = Mati?re s?che - (Mati?re min?rale + Mati?res azot?es + Mati?res grasses + Amidon + Sucres + Cellulose brute)
1254
    if MM + MAT + Lip + Amidon + Sucres + CB > 1000
1255
    then
1256
      Residu := 0
1257
    else
1258
      Residu := 1000 - (MM + MAT + Lip + Amidon + Sucres + CB) ;
1259
    // CUD R?sidu
1260
    if CB + Residu > 0
1261
    then
1262
    begin
1263
      dResidu_C := (MO * dMO_C - (MAT * dMAT_C + Lip * dLip_C + Amidon * 100 + Sucres * 100)) / (CB + Residu) ;
1264
      dResidu_T := (MO * dMO_T - (MAT * dMAT_T + Lip * dLip_T + Amidon * 100 + Sucres * 100)) / (CB + Residu) ;
1265
    end
1266
    else
1267
    begin
1268
      dResidu_C := 0 ;
1269
      dResidu_T := 0 ;
1270
    end ;
1271
    // CUD Cellulose brute = CUD R?sidu
1272
    dCB_C := dResidu_C ;
1273
    dCB_T := dResidu_T ;
1274
  end ;
1275
end ;
1276
1277
procedure TFMatiere.AffichResidu ;
1278
begin
1279
  with PMatiere.CC do
1280
  begin
1281
    // Teneur
1282
    if ConfTCompo = 0
1283
    then // g/kg
1284
      PBTResidu.AsFloat := (Residu + CB) * RapMS
1285
    else // %
1286
      PBTResidu.AsFloat := (Residu + CB) / 1000 * 100 * RapMS ;
1287
    // Digestibilit?
1288
    if ConfDig = 0
1289
    then // CUD
1290
    begin
1291
      // Croissance
1292
      PBdResidu_C.AsFloat := dResidu_C ;
1293
      // Truie
1294
      PBdResidu_T.AsFloat := dResidu_T ;
1295
    end
1296
    else // Teneur digestible
1297
      if ConfdCompo = 0
1298
      then // g/kg
1299
      begin
1300
        // Croissance
1301
        PBdResidu_C.AsFloat := (Residu + CB) * dResidu_C / 100 * RapMS ;
1302
        // Truie
1303
        PBdResidu_T.AsFloat := (Residu + CB) * dResidu_T / 100 * RapMS ;
1304
      end
1305
      else // %
1306
      begin
1307
        // Croissance
1308
        PBdResidu_C.AsFloat := (Residu + CB) / 1000 * dResidu_C * RapMS ;
1309
        // Truie
1310
        PBdResidu_T.AsFloat := (Residu + CB) / 1000 * dResidu_T * RapMS ;
1311
      end ;
1312
  end ;
1313
end ;
1314
1315
// Affichage de la teneur en fonction de la configuration
1316
procedure TFMatiere.AffichTFecale ;
1317
begin
1318
  if ConfTCompo = 0
1319
  then // g/kg
1320
    with PMatiere.CC do
1321
    begin
1322
      if ActiveControl <> PBTMS
1323
      then
1324
        PBTMS.AsFloat := MS ;
1325
      PBTMM.AsFloat := MM * RapMS ;
1326
      PBTMO.AsFloat := MO * RapMS ;
1327
      PBTLip.AsFloat := Lip * RapMS ;
1328
      PBTMAT.AsFloat := MAT * RapMS ;
1329
      PBTAmidon.AsFloat := Amidon * RapMS ;
1330
      PBTSucres.AsFloat := Sucres * RapMS ;
1331
    end
1332
  else // %
1333
    with PMatiere.CC do
1334
    begin
1335
      if ActiveControl <> PBTMS
1336
      then
1337
        PBTMS.AsFloat := MS / 1000 * 100 ;
1338
      PBTMM.AsFloat := MM / 1000 * 100 * RapMS ;
1339
      PBTMO.AsFloat := MO / 1000 * 100 * RapMS ;
1340
      PBTLip.AsFloat := Lip / 1000 * 100 * RapMS ;
1341
      PBTMAT.AsFloat := MAT / 1000 * 100 * RapMS ;
1342
      PBTAmidon.AsFloat := Amidon / 1000 * 100 * RapMS ;
1343
      PBTSucres.AsFloat := Sucres / 1000 * 100 * RapMS ;
1344
    end ;
1345
{
1346
  // Hint (temporaire)
1347
  with PMatiere.CC do
1348
  begin
1349
    PBTMS.Hint := FloatToStr(MS);
1350
    PBTMM.Hint := FloatToStr(MM * RapMS);
1351
    PBTLip.Hint := FloatToStr(Lip * RapMS);
1352
    PBTMAT.Hint := FloatToStr(MAT * RapMS);
1353
    PBTAmidon.Hint := FloatToStr(Amidon * RapMS);
1354
    PBTSucres.Hint := FloatToStr(Sucres * RapMS);
1355
  end;
1356
}
1357
end ;
1358
1359
// Affichage de la digestibilit? f?cale en fonction de la configuration
1360
procedure TFMatiere.AffichdFecale ;
1361
begin
1362
  if ConfDig = 0
1363
  then // CUD
1364
    with PMatiere.CC do
1365
    begin
1366
      // Croissance
1367
      PBdMO_C.AsFloat := dMO_C ;
1368
      PBdLip_C.AsFloat := dLip_C ;
1369
      PBdMAT_C.AsFloat := dMAT_C ;
1370
      PBdAmidon_C.AsFloat := 100 ; // CUD Amidon = 100 %
1371
      PBdSucres_C.AsFloat := 100 ; // CUD Sucres = 100 %
1372
      // Truie
1373
      PBdMO_T.AsFloat := dMO_T ;
1374
      PBdLip_T.AsFloat := dLip_T ;
1375
      PBdMAT_T.AsFloat := dMAT_T ;
1376
      PBdAmidon_T.AsFloat := 100 ; // CUD Amidon = 100 %
1377
      PBdSucres_T.AsFloat := 100 ; // CUD Sucres = 100 %
1378
    end
1379
  else // Teneur digestible
1380
    if ConfdCompo = 0
1381
    then // g/kg
1382
      with PMatiere.CC do
1383
      begin
1384
        // Croissance
1385
        PBdMO_C.AsFloat := MO * dMO_C / 100 * RapMS ;
1386
        PBdLip_C.AsFloat := Lip * dLip_C / 100 * RapMS ;
1387
        PBdMAT_C.AsFloat := MAT * dMAT_C / 100 * RapMS ;
1388
        PBdAmidon_C.AsFloat := Amidon * RapMS ;
1389
        PBdSucres_C.AsFloat := Sucres * RapMS ;
1390
        // Truie
1391
        PBdMO_T.AsFloat := MO * dMO_T / 100 * RapMS ;
1392
        PBdLip_T.AsFloat := Lip * dLip_T / 100 * RapMS ;
1393
        PBdMAT_T.AsFloat := MAT * dMAT_T / 100 * RapMS ;
1394
        PBdAmidon_T.AsFloat := Amidon * RapMS ;
1395
        PBdSucres_T.AsFloat := Sucres * RapMS ;
1396
      end
1397
    else // %
1398
      with PMatiere.CC do
1399
      begin
1400
        // Croissance
1401
        PBdMO_C.AsFloat := MO / 1000 * dMO_C * RapMS ;
1402
        PBdLip_C.AsFloat := Lip / 1000 * dLip_C * RapMS ;
1403
        PBdMAT_C.AsFloat := MAT / 1000 * dMAT_C * RapMS ;
1404
        PBdAmidon_C.AsFloat := Amidon / 1000 * 100 * RapMS ;
1405
        PBdSucres_C.AsFloat := Sucres / 1000 * 100 * RapMS ;
1406
        // Truie
1407
        PBdMO_T.AsFloat := MO / 1000 * dMO_T * RapMS ;
1408
        PBdLip_T.AsFloat := Lip / 1000 * dLip_T * RapMS ;
1409
        PBdMAT_T.AsFloat := MAT / 1000 * dMAT_T * RapMS ;
1410
        PBdAmidon_T.AsFloat := Amidon / 1000 * 100 * RapMS ;
1411
        PBdSucres_T.AsFloat := Sucres / 1000 * 100 * RapMS ;
1412
      end ;
1413
{
1414
  // Hint (temporaire)
1415
  with PMatiere.CC do
1416
  begin
1417
    PBdMO_C.Hint := FloatToStr(dMO_C);
1418
    PBdLip_C.Hint := FloatToStr(dLip_C);
1419
    PBdMAT_C.Hint := FloatToStr(dMAT_C);
1420
    PBdMO_T.Hint := FloatToStr(dMO_T);
1421
    PBdLip_T.Hint := FloatToStr(dLip_T);
1422
    PBdMAT_T.Hint := FloatToStr(dMAT_T);
1423
  end;
1424
}
1425
end ;
1426
1427
procedure TFMatiere.CalculEnergie ;
1428
begin
1429
  with PMatiere.CC do
1430
  begin
1431
{
1432
    EB := (22.64 * MAT + 38.76 * Lip + 17.54 * Amidon + 16.71 * Sucres + 18.58 * (Residu + CB)) / 1000 ;
1433
    ED_C := (23.25 * MAT * dMAT_C / 100 + 38.73 * Lip * dLip_C / 100 + 17.45 * Amidon + 16.77 * Sucres + 16.68 * (Residu + CB) * dResidu_C / 100) / 1000 ;
1434
    ED_T := (23.25 * MAT * dMAT_T / 100 + 38.73 * Lip * dLip_T / 100 + 17.45 * Amidon + 16.77 * Sucres + 16.68 * (Residu + CB) * dResidu_T / 100) / 1000 ;
1435
    EM_C := (20.40 * MAT * dMAT_C / 100 + 39.28 * Lip * dLip_C / 100 + 17.45 * Amidon + 16.47 * Sucres + 15.45 * (Residu + CB) * dResidu_C / 100) / 1000 ;
1436
    EM_T := (20.40 * MAT * dMAT_T / 100 + 39.28 * Lip * dLip_T / 100 + 17.45 * Amidon + 16.47 * Sucres + 15.45 * (Residu + CB) * dResidu_T / 100) / 1000 ;
1437
    EN_C := (12.08 * MAT * dMAT_C / 100 + 35.01 * Lip * dLip_C / 100 + 14.32 * Amidon + 11.94 * Sucres + 8.64 * (Residu + CB) * dResidu_C / 100) / 1000 ;
1438
    EN_T := (12.08 * MAT * dMAT_T / 100 + 35.01 * Lip * dLip_T / 100 + 14.32 * Amidon + 11.94 * Sucres + 8.64 * (Residu + CB) * dResidu_T / 100) / 1000 ;
1439
}
1440
    EB := (ValEnergie[1, 1] * MAT + ValEnergie[2, 1] * Lip
1441
      + ValEnergie[3, 1] * Amidon + ValEnergie[4, 1] * Sucres
1442
      + ValEnergie[6, 1] * (Residu + CB)) / 1000 ;
1443
    ED_C := (ValEnergie[1, 2] * MAT * dMAT_C / 100
1444
      + ValEnergie[2, 2] * Lip * dLip_C / 100
1445
      + ValEnergie[3, 2] * Amidon + ValEnergie[4, 2] * Sucres
1446
      + ValEnergie[6, 2] * (Residu + CB) * dResidu_C / 100) / 1000 ;
1447
    ED_T := (ValEnergie[1, 2] * MAT * dMAT_T / 100
1448
      + ValEnergie[2, 2] * Lip * dLip_T / 100
1449
      + ValEnergie[3, 2] * Amidon + ValEnergie[4, 2] * Sucres
1450
      + ValEnergie[6, 2] * (Residu + CB) * dResidu_T / 100) / 1000 ;
1451
    EM_C := (ValEnergie[1, 3] * MAT * dMAT_C / 100
1452
      + ValEnergie[2, 3] * Lip * dLip_C / 100
1453
      + ValEnergie[3, 3] * Amidon + ValEnergie[4, 3] * Sucres
1454
      + ValEnergie[6, 3] * (Residu + CB) * dResidu_C / 100) / 1000 ;
1455
    EM_T := (ValEnergie[1, 3] * MAT * dMAT_T / 100
1456
      + ValEnergie[2, 3] * Lip * dLip_T / 100
1457
      + ValEnergie[3, 3] * Amidon + ValEnergie[4, 3] * Sucres
1458
      + ValEnergie[6, 3] * (Residu + CB) * dResidu_T / 100) / 1000 ;
1459
    EN_C := (ValEnergie[1, 6] * MAT * dMAT_C / 100
1460
      + ValEnergie[2, 6] * Lip * dLip_C / 100
1461
      + ValEnergie[3, 6] * Amidon + ValEnergie[4, 6] * Sucres
1462
      + ValEnergie[6, 6] * (Residu + CB) * dResidu_C / 100) / 1000 ;
1463
    EN_T := (ValEnergie[1, 6] * MAT * dMAT_T / 100
1464
      + ValEnergie[2, 6] * Lip * dLip_T / 100
1465
      + ValEnergie[3, 6] * Amidon + ValEnergie[4, 6] * Sucres
1466
      + ValEnergie[6, 6] * (Residu + CB) * dResidu_T / 100) / 1000 ;
1467
  end ;
1468
end ;
1469
1470
procedure TFMatiere.AffichEnergie ;
1471
begin
1472
  with PMatiere.CC do
1473
  begin
1474
    // Croissance
1475
    PBEB_C.AsFloat := EB * RapMS ;
1476
    if ActiveControl <> PBED_C
1477
    then
1478
      PBED_C.AsFloat := ED_C * RapMS ;
1479
    if ActiveControl <> PBEM_C
1480
    then
1481
      PBEM_C.AsFloat := EM_C * RapMS ;
1482
    if ActiveControl <> PBEN_C
1483
    then
1484
      PBEN_C.AsFloat := EN_C * RapMS ;
1485
    // Truie
1486
    PBEB_T.AsFloat := EB * RapMS ;
1487
    if ActiveControl <> PBED_T
1488
    then
1489
      PBED_T.AsFloat := ED_T * RapMS ;
1490
    if ActiveControl <> PBEM_T
1491
    then
1492
      PBEM_T.AsFloat := EM_T * RapMS ;
1493
    if ActiveControl <> PBEN_T
1494
    then
1495
      PBEN_T.AsFloat := EN_T * RapMS ;
1496
    // ED / EB
1497
    if EB = 0
1498
    then
1499
    begin
1500
      PBEDsEB_C.Text := '' ;
1501
      PBEDsEB_T.Text := '' ;
1502
    end
1503
    else
1504
    begin
1505
      PBEDsEB_C.AsFloat := ED_C / EB * 100 ;
1506
      PBEDsEB_T.AsFloat := ED_T / EB * 100 ;
1507
    end ;
1508
    // EN / EM
1509
    if EM_C = 0
1510
    then
1511
      PBENsEM_C.Text := ''
1512
    else
1513
      PBENsEM_C.AsFloat := EN_C / EM_C * 100 ;
1514
    if EM_T = 0
1515
    then
1516
      PBENsEM_T.Text := ''
1517
    else
1518
      PBENsEM_T.AsFloat := EN_T / EM_T * 100 ;
1519
  end ;
1520
end ;
1521
1522
procedure TFMatiere.PBTMSChange (Sender : TObject) ;
1523
begin
1524
  if (PBTMS.AsFloat <> 0) and not Update
1525
  then
1526
  begin
1527
    Modified := TRUE ;
1528
    // Nouvelle valeur
1529
    with PMatiere.CC do
1530
      if ConfTCompo = 0
1531
      then // g/kg
1532
        MS := PBTMS.AsFloat
1533
      else // %
1534
        MS := PBTMS.AsFloat / 100 * 1000 ;
1535
    // En cas d'affichage sur frais, la valeur de RapMS change...
1536
    // L'ensemble de l'enregistrement est r?affich? !
1537
    if ConfRap = 0
1538
    then // sur frais
1539
    begin
1540
      IdxMatiere := -1 ;
1541
      CBMatiereChange (nil) ;
1542
    end
1543
    else
1544
      AjustEnabled ;
1545
  end ;
1546
end ;
1547
1548
procedure TFMatiere.PBTMSExit (Sender : TObject) ;
1549
begin
1550
  if (PBTMS.AsFloat = 0) and (PMatiere.CC.MS <> 0)
1551
  then
1552
  begin
1553
    Modified := TRUE ;
1554
    // Valeur nulle
1555
    with PMatiere.CC do
1556
      MS := 0 ;
1557
    // En cas d'affichage sur frais, la valeur de RapMS change...
1558
    // L'ensemble de l'enregistrement est r?affich? !
1559
    if ConfRap = 0
1560
    then // sur frais
1561
    begin
1562
      IdxMatiere := -1 ;
1563
      CBMatiereChange (nil) ;
1564
    end
1565
    else
1566
      AjustEnabled ;
1567
  end ;
1568
end ;
1569
1570
procedure TFMatiere.PBTMMChange (Sender : TObject) ;
1571
begin
1572
  if (PBTMM.AsFloat <> 0) and not Update
1573
  then
1574
  begin
1575
    Modified := TRUE ;
1576
    // Nouvelle valeur
1577
    with PMatiere.CC do
1578
      if ConfTCompo = 0
1579
      then // g/kg
1580
        MM := PBTMM.AsFloat / RapMS
1581
      else // %
1582
        MM := PBTMM.AsFloat / 100 * 1000 / RapMS ;
1583
    // Mise ? jour des champs li?s ? cette valeur
1584
    Update := TRUE ;
1585
    CalculTMO ;
1586
    if ConfDig = 1
1587
    then // Teneur digestible
1588
      AffichdFecale ;
1589
    CalculResidu ;
1590
    AffichResidu ;
1591
    CalculEnergie ;
1592
    AffichEnergie ;
1593
    Update := FALSE ;
1594
  end ;
1595
end ;
1596
1597
procedure TFMatiere.PBTMMExit (Sender : TObject) ;
1598
begin
1599
  if (PBTMM.AsFloat = 0) and (PMatiere.CC.MM <> 0)
1600
  then
1601
  begin
1602
    Modified := TRUE ;
1603
    // Valeur nulle
1604
    with PMatiere.CC do
1605
      MM := 0 ;
1606
    // Mise ? jour des champs li?s ? cette valeur
1607
    Update := TRUE ;
1608
    CalculTMO ;
1609
    if ConfDig = 1
1610
    then // Teneur digestible
1611
      AffichdFecale ;
1612
    CalculResidu ;
1613
    AffichResidu ;
1614
    CalculEnergie ;
1615
    AffichEnergie ;
1616
    Update := FALSE ;
1617
  end ;
1618
end ;
1619
1620
procedure TFMatiere.PBTLipChange (Sender : TObject) ;
1621
begin
1622
  if not Update
1623
  then
1624
  begin
1625
    Modified := TRUE ;
1626
    // Nouvelle valeur
1627
    with PMatiere.CC do
1628
      if ConfTCompo = 0
1629
      then // g/kg
1630
        Lip := PBTLip.AsFloat / RapMS
1631
      else // %
1632
        Lip := PBTLip.AsFloat / 100 * 1000 / RapMS ;
1633
    // Mise ? jour des champs li?s ? cette valeur
1634
    with PMatiere.CC do
1635
      PBLip2.AsFloat := Lip * RapMS ;
1636
    Update := TRUE ;
1637
    if ConfDig = 1
1638
    then // Teneur digestible
1639
      AffichdFecale ;
1640
    CalculResidu ;
1641
    AffichResidu ;
1642
    CalculEnergie ;
1643
    AffichEnergie ;
1644
    if ConfTAG <> 2
1645
    then // non % AG
1646
      AffichTAG ;
1647
    CalculAG ;
1648
    Update := FALSE ;
1649
  end ;
1650
end ;
1651
1652
procedure TFMatiere.PBTMATChange (Sender : TObject) ;
1653
var
1654
  i : integer ;
1655
  variation : double ;
1656
begin
1657
  if (PBTMAT.AsFloat <> 0) and not Update
1658
  then
1659
  begin
1660
    Modified := TRUE ;
1661
    // Variation de la teneur en mati?res azot?s
1662
    with PMatiere.CC do
1663
      if MAT = 0
1664
      then
1665
        variation := 1
1666
      else
1667
        if ConfTCompo = 0
1668
        then // g/kg
1669
          variation := PBTMAT.AsFloat / RapMS / MAT
1670
        else // %
1671
          variation := PBTMAT.AsFloat / 100 * 1000 / RapMS / MAT ;
1672
    // Nouvelle valeur
1673
    with PMatiere.CC do
1674
      if ConfTCompo = 0
1675
      then // g/kg
1676
        MAT := PBTMAT.AsFloat / RapMS
1677
      else // %
1678
        MAT := PBTMAT.AsFloat / 100 * 1000 / RapMS ;
1679
    with PMatiere^ do
1680
      AAtotal[0] := CC.MAT ;
1681
    // Mise ? jour des champs li?s ? cette valeur
1682
    with PMatiere^ do
1683
      case ConfTAA of
1684
        1 : // %
1685
          PBTMAT2.AsFloat := AAtotal[0] / 1000 * 100 * RapMS ;
1686
        2 : // % MAT
1687
          PBTMAT2.AsFloat := AAtotal[0] / CC.MAT * 100 ;
1688
        else // g/kg
1689
          PBTMAT2.AsFloat := AAtotal[0] * RapMS ;
1690
      end ;
1691
    Update := TRUE ;
1692
    if ConfDig = 1
1693
    then // Teneur digestible
1694
      AffichdFecale ;
1695
    CalculResidu ;
1696
    AffichResidu ;
1697
    CalculEnergie ;
1698
    AffichEnergie ;
1699
    if CBAAsMAT.Checked
1700
    then // Variation des teneur en acides amin?s (r?gle de trois)
1701
      with PMatiere^ do
1702
        for i := 1 to 12 do
1703
          AAtotal[i] := AAtotal[i] * variation ;
1704
    AffichTAA ;
1705
    if ConfDig = 1
1706
    then // Teneur digestible
1707
      AffichdAA ;
1708
    CalculAA ;
1709
    Update := FALSE ;
1710
  end ;
1711
end ;
1712
1713
procedure TFMatiere.PBTMATExit (Sender : TObject) ;
1714
var
1715
  i : integer ;
1716
begin
1717
  if PBTMAT.AsFloat = 0
1718
  then
1719
  begin
1720
    Modified := TRUE ;
1721
    // Valeur nulle
1722
    with PMatiere.CC do
1723
      MAT := 0 ;
1724
    with PMatiere^ do
1725
      AAtotal[0] := 0 ;
1726
    // Mise ? jour des champs li?s ? cette valeur
1727
    PBTMAT2.AsFloat := 0 ;
1728
    Update := TRUE ;
1729
    if ConfDig = 1
1730
    then // Teneur digestible
1731
      AffichdFecale ;
1732
    CalculResidu ;
1733
    AffichResidu ;
1734
    CalculEnergie ;
1735
    AffichEnergie ;
1736
    if CBAAsMAT.Checked
1737
    then
1738
    begin
1739
      // Variation des teneur en acides amin?s (r?gle de trois)
1740
      with PMatiere^ do
1741
        for i := 1 to 12 do
1742
          AAtotal[i] := 0 ;
1743
      AffichTAA ;
1744
      if ConfDig = 0
1745
      then // Teneur digestible
1746
        AffichdAA ;
1747
    end ;
1748
    CalculAA ;
1749
    Update := FALSE ;
1750
  end ;
1751
end ;
1752
1753
procedure TFMatiere.PBTAmidonChange (Sender : TObject) ;
1754
begin
1755
  if not Update
1756
  then
1757
  begin
1758
    Modified := TRUE ;
1759
    // Nouvelle valeur
1760
    with PMatiere.CC do
1761
      if ConfTCompo = 0
1762
      then // g/kg
1763
        Amidon := PBTAmidon.AsFloat / RapMS
1764
      else // %
1765
        Amidon := PBTAmidon.AsFloat / 100 * 1000 / RapMS ;
1766
    // Mise ? jour des champs li?s ? cette valeur
1767
    Update := TRUE ;
1768
    if ConfDig = 1
1769
    then // Teneur digestible
1770
      AffichdFecale ;
1771
    CalculResidu ;
1772
    AffichResidu ;
1773
    CalculEnergie ;
1774
    AffichEnergie ;
1775
    Update := FALSE ;
1776
  end ;
1777
end ;
1778
1779
procedure TFMatiere.PBTSucresChange (Sender : TObject) ;
1780
begin
1781
  if not Update
1782
  then
1783
  begin
1784
    Modified := TRUE ;
1785
    // Nouvelle valeur
1786
    with PMatiere.CC do
1787
      if ConfTCompo = 0
1788
      then // g/kg
1789
        Sucres := PBTSucres.AsFloat / RapMS
1790
      else // %
1791
        Sucres := PBTSucres.AsFloat / 100 * 1000 / RapMS ;
1792
    // Mise ? jour des champs li?s ? cette valeur
1793
    Update := TRUE ;
1794
    if ConfDig = 1
1795
    then // Teneur digestible
1796
      AffichdFecale ;
1797
    CalculResidu ;
1798
    AffichResidu ;
1799
    CalculEnergie ;
1800
    AffichEnergie ;
1801
    Update := FALSE ;
1802
  end ;
1803
end ;
1804
1805
procedure TFMatiere.PBdMO_CChange (Sender : TObject) ;
1806
begin
1807
  if not Update
1808
  then
1809
  begin
1810
    Modified := TRUE ;
1811
    // Nouvelle valeur
1812
    with PMatiere.CC do
1813
      if ConfDig = 0
1814
      then // CUD
1815
        dMO_C := PBdMO_C.AsFloat
1816
      else // Teneur digestible
1817
        if ConfdCompo = 0
1818
        then // g/kg
1819
          dMO_C := PBdMO_C.AsFloat / MO * 100 / RapMS
1820
        else // %
1821
          dMO_C := PBdMO_C.AsFloat / MO * 1000 / RapMS ;
1822
    // Mise ? jour des champs li?s ? cette valeur
1823
    Update := TRUE ;
1824
    CalculResidu ;
1825
    AffichResidu ;
1826
    CalculEnergie ;
1827
    AffichEnergie ;
1828
    Update := FALSE ;
1829
  end ;
1830
end ;
1831
1832
procedure TFMatiere.PBdLip_CChange (Sender : TObject) ;
1833
begin
1834
  if not Update
1835
  then
1836
  begin
1837
    Modified := TRUE ;
1838
    // Nouvelle valeur
1839
    with PMatiere.CC do
1840
      if ConfDig = 0
1841
      then // CUD
1842
        dLip_C := PBdLip_C.AsFloat
1843
      else // Teneur digestible
1844
        if ConfdCompo = 0
1845
        then // g/kg
1846
          dLip_C := PBdLip_C.AsFloat / Lip * 100 / RapMS
1847
        else // %
1848
          dLip_C := PBdLip_C.AsFloat / Lip * 1000 / RapMS ;
1849
    // Mise ? jour des champs li?s ? cette valeur
1850
    Update := TRUE ;
1851
    CalculResidu ;
1852
    AffichResidu ;
1853
    CalculEnergie ;
1854
    AffichEnergie ;
1855
    Update := FALSE ;
1856
  end ;
1857
end ;
1858
1859
procedure TFMatiere.PBdMAT_CChange (Sender : TObject) ;
1860
begin
1861
  if not Update
1862
  then
1863
  begin
1864
    Modified := TRUE ;
1865
    // Nouvelle valeur
1866
    with PMatiere.CC do
1867
      if ConfDig = 0
1868
      then // CUD
1869
        dMAT_C := PBdMAT_C.AsFloat
1870
      else // Teneur digestible
1871
        if ConfdCompo = 0
1872
        then // g/kg
1873
          dMAT_C := PBdMAT_C.AsFloat / MAT * 100 / RapMS
1874
        else // %
1875
          dMAT_C := PBdMAT_C.AsFloat / MAT * 1000 / RapMS ;
1876
    // Mise ? jour des champs li?s ? cette valeur
1877
    Update := TRUE ;
1878
    CalculResidu ;
1879
    AffichResidu ;
1880
    CalculEnergie ;
1881
    AffichEnergie ;
1882
    Update := FALSE ;
1883
  end ;
1884
end ;
1885
1886
procedure TFMatiere.PBdMO_TChange (Sender : TObject) ;
1887
begin
1888
  if not Update
1889
  then
1890
  begin
1891
    Modified := TRUE ;
1892
    // Nouvelle valeur
1893
    with PMatiere.CC do
1894
      if ConfDig = 0
1895
      then // CUD
1896
        dMO_T := PBdMO_T.AsFloat
1897
      else // Teneur digestible
1898
        if ConfdCompo = 0
1899
        then // g/kg
1900
          dMO_T := PBdMO_T.AsFloat / MO * 100 / RapMS
1901
        else // %
1902
          dMO_T := PBdMO_T.AsFloat / MO * 1000 / RapMS ;
1903
    // Mise ? jour des champs li?s ? cette valeur
1904
    Update := TRUE ;
1905
    CalculResidu ;
1906
    AffichResidu ;
1907
    CalculEnergie ;
1908
    AffichEnergie ;
1909
    Update := FALSE ;
1910
  end ;
1911
end ;
1912
1913
procedure TFMatiere.PBdLip_TChange (Sender : TObject) ;
1914
begin
1915
  if not Update
1916
  then
1917
  begin
1918
    Modified := TRUE ;
1919
    // Nouvelle valeur
1920
    with PMatiere.CC do
1921
      if ConfDig = 0
1922
      then // CUD
1923
        dLip_T := PBdLip_T.AsFloat
1924
      else // Teneur digestible
1925
        if ConfdCompo = 0
1926
        then // g/kg
1927
          dLip_T := PBdLip_T.AsFloat / Lip * 100 / RapMS
1928
        else // %
1929
          dLip_T := PBdLip_T.AsFloat / Lip * 1000 / RapMS ;
1930
    // Mise ? jour des champs li?s ? cette valeur
1931
    Update := TRUE ;
1932
    CalculResidu ;
1933
    AffichResidu ;
1934
    CalculEnergie ;
1935
    AffichEnergie ;
1936
    Update := FALSE ;
1937
  end ;
1938
end ;
1939
1940
procedure TFMatiere.PBdMAT_TChange (Sender : TObject) ;
1941
begin
1942
  if not Update
1943
  then
1944
  begin
1945
    Modified := TRUE ;
1946
    // Nouvelle valeur
1947
    with PMatiere.CC do
1948
      if ConfDig = 0
1949
      then // CUD
1950
        dMAT_T := PBdMAT_T.AsFloat
1951
      else // Teneur digestible
1952
        if ConfdCompo = 0
1953
        then // g/kg
1954
          dMAT_T := PBdMAT_T.AsFloat / MAT * 100 / RapMS
1955
        else // %
1956
          dMAT_T := PBdMAT_T.AsFloat / MAT * 1000 / RapMS ;
1957
    // Mise ? jour des champs li?s ? cette valeur
1958
    Update := TRUE ;
1959
    CalculResidu ;
1960
    AffichResidu ;
1961
    CalculEnergie ;
1962
    AffichEnergie ;
1963
    Update := FALSE ;
1964
  end ;
1965
end ;
1966
1967
procedure TFMatiere.CBCorrCUDClick (Sender : TObject) ;
1968
begin
1969
  if AffCorrCUD
1970
  then
1971
  begin
1972
    FWarning := TFWarning.Create (Self) ;
1973
    with FWarning do
1974
    begin
1975
      Msg := 'CorrCUD';
1976
      ShowModal ;
1977
      Release ;
1978
      AffCorrCUD := FALSE ;
1979
    end ;
1980
  end ;
1981
  if not CBCorrCUD.Checked
1982
  then
1983
  begin
1984
    RBED.Checked := FALSE ;
1985
    RBEM.Checked := FALSE ;
1986
    RBEN.Checked := FALSE ;
1987
  end ;
1988
  RBED.Enabled := CBCorrCUD.Checked ;
1989
  RBEM.Enabled := CBCorrCUD.Checked ;
1990
  RBEN.Enabled := CBCorrCUD.Checked ;
1991
  Update := TRUE ;
1992
  RBEDClick (nil) ;
1993
  RBEMClick (nil) ;
1994
  RBENClick (nil) ;
1995
  Update := FALSE ;
1996
  PBdMO_C.Enabled := not CBCorrCUD.Checked ;
1997
  PBdLip_C.Enabled := not CBCorrCUD.Checked ;
1998
  PBdMAT_C.Enabled := not CBCorrCUD.Checked ;
1999
  PBdMO_T.Enabled := not CBCorrCUD.Checked ;
2000
  PBdLip_T.Enabled := not CBCorrCUD.Checked ;
2001
  PBdMAT_T.Enabled := not CBCorrCUD.Checked ;
2002
end ;
2003
2004
procedure TFMatiere.LCorrCUDClick (Sender : TObject) ;
2005
begin
2006
  if CBCorrCUD.Enabled
2007
  then
2008
    CBCorrCUD.Checked := not CBCorrCUD.Checked ;
2009
end ;
2010
2011
procedure TFMatiere.RBEDClick (Sender : TObject) ;
2012
begin
2013
  PBED_C.Enabled := RBED.Checked ;
2014
  PBED_T.Enabled := RBED.Checked ;
2015
  if not Update
2016
  then
2017
  begin
2018
    Update := TRUE ;
2019
    RBEMClick (nil) ;
2020
    RBENClick (nil) ;
2021
    Update := FALSE ;
2022
  end ;
2023
end ;
2024
2025
procedure TFMatiere.LEDClick (Sender : TObject) ;
2026
begin
2027
  if RBED.Enabled
2028
  then
2029
    RBED.Checked := TRUE ;
2030
end ;
2031
2032
procedure TFMatiere.PBED_CChange (Sender : TObject) ;
2033
begin
2034
  if (PBED_C.AsFloat <> 0) and not Update
2035
  then
2036
  begin
2037
    Modified := TRUE ;
2038
    // Nouvelle valeur
2039
    with PMatiere.CC do
2040
      ED_C := PBED_C.AsFloat / RapMS ;
2041
    // Mise ? jour des champs li?s ? cette valeur
2042
    Update := TRUE ;
2043
    CalculDigEDCrois ;
2044
    AffichdFecale ;
2045
    CalculEnergie ;
2046
    AffichEnergie ;
2047
    Update := FALSE ;
2048
  end ;
2049
end ;
2050
2051
procedure TFMatiere.PBED_CExit (Sender : TObject) ;
2052
begin
2053
  if (PBED_C.AsFloat = 0) and (PMatiere.CC.ED_C <> 0)
2054
  then
2055
  begin
2056
    Modified := TRUE ;
2057
    // Valeur nulle
2058
    with PMatiere.CC do
2059
      ED_C := 0 ;
2060
    // Mise ? jour des champs li?s ? cette valeur
2061
    Update := TRUE ;
2062
    CalculDigEDCrois ;
2063
    AffichdFecale ;
2064
    CalculEnergie ;
2065
    AffichEnergie ;
2066
    Update := FALSE ;
2067
  end ;
2068
end ;
2069
2070
procedure TFMatiere.CalculDigEDCrois ;
2071
var
2072
  x : double ;
2073
begin
2074
  with PMatiere.CC do
2075
  begin
2076
    x := (ED_C * 1000 - 17.45 * Amidon - 16.77 * Sucres) / (23.25 * MAT * dMAT_C / 100 + 38.73 * Lip * dLip_C / 100 + 16.68 * (Residu + CB) * dResidu_C / 100) ;
2077
    dLip_C := dLip_C * x ;
2078
    dMAT_C := dMAT_C * x ;
2079
    dResidu_C := dResidu_C * x ;
2080
    dCB_C := dCB_C * x ;
2081
    dMO_C := ((dMO_C * MO - Amidon * 100 - Sucres * 100) * x + Amidon * 100 + Sucres * 100) / MO ;
2082
  end ;
2083
end ;
2084
2085
procedure TFMatiere.PBED_TChange (Sender : TObject) ;
2086
begin
2087
  if (PBED_T.AsFloat <> 0) and not Update
2088
  then
2089
  begin
2090
    Modified := TRUE ;
2091
    // Nouvelle valeur
2092
    with PMatiere.CC do
2093
      ED_T := PBED_T.AsFloat / RapMS ;
2094
    // Mise ? jour des champs li?s ? cette valeur
2095
    Update := TRUE ;
2096
    CalculDigEDTruie ;
2097
    AffichdFecale ;
2098
    CalculEnergie ;
2099
    AffichEnergie ;
2100
    Update := FALSE ;
2101
  end ;
2102
end ;
2103
2104
procedure TFMatiere.PBED_TExit (Sender : TObject) ;
2105
begin
2106
  if (PBED_T.AsFloat = 0) and (PMatiere.CC.ED_T <> 0)
2107
  then
2108
  begin
2109
    Modified := TRUE ;
2110
    // Valeur nulle
2111
    with PMatiere.CC do
2112
      ED_T := 0 ;
2113
    // Mise ? jour des champs li?s ? cette valeur
2114
    Update := TRUE ;
2115
    CalculDigEDTruie ;
2116
    AffichdFecale ;
2117
    CalculEnergie ;
2118
    AffichEnergie ;
2119
    Update := FALSE ;
2120
  end ;
2121
end ;
2122
2123
procedure TFMatiere.CalculDigEDTruie ;
2124
var
2125
  x : double ;
2126
begin
2127
  with PMatiere.CC do
2128
  begin
2129
    x := (ED_T * 1000 - 17.45 * Amidon - 16.77 * Sucres) / (23.25 * MAT * dMAT_T / 100 + 38.73 * Lip * dLip_T / 100 + 16.68 * (Residu + CB) * dResidu_T / 100) ;
2130
    dLip_T := dLip_T * x ;
2131
    dMAT_T := dMAT_T * x ;
2132
    dResidu_T := dResidu_T * x ;
2133
    dCB_T := dCB_T * x ;
2134
    dMO_T := ((dMO_T * MO - Amidon * 100 - Sucres * 100) * x + Amidon * 100 + Sucres * 100) / MO ;
2135
  end ;
2136
end ;
2137
2138
procedure TFMatiere.RBEMClick (Sender : TObject) ;
2139
begin
2140
  PBEM_C.Enabled := RBEM.Checked ;
2141
  PBEM_T.Enabled := RBEM.Checked ;
2142
  if not Update
2143
  then
2144
  begin
2145
    Update := TRUE ;
2146
    RBEDClick (nil) ;
2147
    RBENClick (nil) ;
2148
    Update := FALSE ;
2149
  end ;
2150
end ;
2151
2152
procedure TFMatiere.LEMClick (Sender : TObject) ;
2153
begin
2154
  if RBEM.Enabled
2155
  then
2156
    RBEM.Checked := TRUE ;
2157
end ;
2158
2159
procedure TFMatiere.PBEM_CChange (Sender : TObject) ;
2160
begin
2161
  if (PBEM_C.AsFloat <> 0) and not Update
2162
  then
2163
  begin
2164
    Modified := TRUE ;
2165
    // Nouvelle valeur
2166
    with PMatiere.CC do
2167
      EM_C := PBEM_C.AsFloat / RapMS ;
2168
    // Mise ? jour des champs li?s ? cette valeur
2169
    Update := TRUE ;
2170
    CalculDigEMCrois ;
2171
    AffichdFecale ;
2172
    CalculEnergie ;
2173
    AffichEnergie ;
2174
    Update := FALSE ;
2175
  end ;
2176
end ;
2177
2178
procedure TFMatiere.PBEM_CExit (Sender : TObject) ;
2179
begin
2180
  if (PBEM_C.AsFloat = 0) and (PMatiere.CC.EM_C <> 0)
2181
  then
2182
  begin
2183
    Modified := TRUE ;
2184
    // Valeur nulle
2185
    with PMatiere.CC do
2186
      EM_C := 0 ;
2187
    // Mise ? jour des champs li?s ? cette valeur
2188
    Update := TRUE ;
2189
    CalculDigEMCrois ;
2190
    AffichdFecale ;
2191
    CalculEnergie ;
2192
    AffichEnergie ;
2193
    Update := FALSE ;
2194
  end ;
2195
end ;
2196
2197
procedure TFMatiere.CalculDigEMCrois ;
2198
var
2199
  x : double ;
2200
begin
2201
  with PMatiere.CC do
2202
  begin
2203
    x := (EM_C * 1000 - 17.45 * Amidon - 16.47 * Sucres) / (20.40 * MAT * dMAT_C / 100 + 39.28 * Lip * dLip_C / 100 + 15.45 * (Residu + CB) * dResidu_C / 100) ;
2204
    dLip_C := dLip_C * x ;
2205
    dMAT_C := dMAT_C * x ;
2206
    dResidu_C := dResidu_C * x ;
2207
    dCB_C := dCB_C * x ;
2208
    dMO_C := ((dMO_C * MO - Amidon * 100 - Sucres * 100) * x + Amidon * 100 + Sucres * 100) / MO ;
2209
  end ;
2210
end ;
2211
2212
procedure TFMatiere.PBEM_TChange (Sender : TObject) ;
2213
begin
2214
  if (PBEM_T.AsFloat <> 0) and not Update
2215
  then
2216
  begin
2217
    Modified := TRUE ;
2218
    // Nouvelle valeur
2219
    with PMatiere.CC do
2220
      EM_T := PBEM_T.AsFloat / RapMS ;
2221
    // Mise ? jour des champs li?s ? cette valeur
2222
    Update := TRUE ;
2223
    CalculDigEMTruie ;
2224
    AffichdFecale ;
2225
    CalculEnergie ;
2226
    AffichEnergie ;
2227
    Update := FALSE ;
2228
  end ;
2229
end ;
2230
2231
procedure TFMatiere.PBEM_TExit (Sender : TObject) ;
2232
begin
2233
  if (PBEM_T.AsFloat = 0) and (PMatiere.CC.EM_T <> 0)
2234
  then
2235
  begin
2236
    Modified := TRUE ;
2237
    // Valeur nulle
2238
    with PMatiere.CC do
2239
      EM_T := 0 ;
2240
    // Mise ? jour des champs li?s ? cette valeur
2241
    Update := TRUE ;
2242
    CalculDigEMTruie ;
2243
    AffichdFecale ;
2244
    CalculEnergie ;
2245
    AffichEnergie ;
2246
    Update := FALSE ;
2247
  end ;
2248
end ;
2249
2250
procedure TFMatiere.CalculDigEMTruie ;
2251
var
2252
  x : double ;
2253
begin
2254
  with PMatiere.CC do
2255
  begin
2256
    x := (EM_T * 1000 - 17.45 * Amidon - 16.47 * Sucres) / (20.40 * MAT * dMAT_T / 100 + 39.28 * Lip * dLip_T / 100 + 15.45 * (Residu + CB) * dResidu_T / 100) ;
2257
    dLip_T := dLip_T * x ;
2258
    dMAT_T := dMAT_T * x ;
2259
    dResidu_T := dResidu_T * x ;
2260
    dCB_T := dCB_T * x ;
2261
    dMO_T := ((dMO_T * MO - Amidon * 100 - Sucres * 100) * x + Amidon * 100 + Sucres * 100) / MO ;
2262
  end ;
2263
end ;
2264
2265
procedure TFMatiere.RBENClick (Sender : TObject) ;
2266
begin
2267
  PBEN_C.Enabled := RBEN.Checked ;
2268
  PBEN_T.Enabled := RBEN.Checked ;
2269
  if not Update
2270
  then
2271
  begin
2272
    Update := TRUE ;
2273
    RBEDClick (nil) ;
2274
    RBEMClick (nil) ;
2275
    Update := FALSE ;
2276
  end ;
2277
end ;
2278
2279
procedure TFMatiere.LENClick (Sender : TObject) ;
2280
begin
2281
  if RBEN.Enabled
2282
  then
2283
    RBEN.Checked := TRUE ;
2284
end ;
2285
2286
procedure TFMatiere.PBEN_CChange (Sender : TObject) ;
2287
begin
2288
  if (PBEN_C.AsFloat <> 0) and not Update
2289
  then
2290
  begin
2291
    Modified := TRUE ;
2292
    // Nouvelle valeur
2293
    with PMatiere.CC do
2294
      EN_C := PBEN_C.AsFloat / RapMS ;
2295
    // Mise ? jour des champs li?s ? cette valeur
2296
    Update := TRUE ;
2297
    CalculDigENCrois ;
2298
    AffichdFecale ;
2299
    CalculEnergie ;
2300
    AffichEnergie ;
2301
    Update := FALSE ;
2302
  end ;
2303
end ;
2304
2305
procedure TFMatiere.PBEN_CExit (Sender : TObject) ;
2306
begin
2307
  if (PBEN_C.AsFloat = 0) and (PMatiere.CC.EN_C <> 0)
2308
  then
2309
  begin
2310
    Modified := TRUE ;
2311
    // Valeur nulle
2312
    with PMatiere.CC do
2313
      EN_C := 0 ;
2314
    // Mise ? jour des champs li?s ? cette valeur
2315
    Update := TRUE ;
2316
    CalculDigENCrois ;
2317
    AffichdFecale ;
2318
    CalculEnergie ;
2319
    AffichEnergie ;
2320
    Update := FALSE ;
2321
  end ;
2322
end ;
2323
2324
procedure TFMatiere.CalculDigENCrois ;
2325
var
2326
  x : double ;
2327
begin
2328
  with PMatiere.CC do
2329
  begin
2330
    x := (EN_C * 1000 - 14.32 * Amidon - 11.94 * Sucres) / (12.08 * MAT * dMAT_C / 100 + 35.01 * Lip * dLip_C / 100 + 8.64 * (Residu + CB) * dResidu_C / 100) ;
2331
    dLip_C := dLip_C * x ;
2332
    dMAT_C := dMAT_C * x ;
2333
    dResidu_C := dResidu_C * x ;
2334
    dCB_C := dCB_C * x ;
2335
    dMO_C := ((dMO_C * MO - Amidon * 100 - Sucres * 100) * x + Amidon * 100 + Sucres * 100) / MO ;
2336
  end ;
2337
end ;
2338
2339
procedure TFMatiere.PBEN_TChange (Sender : TObject) ;
2340
begin
2341
  if (PBEN_T.AsFloat <> 0) and not Update
2342
  then
2343
  begin
2344
    Modified := TRUE ;
2345
    // Nouvelle valeur
2346
    with PMatiere.CC do
2347
      EN_T := PBEN_T.AsFloat / RapMS ;
2348
    // Mise ? jour des champs li?s ? cette valeur
2349
    Update := TRUE ;
2350
    CalculDigENTruie ;
2351
    AffichdFecale ;
2352
    CalculEnergie ;
2353
    AffichEnergie ;
2354
    Update := FALSE ;
2355
  end ;
2356
end ;
2357
2358
procedure TFMatiere.PBEN_TExit (Sender : TObject) ;
2359
begin
2360
  if (PBEN_T.AsFloat = 0) and (PMatiere.CC.EN_T <> 0)
2361
  then
2362
  begin
2363
    Modified := TRUE ;
2364
    // Valeur nulle
2365
    with PMatiere.CC do
2366
      EN_T := 0 ;
2367
    // Mise ? jour des champs li?s ? cette valeur
2368
    Update := TRUE ;
2369
    CalculDigENTruie ;
2370
    AffichdFecale ;
2371
    CalculEnergie ;
2372
    AffichEnergie ;
2373
    Update := FALSE ;
2374
  end ;
2375
end ;
2376
2377
procedure TFMatiere.CalculDigENTruie ;
2378
var
2379
  x : double ;
2380
begin
2381
  with PMatiere.CC do
2382
  begin
2383
    x := (EN_T * 1000 - 14.32 * Amidon - 11.94 * Sucres) / (12.08 * MAT * dMAT_T / 100 + 35.01 * Lip * dLip_T / 100 + 8.64 * (Residu + CB) * dResidu_T / 100) ;
2384
    dLip_T := dLip_T * x ;
2385
    dMAT_T := dMAT_T * x ;
2386
    dResidu_T := dResidu_T * x ;
2387
    dCB_T := dCB_T * x ;
2388
    dMO_T := ((dMO_T * MO - Amidon * 100 - Sucres * 100) * x + Amidon * 100 + Sucres * 100) / MO ;
2389
  end ;
2390
end ;
2391
2392
////////////////////////////////////////////////////////////////////////////////
2393
// Acides amin?s
2394
////////////////////////////////////////////////////////////////////////////////
2395
2396
// Affichage de la teneur en fonction de la configuration
2397
procedure TFMatiere.AffichTAA ;
2398
begin
2399
//  with PMatiere^ do
2400
//    AAtotal[0] := CC.MAT ;
2401
  case ConfTAA of
2402
    1 : // %
2403
      with PMatiere^ do
2404
      begin
2405
        PBTMAT2.AsFloat := AAtotal[0] / 1000 * 100 * RapMS ;
2406
        if ActiveControl <> PBTLys
2407
        then
2408
          PBTLys.AsFloat := AAtotal[1] / 1000 * 100 * RapMS ;
2409
        PBTMet.AsFloat := AAtotal[2] / 1000 * 100 * RapMS ;
2410
        PBTCys.AsFloat := AAtotal[3] / 1000 * 100 * RapMS ;
2411
        PBTTrp.AsFloat := AAtotal[4] / 1000 * 100 * RapMS ;
2412
        PBTThr.AsFloat := AAtotal[5] / 1000 * 100 * RapMS ;
2413
        PBTPhe.AsFloat := AAtotal[6] / 1000 * 100 * RapMS ;
2414
        PBTTyr.AsFloat := AAtotal[7] / 1000 * 100 * RapMS ;
2415
        PBTLeu.AsFloat := AAtotal[8] / 1000 * 100 * RapMS ;
2416
        PBTIle.AsFloat := AAtotal[9] / 1000 * 100 * RapMS ;
2417
        PBTVal.AsFloat := AAtotal[10] / 1000 * 100 * RapMS ;
2418
        PBTHis.AsFloat := AAtotal[11] / 1000 * 100 * RapMS ;
2419
        PBTArg.AsFloat := AAtotal[12] / 1000 * 100 * RapMS ;
2420
      end ;
2421
    2 : // % MAT
2422
      if PMatiere.CC.MAT = 0
2423
      then
2424
      begin
2425
        PBTMAT2.AsFloat := 0 ;
2426
        PBTLys.AsFloat := 0 ;
2427
        PBTMet.AsFloat := 0 ;
2428
        PBTCys.AsFloat := 0 ;
2429
        PBTTrp.AsFloat := 0 ;
2430
        PBTThr.AsFloat := 0 ;
2431
        PBTPhe.AsFloat := 0 ;
2432
        PBTTyr.AsFloat := 0 ;
2433
        PBTLeu.AsFloat := 0 ;
2434
        PBTIle.AsFloat := 0 ;
2435
        PBTVal.AsFloat := 0 ;
2436
        PBTHis.AsFloat := 0 ;
2437
        PBTArg.AsFloat := 0 ;
2438
      end
2439
      else
2440
        with PMatiere^ do
2441
        begin
2442
          PBTMAT2.AsFloat := AAtotal[0] / CC.MAT * 100 ;
2443
          if ActiveControl <> PBTLys
2444
          then
2445
            PBTLys.AsFloat := AAtotal[1] / CC.MAT * 100 ;
2446
          PBTMet.AsFloat := AAtotal[2] / CC.MAT * 100 ;
2447
          PBTCys.AsFloat := AAtotal[3] / CC.MAT * 100 ;
2448
          PBTTrp.AsFloat := AAtotal[4] / CC.MAT * 100 ;
2449
          PBTThr.AsFloat := AAtotal[5] / CC.MAT * 100 ;
2450
          PBTPhe.AsFloat := AAtotal[6] / CC.MAT * 100 ;
2451
          PBTTyr.AsFloat := AAtotal[7] / CC.MAT * 100 ;
2452
          PBTLeu.AsFloat := AAtotal[8] / CC.MAT * 100 ;
2453
          PBTIle.AsFloat := AAtotal[9] / CC.MAT * 100 ;
2454
          PBTVal.AsFloat := AAtotal[10] / CC.MAT * 100 ;
2455
          PBTHis.AsFloat := AAtotal[11] / CC.MAT * 100 ;
2456
          PBTArg.AsFloat := AAtotal[12] / CC.MAT * 100 ;
2457
        end ;
2458
    else // g/kg
2459
      with PMatiere^ do
2460
      begin
2461
        PBTMAT2.AsFloat := AAtotal[0] * RapMS ;
2462
        if ActiveControl <> PBTLys
2463
        then
2464
          PBTLys.AsFloat := AAtotal[1] * RapMS ;
2465
        PBTMet.AsFloat := AAtotal[2] * RapMS ;
2466
        PBTCys.AsFloat := AAtotal[3] * RapMS ;
2467
        PBTTrp.AsFloat := AAtotal[4] * RapMS ;
2468
        PBTThr.AsFloat := AAtotal[5] * RapMS ;
2469
        PBTPhe.AsFloat := AAtotal[6] * RapMS ;
2470
        PBTTyr.AsFloat := AAtotal[7] * RapMS ;
2471
        PBTLeu.AsFloat := AAtotal[8] * RapMS ;
2472
        PBTIle.AsFloat := AAtotal[9] * RapMS ;
2473
        PBTVal.AsFloat := AAtotal[10] * RapMS ;
2474
        PBTHis.AsFloat := AAtotal[11] * RapMS ;
2475
        PBTArg.AsFloat := AAtotal[12] * RapMS ;
2476
      end ;
2477
  end ;
2478
end ;
2479
2480
// Affichage de la digestibilit? il?ale en fonction de la configuration
2481
procedure TFMatiere.AffichdAA ;
2482
begin
2483
  if ConfDig = 0
2484
  then // CUD
2485
    with PMatiere^ do
2486
    begin
2487
      PBdMATStd.AsFloat := CUDAA[0] ;
2488
      PBdLysStd.AsFloat := CUDAA[1] ;
2489
      PBdMetStd.AsFloat := CUDAA[2] ;
2490
      PBdCysStd.AsFloat := CUDAA[3] ;
2491
      PBdTrpStd.AsFloat := CUDAA[4] ;
2492
      PBdThrStd.AsFloat := CUDAA[5] ;
2493
      PBdPheStd.AsFloat := CUDAA[6] ;
2494
      PBdTyrStd.AsFloat := CUDAA[7] ;
2495
      PBdLeuStd.AsFloat := CUDAA[8] ;
2496
      PBdIleStd.AsFloat := CUDAA[9] ;
2497
      PBdValStd.AsFloat := CUDAA[10] ;
2498
      PBdHisStd.AsFloat := CUDAA[11] ;
2499
      PBdArgStd.AsFloat := CUDAA[12] ;
2500
    end
2501
  else // Teneur digestible
2502
    if ConfdAA = 0
2503
    then // g/kg
2504
      with PMatiere^ do
2505
      begin
2506
        PBdMATStd.AsFloat := AAtotal[0] * CUDAA[0] / 100 * RapMS ;
2507
        PBdLysStd.AsFloat := AAtotal[1] * CUDAA[1] / 100 * RapMS ;
2508
        PBdMetStd.AsFloat := AAtotal[2] * CUDAA[2] / 100 * RapMS ;
2509
        PBdCysStd.AsFloat := AAtotal[3] * CUDAA[3] / 100 * RapMS ;
2510
        PBdTrpStd.AsFloat := AAtotal[4] * CUDAA[4] / 100 * RapMS ;
2511
        PBdThrStd.AsFloat := AAtotal[5] * CUDAA[5] / 100 * RapMS ;
2512
        PBdPheStd.AsFloat := AAtotal[6] * CUDAA[6] / 100 * RapMS ;
2513
        PBdTyrStd.AsFloat := AAtotal[7] * CUDAA[7] / 100 * RapMS ;
2514
        PBdLeuStd.AsFloat := AAtotal[8] * CUDAA[8] / 100 * RapMS ;
2515
        PBdIleStd.AsFloat := AAtotal[9] * CUDAA[9] / 100 * RapMS ;
2516
        PBdValStd.AsFloat := AAtotal[10] * CUDAA[10] / 100 * RapMS ;
2517
        PBdHisStd.AsFloat := AAtotal[11] * CUDAA[11] / 100 * RapMS ;
2518
        PBdArgStd.AsFloat := AAtotal[12] * CUDAA[12] / 100 * RapMS ;
2519
      end
2520
    else // %
2521
      with PMatiere^ do
2522
      begin
2523
        PBdMATStd.AsFloat := AAtotal[0] / 1000 * CUDAA[0] * RapMS ;
2524
        PBdLysStd.AsFloat := AAtotal[1] / 1000 * CUDAA[1] * RapMS ;
2525
        PBdMetStd.AsFloat := AAtotal[2] / 1000 * CUDAA[2] * RapMS ;
2526
        PBdCysStd.AsFloat := AAtotal[3] / 1000 * CUDAA[3] * RapMS ;
2527
        PBdTrpStd.AsFloat := AAtotal[4] / 1000 * CUDAA[4] * RapMS ;
2528
        PBdThrStd.AsFloat := AAtotal[5] / 1000 * CUDAA[5] * RapMS ;
2529
        PBdPheStd.AsFloat := AAtotal[6] / 1000 * CUDAA[6] * RapMS ;
2530
        PBdTyrStd.AsFloat := AAtotal[7] / 1000 * CUDAA[7] * RapMS ;
2531
        PBdLeuStd.AsFloat := AAtotal[8] / 1000 * CUDAA[8] * RapMS ;
2532
        PBdIleStd.AsFloat := AAtotal[9] / 1000 * CUDAA[9] * RapMS ;
2533
        PBdValStd.AsFloat := AAtotal[10] / 1000 * CUDAA[10] * RapMS ;
2534
        PBdHisStd.AsFloat := AAtotal[11] / 1000 * CUDAA[11] * RapMS ;
2535
        PBdArgStd.AsFloat := AAtotal[12] / 1000 * CUDAA[12] * RapMS ;
2536
      end ;
2537
end ;
2538
2539
procedure TFMatiere.CalculAA ;
2540
begin
2541
  // Digestibilit? apparente
2542
  if ConfDig = 0
2543
  then // CUD
2544
    with PMatiere^ do
2545
    begin
2546
      if AAtotal[0] = 0
2547
      then
2548
        PBdMATApp.Text := ''
2549
      else
2550
        PBdMATApp.AsFloat := CUDAA[0] - AAendogene[0] * 100 / AAtotal[0] ;
2551
      if AAtotal[1] = 0
2552
      then
2553
        PBdLysApp.Text := ''
2554
      else
2555
        PBdLysApp.AsFloat := CUDAA[1] - AAendogene[1] * 100 / AAtotal[1] ;
2556
      if AAtotal[2] = 0
2557
      then
2558
        PBdMetApp.Text := ''
2559
      else
2560
        PBdMetApp.AsFloat := CUDAA[2] - AAendogene[2] * 100 / AAtotal[2] ;
2561
      if AAtotal[3] = 0
2562
      then
2563
        PBdCysApp.Text := ''
2564
      else
2565
        PBdCysApp.AsFloat := CUDAA[3] - AAendogene[3] * 100 / AAtotal[3] ;
2566
      if AAtotal[4] = 0
2567
      then
2568
        PBdTrpApp.Text := ''
2569
      else
2570
        PBdTrpApp.AsFloat := CUDAA[4] - AAendogene[4] * 100 / AAtotal[4] ;
2571
      if AAtotal[5] = 0
2572
      then
2573
        PBdThrApp.Text := ''
2574
      else
2575
        PBdThrApp.AsFloat := CUDAA[5] - AAendogene[5] * 100 / AAtotal[5] ;
2576
      if AAtotal[6] = 0
2577
      then
2578
        PBdPheApp.Text := ''
2579
      else
2580
        PBdPheApp.AsFloat := CUDAA[6] - AAendogene[6] * 100 / AAtotal[6] ;
2581
      if AAtotal[7] = 0
2582
      then
2583
        PBdTyrApp.Text := ''
2584
      else
2585
        PBdTyrApp.AsFloat := CUDAA[7] - AAendogene[7] * 100 / AAtotal[7] ;
2586
      if AAtotal[8] = 0
2587
      then
2588
        PBdLeuApp.Text := ''
2589
      else
2590
        PBdLeuApp.AsFloat := CUDAA[8] - AAendogene[8] * 100 / AAtotal[8] ;
2591
      if AAtotal[9] = 0
2592
      then
2593
        PBdIleApp.Text := ''
2594
      else
2595
        PBdIleApp.AsFloat := CUDAA[9] - AAendogene[9] * 100 / AAtotal[9] ;
2596
      if AAtotal[10] = 0
2597
      then
2598
        PBdValApp.Text := ''
2599
      else
2600
        PBdValApp.AsFloat := CUDAA[10] - AAendogene[10] * 100 / AAtotal[10] ;
2601
      if AAtotal[11] = 0
2602
      then
2603
        PBdHisApp.Text := ''
2604
      else
2605
        PBdHisApp.AsFloat := CUDAA[11] - AAendogene[11] * 100 / AAtotal[11] ;
2606
      if AAtotal[12] = 0
2607
      then
2608
        PBdArgApp.Text := ''
2609
      else
2610
        PBdArgApp.AsFloat := CUDAA[12] - AAendogene[12] * 100 / AAtotal[12] ;
2611
    end
2612
  else // Teneur digestible
2613
    if ConfdAA = 0
2614
    then // g/kg
2615
      with PMatiere^ do
2616
      begin
2617
        PBdMATApp.AsFloat := (AAtotal[0] * CUDAA[0] / 100 - AAendogene[0]) * RapMS ;
2618
        PBdLysApp.AsFloat := (AAtotal[1] * CUDAA[1] / 100 - AAendogene[1]) * RapMS ;
2619
        PBdMetApp.AsFloat := (AAtotal[2] * CUDAA[2] / 100 - AAendogene[2]) * RapMS ;
2620
        PBdCysApp.AsFloat := (AAtotal[3] * CUDAA[3] / 100 - AAendogene[3]) * RapMS ;
2621
        PBdTrpApp.AsFloat := (AAtotal[4] * CUDAA[4] / 100 - AAendogene[4]) * RapMS ;
2622
        PBdThrApp.AsFloat := (AAtotal[5] * CUDAA[5] / 100 - AAendogene[5]) * RapMS ;
2623
        PBdPheApp.AsFloat := (AAtotal[6] * CUDAA[6] / 100 - AAendogene[6]) * RapMS ;
2624
        PBdTyrApp.AsFloat := (AAtotal[7] * CUDAA[7] / 100 - AAendogene[7]) * RapMS ;
2625
        PBdLeuApp.AsFloat := (AAtotal[8] * CUDAA[8] / 100 - AAendogene[8]) * RapMS ;
2626
        PBdIleApp.AsFloat := (AAtotal[9] * CUDAA[9] / 100 - AAendogene[9]) * RapMS ;
2627
        PBdValApp.AsFloat := (AAtotal[10] * CUDAA[10] / 100 - AAendogene[10]) * RapMS ;
2628
        PBdHisApp.AsFloat := (AAtotal[11] * CUDAA[11] / 100 - AAendogene[11]) * RapMS ;
2629
        PBdArgApp.AsFloat := (AAtotal[12] * CUDAA[12] / 100 - AAendogene[12]) * RapMS ;
2630
      end
2631
    else // %
2632
      with PMatiere^ do
2633
      begin
2634
        PBdMATApp.AsFloat := (AAtotal[0] / 1000 * CUDAA[0] - AAendogene[0] * 100 / 1000) * RapMS ;
2635
        PBdLysApp.AsFloat := (AAtotal[1] / 1000 * CUDAA[1] - AAendogene[1] * 100 / 1000) * RapMS ;
2636
        PBdMetApp.AsFloat := (AAtotal[2] / 1000 * CUDAA[2] - AAendogene[2] * 100 / 1000) * RapMS ;
2637
        PBdCysApp.AsFloat := (AAtotal[3] / 1000 * CUDAA[3] - AAendogene[3] * 100 / 1000) * RapMS ;
2638
        PBdTrpApp.AsFloat := (AAtotal[4] / 1000 * CUDAA[4] - AAendogene[4] * 100 / 1000) * RapMS ;
2639
        PBdThrApp.AsFloat := (AAtotal[5] / 1000 * CUDAA[5] - AAendogene[5] * 100 / 1000) * RapMS ;
2640
        PBdPheApp.AsFloat := (AAtotal[6] / 1000 * CUDAA[6] - AAendogene[6] * 100 / 1000) * RapMS ;
2641
        PBdTyrApp.AsFloat := (AAtotal[7] / 1000 * CUDAA[7] - AAendogene[7] * 100 / 1000) * RapMS ;
2642
        PBdLeuApp.AsFloat := (AAtotal[8] / 1000 * CUDAA[8] - AAendogene[8] * 100 / 1000) * RapMS ;
2643
        PBdIleApp.AsFloat := (AAtotal[9] / 1000 * CUDAA[9] - AAendogene[9] * 100 / 1000) * RapMS ;
2644
        PBdValApp.AsFloat := (AAtotal[10] / 1000 * CUDAA[10] - AAendogene[10] * 100 / 1000) * RapMS ;
2645
        PBdHisApp.AsFloat := (AAtotal[11] / 1000 * CUDAA[11] - AAendogene[11] * 100 / 1000) * RapMS ;
2646
        PBdArgApp.AsFloat := (AAtotal[12] / 1000 * CUDAA[12] - AAendogene[12] * 100 / 1000) * RapMS ;
2647
      end ;
2648
  // Prot?ine id?ale standardis?e
2649
  PBProtLysStd.AsFloat := 100 ;
2650
  if (PMatiere.AAtotal[1] = 0) or (PMatiere.CUDAA[1] = 0)
2651
  then
2652
  begin
2653
    PBProtMetStd.Text := '' ;
2654
    PBProtCysStd.Text := '' ;
2655
    PBProtTrpStd.Text := '' ;
2656
    PBProtThrStd.Text := '' ;
2657
    PBProtPheStd.Text := '' ;
2658
    PBProtTyrStd.Text := '' ;
2659
    PBProtLeuStd.Text := '' ;
2660
    PBProtIleStd.Text := '' ;
2661
    PBProtValStd.Text := '' ;
2662
    PBProtHisStd.Text := '' ;
2663
    PBProtArgStd.Text := '' ;
2664
  end
2665
  else
2666
    with PMatiere^ do
2667
    begin
2668
      PBProtMetStd.AsFloat := (AAtotal[2] * CUDAA[2]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2669
      PBProtCysStd.AsFloat := (AAtotal[3] * CUDAA[3]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2670
      PBProtTrpStd.AsFloat := (AAtotal[4] * CUDAA[4]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2671
      PBProtThrStd.AsFloat := (AAtotal[5] * CUDAA[5]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2672
      PBProtPheStd.AsFloat := (AAtotal[6] * CUDAA[6]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2673
      PBProtTyrStd.AsFloat := (AAtotal[7] * CUDAA[7]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2674
      PBProtLeuStd.AsFloat := (AAtotal[8] * CUDAA[8]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2675
      PBProtIleStd.AsFloat := (AAtotal[9] * CUDAA[9]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2676
      PBProtValStd.AsFloat := (AAtotal[10] * CUDAA[10]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2677
      PBProtHisStd.AsFloat := (AAtotal[11] * CUDAA[11]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2678
      PBProtArgStd.AsFloat := (AAtotal[12] * CUDAA[12]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2679
    end ;
2680
  // Prot?ine id?ale totale
2681
  PBProtLysTot.AsFloat := 100 ;
2682
  if (PMatiere.AAtotal[1] = 0) or (PMatiere.CUDAA[1] = 0)
2683
  then
2684
  begin
2685
    PBProtMetTot.Text := '' ;
2686
    PBProtCysTot.Text := '' ;
2687
    PBProtTrpTot.Text := '' ;
2688
    PBProtThrTot.Text := '' ;
2689
    PBProtPheTot.Text := '' ;
2690
    PBProtTyrTot.Text := '' ;
2691
    PBProtLeuTot.Text := '' ;
2692
    PBProtIleTot.Text := '' ;
2693
    PBProtValTot.Text := '' ;
2694
    PBProtHisTot.Text := '' ;
2695
    PBProtArgTot.Text := '' ;
2696
  end
2697
  else
2698
    with PMatiere^ do
2699
    begin
2700
      PBProtMetTot.AsFloat := AAtotal[2] / AAtotal[1] * 100 ;
2701
      PBProtCysTot.AsFloat := AAtotal[3] / AAtotal[1] * 100 ;
2702
      PBProtTrpTot.AsFloat := AAtotal[4] / AAtotal[1] * 100 ;
2703
      PBProtThrTot.AsFloat := AAtotal[5] / AAtotal[1] * 100 ;
2704
      PBProtPheTot.AsFloat := AAtotal[6] / AAtotal[1] * 100 ;
2705
      PBProtTyrTot.AsFloat := AAtotal[7] / AAtotal[1] * 100 ;
2706
      PBProtLeuTot.AsFloat := AAtotal[8] / AAtotal[1] * 100 ;
2707
      PBProtIleTot.AsFloat := AAtotal[9] / AAtotal[1] * 100 ;
2708
      PBProtValTot.AsFloat := AAtotal[10] / AAtotal[1] * 100 ;
2709
      PBProtHisTot.AsFloat := AAtotal[11] / AAtotal[1] * 100 ;
2710
      PBProtArgTot.AsFloat := AAtotal[12] / AAtotal[1] * 100 ;
2711
    end ;
2712
  // met + cys
2713
  PBTMetCys.AsFloat := PBTMet.AsFloat + PBTCys.AsFloat ;
2714
  if ConfDig = 0
2715
  then // CUD
2716
    if PBTMetCys.AsFloat = 0
2717
    then
2718
    begin
2719
      PBdMetCysStd.Text := '' ;
2720
      PBdMetCysApp.Text := '' ;
2721
    end
2722
    else
2723
    begin
2724
      PBdMetCysStd.AsFloat := (PBTMet.AsFloat * PBdMetStd.AsFloat + PBTCys.AsFloat * PBdCysStd.AsFloat) / PBTMetCys.AsFloat ;
2725
      PBdMetCysApp.AsFloat := (PBTMet.AsFloat * PBdMetApp.AsFloat + PBTCys.AsFloat * PBdCysApp.AsFloat) / PBTMetCys.AsFloat ;
2726
    end
2727
  else // Teneur digestible
2728
  begin
2729
    PBdMetCysStd.AsFloat := PBdMetStd.AsFloat + PBdCysStd.AsFloat ;
2730
    PBdMetCysApp.AsFloat := PBdMetApp.AsFloat + PBdCysApp.AsFloat ;
2731
  end ;
2732
  if (PMatiere.AAtotal[1] = 0) or (PMatiere.CUDAA[1] = 0)
2733
  then
2734
  begin
2735
    PBProtMetCysStd.Text := '' ;
2736
    PBProtMetCysTot.Text := '' ;
2737
  end
2738
  else
2739
  begin
2740
    PBProtMetCysStd.AsFloat := PBProtMetStd.AsFloat + PBProtCysStd.AsFloat ;
2741
    PBProtMetCysTot.AsFloat := PBProtMetTot.AsFloat + PBProtCysTot.AsFloat ;
2742
  end ;
2743
  // phe + tyr
2744
  PBTPheTyr.AsFloat := PBTPhe.AsFloat + PBTTyr.AsFloat ;
2745
  if ConfDig = 0
2746
  then // CUD
2747
    if PBTPheTyr.AsFloat = 0
2748
    then
2749
    begin
2750
      PBdPheTyrStd.Text := '' ;
2751
      PBdPheTyrApp.Text := '' ;
2752
    end
2753
    else
2754
    begin
2755
      PBdPheTyrStd.AsFloat := (PBTPhe.AsFloat * PBdPheStd.AsFloat + PBTTyr.AsFloat * PBdTyrStd.AsFloat) / PBTPheTyr.AsFloat ;
2756
      PBdPheTyrApp.AsFloat := (PBTPhe.AsFloat * PBdPheApp.AsFloat + PBTTyr.AsFloat * PBdTyrApp.AsFloat) / PBTPheTyr.AsFloat ;
2757
    end
2758
  else // Teneur digestible
2759
  begin
2760
    PBdPheTyrStd.AsFloat := PBdPheStd.AsFloat + PBdTyrStd.AsFloat ;
2761
    PBdPheTyrApp.AsFloat := PBdPheApp.AsFloat + PBdTyrApp.AsFloat ;
2762
  end ;
2763
  if (PMatiere.AAtotal[1] = 0) or (PMatiere.CUDAA[1] = 0)
2764
  then
2765
  begin
2766
    PBProtPheTyrStd.Text := '' ;
2767
    PBProtPheTyrTot.Text := '' ;
2768
  end
2769
  else
2770
  begin
2771
    PBProtPheTyrStd.AsFloat := PBProtPheStd.AsFloat + PBProtTyrStd.AsFloat ;
2772
    PBProtPheTyrTot.AsFloat := PBProtPheTot.AsFloat + PBProtTyrTot.AsFloat ;
2773
  end ;
2774
  // trp / AA neutres
2775
  with PMatiere^ do
2776
    if AAtotal[6] * CUDAA[6] + AAtotal[7] * CUDAA[7] + AAtotal[8] * CUDAA[8] + AAtotal[9] * CUDAA[9] + AAtotal[10] * CUDAA[10] = 0
2777
    then
2778
      PBTrpStd.Text := ''
2779
    else
2780
      PBTrpStd.AsFloat := AAtotal[4] * CUDAA[4] / (AAtotal[6] * CUDAA[6] + AAtotal[7] * CUDAA[7] + AAtotal[8] * CUDAA[8] + AAtotal[9] * CUDAA[9] + AAtotal[10] * CUDAA[10]) * 100 ;
2781
  with PMatiere^ do
2782
    if AAtotal[6] + AAtotal[7] + AAtotal[8] + AAtotal[9] + AAtotal[10] = 0
2783
    then
2784
      PBTrpTot.Text := ''
2785
    else
2786
      PBTrpTot.AsFloat := AAtotal[4] / (AAtotal[6] + AAtotal[7] + AAtotal[8] + AAtotal[9] + AAtotal[10]) * 100 ;
2787
  // EAA-N / N
2788
  if (PMatiere.AAtotal[0] = 0) or (PMatiere.CUDAA[0] = 0)
2789
  then
2790
    PBEAAStd.Text := ''
2791
  else
2792
    with PMatiere^ do
2793
      PBEAAStd.AsFloat := 14 * (2/146 * AAtotal[1] * CUDAA[1] + 1/149 * AAtotal[2] * CUDAA[2] + 1/121 * AAtotal[3] * CUDAA[3] + 1/119 * AAtotal[5] * CUDAA[5] + 2/204 * AAtotal[4] * CUDAA[4] + 1/131 * AAtotal[9] * CUDAA[9] + 1/131 * AAtotal[8] * CUDAA[8] + 1/117 * AAtotal[10] * CUDAA[10] + 1/165 * AAtotal[6] * CUDAA[6] + 1/181 * AAtotal[7] * CUDAA[7] + 3/155 * AAtotal[11] * CUDAA[11] + 4/174 * AAtotal[12] * CUDAA[12]) / (AAtotal[0] * CUDAA[0] / 6.25) * 100 ;
2794
  if PMatiere.AAtotal[0] = 0
2795
  then
2796
    PBEAATot.Text := ''
2797
  else
2798
    with PMatiere^ do
2799
      PBEAATot.AsFloat := 14 * (2/146 * AAtotal[1] + 1/149 * AAtotal[2] + 1/121 * AAtotal[3] + 1/119 * AAtotal[5] + 2/204 * AAtotal[4] + 1/131 * AAtotal[9] + 1/131 * AAtotal[8] + 1/117 * AAtotal[10] + 1/165 * AAtotal[6] + 1/181 * AAtotal[7] + 3/155 * AAtotal[11] + 4/174 * AAtotal[12]) / (AAtotal[0] / 6.25) * 100 ;
2800
end ;
2801
2802
procedure TFMatiere.CBAAsLysClick (Sender : TObject) ;
2803
begin
2804
  PBTMet.Enabled := not CBAAsLys.Checked ;
2805
  PBTCys.Enabled := not CBAAsLys.Checked ;
2806
  PBTTrp.Enabled := not CBAAsLys.Checked ;
2807
  PBTThr.Enabled := not CBAAsLys.Checked ;
2808
  PBTPhe.Enabled := not CBAAsLys.Checked ;
2809
  PBTTyr.Enabled := not CBAAsLys.Checked ;
2810
  PBTLeu.Enabled := not CBAAsLys.Checked ;
2811
  PBTIle.Enabled := not CBAAsLys.Checked ;
2812
  PBTVal.Enabled := not CBAAsLys.Checked ;
2813
  PBTHis.Enabled := not CBAAsLys.Checked ;
2814
  PBTArg.Enabled := not CBAAsLys.Checked ;
2815
end ;
2816
2817
procedure TFMatiere.PBTLysChange(Sender: TObject);
2818
var
2819
  i : integer ;
2820
  variation : double ;
2821
begin
2822
  if (PBTLys.AsFloat <> 0) and not Update
2823
  then
2824
  begin
2825
    Modified := TRUE ;
2826
    // Variation de la teneur en lysine
2827
    with PMatiere^ do
2828
      if AAtotal[1] = 0
2829
      then
2830
        variation := 1
2831
      else
2832
        case ConfTAA of
2833
          1 : // %
2834
            variation := PBTLys.AsFloat / 100 * 1000 / RapMS / AAtotal[1] ;
2835
          2 : // % MAT
2836
            variation := PBTLys.AsFloat * CC.MAT / 100 / AAtotal[1] ;
2837
          else // g/kg
2838
            variation := PBTLys.AsFloat / RapMS / AAtotal[1] ;
2839
        end ;
2840
    // Nouvelle valeur
2841
    with PMatiere^ do
2842
      case ConfTAA of
2843
        1 : // %
2844
          AAtotal[1] := PBTLys.AsFloat / 100 * 1000 / RapMS ;
2845
        2 : // % MAT
2846
          AAtotal[1] := PBTLys.AsFloat * CC.MAT / 100 ;
2847
        else // g/kg
2848
          AAtotal[1] := PBTLys.AsFloat / RapMS ;
2849
      end ;
2850
    Update := TRUE ;
2851
    if CBAAsLys.Checked
2852
    then
2853
    begin
2854
      // Variation des teneur en acides amin?s (r?gle de trois)
2855
      with PMatiere^ do
2856
        for i := 2 to 12 do
2857
          AAtotal[i] := AAtotal[i] * variation ;
2858
      // Affichage des valeurs
2859
      AffichTAA ;
2860
    end ;
2861
    if ConfDig = 1
2862
    then // Teneur digestible
2863
      AffichdAA ;
2864
    Update := FALSE ;
2865
    // Calcul des champs li?s ? cette valeur
2866
    CalculAA ;
2867
  end ;
2868
end;
2869
2870
procedure TFMatiere.PBTLysExit (Sender : TObject) ;
2871
var
2872
  i : integer ;
2873
begin
2874
  if (PBTLys.AsFloat = 0) and (PMatiere.AAtotal[1] <> 0)
2875
  then
2876
  begin
2877
    Modified := TRUE ;
2878
    // Valeur nulle
2879
    with PMatiere^ do
2880
      AAtotal[1] := 0 ;
2881
    Update := TRUE ;
2882
    if CBAAsLys.Checked
2883
    then
2884
    begin
2885
      // Variation des teneur en acides amin?s (r?gle de trois)
2886
      with PMatiere^ do
2887
        for i := 2 to 12 do
2888
          AAtotal[i] := 0 ;
2889
      // Affichage des valeurs
2890
      AffichTAA ;
2891
    end ;
2892
    if ConfDig = 1
2893
    then // Teneur digestible
2894
      AffichdAA ;
2895
    Update := FALSE ;
2896
    // Calcul des champs li?s ? cette valeur
2897
    CalculAA ;
2898
  end ;
2899
end ;
2900
2901
procedure TFMatiere.PBTMetChange(Sender: TObject);
2902
begin
2903
  if not Update
2904
  then
2905
  begin
2906
    Modified := TRUE ;
2907
    // Nouvelle valeur
2908
    with PMatiere^ do
2909
      case ConfTAA of
2910
        1 : // %
2911
          AAtotal[2] := PBTMet.AsFloat / 100 * 1000 / RapMS ;
2912
        2 : // % MAT
2913
          AAtotal[2] := PBTMet.AsFloat * CC.MAT / 100 ;
2914
        else // g/kg
2915
          AAtotal[2] := PBTMet.AsFloat / RapMS ;
2916
      end ;
2917
    Update := TRUE ;
2918
    if ConfDig = 1
2919
    then // Teneur digestible
2920
      AffichdAA ;
2921
    Update := FALSE ;
2922
    // Calcul des champs li?s ? cette valeur
2923
    CalculAA ;
2924
  end ;
2925
end;
2926
2927
procedure TFMatiere.PBTCysChange(Sender: TObject);
2928
begin
2929
  if not Update
2930
  then
2931
  begin
2932
    Modified := TRUE ;
2933
    // Nouvelle valeur
2934
    with PMatiere^ do
2935
      case ConfTAA of
2936
        1 : // %
2937
          AAtotal[3] := PBTCys.AsFloat / 100 * 1000 / RapMS ;
2938
        2 : // % MAT
2939
          AAtotal[3] := PBTCys.AsFloat * CC.MAT / 100 ;
2940
        else // g/kg
2941
          AAtotal[3] := PBTCys.AsFloat / RapMS ;
2942
      end ;
2943
    Update := TRUE ;
2944
    if ConfDig = 1
2945
    then // Teneur digestible
2946
      AffichdAA ;
2947
    Update := FALSE ;
2948
    // Calcul des champs li?s ? cette valeur
2949
    CalculAA ;
2950
  end ;
2951
end;
2952
2953
procedure TFMatiere.PBTTrpChange(Sender: TObject);
2954
begin
2955
  if not Update
2956
  then
2957
  begin
2958
    Modified := TRUE ;
2959
    // Nouvelle valeur
2960
    with PMatiere^ do
2961
      case ConfTAA of
2962
        1 : // %
2963
          AAtotal[4] := PBTTrp.AsFloat / 100 * 1000 / RapMS ;
2964
        2 : // % MAT
2965
          AAtotal[4] := PBTTrp.AsFloat * CC.MAT / 100 ;
2966
        else // g/kg
2967
          AAtotal[4] := PBTTrp.AsFloat / RapMS ;
2968
      end ;
2969
    Update := TRUE ;
2970
    if ConfDig = 1
2971
    then // Teneur digestible
2972
      AffichdAA ;
2973
    Update := FALSE ;
2974
    // Calcul des champs li?s ? cette valeur
2975
    CalculAA ;
2976
  end ;
2977
end;
2978
2979
procedure TFMatiere.PBTThrChange(Sender: TObject);
2980
begin
2981
  if not Update
2982
  then
2983
  begin
2984
    Modified := TRUE ;
2985
    // Nouvelle valeur
2986
    with PMatiere^ do
2987
      case ConfTAA of
2988
        1 : // %
2989
          AAtotal[5] := PBTThr.AsFloat / 100 * 1000 / RapMS ;
2990
        2 : // % MAT
2991
          AAtotal[5] := PBTThr.AsFloat * CC.MAT / 100 ;
2992
        else // g/kg
2993
          AAtotal[5] := PBTThr.AsFloat / RapMS ;
2994
      end ;
2995
    Update := TRUE ;
2996
    if ConfDig = 1
2997
    then // Teneur digestible
2998
      AffichdAA ;
2999
    Update := FALSE ;
3000
    // Calcul des champs li?s ? cette valeur
3001
    CalculAA ;
3002
  end ;
3003
end;
3004
3005
procedure TFMatiere.PBTPheChange(Sender: TObject);
3006
begin
3007
  if not Update
3008
  then
3009
  begin
3010
    Modified := TRUE ;
3011
    // Nouvelle valeur
3012
    with PMatiere^ do
3013
      case ConfTAA of
3014
        1 : // %
3015
          AAtotal[6] := PBTPhe.AsFloat / 100 * 1000 / RapMS ;
3016
        2 : // % MAT
3017
          AAtotal[6] := PBTPhe.AsFloat * CC.MAT / 100 ;
3018
        else // g/kg
3019
          AAtotal[6] := PBTPhe.AsFloat / RapMS ;
3020
      end ;
3021
    Update := TRUE ;
3022
    if ConfDig = 1
3023
    then // Teneur digestible
3024
      AffichdAA ;
3025
    Update := FALSE ;
3026
    // Calcul des champs li?s ? cette valeur
3027
    CalculAA ;
3028
  end ;
3029
end;
3030
3031
procedure TFMatiere.PBTTyrChange(Sender: TObject);
3032
begin
3033
  if not Update
3034
  then
3035
  begin
3036
    Modified := TRUE ;
3037
    // Nouvelle valeur
3038
    with PMatiere^ do
3039
      case ConfTAA of
3040
        1 : // %
3041
          AAtotal[7] := PBTTyr.AsFloat / 100 * 1000 / RapMS ;
3042
        2 : // % MAT
3043
          AAtotal[7] := PBTTyr.AsFloat * CC.MAT / 100 ;
3044
        else // g/kg
3045
          AAtotal[7] := PBTTyr.AsFloat / RapMS ;
3046
      end ;
3047
    Update := TRUE ;
3048
    if ConfDig = 1
3049
    then // Teneur digestible
3050
      AffichdAA ;
3051
    Update := FALSE ;
3052
    // Calcul des champs li?s ? cette valeur
3053
    CalculAA ;
3054
  end ;
3055
end;
3056
3057
procedure TFMatiere.PBTLeuChange(Sender: TObject);
3058
begin
3059
  if not Update
3060
  then
3061
  begin
3062
    Modified := TRUE ;
3063
    // Nouvelle valeur
3064
    with PMatiere^ do
3065
      case ConfTAA of
3066
        1 : // %
3067
          AAtotal[8] := PBTLeu.AsFloat / 100 * 1000 / RapMS ;
3068
        2 : // % MAT
3069
          AAtotal[8] := PBTLeu.AsFloat * CC.MAT / 100 ;
3070
        else // g/kg
3071
          AAtotal[8] := PBTLeu.AsFloat / RapMS ;
3072
      end ;
3073
    Update := TRUE ;
3074
    if ConfDig = 1
3075
    then // Teneur digestible
3076
      AffichdAA ;
3077
    Update := FALSE ;
3078
    // Calcul des champs li?s ? cette valeur
3079
    CalculAA ;
3080
  end ;
3081
end;
3082
3083
procedure TFMatiere.PBTIleChange(Sender: TObject);
3084
begin
3085
  if not Update
3086
  then
3087
  begin
3088
    Modified := TRUE ;
3089
    // Nouvelle valeur
3090
    with PMatiere^ do
3091
      case ConfTAA of
3092
        1 : // %
3093
          AAtotal[9] := PBTIle.AsFloat / 100 * 1000 / RapMS ;
3094
        2 : // % MAT
3095
          AAtotal[9] := PBTIle.AsFloat * CC.MAT / 100 ;
3096
        else // g/kg
3097
          AAtotal[9] := PBTIle.AsFloat / RapMS ;
3098
      end ;
3099
    Update := TRUE ;
3100
    if ConfDig = 1
3101
    then // Teneur digestible
3102
      AffichdAA ;
3103
    Update := FALSE ;
3104
    // Calcul des champs li?s ? cette valeur
3105
    CalculAA ;
3106
  end ;
3107
end;
3108
3109
procedure TFMatiere.PBTValChange(Sender: TObject);
3110
begin
3111
  if not Update
3112
  then
3113
  begin
3114
    Modified := TRUE ;
3115
    // Nouvelle valeur
3116
    with PMatiere^ do
3117
      case ConfTAA of
3118
        1 : // %
3119
          AAtotal[10] := PBTVal.AsFloat / 100 * 1000 / RapMS ;
3120
        2 : // % MAT
3121
          AAtotal[10] := PBTVal.AsFloat * CC.MAT / 100 ;
3122
        else // g/kg
3123
          AAtotal[10] := PBTVal.AsFloat / RapMS ;
3124
      end ;
3125
    Update := TRUE ;
3126
    if ConfDig = 1
3127
    then // Teneur digestible
3128
      AffichdAA ;
3129
    Update := FALSE ;
3130
    // Calcul des champs li?s ? cette valeur
3131
    CalculAA ;
3132
  end ;
3133
end;
3134
3135
procedure TFMatiere.PBTHisChange(Sender: TObject);
3136
begin
3137
  if not Update
3138
  then
3139
  begin
3140
    Modified := TRUE ;
3141
    // Nouvelle valeur
3142
    with PMatiere^ do
3143
      case ConfTAA of
3144
        1 : // %
3145
          AAtotal[11] := PBTHis.AsFloat / 100 * 1000 / RapMS ;
3146
        2 : // % MAT
3147
          AAtotal[11] := PBTHis.AsFloat * CC.MAT / 100 ;
3148
        else // g/kg
3149
          AAtotal[11] := PBTHis.AsFloat / RapMS ;
3150
      end ;
3151
    Update := TRUE ;
3152
    if ConfDig = 1
3153
    then // Teneur digestible
3154
      AffichdAA ;
3155
    Update := FALSE ;
3156
    // Calcul des champs li?s ? cette valeur
3157
    CalculAA ;
3158
  end ;
3159
end;
3160
3161
procedure TFMatiere.PBTArgChange(Sender: TObject);
3162
begin
3163
  if not Update
3164
  then
3165
  begin
3166
    Modified := TRUE ;
3167
    // Nouvelle valeur
3168
    with PMatiere^ do
3169
      case ConfTAA of
3170
        1 : // %
3171
          AAtotal[12] := PBTArg.AsFloat / 100 * 1000 / RapMS ;
3172
        2 : // % MAT
3173
          AAtotal[12] := PBTArg.AsFloat * CC.MAT / 100 ;
3174
        else // g/kg
3175
          AAtotal[12] := PBTArg.AsFloat / RapMS ;
3176
      end ;
3177
    Update := TRUE ;
3178
    if ConfDig = 1
3179
    then // Teneur digestible
3180
      AffichdAA ;
3181
    Update := FALSE ;
3182
    // Calcul des champs li?s ? cette valeur
3183
    CalculAA ;
3184
  end ;
3185
end;
3186
3187
procedure TFMatiere.PBdMATStdChange(Sender: TObject);
3188
begin
3189
  if not Update
3190
  then
3191
  begin
3192
    Modified := TRUE ;
3193
    // Nouvelle valeur
3194
    with PMatiere^ do
3195
      if ConfDig = 0
3196
      then // CUD
3197
        CUDAA[0] := PBdMATStd.AsFloat
3198
      else // Teneur digestible
3199
        if ConfdAA = 0
3200
        then // g/kg
3201
          CUDAA[0] := PBdMATStd.AsFloat / AATotal[0] * 100 / RapMS
3202
        else // %
3203
          CUDAA[0] := PBdMATStd.AsFloat / AATotal[0] * 1000 / RapMS ;
3204
    // Calcul des champs li?s ? cette valeur
3205
    CalculAA ;
3206
  end ;
3207
end;
3208
3209
procedure TFMatiere.PBdLysStdChange(Sender: TObject);
3210
begin
3211
  if not Update
3212
  then
3213
  begin
3214
    Modified := TRUE ;
3215
    // Nouvelle valeur
3216
    with PMatiere^ do
3217
      if ConfDig = 0
3218
      then // CUD
3219
        CUDAA[1] := PBdLysStd.AsFloat
3220
      else // Teneur digestible
3221
        if ConfdAA = 0
3222
        then // g/kg
3223
          CUDAA[1] := PBdLysStd.AsFloat / AATotal[1] * 100 / RapMS
3224
        else // %
3225
          CUDAA[1] := PBdLysStd.AsFloat / AATotal[1] * 1000 / RapMS ;
3226
    // Calcul des champs li?s ? cette valeur
3227
    CalculAA ;
3228
  end ;
3229
end;
3230
3231
procedure TFMatiere.PBdMetStdChange(Sender: TObject);
3232
begin
3233
  if not Update
3234
  then
3235
  begin
3236
    Modified := TRUE ;
3237
    // Nouvelle valeur
3238
    with PMatiere^ do
3239
      if ConfDig = 0
3240
      then // CUD
3241
        CUDAA[2] := PBdMetStd.AsFloat
3242
      else // Teneur digestible
3243
        if ConfdAA = 0
3244
        then // g/kg
3245
          CUDAA[2] := PBdMetStd.AsFloat / AATotal[2] * 100 / RapMS
3246
        else // %
3247
          CUDAA[2] := PBdMetStd.AsFloat / AATotal[2] * 1000 / RapMS ;
3248
    // Calcul des champs li?s ? cette valeur
3249
    CalculAA ;
3250
  end ;
3251
end;
3252
3253
procedure TFMatiere.PBdCysStdChange(Sender: TObject);
3254
begin
3255
  if not Update
3256
  then
3257
  begin
3258
    Modified := TRUE ;
3259
    // Nouvelle valeur
3260
    with PMatiere^ do
3261
      if ConfDig = 0
3262
      then // CUD
3263
        CUDAA[3] := PBdCysStd.AsFloat
3264
      else // Teneur digestible
3265
        if ConfdAA = 0
3266
        then // g/kg
3267
          CUDAA[3] := PBdCysStd.AsFloat / AATotal[3] * 100 / RapMS
3268
        else // %
3269
          CUDAA[3] := PBdCysStd.AsFloat / AATotal[3] * 1000 / RapMS ;
3270
    // Calcul des champs li?s ? cette valeur
3271
    CalculAA ;
3272
  end ;
3273
end;
3274
3275
procedure TFMatiere.PBdTrpStdChange(Sender: TObject);
3276
begin
3277
  if not Update
3278
  then
3279
  begin
3280
    Modified := TRUE ;
3281
    // Nouvelle valeur
3282
    with PMatiere^ do
3283
      if ConfDig = 0
3284
      then // CUD
3285
        CUDAA[4] := PBdTrpStd.AsFloat
3286
      else // Teneur digestible
3287
        if ConfdAA = 0
3288
        then // g/kg
3289
          CUDAA[4] := PBdTrpStd.AsFloat / AATotal[4] * 100 / RapMS
3290
        else // %
3291
          CUDAA[4] := PBdTrpStd.AsFloat / AATotal[4] * 1000 / RapMS ;
3292
    // Calcul des champs li?s ? cette valeur
3293
    CalculAA ;
3294
  end ;
3295
end;
3296
3297
procedure TFMatiere.PBdThrStdChange(Sender: TObject);
3298
begin
3299
  if not Update
3300
  then
3301
  begin
3302
    Modified := TRUE ;
3303
    // Nouvelle valeur
3304
    with PMatiere^ do
3305
      if ConfDig = 0
3306
      then // CUD
3307
        CUDAA[5] := PBdThrStd.AsFloat
3308
      else // Teneur digestible
3309
        if ConfdAA = 0
3310
        then // g/kg
3311
          CUDAA[5] := PBdThrStd.AsFloat / AATotal[5] * 100 / RapMS
3312
        else // %
3313
          CUDAA[5] := PBdThrStd.AsFloat / AATotal[5] * 1000 / RapMS ;
3314
    // Calcul des champs li?s ? cette valeur
3315
    CalculAA ;
3316
  end ;
3317
end;
3318
3319
procedure TFMatiere.PBdPheStdChange(Sender: TObject);
3320
begin
3321
  if not Update
3322
  then
3323
  begin
3324
    Modified := TRUE ;
3325
    // Nouvelle valeur
3326
    with PMatiere^ do
3327
      if ConfDig = 0
3328
      then // CUD
3329
        CUDAA[6] := PBdPheStd.AsFloat
3330
      else // Teneur digestible
3331
        if ConfdAA = 0
3332
        then // g/kg
3333
          CUDAA[6] := PBdPheStd.AsFloat / AATotal[6] * 100 / RapMS
3334
        else // %
3335
          CUDAA[6] := PBdPheStd.AsFloat / AATotal[6] * 1000 / RapMS ;
3336
    // Calcul des champs li?s ? cette valeur
3337
    CalculAA ;
3338
  end ;
3339
end;
3340
3341
procedure TFMatiere.PBdTyrStdChange(Sender: TObject);
3342
begin
3343
  if not Update
3344
  then
3345
  begin
3346
    Modified := TRUE ;
3347
    // Nouvelle valeur
3348
    with PMatiere^ do
3349
      if ConfDig = 0
3350
      then // CUD
3351
        CUDAA[7] := PBdTyrStd.AsFloat
3352
      else // Teneur digestible
3353
        if ConfdAA = 0
3354
        then // g/kg
3355
          CUDAA[7] := PBdTyrStd.AsFloat / AATotal[7] * 100 / RapMS
3356
        else // %
3357
          CUDAA[7] := PBdTyrStd.AsFloat / AATotal[7] * 1000 / RapMS ;
3358
    // Calcul des champs li?s ? cette valeur
3359
    CalculAA ;
3360
  end ;
3361
end;
3362
3363
procedure TFMatiere.PBdLeuStdChange(Sender: TObject);
3364
begin
3365
  if not Update
3366
  then
3367
  begin
3368
    Modified := TRUE ;
3369
    // Nouvelle valeur
3370
    with PMatiere^ do
3371
      if ConfDig = 0
3372
      then // CUD
3373
        CUDAA[8] := PBdLeuStd.AsFloat
3374
      else // Teneur digestible
3375
        if ConfdAA = 0
3376
        then // g/kg
3377
          CUDAA[8] := PBdLeuStd.AsFloat / AATotal[8] * 100 / RapMS
3378
        else // %
3379
          CUDAA[8] := PBdLeuStd.AsFloat / AATotal[8] * 1000 / RapMS ;
3380
    // Calcul des champs li?s ? cette valeur
3381
    CalculAA ;
3382
  end ;
3383
end;
3384
3385
procedure TFMatiere.PBdIleStdChange(Sender: TObject);
3386
begin
3387
  if not Update
3388
  then
3389
  begin
3390
    Modified := TRUE ;
3391
    // Nouvelle valeur
3392
    with PMatiere^ do
3393
      if ConfDig = 0
3394
      then // CUD
3395
        CUDAA[9] := PBdIleStd.AsFloat
3396
      else // Teneur digestible
3397
        if ConfdAA = 0
3398
        then // g/kg
3399
          CUDAA[9] := PBdIleStd.AsFloat / AATotal[9] * 100 / RapMS
3400
        else // %
3401
          CUDAA[9] := PBdIleStd.AsFloat / AATotal[9] * 1000 / RapMS ;
3402
    // Calcul des champs li?s ? cette valeur
3403
    CalculAA ;
3404
  end ;
3405
end;
3406
3407
procedure TFMatiere.PBdValStdChange(Sender: TObject);
3408
begin
3409
  if not Update
3410
  then
3411
  begin
3412
    Modified := TRUE ;
3413
    // Nouvelle valeur
3414
    with PMatiere^ do
3415
      if ConfDig = 0
3416
      then // CUD
3417
        CUDAA[10] := PBdValStd.AsFloat
3418
      else // Teneur digestible
3419
        if ConfdAA = 0
3420
        then // g/kg
3421
          CUDAA[10] := PBdValStd.AsFloat / AATotal[10] * 100 / RapMS
3422
        else // %
3423
          CUDAA[10] := PBdValStd.AsFloat / AATotal[10] * 1000 / RapMS ;
3424
    // Calcul des champs li?s ? cette valeur
3425
    CalculAA ;
3426
  end ;
3427
end;
3428
3429
procedure TFMatiere.PBdHisStdChange(Sender: TObject);
3430
begin
3431
  if not Update
3432
  then
3433
  begin
3434
    Modified := TRUE ;
3435
    // Nouvelle valeur
3436
    with PMatiere^ do
3437
      if ConfDig = 0
3438
      then // CUD
3439
        CUDAA[11] := PBdHisStd.AsFloat
3440
      else // Teneur digestible
3441
        if ConfdAA = 0
3442
        then // g/kg
3443
          CUDAA[11] := PBdHisStd.AsFloat / AATotal[11] * 100 / RapMS
3444
        else // %
3445
          CUDAA[11] := PBdHisStd.AsFloat / AATotal[11] * 1000 / RapMS ;
3446
    // Calcul des champs li?s ? cette valeur
3447
    CalculAA ;
3448
  end ;
3449
end;
3450
3451
procedure TFMatiere.PBdArgStdChange(Sender: TObject);
3452
begin
3453
  if not Update
3454
  then
3455
  begin
3456
    Modified := TRUE ;
3457
    // Nouvelle valeur
3458
    with PMatiere^ do
3459
      if ConfDig = 0
3460
      then // CUD
3461
        CUDAA[12] := PBdArgStd.AsFloat
3462
      else // Teneur digestible
3463
        if ConfdAA = 0
3464
        then // g/kg
3465
          CUDAA[12] := PBdArgStd.AsFloat / AATotal[12] * 100 / RapMS
3466
        else // %
3467
          CUDAA[12] := PBdArgStd.AsFloat / AATotal[12] * 1000 / RapMS ;
3468
    // Calcul des champs li?s ? cette valeur
3469
    CalculAA ;
3470
  end ;
3471
end;
3472
3473
////////////////////////////////////////////////////////////////////////////////
3474
// Acides gras
3475
////////////////////////////////////////////////////////////////////////////////
3476
3477
// Affichage de la teneur en fonction de la configuration
3478
procedure TFMatiere.AffichTAG ;
3479
begin
3480
  case ConfTAG of
3481
    0 : // g/kg
3482
      with PMatiere.CC do
3483
      begin
3484
        PBC6C8C10_0.AsFloat := C6C8C10 / 100 * AGsLip / 100 * Lip * RapMS ;
3485
        PBC12_0.AsFloat := C12_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3486
        PBC14_0.AsFloat := C14_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3487
        PBC16_0.AsFloat := C16_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3488
        PBC16_1.AsFloat := C16_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3489
        PBC18_0.AsFloat := C18_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3490
        PBC18_1.AsFloat := C18_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3491
        PBC18_2.AsFloat := C18_2 / 100 * AGsLip / 100 * Lip * RapMS ;
3492
        PBC18_3.AsFloat := C18_3 / 100 * AGsLip / 100 * Lip * RapMS ;
3493
        PBC18_4.AsFloat := C18_4 / 100 * AGsLip / 100 * Lip * RapMS ;
3494
        PBC20_0.AsFloat := C20_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3495
        PBC20_1.AsFloat := C20_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3496
        PBC20_4.AsFloat := C20_4 / 100 * AGsLip / 100 * Lip * RapMS ;
3497
        PBC20_5.AsFloat := C20_5 / 100 * AGsLip / 100 * Lip * RapMS ;
3498
        PBC22_0.AsFloat := C22_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3499
        PBC22_1.AsFloat := C22_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3500
        PBC22_5.AsFloat := C22_5 / 100 * AGsLip / 100 * Lip * RapMS ;
3501
        PBC22_6.AsFloat := C22_6 / 100 * AGsLip / 100 * Lip * RapMS ;
3502
        PBC24_0.AsFloat := C24_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3503
      end ;
3504
    1 : // %
3505
      with PMatiere.CC do
3506
      begin
3507
        PBC6C8C10_0.AsFloat := C6C8C10 * AGsLip / 100 * Lip / 1000 * RapMS ;
3508
        PBC12_0.AsFloat := C12_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3509
        PBC14_0.AsFloat := C14_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3510
        PBC16_0.AsFloat := C16_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3511
        PBC16_1.AsFloat := C16_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3512
        PBC18_0.AsFloat := C18_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3513
        PBC18_1.AsFloat := C18_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3514
        PBC18_2.AsFloat := C18_2 * AGsLip / 100 * Lip / 1000 * RapMS ;
3515
        PBC18_3.AsFloat := C18_3 * AGsLip / 100 * Lip / 1000 * RapMS ;
3516
        PBC18_4.AsFloat := C18_4 * AGsLip / 100 * Lip / 1000 * RapMS ;
3517
        PBC20_0.AsFloat := C20_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3518
        PBC20_1.AsFloat := C20_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3519
        PBC20_4.AsFloat := C20_4 * AGsLip / 100 * Lip / 1000 * RapMS ;
3520
        PBC20_5.AsFloat := C20_5 * AGsLip / 100 * Lip / 1000 * RapMS ;
3521
        PBC22_0.AsFloat := C22_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3522
        PBC22_1.AsFloat := C22_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3523
        PBC22_5.AsFloat := C22_5 * AGsLip / 100 * Lip / 1000 * RapMS ;
3524
        PBC22_6.AsFloat := C22_6 * AGsLip / 100 * Lip / 1000 * RapMS ;
3525
        PBC24_0.AsFloat := C24_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3526
      end ;
3527
    else // % acides gras
3528
      with PMatiere.CC do
3529
      begin
3530
        PBC6C8C10_0.AsFloat := C6C8C10 ;
3531
        PBC12_0.AsFloat := C12_0 ;
3532
        PBC14_0.AsFloat := C14_0 ;
3533
        PBC16_0.AsFloat := C16_0 ;
3534
        PBC16_1.AsFloat := C16_1 ;
3535
        PBC18_0.AsFloat := C18_0 ;
3536
        PBC18_1.AsFloat := C18_1 ;
3537
        PBC18_2.AsFloat := C18_2 ;
3538
        PBC18_3.AsFloat := C18_3 ;
3539
        PBC18_4.AsFloat := C18_4 ;
3540
        PBC20_0.AsFloat := C20_0 ;
3541
        PBC20_1.AsFloat := C20_1 ;
3542
        PBC20_4.AsFloat := C20_4 ;
3543
        PBC20_5.AsFloat := C20_5 ;
3544
        PBC22_0.AsFloat := C22_0 ;
3545
        PBC22_1.AsFloat := C22_1 ;
3546
        PBC22_5.AsFloat := C22_5 ;
3547
        PBC22_6.AsFloat := C22_6 ;
3548
        PBC24_0.AsFloat := C24_0 ;
3549
      end ;
3550
  end ;
3551
end ;
3552
3553
procedure TFMatiere.CalculAG ;
3554
var
3555
  Omega3, Omega6 : double ;
3556
begin
3557
  // Teneurs totales
3558
  PBC6C8C10_tot.AsFloat := PBC6C8C10_0.AsFloat ;
3559
  PBC12_tot.AsFloat := PBC12_0.AsFloat ;
3560
  PBC14_tot.AsFloat := PBC14_0.AsFloat ;
3561
  PBC16_tot.AsFloat := PBC16_0.AsFloat + PBC16_1.AsFloat ;
3562
  PBC18_tot.AsFloat := PBC18_0.AsFloat + PBC18_1.AsFloat + PBC18_2.AsFloat + PBC18_3.AsFloat + PBC18_4.AsFloat ;
3563
  PBC20_tot.AsFloat := PBC20_0.AsFloat + PBC20_1.AsFloat + PBC20_4.AsFloat + PBC20_5.AsFloat ;
3564
  PBC22_tot.AsFloat := PBC22_0.AsFloat + PBC22_1.AsFloat + PBC22_5.AsFloat + PBC22_6.AsFloat ;
3565
  PBC24_tot.AsFloat := PBC24_0.AsFloat ;
3566
  PBCtot_tot.AsFloat := PBC6C8C10_tot.AsFloat + PBC12_tot.AsFloat + PBC14_tot.AsFloat + PBC16_tot.AsFloat + PBC18_tot.AsFloat + PBC20_tot.AsFloat + PBC22_tot.AsFloat + PBC24_tot.AsFloat ;
3567
  PBCtot_0.AsFloat := PBC6C8C10_0.AsFloat + PBC12_0.AsFloat + PBC14_0.AsFloat + PBC16_0.AsFloat + PBC18_0.AsFloat + PBC20_0.AsFloat + PBC22_0.AsFloat + PBC24_0.AsFloat ;
3568
  PBCtot_1.AsFloat := PBC16_1.AsFloat + PBC18_1.AsFloat + PBC20_1.AsFloat + PBC22_1.AsFloat ;
3569
  PBCtot_2.AsFloat := PBC18_2.AsFloat ;
3570
  PBCtot_3.AsFloat := PBC18_3.AsFloat ;
3571
  PBCtot_4.AsFloat := PBC18_4.AsFloat + PBC20_4.AsFloat ;
3572
  PBCtot_5.AsFloat := PBC20_5.AsFloat + PBC22_5.AsFloat ;
3573
  PBCtot_6.AsFloat := PBC22_6.AsFloat ;
3574
  // Acides gras satur?s
3575
  if PBCtot_tot.AsFloat = 0
3576
  then
3577
    PBSatur.Text := ''
3578
  else
3579
    PBSatur.AsFloat := PBCtot_0.AsFloat / PBCtot_tot.AsFloat * 100 ;
3580
  // Acides gras mono-insatur?s
3581
  if PBCtot_tot.AsFloat = 0
3582
  then
3583
    PBMono.Text := ''
3584
  else
3585
    PBMono.AsFloat := PBCtot_1.AsFloat / PBCtot_tot.AsFloat * 100 ;
3586
  // Acides gras poly-insatur?s
3587
  PBPoly.AsFloat := 100 - (PBSatur.AsFloat + PBMono.AsFloat) ;
3588
  // Omega-6 / Omega-3
3589
  Omega3 := PBC18_3.AsFloat + PBC18_4.AsFloat + PBC20_5.AsFloat + PBC22_5.AsFloat + PBC22_6.AsFloat ;
3590
  Omega6 := PBC18_2.AsFloat + PBC20_4.AsFloat ;
3591
  if Omega3 = 0
3592
  then
3593
    PBO6sO3.Text := 'infini'
3594
  else
3595
    PBO6sO3.AsFloat := Omega6 / Omega3 ;
3596
end ;
3597
3598
procedure TFMatiere.PBAGChange (Sender : TObject) ;
3599
begin
3600
  if not Update
3601
  then
3602
  begin
3603
    Modified := TRUE ;
3604
    // Nouvelle valeur
3605
    PMatiere.CC.AGsLip := PBAG.AsFloat ;
3606
    Update := TRUE ;
3607
    // R?affichage des teneurs en acides gras (si besoin)
3608
    case ConfTAG of
3609
      0 : // g/kg
3610
        with PMatiere.CC do
3611
        begin
3612
          PBC6C8C10_0.AsFloat := C6C8C10 / 100 * AGsLip / 100 * Lip * RapMS ;
3613
          PBC12_0.AsFloat := C12_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3614
          PBC14_0.AsFloat := C14_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3615
          PBC16_0.AsFloat := C16_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3616
          PBC16_1.AsFloat := C16_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3617
          PBC18_0.AsFloat := C18_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3618
          PBC18_1.AsFloat := C18_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3619
          PBC18_2.AsFloat := C18_2 / 100 * AGsLip / 100 * Lip * RapMS ;
3620
          PBC18_3.AsFloat := C18_3 / 100 * AGsLip / 100 * Lip * RapMS ;
3621
          PBC18_4.AsFloat := C18_4 / 100 * AGsLip / 100 * Lip * RapMS ;
3622
          PBC20_0.AsFloat := C20_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3623
          PBC20_1.AsFloat := C20_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3624
          PBC20_4.AsFloat := C20_4 / 100 * AGsLip / 100 * Lip * RapMS ;
3625
          PBC20_5.AsFloat := C20_5 / 100 * AGsLip / 100 * Lip * RapMS ;
3626
          PBC22_0.AsFloat := C22_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3627
          PBC22_1.AsFloat := C22_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3628
          PBC22_5.AsFloat := C22_5 / 100 * AGsLip / 100 * Lip * RapMS ;
3629
          PBC22_6.AsFloat := C22_6 / 100 * AGsLip / 100 * Lip * RapMS ;
3630
          PBC24_0.AsFloat := C24_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3631
        end ;
3632
      1 : // %
3633
        with PMatiere.CC do
3634
        begin
3635
          PBC6C8C10_0.AsFloat := C6C8C10 * AGsLip / 100 * Lip / 1000 * RapMS ;
3636
          PBC12_0.AsFloat := C12_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3637
          PBC14_0.AsFloat := C14_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3638
          PBC16_0.AsFloat := C16_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3639
          PBC16_1.AsFloat := C16_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3640
          PBC18_0.AsFloat := C18_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3641
          PBC18_1.AsFloat := C18_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3642
          PBC18_2.AsFloat := C18_2 * AGsLip / 100 * Lip / 1000 * RapMS ;
3643
          PBC18_3.AsFloat := C18_3 * AGsLip / 100 * Lip / 1000 * RapMS ;
3644
          PBC18_4.AsFloat := C18_4 * AGsLip / 100 * Lip / 1000 * RapMS ;
3645
          PBC20_0.AsFloat := C20_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3646
          PBC20_1.AsFloat := C20_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3647
          PBC20_4.AsFloat := C20_4 * AGsLip / 100 * Lip / 1000 * RapMS ;
3648
          PBC20_5.AsFloat := C20_5 * AGsLip / 100 * Lip / 1000 * RapMS ;
3649
          PBC22_0.AsFloat := C22_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3650
          PBC22_1.AsFloat := C22_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3651
          PBC22_5.AsFloat := C22_5 * AGsLip / 100 * Lip / 1000 * RapMS ;
3652
          PBC22_6.AsFloat := C22_6 * AGsLip / 100 * Lip / 1000 * RapMS ;
3653
          PBC24_0.AsFloat := C24_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3654
        end ;
3655
    end ;
3656
    Update := FALSE ;
3657
    // Calcul des champs li?s ? cette valeur
3658
    CalculAG ;
3659
  end ;
3660
end ;
3661
3662
procedure TFMatiere.PBC6C8C10_0Change (Sender : TObject) ;
3663
begin
3664
  if not Update
3665
  then
3666
  begin
3667
    Modified := TRUE ;
3668
    // Nouvelle valeur
3669
    with PMatiere.CC do
3670
      case ConfTAG of
3671
        0 : // g/kg
3672
          if (AGsLip = 0) or (Lip = 0)
3673
          then
3674
            C6C8C10 := 0
3675
          else
3676
            C6C8C10 := PBC6C8C10_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3677
        1 : // %
3678
          if (AGsLip = 0) or (Lip = 0)
3679
          then
3680
            C6C8C10 := 0
3681
          else
3682
            C6C8C10 := PBC6C8C10_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3683
        else // % acides gras
3684
          C6C8C10 := PBC6C8C10_0.AsFloat ;
3685
      end ;
3686
    // Calcul des champs li?s ? cette valeur
3687
    CalculAG ;
3688
  end ;
3689
end ;
3690
3691
procedure TFMatiere.PBC12_0Change (Sender : TObject) ;
3692
begin
3693
  if not Update
3694
  then
3695
  begin
3696
    Modified := TRUE ;
3697
    // Nouvelle valeur
3698
    with PMatiere.CC do
3699
      case ConfTAG of
3700
        0 : // g/kg
3701
          if (AGsLip = 0) or (Lip = 0)
3702
          then
3703
            C12_0 := 0
3704
          else
3705
            C12_0 := PBC12_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3706
        1 : // %
3707
          if (AGsLip = 0) or (Lip = 0)
3708
          then
3709
            C12_0 := 0
3710
          else
3711
            C12_0 := PBC12_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3712
        else // % acides gras
3713
          C12_0 := PBC12_0.AsFloat ;
3714
      end ;
3715
    // Calcul des champs li?s ? cette valeur
3716
    CalculAG ;
3717
  end ;
3718
end ;
3719
3720
procedure TFMatiere.PBC14_0Change (Sender : TObject) ;
3721
begin
3722
  if not Update
3723
  then
3724
  begin
3725
    Modified := TRUE ;
3726
    // Nouvelle valeur
3727
    with PMatiere.CC do
3728
      case ConfTAG of
3729
        0 : // g/kg
3730
          if (AGsLip = 0) or (Lip = 0)
3731
          then
3732
            C14_0 := 0
3733
          else
3734
            C14_0 := PBC14_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3735
        1 : // %
3736
          if (AGsLip = 0) or (Lip = 0)
3737
          then
3738
            C14_0 := 0
3739
          else
3740
            C14_0 := PBC14_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3741
        else // % acides gras
3742
          C14_0 := PBC14_0.AsFloat ;
3743
      end ;
3744
    // Calcul des champs li?s ? cette valeur
3745
    CalculAG ;
3746
  end ;
3747
end ;
3748
3749
procedure TFMatiere.PBC16_0Change (Sender : TObject) ;
3750
begin
3751
  if not Update
3752
  then
3753
  begin
3754
    Modified := TRUE ;
3755
    // Nouvelle valeur
3756
    with PMatiere.CC do
3757
      case ConfTAG of
3758
        0 : // g/kg
3759
          if (AGsLip = 0) or (Lip = 0)
3760
          then
3761
            C16_0 := 0
3762
          else
3763
            C16_0 := PBC16_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3764
        1 : // %
3765
          if (AGsLip = 0) or (Lip = 0)
3766
          then
3767
            C16_0 := 0
3768
          else
3769
            C16_0 := PBC16_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3770
        else // % acides gras
3771
          C16_0 := PBC16_0.AsFloat ;
3772
      end ;
3773
    // Calcul des champs li?s ? cette valeur
3774
    CalculAG ;
3775
  end ;
3776
end ;
3777
3778
procedure TFMatiere.PBC16_1Change (Sender : TObject) ;
3779
begin
3780
  if not Update
3781
  then
3782
  begin
3783
    Modified := TRUE ;
3784
    // Nouvelle valeur
3785
    with PMatiere.CC do
3786
      case ConfTAG of
3787
        0 : // g/kg
3788
          if (AGsLip = 0) or (Lip = 0)
3789
          then
3790
            C16_1 := 0
3791
          else
3792
            C16_1 := PBC16_1.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3793
        1 : // %
3794
          if (AGsLip = 0) or (Lip = 0)
3795
          then
3796
            C16_1 := 0
3797
          else
3798
            C16_1 := PBC16_1.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3799
        else // % acides gras
3800
          C16_1 := PBC16_1.AsFloat ;
3801
      end ;
3802
    // Calcul des champs li?s ? cette valeur
3803
    CalculAG ;
3804
  end ;
3805
end ;
3806
3807
procedure TFMatiere.PBC18_0Change (Sender : TObject) ;
3808
begin
3809
  if not Update
3810
  then
3811
  begin
3812
    Modified := TRUE ;
3813
    // Nouvelle valeur
3814
    with PMatiere.CC do
3815
      case ConfTAG of
3816
        0 : // g/kg
3817
          if (AGsLip = 0) or (Lip = 0)
3818
          then
3819
            C18_0 := 0
3820
          else
3821
            C18_0 := PBC18_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3822
        1 : // %
3823
          if (AGsLip = 0) or (Lip = 0)
3824
          then
3825
            C18_0 := 0
3826
          else
3827
            C18_0 := PBC18_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3828
        else // % acides gras
3829
          C18_0 := PBC18_0.AsFloat ;
3830
      end ;
3831
    // Calcul des champs li?s ? cette valeur
3832
    CalculAG ;
3833
  end ;
3834
end ;
3835
3836
procedure TFMatiere.PBC18_1Change (Sender : TObject) ;
3837
begin
3838
  if not Update
3839
  then
3840
  begin
3841
    Modified := TRUE ;
3842
    // Nouvelle valeur
3843
    with PMatiere.CC do
3844
      case ConfTAG of
3845
        0 : // g/kg
3846
          if (AGsLip = 0) or (Lip = 0)
3847
          then
3848
            C18_1 := 0
3849
          else
3850
            C18_1 := PBC18_1.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3851
        1 : // %
3852
          if (AGsLip = 0) or (Lip = 0)
3853
          then
3854
            C18_1 := 0
3855
          else
3856
            C18_1 := PBC18_1.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3857
        else // % acides gras
3858
          C18_1 := PBC18_1.AsFloat ;
3859
      end ;
3860
    // Calcul des champs li?s ? cette valeur
3861
    CalculAG ;
3862
  end ;
3863
end ;
3864
3865
procedure TFMatiere.PBC18_2Change (Sender : TObject) ;
3866
begin
3867
  if not Update
3868
  then
3869
  begin
3870
    Modified := TRUE ;
3871
    // Nouvelle valeur
3872
    with PMatiere.CC do
3873
      case ConfTAG of
3874
        0 : // g/kg
3875
          if (AGsLip = 0) or (Lip = 0)
3876
          then
3877
            C18_2 := 0
3878
          else
3879
            C18_2 := PBC18_2.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3880
        1 : // %
3881
          if (AGsLip = 0) or (Lip = 0)
3882
          then
3883
            C18_2 := 0
3884
          else
3885
            C18_2 := PBC18_2.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3886
        else // % acides gras
3887
          C18_2 := PBC18_2.AsFloat ;
3888
      end ;
3889
    // Calcul des champs li?s ? cette valeur
3890
    CalculAG ;
3891
  end ;
3892
end ;
3893
3894
procedure TFMatiere.PBC18_3Change (Sender : TObject) ;
3895
begin
3896
  if not Update
3897
  then
3898
  begin
3899
    Modified := TRUE ;
3900
    // Nouvelle valeur
3901
    with PMatiere.CC do
3902
      case ConfTAG of
3903
        0 : // g/kg
3904
          if (AGsLip = 0) or (Lip = 0)
3905
          then
3906
            C18_3 := 0
3907
          else
3908
            C18_3 := PBC18_3.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3909
        1 : // %
3910
          if (AGsLip = 0) or (Lip = 0)
3911
          then
3912
            C18_3 := 0
3913
          else
3914
            C18_3 := PBC18_3.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3915
        else // % acides gras
3916
          C18_3 := PBC18_3.AsFloat ;
3917
      end ;
3918
    // Calcul des champs li?s ? cette valeur
3919
    CalculAG ;
3920
  end ;
3921
end ;
3922
3923
procedure TFMatiere.PBC18_4Change (Sender : TObject) ;
3924
begin
3925
  if not Update
3926
  then
3927
  begin
3928
    Modified := TRUE ;
3929
    // Nouvelle valeur
3930
    with PMatiere.CC do
3931
      case ConfTAG of
3932
        0 : // g/kg
3933
          if (AGsLip = 0) or (Lip = 0)
3934
          then
3935
            C18_4 := 0
3936
          else
3937
            C18_4 := PBC18_4.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3938
        1 : // %
3939
          if (AGsLip = 0) or (Lip = 0)
3940
          then
3941
            C18_4 := 0
3942
          else
3943
            C18_4 := PBC18_4.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3944
        else // % acides gras
3945
          C18_4 := PBC18_4.AsFloat ;
3946
      end ;
3947
    // Calcul des champs li?s ? cette valeur
3948
    CalculAG ;
3949
  end ;
3950
end ;
3951
3952
procedure TFMatiere.PBC20_0Change (Sender : TObject) ;
3953
begin
3954
  if not Update
3955
  then
3956
  begin
3957
    Modified := TRUE ;
3958
    // Nouvelle valeur
3959
    with PMatiere.CC do
3960
      case ConfTAG of
3961
        0 : // g/kg
3962
          if (AGsLip = 0) or (Lip = 0)
3963
          then
3964
            C20_0 := 0
3965
          else
3966
            C20_0 := PBC20_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3967
        1 : // %
3968
          if (AGsLip = 0) or (Lip = 0)
3969
          then
3970
            C20_0 := 0
3971
          else
3972
            C20_0 := PBC20_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3973
        else // % acides gras
3974
          C20_0 := PBC20_0.AsFloat ;
3975
      end ;
3976
    // Calcul des champs li?s ? cette valeur
3977
    CalculAG ;
3978
  end ;
3979
end ;
3980
3981
procedure TFMatiere.PBC20_1Change (Sender : TObject) ;
3982
begin
3983
  if not Update
3984
  then
3985
  begin
3986
    Modified := TRUE ;
3987
    // Nouvelle valeur
3988
    with PMatiere.CC do
3989
      case ConfTAG of
3990
        0 : // g/kg
3991
          if (AGsLip = 0) or (Lip = 0)
3992
          then
3993
            C20_1 := 0
3994
          else
3995
            C20_1 := PBC20_1.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3996
        1 : // %
3997
          if (AGsLip = 0) or (Lip = 0)
3998
          then
3999
            C20_1 := 0
4000
          else
4001
            C20_1 := PBC20_1.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4002
        else // % acides gras
4003
          C20_1 := PBC20_1.AsFloat ;
4004
      end ;
4005
    // Calcul des champs li?s ? cette valeur
4006
    CalculAG ;
4007
  end ;
4008
end ;
4009
4010
procedure TFMatiere.PBC20_4Change (Sender : TObject) ;
4011
begin
4012
  if not Update
4013
  then
4014
  begin
4015
    Modified := TRUE ;
4016
    // Nouvelle valeur
4017
    with PMatiere.CC do
4018
      case ConfTAG of
4019
        0 : // g/kg
4020
          if (AGsLip = 0) or (Lip = 0)
4021
          then
4022
            C20_4 := 0
4023
          else
4024
            C20_4 := PBC20_4.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4025
        1 : // %
4026
          if (AGsLip = 0) or (Lip = 0)
4027
          then
4028
            C20_4 := 0
4029
          else
4030
            C20_4 := PBC20_4.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4031
        else // % acides gras
4032
          C20_4 := PBC20_4.AsFloat ;
4033
      end ;
4034
    // Calcul des champs li?s ? cette valeur
4035
    CalculAG ;
4036
  end ;
4037
end ;
4038
4039
procedure TFMatiere.PBC20_5Change (Sender : TObject) ;
4040
begin
4041
  if not Update
4042
  then
4043
  begin
4044
    Modified := TRUE ;
4045
    // Nouvelle valeur
4046
    with PMatiere.CC do
4047
      case ConfTAG of
4048
        0 : // g/kg
4049
          if (AGsLip = 0) or (Lip = 0)
4050
          then
4051
            C20_5 := 0
4052
          else
4053
            C20_5 := PBC20_5.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4054
        1 : // %
4055
          if (AGsLip = 0) or (Lip = 0)
4056
          then
4057
            C20_5 := 0
4058
          else
4059
            C20_5 := PBC20_5.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4060
        else // % acides gras
4061
          C20_5 := PBC20_5.AsFloat ;
4062
      end ;
4063
    // Calcul des champs li?s ? cette valeur
4064
    CalculAG ;
4065
  end ;
4066
end ;
4067
4068
procedure TFMatiere.PBC22_0Change (Sender : TObject) ;
4069
begin
4070
  if not Update
4071
  then
4072
  begin
4073
    Modified := TRUE ;
4074
    // Nouvelle valeur
4075
    with PMatiere.CC do
4076
      case ConfTAG of
4077
        0 : // g/kg
4078
          if (AGsLip = 0) or (Lip = 0)
4079
          then
4080
            C22_0 := 0
4081
          else
4082
            C22_0 := PBC22_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4083
        1 : // %
4084
          if (AGsLip = 0) or (Lip = 0)
4085
          then
4086
            C22_0 := 0
4087
          else
4088
            C22_0 := PBC22_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4089
        else // % acides gras
4090
          C22_0 := PBC22_0.AsFloat ;
4091
      end ;
4092
    // Calcul des champs li?s ? cette valeur
4093
    CalculAG ;
4094
  end ;
4095
end ;
4096
4097
procedure TFMatiere.PBC22_1Change (Sender : TObject) ;
4098
begin
4099
  if not Update
4100
  then
4101
  begin
4102
    Modified := TRUE ;
4103
    // Nouvelle valeur
4104
    with PMatiere.CC do
4105
      case ConfTAG of
4106
        0 : // g/kg
4107
          if (AGsLip = 0) or (Lip = 0)
4108
          then
4109
            C22_1 := 0
4110
          else
4111
            C22_1 := PBC22_1.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4112
        1 : // %
4113
          if (AGsLip = 0) or (Lip = 0)
4114
          then
4115
            C22_1 := 0
4116
          else
4117
            C22_1 := PBC22_1.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4118
        else // % acides gras
4119
          C22_1 := PBC22_1.AsFloat ;
4120
      end ;
4121
    // Calcul des champs li?s ? cette valeur
4122
    CalculAG ;
4123
  end ;
4124
end ;
4125
4126
procedure TFMatiere.PBC22_5Change (Sender : TObject) ;
4127
begin
4128
  if not Update
4129
  then
4130
  begin
4131
    Modified := TRUE ;
4132
    // Nouvelle valeur
4133
    with PMatiere.CC do
4134
      case ConfTAG of
4135
        0 : // g/kg
4136
          if (AGsLip = 0) or (Lip = 0)
4137
          then
4138
            C22_5 := 0
4139
          else
4140
            C22_5 := PBC22_5.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4141
        1 : // %
4142
          if (AGsLip = 0) or (Lip = 0)
4143
          then
4144
            C22_5 := 0
4145
          else
4146
            C22_5 := PBC22_5.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4147
        else // % acides gras
4148
          C22_5 := PBC22_5.AsFloat ;
4149
      end ;
4150
    // Calcul des champs li?s ? cette valeur
4151
    CalculAG ;
4152
  end ;
4153
end ;
4154
4155
procedure TFMatiere.PBC22_6Change (Sender : TObject) ;
4156
begin
4157
  if not Update
4158
  then
4159
  begin
4160
    Modified := TRUE ;
4161
    // Nouvelle valeur
4162
    with PMatiere.CC do
4163
      case ConfTAG of
4164
        0 : // g/kg
4165
          if (AGsLip = 0) or (Lip = 0)
4166
          then
4167
            C22_6 := 0
4168
          else
4169
            C22_6 := PBC22_6.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4170
        1 : // %
4171
          if (AGsLip = 0) or (Lip = 0)
4172
          then
4173
            C22_6 := 0
4174
          else
4175
            C22_6 := PBC22_6.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4176
        else // % acides gras
4177
          C22_6 := PBC22_6.AsFloat ;
4178
      end ;
4179
    // Calcul des champs li?s ? cette valeur
4180
    CalculAG ;
4181
  end ;
4182
end ;
4183
4184
procedure TFMatiere.PBC24_0Change (Sender : TObject) ;
4185
begin
4186
  if not Update
4187
  then
4188
  begin
4189
    Modified := TRUE ;
4190
    // Nouvelle valeur
4191
    with PMatiere.CC do
4192
      case ConfTAG of
4193
        0 : // g/kg
4194
          if (AGsLip = 0) or (Lip = 0)
4195
          then
4196
            C24_0 := 0
4197
          else
4198
            C24_0 := PBC24_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4199
        1 : // %
4200
          if (AGsLip = 0) or (Lip = 0)
4201
          then
4202
            C24_0 := 0
4203
          else
4204
            C24_0 := PBC24_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4205
        else // % acides gras
4206
          C24_0 := PBC24_0.AsFloat ;
4207
      end ;
4208
    // Calcul des champs li?s ? cette valeur
4209
    CalculAG ;
4210
  end ;
4211
end ;
4212
4213
////////////////////////////////////////////////////////////////////////////////
4214
// Min?raux
4215
////////////////////////////////////////////////////////////////////////////////
4216
4217
// Affichage de la teneur en fonction de la configuration
4218
procedure TFMatiere.AffichTMineraux;
4219
begin
4220
  // Macro-?l?ments
4221
  if ConfTMacro = 0
4222
  then // g/kg
4223
    with PMatiere.CC do
4224
    begin
4225
      PBCa.AsFloat := Ca * RapMS;
4226
      PBP.AsFloat := P * RapMS;
4227
      PBNa.AsFloat := Na * RapMS;
4228
      PBK.AsFloat := K * RapMS;
4229
      PBMg.AsFloat := Mg * RapMS;
4230
      PBCl.AsFloat := Cl * RapMS;
4231
      PBS.AsFloat := S * RapMS;
4232
    end
4233
  else // %
4234
    with PMatiere.CC do
4235
    begin
4236
      PBCa.AsFloat := Ca / 1000 * 100 * RapMS;
4237
      PBP.AsFloat := P / 1000 * 100 * RapMS;
4238
      PBNa.AsFloat := Na / 1000 * 100 * RapMS;
4239
      PBK.AsFloat := K / 1000 * 100 * RapMS;
4240
      PBMg.AsFloat := Mg / 1000 * 100 * RapMS;
4241
      PBCl.AsFloat := Cl / 1000 * 100 * RapMS;
4242
      PBS.AsFloat := S / 1000 * 100 * RapMS;
4243
    end ;
4244
  // Oligo-?l?ments
4245
  if ConfTOligo = 0
4246
  then // mg/kg
4247
    with PMatiere.CC do
4248
    begin
4249
      PBCu.AsFloat := Cu * RapMS;
4250
      PBZn.AsFloat := Zn * RapMS;
4251
      PBMn.AsFloat := Mn * RapMS;
4252
      PBFe.AsFloat := Fe * RapMS;
4253
      PBSe.AsFloat := Se * RapMS;
4254
      PBCo.AsFloat := Co * RapMS;
4255
      PBMb.AsFloat := Mb * RapMS;
4256
      PBI.AsFloat := I * RapMS;
4257
    end
4258
  else // %
4259
    with PMatiere.CC do
4260
    begin
4261
      PBCu.AsFloat := Cu / 1000000 * 100 * RapMS;
4262
      PBZn.AsFloat := Zn / 1000000 * 100 * RapMS;
4263
      PBMn.AsFloat := Mn / 1000000 * 100 * RapMS;
4264
      PBFe.AsFloat := Fe / 1000000 * 100 * RapMS;
4265
      PBSe.AsFloat := Se / 1000000 * 100 * RapMS;
4266
      PBCo.AsFloat := Co / 1000000 * 100 * RapMS;
4267
      PBMb.AsFloat := Mb / 1000000 * 100 * RapMS;
4268
      PBI.AsFloat := I / 1000000 * 100 * RapMS;
4269
    end ;
4270
  // Phosphore
4271
  PBPtot.AsFloat := PBP.AsFloat;
4272
  if ConfTMacro = 0
4273
  then // g/kg
4274
    with PMatiere.CC do
4275
    begin
4276
      PBPdigG.AsFloat := PdigG * RapMS;
4277
      PBPdigF.AsFloat := PdigF * RapMS;
4278
    end
4279
  else // %
4280
    with PMatiere.CC do
4281
    begin
4282
      PBPdigG.AsFloat := PdigG / 1000 * 100 * RapMS;
4283
      PBPdigF.AsFloat := PdigF / 1000 * 100 * RapMS;
4284
    end;
4285
  with PMatiere.CC do
4286
  begin
4287
    PBPhytase.AsFloat := Phytase;
4288
    PBActPhytE.AsFloat := ActPhytE * RapMS;
4289
    PBActPhytM.AsFloat := ActPhytM * RapMS;
4290
  end;
4291
end;
4292
4293
procedure TFMatiere.CalculMineraux;
4294
begin
4295
  // Ca / P
4296
  if PMatiere.CC.P = 0
4297
  then
4298
    PBCasP.Text := 'infini'
4299
  else
4300
    with PMatiere.CC do
4301
      PBCasP.AsFloat := Ca / P;
4302
  // Bilan cations-anions
4303
  with PMatiere.CC do
4304
    PBBilanCA.AsFloat := 1000 * (K / 39 + Na / 23 - Cl / 35.5 - S / 16);
4305
  // Bilan ?lectrolytique
4306
  with PMatiere.CC do
4307
    PBBilanE.AsFloat := 1000 * (K / 39 + Na / 23 - Cl / 35.5);
4308
end;
4309
4310
procedure TFMatiere.PBCaChange (Sender : TObject) ;
4311
begin
4312
  if not Update
4313
  then
4314
  begin
4315
    Modified := TRUE ;
4316
    // Nouvelle valeur
4317
    with PMatiere.CC do
4318
      if ConfTMacro = 0
4319
      then // g/kg
4320
        Ca := PBCa.AsFloat / RapMS
4321
      else // %
4322
        Ca := PBCa.AsFloat * 1000 / 100 / RapMS ;
4323
    // Calcul des champs li?s ? cette valeur
4324
    CalculMineraux ;
4325
  end ;
4326
end ;
4327
4328
procedure TFMatiere.PBPChange (Sender : TObject) ;
4329
begin
4330
  if not Update
4331
  then
4332
  begin
4333
    Modified := TRUE ;
4334
    // Nouvelle valeur
4335
    with PMatiere.CC do
4336
      if ConfTMacro = 0
4337
      then // g/kg
4338
        P := PBP.AsFloat / RapMS
4339
      else // %
4340
        P := PBP.AsFloat * 1000 / 100 / RapMS ;
4341
    PBPtot.AsFloat := PBP.AsFloat;
4342
    // Calcul des champs li?s ? cette valeur
4343
    CalculMineraux ;
4344
  end ;
4345
end ;
4346
4347
procedure TFMatiere.PBNaChange (Sender : TObject) ;
4348
begin
4349
  if not Update
4350
  then
4351
  begin
4352
    Modified := TRUE ;
4353
    // Nouvelle valeur
4354
    with PMatiere.CC do
4355
      if ConfTMacro = 0
4356
      then // g/kg
4357
        Na := PBNa.AsFloat / RapMS
4358
      else // %
4359
        Na := PBNa.AsFloat * 1000 / 100 / RapMS ;
4360
    // Calcul des champs li?s ? cette valeur
4361
    CalculMineraux ;
4362
  end ;
4363
end ;
4364
4365
procedure TFMatiere.PBKChange (Sender : TObject) ;
4366
begin
4367
  if not Update
4368
  then
4369
  begin
4370
    Modified := TRUE ;
4371
    // Nouvelle valeur
4372
    with PMatiere.CC do
4373
      if ConfTMacro = 0
4374
      then // g/kg
4375
        K := PBK.AsFloat / RapMS
4376
      else // %
4377
        K := PBK.AsFloat * 1000 / 100 / RapMS ;
4378
    // Calcul des champs li?s ? cette valeur
4379
    CalculMineraux ;
4380
  end ;
4381
end ;
4382
4383
procedure TFMatiere.PBMgChange (Sender : TObject) ;
4384
begin
4385
  if not Update
4386
  then
4387
  begin
4388
    Modified := TRUE ;
4389
    // Nouvelle valeur
4390
    with PMatiere.CC do
4391
      if ConfTMacro = 0
4392
      then // g/kg
4393
        Mg := PBMg.AsFloat / RapMS
4394
      else // %
4395
        Mg := PBMg.AsFloat * 1000 / 100 / RapMS ;
4396
  end ;
4397
end ;
4398
4399
procedure TFMatiere.PBClChange (Sender : TObject) ;
4400
begin
4401
  if not Update
4402
  then
4403
  begin
4404
    Modified := TRUE ;
4405
    // Nouvelle valeur
4406
    with PMatiere.CC do
4407
      if ConfTMacro = 0
4408
      then // g/kg
4409
        Cl := PBCl.AsFloat / RapMS
4410
      else // %
4411
        Cl := PBCl.AsFloat * 1000 / 100 / RapMS ;
4412
    // Calcul des champs li?s ? cette valeur
4413
    CalculMineraux ;
4414
  end ;
4415
end ;
4416
4417
procedure TFMatiere.PBSChange (Sender : TObject) ;
4418
begin
4419
  if not Update
4420
  then
4421
  begin
4422
    Modified := TRUE ;
4423
    // Nouvelle valeur
4424
    with PMatiere.CC do
4425
      if ConfTMacro = 0
4426
      then // g/kg
4427
        S := PBS.AsFloat / RapMS
4428
      else // %
4429
        S := PBS.AsFloat * 1000 / 100 / RapMS ;
4430
    // Calcul des champs li?s ? cette valeur
4431
    CalculMineraux ;
4432
  end ;
4433
end ;
4434
4435
procedure TFMatiere.PBCuChange (Sender : TObject) ;
4436
begin
4437
  if not Update
4438
  then
4439
  begin
4440
    Modified := TRUE ;
4441
    // Nouvelle valeur
4442
    with PMatiere.CC do
4443
      if ConfTOligo = 0
4444
      then // mg/kg
4445
        Cu := PBCu.AsFloat / RapMS
4446
      else // %
4447
        Cu := PBCu.AsFloat * 1000000 / 100 / RapMS ;
4448
  end ;
4449
end ;
4450
4451
procedure TFMatiere.PBZnChange (Sender : TObject) ;
4452
begin
4453
  if not Update
4454
  then
4455
  begin
4456
    Modified := TRUE ;
4457
    // Nouvelle valeur
4458
    with PMatiere.CC do
4459
      if ConfTOligo = 0
4460
      then // mg/kg
4461
        Zn := PBZn.AsFloat / RapMS
4462
      else // %
4463
        Zn := PBZn.AsFloat * 1000000 / 100 / RapMS ;
4464
  end ;
4465
end ;
4466
4467
procedure TFMatiere.PBMnChange (Sender : TObject) ;
4468
begin
4469
  if not Update
4470
  then
4471
  begin
4472
    Modified := TRUE ;
4473
    // Nouvelle valeur
4474
    with PMatiere.CC do
4475
      if ConfTOligo = 0
4476
      then // mg/kg
4477
        Mn := PBMn.AsFloat / RapMS
4478
      else // %
4479
        Mn := PBMn.AsFloat * 1000000 / 100 / RapMS ;
4480
  end ;
4481
end ;
4482
4483
procedure TFMatiere.PBFeChange (Sender : TObject) ;
4484
begin
4485
  if not Update
4486
  then
4487
  begin
4488
    Modified := TRUE ;
4489
    // Nouvelle valeur
4490
    with PMatiere.CC do
4491
      if ConfTOligo = 0
4492
      then // mg/kg
4493
        Fe := PBFe.AsFloat / RapMS
4494
      else // %
4495
        Fe := PBFe.AsFloat * 1000000 / 100 / RapMS ;
4496
  end ;
4497
end ;
4498
4499
procedure TFMatiere.PBSeChange (Sender : TObject) ;
4500
begin
4501
  if not Update
4502
  then
4503
  begin
4504
    Modified := TRUE ;
4505
    // Nouvelle valeur
4506
    with PMatiere.CC do
4507
      if ConfTOligo = 0
4508
      then // mg/kg
4509
        Se := PBSe.AsFloat / RapMS
4510
      else // %
4511
        Se := PBSe.AsFloat * 1000000 / 100 / RapMS ;
4512
  end ;
4513
end ;
4514
4515
procedure TFMatiere.PBCoChange (Sender : TObject) ;
4516
begin
4517
  if not Update
4518
  then
4519
  begin
4520
    Modified := TRUE ;
4521
    // Nouvelle valeur
4522
    with PMatiere.CC do
4523
      if ConfTOligo = 0
4524
      then // mg/kg
4525
        Co := PBCo.AsFloat / RapMS
4526
      else // %
4527
        Co := PBCo.AsFloat * 1000000 / 100 / RapMS ;
4528
  end ;
4529
end ;
4530
4531
procedure TFMatiere.PBMbChange (Sender : TObject) ;
4532
begin
4533
  if not Update
4534
  then
4535
  begin
4536
    Modified := TRUE ;
4537
    // Nouvelle valeur
4538
    with PMatiere.CC do
4539
      if ConfTOligo = 0
4540
      then // mg/kg
4541
        Mb := PBMb.AsFloat / RapMS
4542
      else // %
4543
        Mb := PBMb.AsFloat * 1000000 / 100 / RapMS ;
4544
  end ;
4545
end ;
4546
4547
procedure TFMatiere.PBIChange (Sender : TObject) ;
4548
begin
4549
  if not Update
4550
  then
4551
  begin
4552
    Modified := TRUE ;
4553
    // Nouvelle valeur
4554
    with PMatiere.CC do
4555
      if ConfTOligo = 0
4556
      then // mg/kg
4557
        I := PBI.AsFloat / RapMS
4558
      else // %
4559
        I := PBI.AsFloat * 1000000 / 100 / RapMS ;
4560
  end ;
4561
end ;
4562
4563
procedure TFMatiere.PBPdigGChange (Sender : TObject) ;
4564
begin
4565
  if not Update
4566
  then
4567
  begin
4568
    Modified := TRUE ;
4569
    // Nouvelle valeur
4570
    with PMatiere.CC do
4571
      if ConfTMacro = 0
4572
      then // g/kg
4573
        PdigG := PBPdigG.AsFloat / RapMS
4574
      else // %
4575
        PdigG := PBPdigG.AsFloat * 1000 / 100 / RapMS ;
4576
  end ;
4577
end ;
4578
4579
procedure TFMatiere.PBPdigFChange (Sender : TObject) ;
4580
begin
4581
  if not Update
4582
  then
4583
  begin
4584
    Modified := TRUE ;
4585
    // Nouvelle valeur
4586
    with PMatiere.CC do
4587
      if ConfTMacro = 0
4588
      then // g/kg
4589
        PdigF := PBPdigF.AsFloat / RapMS
4590
      else // %
4591
        PdigF := PBPdigF.AsFloat * 1000 / 100 / RapMS ;
4592
  end ;
4593
end ;
4594
4595
procedure TFMatiere.PBPhytaseChange (Sender : TObject) ;
4596
begin
4597
  if not Update
4598
  then
4599
  begin
4600
    Modified := TRUE ;
4601
    // Nouvelle valeur
4602
    with PMatiere.CC do
4603
      Phytase := PBPhytase.AsFloat ;
4604
  end ;
4605
end ;
4606
4607
procedure TFMatiere.PBActPhytEChange (Sender : TObject) ;
4608
begin
4609
  if not Update
4610
  then
4611
  begin
4612
    Modified := TRUE ;
4613
    // Nouvelle valeur
4614
    with PMatiere.CC do
4615
      ActPhytE := PBActPhytE.AsFloat / RapMS ;
4616
  end ;
4617
end ;
4618
4619
procedure TFMatiere.PBActPhytMChange (Sender : TObject) ;
4620
begin
4621
  if not Update
4622
  then
4623
  begin
4624
    Modified := TRUE ;
4625
    // Nouvelle valeur
4626
    with PMatiere.CC do
4627
      ActPhytM := PBActPhytM.AsFloat / RapMS ;
4628
  end ;
4629
end ;
4630
4631
////////////////////////////////////////////////////////////////////////////////
4632
// Fibres
4633
////////////////////////////////////////////////////////////////////////////////
4634
4635
// Affichage de la teneur en fonction de la configuration
4636
procedure TFMatiere.AffichTFibres ;
4637
begin
4638
  if ConfTFibres = 0
4639
  then // g/kg
4640
    with PMatiere.CC do
4641
    begin
4642
      PBCB.AsFloat := CB * RapMS ;
4643
      PBNDF.AsFloat := NDF * RapMS ;
4644
      PBADF.AsFloat := ADF * RapMS ;
4645
      PBADL.AsFloat := ADL * RapMS ;
4646
      PBParois.AsFloat := Parois * RapMS ;
4647
    end
4648
  else // %
4649
    with PMatiere.CC do
4650
    begin
4651
      PBCB.AsFloat := CB / 1000 * 100 * RapMS ;
4652
      PBNDF.AsFloat := NDF / 1000 * 100 * RapMS ;
4653
      PBADF.AsFloat := ADF / 1000 * 100 * RapMS ;
4654
      PBADL.AsFloat := ADL / 1000 * 100 * RapMS ;
4655
      PBParois.AsFloat := Parois / 1000 * 100 * RapMS ;
4656
    end ;
4657
end ;
4658
4659
procedure TFMatiere.PBCBChange (Sender : TObject) ;
4660
begin
4661
  if not Update
4662
  then
4663
  begin
4664
    Modified := TRUE ;
4665
    // Nouvelle valeur
4666
    with PMatiere.CC do
4667
      if ConfTFibres = 0
4668
      then // g/kg
4669
        CB := PBCB.AsFloat / RapMS
4670
      else // %
4671
        CB := PBCB.AsFloat * 1000 / 100 / RapMS ;
4672
    // Calcul des champs li?s ? cette valeur
4673
    CalculResidu ;
4674
    AffichResidu ;
4675
  end ;
4676
end ;
4677
4678
procedure TFMatiere.PBNDFChange(Sender: TObject);
4679
begin
4680
  if not Update
4681
  then
4682
  begin
4683
    Modified := TRUE ;
4684
    // Nouvelle valeur
4685
    with PMatiere.CC do
4686
      if ConfTFibres = 0
4687
      then // g/kg
4688
        NDF := PBNDF.AsFloat / RapMS
4689
      else // %
4690
        NDF := PBNDF.AsFloat * 1000 / 100 / RapMS ;
4691
  end ;
4692
end;
4693
4694
procedure TFMatiere.PBADFChange(Sender: TObject);
4695
begin
4696
  if not Update
4697
  then
4698
  begin
4699
    Modified := TRUE ;
4700
    // Nouvelle valeur
4701
    with PMatiere.CC do
4702
      if ConfTFibres = 0
4703
      then // g/kg
4704
        ADF := PBADF.AsFloat / RapMS
4705
      else // %
4706
        ADF := PBADF.AsFloat * 1000 / 100 / RapMS ;
4707
  end ;
4708
end;
4709
4710
procedure TFMatiere.PBADLChange(Sender: TObject);
4711
begin
4712
  if not Update
4713
  then
4714
  begin
4715
    Modified := TRUE ;
4716
    // Nouvelle valeur
4717
    with PMatiere.CC do
4718
      if ConfTFibres = 0
4719
      then // g/kg
4720
        ADL := PBADL.AsFloat / RapMS
4721
      else // %
4722
        ADL := PBADL.AsFloat * 1000 / 100 / RapMS ;
4723
  end ;
4724
end;
4725
4726
procedure TFMatiere.PBParoisChange(Sender: TObject);
4727
begin
4728
  if not Update
4729
  then
4730
  begin
4731
    Modified := TRUE ;
4732
    // Nouvelle valeur
4733
    with PMatiere.CC do
4734
      if ConfTFibres = 0
4735
      then // g/kg
4736
        Parois := PBParois.AsFloat / RapMS
4737
      else // %
4738
        Parois := PBParois.AsFloat * 1000 / 100 / RapMS ;
4739
  end ;
4740
end;
4741
4742
end.