Statistiques
| Révision:

root / UFAliment.pas @ 3

Historique | Voir | Annoter | Télécharger (163,056 ko)

1
unit UFAliment ;
2

    
3
interface
4

    
5
uses
6
  Windows, Controls, Forms, Classes, StdCtrls, ComCtrls, Buttons, Grids,
7
  PBNumEdit, JvEnterTab, JvStringGrid, JvExGrids, JvExControls;
8

    
9
type
10
  TFAliment = class(TForm)
11
    GBAliment: TGroupBox;
12
    SBAdd: TSpeedButton;
13
    SBDel: TSpeedButton;
14
    SBRename: TSpeedButton;
15
    SBComment: TSpeedButton;
16
    CBAliment: TComboBox;
17
    PC: TPageControl;
18
    TSElem: TTabSheet;
19
    GBEnergie: TGroupBox;
20
    GBEVal: TGroupBox;
21
    LEVal_C: TLabel;
22
    LEN: TLabel;
23
    LEM: TLabel;
24
    LED: TLabel;
25
    LEB: TLabel;
26
    LEVal_T: TLabel;
27
    LCorrCUD: TLabel;
28
    RBEN: TRadioButton;
29
    RBEM: TRadioButton;
30
    RBED: TRadioButton;
31
    PBEB_T: TPBNumEdit;
32
    PBEB_C: TPBNumEdit;
33
    CBCorrCUD: TCheckBox;
34
    PBED_C: TPBNumEdit;
35
    PBED_T: TPBNumEdit;
36
    PBEM_C: TPBNumEdit;
37
    PBEM_T: TPBNumEdit;
38
    PBEN_C: TPBNumEdit;
39
    PBEN_T: TPBNumEdit;
40
    BGERap: TGroupBox;
41
    LEDsEB: TLabel;
42
    LENsEM: TLabel;
43
    LERap_C: TLabel;
44
    LERap_T: TLabel;
45
    PBEDsEB_C: TPBNumEdit;
46
    PBENsEM_C: TPBNumEdit;
47
    PBEDsEB_T: TPBNumEdit;
48
    PBENsEM_T: TPBNumEdit;
49
    GBFecale: TGroupBox;
50
    LMS: TLabel;
51
    LMM: TLabel;
52
    LMO: TLabel;
53
    LLip: TLabel;
54
    LMAT: TLabel;
55
    LAmidon: TLabel;
56
    LSucres: TLabel;
57
    GBdFecale: TGroupBox;
58
    LdFecale_C: TLabel;
59
    LdFecale_T: TLabel;
60
    PBdMO_C: TPBNumEdit;
61
    PBdLip_C: TPBNumEdit;
62
    PBdMAT_C: TPBNumEdit;
63
    PBdSucres_C: TPBNumEdit;
64
    PBdLip_T: TPBNumEdit;
65
    PBdMAT_T: TPBNumEdit;
66
    PBdAmidon_T: TPBNumEdit;
67
    PBdSucres_T: TPBNumEdit;
68
    PBdMO_T: TPBNumEdit;
69
    PBdAmidon_C: TPBNumEdit;
70
    GBTFecale: TGroupBox;
71
    PBTMS: TPBNumEdit;
72
    PBTMM: TPBNumEdit;
73
    PBTMO: TPBNumEdit;
74
    PBTLip: TPBNumEdit;
75
    PBTMAT: TPBNumEdit;
76
    PBTAmidon: TPBNumEdit;
77
    PBTSucres: TPBNumEdit;
78
    TSAA: TTabSheet;
79
    GBAA: TGroupBox;
80
    LMAT2: TLabel;
81
    LLys: TLabel;
82
    LMet: TLabel;
83
    LCys: TLabel;
84
    LTrp: TLabel;
85
    LThr: TLabel;
86
    LPhe: TLabel;
87
    LTyr: TLabel;
88
    LLeu: TLabel;
89
    LIle: TLabel;
90
    LVal: TLabel;
91
    LHis: TLabel;
92
    LArg: TLabel;
93
    GBTAA: TGroupBox;
94
    PBTVal: TPBNumEdit;
95
    PBTMAT2: TPBNumEdit;
96
    PBTLys: TPBNumEdit;
97
    PBTMet: TPBNumEdit;
98
    PBTCys: TPBNumEdit;
99
    PBTTrp: TPBNumEdit;
100
    PBTThr: TPBNumEdit;
101
    PBTPhe: TPBNumEdit;
102
    PBTTyr: TPBNumEdit;
103
    PBTLeu: TPBNumEdit;
104
    PBTIle: TPBNumEdit;
105
    PBTArg: TPBNumEdit;
106
    PBTHis: TPBNumEdit;
107
    CBAAsLys: TCheckBox;
108
    GBdAA: TGroupBox;
109
    LdAAStd: TLabel;
110
    LdAAApp: TLabel;
111
    PBdArgStd: TPBNumEdit;
112
    PBdMATStd: TPBNumEdit;
113
    PBdLysStd: TPBNumEdit;
114
    PBdMetStd: TPBNumEdit;
115
    PBdCysStd: TPBNumEdit;
116
    PBdTrpStd: TPBNumEdit;
117
    PBdThrStd: TPBNumEdit;
118
    PBdPheStd: TPBNumEdit;
119
    PBdTyrStd: TPBNumEdit;
120
    PBdLeuStd: TPBNumEdit;
121
    PBdIleStd: TPBNumEdit;
122
    PBdValStd: TPBNumEdit;
123
    PBdHisStd: TPBNumEdit;
124
    PBdMATApp: TPBNumEdit;
125
    PBdLysApp: TPBNumEdit;
126
    PBdMetApp: TPBNumEdit;
127
    PBdCysApp: TPBNumEdit;
128
    PBdTrpApp: TPBNumEdit;
129
    PBdThrApp: TPBNumEdit;
130
    PBdPheApp: TPBNumEdit;
131
    PBdTyrApp: TPBNumEdit;
132
    PBdLeuApp: TPBNumEdit;
133
    PBdIleApp: TPBNumEdit;
134
    PBdValApp: TPBNumEdit;
135
    PBdHisApp: TPBNumEdit;
136
    PBdArgApp: TPBNumEdit;
137
    GBProt: TGroupBox;
138
    LProtStd: TLabel;
139
    LProtTot: TLabel;
140
    PBProtTrpStd: TPBNumEdit;
141
    PBProtLysStd: TPBNumEdit;
142
    PBProtMetStd: TPBNumEdit;
143
    PBProtCysStd: TPBNumEdit;
144
    PBProtThrStd: TPBNumEdit;
145
    PBProtPheStd: TPBNumEdit;
146
    PBProtTyrStd: TPBNumEdit;
147
    PBProtLeuStd: TPBNumEdit;
148
    PBProtIleStd: TPBNumEdit;
149
    PBProtValStd: TPBNumEdit;
150
    PBProtHisStd: TPBNumEdit;
151
    PBProtArgStd: TPBNumEdit;
152
    PBProtLysTot: TPBNumEdit;
153
    PBProtMetTot: TPBNumEdit;
154
    PBProtCysTot: TPBNumEdit;
155
    PBProtTrpTot: TPBNumEdit;
156
    PBProtThrTot: TPBNumEdit;
157
    PBProtPheTot: TPBNumEdit;
158
    PBProtTyrTot: TPBNumEdit;
159
    PBProtLeuTot: TPBNumEdit;
160
    PBProtIleTot: TPBNumEdit;
161
    PBProtValTot: TPBNumEdit;
162
    PBProtHisTot: TPBNumEdit;
163
    PBProtArgTot: TPBNumEdit;
164
    GBCompAA: TGroupBox;
165
    GBMetCys: TGroupBox;
166
    LTMetCys: TLabel;
167
    LdMetCys: TLabel;
168
    LProtMetCys: TLabel;
169
    PBTMetCys: TPBNumEdit;
170
    PBdMetCysStd: TPBNumEdit;
171
    PBProtMetCysStd: TPBNumEdit;
172
    GBTrp: TGroupBox;
173
    LTrpTot: TLabel;
174
    LTrpStd: TLabel;
175
    PBTrpTot: TPBNumEdit;
176
    PBTrpStd: TPBNumEdit;
177
    GBPheTyr: TGroupBox;
178
    LTPheTyr: TLabel;
179
    LdPheTyr: TLabel;
180
    LProtPheTyr: TLabel;
181
    PBTPheTyr: TPBNumEdit;
182
    PBdPheTyrStd: TPBNumEdit;
183
    PBProtPheTyrStd: TPBNumEdit;
184
    GBEAA: TGroupBox;
185
    LEAATot: TLabel;
186
    LEAAStd: TLabel;
187
    PBEAATot: TPBNumEdit;
188
    PBEAAStd: TPBNumEdit;
189
    TSAG: TTabSheet;
190
    LAG: TLabel;
191
    LLip2: TLabel;
192
    LSatur: TLabel;
193
    LMono: TLabel;
194
    LPoly: TLabel;
195
    LO6sO3: TLabel;
196
    GBTAG: TGroupBox;
197
    LC6C8C10: TLabel;
198
    LC24: TLabel;
199
    LC22: TLabel;
200
    LC20: TLabel;
201
    LC18: TLabel;
202
    LC14: TLabel;
203
    LC16: TLabel;
204
    LC12: TLabel;
205
    LCtot: TLabel;
206
    GBAGtot: TGroupBox;
207
    PBC24_tot: TPBNumEdit;
208
    PBC22_tot: TPBNumEdit;
209
    PBC20_tot: TPBNumEdit;
210
    PBC18_tot: TPBNumEdit;
211
    PBC16_tot: TPBNumEdit;
212
    PBC14_tot: TPBNumEdit;
213
    PBC12_tot: TPBNumEdit;
214
    PBC6C8C10_tot: TPBNumEdit;
215
    PBCtot_tot: TPBNumEdit;
216
    GBAG0: TGroupBox;
217
    PBC6C8C10_0: TPBNumEdit;
218
    PBC12_0: TPBNumEdit;
219
    PBC14_0: TPBNumEdit;
220
    PBC16_0: TPBNumEdit;
221
    PBC18_0: TPBNumEdit;
222
    PBC20_0: TPBNumEdit;
223
    PBC22_0: TPBNumEdit;
224
    PBC24_0: TPBNumEdit;
225
    PBCtot_0: TPBNumEdit;
226
    GBAG1: TGroupBox;
227
    PBC22_1: TPBNumEdit;
228
    PBC16_1: TPBNumEdit;
229
    PBC18_1: TPBNumEdit;
230
    PBC20_1: TPBNumEdit;
231
    PBCtot_1: TPBNumEdit;
232
    GBAG2: TGroupBox;
233
    PBC18_2: TPBNumEdit;
234
    PBCtot_2: TPBNumEdit;
235
    GBAG3: TGroupBox;
236
    PBC18_3: TPBNumEdit;
237
    PBCtot_3: TPBNumEdit;
238
    GBAG4: TGroupBox;
239
    PBC18_4: TPBNumEdit;
240
    PBC20_4: TPBNumEdit;
241
    PBCtot_4: TPBNumEdit;
242
    GBAG5: TGroupBox;
243
    PBC20_5: TPBNumEdit;
244
    PBC22_5: TPBNumEdit;
245
    PBCtot_5: TPBNumEdit;
246
    GBAG6: TGroupBox;
247
    PBC22_6: TPBNumEdit;
248
    PBCtot_6: TPBNumEdit;
249
    PBAG: TPBNumEdit;
250
    PBLip2: TPBNumEdit;
251
    PBSatur: TPBNumEdit;
252
    PBMono: TPBNumEdit;
253
    PBPoly: TPBNumEdit;
254
    PBO6sO3: TPBNumEdit;
255
    TSMineraux: TTabSheet;
256
    LBilanCA: TLabel;
257
    LBilanE: TLabel;
258
    GBP: TGroupBox;
259
    LPdigG: TLabel;
260
    LPhytase: TLabel;
261
    LActPhytE: TLabel;
262
    LCasP: TLabel;
263
    LPtot: TLabel;
264
    PBPhytase: TPBNumEdit;
265
    PBPdigG: TPBNumEdit;
266
    PBActPhytE: TPBNumEdit;
267
    PBCasP: TPBNumEdit;
268
    PBPtot: TPBNumEdit;
269
    GBMacro: TGroupBox;
270
    LCa: TLabel;
271
    LP: TLabel;
272
    LMg: TLabel;
273
    LCl: TLabel;
274
    LK: TLabel;
275
    LNa: TLabel;
276
    LS: TLabel;
277
    GBTMacro: TGroupBox;
278
    PBCa: TPBNumEdit;
279
    PBP: TPBNumEdit;
280
    PBMg: TPBNumEdit;
281
    PBCl: TPBNumEdit;
282
    PBK: TPBNumEdit;
283
    PBNa: TPBNumEdit;
284
    PBS: TPBNumEdit;
285
    GBOligo: TGroupBox;
286
    LZn: TLabel;
287
    LCu: TLabel;
288
    LFe: TLabel;
289
    LMn: TLabel;
290
    LCo: TLabel;
291
    LSe: TLabel;
292
    LI: TLabel;
293
    LMb: TLabel;
294
    GBTOligo: TGroupBox;
295
    PBCu: TPBNumEdit;
296
    PBFe: TPBNumEdit;
297
    PBMn: TPBNumEdit;
298
    PBZn: TPBNumEdit;
299
    PBSe: TPBNumEdit;
300
    PBI: TPBNumEdit;
301
    PBMb: TPBNumEdit;
302
    PBCo: TPBNumEdit;
303
    PBBilanCA: TPBNumEdit;
304
    PBBilanE: TPBNumEdit;
305
    TSFibres: TTabSheet;
306
    GBFibres: TGroupBox;
307
    LNDF: TLabel;
308
    LCB: TLabel;
309
    LParois: TLabel;
310
    LADL: TLabel;
311
    LADF: TLabel;
312
    PBParois: TPBNumEdit;
313
    PBADL: TPBNumEdit;
314
    PBADF: TPBNumEdit;
315
    PBNDF: TPBNumEdit;
316
    PBCB: TPBNumEdit;
317
    TSMatiere: TTabSheet;
318
    CBAAsMAT: TCheckBox;
319
    LBGauche: TListBox;
320
    LBDroite: TListBox;
321
    CBType: TComboBox;
322
    LType: TLabel;
323
    SBPlus: TSpeedButton;
324
    SBMoins: TSpeedButton;
325
    LMSG: TLabel;
326
    LMSD: TLabel;
327
    PBMSG: TPBNumEdit;
328
    PBMSD: TPBNumEdit;
329
    PBQte: TPBNumEdit;
330
    PBTotal: TPBNumEdit;
331
    LTotal: TLabel;
332
    LQte: TLabel;
333
    BBCalcul: TBitBtn;
334
    GBGauche: TGroupBox;
335
    GBDroite: TGroupBox;
336
    BBGraph: TBitBtn;
337
    SBHaut: TSpeedButton;
338
    SBBas: TSpeedButton;
339
    LBRap: TListBox;
340
    LBDig: TListBox;
341
    LBdCompo: TListBox;
342
    LBdAA: TListBox;
343
    LBTCompo: TListBox;
344
    LBTAA: TListBox;
345
    LBTAG: TListBox;
346
    LBTMacro: TListBox;
347
    LBTOligo: TListBox;
348
    LBTFibres: TListBox;
349
    LMATG: TLabel;
350
    PBMATG: TPBNumEdit;
351
    LdLysG: TLabel;
352
    PBdLysG: TPBNumEdit;
353
    LEDG: TLabel;
354
    PBEDG: TPBNumEdit;
355
    LEMG: TLabel;
356
    PBEMG: TPBNumEdit;
357
    LENG: TLabel;
358
    PBENG: TPBNumEdit;
359
    LPdigF: TLabel;
360
    PBPdigF: TPBNumEdit;
361
    LActPhytM: TLabel;
362
    PBActPhytM: TPBNumEdit;
363
    LActPhyt: TLabel;
364
    LPdig: TLabel;
365
    SBSave: TSpeedButton;
366
    SBPrint: TSpeedButton;
367
    PBdMetCysApp: TPBNumEdit;
368
    PBProtMetCysTot: TPBNumEdit;
369
    PBdPheTyrApp: TPBNumEdit;
370
    PBProtPheTyrTot: TPBNumEdit;
371
    JvEnterAsTab: TJvEnterAsTab;
372
    LResidu: TLabel;
373
    PBTResidu: TPBNumEdit;
374
    PBdResidu_C: TPBNumEdit;
375
    PBdResidu_T: TPBNumEdit;
376
    SBReplace: TSpeedButton;
377
    SBSortQte: TSpeedButton;
378
    SBSortNom: TSpeedButton;
379
    JvSGSort: TJvStringGrid;
380
    procedure FormShow(Sender: TObject);
381
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
382
    procedure FormDeactivate(Sender: TObject);
383
    procedure CBAlimentChange(Sender: TObject);
384
    procedure SBAddClick(Sender: TObject);
385
    procedure SBDelClick(Sender: TObject);
386
    procedure SBRenameClick(Sender: TObject);
387
    procedure SBCommentClick(Sender: TObject);
388
    procedure PBTMSChange(Sender: TObject);
389
    procedure PBTMSExit(Sender: TObject);
390
    procedure PBTMMChange(Sender: TObject);
391
    procedure PBTMMExit(Sender: TObject);
392
    procedure PBTLipChange(Sender: TObject);
393
    procedure PBTMATChange(Sender: TObject);
394
    procedure PBTMATExit(Sender: TObject);
395
    procedure PBTAmidonChange(Sender: TObject);
396
    procedure PBTSucresChange(Sender: TObject);
397
    procedure PBdMO_CChange(Sender: TObject);
398
    procedure PBdLip_CChange(Sender: TObject);
399
    procedure PBdMAT_CChange(Sender: TObject);
400
    procedure PBdMO_TChange(Sender: TObject);
401
    procedure PBdLip_TChange(Sender: TObject);
402
    procedure PBdMAT_TChange(Sender: TObject);
403
    procedure CBCorrCUDClick(Sender: TObject);
404
    procedure LCorrCUDClick(Sender: TObject);
405
    procedure RBEDClick(Sender: TObject);
406
    procedure LEDClick(Sender: TObject);
407
    procedure RBEMClick(Sender: TObject);
408
    procedure LEMClick(Sender: TObject);
409
    procedure RBENClick(Sender: TObject);
410
    procedure LENClick(Sender: TObject);
411
    procedure PBED_CChange(Sender: TObject);
412
    procedure PBED_CExit(Sender: TObject);
413
    procedure PBEM_CChange(Sender: TObject);
414
    procedure PBEM_CExit(Sender: TObject);
415
    procedure PBEN_CChange(Sender: TObject);
416
    procedure PBEN_CExit(Sender: TObject);
417
    procedure PBED_TChange(Sender: TObject);
418
    procedure PBED_TExit(Sender: TObject);
419
    procedure PBEM_TChange(Sender: TObject);
420
    procedure PBEM_TExit(Sender: TObject);
421
    procedure PBEN_TChange(Sender: TObject);
422
    procedure PBEN_TExit(Sender: TObject);
423
    procedure PBTLysChange(Sender: TObject);
424
    procedure PBTLysExit(Sender: TObject);
425
    procedure PBTMetChange(Sender: TObject);
426
    procedure PBTCysChange(Sender: TObject);
427
    procedure PBTTrpChange(Sender: TObject);
428
    procedure PBTThrChange(Sender: TObject);
429
    procedure PBTPheChange(Sender: TObject);
430
    procedure PBTTyrChange(Sender: TObject);
431
    procedure PBTLeuChange(Sender: TObject);
432
    procedure PBTIleChange(Sender: TObject);
433
    procedure PBTValChange(Sender: TObject);
434
    procedure PBTHisChange(Sender: TObject);
435
    procedure PBTArgChange(Sender: TObject);
436
    procedure CBAAsLysClick(Sender: TObject);
437
    procedure PBdMATStdChange(Sender: TObject);
438
    procedure PBdLysStdChange(Sender: TObject);
439
    procedure PBdMetStdChange(Sender: TObject);
440
    procedure PBdCysStdChange(Sender: TObject);
441
    procedure PBdTrpStdChange(Sender: TObject);
442
    procedure PBdThrStdChange(Sender: TObject);
443
    procedure PBdPheStdChange(Sender: TObject);
444
    procedure PBdTyrStdChange(Sender: TObject);
445
    procedure PBdLeuStdChange(Sender: TObject);
446
    procedure PBdIleStdChange(Sender: TObject);
447
    procedure PBdValStdChange(Sender: TObject);
448
    procedure PBdHisStdChange(Sender: TObject);
449
    procedure PBdArgStdChange(Sender: TObject);
450
    procedure PBC6C8C10_0Change(Sender: TObject);
451
    procedure PBC12_0Change(Sender: TObject);
452
    procedure PBC14_0Change(Sender: TObject);
453
    procedure PBC16_0Change(Sender: TObject);
454
    procedure PBC16_1Change(Sender: TObject);
455
    procedure PBC18_0Change(Sender: TObject);
456
    procedure PBC18_1Change(Sender: TObject);
457
    procedure PBC18_2Change(Sender: TObject);
458
    procedure PBC18_3Change(Sender: TObject);
459
    procedure PBC18_4Change(Sender: TObject);
460
    procedure PBC20_0Change(Sender: TObject);
461
    procedure PBC20_1Change(Sender: TObject);
462
    procedure PBC20_4Change(Sender: TObject);
463
    procedure PBC20_5Change(Sender: TObject);
464
    procedure PBC22_0Change(Sender: TObject);
465
    procedure PBC22_1Change(Sender: TObject);
466
    procedure PBC22_5Change(Sender: TObject);
467
    procedure PBC22_6Change(Sender: TObject);
468
    procedure PBC24_0Change(Sender: TObject);
469
    procedure PBAGChange(Sender: TObject);
470
    procedure PBCaChange(Sender: TObject);
471
    procedure PBPChange(Sender: TObject);
472
    procedure PBNaChange(Sender: TObject);
473
    procedure PBKChange(Sender: TObject);
474
    procedure PBMgChange(Sender: TObject);
475
    procedure PBClChange(Sender: TObject);
476
    procedure PBSChange(Sender: TObject);
477
    procedure PBCuChange(Sender: TObject);
478
    procedure PBZnChange(Sender: TObject);
479
    procedure PBMnChange(Sender: TObject);
480
    procedure PBFeChange(Sender: TObject);
481
    procedure PBSeChange(Sender: TObject);
482
    procedure PBCoChange(Sender: TObject);
483
    procedure PBMbChange(Sender: TObject);
484
    procedure PBIChange(Sender: TObject);
485
    procedure PBPdigGChange(Sender: TObject);
486
    procedure PBPhytaseChange(Sender: TObject);
487
    procedure PBActPhytEChange(Sender: TObject);
488
    procedure PBCBChange(Sender: TObject);
489
    procedure PBNDFChange(Sender: TObject);
490
    procedure PBADFChange(Sender: TObject);
491
    procedure PBADLChange(Sender: TObject);
492
    procedure PBParoisChange(Sender: TObject);
493
    procedure FormActivate(Sender: TObject);
494
    procedure SBPlusClick(Sender: TObject);
495
    procedure SBMoinsClick(Sender: TObject);
496
    procedure LBDroiteDblClick(Sender: TObject);
497
    procedure LBGaucheDblClick(Sender: TObject);
498
    procedure CBTypeChange(Sender: TObject);
499
    procedure LBDroiteDrawItem(Control: TWinControl; Index: Integer;
500
      Rect: TRect; State: TOwnerDrawState);
501
    procedure PBMSDChange(Sender: TObject);
502
    procedure PBQteChange(Sender: TObject);
503
    procedure PBTotalChange(Sender: TObject);
504
    procedure LBGaucheClick(Sender: TObject);
505
    procedure LBDroiteClick(Sender: TObject);
506
    procedure BBCalculClick(Sender: TObject);
507
    procedure BBGraphClick(Sender: TObject);
508
    procedure SBHautClick(Sender: TObject);
509
    procedure SBBasClick(Sender: TObject);
510
    procedure PBQteKeyPress(Sender: TObject; var Key: Char);
511
    procedure PBPdigFChange(Sender: TObject);
512
    procedure PBActPhytMChange(Sender: TObject);
513
    procedure SBSaveClick(Sender: TObject);
514
    procedure SBPrintClick(Sender: TObject);
515
    procedure FormCreate(Sender: TObject);
516
    procedure PCChange(Sender: TObject);
517
    procedure SBReplaceClick(Sender: TObject);
518
    procedure SBSortQteClick(Sender: TObject);
519
    procedure SBSortNomClick(Sender: TObject);
520
  private
521
    { D?clarations priv?es }
522
    Update, Modified : boolean ;
523
    RapMS : double ;
524
    procedure Save ;
525
    procedure CalculTMO ;
526
    procedure CalculResidu ;
527
    procedure CalculEnergie ;
528
    procedure CalculDigEDCrois ;
529
    procedure CalculDigEMCrois ;
530
    procedure CalculDigENCrois ;
531
    procedure CalculDigEDTruie ;
532
    procedure CalculDigEMTruie ;
533
    procedure CalculDigENTruie ;
534
    procedure CalculAA ;
535
    procedure CalculAG ;
536
    procedure CalculMineraux ;
537
    procedure AffichTFecale ;
538
    procedure AffichdFecale ;
539
    procedure AffichResidu ;
540
    procedure AffichEnergie ;
541
    procedure AffichTAA ;
542
    procedure AffichdAA ;
543
    procedure AffichTAG ;
544
    procedure AffichTMineraux ;
545
    procedure AffichTFibres ;
546
    procedure VerifyMP ;
547
  public
548
    { D?clarations publiques }
549
    IdxAliment : integer ;
550
    procedure AjustCaption ;
551
    procedure AjustDecimals ;
552
    procedure AjustEnabled ;
553
  end;
554

    
555
var
556
  FAliment: TFAliment;
557

    
558
implementation
559

    
560
uses
561
  Dialogs, Graphics, SysUtils, gnugettext, UVariables, UStrings, UInit, UUtil,
562
  UFindRec, UFWarning, UFCommentAli, UFGraphAli, UFRapportAli;
563

    
564
{$R *.dfm}
565

    
566
{ TFAliment }
567

    
568
procedure TFAliment.FormCreate(Sender: TObject);
569
begin
570
  if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1
571
  then
572
    Font.Name := 'Arial Unicode MS';
573
  TranslateComponent(Self);
574
  Constraints.MinWidth := 744 + (Width - ClientWidth);
575
  Width := Constraints.MinWidth;
576
  Constraints.MinHeight := 463 + (Height - ClientHeight);
577
  Height := Constraints.MinHeight;
578
  CBType.ItemIndex := 0 ;
579
end;
580

    
581
procedure TFAliment.FormShow (Sender : TObject) ;
582
begin
583
  Modified := FALSE ;
584
  AjustCaption ;
585
  AjustDecimals ;
586
//  CBTypeChange (nil) ;
587
  StringsAliment (CBAliment.Items, 0, TRUE) ;
588
  SBAdd.Enabled := IsComplete or (ListAliment.Count < 10) ;
589
  SBSave.Enabled := IsComplete or IsEducation ;
590
  IdxAliment := -1 ;
591
//  CBAlimentChange (nil) ;
592
end ;
593

    
594
procedure TFAliment.FormClose (Sender : TObject ; var Action : TCloseAction) ;
595
begin
596
  if Modified then Save ;
597
  Action := caFree ;
598
  NumWinAliment := -1 ;
599
end ;
600

    
601
procedure TFAliment.FormActivate (Sender : TObject) ;
602
var
603
  i : integer ;
604
begin
605
//  if IdxAliment <> -1
606
//  then
607
//    PAliment := ListAliment[IdxAliment] ;
608
  CBAlimentChange (nil) ;
609
  CBTypeChange (nil) ;
610

    
611
  for i := 0 to PC.PageCount - 1 do
612
    PC.Pages[i].Enabled := IsComplete or IsEducation or IsEvaluation ;
613
end ;
614

    
615
procedure TFAliment.FormDeactivate (Sender : TObject) ;
616
begin
617
  if Modified then Save ;
618
end ;
619

    
620
procedure TFAliment.Save ;
621
var
622
  s : string ;
623
begin
624
  Modified := FALSE ;
625
  if IsComplete or IsEducation
626
  then
627
    if MessageDlg (Caption + sLineBreak + MsgSave, mtConfirmation, [mbYes, mbNo], 0) = mrYes
628
    then
629
    begin
630
      SaveAliment ;
631
      if not AlimentValid (PAliment)
632
      then
633
        MessageDlg(Format (MsgInvalidData, [Caption, PAliment.Nom]), mtWarning, [mbOK], 0) ;
634
    end
635
    else
636
    begin
637
      LoadAliment ;
638
      s := CBAliment.Text ;
639
      StringsAliment (CBAliment.Items, 0, TRUE) ;
640
      if FindIdxAliment (s) = -1
641
      then
642
      begin
643
        IdxAliment := -1 ;
644
        CBAlimentChange (nil) ;
645
      end
646
      else
647
        CBAliment.ItemIndex := CBAliment.Items.IndexOf (s) ;
648
    end ;
649
end ;
650

    
651
// Adaptation des libell?s par rapport ? la configuration
652
procedure TFAliment.AjustCaption;
653
begin
654
  Hint := Format(_('Chemical composition (%s)'), [LBRap.Items[ConfRap]]);
655
  GBTFecale.Caption := Format('%s (%s)', [_('Content'), LBTCompo.Items[ConfTCompo]]);
656
  GBdFecale.Caption := Format('%s (%s)', [LBDig.Items[ConfDig], LBdCompo.Items[ConfdCompo]]);
657
  GBTAA.Caption := Format('%s (%s)', [_('Content'), LBTAA.Items[ConfTAA]]);
658
  GBdAA.Caption := Format('%s (%s)', [LBDig.Items[ConfDig], LBdAA.Items[ConfdAA]]);
659
  GBTAG.Caption := Format('%s (%s)', [_('Content'), LBTAG.Items[ConfTAG]]);
660
  GBTMacro.Caption := Format('%s (%s)', [_('Content'), LBTMacro.Items[ConfTMacro]]);
661
  GBTOligo.Caption := Format('%s (%s)', [_('Content'), LBTOligo.Items[ConfTOligo]]);
662
  LPtot.Caption := Format('%s (%s)', [_('Total phosphorus'), LBTMacro.Items[ConfTMacro]]);
663
  LPdig.Caption := Format('%s (%s)', [_('Digestible phosphorus'), LBTMacro.Items[ConfTMacro]]);
664
  GBFibres.Caption := Format('%s (%s)', [_('Content'), LBTFibres.Items[ConfTFibres]]);
665
  if ConfDig = 0
666
  then // CUD
667
  begin
668
    LdMetCys.Caption := _('Std. digestibility');
669
    LdPheTyr.Caption := _('Std. digestibility');
670
  end
671
  else // Teneur digestible
672
  begin
673
    LdMetCys.Caption := _('Std. dig. content');
674
    LdPheTyr.Caption := _('Std. dig. content');
675
  end;
676
end;
677

    
678
// Ajustement du nombre de d?cimales en fonction de la configuration
679
procedure TFAliment.AjustDecimals;
680
begin
681
  Update := TRUE;
682
  // Composition ?l?mentaire
683
  if ConfTCompo = 0
684
  then // g/kg
685
    PBTMS.Decimals := 1
686
  else // %
687
    PBTMS.Decimals := 2;
688
  PBTMM.Decimals := PBTMS.Decimals;
689
  PBTMO.Decimals := PBTMS.Decimals;
690
  PBTLip.Decimals := PBTMS.Decimals;
691
  PBTMAT.Decimals := PBTMS.Decimals;
692
  PBTAmidon.Decimals := PBTMS.Decimals;
693
  PBTSucres.Decimals := PBTMS.Decimals;
694
  PBTResidu.Decimals := PBTMS.Decimals;
695
  if (ConfDig = 0)
696
  then // CUD
697
    PBdMO_C.Decimals := 1
698
  else // Teneur digestible
699
    if ConfdCompo = 0
700
    then // g/kg
701
      PBdMO_C.Decimals := 1
702
    else // %
703
      PBdMO_C.Decimals := 2;
704
  PBdLip_C.Decimals := PBdMO_C.Decimals;
705
  PBdMAT_C.Decimals := PBdMO_C.Decimals;
706
  PBdAmidon_C.Decimals := PBdMO_C.Decimals;
707
  PBdSucres_C.Decimals := PBdMO_C.Decimals;
708
  PBdResidu_C.Decimals := PBdMO_C.Decimals;
709
  PBdMO_T.Decimals := PBdMO_C.Decimals;
710
  PBdLip_T.Decimals := PBdMO_C.Decimals;
711
  PBdMAT_T.Decimals := PBdMO_C.Decimals;
712
  PBdAmidon_T.Decimals := PBdMO_C.Decimals;
713
  PBdSucres_T.Decimals := PBdMO_C.Decimals;
714
  PBdResidu_T.Decimals := PBdMO_C.Decimals;
715
  // Acides amin?s
716
  if ConfTAA = 1
717
  then // %
718
    PBTMAT2.Decimals := 3
719
  else // %MAT ou g/kg
720
    PBTMAT2.Decimals := 2;
721
  PBTLys.Decimals := PBTMAT2.Decimals;
722
  PBTMet.Decimals := PBTMAT2.Decimals;
723
  PBTCys.Decimals := PBTMAT2.Decimals;
724
  PBTTrp.Decimals := PBTMAT2.Decimals;
725
  PBTThr.Decimals := PBTMAT2.Decimals;
726
  PBTPhe.Decimals := PBTMAT2.Decimals;
727
  PBTTyr.Decimals := PBTMAT2.Decimals;
728
  PBTLeu.Decimals := PBTMAT2.Decimals;
729
  PBTIle.Decimals := PBTMAT2.Decimals;
730
  PBTVal.Decimals := PBTMAT2.Decimals;
731
  PBTHis.Decimals := PBTMAT2.Decimals;
732
  PBTArg.Decimals := PBTMAT2.Decimals;
733
  PBTMetCys.Decimals := PBTMAT2.Decimals;
734
  PBTPheTyr.Decimals := PBTMAT2.Decimals;
735
  if ConfDig = 0
736
  then // CUD
737
    PBdMATStd.Decimals := 1
738
  else // Teneur digestible
739
    if ConfdAA = 0
740
    then // g/kg
741
      PBdMATStd.Decimals := 2
742
    else // %
743
      PBdMATStd.Decimals := 3;
744
  PBdLysStd.Decimals := PBdMATStd.Decimals;
745
  PBdMetStd.Decimals := PBdMATStd.Decimals;
746
  PBdCysStd.Decimals := PBdMATStd.Decimals;
747
  PBdTrpStd.Decimals := PBdMATStd.Decimals;
748
  PBdThrStd.Decimals := PBdMATStd.Decimals;
749
  PBdPheStd.Decimals := PBdMATStd.Decimals;
750
  PBdTyrStd.Decimals := PBdMATStd.Decimals;
751
  PBdLeuStd.Decimals := PBdMATStd.Decimals;
752
  PBdIleStd.Decimals := PBdMATStd.Decimals;
753
  PBdValStd.Decimals := PBdMATStd.Decimals;
754
  PBdHisStd.Decimals := PBdMATStd.Decimals;
755
  PBdArgStd.Decimals := PBdMATStd.Decimals;
756
  PBdMATApp.Decimals := PBdMATStd.Decimals;
757
  PBdLysApp.Decimals := PBdMATStd.Decimals;
758
  PBdMetApp.Decimals := PBdMATStd.Decimals;
759
  PBdCysApp.Decimals := PBdMATStd.Decimals;
760
  PBdTrpApp.Decimals := PBdMATStd.Decimals;
761
  PBdThrApp.Decimals := PBdMATStd.Decimals;
762
  PBdPheApp.Decimals := PBdMATStd.Decimals;
763
  PBdTyrApp.Decimals := PBdMATStd.Decimals;
764
  PBdLeuApp.Decimals := PBdMATStd.Decimals;
765
  PBdIleApp.Decimals := PBdMATStd.Decimals;
766
  PBdValApp.Decimals := PBdMATStd.Decimals;
767
  PBdHisApp.Decimals := PBdMATStd.Decimals;
768
  PBdArgApp.Decimals := PBdMATStd.Decimals;
769
  PBdMetCysStd.Decimals := PBdMATStd.Decimals;
770
  PBdMetCysApp.Decimals := PBdMATStd.Decimals;
771
  PBdPheTyrStd.Decimals := PBdMATStd.Decimals;
772
  PBdPheTyrApp.Decimals := PBdMATStd.Decimals;
773
  // Acides gras
774
  case ConfTAG of
775
    0: // g/kg
776
      PBC6C8C10_0.Decimals := 2;
777
    1: // %
778
      PBC6C8C10_0.Decimals := 3;
779
    else // % acides gras
780
      PBC6C8C10_0.Decimals := 1;
781
  end;
782
  PBC12_0.Decimals := PBC6C8C10_0.Decimals;
783
  PBC14_0.Decimals := PBC6C8C10_0.Decimals;
784
  PBC16_0.Decimals := PBC6C8C10_0.Decimals;
785
  PBC16_1.Decimals := PBC6C8C10_0.Decimals;
786
  PBC18_0.Decimals := PBC6C8C10_0.Decimals;
787
  PBC18_1.Decimals := PBC6C8C10_0.Decimals;
788
  PBC18_2.Decimals := PBC6C8C10_0.Decimals;
789
  PBC18_3.Decimals := PBC6C8C10_0.Decimals;
790
  PBC18_4.Decimals := PBC6C8C10_0.Decimals;
791
  PBC20_0.Decimals := PBC6C8C10_0.Decimals;
792
  PBC20_1.Decimals := PBC6C8C10_0.Decimals;
793
  PBC20_4.Decimals := PBC6C8C10_0.Decimals;
794
  PBC20_5.Decimals := PBC6C8C10_0.Decimals;
795
  PBC22_0.Decimals := PBC6C8C10_0.Decimals;
796
  PBC22_1.Decimals := PBC6C8C10_0.Decimals;
797
  PBC22_5.Decimals := PBC6C8C10_0.Decimals;
798
  PBC22_6.Decimals := PBC6C8C10_0.Decimals;
799
  PBC24_0.Decimals := PBC6C8C10_0.Decimals;
800
  PBC6C8C10_tot.Decimals := PBC6C8C10_0.Decimals;
801
  PBC12_tot.Decimals := PBC6C8C10_0.Decimals;
802
  PBC14_tot.Decimals := PBC6C8C10_0.Decimals;
803
  PBC16_tot.Decimals := PBC6C8C10_0.Decimals;
804
  PBC18_tot.Decimals := PBC6C8C10_0.Decimals;
805
  PBC20_tot.Decimals := PBC6C8C10_0.Decimals;
806
  PBC22_tot.Decimals := PBC6C8C10_0.Decimals;
807
  PBC24_tot.Decimals := PBC6C8C10_0.Decimals;
808
  PBCtot_tot.Decimals := PBC6C8C10_0.Decimals;
809
  PBCtot_0.Decimals := PBC6C8C10_0.Decimals;
810
  PBCtot_1.Decimals := PBC6C8C10_0.Decimals;
811
  PBCtot_2.Decimals := PBC6C8C10_0.Decimals;
812
  PBCtot_3.Decimals := PBC6C8C10_0.Decimals;
813
  PBCtot_4.Decimals := PBC6C8C10_0.Decimals;
814
  PBCtot_5.Decimals := PBC6C8C10_0.Decimals;
815
  PBCtot_6.Decimals := PBC6C8C10_0.Decimals;
816
  // Min?raux
817
  if ConfTMacro = 0
818
  then // g/kg
819
    PBCa.Decimals := 2
820
  else // %
821
    PBCa.Decimals := 3;
822
  PBP.Decimals := PBCa.Decimals;
823
  PBNa.Decimals := PBCa.Decimals;
824
  PBK.Decimals := PBCa.Decimals;
825
  PBMg.Decimals := PBCa.Decimals;
826
  PBCl.Decimals := PBCa.Decimals;
827
  PBS.Decimals := PBCa.Decimals;
828
  if ConfTOligo = 0
829
  then // mg/kg
830
    PBCu.Decimals := 2
831
  else // %
832
    PBCu.Decimals := 6;
833
  PBZn.Decimals := PBCu.Decimals;
834
  PBMn.Decimals := PBCu.Decimals;
835
  PBFe.Decimals := PBCu.Decimals;
836
  PBSe.Decimals := PBCu.Decimals;
837
  PBCo.Decimals := PBCu.Decimals;
838
  PBMb.Decimals := PBCu.Decimals;
839
  PBI.Decimals := PBCu.Decimals;
840
  PBPtot.Decimals := PBCa.Decimals;
841
  PBPdigG.Decimals := PBCa.Decimals;
842
  PBPdigF.Decimals := PBCa.Decimals;
843
  // Fibres
844
  if ConfTFibres = 0
845
  then // g/kg
846
    PBCB.Decimals := 1
847
  else // %
848
    PBCB.Decimals := 2;
849
  PBNDF.Decimals := PBCB.Decimals;
850
  PBADF.Decimals := PBCB.Decimals;
851
  PBADL.Decimals := PBCB.Decimals;
852
  PBParois.Decimals := PBCB.Decimals;
853
  Update := FALSE;
854
end;
855

    
856
// Activation (ou non) des champs de saisie
857
procedure TFAliment.AjustEnabled;
858
begin
859
  if IdxAliment = -1
860
  then
861
    SBDel.Enabled := FALSE
862
  else
863
    SBDel.Enabled := TRUE ;
864
  SBRename.Enabled := SBDel.Enabled ;
865
  SBComment.Enabled := SBDel.Enabled ;
866
  SBSave.Enabled := SBDel.Enabled ;
867
  SBPrint.Enabled := SBDel.Enabled ;
868
  if PC.Visible
869
  then
870
  begin
871
    // Composition ?l?mentaire
872
    if PAliment.CC.MS = 0
873
    then
874
      PBTMM.Enabled := FALSE
875
    else
876
      PBTMM.Enabled := TRUE ;
877
    PBTLip.Enabled := PBTMM.Enabled ;
878
    PBTMAT.Enabled := PBTMM.Enabled ;
879
    PBTAmidon.Enabled := PBTMM.Enabled ;
880
    PBTSucres.Enabled := PBTMM.Enabled ;
881
    PBdMO_C.Enabled := PBTMM.Enabled ;
882
    PBdLip_C.Enabled := PBTMM.Enabled ;
883
    PBdMAT_C.Enabled := PBTMM.Enabled ;
884
    PBdMO_T.Enabled := PBTMM.Enabled ;
885
    PBdLip_T.Enabled := PBTMM.Enabled ;
886
    PBdMAT_T.Enabled := PBTMM.Enabled ;
887
    CBAAsMAT.Enabled := PBTMM.Enabled ;
888
    CBCorrCUD.Enabled := PBTMM.Enabled ;
889
    // Acides amin?s
890
    PBTLys.Enabled := PBTMM.Enabled ;
891
    PBTMet.Enabled := PBTMM.Enabled and not CBAAsLys.Checked ;
892
    PBTCys.Enabled := PBTMet.Enabled ;
893
    PBTTrp.Enabled := PBTMet.Enabled ;
894
    PBTThr.Enabled := PBTMet.Enabled ;
895
    PBTPhe.Enabled := PBTMet.Enabled ;
896
    PBTTyr.Enabled := PBTMet.Enabled ;
897
    PBTLeu.Enabled := PBTMet.Enabled ;
898
    PBTIle.Enabled := PBTMet.Enabled ;
899
    PBTVal.Enabled := PBTMet.Enabled ;
900
    PBTHis.Enabled := PBTMet.Enabled ;
901
    PBTArg.Enabled := PBTMet.Enabled ;
902
    PBdMATStd.Enabled := PBTMM.Enabled ;
903
    PBdLysStd.Enabled := PBTMM.Enabled ;
904
    PBdMetStd.Enabled := PBTMM.Enabled ;
905
    PBdCysStd.Enabled := PBTMM.Enabled ;
906
    PBdTrpStd.Enabled := PBTMM.Enabled ;
907
    PBdThrStd.Enabled := PBTMM.Enabled ;
908
    PBdPheStd.Enabled := PBTMM.Enabled ;
909
    PBdTyrStd.Enabled := PBTMM.Enabled ;
910
    PBdLeuStd.Enabled := PBTMM.Enabled ;
911
    PBdIleStd.Enabled := PBTMM.Enabled ;
912
    PBdValStd.Enabled := PBTMM.Enabled ;
913
    PBdHisStd.Enabled := PBTMM.Enabled ;
914
    PBdArgStd.Enabled := PBTMM.Enabled ;
915
    CBAAsLys.Enabled := PBTMM.Enabled ;
916
    // Acides gras
917
    PBC6C8C10_0.Enabled := PBTMM.Enabled ;
918
    PBC12_0.Enabled := PBTMM.Enabled ;
919
    PBC14_0.Enabled := PBTMM.Enabled ;
920
    PBC16_0.Enabled := PBTMM.Enabled ;
921
    PBC16_1.Enabled := PBTMM.Enabled ;
922
    PBC18_0.Enabled := PBTMM.Enabled ;
923
    PBC18_1.Enabled := PBTMM.Enabled ;
924
    PBC18_2.Enabled := PBTMM.Enabled ;
925
    PBC18_3.Enabled := PBTMM.Enabled ;
926
    PBC18_4.Enabled := PBTMM.Enabled ;
927
    PBC20_0.Enabled := PBTMM.Enabled ;
928
    PBC20_1.Enabled := PBTMM.Enabled ;
929
    PBC20_4.Enabled := PBTMM.Enabled ;
930
    PBC20_5.Enabled := PBTMM.Enabled ;
931
    PBC22_0.Enabled := PBTMM.Enabled ;
932
    PBC22_1.Enabled := PBTMM.Enabled ;
933
    PBC22_5.Enabled := PBTMM.Enabled ;
934
    PBC22_6.Enabled := PBTMM.Enabled ;
935
    PBC24_0.Enabled := PBTMM.Enabled ;
936
    PBAG.Enabled := PBTMM.Enabled ;
937
    // Min?raux
938
    PBCa.Enabled := PBTMM.Enabled ;
939
    PBP.Enabled := PBTMM.Enabled ;
940
    PBNa.Enabled := PBTMM.Enabled ;
941
    PBK.Enabled := PBTMM.Enabled ;
942
    PBMg.Enabled := PBTMM.Enabled ;
943
    PBCl.Enabled := PBTMM.Enabled ;
944
    PBS.Enabled := PBTMM.Enabled ;
945
    PBCu.Enabled := PBTMM.Enabled ;
946
    PBZn.Enabled := PBTMM.Enabled ;
947
    PBMn.Enabled := PBTMM.Enabled ;
948
    PBFe.Enabled := PBTMM.Enabled ;
949
    PBSe.Enabled := PBTMM.Enabled ;
950
    PBCo.Enabled := PBTMM.Enabled ;
951
    PBMb.Enabled := PBTMM.Enabled ;
952
    PBI.Enabled := PBTMM.Enabled ;
953
    PBPdigG.Enabled := PBTMM.Enabled ;
954
    PBPdigF.Enabled := PBTMM.Enabled ;
955
    PBPhytase.Enabled := PBTMM.Enabled ;
956
    PBActPhytE.Enabled := PBTMM.Enabled ;
957
    PBActPhytM.Enabled := PBTMM.Enabled ;
958
    // Fibres
959
    PBCB.Enabled := PBTMM.Enabled ;
960
    PBNDF.Enabled := PBTMM.Enabled ;
961
    PBADF.Enabled := PBTMM.Enabled ;
962
    PBADL.Enabled := PBTMM.Enabled ;
963
    PBParois.Enabled := PBTMM.Enabled ;
964
  end ;
965
end ;
966

    
967
procedure TFAliment.CBAlimentChange (Sender : TObject) ;
968
var
969
  i : integer ;
970
begin
971
  if (IdxAliment <> -1) and (CBAliment.Text <> PAliment.Nom)
972
  then
973
    if Modified then Save ;
974
  IdxAliment := FindIdxAliment (CBAliment.Text) ;
975
  if IdxAliment = -1
976
  then // Pas d'enregistrement
977
  begin
978
    CBAliment.Repaint ;
979
    PC.ActivePageIndex := 0 ;
980
    PC.Visible := FALSE ;
981
    AjustEnabled ;
982
  end
983
  else // Affichage de l'enregistrement
984
  begin
985
    PC.Visible := TRUE ;
986
    PAliment := ListAliment[IdxAliment] ;
987
    with PAliment^ do
988
      CBAliment.Hint := Memo ;
989
    with PAliment.CC do
990
      if ConfRap = 0
991
      then // sur frais
992
        RapMS := MS / 1000
993
      else // sur mati?re s?che
994
        RapMS := 1 ;
995
    AjustEnabled ;
996
    Update := TRUE ;
997
    // Composition ?l?mentaire
998
    // Certaines donn?es calcul?es sont stock?es...
999
    // On les recalcule tout de m?me avant de les afficher !
1000
    CalculTMO ;
1001
    CalculResidu ;
1002
    CalculEnergie ;
1003
    AffichTFecale ;
1004
    AffichdFecale ;
1005
    AffichResidu ;
1006
    AffichEnergie ;
1007
    // Acides amin?s
1008
    AffichTAA ;
1009
    AffichdAA ;
1010
    CalculAA ;
1011
    // Acides gras
1012
    with PAliment.CC do
1013
      PBLip2.AsFloat := Lip * RapMS ;
1014
    with PAliment.CC do
1015
      PBAG.AsFloat := AGsLip ;
1016
    AffichTAG ;
1017
    CalculAG ;
1018
    // Min?raux
1019
    AffichTMineraux ;
1020
    CalculMineraux ;
1021
    // Fibres
1022
    AffichTFibres ;
1023
    Update := FALSE ;
1024
    CBAAsMAT.Checked := TRUE ;
1025
    CBCorrCUD.Checked := FALSE ;
1026
    // Mati?res premi?res
1027
    TSMatiere.TabVisible := ConfAffMP ;
1028
    LBDroite.Clear ;
1029
    PBTotal.AsFloat := 0 ;
1030
    if PAliment.MP.NbMat > 0
1031
    then
1032
      for i := 0 to PAliment.MP.NbMat - 1 do
1033
      begin
1034
        if PAliment.MP.NumMat[i] = 0
1035
        then
1036
          LBDroite.Items.Add ('')
1037
        else
1038
          LBDroite.Items.Add (FindNomMatiere (PAliment.MP.NumMat[i])) ;
1039
        PBTotal.AsFloat := PBTotal.AsFloat + PAliment.MP.Qte[i] ;
1040
      end ;
1041
    LBDroiteClick (nil) ;
1042
    LBGauche.ItemIndex := -1 ;
1043
    LBGaucheClick (nil) ;
1044
    case PAliment.Typ of
1045
      1 : // Porc croissance
1046
      begin
1047
        PBEDG.Hint := Format ('%s (%s/%s %s)', [StrED_C, StrMJ, StrKg, StrFrais]) ;
1048
        PBEMG.Hint := Format ('%s (%s/%s %s)', [StrEM_C, StrMJ, StrKg, StrFrais]) ;
1049
        PBENG.Hint := Format ('%s (%s/%s %s)', [StrEN_C, StrMJ, StrKg, StrFrais]) ;
1050
      end ;
1051
      2 : // Truie reproductrice
1052
      begin
1053
        PBEDG.Hint := Format ('%s (%s/%s %s)', [StrED_T, StrMJ, StrKg, StrFrais]) ;
1054
        PBEMG.Hint := Format ('%s (%s/%s %s)', [StrEM_T, StrMJ, StrKg, StrFrais]) ;
1055
        PBENG.Hint := Format ('%s (%s/%s %s)', [StrEN_T, StrMJ, StrKg, StrFrais]) ;
1056
      end ;
1057
      else
1058
      begin
1059
        PBEDG.Hint := StrTyp0 ;
1060
        PBEMG.Hint := StrTyp0 ;
1061
        PBENG.Hint := StrTyp0 ;
1062
      end ;
1063
    end ;
1064
    LEDG.Hint := PBEDG.Hint ;
1065
    LEMG.Hint := PBEMG.Hint ;
1066
    LENG.Hint := PBENG.Hint ;
1067
    if PAliment.MP.NbMat = 0
1068
    then
1069
      SBMoins.Enabled := FALSE
1070
    else
1071
      SBMoins.Enabled := TRUE ;
1072
    if PAliment.MP.NbMat > MAX_MP
1073
    then
1074
      SBPlus.Enabled := FALSE
1075
    else
1076
      SBPlus.Enabled := TRUE ;
1077
    VerifyMP ;
1078
  end ;
1079
end ;
1080

    
1081
procedure TFAliment.SBAddClick (Sender : TObject) ;
1082
var
1083
  i, n, q : integer ;
1084
  s : string ;
1085
  ok : boolean ;
1086
  PBackup : PRecAliment ;
1087
begin
1088
  if Modified then Save ;
1089
  if IdxAliment = -1
1090
  then
1091
    q := mrNo
1092
  else
1093
    q := MessageDlg (MsgCopy, mtConfirmation, [mbYes, mbNo], 0) ;
1094
  // saisie du nouveau nom
1095
  s := '' ;
1096
  repeat
1097
    if InputQuery (FAliment.Caption, MsgName, s)
1098
    then // V?rification du nom
1099
    begin
1100
      s := Trim (s) ; // Suppression des espaces au d?but et ? la fin
1101
      if s = ''
1102
      then // Pas de nom
1103
      begin
1104
        ok := FALSE ;
1105
        MessageDlg (MsgNameEmpty, mtWarning, [mbOk], 0) ;
1106
      end
1107
      else
1108
        if Length (s) > 35
1109
        then // Nom trop long
1110
        begin
1111
          ok := FALSE ;
1112
          MessageDlg (Format (MsgNameTooLarge, [35]), mtWarning, [mbOk], 0) ;
1113
          s := Copy (s, 1, 35) ;
1114
        end
1115
        else
1116
        begin
1117
          ok := TRUE ;
1118
          i := 0 ;
1119
          while ok and (i < ListAliment.Count) do
1120
          begin
1121
            PAliment := ListAliment[i] ;
1122
            if PAliment.Nom = s
1123
            then // Nom d?j? utilis?
1124
            begin
1125
              ok := FALSE ;
1126
              MessageDlg (MsgNameExists, mtWarning, [mbOk], 0) ;
1127
            end
1128
            else
1129
              Inc (i) ;
1130
          end ;
1131
        end ;
1132
    end
1133
    else // Annulation
1134
    begin
1135
      s := '' ;
1136
      if (IdxAliment <> -1)
1137
      then
1138
        PAliment := ListAliment[IdxAliment] ;
1139
      ok := TRUE ;
1140
    end ;
1141
  until ok ;
1142
  if s <> ''
1143
  then // Cr?ation du nouvel enregistrement
1144
  begin
1145
    // recherche du premier num?ro libre
1146
    n := 0 ;
1147
    repeat
1148
      Inc (n) ;
1149
      ok := TRUE ;
1150
      i := 0 ;
1151
      while ok and (i < ListAliment.Count) do
1152
      begin
1153
        PAliment := ListAliment[i] ;
1154
        if PAliment.Num = n
1155
        then
1156
          ok := FALSE
1157
        else
1158
          Inc (i) ;
1159
      end ;
1160
    until ok ;
1161
    New (PAliment) ;
1162
    with PAliment^ do
1163
    begin
1164
      Nom := s ;
1165
      Num := n ;
1166
      if q = mrYes
1167
      then
1168
      begin
1169
        PBackup := ListAliment[IdxAliment] ;
1170
        Memo := PBackup.Memo ;
1171
        Typ := PBackup.Typ ;
1172
        Presentation := PBackup.Presentation ;
1173
        Prix := PBackup.Prix ;
1174
        MP := PBackup.MP ;
1175
        CC := PBackup.CC ;
1176
        for i := 0 to 12 do
1177
          AAtotal[i] := PBackup.AATotal[i] ;
1178
        for i := 0 to 12 do
1179
          CUDAA[i] := PBackup.CUDAA[i] ;
1180
      end
1181
      else
1182
      begin
1183
        Memo := '' ;
1184
        Typ := 0 ;
1185
        Presentation := 0 ;
1186
        Prix := 0 ;
1187
        MP.NbMat := 0 ;
1188
        for i := 0 to MAX_MP do
1189
        begin
1190
          MP.NumMat[i] := 0 ;
1191
          MP.MS[i] := 0 ;
1192
          MP.Qte[i] := 0 ;
1193
        end ;
1194
        CC := CCVide ;
1195
        for i := 0 to 12 do
1196
          AAtotal[i] := 0 ;
1197
        for i := 0 to 12 do
1198
          CUDAA[i] := 0 ;
1199
        if ConfAffMP
1200
        then
1201
          PC.ActivePage := TSMatiere
1202
        else
1203
          PC.ActivePage := TSElem ;
1204
        PCChange(nil);
1205
      end ;
1206
    end ;
1207
    ListAliment.Add (PAliment) ;
1208
    CBAliment.Items.Add (PAliment.Nom) ;
1209
    CBAliment.ItemIndex := CBAliment.Items.IndexOf (PAliment.Nom) ;
1210
    CBAlimentChange (nil) ;
1211
    Modified := TRUE ;
1212
    SBAdd.Enabled := IsComplete or (ListAliment.Count < 10) ;
1213
    SBCommentClick (nil) ;
1214
  end ;
1215
end ;
1216

    
1217
procedure TFAliment.SBDelClick (Sender : TObject) ;
1218
begin
1219
  if AlimentUsed (PAliment.Num)
1220
  then // Enregistrement utilis?
1221
    MessageDlg (MsgDelErr, mtWarning, [mbOk], 0)
1222
  else // Suppression de l'enregistrement
1223
    if MessageDlg (MsgDel, mtConfirmation, [mbYes, mbNo], 0) = mrYes
1224
    then
1225
    begin
1226
      Dispose (PAliment) ;
1227
      ListAliment.Delete (IdxAliment) ;
1228
      SaveAliment ; // Sauvegarde !
1229
      Modified := FALSE ;
1230
      CBAliment.DeleteSelected ;
1231
      IdxAliment := -1 ;
1232
      CBAliment.ItemIndex := -1 ;
1233
      CBAlimentChange (nil) ;
1234
      SBAdd.Enabled := IsComplete or (ListAliment.Count < 10) ;
1235
    end ;
1236
end ;
1237

    
1238
procedure TFAliment.SBRenameClick (Sender : TObject) ;
1239
var
1240
  i : integer ;
1241
  s : string ;
1242
  ok : boolean ;
1243
begin
1244
  // Saisie du nouveau nom
1245
  s := CBAliment.Text ;
1246
  repeat
1247
    if InputQuery (FAliment.Caption, MsgRename, s) and (s <> CBAliment.Text)
1248
    then // V?rification du nom
1249
    begin
1250
      s := Trim (s) ; // Suppression des espaces au d?but et ? la fin
1251
      if s = ''
1252
      then // Pas de nom
1253
      begin
1254
        ok := FALSE ;
1255
        MessageDlg (MsgNameEmpty, mtWarning, [mbOk], 0) ;
1256
      end
1257
      else
1258
        if Length (s) > 35
1259
        then // Nom trop long
1260
        begin
1261
          ok := FALSE ;
1262
          MessageDlg (Format (MsgNameTooLarge, [35]), mtWarning, [mbOk], 0) ;
1263
          s := Copy (s, 1, 35) ;
1264
        end
1265
        else
1266
        begin
1267
          ok := TRUE ;
1268
          i := 0 ;
1269
          while ok and (i < ListAliment.Count) do
1270
          begin
1271
            PAliment := ListAliment[i] ;
1272
            if PAliment.Nom = s
1273
            then // Nom d?j? utilis?
1274
            begin
1275
              ok := FALSE ;
1276
              MessageDlg (MsgNameExists, mtWarning, [mbOk], 0) ;
1277
            end
1278
            else
1279
              Inc (i) ;
1280
          end ;
1281
        end ;
1282
    end
1283
    else // Annulation
1284
    begin
1285
      s := '' ;
1286
      ok := TRUE ;
1287
    end ;
1288
  until ok ;
1289
  PAliment := ListAliment[IdxAliment] ;
1290
  if s <> ''
1291
  then // Renommer l'enregistrement
1292
  begin
1293
    PAliment.Nom := s ;
1294
    Modified := TRUE ;
1295
    StringsAliment (CBAliment.Items, 0, TRUE) ;
1296
    CBAliment.ItemIndex := CBAliment.Items.IndexOf (s) ;
1297
  end ;
1298
end ;
1299

    
1300
procedure TFAliment.SBCommentClick (Sender : TObject) ;
1301
begin
1302
  // Saisie du commentaire
1303
  FCommentAli := TFCommentAli.Create (Self) ;
1304
  with FCommentAli do
1305
  begin
1306
    Memo.Text := PAliment.Memo ;
1307
    CBType.ItemIndex := PAliment.Typ ;
1308
    CBPresentation.ItemIndex := PAliment.Presentation ;
1309
    PBPrix.AsFloat := PAliment.Prix ;
1310
    LMonnaie.Caption := Format ('%s / 1000 %s', [CurrencySign, StrKg]) ;
1311
    if ShowModal = mrOk
1312
    then // Commenter l'enregistrement
1313
    begin
1314
      PAliment.Memo := Memo.Text ;
1315
      PAliment.Typ := CBType.ItemIndex ;
1316
      PAliment.Presentation := CBPresentation.ItemIndex ;
1317
      PAliment.Prix := PBPrix.AsFloat ;
1318
      Modified := TRUE ;
1319
      CBAliment.Hint := PAliment.Memo ;
1320
    end ;
1321
    Release ;
1322
  end ;
1323
end ;
1324

    
1325
procedure TFAliment.SBSaveClick(Sender: TObject);
1326
begin
1327
  SaveAliment ;
1328
  if not AlimentValid (PAliment)
1329
  then
1330
    MessageDlg(Format (MsgInvalidData, [Caption, PAliment.Nom]), mtWarning, [mbOK], 0) ;
1331
  Modified := FALSE ;
1332
end;
1333

    
1334
procedure TFAliment.SBPrintClick(Sender: TObject);
1335
begin
1336
  FRapportAli := TFRapportAli.Create (Self) ;
1337
  FRapportAli.ShowModal ;
1338
  FRapportAli.Release ;
1339
end;
1340

    
1341
////////////////////////////////////////////////////////////////////////////////
1342
// Composition ?l?mentaire
1343
////////////////////////////////////////////////////////////////////////////////
1344

    
1345
// Mati?re organique = Mati?re s?che - Mati?res min?rales
1346
procedure TFAliment.CalculTMO ;
1347
begin
1348
  with PAliment.CC do
1349
    MO := 1000 - MM ;
1350
  // Affichage de la valeur
1351
  if ConfTCompo = 0
1352
  then // g/kg
1353
    with PAliment.CC do
1354
      PBTMO.AsFloat := MO * RapMS
1355
  else // %
1356
    with PAliment.CC do
1357
      PBTMO.AsFloat := MO / 1000 * 100 * RapMS ;
1358
end ;
1359

    
1360
procedure TFAliment.CalculResidu ;
1361
begin
1362
  with PAliment.CC do
1363
  begin
1364
    // R?sidu = Mati?re s?che - (Mati?re min?rale + Mati?res azot?es + Mati?res grasses + Amidon + Sucres + Cellulose brute)
1365
    if MM + MAT + Lip + Amidon + Sucres + CB > 1000
1366
    then
1367
      Residu := 0
1368
    else
1369
      Residu := 1000 - (MM + MAT + Lip + Amidon + Sucres + CB) ;
1370
    // CUD R?sidu
1371
    if CB + Residu > 0
1372
    then
1373
    begin
1374
      dResidu_C := (MO * dMO_C - (MAT * dMAT_C + Lip * dLip_C + Amidon * 100 + Sucres * 100)) / (CB + Residu) ;
1375
      dResidu_T := (MO * dMO_T - (MAT * dMAT_T + Lip * dLip_T + Amidon * 100 + Sucres * 100)) / (CB + Residu) ;
1376
    end
1377
    else
1378
    begin
1379
      dResidu_C := 0 ;
1380
      dResidu_T := 0 ;
1381
    end ;
1382
    // CUD Cellulose brute = CUD R?sidu
1383
    dCB_C := dResidu_C ;
1384
    dCB_T := dResidu_T ;
1385
  end ;
1386
end ;
1387

    
1388
procedure TFAliment.AffichResidu ;
1389
begin
1390
  with PAliment.CC do
1391
  begin
1392
    // Teneur
1393
    if ConfTCompo = 0
1394
    then // g/kg
1395
      PBTResidu.AsFloat := (Residu + CB) * RapMS
1396
    else // %
1397
      PBTResidu.AsFloat := (Residu + CB) / 1000 * 100 * RapMS ;
1398
    // Digestibilit?
1399
    if ConfDig = 0
1400
    then // CUD
1401
    begin
1402
      // Croissance
1403
      PBdResidu_C.AsFloat := dResidu_C ;
1404
      // Truie
1405
      PBdResidu_T.AsFloat := dResidu_T ;
1406
    end
1407
    else // Teneur digestible
1408
      if ConfdCompo = 0
1409
      then // g/kg
1410
      begin
1411
        // Croissance
1412
        PBdResidu_C.AsFloat := (Residu + CB) * dResidu_C / 100 * RapMS ;
1413
        // Truie
1414
        PBdResidu_T.AsFloat := (Residu + CB) * dResidu_T / 100 * RapMS ;
1415
      end
1416
      else // %
1417
      begin
1418
        // Croissance
1419
        PBdResidu_C.AsFloat := (Residu + CB) / 1000 * dResidu_C * RapMS ;
1420
        // Truie
1421
        PBdResidu_T.AsFloat := (Residu + CB) / 1000 * dResidu_T * RapMS ;
1422
      end ;
1423
  end ;
1424
end ;
1425

    
1426
// Affichage de la teneur en fonction de la configuration
1427
procedure TFAliment.AffichTFecale ;
1428
begin
1429
  if ConfTCompo = 0
1430
  then // g/kg
1431
    with PAliment.CC do
1432
    begin
1433
      if ActiveControl <> PBTMS
1434
      then
1435
        PBTMS.AsFloat := MS ;
1436
      PBTMM.AsFloat := MM * RapMS ;
1437
      PBTMO.AsFloat := MO * RapMS ;
1438
      PBTLip.AsFloat := Lip * RapMS ;
1439
      PBTMAT.AsFloat := MAT * RapMS ;
1440
      PBTAmidon.AsFloat := Amidon * RapMS ;
1441
      PBTSucres.AsFloat := Sucres * RapMS ;
1442
    end
1443
  else // %
1444
    with PAliment.CC do
1445
    begin
1446
      if ActiveControl <> PBTMS
1447
      then
1448
        PBTMS.AsFloat := MS / 1000 * 100 ;
1449
      PBTMM.AsFloat := MM / 1000 * 100 * RapMS ;
1450
      PBTMO.AsFloat := MO / 1000 * 100 * RapMS ;
1451
      PBTLip.AsFloat := Lip / 1000 * 100 * RapMS ;
1452
      PBTMAT.AsFloat := MAT / 1000 * 100 * RapMS ;
1453
      PBTAmidon.AsFloat := Amidon / 1000 * 100 * RapMS ;
1454
      PBTSucres.AsFloat := Sucres / 1000 * 100 * RapMS ;
1455
    end ;
1456
{
1457
  // Hint (temporaire)
1458
  with PAliment.CC do
1459
  begin
1460
    PBTMS.Hint := FloatToStr(MS);
1461
    PBTMM.Hint := FloatToStr(MM * RapMS);
1462
    PBTLip.Hint := FloatToStr(Lip * RapMS);
1463
    PBTMAT.Hint := FloatToStr(MAT * RapMS);
1464
    PBTAmidon.Hint := FloatToStr(Amidon * RapMS);
1465
    PBTSucres.Hint := FloatToStr(Sucres * RapMS);
1466
  end;
1467
}
1468
end ;
1469

    
1470
// Affichage de la digestibilit? f?cale en fonction de la configuration
1471
procedure TFAliment.AffichdFecale ;
1472
begin
1473
  if ConfDig = 0
1474
  then // CUD
1475
    with PAliment.CC do
1476
    begin
1477
      // Croissance
1478
      PBdMO_C.AsFloat := dMO_C ;
1479
      PBdLip_C.AsFloat := dLip_C ;
1480
      PBdMAT_C.AsFloat := dMAT_C ;
1481
      PBdAmidon_C.AsFloat := 100 ; // CUD Amidon = 100 %
1482
      PBdSucres_C.AsFloat := 100 ; // CUD Sucres = 100 %
1483
      // Truie
1484
      PBdMO_T.AsFloat := dMO_T ;
1485
      PBdLip_T.AsFloat := dLip_T ;
1486
      PBdMAT_T.AsFloat := dMAT_T ;
1487
      PBdAmidon_T.AsFloat := 100 ; // CUD Amidon = 100 %
1488
      PBdSucres_T.AsFloat := 100 ; // CUD Sucres = 100 %
1489
    end
1490
  else // Teneur digestible
1491
    if ConfdCompo = 0
1492
    then // g/kg
1493
      with PAliment.CC do
1494
      begin
1495
        // Croissance
1496
        PBdMO_C.AsFloat := MO * dMO_C / 100 * RapMS ;
1497
        PBdLip_C.AsFloat := Lip * dLip_C / 100 * RapMS ;
1498
        PBdMAT_C.AsFloat := MAT * dMAT_C / 100 * RapMS ;
1499
        PBdAmidon_C.AsFloat := Amidon * RapMS ;
1500
        PBdSucres_C.AsFloat := Sucres * RapMS ;
1501
        // Truie
1502
        PBdMO_T.AsFloat := MO * dMO_T / 100 * RapMS ;
1503
        PBdLip_T.AsFloat := Lip * dLip_T / 100 * RapMS ;
1504
        PBdMAT_T.AsFloat := MAT * dMAT_T / 100 * RapMS ;
1505
        PBdAmidon_T.AsFloat := Amidon * RapMS ;
1506
        PBdSucres_T.AsFloat := Sucres * RapMS ;
1507
      end
1508
    else // %
1509
      with PAliment.CC do
1510
      begin
1511
        // Croissance
1512
        PBdMO_C.AsFloat := MO / 1000 * dMO_C * RapMS ;
1513
        PBdLip_C.AsFloat := Lip / 1000 * dLip_C * RapMS ;
1514
        PBdMAT_C.AsFloat := MAT / 1000 * dMAT_C * RapMS ;
1515
        PBdAmidon_C.AsFloat := Amidon / 1000 * 100 * RapMS ;
1516
        PBdSucres_C.AsFloat := Sucres / 1000 * 100 * RapMS ;
1517
        // Truie
1518
        PBdMO_T.AsFloat := MO / 1000 * dMO_T * RapMS ;
1519
        PBdLip_T.AsFloat := Lip / 1000 * dLip_T * RapMS ;
1520
        PBdMAT_T.AsFloat := MAT / 1000 * dMAT_T * RapMS ;
1521
        PBdAmidon_T.AsFloat := Amidon / 1000 * 100 * RapMS ;
1522
        PBdSucres_T.AsFloat := Sucres / 1000 * 100 * RapMS ;
1523
      end ;
1524
{
1525
  // Hint (temporaire)
1526
  with PAliment.CC do
1527
  begin
1528
    PBdMO_C.Hint := FloatToStr(dMO_C);
1529
    PBdLip_C.Hint := FloatToStr(dLip_C);
1530
    PBdMAT_C.Hint := FloatToStr(dMAT_C);
1531
    PBdMO_T.Hint := FloatToStr(dMO_T);
1532
    PBdLip_T.Hint := FloatToStr(dLip_T);
1533
    PBdMAT_T.Hint := FloatToStr(dMAT_T);
1534
  end;
1535
}
1536
end ;
1537

    
1538
procedure TFAliment.CalculEnergie ;
1539
begin
1540
  with PAliment.CC do
1541
  begin
1542
{
1543
    EB := (22.64 * MAT + 38.76 * Lip + 17.54 * Amidon + 16.71 * Sucres + 18.58 * (Residu + CB)) / 1000 ;
1544
    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 ;
1545
    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 ;
1546
    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 ;
1547
    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 ;
1548
    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 ;
1549
    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 ;
1550
}
1551
    EB := (ValEnergie[1, 1] * MAT + ValEnergie[2, 1] * Lip
1552
      + ValEnergie[3, 1] * Amidon + ValEnergie[4, 1] * Sucres
1553
      + ValEnergie[6, 1] * (Residu + CB)) / 1000 ;
1554
    ED_C := (ValEnergie[1, 2] * MAT * dMAT_C / 100
1555
      + ValEnergie[2, 2] * Lip * dLip_C / 100
1556
      + ValEnergie[3, 2] * Amidon + ValEnergie[4, 2] * Sucres
1557
      + ValEnergie[6, 2] * (Residu + CB) * dResidu_C / 100) / 1000 ;
1558
    ED_T := (ValEnergie[1, 2] * MAT * dMAT_T / 100
1559
      + ValEnergie[2, 2] * Lip * dLip_T / 100
1560
      + ValEnergie[3, 2] * Amidon + ValEnergie[4, 2] * Sucres
1561
      + ValEnergie[6, 2] * (Residu + CB) * dResidu_T / 100) / 1000 ;
1562
    EM_C := (ValEnergie[1, 3] * MAT * dMAT_C / 100
1563
      + ValEnergie[2, 3] * Lip * dLip_C / 100
1564
      + ValEnergie[3, 3] * Amidon + ValEnergie[4, 3] * Sucres
1565
      + ValEnergie[6, 3] * (Residu + CB) * dResidu_C / 100) / 1000 ;
1566
    EM_T := (ValEnergie[1, 3] * MAT * dMAT_T / 100
1567
      + ValEnergie[2, 3] * Lip * dLip_T / 100
1568
      + ValEnergie[3, 3] * Amidon + ValEnergie[4, 3] * Sucres
1569
      + ValEnergie[6, 3] * (Residu + CB) * dResidu_T / 100) / 1000 ;
1570
    EN_C := (ValEnergie[1, 6] * MAT * dMAT_C / 100
1571
      + ValEnergie[2, 6] * Lip * dLip_C / 100
1572
      + ValEnergie[3, 6] * Amidon + ValEnergie[4, 6] * Sucres
1573
      + ValEnergie[6, 6] * (Residu + CB) * dResidu_C / 100) / 1000 ;
1574
    EN_T := (ValEnergie[1, 6] * MAT * dMAT_T / 100
1575
      + ValEnergie[2, 6] * Lip * dLip_T / 100
1576
      + ValEnergie[3, 6] * Amidon + ValEnergie[4, 6] * Sucres
1577
      + ValEnergie[6, 6] * (Residu + CB) * dResidu_T / 100) / 1000 ;
1578
  end ;
1579
end ;
1580

    
1581
procedure TFAliment.AffichEnergie ;
1582
begin
1583
  with PAliment.CC do
1584
  begin
1585
    // Croissance
1586
    PBEB_C.AsFloat := EB * RapMS ;
1587
    if ActiveControl <> PBED_C
1588
    then
1589
      PBED_C.AsFloat := ED_C * RapMS ;
1590
    if ActiveControl <> PBEM_C
1591
    then
1592
      PBEM_C.AsFloat := EM_C * RapMS ;
1593
    if ActiveControl <> PBEN_C
1594
    then
1595
      PBEN_C.AsFloat := EN_C * RapMS ;
1596
    // Truie
1597
    PBEB_T.AsFloat := EB * RapMS ;
1598
    if ActiveControl <> PBED_T
1599
    then
1600
      PBED_T.AsFloat := ED_T * RapMS ;
1601
    if ActiveControl <> PBEM_T
1602
    then
1603
      PBEM_T.AsFloat := EM_T * RapMS ;
1604
    if ActiveControl <> PBEN_T
1605
    then
1606
      PBEN_T.AsFloat := EN_T * RapMS ;
1607
    // ED / EB
1608
    if EB = 0
1609
    then
1610
    begin
1611
      PBEDsEB_C.Text := '' ;
1612
      PBEDsEB_T.Text := '' ;
1613
    end
1614
    else
1615
    begin
1616
      PBEDsEB_C.AsFloat := ED_C / EB * 100 ;
1617
      PBEDsEB_T.AsFloat := ED_T / EB * 100 ;
1618
    end ;
1619
    // EN / EM
1620
    if EM_C = 0
1621
    then
1622
      PBENsEM_C.Text := ''
1623
    else
1624
      PBENsEM_C.AsFloat := EN_C / EM_C * 100 ;
1625
    if EM_T = 0
1626
    then
1627
      PBENsEM_T.Text := ''
1628
    else
1629
      PBENsEM_T.AsFloat := EN_T / EM_T * 100 ;
1630
  end ;
1631
end ;
1632

    
1633
procedure TFAliment.PBTMSChange (Sender : TObject) ;
1634
begin
1635
  if (PBTMS.AsFloat <> 0) and not Update
1636
  then
1637
  begin
1638
    Modified := TRUE ;
1639
    // Nouvelle valeur
1640
    with PAliment.CC do
1641
      if ConfTCompo = 0
1642
      then // g/kg
1643
        MS := PBTMS.AsFloat
1644
      else // %
1645
        MS := PBTMS.AsFloat / 100 * 1000 ;
1646
    // En cas d'affichage sur frais, la valeur de RapMS change...
1647
    // L'ensemble de l'enregistrement est r?affich? !
1648
    if ConfRap = 0
1649
    then // sur frais
1650
    begin
1651
      IdxAliment := -1 ;
1652
      CBAlimentChange (nil) ;
1653
    end
1654
    else
1655
      AjustEnabled ;
1656
  end ;
1657
end ;
1658

    
1659
procedure TFAliment.PBTMSExit (Sender : TObject) ;
1660
begin
1661
  if (PBTMS.AsFloat = 0) and (PAliment.CC.MS <> 0)
1662
  then
1663
  begin
1664
    Modified := TRUE ;
1665
    // Valeur nulle
1666
    with PAliment.CC do
1667
      MS := 0 ;
1668
    // En cas d'affichage sur frais, la valeur de RapMS change...
1669
    // L'ensemble de l'enregistrement est r?affich? !
1670
    if ConfRap = 0
1671
    then // sur frais
1672
    begin
1673
      IdxAliment := -1 ;
1674
      CBAlimentChange (nil) ;
1675
    end
1676
    else
1677
      AjustEnabled ;
1678
  end ;
1679
end ;
1680

    
1681
procedure TFAliment.PBTMMChange (Sender : TObject) ;
1682
begin
1683
  if (PBTMM.AsFloat <> 0) and not Update
1684
  then
1685
  begin
1686
    Modified := TRUE ;
1687
    // Nouvelle valeur
1688
    with PAliment.CC do
1689
      if ConfTCompo = 0
1690
      then // g/kg
1691
        MM := PBTMM.AsFloat / RapMS
1692
      else // %
1693
        MM := PBTMM.AsFloat / 100 * 1000 / RapMS ;
1694
    // Mise ? jour des champs li?s ? cette valeur
1695
    Update := TRUE ;
1696
    CalculTMO ;
1697
    if ConfDig = 1
1698
    then // Teneur digestible
1699
      AffichdFecale ;
1700
    CalculResidu ;
1701
    AffichResidu ;
1702
    CalculEnergie ;
1703
    AffichEnergie ;
1704
    Update := FALSE ;
1705
  end ;
1706
end ;
1707

    
1708
procedure TFAliment.PBTMMExit (Sender : TObject) ;
1709
begin
1710
  if (PBTMM.AsFloat = 0) and (PAliment.CC.MM <> 0)
1711
  then
1712
  begin
1713
    Modified := TRUE ;
1714
    // Valeur nulle
1715
    with PAliment.CC do
1716
      MM := 0 ;
1717
    // Mise ? jour des champs li?s ? cette valeur
1718
    Update := TRUE ;
1719
    CalculTMO ;
1720
    if ConfDig = 1
1721
    then // Teneur digestible
1722
      AffichdFecale ;
1723
    CalculResidu ;
1724
    AffichResidu ;
1725
    CalculEnergie ;
1726
    AffichEnergie ;
1727
    Update := FALSE ;
1728
  end ;
1729
end ;
1730

    
1731
procedure TFAliment.PBTLipChange (Sender : TObject) ;
1732
begin
1733
  if not Update
1734
  then
1735
  begin
1736
    Modified := TRUE ;
1737
    // Nouvelle valeur
1738
    with PAliment.CC do
1739
      if ConfTCompo = 0
1740
      then // g/kg
1741
        Lip := PBTLip.AsFloat / RapMS
1742
      else // %
1743
        Lip := PBTLip.AsFloat / 100 * 1000 / RapMS ;
1744
    // Mise ? jour des champs li?s ? cette valeur
1745
    with PAliment.CC do
1746
      PBLip2.AsFloat := Lip * RapMS ;
1747
    Update := TRUE ;
1748
    if ConfDig = 1
1749
    then // Teneur digestible
1750
      AffichdFecale ;
1751
    CalculResidu ;
1752
    AffichResidu ;
1753
    CalculEnergie ;
1754
    AffichEnergie ;
1755
    if ConfTAG <> 2
1756
    then // non % AG
1757
      AffichTAG ;
1758
    CalculAG ;
1759
    Update := FALSE ;
1760
  end ;
1761
end ;
1762

    
1763
procedure TFAliment.PBTMATChange (Sender : TObject) ;
1764
var
1765
  i : integer ;
1766
  variation : double ;
1767
begin
1768
  if (PBTMAT.AsFloat <> 0) and not Update
1769
  then
1770
  begin
1771
    Modified := TRUE ;
1772
    // Variation de la teneur en mati?res azot?s
1773
    with PAliment.CC do
1774
      if MAT = 0
1775
      then
1776
        variation := 1
1777
      else
1778
        if ConfTCompo = 0
1779
        then // g/kg
1780
          variation := PBTMAT.AsFloat / RapMS / MAT
1781
        else // %
1782
          variation := PBTMAT.AsFloat / 100 * 1000 / RapMS / MAT ;
1783
    // Nouvelle valeur
1784
    with PAliment.CC do
1785
      if ConfTCompo = 0
1786
      then // g/kg
1787
        MAT := PBTMAT.AsFloat / RapMS
1788
      else // %
1789
        MAT := PBTMAT.AsFloat / 100 * 1000 / RapMS ;
1790
    with PAliment^ do
1791
      AAtotal[0] := CC.MAT ;
1792
    // Mise ? jour des champs li?s ? cette valeur
1793
    with PAliment^ do
1794
      case ConfTAA of
1795
        1 : // %
1796
          PBTMAT2.AsFloat := AAtotal[0] / 1000 * 100 * RapMS ;
1797
        2 : // % MAT
1798
          PBTMAT2.AsFloat := AAtotal[0] / CC.MAT * 100 ;
1799
        else // g/kg
1800
          PBTMAT2.AsFloat := AAtotal[0] * RapMS ;
1801
      end ;
1802
    Update := TRUE ;
1803
    if ConfDig = 1
1804
    then // Teneur digestible
1805
      AffichdFecale ;
1806
    CalculResidu ;
1807
    AffichResidu ;
1808
    CalculEnergie ;
1809
    AffichEnergie ;
1810
    if CBAAsMAT.Checked
1811
    then // Variation des teneur en acides amin?s (r?gle de trois)
1812
      with PAliment^ do
1813
        for i := 1 to 12 do
1814
          AAtotal[i] := AAtotal[i] * variation ;
1815
    AffichTAA ;
1816
    if ConfDig = 1
1817
    then // Teneur digestible
1818
      AffichdAA ;
1819
    CalculAA ;
1820
    Update := FALSE ;
1821
  end ;
1822
end ;
1823

    
1824
procedure TFAliment.PBTMATExit (Sender : TObject) ;
1825
var
1826
  i : integer ;
1827
begin
1828
  if PBTMAT.AsFloat = 0
1829
  then
1830
  begin
1831
    Modified := TRUE ;
1832
    // Valeur nulle
1833
    with PAliment.CC do
1834
      MAT := 0 ;
1835
    with PAliment^ do
1836
      AAtotal[0] := 0 ;
1837
    // Mise ? jour des champs li?s ? cette valeur
1838
    PBTMAT2.AsFloat := 0 ;
1839
    Update := TRUE ;
1840
    if ConfDig = 1
1841
    then // Teneur digestible
1842
      AffichdFecale ;
1843
    CalculResidu ;
1844
    AffichResidu ;
1845
    CalculEnergie ;
1846
    AffichEnergie ;
1847
    if CBAAsMAT.Checked
1848
    then
1849
    begin
1850
      // Variation des teneur en acides amin?s (r?gle de trois)
1851
      with PAliment^ do
1852
        for i := 1 to 12 do
1853
          AAtotal[i] := 0 ;
1854
      AffichTAA ;
1855
      if ConfDig = 0
1856
      then // Teneur digestible
1857
        AffichdAA ;
1858
    end ;
1859
    CalculAA ;
1860
    Update := FALSE ;
1861
  end ;
1862
end ;
1863

    
1864
procedure TFAliment.PBTAmidonChange (Sender : TObject) ;
1865
begin
1866
  if not Update
1867
  then
1868
  begin
1869
    Modified := TRUE ;
1870
    // Nouvelle valeur
1871
    with PAliment.CC do
1872
      if ConfTCompo = 0
1873
      then // g/kg
1874
        Amidon := PBTAmidon.AsFloat / RapMS
1875
      else // %
1876
        Amidon := PBTAmidon.AsFloat / 100 * 1000 / RapMS ;
1877
    // Mise ? jour des champs li?s ? cette valeur
1878
    Update := TRUE ;
1879
    if ConfDig = 1
1880
    then // Teneur digestible
1881
      AffichdFecale ;
1882
    CalculResidu ;
1883
    AffichResidu ;
1884
    CalculEnergie ;
1885
    AffichEnergie ;
1886
    Update := FALSE ;
1887
  end ;
1888
end ;
1889

    
1890
procedure TFAliment.PBTSucresChange (Sender : TObject) ;
1891
begin
1892
  if not Update
1893
  then
1894
  begin
1895
    Modified := TRUE ;
1896
    // Nouvelle valeur
1897
    with PAliment.CC do
1898
      if ConfTCompo = 0
1899
      then // g/kg
1900
        Sucres := PBTSucres.AsFloat / RapMS
1901
      else // %
1902
        Sucres := PBTSucres.AsFloat / 100 * 1000 / RapMS ;
1903
    // Mise ? jour des champs li?s ? cette valeur
1904
    Update := TRUE ;
1905
    if ConfDig = 1
1906
    then // Teneur digestible
1907
      AffichdFecale ;
1908
    CalculResidu ;
1909
    AffichResidu ;
1910
    CalculEnergie ;
1911
    AffichEnergie ;
1912
    Update := FALSE ;
1913
  end ;
1914
end ;
1915

    
1916
procedure TFAliment.PBdMO_CChange (Sender : TObject) ;
1917
begin
1918
  if not Update
1919
  then
1920
  begin
1921
    Modified := TRUE ;
1922
    // Nouvelle valeur
1923
    with PAliment.CC do
1924
      if ConfDig = 0
1925
      then // CUD
1926
        dMO_C := PBdMO_C.AsFloat
1927
      else // Teneur digestible
1928
        if ConfdCompo = 0
1929
        then // g/kg
1930
          dMO_C := PBdMO_C.AsFloat / MO * 100 / RapMS
1931
        else // %
1932
          dMO_C := PBdMO_C.AsFloat / MO * 1000 / RapMS ;
1933
    // Mise ? jour des champs li?s ? cette valeur
1934
    Update := TRUE ;
1935
    CalculResidu ;
1936
    AffichResidu ;
1937
    CalculEnergie ;
1938
    AffichEnergie ;
1939
    Update := FALSE ;
1940
  end ;
1941
end ;
1942

    
1943
procedure TFAliment.PBdLip_CChange (Sender : TObject) ;
1944
begin
1945
  if not Update
1946
  then
1947
  begin
1948
    Modified := TRUE ;
1949
    // Nouvelle valeur
1950
    with PAliment.CC do
1951
      if ConfDig = 0
1952
      then // CUD
1953
        dLip_C := PBdLip_C.AsFloat
1954
      else // Teneur digestible
1955
        if ConfdCompo = 0
1956
        then // g/kg
1957
          dLip_C := PBdLip_C.AsFloat / Lip * 100 / RapMS
1958
        else // %
1959
          dLip_C := PBdLip_C.AsFloat / Lip * 1000 / RapMS ;
1960
    // Mise ? jour des champs li?s ? cette valeur
1961
    Update := TRUE ;
1962
    CalculResidu ;
1963
    AffichResidu ;
1964
    CalculEnergie ;
1965
    AffichEnergie ;
1966
    Update := FALSE ;
1967
  end ;
1968
end ;
1969

    
1970
procedure TFAliment.PBdMAT_CChange (Sender : TObject) ;
1971
begin
1972
  if not Update
1973
  then
1974
  begin
1975
    Modified := TRUE ;
1976
    // Nouvelle valeur
1977
    with PAliment.CC do
1978
      if ConfDig = 0
1979
      then // CUD
1980
        dMAT_C := PBdMAT_C.AsFloat
1981
      else // Teneur digestible
1982
        if ConfdCompo = 0
1983
        then // g/kg
1984
          dMAT_C := PBdMAT_C.AsFloat / MAT * 100 / RapMS
1985
        else // %
1986
          dMAT_C := PBdMAT_C.AsFloat / MAT * 1000 / RapMS ;
1987
    // Mise ? jour des champs li?s ? cette valeur
1988
    Update := TRUE ;
1989
    CalculResidu ;
1990
    AffichResidu ;
1991
    CalculEnergie ;
1992
    AffichEnergie ;
1993
    Update := FALSE ;
1994
  end ;
1995
end ;
1996

    
1997
procedure TFAliment.PBdMO_TChange (Sender : TObject) ;
1998
begin
1999
  if not Update
2000
  then
2001
  begin
2002
    Modified := TRUE ;
2003
    // Nouvelle valeur
2004
    with PAliment.CC do
2005
      if ConfDig = 0
2006
      then // CUD
2007
        dMO_T := PBdMO_T.AsFloat
2008
      else // Teneur digestible
2009
        if ConfdCompo = 0
2010
        then // g/kg
2011
          dMO_T := PBdMO_T.AsFloat / MO * 100 / RapMS
2012
        else // %
2013
          dMO_T := PBdMO_T.AsFloat / MO * 1000 / RapMS ;
2014
    // Mise ? jour des champs li?s ? cette valeur
2015
    Update := TRUE ;
2016
    CalculResidu ;
2017
    AffichResidu ;
2018
    CalculEnergie ;
2019
    AffichEnergie ;
2020
    Update := FALSE ;
2021
  end ;
2022
end ;
2023

    
2024
procedure TFAliment.PBdLip_TChange (Sender : TObject) ;
2025
begin
2026
  if not Update
2027
  then
2028
  begin
2029
    Modified := TRUE ;
2030
    // Nouvelle valeur
2031
    with PAliment.CC do
2032
      if ConfDig = 0
2033
      then // CUD
2034
        dLip_T := PBdLip_T.AsFloat
2035
      else // Teneur digestible
2036
        if ConfdCompo = 0
2037
        then // g/kg
2038
          dLip_T := PBdLip_T.AsFloat / Lip * 100 / RapMS
2039
        else // %
2040
          dLip_T := PBdLip_T.AsFloat / Lip * 1000 / RapMS ;
2041
    // Mise ? jour des champs li?s ? cette valeur
2042
    Update := TRUE ;
2043
    CalculResidu ;
2044
    AffichResidu ;
2045
    CalculEnergie ;
2046
    AffichEnergie ;
2047
    Update := FALSE ;
2048
  end ;
2049
end ;
2050

    
2051
procedure TFAliment.PBdMAT_TChange (Sender : TObject) ;
2052
begin
2053
  if not Update
2054
  then
2055
  begin
2056
    Modified := TRUE ;
2057
    // Nouvelle valeur
2058
    with PAliment.CC do
2059
      if ConfDig = 0
2060
      then // CUD
2061
        dMAT_T := PBdMAT_T.AsFloat
2062
      else // Teneur digestible
2063
        if ConfdCompo = 0
2064
        then // g/kg
2065
          dMAT_T := PBdMAT_T.AsFloat / MAT * 100 / RapMS
2066
        else // %
2067
          dMAT_T := PBdMAT_T.AsFloat / MAT * 1000 / RapMS ;
2068
    // Mise ? jour des champs li?s ? cette valeur
2069
    Update := TRUE ;
2070
    CalculResidu ;
2071
    AffichResidu ;
2072
    CalculEnergie ;
2073
    AffichEnergie ;
2074
    Update := FALSE ;
2075
  end ;
2076
end ;
2077

    
2078
procedure TFAliment.CBCorrCUDClick (Sender : TObject) ;
2079
begin
2080
  if AffCorrCUD
2081
  then
2082
  begin
2083
    FWarning := TFWarning.Create (Self) ;
2084
    with FWarning do
2085
    begin
2086
      Msg := 'CorrCUD';
2087
      ShowModal ;
2088
      Release ;
2089
      AffCorrCUD := FALSE ;
2090
    end ;
2091
  end ;
2092
  if not CBCorrCUD.Checked
2093
  then
2094
  begin
2095
    RBED.Checked := FALSE ;
2096
    RBEM.Checked := FALSE ;
2097
    RBEN.Checked := FALSE ;
2098
  end ;
2099
  RBED.Enabled := CBCorrCUD.Checked ;
2100
  RBEM.Enabled := CBCorrCUD.Checked ;
2101
  RBEN.Enabled := CBCorrCUD.Checked ;
2102
  Update := TRUE ;
2103
  RBEDClick (nil) ;
2104
  RBEMClick (nil) ;
2105
  RBENClick (nil) ;
2106
  Update := FALSE ;
2107
  PBdMO_C.Enabled := not CBCorrCUD.Checked ;
2108
  PBdLip_C.Enabled := not CBCorrCUD.Checked ;
2109
  PBdMAT_C.Enabled := not CBCorrCUD.Checked ;
2110
  PBdMO_T.Enabled := not CBCorrCUD.Checked ;
2111
  PBdLip_T.Enabled := not CBCorrCUD.Checked ;
2112
  PBdMAT_T.Enabled := not CBCorrCUD.Checked ;
2113
end ;
2114

    
2115
procedure TFAliment.LCorrCUDClick (Sender : TObject) ;
2116
begin
2117
  if CBCorrCUD.Enabled
2118
  then
2119
    CBCorrCUD.Checked := not CBCorrCUD.Checked ;
2120
end ;
2121

    
2122
procedure TFAliment.RBEDClick (Sender : TObject) ;
2123
begin
2124
  PBED_C.Enabled := RBED.Checked ;
2125
  PBED_T.Enabled := RBED.Checked ;
2126
  if not Update
2127
  then
2128
  begin
2129
    Update := TRUE ;
2130
    RBEMClick (nil) ;
2131
    RBENClick (nil) ;
2132
    Update := FALSE ;
2133
  end ;
2134
end ;
2135

    
2136
procedure TFAliment.LEDClick (Sender : TObject) ;
2137
begin
2138
  if RBED.Enabled
2139
  then
2140
    RBED.Checked := TRUE ;
2141
end ;
2142

    
2143
procedure TFAliment.PBED_CChange (Sender : TObject) ;
2144
begin
2145
  if (PBED_C.AsFloat <> 0) and not Update
2146
  then
2147
  begin
2148
    Modified := TRUE ;
2149
    // Nouvelle valeur
2150
    with PAliment.CC do
2151
      ED_C := PBED_C.AsFloat / RapMS ;
2152
    // Mise ? jour des champs li?s ? cette valeur
2153
    Update := TRUE ;
2154
    CalculDigEDCrois ;
2155
    AffichdFecale ;
2156
    CalculEnergie ;
2157
    AffichEnergie ;
2158
    Update := FALSE ;
2159
  end ;
2160
end ;
2161

    
2162
procedure TFAliment.PBED_CExit (Sender : TObject) ;
2163
begin
2164
  if (PBED_C.AsFloat = 0) and (PAliment.CC.ED_C <> 0)
2165
  then
2166
  begin
2167
    Modified := TRUE ;
2168
    // Valeur nulle
2169
    with PAliment.CC do
2170
      ED_C := 0 ;
2171
    // Mise ? jour des champs li?s ? cette valeur
2172
    Update := TRUE ;
2173
    CalculDigEDCrois ;
2174
    AffichdFecale ;
2175
    CalculEnergie ;
2176
    AffichEnergie ;
2177
    Update := FALSE ;
2178
  end ;
2179
end ;
2180

    
2181
procedure TFAliment.CalculDigEDCrois ;
2182
var
2183
  x : double ;
2184
begin
2185
  with PAliment.CC do
2186
  begin
2187
    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) ;
2188
    dLip_C := dLip_C * x ;
2189
    dMAT_C := dMAT_C * x ;
2190
    dResidu_C := dResidu_C * x ;
2191
    dCB_C := dCB_C * x ;
2192
    dMO_C := ((dMO_C * MO - Amidon * 100 - Sucres * 100) * x + Amidon * 100 + Sucres * 100) / MO ;
2193
  end ;
2194
end ;
2195

    
2196
procedure TFAliment.PBED_TChange (Sender : TObject) ;
2197
begin
2198
  if (PBED_T.AsFloat <> 0) and not Update
2199
  then
2200
  begin
2201
    Modified := TRUE ;
2202
    // Nouvelle valeur
2203
    with PAliment.CC do
2204
      ED_T := PBED_T.AsFloat / RapMS ;
2205
    // Mise ? jour des champs li?s ? cette valeur
2206
    Update := TRUE ;
2207
    CalculDigEDTruie ;
2208
    AffichdFecale ;
2209
    CalculEnergie ;
2210
    AffichEnergie ;
2211
    Update := FALSE ;
2212
  end ;
2213
end ;
2214

    
2215
procedure TFAliment.PBED_TExit (Sender : TObject) ;
2216
begin
2217
  if (PBED_T.AsFloat = 0) and (PAliment.CC.ED_T <> 0)
2218
  then
2219
  begin
2220
    Modified := TRUE ;
2221
    // Valeur nulle
2222
    with PAliment.CC do
2223
      ED_T := 0 ;
2224
    // Mise ? jour des champs li?s ? cette valeur
2225
    Update := TRUE ;
2226
    CalculDigEDTruie ;
2227
    AffichdFecale ;
2228
    CalculEnergie ;
2229
    AffichEnergie ;
2230
    Update := FALSE ;
2231
  end ;
2232
end ;
2233

    
2234
procedure TFAliment.CalculDigEDTruie ;
2235
var
2236
  x : double ;
2237
begin
2238
  with PAliment.CC do
2239
  begin
2240
    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) ;
2241
    dLip_T := dLip_T * x ;
2242
    dMAT_T := dMAT_T * x ;
2243
    dResidu_T := dResidu_T * x ;
2244
    dCB_T := dCB_T * x ;
2245
    dMO_T := ((dMO_T * MO - Amidon * 100 - Sucres * 100) * x + Amidon * 100 + Sucres * 100) / MO ;
2246
  end ;
2247
end ;
2248

    
2249
procedure TFAliment.RBEMClick (Sender : TObject) ;
2250
begin
2251
  PBEM_C.Enabled := RBEM.Checked ;
2252
  PBEM_T.Enabled := RBEM.Checked ;
2253
  if not Update
2254
  then
2255
  begin
2256
    Update := TRUE ;
2257
    RBEDClick (nil) ;
2258
    RBENClick (nil) ;
2259
    Update := FALSE ;
2260
  end ;
2261
end ;
2262

    
2263
procedure TFAliment.LEMClick (Sender : TObject) ;
2264
begin
2265
  if RBEM.Enabled
2266
  then
2267
    RBEM.Checked := TRUE ;
2268
end ;
2269

    
2270
procedure TFAliment.PBEM_CChange (Sender : TObject) ;
2271
begin
2272
  if (PBEM_C.AsFloat <> 0) and not Update
2273
  then
2274
  begin
2275
    Modified := TRUE ;
2276
    // Nouvelle valeur
2277
    with PAliment.CC do
2278
      EM_C := PBEM_C.AsFloat / RapMS ;
2279
    // Mise ? jour des champs li?s ? cette valeur
2280
    Update := TRUE ;
2281
    CalculDigEMCrois ;
2282
    AffichdFecale ;
2283
    CalculEnergie ;
2284
    AffichEnergie ;
2285
    Update := FALSE ;
2286
  end ;
2287
end ;
2288

    
2289
procedure TFAliment.PBEM_CExit (Sender : TObject) ;
2290
begin
2291
  if (PBEM_C.AsFloat = 0) and (PAliment.CC.EM_C <> 0)
2292
  then
2293
  begin
2294
    Modified := TRUE ;
2295
    // Valeur nulle
2296
    with PAliment.CC do
2297
      EM_C := 0 ;
2298
    // Mise ? jour des champs li?s ? cette valeur
2299
    Update := TRUE ;
2300
    CalculDigEMCrois ;
2301
    AffichdFecale ;
2302
    CalculEnergie ;
2303
    AffichEnergie ;
2304
    Update := FALSE ;
2305
  end ;
2306
end ;
2307

    
2308
procedure TFAliment.CalculDigEMCrois ;
2309
var
2310
  x : double ;
2311
begin
2312
  with PAliment.CC do
2313
  begin
2314
    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) ;
2315
    dLip_C := dLip_C * x ;
2316
    dMAT_C := dMAT_C * x ;
2317
    dResidu_C := dResidu_C * x ;
2318
    dCB_C := dCB_C * x ;
2319
    dMO_C := ((dMO_C * MO - Amidon * 100 - Sucres * 100) * x + Amidon * 100 + Sucres * 100) / MO ;
2320
  end ;
2321
end ;
2322

    
2323
procedure TFAliment.PBEM_TChange (Sender : TObject) ;
2324
begin
2325
  if (PBEM_T.AsFloat <> 0) and not Update
2326
  then
2327
  begin
2328
    Modified := TRUE ;
2329
    // Nouvelle valeur
2330
    with PAliment.CC do
2331
      EM_T := PBEM_T.AsFloat / RapMS ;
2332
    // Mise ? jour des champs li?s ? cette valeur
2333
    Update := TRUE ;
2334
    CalculDigEMTruie ;
2335
    AffichdFecale ;
2336
    CalculEnergie ;
2337
    AffichEnergie ;
2338
    Update := FALSE ;
2339
  end ;
2340
end ;
2341

    
2342
procedure TFAliment.PBEM_TExit (Sender : TObject) ;
2343
begin
2344
  if (PBEM_T.AsFloat = 0) and (PAliment.CC.EM_T <> 0)
2345
  then
2346
  begin
2347
    Modified := TRUE ;
2348
    // Valeur nulle
2349
    with PAliment.CC do
2350
      EM_T := 0 ;
2351
    // Mise ? jour des champs li?s ? cette valeur
2352
    Update := TRUE ;
2353
    CalculDigEMTruie ;
2354
    AffichdFecale ;
2355
    CalculEnergie ;
2356
    AffichEnergie ;
2357
    Update := FALSE ;
2358
  end ;
2359
end ;
2360

    
2361
procedure TFAliment.CalculDigEMTruie ;
2362
var
2363
  x : double ;
2364
begin
2365
  with PAliment.CC do
2366
  begin
2367
    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) ;
2368
    dLip_T := dLip_T * x ;
2369
    dMAT_T := dMAT_T * x ;
2370
    dResidu_T := dResidu_T * x ;
2371
    dCB_T := dCB_T * x ;
2372
    dMO_T := ((dMO_T * MO - Amidon * 100 - Sucres * 100) * x + Amidon * 100 + Sucres * 100) / MO ;
2373
  end ;
2374
end ;
2375

    
2376
procedure TFAliment.RBENClick (Sender : TObject) ;
2377
begin
2378
  PBEN_C.Enabled := RBEN.Checked ;
2379
  PBEN_T.Enabled := RBEN.Checked ;
2380
  if not Update
2381
  then
2382
  begin
2383
    Update := TRUE ;
2384
    RBEDClick (nil) ;
2385
    RBEMClick (nil) ;
2386
    Update := FALSE ;
2387
  end ;
2388
end ;
2389

    
2390
procedure TFAliment.LENClick (Sender : TObject) ;
2391
begin
2392
  if RBEN.Enabled
2393
  then
2394
    RBEN.Checked := TRUE ;
2395
end ;
2396

    
2397
procedure TFAliment.PBEN_CChange (Sender : TObject) ;
2398
begin
2399
  if (PBEN_C.AsFloat <> 0) and not Update
2400
  then
2401
  begin
2402
    Modified := TRUE ;
2403
    // Nouvelle valeur
2404
    with PAliment.CC do
2405
      EN_C := PBEN_C.AsFloat / RapMS ;
2406
    // Mise ? jour des champs li?s ? cette valeur
2407
    Update := TRUE ;
2408
    CalculDigENCrois ;
2409
    AffichdFecale ;
2410
    CalculEnergie ;
2411
    AffichEnergie ;
2412
    Update := FALSE ;
2413
  end ;
2414
end ;
2415

    
2416
procedure TFAliment.PBEN_CExit (Sender : TObject) ;
2417
begin
2418
  if (PBEN_C.AsFloat = 0) and (PAliment.CC.EN_C <> 0)
2419
  then
2420
  begin
2421
    Modified := TRUE ;
2422
    // Valeur nulle
2423
    with PAliment.CC do
2424
      EN_C := 0 ;
2425
    // Mise ? jour des champs li?s ? cette valeur
2426
    Update := TRUE ;
2427
    CalculDigENCrois ;
2428
    AffichdFecale ;
2429
    CalculEnergie ;
2430
    AffichEnergie ;
2431
    Update := FALSE ;
2432
  end ;
2433
end ;
2434

    
2435
procedure TFAliment.CalculDigENCrois ;
2436
var
2437
  x : double ;
2438
begin
2439
  with PAliment.CC do
2440
  begin
2441
    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) ;
2442
    dLip_C := dLip_C * x ;
2443
    dMAT_C := dMAT_C * x ;
2444
    dResidu_C := dResidu_C * x ;
2445
    dCB_C := dCB_C * x ;
2446
    dMO_C := ((dMO_C * MO - Amidon * 100 - Sucres * 100) * x + Amidon * 100 + Sucres * 100) / MO ;
2447
  end ;
2448
end ;
2449

    
2450
procedure TFAliment.PBEN_TChange (Sender : TObject) ;
2451
begin
2452
  if (PBEN_T.AsFloat <> 0) and not Update
2453
  then
2454
  begin
2455
    Modified := TRUE ;
2456
    // Nouvelle valeur
2457
    with PAliment.CC do
2458
      EN_T := PBEN_T.AsFloat / RapMS ;
2459
    // Mise ? jour des champs li?s ? cette valeur
2460
    Update := TRUE ;
2461
    CalculDigENTruie ;
2462
    AffichdFecale ;
2463
    CalculEnergie ;
2464
    AffichEnergie ;
2465
    Update := FALSE ;
2466
  end ;
2467
end ;
2468

    
2469
procedure TFAliment.PBEN_TExit (Sender : TObject) ;
2470
begin
2471
  if (PBEN_T.AsFloat = 0) and (PAliment.CC.EN_T <> 0)
2472
  then
2473
  begin
2474
    Modified := TRUE ;
2475
    // Valeur nulle
2476
    with PAliment.CC do
2477
      EN_T := 0 ;
2478
    // Mise ? jour des champs li?s ? cette valeur
2479
    Update := TRUE ;
2480
    CalculDigENTruie ;
2481
    AffichdFecale ;
2482
    CalculEnergie ;
2483
    AffichEnergie ;
2484
    Update := FALSE ;
2485
  end ;
2486
end ;
2487

    
2488
procedure TFAliment.CalculDigENTruie ;
2489
var
2490
  x : double ;
2491
begin
2492
  with PAliment.CC do
2493
  begin
2494
    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) ;
2495
    dLip_T := dLip_T * x ;
2496
    dMAT_T := dMAT_T * x ;
2497
    dResidu_T := dResidu_T * x ;
2498
    dCB_T := dCB_T * x ;
2499
    dMO_T := ((dMO_T * MO - Amidon * 100 - Sucres * 100) * x + Amidon * 100 + Sucres * 100) / MO ;
2500
  end ;
2501
end ;
2502

    
2503
////////////////////////////////////////////////////////////////////////////////
2504
// Acides amin?s
2505
////////////////////////////////////////////////////////////////////////////////
2506

    
2507
// Affichage de la teneur en fonction de la configuration
2508
procedure TFAliment.AffichTAA ;
2509
begin
2510
//  with PAliment^ do
2511
//    AAtotal[0] := CC.MAT ;
2512
  case ConfTAA of
2513
    1 : // %
2514
      with PAliment^ do
2515
      begin
2516
        PBTMAT2.AsFloat := AAtotal[0] / 1000 * 100 * RapMS ;
2517
        if ActiveControl <> PBTLys
2518
        then
2519
          PBTLys.AsFloat := AAtotal[1] / 1000 * 100 * RapMS ;
2520
        PBTMet.AsFloat := AAtotal[2] / 1000 * 100 * RapMS ;
2521
        PBTCys.AsFloat := AAtotal[3] / 1000 * 100 * RapMS ;
2522
        PBTTrp.AsFloat := AAtotal[4] / 1000 * 100 * RapMS ;
2523
        PBTThr.AsFloat := AAtotal[5] / 1000 * 100 * RapMS ;
2524
        PBTPhe.AsFloat := AAtotal[6] / 1000 * 100 * RapMS ;
2525
        PBTTyr.AsFloat := AAtotal[7] / 1000 * 100 * RapMS ;
2526
        PBTLeu.AsFloat := AAtotal[8] / 1000 * 100 * RapMS ;
2527
        PBTIle.AsFloat := AAtotal[9] / 1000 * 100 * RapMS ;
2528
        PBTVal.AsFloat := AAtotal[10] / 1000 * 100 * RapMS ;
2529
        PBTHis.AsFloat := AAtotal[11] / 1000 * 100 * RapMS ;
2530
        PBTArg.AsFloat := AAtotal[12] / 1000 * 100 * RapMS ;
2531
      end ;
2532
    2 : // % MAT
2533
      if PAliment.CC.MAT = 0
2534
      then
2535
      begin
2536
        PBTMAT2.AsFloat := 0 ;
2537
        PBTLys.AsFloat := 0 ;
2538
        PBTMet.AsFloat := 0 ;
2539
        PBTCys.AsFloat := 0 ;
2540
        PBTTrp.AsFloat := 0 ;
2541
        PBTThr.AsFloat := 0 ;
2542
        PBTPhe.AsFloat := 0 ;
2543
        PBTTyr.AsFloat := 0 ;
2544
        PBTLeu.AsFloat := 0 ;
2545
        PBTIle.AsFloat := 0 ;
2546
        PBTVal.AsFloat := 0 ;
2547
        PBTHis.AsFloat := 0 ;
2548
        PBTArg.AsFloat := 0 ;
2549
      end
2550
      else
2551
        with PAliment^ do
2552
        begin
2553
          PBTMAT2.AsFloat := AAtotal[0] / CC.MAT * 100 ;
2554
          if ActiveControl <> PBTLys
2555
          then
2556
            PBTLys.AsFloat := AAtotal[1] / CC.MAT * 100 ;
2557
          PBTMet.AsFloat := AAtotal[2] / CC.MAT * 100 ;
2558
          PBTCys.AsFloat := AAtotal[3] / CC.MAT * 100 ;
2559
          PBTTrp.AsFloat := AAtotal[4] / CC.MAT * 100 ;
2560
          PBTThr.AsFloat := AAtotal[5] / CC.MAT * 100 ;
2561
          PBTPhe.AsFloat := AAtotal[6] / CC.MAT * 100 ;
2562
          PBTTyr.AsFloat := AAtotal[7] / CC.MAT * 100 ;
2563
          PBTLeu.AsFloat := AAtotal[8] / CC.MAT * 100 ;
2564
          PBTIle.AsFloat := AAtotal[9] / CC.MAT * 100 ;
2565
          PBTVal.AsFloat := AAtotal[10] / CC.MAT * 100 ;
2566
          PBTHis.AsFloat := AAtotal[11] / CC.MAT * 100 ;
2567
          PBTArg.AsFloat := AAtotal[12] / CC.MAT * 100 ;
2568
        end ;
2569
    else // g/kg
2570
      with PAliment^ do
2571
      begin
2572
        PBTMAT2.AsFloat := AAtotal[0] * RapMS ;
2573
        if ActiveControl <> PBTLys
2574
        then
2575
          PBTLys.AsFloat := AAtotal[1] * RapMS ;
2576
        PBTMet.AsFloat := AAtotal[2] * RapMS ;
2577
        PBTCys.AsFloat := AAtotal[3] * RapMS ;
2578
        PBTTrp.AsFloat := AAtotal[4] * RapMS ;
2579
        PBTThr.AsFloat := AAtotal[5] * RapMS ;
2580
        PBTPhe.AsFloat := AAtotal[6] * RapMS ;
2581
        PBTTyr.AsFloat := AAtotal[7] * RapMS ;
2582
        PBTLeu.AsFloat := AAtotal[8] * RapMS ;
2583
        PBTIle.AsFloat := AAtotal[9] * RapMS ;
2584
        PBTVal.AsFloat := AAtotal[10] * RapMS ;
2585
        PBTHis.AsFloat := AAtotal[11] * RapMS ;
2586
        PBTArg.AsFloat := AAtotal[12] * RapMS ;
2587
      end ;
2588
  end ;
2589
end ;
2590

    
2591
// Affichage de la digestibilit? il?ale en fonction de la configuration
2592
procedure TFAliment.AffichdAA ;
2593
begin
2594
  if ConfDig = 0
2595
  then // CUD
2596
    with PAliment^ do
2597
    begin
2598
      PBdMATStd.AsFloat := CUDAA[0] ;
2599
      PBdLysStd.AsFloat := CUDAA[1] ;
2600
      PBdMetStd.AsFloat := CUDAA[2] ;
2601
      PBdCysStd.AsFloat := CUDAA[3] ;
2602
      PBdTrpStd.AsFloat := CUDAA[4] ;
2603
      PBdThrStd.AsFloat := CUDAA[5] ;
2604
      PBdPheStd.AsFloat := CUDAA[6] ;
2605
      PBdTyrStd.AsFloat := CUDAA[7] ;
2606
      PBdLeuStd.AsFloat := CUDAA[8] ;
2607
      PBdIleStd.AsFloat := CUDAA[9] ;
2608
      PBdValStd.AsFloat := CUDAA[10] ;
2609
      PBdHisStd.AsFloat := CUDAA[11] ;
2610
      PBdArgStd.AsFloat := CUDAA[12] ;
2611
    end
2612
  else // Teneur digestible
2613
    if ConfdAA = 0
2614
    then // g/kg
2615
      with PAliment^ do
2616
      begin
2617
        PBdMATStd.AsFloat := AAtotal[0] * CUDAA[0] / 100 * RapMS ;
2618
        PBdLysStd.AsFloat := AAtotal[1] * CUDAA[1] / 100 * RapMS ;
2619
        PBdMetStd.AsFloat := AAtotal[2] * CUDAA[2] / 100 * RapMS ;
2620
        PBdCysStd.AsFloat := AAtotal[3] * CUDAA[3] / 100 * RapMS ;
2621
        PBdTrpStd.AsFloat := AAtotal[4] * CUDAA[4] / 100 * RapMS ;
2622
        PBdThrStd.AsFloat := AAtotal[5] * CUDAA[5] / 100 * RapMS ;
2623
        PBdPheStd.AsFloat := AAtotal[6] * CUDAA[6] / 100 * RapMS ;
2624
        PBdTyrStd.AsFloat := AAtotal[7] * CUDAA[7] / 100 * RapMS ;
2625
        PBdLeuStd.AsFloat := AAtotal[8] * CUDAA[8] / 100 * RapMS ;
2626
        PBdIleStd.AsFloat := AAtotal[9] * CUDAA[9] / 100 * RapMS ;
2627
        PBdValStd.AsFloat := AAtotal[10] * CUDAA[10] / 100 * RapMS ;
2628
        PBdHisStd.AsFloat := AAtotal[11] * CUDAA[11] / 100 * RapMS ;
2629
        PBdArgStd.AsFloat := AAtotal[12] * CUDAA[12] / 100 * RapMS ;
2630
      end
2631
    else // %
2632
      with PAliment^ do
2633
      begin
2634
        PBdMATStd.AsFloat := AAtotal[0] / 1000 * CUDAA[0] * RapMS ;
2635
        PBdLysStd.AsFloat := AAtotal[1] / 1000 * CUDAA[1] * RapMS ;
2636
        PBdMetStd.AsFloat := AAtotal[2] / 1000 * CUDAA[2] * RapMS ;
2637
        PBdCysStd.AsFloat := AAtotal[3] / 1000 * CUDAA[3] * RapMS ;
2638
        PBdTrpStd.AsFloat := AAtotal[4] / 1000 * CUDAA[4] * RapMS ;
2639
        PBdThrStd.AsFloat := AAtotal[5] / 1000 * CUDAA[5] * RapMS ;
2640
        PBdPheStd.AsFloat := AAtotal[6] / 1000 * CUDAA[6] * RapMS ;
2641
        PBdTyrStd.AsFloat := AAtotal[7] / 1000 * CUDAA[7] * RapMS ;
2642
        PBdLeuStd.AsFloat := AAtotal[8] / 1000 * CUDAA[8] * RapMS ;
2643
        PBdIleStd.AsFloat := AAtotal[9] / 1000 * CUDAA[9] * RapMS ;
2644
        PBdValStd.AsFloat := AAtotal[10] / 1000 * CUDAA[10] * RapMS ;
2645
        PBdHisStd.AsFloat := AAtotal[11] / 1000 * CUDAA[11] * RapMS ;
2646
        PBdArgStd.AsFloat := AAtotal[12] / 1000 * CUDAA[12] * RapMS ;
2647
      end ;
2648
end ;
2649

    
2650
procedure TFAliment.CalculAA ;
2651
begin
2652
  // Digestibilit? apparente
2653
  if ConfDig = 0
2654
  then // CUD
2655
    with PAliment^ do
2656
    begin
2657
      if AAtotal[0] = 0
2658
      then
2659
        PBdMATApp.Text := ''
2660
      else
2661
        PBdMATApp.AsFloat := CUDAA[0] - AAendogene[0] * 100 / AAtotal[0] ;
2662
      if AAtotal[1] = 0
2663
      then
2664
        PBdLysApp.Text := ''
2665
      else
2666
        PBdLysApp.AsFloat := CUDAA[1] - AAendogene[1] * 100 / AAtotal[1] ;
2667
      if AAtotal[2] = 0
2668
      then
2669
        PBdMetApp.Text := ''
2670
      else
2671
        PBdMetApp.AsFloat := CUDAA[2] - AAendogene[2] * 100 / AAtotal[2] ;
2672
      if AAtotal[3] = 0
2673
      then
2674
        PBdCysApp.Text := ''
2675
      else
2676
        PBdCysApp.AsFloat := CUDAA[3] - AAendogene[3] * 100 / AAtotal[3] ;
2677
      if AAtotal[4] = 0
2678
      then
2679
        PBdTrpApp.Text := ''
2680
      else
2681
        PBdTrpApp.AsFloat := CUDAA[4] - AAendogene[4] * 100 / AAtotal[4] ;
2682
      if AAtotal[5] = 0
2683
      then
2684
        PBdThrApp.Text := ''
2685
      else
2686
        PBdThrApp.AsFloat := CUDAA[5] - AAendogene[5] * 100 / AAtotal[5] ;
2687
      if AAtotal[6] = 0
2688
      then
2689
        PBdPheApp.Text := ''
2690
      else
2691
        PBdPheApp.AsFloat := CUDAA[6] - AAendogene[6] * 100 / AAtotal[6] ;
2692
      if AAtotal[7] = 0
2693
      then
2694
        PBdTyrApp.Text := ''
2695
      else
2696
        PBdTyrApp.AsFloat := CUDAA[7] - AAendogene[7] * 100 / AAtotal[7] ;
2697
      if AAtotal[8] = 0
2698
      then
2699
        PBdLeuApp.Text := ''
2700
      else
2701
        PBdLeuApp.AsFloat := CUDAA[8] - AAendogene[8] * 100 / AAtotal[8] ;
2702
      if AAtotal[9] = 0
2703
      then
2704
        PBdIleApp.Text := ''
2705
      else
2706
        PBdIleApp.AsFloat := CUDAA[9] - AAendogene[9] * 100 / AAtotal[9] ;
2707
      if AAtotal[10] = 0
2708
      then
2709
        PBdValApp.Text := ''
2710
      else
2711
        PBdValApp.AsFloat := CUDAA[10] - AAendogene[10] * 100 / AAtotal[10] ;
2712
      if AAtotal[11] = 0
2713
      then
2714
        PBdHisApp.Text := ''
2715
      else
2716
        PBdHisApp.AsFloat := CUDAA[11] - AAendogene[11] * 100 / AAtotal[11] ;
2717
      if AAtotal[12] = 0
2718
      then
2719
        PBdArgApp.Text := ''
2720
      else
2721
        PBdArgApp.AsFloat := CUDAA[12] - AAendogene[12] * 100 / AAtotal[12] ;
2722
    end
2723
  else // Teneur digestible
2724
    if ConfdAA = 0
2725
    then // g/kg
2726
      with PAliment^ do
2727
      begin
2728
        PBdMATApp.AsFloat := (AAtotal[0] * CUDAA[0] / 100 - AAendogene[0]) * RapMS ;
2729
        PBdLysApp.AsFloat := (AAtotal[1] * CUDAA[1] / 100 - AAendogene[1]) * RapMS ;
2730
        PBdMetApp.AsFloat := (AAtotal[2] * CUDAA[2] / 100 - AAendogene[2]) * RapMS ;
2731
        PBdCysApp.AsFloat := (AAtotal[3] * CUDAA[3] / 100 - AAendogene[3]) * RapMS ;
2732
        PBdTrpApp.AsFloat := (AAtotal[4] * CUDAA[4] / 100 - AAendogene[4]) * RapMS ;
2733
        PBdThrApp.AsFloat := (AAtotal[5] * CUDAA[5] / 100 - AAendogene[5]) * RapMS ;
2734
        PBdPheApp.AsFloat := (AAtotal[6] * CUDAA[6] / 100 - AAendogene[6]) * RapMS ;
2735
        PBdTyrApp.AsFloat := (AAtotal[7] * CUDAA[7] / 100 - AAendogene[7]) * RapMS ;
2736
        PBdLeuApp.AsFloat := (AAtotal[8] * CUDAA[8] / 100 - AAendogene[8]) * RapMS ;
2737
        PBdIleApp.AsFloat := (AAtotal[9] * CUDAA[9] / 100 - AAendogene[9]) * RapMS ;
2738
        PBdValApp.AsFloat := (AAtotal[10] * CUDAA[10] / 100 - AAendogene[10]) * RapMS ;
2739
        PBdHisApp.AsFloat := (AAtotal[11] * CUDAA[11] / 100 - AAendogene[11]) * RapMS ;
2740
        PBdArgApp.AsFloat := (AAtotal[12] * CUDAA[12] / 100 - AAendogene[12]) * RapMS ;
2741
      end
2742
    else // %
2743
      with PAliment^ do
2744
      begin
2745
        PBdMATApp.AsFloat := (AAtotal[0] / 1000 * CUDAA[0] - AAendogene[0] * 100 / 1000) * RapMS ;
2746
        PBdLysApp.AsFloat := (AAtotal[1] / 1000 * CUDAA[1] - AAendogene[1] * 100 / 1000) * RapMS ;
2747
        PBdMetApp.AsFloat := (AAtotal[2] / 1000 * CUDAA[2] - AAendogene[2] * 100 / 1000) * RapMS ;
2748
        PBdCysApp.AsFloat := (AAtotal[3] / 1000 * CUDAA[3] - AAendogene[3] * 100 / 1000) * RapMS ;
2749
        PBdTrpApp.AsFloat := (AAtotal[4] / 1000 * CUDAA[4] - AAendogene[4] * 100 / 1000) * RapMS ;
2750
        PBdThrApp.AsFloat := (AAtotal[5] / 1000 * CUDAA[5] - AAendogene[5] * 100 / 1000) * RapMS ;
2751
        PBdPheApp.AsFloat := (AAtotal[6] / 1000 * CUDAA[6] - AAendogene[6] * 100 / 1000) * RapMS ;
2752
        PBdTyrApp.AsFloat := (AAtotal[7] / 1000 * CUDAA[7] - AAendogene[7] * 100 / 1000) * RapMS ;
2753
        PBdLeuApp.AsFloat := (AAtotal[8] / 1000 * CUDAA[8] - AAendogene[8] * 100 / 1000) * RapMS ;
2754
        PBdIleApp.AsFloat := (AAtotal[9] / 1000 * CUDAA[9] - AAendogene[9] * 100 / 1000) * RapMS ;
2755
        PBdValApp.AsFloat := (AAtotal[10] / 1000 * CUDAA[10] - AAendogene[10] * 100 / 1000) * RapMS ;
2756
        PBdHisApp.AsFloat := (AAtotal[11] / 1000 * CUDAA[11] - AAendogene[11] * 100 / 1000) * RapMS ;
2757
        PBdArgApp.AsFloat := (AAtotal[12] / 1000 * CUDAA[12] - AAendogene[12] * 100 / 1000) * RapMS ;
2758
      end ;
2759
  // Prot?ine id?ale standardis?e
2760
  PBProtLysStd.AsFloat := 100 ;
2761
  if (PAliment.AAtotal[1] = 0) or (PAliment.CUDAA[1] = 0)
2762
  then
2763
  begin
2764
    PBProtMetStd.Text := '' ;
2765
    PBProtCysStd.Text := '' ;
2766
    PBProtTrpStd.Text := '' ;
2767
    PBProtThrStd.Text := '' ;
2768
    PBProtPheStd.Text := '' ;
2769
    PBProtTyrStd.Text := '' ;
2770
    PBProtLeuStd.Text := '' ;
2771
    PBProtIleStd.Text := '' ;
2772
    PBProtValStd.Text := '' ;
2773
    PBProtHisStd.Text := '' ;
2774
    PBProtArgStd.Text := '' ;
2775
  end
2776
  else
2777
    with PAliment^ do
2778
    begin
2779
      PBProtMetStd.AsFloat := (AAtotal[2] * CUDAA[2]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2780
      PBProtCysStd.AsFloat := (AAtotal[3] * CUDAA[3]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2781
      PBProtTrpStd.AsFloat := (AAtotal[4] * CUDAA[4]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2782
      PBProtThrStd.AsFloat := (AAtotal[5] * CUDAA[5]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2783
      PBProtPheStd.AsFloat := (AAtotal[6] * CUDAA[6]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2784
      PBProtTyrStd.AsFloat := (AAtotal[7] * CUDAA[7]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2785
      PBProtLeuStd.AsFloat := (AAtotal[8] * CUDAA[8]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2786
      PBProtIleStd.AsFloat := (AAtotal[9] * CUDAA[9]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2787
      PBProtValStd.AsFloat := (AAtotal[10] * CUDAA[10]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2788
      PBProtHisStd.AsFloat := (AAtotal[11] * CUDAA[11]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2789
      PBProtArgStd.AsFloat := (AAtotal[12] * CUDAA[12]) / (AAtotal[1] * CUDAA[1]) * 100 ;
2790
    end ;
2791
  // Prot?ine id?ale totale
2792
  PBProtLysTot.AsFloat := 100 ;
2793
  if (PAliment.AAtotal[1] = 0) or (PAliment.CUDAA[1] = 0)
2794
  then
2795
  begin
2796
    PBProtMetTot.Text := '' ;
2797
    PBProtCysTot.Text := '' ;
2798
    PBProtTrpTot.Text := '' ;
2799
    PBProtThrTot.Text := '' ;
2800
    PBProtPheTot.Text := '' ;
2801
    PBProtTyrTot.Text := '' ;
2802
    PBProtLeuTot.Text := '' ;
2803
    PBProtIleTot.Text := '' ;
2804
    PBProtValTot.Text := '' ;
2805
    PBProtHisTot.Text := '' ;
2806
    PBProtArgTot.Text := '' ;
2807
  end
2808
  else
2809
    with PAliment^ do
2810
    begin
2811
      PBProtMetTot.AsFloat := AAtotal[2] / AAtotal[1] * 100 ;
2812
      PBProtCysTot.AsFloat := AAtotal[3] / AAtotal[1] * 100 ;
2813
      PBProtTrpTot.AsFloat := AAtotal[4] / AAtotal[1] * 100 ;
2814
      PBProtThrTot.AsFloat := AAtotal[5] / AAtotal[1] * 100 ;
2815
      PBProtPheTot.AsFloat := AAtotal[6] / AAtotal[1] * 100 ;
2816
      PBProtTyrTot.AsFloat := AAtotal[7] / AAtotal[1] * 100 ;
2817
      PBProtLeuTot.AsFloat := AAtotal[8] / AAtotal[1] * 100 ;
2818
      PBProtIleTot.AsFloat := AAtotal[9] / AAtotal[1] * 100 ;
2819
      PBProtValTot.AsFloat := AAtotal[10] / AAtotal[1] * 100 ;
2820
      PBProtHisTot.AsFloat := AAtotal[11] / AAtotal[1] * 100 ;
2821
      PBProtArgTot.AsFloat := AAtotal[12] / AAtotal[1] * 100 ;
2822
    end ;
2823
  // met + cys
2824
  PBTMetCys.AsFloat := PBTMet.AsFloat + PBTCys.AsFloat ;
2825
  if ConfDig = 0
2826
  then // CUD
2827
    if PBTMetCys.AsFloat = 0
2828
    then
2829
    begin
2830
      PBdMetCysStd.Text := '' ;
2831
      PBdMetCysApp.Text := '' ;
2832
    end
2833
    else
2834
    begin
2835
      PBdMetCysStd.AsFloat := (PBTMet.AsFloat * PBdMetStd.AsFloat + PBTCys.AsFloat * PBdCysStd.AsFloat) / PBTMetCys.AsFloat ;
2836
      PBdMetCysApp.AsFloat := (PBTMet.AsFloat * PBdMetApp.AsFloat + PBTCys.AsFloat * PBdCysApp.AsFloat) / PBTMetCys.AsFloat ;
2837
    end
2838
  else // Teneur digestible
2839
  begin
2840
    PBdMetCysStd.AsFloat := PBdMetStd.AsFloat + PBdCysStd.AsFloat ;
2841
    PBdMetCysApp.AsFloat := PBdMetApp.AsFloat + PBdCysApp.AsFloat ;
2842
  end ;
2843
  if (PAliment.AAtotal[1] = 0) or (PAliment.CUDAA[1] = 0)
2844
  then
2845
  begin
2846
    PBProtMetCysStd.Text := '' ;
2847
    PBProtMetCysTot.Text := '' ;
2848
  end
2849
  else
2850
  begin
2851
    PBProtMetCysStd.AsFloat := PBProtMetStd.AsFloat + PBProtCysStd.AsFloat ;
2852
    PBProtMetCysTot.AsFloat := PBProtMetTot.AsFloat + PBProtCysTot.AsFloat ;
2853
  end ;
2854
  // phe + tyr
2855
  PBTPheTyr.AsFloat := PBTPhe.AsFloat + PBTTyr.AsFloat ;
2856
  if ConfDig = 0
2857
  then // CUD
2858
    if PBTPheTyr.AsFloat = 0
2859
    then
2860
    begin
2861
      PBdPheTyrStd.Text := '' ;
2862
      PBdPheTyrApp.Text := '' ;
2863
    end
2864
    else
2865
    begin
2866
      PBdPheTyrStd.AsFloat := (PBTPhe.AsFloat * PBdPheStd.AsFloat + PBTTyr.AsFloat * PBdTyrStd.AsFloat) / PBTPheTyr.AsFloat ;
2867
      PBdPheTyrApp.AsFloat := (PBTPhe.AsFloat * PBdPheApp.AsFloat + PBTTyr.AsFloat * PBdTyrApp.AsFloat) / PBTPheTyr.AsFloat ;
2868
    end
2869
  else // Teneur digestible
2870
  begin
2871
    PBdPheTyrStd.AsFloat := PBdPheStd.AsFloat + PBdTyrStd.AsFloat ;
2872
    PBdPheTyrApp.AsFloat := PBdPheApp.AsFloat + PBdTyrApp.AsFloat ;
2873
  end ;
2874
  if (PAliment.AAtotal[1] = 0) or (PAliment.CUDAA[1] = 0)
2875
  then
2876
  begin
2877
    PBProtPheTyrStd.Text := '' ;
2878
    PBProtPheTyrTot.Text := '' ;
2879
  end
2880
  else
2881
  begin
2882
    PBProtPheTyrStd.AsFloat := PBProtPheStd.AsFloat + PBProtTyrStd.AsFloat ;
2883
    PBProtPheTyrTot.AsFloat := PBProtPheTot.AsFloat + PBProtTyrTot.AsFloat ;
2884
  end ;
2885
  // trp / AA neutres
2886
  with PAliment^ do
2887
    if AAtotal[6] * CUDAA[6] + AAtotal[7] * CUDAA[7] + AAtotal[8] * CUDAA[8] + AAtotal[9] * CUDAA[9] + AAtotal[10] * CUDAA[10] = 0
2888
    then
2889
      PBTrpStd.Text := ''
2890
    else
2891
      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 ;
2892
  with PAliment^ do
2893
    if AAtotal[6] + AAtotal[7] + AAtotal[8] + AAtotal[9] + AAtotal[10] = 0
2894
    then
2895
      PBTrpTot.Text := ''
2896
    else
2897
      PBTrpTot.AsFloat := AAtotal[4] / (AAtotal[6] + AAtotal[7] + AAtotal[8] + AAtotal[9] + AAtotal[10]) * 100 ;
2898
  // EAA-N / N
2899
  if (PAliment.AAtotal[0] = 0) or (PAliment.CUDAA[0] = 0)
2900
  then
2901
    PBEAAStd.Text := ''
2902
  else
2903
    with PAliment^ do
2904
      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 ;
2905
  if PAliment.AAtotal[0] = 0
2906
  then
2907
    PBEAATot.Text := ''
2908
  else
2909
    with PAliment^ do
2910
      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 ;
2911
end ;
2912

    
2913
procedure TFAliment.CBAAsLysClick (Sender : TObject) ;
2914
begin
2915
  PBTMet.Enabled := not CBAAsLys.Checked ;
2916
  PBTCys.Enabled := not CBAAsLys.Checked ;
2917
  PBTTrp.Enabled := not CBAAsLys.Checked ;
2918
  PBTThr.Enabled := not CBAAsLys.Checked ;
2919
  PBTPhe.Enabled := not CBAAsLys.Checked ;
2920
  PBTTyr.Enabled := not CBAAsLys.Checked ;
2921
  PBTLeu.Enabled := not CBAAsLys.Checked ;
2922
  PBTIle.Enabled := not CBAAsLys.Checked ;
2923
  PBTVal.Enabled := not CBAAsLys.Checked ;
2924
  PBTHis.Enabled := not CBAAsLys.Checked ;
2925
  PBTArg.Enabled := not CBAAsLys.Checked ;
2926
end ;
2927

    
2928
procedure TFAliment.PBTLysChange(Sender: TObject);
2929
var
2930
  i : integer ;
2931
  variation : double ;
2932
begin
2933
  if (PBTLys.AsFloat <> 0) and not Update
2934
  then
2935
  begin
2936
    Modified := TRUE ;
2937
    // Variation de la teneur en lysine
2938
    with PAliment^ do
2939
      if AAtotal[1] = 0
2940
      then
2941
        variation := 1
2942
      else
2943
        case ConfTAA of
2944
          1 : // %
2945
            variation := PBTLys.AsFloat / 100 * 1000 / RapMS / AAtotal[1] ;
2946
          2 : // % MAT
2947
            variation := PBTLys.AsFloat * CC.MAT / 100 / AAtotal[1] ;
2948
          else // g/kg
2949
            variation := PBTLys.AsFloat / RapMS / AAtotal[1] ;
2950
        end ;
2951
    // Nouvelle valeur
2952
    with PAliment^ do
2953
      case ConfTAA of
2954
        1 : // %
2955
          AAtotal[1] := PBTLys.AsFloat / 100 * 1000 / RapMS ;
2956
        2 : // % MAT
2957
          AAtotal[1] := PBTLys.AsFloat * CC.MAT / 100 ;
2958
        else // g/kg
2959
          AAtotal[1] := PBTLys.AsFloat / RapMS ;
2960
      end ;
2961
    Update := TRUE ;
2962
    if CBAAsLys.Checked
2963
    then
2964
    begin
2965
      // Variation des teneur en acides amin?s (r?gle de trois)
2966
      with PAliment^ do
2967
        for i := 2 to 12 do
2968
          AAtotal[i] := AAtotal[i] * variation ;
2969
      // Affichage des valeurs
2970
      AffichTAA ;
2971
    end ;
2972
    if ConfDig = 1
2973
    then // Teneur digestible
2974
      AffichdAA ;
2975
    Update := FALSE ;
2976
    // Calcul des champs li?s ? cette valeur
2977
    CalculAA ;
2978
  end ;
2979
end;
2980

    
2981
procedure TFAliment.PBTLysExit (Sender : TObject) ;
2982
var
2983
  i : integer ;
2984
begin
2985
  if (PBTLys.AsFloat = 0) and (PAliment.AAtotal[1] <> 0)
2986
  then
2987
  begin
2988
    Modified := TRUE ;
2989
    // Valeur nulle
2990
    with PAliment^ do
2991
      AAtotal[1] := 0 ;
2992
    Update := TRUE ;
2993
    if CBAAsLys.Checked
2994
    then
2995
    begin
2996
      // Variation des teneur en acides amin?s (r?gle de trois)
2997
      with PAliment^ do
2998
        for i := 2 to 12 do
2999
          AAtotal[i] := 0 ;
3000
      // Affichage des valeurs
3001
      AffichTAA ;
3002
    end ;
3003
    if ConfDig = 1
3004
    then // Teneur digestible
3005
      AffichdAA ;
3006
    Update := FALSE ;
3007
    // Calcul des champs li?s ? cette valeur
3008
    CalculAA ;
3009
  end ;
3010
end ;
3011

    
3012
procedure TFAliment.PBTMetChange(Sender: TObject);
3013
begin
3014
  if not Update
3015
  then
3016
  begin
3017
    Modified := TRUE ;
3018
    // Nouvelle valeur
3019
    with PAliment^ do
3020
      case ConfTAA of
3021
        1 : // %
3022
          AAtotal[2] := PBTMet.AsFloat / 100 * 1000 / RapMS ;
3023
        2 : // % MAT
3024
          AAtotal[2] := PBTMet.AsFloat * CC.MAT / 100 ;
3025
        else // g/kg
3026
          AAtotal[2] := PBTMet.AsFloat / RapMS ;
3027
      end ;
3028
    Update := TRUE ;
3029
    if ConfDig = 1
3030
    then // Teneur digestible
3031
      AffichdAA ;
3032
    Update := FALSE ;
3033
    // Calcul des champs li?s ? cette valeur
3034
    CalculAA ;
3035
  end ;
3036
end;
3037

    
3038
procedure TFAliment.PBTCysChange(Sender: TObject);
3039
begin
3040
  if not Update
3041
  then
3042
  begin
3043
    Modified := TRUE ;
3044
    // Nouvelle valeur
3045
    with PAliment^ do
3046
      case ConfTAA of
3047
        1 : // %
3048
          AAtotal[3] := PBTCys.AsFloat / 100 * 1000 / RapMS ;
3049
        2 : // % MAT
3050
          AAtotal[3] := PBTCys.AsFloat * CC.MAT / 100 ;
3051
        else // g/kg
3052
          AAtotal[3] := PBTCys.AsFloat / RapMS ;
3053
      end ;
3054
    Update := TRUE ;
3055
    if ConfDig = 1
3056
    then // Teneur digestible
3057
      AffichdAA ;
3058
    Update := FALSE ;
3059
    // Calcul des champs li?s ? cette valeur
3060
    CalculAA ;
3061
  end ;
3062
end;
3063

    
3064
procedure TFAliment.PBTTrpChange(Sender: TObject);
3065
begin
3066
  if not Update
3067
  then
3068
  begin
3069
    Modified := TRUE ;
3070
    // Nouvelle valeur
3071
    with PAliment^ do
3072
      case ConfTAA of
3073
        1 : // %
3074
          AAtotal[4] := PBTTrp.AsFloat / 100 * 1000 / RapMS ;
3075
        2 : // % MAT
3076
          AAtotal[4] := PBTTrp.AsFloat * CC.MAT / 100 ;
3077
        else // g/kg
3078
          AAtotal[4] := PBTTrp.AsFloat / RapMS ;
3079
      end ;
3080
    Update := TRUE ;
3081
    if ConfDig = 1
3082
    then // Teneur digestible
3083
      AffichdAA ;
3084
    Update := FALSE ;
3085
    // Calcul des champs li?s ? cette valeur
3086
    CalculAA ;
3087
  end ;
3088
end;
3089

    
3090
procedure TFAliment.PBTThrChange(Sender: TObject);
3091
begin
3092
  if not Update
3093
  then
3094
  begin
3095
    Modified := TRUE ;
3096
    // Nouvelle valeur
3097
    with PAliment^ do
3098
      case ConfTAA of
3099
        1 : // %
3100
          AAtotal[5] := PBTThr.AsFloat / 100 * 1000 / RapMS ;
3101
        2 : // % MAT
3102
          AAtotal[5] := PBTThr.AsFloat * CC.MAT / 100 ;
3103
        else // g/kg
3104
          AAtotal[5] := PBTThr.AsFloat / RapMS ;
3105
      end ;
3106
    Update := TRUE ;
3107
    if ConfDig = 1
3108
    then // Teneur digestible
3109
      AffichdAA ;
3110
    Update := FALSE ;
3111
    // Calcul des champs li?s ? cette valeur
3112
    CalculAA ;
3113
  end ;
3114
end;
3115

    
3116
procedure TFAliment.PBTPheChange(Sender: TObject);
3117
begin
3118
  if not Update
3119
  then
3120
  begin
3121
    Modified := TRUE ;
3122
    // Nouvelle valeur
3123
    with PAliment^ do
3124
      case ConfTAA of
3125
        1 : // %
3126
          AAtotal[6] := PBTPhe.AsFloat / 100 * 1000 / RapMS ;
3127
        2 : // % MAT
3128
          AAtotal[6] := PBTPhe.AsFloat * CC.MAT / 100 ;
3129
        else // g/kg
3130
          AAtotal[6] := PBTPhe.AsFloat / RapMS ;
3131
      end ;
3132
    Update := TRUE ;
3133
    if ConfDig = 1
3134
    then // Teneur digestible
3135
      AffichdAA ;
3136
    Update := FALSE ;
3137
    // Calcul des champs li?s ? cette valeur
3138
    CalculAA ;
3139
  end ;
3140
end;
3141

    
3142
procedure TFAliment.PBTTyrChange(Sender: TObject);
3143
begin
3144
  if not Update
3145
  then
3146
  begin
3147
    Modified := TRUE ;
3148
    // Nouvelle valeur
3149
    with PAliment^ do
3150
      case ConfTAA of
3151
        1 : // %
3152
          AAtotal[7] := PBTTyr.AsFloat / 100 * 1000 / RapMS ;
3153
        2 : // % MAT
3154
          AAtotal[7] := PBTTyr.AsFloat * CC.MAT / 100 ;
3155
        else // g/kg
3156
          AAtotal[7] := PBTTyr.AsFloat / RapMS ;
3157
      end ;
3158
    Update := TRUE ;
3159
    if ConfDig = 1
3160
    then // Teneur digestible
3161
      AffichdAA ;
3162
    Update := FALSE ;
3163
    // Calcul des champs li?s ? cette valeur
3164
    CalculAA ;
3165
  end ;
3166
end;
3167

    
3168
procedure TFAliment.PBTLeuChange(Sender: TObject);
3169
begin
3170
  if not Update
3171
  then
3172
  begin
3173
    Modified := TRUE ;
3174
    // Nouvelle valeur
3175
    with PAliment^ do
3176
      case ConfTAA of
3177
        1 : // %
3178
          AAtotal[8] := PBTLeu.AsFloat / 100 * 1000 / RapMS ;
3179
        2 : // % MAT
3180
          AAtotal[8] := PBTLeu.AsFloat * CC.MAT / 100 ;
3181
        else // g/kg
3182
          AAtotal[8] := PBTLeu.AsFloat / RapMS ;
3183
      end ;
3184
    Update := TRUE ;
3185
    if ConfDig = 1
3186
    then // Teneur digestible
3187
      AffichdAA ;
3188
    Update := FALSE ;
3189
    // Calcul des champs li?s ? cette valeur
3190
    CalculAA ;
3191
  end ;
3192
end;
3193

    
3194
procedure TFAliment.PBTIleChange(Sender: TObject);
3195
begin
3196
  if not Update
3197
  then
3198
  begin
3199
    Modified := TRUE ;
3200
    // Nouvelle valeur
3201
    with PAliment^ do
3202
      case ConfTAA of
3203
        1 : // %
3204
          AAtotal[9] := PBTIle.AsFloat / 100 * 1000 / RapMS ;
3205
        2 : // % MAT
3206
          AAtotal[9] := PBTIle.AsFloat * CC.MAT / 100 ;
3207
        else // g/kg
3208
          AAtotal[9] := PBTIle.AsFloat / RapMS ;
3209
      end ;
3210
    Update := TRUE ;
3211
    if ConfDig = 1
3212
    then // Teneur digestible
3213
      AffichdAA ;
3214
    Update := FALSE ;
3215
    // Calcul des champs li?s ? cette valeur
3216
    CalculAA ;
3217
  end ;
3218
end;
3219

    
3220
procedure TFAliment.PBTValChange(Sender: TObject);
3221
begin
3222
  if not Update
3223
  then
3224
  begin
3225
    Modified := TRUE ;
3226
    // Nouvelle valeur
3227
    with PAliment^ do
3228
      case ConfTAA of
3229
        1 : // %
3230
          AAtotal[10] := PBTVal.AsFloat / 100 * 1000 / RapMS ;
3231
        2 : // % MAT
3232
          AAtotal[10] := PBTVal.AsFloat * CC.MAT / 100 ;
3233
        else // g/kg
3234
          AAtotal[10] := PBTVal.AsFloat / RapMS ;
3235
      end ;
3236
    Update := TRUE ;
3237
    if ConfDig = 1
3238
    then // Teneur digestible
3239
      AffichdAA ;
3240
    Update := FALSE ;
3241
    // Calcul des champs li?s ? cette valeur
3242
    CalculAA ;
3243
  end ;
3244
end;
3245

    
3246
procedure TFAliment.PBTHisChange(Sender: TObject);
3247
begin
3248
  if not Update
3249
  then
3250
  begin
3251
    Modified := TRUE ;
3252
    // Nouvelle valeur
3253
    with PAliment^ do
3254
      case ConfTAA of
3255
        1 : // %
3256
          AAtotal[11] := PBTHis.AsFloat / 100 * 1000 / RapMS ;
3257
        2 : // % MAT
3258
          AAtotal[11] := PBTHis.AsFloat * CC.MAT / 100 ;
3259
        else // g/kg
3260
          AAtotal[11] := PBTHis.AsFloat / RapMS ;
3261
      end ;
3262
    Update := TRUE ;
3263
    if ConfDig = 1
3264
    then // Teneur digestible
3265
      AffichdAA ;
3266
    Update := FALSE ;
3267
    // Calcul des champs li?s ? cette valeur
3268
    CalculAA ;
3269
  end ;
3270
end;
3271

    
3272
procedure TFAliment.PBTArgChange(Sender: TObject);
3273
begin
3274
  if not Update
3275
  then
3276
  begin
3277
    Modified := TRUE ;
3278
    // Nouvelle valeur
3279
    with PAliment^ do
3280
      case ConfTAA of
3281
        1 : // %
3282
          AAtotal[12] := PBTArg.AsFloat / 100 * 1000 / RapMS ;
3283
        2 : // % MAT
3284
          AAtotal[12] := PBTArg.AsFloat * CC.MAT / 100 ;
3285
        else // g/kg
3286
          AAtotal[12] := PBTArg.AsFloat / RapMS ;
3287
      end ;
3288
    Update := TRUE ;
3289
    if ConfDig = 1
3290
    then // Teneur digestible
3291
      AffichdAA ;
3292
    Update := FALSE ;
3293
    // Calcul des champs li?s ? cette valeur
3294
    CalculAA ;
3295
  end ;
3296
end;
3297

    
3298
procedure TFAliment.PBdMATStdChange(Sender: TObject);
3299
begin
3300
  if not Update
3301
  then
3302
  begin
3303
    Modified := TRUE ;
3304
    // Nouvelle valeur
3305
    with PAliment^ do
3306
      if ConfDig = 0
3307
      then // CUD
3308
        CUDAA[0] := PBdMATStd.AsFloat
3309
      else // Teneur digestible
3310
        if ConfdAA = 0
3311
        then // g/kg
3312
          CUDAA[0] := PBdMATStd.AsFloat / AATotal[0] * 100 / RapMS
3313
        else // %
3314
          CUDAA[0] := PBdMATStd.AsFloat / AATotal[0] * 1000 / RapMS ;
3315
    // Calcul des champs li?s ? cette valeur
3316
    CalculAA ;
3317
  end ;
3318
end;
3319

    
3320
procedure TFAliment.PBdLysStdChange(Sender: TObject);
3321
begin
3322
  if not Update
3323
  then
3324
  begin
3325
    Modified := TRUE ;
3326
    // Nouvelle valeur
3327
    with PAliment^ do
3328
      if ConfDig = 0
3329
      then // CUD
3330
        CUDAA[1] := PBdLysStd.AsFloat
3331
      else // Teneur digestible
3332
        if ConfdAA = 0
3333
        then // g/kg
3334
          CUDAA[1] := PBdLysStd.AsFloat / AATotal[1] * 100 / RapMS
3335
        else // %
3336
          CUDAA[1] := PBdLysStd.AsFloat / AATotal[1] * 1000 / RapMS ;
3337
    // Calcul des champs li?s ? cette valeur
3338
    CalculAA ;
3339
  end ;
3340
end;
3341

    
3342
procedure TFAliment.PBdMetStdChange(Sender: TObject);
3343
begin
3344
  if not Update
3345
  then
3346
  begin
3347
    Modified := TRUE ;
3348
    // Nouvelle valeur
3349
    with PAliment^ do
3350
      if ConfDig = 0
3351
      then // CUD
3352
        CUDAA[2] := PBdMetStd.AsFloat
3353
      else // Teneur digestible
3354
        if ConfdAA = 0
3355
        then // g/kg
3356
          CUDAA[2] := PBdMetStd.AsFloat / AATotal[2] * 100 / RapMS
3357
        else // %
3358
          CUDAA[2] := PBdMetStd.AsFloat / AATotal[2] * 1000 / RapMS ;
3359
    // Calcul des champs li?s ? cette valeur
3360
    CalculAA ;
3361
  end ;
3362
end;
3363

    
3364
procedure TFAliment.PBdCysStdChange(Sender: TObject);
3365
begin
3366
  if not Update
3367
  then
3368
  begin
3369
    Modified := TRUE ;
3370
    // Nouvelle valeur
3371
    with PAliment^ do
3372
      if ConfDig = 0
3373
      then // CUD
3374
        CUDAA[3] := PBdCysStd.AsFloat
3375
      else // Teneur digestible
3376
        if ConfdAA = 0
3377
        then // g/kg
3378
          CUDAA[3] := PBdCysStd.AsFloat / AATotal[3] * 100 / RapMS
3379
        else // %
3380
          CUDAA[3] := PBdCysStd.AsFloat / AATotal[3] * 1000 / RapMS ;
3381
    // Calcul des champs li?s ? cette valeur
3382
    CalculAA ;
3383
  end ;
3384
end;
3385

    
3386
procedure TFAliment.PBdTrpStdChange(Sender: TObject);
3387
begin
3388
  if not Update
3389
  then
3390
  begin
3391
    Modified := TRUE ;
3392
    // Nouvelle valeur
3393
    with PAliment^ do
3394
      if ConfDig = 0
3395
      then // CUD
3396
        CUDAA[4] := PBdTrpStd.AsFloat
3397
      else // Teneur digestible
3398
        if ConfdAA = 0
3399
        then // g/kg
3400
          CUDAA[4] := PBdTrpStd.AsFloat / AATotal[4] * 100 / RapMS
3401
        else // %
3402
          CUDAA[4] := PBdTrpStd.AsFloat / AATotal[4] * 1000 / RapMS ;
3403
    // Calcul des champs li?s ? cette valeur
3404
    CalculAA ;
3405
  end ;
3406
end;
3407

    
3408
procedure TFAliment.PBdThrStdChange(Sender: TObject);
3409
begin
3410
  if not Update
3411
  then
3412
  begin
3413
    Modified := TRUE ;
3414
    // Nouvelle valeur
3415
    with PAliment^ do
3416
      if ConfDig = 0
3417
      then // CUD
3418
        CUDAA[5] := PBdThrStd.AsFloat
3419
      else // Teneur digestible
3420
        if ConfdAA = 0
3421
        then // g/kg
3422
          CUDAA[5] := PBdThrStd.AsFloat / AATotal[5] * 100 / RapMS
3423
        else // %
3424
          CUDAA[5] := PBdThrStd.AsFloat / AATotal[5] * 1000 / RapMS ;
3425
    // Calcul des champs li?s ? cette valeur
3426
    CalculAA ;
3427
  end ;
3428
end;
3429

    
3430
procedure TFAliment.PBdPheStdChange(Sender: TObject);
3431
begin
3432
  if not Update
3433
  then
3434
  begin
3435
    Modified := TRUE ;
3436
    // Nouvelle valeur
3437
    with PAliment^ do
3438
      if ConfDig = 0
3439
      then // CUD
3440
        CUDAA[6] := PBdPheStd.AsFloat
3441
      else // Teneur digestible
3442
        if ConfdAA = 0
3443
        then // g/kg
3444
          CUDAA[6] := PBdPheStd.AsFloat / AATotal[6] * 100 / RapMS
3445
        else // %
3446
          CUDAA[6] := PBdPheStd.AsFloat / AATotal[6] * 1000 / RapMS ;
3447
    // Calcul des champs li?s ? cette valeur
3448
    CalculAA ;
3449
  end ;
3450
end;
3451

    
3452
procedure TFAliment.PBdTyrStdChange(Sender: TObject);
3453
begin
3454
  if not Update
3455
  then
3456
  begin
3457
    Modified := TRUE ;
3458
    // Nouvelle valeur
3459
    with PAliment^ do
3460
      if ConfDig = 0
3461
      then // CUD
3462
        CUDAA[7] := PBdTyrStd.AsFloat
3463
      else // Teneur digestible
3464
        if ConfdAA = 0
3465
        then // g/kg
3466
          CUDAA[7] := PBdTyrStd.AsFloat / AATotal[7] * 100 / RapMS
3467
        else // %
3468
          CUDAA[7] := PBdTyrStd.AsFloat / AATotal[7] * 1000 / RapMS ;
3469
    // Calcul des champs li?s ? cette valeur
3470
    CalculAA ;
3471
  end ;
3472
end;
3473

    
3474
procedure TFAliment.PBdLeuStdChange(Sender: TObject);
3475
begin
3476
  if not Update
3477
  then
3478
  begin
3479
    Modified := TRUE ;
3480
    // Nouvelle valeur
3481
    with PAliment^ do
3482
      if ConfDig = 0
3483
      then // CUD
3484
        CUDAA[8] := PBdLeuStd.AsFloat
3485
      else // Teneur digestible
3486
        if ConfdAA = 0
3487
        then // g/kg
3488
          CUDAA[8] := PBdLeuStd.AsFloat / AATotal[8] * 100 / RapMS
3489
        else // %
3490
          CUDAA[8] := PBdLeuStd.AsFloat / AATotal[8] * 1000 / RapMS ;
3491
    // Calcul des champs li?s ? cette valeur
3492
    CalculAA ;
3493
  end ;
3494
end;
3495

    
3496
procedure TFAliment.PBdIleStdChange(Sender: TObject);
3497
begin
3498
  if not Update
3499
  then
3500
  begin
3501
    Modified := TRUE ;
3502
    // Nouvelle valeur
3503
    with PAliment^ do
3504
      if ConfDig = 0
3505
      then // CUD
3506
        CUDAA[9] := PBdIleStd.AsFloat
3507
      else // Teneur digestible
3508
        if ConfdAA = 0
3509
        then // g/kg
3510
          CUDAA[9] := PBdIleStd.AsFloat / AATotal[9] * 100 / RapMS
3511
        else // %
3512
          CUDAA[9] := PBdIleStd.AsFloat / AATotal[9] * 1000 / RapMS ;
3513
    // Calcul des champs li?s ? cette valeur
3514
    CalculAA ;
3515
  end ;
3516
end;
3517

    
3518
procedure TFAliment.PBdValStdChange(Sender: TObject);
3519
begin
3520
  if not Update
3521
  then
3522
  begin
3523
    Modified := TRUE ;
3524
    // Nouvelle valeur
3525
    with PAliment^ do
3526
      if ConfDig = 0
3527
      then // CUD
3528
        CUDAA[10] := PBdValStd.AsFloat
3529
      else // Teneur digestible
3530
        if ConfdAA = 0
3531
        then // g/kg
3532
          CUDAA[10] := PBdValStd.AsFloat / AATotal[10] * 100 / RapMS
3533
        else // %
3534
          CUDAA[10] := PBdValStd.AsFloat / AATotal[10] * 1000 / RapMS ;
3535
    // Calcul des champs li?s ? cette valeur
3536
    CalculAA ;
3537
  end ;
3538
end;
3539

    
3540
procedure TFAliment.PBdHisStdChange(Sender: TObject);
3541
begin
3542
  if not Update
3543
  then
3544
  begin
3545
    Modified := TRUE ;
3546
    // Nouvelle valeur
3547
    with PAliment^ do
3548
      if ConfDig = 0
3549
      then // CUD
3550
        CUDAA[11] := PBdHisStd.AsFloat
3551
      else // Teneur digestible
3552
        if ConfdAA = 0
3553
        then // g/kg
3554
          CUDAA[11] := PBdHisStd.AsFloat / AATotal[11] * 100 / RapMS
3555
        else // %
3556
          CUDAA[11] := PBdHisStd.AsFloat / AATotal[11] * 1000 / RapMS ;
3557
    // Calcul des champs li?s ? cette valeur
3558
    CalculAA ;
3559
  end ;
3560
end;
3561

    
3562
procedure TFAliment.PBdArgStdChange(Sender: TObject);
3563
begin
3564
  if not Update
3565
  then
3566
  begin
3567
    Modified := TRUE ;
3568
    // Nouvelle valeur
3569
    with PAliment^ do
3570
      if ConfDig = 0
3571
      then // CUD
3572
        CUDAA[12] := PBdArgStd.AsFloat
3573
      else // Teneur digestible
3574
        if ConfdAA = 0
3575
        then // g/kg
3576
          CUDAA[12] := PBdArgStd.AsFloat / AATotal[12] * 100 / RapMS
3577
        else // %
3578
          CUDAA[12] := PBdArgStd.AsFloat / AATotal[12] * 1000 / RapMS ;
3579
    // Calcul des champs li?s ? cette valeur
3580
    CalculAA ;
3581
  end ;
3582
end;
3583

    
3584
////////////////////////////////////////////////////////////////////////////////
3585
// Acides gras
3586
////////////////////////////////////////////////////////////////////////////////
3587

    
3588
// Affichage de la teneur en fonction de la configuration
3589
procedure TFAliment.AffichTAG ;
3590
begin
3591
  case ConfTAG of
3592
    0 : // g/kg
3593
      with PAliment.CC do
3594
      begin
3595
        PBC6C8C10_0.AsFloat := C6C8C10 / 100 * AGsLip / 100 * Lip * RapMS ;
3596
        PBC12_0.AsFloat := C12_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3597
        PBC14_0.AsFloat := C14_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3598
        PBC16_0.AsFloat := C16_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3599
        PBC16_1.AsFloat := C16_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3600
        PBC18_0.AsFloat := C18_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3601
        PBC18_1.AsFloat := C18_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3602
        PBC18_2.AsFloat := C18_2 / 100 * AGsLip / 100 * Lip * RapMS ;
3603
        PBC18_3.AsFloat := C18_3 / 100 * AGsLip / 100 * Lip * RapMS ;
3604
        PBC18_4.AsFloat := C18_4 / 100 * AGsLip / 100 * Lip * RapMS ;
3605
        PBC20_0.AsFloat := C20_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3606
        PBC20_1.AsFloat := C20_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3607
        PBC20_4.AsFloat := C20_4 / 100 * AGsLip / 100 * Lip * RapMS ;
3608
        PBC20_5.AsFloat := C20_5 / 100 * AGsLip / 100 * Lip * RapMS ;
3609
        PBC22_0.AsFloat := C22_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3610
        PBC22_1.AsFloat := C22_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3611
        PBC22_5.AsFloat := C22_5 / 100 * AGsLip / 100 * Lip * RapMS ;
3612
        PBC22_6.AsFloat := C22_6 / 100 * AGsLip / 100 * Lip * RapMS ;
3613
        PBC24_0.AsFloat := C24_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3614
      end ;
3615
    1 : // %
3616
      with PAliment.CC do
3617
      begin
3618
        PBC6C8C10_0.AsFloat := C6C8C10 * AGsLip / 100 * Lip / 1000 * RapMS ;
3619
        PBC12_0.AsFloat := C12_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3620
        PBC14_0.AsFloat := C14_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3621
        PBC16_0.AsFloat := C16_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3622
        PBC16_1.AsFloat := C16_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3623
        PBC18_0.AsFloat := C18_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3624
        PBC18_1.AsFloat := C18_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3625
        PBC18_2.AsFloat := C18_2 * AGsLip / 100 * Lip / 1000 * RapMS ;
3626
        PBC18_3.AsFloat := C18_3 * AGsLip / 100 * Lip / 1000 * RapMS ;
3627
        PBC18_4.AsFloat := C18_4 * AGsLip / 100 * Lip / 1000 * RapMS ;
3628
        PBC20_0.AsFloat := C20_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3629
        PBC20_1.AsFloat := C20_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3630
        PBC20_4.AsFloat := C20_4 * AGsLip / 100 * Lip / 1000 * RapMS ;
3631
        PBC20_5.AsFloat := C20_5 * AGsLip / 100 * Lip / 1000 * RapMS ;
3632
        PBC22_0.AsFloat := C22_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3633
        PBC22_1.AsFloat := C22_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3634
        PBC22_5.AsFloat := C22_5 * AGsLip / 100 * Lip / 1000 * RapMS ;
3635
        PBC22_6.AsFloat := C22_6 * AGsLip / 100 * Lip / 1000 * RapMS ;
3636
        PBC24_0.AsFloat := C24_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3637
      end ;
3638
    else // % acides gras
3639
      with PAliment.CC do
3640
      begin
3641
        PBC6C8C10_0.AsFloat := C6C8C10 ;
3642
        PBC12_0.AsFloat := C12_0 ;
3643
        PBC14_0.AsFloat := C14_0 ;
3644
        PBC16_0.AsFloat := C16_0 ;
3645
        PBC16_1.AsFloat := C16_1 ;
3646
        PBC18_0.AsFloat := C18_0 ;
3647
        PBC18_1.AsFloat := C18_1 ;
3648
        PBC18_2.AsFloat := C18_2 ;
3649
        PBC18_3.AsFloat := C18_3 ;
3650
        PBC18_4.AsFloat := C18_4 ;
3651
        PBC20_0.AsFloat := C20_0 ;
3652
        PBC20_1.AsFloat := C20_1 ;
3653
        PBC20_4.AsFloat := C20_4 ;
3654
        PBC20_5.AsFloat := C20_5 ;
3655
        PBC22_0.AsFloat := C22_0 ;
3656
        PBC22_1.AsFloat := C22_1 ;
3657
        PBC22_5.AsFloat := C22_5 ;
3658
        PBC22_6.AsFloat := C22_6 ;
3659
        PBC24_0.AsFloat := C24_0 ;
3660
      end ;
3661
  end ;
3662
end ;
3663

    
3664
procedure TFAliment.CalculAG ;
3665
var
3666
  Omega3, Omega6 : double ;
3667
begin
3668
  // Teneurs totales
3669
  PBC6C8C10_tot.AsFloat := PBC6C8C10_0.AsFloat ;
3670
  PBC12_tot.AsFloat := PBC12_0.AsFloat ;
3671
  PBC14_tot.AsFloat := PBC14_0.AsFloat ;
3672
  PBC16_tot.AsFloat := PBC16_0.AsFloat + PBC16_1.AsFloat ;
3673
  PBC18_tot.AsFloat := PBC18_0.AsFloat + PBC18_1.AsFloat + PBC18_2.AsFloat + PBC18_3.AsFloat + PBC18_4.AsFloat ;
3674
  PBC20_tot.AsFloat := PBC20_0.AsFloat + PBC20_1.AsFloat + PBC20_4.AsFloat + PBC20_5.AsFloat ;
3675
  PBC22_tot.AsFloat := PBC22_0.AsFloat + PBC22_1.AsFloat + PBC22_5.AsFloat + PBC22_6.AsFloat ;
3676
  PBC24_tot.AsFloat := PBC24_0.AsFloat ;
3677
  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 ;
3678
  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 ;
3679
  PBCtot_1.AsFloat := PBC16_1.AsFloat + PBC18_1.AsFloat + PBC20_1.AsFloat + PBC22_1.AsFloat ;
3680
  PBCtot_2.AsFloat := PBC18_2.AsFloat ;
3681
  PBCtot_3.AsFloat := PBC18_3.AsFloat ;
3682
  PBCtot_4.AsFloat := PBC18_4.AsFloat + PBC20_4.AsFloat ;
3683
  PBCtot_5.AsFloat := PBC20_5.AsFloat + PBC22_5.AsFloat ;
3684
  PBCtot_6.AsFloat := PBC22_6.AsFloat ;
3685
  // Acides gras satur?s
3686
  if PBCtot_tot.AsFloat = 0
3687
  then
3688
    PBSatur.Text := ''
3689
  else
3690
    PBSatur.AsFloat := PBCtot_0.AsFloat / PBCtot_tot.AsFloat * 100 ;
3691
  // Acides gras mono-insatur?s
3692
  if PBCtot_tot.AsFloat = 0
3693
  then
3694
    PBMono.Text := ''
3695
  else
3696
    PBMono.AsFloat := PBCtot_1.AsFloat / PBCtot_tot.AsFloat * 100 ;
3697
  // Acides gras poly-insatur?s
3698
  PBPoly.AsFloat := 100 - (PBSatur.AsFloat + PBMono.AsFloat) ;
3699
  // Omega-6 / Omega-3
3700
  Omega3 := PBC18_3.AsFloat + PBC18_4.AsFloat + PBC20_5.AsFloat + PBC22_5.AsFloat + PBC22_6.AsFloat ;
3701
  Omega6 := PBC18_2.AsFloat + PBC20_4.AsFloat ;
3702
  if Omega3 = 0
3703
  then
3704
    PBO6sO3.Text := 'infini'
3705
  else
3706
    PBO6sO3.AsFloat := Omega6 / Omega3 ;
3707
end ;
3708

    
3709
procedure TFAliment.PBAGChange (Sender : TObject) ;
3710
begin
3711
  if not Update
3712
  then
3713
  begin
3714
    Modified := TRUE ;
3715
    // Nouvelle valeur
3716
    PAliment.CC.AGsLip := PBAG.AsFloat ;
3717
    Update := TRUE ;
3718
    // R?affichage des teneurs en acides gras (si besoin)
3719
    case ConfTAG of
3720
      0 : // g/kg
3721
        with PAliment.CC do
3722
        begin
3723
          PBC6C8C10_0.AsFloat := C6C8C10 / 100 * AGsLip / 100 * Lip * RapMS ;
3724
          PBC12_0.AsFloat := C12_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3725
          PBC14_0.AsFloat := C14_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3726
          PBC16_0.AsFloat := C16_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3727
          PBC16_1.AsFloat := C16_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3728
          PBC18_0.AsFloat := C18_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3729
          PBC18_1.AsFloat := C18_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3730
          PBC18_2.AsFloat := C18_2 / 100 * AGsLip / 100 * Lip * RapMS ;
3731
          PBC18_3.AsFloat := C18_3 / 100 * AGsLip / 100 * Lip * RapMS ;
3732
          PBC18_4.AsFloat := C18_4 / 100 * AGsLip / 100 * Lip * RapMS ;
3733
          PBC20_0.AsFloat := C20_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3734
          PBC20_1.AsFloat := C20_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3735
          PBC20_4.AsFloat := C20_4 / 100 * AGsLip / 100 * Lip * RapMS ;
3736
          PBC20_5.AsFloat := C20_5 / 100 * AGsLip / 100 * Lip * RapMS ;
3737
          PBC22_0.AsFloat := C22_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3738
          PBC22_1.AsFloat := C22_1 / 100 * AGsLip / 100 * Lip * RapMS ;
3739
          PBC22_5.AsFloat := C22_5 / 100 * AGsLip / 100 * Lip * RapMS ;
3740
          PBC22_6.AsFloat := C22_6 / 100 * AGsLip / 100 * Lip * RapMS ;
3741
          PBC24_0.AsFloat := C24_0 / 100 * AGsLip / 100 * Lip * RapMS ;
3742
        end ;
3743
      1 : // %
3744
        with PAliment.CC do
3745
        begin
3746
          PBC6C8C10_0.AsFloat := C6C8C10 * AGsLip / 100 * Lip / 1000 * RapMS ;
3747
          PBC12_0.AsFloat := C12_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3748
          PBC14_0.AsFloat := C14_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3749
          PBC16_0.AsFloat := C16_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3750
          PBC16_1.AsFloat := C16_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3751
          PBC18_0.AsFloat := C18_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3752
          PBC18_1.AsFloat := C18_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3753
          PBC18_2.AsFloat := C18_2 * AGsLip / 100 * Lip / 1000 * RapMS ;
3754
          PBC18_3.AsFloat := C18_3 * AGsLip / 100 * Lip / 1000 * RapMS ;
3755
          PBC18_4.AsFloat := C18_4 * AGsLip / 100 * Lip / 1000 * RapMS ;
3756
          PBC20_0.AsFloat := C20_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3757
          PBC20_1.AsFloat := C20_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3758
          PBC20_4.AsFloat := C20_4 * AGsLip / 100 * Lip / 1000 * RapMS ;
3759
          PBC20_5.AsFloat := C20_5 * AGsLip / 100 * Lip / 1000 * RapMS ;
3760
          PBC22_0.AsFloat := C22_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3761
          PBC22_1.AsFloat := C22_1 * AGsLip / 100 * Lip / 1000 * RapMS ;
3762
          PBC22_5.AsFloat := C22_5 * AGsLip / 100 * Lip / 1000 * RapMS ;
3763
          PBC22_6.AsFloat := C22_6 * AGsLip / 100 * Lip / 1000 * RapMS ;
3764
          PBC24_0.AsFloat := C24_0 * AGsLip / 100 * Lip / 1000 * RapMS ;
3765
        end ;
3766
    end ;
3767
    Update := FALSE ;
3768
    // Calcul des champs li?s ? cette valeur
3769
    CalculAG ;
3770
  end ;
3771
end ;
3772

    
3773
procedure TFAliment.PBC6C8C10_0Change (Sender : TObject) ;
3774
begin
3775
  if not Update
3776
  then
3777
  begin
3778
    Modified := TRUE ;
3779
    // Nouvelle valeur
3780
    with PAliment.CC do
3781
      case ConfTAG of
3782
        0 : // g/kg
3783
          if (AGsLip = 0) or (Lip = 0)
3784
          then
3785
            C6C8C10 := 0
3786
          else
3787
            C6C8C10 := PBC6C8C10_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3788
        1 : // %
3789
          if (AGsLip = 0) or (Lip = 0)
3790
          then
3791
            C6C8C10 := 0
3792
          else
3793
            C6C8C10 := PBC6C8C10_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3794
        else // % acides gras
3795
          C6C8C10 := PBC6C8C10_0.AsFloat ;
3796
      end ;
3797
    // Calcul des champs li?s ? cette valeur
3798
    CalculAG ;
3799
  end ;
3800
end ;
3801

    
3802
procedure TFAliment.PBC12_0Change (Sender : TObject) ;
3803
begin
3804
  if not Update
3805
  then
3806
  begin
3807
    Modified := TRUE ;
3808
    // Nouvelle valeur
3809
    with PAliment.CC do
3810
      case ConfTAG of
3811
        0 : // g/kg
3812
          if (AGsLip = 0) or (Lip = 0)
3813
          then
3814
            C12_0 := 0
3815
          else
3816
            C12_0 := PBC12_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3817
        1 : // %
3818
          if (AGsLip = 0) or (Lip = 0)
3819
          then
3820
            C12_0 := 0
3821
          else
3822
            C12_0 := PBC12_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3823
        else // % acides gras
3824
          C12_0 := PBC12_0.AsFloat ;
3825
      end ;
3826
    // Calcul des champs li?s ? cette valeur
3827
    CalculAG ;
3828
  end ;
3829
end ;
3830

    
3831
procedure TFAliment.PBC14_0Change (Sender : TObject) ;
3832
begin
3833
  if not Update
3834
  then
3835
  begin
3836
    Modified := TRUE ;
3837
    // Nouvelle valeur
3838
    with PAliment.CC do
3839
      case ConfTAG of
3840
        0 : // g/kg
3841
          if (AGsLip = 0) or (Lip = 0)
3842
          then
3843
            C14_0 := 0
3844
          else
3845
            C14_0 := PBC14_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3846
        1 : // %
3847
          if (AGsLip = 0) or (Lip = 0)
3848
          then
3849
            C14_0 := 0
3850
          else
3851
            C14_0 := PBC14_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3852
        else // % acides gras
3853
          C14_0 := PBC14_0.AsFloat ;
3854
      end ;
3855
    // Calcul des champs li?s ? cette valeur
3856
    CalculAG ;
3857
  end ;
3858
end ;
3859

    
3860
procedure TFAliment.PBC16_0Change (Sender : TObject) ;
3861
begin
3862
  if not Update
3863
  then
3864
  begin
3865
    Modified := TRUE ;
3866
    // Nouvelle valeur
3867
    with PAliment.CC do
3868
      case ConfTAG of
3869
        0 : // g/kg
3870
          if (AGsLip = 0) or (Lip = 0)
3871
          then
3872
            C16_0 := 0
3873
          else
3874
            C16_0 := PBC16_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3875
        1 : // %
3876
          if (AGsLip = 0) or (Lip = 0)
3877
          then
3878
            C16_0 := 0
3879
          else
3880
            C16_0 := PBC16_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3881
        else // % acides gras
3882
          C16_0 := PBC16_0.AsFloat ;
3883
      end ;
3884
    // Calcul des champs li?s ? cette valeur
3885
    CalculAG ;
3886
  end ;
3887
end ;
3888

    
3889
procedure TFAliment.PBC16_1Change (Sender : TObject) ;
3890
begin
3891
  if not Update
3892
  then
3893
  begin
3894
    Modified := TRUE ;
3895
    // Nouvelle valeur
3896
    with PAliment.CC do
3897
      case ConfTAG of
3898
        0 : // g/kg
3899
          if (AGsLip = 0) or (Lip = 0)
3900
          then
3901
            C16_1 := 0
3902
          else
3903
            C16_1 := PBC16_1.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3904
        1 : // %
3905
          if (AGsLip = 0) or (Lip = 0)
3906
          then
3907
            C16_1 := 0
3908
          else
3909
            C16_1 := PBC16_1.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3910
        else // % acides gras
3911
          C16_1 := PBC16_1.AsFloat ;
3912
      end ;
3913
    // Calcul des champs li?s ? cette valeur
3914
    CalculAG ;
3915
  end ;
3916
end ;
3917

    
3918
procedure TFAliment.PBC18_0Change (Sender : TObject) ;
3919
begin
3920
  if not Update
3921
  then
3922
  begin
3923
    Modified := TRUE ;
3924
    // Nouvelle valeur
3925
    with PAliment.CC do
3926
      case ConfTAG of
3927
        0 : // g/kg
3928
          if (AGsLip = 0) or (Lip = 0)
3929
          then
3930
            C18_0 := 0
3931
          else
3932
            C18_0 := PBC18_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3933
        1 : // %
3934
          if (AGsLip = 0) or (Lip = 0)
3935
          then
3936
            C18_0 := 0
3937
          else
3938
            C18_0 := PBC18_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3939
        else // % acides gras
3940
          C18_0 := PBC18_0.AsFloat ;
3941
      end ;
3942
    // Calcul des champs li?s ? cette valeur
3943
    CalculAG ;
3944
  end ;
3945
end ;
3946

    
3947
procedure TFAliment.PBC18_1Change (Sender : TObject) ;
3948
begin
3949
  if not Update
3950
  then
3951
  begin
3952
    Modified := TRUE ;
3953
    // Nouvelle valeur
3954
    with PAliment.CC do
3955
      case ConfTAG of
3956
        0 : // g/kg
3957
          if (AGsLip = 0) or (Lip = 0)
3958
          then
3959
            C18_1 := 0
3960
          else
3961
            C18_1 := PBC18_1.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3962
        1 : // %
3963
          if (AGsLip = 0) or (Lip = 0)
3964
          then
3965
            C18_1 := 0
3966
          else
3967
            C18_1 := PBC18_1.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3968
        else // % acides gras
3969
          C18_1 := PBC18_1.AsFloat ;
3970
      end ;
3971
    // Calcul des champs li?s ? cette valeur
3972
    CalculAG ;
3973
  end ;
3974
end ;
3975

    
3976
procedure TFAliment.PBC18_2Change (Sender : TObject) ;
3977
begin
3978
  if not Update
3979
  then
3980
  begin
3981
    Modified := TRUE ;
3982
    // Nouvelle valeur
3983
    with PAliment.CC do
3984
      case ConfTAG of
3985
        0 : // g/kg
3986
          if (AGsLip = 0) or (Lip = 0)
3987
          then
3988
            C18_2 := 0
3989
          else
3990
            C18_2 := PBC18_2.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
3991
        1 : // %
3992
          if (AGsLip = 0) or (Lip = 0)
3993
          then
3994
            C18_2 := 0
3995
          else
3996
            C18_2 := PBC18_2.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
3997
        else // % acides gras
3998
          C18_2 := PBC18_2.AsFloat ;
3999
      end ;
4000
    // Calcul des champs li?s ? cette valeur
4001
    CalculAG ;
4002
  end ;
4003
end ;
4004

    
4005
procedure TFAliment.PBC18_3Change (Sender : TObject) ;
4006
begin
4007
  if not Update
4008
  then
4009
  begin
4010
    Modified := TRUE ;
4011
    // Nouvelle valeur
4012
    with PAliment.CC do
4013
      case ConfTAG of
4014
        0 : // g/kg
4015
          if (AGsLip = 0) or (Lip = 0)
4016
          then
4017
            C18_3 := 0
4018
          else
4019
            C18_3 := PBC18_3.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4020
        1 : // %
4021
          if (AGsLip = 0) or (Lip = 0)
4022
          then
4023
            C18_3 := 0
4024
          else
4025
            C18_3 := PBC18_3.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4026
        else // % acides gras
4027
          C18_3 := PBC18_3.AsFloat ;
4028
      end ;
4029
    // Calcul des champs li?s ? cette valeur
4030
    CalculAG ;
4031
  end ;
4032
end ;
4033

    
4034
procedure TFAliment.PBC18_4Change (Sender : TObject) ;
4035
begin
4036
  if not Update
4037
  then
4038
  begin
4039
    Modified := TRUE ;
4040
    // Nouvelle valeur
4041
    with PAliment.CC do
4042
      case ConfTAG of
4043
        0 : // g/kg
4044
          if (AGsLip = 0) or (Lip = 0)
4045
          then
4046
            C18_4 := 0
4047
          else
4048
            C18_4 := PBC18_4.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4049
        1 : // %
4050
          if (AGsLip = 0) or (Lip = 0)
4051
          then
4052
            C18_4 := 0
4053
          else
4054
            C18_4 := PBC18_4.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4055
        else // % acides gras
4056
          C18_4 := PBC18_4.AsFloat ;
4057
      end ;
4058
    // Calcul des champs li?s ? cette valeur
4059
    CalculAG ;
4060
  end ;
4061
end ;
4062

    
4063
procedure TFAliment.PBC20_0Change (Sender : TObject) ;
4064
begin
4065
  if not Update
4066
  then
4067
  begin
4068
    Modified := TRUE ;
4069
    // Nouvelle valeur
4070
    with PAliment.CC do
4071
      case ConfTAG of
4072
        0 : // g/kg
4073
          if (AGsLip = 0) or (Lip = 0)
4074
          then
4075
            C20_0 := 0
4076
          else
4077
            C20_0 := PBC20_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4078
        1 : // %
4079
          if (AGsLip = 0) or (Lip = 0)
4080
          then
4081
            C20_0 := 0
4082
          else
4083
            C20_0 := PBC20_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4084
        else // % acides gras
4085
          C20_0 := PBC20_0.AsFloat ;
4086
      end ;
4087
    // Calcul des champs li?s ? cette valeur
4088
    CalculAG ;
4089
  end ;
4090
end ;
4091

    
4092
procedure TFAliment.PBC20_1Change (Sender : TObject) ;
4093
begin
4094
  if not Update
4095
  then
4096
  begin
4097
    Modified := TRUE ;
4098
    // Nouvelle valeur
4099
    with PAliment.CC do
4100
      case ConfTAG of
4101
        0 : // g/kg
4102
          if (AGsLip = 0) or (Lip = 0)
4103
          then
4104
            C20_1 := 0
4105
          else
4106
            C20_1 := PBC20_1.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4107
        1 : // %
4108
          if (AGsLip = 0) or (Lip = 0)
4109
          then
4110
            C20_1 := 0
4111
          else
4112
            C20_1 := PBC20_1.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4113
        else // % acides gras
4114
          C20_1 := PBC20_1.AsFloat ;
4115
      end ;
4116
    // Calcul des champs li?s ? cette valeur
4117
    CalculAG ;
4118
  end ;
4119
end ;
4120

    
4121
procedure TFAliment.PBC20_4Change (Sender : TObject) ;
4122
begin
4123
  if not Update
4124
  then
4125
  begin
4126
    Modified := TRUE ;
4127
    // Nouvelle valeur
4128
    with PAliment.CC do
4129
      case ConfTAG of
4130
        0 : // g/kg
4131
          if (AGsLip = 0) or (Lip = 0)
4132
          then
4133
            C20_4 := 0
4134
          else
4135
            C20_4 := PBC20_4.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4136
        1 : // %
4137
          if (AGsLip = 0) or (Lip = 0)
4138
          then
4139
            C20_4 := 0
4140
          else
4141
            C20_4 := PBC20_4.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4142
        else // % acides gras
4143
          C20_4 := PBC20_4.AsFloat ;
4144
      end ;
4145
    // Calcul des champs li?s ? cette valeur
4146
    CalculAG ;
4147
  end ;
4148
end ;
4149

    
4150
procedure TFAliment.PBC20_5Change (Sender : TObject) ;
4151
begin
4152
  if not Update
4153
  then
4154
  begin
4155
    Modified := TRUE ;
4156
    // Nouvelle valeur
4157
    with PAliment.CC do
4158
      case ConfTAG of
4159
        0 : // g/kg
4160
          if (AGsLip = 0) or (Lip = 0)
4161
          then
4162
            C20_5 := 0
4163
          else
4164
            C20_5 := PBC20_5.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4165
        1 : // %
4166
          if (AGsLip = 0) or (Lip = 0)
4167
          then
4168
            C20_5 := 0
4169
          else
4170
            C20_5 := PBC20_5.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4171
        else // % acides gras
4172
          C20_5 := PBC20_5.AsFloat ;
4173
      end ;
4174
    // Calcul des champs li?s ? cette valeur
4175
    CalculAG ;
4176
  end ;
4177
end ;
4178

    
4179
procedure TFAliment.PBC22_0Change (Sender : TObject) ;
4180
begin
4181
  if not Update
4182
  then
4183
  begin
4184
    Modified := TRUE ;
4185
    // Nouvelle valeur
4186
    with PAliment.CC do
4187
      case ConfTAG of
4188
        0 : // g/kg
4189
          if (AGsLip = 0) or (Lip = 0)
4190
          then
4191
            C22_0 := 0
4192
          else
4193
            C22_0 := PBC22_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4194
        1 : // %
4195
          if (AGsLip = 0) or (Lip = 0)
4196
          then
4197
            C22_0 := 0
4198
          else
4199
            C22_0 := PBC22_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4200
        else // % acides gras
4201
          C22_0 := PBC22_0.AsFloat ;
4202
      end ;
4203
    // Calcul des champs li?s ? cette valeur
4204
    CalculAG ;
4205
  end ;
4206
end ;
4207

    
4208
procedure TFAliment.PBC22_1Change (Sender : TObject) ;
4209
begin
4210
  if not Update
4211
  then
4212
  begin
4213
    Modified := TRUE ;
4214
    // Nouvelle valeur
4215
    with PAliment.CC do
4216
      case ConfTAG of
4217
        0 : // g/kg
4218
          if (AGsLip = 0) or (Lip = 0)
4219
          then
4220
            C22_1 := 0
4221
          else
4222
            C22_1 := PBC22_1.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4223
        1 : // %
4224
          if (AGsLip = 0) or (Lip = 0)
4225
          then
4226
            C22_1 := 0
4227
          else
4228
            C22_1 := PBC22_1.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4229
        else // % acides gras
4230
          C22_1 := PBC22_1.AsFloat ;
4231
      end ;
4232
    // Calcul des champs li?s ? cette valeur
4233
    CalculAG ;
4234
  end ;
4235
end ;
4236

    
4237
procedure TFAliment.PBC22_5Change (Sender : TObject) ;
4238
begin
4239
  if not Update
4240
  then
4241
  begin
4242
    Modified := TRUE ;
4243
    // Nouvelle valeur
4244
    with PAliment.CC do
4245
      case ConfTAG of
4246
        0 : // g/kg
4247
          if (AGsLip = 0) or (Lip = 0)
4248
          then
4249
            C22_5 := 0
4250
          else
4251
            C22_5 := PBC22_5.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4252
        1 : // %
4253
          if (AGsLip = 0) or (Lip = 0)
4254
          then
4255
            C22_5 := 0
4256
          else
4257
            C22_5 := PBC22_5.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4258
        else // % acides gras
4259
          C22_5 := PBC22_5.AsFloat ;
4260
      end ;
4261
    // Calcul des champs li?s ? cette valeur
4262
    CalculAG ;
4263
  end ;
4264
end ;
4265

    
4266
procedure TFAliment.PBC22_6Change (Sender : TObject) ;
4267
begin
4268
  if not Update
4269
  then
4270
  begin
4271
    Modified := TRUE ;
4272
    // Nouvelle valeur
4273
    with PAliment.CC do
4274
      case ConfTAG of
4275
        0 : // g/kg
4276
          if (AGsLip = 0) or (Lip = 0)
4277
          then
4278
            C22_6 := 0
4279
          else
4280
            C22_6 := PBC22_6.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4281
        1 : // %
4282
          if (AGsLip = 0) or (Lip = 0)
4283
          then
4284
            C22_6 := 0
4285
          else
4286
            C22_6 := PBC22_6.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4287
        else // % acides gras
4288
          C22_6 := PBC22_6.AsFloat ;
4289
      end ;
4290
    // Calcul des champs li?s ? cette valeur
4291
    CalculAG ;
4292
  end ;
4293
end ;
4294

    
4295
procedure TFAliment.PBC24_0Change (Sender : TObject) ;
4296
begin
4297
  if not Update
4298
  then
4299
  begin
4300
    Modified := TRUE ;
4301
    // Nouvelle valeur
4302
    with PAliment.CC do
4303
      case ConfTAG of
4304
        0 : // g/kg
4305
          if (AGsLip = 0) or (Lip = 0)
4306
          then
4307
            C24_0 := 0
4308
          else
4309
            C24_0 := PBC24_0.AsFloat * 100 / AGsLip * 100 / Lip / RapMS ;
4310
        1 : // %
4311
          if (AGsLip = 0) or (Lip = 0)
4312
          then
4313
            C24_0 := 0
4314
          else
4315
            C24_0 := PBC24_0.AsFloat / AGsLip * 100 / Lip * 1000 / RapMS ;
4316
        else // % acides gras
4317
          C24_0 := PBC24_0.AsFloat ;
4318
      end ;
4319
    // Calcul des champs li?s ? cette valeur
4320
    CalculAG ;
4321
  end ;
4322
end ;
4323

    
4324
////////////////////////////////////////////////////////////////////////////////
4325
// Min?raux
4326
////////////////////////////////////////////////////////////////////////////////
4327

    
4328
// Affichage de la teneur en fonction de la configuration
4329
procedure TFAliment.AffichTMineraux;
4330
begin
4331
  // Macro-?l?ments
4332
  if ConfTMacro = 0
4333
  then // g/kg
4334
    with PAliment.CC do
4335
    begin
4336
      PBCa.AsFloat := Ca * RapMS;
4337
      PBP.AsFloat := P * RapMS;
4338
      PBNa.AsFloat := Na * RapMS;
4339
      PBK.AsFloat := K * RapMS;
4340
      PBMg.AsFloat := Mg * RapMS;
4341
      PBCl.AsFloat := Cl * RapMS;
4342
      PBS.AsFloat := S * RapMS;
4343
    end
4344
  else // %
4345
    with PAliment.CC do
4346
    begin
4347
      PBCa.AsFloat := Ca / 1000 * 100 * RapMS;
4348
      PBP.AsFloat := P / 1000 * 100 * RapMS;
4349
      PBNa.AsFloat := Na / 1000 * 100 * RapMS;
4350
      PBK.AsFloat := K / 1000 * 100 * RapMS;
4351
      PBMg.AsFloat := Mg / 1000 * 100 * RapMS;
4352
      PBCl.AsFloat := Cl / 1000 * 100 * RapMS;
4353
      PBS.AsFloat := S / 1000 * 100 * RapMS;
4354
    end ;
4355
  // Oligo-?l?ments
4356
  if ConfTOligo = 0
4357
  then // mg/kg
4358
    with PAliment.CC do
4359
    begin
4360
      PBCu.AsFloat := Cu * RapMS;
4361
      PBZn.AsFloat := Zn * RapMS;
4362
      PBMn.AsFloat := Mn * RapMS;
4363
      PBFe.AsFloat := Fe * RapMS;
4364
      PBSe.AsFloat := Se * RapMS;
4365
      PBCo.AsFloat := Co * RapMS;
4366
      PBMb.AsFloat := Mb * RapMS;
4367
      PBI.AsFloat := I * RapMS;
4368
    end
4369
  else // %
4370
    with PAliment.CC do
4371
    begin
4372
      PBCu.AsFloat := Cu / 1000000 * 100 * RapMS;
4373
      PBZn.AsFloat := Zn / 1000000 * 100 * RapMS;
4374
      PBMn.AsFloat := Mn / 1000000 * 100 * RapMS;
4375
      PBFe.AsFloat := Fe / 1000000 * 100 * RapMS;
4376
      PBSe.AsFloat := Se / 1000000 * 100 * RapMS;
4377
      PBCo.AsFloat := Co / 1000000 * 100 * RapMS;
4378
      PBMb.AsFloat := Mb / 1000000 * 100 * RapMS;
4379
      PBI.AsFloat := I / 1000000 * 100 * RapMS;
4380
    end ;
4381
  // Phosphore
4382
  PBPtot.AsFloat := PBP.AsFloat;
4383
  if ConfTMacro = 0
4384
  then // g/kg
4385
    with PAliment.CC do
4386
    begin
4387
      PBPdigG.AsFloat := PdigG * RapMS;
4388
      PBPdigF.AsFloat := PdigF * RapMS;
4389
    end
4390
  else // %
4391
    with PAliment.CC do
4392
    begin
4393
      PBPdigG.AsFloat := PdigG / 1000 * 100 * RapMS;
4394
      PBPdigF.AsFloat := PdigF / 1000 * 100 * RapMS;
4395
    end;
4396
  with PAliment.CC do
4397
  begin
4398
    PBPhytase.AsFloat := Phytase;
4399
    PBActPhytE.AsFloat := ActPhytE * RapMS;
4400
    PBActPhytM.AsFloat := ActPhytM * RapMS;
4401
  end;
4402
end;
4403

    
4404
procedure TFAliment.CalculMineraux;
4405
begin
4406
  // Ca / P
4407
  if PAliment.CC.P = 0
4408
  then
4409
    PBCasP.Text := 'infini'
4410
  else
4411
    with PAliment.CC do
4412
      PBCasP.AsFloat := Ca / P;
4413
  // Bilan cations-anions
4414
  with PAliment.CC do
4415
    PBBilanCA.AsFloat := 1000 * (K / 39 + Na / 23 - Cl / 35.5 - S / 16);
4416
  // Bilan ?lectrolytique
4417
  with PAliment.CC do
4418
    PBBilanE.AsFloat := 1000 * (K / 39 + Na / 23 - Cl / 35.5);
4419
end;
4420

    
4421
procedure TFAliment.PBCaChange (Sender : TObject) ;
4422
begin
4423
  if not Update
4424
  then
4425
  begin
4426
    Modified := TRUE ;
4427
    // Nouvelle valeur
4428
    with PAliment.CC do
4429
      if ConfTMacro = 0
4430
      then // g/kg
4431
        Ca := PBCa.AsFloat / RapMS
4432
      else // %
4433
        Ca := PBCa.AsFloat * 1000 / 100 / RapMS ;
4434
    // Calcul des champs li?s ? cette valeur
4435
    CalculMineraux ;
4436
  end ;
4437
end ;
4438

    
4439
procedure TFAliment.PBPChange (Sender : TObject) ;
4440
begin
4441
  if not Update
4442
  then
4443
  begin
4444
    Modified := TRUE ;
4445
    // Nouvelle valeur
4446
    with PAliment.CC do
4447
      if ConfTMacro = 0
4448
      then // g/kg
4449
        P := PBP.AsFloat / RapMS
4450
      else // %
4451
        P := PBP.AsFloat * 1000 / 100 / RapMS ;
4452
    PBPtot.AsFloat := PBP.AsFloat;
4453
    // Calcul des champs li?s ? cette valeur
4454
    CalculMineraux ;
4455
  end ;
4456
end ;
4457

    
4458
procedure TFAliment.PBNaChange (Sender : TObject) ;
4459
begin
4460
  if not Update
4461
  then
4462
  begin
4463
    Modified := TRUE ;
4464
    // Nouvelle valeur
4465
    with PAliment.CC do
4466
      if ConfTMacro = 0
4467
      then // g/kg
4468
        Na := PBNa.AsFloat / RapMS
4469
      else // %
4470
        Na := PBNa.AsFloat * 1000 / 100 / RapMS ;
4471
    // Calcul des champs li?s ? cette valeur
4472
    CalculMineraux ;
4473
  end ;
4474
end ;
4475

    
4476
procedure TFAliment.PBKChange (Sender : TObject) ;
4477
begin
4478
  if not Update
4479
  then
4480
  begin
4481
    Modified := TRUE ;
4482
    // Nouvelle valeur
4483
    with PAliment.CC do
4484
      if ConfTMacro = 0
4485
      then // g/kg
4486
        K := PBK.AsFloat / RapMS
4487
      else // %
4488
        K := PBK.AsFloat * 1000 / 100 / RapMS ;
4489
    // Calcul des champs li?s ? cette valeur
4490
    CalculMineraux ;
4491
  end ;
4492
end ;
4493

    
4494
procedure TFAliment.PBMgChange (Sender : TObject) ;
4495
begin
4496
  if not Update
4497
  then
4498
  begin
4499
    Modified := TRUE ;
4500
    // Nouvelle valeur
4501
    with PAliment.CC do
4502
      if ConfTMacro = 0
4503
      then // g/kg
4504
        Mg := PBMg.AsFloat / RapMS
4505
      else // %
4506
        Mg := PBMg.AsFloat * 1000 / 100 / RapMS ;
4507
  end ;
4508
end ;
4509

    
4510
procedure TFAliment.PBClChange (Sender : TObject) ;
4511
begin
4512
  if not Update
4513
  then
4514
  begin
4515
    Modified := TRUE ;
4516
    // Nouvelle valeur
4517
    with PAliment.CC do
4518
      if ConfTMacro = 0
4519
      then // g/kg
4520
        Cl := PBCl.AsFloat / RapMS
4521
      else // %
4522
        Cl := PBCl.AsFloat * 1000 / 100 / RapMS ;
4523
    // Calcul des champs li?s ? cette valeur
4524
    CalculMineraux ;
4525
  end ;
4526
end ;
4527

    
4528
procedure TFAliment.PBSChange (Sender : TObject) ;
4529
begin
4530
  if not Update
4531
  then
4532
  begin
4533
    Modified := TRUE ;
4534
    // Nouvelle valeur
4535
    with PAliment.CC do
4536
      if ConfTMacro = 0
4537
      then // g/kg
4538
        S := PBS.AsFloat / RapMS
4539
      else // %
4540
        S := PBS.AsFloat * 1000 / 100 / RapMS ;
4541
    // Calcul des champs li?s ? cette valeur
4542
    CalculMineraux ;
4543
  end ;
4544
end ;
4545

    
4546
procedure TFAliment.PBCuChange (Sender : TObject) ;
4547
begin
4548
  if not Update
4549
  then
4550
  begin
4551
    Modified := TRUE ;
4552
    // Nouvelle valeur
4553
    with PAliment.CC do
4554
      if ConfTOligo = 0
4555
      then // mg/kg
4556
        Cu := PBCu.AsFloat / RapMS
4557
      else // %
4558
        Cu := PBCu.AsFloat * 1000000 / 100 / RapMS ;
4559
  end ;
4560
end ;
4561

    
4562
procedure TFAliment.PBZnChange (Sender : TObject) ;
4563
begin
4564
  if not Update
4565
  then
4566
  begin
4567
    Modified := TRUE ;
4568
    // Nouvelle valeur
4569
    with PAliment.CC do
4570
      if ConfTOligo = 0
4571
      then // mg/kg
4572
        Zn := PBZn.AsFloat / RapMS
4573
      else // %
4574
        Zn := PBZn.AsFloat * 1000000 / 100 / RapMS ;
4575
  end ;
4576
end ;
4577

    
4578
procedure TFAliment.PBMnChange (Sender : TObject) ;
4579
begin
4580
  if not Update
4581
  then
4582
  begin
4583
    Modified := TRUE ;
4584
    // Nouvelle valeur
4585
    with PAliment.CC do
4586
      if ConfTOligo = 0
4587
      then // mg/kg
4588
        Mn := PBMn.AsFloat / RapMS
4589
      else // %
4590
        Mn := PBMn.AsFloat * 1000000 / 100 / RapMS ;
4591
  end ;
4592
end ;
4593

    
4594
procedure TFAliment.PBFeChange (Sender : TObject) ;
4595
begin
4596
  if not Update
4597
  then
4598
  begin
4599
    Modified := TRUE ;
4600
    // Nouvelle valeur
4601
    with PAliment.CC do
4602
      if ConfTOligo = 0
4603
      then // mg/kg
4604
        Fe := PBFe.AsFloat / RapMS
4605
      else // %
4606
        Fe := PBFe.AsFloat * 1000000 / 100 / RapMS ;
4607
  end ;
4608
end ;
4609

    
4610
procedure TFAliment.PBSeChange (Sender : TObject) ;
4611
begin
4612
  if not Update
4613
  then
4614
  begin
4615
    Modified := TRUE ;
4616
    // Nouvelle valeur
4617
    with PAliment.CC do
4618
      if ConfTOligo = 0
4619
      then // mg/kg
4620
        Se := PBSe.AsFloat / RapMS
4621
      else // %
4622
        Se := PBSe.AsFloat * 1000000 / 100 / RapMS ;
4623
  end ;
4624
end ;
4625

    
4626
procedure TFAliment.PBCoChange (Sender : TObject) ;
4627
begin
4628
  if not Update
4629
  then
4630
  begin
4631
    Modified := TRUE ;
4632
    // Nouvelle valeur
4633
    with PAliment.CC do
4634
      if ConfTOligo = 0
4635
      then // mg/kg
4636
        Co := PBCo.AsFloat / RapMS
4637
      else // %
4638
        Co := PBCo.AsFloat * 1000000 / 100 / RapMS ;
4639
  end ;
4640
end ;
4641

    
4642
procedure TFAliment.PBMbChange (Sender : TObject) ;
4643
begin
4644
  if not Update
4645
  then
4646
  begin
4647
    Modified := TRUE ;
4648
    // Nouvelle valeur
4649
    with PAliment.CC do
4650
      if ConfTOligo = 0
4651
      then // mg/kg
4652
        Mb := PBMb.AsFloat / RapMS
4653
      else // %
4654
        Mb := PBMb.AsFloat * 1000000 / 100 / RapMS ;
4655
  end ;
4656
end ;
4657

    
4658
procedure TFAliment.PBIChange (Sender : TObject) ;
4659
begin
4660
  if not Update
4661
  then
4662
  begin
4663
    Modified := TRUE ;
4664
    // Nouvelle valeur
4665
    with PAliment.CC do
4666
      if ConfTOligo = 0
4667
      then // mg/kg
4668
        I := PBI.AsFloat / RapMS
4669
      else // %
4670
        I := PBI.AsFloat * 1000000 / 100 / RapMS ;
4671
  end ;
4672
end ;
4673

    
4674
procedure TFAliment.PBPdigGChange (Sender : TObject) ;
4675
begin
4676
  if not Update
4677
  then
4678
  begin
4679
    Modified := TRUE ;
4680
    // Nouvelle valeur
4681
    with PAliment.CC do
4682
      if ConfTMacro = 0
4683
      then // g/kg
4684
        PdigG := PBPdigG.AsFloat / RapMS
4685
      else // %
4686
        PdigG := PBPdigG.AsFloat * 1000 / 100 / RapMS ;
4687
  end ;
4688
end ;
4689

    
4690
procedure TFAliment.PBPdigFChange (Sender : TObject) ;
4691
begin
4692
  if not Update
4693
  then
4694
  begin
4695
    Modified := TRUE ;
4696
    // Nouvelle valeur
4697
    with PAliment.CC do
4698
      if ConfTMacro = 0
4699
      then // g/kg
4700
        PdigF := PBPdigF.AsFloat / RapMS
4701
      else // %
4702
        PdigF := PBPdigF.AsFloat * 1000 / 100 / RapMS ;
4703
  end ;
4704
end ;
4705

    
4706
procedure TFAliment.PBPhytaseChange (Sender : TObject) ;
4707
begin
4708
  if not Update
4709
  then
4710
  begin
4711
    Modified := TRUE ;
4712
    // Nouvelle valeur
4713
    with PAliment.CC do
4714
      Phytase := PBPhytase.AsFloat ;
4715
  end ;
4716
end ;
4717

    
4718
procedure TFAliment.PBActPhytEChange (Sender : TObject) ;
4719
begin
4720
  if not Update
4721
  then
4722
  begin
4723
    Modified := TRUE ;
4724
    // Nouvelle valeur
4725
    with PAliment.CC do
4726
      ActPhytE := PBActPhytE.AsFloat / RapMS ;
4727
  end ;
4728
end ;
4729

    
4730
procedure TFAliment.PBActPhytMChange (Sender : TObject) ;
4731
begin
4732
  if not Update
4733
  then
4734
  begin
4735
    Modified := TRUE ;
4736
    // Nouvelle valeur
4737
    with PAliment.CC do
4738
      ActPhytM := PBActPhytM.AsFloat / RapMS ;
4739
  end ;
4740
end ;
4741

    
4742
////////////////////////////////////////////////////////////////////////////////
4743
// Fibres
4744
////////////////////////////////////////////////////////////////////////////////
4745

    
4746
// Affichage de la teneur en fonction de la configuration
4747
procedure TFAliment.AffichTFibres ;
4748
begin
4749
  if ConfTFibres = 0
4750
  then // g/kg
4751
    with PAliment.CC do
4752
    begin
4753
      PBCB.AsFloat := CB * RapMS ;
4754
      PBNDF.AsFloat := NDF * RapMS ;
4755
      PBADF.AsFloat := ADF * RapMS ;
4756
      PBADL.AsFloat := ADL * RapMS ;
4757
      PBParois.AsFloat := Parois * RapMS ;
4758
    end
4759
  else // %
4760
    with PAliment.CC do
4761
    begin
4762
      PBCB.AsFloat := CB / 1000 * 100 * RapMS ;
4763
      PBNDF.AsFloat := NDF / 1000 * 100 * RapMS ;
4764
      PBADF.AsFloat := ADF / 1000 * 100 * RapMS ;
4765
      PBADL.AsFloat := ADL / 1000 * 100 * RapMS ;
4766
      PBParois.AsFloat := Parois / 1000 * 100 * RapMS ;
4767
    end ;
4768
end ;
4769

    
4770
procedure TFAliment.PBCBChange (Sender : TObject) ;
4771
begin
4772
  if not Update
4773
  then
4774
  begin
4775
    Modified := TRUE ;
4776
    // Nouvelle valeur
4777
    with PAliment.CC do
4778
      if ConfTFibres = 0
4779
      then // g/kg
4780
        CB := PBCB.AsFloat / RapMS
4781
      else // %
4782
        CB := PBCB.AsFloat * 1000 / 100 / RapMS ;
4783
    // Calcul des champs li?s ? cette valeur
4784
    CalculResidu ;
4785
    AffichResidu ;
4786
  end ;
4787
end ;
4788

    
4789
procedure TFAliment.PBNDFChange(Sender: TObject);
4790
begin
4791
  if not Update
4792
  then
4793
  begin
4794
    Modified := TRUE ;
4795
    // Nouvelle valeur
4796
    with PAliment.CC do
4797
      if ConfTFibres = 0
4798
      then // g/kg
4799
        NDF := PBNDF.AsFloat / RapMS
4800
      else // %
4801
        NDF := PBNDF.AsFloat * 1000 / 100 / RapMS ;
4802
  end ;
4803
end;
4804

    
4805
procedure TFAliment.PBADFChange(Sender: TObject);
4806
begin
4807
  if not Update
4808
  then
4809
  begin
4810
    Modified := TRUE ;
4811
    // Nouvelle valeur
4812
    with PAliment.CC do
4813
      if ConfTFibres = 0
4814
      then // g/kg
4815
        ADF := PBADF.AsFloat / RapMS
4816
      else // %
4817
        ADF := PBADF.AsFloat * 1000 / 100 / RapMS ;
4818
  end ;
4819
end;
4820

    
4821
procedure TFAliment.PBADLChange(Sender: TObject);
4822
begin
4823
  if not Update
4824
  then
4825
  begin
4826
    Modified := TRUE ;
4827
    // Nouvelle valeur
4828
    with PAliment.CC do
4829
      if ConfTFibres = 0
4830
      then // g/kg
4831
        ADL := PBADL.AsFloat / RapMS
4832
      else // %
4833
        ADL := PBADL.AsFloat * 1000 / 100 / RapMS ;
4834
  end ;
4835
end;
4836

    
4837
procedure TFAliment.PBParoisChange(Sender: TObject);
4838
begin
4839
  if not Update
4840
  then
4841
  begin
4842
    Modified := TRUE ;
4843
    // Nouvelle valeur
4844
    with PAliment.CC do
4845
      if ConfTFibres = 0
4846
      then // g/kg
4847
        Parois := PBParois.AsFloat / RapMS
4848
      else // %
4849
        Parois := PBParois.AsFloat * 1000 / 100 / RapMS ;
4850
  end ;
4851
end;
4852

    
4853
////////////////////////////////////////////////////////////////////////////////
4854
// Mati?res premi?res
4855
////////////////////////////////////////////////////////////////////////////////
4856

    
4857
procedure TFAliment.CBTypeChange (Sender : TObject) ;
4858
begin
4859
  StringsMatiere (LBGauche.Items, CBType.ItemIndex, FALSE, TRUE) ;
4860
  LBGaucheClick (nil) ;
4861
end ;
4862

    
4863
procedure TFAliment.SBMoinsClick (Sender : TObject) ;
4864
var
4865
  i : integer ;
4866
begin
4867
  if LBDroite.ItemIndex = -1
4868
  then
4869
    Exit ;
4870
  Modified := TRUE ;
4871
  with PAliment.MP do
4872
  begin
4873
    // Total = Total - Quantit?
4874
    PBTotal.AsFloat := PBTotal.AsFloat - Qte[LBDroite.ItemIndex] ;
4875
    Dec (NbMat) ;
4876
    if LBDroite.ItemIndex < NbMat
4877
    then
4878
      // D?calage des ?l?ments suivants vers le bas
4879
      for i := LBDroite.ItemIndex to NbMat - 1 do
4880
      begin
4881
        NumMat[i] := NumMat[i + 1] ;
4882
        Qte[i] := Qte[i + 1] ;
4883
        MS[i] := MS[i + 1] ;
4884
      end ;
4885
    // Effacement du dernier ?l?ment
4886
    NumMat[NbMat] := 0 ;
4887
    Qte[NbMat] := 0 ;
4888
    MS[NbMat] := 0 ;
4889
  end ;
4890
  LBDroite.DeleteSelected ;
4891
  LBDroiteClick (nil) ;
4892
  if PAliment.MP.NbMat = 0
4893
  then
4894
  begin
4895
    SBMoins.Enabled := FALSE ;
4896
    BBGraph.Enabled := FALSE ;
4897
    BBCalcul.Enabled := FALSE ;
4898
  end ;
4899
  SBPlus.Enabled := TRUE ;
4900
  VerifyMP ;
4901
end ;
4902

    
4903
procedure TFAliment.SBPlusClick (Sender : TObject) ;
4904
begin
4905
  if LBGauche.ItemIndex = -1
4906
  then
4907
    Exit ;
4908
  Modified := TRUE ;
4909
  PMatiere := ListMatiere[FindIdxMatiere (LBGauche.Items[LBGauche.ItemIndex])] ;
4910
  with PAliment.MP do
4911
  begin
4912
    NumMat[NbMat] := PMatiere.Num ;
4913
    Qte[NbMat] := 0 ;
4914
    MS[NbMat] := PMatiere.CC.MS ;
4915
    Inc (NbMat) ;
4916
  end ;
4917
  LBDroite.Items.Add (LBGauche.Items[LBGauche.ItemIndex]) ;
4918
  LBDroite.ItemIndex := LBDroite.Count - 1 ;
4919
  LBDroiteClick (nil) ;
4920
  SBMoins.Enabled := TRUE ;
4921
  BBGraph.Enabled := TRUE ;
4922
  BBCalcul.Enabled := TRUE ;
4923
  if PAliment.MP.NbMat > MAX_MP
4924
  then
4925
    SBPlus.Enabled := FALSE ;
4926
  ActiveControl := PBQte ;
4927
end ;
4928

    
4929
procedure TFAliment.SBReplaceClick(Sender: TObject);
4930
begin
4931
  if (LBGauche.ItemIndex = -1) or (LBDroite.ItemIndex = -1)
4932
  then
4933
    Exit ;
4934
  Modified := TRUE ;
4935
  PMatiere := ListMatiere[FindIdxMatiere (LBGauche.Items[LBGauche.ItemIndex])] ;
4936
  with PAliment.MP do
4937
  begin
4938
    NumMat[LBDroite.ItemIndex] := PMatiere.Num ;
4939
    MS[LBDroite.ItemIndex] := PMatiere.CC.MS ;
4940
  end ;
4941
  LBDroite.Items[LBDroite.ItemIndex] := LBGauche.Items[LBGauche.ItemIndex] ;
4942
  LBDroiteClick (nil) ;
4943
  ActiveControl := PBQte ;
4944
  VerifyMP ;
4945
end;
4946

    
4947
procedure TFAliment.LBGaucheClick (Sender : TObject) ;
4948
begin
4949
  if LBGauche.ItemIndex = -1
4950
  then
4951
  begin
4952
    PBMSG.Text := '' ;
4953
    PBMATG.Text := '' ;
4954
    PBdLysG.Text := '' ;
4955
    PBEDG.Text := '' ;
4956
    PBEMG.Text := '' ;
4957
    PBENG.Text := '' ;
4958
  end
4959
  else
4960
  begin
4961
    PMatiere := ListMatiere[FindIdxMatiere (LBGauche.Items[LBGauche.ItemIndex])] ;
4962
    // Informations
4963
    PBMSG.AsFloat := PMatiere.CC.MS ;
4964
    PBMATG.AsFloat := PMatiere.CC.MAT * PMatiere.CC.MS / 1000 ;
4965
    PBdLysG.AsFloat := PMatiere.AAtotal[1] * PMatiere.CUDAA[1] / 100 * PMatiere.CC.MS / 1000 ;
4966
    case PAliment.Typ of
4967
      1 : // Porc croissance
4968
      begin
4969
        PBEDG.AsFloat := PMatiere.CC.ED_C * PMatiere.CC.MS / 1000 ;
4970
        PBEMG.AsFloat := PMatiere.CC.EM_C * PMatiere.CC.MS / 1000 ;
4971
        PBENG.AsFloat := PMatiere.CC.EN_C * PMatiere.CC.MS / 1000 ;
4972
      end ;
4973
      2 : // Truie reproductrice
4974
      begin
4975
        PBEDG.AsFloat := PMatiere.CC.ED_T * PMatiere.CC.MS / 1000 ;
4976
        PBEMG.AsFloat := PMatiere.CC.EM_T * PMatiere.CC.MS / 1000 ;
4977
        PBENG.AsFloat := PMatiere.CC.EN_T * PMatiere.CC.MS / 1000 ;
4978
      end ;
4979
      else
4980
      begin
4981
        PBEDG.Text := '' ;
4982
        PBEMG.Text := '' ;
4983
        PBENG.Text := '' ;
4984
      end ;
4985
    end ;
4986
//    if (LBDroite.ItemIndex <> -1) and (LBDroite.Items[LBDroite.ItemIndex] <> LBGauche.Items[LBGauche.ItemIndex])
4987
//    then
4988
//    begin
4989
//      LBDroite.ItemIndex := -1 ;
4990
//      LBDroiteClick (nil) ;
4991
//    end ;
4992
  end ;
4993
end ;
4994

    
4995
procedure TFAliment.LBGaucheDblClick (Sender : TObject) ;
4996
begin
4997
  SBPlusClick (nil) ;
4998
end ;
4999

    
5000
procedure TFAliment.LBDroiteClick (Sender : TObject) ;
5001
begin
5002
  if LBDroite.ItemIndex = -1
5003
  then
5004
  begin
5005
    PBQte.Enabled := FALSE ;
5006
    PBMSD.Enabled := FALSE ;
5007
    Update := TRUE ;
5008
    PBQte.Text := '' ;
5009
    PBMSD.Text := '' ;
5010
    Update := FALSE ;
5011
  end
5012
  else
5013
  begin
5014
    PBMSD.Enabled := TRUE ;
5015
    PBQte.Enabled := TRUE ;
5016
    Update := TRUE ;
5017
    PBQte.AsFloat := PAliment.MP.Qte[LBDroite.ItemIndex] ;
5018
    PBMSD.AsFloat := PAliment.MP.MS[LBDroite.ItemIndex] ;
5019
    Update := FALSE ;
5020
    LBGauche.ItemIndex := LBGauche.Items.IndexOf (LBDroite.Items[LBDroite.ItemIndex]) ;
5021
    LBGaucheClick (nil) ;
5022
    ActiveControl := PBQte ;
5023
    PBQte.SelectAll ;
5024
  end ;
5025
end ;
5026

    
5027
procedure TFAliment.LBDroiteDblClick (Sender : TObject) ;
5028
begin
5029
  SBMoinsClick (nil) ;
5030
end ;
5031

    
5032
procedure TFAliment.LBDroiteDrawItem (Control : TWinControl ; Index : Integer ;
5033
  Rect : TRect ; State : TOwnerDrawState) ;
5034
begin
5035
  with (Control as TListBox).Canvas do
5036
  begin
5037
    // Cadre principal
5038
    FillRect (Rect) ;
5039
    // Nom
5040
    SetTextAlign (Handle, TA_LEFT) ;
5041
    TextRect (Rect, Rect.Left + 2, Rect.Top, LBDroite.Items[Index]) ;
5042
    // Quantit?
5043
    Rect.Left := 216 ;
5044
    if (LBDroite.Items.Count > 20)
5045
    then
5046
      Rect.Right := Rect.Right - 1
5047
    else
5048
      // L'ascensseur fait 17 pixels
5049
      Rect.Right := Rect.Right - 18 ;
5050
    SetTextAlign (Handle, TA_RIGHT) ;
5051
    TextRect (Rect, Rect.Right - 2, Rect.Top, Format ('%7.3f', [PAliment.MP.Qte[Index]])) ;
5052
  end ;
5053
end ;
5054

    
5055
procedure TFAliment.SBHautClick (Sender : TObject) ;
5056
var
5057
  BakNumMat, OldPos : integer ;
5058
  BakQte, BakMS : double ;
5059
begin
5060
  if LBDroite.ItemIndex = -1
5061
  then
5062
    Exit ;
5063
  if LBDroite.ItemIndex > 0
5064
  then
5065
  begin
5066
    OldPos := LBDroite.ItemIndex;
5067
    Modified := TRUE ;
5068
    with PAliment.MP do
5069
    begin
5070
      BakNumMat := NumMat[LBDroite.ItemIndex] ;
5071
      BakQte := Qte[LBDroite.ItemIndex] ;
5072
      BakMS := MS[LBDroite.ItemIndex] ;
5073
      NumMat[LBDroite.ItemIndex] := NumMat[LBDroite.ItemIndex - 1] ;
5074
      Qte[LBDroite.ItemIndex] := Qte[LBDroite.ItemIndex - 1] ;
5075
      MS[LBDroite.ItemIndex] := MS[LBDroite.ItemIndex - 1] ;
5076
      NumMat[LBDroite.ItemIndex - 1] := BakNumMat ;
5077
      Qte[LBDroite.ItemIndex - 1] := BakQte ;
5078
      MS[LBDroite.ItemIndex - 1] := BakMS ;
5079
    end ;
5080
    LBDroite.Items.Move (LBDroite.ItemIndex, LBDroite.ItemIndex - 1) ;
5081
//    LBDroite.ItemIndex := LBDroite.ItemIndex - 1 ;
5082
    LBDroite.ItemIndex := OldPos - 1;
5083
    LBDroiteClick (nil) ;
5084
  end
5085
  else
5086
    MessageBeep (0) ;
5087
end ;
5088

    
5089
procedure TFAliment.SBBasClick (Sender : TObject) ;
5090
var
5091
  BakNumMat, OldPos : integer ;
5092
  BakQte, BakMS : double ;
5093
begin
5094
  if LBDroite.ItemIndex = -1
5095
  then
5096
    Exit ;
5097
  if LBDroite.ItemIndex < PAliment.MP.NbMat - 1
5098
  then
5099
  begin
5100
    OldPos := LBDroite.ItemIndex;
5101
    Modified := TRUE ;
5102
    with PAliment.MP do
5103
    begin
5104
      BakNumMat := NumMat[LBDroite.ItemIndex] ;
5105
      BakQte := Qte[LBDroite.ItemIndex] ;
5106
      BakMS := MS[LBDroite.ItemIndex] ;
5107
      NumMat[LBDroite.ItemIndex] := NumMat[LBDroite.ItemIndex + 1] ;
5108
      Qte[LBDroite.ItemIndex] := Qte[LBDroite.ItemIndex + 1] ;
5109
      MS[LBDroite.ItemIndex] := MS[LBDroite.ItemIndex + 1] ;
5110
      NumMat[LBDroite.ItemIndex + 1] := BakNumMat ;
5111
      Qte[LBDroite.ItemIndex + 1] := BakQte ;
5112
      MS[LBDroite.ItemIndex + 1] := BakMS ;
5113
    end ;
5114
    LBDroite.Items.Move (LBDroite.ItemIndex, LBDroite.ItemIndex + 1) ;
5115
//    LBDroite.ItemIndex := LBDroite.ItemIndex + 1 ;
5116
    LBDroite.ItemIndex := OldPos + 1;
5117
    LBDroiteClick (nil) ;
5118
  end
5119
  else
5120
    MessageBeep (0) ;
5121
end ;
5122

    
5123
procedure TFAliment.SBSortQteClick(Sender: TObject);
5124
var
5125
  i, OldPos, NewPos : integer ;
5126
begin
5127
  if PAliment.MP.NbMat = 0
5128
  then
5129
    Exit ;
5130
  with JvSGSort do
5131
  begin
5132
    OldPos := LBDroite.ItemIndex;
5133
    Clear ;
5134
    RowCount := PAliment.MP.NbMat ;
5135
    Height := RowCount * DefaultRowHeight + RowCount + 1 ;
5136
    for i := 0 to RowCount - 1 do
5137
    begin
5138
      Cells[0, i] := IntToStr (i) ;
5139
      Cells[1, i] := IntToStr (PAliment.MP.NumMat[i]) ;
5140
      Cells[2, i] := LBDroite.Items[i] ;
5141
      Cells[3, i] := FloatToStr (PAliment.MP.Qte[i]) ;
5142
      Cells[4, i] := FloatToStr (PAliment.MP.MS[i]) ;
5143
    end ;
5144
    SortGrid(3, FALSE, FALSE, stNumeric, TRUE) ;
5145
    Modified := TRUE ;
5146
    LBDroite.Items.Clear ;
5147
    NewPos := -1;
5148
    for i := 0 to RowCount - 1 do
5149
    begin
5150
      PAliment.MP.NumMat[i] := StrToInt (Cells[1, i]) ;
5151
      PAliment.MP.Qte[i] := StrToFloat (Cells[3, i]) ;
5152
      PAliment.MP.MS[i] := StrToFloat (Cells[4, i]) ;
5153
      LBDroite.Items.Add (Cells[2, i]) ;
5154
      if StrToInt(Cells[0, i]) = OldPos then NewPos := i;
5155
    end ;
5156
    LBDroite.ItemIndex := NewPos;
5157
    LBDroiteClick (nil) ;
5158
  end ;
5159
end;
5160

    
5161
procedure TFAliment.SBSortNomClick(Sender: TObject);
5162
var
5163
  i, OldPos, NewPos : integer ;
5164
begin
5165
  if PAliment.MP.NbMat = 0
5166
  then
5167
    Exit ;
5168
  with JvSGSort do
5169
  begin
5170
    OldPos := LBDroite.ItemIndex;
5171
    Clear ;
5172
    RowCount := PAliment.MP.NbMat ;
5173
    Height := RowCount * DefaultRowHeight + RowCount + 1 ;
5174
    for i := 0 to RowCount - 1 do
5175
    begin
5176
      Cells[0, i] := IntToStr (i) ;
5177
      Cells[1, i] := IntToStr (PAliment.MP.NumMat[i]) ;
5178
      Cells[2, i] := LBDroite.Items[i] ;
5179
      Cells[3, i] := FloatToStr (PAliment.MP.Qte[i]) ;
5180
      Cells[4, i] := FloatToStr (PAliment.MP.MS[i]) ;
5181
    end ;
5182
    SortGrid(2, TRUE, FALSE, stClassic, TRUE) ;
5183
    Modified := TRUE ;
5184
    LBDroite.Items.Clear ;
5185
    NewPos := -1;
5186
    for i := 0 to RowCount - 1 do
5187
    begin
5188
      PAliment.MP.NumMat[i] := StrToInt (Cells[1, i]) ;
5189
      PAliment.MP.Qte[i] := StrToFloat (Cells[3, i]) ;
5190
      PAliment.MP.MS[i] := StrToFloat (Cells[4, i]) ;
5191
      LBDroite.Items.Add (Cells[2, i]) ;
5192
      if StrToInt(Cells[0, i]) = OldPos then NewPos := i;
5193
    end ;
5194
    LBDroite.ItemIndex := NewPos;
5195
    LBDroiteClick (nil) ;
5196
  end ;
5197
end;
5198

    
5199
procedure TFAliment.PBQteKeyPress (Sender : TObject ; var Key : Char) ;
5200
begin
5201
  if Key = #13
5202
  then
5203
    if LBDroite.ItemIndex < PAliment.MP.NbMat - 1
5204
    then
5205
    begin
5206
      LBDroite.ItemIndex := LBDroite.ItemIndex + 1 ;
5207
      LBDroiteClick (nil) ;
5208
      Key := #0 ;
5209
    end ;
5210
end ;
5211

    
5212
procedure TFAliment.PBTotalChange (Sender : TObject) ;
5213
begin
5214
  if PBTotal.AsFloat = 1000
5215
  then // Vert
5216
    PBTotal.Font.Color := clLime
5217
  else
5218
    if (PBTotal.AsFloat < 999) or (PBTotal.AsFloat > 1001)
5219
    then // Rouge
5220
      PBTotal.Font.Color := clRed
5221
    else // Orange
5222
      PBTotal.Font.Color := TColor($0080FF) ;
5223
end ;
5224

    
5225
procedure TFAliment.PBMSDChange (Sender : TObject) ;
5226
begin
5227
  if not Update
5228
  then
5229
  begin
5230
    Modified := TRUE ;
5231
    // Nouvelle valeur
5232
    with PAliment.MP do
5233
      MS[LBDroite.ItemIndex] := PBMSD.AsFloat ;
5234
  end ;
5235
end ;
5236

    
5237
procedure TFAliment.PBQteChange (Sender : TObject) ;
5238
begin
5239
  if not Update
5240
  then
5241
  begin
5242
    Modified := TRUE ;
5243
    // Total = Total - AcienneQuantit? + NouvelleQuantit?
5244
    with PAliment.MP do
5245
      PBTotal.AsFloat := PBTotal.AsFloat - Qte[LBDroite.ItemIndex] + PBQte.AsFloat ;
5246
    // Nouvelle valeur
5247
    with PAliment.MP do
5248
      Qte[LBDroite.ItemIndex] := PBQte.AsFloat ;
5249
    LBDroite.Repaint ;
5250
  end ;
5251
end ;
5252

    
5253
procedure TFAliment.VerifyMP ;
5254
var
5255
  i : integer ;
5256
  ok : boolean ;
5257
begin
5258
  ok := TRUE ;
5259
  if PAliment.MP.NbMat > 0
5260
  then
5261
    for i := 0 to PAliment.MP.NbMat - 1 do
5262
      if PAliment.MP.NumMat[i] = 0 then ok := FALSE ;
5263
  BBCalcul.Enabled := ok ;
5264
  BBGraph.Enabled := ok ;
5265
end ;
5266

    
5267
procedure TFAliment.BBCalculClick (Sender : TObject) ;
5268
var
5269
  i, j : integer ;
5270
begin
5271
  if AffCalcAli
5272
  then
5273
  begin
5274
    FWarning := TFWarning.Create (Self) ;
5275
    with FWarning do
5276
    begin
5277
      Msg := 'CalcAli';
5278
      ShowModal ;
5279
      Release ;
5280
      AffCalcAli := FALSE ;
5281
    end ;
5282
  end ;
5283
  if MessageDlg (MsgCalcul, mtConfirmation, [mbYes, mbNo], 0) = mrYes
5284
  then
5285
  begin
5286
    Modified := TRUE ;
5287
    with PAliment^ do
5288
    begin
5289
      // Initialisation
5290
      CC := CCVide ;
5291
      for j := 0 to 12 do
5292
        AAtotal[j] := 0 ;
5293
      for j := 0 to 12 do
5294
        CUDAA[j] := 0 ;
5295
      with MP do
5296
        if PBTotal.AsFloat > 0
5297
        then
5298
        begin
5299
          CC.MS := 0 ; // CCVide initialise MS ? 1000
5300
          // Total
5301
          for i := 0 to NbMat - 1 do
5302
          begin
5303
            PMatiere := ListMatiere[FindIdxMatiere (LBDroite.Items[i])] ;
5304
            CC.MS := CC.MS + (Qte[i] * MS[i]) ;
5305
            CC.MM := CC.MM + (Qte[i] * MS[i] * PMatiere.CC.MM) ;
5306
            CC.MO := CC.MO + (Qte[i] * MS[i] * PMatiere.CC.MO) ;
5307
            CC.Lip := CC.Lip + (Qte[i] * MS[i] * PMatiere.CC.Lip) ;
5308
            CC.MAT := CC.MAT + (Qte[i] * MS[i] * PMatiere.CC.MAT) ;
5309
            CC.Amidon := CC.Amidon + (Qte[i] * MS[i] * PMatiere.CC.Amidon) ;
5310
            CC.Sucres := CC.Sucres + (Qte[i] * MS[i] * PMatiere.CC.Sucres) ;
5311
            CC.dMO_T := CC.dMO_T + (Qte[i] * MS[i] * PMatiere.CC.MO * PMatiere.CC.dMO_T) ;
5312
            CC.dMO_C := CC.dMO_C + (Qte[i] * MS[i] * PMatiere.CC.MO * PMatiere.CC.dMO_C) ;
5313
            CC.dLip_T := CC.dLip_T + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.dLip_T) ;
5314
            CC.dLip_C := CC.dLip_C + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.dLip_C) ;
5315
            CC.dMAT_T := CC.dMAT_T + (Qte[i] * MS[i] * PMatiere.CC.MAT * PMatiere.CC.dMAT_T) ;
5316
            CC.dMAT_C := CC.dMAT_C + (Qte[i] * MS[i] * PMatiere.CC.MAT * PMatiere.CC.dMAT_C) ;
5317
            CC.Ca := CC.Ca + (Qte[i] * MS[i] * PMatiere.CC.Ca) ;
5318
            CC.P := CC.P + (Qte[i] * MS[i] * PMatiere.CC.P) ;
5319
            CC.Na := CC.Na + (Qte[i] * MS[i] * PMatiere.CC.Na) ;
5320
            CC.K := CC.K + (Qte[i] * MS[i] * PMatiere.CC.K) ;
5321
            CC.Cl := CC.Cl + (Qte[i] * MS[i] * PMatiere.CC.Cl) ;
5322
            CC.Mg := CC.Mg + (Qte[i] * MS[i] * PMatiere.CC.Mg) ;
5323
            CC.Cu := CC.Cu + (Qte[i] * MS[i] * PMatiere.CC.Cu) ;
5324
            CC.Zn := CC.Zn + (Qte[i] * MS[i] * PMatiere.CC.Zn) ;
5325
            CC.Fe := CC.Fe + (Qte[i] * MS[i] * PMatiere.CC.Fe) ;
5326
            CC.Mn := CC.Mn + (Qte[i] * MS[i] * PMatiere.CC.Mn) ;
5327
            CC.S := CC.S + (Qte[i] * MS[i] * PMatiere.CC.S) ;
5328
            CC.Se := CC.Se + (Qte[i] * MS[i] * PMatiere.CC.Se) ;
5329
            CC.Co := CC.Co + (Qte[i] * MS[i] * PMatiere.CC.Co) ;
5330
            CC.Mb := CC.Mb + (Qte[i] * MS[i] * PMatiere.CC.Mb) ;
5331
            CC.I := CC.I + (Qte[i] * MS[i] * PMatiere.CC.I) ;
5332
            CC.Phytase := CC.Phytase + (Qte[i] * MS[i] * PMatiere.CC.P * PMatiere.CC.Phytase) ;
5333
            CC.ActPhytE := CC.ActPhytE + (Qte[i] * MS[i] * PMatiere.CC.ActPhytE) ;
5334
            CC.ActPhytM := CC.ActPhytM + (Qte[i] * MS[i] * PMatiere.CC.ActPhytM) ;
5335
            CC.PdigG := CC.PdigG + (Qte[i] * MS[i] * PMatiere.CC.PdigG) ;
5336
            CC.PdigF := CC.PdigF + (Qte[i] * MS[i] * PMatiere.CC.PdigF) ;
5337
            CC.AGsLip := CC.AGsLip + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip) ;
5338
            CC.C6C8C10 := CC.C6C8C10 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C6C8C10) ;
5339
            CC.C12_0 := CC.C12_0 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C12_0) ;
5340
            CC.C14_0 := CC.C14_0 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C14_0) ;
5341
            CC.C16_0 := CC.C16_0 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C16_0) ;
5342
            CC.C16_1 := CC.C16_1 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C16_1) ;
5343
            CC.C18_0 := CC.C18_0 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C18_0) ;
5344
            CC.C18_1 := CC.C18_1 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C18_1) ;
5345
            CC.C18_2 := CC.C18_2 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C18_2) ;
5346
            CC.C18_3 := CC.C18_3 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C18_3) ;
5347
            CC.C18_4 := CC.C18_4 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C18_4) ;
5348
            CC.C20_0 := CC.C20_0 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C20_0) ;
5349
            CC.C20_1 := CC.C20_1 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C20_1) ;
5350
            CC.C20_4 := CC.C20_4 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C20_4) ;
5351
            CC.C20_5 := CC.C20_5 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C20_5) ;
5352
            CC.C22_0 := CC.C22_0 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C22_0) ;
5353
            CC.C22_1 := CC.C22_1 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C22_1) ;
5354
            CC.C22_5 := CC.C22_5 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C22_5) ;
5355
            CC.C22_6 := CC.C22_6 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C22_6) ;
5356
            CC.C24_0 := CC.C24_0 + (Qte[i] * MS[i] * PMatiere.CC.Lip * PMatiere.CC.AGsLip * PMatiere.CC.C24_0) ;
5357
            CC.CB := CC.CB + (Qte[i] * MS[i] * PMatiere.CC.CB) ;
5358
            CC.dCB_T := CC.dCB_T + (Qte[i] * MS[i] * PMatiere.CC.CB * PMatiere.CC.dCB_T) ;
5359
            CC.dCB_C := CC.dCB_C + (Qte[i] * MS[i] * PMatiere.CC.CB * PMatiere.CC.dCB_C) ;
5360
            CC.Residu := CC.Residu + (Qte[i] * MS[i] * PMatiere.CC.Residu) ;
5361
            CC.dResidu_T := CC.dResidu_T + (Qte[i] * MS[i] * PMatiere.CC.Residu * PMatiere.CC.dResidu_T) ;
5362
            CC.dResidu_C := CC.dResidu_C + (Qte[i] * MS[i] * PMatiere.CC.Residu * PMatiere.CC.dResidu_C) ;
5363
            CC.NDF := CC.NDF + (Qte[i] * MS[i] * PMatiere.CC.NDF) ;
5364
            CC.ADF := CC.ADF + (Qte[i] * MS[i] * PMatiere.CC.ADF) ;
5365
            CC.ADL := CC.ADL + (Qte[i] * MS[i] * PMatiere.CC.ADL) ;
5366
            CC.Parois := CC.Parois + (Qte[i] * MS[i] * PMatiere.CC.Parois) ;
5367
            for j := 0 to 12 do
5368
              AAtotal[j] := AAtotal[j] + (Qte[i] * MS[i] * PMatiere.AAtotal[j]) ;
5369
            for j := 0 to 12 do
5370
              CUDAA[j] := CUDAA[j] + (Qte[i] * MS[i] * PMatiere.AAtotal[j] * PMatiere.CUDAA[j]) ;
5371
          end ;
5372
          // Moyenne
5373
          CC.MS := CC.MS / PBTotal.AsFloat ;
5374
          CC.MM := CC.MM / (PBTotal.AsFloat * CC.MS) ;
5375
          CC.MO := CC.MO / (PBTotal.AsFloat * CC.MS) ;
5376
          CC.Lip := CC.Lip / (PBTotal.AsFloat * CC.MS) ;
5377
          CC.MAT := CC.MAT / (PBTotal.AsFloat * CC.MS) ;
5378
          CC.Amidon := CC.Amidon / (PBTotal.AsFloat * CC.MS) ;
5379
          CC.Sucres := CC.Sucres / (PBTotal.AsFloat * CC.MS) ;
5380
          CC.dMO_T := CC.dMO_T / (PBTotal.AsFloat * CC.MO * CC.MS) ;
5381
          CC.dMO_C := CC.dMO_C / (PBTotal.AsFloat * CC.MO * CC.MS) ;
5382
          CC.dLip_T := CC.dLip_T / (PBTotal.AsFloat * CC.Lip * CC.MS) ;
5383
          CC.dLip_C := CC.dLip_C / (PBTotal.AsFloat * CC.Lip * CC.MS) ;
5384
          CC.dMAT_T := CC.dMAT_T / (PBTotal.AsFloat * CC.MAT * CC.MS) ;
5385
          CC.dMAT_C := CC.dMAT_C / (PBTotal.AsFloat * CC.MAT * CC.MS) ;
5386
          CC.Ca := CC.Ca / (PBTotal.AsFloat * CC.MS) ;
5387
          CC.P := CC.P / (PBTotal.AsFloat * CC.MS) ;
5388
          CC.Na := CC.Na / (PBTotal.AsFloat * CC.MS) ;
5389
          CC.K := CC.K / (PBTotal.AsFloat * CC.MS) ;
5390
          CC.Cl := CC.Cl / (PBTotal.AsFloat * CC.MS) ;
5391
          CC.Mg := CC.Mg / (PBTotal.AsFloat * CC.MS) ;
5392
          CC.Cu := CC.Cu / (PBTotal.AsFloat * CC.MS) ;
5393
          CC.Zn := CC.Zn / (PBTotal.AsFloat * CC.MS) ;
5394
          CC.Fe := CC.Fe / (PBTotal.AsFloat * CC.MS) ;
5395
          CC.Mn := CC.Mn / (PBTotal.AsFloat * CC.MS) ;
5396
          CC.S := CC.S / (PBTotal.AsFloat * CC.MS) ;
5397
          CC.Se := CC.Se / (PBTotal.AsFloat * CC.MS) ;
5398
          CC.Co := CC.Co / (PBTotal.AsFloat * CC.MS) ;
5399
          CC.Mb := CC.Mb / (PBTotal.AsFloat * CC.MS) ;
5400
          CC.I := CC.I / (PBTotal.AsFloat * CC.MS) ;
5401
          if CC.P = 0
5402
          then
5403
            CC.Phytase := 0
5404
          else
5405
            CC.Phytase := CC.Phytase / (PBTotal.AsFloat * CC.MS * CC.P) ;
5406
          CC.ActPhytE := CC.ActPhytE / (PBTotal.AsFloat * CC.MS) ;
5407
          CC.ActPhytM := CC.ActPhytM / (PBTotal.AsFloat * CC.MS) ;
5408
          CC.PdigG := CC.PdigG / (PBTotal.AsFloat * CC.MS) ;
5409
          CC.PdigF := CC.PdigF / (PBTotal.AsFloat * CC.MS) ;
5410
          if CC.Lip = 0
5411
          then
5412
            CC.AGsLip := 0
5413
          else
5414
            CC.AGsLip := CC.AGsLip / (PBTotal.AsFloat * CC.MS * CC.Lip) ;
5415
          if CC.AGsLip = 0
5416
          then
5417
          begin
5418
            CC.C6C8C10 := 0 ;
5419
            CC.C12_0 := 0 ;
5420
            CC.C14_0 := 0 ;
5421
            CC.C16_0 := 0 ;
5422
            CC.C16_1 := 0 ;
5423
            CC.C18_0 := 0 ;
5424
            CC.C18_1 := 0 ;
5425
            CC.C18_2 := 0 ;
5426
            CC.C18_3 := 0 ;
5427
            CC.C18_4 := 0 ;
5428
            CC.C20_0 := 0 ;
5429
            CC.C20_1 := 0 ;
5430
            CC.C20_4 := 0 ;
5431
            CC.C20_5 := 0 ;
5432
            CC.C22_0 := 0 ;
5433
            CC.C22_1 := 0 ;
5434
            CC.C22_5 := 0 ;
5435
            CC.C22_6 := 0 ;
5436
            CC.C24_0 := 0 ;
5437
          end
5438
          else
5439
          begin
5440
            CC.C6C8C10 := CC.C6C8C10 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5441
            CC.C12_0 := CC.C12_0 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5442
            CC.C14_0 := CC.C14_0 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5443
            CC.C16_0 := CC.C16_0 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5444
            CC.C16_1 := CC.C16_1 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5445
            CC.C18_0 := CC.C18_0 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5446
            CC.C18_1 := CC.C18_1 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5447
            CC.C18_2 := CC.C18_2 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5448
            CC.C18_3 := CC.C18_3 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5449
            CC.C18_4 := CC.C18_4 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5450
            CC.C20_0 := CC.C20_0 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5451
            CC.C20_1 := CC.C20_1 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5452
            CC.C20_4 := CC.C20_4 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5453
            CC.C20_5 := CC.C20_5 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5454
            CC.C22_0 := CC.C22_0 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5455
            CC.C22_1 := CC.C22_1 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5456
            CC.C22_5 := CC.C22_5 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5457
            CC.C22_6 := CC.C22_6 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5458
            CC.C24_0 := CC.C24_0 / (PBTotal.AsFloat * CC.MS * CC.Lip * CC.AGsLip) ;
5459
          end ;
5460
          CC.CB := CC.CB / (PBTotal.AsFloat * CC.MS) ;
5461
          if CC.CB = 0
5462
          then
5463
          begin
5464
            CC.dCB_T := 0 ;
5465
            CC.dCB_C := 0 ;
5466
          end
5467
          else
5468
          begin
5469
            CC.dCB_T := CC.dCB_T / (PBTotal.AsFloat * CC.CB * CC.MS) ;
5470
            CC.dCB_C := CC.dCB_C / (PBTotal.AsFloat * CC.CB * CC.MS) ;
5471
          end ;
5472
          CC.Residu := CC.Residu / (PBTotal.AsFloat * CC.MS) ;
5473
          if CC.Residu = 0
5474
          then
5475
          begin
5476
            CC.dResidu_T := 0 ;
5477
            CC.dResidu_C := 0 ;
5478
          end
5479
          else
5480
          begin
5481
            CC.dResidu_T := CC.dResidu_T / (PBTotal.AsFloat * CC.Residu * CC.MS) ;
5482
            CC.dResidu_C := CC.dResidu_C / (PBTotal.AsFloat * CC.Residu * CC.MS) ;
5483
          end ;
5484
          CC.NDF := CC.NDF / (PBTotal.AsFloat * CC.MS) ;
5485
          CC.ADF := CC.ADF / (PBTotal.AsFloat * CC.MS) ;
5486
          CC.ADL := CC.ADL / (PBTotal.AsFloat * CC.MS) ;
5487
          CC.Parois := CC.Parois / (PBTotal.AsFloat * CC.MS) ;
5488
          for j := 0 to 12 do
5489
            AAtotal[j] := AAtotal[j] / (PBTotal.AsFloat * CC.MS) ;
5490
          for j := 0 to 12 do
5491
            if AAtotal[j] = 0
5492
            then
5493
              CUDAA[j] := 0
5494
            else
5495
              CUDAA[j] := CUDAA[j] / (PBTotal.AsFloat * AAtotal[j] * CC.MS) ;
5496
        end ;
5497
    end ;
5498
    // Affichage
5499
    CBAlimentChange (nil) ;
5500
  end ;
5501
end ;
5502

    
5503
procedure TFAliment.BBGraphClick (Sender : TObject) ;
5504
begin
5505
  if AffGraphAli
5506
  then
5507
  begin
5508
    FWarning := TFWarning.Create(Self);
5509
    with FWarning do
5510
    begin
5511
      Msg := 'GraphAli';
5512
      ShowModal;
5513
      Release;
5514
      AffGraphAli := FALSE;
5515
    end;
5516
  end;
5517
  FGraphAli := TFGraphAli.Create(nil);
5518
  FGraphAli.ShowModal;
5519
  FGraphAli.Release;
5520
end;
5521

    
5522
procedure TFAliment.PCChange(Sender: TObject);
5523
begin
5524
  if PC.ActivePageIndex = 5
5525
  then // Mati?res premi?res
5526
    JvEnterAsTab.EnterAsTab := FALSE
5527
  else
5528
    JvEnterAsTab.EnterAsTab := TRUE ;
5529
end;
5530

    
5531
end.