root / UFSimulT.pas @ 3
Historique | Voir | Annoter | Télécharger (34,376 ko)
1 | 3 | avalancogn | unit UFSimulT ;
|
---|---|---|---|
2 | |||
3 | interface
|
||
4 | |||
5 | uses
|
||
6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
||
7 | Dialogs, ComCtrls, StdCtrls, Buttons, ExtCtrls, PBNumEdit, PBSuperSpin, |
||
8 | JvExControls, JvComponent, JvEnterTab, UVariables, gnugettext; |
||
9 | |||
10 | type
|
||
11 | TFSimulT = class(TForm)
|
||
12 | PC: TPageControl; |
||
13 | ResSimul: TTabSheet; |
||
14 | CompSimul: TTabSheet; |
||
15 | SensSimul: TTabSheet; |
||
16 | GBSimul: TGroupBox; |
||
17 | SBAddSimul: TSpeedButton; |
||
18 | SBDelSimul: TSpeedButton; |
||
19 | CBSimul: TComboBox; |
||
20 | CBProfil: TComboBox; |
||
21 | CBRation: TComboBox; |
||
22 | CBSeqAli: TComboBox; |
||
23 | CBCompSimul1: TCheckBox; |
||
24 | CBCompSimul2: TCheckBox; |
||
25 | CBCompSimul3: TCheckBox; |
||
26 | CBCompSimul4: TCheckBox; |
||
27 | CBCompSimul5: TCheckBox; |
||
28 | LVariable: TLabel; |
||
29 | LVariation: TLabel; |
||
30 | PBVariation: TPBSuperSpin; |
||
31 | LProfil: TLabel; |
||
32 | LSeqAli: TLabel; |
||
33 | LRation: TLabel; |
||
34 | PSimul: TPanel; |
||
35 | BBResSimul: TBitBtn; |
||
36 | BBTabSimul: TBitBtn; |
||
37 | SBRename: TSpeedButton; |
||
38 | SBComment: TSpeedButton; |
||
39 | BBRapSimul: TBitBtn; |
||
40 | PResSimul: TPanel; |
||
41 | CBSimulSens: TComboBox; |
||
42 | LSimulSens: TLabel; |
||
43 | PSensSimul: TPanel; |
||
44 | BBSensSimul: TBitBtn; |
||
45 | CBSimulComp1: TComboBox; |
||
46 | CBSimulComp2: TComboBox; |
||
47 | CBSimulComp3: TComboBox; |
||
48 | CBSimulComp4: TComboBox; |
||
49 | CBSimulComp5: TComboBox; |
||
50 | PCompSimul: TPanel; |
||
51 | BBCompSimul: TBitBtn; |
||
52 | GBAlim: TGroupBox; |
||
53 | GBFin: TGroupBox; |
||
54 | GBInit: TGroupBox; |
||
55 | PCenter: TPanel; |
||
56 | PLeft: TPanel; |
||
57 | GBParam: TGroupBox; |
||
58 | LLoge: TLabel; |
||
59 | CBLoge: TComboBox; |
||
60 | LDureeLact: TLabel; |
||
61 | LPorteeInit: TLabel; |
||
62 | LPorteeFin: TLabel; |
||
63 | CBStadeInit: TComboBox; |
||
64 | CBStadeFin: TComboBox; |
||
65 | LBPortee: TListBox; |
||
66 | PBDureeLact: TPBSuperSpin; |
||
67 | PBPorteeInit: TPBSuperSpin; |
||
68 | PBPorteeFin: TPBSuperSpin; |
||
69 | PAlim: TPanel; |
||
70 | LOptInit: TLabel; |
||
71 | CBOptInit: TComboBox; |
||
72 | CBVariable: TComboBox; |
||
73 | GBEtatVar: TGroupBox; |
||
74 | LPorteeVar: TLabel; |
||
75 | CBStadeVar: TComboBox; |
||
76 | PBPorteeVarInit: TPBSuperSpin; |
||
77 | PBPorteeVarFin: TPBSuperSpin; |
||
78 | LAVar: TLabel; |
||
79 | LStadeVar: TLabel; |
||
80 | GBModulation: TGroupBox; |
||
81 | SBSave: TSpeedButton; |
||
82 | ChkSeqAli: TCheckBox; |
||
83 | ChkRation: TCheckBox; |
||
84 | CBRationProfil: TComboBox; |
||
85 | JvEnterAsTab: TJvEnterAsTab; |
||
86 | procedure FormShow(Sender: TObject);
|
||
87 | procedure FormClose(Sender: TObject; var Action: TCloseAction); |
||
88 | procedure CBSimulChange(Sender: TObject);
|
||
89 | procedure FormActivate(Sender: TObject);
|
||
90 | procedure FormDeactivate(Sender: TObject);
|
||
91 | procedure SBAddSimulClick(Sender: TObject);
|
||
92 | procedure SBDelSimulClick(Sender: TObject);
|
||
93 | procedure PCChange(Sender: TObject);
|
||
94 | procedure BBResSimulClick(Sender: TObject);
|
||
95 | procedure BBCompSimulClick(Sender: TObject);
|
||
96 | procedure BBSensSimulClick(Sender: TObject);
|
||
97 | procedure CBProfilChange(Sender: TObject);
|
||
98 | procedure CBRationChange(Sender: TObject);
|
||
99 | procedure CBSeqAliChange(Sender: TObject);
|
||
100 | procedure CBCompSimul1Click(Sender: TObject);
|
||
101 | procedure CBCompSimul2Click(Sender: TObject);
|
||
102 | procedure CBCompSimul3Click(Sender: TObject);
|
||
103 | procedure CBCompSimul4Click(Sender: TObject);
|
||
104 | procedure CBCompSimul5Click(Sender: TObject);
|
||
105 | procedure BBTabSimulClick(Sender: TObject);
|
||
106 | procedure SBRenameClick(Sender: TObject);
|
||
107 | procedure SBCommentClick(Sender: TObject);
|
||
108 | procedure BBRapSimulClick(Sender: TObject);
|
||
109 | procedure CBSimulSensChange(Sender: TObject);
|
||
110 | procedure CBSimulComp1Change(Sender: TObject);
|
||
111 | procedure CBSimulComp2Change(Sender: TObject);
|
||
112 | procedure CBSimulComp3Change(Sender: TObject);
|
||
113 | procedure CBSimulComp4Change(Sender: TObject);
|
||
114 | procedure CBSimulComp5Change(Sender: TObject);
|
||
115 | procedure LBPorteeDrawItem(Control: TWinControl; Index: Integer;
|
||
116 | Rect: TRect; State: TOwnerDrawState); |
||
117 | procedure LBPorteeClick(Sender: TObject);
|
||
118 | procedure PBDureeLactChange(Sender: TObject);
|
||
119 | procedure PBPorteeInitChange(Sender: TObject);
|
||
120 | procedure PBPorteeFinChange(Sender: TObject);
|
||
121 | procedure CBStadeInitChange(Sender: TObject);
|
||
122 | procedure CBStadeFinChange(Sender: TObject);
|
||
123 | procedure CBLogeChange(Sender: TObject);
|
||
124 | procedure CBOptInitChange(Sender: TObject);
|
||
125 | procedure CBVariableChange(Sender: TObject);
|
||
126 | procedure PBPorteeVarInitChange(Sender: TObject);
|
||
127 | procedure PBPorteeVarFinChange(Sender: TObject);
|
||
128 | procedure SBSaveClick(Sender: TObject);
|
||
129 | procedure BBRapSensSimulClick(Sender: TObject);
|
||
130 | procedure BBRapCompSimulClick(Sender: TObject);
|
||
131 | procedure ChkSeqAliClick(Sender: TObject);
|
||
132 | procedure ChkRationClick(Sender: TObject);
|
||
133 | procedure FormCreate(Sender: TObject);
|
||
134 | private
|
||
135 | { D?clarations priv?es }
|
||
136 | Update, Modified, Modal: boolean; |
||
137 | IdxSimulT: integer; |
||
138 | procedure Save;
|
||
139 | procedure ValidBBResSimul;
|
||
140 | procedure ValidBBCompSimul;
|
||
141 | procedure ValidBBSensSimul;
|
||
142 | public
|
||
143 | { D?clarations publiques }
|
||
144 | end;
|
||
145 | |||
146 | var
|
||
147 | FSimulT: TFSimulT; |
||
148 | |||
149 | implementation
|
||
150 | |||
151 | uses
|
||
152 | UStrings, UInit, UUtil, UFindRec, UFComment, UCalcSimulT, UFResSimulT, |
||
153 | UFRapSimulT, {UFTabSimulT,} UFCompSimulT, UFWarning;
|
||
154 | |||
155 | {$R *.dfm}
|
||
156 | |||
157 | { TFSimulT }
|
||
158 | |||
159 | procedure TFSimulT.FormCreate(Sender: TObject);
|
||
160 | begin
|
||
161 | if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
||
162 | then
|
||
163 | Font.Name := 'Arial Unicode MS';
|
||
164 | TranslateComponent(Self); |
||
165 | Constraints.MinWidth := 624 + (Width - ClientWidth);
|
||
166 | Width := Constraints.MinWidth; |
||
167 | Constraints.MinHeight := 396 + (Height - ClientHeight);
|
||
168 | Height := Constraints.MinHeight; |
||
169 | CBOptInit.ItemIndex := 0;
|
||
170 | CBRationProfil.ItemIndex := 0;
|
||
171 | CBStadeVar.ItemIndex := 0;
|
||
172 | end;
|
||
173 | |||
174 | procedure TFSimulT.FormShow(Sender: TObject);
|
||
175 | begin
|
||
176 | Modified := False; |
||
177 | Modal := False; |
||
178 | PC.ActivePageIndex := 0;
|
||
179 | // Simualtion simple
|
||
180 | StringsSimulT(CBSimul.Items, True); |
||
181 | SBAddSimul.Enabled := IsComplete or (ListSimulT.Count < 5); |
||
182 | SBSave.Enabled := IsComplete or IsEducation;
|
||
183 | // Comparaison
|
||
184 | StringsSimulT(CBSimulComp1.Items, False); |
||
185 | StringsSimulT(CBSimulComp2.Items, False); |
||
186 | StringsSimulT(CBSimulComp3.Items, False); |
||
187 | StringsSimulT(CBSimulComp4.Items, False); |
||
188 | StringsSimulT(CBSimulComp5.Items, False); |
||
189 | // Sensibilit?
|
||
190 | StringsSimulT(CBSimulSens.Items, False); |
||
191 | PBPorteeVarInit.AsInteger := 1;
|
||
192 | PBPorteeVarFin.AsInteger := 8;
|
||
193 | IdxSimulT := -1;
|
||
194 | // CBSimulChange(nil);
|
||
195 | end;
|
||
196 | |||
197 | procedure TFSimulT.FormClose(Sender: TObject; var Action: TCloseAction); |
||
198 | begin
|
||
199 | if Modified then Save; |
||
200 | Action := caFree; |
||
201 | NumWinSimulT := -1;
|
||
202 | end;
|
||
203 | |||
204 | procedure TFSimulT.FormActivate(Sender: TObject);
|
||
205 | begin
|
||
206 | if not Modal |
||
207 | then
|
||
208 | begin
|
||
209 | StringsProfilT(CBProfil.Items, False); |
||
210 | StringsLogeT(CBLoge.Items, False); |
||
211 | StringsSeqAliT(CBSeqAli.Items, False); |
||
212 | StringsRationT(CBRation.Items, False); |
||
213 | PCChange(nil);
|
||
214 | PSimul.Enabled := IsComplete or IsEducation or IsEvaluation; |
||
215 | end;
|
||
216 | end;
|
||
217 | |||
218 | procedure TFSimulT.FormDeactivate(Sender: TObject);
|
||
219 | begin
|
||
220 | if Modified and not Modal then Save; |
||
221 | end;
|
||
222 | |||
223 | procedure TFSimulT.PCChange(Sender: TObject);
|
||
224 | begin
|
||
225 | // if Modified then Save;
|
||
226 | case PC.ActivePageIndex of |
||
227 | 0: // Simulation simple |
||
228 | CBSimulChange(nil);
|
||
229 | 1: // Comparaison |
||
230 | begin
|
||
231 | StringsSimulT(CBSimulComp1.Items, False); |
||
232 | CBSimulComp1Change(nil);
|
||
233 | StringsSimulT(CBSimulComp2.Items, False); |
||
234 | CBSimulComp2Change(nil);
|
||
235 | StringsSimulT(CBSimulComp3.Items, False); |
||
236 | CBSimulComp3Change(nil);
|
||
237 | StringsSimulT(CBSimulComp4.Items, False); |
||
238 | CBSimulComp4Change(nil);
|
||
239 | StringsSimulT(CBSimulComp5.Items, False); |
||
240 | CBSimulComp5Change(nil);
|
||
241 | end;
|
||
242 | 2: // Sensibilit? |
||
243 | begin
|
||
244 | StringsSimulT(CBSimulSens.Items, False); |
||
245 | CBSimulSensChange(nil);
|
||
246 | end;
|
||
247 | end;
|
||
248 | end;
|
||
249 | |||
250 | // Simulation simple
|
||
251 | |||
252 | procedure TFSimulT.Save;
|
||
253 | var
|
||
254 | s: string;
|
||
255 | begin
|
||
256 | Modified := False; |
||
257 | if IsComplete or IsEducation |
||
258 | then
|
||
259 | if MessageDlg(Caption + sLineBreak + MsgSave, mtConfirmation, [mbYes, mbNo], 0) = mrYes |
||
260 | then
|
||
261 | begin
|
||
262 | SaveSimulT; |
||
263 | if not SimulTValid(PSimulT) |
||
264 | then
|
||
265 | MessageDlg(Format(MsgInvalidData, [Caption, PSimulT.Nom]), mtWarning, [mbOK], 0);
|
||
266 | // Comparaison
|
||
267 | StringsSimulT(CBSimulComp1.Items, False); |
||
268 | StringsSimulT(CBSimulComp2.Items, False); |
||
269 | StringsSimulT(CBSimulComp3.Items, False); |
||
270 | StringsSimulT(CBSimulComp4.Items, False); |
||
271 | StringsSimulT(CBSimulComp5.Items, False); |
||
272 | // Sensibilit?
|
||
273 | StringsSimulT(CBSimulSens.Items, False); |
||
274 | end
|
||
275 | else
|
||
276 | begin
|
||
277 | LoadSimulT; |
||
278 | s := CBSimul.Text; |
||
279 | StringsSimulT(CBSimul.Items, True); |
||
280 | if FindIdxSimulT(s) = -1 |
||
281 | then
|
||
282 | begin
|
||
283 | IdxSimulT := -1;
|
||
284 | CBSimulChange(nil);
|
||
285 | end
|
||
286 | else
|
||
287 | CBSimul.ItemIndex := CBSimul.Items.IndexOf(s); |
||
288 | end;
|
||
289 | end;
|
||
290 | |||
291 | procedure TFSimulT.CBSimulChange(Sender: TObject);
|
||
292 | begin
|
||
293 | if (IdxSimulT <> -1) and (CBSimul.Text <> PSimulT.Nom) |
||
294 | then
|
||
295 | if Modified then Save; |
||
296 | IdxSimulT := FindIdxSimulT (CBSimul.Text); |
||
297 | if IdxSimulT = -1 |
||
298 | then // Pas d'enregistrement |
||
299 | begin
|
||
300 | CBSimul.Repaint ; |
||
301 | SBDelSimul.Enabled := FALSE ; |
||
302 | SBRename.Enabled := FALSE ; |
||
303 | SBComment.Enabled := FALSE ; |
||
304 | SBSave.Enabled := FALSE ; |
||
305 | PSimul.Visible := FALSE ; |
||
306 | BBResSimul.Enabled := FALSE ; |
||
307 | BBRapSimul.Enabled := FALSE ; |
||
308 | BBTabSimul.Enabled := FALSE ; |
||
309 | end
|
||
310 | else // Affichage de l'enregistrement |
||
311 | begin
|
||
312 | SBDelSimul.Enabled := TRUE ; |
||
313 | SBRename.Enabled := TRUE ; |
||
314 | SBComment.Enabled := TRUE ; |
||
315 | SBSave.Enabled := TRUE ; |
||
316 | PSimul.Visible := TRUE ; |
||
317 | PSimulT := ListSimulT[IdxSimulT] ; |
||
318 | with PSimulT^ do |
||
319 | begin
|
||
320 | Update := TRUE ; |
||
321 | CBSimul.Hint := Memo ; |
||
322 | if Profil = -1 |
||
323 | then
|
||
324 | CBProfil.ItemIndex := -1
|
||
325 | else
|
||
326 | CBProfil.ItemIndex := CBProfil.Items.IndexOf (FindNomProfilT (Profil)) ; |
||
327 | if CBProfil.ItemIndex = -1 |
||
328 | then
|
||
329 | CBProfil.Hint := ''
|
||
330 | else
|
||
331 | begin
|
||
332 | PProfilT := ListProfilT[FindIdxProfilT (CBProfil.Text)] ; |
||
333 | CBProfil.Hint := PProfilT.Memo ; |
||
334 | end ;
|
||
335 | if Logement = -1 |
||
336 | then
|
||
337 | CBLoge.ItemIndex := -1
|
||
338 | else
|
||
339 | CBLoge.ItemIndex := CBLoge.Items.IndexOf (FindNomLogeT (Logement)) ; |
||
340 | if CBLoge.ItemIndex = -1 |
||
341 | then
|
||
342 | CBLoge.Hint := ''
|
||
343 | else
|
||
344 | begin
|
||
345 | PLogeT := ListLogeT[FindIdxLogeT (CBLoge.Text)] ; |
||
346 | CBLoge.Hint := PLogeT.Memo ; |
||
347 | end ;
|
||
348 | PBDureeLact.AsInteger := DureeLact ; |
||
349 | CBOptInit.ItemIndex := OptInit ; |
||
350 | PBPorteeInit.AsInteger := StadeInit div 3 + 1 ; |
||
351 | CBStadeInit.ItemIndex := StadeInit mod 3 ; |
||
352 | PBPorteeFin.AsInteger := StadeFin div 3 + 1 ; |
||
353 | CBStadeFin.ItemIndex := StadeFin mod 3 ; |
||
354 | LBPortee.ItemIndex := -1 ;
|
||
355 | LBPorteeClick (nil) ;
|
||
356 | LBPortee.Repaint ; |
||
357 | Update := FALSE ; |
||
358 | end ;
|
||
359 | ValidBBResSimul; |
||
360 | end;
|
||
361 | end;
|
||
362 | |||
363 | procedure TFSimulT.SBAddSimulClick (Sender : TObject) ;
|
||
364 | var
|
||
365 | i, n, q : integer ; |
||
366 | s : string ;
|
||
367 | ok : boolean ; |
||
368 | PBackup : PRecSimulT ; |
||
369 | begin
|
||
370 | if Modified then Save ; |
||
371 | if IdxSimulT = -1 |
||
372 | then
|
||
373 | q := mrNo |
||
374 | else
|
||
375 | q := MessageDlg (MsgCopy, mtConfirmation, [mbYes, mbNo], 0) ;
|
||
376 | // saisie du nouveau nom
|
||
377 | s := '' ;
|
||
378 | repeat
|
||
379 | if InputQuery (FSimulT.Caption, MsgName, s)
|
||
380 | then // V?rification du nom |
||
381 | begin
|
||
382 | s := Trim (s) ; // Suppression des espaces au d?but et ? la fin
|
||
383 | if s = '' |
||
384 | then // Pas de nom |
||
385 | begin
|
||
386 | ok := FALSE ; |
||
387 | MessageDlg (MsgNameEmpty, mtWarning, [mbOk], 0) ;
|
||
388 | end
|
||
389 | else
|
||
390 | if Length (s) > 25 |
||
391 | then // Nom trop long |
||
392 | begin
|
||
393 | ok := FALSE ; |
||
394 | MessageDlg (Format (MsgNameTooLarge, [25]), mtWarning, [mbOk], 0) ; |
||
395 | s := Copy (s, 1, 25) ; |
||
396 | end
|
||
397 | else
|
||
398 | begin
|
||
399 | ok := TRUE ; |
||
400 | i := 0 ;
|
||
401 | while ok and (i < ListSimulT.Count) do |
||
402 | begin
|
||
403 | PSimulT := ListSimulT[i] ; |
||
404 | if PSimulT.Nom = s
|
||
405 | then // Nom d?j? utilis? |
||
406 | begin
|
||
407 | ok := FALSE ; |
||
408 | MessageDlg (MsgNameExists, mtWarning, [mbOk], 0) ;
|
||
409 | end
|
||
410 | else
|
||
411 | Inc (i) ; |
||
412 | end ;
|
||
413 | end ;
|
||
414 | end
|
||
415 | else // Annulation |
||
416 | begin
|
||
417 | s := '' ;
|
||
418 | if (IdxSimulT <> -1) |
||
419 | then
|
||
420 | PSimulT := ListSimulT[IdxSimulT] ; |
||
421 | ok := TRUE ; |
||
422 | end ;
|
||
423 | until ok ;
|
||
424 | if s <> '' |
||
425 | then // Cr?ation du nouvel enregistrement |
||
426 | begin
|
||
427 | // recherche du premier num?ro libre
|
||
428 | n := 0 ;
|
||
429 | repeat
|
||
430 | Inc (n) ; |
||
431 | ok := TRUE ; |
||
432 | i := 0 ;
|
||
433 | while ok and (i < ListSimulT.Count) do |
||
434 | begin
|
||
435 | PSimulT := ListSimulT[i] ; |
||
436 | if PSimulT.Num = n
|
||
437 | then
|
||
438 | ok := FALSE |
||
439 | else
|
||
440 | Inc (i) ; |
||
441 | end ;
|
||
442 | until ok ;
|
||
443 | New (PSimulT) ; |
||
444 | with PSimulT^ do |
||
445 | begin
|
||
446 | Nom := s ; |
||
447 | Num := n ; |
||
448 | if q = mrYes
|
||
449 | then
|
||
450 | begin
|
||
451 | PBackup := ListSimulT[IdxSimulT] ; |
||
452 | Memo := PBackup.Memo ; |
||
453 | Profil := PBackup.Profil ; |
||
454 | Logement := PBackup.Logement ; |
||
455 | DureeLact := PBackup.DureeLact ; |
||
456 | DureeISSF := PBackup.DureeISSF ; // DureeISSF n'est plus utilis?
|
||
457 | OptInit := PBackup.OptInit ; |
||
458 | StadeInit := PBackup.StadeInit ; |
||
459 | StadeFin := PBackup.StadeFin ; |
||
460 | SeqAli := PBackup.SeqAli ; |
||
461 | Ration := PBackup.Ration ; |
||
462 | end
|
||
463 | else
|
||
464 | begin
|
||
465 | Memo := '' ;
|
||
466 | Profil := -1 ;
|
||
467 | Logement := -1 ;
|
||
468 | DureeLact := 28 ;
|
||
469 | DureeISSF := 5 ; // DureeISSF n'est plus utilis? |
||
470 | OptInit := 0 ;
|
||
471 | StadeInit := 0 ;
|
||
472 | StadeFin := 2 ;
|
||
473 | for i := 1 to NB_CYCLES do |
||
474 | SeqAli[i] := -1 ;
|
||
475 | for i := 1 to NB_CYCLES do |
||
476 | Ration[i] := -1 ;
|
||
477 | end ;
|
||
478 | end ;
|
||
479 | ListSimulT.Add (PSimulT) ; |
||
480 | CBSimul.Items.Add (PSimulT.Nom) ; |
||
481 | CBSimul.ItemIndex := CBSimul.Items.IndexOf (PSimulT.Nom) ; |
||
482 | CBSimulChange (nil) ;
|
||
483 | Modified := TRUE ; |
||
484 | SBAddSimul.Enabled := IsComplete or (ListSimulT.Count < 5) ; |
||
485 | SBCommentClick (nil) ;
|
||
486 | end ;
|
||
487 | end ;
|
||
488 | |||
489 | procedure TFSimulT.SBDelSimulClick (Sender : TObject) ;
|
||
490 | begin
|
||
491 | if MessageDlg (MsgDel, mtConfirmation, [mbYes, mbNo], 0) = mrYes |
||
492 | then
|
||
493 | begin
|
||
494 | Dispose (PSimulT) ; |
||
495 | ListSimulT.Delete (IdxSimulT) ; |
||
496 | SaveSimulT ; // Sauvegarde !
|
||
497 | Modified := FALSE ; |
||
498 | CBSimul.DeleteSelected ; |
||
499 | IdxSimulT := -1 ;
|
||
500 | CBSimul.ItemIndex := -1 ;
|
||
501 | CBSimulChange (nil) ;
|
||
502 | SBAddSimul.Enabled := IsComplete or (ListSimulT.Count < 5) ; |
||
503 | end ;
|
||
504 | end ;
|
||
505 | |||
506 | procedure TFSimulT.SBRenameClick (Sender : TObject) ;
|
||
507 | var
|
||
508 | i : integer ; |
||
509 | s : string ;
|
||
510 | ok : boolean ; |
||
511 | begin
|
||
512 | // Saisie du nouveau nom
|
||
513 | s := CBSimul.Text ; |
||
514 | repeat
|
||
515 | if InputQuery (FSimulT.Caption, MsgRename, s) and (s <> CBSimul.Text) |
||
516 | then // V?rification du nom |
||
517 | begin
|
||
518 | s := Trim (s) ; // Suppression des espaces au d?but et ? la fin
|
||
519 | if s = '' |
||
520 | then // Pas de nom |
||
521 | begin
|
||
522 | ok := FALSE ; |
||
523 | MessageDlg (MsgNameEmpty, mtWarning, [mbOk], 0) ;
|
||
524 | end
|
||
525 | else
|
||
526 | if Length (s) > 25 |
||
527 | then // Nom trop long |
||
528 | begin
|
||
529 | ok := FALSE ; |
||
530 | MessageDlg (Format (MsgNameTooLarge, [25]), mtWarning, [mbOk], 0) ; |
||
531 | s := Copy (s, 1, 25) ; |
||
532 | end
|
||
533 | else
|
||
534 | begin
|
||
535 | ok := TRUE ; |
||
536 | i := 0 ;
|
||
537 | while ok and (i < ListSimulT.Count) do |
||
538 | begin
|
||
539 | PSimulT := ListSimulT[i] ; |
||
540 | if PSimulT.Nom = s
|
||
541 | then // Nom d?j? utilis? |
||
542 | begin
|
||
543 | ok := FALSE ; |
||
544 | MessageDlg (MsgNameExists, mtWarning, [mbOk], 0) ;
|
||
545 | end
|
||
546 | else
|
||
547 | Inc (i) ; |
||
548 | end ;
|
||
549 | end ;
|
||
550 | end
|
||
551 | else // Annulation |
||
552 | begin
|
||
553 | s := '' ;
|
||
554 | ok := TRUE ; |
||
555 | end ;
|
||
556 | until ok ;
|
||
557 | PSimulT := ListSimulT[IdxSimulT] ; |
||
558 | if s <> '' |
||
559 | then // Renommer l'enregistrement |
||
560 | begin
|
||
561 | PSimulT.Nom := s ; |
||
562 | Modified := TRUE ; |
||
563 | StringsSimulT (CBSimul.Items, TRUE) ; |
||
564 | CBSimul.ItemIndex := CBSimul.Items.IndexOf (s) ; |
||
565 | end ;
|
||
566 | end ;
|
||
567 | |||
568 | procedure TFSimulT.SBCommentClick (Sender : TObject) ;
|
||
569 | begin
|
||
570 | // Saisie du commentaire
|
||
571 | FComment := TFComment.Create (Self) ; |
||
572 | with FComment do |
||
573 | begin
|
||
574 | Memo.Text := PSimulT.Memo ; |
||
575 | if ShowModal = mrOk
|
||
576 | then // Commenter l'enregistrement |
||
577 | begin
|
||
578 | PSimulT.Memo := Memo.Text ; |
||
579 | Modified := TRUE ; |
||
580 | CBSimul.Hint := PSimulT.Memo ; |
||
581 | end ;
|
||
582 | Release ; |
||
583 | end ;
|
||
584 | end ;
|
||
585 | |||
586 | procedure TFSimulT.SBSaveClick(Sender: TObject);
|
||
587 | begin
|
||
588 | SaveSimulT ; |
||
589 | if not SimulTValid (PSimulT) |
||
590 | then
|
||
591 | MessageDlg(Format (MsgInvalidData, [Caption, PSimulT.Nom]), mtWarning, [mbOK], 0) ;
|
||
592 | Modified := FALSE ; |
||
593 | end;
|
||
594 | |||
595 | procedure TFSimulT.CBProfilChange (Sender : TObject) ;
|
||
596 | begin
|
||
597 | if CBProfil.ItemIndex = -1 |
||
598 | then
|
||
599 | CBProfil.Hint := ''
|
||
600 | else
|
||
601 | begin
|
||
602 | PProfilT := ListProfilT[FindIdxProfilT (CBProfil.Text)] ; |
||
603 | CBProfil.Hint := PProfilT.Memo ; |
||
604 | end ;
|
||
605 | if not Update |
||
606 | then
|
||
607 | begin
|
||
608 | Modified := TRUE ; |
||
609 | PSimulT.Profil := FindNumProfilT (CBProfil.Text) ; |
||
610 | PBDureeLact.AsInteger := PProfilT.DureeLact ; |
||
611 | ValidBBResSimul ; |
||
612 | end ;
|
||
613 | end ;
|
||
614 | |||
615 | procedure TFSimulT.CBLogeChange (Sender : TObject) ;
|
||
616 | begin
|
||
617 | if CBLoge.ItemIndex = -1 |
||
618 | then
|
||
619 | CBLoge.Hint := ''
|
||
620 | else
|
||
621 | begin
|
||
622 | PLogeT := ListLogeT[FindIdxLogeT (CBLoge.Text)] ; |
||
623 | CBLoge.Hint := PLogeT.Memo ; |
||
624 | end ;
|
||
625 | if not Update |
||
626 | then
|
||
627 | begin
|
||
628 | Modified := TRUE ; |
||
629 | PSimulT.Logement := FindNumLogeT (CBLoge.Text) ; |
||
630 | ValidBBResSimul ; |
||
631 | end ;
|
||
632 | end ;
|
||
633 | |||
634 | procedure TFSimulT.PBDureeLactChange (Sender : TObject) ;
|
||
635 | begin
|
||
636 | if not Update |
||
637 | then
|
||
638 | begin
|
||
639 | Modified := TRUE ; |
||
640 | PSimulT.DureeLact := PBDureeLact.AsInteger ; |
||
641 | end ;
|
||
642 | end ;
|
||
643 | |||
644 | procedure TFSimulT.CBOptInitChange (Sender : TObject) ;
|
||
645 | begin
|
||
646 | if CBOptInit.ItemIndex = 2 |
||
647 | then // Au d?part seulement |
||
648 | if AffOptInit
|
||
649 | then
|
||
650 | begin
|
||
651 | FWarning := TFWarning.Create (Self) ; |
||
652 | with FWarning do |
||
653 | begin
|
||
654 | Msg := 'OptInit';
|
||
655 | ShowModal ; |
||
656 | Release ; |
||
657 | AffOptInit := FALSE ; |
||
658 | end ;
|
||
659 | end ;
|
||
660 | if not Update |
||
661 | then
|
||
662 | begin
|
||
663 | Modified := TRUE ; |
||
664 | PSimulT.OptInit := CBOptInit.ItemIndex ; |
||
665 | end ;
|
||
666 | end ;
|
||
667 | |||
668 | procedure TFSimulT.PBPorteeInitChange (Sender : TObject) ;
|
||
669 | begin
|
||
670 | if not Update |
||
671 | then
|
||
672 | begin
|
||
673 | Modified := TRUE ; |
||
674 | PSimulT.StadeInit := (PBPorteeInit.AsInteger - 1) * 3 |
||
675 | + CBStadeInit.ItemIndex ; |
||
676 | if PSimulT.StadeInit >= PSimulT.StadeFin
|
||
677 | then
|
||
678 | if PSimulT.StadeFin >= 21 |
||
679 | then // Port?e 8 |
||
680 | begin
|
||
681 | PSimulT.StadeFin := PSimulT.StadeFin + 1 ;
|
||
682 | Update := TRUE ; |
||
683 | CBStadeFin.ItemIndex := PSimulT.StadeFin mod 3 ; |
||
684 | Update := FALSE ; |
||
685 | end
|
||
686 | else
|
||
687 | begin
|
||
688 | PSimulT.StadeFin := PSimulT.StadeFin + 3 ;
|
||
689 | Update := TRUE ; |
||
690 | PBPorteeFin.AsInteger := PSimulT.StadeFin div 3 + 1 ; |
||
691 | Update := FALSE ; |
||
692 | end ;
|
||
693 | LBPortee.Repaint ; |
||
694 | end ;
|
||
695 | end ;
|
||
696 | |||
697 | procedure TFSimulT.CBStadeInitChange (Sender : TObject) ;
|
||
698 | begin
|
||
699 | if not Update |
||
700 | then
|
||
701 | begin
|
||
702 | Modified := TRUE ; |
||
703 | PSimulT.StadeInit := (PBPorteeInit.AsInteger - 1) * 3 |
||
704 | + CBStadeInit.ItemIndex ; |
||
705 | if PSimulT.StadeInit >= PSimulT.StadeFin
|
||
706 | then
|
||
707 | if PSimulT.StadeFin mod 3 = 2 |
||
708 | then // Sevrage |
||
709 | begin
|
||
710 | PSimulT.StadeFin := PSimulT.StadeFin + 3 ;
|
||
711 | Update := TRUE ; |
||
712 | PBPorteeFin.AsInteger := PSimulT.StadeFin div 3 + 1 ; |
||
713 | Update := FALSE ; |
||
714 | end
|
||
715 | else
|
||
716 | begin
|
||
717 | PSimulT.StadeFin := PSimulT.StadeFin + 1 ;
|
||
718 | Update := TRUE ; |
||
719 | CBStadeFin.ItemIndex := PSimulT.StadeFin mod 3 ; |
||
720 | Update := FALSE ; |
||
721 | end ;
|
||
722 | LBPortee.Repaint ; |
||
723 | end ;
|
||
724 | end ;
|
||
725 | |||
726 | procedure TFSimulT.PBPorteeFinChange (Sender : TObject) ;
|
||
727 | begin
|
||
728 | if not Update |
||
729 | then
|
||
730 | begin
|
||
731 | Modified := TRUE ; |
||
732 | PSimulT.StadeFin := (PBPorteeFin.AsInteger - 1) * 3 |
||
733 | + CBStadeFin.ItemIndex ; |
||
734 | if PSimulT.StadeInit >= PSimulT.StadeFin
|
||
735 | then
|
||
736 | if PSimulT.StadeFin div 3 = PSimulT.StadeInit div 3 |
||
737 | then
|
||
738 | begin
|
||
739 | PSimulT.StadeFin := PSimulT.StadeInit + 1 ;
|
||
740 | Update := TRUE ; |
||
741 | CBStadeFin.ItemIndex := PSimulT.StadeFin mod 3 ; |
||
742 | Update := FALSE ; |
||
743 | end
|
||
744 | else
|
||
745 | begin
|
||
746 | PSimulT.StadeFin := PSimulT.StadeFin + 3 ;
|
||
747 | Update := TRUE ; |
||
748 | PBPorteeFin.AsInteger := PSimulT.StadeFin div 3 + 1 ; |
||
749 | Update := FALSE ; |
||
750 | end ;
|
||
751 | LBPortee.Repaint ; |
||
752 | end ;
|
||
753 | end ;
|
||
754 | |||
755 | procedure TFSimulT.CBStadeFinChange (Sender : TObject) ;
|
||
756 | begin
|
||
757 | if not Update |
||
758 | then
|
||
759 | begin
|
||
760 | Modified := TRUE ; |
||
761 | PSimulT.StadeFin := (PBPorteeFin.AsInteger - 1) * 3 |
||
762 | + CBStadeFin.ItemIndex ; |
||
763 | if PSimulT.StadeInit >= PSimulT.StadeFin
|
||
764 | then
|
||
765 | if PSimulT.StadeFin >= 21 |
||
766 | then // Port?e 8 |
||
767 | begin
|
||
768 | PSimulT.StadeFin := PSimulT.StadeInit + 1 ;
|
||
769 | Update := TRUE ; |
||
770 | CBStadeFin.ItemIndex := PSimulT.StadeFin mod 3 ; |
||
771 | Update := FALSE ; |
||
772 | end
|
||
773 | else
|
||
774 | begin
|
||
775 | PSimulT.StadeFin := PSimulT.StadeFin + 3 ;
|
||
776 | Update := TRUE ; |
||
777 | PBPorteeFin.AsInteger := PSimulT.StadeFin div 3 + 1 ; |
||
778 | Update := FALSE ; |
||
779 | end ;
|
||
780 | LBPortee.Repaint ; |
||
781 | end ;
|
||
782 | end ;
|
||
783 | |||
784 | procedure TFSimulT.LBPorteeDrawItem (Control : TWinControl ; Index : Integer ;
|
||
785 | Rect : TRect ; State : TOwnerDrawState) ; |
||
786 | begin
|
||
787 | with (Control as TListBox).Canvas do |
||
788 | begin
|
||
789 | // Cadre principal
|
||
790 | FillRect (Rect) ; |
||
791 | // if (PSimulT.SeqAli[Index + 1] = -1) or (PSimulT.Ration[Index + 1] = -1)
|
||
792 | // then
|
||
793 | // Font.Color := clRed
|
||
794 | // else
|
||
795 | if (odSelected in State) |
||
796 | then
|
||
797 | Font.Color := clYellow |
||
798 | else
|
||
799 | Font.Color := clBlue ; |
||
800 | // ISSF
|
||
801 | if (Index * 3 + 2 >= PSimulT.StadeInit) |
||
802 | and (Index * 3 + 2 < PSimulT.StadeFin) |
||
803 | then
|
||
804 | TextRect (Rect, Rect.Left + 240, Rect.Top, StrISSF) ;
|
||
805 | Rect.Right := 240 ;
|
||
806 | // Lactation
|
||
807 | if (Index * 3 + 1 >= PSimulT.StadeInit) |
||
808 | and (Index * 3 + 1 < PSimulT.StadeFin) |
||
809 | then
|
||
810 | TextRect (Rect, Rect.Left + 160, Rect.Top, StrLactation) ;
|
||
811 | Rect.Right := 160 ;
|
||
812 | // Gestation
|
||
813 | if (Index * 3 >= PSimulT.StadeInit) |
||
814 | and (Index * 3 < PSimulT.StadeFin) |
||
815 | then
|
||
816 | TextRect (Rect, Rect.Left + 80, Rect.Top, StrGestation) ;
|
||
817 | Rect.Right := 80 ;
|
||
818 | // Texte
|
||
819 | if (odSelected in State) |
||
820 | then
|
||
821 | Font.Color := clWhite |
||
822 | else
|
||
823 | Font.Color := clBlack ; |
||
824 | TextRect (Rect, Rect.Left, Rect.Top, LBPortee.Items[Index]) ; |
||
825 | end ;
|
||
826 | end ;
|
||
827 | |||
828 | procedure TFSimulT.LBPorteeClick (Sender : TObject) ;
|
||
829 | begin
|
||
830 | if LBPortee.ItemIndex = -1 |
||
831 | then
|
||
832 | LBPortee.ItemIndex := PBPorteeInit.AsInteger - 1 ;
|
||
833 | Update := TRUE ; |
||
834 | ChkSeqAli.Checked := (PSimulT.SeqAli[LBPortee.ItemIndex + 1] = -1) ; |
||
835 | ChkRation.Checked := (PSimulT.Ration[LBPortee.ItemIndex + 1] = -1) ; |
||
836 | if PSimulT.Profil = -1 |
||
837 | then
|
||
838 | CBSeqAli.ItemIndex := -1
|
||
839 | else
|
||
840 | if ChkSeqAli.Checked
|
||
841 | then
|
||
842 | CBSeqAli.ItemIndex := CBSeqAli.Items.IndexOf (FindNomSeqAliT (PProfilT.SeqAli)) |
||
843 | else
|
||
844 | CBSeqAli.ItemIndex := CBSeqAli.Items.IndexOf (FindNomSeqAliT (PSimulT.SeqAli[LBPortee.ItemIndex + 1])) ;
|
||
845 | CBSeqAliChange (nil) ;
|
||
846 | if ChkRation.Checked
|
||
847 | then
|
||
848 | CBRation.ItemIndex := -1
|
||
849 | else
|
||
850 | CBRation.ItemIndex := CBRation.Items.IndexOf (FindNomRationT (PSimulT.Ration[LBPortee.ItemIndex + 1])) ;
|
||
851 | CBRationChange (nil) ;
|
||
852 | Update := FALSE ; |
||
853 | end ;
|
||
854 | |||
855 | procedure TFSimulT.CBSeqAliChange (Sender : TObject) ;
|
||
856 | begin
|
||
857 | if CBSeqAli.ItemIndex = -1 |
||
858 | then
|
||
859 | CBSeqAli.Hint := ''
|
||
860 | else
|
||
861 | begin
|
||
862 | PSeqAliT := ListSeqAliT[FindIdxSeqAliT (CBSeqAli.Text)] ; |
||
863 | CBSeqAli.Hint := PSeqAliT.Memo ; |
||
864 | end ;
|
||
865 | if not Update |
||
866 | then
|
||
867 | begin
|
||
868 | Modified := TRUE ; |
||
869 | PSimulT.SeqAli[LBPortee.ItemIndex + 1] := FindNumSeqAliT (CBSeqAli.Text) ;
|
||
870 | // LBPortee.Repaint ;
|
||
871 | end ;
|
||
872 | end ;
|
||
873 | |||
874 | procedure TFSimulT.ChkSeqAliClick(Sender: TObject);
|
||
875 | begin
|
||
876 | CBSeqAli.Enabled := not ChkSeqAli.Checked ;
|
||
877 | if ChkSeqAli.Checked
|
||
878 | then
|
||
879 | if not Update |
||
880 | then
|
||
881 | begin
|
||
882 | Modified := TRUE ; |
||
883 | PSimulT.SeqAli[LBPortee.ItemIndex + 1] := -1 ; |
||
884 | Update := TRUE ; |
||
885 | if PSimulT.Profil = -1 |
||
886 | then
|
||
887 | CBSeqAli.ItemIndex := -1
|
||
888 | else
|
||
889 | CBSeqAli.ItemIndex := CBSeqAli.Items.IndexOf (FindNomSeqAliT (PProfilT.SeqAli)) ; |
||
890 | CBSeqAliChange (nil) ;
|
||
891 | Update := FALSE ; |
||
892 | // LBPortee.Repaint ;
|
||
893 | end ;
|
||
894 | end;
|
||
895 | |||
896 | procedure TFSimulT.CBRationChange (Sender : TObject) ;
|
||
897 | begin
|
||
898 | if CBRation.ItemIndex = -1 |
||
899 | then
|
||
900 | CBRation.Hint := ''
|
||
901 | else
|
||
902 | begin
|
||
903 | PRationT := ListRationT[FindIdxRationT (CBRation.Text)] ; |
||
904 | CBRation.Hint := PRationT.Memo ; |
||
905 | end ;
|
||
906 | if not Update |
||
907 | then
|
||
908 | begin
|
||
909 | Modified := TRUE ; |
||
910 | PSimulT.Ration[LBPortee.ItemIndex + 1] := FindNumRationT (CBRation.Text) ;
|
||
911 | // LBPortee.Repaint ;
|
||
912 | end ;
|
||
913 | end ;
|
||
914 | |||
915 | procedure TFSimulT.ChkRationClick(Sender: TObject);
|
||
916 | begin
|
||
917 | CBRation.Visible := not ChkRation.Checked ;
|
||
918 | CBRationProfil.Visible := ChkRation.Checked ; |
||
919 | if ChkRation.Checked
|
||
920 | then
|
||
921 | if not Update |
||
922 | then
|
||
923 | begin
|
||
924 | Modified := TRUE ; |
||
925 | PSimulT.Ration[LBPortee.ItemIndex + 1] := -1 ; |
||
926 | Update := TRUE ; |
||
927 | CBRation.ItemIndex := -1 ;
|
||
928 | CBRationChange (nil) ;
|
||
929 | Update := FALSE ; |
||
930 | // LBPortee.Repaint ;
|
||
931 | end ;
|
||
932 | end;
|
||
933 | |||
934 | procedure TFSimulT.BBResSimulClick (Sender : TObject) ;
|
||
935 | begin
|
||
936 | if AffSimulT
|
||
937 | then
|
||
938 | begin
|
||
939 | FWarning := TFWarning.Create (Self) ; |
||
940 | with FWarning do |
||
941 | begin
|
||
942 | Msg := 'SimulT';
|
||
943 | ShowModal ; |
||
944 | Release ; |
||
945 | AffSimulT := FALSE ; |
||
946 | end ;
|
||
947 | end ;
|
||
948 | Modal := True; |
||
949 | New (PResSimulT) ; |
||
950 | CalcSimulT (PSimulT.Num, -1, 1, 1, 8, 0, PResSimulT) ; |
||
951 | FResSimulT := TFResSimulT.Create (Self) ; |
||
952 | FResSimulT.ShowModal ; |
||
953 | FResSimulT.Release ; |
||
954 | Dispose (PResSimulT) ; |
||
955 | Modal := False; |
||
956 | end ;
|
||
957 | |||
958 | procedure TFSimulT.BBRapSimulClick (Sender : TObject) ;
|
||
959 | begin
|
||
960 | if AffSimulT
|
||
961 | then
|
||
962 | begin
|
||
963 | FWarning := TFWarning.Create (Self) ; |
||
964 | with FWarning do |
||
965 | begin
|
||
966 | Msg := 'SimulT';
|
||
967 | ShowModal ; |
||
968 | Release ; |
||
969 | AffSimulT := FALSE ; |
||
970 | end ;
|
||
971 | end ;
|
||
972 | Modal := True; |
||
973 | New (PResSimulT) ; |
||
974 | CalcSimulT (PSimulT.Num, -1, 1, 1, 8, 0, PResSimulT) ; |
||
975 | FRapSimulT := TFRapSimulT.Create (Self) ; |
||
976 | FRapSimulT.QRRapport.PreviewModal ; |
||
977 | FRapSimulT.Release ; |
||
978 | Dispose (PResSimulT) ; |
||
979 | Modal := False; |
||
980 | end ;
|
||
981 | |||
982 | procedure TFSimulT.BBTabSimulClick (Sender : TObject) ;
|
||
983 | begin
|
||
984 | // Modal := True;
|
||
985 | // New (PResSimulT) ;
|
||
986 | // CalcSimulT (PSimulT.Num, -1, 1, 1, 8, 0, PResSimulT) ;
|
||
987 | // FTabSimulT := TFTabSimulT.Create (Self) ;
|
||
988 | // FTabSimulT.ShowModal ;
|
||
989 | // FTabSimulT.Release ;
|
||
990 | // Dispose (PResSimulT) ;
|
||
991 | // Modal := False;
|
||
992 | end ;
|
||
993 | |||
994 | procedure TFSimulT.ValidBBResSimul ;
|
||
995 | var
|
||
996 | ok : boolean ; |
||
997 | begin
|
||
998 | ok := SimulTValid (PSimulT) ; |
||
999 | // PCenter.Visible := ok ;
|
||
1000 | BBResSimul.Enabled := ok ; |
||
1001 | BBRapSimul.Enabled := ok ; |
||
1002 | BBTabSimul.Enabled := ok ; |
||
1003 | if ok then LBPorteeClick (nil) ; |
||
1004 | end ;
|
||
1005 | |||
1006 | // Comparaison
|
||
1007 | |||
1008 | procedure TFSimulT.CBCompSimul1Click (Sender : TObject) ;
|
||
1009 | begin
|
||
1010 | if CBCompSimul1.Checked
|
||
1011 | then
|
||
1012 | CBSimulComp1.Enabled := TRUE |
||
1013 | else
|
||
1014 | CBSimulComp1.Enabled := FALSE ; |
||
1015 | ValidBBCompSimul ; |
||
1016 | end ;
|
||
1017 | |||
1018 | procedure TFSimulT.CBCompSimul2Click (Sender : TObject) ;
|
||
1019 | begin
|
||
1020 | if CBCompSimul2.Checked
|
||
1021 | then
|
||
1022 | CBSimulComp2.Enabled := TRUE |
||
1023 | else
|
||
1024 | CBSimulComp2.Enabled := FALSE ; |
||
1025 | ValidBBCompSimul ; |
||
1026 | end ;
|
||
1027 | |||
1028 | procedure TFSimulT.CBCompSimul3Click (Sender : TObject) ;
|
||
1029 | begin
|
||
1030 | if CBCompSimul3.Checked
|
||
1031 | then
|
||
1032 | CBSimulComp3.Enabled := TRUE |
||
1033 | else
|
||
1034 | CBSimulComp3.Enabled := FALSE ; |
||
1035 | ValidBBCompSimul ; |
||
1036 | end ;
|
||
1037 | |||
1038 | procedure TFSimulT.CBCompSimul4Click (Sender : TObject) ;
|
||
1039 | begin
|
||
1040 | if CBCompSimul4.Checked
|
||
1041 | then
|
||
1042 | CBSimulComp4.Enabled := TRUE |
||
1043 | else
|
||
1044 | CBSimulComp4.Enabled := FALSE ; |
||
1045 | ValidBBCompSimul ; |
||
1046 | end ;
|
||
1047 | |||
1048 | procedure TFSimulT.CBCompSimul5Click (Sender : TObject) ;
|
||
1049 | begin
|
||
1050 | if CBCompSimul5.Checked
|
||
1051 | then
|
||
1052 | CBSimulComp5.Enabled := TRUE |
||
1053 | else
|
||
1054 | CBSimulComp5.Enabled := FALSE ; |
||
1055 | ValidBBCompSimul ; |
||
1056 | end ;
|
||
1057 | |||
1058 | procedure TFSimulT.CBSimulComp1Change (Sender : TObject) ;
|
||
1059 | begin
|
||
1060 | if CBSimulComp1.ItemIndex = -1 |
||
1061 | then
|
||
1062 | CBSimulComp1.Hint := ''
|
||
1063 | else
|
||
1064 | begin
|
||
1065 | PSimulT := ListSimulT[FindIdxSimulT (CBSimulComp1.Text)] ; |
||
1066 | CBSimulComp1.Hint := PSimulT.Memo ; |
||
1067 | end ;
|
||
1068 | ValidBBCompSimul ; |
||
1069 | end ;
|
||
1070 | |||
1071 | procedure TFSimulT.CBSimulComp2Change (Sender : TObject) ;
|
||
1072 | begin
|
||
1073 | if CBSimulComp2.ItemIndex = -1 |
||
1074 | then
|
||
1075 | CBSimulComp2.Hint := ''
|
||
1076 | else
|
||
1077 | begin
|
||
1078 | PSimulT := ListSimulT[FindIdxSimulT (CBSimulComp2.Text)] ; |
||
1079 | CBSimulComp2.Hint := PSimulT.Memo ; |
||
1080 | end ;
|
||
1081 | ValidBBCompSimul ; |
||
1082 | end ;
|
||
1083 | |||
1084 | procedure TFSimulT.CBSimulComp3Change (Sender : TObject) ;
|
||
1085 | begin
|
||
1086 | if CBSimulComp3.ItemIndex = -1 |
||
1087 | then
|
||
1088 | CBSimulComp3.Hint := ''
|
||
1089 | else
|
||
1090 | begin
|
||
1091 | PSimulT := ListSimulT[FindIdxSimulT (CBSimulComp3.Text)] ; |
||
1092 | CBSimulComp3.Hint := PSimulT.Memo ; |
||
1093 | end ;
|
||
1094 | ValidBBCompSimul ; |
||
1095 | end ;
|
||
1096 | |||
1097 | procedure TFSimulT.CBSimulComp4Change (Sender : TObject) ;
|
||
1098 | begin
|
||
1099 | if CBSimulComp4.ItemIndex = -1 |
||
1100 | then
|
||
1101 | CBSimulComp4.Hint := ''
|
||
1102 | else
|
||
1103 | begin
|
||
1104 | PSimulT := ListSimulT[FindIdxSimulT (CBSimulComp4.Text)] ; |
||
1105 | CBSimulComp4.Hint := PSimulT.Memo ; |
||
1106 | end ;
|
||
1107 | ValidBBCompSimul ; |
||
1108 | end ;
|
||
1109 | |||
1110 | procedure TFSimulT.CBSimulComp5Change (Sender : TObject) ;
|
||
1111 | begin
|
||
1112 | if CBSimulComp5.ItemIndex = -1 |
||
1113 | then
|
||
1114 | CBSimulComp5.Hint := ''
|
||
1115 | else
|
||
1116 | begin
|
||
1117 | PSimulT := ListSimulT[FindIdxSimulT (CBSimulComp5.Text)] ; |
||
1118 | CBSimulComp5.Hint := PSimulT.Memo ; |
||
1119 | end ;
|
||
1120 | ValidBBCompSimul ; |
||
1121 | end ;
|
||
1122 | |||
1123 | procedure TFSimulT.BBCompSimulClick (Sender : TObject) ;
|
||
1124 | var
|
||
1125 | i : integer ; |
||
1126 | begin
|
||
1127 | if AffSimulT
|
||
1128 | then
|
||
1129 | begin
|
||
1130 | FWarning := TFWarning.Create (Self) ; |
||
1131 | with FWarning do |
||
1132 | begin
|
||
1133 | Msg := 'SimulT';
|
||
1134 | ShowModal ; |
||
1135 | Release ; |
||
1136 | AffSimulT := FALSE ; |
||
1137 | end ;
|
||
1138 | end ;
|
||
1139 | Modal := True; |
||
1140 | // Simulation 1
|
||
1141 | with TabSimulT[1] do |
||
1142 | if CBCompSimul1.Checked and (CBSimulComp1.ItemIndex <> -1) |
||
1143 | then
|
||
1144 | begin
|
||
1145 | Ok := TRUE ; |
||
1146 | Simul := FindNumSimulT (CBSimulComp1.Text) ; |
||
1147 | end
|
||
1148 | else
|
||
1149 | Ok := FALSE ; |
||
1150 | // Simulation 2
|
||
1151 | with TabSimulT[2] do |
||
1152 | if CBCompSimul2.Checked and (CBSimulComp2.ItemIndex <> -1) |
||
1153 | then
|
||
1154 | begin
|
||
1155 | Ok := TRUE ; |
||
1156 | Simul := FindNumSimulT (CBSimulComp2.Text) ; |
||
1157 | end
|
||
1158 | else
|
||
1159 | Ok := FALSE ; |
||
1160 | // Simulation 3
|
||
1161 | with TabSimulT[3] do |
||
1162 | if CBCompSimul3.Checked and (CBSimulComp3.ItemIndex <> -1) |
||
1163 | then
|
||
1164 | begin
|
||
1165 | Ok := TRUE ; |
||
1166 | Simul := FindNumSimulT (CBSimulComp3.Text) ; |
||
1167 | end
|
||
1168 | else
|
||
1169 | Ok := FALSE ; |
||
1170 | // Simulation 4
|
||
1171 | with TabSimulT[4] do |
||
1172 | if CBCompSimul4.Checked and (CBSimulComp4.ItemIndex <> -1) |
||
1173 | then
|
||
1174 | begin
|
||
1175 | Ok := TRUE ; |
||
1176 | Simul := FindNumSimulT (CBSimulComp4.Text) ; |
||
1177 | end
|
||
1178 | else
|
||
1179 | Ok := FALSE ; |
||
1180 | // Simulation 5
|
||
1181 | with TabSimulT[5] do |
||
1182 | if CBCompSimul5.Checked and (CBSimulComp5.ItemIndex <> -1) |
||
1183 | then
|
||
1184 | begin
|
||
1185 | Ok := TRUE ; |
||
1186 | Simul := FindNumSimulT (CBSimulComp5.Text) ; |
||
1187 | end
|
||
1188 | else
|
||
1189 | Ok := FALSE ; |
||
1190 | // Calcul des simulations
|
||
1191 | for i := 1 to 5 do |
||
1192 | with TabSimulT[i] do |
||
1193 | if Ok
|
||
1194 | then
|
||
1195 | begin
|
||
1196 | New (Result) ; |
||
1197 | CalcSimulT (Simul, -1, 1, 1, 8, 0, Result) ; |
||
1198 | end ;
|
||
1199 | FCompSimulT := TFCompSimulT.Create (Self) ; |
||
1200 | FCompSimulT.ShowModal ; |
||
1201 | FCompSimulT.Release ; |
||
1202 | for i := 1 to 5 do |
||
1203 | with TabSimulT[i] do |
||
1204 | if Ok then Dispose (Result) ; |
||
1205 | Modal := False; |
||
1206 | end ;
|
||
1207 | |||
1208 | procedure TFSimulT.BBRapCompSimulClick(Sender: TObject);
|
||
1209 | begin
|
||
1210 | //
|
||
1211 | end;
|
||
1212 | |||
1213 | procedure TFSimulT.ValidBBCompSimul ;
|
||
1214 | begin
|
||
1215 | if (CBCompSimul1.Checked and (CBSimulComp1.ItemIndex <> -1)) |
||
1216 | or (CBCompSimul2.Checked and (CBSimulComp2.ItemIndex <> -1)) |
||
1217 | or (CBCompSimul3.Checked and (CBSimulComp3.ItemIndex <> -1)) |
||
1218 | or (CBCompSimul4.Checked and (CBSimulComp4.ItemIndex <> -1)) |
||
1219 | or (CBCompSimul5.Checked and (CBSimulComp5.ItemIndex <> -1)) |
||
1220 | then
|
||
1221 | BBCompSimul.Enabled := TRUE |
||
1222 | else
|
||
1223 | BBCompSimul.Enabled := FALSE ; |
||
1224 | BBCompSimul.Enabled := BBCompSimul.Enabled ; |
||
1225 | end ;
|
||
1226 | |||
1227 | // Sensibilit?
|
||
1228 | |||
1229 | procedure TFSimulT.CBSimulSensChange (Sender : TObject) ;
|
||
1230 | begin
|
||
1231 | if CBSimulSens.ItemIndex = -1 |
||
1232 | then
|
||
1233 | CBSimulSens.Hint := ''
|
||
1234 | else
|
||
1235 | begin
|
||
1236 | PSimulT := ListSimulT[FindIdxSimulT (CBSimulSens.Text)] ; |
||
1237 | CBSimulSens.Hint := PSimulT.Memo ; |
||
1238 | end ;
|
||
1239 | ValidBBSensSimul ; |
||
1240 | end ;
|
||
1241 | |||
1242 | procedure TFSimulT.CBVariableChange(Sender: TObject);
|
||
1243 | begin
|
||
1244 | GBEtatVar.Visible := (CBVariable.ItemIndex > 2) ;
|
||
1245 | CBStadeVar.Enabled := (CBVariable.ItemIndex <> 3) ;
|
||
1246 | if CBVariable.ItemIndex = 3 |
||
1247 | then // Temp?rature ambiante |
||
1248 | CBStadeVar.ItemIndex := 0 ; // Gestation |
||
1249 | ValidBBSensSimul ; |
||
1250 | end;
|
||
1251 | |||
1252 | procedure TFSimulT.PBPorteeVarInitChange(Sender: TObject);
|
||
1253 | begin
|
||
1254 | if (PBPorteeVarInit.AsInteger >= PBPorteeVarInit.MinValue)
|
||
1255 | and (PBPorteeVarInit.AsInteger <= PBPorteeVarInit.MaxValue)
|
||
1256 | then
|
||
1257 | if (PBPorteeVarInit.AsInteger > PBPorteeVarFin.AsInteger)
|
||
1258 | then
|
||
1259 | PBPorteeVarFin.AsInteger := PBPorteeVarInit.AsInteger ; |
||
1260 | end;
|
||
1261 | |||
1262 | procedure TFSimulT.PBPorteeVarFinChange(Sender: TObject);
|
||
1263 | begin
|
||
1264 | if (PBPorteeVarFin.AsInteger >= PBPorteeVarFin.MinValue)
|
||
1265 | and (PBPorteeVarFin.AsInteger <= PBPorteeVarFin.MaxValue)
|
||
1266 | then
|
||
1267 | if (PBPorteeVarFin.AsInteger < PBPorteeVarInit.AsInteger)
|
||
1268 | then
|
||
1269 | PBPorteeVarInit.AsInteger := PBPorteeVarFin.AsInteger ; |
||
1270 | end;
|
||
1271 | |||
1272 | procedure TFSimulT.BBSensSimulClick (Sender : TObject) ;
|
||
1273 | var
|
||
1274 | i, k : integer ; |
||
1275 | d : double ; |
||
1276 | begin
|
||
1277 | if AffSimulT
|
||
1278 | then
|
||
1279 | begin
|
||
1280 | FWarning := TFWarning.Create (Self) ; |
||
1281 | with FWarning do |
||
1282 | begin
|
||
1283 | Msg := 'SimulT';
|
||
1284 | ShowModal ; |
||
1285 | Release ; |
||
1286 | AffSimulT := FALSE ; |
||
1287 | end ;
|
||
1288 | end ;
|
||
1289 | Modal := True; |
||
1290 | i := CBVariable.ItemIndex ; |
||
1291 | d := PBVariation.AsFloat ; |
||
1292 | TabSimulT[1].Variation := (100 + d * 2) / 100 ; |
||
1293 | TabSimulT[2].Variation := (100 + d) / 100 ; |
||
1294 | TabSimulT[3].Variation := 1 ; |
||
1295 | TabSimulT[4].Variation := (100 - d) / 100 ; |
||
1296 | TabSimulT[5].Variation := (100 - d * 2) / 100 ; |
||
1297 | for k := 1 to 5 do |
||
1298 | with TabSimulT[k] do |
||
1299 | begin
|
||
1300 | Ok := TRUE ; |
||
1301 | Simul := FindNumSimulT (CBSimulSens.Text) ; |
||
1302 | // Calcul des simulations
|
||
1303 | New (Result) ; |
||
1304 | if (CBVariable.ItemIndex > 2) |
||
1305 | then
|
||
1306 | CalcSimulT (Simul, i, Variation, PBPorteeVarInit.AsInteger, PBPorteeVarFin.AsInteger, CBStadeVar.ItemIndex, Result) |
||
1307 | else
|
||
1308 | CalcSimulT (Simul, i, Variation, 1, 8, 0, Result) ; |
||
1309 | end ;
|
||
1310 | FCompSimulT := TFCompSimulT.Create (Self) ; |
||
1311 | FCompSimulT.ShowModal ; |
||
1312 | FCompSimulT.Release ; |
||
1313 | for k := 1 to 5 do |
||
1314 | Dispose (TabSimulT[k].Result) ; |
||
1315 | Modal := False; |
||
1316 | end ;
|
||
1317 | |||
1318 | procedure TFSimulT.BBRapSensSimulClick(Sender: TObject);
|
||
1319 | begin
|
||
1320 | //
|
||
1321 | end;
|
||
1322 | |||
1323 | procedure TFSimulT.ValidBBSensSimul ;
|
||
1324 | begin
|
||
1325 | BBSensSimul.Enabled := (CBSimulSens.ItemIndex <> -1) and (CBVariable.ItemIndex <> -1); |
||
1326 | BBSensSimul.Enabled := BBSensSimul.Enabled; |
||
1327 | end ;
|
||
1328 | |||
1329 | end. |