root / UnitPredictionCreate.pas @ 1
Historique | Voir | Annoter | Télécharger (18,936 ko)
1 |
unit UnitPredictionCreate;
|
---|---|
2 |
|
3 |
interface
|
4 |
|
5 |
uses
|
6 |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
7 |
Dialogs, StdCtrls, DBCtrls, Mask, JvExControls, JvExStdCtrls, JvEdit, |
8 |
JvValidateEdit, JvEnterTab, JvExMask, JvSpin, gnugettext, JvButton, JvCtrls, |
9 |
ImgList, ActnList, ExtCtrls; |
10 |
|
11 |
type
|
12 |
TFormPredictionCreate = class(TForm)
|
13 |
EnterAsTab: TJvEnterAsTab; |
14 |
LabelName: TLabel; |
15 |
EditName: TEdit; |
16 |
GroupBoxStep2: TGroupBox; |
17 |
LabelMM: TLabel; |
18 |
ValidateEditMM: TJvValidateEdit; |
19 |
ComboBoxMM: TComboBox; |
20 |
GroupBoxStep5: TGroupBox; |
21 |
LabelMAT: TLabel; |
22 |
LabelMG: TLabel; |
23 |
ValidateEditMG: TJvValidateEdit; |
24 |
ValidateEditEB: TJvValidateEdit; |
25 |
ComboBoxMG: TComboBox; |
26 |
ComboBoxEB: TComboBox; |
27 |
GroupBoxStep4: TGroupBox; |
28 |
LabelEB: TLabel; |
29 |
LabelNDF: TLabel; |
30 |
LabelADF: TLabel; |
31 |
LabeldMOv: TLabel; |
32 |
ValidateEditCB: TJvValidateEdit; |
33 |
ValidateEditNDF: TJvValidateEdit; |
34 |
ValidateEditADF: TJvValidateEdit; |
35 |
ValidateEditdMOv: TJvValidateEdit; |
36 |
ComboBoxFibre: TComboBox; |
37 |
GroupBoxStep6: TGroupBox; |
38 |
LabelCB: TLabel; |
39 |
ValidateEditAmidon: TJvValidateEdit; |
40 |
ComboBoxAmidon: TComboBox; |
41 |
GroupBoxStep7: TGroupBox; |
42 |
LabelAmidon: TLabel; |
43 |
ValidateEditSucres: TJvValidateEdit; |
44 |
ComboBoxSucres: TComboBox; |
45 |
GroupBoxStep3: TGroupBox; |
46 |
LabelSucres: TLabel; |
47 |
ValidateEditMAT: TJvValidateEdit; |
48 |
ComboBoxMAT: TComboBox; |
49 |
GroupBoxStep1: TGroupBox; |
50 |
LabelMS: TLabel; |
51 |
ValidateEditMS: TJvValidateEdit; |
52 |
ButtonNext: TButton; |
53 |
ComboBoxMS: TComboBox; |
54 |
GroupBoxBonus: TGroupBox; |
55 |
LabelCrois: TLabel; |
56 |
LabelTruie: TLabel; |
57 |
SpinEditBonusC: TJvSpinEdit; |
58 |
SpinEditBonusT: TJvSpinEdit; |
59 |
CheckBoxMM: TCheckBox; |
60 |
CheckBoxMG: TCheckBox; |
61 |
CheckBoxEB: TCheckBox; |
62 |
CheckBoxCB: TCheckBox; |
63 |
CheckBoxNDF: TCheckBox; |
64 |
CheckBoxADF: TCheckBox; |
65 |
CheckBoxdMOv: TCheckBox; |
66 |
CheckBoxAmidon: TCheckBox; |
67 |
CheckBoxSucres: TCheckBox; |
68 |
CheckBoxMAT: TCheckBox; |
69 |
ActionListButtons: TActionList; |
70 |
ActionView: TAction; |
71 |
ActionReset: TAction; |
72 |
ActionHelp: TAction; |
73 |
ActionClose: TAction; |
74 |
ImageListIcons: TImageList; |
75 |
JvImgBtnClose: TJvImgBtn; |
76 |
JvImgBtnHelp: TJvImgBtn; |
77 |
JvImgBtnReset: TJvImgBtn; |
78 |
JvImgBtnView: TJvImgBtn; |
79 |
PanelButtons: TPanel; |
80 |
procedure FormCreate(Sender: TObject);
|
81 |
procedure ButtonNextClick(Sender: TObject);
|
82 |
procedure CheckBoxMMClick(Sender: TObject);
|
83 |
procedure CheckBoxMATClick(Sender: TObject);
|
84 |
procedure CheckBoxdMOvClick(Sender: TObject);
|
85 |
procedure CheckBoxMGClick(Sender: TObject);
|
86 |
procedure CheckBoxEBClick(Sender: TObject);
|
87 |
procedure CheckBoxAmidonClick(Sender: TObject);
|
88 |
procedure CheckBoxSucresClick(Sender: TObject);
|
89 |
procedure CheckBoxCBClick(Sender: TObject);
|
90 |
procedure CheckBoxNDFClick(Sender: TObject);
|
91 |
procedure CheckBoxADFClick(Sender: TObject);
|
92 |
procedure ComboBoxMSChange(Sender: TObject);
|
93 |
procedure ComboBoxMMChange(Sender: TObject);
|
94 |
procedure ComboBoxMATChange(Sender: TObject);
|
95 |
procedure ComboBoxFibreChange(Sender: TObject);
|
96 |
procedure ComboBoxMGChange(Sender: TObject);
|
97 |
procedure ComboBoxEBChange(Sender: TObject);
|
98 |
procedure ComboBoxAmidonChange(Sender: TObject);
|
99 |
procedure ComboBoxSucresChange(Sender: TObject);
|
100 |
procedure ActionViewExecute(Sender: TObject);
|
101 |
procedure ActionResetExecute(Sender: TObject);
|
102 |
procedure ActionHelpExecute(Sender: TObject);
|
103 |
procedure ActionCloseExecute(Sender: TObject);
|
104 |
procedure NumEditKeyDown(Sender: TObject; var Key: Word; |
105 |
Shift: TShiftState); |
106 |
procedure NumEditKeyPress(Sender: TObject; var Key: Char); |
107 |
private
|
108 |
{ D?clarations priv?es }
|
109 |
procedure EditActivate(Edit: TJvValidateEdit);
|
110 |
procedure EditEmpty(Edit: TJvValidateEdit);
|
111 |
public
|
112 |
{ D?clarations publiques }
|
113 |
end;
|
114 |
|
115 |
var
|
116 |
FormPredictionCreate: TFormPredictionCreate; |
117 |
|
118 |
implementation
|
119 |
|
120 |
{$R *.dfm}
|
121 |
|
122 |
uses
|
123 |
UnitDeclaration, UnitOptions, UnitPredictionDetail; |
124 |
|
125 |
var
|
126 |
VK_Separator: boolean; |
127 |
|
128 |
procedure TFormPredictionCreate.ActionCloseExecute(Sender: TObject);
|
129 |
begin
|
130 |
ModalResult := mrClose; |
131 |
end;
|
132 |
|
133 |
procedure TFormPredictionCreate.ActionHelpExecute(Sender: TObject);
|
134 |
begin
|
135 |
Application.HelpContext(HelpContext); |
136 |
end;
|
137 |
|
138 |
procedure TFormPredictionCreate.ActionResetExecute(Sender: TObject);
|
139 |
begin
|
140 |
EditName.Enabled := True; |
141 |
ActiveControl := EditName; |
142 |
EditName.SelectAll; |
143 |
ValidateEditMS.Enabled := True; |
144 |
ValidateEditMS.AsFloat := 0;
|
145 |
ComboBoxMS.Enabled := True; |
146 |
ButtonNext.Visible := True; |
147 |
CheckBoxMM.Checked := False; |
148 |
CheckBoxMM.Enabled := False; |
149 |
ComboBoxMM.Enabled := False; |
150 |
CheckBoxMAT.Checked := False; |
151 |
CheckBoxMAT.Enabled := False; |
152 |
ComboBoxMAT.Enabled := False; |
153 |
CheckBoxCB.Checked := False; |
154 |
CheckBoxCB.Enabled := False; |
155 |
CheckBoxNDF.Checked := False; |
156 |
CheckBoxNDF.Enabled := False; |
157 |
CheckBoxADF.Checked := False; |
158 |
CheckBoxADF.Enabled := False; |
159 |
ComboBoxFibre.Enabled := False; |
160 |
CheckBoxdMOv.Checked := False; |
161 |
CheckBoxdMOv.Enabled := True; |
162 |
CheckBoxMG.Checked := False; |
163 |
CheckBoxMG.Enabled := False; |
164 |
ComboBoxMG.Enabled := False; |
165 |
CheckBoxEB.Checked := False; |
166 |
CheckBoxEB.Enabled := False; |
167 |
ComboBoxEB.Enabled := False; |
168 |
CheckBoxAmidon.Checked := False; |
169 |
CheckBoxAmidon.Enabled := False; |
170 |
ComboBoxAmidon.Enabled := False; |
171 |
CheckBoxSucres.Checked := False; |
172 |
CheckBoxSucres.Enabled := False; |
173 |
ComboBoxSucres.Enabled := False; |
174 |
SpinEditBonusC.Enabled := False; |
175 |
SpinEditBonusT.Enabled := False; |
176 |
JvImgBtnView.Enabled := False; |
177 |
JvImgBtnReset.Enabled := False; |
178 |
end;
|
179 |
|
180 |
procedure TFormPredictionCreate.ActionViewExecute(Sender: TObject);
|
181 |
var
|
182 |
Nb: Integer; |
183 |
MM, MAT, MG, Fibre, Amidon, Sucres, CB, NDF, ADF: Double; |
184 |
begin
|
185 |
{
|
186 |
if not CheckBoxMM.Checked
|
187 |
then
|
188 |
begin
|
189 |
MessageDlg(_('You must specify an ash value for this diet.'), mtError, [mbOK], 0);
|
190 |
ActiveControl := CheckBoxMM;
|
191 |
Exit;
|
192 |
end;
|
193 |
if not CheckBoxMAT.Checked
|
194 |
then
|
195 |
begin
|
196 |
MessageDlg(_('You must specify a crude protein value for this diet.'), mtError, [mbOK], 0);
|
197 |
ActiveControl := CheckBoxMAT;
|
198 |
Exit;
|
199 |
end;
|
200 |
if not CheckBoxCB.Checked and not CheckBoxNDF.Checked and not CheckBoxADF.Checked and not CheckBoxdMOv.Checked
|
201 |
then
|
202 |
begin
|
203 |
MessageDlg(_('You must specify a fiber value (crude fiber, NDF or ADF) or in vitro digestibility of organic matter for this diet.'), mtError, [mbOK], 0);
|
204 |
ActiveControl := CheckBoxCB;
|
205 |
Exit;
|
206 |
end;
|
207 |
if not CheckBoxMG.Checked and not CheckBoxEB.Checked
|
208 |
then
|
209 |
begin
|
210 |
MessageDlg(_('You must specify a crude fat value or a gross energy value for this diet.'), mtError, [mbOK], 0);
|
211 |
ActiveControl := CheckBoxMG;
|
212 |
Exit;
|
213 |
end;
|
214 |
}
|
215 |
if CheckBoxMM.Checked
|
216 |
then
|
217 |
with DataModuleDeclaration do |
218 |
MM := InputProximal(ValidateEditMM.AsFloat, RapMS, ComboBoxMM.ItemIndex div 2, ComboBoxMM.ItemIndex mod 2) |
219 |
else
|
220 |
MM := 0;
|
221 |
if CheckBoxMAT.Checked
|
222 |
then
|
223 |
with DataModuleDeclaration do |
224 |
MAT := InputProximal(ValidateEditMAT.AsFloat, RapMS, ComboBoxMAT.ItemIndex div 2, ComboBoxMAT.ItemIndex mod 2) |
225 |
else
|
226 |
MAT := 0;
|
227 |
if CheckBoxMG.Checked
|
228 |
then
|
229 |
with DataModuleDeclaration do |
230 |
MG := InputProximal(ValidateEditMG.AsFloat, RapMS, ComboBoxMG.ItemIndex div 2, ComboBoxMG.ItemIndex mod 2) |
231 |
else
|
232 |
MG := 0;
|
233 |
Nb := 0;
|
234 |
if CheckBoxCB.Checked
|
235 |
then
|
236 |
begin
|
237 |
with DataModuleDeclaration do |
238 |
CB := InputProximal(ValidateEditCB.AsFloat, RapMS, ComboBoxFibre.ItemIndex div 2, ComboBoxFibre.ItemIndex mod 2); |
239 |
Inc(Nb); |
240 |
end
|
241 |
else
|
242 |
CB := 0;
|
243 |
if CheckBoxNDF.Checked
|
244 |
then
|
245 |
begin
|
246 |
with DataModuleDeclaration do |
247 |
NDF := InputProximal(ValidateEditNDF.AsFloat, RapMS, ComboBoxFibre.ItemIndex div 2, ComboBoxFibre.ItemIndex mod 2); |
248 |
Inc(Nb); |
249 |
end
|
250 |
else
|
251 |
NDF := 0;
|
252 |
if CheckBoxADF.Checked
|
253 |
then
|
254 |
begin
|
255 |
with DataModuleDeclaration do |
256 |
ADF := InputProximal(ValidateEditADF.AsFloat, RapMS, ComboBoxFibre.ItemIndex div 2, ComboBoxFibre.ItemIndex mod 2); |
257 |
Inc(Nb); |
258 |
end
|
259 |
else
|
260 |
ADF := 0;
|
261 |
if Nb = 0 |
262 |
then
|
263 |
Fibre := 0
|
264 |
else // Moyenne des ?quations significatives |
265 |
Fibre := (CB * NDF_CB + NDF + ADF * NDF_ADF) / Nb; |
266 |
if CheckBoxAmidon.Checked
|
267 |
then
|
268 |
with DataModuleDeclaration do |
269 |
Amidon := InputProximal(ValidateEditAmidon.AsFloat, RapMS, ComboBoxAmidon.ItemIndex div 2, ComboBoxAmidon.ItemIndex mod 2) |
270 |
else
|
271 |
Amidon := 0;
|
272 |
if CheckBoxSucres.Checked
|
273 |
then
|
274 |
with DataModuleDeclaration do |
275 |
Sucres := InputProximal(ValidateEditSucres.AsFloat, RapMS, ComboBoxSucres.ItemIndex div 2, ComboBoxSucres.ItemIndex mod 2) |
276 |
else
|
277 |
Sucres := 0;
|
278 |
if MM + MAT + MG + Fibre + Amidon + Sucres > 1.05 |
279 |
then
|
280 |
if MessageDlg(_('The sum of nutrients is estimated to more than 100% of the dry matter.' + sLineBreak + 'Are you sure you want to continue?'), mtError, [mbYes, mbNo], 0) <> mrYes |
281 |
then
|
282 |
Exit; |
283 |
FormPredictionDetail := TFormPredictionDetail.Create(nil);
|
284 |
try
|
285 |
FormPredictionDetail.ShowModal; |
286 |
finally
|
287 |
FormPredictionDetail.Release; |
288 |
end;
|
289 |
end;
|
290 |
|
291 |
procedure TFormPredictionCreate.ButtonNextClick(Sender: TObject);
|
292 |
begin
|
293 |
if Trim(EditName.Text) = '' |
294 |
then
|
295 |
begin
|
296 |
MessageDlg(_('You must specify a name for this diet.'), mtError, [mbOK], 0); |
297 |
ActiveControl := EditName; |
298 |
Exit; |
299 |
end;
|
300 |
if ValidateEditMS.AsFloat = 0 |
301 |
then
|
302 |
begin
|
303 |
MessageDlg(_('You must specify a dry matter value for this diet.'), mtError, [mbOK], 0); |
304 |
ActiveControl := ValidateEditMS; |
305 |
Exit; |
306 |
end;
|
307 |
CheckBoxMM.Enabled := True; |
308 |
ActiveControl := CheckBoxMM; |
309 |
ComboBoxMM.Enabled := True; |
310 |
CheckBoxMAT.Enabled := True; |
311 |
ComboBoxMAT.Enabled := True; |
312 |
CheckBoxCB.Enabled := True; |
313 |
CheckBoxNDF.Enabled := True; |
314 |
CheckBoxADF.Enabled := True; |
315 |
ComboBoxFibre.Enabled := True; |
316 |
CheckBoxdMOv.Enabled := True; |
317 |
CheckBoxMG.Enabled := True; |
318 |
ComboBoxMG.Enabled := True; |
319 |
CheckBoxEB.Enabled := True; |
320 |
ComboBoxEB.Enabled := True; |
321 |
CheckBoxAmidon.Enabled := True; |
322 |
ComboBoxAmidon.Enabled := True; |
323 |
CheckBoxSucres.Enabled := True; |
324 |
ComboBoxSucres.Enabled := True; |
325 |
SpinEditBonusC.Enabled := True; |
326 |
SpinEditBonusT.Enabled := True; |
327 |
JvImgBtnView.Enabled := True; |
328 |
JvImgBtnReset.Enabled := True; |
329 |
EditName.Enabled := False; |
330 |
ValidateEditMS.Enabled := False; |
331 |
ComboBoxMS.Enabled := False; |
332 |
ButtonNext.Visible := False; |
333 |
end;
|
334 |
|
335 |
procedure TFormPredictionCreate.CheckBoxADFClick(Sender: TObject);
|
336 |
begin
|
337 |
if CheckBoxADF.Checked
|
338 |
then // Activer la saisie |
339 |
EditActivate(ValidateEditADF) |
340 |
else // Valeur inconnue |
341 |
EditEmpty(ValidateEditADF); |
342 |
ComboBoxFibreChange(nil);
|
343 |
end;
|
344 |
|
345 |
procedure TFormPredictionCreate.CheckBoxAmidonClick(Sender: TObject);
|
346 |
begin
|
347 |
if CheckBoxAmidon.Checked
|
348 |
then // Activer la saisie |
349 |
EditActivate(ValidateEditAmidon) |
350 |
else // Valeur inconnue |
351 |
EditEmpty(ValidateEditAmidon); |
352 |
ComboBoxAmidonChange(nil);
|
353 |
end;
|
354 |
|
355 |
procedure TFormPredictionCreate.CheckBoxCBClick(Sender: TObject);
|
356 |
begin
|
357 |
if CheckBoxCB.Checked
|
358 |
then // Activer la saisie |
359 |
EditActivate(ValidateEditCB) |
360 |
else // Valeur inconnue |
361 |
EditEmpty(ValidateEditCB); |
362 |
ComboBoxFibreChange(nil);
|
363 |
end;
|
364 |
|
365 |
procedure TFormPredictionCreate.CheckBoxdMOvClick(Sender: TObject);
|
366 |
begin
|
367 |
if CheckBoxdMOv.Checked
|
368 |
then // Activer la saisie |
369 |
EditActivate(ValidateEditdMOv) |
370 |
else // Valeur inconnue |
371 |
EditEmpty(ValidateEditdMOv); |
372 |
ValidateEditdMOv.DecimalPlaces := 1;
|
373 |
end;
|
374 |
|
375 |
procedure TFormPredictionCreate.CheckBoxEBClick(Sender: TObject);
|
376 |
begin
|
377 |
if CheckBoxEB.Checked
|
378 |
then // Activer la saisie |
379 |
EditActivate(ValidateEditEB) |
380 |
else // Valeur inconnue |
381 |
EditEmpty(ValidateEditEB); |
382 |
ComboBoxEBChange(nil);
|
383 |
end;
|
384 |
|
385 |
procedure TFormPredictionCreate.CheckBoxMATClick(Sender: TObject);
|
386 |
begin
|
387 |
if CheckBoxMAT.Checked
|
388 |
then // Activer la saisie |
389 |
EditActivate(ValidateEditMAT) |
390 |
else // Valeur inconnue |
391 |
EditEmpty(ValidateEditMAT); |
392 |
ComboBoxMATChange(nil);
|
393 |
end;
|
394 |
|
395 |
procedure TFormPredictionCreate.CheckBoxMGClick(Sender: TObject);
|
396 |
begin
|
397 |
if CheckBoxMG.Checked
|
398 |
then // Activer la saisie |
399 |
EditActivate(ValidateEditMG) |
400 |
else // Valeur inconnue |
401 |
EditEmpty(ValidateEditMG); |
402 |
ComboBoxMGChange(nil);
|
403 |
end;
|
404 |
|
405 |
procedure TFormPredictionCreate.CheckBoxMMClick(Sender: TObject);
|
406 |
begin
|
407 |
if CheckBoxMM.Checked
|
408 |
then // Activer la saisie |
409 |
EditActivate(ValidateEditMM) |
410 |
else // Valeur inconnue |
411 |
EditEmpty(ValidateEditMM); |
412 |
ComboBoxMMChange(nil);
|
413 |
end;
|
414 |
|
415 |
procedure TFormPredictionCreate.CheckBoxNDFClick(Sender: TObject);
|
416 |
begin
|
417 |
if CheckBoxNDF.Checked
|
418 |
then // Activer la saisie |
419 |
EditActivate(ValidateEditNDF) |
420 |
else // Valeur inconnue |
421 |
EditEmpty(ValidateEditNDF); |
422 |
ComboBoxFibreChange(nil);
|
423 |
end;
|
424 |
|
425 |
procedure TFormPredictionCreate.CheckBoxSucresClick(Sender: TObject);
|
426 |
begin
|
427 |
if CheckBoxSucres.Checked
|
428 |
then // Activer la saisie |
429 |
EditActivate(ValidateEditSucres) |
430 |
else // Valeur inconnue |
431 |
EditEmpty(ValidateEditSucres); |
432 |
ComboBoxSucresChange(nil);
|
433 |
end;
|
434 |
|
435 |
procedure TFormPredictionCreate.ComboBoxAmidonChange(Sender: TObject);
|
436 |
begin
|
437 |
if ComboBoxAmidon.ItemIndex mod 2 = 0 |
438 |
then // % |
439 |
begin
|
440 |
ValidateEditAmidon.DecimalPlaces := 2;
|
441 |
ValidateEditAmidon.MaxValue := 100;
|
442 |
end
|
443 |
else // g/kg |
444 |
begin
|
445 |
ValidateEditAmidon.DecimalPlaces := 1;
|
446 |
ValidateEditAmidon.MaxValue := 1000;
|
447 |
end;
|
448 |
end;
|
449 |
|
450 |
procedure TFormPredictionCreate.ComboBoxEBChange(Sender: TObject);
|
451 |
begin
|
452 |
if ComboBoxEB.ItemIndex mod 2 = 0 |
453 |
then // MJ/kg |
454 |
ValidateEditEB.DecimalPlaces := 2
|
455 |
else // kcal/kg |
456 |
ValidateEditEB.DecimalPlaces := 0;
|
457 |
end;
|
458 |
|
459 |
procedure TFormPredictionCreate.ComboBoxFibreChange(Sender: TObject);
|
460 |
begin
|
461 |
if ComboBoxFibre.ItemIndex mod 2 = 0 |
462 |
then // % |
463 |
begin
|
464 |
ValidateEditCB.DecimalPlaces := 2;
|
465 |
ValidateEditNDF.DecimalPlaces := 2;
|
466 |
ValidateEditADF.DecimalPlaces := 2;
|
467 |
ValidateEditCB.MaxValue := 100;
|
468 |
ValidateEditNDF.MaxValue := 100;
|
469 |
ValidateEditADF.MaxValue := 100;
|
470 |
end
|
471 |
else // g/kg |
472 |
begin
|
473 |
ValidateEditCB.DecimalPlaces := 1;
|
474 |
ValidateEditNDF.DecimalPlaces := 1;
|
475 |
ValidateEditADF.DecimalPlaces := 1;
|
476 |
ValidateEditCB.MaxValue := 1000;
|
477 |
ValidateEditNDF.MaxValue := 1000;
|
478 |
ValidateEditADF.MaxValue := 1000;
|
479 |
end;
|
480 |
end;
|
481 |
|
482 |
procedure TFormPredictionCreate.ComboBoxMATChange(Sender: TObject);
|
483 |
begin
|
484 |
if ComboBoxMAT.ItemIndex mod 2 = 0 |
485 |
then // % |
486 |
begin
|
487 |
ValidateEditMAT.DecimalPlaces := 2;
|
488 |
ValidateEditMAT.MaxValue := 100;
|
489 |
end
|
490 |
else // g/kg |
491 |
begin
|
492 |
ValidateEditMAT.DecimalPlaces := 1;
|
493 |
ValidateEditMAT.MaxValue := 1000;
|
494 |
end;
|
495 |
end;
|
496 |
|
497 |
procedure TFormPredictionCreate.ComboBoxMGChange(Sender: TObject);
|
498 |
begin
|
499 |
if ComboBoxMG.ItemIndex mod 2 = 0 |
500 |
then // % |
501 |
begin
|
502 |
ValidateEditMG.DecimalPlaces := 2;
|
503 |
ValidateEditMG.MaxValue := 100;
|
504 |
end
|
505 |
else // g/kg |
506 |
begin
|
507 |
ValidateEditMG.DecimalPlaces := 1;
|
508 |
ValidateEditMG.MaxValue := 1000;
|
509 |
end;
|
510 |
end;
|
511 |
|
512 |
procedure TFormPredictionCreate.ComboBoxMMChange(Sender: TObject);
|
513 |
begin
|
514 |
if ComboBoxMM.ItemIndex mod 2 = 0 |
515 |
then // % |
516 |
begin
|
517 |
ValidateEditMM.DecimalPlaces := 2;
|
518 |
ValidateEditMM.MaxValue := 100;
|
519 |
end
|
520 |
else // g/kg |
521 |
begin
|
522 |
ValidateEditMM.DecimalPlaces := 1;
|
523 |
ValidateEditMM.MaxValue := 1000;
|
524 |
end;
|
525 |
end;
|
526 |
|
527 |
procedure TFormPredictionCreate.ComboBoxMSChange(Sender: TObject);
|
528 |
begin
|
529 |
if ComboBoxMS.ItemIndex = 0 |
530 |
then // % |
531 |
begin
|
532 |
ValidateEditMS.DecimalPlaces := 2;
|
533 |
ValidateEditMS.MaxValue := 100;
|
534 |
end
|
535 |
else // g/kg |
536 |
begin
|
537 |
ValidateEditMS.DecimalPlaces := 1;
|
538 |
ValidateEditMS.MaxValue := 1000;
|
539 |
end;
|
540 |
end;
|
541 |
|
542 |
procedure TFormPredictionCreate.ComboBoxSucresChange(Sender: TObject);
|
543 |
begin
|
544 |
if ComboBoxSucres.ItemIndex mod 2 = 0 |
545 |
then // % |
546 |
begin
|
547 |
ValidateEditSucres.DecimalPlaces := 2;
|
548 |
ValidateEditSucres.MaxValue := 100;
|
549 |
end
|
550 |
else // g/kg |
551 |
begin
|
552 |
ValidateEditSucres.DecimalPlaces := 1;
|
553 |
ValidateEditSucres.MaxValue := 1000;
|
554 |
end;
|
555 |
end;
|
556 |
|
557 |
procedure TFormPredictionCreate.EditActivate(Edit: TJvValidateEdit);
|
558 |
begin
|
559 |
Edit.DisplayFormat := dfFloat; |
560 |
Edit.Enabled := True; |
561 |
ActiveControl := Edit; |
562 |
end;
|
563 |
|
564 |
procedure TFormPredictionCreate.EditEmpty(Edit: TJvValidateEdit);
|
565 |
begin
|
566 |
Edit.DisplayFormat := dfNone; |
567 |
Edit.Value := '';
|
568 |
Edit.Enabled := False; |
569 |
end;
|
570 |
|
571 |
procedure TFormPredictionCreate.FormCreate(Sender: TObject);
|
572 |
var
|
573 |
i: Integer; |
574 |
begin
|
575 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
576 |
then
|
577 |
Font.Name := 'Arial Unicode MS';
|
578 |
// PanelButtons.Font.Size := PanelButtons.Font.Size + 2;
|
579 |
PanelButtons.Font.Style := [fsBold]; |
580 |
LabelName.Font.Style := [fsBold]; |
581 |
EditName.Font.Style := [fsBold]; |
582 |
TranslateComponent(Self); |
583 |
ComboBoxMS.ItemIndex := FormOptions.Proximal; |
584 |
ComboBoxMSChange(nil);
|
585 |
for i := 0 to FormOptions.ComboBoxProximal.Items.Count - 1 do |
586 |
ComboBoxMM.Items.Add(Format('%s %s', [FormOptions.ComboBoxProximal.Items[i], _('DM')])); |
587 |
ComboBoxMM.ItemIndex := FormOptions.Proximal + 2 * FormOptions.Expression;
|
588 |
ComboBoxMMChange(nil);
|
589 |
for i := 0 to FormOptions.ComboBoxProximal.Items.Count - 1 do |
590 |
ComboBoxMAT.Items.Add(Format('%s %s', [FormOptions.ComboBoxProximal.Items[i], _('DM')])); |
591 |
ComboBoxMAT.ItemIndex := FormOptions.Proximal + 2 * FormOptions.Expression;
|
592 |
ComboBoxMATChange(nil);
|
593 |
for i := 0 to FormOptions.ComboBoxProximal.Items.Count - 1 do |
594 |
ComboBoxFibre.Items.Add(Format('%s %s', [FormOptions.ComboBoxProximal.Items[i], _('DM')])); |
595 |
ComboBoxFibre.ItemIndex := FormOptions.Proximal + 2 * FormOptions.Expression;
|
596 |
ComboBoxFibreChange(nil);
|
597 |
LabeldMOv.Caption := LabeldMOv.Caption + ' (%)';
|
598 |
for i := 0 to FormOptions.ComboBoxProximal.Items.Count - 1 do |
599 |
ComboBoxMG.Items.Add(Format('%s %s', [FormOptions.ComboBoxProximal.Items[i], _('DM')])); |
600 |
ComboBoxMG.ItemIndex := FormOptions.Proximal + 2 * FormOptions.Expression;
|
601 |
ComboBoxMGChange(nil);
|
602 |
for i := 0 to FormOptions.ComboBoxEnergy.Items.Count - 1 do |
603 |
ComboBoxEB.Items.Add(Format('%s %s', [FormOptions.ComboBoxEnergy.Items[i], _('DM')])); |
604 |
ComboBoxEB.ItemIndex := FormOptions.Energy + 2 * FormOptions.Expression;
|
605 |
ComboBoxEBChange(nil);
|
606 |
for i := 0 to FormOptions.ComboBoxProximal.Items.Count - 1 do |
607 |
ComboBoxAmidon.Items.Add(Format('%s %s', [FormOptions.ComboBoxProximal.Items[i], _('DM')])); |
608 |
ComboBoxAmidon.ItemIndex := FormOptions.Proximal + 2 * FormOptions.Expression;
|
609 |
ComboBoxAmidonChange(nil);
|
610 |
for i := 0 to FormOptions.ComboBoxProximal.Items.Count - 1 do |
611 |
ComboBoxSucres.Items.Add(Format('%s %s', [FormOptions.ComboBoxProximal.Items[i], _('DM')])); |
612 |
ComboBoxSucres.ItemIndex := FormOptions.Proximal + 2 * FormOptions.Expression;
|
613 |
ComboBoxSucresChange(nil);
|
614 |
GroupBoxBonus.Caption := GroupBoxBonus.Caption + ' (%)';
|
615 |
end;
|
616 |
|
617 |
procedure TFormPredictionCreate.NumEditKeyDown(Sender: TObject;
|
618 |
var Key: Word; Shift: TShiftState);
|
619 |
begin
|
620 |
// D?tection de l'appui sur le s?parateur d?cimal du pav? num?rique
|
621 |
VK_Separator := (Key = VK_DECIMAL); |
622 |
end;
|
623 |
|
624 |
procedure TFormPredictionCreate.NumEditKeyPress(Sender: TObject;
|
625 |
var Key: Char);
|
626 |
begin
|
627 |
if VK_Separator then |
628 |
// Renvoyer le s?parateur d?cimal des options r?gionales et linguistiques
|
629 |
Key := DecimalSeparator; |
630 |
end;
|
631 |
|
632 |
end.
|