Statistiques
| Révision:

root / UnitMain.pas @ 1

Historique | Voir | Annoter | Télécharger (40,852 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', ClientDataSetInraAfzName.Value)]);
246
            end;
247
          end
248
          else
249
          begin
250
            ClientDataSetInraAfz.Locate('Id', ClientDataSetIngredientsId.Value, []);
251
            ClientDataSetIngredientsName.Value := dgettext('InraAfz', ClientDataSetInraAfzName.Value);
252
            if not ClientDataSetInraAfzComment.IsNull
253
            then
254
              ClientDataSetIngredientsDefinition.Value := dgettext('InraAfz', 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', 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
        ClientDataSetIngredientsdP.DisplayFormat := DecimalFormat(1);
654
        ClientDataSetIngredientsdPphy.DisplayFormat := DecimalFormat(1);
655
      end;
656
      // Chargement des mati?res premi?res en m?moire
657
      ClientDataSetIngredients.IndexFieldNames := '';
658
      ClientDataSetIngredients.CreateDataSet;
659
      // Mati?res premi?res de r?f?rence
660
      ClientDataSetInraAfz.First;
661
      while not ClientDataSetInraAfz.Eof do
662
      begin
663
        ClientDataSetIngredients.Append;
664
        try
665
          ClientDataSetIngredientsId.Value := ClientDataSetInraAfzId.Value;
666
          ClientDataSetIngredientsName.Value := dgettext('InraAfz', ClientDataSetInraAfzName.Value);
667
          if not ClientDataSetInraAfzComment.IsNull
668
          then
669
            ClientDataSetIngredientsDefinition.Value := dgettext('InraAfz', ClientDataSetInraAfzComment.Value);
670
          ClientDataSetIngredientsClass.Value := ClientDataSetInraAfzClass.Value;
671
          ClientDataSetIngredientsUser.Value := False;
672
          ClientDataSetIngredientsModel.Clear;
673
          ClientDataSetIngredientsSource.Value := Format('%s (?%s)', [_('Reference tables'), ClientDataSetInraAfzSource.Value]);
674
          CalcInraAfz;
675
          ClientDataSetIngredients.Post;
676
        except
677
          ClientDataSetIngredients.Cancel;
678
        end;
679
        Application.ProcessMessages;
680
        ClientDataSetInraAfz.Next;
681
      end;
682
      // Mati?res premi?res utilisateur
683
      TableIngredients := DBUser.GetTable('SELECT * FROM Ingredients');
684
      with TableIngredients do
685
        try
686
          while not Eof do
687
          begin
688
            ClientDataSetIngredients.Append;
689
            try
690
              ClientDataSetIngredientsId.Value := FieldAsInteger(FieldIndex['Id']);
691
//              ClientDataSetIngredientsName.Value := UTF8ToString(RawByteString(FieldAsString(FieldIndex['Name'])));
692
              ClientDataSetIngredientsName.Value := FieldAsString(FieldIndex['Name']);
693
//              ClientDataSetIngredientsDefinition.Value := UTF8ToString(RawByteString(FieldAsString(FieldIndex['Definition'])));
694
              ClientDataSetIngredientsDefinition.Value := FieldAsString(FieldIndex['Definition']);
695
              ClientDataSetIngredientsClass.Value := FieldAsInteger(FieldIndex['Class']);
696
              ClientDataSetIngredientsUser.Value := True;
697
              if FieldIsNull(FieldIndex['Model'])
698
              then // Cr?ation originale
699
              begin
700
                ClientDataSetIngredientsSource.Value := _('Original item');
701
                CalcOriginal;
702
              end
703
              else // Copie bas?e sur un mod?le
704
              begin
705
                ClientDataSetIngredientsModel.Value := FieldAsInteger(FieldIndex['Model']);
706
                ClientDataSetInraAfz.Locate('Id', ClientDataSetIngredientsModel.Value, []);
707
                ClientDataSetIngredientsSource.Value := Format(_('Copy of "%s"'), [dgettext('InraAfz', ClientDataSetInraAfzName.Value)]);
708
                CalcCopy;
709
              end;
710
              ClientDataSetIngredients.Post;
711
            except
712
              ClientDataSetIngredients.Cancel;
713
              MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitMain', 'LoadIngredients', 'ClientDataSetIngredients']), mtError, [mbOK], 0);
714
              Exit;
715
            end;
716
            Application.ProcessMessages;
717
            Next;
718
          end;
719
        finally
720
          Free;
721
        end;
722
      ClientDataSetIngredients.IndexFieldNames := 'Name';
723
    end;
724
  finally
725
    Screen.Cursor := crDefault;
726
    Application.ProcessMessages;
727
  end;
728
end;
729

    
730
procedure TFormMain.LoadComposition;
731
begin
732
  Screen.Cursor := crHourGlass;
733
  Application.ProcessMessages;
734
  try
735
    with DataModuleDeclaration do
736
    begin
737
      ClientDataSetComposition.CreateDataSet;
738
      with FormOptions do
739
      begin
740
        ClientDataSetCompositionMS.DisplayFormat := ProximalFormat;
741
        ClientDataSetCompositionLevel.DisplayFormat := IncorporationFormat;
742
        if Proximal = 0
743
        then // %
744
          ClientDataSetCompositionMS.MaxValue := 100
745
        else // g/kg
746
          ClientDataSetCompositionMS.MaxValue := 1000;
747
        if Incorporation = 0
748
        then // %
749
          ClientDataSetCompositionLevel.MaxValue := 100
750
        else // g/kg
751
          ClientDataSetCompositionLevel.MaxValue := 1000;
752
      end;
753
      // Chargement de la composition des aliments en m?moire
754
      TableComposition := DBUser.GetTable('SELECT * FROM Composition');
755
      with TableComposition do
756
        try
757
          while not Eof do
758
          begin
759
            ClientDataSetComposition.Append;
760
            try
761
              ClientDataSetCompositionFeed.Value := FieldAsInteger(FieldIndex['Feed']);
762
              ClientDataSetCompositionIngredient.Value := FieldAsInteger(FieldIndex['Ingredient']);
763
              ClientDataSetCompositionUser.Value := (FieldByName['User'] = DefaultTrueBoolStr);
764
              if ClientDataSetCompositionUser.Value
765
              then
766
                ClientDataSetIngredients.Filter := Format('Id = %d and User', [ClientDataSetCompositionIngredient.Value])
767
              else
768
                ClientDataSetIngredients.Filter := Format('Id = %d and not User', [ClientDataSetCompositionIngredient.Value]);
769
              ClientDataSetIngredients.Filtered := True;
770
              ClientDataSetCompositionIngredientName.Value := ClientDataSetIngredientsName.Value;
771
              ClientDataSetIngredients.Filtered := False;
772
              ClientDataSetIngredients.Filter := '';
773
              ClientDataSetCompositionRank.Value := FieldAsInteger(FieldIndex['Rank']);
774
              ClientDataSetCompositionMS.Value := OutputProximal(FieldAsDouble(FieldIndex['MS']), 1, 0, FormOptions.Proximal);
775
              ClientDataSetCompositionLevel.Value := OutputIncorporation(FieldAsDouble(FieldIndex['Level']), FormOptions.Incorporation);
776
              ClientDataSetComposition.Post;
777
            except
778
              ClientDataSetComposition.Cancel;
779
              MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitMain', 'LoadComposition', 'ClientDataSetComposition']), mtError, [mbOK], 0);
780
              Exit;
781
            end;
782
            Application.ProcessMessages;
783
            Next;
784
          end;
785
        finally
786
          Free;
787
        end;
788
    end;
789
  finally
790
    Screen.Cursor := crDefault;
791
    Application.ProcessMessages;
792
  end;
793
end;
794

    
795
procedure TFormMain.LoadFeeds;
796
begin
797
  Screen.Cursor := crHourGlass;
798
  Application.ProcessMessages;
799
  try
800
    with DataModuleDeclaration do
801
    begin
802
      ClientDataSetFeeds.CreateDataSet;
803
      with FormOptions do
804
      begin
805
        ClientDataSetFeedsBonusC.DisplayFormat := DecimalFormat(1);
806
        ClientDataSetFeedsBonusT.DisplayFormat := DecimalFormat(1);
807
        ClientDataSetFeedsMS.DisplayFormat := ProximalFormat;
808
        ClientDataSetFeedsMS2.DisplayFormat := ProximalFormat;
809
        ClientDataSetFeedsMM.DisplayFormat := ProximalFormat;
810
        ClientDataSetFeedsMAT.DisplayFormat := ProximalFormat;
811
        ClientDataSetFeedsMG.DisplayFormat := ProximalFormat;
812
        ClientDataSetFeedsCB.DisplayFormat := ProximalFormat;
813
        ClientDataSetFeedsAmidon.DisplayFormat := ProximalFormat;
814
        ClientDataSetFeedsSucres.DisplayFormat := ProximalFormat;
815
        ClientDataSetFeedsNDF.DisplayFormat := ProximalFormat;
816
        ClientDataSetFeedsADF.DisplayFormat := ProximalFormat;
817
        ClientDataSetFeedsADL.DisplayFormat := ProximalFormat;
818
        ClientDataSetFeedsEB.DisplayFormat := EnergyFormat;
819
        ClientDataSetFeedsEDc.DisplayFormat := EnergyFormat;
820
        ClientDataSetFeedsEDt.DisplayFormat := EnergyFormat;
821
        ClientDataSetFeedsEDt_EDc.DisplayFormat := DecimalFormat(1);
822
        ClientDataSetFeedsEMc.DisplayFormat := EnergyFormat;
823
        ClientDataSetFeedsEMt.DisplayFormat := EnergyFormat;
824
        ClientDataSetFeedsEMt_EMc.DisplayFormat := DecimalFormat(1);
825
        ClientDataSetFeedsENc.DisplayFormat := EnergyFormat;
826
        ClientDataSetFeedsENt.DisplayFormat := EnergyFormat;
827
        ClientDataSetFeedsENt_ENc.DisplayFormat := DecimalFormat(1);
828
        ClientDataSetFeedsdEc.DisplayFormat := DecimalFormat(1);
829
        ClientDataSetFeedsdEt.DisplayFormat := DecimalFormat(1);
830
        ClientDataSetFeedsEMc_EDc.DisplayFormat := DecimalFormat(1);
831
        ClientDataSetFeedsEMt_EDt.DisplayFormat := DecimalFormat(1);
832
        ClientDataSetFeedsENc_EMc.DisplayFormat := DecimalFormat(1);
833
        ClientDataSetFeedsENt_EMt.DisplayFormat := DecimalFormat(1);
834
        ClientDataSetFeedsdNc.DisplayFormat := DecimalFormat(1);
835
        ClientDataSetFeedsdNt.DisplayFormat := DecimalFormat(1);
836
        ClientDataSetFeedsLys.DisplayFormat := AAFormat;
837
        ClientDataSetFeedsThr.DisplayFormat := AAFormat;
838
        ClientDataSetFeedsMet.DisplayFormat := AAFormat;
839
        ClientDataSetFeedsCys.DisplayFormat := AAFormat;
840
        ClientDataSetFeedsMetCys.DisplayFormat := AAFormat;
841
        ClientDataSetFeedsTrp.DisplayFormat := AAFormat;
842
        ClientDataSetFeedsIle.DisplayFormat := AAFormat;
843
        ClientDataSetFeedsVal.DisplayFormat := AAFormat;
844
        ClientDataSetFeedsLeu.DisplayFormat := AAFormat;
845
        ClientDataSetFeedsPhe.DisplayFormat := AAFormat;
846
        ClientDataSetFeedsTyr.DisplayFormat := AAFormat;
847
        ClientDataSetFeedsPheTyr.DisplayFormat := AAFormat;
848
        ClientDataSetFeedsHis.DisplayFormat := AAFormat;
849
        ClientDataSetFeedsArg.DisplayFormat := AAFormat;
850
        ClientDataSetFeedsAla.DisplayFormat := AAFormat;
851
        ClientDataSetFeedsAsp.DisplayFormat := AAFormat;
852
        ClientDataSetFeedsGlu.DisplayFormat := AAFormat;
853
        ClientDataSetFeedsGly.DisplayFormat := AAFormat;
854
        ClientDataSetFeedsSer.DisplayFormat := AAFormat;
855
        ClientDataSetFeedsPro.DisplayFormat := AAFormat;
856
        ClientDataSetFeedsLysd.DisplayFormat := AAFormat;
857
        ClientDataSetFeedsThrd.DisplayFormat := AAFormat;
858
        ClientDataSetFeedsMetd.DisplayFormat := AAFormat;
859
        ClientDataSetFeedsCysd.DisplayFormat := AAFormat;
860
        ClientDataSetFeedsMetCysd.DisplayFormat := AAFormat;
861
        ClientDataSetFeedsTrpd.DisplayFormat := AAFormat;
862
        ClientDataSetFeedsIled.DisplayFormat := AAFormat;
863
        ClientDataSetFeedsVald.DisplayFormat := AAFormat;
864
        ClientDataSetFeedsLeud.DisplayFormat := AAFormat;
865
        ClientDataSetFeedsPhed.DisplayFormat := AAFormat;
866
        ClientDataSetFeedsTyrd.DisplayFormat := AAFormat;
867
        ClientDataSetFeedsPheTyrd.DisplayFormat := AAFormat;
868
        ClientDataSetFeedsHisd.DisplayFormat := AAFormat;
869
        ClientDataSetFeedsArgd.DisplayFormat := AAFormat;
870
        ClientDataSetFeedsAlad.DisplayFormat := AAFormat;
871
        ClientDataSetFeedsAspd.DisplayFormat := AAFormat;
872
        ClientDataSetFeedsGlud.DisplayFormat := AAFormat;
873
        ClientDataSetFeedsGlyd.DisplayFormat := AAFormat;
874
        ClientDataSetFeedsSerd.DisplayFormat := AAFormat;
875
        ClientDataSetFeedsProd.DisplayFormat := AAFormat;
876
        ClientDataSetFeedsLysd_ENc.DisplayFormat := DecimalFormat(2);
877
        ClientDataSetFeedsLysd_ENt.DisplayFormat := DecimalFormat(2);
878
        ClientDataSetFeedsThrd_Lysd.DisplayFormat := DecimalFormat(0);
879
        ClientDataSetFeedsMetd_Lysd.DisplayFormat := DecimalFormat(0);
880
        ClientDataSetFeedsCysd_Lysd.DisplayFormat := DecimalFormat(0);
881
        ClientDataSetFeedsMetCysd_Lysd.DisplayFormat := DecimalFormat(0);
882
        ClientDataSetFeedsTrpd_Lysd.DisplayFormat := DecimalFormat(0);
883
        ClientDataSetFeedsIled_Lysd.DisplayFormat := DecimalFormat(0);
884
        ClientDataSetFeedsVald_Lysd.DisplayFormat := DecimalFormat(0);
885
        ClientDataSetFeedsLeud_Lysd.DisplayFormat := DecimalFormat(0);
886
        ClientDataSetFeedsPhed_Lysd.DisplayFormat := DecimalFormat(0);
887
        ClientDataSetFeedsTyrd_Lysd.DisplayFormat := DecimalFormat(0);
888
        ClientDataSetFeedsPheTyrd_Lysd.DisplayFormat := DecimalFormat(0);
889
        ClientDataSetFeedsHisd_Lysd.DisplayFormat := DecimalFormat(0);
890
        ClientDataSetFeedsArgd_Lysd.DisplayFormat := DecimalFormat(0);
891
        ClientDataSetFeedsAlad_Lysd.DisplayFormat := DecimalFormat(0);
892
        ClientDataSetFeedsAspd_Lysd.DisplayFormat := DecimalFormat(0);
893
        ClientDataSetFeedsGlud_Lysd.DisplayFormat := DecimalFormat(0);
894
        ClientDataSetFeedsGlyd_Lysd.DisplayFormat := DecimalFormat(0);
895
        ClientDataSetFeedsSerd_Lysd.DisplayFormat := DecimalFormat(0);
896
        ClientDataSetFeedsProd_Lysd.DisplayFormat := DecimalFormat(0);
897
        ClientDataSetFeedsCa.DisplayFormat := MineralsFormat;
898
        ClientDataSetFeedsP.DisplayFormat := MineralsFormat;
899
        ClientDataSetFeedsPd.DisplayFormat := MineralsFormat;
900
        ClientDataSetFeedsCa_Pd.DisplayFormat := DecimalFormat(1);
901
        ClientDataSetFeedsPd_ENc.DisplayFormat := DecimalFormat(2);
902
        ClientDataSetFeedsPd_ENt.DisplayFormat := DecimalFormat(2);
903
        ClientDataSetFeedsPhytaseConcentration.DisplayFormat := DecimalFormat(0);
904
        ClientDataSetFeedsPhytaseIncorporation.DisplayFormat := DecimalFormat(0);
905
        ClientDataSetFeedsPhytaseLevel.DisplayFormat := IncorporationFormat;
906
        ClientDataSetFeedsTotal.DisplayFormat := IncorporationFormat;
907
        ClientDataSetFeedsRemain.DisplayFormat := IncorporationFormat;
908
      end;
909
      // Chargement des aliments en m?moire
910
      TableFeeds := DBUser.GetTable('SELECT * FROM Feeds');
911
      with TableFeeds do
912
        try
913
          while not Eof do
914
          begin
915
            ClientDataSetFeeds.Append;
916
            try
917
              ClientDataSetFeedsId.Value := FieldAsInteger(FieldIndex['Id']);
918
//              ClientDataSetFeedsName.Value := UTF8ToString(RawByteString(FieldAsString(FieldIndex['Name'])));
919
              ClientDataSetFeedsName.Value := FieldAsString(FieldIndex['Name']);
920
//              ClientDataSetFeedsDescription.Value := UTF8ToString(RawByteString(FieldAsString(FieldIndex['Description'])));
921
              ClientDataSetFeedsDescription.Value := FieldAsString(FieldIndex['Description']);
922
              ClientDataSetFeedsPresentation.Value := FieldAsInteger(FieldIndex['Presentation']);
923
              ClientDataSetFeedsBonusC.Value := FieldAsDouble(FieldIndex['BonusC']) * 100;
924
              ClientDataSetFeedsBonusT.Value := FieldAsDouble(FieldIndex['BonusT']) * 100;
925
              if not TableFeeds.FieldIsNull(FieldIndex['Phytase'])
926
              then
927
                ClientDataSetFeedsPhytaseId.Value := FieldAsInteger(FieldIndex['Phytase']);
928
              if not TableFeeds.FieldIsNull(FieldIndex['Concentration'])
929
              then
930
                ClientDataSetFeedsPhytaseConcentration.Value := FieldAsDouble(FieldIndex['Concentration']);
931
              if not TableFeeds.FieldIsNull(FieldIndex['Incorporation'])
932
              then
933
                ClientDataSetFeedsPhytaseIncorporation.Value := FieldAsDouble(FieldIndex['Incorporation']);
934
              ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
935
              ClientDataSetComposition.Filtered := True;
936
              CalcFeed;
937
              ClientDataSetComposition.Filtered := False;
938
              ClientDataSetComposition.Filter := '';
939
              ClientDataSetFeeds.Post;
940
            except
941
              ClientDataSetFeeds.Cancel;
942
              MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitMain', 'LoadFeeds', 'ClientDataSetFeeds']), mtError, [mbOK], 0);
943
              Exit;
944
            end;
945
            Application.ProcessMessages;
946
            Next;
947
          end;
948
        finally
949
          Free;
950
        end;
951
    end;
952
  finally
953
    Screen.Cursor := crDefault;
954
    Application.ProcessMessages;
955
  end;
956
end;
957

    
958
end.