root / UnitMain.pas @ 12
Historique | Voir | Annoter | Télécharger (41,451 ko)
1 |
unit UnitMain;
|
---|---|
2 |
|
3 |
interface
|
4 |
|
5 |
uses
|
6 |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
7 |
ShellAPI, Dialogs, XPMan, StdCtrls, ComCtrls, ExtCtrls, Buttons, DB, |
8 |
pngimage, JvExExtCtrls, JvBevel, gnugettext; |
9 |
|
10 |
type
|
11 |
TFormMain = class(TForm)
|
12 |
LabelVersion: TLabel; |
13 |
LabelMain: TLabel; |
14 |
ComboBoxLanguage: TComboBox; |
15 |
BitBtnOptions: TBitBtn; |
16 |
BitBtnIngredients: TBitBtn; |
17 |
BitBtnFeeds: TBitBtn; |
18 |
BitBtnQuit: TBitBtn; |
19 |
BitBtnHelp: TBitBtn; |
20 |
BitBtnWeb: TBitBtn; |
21 |
BitBtnUpdate: TBitBtn; |
22 |
BitBtnLegal: TBitBtn; |
23 |
BitBtnCredits: TBitBtn; |
24 |
BitBtnTutorial: TBitBtn; |
25 |
ImageWallpaper: TImage; |
26 |
XPManifestStyle: TXPManifest; |
27 |
JvBevelINRA: TJvBevel; |
28 |
JvBevelAFZ: TJvBevel; |
29 |
JvBevelAEL: TJvBevel; |
30 |
procedure FormCreate(Sender: TObject);
|
31 |
procedure ComboBoxLanguageDrawItem(Control: TWinControl; Index: Integer;
|
32 |
Rect: TRect; State: TOwnerDrawState); |
33 |
procedure ComboBoxLanguageChange(Sender: TObject);
|
34 |
procedure FormClose(Sender: TObject; var Action: TCloseAction); |
35 |
procedure BitBtnOptionsClick(Sender: TObject);
|
36 |
procedure BitBtnQuitClick(Sender: TObject);
|
37 |
procedure BitBtnIngredientsClick(Sender: TObject);
|
38 |
procedure BitBtnFeedsClick(Sender: TObject);
|
39 |
procedure BitBtnHelpClick(Sender: TObject);
|
40 |
procedure FormShow(Sender: TObject);
|
41 |
procedure BitBtnWebClick(Sender: TObject);
|
42 |
procedure BitBtnUpdateClick(Sender: TObject);
|
43 |
procedure BitBtnCreditsClick(Sender: TObject);
|
44 |
procedure BitBtnLegalClick(Sender: TObject);
|
45 |
procedure JvBevelINRAClick(Sender: TObject);
|
46 |
procedure JvBevelINRAMouseEnter(Sender: TObject);
|
47 |
procedure JvBevelINRAMouseDown(Sender: TObject; Button: TMouseButton;
|
48 |
Shift: TShiftState; X, Y: Integer); |
49 |
procedure JvBevelINRAMouseLeave(Sender: TObject);
|
50 |
procedure JvBevelINRAMouseUp(Sender: TObject; Button: TMouseButton;
|
51 |
Shift: TShiftState; X, Y: Integer); |
52 |
procedure JvBevelAFZClick(Sender: TObject);
|
53 |
procedure JvBevelAFZMouseDown(Sender: TObject; Button: TMouseButton;
|
54 |
Shift: TShiftState; X, Y: Integer); |
55 |
procedure JvBevelAFZMouseEnter(Sender: TObject);
|
56 |
procedure JvBevelAFZMouseLeave(Sender: TObject);
|
57 |
procedure JvBevelAFZMouseUp(Sender: TObject; Button: TMouseButton;
|
58 |
Shift: TShiftState; X, Y: Integer); |
59 |
procedure JvBevelAELClick(Sender: TObject);
|
60 |
procedure JvBevelAELMouseDown(Sender: TObject; Button: TMouseButton;
|
61 |
Shift: TShiftState; X, Y: Integer); |
62 |
procedure JvBevelAELMouseEnter(Sender: TObject);
|
63 |
procedure JvBevelAELMouseLeave(Sender: TObject);
|
64 |
procedure JvBevelAELMouseUp(Sender: TObject; Button: TMouseButton;
|
65 |
Shift: TShiftState; X, Y: Integer); |
66 |
procedure BitBtnTutorialClick(Sender: TObject);
|
67 |
procedure FormDestroy(Sender: TObject);
|
68 |
private
|
69 |
{ D?clarations priv?es }
|
70 |
public
|
71 |
{ D?clarations publiques }
|
72 |
procedure LoadIngredients;
|
73 |
procedure LoadComposition;
|
74 |
procedure LoadFeeds;
|
75 |
end;
|
76 |
|
77 |
var
|
78 |
FormMain: TFormMain; |
79 |
|
80 |
implementation
|
81 |
|
82 |
{$R *.dfm}
|
83 |
|
84 |
uses
|
85 |
UnitOptions, UnitDeclaration, UnitIngredientsList, UnitFeedsList; |
86 |
|
87 |
const
|
88 |
EVAPIG = 'www.evapig.com';
|
89 |
INRA = 'www.inrae.fr';
|
90 |
AFZ = 'www.zootechnie.fr';
|
91 |
AEL = 'www.ajinomoto-animalnutrition-emea.com';
|
92 |
HELP_DISCLAIMER = 5000;
|
93 |
HELP_CREDITS = 6000;
|
94 |
|
95 |
var
|
96 |
OldWndProc: Pointer; |
97 |
WndMsg: DWORD; |
98 |
|
99 |
function NewWndProc(WindowHandle: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT stdcall; |
100 |
begin
|
101 |
if Msg = WndMsg
|
102 |
then // Appel par une autre instance : restauration |
103 |
begin
|
104 |
Result := SendMessage(Application.Handle, WM_SYSCOMMAND, SC_RESTORE, 0);
|
105 |
SetForegroundWindow(Application.Handle); |
106 |
end
|
107 |
else
|
108 |
Result := CallWindowProc(OldWndProc, WindowHandle, Msg, WParam, LParam); |
109 |
end;
|
110 |
|
111 |
procedure TFormMain.BitBtnCreditsClick(Sender: TObject);
|
112 |
begin
|
113 |
Application.HelpContext(HELP_CREDITS); |
114 |
end;
|
115 |
|
116 |
procedure TFormMain.BitBtnFeedsClick(Sender: TObject);
|
117 |
begin
|
118 |
LoadFeeds; |
119 |
try
|
120 |
FormFeedsList := TFormFeedsList.Create(nil);
|
121 |
try
|
122 |
FormFeedsList.ShowModal; |
123 |
finally
|
124 |
FormFeedsList.Release; |
125 |
end;
|
126 |
finally
|
127 |
with DataModuleDeclaration do |
128 |
begin
|
129 |
ClientDataSetFeeds.Close; |
130 |
ClientDataSetFeeds.FieldDefs.Clear; // Bugs 5483 & 38984
|
131 |
end;
|
132 |
end;
|
133 |
end;
|
134 |
|
135 |
procedure TFormMain.BitBtnHelpClick(Sender: TObject);
|
136 |
begin
|
137 |
Application.HelpShowTableOfContents; |
138 |
end;
|
139 |
|
140 |
procedure TFormMain.BitBtnIngredientsClick(Sender: TObject);
|
141 |
begin
|
142 |
FormIngredientsList := TFormIngredientsList.Create(nil);
|
143 |
try
|
144 |
FormIngredientsList.ShowModal; |
145 |
finally
|
146 |
FormIngredientsList.Release; |
147 |
end;
|
148 |
end;
|
149 |
|
150 |
procedure TFormMain.BitBtnLegalClick(Sender: TObject);
|
151 |
begin
|
152 |
Application.HelpContext(HELP_DISCLAIMER); |
153 |
end;
|
154 |
|
155 |
procedure TFormMain.BitBtnOptionsClick(Sender: TObject);
|
156 |
begin
|
157 |
FormOptions.ShowModal; |
158 |
if FormOptions.OptionChanged
|
159 |
then // Recharger les mati?res premi?res en m?moire |
160 |
with DataModuleDeclaration do |
161 |
begin
|
162 |
ClientDataSetIngredients.Close; |
163 |
ClientDataSetComposition.Close; |
164 |
LoadIngredients; |
165 |
LoadComposition; |
166 |
FormOptions.OptionChanged := False; |
167 |
end;
|
168 |
end;
|
169 |
|
170 |
procedure TFormMain.BitBtnQuitClick(Sender: TObject);
|
171 |
begin
|
172 |
Close; |
173 |
end;
|
174 |
|
175 |
procedure TFormMain.BitBtnTutorialClick(Sender: TObject);
|
176 |
var
|
177 |
TutoFile: string;
|
178 |
begin
|
179 |
TutoFile := ExtractFilePath(Application.ExeName) + 'Tutorial.pps';
|
180 |
if not FileExists(TutoFile) |
181 |
then
|
182 |
MessageDlg(Format(_('%s: file not found') + sLineBreak
|
183 |
+ _('You can download this tutorial from the website'), [TutoFile]), mtError, [mbOK], 0) |
184 |
else
|
185 |
if ShellExecute(Handle, 'open', PChar(TutoFile), nil, nil, SW_SHOWNORMAL) <= 32 |
186 |
then
|
187 |
MessageDlg(Format(_('PPS file type is not supported') + sLineBreak
|
188 |
+ _('You can download for free the PowerPoint viewer from Microsoft web site'), [TutoFile]), mtError, [mbOK], 0); |
189 |
end;
|
190 |
|
191 |
procedure TFormMain.BitBtnUpdateClick(Sender: TObject);
|
192 |
begin
|
193 |
ShellExecute(Handle, 'open', PChar(Format('%s/update?version=%d.%d.%d.%d', [EVAPIG, MajorVersion, MinorVersion, ReleaseVersion, BuildVersion])), nil, nil, SW_SHOWNORMAL); |
194 |
end;
|
195 |
|
196 |
procedure TFormMain.BitBtnWebClick(Sender: TObject);
|
197 |
begin
|
198 |
ShellExecute(Handle, 'open', EVAPIG, nil, nil, SW_SHOWNORMAL); |
199 |
end;
|
200 |
|
201 |
procedure TFormMain.ComboBoxLanguageChange(Sender: TObject);
|
202 |
begin
|
203 |
if ComboBoxLanguage.Items[ComboBoxLanguage.ItemIndex] <> FormOptions.CurrentLanguage
|
204 |
then // Changement de langue |
205 |
begin
|
206 |
FormOptions.CurrentLanguage := ComboBoxLanguage.Items[ComboBoxLanguage.ItemIndex]; |
207 |
Screen.Cursor := crHourGlass; |
208 |
try
|
209 |
UseLanguage(FormOptions.CurrentLanguage); |
210 |
RetranslateComponent(Self); |
211 |
// ComboBoxLanguage.Repaint;
|
212 |
LabelVersion.Caption := Format('%s %d.%d.%d.%d', [LabelVersion.Caption, MajorVersion, MinorVersion, ReleaseVersion, BuildVersion]);
|
213 |
BitBtnHelp.Caption := Format('%s (F1)', [BitBtnHelp.Caption]);
|
214 |
BitBtnWeb.Hint := EVAPIG; |
215 |
JvBevelINRA.Hint := INRA; |
216 |
JvBevelAFZ.Hint := AFZ; |
217 |
JvBevelAEL.Hint := AEL; |
218 |
RetranslateComponent(FormOptions); |
219 |
with DataModuleDeclaration do |
220 |
begin
|
221 |
// Traduire les classes de mati?res premi?res
|
222 |
ClientDataSetClasses.First; |
223 |
while not ClientDataSetClasses.Eof do |
224 |
begin
|
225 |
ClientDataSetClasses.Edit; |
226 |
ClientDataSetClassesName.Value := dgettext('InraAfz', ClassList[ClientDataSetClassesId.Value - 1]); |
227 |
ClientDataSetClasses.Post; |
228 |
ClientDataSetClasses.Next; |
229 |
end;
|
230 |
// Traduire les mati?res premi?res
|
231 |
ClientDataSetIngredients.IndexFieldNames := '';
|
232 |
ClientDataSetIngredients.First; |
233 |
while not ClientDataSetIngredients.Eof do |
234 |
begin
|
235 |
ClientDataSetIngredients.Edit; |
236 |
if ClientDataSetIngredientsUser.Value
|
237 |
then
|
238 |
begin
|
239 |
if ClientDataSetIngredientsModel.IsNull
|
240 |
then
|
241 |
ClientDataSetIngredientsSource.Value := _('Original item')
|
242 |
else
|
243 |
begin
|
244 |
ClientDataSetInraAfz.Locate('Id', ClientDataSetIngredientsModel.Value, []);
|
245 |
ClientDataSetIngredientsSource.Value := Format(_('Copy of "%s"'), [dgettext('InraAfz', WideString(ClientDataSetInraAfzName.Value))]); |
246 |
end;
|
247 |
end
|
248 |
else
|
249 |
begin
|
250 |
ClientDataSetInraAfz.Locate('Id', ClientDataSetIngredientsId.Value, []);
|
251 |
ClientDataSetIngredientsName.Value := dgettext('InraAfz', WideString(ClientDataSetInraAfzName.Value));
|
252 |
if not ClientDataSetInraAfzComment.IsNull |
253 |
then
|
254 |
ClientDataSetIngredientsDefinition.Value := dgettext('InraAfz', WideString(ClientDataSetInraAfzComment.Value));
|
255 |
ClientDataSetIngredientsSource.Value := Format('%s (?%s)', [_('Reference tables'), ClientDataSetInraAfzSource.Value]); |
256 |
end;
|
257 |
ClientDataSetIngredients.Post; |
258 |
ClientDataSetIngredients.Next; |
259 |
end;
|
260 |
ClientDataSetIngredients.IndexFieldNames := 'Name';
|
261 |
// Traduire la composition des aliments
|
262 |
ClientDataSetComposition.First; |
263 |
while not ClientDataSetComposition.Eof do |
264 |
begin
|
265 |
if not ClientDataSetCompositionUser.Value |
266 |
then // Mati?re premi?re de r?f?rence (traduire) |
267 |
begin
|
268 |
ClientDataSetInraAfz.Locate('Id', ClientDataSetCompositionIngredient.Value, []);
|
269 |
ClientDataSetComposition.Edit; |
270 |
ClientDataSetCompositionIngredientName.Value := dgettext('InraAfz', WideString(ClientDataSetInraAfzName.Value));
|
271 |
ClientDataSetComposition.Post; |
272 |
end;
|
273 |
ClientDataSetComposition.Next; |
274 |
end;
|
275 |
end;
|
276 |
// Enregistrer la configuration
|
277 |
with FormOptions do |
278 |
begin
|
279 |
Reg.Access := KEY_WRITE; |
280 |
if Reg.OpenKey('\Software\EvaPig2020', True) |
281 |
then
|
282 |
begin
|
283 |
Reg.WriteString('Language', CurrentLanguage);
|
284 |
Reg.CloseKey; |
285 |
end;
|
286 |
end;
|
287 |
finally
|
288 |
Screen.Cursor := crDefault; |
289 |
end;
|
290 |
end;
|
291 |
end;
|
292 |
|
293 |
procedure TFormMain.ComboBoxLanguageDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
294 |
var
|
295 |
LanguageName: String;
|
296 |
begin
|
297 |
with Control as TComboBox do |
298 |
begin
|
299 |
// Conversion du code ISO en nom (d?j? traduit)
|
300 |
LanguageName := dgettext('languagecodes', Items[Index]);
|
301 |
// Cadre
|
302 |
Canvas.FillRect(Rect); |
303 |
// Texte
|
304 |
Canvas.TextOut(Rect.Left + 2, Rect.Top, LanguageName);
|
305 |
end;
|
306 |
end;
|
307 |
|
308 |
procedure TFormMain.FormClose(Sender: TObject; var Action: TCloseAction); |
309 |
begin
|
310 |
Screen.Cursor := crHourGlass; |
311 |
Application.ProcessMessages; |
312 |
with DataModuleDeclaration do |
313 |
begin
|
314 |
ClientDataSetIngredients.Close; |
315 |
ClientDataSetComposition.Close; |
316 |
end;
|
317 |
end;
|
318 |
|
319 |
procedure TFormMain.FormCreate(Sender: TObject);
|
320 |
var
|
321 |
Buffer: Pointer; |
322 |
Version: PVSFixedFileInfo; |
323 |
BufferSize, VersionSize: DWORD; |
324 |
begin
|
325 |
WndMsg := RegisterWindowMessage(PChar(Application.Title)); |
326 |
OldWndProc := Pointer(SetWindowLong(FormMain.Handle, GWL_WNDPROC, Longint(@NewWndProc))); |
327 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
328 |
then
|
329 |
Font.Name := 'Arial Unicode MS';
|
330 |
LabelVersion.Font.Style := [fsBold]; |
331 |
LabelMain.Font.Style := [fsBold]; |
332 |
BitBtnIngredients.Font.Style := [fsBold]; |
333 |
BitBtnFeeds.Font.Style := [fsBold]; |
334 |
BitBtnOptions.Font.Style := [fsBold]; |
335 |
BitBtnTutorial.Font.Style := [fsBold]; |
336 |
BitBtnHelp.Font.Style := [fsBold]; |
337 |
BitBtnWeb.Font.Style := [fsBold]; |
338 |
BitBtnQuit.Font.Style := [fsBold]; |
339 |
TranslateComponent(Self); |
340 |
// Version du programme
|
341 |
BufferSize := GetFileVersionInfoSize(PChar(Application.ExeName), BufferSize); |
342 |
if BufferSize > 0 |
343 |
then
|
344 |
begin
|
345 |
GetMem(Buffer, BufferSize); |
346 |
if GetFileVersionInfo(PChar(Application.ExeName), 0, BufferSize, Buffer) |
347 |
then
|
348 |
begin
|
349 |
VerQueryValue(Buffer, '\', Pointer(Version), VersionSize);
|
350 |
MajorVersion := Version.dwFileVersionMS shr 16; |
351 |
MinorVersion := Version.dwFileVersionMS and $FFFF; |
352 |
ReleaseVersion := Version.dwFileVersionLS shr 16; |
353 |
BuildVersion := Version.dwFileVersionLS and $FFFF; |
354 |
end;
|
355 |
FreeMem(Buffer, BufferSize); |
356 |
end;
|
357 |
// R?cup?ration de la liste de langues disponibles
|
358 |
DefaultInstance.GetListOfLanguages('default', ComboBoxLanguage.Items);
|
359 |
ComboBoxLanguage.Items.Insert(0, 'en'); // Langue par d?faut |
360 |
// Initialisation de FormOptions (lecture de la base de registre)
|
361 |
FormOptions := TFormOptions.Create(nil);
|
362 |
{
|
363 |
SetBounds(FormOptions.MainLeft, FormOptions.MainTop, FormOptions.MainWidth, FormOptions.MainHeight);
|
364 |
}
|
365 |
if (ComboBoxLanguage.Items.IndexOf(FormOptions.CurrentLanguage) = -1) and (Length(FormOptions.CurrentLanguage) = 5) |
366 |
then // Passage ? la langue g?n?rique |
367 |
FormOptions.CurrentLanguage := Copy(FormOptions.CurrentLanguage, 1, 2); |
368 |
if ComboBoxLanguage.Items.IndexOf(FormOptions.CurrentLanguage) = -1 |
369 |
then // Utilisation de la langue par d?faut |
370 |
FormOptions.CurrentLanguage := 'en';
|
371 |
if FormOptions.CurrentLanguage <> DefaultInstance.GetCurrentLanguage
|
372 |
then // Traduire |
373 |
begin
|
374 |
UseLanguage(FormOptions.CurrentLanguage); |
375 |
RetranslateComponent(Self); |
376 |
RetranslateComponent(FormOptions); |
377 |
// Traduire les classes de mati?res premi?res
|
378 |
with DataModuleDeclaration do |
379 |
begin
|
380 |
ClientDataSetClasses.First; |
381 |
while not ClientDataSetClasses.Eof do |
382 |
begin
|
383 |
ClientDataSetClasses.Edit; |
384 |
ClientDataSetClassesName.Value := dgettext('InraAfz', ClassList[ClientDataSetClassesId.Value - 1]); |
385 |
ClientDataSetClasses.Post; |
386 |
ClientDataSetClasses.Next; |
387 |
end;
|
388 |
end;
|
389 |
end;
|
390 |
// S?lection de la langue courante
|
391 |
ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOf(FormOptions.CurrentLanguage); |
392 |
end;
|
393 |
|
394 |
procedure TFormMain.FormDestroy(Sender: TObject);
|
395 |
begin
|
396 |
{
|
397 |
// M?moriser la taille et la position
|
398 |
if (Left <> FormOptions.MainLeft)
|
399 |
or (Top <> FormOptions.MainTop)
|
400 |
or (Width <> FormOptions.MainWidth)
|
401 |
or (Height <> FormOptions.MainHeight)
|
402 |
then
|
403 |
begin
|
404 |
FormOptions.Reg.Access := KEY_WRITE;
|
405 |
if FormOptions.Reg.OpenKey('\Software\EvaPig2020', True)
|
406 |
then
|
407 |
begin
|
408 |
FormOptions.Reg.WriteInteger('Left', Left);
|
409 |
FormOptions.Reg.WriteInteger('Top', Top);
|
410 |
FormOptions.Reg.WriteInteger('Width', Width);
|
411 |
FormOptions.Reg.WriteInteger('Height', Height);
|
412 |
FormOptions.Reg.CloseKey;
|
413 |
end;
|
414 |
end;
|
415 |
}
|
416 |
FormOptions.Release; |
417 |
SetWindowLong(FormMain.Handle, GWL_WNDPROC, Longint(OldWndProc)); |
418 |
Application.ProcessMessages; |
419 |
Screen.Cursor := crDefault; |
420 |
Application.ProcessMessages; |
421 |
end;
|
422 |
|
423 |
procedure TFormMain.FormShow(Sender: TObject);
|
424 |
begin
|
425 |
{
|
426 |
if Screen.Fonts.IndexOf('Arial Unicode MS') = -1
|
427 |
then // Police absente
|
428 |
MessageDlg(_('The font ''Arial Unicode MS'' is not installed in your system.') + sLineBreak
|
429 |
+ _('You may then have some difficulties to display languages other than yours.'), mtWarning, [mbOK], 0);
|
430 |
}
|
431 |
LabelVersion.Font.Color := TColor($B0A4FF);
|
432 |
LabelVersion.Caption := Format('%s %d.%d.%d.%d', [LabelVersion.Caption, MajorVersion, MinorVersion, ReleaseVersion, BuildVersion]);
|
433 |
BitBtnHelp.Caption := Format('%s (F1)', [BitBtnHelp.Caption]);
|
434 |
BitBtnWeb.Hint := EVAPIG; |
435 |
JvBevelINRA.Hint := INRA; |
436 |
JvBevelAFZ.Hint := AFZ; |
437 |
JvBevelAEL.Hint := AEL; |
438 |
// Chargement des donn?es
|
439 |
LoadIngredients; |
440 |
LoadComposition; |
441 |
end;
|
442 |
|
443 |
procedure TFormMain.JvBevelAELClick(Sender: TObject);
|
444 |
begin
|
445 |
ShellExecute(Handle, 'open', AEL, nil, nil, SW_SHOWNORMAL); |
446 |
end;
|
447 |
|
448 |
procedure TFormMain.JvBevelAELMouseDown(Sender: TObject; Button: TMouseButton;
|
449 |
Shift: TShiftState; X, Y: Integer); |
450 |
begin
|
451 |
JvBevelAEL.Outer := bvLowered; |
452 |
end;
|
453 |
|
454 |
procedure TFormMain.JvBevelAELMouseEnter(Sender: TObject);
|
455 |
begin
|
456 |
Screen.Cursor := crHandPoint; |
457 |
JvBevelAEL.Outer := bvRaised; |
458 |
end;
|
459 |
|
460 |
procedure TFormMain.JvBevelAELMouseLeave(Sender: TObject);
|
461 |
begin
|
462 |
Screen.Cursor := crDefault; |
463 |
JvBevelAEL.Outer := bvSpace; |
464 |
end;
|
465 |
|
466 |
procedure TFormMain.JvBevelAELMouseUp(Sender: TObject; Button: TMouseButton;
|
467 |
Shift: TShiftState; X, Y: Integer); |
468 |
begin
|
469 |
JvBevelAEL.Outer := bvRaised; |
470 |
end;
|
471 |
|
472 |
procedure TFormMain.JvBevelAFZClick(Sender: TObject);
|
473 |
begin
|
474 |
ShellExecute(Handle, 'open', AFZ, nil, nil, SW_SHOWNORMAL); |
475 |
end;
|
476 |
|
477 |
procedure TFormMain.JvBevelAFZMouseDown(Sender: TObject; Button: TMouseButton;
|
478 |
Shift: TShiftState; X, Y: Integer); |
479 |
begin
|
480 |
JvBevelAFZ.Outer := bvLowered; |
481 |
end;
|
482 |
|
483 |
procedure TFormMain.JvBevelAFZMouseEnter(Sender: TObject);
|
484 |
begin
|
485 |
Screen.Cursor := crHandPoint; |
486 |
JvBevelAFZ.Outer := bvRaised; |
487 |
end;
|
488 |
|
489 |
procedure TFormMain.JvBevelAFZMouseLeave(Sender: TObject);
|
490 |
begin
|
491 |
Screen.Cursor := crDefault; |
492 |
JvBevelAFZ.Outer := bvSpace; |
493 |
end;
|
494 |
|
495 |
procedure TFormMain.JvBevelAFZMouseUp(Sender: TObject; Button: TMouseButton;
|
496 |
Shift: TShiftState; X, Y: Integer); |
497 |
begin
|
498 |
JvBevelAFZ.Outer := bvRaised; |
499 |
end;
|
500 |
|
501 |
procedure TFormMain.JvBevelINRAClick(Sender: TObject);
|
502 |
begin
|
503 |
ShellExecute(Handle, 'open', INRA, nil, nil, SW_SHOWNORMAL); |
504 |
end;
|
505 |
|
506 |
procedure TFormMain.JvBevelINRAMouseDown(Sender: TObject; Button: TMouseButton;
|
507 |
Shift: TShiftState; X, Y: Integer); |
508 |
begin
|
509 |
JvBevelINRA.Outer := bvLowered; |
510 |
end;
|
511 |
|
512 |
procedure TFormMain.JvBevelINRAMouseEnter(Sender: TObject);
|
513 |
begin
|
514 |
Screen.Cursor := crHandPoint; |
515 |
JvBevelINRA.Outer := bvRaised; |
516 |
end;
|
517 |
|
518 |
procedure TFormMain.JvBevelINRAMouseLeave(Sender: TObject);
|
519 |
begin
|
520 |
Screen.Cursor := crDefault; |
521 |
JvBevelINRA.Outer := bvSpace; |
522 |
end;
|
523 |
|
524 |
procedure TFormMain.JvBevelINRAMouseUp(Sender: TObject; Button: TMouseButton;
|
525 |
Shift: TShiftState; X, Y: Integer); |
526 |
begin
|
527 |
JvBevelINRA.Outer := bvRaised; |
528 |
end;
|
529 |
|
530 |
procedure TFormMain.LoadIngredients;
|
531 |
begin
|
532 |
Screen.Cursor := crHourGlass; |
533 |
Application.ProcessMessages; |
534 |
try
|
535 |
with DataModuleDeclaration do |
536 |
begin
|
537 |
with FormOptions do |
538 |
begin
|
539 |
ClientDataSetIngredientsMS.DisplayFormat := ProximalFormat; |
540 |
ClientDataSetIngredientsMS2.DisplayFormat := ProximalFormat; |
541 |
ClientDataSetIngredientsMM.DisplayFormat := ProximalFormat; |
542 |
ClientDataSetIngredientsMAT.DisplayFormat := ProximalFormat; |
543 |
ClientDataSetIngredientsMG.DisplayFormat := ProximalFormat; |
544 |
ClientDataSetIngredientsCB.DisplayFormat := ProximalFormat; |
545 |
ClientDataSetIngredientsAmidon.DisplayFormat := ProximalFormat; |
546 |
ClientDataSetIngredientsSucres.DisplayFormat := ProximalFormat; |
547 |
ClientDataSetIngredientsNDF.DisplayFormat := ProximalFormat; |
548 |
ClientDataSetIngredientsADF.DisplayFormat := ProximalFormat; |
549 |
ClientDataSetIngredientsADL.DisplayFormat := ProximalFormat; |
550 |
ClientDataSetIngredientsEB.DisplayFormat := EnergyFormat; |
551 |
ClientDataSetIngredientsBonus.DisplayFormat := DecimalFormat(1);
|
552 |
ClientDataSetIngredientsEDc.DisplayFormat := EnergyFormat; |
553 |
ClientDataSetIngredientsEDt.DisplayFormat := EnergyFormat; |
554 |
ClientDataSetIngredientsEDt_EDc.DisplayFormat := DecimalFormat(1);
|
555 |
ClientDataSetIngredientsEMc.DisplayFormat := EnergyFormat; |
556 |
ClientDataSetIngredientsEMt.DisplayFormat := EnergyFormat; |
557 |
ClientDataSetIngredientsEMt_EMc.DisplayFormat := DecimalFormat(1);
|
558 |
ClientDataSetIngredientsENc.DisplayFormat := EnergyFormat; |
559 |
ClientDataSetIngredientsENt.DisplayFormat := EnergyFormat; |
560 |
ClientDataSetIngredientsENt_ENc.DisplayFormat := DecimalFormat(1);
|
561 |
ClientDataSetIngredientsdEc.DisplayFormat := DecimalFormat(1);
|
562 |
ClientDataSetIngredientsdEt.DisplayFormat := DecimalFormat(1);
|
563 |
ClientDataSetIngredientsEMc_EDc.DisplayFormat := DecimalFormat(1);
|
564 |
ClientDataSetIngredientsEMt_EDt.DisplayFormat := DecimalFormat(1);
|
565 |
ClientDataSetIngredientsENc_EMc.DisplayFormat := DecimalFormat(1);
|
566 |
ClientDataSetIngredientsENt_EMt.DisplayFormat := DecimalFormat(1);
|
567 |
ClientDataSetIngredientsdNc.DisplayFormat := DecimalFormat(1);
|
568 |
ClientDataSetIngredientsdNt.DisplayFormat := DecimalFormat(1);
|
569 |
ClientDataSetIngredientsLys.DisplayFormat := AAFormat; |
570 |
ClientDataSetIngredientsThr.DisplayFormat := AAFormat; |
571 |
ClientDataSetIngredientsMet.DisplayFormat := AAFormat; |
572 |
ClientDataSetIngredientsCys.DisplayFormat := AAFormat; |
573 |
ClientDataSetIngredientsMetCys.DisplayFormat := AAFormat; |
574 |
ClientDataSetIngredientsTrp.DisplayFormat := AAFormat; |
575 |
ClientDataSetIngredientsIle.DisplayFormat := AAFormat; |
576 |
ClientDataSetIngredientsVal.DisplayFormat := AAFormat; |
577 |
ClientDataSetIngredientsLeu.DisplayFormat := AAFormat; |
578 |
ClientDataSetIngredientsPhe.DisplayFormat := AAFormat; |
579 |
ClientDataSetIngredientsTyr.DisplayFormat := AAFormat; |
580 |
ClientDataSetIngredientsPheTyr.DisplayFormat := AAFormat; |
581 |
ClientDataSetIngredientsHis.DisplayFormat := AAFormat; |
582 |
ClientDataSetIngredientsArg.DisplayFormat := AAFormat; |
583 |
ClientDataSetIngredientsAla.DisplayFormat := AAFormat; |
584 |
ClientDataSetIngredientsAsp.DisplayFormat := AAFormat; |
585 |
ClientDataSetIngredientsGlu.DisplayFormat := AAFormat; |
586 |
ClientDataSetIngredientsGly.DisplayFormat := AAFormat; |
587 |
ClientDataSetIngredientsSer.DisplayFormat := AAFormat; |
588 |
ClientDataSetIngredientsPro.DisplayFormat := AAFormat; |
589 |
ClientDataSetIngredientsdLys.DisplayFormat := DecimalFormat(1);
|
590 |
ClientDataSetIngredientsdThr.DisplayFormat := DecimalFormat(1);
|
591 |
ClientDataSetIngredientsdMet.DisplayFormat := DecimalFormat(1);
|
592 |
ClientDataSetIngredientsdCys.DisplayFormat := DecimalFormat(1);
|
593 |
ClientDataSetIngredientsdMetCys.DisplayFormat := DecimalFormat(1);
|
594 |
ClientDataSetIngredientsdTrp.DisplayFormat := DecimalFormat(1);
|
595 |
ClientDataSetIngredientsdIle.DisplayFormat := DecimalFormat(1);
|
596 |
ClientDataSetIngredientsdVal.DisplayFormat := DecimalFormat(1);
|
597 |
ClientDataSetIngredientsdLeu.DisplayFormat := DecimalFormat(1);
|
598 |
ClientDataSetIngredientsdPhe.DisplayFormat := DecimalFormat(1);
|
599 |
ClientDataSetIngredientsdTyr.DisplayFormat := DecimalFormat(1);
|
600 |
ClientDataSetIngredientsdPheTyr.DisplayFormat := DecimalFormat(1);
|
601 |
ClientDataSetIngredientsdHis.DisplayFormat := DecimalFormat(1);
|
602 |
ClientDataSetIngredientsdArg.DisplayFormat := DecimalFormat(1);
|
603 |
ClientDataSetIngredientsdAla.DisplayFormat := DecimalFormat(1);
|
604 |
ClientDataSetIngredientsdAsp.DisplayFormat := DecimalFormat(1);
|
605 |
ClientDataSetIngredientsdGlu.DisplayFormat := DecimalFormat(1);
|
606 |
ClientDataSetIngredientsdGly.DisplayFormat := DecimalFormat(1);
|
607 |
ClientDataSetIngredientsdSer.DisplayFormat := DecimalFormat(1);
|
608 |
ClientDataSetIngredientsdPro.DisplayFormat := DecimalFormat(1);
|
609 |
ClientDataSetIngredientsLys_MAT.DisplayFormat := DecimalFormat(1);
|
610 |
ClientDataSetIngredientsThr_MAT.DisplayFormat := DecimalFormat(1);
|
611 |
ClientDataSetIngredientsMet_MAT.DisplayFormat := DecimalFormat(1);
|
612 |
ClientDataSetIngredientsCys_MAT.DisplayFormat := DecimalFormat(1);
|
613 |
ClientDataSetIngredientsMetCys_MAT.DisplayFormat := DecimalFormat(1);
|
614 |
ClientDataSetIngredientsTrp_MAT.DisplayFormat := DecimalFormat(1);
|
615 |
ClientDataSetIngredientsIle_MAT.DisplayFormat := DecimalFormat(1);
|
616 |
ClientDataSetIngredientsVal_MAT.DisplayFormat := DecimalFormat(1);
|
617 |
ClientDataSetIngredientsLeu_MAT.DisplayFormat := DecimalFormat(1);
|
618 |
ClientDataSetIngredientsPhe_MAT.DisplayFormat := DecimalFormat(1);
|
619 |
ClientDataSetIngredientsTyr_MAT.DisplayFormat := DecimalFormat(1);
|
620 |
ClientDataSetIngredientsPheTyr_MAT.DisplayFormat := DecimalFormat(1);
|
621 |
ClientDataSetIngredientsHis_MAT.DisplayFormat := DecimalFormat(1);
|
622 |
ClientDataSetIngredientsArg_MAT.DisplayFormat := DecimalFormat(1);
|
623 |
ClientDataSetIngredientsAla_MAT.DisplayFormat := DecimalFormat(1);
|
624 |
ClientDataSetIngredientsAsp_MAT.DisplayFormat := DecimalFormat(1);
|
625 |
ClientDataSetIngredientsGlu_MAT.DisplayFormat := DecimalFormat(1);
|
626 |
ClientDataSetIngredientsGly_MAT.DisplayFormat := DecimalFormat(1);
|
627 |
ClientDataSetIngredientsSer_MAT.DisplayFormat := DecimalFormat(1);
|
628 |
ClientDataSetIngredientsPro_MAT.DisplayFormat := DecimalFormat(1);
|
629 |
ClientDataSetIngredientsLysd.DisplayFormat := AAFormat; |
630 |
ClientDataSetIngredientsThrd.DisplayFormat := AAFormat; |
631 |
ClientDataSetIngredientsMetd.DisplayFormat := AAFormat; |
632 |
ClientDataSetIngredientsCysd.DisplayFormat := AAFormat; |
633 |
ClientDataSetIngredientsMetCysd.DisplayFormat := AAFormat; |
634 |
ClientDataSetIngredientsTrpd.DisplayFormat := AAFormat; |
635 |
ClientDataSetIngredientsIled.DisplayFormat := AAFormat; |
636 |
ClientDataSetIngredientsVald.DisplayFormat := AAFormat; |
637 |
ClientDataSetIngredientsLeud.DisplayFormat := AAFormat; |
638 |
ClientDataSetIngredientsPhed.DisplayFormat := AAFormat; |
639 |
ClientDataSetIngredientsTyrd.DisplayFormat := AAFormat; |
640 |
ClientDataSetIngredientsPheTyrd.DisplayFormat := AAFormat; |
641 |
ClientDataSetIngredientsHisd.DisplayFormat := AAFormat; |
642 |
ClientDataSetIngredientsArgd.DisplayFormat := AAFormat; |
643 |
ClientDataSetIngredientsAlad.DisplayFormat := AAFormat; |
644 |
ClientDataSetIngredientsAspd.DisplayFormat := AAFormat; |
645 |
ClientDataSetIngredientsGlud.DisplayFormat := AAFormat; |
646 |
ClientDataSetIngredientsGlyd.DisplayFormat := AAFormat; |
647 |
ClientDataSetIngredientsSerd.DisplayFormat := AAFormat; |
648 |
ClientDataSetIngredientsProd.DisplayFormat := AAFormat; |
649 |
ClientDataSetIngredientsLysd_ENc.DisplayFormat := DecimalFormat(2);
|
650 |
ClientDataSetIngredientsLysd_ENt.DisplayFormat := DecimalFormat(2);
|
651 |
ClientDataSetIngredientsCa.DisplayFormat := MineralsFormat; |
652 |
ClientDataSetIngredientsP.DisplayFormat := MineralsFormat; |
653 |
ClientDataSetIngredientsNa.DisplayFormat := MineralsFormat; |
654 |
ClientDataSetIngredientsK.DisplayFormat := MineralsFormat; |
655 |
ClientDataSetIngredientsCl.DisplayFormat := MineralsFormat; |
656 |
ClientDataSetIngredientsBE.DisplayFormat := DecimalFormat(1);
|
657 |
ClientDataSetIngredientsdP.DisplayFormat := DecimalFormat(1);
|
658 |
ClientDataSetIngredientsdPphy.DisplayFormat := DecimalFormat(1);
|
659 |
end;
|
660 |
// Chargement des mati?res premi?res en m?moire
|
661 |
ClientDataSetIngredients.IndexFieldNames := '';
|
662 |
ClientDataSetIngredients.CreateDataSet; |
663 |
// Mati?res premi?res de r?f?rence
|
664 |
ClientDataSetInraAfz.First; |
665 |
while not ClientDataSetInraAfz.Eof do |
666 |
begin
|
667 |
ClientDataSetIngredients.Append; |
668 |
try
|
669 |
ClientDataSetIngredientsId.Value := ClientDataSetInraAfzId.Value; |
670 |
ClientDataSetIngredientsName.Value := dgettext('InraAfz', WideString(ClientDataSetInraAfzName.Value));
|
671 |
if not ClientDataSetInraAfzComment.IsNull |
672 |
then
|
673 |
ClientDataSetIngredientsDefinition.Value := dgettext('InraAfz', WideString(ClientDataSetInraAfzComment.Value));
|
674 |
ClientDataSetIngredientsClass.Value := ClientDataSetInraAfzClass.Value; |
675 |
ClientDataSetIngredientsUser.Value := False; |
676 |
ClientDataSetIngredientsModel.Clear; |
677 |
ClientDataSetIngredientsSource.Value := Format('%s (?%s)', [_('Reference tables'), ClientDataSetInraAfzSource.Value]); |
678 |
CalcInraAfz; |
679 |
ClientDataSetIngredients.Post; |
680 |
except
|
681 |
ClientDataSetIngredients.Cancel; |
682 |
end;
|
683 |
Application.ProcessMessages; |
684 |
ClientDataSetInraAfz.Next; |
685 |
end;
|
686 |
// Mati?res premi?res utilisateur
|
687 |
TableIngredients := DBUser.GetTable('SELECT * FROM Ingredients');
|
688 |
with TableIngredients do |
689 |
try
|
690 |
while not Eof do |
691 |
begin
|
692 |
ClientDataSetIngredients.Append; |
693 |
try
|
694 |
ClientDataSetIngredientsId.Value := FieldAsInteger(FieldIndex['Id']);
|
695 |
// ClientDataSetIngredientsName.Value := UTF8ToString(RawByteString(FieldAsString(FieldIndex['Name'])));
|
696 |
ClientDataSetIngredientsName.Value := FieldAsString(FieldIndex['Name']);
|
697 |
// ClientDataSetIngredientsDefinition.Value := UTF8ToString(RawByteString(FieldAsString(FieldIndex['Definition'])));
|
698 |
ClientDataSetIngredientsDefinition.Value := FieldAsString(FieldIndex['Definition']);
|
699 |
ClientDataSetIngredientsClass.Value := FieldAsInteger(FieldIndex['Class']);
|
700 |
ClientDataSetIngredientsUser.Value := True; |
701 |
if FieldIsNull(FieldIndex['Model']) |
702 |
then // Cr?ation originale |
703 |
begin
|
704 |
ClientDataSetIngredientsSource.Value := _('Original item');
|
705 |
CalcOriginal; |
706 |
end
|
707 |
else // Copie bas?e sur un mod?le |
708 |
begin
|
709 |
ClientDataSetIngredientsModel.Value := FieldAsInteger(FieldIndex['Model']);
|
710 |
ClientDataSetInraAfz.Locate('Id', ClientDataSetIngredientsModel.Value, []);
|
711 |
ClientDataSetIngredientsSource.Value := Format(_('Copy of "%s"'), [dgettext('InraAfz', WideString(ClientDataSetInraAfzName.Value))]); |
712 |
CalcCopy; |
713 |
end;
|
714 |
ClientDataSetIngredients.Post; |
715 |
except
|
716 |
ClientDataSetIngredients.Cancel; |
717 |
MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitMain', 'LoadIngredients', 'ClientDataSetIngredients']), mtError, [mbOK], 0); |
718 |
Exit; |
719 |
end;
|
720 |
Application.ProcessMessages; |
721 |
Next; |
722 |
end;
|
723 |
finally
|
724 |
Free; |
725 |
end;
|
726 |
ClientDataSetIngredients.IndexFieldNames := 'Name';
|
727 |
end;
|
728 |
finally
|
729 |
Screen.Cursor := crDefault; |
730 |
Application.ProcessMessages; |
731 |
end;
|
732 |
end;
|
733 |
|
734 |
procedure TFormMain.LoadComposition;
|
735 |
begin
|
736 |
Screen.Cursor := crHourGlass; |
737 |
Application.ProcessMessages; |
738 |
try
|
739 |
with DataModuleDeclaration do |
740 |
begin
|
741 |
ClientDataSetComposition.CreateDataSet; |
742 |
with FormOptions do |
743 |
begin
|
744 |
ClientDataSetCompositionMS.DisplayFormat := ProximalFormat; |
745 |
ClientDataSetCompositionLevel.DisplayFormat := IncorporationFormat; |
746 |
if Proximal = 0 |
747 |
then // % |
748 |
ClientDataSetCompositionMS.MaxValue := 100
|
749 |
else // g/kg |
750 |
ClientDataSetCompositionMS.MaxValue := 1000;
|
751 |
if Incorporation = 0 |
752 |
then // % |
753 |
ClientDataSetCompositionLevel.MaxValue := 100
|
754 |
else // g/kg |
755 |
ClientDataSetCompositionLevel.MaxValue := 1000;
|
756 |
end;
|
757 |
// Chargement de la composition des aliments en m?moire
|
758 |
TableComposition := DBUser.GetTable('SELECT * FROM Composition');
|
759 |
with TableComposition do |
760 |
try
|
761 |
while not Eof do |
762 |
begin
|
763 |
ClientDataSetComposition.Append; |
764 |
try
|
765 |
ClientDataSetCompositionFeed.Value := FieldAsInteger(FieldIndex['Feed']);
|
766 |
ClientDataSetCompositionIngredient.Value := FieldAsInteger(FieldIndex['Ingredient']);
|
767 |
ClientDataSetCompositionUser.Value := (FieldByName['User'] = DefaultTrueBoolStr);
|
768 |
if ClientDataSetCompositionUser.Value
|
769 |
then
|
770 |
ClientDataSetIngredients.Filter := Format('Id = %d and User', [ClientDataSetCompositionIngredient.Value])
|
771 |
else
|
772 |
ClientDataSetIngredients.Filter := Format('Id = %d and not User', [ClientDataSetCompositionIngredient.Value]);
|
773 |
ClientDataSetIngredients.Filtered := True; |
774 |
ClientDataSetCompositionIngredientName.Value := ClientDataSetIngredientsName.Value; |
775 |
ClientDataSetIngredients.Filtered := False; |
776 |
ClientDataSetIngredients.Filter := '';
|
777 |
ClientDataSetCompositionRank.Value := FieldAsInteger(FieldIndex['Rank']);
|
778 |
ClientDataSetCompositionMS.Value := OutputProximal(FieldAsDouble(FieldIndex['MS']), 1, 0, FormOptions.Proximal); |
779 |
ClientDataSetCompositionLevel.Value := OutputIncorporation(FieldAsDouble(FieldIndex['Level']), FormOptions.Incorporation);
|
780 |
ClientDataSetComposition.Post; |
781 |
except
|
782 |
ClientDataSetComposition.Cancel; |
783 |
MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitMain', 'LoadComposition', 'ClientDataSetComposition']), mtError, [mbOK], 0); |
784 |
Exit; |
785 |
end;
|
786 |
Application.ProcessMessages; |
787 |
Next; |
788 |
end;
|
789 |
finally
|
790 |
Free; |
791 |
end;
|
792 |
end;
|
793 |
finally
|
794 |
Screen.Cursor := crDefault; |
795 |
Application.ProcessMessages; |
796 |
end;
|
797 |
end;
|
798 |
|
799 |
procedure TFormMain.LoadFeeds;
|
800 |
begin
|
801 |
Screen.Cursor := crHourGlass; |
802 |
Application.ProcessMessages; |
803 |
try
|
804 |
with DataModuleDeclaration do |
805 |
begin
|
806 |
ClientDataSetFeeds.CreateDataSet; |
807 |
with FormOptions do |
808 |
begin
|
809 |
ClientDataSetFeedsBonusC.DisplayFormat := DecimalFormat(1);
|
810 |
ClientDataSetFeedsBonusT.DisplayFormat := DecimalFormat(1);
|
811 |
ClientDataSetFeedsMS.DisplayFormat := ProximalFormat; |
812 |
ClientDataSetFeedsMS2.DisplayFormat := ProximalFormat; |
813 |
ClientDataSetFeedsMM.DisplayFormat := ProximalFormat; |
814 |
ClientDataSetFeedsMAT.DisplayFormat := ProximalFormat; |
815 |
ClientDataSetFeedsMG.DisplayFormat := ProximalFormat; |
816 |
ClientDataSetFeedsCB.DisplayFormat := ProximalFormat; |
817 |
ClientDataSetFeedsAmidon.DisplayFormat := ProximalFormat; |
818 |
ClientDataSetFeedsSucres.DisplayFormat := ProximalFormat; |
819 |
ClientDataSetFeedsNDF.DisplayFormat := ProximalFormat; |
820 |
ClientDataSetFeedsADF.DisplayFormat := ProximalFormat; |
821 |
ClientDataSetFeedsADL.DisplayFormat := ProximalFormat; |
822 |
ClientDataSetFeedsEB.DisplayFormat := EnergyFormat; |
823 |
ClientDataSetFeedsEDc.DisplayFormat := EnergyFormat; |
824 |
ClientDataSetFeedsEDt.DisplayFormat := EnergyFormat; |
825 |
ClientDataSetFeedsEDt_EDc.DisplayFormat := DecimalFormat(1);
|
826 |
ClientDataSetFeedsEMc.DisplayFormat := EnergyFormat; |
827 |
ClientDataSetFeedsEMt.DisplayFormat := EnergyFormat; |
828 |
ClientDataSetFeedsEMt_EMc.DisplayFormat := DecimalFormat(1);
|
829 |
ClientDataSetFeedsENc.DisplayFormat := EnergyFormat; |
830 |
ClientDataSetFeedsENt.DisplayFormat := EnergyFormat; |
831 |
ClientDataSetFeedsENt_ENc.DisplayFormat := DecimalFormat(1);
|
832 |
ClientDataSetFeedsdEc.DisplayFormat := DecimalFormat(1);
|
833 |
ClientDataSetFeedsdEt.DisplayFormat := DecimalFormat(1);
|
834 |
ClientDataSetFeedsEMc_EDc.DisplayFormat := DecimalFormat(1);
|
835 |
ClientDataSetFeedsEMt_EDt.DisplayFormat := DecimalFormat(1);
|
836 |
ClientDataSetFeedsENc_EMc.DisplayFormat := DecimalFormat(1);
|
837 |
ClientDataSetFeedsENt_EMt.DisplayFormat := DecimalFormat(1);
|
838 |
ClientDataSetFeedsdNc.DisplayFormat := DecimalFormat(1);
|
839 |
ClientDataSetFeedsdNt.DisplayFormat := DecimalFormat(1);
|
840 |
ClientDataSetFeedsLys.DisplayFormat := AAFormat; |
841 |
ClientDataSetFeedsThr.DisplayFormat := AAFormat; |
842 |
ClientDataSetFeedsMet.DisplayFormat := AAFormat; |
843 |
ClientDataSetFeedsCys.DisplayFormat := AAFormat; |
844 |
ClientDataSetFeedsMetCys.DisplayFormat := AAFormat; |
845 |
ClientDataSetFeedsTrp.DisplayFormat := AAFormat; |
846 |
ClientDataSetFeedsIle.DisplayFormat := AAFormat; |
847 |
ClientDataSetFeedsVal.DisplayFormat := AAFormat; |
848 |
ClientDataSetFeedsLeu.DisplayFormat := AAFormat; |
849 |
ClientDataSetFeedsPhe.DisplayFormat := AAFormat; |
850 |
ClientDataSetFeedsTyr.DisplayFormat := AAFormat; |
851 |
ClientDataSetFeedsPheTyr.DisplayFormat := AAFormat; |
852 |
ClientDataSetFeedsHis.DisplayFormat := AAFormat; |
853 |
ClientDataSetFeedsArg.DisplayFormat := AAFormat; |
854 |
ClientDataSetFeedsAla.DisplayFormat := AAFormat; |
855 |
ClientDataSetFeedsAsp.DisplayFormat := AAFormat; |
856 |
ClientDataSetFeedsGlu.DisplayFormat := AAFormat; |
857 |
ClientDataSetFeedsGly.DisplayFormat := AAFormat; |
858 |
ClientDataSetFeedsSer.DisplayFormat := AAFormat; |
859 |
ClientDataSetFeedsPro.DisplayFormat := AAFormat; |
860 |
ClientDataSetFeedsLysd.DisplayFormat := AAFormat; |
861 |
ClientDataSetFeedsThrd.DisplayFormat := AAFormat; |
862 |
ClientDataSetFeedsMetd.DisplayFormat := AAFormat; |
863 |
ClientDataSetFeedsCysd.DisplayFormat := AAFormat; |
864 |
ClientDataSetFeedsMetCysd.DisplayFormat := AAFormat; |
865 |
ClientDataSetFeedsTrpd.DisplayFormat := AAFormat; |
866 |
ClientDataSetFeedsIled.DisplayFormat := AAFormat; |
867 |
ClientDataSetFeedsVald.DisplayFormat := AAFormat; |
868 |
ClientDataSetFeedsLeud.DisplayFormat := AAFormat; |
869 |
ClientDataSetFeedsPhed.DisplayFormat := AAFormat; |
870 |
ClientDataSetFeedsTyrd.DisplayFormat := AAFormat; |
871 |
ClientDataSetFeedsPheTyrd.DisplayFormat := AAFormat; |
872 |
ClientDataSetFeedsHisd.DisplayFormat := AAFormat; |
873 |
ClientDataSetFeedsArgd.DisplayFormat := AAFormat; |
874 |
ClientDataSetFeedsAlad.DisplayFormat := AAFormat; |
875 |
ClientDataSetFeedsAspd.DisplayFormat := AAFormat; |
876 |
ClientDataSetFeedsGlud.DisplayFormat := AAFormat; |
877 |
ClientDataSetFeedsGlyd.DisplayFormat := AAFormat; |
878 |
ClientDataSetFeedsSerd.DisplayFormat := AAFormat; |
879 |
ClientDataSetFeedsProd.DisplayFormat := AAFormat; |
880 |
ClientDataSetFeedsLysd_ENc.DisplayFormat := DecimalFormat(2);
|
881 |
ClientDataSetFeedsLysd_ENt.DisplayFormat := DecimalFormat(2);
|
882 |
ClientDataSetFeedsThrd_Lysd.DisplayFormat := DecimalFormat(0);
|
883 |
ClientDataSetFeedsMetd_Lysd.DisplayFormat := DecimalFormat(0);
|
884 |
ClientDataSetFeedsCysd_Lysd.DisplayFormat := DecimalFormat(0);
|
885 |
ClientDataSetFeedsMetCysd_Lysd.DisplayFormat := DecimalFormat(0);
|
886 |
ClientDataSetFeedsTrpd_Lysd.DisplayFormat := DecimalFormat(0);
|
887 |
ClientDataSetFeedsIled_Lysd.DisplayFormat := DecimalFormat(0);
|
888 |
ClientDataSetFeedsVald_Lysd.DisplayFormat := DecimalFormat(0);
|
889 |
ClientDataSetFeedsLeud_Lysd.DisplayFormat := DecimalFormat(0);
|
890 |
ClientDataSetFeedsPhed_Lysd.DisplayFormat := DecimalFormat(0);
|
891 |
ClientDataSetFeedsTyrd_Lysd.DisplayFormat := DecimalFormat(0);
|
892 |
ClientDataSetFeedsPheTyrd_Lysd.DisplayFormat := DecimalFormat(0);
|
893 |
ClientDataSetFeedsHisd_Lysd.DisplayFormat := DecimalFormat(0);
|
894 |
ClientDataSetFeedsArgd_Lysd.DisplayFormat := DecimalFormat(0);
|
895 |
ClientDataSetFeedsAlad_Lysd.DisplayFormat := DecimalFormat(0);
|
896 |
ClientDataSetFeedsAspd_Lysd.DisplayFormat := DecimalFormat(0);
|
897 |
ClientDataSetFeedsGlud_Lysd.DisplayFormat := DecimalFormat(0);
|
898 |
ClientDataSetFeedsGlyd_Lysd.DisplayFormat := DecimalFormat(0);
|
899 |
ClientDataSetFeedsSerd_Lysd.DisplayFormat := DecimalFormat(0);
|
900 |
ClientDataSetFeedsProd_Lysd.DisplayFormat := DecimalFormat(0);
|
901 |
ClientDataSetFeedsCa.DisplayFormat := MineralsFormat; |
902 |
ClientDataSetFeedsP.DisplayFormat := MineralsFormat; |
903 |
ClientDataSetFeedsNa.DisplayFormat := MineralsFormat; |
904 |
ClientDataSetFeedsK.DisplayFormat := MineralsFormat; |
905 |
ClientDataSetFeedsCl.DisplayFormat := MineralsFormat; |
906 |
ClientDataSetFeedsBE.DisplayFormat := DecimalFormat(1);
|
907 |
ClientDataSetFeedsPd.DisplayFormat := MineralsFormat; |
908 |
ClientDataSetFeedsCa_Pd.DisplayFormat := DecimalFormat(2);
|
909 |
ClientDataSetFeedsPd_ENc.DisplayFormat := DecimalFormat(2);
|
910 |
ClientDataSetFeedsPd_ENt.DisplayFormat := DecimalFormat(2);
|
911 |
ClientDataSetFeedsPhytaseConcentration.DisplayFormat := DecimalFormat(0);
|
912 |
ClientDataSetFeedsPhytaseIncorporation.DisplayFormat := DecimalFormat(0);
|
913 |
ClientDataSetFeedsPhytaseLevel.DisplayFormat := IncorporationFormat; |
914 |
ClientDataSetFeedsTotal.DisplayFormat := IncorporationFormat; |
915 |
ClientDataSetFeedsRemain.DisplayFormat := IncorporationFormat; |
916 |
end;
|
917 |
// Chargement des aliments en m?moire
|
918 |
TableFeeds := DBUser.GetTable('SELECT * FROM Feeds');
|
919 |
with TableFeeds do |
920 |
try
|
921 |
while not Eof do |
922 |
begin
|
923 |
ClientDataSetFeeds.Append; |
924 |
try
|
925 |
ClientDataSetFeedsId.Value := FieldAsInteger(FieldIndex['Id']);
|
926 |
// ClientDataSetFeedsName.Value := UTF8ToString(RawByteString(FieldAsString(FieldIndex['Name'])));
|
927 |
ClientDataSetFeedsName.Value := FieldAsString(FieldIndex['Name']);
|
928 |
// ClientDataSetFeedsDescription.Value := UTF8ToString(RawByteString(FieldAsString(FieldIndex['Description'])));
|
929 |
ClientDataSetFeedsDescription.Value := FieldAsString(FieldIndex['Description']);
|
930 |
ClientDataSetFeedsPresentation.Value := FieldAsInteger(FieldIndex['Presentation']);
|
931 |
ClientDataSetFeedsBonusC.Value := FieldAsDouble(FieldIndex['BonusC']) * 100; |
932 |
ClientDataSetFeedsBonusT.Value := FieldAsDouble(FieldIndex['BonusT']) * 100; |
933 |
if not TableFeeds.FieldIsNull(FieldIndex['Phytase']) |
934 |
then
|
935 |
ClientDataSetFeedsPhytaseId.Value := FieldAsInteger(FieldIndex['Phytase']);
|
936 |
if not TableFeeds.FieldIsNull(FieldIndex['Concentration']) |
937 |
then
|
938 |
ClientDataSetFeedsPhytaseConcentration.Value := FieldAsDouble(FieldIndex['Concentration']);
|
939 |
if not TableFeeds.FieldIsNull(FieldIndex['Incorporation']) |
940 |
then
|
941 |
ClientDataSetFeedsPhytaseIncorporation.Value := FieldAsDouble(FieldIndex['Incorporation']);
|
942 |
ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
|
943 |
ClientDataSetComposition.Filtered := True; |
944 |
CalcFeed; |
945 |
ClientDataSetComposition.Filtered := False; |
946 |
ClientDataSetComposition.Filter := '';
|
947 |
ClientDataSetFeeds.Post; |
948 |
except
|
949 |
ClientDataSetFeeds.Cancel; |
950 |
MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitMain', 'LoadFeeds', 'ClientDataSetFeeds']), mtError, [mbOK], 0); |
951 |
Exit; |
952 |
end;
|
953 |
Application.ProcessMessages; |
954 |
Next; |
955 |
end;
|
956 |
finally
|
957 |
Free; |
958 |
end;
|
959 |
end;
|
960 |
finally
|
961 |
Screen.Cursor := crDefault; |
962 |
Application.ProcessMessages; |
963 |
end;
|
964 |
end;
|
965 |
|
966 |
end.
|