root / UFBesLactT.pas @ 3
Historique | Voir | Annoter | Télécharger (29,38 ko)
1 | 3 | avalancogn | unit UFBesLactT ;
|
---|---|---|---|
2 | |||
3 | interface
|
||
4 | |||
5 | uses
|
||
6 | Windows, Forms, Classes, Controls, StdCtrls, Buttons, PBNumEdit, PBSuperSpin; |
||
7 | |||
8 | type
|
||
9 | TFBesLactT = class(TForm)
|
||
10 | GBProfil: TGroupBox; |
||
11 | LPortee: TLabel; |
||
12 | CBProfil: TComboBox; |
||
13 | PBPortee: TPBSuperSpin; |
||
14 | GBSevrage: TGroupBox; |
||
15 | LSevres: TLabel; |
||
16 | LPdsNais: TLabel; |
||
17 | PBSevres: TPBNumEdit; |
||
18 | PBPdsNais: TPBNumEdit; |
||
19 | ChkSevres: TCheckBox; |
||
20 | ChkPdsNais: TCheckBox; |
||
21 | GBMiseBas: TGroupBox; |
||
22 | GBAliment: TGroupBox; |
||
23 | LRation: TLabel; |
||
24 | LSeqAli: TLabel; |
||
25 | LAppAli: TLabel; |
||
26 | LEMAli: TLabel; |
||
27 | CBRation: TComboBox; |
||
28 | CBSeqAli: TComboBox; |
||
29 | PBAppAli: TPBNumEdit; |
||
30 | PBEMAli: TPBNumEdit; |
||
31 | ChkSeqAli: TCheckBox; |
||
32 | ChkRation: TCheckBox; |
||
33 | ChkAppAli: TCheckBox; |
||
34 | ChkEMAli: TCheckBox; |
||
35 | GBResult: TGroupBox; |
||
36 | LAliment: TLabel; |
||
37 | LBesoins: TLabel; |
||
38 | LdLys: TLabel; |
||
39 | LEN: TLabel; |
||
40 | LEM: TLabel; |
||
41 | PBBesdLys: TPBNumEdit; |
||
42 | PBBesEN: TPBNumEdit; |
||
43 | PBBesEM: TPBNumEdit; |
||
44 | PBBesAli: TPBNumEdit; |
||
45 | BBRapLact: TBitBtn; |
||
46 | BBResLact: TBitBtn; |
||
47 | LP2MB: TLabel; |
||
48 | LPdsApMB: TLabel; |
||
49 | PBPdsApMB: TPBNumEdit; |
||
50 | PBP2MB: TPBNumEdit; |
||
51 | ChkPdsApMB: TCheckBox; |
||
52 | ChkP2MB: TCheckBox; |
||
53 | LDureeLact: TLabel; |
||
54 | PBDureeLact: TPBSuperSpin; |
||
55 | LPdsSev: TLabel; |
||
56 | PBPdsSev: TPBNumEdit; |
||
57 | ChkPdsSev: TCheckBox; |
||
58 | LGMQ: TLabel; |
||
59 | PBGMQ: TPBNumEdit; |
||
60 | Label2: TLabel; |
||
61 | PBDefEN: TPBNumEdit; |
||
62 | PBDefEM: TPBNumEdit; |
||
63 | PBDefAli: TPBNumEdit; |
||
64 | CBRationProfil: TComboBox; |
||
65 | ChkDureeLact: TCheckBox; |
||
66 | procedure FormClose(Sender: TObject; var Action: TCloseAction); |
||
67 | procedure FormActivate(Sender: TObject);
|
||
68 | procedure CBProfilChange(Sender: TObject);
|
||
69 | procedure PBPorteeChange(Sender: TObject);
|
||
70 | procedure PBPdsApMBChange(Sender: TObject);
|
||
71 | procedure ChkPdsApMBClick(Sender: TObject);
|
||
72 | procedure PBP2MBChange(Sender: TObject);
|
||
73 | procedure ChkP2MBClick(Sender: TObject);
|
||
74 | procedure PBDureeLactChange(Sender: TObject);
|
||
75 | procedure PBSevresChange(Sender: TObject);
|
||
76 | procedure ChkSevresClick(Sender: TObject);
|
||
77 | procedure PBPdsNaisChange(Sender: TObject);
|
||
78 | procedure ChkPdsNaisClick(Sender: TObject);
|
||
79 | procedure PBPdsSevChange(Sender: TObject);
|
||
80 | procedure ChkPdsSevClick(Sender: TObject);
|
||
81 | procedure CBSeqAliChange(Sender: TObject);
|
||
82 | procedure ChkSeqAliClick(Sender: TObject);
|
||
83 | procedure CBRationChange(Sender: TObject);
|
||
84 | procedure ChkRationClick(Sender: TObject);
|
||
85 | procedure PBAppAliChange(Sender: TObject);
|
||
86 | procedure ChkAppAliClick(Sender: TObject);
|
||
87 | procedure PBEMAliChange(Sender: TObject);
|
||
88 | procedure ChkEMAliClick(Sender: TObject);
|
||
89 | procedure BBResLactClick(Sender: TObject);
|
||
90 | procedure BBRapLactClick(Sender: TObject);
|
||
91 | procedure FormShow(Sender: TObject);
|
||
92 | procedure FormCreate(Sender: TObject);
|
||
93 | procedure ChkDureeLactClick(Sender: TObject);
|
||
94 | private
|
||
95 | { D?clarations priv?es }
|
||
96 | Update, Modal: boolean; |
||
97 | cycle: integer; |
||
98 | PdsSev, GMQPort: double; |
||
99 | procedure CalcApport;
|
||
100 | procedure CalcGMQ;
|
||
101 | procedure CalcResult;
|
||
102 | procedure AjustEnabled;
|
||
103 | public
|
||
104 | { D?clarations publiques }
|
||
105 | DureeLact: integer; |
||
106 | AppAliTot, AppEDTot, AppEMTot, AppENTot: double; |
||
107 | BesEMTot, BesEMEntTot, BesEMLaitTot: double; |
||
108 | AppAli, AppED, AppEM, AppEN: array [1..28] of double; |
||
109 | BesEMEnt, BesEMLait, BesP, BesCa: array [1..28] of double; |
||
110 | AppAA, BesAA, BesAAEnt, BesAALait: array[1..14, 1..28] of double; |
||
111 | end;
|
||
112 | |||
113 | var
|
||
114 | FBesLactT: TFBesLactT; |
||
115 | |||
116 | implementation
|
||
117 | |||
118 | uses
|
||
119 | Math, gnugettext, UVariables, UInit, UFindRec, UCalcul, UFResBesLactT, |
||
120 | UFRapBesLactT; |
||
121 | |||
122 | {$R *.dfm}
|
||
123 | |||
124 | { TFBesLactT }
|
||
125 | |||
126 | procedure TFBesLactT.FormCreate(Sender: TObject);
|
||
127 | begin
|
||
128 | if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
||
129 | then
|
||
130 | Font.Name := 'Arial Unicode MS';
|
||
131 | TranslateComponent(Self); |
||
132 | Constraints.MinWidth := 624 + (Width - ClientWidth);
|
||
133 | Width := Constraints.MinWidth; |
||
134 | Constraints.MaxWidth := Constraints.MinWidth; |
||
135 | Constraints.MinHeight := 464 + (Height - ClientHeight);
|
||
136 | Height := Constraints.MinHeight; |
||
137 | Constraints.MaxHeight := Constraints.MinHeight; |
||
138 | CBRationProfil.ItemIndex := 0;
|
||
139 | end;
|
||
140 | |||
141 | procedure TFBesLactT.FormShow(Sender: TObject);
|
||
142 | begin
|
||
143 | Modal := False; |
||
144 | Update := True; |
||
145 | PBPortee.AsInteger := 1;
|
||
146 | PBDureeLact.AsInteger := 28;
|
||
147 | Update := False; |
||
148 | end;
|
||
149 | |||
150 | procedure TFBesLactT.FormClose(Sender: TObject; var Action: TCloseAction); |
||
151 | begin
|
||
152 | Action := caFree; |
||
153 | NumWinBesLactT := -1;
|
||
154 | end;
|
||
155 | |||
156 | procedure TFBesLactT.FormActivate(Sender: TObject);
|
||
157 | begin
|
||
158 | if not Modal |
||
159 | then
|
||
160 | begin
|
||
161 | StringsProfilT(CBProfil.Items, False); |
||
162 | StringsSeqAliT(CBSeqAli.Items, False); |
||
163 | StringsRationT(CBRation.Items, False); |
||
164 | CBProfilChange(nil);
|
||
165 | end;
|
||
166 | end;
|
||
167 | |||
168 | procedure TFBesLactT.CBProfilChange(Sender: TObject);
|
||
169 | begin
|
||
170 | if CBProfil.ItemIndex = -1 |
||
171 | then
|
||
172 | begin
|
||
173 | CBProfil.Hint := '' ;
|
||
174 | Update := TRUE ; |
||
175 | ChkPdsApMB.Checked := FALSE ; |
||
176 | ChkP2MB.Checked := FALSE ; |
||
177 | ChkSevres.Checked := FALSE ; |
||
178 | ChkPdsNais.Checked := FALSE ; |
||
179 | ChkPdsSev.Checked := FALSE ; |
||
180 | ChkSeqAli.Checked := FALSE ; |
||
181 | ChkRation.Checked := FALSE ; |
||
182 | ChkAppAli.Checked := FALSE ; |
||
183 | ChkEMAli.Checked := FALSE ; |
||
184 | CalcApport ; // L'apport est recalcul? avec des teneurs standards
|
||
185 | CalcResult ; |
||
186 | Update := FALSE ; |
||
187 | end
|
||
188 | else
|
||
189 | begin
|
||
190 | PProfilT := ListProfilT[FindIdxProfilT (CBProfil.Text)] ; |
||
191 | CBProfil.Hint := PProfilT.Memo ; |
||
192 | // Remplissage des champs avec les valeurs du profil
|
||
193 | Update := TRUE ; |
||
194 | if ChkDureeLact.Checked
|
||
195 | then
|
||
196 | ChkDureeLactClick (nil)
|
||
197 | else
|
||
198 | ChkDureeLact.Checked := TRUE ; |
||
199 | if ChkPdsApMB.Checked
|
||
200 | then
|
||
201 | ChkPdsApMBClick (nil)
|
||
202 | else
|
||
203 | ChkPdsApMB.Checked := TRUE ; |
||
204 | if ChkP2MB.Checked
|
||
205 | then
|
||
206 | ChkP2MBClick (nil)
|
||
207 | else
|
||
208 | ChkP2MB.Checked := TRUE ; |
||
209 | if ChkSevres.Checked
|
||
210 | then
|
||
211 | ChkSevresClick (nil)
|
||
212 | else
|
||
213 | ChkSevres.Checked := TRUE ; |
||
214 | if ChkPdsNais.Checked
|
||
215 | then
|
||
216 | ChkPdsNaisClick (nil)
|
||
217 | else
|
||
218 | ChkPdsNais.Checked := TRUE ; |
||
219 | if ChkPdsSev.Checked
|
||
220 | then
|
||
221 | ChkPdsSevClick (nil)
|
||
222 | else
|
||
223 | ChkPdsSev.Checked := TRUE ; |
||
224 | if ChkSeqAli.Checked
|
||
225 | then
|
||
226 | ChkSeqAliClick (nil)
|
||
227 | else
|
||
228 | ChkSeqAli.Checked := TRUE ; |
||
229 | if ChkRation.Checked
|
||
230 | then
|
||
231 | ChkRationClick (nil)
|
||
232 | else
|
||
233 | ChkRation.Checked := TRUE ; |
||
234 | ChkAppAli.Checked := TRUE ; |
||
235 | ChkEMAli.Checked := TRUE ; |
||
236 | CalcApport ; |
||
237 | ChkAppAliClick (nil) ;
|
||
238 | ChkEMAliClick (nil) ;
|
||
239 | CalcGMQ ; |
||
240 | CalcResult ; |
||
241 | Update := FALSE ; |
||
242 | end ;
|
||
243 | AjustEnabled ; |
||
244 | end;
|
||
245 | |||
246 | procedure TFBesLactT.PBPorteeChange(Sender: TObject);
|
||
247 | begin
|
||
248 | cycle := PBPortee.AsInteger ; |
||
249 | if CBProfil.ItemIndex <> -1 |
||
250 | then
|
||
251 | begin
|
||
252 | // Remplissage des champs avec les valeurs du profil
|
||
253 | Update := TRUE ; |
||
254 | if ChkPdsApMB.Checked
|
||
255 | then
|
||
256 | ChkPdsApMBClick (nil)
|
||
257 | else
|
||
258 | ChkPdsApMB.Checked := TRUE ; |
||
259 | if ChkP2MB.Checked
|
||
260 | then
|
||
261 | ChkP2MBClick (nil)
|
||
262 | else
|
||
263 | ChkP2MB.Checked := TRUE ; |
||
264 | if ChkSevres.Checked
|
||
265 | then
|
||
266 | ChkSevresClick (nil)
|
||
267 | else
|
||
268 | ChkSevres.Checked := TRUE ; |
||
269 | if ChkPdsNais.Checked
|
||
270 | then
|
||
271 | ChkPdsNaisClick (nil)
|
||
272 | else
|
||
273 | ChkPdsNais.Checked := TRUE ; |
||
274 | if ChkPdsSev.Checked
|
||
275 | then
|
||
276 | ChkPdsSevClick (nil)
|
||
277 | else
|
||
278 | ChkPdsSev.Checked := TRUE ; |
||
279 | if ChkRation.Checked
|
||
280 | then
|
||
281 | ChkRationClick (nil)
|
||
282 | else
|
||
283 | ChkRation.Checked := TRUE ; |
||
284 | ChkAppAli.Checked := TRUE ; |
||
285 | ChkEMAli.Checked := TRUE ; |
||
286 | CalcApport ; |
||
287 | ChkAppAliClick (nil) ;
|
||
288 | ChkEMAliClick (nil) ;
|
||
289 | CalcGMQ ; |
||
290 | CalcResult ; |
||
291 | Update := FALSE ; |
||
292 | end ;
|
||
293 | end;
|
||
294 | |||
295 | procedure TFBesLactT.PBPdsApMBChange(Sender: TObject);
|
||
296 | begin
|
||
297 | if not Update |
||
298 | then
|
||
299 | begin
|
||
300 | Update := TRUE ; |
||
301 | CalcResult ; |
||
302 | Update := FALSE ; |
||
303 | end ;
|
||
304 | end;
|
||
305 | |||
306 | procedure TFBesLactT.ChkPdsApMBClick(Sender: TObject);
|
||
307 | begin
|
||
308 | PBPdsApMB.Enabled := not ChkPdsApMB.Checked ;
|
||
309 | if ChkPdsApMB.Checked
|
||
310 | then
|
||
311 | if not Update |
||
312 | then
|
||
313 | begin
|
||
314 | Update := TRUE ; |
||
315 | PBPdsApMB.AsFloat := PProfilT.Truies[cycle].PdsApMB ; |
||
316 | CalcResult ; |
||
317 | Update := FALSE ; |
||
318 | end
|
||
319 | else
|
||
320 | PBPdsApMB.AsFloat := PProfilT.Truies[cycle].PdsApMB ; |
||
321 | end;
|
||
322 | |||
323 | procedure TFBesLactT.PBP2MBChange(Sender: TObject);
|
||
324 | begin
|
||
325 | if not Update |
||
326 | then
|
||
327 | begin
|
||
328 | Update := TRUE ; |
||
329 | CalcResult ; |
||
330 | Update := FALSE ; |
||
331 | end ;
|
||
332 | end;
|
||
333 | |||
334 | procedure TFBesLactT.ChkP2MBClick(Sender: TObject);
|
||
335 | begin
|
||
336 | PBP2MB.Enabled := not ChkP2MB.Checked ;
|
||
337 | if ChkP2MB.Checked
|
||
338 | then
|
||
339 | if not Update |
||
340 | then
|
||
341 | begin
|
||
342 | Update := TRUE ; |
||
343 | PBP2MB.AsFloat := PProfilT.Truies[cycle].P2MB ; |
||
344 | CalcResult ; |
||
345 | Update := FALSE ; |
||
346 | end
|
||
347 | else
|
||
348 | PBP2MB.AsFloat := PProfilT.Truies[cycle].P2MB ; |
||
349 | end;
|
||
350 | |||
351 | procedure TFBesLactT.PBDureeLactChange(Sender: TObject);
|
||
352 | begin
|
||
353 | DureeLact := PBDureeLact.AsInteger ; |
||
354 | if not Update |
||
355 | then
|
||
356 | begin
|
||
357 | Update := TRUE ; |
||
358 | ChkPdsSevClick (nil) ;
|
||
359 | CalcApport ; |
||
360 | ChkAppAliClick (nil) ;
|
||
361 | ChkEMAliClick (nil) ;
|
||
362 | CalcGMQ ; |
||
363 | CalcResult ; |
||
364 | Update := FALSE ; |
||
365 | end ;
|
||
366 | end;
|
||
367 | |||
368 | procedure TFBesLactT.ChkDureeLactClick(Sender: TObject);
|
||
369 | begin
|
||
370 | PBDureeLact.Enabled := not ChkDureeLact.Checked ;
|
||
371 | if ChkDureeLact.Checked
|
||
372 | then
|
||
373 | if not Update |
||
374 | then
|
||
375 | begin
|
||
376 | Update := TRUE ; |
||
377 | PBDureeLact.AsInteger := PProfilT.DureeLact ; |
||
378 | ChkPdsSevClick (nil) ;
|
||
379 | CalcApport ; |
||
380 | ChkAppAliClick (nil) ;
|
||
381 | ChkEMAliClick (nil) ;
|
||
382 | CalcGMQ ; |
||
383 | CalcResult ; |
||
384 | Update := FALSE ; |
||
385 | end
|
||
386 | else
|
||
387 | PBDureeLact.AsInteger := PProfilT.DureeLact ; |
||
388 | end;
|
||
389 | |||
390 | procedure TFBesLactT.PBSevresChange(Sender: TObject);
|
||
391 | begin
|
||
392 | if not Update |
||
393 | then
|
||
394 | begin
|
||
395 | Update := TRUE ; |
||
396 | CalcGMQ ; |
||
397 | CalcResult ; |
||
398 | Update := FALSE ; |
||
399 | end ;
|
||
400 | end;
|
||
401 | |||
402 | procedure TFBesLactT.ChkSevresClick(Sender: TObject);
|
||
403 | begin
|
||
404 | PBSevres.Enabled := not ChkSevres.Checked ;
|
||
405 | if ChkSevres.Checked
|
||
406 | then
|
||
407 | if not Update |
||
408 | then
|
||
409 | begin
|
||
410 | Update := TRUE ; |
||
411 | PBSevres.AsFloat := PProfilT.Porcelets[cycle].Sevres ; |
||
412 | CalcGMQ ; |
||
413 | CalcResult ; |
||
414 | Update := FALSE ; |
||
415 | end
|
||
416 | else
|
||
417 | PBSevres.AsFloat := PProfilT.Porcelets[cycle].Sevres ; |
||
418 | end;
|
||
419 | |||
420 | procedure TFBesLactT.PBPdsNaisChange(Sender: TObject);
|
||
421 | begin
|
||
422 | if not Update |
||
423 | then
|
||
424 | begin
|
||
425 | Update := TRUE ; |
||
426 | CalcGMQ ; |
||
427 | CalcResult ; |
||
428 | Update := FALSE ; |
||
429 | end ;
|
||
430 | end;
|
||
431 | |||
432 | procedure TFBesLactT.ChkPdsNaisClick(Sender: TObject);
|
||
433 | begin
|
||
434 | PBPdsNais.Enabled := not ChkPdsNais.Checked ;
|
||
435 | if ChkPdsNais.Checked
|
||
436 | then
|
||
437 | if not Update |
||
438 | then
|
||
439 | begin
|
||
440 | Update := TRUE ; |
||
441 | PBPdsNais.AsFloat := PProfilT.Porcelets[cycle].PdsNais ; |
||
442 | CalcGMQ ; |
||
443 | CalcResult ; |
||
444 | Update := FALSE ; |
||
445 | end
|
||
446 | else
|
||
447 | PBPdsNais.AsFloat := PProfilT.Porcelets[cycle].PdsNais ; |
||
448 | end;
|
||
449 | |||
450 | procedure TFBesLactT.PBPdsSevChange(Sender: TObject);
|
||
451 | begin
|
||
452 | if not Update |
||
453 | then
|
||
454 | begin
|
||
455 | Update := TRUE ; |
||
456 | CalcGMQ ; |
||
457 | CalcResult ; |
||
458 | Update := FALSE ; |
||
459 | end ;
|
||
460 | end;
|
||
461 | |||
462 | procedure TFBesLactT.ChkPdsSevClick(Sender: TObject);
|
||
463 | var
|
||
464 | GainProfil, GainSimul : double ; |
||
465 | begin
|
||
466 | PBPdsSev.Enabled := not ChkPdsSev.Checked ;
|
||
467 | if ChkPdsSev.Checked
|
||
468 | then
|
||
469 | if not Update |
||
470 | then
|
||
471 | begin
|
||
472 | Update := TRUE ; |
||
473 | // Ajustement du poids de sevrage ? la dur?e de lactation
|
||
474 | GainProfil := (273 * PProfilT.DureeLact + (289 / 0.38) * Exp (-0.38 * PProfilT.DureeLact) - 289 / 0.38) / 1000 ; |
||
475 | GainSimul := (273 * DureeLact + (289 / 0.38) * Exp (-0.38 * DureeLact) - 289 / 0.38) / 1000 ; |
||
476 | PdsSev := PProfilT.Porcelets[cycle].PdsNais + GainSimul * (PProfilT.Porcelets[cycle].PdsSev - PProfilT.Porcelets[cycle].PdsNais) / GainProfil ; |
||
477 | PBPdsSev.AsFloat := PdsSev ; |
||
478 | CalcGMQ ; |
||
479 | CalcResult ; |
||
480 | Update := FALSE ; |
||
481 | end
|
||
482 | else
|
||
483 | begin
|
||
484 | // Ajustement du poids de sevrage ? la dur?e de lactation
|
||
485 | GainProfil := (273 * PProfilT.DureeLact + (289 / 0.38) * Exp (-0.38 * PProfilT.DureeLact) - 289 / 0.38) / 1000 ; |
||
486 | GainSimul := (273 * DureeLact + (289 / 0.38) * Exp (-0.38 * DureeLact) - 289 / 0.38) / 1000 ; |
||
487 | PdsSev := PProfilT.Porcelets[cycle].PdsNais + GainSimul * (PProfilT.Porcelets[cycle].PdsSev - PProfilT.Porcelets[cycle].PdsNais) / GainProfil ; |
||
488 | PBPdsSev.AsFloat := PdsSev ; |
||
489 | end ;
|
||
490 | end;
|
||
491 | |||
492 | procedure TFBesLactT.CBSeqAliChange(Sender: TObject);
|
||
493 | begin
|
||
494 | if CBSeqAli.ItemIndex = -1 |
||
495 | then
|
||
496 | CBSeqAli.Hint := ''
|
||
497 | else
|
||
498 | begin
|
||
499 | PSeqAliT := ListSeqAliT[FindIdxSeqAliT (CBSeqAli.Text)] ; |
||
500 | CBSeqAli.Hint := PSeqAliT.Memo ; |
||
501 | if not Update |
||
502 | then
|
||
503 | begin
|
||
504 | Update := TRUE ; |
||
505 | ChkEMAli.Checked := TRUE ; |
||
506 | CalcApport ; |
||
507 | ChkAppAliClick (nil) ;
|
||
508 | ChkEMAliClick (nil) ;
|
||
509 | CalcResult ; |
||
510 | Update := FALSE ; |
||
511 | end ;
|
||
512 | end ;
|
||
513 | AjustEnabled ; |
||
514 | end;
|
||
515 | |||
516 | procedure TFBesLactT.ChkSeqAliClick(Sender: TObject);
|
||
517 | begin
|
||
518 | CBSeqAli.Enabled := not ChkSeqAli.Checked ;
|
||
519 | if ChkSeqAli.Checked
|
||
520 | then
|
||
521 | if not Update |
||
522 | then
|
||
523 | begin
|
||
524 | Update := TRUE ; |
||
525 | CBSeqAli.ItemIndex := CBSeqAli.Items.IndexOf (FindNomSeqAliT (PProfilT.SeqAli)) ; |
||
526 | CBSeqAliChange (nil) ;
|
||
527 | ChkEMAli.Checked := TRUE ; |
||
528 | CalcApport ; |
||
529 | ChkAppAliClick (nil) ;
|
||
530 | ChkEMAliClick (nil) ;
|
||
531 | CalcResult ; |
||
532 | Update := FALSE ; |
||
533 | end
|
||
534 | else
|
||
535 | begin
|
||
536 | CBSeqAli.ItemIndex := CBSeqAli.Items.IndexOf (FindNomSeqAliT (PProfilT.SeqAli)) ; |
||
537 | CBSeqAliChange (nil) ;
|
||
538 | end ;
|
||
539 | end;
|
||
540 | |||
541 | procedure TFBesLactT.CBRationChange(Sender: TObject);
|
||
542 | begin
|
||
543 | if CBRation.ItemIndex = -1 |
||
544 | then
|
||
545 | CBRation.Hint := ''
|
||
546 | else
|
||
547 | begin
|
||
548 | PRationT := ListRationT[FindIdxRationT (CBRation.Text)] ; |
||
549 | CBRation.Hint := PRationT.Memo ; |
||
550 | if not Update |
||
551 | then
|
||
552 | begin
|
||
553 | Update := TRUE ; |
||
554 | ChkAppAli.Checked := TRUE ; |
||
555 | CalcApport ; |
||
556 | ChkAppAliClick (nil) ;
|
||
557 | if ChkEMAli.Checked
|
||
558 | then
|
||
559 | ChkEMAliClick (nil) ;
|
||
560 | CalcResult ; |
||
561 | Update := FALSE ; |
||
562 | end ;
|
||
563 | end ;
|
||
564 | AjustEnabled ; |
||
565 | end;
|
||
566 | |||
567 | procedure TFBesLactT.ChkRationClick(Sender: TObject);
|
||
568 | begin
|
||
569 | CBRation.Visible := not ChkRation.Checked ;
|
||
570 | CBRationProfil.Visible := ChkRation.Checked ; |
||
571 | if ChkRation.Checked
|
||
572 | then
|
||
573 | if not Update |
||
574 | then
|
||
575 | begin
|
||
576 | Update := TRUE ; |
||
577 | CBRation.ItemIndex := -1 ;
|
||
578 | CBRationChange (nil) ;
|
||
579 | ChkAppAli.Checked := TRUE ; |
||
580 | CalcApport ; |
||
581 | ChkAppAliClick (nil) ;
|
||
582 | if ChkEMAli.Checked
|
||
583 | then
|
||
584 | ChkEMAliClick (nil) ;
|
||
585 | CalcResult ; |
||
586 | Update := FALSE ; |
||
587 | end
|
||
588 | else
|
||
589 | begin
|
||
590 | CBRation.ItemIndex := -1 ;
|
||
591 | CBRationChange (nil) ;
|
||
592 | end ;
|
||
593 | end;
|
||
594 | |||
595 | procedure TFBesLactT.PBAppAliChange(Sender: TObject);
|
||
596 | begin
|
||
597 | if not Update |
||
598 | then
|
||
599 | begin
|
||
600 | Update := TRUE ; |
||
601 | CalcApport ; |
||
602 | if ChkEMAli.Checked
|
||
603 | then
|
||
604 | ChkEMAliClick (nil) ;
|
||
605 | CalcResult ; |
||
606 | Update := FALSE ; |
||
607 | end ;
|
||
608 | end;
|
||
609 | |||
610 | procedure TFBesLactT.ChkAppAliClick(Sender: TObject);
|
||
611 | begin
|
||
612 | PBAppAli.Enabled := not ChkAppAli.Checked ;
|
||
613 | if ChkAppAli.Checked
|
||
614 | then
|
||
615 | if not Update |
||
616 | then
|
||
617 | begin
|
||
618 | Update := TRUE ; |
||
619 | CalcApport ; |
||
620 | PBAppAli.AsFloat := AppAliTot / DureeLact ; |
||
621 | if ChkEMAli.Checked
|
||
622 | then
|
||
623 | ChkEMAliClick (nil) ;
|
||
624 | CalcResult ; |
||
625 | Update := FALSE ; |
||
626 | end
|
||
627 | else
|
||
628 | PBAppAli.AsFloat := AppAliTot / DureeLact ; |
||
629 | end;
|
||
630 | |||
631 | procedure TFBesLactT.PBEMAliChange(Sender: TObject);
|
||
632 | begin
|
||
633 | if not Update |
||
634 | then
|
||
635 | begin
|
||
636 | Update := TRUE ; |
||
637 | CalcApport ; |
||
638 | CalcResult ; |
||
639 | Update := FALSE ; |
||
640 | end ;
|
||
641 | end;
|
||
642 | |||
643 | procedure TFBesLactT.ChkEMAliClick(Sender: TObject);
|
||
644 | begin
|
||
645 | PBEMAli.Enabled := not ChkEMAli.Checked ;
|
||
646 | if ChkEMAli.Checked
|
||
647 | then
|
||
648 | if not Update |
||
649 | then
|
||
650 | begin
|
||
651 | Update := TRUE ; |
||
652 | CalcApport ; |
||
653 | if AppAliTot = 0 |
||
654 | then
|
||
655 | PBEMAli.Text := ''
|
||
656 | else
|
||
657 | PBEMAli.AsFloat := AppEMTot / AppAliTot ; |
||
658 | CalcResult ; |
||
659 | Update := FALSE ; |
||
660 | end
|
||
661 | else
|
||
662 | if AppAliTot = 0 |
||
663 | then
|
||
664 | PBEMAli.Text := ''
|
||
665 | else
|
||
666 | PBEMAli.AsFloat := AppEMTot / AppAliTot |
||
667 | else
|
||
668 | if not Update |
||
669 | then
|
||
670 | begin
|
||
671 | Update := TRUE ; |
||
672 | CalcApport ; // L'apport est recalcul? avec des teneurs standards
|
||
673 | CalcResult ; |
||
674 | Update := FALSE ; |
||
675 | end ;
|
||
676 | end;
|
||
677 | |||
678 | procedure TFBesLactT.CalcApport ;
|
||
679 | var
|
||
680 | i, Jour, AA, Unite : integer ; |
||
681 | PctAli1, PctAli2, Quantite, Ingere, IngSec1, IngSec2 : double ; |
||
682 | NumRuleSeqAli, NumRuleRation : integer ; |
||
683 | RuleSeqAli : array[1..MAX_RULE] of RecRuleSeqAliT ; |
||
684 | RuleRation : array[1..MAX_RULE] of RecRuleRationT ; |
||
685 | RuleSeqAliInit, RuleRationInit, Ecart : integer ; |
||
686 | RecCC1, RecCC2 : CompositionChimique ; |
||
687 | TabAAtotal1, TabAAtotal2, TabCUDAA1, TabCUDAA2 : array[0..12] of double ; |
||
688 | ok : boolean ; |
||
689 | begin
|
||
690 | // Initialisation
|
||
691 | AppAliTot := 0 ;
|
||
692 | AppEDTot := 0 ;
|
||
693 | AppEMTot := 0 ;
|
||
694 | AppENTot := 0 ;
|
||
695 | for Jour := 1 to DureeLact do |
||
696 | begin
|
||
697 | AppAli[Jour] := 0 ;
|
||
698 | AppED[Jour] := 0 ;
|
||
699 | AppEM[Jour] := 0 ;
|
||
700 | AppEN[Jour] := 0 ;
|
||
701 | for AA := 1 to 14 do |
||
702 | AppAA[AA, Jour] := 0 ;
|
||
703 | end ;
|
||
704 | if ChkEMAli.Checked
|
||
705 | then // S?quence alimentaire |
||
706 | if CBSeqAli.ItemIndex = -1 |
||
707 | then
|
||
708 | Exit |
||
709 | else // Chargement des r?gles |
||
710 | for i := 1 to PSeqAliT.NbRuleLact do |
||
711 | RuleSeqAli[i] := PSeqAliT.RuleLact[i] |
||
712 | else // Teneur en EM |
||
713 | if PBEMAli.AsFloat = 0 |
||
714 | then
|
||
715 | Exit |
||
716 | else
|
||
717 | if CBSeqAli.ItemIndex = -1 |
||
718 | then // Cr?ation d'une r?gle sans aliment |
||
719 | with RuleSeqAli[1] do |
||
720 | begin
|
||
721 | ModeFin := -1 ;
|
||
722 | NumAli1 := -1 ;
|
||
723 | NumAli2 := -1 ;
|
||
724 | PctAli1Init := 100 ;
|
||
725 | PctAli1Fin := 100 ;
|
||
726 | end
|
||
727 | else // Chargement des r?gles |
||
728 | for i := 1 to PSeqAliT.NbRuleGest do |
||
729 | RuleSeqAli[i] := PSeqAliT.RuleGest[i] ; |
||
730 | NumRuleSeqAli := 1 ;
|
||
731 | RuleSeqAliInit := 1 ;
|
||
732 | if ChkAppAli.Checked
|
||
733 | then
|
||
734 | if ChkRation.Checked
|
||
735 | then // Profil animal |
||
736 | if CBProfil.ItemIndex = -1 |
||
737 | then
|
||
738 | Exit |
||
739 | else // Cr?ation d'une r?gle ? partir du profil animal |
||
740 | begin
|
||
741 | with RuleRation[1] do |
||
742 | begin
|
||
743 | ModeFin := -1 ;
|
||
744 | Equation := 3 ; // Curvilin?aire |
||
745 | a := PProfilT.Lact[Cycle] / 2 ; // Initial |
||
746 | c := PProfilT.Lact[Cycle] ; // Moyenne
|
||
747 | d := DureeLact ; // Dur?e
|
||
748 | end ;
|
||
749 | Unite := PProfilT.Unite ; |
||
750 | end
|
||
751 | else // Plan de rationnement |
||
752 | if CBRation.ItemIndex = -1 |
||
753 | then
|
||
754 | Exit |
||
755 | else // Chargement des r?gles |
||
756 | begin
|
||
757 | for i := 1 to PRationT.NbRuleLact do |
||
758 | RuleRation[i] := PRationT.RuleLact[i] ; |
||
759 | Unite := PRationT.UniteLact ; |
||
760 | end
|
||
761 | else // Consommation moyenne |
||
762 | if PBAppAli.AsFloat = 0 |
||
763 | then
|
||
764 | Exit |
||
765 | else // Cr?ation d'une r?gle ? partir de la consommation moyenne |
||
766 | begin
|
||
767 | with RuleRation[1] do |
||
768 | begin
|
||
769 | ModeFin := -1 ;
|
||
770 | Equation := 3 ; // Curvilin?aire |
||
771 | a := PBAppAli.AsFloat / 2 ; // Initial |
||
772 | c := PBAppAli.AsFloat ; // Moyenne
|
||
773 | d := DureeLact ; // Dur?e
|
||
774 | end ;
|
||
775 | Unite := 0 ; // Quantit? |
||
776 | end ;
|
||
777 | NumRuleRation := 1 ;
|
||
778 | RuleRationInit := 1 ;
|
||
779 | // Boucle des jours
|
||
780 | for Jour := 1 to DureeLact do |
||
781 | begin
|
||
782 | // Aliment(s) distribu?(s)
|
||
783 | repeat
|
||
784 | ok := TRUE ; |
||
785 | with RuleSeqAli[NumRuleSeqAli] do |
||
786 | if ModeFin = 0 |
||
787 | then // Dur?e |
||
788 | if (Jour - RuleSeqAliInit + 1 > ValFin) then ok := FALSE ; |
||
789 | if not (ok) |
||
790 | then // Changement de r?gle |
||
791 | begin
|
||
792 | Inc (NumRuleSeqAli) ; |
||
793 | RuleSeqAliInit := Jour ; |
||
794 | end ;
|
||
795 | until ok ;
|
||
796 | with RuleSeqAli[NumRuleSeqAli] do |
||
797 | begin
|
||
798 | // Composition aliment 1
|
||
799 | if NumAli1 = -1 |
||
800 | then
|
||
801 | begin
|
||
802 | RecCC1 := CCVide ; |
||
803 | for i := 0 to 12 do |
||
804 | TabAAtotal1[i] := 0 ;
|
||
805 | for i := 0 to 12 do |
||
806 | TabCUDAA1[i] := 0 ;
|
||
807 | end
|
||
808 | else
|
||
809 | begin
|
||
810 | PAliment := ListAliment[FindIdxAliment (FindNomAliment (NumAli1))] ; |
||
811 | RecCC1 := PAliment.CC ; |
||
812 | for i := 0 to 12 do |
||
813 | TabAAtotal1[i] := PAliment.AAtotal[i] ; |
||
814 | for i := 0 to 12 do |
||
815 | TabCUDAA1[i] := PAliment.CUDAA[i] ; |
||
816 | end ;
|
||
817 | if not ChkEMAli.Checked |
||
818 | then // Teneur en EM |
||
819 | with RecCC1 do |
||
820 | begin
|
||
821 | ED_T := (PBEMAli.AsFloat / 0.96) / MS * 1000 ; |
||
822 | EM_T := (PBEMAli.AsFloat) / MS * 1000 ;
|
||
823 | EN_T := (PBEMAli.AsFloat * 0.74) / MS * 1000 ; |
||
824 | end ;
|
||
825 | // Composition aliment 2
|
||
826 | if NumAli2 = -1 |
||
827 | then
|
||
828 | begin
|
||
829 | RecCC2 := CCVide ; |
||
830 | for i := 0 to 12 do |
||
831 | TabAAtotal2[i] := 0 ;
|
||
832 | for i := 0 to 12 do |
||
833 | TabCUDAA2[i] := 0 ;
|
||
834 | end
|
||
835 | else
|
||
836 | begin
|
||
837 | PAliment := ListAliment[FindIdxAliment (FindNomAliment (NumAli2))] ; |
||
838 | RecCC2 := PAliment.CC ; |
||
839 | for i := 0 to 12 do |
||
840 | TabAAtotal2[i] := PAliment.AAtotal[i] ; |
||
841 | for i := 0 to 12 do |
||
842 | TabCUDAA2[i] := PAliment.CUDAA[i] ; |
||
843 | end ;
|
||
844 | if not ChkEMAli.Checked |
||
845 | then // Teneur en EM |
||
846 | with RecCC2 do |
||
847 | begin
|
||
848 | ED_T := (PBEMAli.AsFloat / 0.96) / MS * 1000 ; |
||
849 | EM_T := (PBEMAli.AsFloat) / MS * 1000 ;
|
||
850 | EN_T := (PBEMAli.AsFloat * 0.74) / MS * 1000 ; |
||
851 | end ;
|
||
852 | // Calcul des % aliments
|
||
853 | if PctAli1Init = PctAli1Fin
|
||
854 | then
|
||
855 | PctAli1 := PctAli1Init |
||
856 | else // Transition |
||
857 | begin
|
||
858 | Ecart := PctAli1Fin - PctAli1Init ; |
||
859 | if ModeFin = 0 |
||
860 | then // Dur?e |
||
861 | PctAli1 := PctAli1Init + (Jour - RuleSeqAliInit) * Ecart / ValFin |
||
862 | else // Fin |
||
863 | PctAli1 := PctAli1Init + (Jour - RuleSeqAliInit) * Ecart / (DureeLact - RuleSeqAliInit) ; |
||
864 | end ;
|
||
865 | end ;
|
||
866 | PctAli2 := 100 - PctAli1 ;
|
||
867 | // Quantit?(s) distribu?e(s)
|
||
868 | repeat
|
||
869 | ok := TRUE ; |
||
870 | with RuleRation[NumRuleRation] do |
||
871 | if ModeFin = 0 |
||
872 | then // Dur?e |
||
873 | if Jour - RuleRationInit + 1 > ValFin then ok := FALSE ; |
||
874 | if not (ok) |
||
875 | then // Changement de r?gle |
||
876 | begin
|
||
877 | Inc (NumRuleRation) ; |
||
878 | RuleRationInit := Jour ; |
||
879 | end ;
|
||
880 | until ok ;
|
||
881 | with RuleRation[NumRuleRation] do |
||
882 | begin
|
||
883 | // Calcul des quantit?s
|
||
884 | case Equation of |
||
885 | 0 : // Constant |
||
886 | Quantite := a ; |
||
887 | 1 : // Lin?aire |
||
888 | Quantite := a + b * (Jour - RuleRationInit) ; |
||
889 | 2 : // Lin?aire-plateau |
||
890 | Quantite := LPvaleur (a, b, c, Jour - RuleRationInit + 1, d) ;
|
||
891 | 3 : // Curvilin?aire |
||
892 | Quantite := CLvaleur (a, c, Jour - RuleRationInit + 1, d) ;
|
||
893 | else
|
||
894 | Quantite := 0 ;
|
||
895 | end ;
|
||
896 | // Convertion de ED, EM, EN en quantit? si besoin
|
||
897 | case Unite of |
||
898 | 1 : // ED (MJ/j) |
||
899 | Ingere := Quantite |
||
900 | / (PctAli1 / 100 * RecCC1.ED_T * RecCC1.MS / 1000 |
||
901 | + PctAli2 / 100 * RecCC2.ED_T * RecCC2.MS / 1000) ; |
||
902 | 2 : // EM (MJ/j) |
||
903 | Ingere := Quantite |
||
904 | / (PctAli1 / 100 * RecCC1.EM_T * RecCC1.MS / 1000 |
||
905 | + PctAli2 / 100 * RecCC2.EM_T * RecCC2.MS / 1000) ; |
||
906 | 3 : // EN (MJ/j) |
||
907 | Ingere := Quantite |
||
908 | / (PctAli1 / 100 * RecCC1.EN_T * RecCC1.MS / 1000 |
||
909 | + PctAli2 / 100 * RecCC2.EN_T * RecCC2.MS / 1000) ; |
||
910 | 4 : // MS (kg/j) |
||
911 | Ingere := Quantite |
||
912 | / (PctAli1 / 100 * RecCC1.MS / 1000 |
||
913 | + PctAli2 / 100 * RecCC2.MS / 1000) ; |
||
914 | else // QI (kg/j) |
||
915 | Ingere := Quantite ; |
||
916 | end ;
|
||
917 | end ;
|
||
918 | // Aliment ing?r?
|
||
919 | AppAli[Jour] := Ingere ; |
||
920 | IngSec1 := Ingere * PctAli1 / 100 * RecCC1.MS / 1000 ; |
||
921 | IngSec2 := Ingere * PctAli2 / 100 * RecCC2.MS / 1000 ; |
||
922 | // Energie ing?r?e
|
||
923 | AppED[Jour] := IngSec1 * RecCC1.ED_T + IngSec2 * RecCC2.ED_T ; |
||
924 | AppEM[Jour] := IngSec1 * RecCC1.EM_T + IngSec2 * RecCC2.EM_T ; |
||
925 | AppEN[Jour] := IngSec1 * RecCC1.EN_T + IngSec2 * RecCC2.EN_T ; |
||
926 | // Acides amin?s digestibles
|
||
927 | for AA := 1 to 12 do |
||
928 | AppAA[AA, Jour] := IngSec1 * TabAAtotal1[AA] * TabCUDAA1[AA] / 100
|
||
929 | + IngSec2 * TabAAtotal2[AA] * TabCUDAA2[AA] / 100 ;
|
||
930 | // met+cys
|
||
931 | AppAA[13, Jour] := AppAA[2, Jour] + AppAA[3, Jour] ; |
||
932 | // phe+tyr
|
||
933 | AppAA[14, Jour] := AppAA[6, Jour] + AppAA[7, Jour] ; |
||
934 | end ;
|
||
935 | // Totaux
|
||
936 | AppAliTot := Sum (Slice (AppAli, DureeLact)) ; |
||
937 | AppEDTot := Sum (Slice (AppED, DureeLact)) ; |
||
938 | AppEMTot := Sum (Slice (AppEM, DureeLact)) ; |
||
939 | AppENTot := Sum (Slice (AppEN, DureeLact)) ; |
||
940 | end;
|
||
941 | |||
942 | procedure TFBesLactT.CalcGMQ ;
|
||
943 | begin
|
||
944 | GMQPort := (PBPdsSev.AsFloat - PBPdsNais.AsFloat) * PBSevres.AsFloat / DureeLact ; |
||
945 | PBGMQ.AsFloat := GMQPort ; |
||
946 | end ;
|
||
947 | |||
948 | procedure TFBesLactT.CalcResult ;
|
||
949 | var
|
||
950 | Jour, AA : integer ; |
||
951 | RA, NRLait : double ; |
||
952 | begin
|
||
953 | if (PBPdsApMB.AsFloat > 0) |
||
954 | and (PBP2MB.AsFloat > 0) |
||
955 | and (PBSevres.AsFloat > 0) |
||
956 | and (PBPdsNais.AsFloat > 0) |
||
957 | and (PBPdsSev.AsFloat > PBPdsNais.AsFloat)
|
||
958 | and (PBAppAli.AsFloat > 0) |
||
959 | and (PBEMAli.AsFloat > 0) |
||
960 | then
|
||
961 | begin
|
||
962 | //
|
||
963 | // Besoins ?n?rg?tiques
|
||
964 | //
|
||
965 | // Energie pour l'entretien
|
||
966 | BesEMEntTot := Power (PProfilT.Truies[Cycle].PdsApMB, 0.75) * EELact ;
|
||
967 | for Jour := 1 to DureeLact do |
||
968 | BesEMEnt[Jour] := BesEMEntTot ; |
||
969 | // Energie pour la production de lait
|
||
970 | RA := 0.0000023096 * Power (DureeLact, 4) - 0.00027619 * Power (DureeLact, 3) + 0.012889 * Power (DureeLact, 2) - 0.28116 * DureeLact + 4.799 ; |
||
971 | for Jour := 1 to DureeLact do |
||
972 | BesEMLait[Jour] := (20.6 * GMQPort * 1000 - 376 * PProfilT.Porcelets[cycle].Sevres) * RA * Exp (-0.025 * Jour) * Exp (-Exp (0.5 - 0.1 * Jour)) / 1000 / KL ; |
||
973 | BesEMLaitTot := Mean (Slice (BesEMLait, DureeLact)) ; |
||
974 | // Besoin total en ?nergie
|
||
975 | BesEMTot := BesEMEntTot + BesEMLaitTot ; |
||
976 | //
|
||
977 | // Besoins en acides amin?s
|
||
978 | //
|
||
979 | for Jour := 1 to DureeLact do |
||
980 | begin
|
||
981 | // Production d'azote dans le lait
|
||
982 | NRLait := (0.0257 * GMQPort * 1000 + 0.42 * PProfilT.Porcelets[cycle].Sevres) * RA * Exp (-0.025 * Jour) * Exp (- Exp (0.5 - 0.1 * Jour)) ; |
||
983 | // 1) Besoin total
|
||
984 | BesAA[1, Jour] := (14.2 + 0.629 * NRLait) / 1.335 ; |
||
985 | for AA := 2 to 12 do |
||
986 | BesAA[AA, Jour] := BesAA[1, Jour] * ProtIdLact[AA] / 100 ; |
||
987 | // met+cys
|
||
988 | BesAA[13, Jour] := BesAA[1, Jour] * (ProtIdLact[2] + ProtIdLact[3]) / 100 ; |
||
989 | // phe+tyr
|
||
990 | BesAA[14, Jour] := BesAA[1, Jour] * (ProtIdLact[6] + ProtIdLact[7]) / 100 ; |
||
991 | // 2) Besoin d'entretien
|
||
992 | BesAAEnt[1, Jour] := Power (PProfilT.Truies[Cycle].PdsApMB, 0.75) * 0.036 ; |
||
993 | for AA := 2 to 12 do |
||
994 | BesAAEnt[AA, Jour] := BesAAEnt[1, Jour] * ProtIdEnt[AA] / 100 ; |
||
995 | // met+cys
|
||
996 | BesAAEnt[13, Jour] := BesAAEnt[1, Jour] * (ProtIdEnt[2] + ProtIdEnt[3]) / 100 ; |
||
997 | // phe+tyr
|
||
998 | BesAAEnt[14, Jour] := BesAAEnt[1, Jour] * (ProtIdEnt[6] + ProtIdEnt[7]) / 100 ; |
||
999 | // 3) Besoin pour la port?e
|
||
1000 | for AA := 1 to 14 do |
||
1001 | BesAALait[AA, Jour] := BesAA[AA, Jour] - BesAAEnt[AA, Jour] ; |
||
1002 | end ;
|
||
1003 | //
|
||
1004 | // Besoins en min?raux
|
||
1005 | //
|
||
1006 | for Jour := 1 to DureeLact do |
||
1007 | begin
|
||
1008 | // Production d'azote dans le lait
|
||
1009 | NRLait := (0.0257 * GMQPort * 1000 + 0.42 * PProfilT.Porcelets[cycle].Sevres) * RA * Exp (-0.025 * Jour) * Exp (- Exp (0.5 - 0.1 * Jour)) ; |
||
1010 | // Phosphore digestible
|
||
1011 | BesP[Jour] := 10 * PProfilT.Truies[Cycle].PdsApMB / 1000 |
||
1012 | + NRLait * 6.38 / 0.050 / 1000 * 1.55 ; |
||
1013 | // Calcium total
|
||
1014 | BesCa[Jour] := BesP[Jour] * 3.2 ;
|
||
1015 | end ;
|
||
1016 | //
|
||
1017 | // Affichage des r?sultats
|
||
1018 | //
|
||
1019 | if (AppEMTot = 0) |
||
1020 | then
|
||
1021 | PBBesAli.AsFloat := 0
|
||
1022 | else
|
||
1023 | PBBesAli.AsFloat := BesEMTot * AppAliTot / AppEMTot ; |
||
1024 | PBBesEM.AsFloat := BesEMTot ; |
||
1025 | if (AppEMTot = 0) |
||
1026 | then
|
||
1027 | PBBesEN.AsFloat := 0
|
||
1028 | else
|
||
1029 | PBBesEN.AsFloat := BesEMTot * AppENTot / AppEMTot ; |
||
1030 | if (PBAppAli.AsFloat = 0) |
||
1031 | then
|
||
1032 | PBBesdLys.AsFloat := 0
|
||
1033 | else
|
||
1034 | PBBesdLys.AsFloat := Mean (Slice (BesAA[1], DureeLact)) ;
|
||
1035 | if (BesEMTot > AppEMTot / DureeLact)
|
||
1036 | then // D?ficit |
||
1037 | begin
|
||
1038 | PBDefAli.AsFloat := PBBesAli.AsFloat - PBAppAli.AsFloat ; |
||
1039 | PBDefEM.AsFloat := PBBesEM.AsFloat - AppEMTot / DureeLact ; |
||
1040 | PBDefEN.AsFloat := PBBesEN.AsFloat - AppENTot / DureeLact ; |
||
1041 | end
|
||
1042 | else // Exc?s |
||
1043 | begin
|
||
1044 | PBDefAli.AsFloat := 0 ;
|
||
1045 | PBDefEM.AsFloat := 0 ;
|
||
1046 | PBDefEN.AsFloat := 0 ;
|
||
1047 | end ;
|
||
1048 | BBResLact.Enabled := TRUE ; |
||
1049 | BBRapLact.Enabled := TRUE ; |
||
1050 | end
|
||
1051 | else
|
||
1052 | begin
|
||
1053 | PBBesAli.Text := '' ;
|
||
1054 | PBBesEM.Text := '' ;
|
||
1055 | PBBesEN.Text := '' ;
|
||
1056 | PBBesdLys.Text := '' ;
|
||
1057 | PBDefAli.Text := '' ;
|
||
1058 | PBDefEM.Text := '' ;
|
||
1059 | PBDefEN.Text := '' ;
|
||
1060 | BBResLact.Enabled := FALSE ; |
||
1061 | BBRapLact.Enabled := FALSE ; |
||
1062 | end ;
|
||
1063 | end;
|
||
1064 | |||
1065 | procedure TFBesLactT.BBResLactClick(Sender: TObject);
|
||
1066 | begin
|
||
1067 | Modal := True; |
||
1068 | FResBesLactT := TFResBesLactT.Create (Self) ; |
||
1069 | FResBesLactT.ShowModal ; |
||
1070 | FResBesLactT.Release ; |
||
1071 | Modal := False; |
||
1072 | end;
|
||
1073 | |||
1074 | procedure TFBesLactT.BBRapLactClick(Sender: TObject);
|
||
1075 | begin
|
||
1076 | Modal := True; |
||
1077 | FRapBesLactT := TFRapBesLactT.Create(Self); |
||
1078 | FRapBesLactT.QRRapport.PreviewModal ; |
||
1079 | FRapBesLactT.Release; |
||
1080 | Modal := False; |
||
1081 | end;
|
||
1082 | |||
1083 | procedure TFBesLactT.AjustEnabled;
|
||
1084 | begin
|
||
1085 | ChkPdsApMB.Visible := CBProfil.ItemIndex <> -1 ;
|
||
1086 | ChkP2MB.Visible := CBProfil.ItemIndex <> -1 ;
|
||
1087 | ChkSevres.Visible := CBProfil.ItemIndex <> -1 ;
|
||
1088 | ChkPdsNais.Visible := CBProfil.ItemIndex <> -1 ;
|
||
1089 | ChkPdsSev.Visible := CBProfil.ItemIndex <> -1 ;
|
||
1090 | ChkSeqAli.Visible := CBProfil.ItemIndex <> -1 ;
|
||
1091 | ChkRation.Visible := CBProfil.ItemIndex <> -1 ;
|
||
1092 | ChkAppAli.Visible := (CBProfil.ItemIndex <> -1) or (CBRation.ItemIndex <> -1) ; |
||
1093 | ChkEMAli.Visible := (CBProfil.ItemIndex <> -1) or (CBSeqAli.ItemIndex <> -1) ; |
||
1094 | end;
|
||
1095 | |||
1096 | end. |