root / UFLogeT.pas @ 5
Historique | Voir | Annoter | Télécharger (21,733 ko)
1 |
unit UFLogeT ;
|
---|---|
2 |
|
3 |
interface
|
4 |
|
5 |
uses
|
6 |
Windows, Forms, Classes, Controls, StdCtrls, Buttons, ExtCtrls, ComCtrls, |
7 |
PBNumEdit, PBSuperSpin, JvEnterTab, JvExControls, UVariables; |
8 |
|
9 |
type
|
10 |
TFLogeT = class(TForm)
|
11 |
GBLogement: TGroupBox; |
12 |
CBLoge: TComboBox; |
13 |
LBRule: TListBox; |
14 |
LNo: TLabel; |
15 |
LModeFin: TLabel; |
16 |
GBLoge: TGroupBox; |
17 |
GBRule: TGroupBox; |
18 |
SBAddRule: TSpeedButton; |
19 |
SBDelRule: TSpeedButton; |
20 |
SBAddLoge: TSpeedButton; |
21 |
SBDelLoge: TSpeedButton; |
22 |
SBRename: TSpeedButton; |
23 |
SBComment: TSpeedButton; |
24 |
GBEnd: TGroupBox; |
25 |
LUnitFin: TLabel; |
26 |
PBValFin: TPBNumEdit; |
27 |
CBModeFin: TComboBox; |
28 |
TC: TTabControl; |
29 |
LTyp: TLabel; |
30 |
CBTyp: TComboBox; |
31 |
LSol: TLabel; |
32 |
CBSol: TComboBox; |
33 |
LTemp: TLabel; |
34 |
PBTemp: TPBSuperSpin; |
35 |
GBComport: TGroupBox; |
36 |
LDebout: TLabel; |
37 |
PBAct: TPBSuperSpin; |
38 |
TBAct: TTrackBar; |
39 |
LCalme: TLabel; |
40 |
LMoyenne: TLabel; |
41 |
LActive: TLabel; |
42 |
SBReset: TSpeedButton; |
43 |
SBSave: TSpeedButton; |
44 |
SBPrint: TSpeedButton; |
45 |
PLoge: TPanel; |
46 |
GBParam: TGroupBox; |
47 |
PAct: TPanel; |
48 |
JvEnterAsTab: TJvEnterAsTab; |
49 |
procedure FormShow(Sender: TObject);
|
50 |
procedure FormClose(Sender: TObject; var Action: TCloseAction); |
51 |
procedure LBRuleDrawItem(Control: TWinControl; Index: Integer;
|
52 |
Rect: TRect; State: TOwnerDrawState); |
53 |
procedure CBLogeChange(Sender: TObject);
|
54 |
procedure SBAddLogeClick(Sender: TObject);
|
55 |
procedure SBDelLogeClick(Sender: TObject);
|
56 |
procedure SBAddRuleClick(Sender: TObject);
|
57 |
procedure SBDelRuleClick(Sender: TObject);
|
58 |
procedure LBRuleClick(Sender: TObject);
|
59 |
procedure FormActivate(Sender: TObject);
|
60 |
procedure FormDeactivate(Sender: TObject);
|
61 |
procedure SBRenameClick(Sender: TObject);
|
62 |
procedure SBCommentClick(Sender: TObject);
|
63 |
procedure PBValFinChange(Sender: TObject);
|
64 |
procedure TCChange(Sender: TObject);
|
65 |
procedure CBTypChange(Sender: TObject);
|
66 |
procedure CBSolChange(Sender: TObject);
|
67 |
procedure PBTempChange(Sender: TObject);
|
68 |
procedure PBActChange(Sender: TObject);
|
69 |
procedure TBActChange(Sender: TObject);
|
70 |
procedure SBResetClick(Sender: TObject);
|
71 |
procedure SBSaveClick(Sender: TObject);
|
72 |
procedure SBPrintClick(Sender: TObject);
|
73 |
procedure FormCreate(Sender: TObject);
|
74 |
private
|
75 |
{ D?clarations priv?es }
|
76 |
Update, Modified : boolean ; |
77 |
IdxLogeT, NbRule, NumRule : integer ; |
78 |
Rule : array[1..MAX_RULE] of RecRuleLogeT ; |
79 |
procedure Save ;
|
80 |
public
|
81 |
{ D?clarations publiques }
|
82 |
function StrModeFin (etat, regle : integer) : string ; |
83 |
end;
|
84 |
|
85 |
var
|
86 |
FLogeT: TFLogeT; |
87 |
|
88 |
implementation
|
89 |
|
90 |
uses
|
91 |
Dialogs, Graphics, SysUtils, gnugettext, UStrings, UInit, UUtil, UFindRec, |
92 |
UFComment, UFRapLogeT ; |
93 |
|
94 |
{$R *.dfm}
|
95 |
|
96 |
{ TFLogeT }
|
97 |
|
98 |
procedure TFLogeT.FormCreate(Sender: TObject);
|
99 |
begin
|
100 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
101 |
then
|
102 |
Font.Name := 'Arial Unicode MS';
|
103 |
TranslateComponent(Self); |
104 |
Constraints.MinWidth := 616 + (Width - ClientWidth);
|
105 |
Width := Constraints.MinWidth; |
106 |
Constraints.MinHeight := 516 + (Height - ClientHeight);
|
107 |
Height := Constraints.MinHeight; |
108 |
CBModeFin.ItemIndex := 0;
|
109 |
LTemp.Caption := Format('%s (%s)', [LTemp.Caption, StrDegC]);
|
110 |
end;
|
111 |
|
112 |
procedure TFLogeT.FormShow (Sender : TObject) ;
|
113 |
begin
|
114 |
Modified := FALSE ; |
115 |
StringsLogeT (CBLoge.Items, TRUE) ; |
116 |
SBAddLoge.Enabled := IsComplete or (ListLogeT.Count < 5) ; |
117 |
SBSave.Enabled := IsComplete or IsEducation ;
|
118 |
IdxLogeT := -1 ;
|
119 |
// CBLogeChange (nil) ;
|
120 |
end ;
|
121 |
|
122 |
procedure TFLogeT.FormClose (Sender : TObject ; var Action : TCloseAction) ; |
123 |
begin
|
124 |
if Modified then Save ; |
125 |
Action := caFree ; |
126 |
NumWinLogeT := -1 ;
|
127 |
end ;
|
128 |
|
129 |
procedure TFLogeT.FormActivate (Sender : TObject) ;
|
130 |
begin
|
131 |
// if IdxLogeT <> -1
|
132 |
// then
|
133 |
// PLogeT := ListLogeT[IdxLogeT] ;
|
134 |
CBLogeChange (nil) ;
|
135 |
GBParam.Enabled := IsComplete or IsEducation or IsEvaluation ; |
136 |
SBAddRule.Visible := GBParam.Enabled ; |
137 |
SBDelRule.Visible := GBParam.Enabled ; |
138 |
end ;
|
139 |
|
140 |
procedure TFLogeT.FormDeactivate (Sender : TObject) ;
|
141 |
begin
|
142 |
if Modified then Save ; |
143 |
end ;
|
144 |
|
145 |
procedure TFLogeT.Save ;
|
146 |
var
|
147 |
s : string ;
|
148 |
begin
|
149 |
Modified := FALSE ; |
150 |
if IsComplete or IsEducation |
151 |
then
|
152 |
if MessageDlg (Caption + sLineBreak + MsgSave, mtConfirmation, [mbYes, mbNo], 0) = mrYes |
153 |
then
|
154 |
begin
|
155 |
SaveLogeT ; |
156 |
if not LogeTValid (PLogeT) |
157 |
then
|
158 |
MessageDlg(Format (MsgInvalidData, [Caption, PLogeT.Nom]), mtWarning, [mbOK], 0) ;
|
159 |
end
|
160 |
else
|
161 |
begin
|
162 |
LoadLogeT ; |
163 |
s := CBLoge.Text ; |
164 |
StringsLogeT (CBLoge.Items, TRUE) ; |
165 |
if FindIdxLogeT (s) = -1 |
166 |
then
|
167 |
begin
|
168 |
IdxLogeT := -1 ;
|
169 |
CBLogeChange (nil) ;
|
170 |
end
|
171 |
else
|
172 |
CBLoge.ItemIndex := CBLoge.Items.IndexOf (s) ; |
173 |
end ;
|
174 |
end ;
|
175 |
|
176 |
procedure TFLogeT.CBLogeChange (Sender : TObject) ;
|
177 |
begin
|
178 |
if (IdxLogeT <> -1) and (CBLoge.Text <> PLogeT.Nom) |
179 |
then
|
180 |
if Modified then Save ; |
181 |
IdxLogeT := FindIdxLogeT (CBLoge.Text) ; |
182 |
if IdxLogeT = -1 |
183 |
then
|
184 |
begin
|
185 |
CBLoge.Repaint ; |
186 |
SBDelLoge.Enabled := FALSE ; |
187 |
SBRename.Enabled := FALSE ; |
188 |
SBComment.Enabled := FALSE ; |
189 |
SBSave.Enabled := FALSE ; |
190 |
SBPrint.Enabled := FALSE ; |
191 |
TC.Visible := FALSE ; |
192 |
end
|
193 |
else // Affichage de l'enregistrement |
194 |
begin
|
195 |
SBDelLoge.Enabled := TRUE ; |
196 |
SBRename.Enabled := TRUE ; |
197 |
SBComment.Enabled := TRUE ; |
198 |
SBSave.Enabled := TRUE ; |
199 |
SBPrint.Enabled := TRUE ; |
200 |
TC.Visible := TRUE ; |
201 |
PLogeT := ListLogeT[IdxLogeT] ; |
202 |
with PLogeT^ do |
203 |
CBLoge.Hint := Memo ; |
204 |
TCChange (nil) ;
|
205 |
end ;
|
206 |
end ;
|
207 |
|
208 |
procedure TFLogeT.SBAddLogeClick (Sender : TObject) ;
|
209 |
var
|
210 |
i, n, q : integer ; |
211 |
s : string ;
|
212 |
ok : boolean ; |
213 |
PBackup : PRecLogeT ; |
214 |
begin
|
215 |
if Modified then Save ; |
216 |
if IdxLogeT = -1 |
217 |
then
|
218 |
q := mrNo |
219 |
else
|
220 |
q := MessageDlg (MsgCopy, mtConfirmation, [mbYes, mbNo], 0) ;
|
221 |
// Saisie du nouveau nom
|
222 |
s := '' ;
|
223 |
repeat
|
224 |
if InputQuery (FLogeT.Caption, MsgName, s)
|
225 |
then // V?rification du nom |
226 |
begin
|
227 |
s := Trim (s) ; // Suppression des espaces au d?but et ? la fin
|
228 |
if s = '' |
229 |
then // Pas de nom |
230 |
begin
|
231 |
ok := FALSE ; |
232 |
MessageDlg (MsgNameEmpty, mtWarning, [mbOk], 0) ;
|
233 |
end
|
234 |
else
|
235 |
if Length (s) > 25 |
236 |
then // Nom trop long |
237 |
begin
|
238 |
ok := FALSE ; |
239 |
MessageDlg (Format (MsgNameTooLarge, [25]), mtWarning, [mbOk], 0) ; |
240 |
s := Copy (s, 1, 25) ; |
241 |
end
|
242 |
else
|
243 |
begin
|
244 |
ok := TRUE ; |
245 |
i := 0 ;
|
246 |
while ok and (i < ListLogeT.Count) do |
247 |
begin
|
248 |
PLogeT := ListLogeT[i] ; |
249 |
if PLogeT.Nom = s
|
250 |
then // Nom d?j? utilis? |
251 |
begin
|
252 |
ok := FALSE ; |
253 |
MessageDlg (MsgNameExists, mtWarning, [mbOk], 0) ;
|
254 |
end
|
255 |
else
|
256 |
Inc (i) ; |
257 |
end ;
|
258 |
end ;
|
259 |
end
|
260 |
else // Annulation |
261 |
begin
|
262 |
s := '' ;
|
263 |
if (IdxLogeT <> -1) |
264 |
then
|
265 |
PLogeT := ListLogeT[IdxLogeT] ; |
266 |
ok := TRUE ; |
267 |
end ;
|
268 |
until ok ;
|
269 |
if s <> '' |
270 |
then // Cr?ation du nouvel enregistrement |
271 |
begin
|
272 |
// Recherche du premier num?ro libre
|
273 |
n := 0 ;
|
274 |
repeat
|
275 |
Inc (n) ; |
276 |
ok := TRUE ; |
277 |
i := 0 ;
|
278 |
while ok and (i < ListLogeT.Count) do |
279 |
begin
|
280 |
PLogeT := ListLogeT[i] ; |
281 |
if PLogeT.Num = n
|
282 |
then
|
283 |
ok := FALSE |
284 |
else
|
285 |
Inc (i) ; |
286 |
end ;
|
287 |
until ok ;
|
288 |
New (PLogeT) ; |
289 |
with PLogeT^ do |
290 |
begin
|
291 |
Nom := s ; |
292 |
Num := n ; |
293 |
if q = mrYes
|
294 |
then
|
295 |
begin
|
296 |
PBackup := ListLogeT[IdxLogeT] ; |
297 |
Memo := PBackup.Memo ; |
298 |
NbRuleGest := PBackup.NbRuleGest ; |
299 |
RuleGest := PBackup.RuleGest ; |
300 |
NbRuleLact := PBackup.NbRuleLact ; |
301 |
RuleLact := PBackup.RuleLact ; |
302 |
NbRuleISSF := PBackup.NbRuleISSF ; |
303 |
RuleISSF := PBackup.RuleISSF ; |
304 |
end
|
305 |
else
|
306 |
begin
|
307 |
Memo := '' ;
|
308 |
NbRuleGest := 1 ;
|
309 |
for i := 1 to MAX_RULE do |
310 |
with RuleGest[i] do |
311 |
begin
|
312 |
ModeFin := -1 ;
|
313 |
ValFin := 0 ;
|
314 |
Typ := 0 ;
|
315 |
Sol := 0 ;
|
316 |
Temp := 20 ;
|
317 |
Act := 240 ;
|
318 |
end ;
|
319 |
NbRuleLact := 1 ;
|
320 |
for i := 1 to MAX_RULE do |
321 |
with RuleLact[i] do |
322 |
begin
|
323 |
ModeFin := -1 ;
|
324 |
ValFin := 0 ;
|
325 |
Typ := 0 ;
|
326 |
Sol := 0 ;
|
327 |
Temp := 20 ;
|
328 |
Act := 240 ;
|
329 |
end ;
|
330 |
NbRuleISSF := 1 ;
|
331 |
for i := 1 to MAX_RULE do |
332 |
with RuleISSF[i] do |
333 |
begin
|
334 |
ModeFin := -1 ;
|
335 |
ValFin := 0 ;
|
336 |
Typ := 0 ;
|
337 |
Sol := 0 ;
|
338 |
Temp := 20 ;
|
339 |
Act := 240 ;
|
340 |
end ;
|
341 |
end ;
|
342 |
end ;
|
343 |
ListLogeT.Add (PLogeT) ; |
344 |
CBLoge.Items.Add (PLogeT.Nom) ; |
345 |
CBLoge.ItemIndex := CBLoge.Items.IndexOf (PLogeT.Nom) ; |
346 |
CBLogeChange (nil) ;
|
347 |
Modified := TRUE ; |
348 |
SBAddLoge.Enabled := IsComplete or (ListLogeT.Count < 5) ; |
349 |
SBCommentClick (nil) ;
|
350 |
end ;
|
351 |
end ;
|
352 |
|
353 |
procedure TFLogeT.SBDelLogeClick (Sender : TObject) ;
|
354 |
begin
|
355 |
if LogeTUsed (PLogeT.Num)
|
356 |
then // Enregistrement utilis? |
357 |
MessageDlg (MsgDelErr, mtWarning, [mbOk], 0)
|
358 |
else // Suppression de l'enregistrement |
359 |
if MessageDlg (MsgDel, mtConfirmation, [mbYes, mbNo], 0) = mrYes |
360 |
then
|
361 |
begin
|
362 |
Dispose (PLogeT) ; |
363 |
ListLogeT.Delete (IdxLogeT) ; |
364 |
SaveLogeT ; // Sauvegarde !
|
365 |
Modified := FALSE ; |
366 |
CBLoge.DeleteSelected ; |
367 |
IdxLogeT := -1 ;
|
368 |
CBLoge.ItemIndex := -1 ;
|
369 |
CBLogeChange (nil) ;
|
370 |
SBAddLoge.Enabled := IsComplete or (ListLogeT.Count < 5) ; |
371 |
end ;
|
372 |
end ;
|
373 |
|
374 |
procedure TFLogeT.SBRenameClick (Sender : TObject) ;
|
375 |
var
|
376 |
i : integer ; |
377 |
s : string ;
|
378 |
ok : boolean ; |
379 |
begin
|
380 |
// Saisie du nouveau nom
|
381 |
s := CBLoge.Text ; |
382 |
repeat
|
383 |
if InputQuery (FLogeT.Caption, MsgRename, s) and (s <> CBLoge.Text) |
384 |
then // V?rification du nom |
385 |
begin
|
386 |
s := Trim (s) ; // Suppression des espaces au d?but et ? la fin
|
387 |
if s = '' |
388 |
then // Pas de nom |
389 |
begin
|
390 |
ok := FALSE ; |
391 |
MessageDlg (MsgNameEmpty, mtWarning, [mbOk], 0) ;
|
392 |
end
|
393 |
else
|
394 |
if Length (s) > 25 |
395 |
then // Nom trop long |
396 |
begin
|
397 |
ok := FALSE ; |
398 |
MessageDlg (Format (MsgNameTooLarge, [25]), mtWarning, [mbOk], 0) ; |
399 |
s := Copy (s, 1, 25) ; |
400 |
end
|
401 |
else
|
402 |
begin
|
403 |
ok := TRUE ; |
404 |
i := 0 ;
|
405 |
while ok and (i < ListLogeT.Count) do |
406 |
begin
|
407 |
PLogeT := ListLogeT[i] ; |
408 |
if PLogeT.Nom = s
|
409 |
then // Nom d?j? utilis? |
410 |
begin
|
411 |
ok := FALSE ; |
412 |
MessageDlg (MsgNameExists, mtWarning, [mbOk], 0) ;
|
413 |
end
|
414 |
else
|
415 |
Inc (i) ; |
416 |
end ;
|
417 |
end ;
|
418 |
end
|
419 |
else // Annulation |
420 |
begin
|
421 |
s := '' ;
|
422 |
ok := TRUE ; |
423 |
end ;
|
424 |
until ok ;
|
425 |
PLogeT := ListLogeT[IdxLogeT] ; |
426 |
if s <> '' |
427 |
then // Renommer l'enregistrement |
428 |
begin
|
429 |
PLogeT.Nom := s ; |
430 |
Modified := TRUE ; |
431 |
StringsLogeT (CBLoge.Items, TRUE) ; |
432 |
CBLoge.ItemIndex := CBLoge.Items.IndexOf (s) ; |
433 |
end ;
|
434 |
end ;
|
435 |
|
436 |
procedure TFLogeT.SBCommentClick (Sender : TObject) ;
|
437 |
begin
|
438 |
// Saisie du commentaire
|
439 |
FComment := TFComment.Create (Self) ; |
440 |
with FComment do |
441 |
begin
|
442 |
Memo.Text := PLogeT.Memo ; |
443 |
if ShowModal = mrOk
|
444 |
then // Commenter l'enregistrement |
445 |
begin
|
446 |
PLogeT.Memo := Memo.Text ; |
447 |
Modified := TRUE ; |
448 |
CBLoge.Hint := PLogeT.Memo ; |
449 |
end ;
|
450 |
Release ; |
451 |
end ;
|
452 |
end ;
|
453 |
|
454 |
procedure TFLogeT.SBSaveClick(Sender: TObject);
|
455 |
begin
|
456 |
SaveLogeT ; |
457 |
if not LogeTValid (PLogeT) |
458 |
then
|
459 |
MessageDlg(Format (MsgInvalidData, [Caption, PLogeT.Nom]), mtWarning, [mbOK], 0) ;
|
460 |
Modified := FALSE ; |
461 |
end;
|
462 |
|
463 |
procedure TFLogeT.SBPrintClick(Sender: TObject);
|
464 |
begin
|
465 |
FRapLogeT := TFRapLogeT.Create (Self) ; |
466 |
FRapLogeT.QRRapport.PreviewModal ; |
467 |
FRapLogeT.Release ; |
468 |
end;
|
469 |
|
470 |
procedure TFLogeT.TCChange (Sender : TObject) ;
|
471 |
var
|
472 |
i : integer ; |
473 |
begin
|
474 |
if TC.TabIndex = 1 |
475 |
then // Lactation |
476 |
GBComport.Visible := FALSE |
477 |
else
|
478 |
GBComport.Visible := TRUE ; |
479 |
case TC.TabIndex of |
480 |
0 : // Gestation |
481 |
with PLogeT^ do |
482 |
begin
|
483 |
NbRule := NbRuleGest ; |
484 |
for i := 1 to MAX_RULE do |
485 |
Rule[i] := RuleGest[i] ; |
486 |
end ;
|
487 |
1 : // Lactation |
488 |
with PLogeT^ do |
489 |
begin
|
490 |
NbRule := NbRuleLact ; |
491 |
for i := 1 to MAX_RULE do |
492 |
Rule[i] := RuleLact[i] ; |
493 |
end ;
|
494 |
2 : // I.S.S.F. |
495 |
with PLogeT^ do |
496 |
begin
|
497 |
NbRule := NbRuleISSF ; |
498 |
for i := 1 to MAX_RULE do |
499 |
Rule[i] := RuleISSF[i] ; |
500 |
end ;
|
501 |
end ;
|
502 |
LBRule.Clear ; |
503 |
with PLogeT^ do |
504 |
for i := 1 to NbRule do |
505 |
LBRule.Items.Add ('') ;
|
506 |
LBRule.ItemIndex := 0 ;
|
507 |
LBRuleClick (nil) ;
|
508 |
end ;
|
509 |
|
510 |
procedure TFLogeT.LBRuleClick (Sender : TObject) ;
|
511 |
begin
|
512 |
NumRule := LBRule.ItemIndex + 1 ;
|
513 |
if LBRule.Items.Count < MAX_RULE
|
514 |
then
|
515 |
SBAddRule.Enabled := TRUE |
516 |
else
|
517 |
SBAddRule.Enabled := FALSE ; |
518 |
if NumRule = NbRule
|
519 |
then // Fin |
520 |
SBDelRule.Enabled := FALSE |
521 |
else
|
522 |
SBDelRule.Enabled := TRUE ; |
523 |
GBEnd.Visible := SBDelRule.Enabled ; |
524 |
with Rule[NumRule] do |
525 |
begin
|
526 |
Update := TRUE ; |
527 |
PBValFin.AsInteger := ValFin ; |
528 |
CBTyp.ItemIndex := Typ ; |
529 |
CBSol.ItemIndex := Sol ; |
530 |
PBTemp.AsInteger := Temp ; |
531 |
PBAct.AsInteger := Act ; |
532 |
TBAct.Position := Act ; |
533 |
Update := FALSE ; |
534 |
end ;
|
535 |
end ;
|
536 |
|
537 |
procedure TFLogeT.LBRuleDrawItem (Control : TWinControl ; Index : Integer ;
|
538 |
Rect : TRect ; State : TOwnerDrawState) ; |
539 |
begin
|
540 |
with (Control as TListBox).Canvas do |
541 |
begin
|
542 |
// Cadre principal
|
543 |
FillRect (Rect) ; |
544 |
// Texte
|
545 |
SetTextAlign (Handle, TA_LEFT) ; |
546 |
Rect.Left := 22 ;
|
547 |
TextRect (Rect, Rect.Left, Rect.Top, StrModeFin (TC.TabIndex, Index + 1)) ;
|
548 |
Rect.Left := 0 ;
|
549 |
// Num?ro
|
550 |
SetTextAlign (Handle, TA_RIGHT) ; |
551 |
Rect.Right := 14 ;
|
552 |
TextRect (Rect, Rect.Right, Rect.Top, Format ('%d', [Index + 1])) ; |
553 |
end ;
|
554 |
end ;
|
555 |
|
556 |
procedure TFLogeT.SBAddRuleClick (Sender : TObject) ;
|
557 |
var
|
558 |
i : integer ; |
559 |
begin
|
560 |
for i := NbRule downto NumRule do |
561 |
Rule[i + 1] := Rule[i] ;
|
562 |
with Rule[NumRule] do |
563 |
begin
|
564 |
ModeFin := 0 ;
|
565 |
ValFin := 0 ;
|
566 |
end ;
|
567 |
Inc (NbRule) ; |
568 |
case TC.TabIndex of |
569 |
0 : // Gestation |
570 |
with PLogeT^ do |
571 |
begin
|
572 |
NbRuleGest := NbRule ; |
573 |
for i := 1 to MAX_RULE do |
574 |
RuleGest[i] := Rule[i] ; |
575 |
end ;
|
576 |
1 : // Lactation |
577 |
with PLogeT^ do |
578 |
begin
|
579 |
NbRuleLact := NbRule ; |
580 |
for i := 1 to MAX_RULE do |
581 |
RuleLact[i] := Rule[i] ; |
582 |
end ;
|
583 |
2 : // I.S.S.F. |
584 |
with PLogeT^ do |
585 |
begin
|
586 |
NbRuleISSF := NbRule ; |
587 |
for i := 1 to MAX_RULE do |
588 |
RuleISSF[i] := Rule[i] ; |
589 |
end ;
|
590 |
end ;
|
591 |
LBRule.Items.Add ('') ;
|
592 |
LBRule.ItemIndex := NumRule - 1 ;
|
593 |
LBRuleClick (nil) ;
|
594 |
Modified := TRUE ; |
595 |
ActiveControl := PBValFin ; |
596 |
end ;
|
597 |
|
598 |
procedure TFLogeT.SBDelRuleClick (Sender : TObject) ;
|
599 |
var
|
600 |
i : integer ; |
601 |
begin
|
602 |
Dec (NbRule) ; |
603 |
for i := NumRule to NbRule do |
604 |
Rule[i] := Rule[i + 1] ;
|
605 |
case TC.TabIndex of |
606 |
0 : // Gestation |
607 |
with PLogeT^ do |
608 |
begin
|
609 |
NbRuleGest := NbRule ; |
610 |
for i := 1 to MAX_RULE do |
611 |
RuleGest[i] := Rule[i] ; |
612 |
end ;
|
613 |
1 : // Lactation |
614 |
with PLogeT^ do |
615 |
begin
|
616 |
NbRuleLact := NbRule ; |
617 |
for i := 1 to MAX_RULE do |
618 |
RuleLact[i] := Rule[i] ; |
619 |
end ;
|
620 |
2 : // I.S.S.F. |
621 |
with PLogeT^ do |
622 |
begin
|
623 |
NbRuleISSF := NbRule ; |
624 |
for i := 1 to MAX_RULE do |
625 |
RuleISSF[i] := Rule[i] ; |
626 |
end ;
|
627 |
end ;
|
628 |
i := NumRule ; // Position courante
|
629 |
LBRule.DeleteSelected ; |
630 |
LBRule.ItemIndex := i - 1 ;
|
631 |
LBRuleClick (nil) ;
|
632 |
ActiveControl := LBRule ; |
633 |
Modified := TRUE ; |
634 |
end ;
|
635 |
|
636 |
procedure TFLogeT.PBValFinChange (Sender : TObject) ;
|
637 |
begin
|
638 |
if not Update |
639 |
then
|
640 |
begin
|
641 |
Modified := TRUE ; |
642 |
Rule[NumRule].ValFin := PBValFin.AsInteger ; |
643 |
case TC.TabIndex of |
644 |
0 : // Gestation |
645 |
with PLogeT^ do |
646 |
begin
|
647 |
NbRuleGest := NbRule ; |
648 |
RuleGest[NumRule] := Rule[NumRule] ; |
649 |
end ;
|
650 |
1 : // Lactation |
651 |
with PLogeT^ do |
652 |
begin
|
653 |
NbRuleLact := NbRule ; |
654 |
RuleLact[NumRule] := Rule[NumRule] ; |
655 |
end ;
|
656 |
2 : // I.S.S.F. |
657 |
with PLogeT^ do |
658 |
begin
|
659 |
NbRuleISSF := NbRule ; |
660 |
RuleISSF[NumRule] := Rule[NumRule] ; |
661 |
end ;
|
662 |
end ;
|
663 |
LBRule.Repaint ; |
664 |
end ;
|
665 |
end ;
|
666 |
|
667 |
procedure TFLogeT.CBTypChange (Sender : TObject) ;
|
668 |
begin
|
669 |
if not Update |
670 |
then
|
671 |
begin
|
672 |
Modified := TRUE ; |
673 |
Rule[NumRule].Typ := CBTyp.ItemIndex ; |
674 |
case TC.TabIndex of |
675 |
0 : // Gestation |
676 |
with PLogeT^ do |
677 |
begin
|
678 |
NbRuleGest := NbRule ; |
679 |
RuleGest[NumRule] := Rule[NumRule] ; |
680 |
end ;
|
681 |
1 : // Lactation |
682 |
with PLogeT^ do |
683 |
begin
|
684 |
NbRuleLact := NbRule ; |
685 |
RuleLact[NumRule] := Rule[NumRule] ; |
686 |
end ;
|
687 |
2 : // I.S.S.F. |
688 |
with PLogeT^ do |
689 |
begin
|
690 |
NbRuleISSF := NbRule ; |
691 |
RuleISSF[NumRule] := Rule[NumRule] ; |
692 |
end ;
|
693 |
end ;
|
694 |
// LBRule.Repaint ;
|
695 |
Update := TRUE ; |
696 |
if CBTyp.ItemIndex = 2 |
697 |
then // Plein-air |
698 |
begin
|
699 |
CBSol.ItemIndex := -1 ;
|
700 |
CBSol.Enabled := FALSE ; |
701 |
end
|
702 |
else
|
703 |
begin
|
704 |
CBSol.ItemIndex := Rule[NumRule].Sol ; |
705 |
CBSol.Enabled := TRUE ; |
706 |
end ;
|
707 |
Update := FALSE ; |
708 |
end ;
|
709 |
end ;
|
710 |
|
711 |
procedure TFLogeT.CBSolChange (Sender : TObject) ;
|
712 |
begin
|
713 |
if not Update |
714 |
then
|
715 |
begin
|
716 |
Modified := TRUE ; |
717 |
Rule[NumRule].Sol := CBSol.ItemIndex ; |
718 |
case TC.TabIndex of |
719 |
0 : // Gestation |
720 |
with PLogeT^ do |
721 |
begin
|
722 |
NbRuleGest := NbRule ; |
723 |
RuleGest[NumRule] := Rule[NumRule] ; |
724 |
end ;
|
725 |
1 : // Lactation |
726 |
with PLogeT^ do |
727 |
begin
|
728 |
NbRuleLact := NbRule ; |
729 |
RuleLact[NumRule] := Rule[NumRule] ; |
730 |
end ;
|
731 |
2 : // I.S.S.F. |
732 |
with PLogeT^ do |
733 |
begin
|
734 |
NbRuleISSF := NbRule ; |
735 |
RuleISSF[NumRule] := Rule[NumRule] ; |
736 |
end ;
|
737 |
end ;
|
738 |
// LBRule.Repaint ;
|
739 |
end ;
|
740 |
end ;
|
741 |
|
742 |
procedure TFLogeT.PBTempChange (Sender : TObject) ;
|
743 |
begin
|
744 |
if not Update |
745 |
then
|
746 |
begin
|
747 |
Modified := TRUE ; |
748 |
Rule[NumRule].Temp := PBTemp.AsInteger ; |
749 |
case TC.TabIndex of |
750 |
0 : // Gestation |
751 |
with PLogeT^ do |
752 |
begin
|
753 |
NbRuleGest := NbRule ; |
754 |
RuleGest[NumRule] := Rule[NumRule] ; |
755 |
end ;
|
756 |
1 : // Lactation |
757 |
with PLogeT^ do |
758 |
begin
|
759 |
NbRuleLact := NbRule ; |
760 |
RuleLact[NumRule] := Rule[NumRule] ; |
761 |
end ;
|
762 |
2 : // I.S.S.F. |
763 |
with PLogeT^ do |
764 |
begin
|
765 |
NbRuleISSF := NbRule ; |
766 |
RuleISSF[NumRule] := Rule[NumRule] ; |
767 |
end ;
|
768 |
end ;
|
769 |
// LBRule.Repaint ;
|
770 |
end ;
|
771 |
end ;
|
772 |
|
773 |
procedure TFLogeT.PBActChange (Sender : TObject) ;
|
774 |
begin
|
775 |
if not Update |
776 |
then
|
777 |
begin
|
778 |
Modified := TRUE ; |
779 |
Rule[NumRule].Act := PBAct.AsInteger ; |
780 |
TBAct.Position := PBAct.AsInteger ; |
781 |
case TC.TabIndex of |
782 |
0 : // Gestation |
783 |
with PLogeT^ do |
784 |
begin
|
785 |
NbRuleGest := NbRule ; |
786 |
RuleGest[NumRule] := Rule[NumRule] ; |
787 |
end ;
|
788 |
1 : // Lactation |
789 |
with PLogeT^ do |
790 |
begin
|
791 |
NbRuleLact := NbRule ; |
792 |
RuleLact[NumRule] := Rule[NumRule] ; |
793 |
end ;
|
794 |
2 : // I.S.S.F. |
795 |
with PLogeT^ do |
796 |
begin
|
797 |
NbRuleISSF := NbRule ; |
798 |
RuleISSF[NumRule] := Rule[NumRule] ; |
799 |
end ;
|
800 |
end ;
|
801 |
// LBRule.Repaint ;
|
802 |
end ;
|
803 |
end ;
|
804 |
|
805 |
procedure TFLogeT.TBActChange (Sender : TObject) ;
|
806 |
begin
|
807 |
if not Update |
808 |
and (TBAct.Position >= TBAct.Min)
|
809 |
and (TBAct.Position <= TBAct.Max)
|
810 |
then
|
811 |
begin
|
812 |
Modified := TRUE ; |
813 |
Rule[NumRule].Act := TBAct.Position ; |
814 |
PBAct.AsInteger := TBAct.Position ; |
815 |
case TC.TabIndex of |
816 |
0 : // Gestation |
817 |
with PLogeT^ do |
818 |
begin
|
819 |
NbRuleGest := NbRule ; |
820 |
RuleGest[NumRule] := Rule[NumRule] ; |
821 |
end ;
|
822 |
1 : // Lactation |
823 |
with PLogeT^ do |
824 |
begin
|
825 |
NbRuleLact := NbRule ; |
826 |
RuleLact[NumRule] := Rule[NumRule] ; |
827 |
end ;
|
828 |
2 : // I.S.S.F. |
829 |
with PLogeT^ do |
830 |
begin
|
831 |
NbRuleISSF := NbRule ; |
832 |
RuleISSF[NumRule] := Rule[NumRule] ; |
833 |
end ;
|
834 |
end ;
|
835 |
// LBRule.Repaint ;
|
836 |
end ;
|
837 |
TBAct.SelEnd := TBAct.Position ; |
838 |
end ;
|
839 |
|
840 |
procedure TFLogeT.SBResetClick (Sender : TObject) ;
|
841 |
begin
|
842 |
PBAct.AsInteger := Round ((PBAct.MinValue + PBAct.MaxValue) / 2) ;
|
843 |
end ;
|
844 |
|
845 |
function TFLogeT.StrModeFin (etat, regle : integer) : string ; |
846 |
var
|
847 |
Nb : integer ; |
848 |
Rec : RecRuleLogeT ; |
849 |
begin
|
850 |
case etat of |
851 |
0 : // Gestation |
852 |
Nb := PLogeT.NbRuleGest ; |
853 |
1 : // Lactation |
854 |
Nb := PLogeT.NbRuleLact ; |
855 |
else // I.S.S.F. |
856 |
Nb := PLogeT.NbRuleISSF ; |
857 |
end ;
|
858 |
if regle = Nb
|
859 |
then // Fin |
860 |
case etat of |
861 |
0 : // Gestation |
862 |
result := StrMiseBas ; |
863 |
1 : // Lactation |
864 |
result := StrSevrage ; |
865 |
2 : // I.S.S.F. |
866 |
result := StrSaillie ; |
867 |
end
|
868 |
else
|
869 |
begin
|
870 |
case etat of |
871 |
0 : // Gestation |
872 |
Rec := PLogeT.RuleGest[regle] ; |
873 |
1 : // Lactation |
874 |
Rec := PLogeT.RuleLact[regle] ; |
875 |
2 : // I.S.S.F. |
876 |
Rec := PLogeT.RuleISSF[regle] ; |
877 |
end ;
|
878 |
with Rec do |
879 |
case ModeFin of |
880 |
0 : // Dur?e |
881 |
result := Format ('%s = %d %s', [CBModeFin.Items[ModeFin], ValFin, StrJ]) ;
|
882 |
else
|
883 |
result := '' ;
|
884 |
end ;
|
885 |
end ;
|
886 |
end ;
|
887 |
|
888 |
end.
|