Statistiques
| Révision:

root / UnitFeedsCharts.pas @ 14

Historique | Voir | Annoter | Télécharger (131,679 ko)

1 1 avalancogn
unit UnitFeedsCharts;
2
3
interface
4
5
uses
6
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7
  gnugettext, StdCtrls, ExtCtrls, TeeProcs, TeEngine, Chart, Series, Buttons,
8
  Math, ComCtrls, ImgList, ActnList, JvExStdCtrls, JvButton, JvCtrls;
9
10
type
11
  TFormFeedsCharts = class(TForm)
12
    GroupBoxFeed1: TGroupBox;
13
    PanelFeed1: TPanel;
14
    ChartFeed1: TChart;
15
    GroupBoxChartSelection: TGroupBox;
16
    GroupBoxFeed2: TGroupBox;
17
    PanelFeed2: TPanel;
18
    ChartFeed2: TChart;
19
    GroupBoxFeed3: TGroupBox;
20
    PanelFeed3: TPanel;
21
    ChartFeed3: TChart;
22
    GroupBoxFeed4: TGroupBox;
23
    PanelFeed4: TPanel;
24
    ChartFeed4: TChart;
25
    SpeedButton2D3D1: TSpeedButton;
26
    SpeedButton2D3D2: TSpeedButton;
27
    SpeedButton2D3D3: TSpeedButton;
28
    SpeedButton2D3D4: TSpeedButton;
29
    SpeedButtonPrint1: TSpeedButton;
30
    SpeedButtonPrint2: TSpeedButton;
31
    SpeedButtonPrint3: TSpeedButton;
32
    SpeedButtonPrint4: TSpeedButton;
33
    PanelButtons: TPanel;
34
    PageControlFeedsChats: TPageControl;
35
    TabSheetSingleChart: TTabSheet;
36
    TabSheetChartsComparison: TTabSheet;
37
    GroupBoxChart0: TGroupBox;
38
    Chart0: TChart;
39
    SpeedButton2D3D0: TSpeedButton;
40
    SpeedButtonPrint0: TSpeedButton;
41
    LabelDiet1: TLabel;
42
    LabelDiet2: TLabel;
43
    LabelDiet3: TLabel;
44
    LabelDiet4: TLabel;
45
    LabelDiet5: TLabel;
46
    LabelDiet6: TLabel;
47
    ComboBoxRatios0: TComboBox;
48
    ComboBoxAA0: TComboBox;
49
    ComboBoxEnergy0: TComboBox;
50
    ComboBoxMinerals0: TComboBox;
51
    ComboBoxProximal0: TComboBox;
52
    ComboBoxType0: TComboBox;
53
    ComboBoxDiet1: TComboBox;
54
    ComboBoxDiet2: TComboBox;
55
    ComboBoxDiet3: TComboBox;
56
    ComboBoxDiet4: TComboBox;
57
    ComboBoxDiet5: TComboBox;
58
    ComboBoxDiet6: TComboBox;
59
    ComboBoxAA: TComboBox;
60
    ComboBoxEnergy: TComboBox;
61
    ComboBoxMinerals: TComboBox;
62
    ComboBoxProximal: TComboBox;
63
    ComboBoxType: TComboBox;
64
    ComboBoxFeed1: TComboBox;
65
    ComboBoxFeed2: TComboBox;
66
    ComboBoxFeed3: TComboBox;
67
    ComboBoxFeed4: TComboBox;
68
    JvImgBtnClose: TJvImgBtn;
69
    JvImgBtnHelp: TJvImgBtn;
70
    ActionListButtons: TActionList;
71
    ActionHelp: TAction;
72
    ActionClose: TAction;
73
    ImageListIcons: TImageList;
74
    SeriesBar: TBarSeries;
75
    procedure FormCreate(Sender: TObject);
76
    procedure ComboBoxTypeChange(Sender: TObject);
77
    procedure ComboBoxOptionChange(Sender: TObject);
78
    procedure ComboBoxFeed1Change(Sender: TObject);
79
    procedure ComboBoxFeed2Change(Sender: TObject);
80
    procedure ComboBoxFeed3Change(Sender: TObject);
81
    procedure ComboBoxFeed4Change(Sender: TObject);
82
    procedure FormResize(Sender: TObject);
83
    procedure SpeedButton2D3D1Click(Sender: TObject);
84
    procedure SpeedButton2D3D2Click(Sender: TObject);
85
    procedure SpeedButton2D3D3Click(Sender: TObject);
86
    procedure SpeedButton2D3D4Click(Sender: TObject);
87
    procedure SpeedButtonPrint1Click(Sender: TObject);
88
    procedure SpeedButtonPrint2Click(Sender: TObject);
89
    procedure SpeedButtonPrint3Click(Sender: TObject);
90
    procedure SpeedButtonPrint4Click(Sender: TObject);
91
    procedure ComboBoxType0Change(Sender: TObject);
92
    procedure ComboBoxOption0Change(Sender: TObject);
93
    procedure ComboBoxDietChange(Sender: TObject);
94
    procedure SpeedButton2D3D0Click(Sender: TObject);
95
    procedure SpeedButtonPrint0Click(Sender: TObject);
96
    procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
97
    procedure ActionHelpExecute(Sender: TObject);
98
    procedure ActionCloseExecute(Sender: TObject);
99
  private
100
    { D?clarations priv?es }
101
  public
102
    { D?clarations publiques }
103
  end;
104
105
var
106
  FormFeedsCharts: TFormFeedsCharts;
107
108
implementation
109
110
uses
111
  UnitDeclaration, UnitOptions, UnitChartHReport;
112
113
{$R *.dfm}
114
115
procedure TFormFeedsCharts.ActionCloseExecute(Sender: TObject);
116
begin
117
  ModalResult := mrClose;
118
end;
119
120
procedure TFormFeedsCharts.ActionHelpExecute(Sender: TObject);
121
begin
122
  Application.HelpContext(HelpContext);
123
end;
124
125
procedure TFormFeedsCharts.ComboBoxDietChange(Sender: TObject);
126
var
127
//  FeedBar: TBarSeries;
128
  s: string;
129
130
  procedure AddBarValue;
131
  begin
132
    with DataModuleDeclaration do
133 5 avalancogn
    begin
134 1 avalancogn
      case ComboBoxType0.ItemIndex of
135
        0: // Analyse proximale
136
          case ComboBoxProximal0.ItemIndex of
137
            0: // MS
138
              if not ClientDataSetFeedsMS.IsNull
139
              then SeriesBar.AddBar(ClientDataSetFeedsMS.Value, s, clTeeColor)
140
              else SeriesBar.AddNull(s);
141
            1: // MM
142
              if not ClientDataSetFeedsMM.IsNull
143
              then SeriesBar.AddBar(ClientDataSetFeedsMM.Value, s, clTeeColor)
144
              else SeriesBar.AddNull(s);
145
            2: // MAT
146
              if not ClientDataSetFeedsMAT.IsNull
147
              then SeriesBar.AddBar(ClientDataSetFeedsMAT.Value, s, clTeeColor)
148
              else SeriesBar.AddNull(s);
149
            3: // MG
150
              if not ClientDataSetFeedsMG.IsNull
151
              then SeriesBar.AddBar(ClientDataSetFeedsMG.Value, s, clTeeColor)
152
              else SeriesBar.AddNull(s);
153
            4: // CB
154
              if not ClientDataSetFeedsCB.IsNull
155
              then SeriesBar.AddBar(ClientDataSetFeedsCB.Value, s, clTeeColor)
156
              else SeriesBar.AddNull(s);
157
            5: // NDF
158
              if not ClientDataSetFeedsNDF.IsNull
159
              then SeriesBar.AddBar(ClientDataSetFeedsNDF.Value, s, clTeeColor)
160
              else SeriesBar.AddNull(s);
161
            6: // ADF
162
              if not ClientDataSetFeedsADF.IsNull
163
              then SeriesBar.AddBar(ClientDataSetFeedsADF.Value, s, clTeeColor)
164
              else SeriesBar.AddNull(s);
165
            7: // ADL
166
              if not ClientDataSetFeedsADL.IsNull
167
              then SeriesBar.AddBar(ClientDataSetFeedsADL.Value, s, clTeeColor)
168
              else SeriesBar.AddNull(s);
169
            8: // Amidon
170
              if not ClientDataSetFeedsAmidon.IsNull
171
              then SeriesBar.AddBar(ClientDataSetFeedsAmidon.Value, s, clTeeColor)
172
              else SeriesBar.AddNull(s);
173
            9: // Sucres
174
              if not ClientDataSetFeedsSucres.IsNull
175
              then SeriesBar.AddBar(ClientDataSetFeedsSucres.Value, s, clTeeColor)
176
              else SeriesBar.AddNull(s);
177
          end;
178
        1: // Valeurs ?nerg?tiques
179
          case ComboBoxEnergy0.ItemIndex of
180
            0: // Energie brute
181
              if not ClientDataSetFeedsEB.IsNull
182
              then SeriesBar.AddBar(ClientDataSetFeedsEB.Value, s, clTeeColor)
183
              else SeriesBar.AddNull(s);
184
            1: // Energie digestible (porc croissance)
185
              if not ClientDataSetFeedsEDc.IsNull
186
              then SeriesBar.AddBar(ClientDataSetFeedsEDc.Value, s, clTeeColor)
187
              else SeriesBar.AddNull(s);
188
            2: // Energie digestible (porc adulte)
189
              if not ClientDataSetFeedsEDt.IsNull
190
              then SeriesBar.AddBar(ClientDataSetFeedsEDt.Value, s, clTeeColor)
191
              else SeriesBar.AddNull(s);
192
            3: // Energie m?tabolisable (porc croissance)
193
              if not ClientDataSetFeedsEMc.IsNull
194
              then SeriesBar.AddBar(ClientDataSetFeedsEMc.Value, s, clTeeColor)
195
              else SeriesBar.AddNull(s);
196
            4: // Energie m?tabolisable (porc adulte)
197
              if not ClientDataSetFeedsEMt.IsNull
198
              then SeriesBar.AddBar(ClientDataSetFeedsEMt.Value, s, clTeeColor)
199
              else SeriesBar.AddNull(s);
200
            5: // Energie nette (porc croissance)
201
              if not ClientDataSetFeedsENc.IsNull
202
              then SeriesBar.AddBar(ClientDataSetFeedsENc.Value, s, clTeeColor)
203
              else SeriesBar.AddNull(s);
204
            6: // Energie nette (porc adulte)
205
              if not ClientDataSetFeedsENt.IsNull
206
              then SeriesBar.AddBar(ClientDataSetFeedsENt.Value, s, clTeeColor)
207
              else SeriesBar.AddNull(s);
208
          end;
209
        2: // Rapports ?nerg?tiques
210
          case ComboBoxRatios0.ItemIndex of
211
            0: // Phosphore digestible / Energie nette (porc croissance)
212
              if not ClientDataSetFeedsPd_ENc.IsNull
213
              then SeriesBar.AddBar(ClientDataSetFeedsPd_ENc.Value, s, clTeeColor)
214
              else SeriesBar.AddNull(s);
215
            1: // Phosphore digestible / Energie nette (porc adulte)
216
              if not ClientDataSetFeedsPd_ENt.IsNull
217
              then SeriesBar.AddBar(ClientDataSetFeedsPd_ENt.Value, s, clTeeColor)
218
              else SeriesBar.AddNull(s);
219
            2: // Lysine digestible / Energie nette (porc croissance)
220
              if not ClientDataSetFeedsLysd_ENc.IsNull
221
              then SeriesBar.AddBar(ClientDataSetFeedsLysd_ENc.Value, s, clTeeColor)
222
              else SeriesBar.AddNull(s);
223
            3: // Lysine digestible / Energie nette (porc adulte)
224
              if not ClientDataSetFeedsLysd_ENt.IsNull
225
              then SeriesBar.AddBar(ClientDataSetFeedsLysd_ENt.Value, s, clTeeColor)
226
              else SeriesBar.AddNull(s);
227
          end;
228
        3: // Acides amin?s totaux
229
          case ComboBoxAA0.ItemIndex of
230
            0: // Lysine
231
              if not ClientDataSetFeedsLys.IsNull
232
              then SeriesBar.AddBar(ClientDataSetFeedsLys.Value, s, clTeeColor)
233
              else SeriesBar.AddNull(s);
234
            1: // Thr?onine
235
              if not ClientDataSetFeedsThr.IsNull
236
              then SeriesBar.AddBar(ClientDataSetFeedsThr.Value, s, clTeeColor)
237
              else SeriesBar.AddNull(s);
238
            2: // M?thionine
239
              if not ClientDataSetFeedsMet.IsNull
240
              then SeriesBar.AddBar(ClientDataSetFeedsMet.Value, s, clTeeColor)
241
              else SeriesBar.AddNull(s);
242
            3: // Cyst?ine
243
              if not ClientDataSetFeedsCys.IsNull
244
              then SeriesBar.AddBar(ClientDataSetFeedsCys.Value, s, clTeeColor)
245
              else SeriesBar.AddNull(s);
246
            4: // M?thionine + Cyst?ine
247
              if not ClientDataSetFeedsMetCys.IsNull
248
              then SeriesBar.AddBar(ClientDataSetFeedsMetCys.Value, s, clTeeColor)
249
              else SeriesBar.AddNull(s);
250
            5: // Tryptophane
251
              if not ClientDataSetFeedsTrp.IsNull
252
              then SeriesBar.AddBar(ClientDataSetFeedsTrp.Value, s, clTeeColor)
253
              else SeriesBar.AddNull(s);
254
            6: // Isoleucine
255
              if not ClientDataSetFeedsIle.IsNull
256
              then SeriesBar.AddBar(ClientDataSetFeedsIle.Value, s, clTeeColor)
257
              else SeriesBar.AddNull(s);
258
            7: // Valine
259
              if not ClientDataSetFeedsVal.IsNull
260
              then SeriesBar.AddBar(ClientDataSetFeedsVal.Value, s, clTeeColor)
261
              else SeriesBar.AddNull(s);
262
            8: // Leucine
263
              if not ClientDataSetFeedsLeu.IsNull
264
              then SeriesBar.AddBar(ClientDataSetFeedsLeu.Value, s, clTeeColor)
265
              else SeriesBar.AddNull(s);
266
            9: // Ph?nylalanine
267
              if not ClientDataSetFeedsPhe.IsNull
268
              then SeriesBar.AddBar(ClientDataSetFeedsPhe.Value, s, clTeeColor)
269
              else SeriesBar.AddNull(s);
270
            10: // Tyrosine
271
              if not ClientDataSetFeedsTyr.IsNull
272
              then SeriesBar.AddBar(ClientDataSetFeedsTyr.Value, s, clTeeColor)
273
              else SeriesBar.AddNull(s);
274
            11: // Ph?nylalanine + Tyrosine
275
              if not ClientDataSetFeedsPheTyr.IsNull
276
              then SeriesBar.AddBar(ClientDataSetFeedsPheTyr.Value, s, clTeeColor)
277
              else SeriesBar.AddNull(s);
278
            12: // Histidine
279
              if not ClientDataSetFeedsHis.IsNull
280
              then SeriesBar.AddBar(ClientDataSetFeedsHis.Value, s, clTeeColor)
281
              else SeriesBar.AddNull(s);
282
            13: // Arginine
283
              if not ClientDataSetFeedsArg.IsNull
284
              then SeriesBar.AddBar(ClientDataSetFeedsArg.Value, s, clTeeColor)
285
              else SeriesBar.AddNull(s);
286
            14: // Alanine
287
              if not ClientDataSetFeedsAla.IsNull
288
              then SeriesBar.AddBar(ClientDataSetFeedsAla.Value, s, clTeeColor)
289
              else SeriesBar.AddNull(s);
290
            15: // Aspartate
291
              if not ClientDataSetFeedsAsp.IsNull
292
              then SeriesBar.AddBar(ClientDataSetFeedsAsp.Value, s, clTeeColor)
293
              else SeriesBar.AddNull(s);
294
            16: // Glutamate
295
              if not ClientDataSetFeedsGlu.IsNull
296
              then SeriesBar.AddBar(ClientDataSetFeedsGlu.Value, s, clTeeColor)
297
              else SeriesBar.AddNull(s);
298
            17: // Glycine
299
              if not ClientDataSetFeedsGly.IsNull
300
              then SeriesBar.AddBar(ClientDataSetFeedsGly.Value, s, clTeeColor)
301
              else SeriesBar.AddNull(s);
302
            18: // S?rine
303
              if not ClientDataSetFeedsSer.IsNull
304
              then SeriesBar.AddBar(ClientDataSetFeedsSer.Value, s, clTeeColor)
305
              else SeriesBar.AddNull(s);
306
            19: // Proline
307
              if not ClientDataSetFeedsPro.IsNull
308
              then SeriesBar.AddBar(ClientDataSetFeedsPro.Value, s, clTeeColor)
309
              else SeriesBar.AddNull(s);
310
          end;
311
        4: // Acides amin?s digestibles
312
          case ComboBoxAA0.ItemIndex of
313
            0: // Lysine
314
              if not ClientDataSetFeedsLysd.IsNull
315
              then SeriesBar.AddBar(ClientDataSetFeedsLysd.Value, s, clTeeColor)
316
              else SeriesBar.AddNull(s);
317
            1: // Thr?onine
318
              if not ClientDataSetFeedsThrd.IsNull
319
              then SeriesBar.AddBar(ClientDataSetFeedsThrd.Value, s, clTeeColor)
320
              else SeriesBar.AddNull(s);
321
            2: // M?thionine
322
              if not ClientDataSetFeedsMetd.IsNull
323
              then SeriesBar.AddBar(ClientDataSetFeedsMetd.Value, s, clTeeColor)
324
              else SeriesBar.AddNull(s);
325
            3: // Cyst?ine
326
              if not ClientDataSetFeedsCysd.IsNull
327
              then SeriesBar.AddBar(ClientDataSetFeedsCysd.Value, s, clTeeColor)
328
              else SeriesBar.AddNull(s);
329
            4: // M?thionine + Cyst?ine
330
              if not ClientDataSetFeedsMetCysd.IsNull
331
              then SeriesBar.AddBar(ClientDataSetFeedsMetCysd.Value, s, clTeeColor)
332
              else SeriesBar.AddNull(s);
333
            5: // Tryptophane
334
              if not ClientDataSetFeedsTrpd.IsNull
335
              then SeriesBar.AddBar(ClientDataSetFeedsTrpd.Value, s, clTeeColor)
336
              else SeriesBar.AddNull(s);
337
            6: // Isoleucine
338
              if not ClientDataSetFeedsIled.IsNull
339
              then SeriesBar.AddBar(ClientDataSetFeedsIled.Value, s, clTeeColor)
340
              else SeriesBar.AddNull(s);
341
            7: // Valine
342
              if not ClientDataSetFeedsVald.IsNull
343
              then SeriesBar.AddBar(ClientDataSetFeedsVald.Value, s, clTeeColor)
344
              else SeriesBar.AddNull(s);
345
            8: // Leucine
346
              if not ClientDataSetFeedsLeud.IsNull
347
              then SeriesBar.AddBar(ClientDataSetFeedsLeud.Value, s, clTeeColor)
348
              else SeriesBar.AddNull(s);
349
            9: // Ph?nylalanine
350
              if not ClientDataSetFeedsPhed.IsNull
351
              then SeriesBar.AddBar(ClientDataSetFeedsPhed.Value, s, clTeeColor)
352
              else SeriesBar.AddNull(s);
353
            10: // Tyrosine
354
              if not ClientDataSetFeedsTyrd.IsNull
355
              then SeriesBar.AddBar(ClientDataSetFeedsTyrd.Value, s, clTeeColor)
356
              else SeriesBar.AddNull(s);
357
            11: // Ph?nylalanine + Tyrosine
358
              if not ClientDataSetFeedsPheTyrd.IsNull
359
              then SeriesBar.AddBar(ClientDataSetFeedsPheTyrd.Value, s, clTeeColor)
360
              else SeriesBar.AddNull(s);
361
            12: // Histidine
362
              if not ClientDataSetFeedsHisd.IsNull
363
              then SeriesBar.AddBar(ClientDataSetFeedsHisd.Value, s, clTeeColor)
364
              else SeriesBar.AddNull(s);
365
            13: // Arginine
366
              if not ClientDataSetFeedsArgd.IsNull
367
              then SeriesBar.AddBar(ClientDataSetFeedsArgd.Value, s, clTeeColor)
368
              else SeriesBar.AddNull(s);
369
            14: // Alanine
370
              if not ClientDataSetFeedsAlad.IsNull
371
              then SeriesBar.AddBar(ClientDataSetFeedsAlad.Value, s, clTeeColor)
372
              else SeriesBar.AddNull(s);
373
            15: // Aspartate
374
              if not ClientDataSetFeedsAspd.IsNull
375
              then SeriesBar.AddBar(ClientDataSetFeedsAspd.Value, s, clTeeColor)
376
              else SeriesBar.AddNull(s);
377
            16: // Glutamate
378
              if not ClientDataSetFeedsGlud.IsNull
379
              then SeriesBar.AddBar(ClientDataSetFeedsGlud.Value, s, clTeeColor)
380
              else SeriesBar.AddNull(s);
381
            17: // Glycine
382
              if not ClientDataSetFeedsGlyd.IsNull
383
              then SeriesBar.AddBar(ClientDataSetFeedsGlyd.Value, s, clTeeColor)
384
              else SeriesBar.AddNull(s);
385
            18: // S?rine
386
              if not ClientDataSetFeedsSerd.IsNull
387
              then SeriesBar.AddBar(ClientDataSetFeedsSerd.Value, s, clTeeColor)
388
              else SeriesBar.AddNull(s);
389
            19: // Proline
390
              if not ClientDataSetFeedsProd.IsNull
391
              then SeriesBar.AddBar(ClientDataSetFeedsProd.Value, s, clTeeColor)
392
              else SeriesBar.AddNull(s);
393
          end;
394
        5: // Profils acides amin?s
395
          case ComboBoxAA0.ItemIndex of
396
            0: // Lysine
397
              if not ClientDataSetFeedsLysd.IsNull and (ClientDataSetFeedsLysd.Value <> 0)
398
              then SeriesBar.AddBar(100, s, clTeeColor)
399
              else SeriesBar.AddNull(s);
400
            1: // Thr?onine
401
              if not ClientDataSetFeedsThrd_Lysd.IsNull
402
              then SeriesBar.AddBar(ClientDataSetFeedsThrd_Lysd.Value, s, clTeeColor)
403
              else SeriesBar.AddNull(s);
404
            2: // M?thionine
405
              if not ClientDataSetFeedsMetd_Lysd.IsNull
406
              then SeriesBar.AddBar(ClientDataSetFeedsMetd_Lysd.Value, s, clTeeColor)
407
              else SeriesBar.AddNull(s);
408
            3: // Cyst?ine
409
              if not ClientDataSetFeedsCysd_Lysd.IsNull
410
              then SeriesBar.AddBar(ClientDataSetFeedsCysd_Lysd.Value, s, clTeeColor)
411
              else SeriesBar.AddNull(s);
412
            4: // M?thionine + Cyst?ine
413
              if not ClientDataSetFeedsMetCysd_Lysd.IsNull
414
              then SeriesBar.AddBar(ClientDataSetFeedsMetCysd_Lysd.Value, s, clTeeColor)
415
              else SeriesBar.AddNull(s);
416
            5: // Tryptophane
417
              if not ClientDataSetFeedsTrpd_Lysd.IsNull
418
              then SeriesBar.AddBar(ClientDataSetFeedsTrpd_Lysd.Value, s, clTeeColor)
419
              else SeriesBar.AddNull(s);
420
            6: // Isoleucine
421
              if not ClientDataSetFeedsIled_Lysd.IsNull
422
              then SeriesBar.AddBar(ClientDataSetFeedsIled_Lysd.Value, s, clTeeColor)
423
              else SeriesBar.AddNull(s);
424
            7: // Valine
425
              if not ClientDataSetFeedsVald_Lysd.IsNull
426
              then SeriesBar.AddBar(ClientDataSetFeedsVald_Lysd.Value, s, clTeeColor)
427
              else SeriesBar.AddNull(s);
428
            8: // Leucine
429
              if not ClientDataSetFeedsLeud_Lysd.IsNull
430
              then SeriesBar.AddBar(ClientDataSetFeedsLeud_Lysd.Value, s, clTeeColor)
431
              else SeriesBar.AddNull(s);
432
            9: // Ph?nylalanine
433
              if not ClientDataSetFeedsPhed_Lysd.IsNull
434
              then SeriesBar.AddBar(ClientDataSetFeedsPhed_Lysd.Value, s, clTeeColor)
435
              else SeriesBar.AddNull(s);
436
            10: // Tyrosine
437
              if not ClientDataSetFeedsTyrd_Lysd.IsNull
438
              then SeriesBar.AddBar(ClientDataSetFeedsTyrd_Lysd.Value, s, clTeeColor)
439
              else SeriesBar.AddNull(s);
440
            11: // Ph?nylalanine + Tyrosine
441
              if not ClientDataSetFeedsPheTyrd_Lysd.IsNull
442
              then SeriesBar.AddBar(ClientDataSetFeedsPheTyrd_Lysd.Value, s, clTeeColor)
443
              else SeriesBar.AddNull(s);
444
            12: // Histidine
445
              if not ClientDataSetFeedsHisd_Lysd.IsNull
446
              then SeriesBar.AddBar(ClientDataSetFeedsHisd_Lysd.Value, s, clTeeColor)
447
              else SeriesBar.AddNull(s);
448
            13: // Arginine
449
              if not ClientDataSetFeedsArgd_Lysd.IsNull
450
              then SeriesBar.AddBar(ClientDataSetFeedsArgd_Lysd.Value, s, clTeeColor)
451
              else SeriesBar.AddNull(s);
452
            14: // Alanine
453
              if not ClientDataSetFeedsAlad_Lysd.IsNull
454
              then SeriesBar.AddBar(ClientDataSetFeedsAlad_Lysd.Value, s, clTeeColor)
455
              else SeriesBar.AddNull(s);
456
            15: // Aspartate
457
              if not ClientDataSetFeedsAspd_Lysd.IsNull
458
              then SeriesBar.AddBar(ClientDataSetFeedsAspd_Lysd.Value, s, clTeeColor)
459
              else SeriesBar.AddNull(s);
460
            16: // Glutamate
461
              if not ClientDataSetFeedsGlud_Lysd.IsNull
462
              then SeriesBar.AddBar(ClientDataSetFeedsGlud_Lysd.Value, s, clTeeColor)
463
              else SeriesBar.AddNull(s);
464
            17: // Glycine
465
              if not ClientDataSetFeedsGlyd_Lysd.IsNull
466
              then SeriesBar.AddBar(ClientDataSetFeedsGlyd_Lysd.Value, s, clTeeColor)
467
              else SeriesBar.AddNull(s);
468
            18: // S?rine
469
              if not ClientDataSetFeedsSerd_Lysd.IsNull
470
              then SeriesBar.AddBar(ClientDataSetFeedsSerd_Lysd.Value, s, clTeeColor)
471
              else SeriesBar.AddNull(s);
472
            19: // Proline
473
              if not ClientDataSetFeedsProd_Lysd.IsNull
474
              then SeriesBar.AddBar(ClientDataSetFeedsProd_Lysd.Value, s, clTeeColor)
475
              else SeriesBar.AddNull(s);
476
          end;
477
        6: // Min?raux
478
          case ComboBoxMinerals0.ItemIndex of
479
            0: // Calcium
480
              if not ClientDataSetFeedsCa.IsNull
481
              then SeriesBar.AddBar(ClientDataSetFeedsCa.Value, s, clTeeColor)
482
              else SeriesBar.AddNull(s);
483
            1: // Phosphore
484
              if not ClientDataSetFeedsP.IsNull
485
              then SeriesBar.AddBar(ClientDataSetFeedsP.Value, s, clTeeColor)
486
              else SeriesBar.AddNull(s);
487 4 avalancogn
            2: // Sodium
488
              if not ClientDataSetFeedsNa.IsNull
489
              then SeriesBar.AddBar(ClientDataSetFeedsNa.Value, s, clTeeColor)
490
              else SeriesBar.AddNull(s);
491
            3: // Potassium
492
              if not ClientDataSetFeedsK.IsNull
493
              then SeriesBar.AddBar(ClientDataSetFeedsK.Value, s, clTeeColor)
494
              else SeriesBar.AddNull(s);
495
            4: // Chlore
496
              if not ClientDataSetFeedsCl.IsNull
497
              then SeriesBar.AddBar(ClientDataSetFeedsCl.Value, s, clTeeColor)
498
              else SeriesBar.AddNull(s);
499
            5: // Phosphore digestible
500 1 avalancogn
              if not ClientDataSetFeedsPd.IsNull
501
              then SeriesBar.AddBar(ClientDataSetFeedsPd.Value, s, clTeeColor)
502
              else SeriesBar.AddNull(s);
503 5 avalancogn
            6: // Bilan ?lectrolytique
504
              if not ClientDataSetFeedsBE.IsNull
505
              then SeriesBar.AddBar(ClientDataSetFeedsBE.Value, s, clTeeColor)
506
              else SeriesBar.AddNull(s);
507 1 avalancogn
          end;
508
      end;
509 5 avalancogn
    end;
510 1 avalancogn
  end;
511
512
begin
513
  Chart0.Title.Clear;
514
  Chart0.Title.Text.Add(ComboBoxType0.Text);
515
  case ComboBoxType0.ItemIndex of
516
    0: // Analyse proximale
517
      Chart0.Title.Text.Add(ComboBoxProximal0.Text);
518
    1: // Valeurs ?nerg?tiques
519
      Chart0.Title.Text.Add(ComboBoxEnergy0.Text);
520
    2: // Rapports ?nerg?tiques
521
      Chart0.Title.Text.Add(ComboBoxRatios0.Text);
522
    3, 4, 5: // Acides amin?s
523
      Chart0.Title.Text.Add(ComboBoxAA0.Text);
524
    6: // Min?raux
525
      Chart0.Title.Text.Add(ComboBoxMinerals0.Text);
526
  end;
527
  Chart0.SubTitle.Clear;
528
  case ComboBoxType0.ItemIndex of
529
    0: // Analyse proximale
530
      with FormOptions do
531
        if Expression = 0
532
        then // sur frais
533
          Chart0.SubTitle.Text.Add(ComboBoxProximal.Items[Proximal])
534
        else // sur mati?re s?che
535
          Chart0.SubTitle.Text.Add(Format('%s %s', [ComboBoxProximal.Items[Proximal], _('DM')]));
536
    1: // Valeurs ?nerg?tiques
537
      with FormOptions do
538
        if Expression = 0
539
        then // sur frais
540
          Chart0.SubTitle.Text.Add(ComboBoxEnergy.Items[Energy])
541
        else // sur mati?re s?che
542
          Chart0.SubTitle.Text.Add(Format('%s %s', [ComboBoxEnergy.Items[Energy], _('DM')]));
543
    2: // Rapports ?nerg?tiques
544
      with FormOptions do
545
        if Energy = 0
546
        then // MJ
547
          Chart0.SubTitle.Text.Add(_('g/MJ'))
548
        else // kcal
549
          Chart0.SubTitle.Text.Add(_('g/1000kcal'));
550
    3, 4: // Acides amin?s totaux et digestibles
551
      with FormOptions do
552
        if Expression = 0
553
        then // sur frais
554
          Chart0.SubTitle.Text.Add(ComboBoxAA.Items[AA])
555
        else // sur mati?re s?che
556
          Chart0.SubTitle.Text.Add(Format('%s %s', [ComboBoxAA.Items[AA], _('DM')]));
557
    5: // Profils acides amin?s
558
      Chart0.SubTitle.Text.Add('%');
559
    6: // Min?raux
560 5 avalancogn
      if ComboBoxMinerals0.ItemIndex = 6
561
      then // Bilan ?lectrolytique
562
        with FormOptions do
563
          if Expression = 0
564
          then // sur frais
565
            Chart0.SubTitle.Text.Add(_('mEq/kg'))
566
          else // sur mati?re s?che
567
            Chart0.SubTitle.Text.Add(Format('%s %s', [_('mEq/kg'), _('DM')]))
568
      else
569
        with FormOptions do
570
          if Expression = 0
571
          then // sur frais
572
            Chart0.SubTitle.Text.Add(ComboBoxMinerals.Items[Minerals])
573
          else // sur mati?re s?che
574
            Chart0.SubTitle.Text.Add(Format('%s %s', [ComboBoxMinerals.Items[Minerals], _('DM')]));
575 1 avalancogn
  end;
576
  case ComboBoxType0.ItemIndex of
577
    0: // Analyse proximale
578
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.ProximalFormat;
579
    1: // Valeurs ?nerg?tiques
580
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.EnergyFormat;
581
    2: // Rapports ?nerg?tiques
582
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.DecimalFormat(2);
583
    3, 4: // Acides amin?s totaux et digestibles
584
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.AAFormat;
585
    5: // Profils acides amin?s
586
      Chart0.LeftAxis.AxisValuesFormat := FormOptions.DecimalFormat(0);
587
    6: // Min?raux
588 5 avalancogn
      if ComboBoxMinerals0.ItemIndex = 6
589
      then // Bilan ?lectrolytique
590
        Chart0.LeftAxis.AxisValuesFormat := FormOptions.DecimalFormat(1)
591
      else
592
        Chart0.LeftAxis.AxisValuesFormat := FormOptions.MineralsFormat;
593 1 avalancogn
  end;
594
  SeriesBar.Clear;
595
  SeriesBar.ValueFormat := Chart0.LeftAxis.AxisValuesFormat;
596
  if ComboBoxDiet1.ItemIndex <> -1
597
  then
598
    with DataModuleDeclaration do
599
    begin
600
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet1.Text, []);
601
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet1.Text) + 1;
602
      s := StrTrunc(ComboBoxDiet1.Text, 30);
603
      AddBarValue;
604
    end;
605
  if ComboBoxDiet2.ItemIndex <> -1
606
  then
607
    with DataModuleDeclaration do
608
    begin
609
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet2.Text, []);
610
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet2.Text) + 1;
611
      s := StrTrunc(ComboBoxDiet2.Text, 30);
612
      AddBarValue;
613
    end;
614
  if ComboBoxDiet3.ItemIndex <> -1
615
  then
616
    with DataModuleDeclaration do
617
    begin
618
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet3.Text, []);
619
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet3.Text) + 1;
620
      s := StrTrunc(ComboBoxDiet3.Text, 30);
621
      AddBarValue;
622
    end;
623
  if ComboBoxDiet4.ItemIndex <> -1
624
  then
625
    with DataModuleDeclaration do
626
    begin
627
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet4.Text, []);
628
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet4.Text) + 1;
629
      s := StrTrunc(ComboBoxDiet4.Text, 30);
630
      AddBarValue;
631
    end;
632
  if ComboBoxDiet5.ItemIndex <> -1
633
  then
634
    with DataModuleDeclaration do
635
    begin
636
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet5.Text, []);
637
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet5.Text) + 1;
638
      s := StrTrunc(ComboBoxDiet5.Text, 30);
639
      AddBarValue;
640
    end;
641
  if ComboBoxDiet6.ItemIndex <> -1
642
  then
643
    with DataModuleDeclaration do
644
    begin
645
      ClientDataSetFeeds.Locate('Name', ComboBoxDiet6.Text, []);
646
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxDiet6.Text) + 1;
647
      s := StrTrunc(ComboBoxDiet6.Text, 30);
648
      AddBarValue;
649
    end;
650
end;
651
652
procedure TFormFeedsCharts.ComboBoxFeed1Change(Sender: TObject);
653
var
654
  IngredientName: String;
655
  Cumul, Ratio, Total, Value: Double;
656
  FeedBar: TBarSeries;
657
begin
658
//  while ChartFeed1.SeriesCount > 0 do
659
//    ChartFeed1.Series[0].Free;
660
  ChartFeed1.FreeAllSeries(nil);
661
  ChartFeed1.Title.Clear;
662
  ChartFeed1.SubTitle.Clear;
663
  if ComboBoxFeed1.ItemIndex <> -1
664
  then
665
    with DataModuleDeclaration do
666
    begin
667
      ClientDataSetFeeds.Locate('Name', ComboBoxFeed1.Text, []);
668
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxFeed1.Text) + 1;
669
      ChartFeed1.AxisVisible := True;
670
      ChartFeed1.Title.Text.Add(ClientDataSetFeedsName.Value);
671
      ChartFeed1.SubTitle.Text.Add(ComboBoxType.Text);
672
      case ComboBoxType.ItemIndex of
673
        0: // Analyse proximale
674
          ChartFeed1.SubTitle.Text.Add(ComboBoxProximal.Text);
675
        1: // Valeurs ?nerg?tiques
676
          ChartFeed1.SubTitle.Text.Add(ComboBoxEnergy.Text);
677
        2, 3: // Acides amin?s
678
          ChartFeed1.SubTitle.Text.Add(ComboBoxAA.Text);
679
        4: // Min?raux
680
          ChartFeed1.SubTitle.Text.Add(ComboBoxMinerals.Text);
681
      end;
682
      case ComboBoxType.ItemIndex of
683
        0: // Analyse proximale
684
          case ComboBoxProximal.ItemIndex of
685
            0: // Composition
686
              Cumul := OutputIncorporation(1, FormOptions.Incorporation);
687
            1: // MS
688
              Cumul := ClientDataSetFeedsMS.Value;
689
            2: // MM
690
              Cumul := ClientDataSetFeedsMM.Value;
691
            3: // MAT
692
              Cumul := ClientDataSetFeedsMAT.Value;
693
            4: // MG
694
              Cumul := ClientDataSetFeedsMG.Value;
695
            5: // CB
696
              Cumul := ClientDataSetFeedsCB.Value;
697
            6: // NDF
698
              Cumul := ClientDataSetFeedsNDF.Value;
699
            7: // ADF
700
              Cumul := ClientDataSetFeedsADF.Value;
701
            8: // ADL
702
              Cumul := ClientDataSetFeedsADL.Value;
703
            9: // Amidon
704
              Cumul := ClientDataSetFeedsAmidon.Value;
705
            10: // Sucres
706
              Cumul := ClientDataSetFeedsSucres.Value;
707
            else
708
              Cumul := 0;
709
          end;
710
        1: // Valeurs ?nerg?tiques
711
          case ComboBoxEnergy.ItemIndex of
712
            0: // Energie brute
713
              Cumul := ClientDataSetFeedsEB.Value;
714
            1: // Energie digestible (porc croissance)
715
              Cumul := ClientDataSetFeedsEDc.Value;
716
            2: // Energie digestible (porc adulte)
717
              Cumul := ClientDataSetFeedsEDt.Value;
718
            3: // Energie m?tabolisable (porc croissance)
719
              Cumul := ClientDataSetFeedsEMc.Value;
720
            4: // Energie m?tabolisable (porc adulte)
721
              Cumul := ClientDataSetFeedsEMt.Value;
722
            5: // Energie nette (porc croissance)
723
              Cumul := ClientDataSetFeedsENc.Value;
724
            6: // Energie nette (porc adulte)
725
              Cumul := ClientDataSetFeedsENt.Value;
726
            else
727
              Cumul := 0;
728
          end;
729
        2: // Acides amin?s totaux
730
          case ComboBoxAA.ItemIndex of
731
            0: // Lysine
732
              Cumul := ClientDataSetFeedsLys.Value;
733
            1: // Thr?onine
734
              Cumul := ClientDataSetFeedsThr.Value;
735
            2: // M?thionine
736
              Cumul := ClientDataSetFeedsMet.Value;
737
            3: // Cyst?ine
738
              Cumul := ClientDataSetFeedsCys.Value;
739
            4: // M?thionine + Cyst?ine
740
              Cumul := ClientDataSetFeedsMetCys.Value;
741
            5: // Tryptophane
742
              Cumul := ClientDataSetFeedsTrp.Value;
743
            6: // Isoleucine
744
              Cumul := ClientDataSetFeedsIle.Value;
745
            7: // Valine
746
              Cumul := ClientDataSetFeedsVal.Value;
747
            8: // Leucine
748
              Cumul := ClientDataSetFeedsLeu.Value;
749
            9: // Ph?nylalanine
750
              Cumul := ClientDataSetFeedsPhe.Value;
751
            10: // Tyrosine
752
              Cumul := ClientDataSetFeedsTyr.Value;
753
            11: // Ph?nylalanine + Tyrosine
754
              Cumul := ClientDataSetFeedsPheTyr.Value;
755
            12: // Histidine
756
              Cumul := ClientDataSetFeedsHis.Value;
757
            13: // Arginine
758
              Cumul := ClientDataSetFeedsArg.Value;
759
            14: // Alanine
760
              Cumul := ClientDataSetFeedsAla.Value;
761
            15: // Aspartate
762
              Cumul := ClientDataSetFeedsAsp.Value;
763
            16: // Glutamate
764
              Cumul := ClientDataSetFeedsGlu.Value;
765
            17: // Glycine
766
              Cumul := ClientDataSetFeedsGly.Value;
767
            18: // S?rine
768
              Cumul := ClientDataSetFeedsSer.Value;
769
            19: // Proline
770
              Cumul := ClientDataSetFeedsPro.Value;
771
            else
772
              Cumul := 0;
773
          end;
774
        3: // Acides amin?s digestibles
775
          case ComboBoxAA.ItemIndex of
776
            0: // Lysine
777
              Cumul := ClientDataSetFeedsLysd.Value;
778
            1: // Thr?onine
779
              Cumul := ClientDataSetFeedsThrd.Value;
780
            2: // M?thionine
781
              Cumul := ClientDataSetFeedsMetd.Value;
782
            3: // Cyst?ine
783
              Cumul := ClientDataSetFeedsCysd.Value;
784
            4: // M?thionine + Cyst?ine
785
              Cumul := ClientDataSetFeedsMetCysd.Value;
786
            5: // Tryptophane
787
              Cumul := ClientDataSetFeedsTrpd.Value;
788
            6: // Isoleucine
789
              Cumul := ClientDataSetFeedsIled.Value;
790
            7: // Valine
791
              Cumul := ClientDataSetFeedsVald.Value;
792
            8: // Leucine
793
              Cumul := ClientDataSetFeedsLeud.Value;
794
            9: // Ph?nylalanine
795
              Cumul := ClientDataSetFeedsPhed.Value;
796
            10: // Tyrosine
797
              Cumul := ClientDataSetFeedsTyrd.Value;
798
            11: // Ph?nylalanine + Tyrosine
799
              Cumul := ClientDataSetFeedsPheTyrd.Value;
800
            12: // Histidine
801
              Cumul := ClientDataSetFeedsHisd.Value;
802
            13: // Arginine
803
              Cumul := ClientDataSetFeedsArgd.Value;
804
            14: // Alanine
805
              Cumul := ClientDataSetFeedsAlad.Value;
806
            15: // Aspartate
807
              Cumul := ClientDataSetFeedsAspd.Value;
808
            16: // Glutamate
809
              Cumul := ClientDataSetFeedsGlud.Value;
810
            17: // Glycine
811
              Cumul := ClientDataSetFeedsGlyd.Value;
812
            18: // S?rine
813
              Cumul := ClientDataSetFeedsSerd.Value;
814
            19: // Proline
815
              Cumul := ClientDataSetFeedsProd.Value;
816
            else
817
              Cumul := 0;
818
          end;
819
        4: // Min?raux
820
          case ComboBoxMinerals.ItemIndex of
821
            0: // Calcium
822
              Cumul := ClientDataSetFeedsCa.Value;
823
            1: // Phosphore
824
              Cumul := ClientDataSetFeedsP.Value;
825 4 avalancogn
            2: // Sodium
826
              Cumul := ClientDataSetFeedsNa.Value;
827
            3: // Potassium
828
              Cumul := ClientDataSetFeedsK.Value;
829
            4: // Chlore
830
              Cumul := ClientDataSetFeedsCl.Value;
831
            5: // Phosphore digestible
832 1 avalancogn
              Cumul := ClientDataSetFeedsPd.Value;
833 5 avalancogn
            6: // Bilan ?lectrolytique
834
              Cumul := ClientDataSetFeedsBE.Value;
835 1 avalancogn
            else
836
              Cumul := 0;
837
          end;
838
        else
839
          Cumul := 0;
840
      end;
841
      if Cumul = 0
842
      then // Division par z?ro
843
        Cumul := 1;
844
      ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
845
      ClientDataSetComposition.Filtered := True;
846
      ClientDataSetComposition.First;
847
      Total := 0;
848
      while not ClientDataSetComposition.Eof do
849
      begin
850
        if ClientDataSetCompositionUser.Value
851
        then
852
          ClientDataSetIngredients.Filter := Format('Id = %d and User', [ClientDataSetCompositionIngredient.Value])
853
        else
854
          ClientDataSetIngredients.Filter := Format('Id = %d and not User', [ClientDataSetCompositionIngredient.Value]);
855
        ClientDataSetIngredients.Filtered := True;
856
        IngredientName := StrTrunc(ClientDataSetIngredientsName.Value, 25);
857
        Ratio := InputIncorporation(ClientDataSetCompositionLevel.Value, FormOptions.Incorporation);
858
        if (FormOptions.Expression = 0)
859
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
860
        then // Conversion frais -> sec (mati?re s?che de la mati?re premi?re) - except? pour Composition et MS
861
          Ratio := Ratio / InputProximal(ClientDataSetIngredientsMS.Value, 1, 1, FormOptions.Proximal);
862
        RapMS := InputProximal(ClientDataSetCompositionMS.Value, 1, 1, FormOptions.Proximal);
863
        if ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
864
        then // Conversion sec -> frais (mati?re s?che de la composition) - except? pour Composition et MS
865
          Ratio := Ratio * RapMS;
866
        case ComboBoxType.ItemIndex of
867
          0: // Analyse proximale
868
            case ComboBoxProximal.ItemIndex of
869
              0: // Composition
870
                Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
871
              1: // MS
872
                Value := ClientDataSetCompositionMS.Value * Ratio;
873
              2: // MM
874
                Value := ClientDataSetIngredientsMM.Value * Ratio;
875
              3: // MAT
876
                Value := ClientDataSetIngredientsMAT.Value * Ratio;
877
              4: // MG
878
                Value := ClientDataSetIngredientsMG.Value * Ratio;
879
              5: // CB
880
                Value := ClientDataSetIngredientsCB.Value * Ratio;
881
              6: // NDF
882
                Value := ClientDataSetIngredientsNDF.Value * Ratio;
883
              7: // ADF
884
                Value := ClientDataSetIngredientsADF.Value * Ratio;
885
              8: // ADL
886
                Value := ClientDataSetIngredientsADL.Value * Ratio;
887
              9: // Amidon
888
                Value := ClientDataSetIngredientsAmidon.Value * Ratio;
889
              10: // Sucres
890
                Value := ClientDataSetIngredientsSucres.Value * Ratio;
891
              else
892
                Value := 0;
893
            end;
894
          1: // Valeurs ?nerg?tiques
895
            case ComboBoxEnergy.ItemIndex of
896
              0: // Energie brute
897
                Value := ClientDataSetIngredientsEB.Value * Ratio;
898
              1: // Energie digestible (porc croissance)
899
                Value := ClientDataSetIngredientsEDc.Value * Ratio;
900
              2: // Energie digestible (porc adulte)
901
                Value := ClientDataSetIngredientsEDt.Value * Ratio;
902
              3: // Energie m?tabolisable (porc croissance)
903
                Value := ClientDataSetIngredientsEMc.Value * Ratio;
904
              4: // Energie m?tabolisable (porc adulte)
905
                Value := ClientDataSetIngredientsEMt.Value * Ratio;
906
              5: // Energie nette (porc croissance)
907
                Value := ClientDataSetIngredientsENc.Value * Ratio;
908
              6: // Energie nette (porc adulte)
909
                Value := ClientDataSetIngredientsENt.Value * Ratio;
910
              else
911
                Value := 0;
912
            end;
913
          2: // Acides amin?s totaux
914
            case ComboBoxAA.ItemIndex of
915
              0: // Lysine
916
                Value := ClientDataSetIngredientsLys.Value * Ratio;
917
              1: // Thr?onine
918
                Value := ClientDataSetIngredientsThr.Value * Ratio;
919
              2: // M?thionine
920
                Value := ClientDataSetIngredientsMet.Value * Ratio;
921
              3: // Cyst?ine
922
                Value := ClientDataSetIngredientsCys.Value * Ratio;
923
              4: // M?thionine + Cyst?ine
924
                Value := ClientDataSetIngredientsMetCys.Value * Ratio;
925
              5: // Tryptophane
926
                Value := ClientDataSetIngredientsTrp.Value * Ratio;
927
              6: // Isoleucine
928
                Value := ClientDataSetIngredientsIle.Value * Ratio;
929
              7: // Valine
930
                Value := ClientDataSetIngredientsVal.Value * Ratio;
931
              8: // Leucine
932
                Value := ClientDataSetIngredientsLeu.Value * Ratio;
933
              9: // Ph?nylalanine
934
                Value := ClientDataSetIngredientsPhe.Value * Ratio;
935
              10: // Tyrosine
936
                Value := ClientDataSetIngredientsTyr.Value * Ratio;
937
              11: // Ph?nylalanine + Tyrosine
938
                Value := ClientDataSetIngredientsPheTyr.Value * Ratio;
939
              12: // Histidine
940
                Value := ClientDataSetIngredientsHis.Value * Ratio;
941
              13: // Arginine
942
                Value := ClientDataSetIngredientsArg.Value * Ratio;
943
              14: // Alanine
944
                Value := ClientDataSetIngredientsAla.Value * Ratio;
945
              15: // Aspartate
946
                Value := ClientDataSetIngredientsAsp.Value * Ratio;
947
              16: // Glutamate
948
                Value := ClientDataSetIngredientsGlu.Value * Ratio;
949
              17: // Glycine
950
                Value := ClientDataSetIngredientsGly.Value * Ratio;
951
              18: // S?rine
952
                Value := ClientDataSetIngredientsSer.Value * Ratio;
953
              19: // Proline
954
                Value := ClientDataSetIngredientsPro.Value * Ratio;
955
              else
956
                Value := 0;
957
            end;
958
          3: // Acides amin?s digestibles
959
            case ComboBoxAA.ItemIndex of
960
              0: // Lysine
961
                Value := ClientDataSetIngredientsLysd.Value * Ratio;
962
              1: // Thr?onine
963
                Value := ClientDataSetIngredientsThrd.Value * Ratio;
964
              2: // M?thionine
965
                Value := ClientDataSetIngredientsMetd.Value * Ratio;
966
              3: // Cyst?ine
967
                Value := ClientDataSetIngredientsCysd.Value * Ratio;
968
              4: // M?thionine + Cyst?ine
969
                Value := ClientDataSetIngredientsMetCysd.Value * Ratio;
970
              5: // Tryptophane
971
                Value := ClientDataSetIngredientsTrpd.Value * Ratio;
972
              6: // Isoleucine
973
                Value := ClientDataSetIngredientsIled.Value * Ratio;
974
              7: // Valine
975
                Value := ClientDataSetIngredientsVald.Value * Ratio;
976
              8: // Leucine
977
                Value := ClientDataSetIngredientsLeud.Value * Ratio;
978
              9: // Ph?nylalanine
979
                Value := ClientDataSetIngredientsPhed.Value * Ratio;
980
              10: // Tyrosine
981
                Value := ClientDataSetIngredientsTyrd.Value * Ratio;
982
              11: // Ph?nylalanine + Tyrosine
983
                Value := ClientDataSetIngredientsPheTyrd.Value * Ratio;
984
              12: // Histidine
985
                Value := ClientDataSetIngredientsHisd.Value * Ratio;
986
              13: // Arginine
987
                Value := ClientDataSetIngredientsArgd.Value * Ratio;
988
              14: // Alanine
989
                Value := ClientDataSetIngredientsAlad.Value * Ratio;
990
              15: // Aspartate
991
                Value := ClientDataSetIngredientsAspd.Value * Ratio;
992
              16: // Glutamate
993
                Value := ClientDataSetIngredientsGlud.Value * Ratio;
994
              17: // Glycine
995
                Value := ClientDataSetIngredientsGlyd.Value * Ratio;
996
              18: // S?rine
997
                Value := ClientDataSetIngredientsSerd.Value * Ratio;
998
              19: // Proline
999
                Value := ClientDataSetIngredientsProd.Value * Ratio;
1000
              else
1001
                Value := 0;
1002
            end;
1003
          4: // Min?raux
1004
            case ComboBoxMinerals.ItemIndex of
1005
              0: // Calcium
1006
                Value := ClientDataSetIngredientsCa.Value * Ratio;
1007
              1: // Phosphore
1008
                Value := ClientDataSetIngredientsP.Value * Ratio;
1009 4 avalancogn
              2: // Sodium
1010
                Value := ClientDataSetIngredientsNa.Value * Ratio;
1011
              3: // Potassium
1012
                Value := ClientDataSetIngredientsK.Value * Ratio;
1013
              4: // Chlore
1014
                Value := ClientDataSetIngredientsCl.Value * Ratio;
1015
              5: // Phosphore digestible
1016 1 avalancogn
                if ClientDataSetFeedsPresentation.Value = 0
1017
                then // Farine (dPphy)
1018
                  Value := ClientDataSetIngredientsdPphy.Value / 100 * ClientDataSetIngredientsP.Value * Ratio
1019
                else // Granul?s (dP)
1020
                  Value := ClientDataSetIngredientsdP.Value / 100 * ClientDataSetIngredientsP.Value * Ratio;
1021 5 avalancogn
              6: // Bilan ?lectrolytique
1022
                Value := ClientDataSetIngredientsBE.Value * Ratio;
1023 1 avalancogn
              else
1024
                Value := 0;
1025
            end;
1026
          else
1027
            Value := 0;
1028
        end;
1029
        if (FormOptions.Expression = 1)
1030
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1031
        then // Conversion frais -> sec (mati?re s?che du r?gime) - except? pour Composition et MS
1032
          Value := Value / InputProximal(ClientDataSetFeedsMS.Value, 1, 1, FormOptions.Proximal);
1033
        if Value > 0
1034
        then // Prendre en compte la valeur
1035
        begin
1036
          FeedBar := TBarSeries.Create(ChartFeed1);
1037
          FeedBar.ParentChart := ChartFeed1;
1038
          FeedBar.Title := Format('%s (%1.2f %%)', [IngredientName, Value / Cumul * 100]);
1039
          FeedBar.BarPen.Color := FeedBar.SeriesColor;
1040
          FeedBar.MultiBar := mbStacked100;
1041
          FeedBar.Marks.Visible := False;
1042
          ChartFeed1.AddSeries(FeedBar);
1043
          FeedBar.AddBar(Value, '', clTeeColor);
1044
          Total := Total + Value;
1045
        end;
1046
        ClientDataSetComposition.Next;
1047
      end;
1048
      ClientDataSetIngredients.Filtered := False;
1049
      ClientDataSetIngredients.Filter := '';
1050
      // Cas particuliers
1051
      if (ComboBoxType.ItemIndex = 1)
1052
      and ((ComboBoxEnergy.ItemIndex = 1)
1053
        or (ComboBoxEnergy.ItemIndex = 3)
1054
        or (ComboBoxEnergy.ItemIndex = 5))
1055
      and (ClientDataSetFeedsBonusC.Value > 0)
1056
      then // Bonus ?nergie (porc croissance)
1057
      begin
1058
        case ComboBoxEnergy.ItemIndex of
1059
          1: Value := ClientDataSetFeedsEDc.Value - Total;
1060
          3: Value := ClientDataSetFeedsEMc.Value - Total;
1061
          5: Value := ClientDataSetFeedsENc.Value - Total;
1062
          else Value := 0;
1063
        end;
1064
        FeedBar := TBarSeries.Create(ChartFeed1);
1065
        FeedBar.ParentChart := ChartFeed1;
1066
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
1067
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1068
        FeedBar.MultiBar := mbStacked100;
1069
        FeedBar.Marks.Visible := False;
1070
        ChartFeed1.AddSeries(FeedBar);
1071
        FeedBar.AddBar(Value, '', clTeeColor);
1072
        Total := Total + Value;
1073
      end;
1074
      if (ComboBoxType.ItemIndex = 1)
1075
      and ((ComboBoxEnergy.ItemIndex = 2)
1076
        or (ComboBoxEnergy.ItemIndex = 4)
1077
        or (ComboBoxEnergy.ItemIndex = 6))
1078
      and (ClientDataSetFeedsBonusT.Value > 0)
1079
      then // Bonus ?nergie (porc adulte)
1080
      begin
1081
        case ComboBoxEnergy.ItemIndex of
1082
          2: Value := ClientDataSetFeedsEDt.Value - Total;
1083
          4: Value := ClientDataSetFeedsEMt.Value - Total;
1084
          6: Value := ClientDataSetFeedsENt.Value - Total;
1085
          else Value := 0;
1086
        end;
1087
        FeedBar := TBarSeries.Create(ChartFeed1);
1088
        FeedBar.ParentChart := ChartFeed1;
1089
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
1090
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1091
        FeedBar.MultiBar := mbStacked100;
1092
        FeedBar.Marks.Visible := False;
1093
        ChartFeed1.AddSeries(FeedBar);
1094
        FeedBar.AddBar(Value, '', clTeeColor);
1095
        Total := Total + Value;
1096
      end;
1097
      if (ComboBoxType.ItemIndex = 0)
1098
      and (ComboBoxProximal.ItemIndex = 0)
1099
      and not ClientDataSetFeedsPhytaseId.IsNull
1100
      and (ClientDataSetFeedsPhytaseLevel.Value > 0)
1101
      then // Phytase (taux d'incorporation)
1102
      begin
1103
        Ratio := InputIncorporation(ClientDataSetFeedsPhytaseLevel.Value, FormOptions.Incorporation);
1104
        Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
1105
        FeedBar := TBarSeries.Create(ChartFeed1);
1106
        FeedBar.ParentChart := ChartFeed1;
1107
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
1108
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1109
        FeedBar.MultiBar := mbStacked100;
1110
        FeedBar.Marks.Visible := False;
1111
        ChartFeed1.AddSeries(FeedBar);
1112
        FeedBar.AddBar(Value, '', clTeeColor);
1113
        Total := Total + Value;
1114
      end;
1115
      if (ComboBoxType.ItemIndex = 4)
1116
      and (ComboBoxMinerals.ItemIndex = 2)
1117
      and not ClientDataSetFeedsPhytaseId.IsNull
1118
      and (ClientDataSetFeedsPd.Value > Total)
1119
      then // Phytase (Phosphore digestible)
1120
      begin
1121
        Value := ClientDataSetFeedsPd.Value - Total;
1122
        FeedBar := TBarSeries.Create(ChartFeed1);
1123
        FeedBar.ParentChart := ChartFeed1;
1124
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
1125
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1126
        FeedBar.MultiBar := mbStacked100;
1127
        FeedBar.Marks.Visible := False;
1128
        ChartFeed1.AddSeries(FeedBar);
1129
        FeedBar.AddBar(Value, '', clTeeColor);
1130
        Total := Total + Value;
1131
      end;
1132
      // Total
1133
      case ComboBoxType.ItemIndex of
1134
        0: // Analyse proximale
1135
          if (FormOptions.Expression = 0) or (ComboBoxProximal.ItemIndex < 2)
1136
          then // sur frais
1137
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal]]))
1138
          else // sur mati?re s?che - except? pour Composition et MS
1139
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], _('DM')]));
1140
        1: // Valeurs ?nerg?tiques
1141
          if FormOptions.Expression = 0
1142
          then // sur frais
1143
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy]]))
1144
          else // sur mati?re s?che
1145
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], _('DM')]));
1146
        2, 3: // Acides amin?s
1147
          if FormOptions.Expression = 0
1148
          then // sur frais
1149
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA]]))
1150
          else // sur mati?re s?che
1151
            ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA], _('DM')]));
1152
        4: // Min?raux
1153 5 avalancogn
          if ComboBoxMinerals.ItemIndex = 6
1154
          then // Bilan ?lectrolytique
1155
            if FormOptions.Expression = 0
1156
            then // sur frais
1157
              ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), 1, Total, _('mEq/kg')]))
1158
            else // sur mati?re s?che
1159
              ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), 1, Total, _('mEq/kg'), _('DM')]));
1160
          else
1161
            if FormOptions.Expression = 0
1162
            then // sur frais
1163
              ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals]]))
1164
            else // sur mati?re s?che
1165
              ChartFeed1.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], _('DM')]));
1166 1 avalancogn
      end;
1167
      ClientDataSetComposition.Filtered := False;
1168
      ClientDataSetComposition.Filter := '';
1169
    end;
1170
end;
1171
1172
procedure TFormFeedsCharts.ComboBoxFeed2Change(Sender: TObject);
1173
var
1174
  IngredientName: String;
1175
  Cumul, Ratio, Total, Value: Double;
1176
  FeedBar: TBarSeries;
1177
begin
1178
//  while ChartFeed2.SeriesCount > 0 do
1179
//    ChartFeed2.Series[0].Free;
1180
  ChartFeed2.FreeAllSeries(nil);
1181
  ChartFeed2.Title.Clear;
1182
  ChartFeed2.SubTitle.Clear;
1183
  if ComboBoxFeed2.ItemIndex <> -1
1184
  then
1185
    with DataModuleDeclaration do
1186
    begin
1187
      ClientDataSetFeeds.Locate('Name', ComboBoxFeed2.Text, []);
1188
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxFeed2.Text) + 1;
1189
      ChartFeed2.AxisVisible := True;
1190
      ChartFeed2.Title.Text.Add(ClientDataSetFeedsName.Value);
1191
      ChartFeed2.SubTitle.Text.Add(ComboBoxType.Text);
1192
      case ComboBoxType.ItemIndex of
1193
        0: // Analyse proximale
1194
          ChartFeed2.SubTitle.Text.Add(ComboBoxProximal.Text);
1195
        1: // Valeurs ?nerg?tiques
1196
          ChartFeed2.SubTitle.Text.Add(ComboBoxEnergy.Text);
1197
        2, 3: // Acides amin?s
1198
          ChartFeed2.SubTitle.Text.Add(ComboBoxAA.Text);
1199
        4: // Min?raux
1200
          ChartFeed2.SubTitle.Text.Add(ComboBoxMinerals.Text);
1201
      end;
1202
      case ComboBoxType.ItemIndex of
1203
        0: // Analyse proximale
1204
          case ComboBoxProximal.ItemIndex of
1205
            0: // Composition
1206
              Cumul := OutputIncorporation(1, FormOptions.Incorporation);
1207
            1: // MS
1208
              Cumul := ClientDataSetFeedsMS.Value;
1209
            2: // MM
1210
              Cumul := ClientDataSetFeedsMM.Value;
1211
            3: // MAT
1212
              Cumul := ClientDataSetFeedsMAT.Value;
1213
            4: // MG
1214
              Cumul := ClientDataSetFeedsMG.Value;
1215
            5: // CB
1216
              Cumul := ClientDataSetFeedsCB.Value;
1217
            6: // NDF
1218
              Cumul := ClientDataSetFeedsNDF.Value;
1219
            7: // ADF
1220
              Cumul := ClientDataSetFeedsADF.Value;
1221
            8: // ADL
1222
              Cumul := ClientDataSetFeedsADL.Value;
1223
            9: // Amidon
1224
              Cumul := ClientDataSetFeedsAmidon.Value;
1225
            10: // Sucres
1226
              Cumul := ClientDataSetFeedsSucres.Value;
1227
            else
1228
              Cumul := 0;
1229
          end;
1230
        1: // Valeurs ?nerg?tiques
1231
          case ComboBoxEnergy.ItemIndex of
1232
            0: // Energie brute
1233
              Cumul := ClientDataSetFeedsEB.Value;
1234
            1: // Energie digestible (porc croissance)
1235
              Cumul := ClientDataSetFeedsEDc.Value;
1236
            2: // Energie digestible (porc adulte)
1237
              Cumul := ClientDataSetFeedsEDt.Value;
1238
            3: // Energie m?tabolisable (porc croissance)
1239
              Cumul := ClientDataSetFeedsEMc.Value;
1240
            4: // Energie m?tabolisable (porc adulte)
1241
              Cumul := ClientDataSetFeedsEMt.Value;
1242
            5: // Energie nette (porc croissance)
1243
              Cumul := ClientDataSetFeedsENc.Value;
1244
            6: // Energie nette (porc adulte)
1245
              Cumul := ClientDataSetFeedsENt.Value;
1246
            else
1247
              Cumul := 0;
1248
          end;
1249
        2: // Acides amin?s totaux
1250
          case ComboBoxAA.ItemIndex of
1251
            0: // Lysine
1252
              Cumul := ClientDataSetFeedsLys.Value;
1253
            1: // Thr?onine
1254
              Cumul := ClientDataSetFeedsThr.Value;
1255
            2: // M?thionine
1256
              Cumul := ClientDataSetFeedsMet.Value;
1257
            3: // Cyst?ine
1258
              Cumul := ClientDataSetFeedsCys.Value;
1259
            4: // M?thionine + Cyst?ine
1260
              Cumul := ClientDataSetFeedsMetCys.Value;
1261
            5: // Tryptophane
1262
              Cumul := ClientDataSetFeedsTrp.Value;
1263
            6: // Isoleucine
1264
              Cumul := ClientDataSetFeedsIle.Value;
1265
            7: // Valine
1266
              Cumul := ClientDataSetFeedsVal.Value;
1267
            8: // Leucine
1268
              Cumul := ClientDataSetFeedsLeu.Value;
1269
            9: // Ph?nylalanine
1270
              Cumul := ClientDataSetFeedsPhe.Value;
1271
            10: // Tyrosine
1272
              Cumul := ClientDataSetFeedsTyr.Value;
1273
            11: // Ph?nylalanine + Tyrosine
1274
              Cumul := ClientDataSetFeedsPheTyr.Value;
1275
            12: // Histidine
1276
              Cumul := ClientDataSetFeedsHis.Value;
1277
            13: // Arginine
1278
              Cumul := ClientDataSetFeedsArg.Value;
1279
            14: // Alanine
1280
              Cumul := ClientDataSetFeedsAla.Value;
1281
            15: // Aspartate
1282
              Cumul := ClientDataSetFeedsAsp.Value;
1283
            16: // Glutamate
1284
              Cumul := ClientDataSetFeedsGlu.Value;
1285
            17: // Glycine
1286
              Cumul := ClientDataSetFeedsGly.Value;
1287
            18: // S?rine
1288
              Cumul := ClientDataSetFeedsSer.Value;
1289
            19: // Proline
1290
              Cumul := ClientDataSetFeedsPro.Value;
1291
            else
1292
              Cumul := 0;
1293
          end;
1294
        3: // Acides amin?s digestibles
1295
          case ComboBoxAA.ItemIndex of
1296
            0: // Lysine
1297
              Cumul := ClientDataSetFeedsLysd.Value;
1298
            1: // Thr?onine
1299
              Cumul := ClientDataSetFeedsThrd.Value;
1300
            2: // M?thionine
1301
              Cumul := ClientDataSetFeedsMetd.Value;
1302
            3: // Cyst?ine
1303
              Cumul := ClientDataSetFeedsCysd.Value;
1304
            4: // M?thionine + Cyst?ine
1305
              Cumul := ClientDataSetFeedsMetCysd.Value;
1306
            5: // Tryptophane
1307
              Cumul := ClientDataSetFeedsTrpd.Value;
1308
            6: // Isoleucine
1309
              Cumul := ClientDataSetFeedsIled.Value;
1310
            7: // Valine
1311
              Cumul := ClientDataSetFeedsVald.Value;
1312
            8: // Leucine
1313
              Cumul := ClientDataSetFeedsLeud.Value;
1314
            9: // Ph?nylalanine
1315
              Cumul := ClientDataSetFeedsPhed.Value;
1316
            10: // Tyrosine
1317
              Cumul := ClientDataSetFeedsTyrd.Value;
1318
            11: // Ph?nylalanine + Tyrosine
1319
              Cumul := ClientDataSetFeedsPheTyrd.Value;
1320
            12: // Histidine
1321
              Cumul := ClientDataSetFeedsHisd.Value;
1322
            13: // Arginine
1323
              Cumul := ClientDataSetFeedsArgd.Value;
1324
            14: // Alanine
1325
              Cumul := ClientDataSetFeedsAlad.Value;
1326
            15: // Aspartate
1327
              Cumul := ClientDataSetFeedsAspd.Value;
1328
            16: // Glutamate
1329
              Cumul := ClientDataSetFeedsGlud.Value;
1330
            17: // Glycine
1331
              Cumul := ClientDataSetFeedsGlyd.Value;
1332
            18: // S?rine
1333
              Cumul := ClientDataSetFeedsSerd.Value;
1334
            19: // Proline
1335
              Cumul := ClientDataSetFeedsProd.Value;
1336
            else
1337
              Cumul := 0;
1338
          end;
1339
        4: // Min?raux
1340
          case ComboBoxMinerals.ItemIndex of
1341
            0: // Calcium
1342
              Cumul := ClientDataSetFeedsCa.Value;
1343
            1: // Phosphore
1344
              Cumul := ClientDataSetFeedsP.Value;
1345 4 avalancogn
            2: // Sodium
1346
              Cumul := ClientDataSetFeedsNa.Value;
1347
            3: // Potassium
1348
              Cumul := ClientDataSetFeedsK.Value;
1349
            4: // Chlore
1350
              Cumul := ClientDataSetFeedsCl.Value;
1351
            5: // Phosphore digestible
1352 1 avalancogn
              Cumul := ClientDataSetFeedsPd.Value;
1353 5 avalancogn
            6: // Bilan ?lectrolytique
1354
              Cumul := ClientDataSetFeedsBE.Value;
1355 1 avalancogn
            else
1356
              Cumul := 0;
1357
          end;
1358
        else
1359
          Cumul := 0;
1360
      end;
1361
      if Cumul = 0
1362
      then // Division par z?ro
1363
        Cumul := 1;
1364
      ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
1365
      ClientDataSetComposition.Filtered := True;
1366
      ClientDataSetComposition.First;
1367
      Total := 0;
1368
      while not ClientDataSetComposition.Eof do
1369
      begin
1370
        if ClientDataSetCompositionUser.Value
1371
        then
1372
          ClientDataSetIngredients.Filter := Format('Id = %d and User', [ClientDataSetCompositionIngredient.Value])
1373
        else
1374
          ClientDataSetIngredients.Filter := Format('Id = %d and not User', [ClientDataSetCompositionIngredient.Value]);
1375
        ClientDataSetIngredients.Filtered := True;
1376
        IngredientName := StrTrunc(ClientDataSetIngredientsName.Value, 25);
1377
        Ratio := InputIncorporation(ClientDataSetCompositionLevel.Value, FormOptions.Incorporation);
1378
        if (FormOptions.Expression = 0)
1379
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1380
        then // Conversion frais -> sec (mati?re s?che de la mati?re premi?re) - except? pour Composition et MS
1381
          Ratio := Ratio / InputProximal(ClientDataSetIngredientsMS.Value, 1, 1, FormOptions.Proximal);
1382
        RapMS := InputProximal(ClientDataSetCompositionMS.Value, 1, 1, FormOptions.Proximal);
1383
        if ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1384
        then // Conversion sec -> frais (mati?re s?che de la composition) - except? pour Composition et MS
1385
          Ratio := Ratio * RapMS;
1386
        case ComboBoxType.ItemIndex of
1387
          0: // Analyse proximale
1388
            case ComboBoxProximal.ItemIndex of
1389
              0: // Composition
1390
                Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
1391
              1: // MS
1392
                Value := ClientDataSetCompositionMS.Value * Ratio;
1393
              2: // MM
1394
                Value := ClientDataSetIngredientsMM.Value * Ratio;
1395
              3: // MAT
1396
                Value := ClientDataSetIngredientsMAT.Value * Ratio;
1397
              4: // MG
1398
                Value := ClientDataSetIngredientsMG.Value * Ratio;
1399
              5: // CB
1400
                Value := ClientDataSetIngredientsCB.Value * Ratio;
1401
              6: // NDF
1402
                Value := ClientDataSetIngredientsNDF.Value * Ratio;
1403
              7: // ADF
1404
                Value := ClientDataSetIngredientsADF.Value * Ratio;
1405
              8: // ADL
1406
                Value := ClientDataSetIngredientsADL.Value * Ratio;
1407
              9: // Amidon
1408
                Value := ClientDataSetIngredientsAmidon.Value * Ratio;
1409
              10: // Sucres
1410
                Value := ClientDataSetIngredientsSucres.Value * Ratio;
1411
              else
1412
                Value := 0;
1413
            end;
1414
          1: // Valeurs ?nerg?tiques
1415
            case ComboBoxEnergy.ItemIndex of
1416
              0: // Energie brute
1417
                Value := ClientDataSetIngredientsEB.Value * Ratio;
1418
              1: // Energie digestible (porc croissance)
1419
                Value := ClientDataSetIngredientsEDc.Value * Ratio;
1420
              2: // Energie digestible (porc adulte)
1421
                Value := ClientDataSetIngredientsEDt.Value * Ratio;
1422
              3: // Energie m?tabolisable (porc croissance)
1423
                Value := ClientDataSetIngredientsEMc.Value * Ratio;
1424
              4: // Energie m?tabolisable (porc adulte)
1425
                Value := ClientDataSetIngredientsEMt.Value * Ratio;
1426
              5: // Energie nette (porc croissance)
1427
                Value := ClientDataSetIngredientsENc.Value * Ratio;
1428
              6: // Energie nette (porc adulte)
1429
                Value := ClientDataSetIngredientsENt.Value * Ratio;
1430
              else
1431
                Value := 0;
1432
            end;
1433
          2: // Acides amin?s totaux
1434
            case ComboBoxAA.ItemIndex of
1435
              0: // Lysine
1436
                Value := ClientDataSetIngredientsLys.Value * Ratio;
1437
              1: // Thr?onine
1438
                Value := ClientDataSetIngredientsThr.Value * Ratio;
1439
              2: // M?thionine
1440
                Value := ClientDataSetIngredientsMet.Value * Ratio;
1441
              3: // Cyst?ine
1442
                Value := ClientDataSetIngredientsCys.Value * Ratio;
1443
              4: // M?thionine + Cyst?ine
1444
                Value := ClientDataSetIngredientsMetCys.Value * Ratio;
1445
              5: // Tryptophane
1446
                Value := ClientDataSetIngredientsTrp.Value * Ratio;
1447
              6: // Isoleucine
1448
                Value := ClientDataSetIngredientsIle.Value * Ratio;
1449
              7: // Valine
1450
                Value := ClientDataSetIngredientsVal.Value * Ratio;
1451
              8: // Leucine
1452
                Value := ClientDataSetIngredientsLeu.Value * Ratio;
1453
              9: // Ph?nylalanine
1454
                Value := ClientDataSetIngredientsPhe.Value * Ratio;
1455
              10: // Tyrosine
1456
                Value := ClientDataSetIngredientsTyr.Value * Ratio;
1457
              11: // Ph?nylalanine + Tyrosine
1458
                Value := ClientDataSetIngredientsPheTyr.Value * Ratio;
1459
              12: // Histidine
1460
                Value := ClientDataSetIngredientsHis.Value * Ratio;
1461
              13: // Arginine
1462
                Value := ClientDataSetIngredientsArg.Value * Ratio;
1463
              14: // Alanine
1464
                Value := ClientDataSetIngredientsAla.Value * Ratio;
1465
              15: // Aspartate
1466
                Value := ClientDataSetIngredientsAsp.Value * Ratio;
1467
              16: // Glutamate
1468
                Value := ClientDataSetIngredientsGlu.Value * Ratio;
1469
              17: // Glycine
1470
                Value := ClientDataSetIngredientsGly.Value * Ratio;
1471
              18: // S?rine
1472
                Value := ClientDataSetIngredientsSer.Value * Ratio;
1473
              19: // Proline
1474
                Value := ClientDataSetIngredientsPro.Value * Ratio;
1475
              else
1476
                Value := 0;
1477
            end;
1478
          3: // Acides amin?s digestibles
1479
            case ComboBoxAA.ItemIndex of
1480
              0: // Lysine
1481
                Value := ClientDataSetIngredientsLysd.Value * Ratio;
1482
              1: // Thr?onine
1483
                Value := ClientDataSetIngredientsThrd.Value * Ratio;
1484
              2: // M?thionine
1485
                Value := ClientDataSetIngredientsMetd.Value * Ratio;
1486
              3: // Cyst?ine
1487
                Value := ClientDataSetIngredientsCysd.Value * Ratio;
1488
              4: // M?thionine + Cyst?ine
1489
                Value := ClientDataSetIngredientsMetCysd.Value * Ratio;
1490
              5: // Tryptophane
1491
                Value := ClientDataSetIngredientsTrpd.Value * Ratio;
1492
              6: // Isoleucine
1493
                Value := ClientDataSetIngredientsIled.Value * Ratio;
1494
              7: // Valine
1495
                Value := ClientDataSetIngredientsVald.Value * Ratio;
1496
              8: // Leucine
1497
                Value := ClientDataSetIngredientsLeud.Value * Ratio;
1498
              9: // Ph?nylalanine
1499
                Value := ClientDataSetIngredientsPhed.Value * Ratio;
1500
              10: // Tyrosine
1501
                Value := ClientDataSetIngredientsTyrd.Value * Ratio;
1502
              11: // Ph?nylalanine + Tyrosine
1503
                Value := ClientDataSetIngredientsPheTyrd.Value * Ratio;
1504
              12: // Histidine
1505
                Value := ClientDataSetIngredientsHisd.Value * Ratio;
1506
              13: // Arginine
1507
                Value := ClientDataSetIngredientsArgd.Value * Ratio;
1508
              14: // Alanine
1509
                Value := ClientDataSetIngredientsAlad.Value * Ratio;
1510
              15: // Aspartate
1511
                Value := ClientDataSetIngredientsAspd.Value * Ratio;
1512
              16: // Glutamate
1513
                Value := ClientDataSetIngredientsGlud.Value * Ratio;
1514
              17: // Glycine
1515
                Value := ClientDataSetIngredientsGlyd.Value * Ratio;
1516
              18: // S?rine
1517
                Value := ClientDataSetIngredientsSerd.Value * Ratio;
1518
              19: // Proline
1519
                Value := ClientDataSetIngredientsProd.Value * Ratio;
1520
              else
1521
                Value := 0;
1522
            end;
1523
          4: // Min?raux
1524
            case ComboBoxMinerals.ItemIndex of
1525
              0: // Calcium
1526
                Value := ClientDataSetIngredientsCa.Value * Ratio;
1527
              1: // Phosphore
1528
                Value := ClientDataSetIngredientsP.Value * Ratio;
1529 4 avalancogn
              2: // Sodium
1530
                Value := ClientDataSetIngredientsNa.Value * Ratio;
1531
              3: // Potassium
1532
                Value := ClientDataSetIngredientsK.Value * Ratio;
1533
              4: // Chlore
1534
                Value := ClientDataSetIngredientsCl.Value * Ratio;
1535
              5: // Phosphore digestible
1536 1 avalancogn
                if ClientDataSetFeedsPresentation.Value = 0
1537
                then // Farine (dPphy)
1538
                  Value := ClientDataSetIngredientsdPphy.Value / 100 * ClientDataSetIngredientsP.Value * Ratio
1539
                else // Granul?s (dP)
1540
                  Value := ClientDataSetIngredientsdP.Value / 100 * ClientDataSetIngredientsP.Value * Ratio;
1541 5 avalancogn
              6: // Bilan ?lectrolytique
1542
                Value := ClientDataSetIngredientsBE.Value * Ratio;
1543 1 avalancogn
              else
1544
                Value := 0;
1545
            end;
1546
          else
1547
            Value := 0;
1548
        end;
1549
        if (FormOptions.Expression = 1)
1550
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1551
        then // Conversion frais -> sec (mati?re s?che du r?gime) - except? pour Composition et MS
1552
          Value := Value / InputProximal(ClientDataSetFeedsMS.Value, 1, 1, FormOptions.Proximal);
1553
        if Value > 0
1554
        then // Prendre en compte la valeur
1555
        begin
1556
          FeedBar := TBarSeries.Create(ChartFeed2);
1557
          FeedBar.ParentChart := ChartFeed2;
1558
          FeedBar.Title := Format('%s (%1.2f %%)', [IngredientName, Value / Cumul * 100]);
1559
          FeedBar.BarPen.Color := FeedBar.SeriesColor;
1560
          FeedBar.MultiBar := mbStacked100;
1561
          FeedBar.Marks.Visible := False;
1562
          ChartFeed2.AddSeries(FeedBar);
1563
          FeedBar.AddBar(Value, '', clTeeColor);
1564
          Total := Total + Value;
1565
        end;
1566
        ClientDataSetComposition.Next;
1567
      end;
1568
      ClientDataSetIngredients.Filtered := False;
1569
      ClientDataSetIngredients.Filter := '';
1570
      // Cas particuliers
1571
      if (ComboBoxType.ItemIndex = 1)
1572
      and ((ComboBoxEnergy.ItemIndex = 1)
1573
        or (ComboBoxEnergy.ItemIndex = 3)
1574
        or (ComboBoxEnergy.ItemIndex = 5))
1575
      and (ClientDataSetFeedsBonusC.Value > 0)
1576
      then // Bonus ?nergie (porc croissance)
1577
      begin
1578
        case ComboBoxEnergy.ItemIndex of
1579
          1: Value := ClientDataSetFeedsEDc.Value - Total;
1580
          3: Value := ClientDataSetFeedsEMc.Value - Total;
1581
          5: Value := ClientDataSetFeedsENc.Value - Total;
1582
          else Value := 0;
1583
        end;
1584
        FeedBar := TBarSeries.Create(ChartFeed2);
1585
        FeedBar.ParentChart := ChartFeed2;
1586
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
1587
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1588
        FeedBar.MultiBar := mbStacked100;
1589
        FeedBar.Marks.Visible := False;
1590
        ChartFeed2.AddSeries(FeedBar);
1591
        FeedBar.AddBar(Value, '', clTeeColor);
1592
        Total := Total + Value;
1593
      end;
1594
      if (ComboBoxType.ItemIndex = 1)
1595
      and ((ComboBoxEnergy.ItemIndex = 2)
1596
        or (ComboBoxEnergy.ItemIndex = 4)
1597
        or (ComboBoxEnergy.ItemIndex = 6))
1598
      and (ClientDataSetFeedsBonusT.Value > 0)
1599
      then // Bonus ?nergie (porc adulte)
1600
      begin
1601
        case ComboBoxEnergy.ItemIndex of
1602
          2: Value := ClientDataSetFeedsEDt.Value - Total;
1603
          4: Value := ClientDataSetFeedsEMt.Value - Total;
1604
          6: Value := ClientDataSetFeedsENt.Value - Total;
1605
          else Value := 0;
1606
        end;
1607
        FeedBar := TBarSeries.Create(ChartFeed2);
1608
        FeedBar.ParentChart := ChartFeed2;
1609
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
1610
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1611
        FeedBar.MultiBar := mbStacked100;
1612
        FeedBar.Marks.Visible := False;
1613
        ChartFeed2.AddSeries(FeedBar);
1614
        FeedBar.AddBar(Value, '', clTeeColor);
1615
        Total := Total + Value;
1616
      end;
1617
      if (ComboBoxType.ItemIndex = 0)
1618
      and (ComboBoxProximal.ItemIndex = 0)
1619
      and not ClientDataSetFeedsPhytaseId.IsNull
1620
      and (ClientDataSetFeedsPhytaseLevel.Value > 0)
1621
      then // Phytase (taux d'incorporation)
1622
      begin
1623
        Ratio := InputIncorporation(ClientDataSetFeedsPhytaseLevel.Value, FormOptions.Incorporation);
1624
        Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
1625
        FeedBar := TBarSeries.Create(ChartFeed2);
1626
        FeedBar.ParentChart := ChartFeed2;
1627
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
1628
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1629
        FeedBar.MultiBar := mbStacked100;
1630
        FeedBar.Marks.Visible := False;
1631
        ChartFeed2.AddSeries(FeedBar);
1632
        FeedBar.AddBar(Value, '', clTeeColor);
1633
        Total := Total + Value;
1634
      end;
1635
      if (ComboBoxType.ItemIndex = 4)
1636
      and (ComboBoxMinerals.ItemIndex = 2)
1637
      and not ClientDataSetFeedsPhytaseId.IsNull
1638
      and (ClientDataSetFeedsPd.Value > Total)
1639
      then // Phytase (Phosphore digestible)
1640
      begin
1641
        Value := ClientDataSetFeedsPd.Value - Total;
1642
        FeedBar := TBarSeries.Create(ChartFeed2);
1643
        FeedBar.ParentChart := ChartFeed2;
1644
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
1645
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
1646
        FeedBar.MultiBar := mbStacked100;
1647
        FeedBar.Marks.Visible := False;
1648
        ChartFeed2.AddSeries(FeedBar);
1649
        FeedBar.AddBar(Value, '', clTeeColor);
1650
        Total := Total + Value;
1651
      end;
1652
      // Total
1653
      case ComboBoxType.ItemIndex of
1654
        0: // Analyse proximale
1655
          if (FormOptions.Expression = 0) or (ComboBoxProximal.ItemIndex < 2)
1656
          then // sur frais
1657
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal]]))
1658
          else // sur mati?re s?che - except? pour Composition et MS
1659
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], _('DM')]));
1660
        1: // Valeurs ?nerg?tiques
1661
          if FormOptions.Expression = 0
1662
          then // sur frais
1663
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy]]))
1664
          else // sur mati?re s?che
1665
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], _('DM')]));
1666
        2, 3: // Acides amin?s
1667
          if FormOptions.Expression = 0
1668
          then // sur frais
1669
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA]]))
1670
          else // sur mati?re s?che
1671
            ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA], _('DM')]));
1672
        4: // Min?raux
1673 5 avalancogn
          if ComboBoxMinerals.ItemIndex = 6
1674
          then // Bilan ?lectrolytique
1675
            if FormOptions.Expression = 0
1676
            then // sur frais
1677
              ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), 1, Total, _('mEq/kg')]))
1678
            else // sur mati?re s?che
1679
              ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), 1, Total, _('mEq/kg'), _('DM')]));
1680
          else
1681
            if FormOptions.Expression = 0
1682
            then // sur frais
1683
              ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals]]))
1684
            else // sur mati?re s?che
1685
              ChartFeed2.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], _('DM')]));
1686 1 avalancogn
      end;
1687
      ClientDataSetComposition.Filtered := False;
1688
      ClientDataSetComposition.Filter := '';
1689
    end;
1690
end;
1691
1692
procedure TFormFeedsCharts.ComboBoxFeed3Change(Sender: TObject);
1693
var
1694
  IngredientName: String;
1695
  Cumul, Ratio, Total, Value: Double;
1696
  FeedBar: TBarSeries;
1697
begin
1698
//  while ChartFeed3.SeriesCount > 0 do
1699
//    ChartFeed3.Series[0].Free;
1700
  ChartFeed3.FreeAllSeries(nil);
1701
  ChartFeed3.Title.Clear;
1702
  ChartFeed3.SubTitle.Clear;
1703
  if ComboBoxFeed3.ItemIndex <> -1
1704
  then
1705
    with DataModuleDeclaration do
1706
    begin
1707
      ClientDataSetFeeds.Locate('Name', ComboBoxFeed3.Text, []);
1708
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxFeed3.Text) + 1;
1709
      ChartFeed3.AxisVisible := True;
1710
      ChartFeed3.Title.Text.Add(ClientDataSetFeedsName.Value);
1711
      ChartFeed3.SubTitle.Text.Add(ComboBoxType.Text);
1712
      case ComboBoxType.ItemIndex of
1713
        0: // Analyse proximale
1714
          ChartFeed3.SubTitle.Text.Add(ComboBoxProximal.Text);
1715
        1: // Valeurs ?nerg?tiques
1716
          ChartFeed3.SubTitle.Text.Add(ComboBoxEnergy.Text);
1717
        2, 3: // Acides amin?s
1718
          ChartFeed3.SubTitle.Text.Add(ComboBoxAA.Text);
1719
        4: // Min?raux
1720
          ChartFeed3.SubTitle.Text.Add(ComboBoxMinerals.Text);
1721
      end;
1722
      case ComboBoxType.ItemIndex of
1723
        0: // Analyse proximale
1724
          case ComboBoxProximal.ItemIndex of
1725
            0: // Composition
1726
              Cumul := OutputIncorporation(1, FormOptions.Incorporation);
1727
            1: // MS
1728
              Cumul := ClientDataSetFeedsMS.Value;
1729
            2: // MM
1730
              Cumul := ClientDataSetFeedsMM.Value;
1731
            3: // MAT
1732
              Cumul := ClientDataSetFeedsMAT.Value;
1733
            4: // MG
1734
              Cumul := ClientDataSetFeedsMG.Value;
1735
            5: // CB
1736
              Cumul := ClientDataSetFeedsCB.Value;
1737
            6: // NDF
1738
              Cumul := ClientDataSetFeedsNDF.Value;
1739
            7: // ADF
1740
              Cumul := ClientDataSetFeedsADF.Value;
1741
            8: // ADL
1742
              Cumul := ClientDataSetFeedsADL.Value;
1743
            9: // Amidon
1744
              Cumul := ClientDataSetFeedsAmidon.Value;
1745
            10: // Sucres
1746
              Cumul := ClientDataSetFeedsSucres.Value;
1747
            else
1748
              Cumul := 0;
1749
          end;
1750
        1: // Valeurs ?nerg?tiques
1751
          case ComboBoxEnergy.ItemIndex of
1752
            0: // Energie brute
1753
              Cumul := ClientDataSetFeedsEB.Value;
1754
            1: // Energie digestible (porc croissance)
1755
              Cumul := ClientDataSetFeedsEDc.Value;
1756
            2: // Energie digestible (porc adulte)
1757
              Cumul := ClientDataSetFeedsEDt.Value;
1758
            3: // Energie m?tabolisable (porc croissance)
1759
              Cumul := ClientDataSetFeedsEMc.Value;
1760
            4: // Energie m?tabolisable (porc adulte)
1761
              Cumul := ClientDataSetFeedsEMt.Value;
1762
            5: // Energie nette (porc croissance)
1763
              Cumul := ClientDataSetFeedsENc.Value;
1764
            6: // Energie nette (porc adulte)
1765
              Cumul := ClientDataSetFeedsENt.Value;
1766
            else
1767
              Cumul := 0;
1768
          end;
1769
        2: // Acides amin?s totaux
1770
          case ComboBoxAA.ItemIndex of
1771
            0: // Lysine
1772
              Cumul := ClientDataSetFeedsLys.Value;
1773
            1: // Thr?onine
1774
              Cumul := ClientDataSetFeedsThr.Value;
1775
            2: // M?thionine
1776
              Cumul := ClientDataSetFeedsMet.Value;
1777
            3: // Cyst?ine
1778
              Cumul := ClientDataSetFeedsCys.Value;
1779
            4: // M?thionine + Cyst?ine
1780
              Cumul := ClientDataSetFeedsMetCys.Value;
1781
            5: // Tryptophane
1782
              Cumul := ClientDataSetFeedsTrp.Value;
1783
            6: // Isoleucine
1784
              Cumul := ClientDataSetFeedsIle.Value;
1785
            7: // Valine
1786
              Cumul := ClientDataSetFeedsVal.Value;
1787
            8: // Leucine
1788
              Cumul := ClientDataSetFeedsLeu.Value;
1789
            9: // Ph?nylalanine
1790
              Cumul := ClientDataSetFeedsPhe.Value;
1791
            10: // Tyrosine
1792
              Cumul := ClientDataSetFeedsTyr.Value;
1793
            11: // Ph?nylalanine + Tyrosine
1794
              Cumul := ClientDataSetFeedsPheTyr.Value;
1795
            12: // Histidine
1796
              Cumul := ClientDataSetFeedsHis.Value;
1797
            13: // Arginine
1798
              Cumul := ClientDataSetFeedsArg.Value;
1799
            14: // Alanine
1800
              Cumul := ClientDataSetFeedsAla.Value;
1801
            15: // Aspartate
1802
              Cumul := ClientDataSetFeedsAsp.Value;
1803
            16: // Glutamate
1804
              Cumul := ClientDataSetFeedsGlu.Value;
1805
            17: // Glycine
1806
              Cumul := ClientDataSetFeedsGly.Value;
1807
            18: // S?rine
1808
              Cumul := ClientDataSetFeedsSer.Value;
1809
            19: // Proline
1810
              Cumul := ClientDataSetFeedsPro.Value;
1811
            else
1812
              Cumul := 0;
1813
          end;
1814
        3: // Acides amin?s digestibles
1815
          case ComboBoxAA.ItemIndex of
1816
            0: // Lysine
1817
              Cumul := ClientDataSetFeedsLysd.Value;
1818
            1: // Thr?onine
1819
              Cumul := ClientDataSetFeedsThrd.Value;
1820
            2: // M?thionine
1821
              Cumul := ClientDataSetFeedsMetd.Value;
1822
            3: // Cyst?ine
1823
              Cumul := ClientDataSetFeedsCysd.Value;
1824
            4: // M?thionine + Cyst?ine
1825
              Cumul := ClientDataSetFeedsMetCysd.Value;
1826
            5: // Tryptophane
1827
              Cumul := ClientDataSetFeedsTrpd.Value;
1828
            6: // Isoleucine
1829
              Cumul := ClientDataSetFeedsIled.Value;
1830
            7: // Valine
1831
              Cumul := ClientDataSetFeedsVald.Value;
1832
            8: // Leucine
1833
              Cumul := ClientDataSetFeedsLeud.Value;
1834
            9: // Ph?nylalanine
1835
              Cumul := ClientDataSetFeedsPhed.Value;
1836
            10: // Tyrosine
1837
              Cumul := ClientDataSetFeedsTyrd.Value;
1838
            11: // Ph?nylalanine + Tyrosine
1839
              Cumul := ClientDataSetFeedsPheTyrd.Value;
1840
            12: // Histidine
1841
              Cumul := ClientDataSetFeedsHisd.Value;
1842
            13: // Arginine
1843
              Cumul := ClientDataSetFeedsArgd.Value;
1844
            14: // Alanine
1845
              Cumul := ClientDataSetFeedsAlad.Value;
1846
            15: // Aspartate
1847
              Cumul := ClientDataSetFeedsAspd.Value;
1848
            16: // Glutamate
1849
              Cumul := ClientDataSetFeedsGlud.Value;
1850
            17: // Glycine
1851
              Cumul := ClientDataSetFeedsGlyd.Value;
1852
            18: // S?rine
1853
              Cumul := ClientDataSetFeedsSerd.Value;
1854
            19: // Proline
1855
              Cumul := ClientDataSetFeedsProd.Value;
1856
            else
1857
              Cumul := 0;
1858
          end;
1859
        4: // Min?raux
1860
          case ComboBoxMinerals.ItemIndex of
1861
            0: // Calcium
1862
              Cumul := ClientDataSetFeedsCa.Value;
1863
            1: // Phosphore
1864
              Cumul := ClientDataSetFeedsP.Value;
1865 4 avalancogn
            2: // Sodium
1866
              Cumul := ClientDataSetFeedsNa.Value;
1867
            3: // Potassium
1868
              Cumul := ClientDataSetFeedsK.Value;
1869
            4: // Chlore
1870
              Cumul := ClientDataSetFeedsCl.Value;
1871
            5: // Phosphore digestible
1872 1 avalancogn
              Cumul := ClientDataSetFeedsPd.Value;
1873 5 avalancogn
            6: // Bilan ?lectrolytique
1874
              Cumul := ClientDataSetFeedsBE.Value;
1875 1 avalancogn
            else
1876
              Cumul := 0;
1877
          end;
1878
        else
1879
          Cumul := 0;
1880
      end;
1881
      if Cumul = 0
1882
      then // Division par z?ro
1883
        Cumul := 1;
1884
      ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
1885
      ClientDataSetComposition.Filtered := True;
1886
      ClientDataSetComposition.First;
1887
      Total := 0;
1888
      while not ClientDataSetComposition.Eof do
1889
      begin
1890
        if ClientDataSetCompositionUser.Value
1891
        then
1892
          ClientDataSetIngredients.Filter := Format('Id = %d and User', [ClientDataSetCompositionIngredient.Value])
1893
        else
1894
          ClientDataSetIngredients.Filter := Format('Id = %d and not User', [ClientDataSetCompositionIngredient.Value]);
1895
        ClientDataSetIngredients.Filtered := True;
1896
        IngredientName := StrTrunc(ClientDataSetIngredientsName.Value, 25);
1897
        Ratio := InputIncorporation(ClientDataSetCompositionLevel.Value, FormOptions.Incorporation);
1898
        if (FormOptions.Expression = 0)
1899
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1900
        then // Conversion frais -> sec (mati?re s?che de la mati?re premi?re) - except? pour Composition et MS
1901
          Ratio := Ratio / InputProximal(ClientDataSetIngredientsMS.Value, 1, 1, FormOptions.Proximal);
1902
        RapMS := InputProximal(ClientDataSetCompositionMS.Value, 1, 1, FormOptions.Proximal);
1903
        if ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
1904
        then // Conversion sec -> frais (mati?re s?che de la composition) - except? pour Composition et MS
1905
          Ratio := Ratio * RapMS;
1906
        case ComboBoxType.ItemIndex of
1907
          0: // Analyse proximale
1908
            case ComboBoxProximal.ItemIndex of
1909
              0: // Composition
1910
                Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
1911
              1: // MS
1912
                Value := ClientDataSetCompositionMS.Value * Ratio;
1913
              2: // MM
1914
                Value := ClientDataSetIngredientsMM.Value * Ratio;
1915
              3: // MAT
1916
                Value := ClientDataSetIngredientsMAT.Value * Ratio;
1917
              4: // MG
1918
                Value := ClientDataSetIngredientsMG.Value * Ratio;
1919
              5: // CB
1920
                Value := ClientDataSetIngredientsCB.Value * Ratio;
1921
              6: // NDF
1922
                Value := ClientDataSetIngredientsNDF.Value * Ratio;
1923
              7: // ADF
1924
                Value := ClientDataSetIngredientsADF.Value * Ratio;
1925
              8: // ADL
1926
                Value := ClientDataSetIngredientsADL.Value * Ratio;
1927
              9: // Amidon
1928
                Value := ClientDataSetIngredientsAmidon.Value * Ratio;
1929
              10: // Sucres
1930
                Value := ClientDataSetIngredientsSucres.Value * Ratio;
1931
              else
1932
                Value := 0;
1933
            end;
1934
          1: // Valeurs ?nerg?tiques
1935
            case ComboBoxEnergy.ItemIndex of
1936
              0: // Energie brute
1937
                Value := ClientDataSetIngredientsEB.Value * Ratio;
1938
              1: // Energie digestible (porc croissance)
1939
                Value := ClientDataSetIngredientsEDc.Value * Ratio;
1940
              2: // Energie digestible (porc adulte)
1941
                Value := ClientDataSetIngredientsEDt.Value * Ratio;
1942
              3: // Energie m?tabolisable (porc croissance)
1943
                Value := ClientDataSetIngredientsEMc.Value * Ratio;
1944
              4: // Energie m?tabolisable (porc adulte)
1945
                Value := ClientDataSetIngredientsEMt.Value * Ratio;
1946
              5: // Energie nette (porc croissance)
1947
                Value := ClientDataSetIngredientsENc.Value * Ratio;
1948
              6: // Energie nette (porc adulte)
1949
                Value := ClientDataSetIngredientsENt.Value * Ratio;
1950
              else
1951
                Value := 0;
1952
            end;
1953
          2: // Acides amin?s totaux
1954
            case ComboBoxAA.ItemIndex of
1955
              0: // Lysine
1956
                Value := ClientDataSetIngredientsLys.Value * Ratio;
1957
              1: // Thr?onine
1958
                Value := ClientDataSetIngredientsThr.Value * Ratio;
1959
              2: // M?thionine
1960
                Value := ClientDataSetIngredientsMet.Value * Ratio;
1961
              3: // Cyst?ine
1962
                Value := ClientDataSetIngredientsCys.Value * Ratio;
1963
              4: // M?thionine + Cyst?ine
1964
                Value := ClientDataSetIngredientsMetCys.Value * Ratio;
1965
              5: // Tryptophane
1966
                Value := ClientDataSetIngredientsTrp.Value * Ratio;
1967
              6: // Isoleucine
1968
                Value := ClientDataSetIngredientsIle.Value * Ratio;
1969
              7: // Valine
1970
                Value := ClientDataSetIngredientsVal.Value * Ratio;
1971
              8: // Leucine
1972
                Value := ClientDataSetIngredientsLeu.Value * Ratio;
1973
              9: // Ph?nylalanine
1974
                Value := ClientDataSetIngredientsPhe.Value * Ratio;
1975
              10: // Tyrosine
1976
                Value := ClientDataSetIngredientsTyr.Value * Ratio;
1977
              11: // Ph?nylalanine + Tyrosine
1978
                Value := ClientDataSetIngredientsPheTyr.Value * Ratio;
1979
              12: // Histidine
1980
                Value := ClientDataSetIngredientsHis.Value * Ratio;
1981
              13: // Arginine
1982
                Value := ClientDataSetIngredientsArg.Value * Ratio;
1983
              14: // Alanine
1984
                Value := ClientDataSetIngredientsAla.Value * Ratio;
1985
              15: // Aspartate
1986
                Value := ClientDataSetIngredientsAsp.Value * Ratio;
1987
              16: // Glutamate
1988
                Value := ClientDataSetIngredientsGlu.Value * Ratio;
1989
              17: // Glycine
1990
                Value := ClientDataSetIngredientsGly.Value * Ratio;
1991
              18: // S?rine
1992
                Value := ClientDataSetIngredientsSer.Value * Ratio;
1993
              19: // Proline
1994
                Value := ClientDataSetIngredientsPro.Value * Ratio;
1995
              else
1996
                Value := 0;
1997
            end;
1998
          3: // Acides amin?s digestibles
1999
            case ComboBoxAA.ItemIndex of
2000
              0: // Lysine
2001
                Value := ClientDataSetIngredientsLysd.Value * Ratio;
2002
              1: // Thr?onine
2003
                Value := ClientDataSetIngredientsThrd.Value * Ratio;
2004
              2: // M?thionine
2005
                Value := ClientDataSetIngredientsMetd.Value * Ratio;
2006
              3: // Cyst?ine
2007
                Value := ClientDataSetIngredientsCysd.Value * Ratio;
2008
              4: // M?thionine + Cyst?ine
2009
                Value := ClientDataSetIngredientsMetCysd.Value * Ratio;
2010
              5: // Tryptophane
2011
                Value := ClientDataSetIngredientsTrpd.Value * Ratio;
2012
              6: // Isoleucine
2013
                Value := ClientDataSetIngredientsIled.Value * Ratio;
2014
              7: // Valine
2015
                Value := ClientDataSetIngredientsVald.Value * Ratio;
2016
              8: // Leucine
2017
                Value := ClientDataSetIngredientsLeud.Value * Ratio;
2018
              9: // Ph?nylalanine
2019
                Value := ClientDataSetIngredientsPhed.Value * Ratio;
2020
              10: // Tyrosine
2021
                Value := ClientDataSetIngredientsTyrd.Value * Ratio;
2022
              11: // Ph?nylalanine + Tyrosine
2023
                Value := ClientDataSetIngredientsPheTyrd.Value * Ratio;
2024
              12: // Histidine
2025
                Value := ClientDataSetIngredientsHisd.Value * Ratio;
2026
              13: // Arginine
2027
                Value := ClientDataSetIngredientsArgd.Value * Ratio;
2028
              14: // Alanine
2029
                Value := ClientDataSetIngredientsAlad.Value * Ratio;
2030
              15: // Aspartate
2031
                Value := ClientDataSetIngredientsAspd.Value * Ratio;
2032
              16: // Glutamate
2033
                Value := ClientDataSetIngredientsGlud.Value * Ratio;
2034
              17: // Glycine
2035
                Value := ClientDataSetIngredientsGlyd.Value * Ratio;
2036
              18: // S?rine
2037
                Value := ClientDataSetIngredientsSerd.Value * Ratio;
2038
              19: // Proline
2039
                Value := ClientDataSetIngredientsProd.Value * Ratio;
2040
              else
2041
                Value := 0;
2042
            end;
2043
          4: // Min?raux
2044
            case ComboBoxMinerals.ItemIndex of
2045
              0: // Calcium
2046
                Value := ClientDataSetIngredientsCa.Value * Ratio;
2047
              1: // Phosphore
2048
                Value := ClientDataSetIngredientsP.Value * Ratio;
2049 4 avalancogn
              2: // Sodium
2050
                Value := ClientDataSetIngredientsNa.Value * Ratio;
2051
              3: // Potassium
2052
                Value := ClientDataSetIngredientsK.Value * Ratio;
2053
              4: // Chlore
2054
                Value := ClientDataSetIngredientsCl.Value * Ratio;
2055
              5: // Phosphore digestible
2056 1 avalancogn
                if ClientDataSetFeedsPresentation.Value = 0
2057
                then // Farine (dPphy)
2058
                  Value := ClientDataSetIngredientsdPphy.Value / 100 * ClientDataSetIngredientsP.Value * Ratio
2059
                else // Granul?s (dP)
2060
                  Value := ClientDataSetIngredientsdP.Value / 100 * ClientDataSetIngredientsP.Value * Ratio;
2061 5 avalancogn
              6: // Bilan ?lectrolytique
2062
                Value := ClientDataSetIngredientsBE.Value * Ratio;
2063 1 avalancogn
              else
2064
                Value := 0;
2065
            end;
2066
          else
2067
            Value := 0;
2068
        end;
2069
        if (FormOptions.Expression = 1)
2070
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
2071
        then // Conversion frais -> sec (mati?re s?che du r?gime) - except? pour Composition et MS
2072
          Value := Value / InputProximal(ClientDataSetFeedsMS.Value, 1, 1, FormOptions.Proximal);
2073
        if Value > 0
2074
        then // Prendre en compte la valeur
2075
        begin
2076
          FeedBar := TBarSeries.Create(ChartFeed3);
2077
          FeedBar.ParentChart := ChartFeed3;
2078
          FeedBar.Title := Format('%s (%1.2f %%)', [IngredientName, Value / Cumul * 100]);
2079
          FeedBar.BarPen.Color := FeedBar.SeriesColor;
2080
          FeedBar.MultiBar := mbStacked100;
2081
          FeedBar.Marks.Visible := False;
2082
          ChartFeed3.AddSeries(FeedBar);
2083
          FeedBar.AddBar(Value, '', clTeeColor);
2084
          Total := Total + Value;
2085
        end;
2086
        ClientDataSetComposition.Next;
2087
      end;
2088
      ClientDataSetIngredients.Filtered := False;
2089
      ClientDataSetIngredients.Filter := '';
2090
      // Cas particuliers
2091
      if (ComboBoxType.ItemIndex = 1)
2092
      and ((ComboBoxEnergy.ItemIndex = 1)
2093
        or (ComboBoxEnergy.ItemIndex = 3)
2094
        or (ComboBoxEnergy.ItemIndex = 5))
2095
      and (ClientDataSetFeedsBonusC.Value > 0)
2096
      then // Bonus ?nergie (porc croissance)
2097
      begin
2098
        case ComboBoxEnergy.ItemIndex of
2099
          1: Value := ClientDataSetFeedsEDc.Value - Total;
2100
          3: Value := ClientDataSetFeedsEMc.Value - Total;
2101
          5: Value := ClientDataSetFeedsENc.Value - Total;
2102
          else Value := 0;
2103
        end;
2104
        FeedBar := TBarSeries.Create(ChartFeed3);
2105
        FeedBar.ParentChart := ChartFeed3;
2106
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
2107
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2108
        FeedBar.MultiBar := mbStacked100;
2109
        FeedBar.Marks.Visible := False;
2110
        ChartFeed3.AddSeries(FeedBar);
2111
        FeedBar.AddBar(Value, '', clTeeColor);
2112
        Total := Total + Value;
2113
      end;
2114
      if (ComboBoxType.ItemIndex = 1)
2115
      and ((ComboBoxEnergy.ItemIndex = 2)
2116
        or (ComboBoxEnergy.ItemIndex = 4)
2117
        or (ComboBoxEnergy.ItemIndex = 6))
2118
      and (ClientDataSetFeedsBonusT.Value > 0)
2119
      then // Bonus ?nergie (porc adulte)
2120
      begin
2121
        case ComboBoxEnergy.ItemIndex of
2122
          2: Value := ClientDataSetFeedsEDt.Value - Total;
2123
          4: Value := ClientDataSetFeedsEMt.Value - Total;
2124
          6: Value := ClientDataSetFeedsENt.Value - Total;
2125
          else Value := 0;
2126
        end;
2127
        FeedBar := TBarSeries.Create(ChartFeed3);
2128
        FeedBar.ParentChart := ChartFeed3;
2129
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
2130
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2131
        FeedBar.MultiBar := mbStacked100;
2132
        FeedBar.Marks.Visible := False;
2133
        ChartFeed3.AddSeries(FeedBar);
2134
        FeedBar.AddBar(Value, '', clTeeColor);
2135
        Total := Total + Value;
2136
      end;
2137
      if (ComboBoxType.ItemIndex = 0)
2138
      and (ComboBoxProximal.ItemIndex = 0)
2139
      and not ClientDataSetFeedsPhytaseId.IsNull
2140
      and (ClientDataSetFeedsPhytaseLevel.Value > 0)
2141
      then // Phytase (taux d'incorporation)
2142
      begin
2143
        Ratio := InputIncorporation(ClientDataSetFeedsPhytaseLevel.Value, FormOptions.Incorporation);
2144
        Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
2145
        FeedBar := TBarSeries.Create(ChartFeed3);
2146
        FeedBar.ParentChart := ChartFeed3;
2147
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
2148
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2149
        FeedBar.MultiBar := mbStacked100;
2150
        FeedBar.Marks.Visible := False;
2151
        ChartFeed3.AddSeries(FeedBar);
2152
        FeedBar.AddBar(Value, '', clTeeColor);
2153
        Total := Total + Value;
2154
      end;
2155
      if (ComboBoxType.ItemIndex = 4)
2156
      and (ComboBoxMinerals.ItemIndex = 2)
2157
      and not ClientDataSetFeedsPhytaseId.IsNull
2158
      and (ClientDataSetFeedsPd.Value > Total)
2159
      then // Phytase (Phosphore digestible)
2160
      begin
2161
        Value := ClientDataSetFeedsPd.Value - Total;
2162
        FeedBar := TBarSeries.Create(ChartFeed3);
2163
        FeedBar.ParentChart := ChartFeed3;
2164
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
2165
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2166
        FeedBar.MultiBar := mbStacked100;
2167
        FeedBar.Marks.Visible := False;
2168
        ChartFeed3.AddSeries(FeedBar);
2169
        FeedBar.AddBar(Value, '', clTeeColor);
2170
        Total := Total + Value;
2171
      end;
2172
      // Total
2173
      case ComboBoxType.ItemIndex of
2174
        0: // Analyse proximale
2175
          if (FormOptions.Expression = 0) or (ComboBoxProximal.ItemIndex < 2)
2176
          then // sur frais
2177
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal]]))
2178
          else // sur mati?re s?che - except? pour Composition et MS
2179
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], _('DM')]));
2180
        1: // Valeurs ?nerg?tiques
2181
          if FormOptions.Expression = 0
2182
          then // sur frais
2183
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy]]))
2184
          else // sur mati?re s?che
2185
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], _('DM')]));
2186
        2, 3: // Acides amin?s
2187
          if FormOptions.Expression = 0
2188
          then // sur frais
2189
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA]]))
2190
          else // sur mati?re s?che
2191
            ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA], _('DM')]));
2192
        4: // Min?raux
2193 5 avalancogn
          if ComboBoxMinerals.ItemIndex = 6
2194
          then // Bilan ?lectrolytique
2195
            if FormOptions.Expression = 0
2196
            then // sur frais
2197
              ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), 1, Total, _('mEq/kg')]))
2198
            else // sur mati?re s?che
2199
              ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), 1, Total, _('mEq/kg'), _('DM')]));
2200
          else
2201
            if FormOptions.Expression = 0
2202
            then // sur frais
2203
              ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals]]))
2204
            else // sur mati?re s?che
2205
              ChartFeed3.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], _('DM')]));
2206 1 avalancogn
      end;
2207
      ClientDataSetComposition.Filtered := False;
2208
      ClientDataSetComposition.Filter := '';
2209
    end;
2210
end;
2211
2212
procedure TFormFeedsCharts.ComboBoxFeed4Change(Sender: TObject);
2213
var
2214
  IngredientName: String;
2215
  Cumul, Ratio, Total, Value: Double;
2216
  FeedBar: TBarSeries;
2217
begin
2218
//  while ChartFeed4.SeriesCount > 0 do
2219
//    ChartFeed4.Series[0].Free;
2220
  ChartFeed4.FreeAllSeries(nil);
2221
  ChartFeed4.Title.Clear;
2222
  ChartFeed4.SubTitle.Clear;
2223
  if ComboBoxFeed4.ItemIndex <> -1
2224
  then
2225
    with DataModuleDeclaration do
2226
    begin
2227
      ClientDataSetFeeds.Locate('Name', ComboBoxFeed4.Text, []);
2228
      //ClientDataSetFeeds.RecNo := FeedList.IndexOf(ComboBoxFeed4.Text) + 1;
2229
      ChartFeed4.AxisVisible := True;
2230
      ChartFeed4.Title.Text.Add(ClientDataSetFeedsName.Value);
2231
      ChartFeed4.SubTitle.Text.Add(ComboBoxType.Text);
2232
      case ComboBoxType.ItemIndex of
2233
        0: // Analyse proximale
2234
          ChartFeed4.SubTitle.Text.Add(ComboBoxProximal.Text);
2235
        1: // Valeurs ?nerg?tiques
2236
          ChartFeed4.SubTitle.Text.Add(ComboBoxEnergy.Text);
2237
        2, 3: // Acides amin?s
2238
          ChartFeed4.SubTitle.Text.Add(ComboBoxAA.Text);
2239
        4: // Min?raux
2240
          ChartFeed4.SubTitle.Text.Add(ComboBoxMinerals.Text);
2241
      end;
2242
      case ComboBoxType.ItemIndex of
2243
        0: // Analyse proximale
2244
          case ComboBoxProximal.ItemIndex of
2245
            0: // Composition
2246
              Cumul := OutputIncorporation(1, FormOptions.Incorporation);
2247
            1: // MS
2248
              Cumul := ClientDataSetFeedsMS.Value;
2249
            2: // MM
2250
              Cumul := ClientDataSetFeedsMM.Value;
2251
            3: // MAT
2252
              Cumul := ClientDataSetFeedsMAT.Value;
2253
            4: // MG
2254
              Cumul := ClientDataSetFeedsMG.Value;
2255
            5: // CB
2256
              Cumul := ClientDataSetFeedsCB.Value;
2257
            6: // NDF
2258
              Cumul := ClientDataSetFeedsNDF.Value;
2259
            7: // ADF
2260
              Cumul := ClientDataSetFeedsADF.Value;
2261
            8: // ADL
2262
              Cumul := ClientDataSetFeedsADL.Value;
2263
            9: // Amidon
2264
              Cumul := ClientDataSetFeedsAmidon.Value;
2265
            10: // Sucres
2266
              Cumul := ClientDataSetFeedsSucres.Value;
2267
            else
2268
              Cumul := 0;
2269
          end;
2270
        1: // Valeurs ?nerg?tiques
2271
          case ComboBoxEnergy.ItemIndex of
2272
            0: // Energie brute
2273
              Cumul := ClientDataSetFeedsEB.Value;
2274
            1: // Energie digestible (porc croissance)
2275
              Cumul := ClientDataSetFeedsEDc.Value;
2276
            2: // Energie digestible (porc adulte)
2277
              Cumul := ClientDataSetFeedsEDt.Value;
2278
            3: // Energie m?tabolisable (porc croissance)
2279
              Cumul := ClientDataSetFeedsEMc.Value;
2280
            4: // Energie m?tabolisable (porc adulte)
2281
              Cumul := ClientDataSetFeedsEMt.Value;
2282
            5: // Energie nette (porc croissance)
2283
              Cumul := ClientDataSetFeedsENc.Value;
2284
            6: // Energie nette (porc adulte)
2285
              Cumul := ClientDataSetFeedsENt.Value;
2286
            else
2287
              Cumul := 0;
2288
          end;
2289
        2: // Acides amin?s totaux
2290
          case ComboBoxAA.ItemIndex of
2291
            0: // Lysine
2292
              Cumul := ClientDataSetFeedsLys.Value;
2293
            1: // Thr?onine
2294
              Cumul := ClientDataSetFeedsThr.Value;
2295
            2: // M?thionine
2296
              Cumul := ClientDataSetFeedsMet.Value;
2297
            3: // Cyst?ine
2298
              Cumul := ClientDataSetFeedsCys.Value;
2299
            4: // M?thionine + Cyst?ine
2300
              Cumul := ClientDataSetFeedsMetCys.Value;
2301
            5: // Tryptophane
2302
              Cumul := ClientDataSetFeedsTrp.Value;
2303
            6: // Isoleucine
2304
              Cumul := ClientDataSetFeedsIle.Value;
2305
            7: // Valine
2306
              Cumul := ClientDataSetFeedsVal.Value;
2307
            8: // Leucine
2308
              Cumul := ClientDataSetFeedsLeu.Value;
2309
            9: // Ph?nylalanine
2310
              Cumul := ClientDataSetFeedsPhe.Value;
2311
            10: // Tyrosine
2312
              Cumul := ClientDataSetFeedsTyr.Value;
2313
            11: // Ph?nylalanine + Tyrosine
2314
              Cumul := ClientDataSetFeedsPheTyr.Value;
2315
            12: // Histidine
2316
              Cumul := ClientDataSetFeedsHis.Value;
2317
            13: // Arginine
2318
              Cumul := ClientDataSetFeedsArg.Value;
2319
            14: // Alanine
2320
              Cumul := ClientDataSetFeedsAla.Value;
2321
            15: // Aspartate
2322
              Cumul := ClientDataSetFeedsAsp.Value;
2323
            16: // Glutamate
2324
              Cumul := ClientDataSetFeedsGlu.Value;
2325
            17: // Glycine
2326
              Cumul := ClientDataSetFeedsGly.Value;
2327
            18: // S?rine
2328
              Cumul := ClientDataSetFeedsSer.Value;
2329
            19: // Proline
2330
              Cumul := ClientDataSetFeedsPro.Value;
2331
            else
2332
              Cumul := 0;
2333
          end;
2334
        3: // Acides amin?s digestibles
2335
          case ComboBoxAA.ItemIndex of
2336
            0: // Lysine
2337
              Cumul := ClientDataSetFeedsLysd.Value;
2338
            1: // Thr?onine
2339
              Cumul := ClientDataSetFeedsThrd.Value;
2340
            2: // M?thionine
2341
              Cumul := ClientDataSetFeedsMetd.Value;
2342
            3: // Cyst?ine
2343
              Cumul := ClientDataSetFeedsCysd.Value;
2344
            4: // M?thionine + Cyst?ine
2345
              Cumul := ClientDataSetFeedsMetCysd.Value;
2346
            5: // Tryptophane
2347
              Cumul := ClientDataSetFeedsTrpd.Value;
2348
            6: // Isoleucine
2349
              Cumul := ClientDataSetFeedsIled.Value;
2350
            7: // Valine
2351
              Cumul := ClientDataSetFeedsVald.Value;
2352
            8: // Leucine
2353
              Cumul := ClientDataSetFeedsLeud.Value;
2354
            9: // Ph?nylalanine
2355
              Cumul := ClientDataSetFeedsPhed.Value;
2356
            10: // Tyrosine
2357
              Cumul := ClientDataSetFeedsTyrd.Value;
2358
            11: // Ph?nylalanine + Tyrosine
2359
              Cumul := ClientDataSetFeedsPheTyrd.Value;
2360
            12: // Histidine
2361
              Cumul := ClientDataSetFeedsHisd.Value;
2362
            13: // Arginine
2363
              Cumul := ClientDataSetFeedsArgd.Value;
2364
            14: // Alanine
2365
              Cumul := ClientDataSetFeedsAlad.Value;
2366
            15: // Aspartate
2367
              Cumul := ClientDataSetFeedsAspd.Value;
2368
            16: // Glutamate
2369
              Cumul := ClientDataSetFeedsGlud.Value;
2370
            17: // Glycine
2371
              Cumul := ClientDataSetFeedsGlyd.Value;
2372
            18: // S?rine
2373
              Cumul := ClientDataSetFeedsSerd.Value;
2374
            19: // Proline
2375
              Cumul := ClientDataSetFeedsProd.Value;
2376
            else
2377
              Cumul := 0;
2378
          end;
2379
        4: // Min?raux
2380
          case ComboBoxMinerals.ItemIndex of
2381
            0: // Calcium
2382
              Cumul := ClientDataSetFeedsCa.Value;
2383
            1: // Phosphore
2384
              Cumul := ClientDataSetFeedsP.Value;
2385 4 avalancogn
            2: // Sodium
2386
              Cumul := ClientDataSetFeedsNa.Value;
2387
            3: // Potassium
2388
              Cumul := ClientDataSetFeedsK.Value;
2389
            4: // Chlore
2390
              Cumul := ClientDataSetFeedsCl.Value;
2391
            5: // Phosphore digestible
2392 1 avalancogn
              Cumul := ClientDataSetFeedsPd.Value;
2393 5 avalancogn
            6: // Bilan ?lectrolytique
2394
              Cumul := ClientDataSetFeedsBE.Value;
2395 1 avalancogn
            else
2396
              Cumul := 0;
2397
          end;
2398
        else
2399
          Cumul := 0;
2400
      end;
2401
      if Cumul = 0
2402
      then // Division par z?ro
2403
        Cumul := 1;
2404
      ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
2405
      ClientDataSetComposition.Filtered := True;
2406
      ClientDataSetComposition.First;
2407
      Total := 0;
2408
      while not ClientDataSetComposition.Eof do
2409
      begin
2410
        if ClientDataSetCompositionUser.Value
2411
        then
2412
          ClientDataSetIngredients.Filter := Format('Id = %d and User', [ClientDataSetCompositionIngredient.Value])
2413
        else
2414
          ClientDataSetIngredients.Filter := Format('Id = %d and not User', [ClientDataSetCompositionIngredient.Value]);
2415
        ClientDataSetIngredients.Filtered := True;
2416
        IngredientName := StrTrunc(ClientDataSetIngredientsName.Value, 25);
2417
        Ratio := InputIncorporation(ClientDataSetCompositionLevel.Value, FormOptions.Incorporation);
2418
        if (FormOptions.Expression = 0)
2419
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
2420
        then // Conversion frais -> sec (mati?re s?che de la mati?re premi?re) - except? pour Composition et MS
2421
          Ratio := Ratio / InputProximal(ClientDataSetIngredientsMS.Value, 1, 1, FormOptions.Proximal);
2422
        RapMS := InputProximal(ClientDataSetCompositionMS.Value, 1, 1, FormOptions.Proximal);
2423
        if ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
2424
        then // Conversion sec -> frais (mati?re s?che de la composition) - except? pour Composition et MS
2425
          Ratio := Ratio * RapMS;
2426
        case ComboBoxType.ItemIndex of
2427
          0: // Analyse proximale
2428
            case ComboBoxProximal.ItemIndex of
2429
              0: // Composition
2430
                Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
2431
              1: // MS
2432
                Value := ClientDataSetCompositionMS.Value * Ratio;
2433
              2: // MM
2434
                Value := ClientDataSetIngredientsMM.Value * Ratio;
2435
              3: // MAT
2436
                Value := ClientDataSetIngredientsMAT.Value * Ratio;
2437
              4: // MG
2438
                Value := ClientDataSetIngredientsMG.Value * Ratio;
2439
              5: // CB
2440
                Value := ClientDataSetIngredientsCB.Value * Ratio;
2441
              6: // NDF
2442
                Value := ClientDataSetIngredientsNDF.Value * Ratio;
2443
              7: // ADF
2444
                Value := ClientDataSetIngredientsADF.Value * Ratio;
2445
              8: // ADL
2446
                Value := ClientDataSetIngredientsADL.Value * Ratio;
2447
              9: // Amidon
2448
                Value := ClientDataSetIngredientsAmidon.Value * Ratio;
2449
              10: // Sucres
2450
                Value := ClientDataSetIngredientsSucres.Value * Ratio;
2451
              else
2452
                Value := 0;
2453
            end;
2454
          1: // Valeurs ?nerg?tiques
2455
            case ComboBoxEnergy.ItemIndex of
2456
              0: // Energie brute
2457
                Value := ClientDataSetIngredientsEB.Value * Ratio;
2458
              1: // Energie digestible (porc croissance)
2459
                Value := ClientDataSetIngredientsEDc.Value * Ratio;
2460
              2: // Energie digestible (porc adulte)
2461
                Value := ClientDataSetIngredientsEDt.Value * Ratio;
2462
              3: // Energie m?tabolisable (porc croissance)
2463
                Value := ClientDataSetIngredientsEMc.Value * Ratio;
2464
              4: // Energie m?tabolisable (porc adulte)
2465
                Value := ClientDataSetIngredientsEMt.Value * Ratio;
2466
              5: // Energie nette (porc croissance)
2467
                Value := ClientDataSetIngredientsENc.Value * Ratio;
2468
              6: // Energie nette (porc adulte)
2469
                Value := ClientDataSetIngredientsENt.Value * Ratio;
2470
              else
2471
                Value := 0;
2472
            end;
2473
          2: // Acides amin?s totaux
2474
            case ComboBoxAA.ItemIndex of
2475
              0: // Lysine
2476
                Value := ClientDataSetIngredientsLys.Value * Ratio;
2477
              1: // Thr?onine
2478
                Value := ClientDataSetIngredientsThr.Value * Ratio;
2479
              2: // M?thionine
2480
                Value := ClientDataSetIngredientsMet.Value * Ratio;
2481
              3: // Cyst?ine
2482
                Value := ClientDataSetIngredientsCys.Value * Ratio;
2483
              4: // M?thionine + Cyst?ine
2484
                Value := ClientDataSetIngredientsMetCys.Value * Ratio;
2485
              5: // Tryptophane
2486
                Value := ClientDataSetIngredientsTrp.Value * Ratio;
2487
              6: // Isoleucine
2488
                Value := ClientDataSetIngredientsIle.Value * Ratio;
2489
              7: // Valine
2490
                Value := ClientDataSetIngredientsVal.Value * Ratio;
2491
              8: // Leucine
2492
                Value := ClientDataSetIngredientsLeu.Value * Ratio;
2493
              9: // Ph?nylalanine
2494
                Value := ClientDataSetIngredientsPhe.Value * Ratio;
2495
              10: // Tyrosine
2496
                Value := ClientDataSetIngredientsTyr.Value * Ratio;
2497
              11: // Ph?nylalanine + Tyrosine
2498
                Value := ClientDataSetIngredientsPheTyr.Value * Ratio;
2499
              12: // Histidine
2500
                Value := ClientDataSetIngredientsHis.Value * Ratio;
2501
              13: // Arginine
2502
                Value := ClientDataSetIngredientsArg.Value * Ratio;
2503
              14: // Alanine
2504
                Value := ClientDataSetIngredientsAla.Value * Ratio;
2505
              15: // Aspartate
2506
                Value := ClientDataSetIngredientsAsp.Value * Ratio;
2507
              16: // Glutamate
2508
                Value := ClientDataSetIngredientsGlu.Value * Ratio;
2509
              17: // Glycine
2510
                Value := ClientDataSetIngredientsGly.Value * Ratio;
2511
              18: // S?rine
2512
                Value := ClientDataSetIngredientsSer.Value * Ratio;
2513
              19: // Proline
2514
                Value := ClientDataSetIngredientsPro.Value * Ratio;
2515
              else
2516
                Value := 0;
2517
            end;
2518
          3: // Acides amin?s digestibles
2519
            case ComboBoxAA.ItemIndex of
2520
              0: // Lysine
2521
                Value := ClientDataSetIngredientsLysd.Value * Ratio;
2522
              1: // Thr?onine
2523
                Value := ClientDataSetIngredientsThrd.Value * Ratio;
2524
              2: // M?thionine
2525
                Value := ClientDataSetIngredientsMetd.Value * Ratio;
2526
              3: // Cyst?ine
2527
                Value := ClientDataSetIngredientsCysd.Value * Ratio;
2528
              4: // M?thionine + Cyst?ine
2529
                Value := ClientDataSetIngredientsMetCysd.Value * Ratio;
2530
              5: // Tryptophane
2531
                Value := ClientDataSetIngredientsTrpd.Value * Ratio;
2532
              6: // Isoleucine
2533
                Value := ClientDataSetIngredientsIled.Value * Ratio;
2534
              7: // Valine
2535
                Value := ClientDataSetIngredientsVald.Value * Ratio;
2536
              8: // Leucine
2537
                Value := ClientDataSetIngredientsLeud.Value * Ratio;
2538
              9: // Ph?nylalanine
2539
                Value := ClientDataSetIngredientsPhed.Value * Ratio;
2540
              10: // Tyrosine
2541
                Value := ClientDataSetIngredientsTyrd.Value * Ratio;
2542
              11: // Ph?nylalanine + Tyrosine
2543
                Value := ClientDataSetIngredientsPheTyrd.Value * Ratio;
2544
              12: // Histidine
2545
                Value := ClientDataSetIngredientsHisd.Value * Ratio;
2546
              13: // Arginine
2547
                Value := ClientDataSetIngredientsArgd.Value * Ratio;
2548
              14: // Alanine
2549
                Value := ClientDataSetIngredientsAlad.Value * Ratio;
2550
              15: // Aspartate
2551
                Value := ClientDataSetIngredientsAspd.Value * Ratio;
2552
              16: // Glutamate
2553
                Value := ClientDataSetIngredientsGlud.Value * Ratio;
2554
              17: // Glycine
2555
                Value := ClientDataSetIngredientsGlyd.Value * Ratio;
2556
              18: // S?rine
2557
                Value := ClientDataSetIngredientsSerd.Value * Ratio;
2558
              19: // Proline
2559
                Value := ClientDataSetIngredientsProd.Value * Ratio;
2560
              else
2561
                Value := 0;
2562
            end;
2563
          4: // Min?raux
2564
            case ComboBoxMinerals.ItemIndex of
2565
              0: // Calcium
2566
                Value := ClientDataSetIngredientsCa.Value * Ratio;
2567
              1: // Phosphore
2568
                Value := ClientDataSetIngredientsP.Value * Ratio;
2569 4 avalancogn
              2: // Sodium
2570
                Value := ClientDataSetIngredientsNa.Value * Ratio;
2571
              3: // Potassium
2572
                Value := ClientDataSetIngredientsK.Value * Ratio;
2573
              4: // Chlore
2574
                Value := ClientDataSetIngredientsCl.Value * Ratio;
2575
              5: // Phosphore digestible
2576 1 avalancogn
                if ClientDataSetFeedsPresentation.Value = 0
2577
                then // Farine (dPphy)
2578
                  Value := ClientDataSetIngredientsdPphy.Value / 100 * ClientDataSetIngredientsP.Value * Ratio
2579
                else // Granul?s (dP)
2580
                  Value := ClientDataSetIngredientsdP.Value / 100 * ClientDataSetIngredientsP.Value * Ratio;
2581 5 avalancogn
              6: // Bilan ?lectrolytique
2582
                Value := ClientDataSetIngredientsBE.Value * Ratio;
2583 1 avalancogn
              else
2584
                Value := 0;
2585
            end;
2586
          else
2587
            Value := 0;
2588
        end;
2589
        if (FormOptions.Expression = 1)
2590
        and ((ComboBoxType.ItemIndex <> 0) or (ComboBoxProximal.ItemIndex > 1))
2591
        then // Conversion frais -> sec (mati?re s?che du r?gime) - except? pour Composition et MS
2592
          Value := Value / InputProximal(ClientDataSetFeedsMS.Value, 1, 1, FormOptions.Proximal);
2593
        if Value > 0
2594
        then // Prendre en compte la valeur
2595
        begin
2596
          FeedBar := TBarSeries.Create(ChartFeed4);
2597
          FeedBar.ParentChart := ChartFeed4;
2598
          FeedBar.Title := Format('%s (%1.2f %%)', [IngredientName, Value / Cumul * 100]);
2599
          FeedBar.BarPen.Color := FeedBar.SeriesColor;
2600
          FeedBar.MultiBar := mbStacked100;
2601
          FeedBar.Marks.Visible := False;
2602
          ChartFeed4.AddSeries(FeedBar);
2603
          FeedBar.AddBar(Value, '', clTeeColor);
2604
          Total := Total + Value;
2605
        end;
2606
        ClientDataSetComposition.Next;
2607
      end;
2608
      ClientDataSetIngredients.Filtered := False;
2609
      ClientDataSetIngredients.Filter := '';
2610
      // Cas particuliers
2611
      if (ComboBoxType.ItemIndex = 1)
2612
      and ((ComboBoxEnergy.ItemIndex = 1)
2613
        or (ComboBoxEnergy.ItemIndex = 3)
2614
        or (ComboBoxEnergy.ItemIndex = 5))
2615
      and (ClientDataSetFeedsBonusC.Value > 0)
2616
      then // Bonus ?nergie (porc croissance)
2617
      begin
2618
        case ComboBoxEnergy.ItemIndex of
2619
          1: Value := ClientDataSetFeedsEDc.Value - Total;
2620
          3: Value := ClientDataSetFeedsEMc.Value - Total;
2621
          5: Value := ClientDataSetFeedsENc.Value - Total;
2622
          else Value := 0;
2623
        end;
2624
        FeedBar := TBarSeries.Create(ChartFeed4);
2625
        FeedBar.ParentChart := ChartFeed4;
2626
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
2627
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2628
        FeedBar.MultiBar := mbStacked100;
2629
        FeedBar.Marks.Visible := False;
2630
        ChartFeed4.AddSeries(FeedBar);
2631
        FeedBar.AddBar(Value, '', clTeeColor);
2632
        Total := Total + Value;
2633
      end;
2634
      if (ComboBoxType.ItemIndex = 1)
2635
      and ((ComboBoxEnergy.ItemIndex = 2)
2636
        or (ComboBoxEnergy.ItemIndex = 4)
2637
        or (ComboBoxEnergy.ItemIndex = 6))
2638
      and (ClientDataSetFeedsBonusT.Value > 0)
2639
      then // Bonus ?nergie (porc adulte)
2640
      begin
2641
        case ComboBoxEnergy.ItemIndex of
2642
          2: Value := ClientDataSetFeedsEDt.Value - Total;
2643
          4: Value := ClientDataSetFeedsEMt.Value - Total;
2644
          6: Value := ClientDataSetFeedsENt.Value - Total;
2645
          else Value := 0;
2646
        end;
2647
        FeedBar := TBarSeries.Create(ChartFeed4);
2648
        FeedBar.ParentChart := ChartFeed4;
2649
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Energy bonus'), Value / Cumul * 100]);
2650
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2651
        FeedBar.MultiBar := mbStacked100;
2652
        FeedBar.Marks.Visible := False;
2653
        ChartFeed4.AddSeries(FeedBar);
2654
        FeedBar.AddBar(Value, '', clTeeColor);
2655
        Total := Total + Value;
2656
      end;
2657
      if (ComboBoxType.ItemIndex = 0)
2658
      and (ComboBoxProximal.ItemIndex = 0)
2659
      and not ClientDataSetFeedsPhytaseId.IsNull
2660
      and (ClientDataSetFeedsPhytaseLevel.Value > 0)
2661
      then // Phytase (taux d'incorporation)
2662
      begin
2663
        Ratio := InputIncorporation(ClientDataSetFeedsPhytaseLevel.Value, FormOptions.Incorporation);
2664
        Value := OutputProximal(Ratio, 1, 1, FormOptions.Proximal);
2665
        FeedBar := TBarSeries.Create(ChartFeed4);
2666
        FeedBar.ParentChart := ChartFeed4;
2667
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
2668
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2669
        FeedBar.MultiBar := mbStacked100;
2670
        FeedBar.Marks.Visible := False;
2671
        ChartFeed4.AddSeries(FeedBar);
2672
        FeedBar.AddBar(Value, '', clTeeColor);
2673
        Total := Total + Value;
2674
      end;
2675
      if (ComboBoxType.ItemIndex = 4)
2676
      and (ComboBoxMinerals.ItemIndex = 2)
2677
      and not ClientDataSetFeedsPhytaseId.IsNull
2678
      and (ClientDataSetFeedsPd.Value > Total)
2679
      then // Phytase (Phosphore digestible)
2680
      begin
2681
        Value := ClientDataSetFeedsPd.Value - Total;
2682
        FeedBar := TBarSeries.Create(ChartFeed4);
2683
        FeedBar.ParentChart := ChartFeed4;
2684
        FeedBar.Title := Format('%s (%1.2f %%)', [_('Phytase'), Value / Cumul * 100]);
2685
        FeedBar.BarPen.Color := FeedBar.SeriesColor;
2686
        FeedBar.MultiBar := mbStacked100;
2687
        FeedBar.Marks.Visible := False;
2688
        ChartFeed4.AddSeries(FeedBar);
2689
        FeedBar.AddBar(Value, '', clTeeColor);
2690
        Total := Total + Value;
2691
      end;
2692
      // Total
2693
      case ComboBoxType.ItemIndex of
2694
        0: // Analyse proximale
2695
          if (FormOptions.Expression = 0) or (ComboBoxProximal.ItemIndex < 2)
2696
          then // sur frais
2697
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal]]))
2698
          else // sur mati?re s?che - except? pour Composition et MS
2699
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.ProximalDecimals, Total, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], _('DM')]));
2700
        1: // Valeurs ?nerg?tiques
2701
          if FormOptions.Expression = 0
2702
          then // sur frais
2703
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy]]))
2704
          else // sur mati?re s?che
2705
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.EnergyDecimals, Total, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], _('DM')]));
2706
        2, 3: // Acides amin?s
2707
          if FormOptions.Expression = 0
2708
          then // sur frais
2709
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA]]))
2710
          else // sur mati?re s?che
2711
            ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.AADecimals, Total, FormOptions.ComboBoxAA.Items[FormOptions.AA], _('DM')]));
2712
        4: // Min?raux
2713 5 avalancogn
          if ComboBoxMinerals.ItemIndex = 6
2714
          then // Bilan ?lectrolytique
2715
            if FormOptions.Expression = 0
2716
            then // sur frais
2717
              ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), 1, Total, _('mEq/kg')]))
2718
            else // sur mati?re s?che
2719
              ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), 1, Total, _('mEq/kg'), _('DM')]));
2720
          else
2721
            if FormOptions.Expression = 0
2722
            then // sur frais
2723
              ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals]]))
2724
            else // sur mati?re s?che
2725
              ChartFeed4.SubTitle.Text.Add(Format('%s %1.*f %s %s', [_('Total:'), FormOptions.MineralsDecimals, Total, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], _('DM')]));
2726 1 avalancogn
      end;
2727
      ClientDataSetComposition.Filtered := False;
2728
      ClientDataSetComposition.Filter := '';
2729
    end;
2730
end;
2731
2732
procedure TFormFeedsCharts.ComboBoxOption0Change(Sender: TObject);
2733
begin
2734
  ComboBoxDietChange(nil);
2735
end;
2736
2737
procedure TFormFeedsCharts.ComboBoxOptionChange(Sender: TObject);
2738
begin
2739
  ComboBoxFeed1Change(nil);
2740
  ComboBoxFeed2Change(nil);
2741
  ComboBoxFeed3Change(nil);
2742
  ComboBoxFeed4Change(nil);
2743
end;
2744
2745
procedure TFormFeedsCharts.ComboBoxType0Change(Sender: TObject);
2746
begin
2747
  ComboBoxProximal0.Visible := False;
2748
  ComboBoxEnergy0.Visible := False;
2749
  ComboBoxRatios0.Visible := False;
2750
  ComboBoxAA0.Visible := False;
2751
  ComboBoxMinerals0.Visible := False;
2752
  case ComboBoxType0.ItemIndex of
2753
    0: // Analyse proximale
2754
      ComboBoxProximal0.Visible := True;
2755
    1: // Valeurs ?nerg?tiques
2756
      ComboBoxEnergy0.Visible := True;
2757
    2: // Rapports ?nerg?tiques
2758
      ComboBoxRatios0.Visible := True;
2759
    3, 4, 5: // Acides amin?s
2760
      ComboBoxAA0.Visible := True;
2761
    6: // Min?raux
2762
      ComboBoxMinerals0.Visible := True;
2763
  end;
2764
  ComboBoxOption0Change(nil);
2765
end;
2766
2767
procedure TFormFeedsCharts.ComboBoxTypeChange(Sender: TObject);
2768
begin
2769
  ComboBoxProximal.Visible := False;
2770
  ComboBoxEnergy.Visible := False;
2771
  ComboBoxAA.Visible := False;
2772
  ComboBoxMinerals.Visible := False;
2773
  case ComboBoxType.ItemIndex of
2774
    0: // Analyse proximale
2775
      ComboBoxProximal.Visible := True;
2776
    1: // Valeurs ?nerg?tiques
2777
      ComboBoxEnergy.Visible := True;
2778
    2, 3: // Acides amin?s
2779
      ComboBoxAA.Visible := True;
2780
    4: // Min?raux
2781
      ComboBoxMinerals.Visible := True;
2782
  end;
2783
  ComboBoxOptionChange(nil);
2784
end;
2785
2786
procedure TFormFeedsCharts.FormCreate(Sender: TObject);
2787
begin
2788
  if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1
2789
  then
2790
  begin
2791
    Font.Name := 'Arial Unicode MS';
2792
    SetChartFont(Chart0, 'Arial Unicode MS');
2793
    SeriesBar.Marks.Font.Name := 'Arial Unicode MS';
2794
    SetChartFont(ChartFeed1, 'Arial Unicode MS');
2795
    SetChartFont(ChartFeed2, 'Arial Unicode MS');
2796
    SetChartFont(ChartFeed3, 'Arial Unicode MS');
2797
    SetChartFont(ChartFeed4, 'Arial Unicode MS');
2798
  end;
2799
//  PanelButtons.Font.Size := PanelButtons.Font.Size + 2;
2800
  PanelButtons.Font.Style := [fsBold];
2801
  TranslateComponent(Self);
2802
  // S?lection des ?l?ments par d?faut apr?s traduction des listes
2803
  ComboBoxType0.ItemIndex := 0;
2804
  ComboBoxProximal0.ItemIndex := 0;
2805
  ComboBoxEnergy0.ItemIndex := 0;
2806
  ComboBoxRatios0.ItemIndex := 0;
2807
  ComboBoxAA0.ItemIndex := 0;
2808
  ComboBoxMinerals0.ItemIndex := 0;
2809
  ComboBoxDiet1.Items.Assign(DataModuleDeclaration.FeedList);
2810
  ComboBoxDiet2.Items.Assign(DataModuleDeclaration.FeedList);
2811
  ComboBoxDiet3.Items.Assign(DataModuleDeclaration.FeedList);
2812
  ComboBoxDiet4.Items.Assign(DataModuleDeclaration.FeedList);
2813
  ComboBoxDiet5.Items.Assign(DataModuleDeclaration.FeedList);
2814
  ComboBoxDiet6.Items.Assign(DataModuleDeclaration.FeedList);
2815
  Chart0.Title.Clear;
2816
  Chart0.SubTitle.Clear;
2817
  ComboBoxType.ItemIndex := 0;
2818
  ComboBoxProximal.ItemIndex := 0;
2819
  ComboBoxEnergy.ItemIndex := 0;
2820
  ComboBoxAA.ItemIndex := 0;
2821
  ComboBoxMinerals.ItemIndex := 0;
2822
  ComboBoxFeed1.Items.Assign(DataModuleDeclaration.FeedList);
2823
  ChartFeed1.Title.Clear;
2824
  ChartFeed1.SubTitle.Clear;
2825
  ComboBoxFeed2.Items.Assign(DataModuleDeclaration.FeedList);
2826
  ChartFeed2.Title.Clear;
2827
  ChartFeed2.SubTitle.Clear;
2828
  ComboBoxFeed3.Items.Assign(DataModuleDeclaration.FeedList);
2829
  ChartFeed3.Title.Clear;
2830
  ChartFeed3.SubTitle.Clear;
2831
  ComboBoxFeed4.Items.Assign(DataModuleDeclaration.FeedList);
2832
  ChartFeed4.Title.Clear;
2833
  ChartFeed4.SubTitle.Clear;
2834
end;
2835
2836
procedure TFormFeedsCharts.FormResize(Sender: TObject);
2837
var
2838
  W, H: Integer;
2839
begin
2840
  W := TabSheetChartsComparison.Width div 2;
2841
  H := (TabSheetChartsComparison.Height - GroupBoxChartSelection.Height) div 2;
2842
  GroupBoxFeed1.SetBounds(0, GroupBoxChartSelection.Height, W, H);
2843
  GroupBoxFeed2.SetBounds(W, GroupBoxChartSelection.Height, W, H);
2844
  GroupBoxFeed3.SetBounds(0, GroupBoxChartSelection.Height + H, W, H);
2845
  GroupBoxFeed4.SetBounds(W, GroupBoxChartSelection.Height + H, W, H);
2846
end;
2847
2848
procedure TFormFeedsCharts.SpeedButton2D3D0Click(Sender: TObject);
2849
begin
2850
  Chart0.View3D := not Chart0.View3D;
2851
  if Chart0.View3D
2852
  then
2853
    SeriesBar.Marks.ArrowLength := 8
2854
  else
2855
    SeriesBar.Marks.ArrowLength := 0;
2856
  if Chart0.View3D
2857
  then
2858
    SpeedButton2D3D0.Caption := _('2D')
2859
  else
2860
    SpeedButton2D3D0.Caption := _('3D');
2861
end;
2862
2863
procedure TFormFeedsCharts.SpeedButton2D3D1Click(Sender: TObject);
2864
begin
2865
  ChartFeed1.View3D := not ChartFeed1.View3D;
2866
  if ChartFeed1.View3D
2867
  then
2868
    SpeedButton2D3D1.Caption := _('2D')
2869
  else
2870
    SpeedButton2D3D1.Caption := _('3D');
2871
end;
2872
2873
procedure TFormFeedsCharts.SpeedButton2D3D2Click(Sender: TObject);
2874
begin
2875
  ChartFeed2.View3D := not ChartFeed2.View3D;
2876
  if ChartFeed2.View3D
2877
  then
2878
    SpeedButton2D3D2.Caption := _('2D')
2879
  else
2880
    SpeedButton2D3D2.Caption := _('3D');
2881
end;
2882
2883
procedure TFormFeedsCharts.SpeedButton2D3D3Click(Sender: TObject);
2884
begin
2885
  ChartFeed3.View3D := not ChartFeed3.View3D;
2886
  if ChartFeed3.View3D
2887
  then
2888
    SpeedButton2D3D3.Caption := _('2D')
2889
  else
2890
    SpeedButton2D3D3.Caption := _('3D');
2891
end;
2892
2893
procedure TFormFeedsCharts.SpeedButton2D3D4Click(Sender: TObject);
2894
begin
2895
  ChartFeed4.View3D := not ChartFeed4.View3D;
2896
  if ChartFeed4.View3D
2897
  then
2898
    SpeedButton2D3D4.Caption := _('2D')
2899
  else
2900
    SpeedButton2D3D4.Caption := _('3D');
2901
end;
2902
2903
procedure TFormFeedsCharts.SpeedButtonPrint0Click(Sender: TObject);
2904
begin
2905
  FormChartHReport := TFormChartHReport.Create(nil);
2906
  try
2907
    FormChartHReport.QRChart1.Chart.View3D := Chart0.View3D;
2908
    FormChartHReport.QRChart1.Chart.Title.Assign(Chart0.Title);
2909
    FormChartHReport.QRChart1.Chart.SubTitle.Assign(Chart0.SubTitle);
2910
    FormChartHReport.QRChart1.Chart.Legend.Visible := False;
2911
    CloneChartSeries(SeriesBar).ParentChart := FormChartHReport.QRChart1.Chart;
2912
    FormChartHReport.QuickRepChart.PrinterSetup;
2913
    if FormChartHReport.QuickRepChart.Tag = 0
2914
    then
2915
      FormChartHReport.QuickRepChart.Print;
2916
  finally
2917
    FormChartHReport.Release;
2918
  end;
2919
end;
2920
2921
procedure TFormFeedsCharts.SpeedButtonPrint1Click(Sender: TObject);
2922
var
2923
  i: Integer;
2924
begin
2925
  FormChartHReport := TFormChartHReport.Create(nil);
2926
  try
2927
    FormChartHReport.QRChart1.Chart.View3D := ChartFeed1.View3D;
2928
    FormChartHReport.QRChart1.Chart.Title.Assign(ChartFeed1.Title);
2929
    FormChartHReport.QRChart1.Chart.SubTitle.Assign(ChartFeed1.SubTitle);
2930
    FormChartHReport.QRChart1.Chart.BottomAxis.Labels := False;
2931
    for i := 0 to ChartFeed1.SeriesCount - 1 do
2932
      CloneChartSeries(ChartFeed1[i]).ParentChart := FormChartHReport.QRChart1.Chart;
2933
    FormChartHReport.QuickRepChart.PrinterSetup;
2934
    if FormChartHReport.QuickRepChart.Tag = 0
2935
    then
2936
      FormChartHReport.QuickRepChart.Print;
2937
  finally
2938
    FormChartHReport.Release;
2939
  end;
2940
end;
2941
2942
procedure TFormFeedsCharts.SpeedButtonPrint2Click(Sender: TObject);
2943
var
2944
  i: Integer;
2945
begin
2946
  FormChartHReport := TFormChartHReport.Create(nil);
2947
  try
2948
    FormChartHReport.QRChart1.Chart.View3D := ChartFeed2.View3D;
2949
    FormChartHReport.QRChart1.Chart.Title.Assign(ChartFeed2.Title);
2950
    FormChartHReport.QRChart1.Chart.SubTitle.Assign(ChartFeed2.SubTitle);
2951
    FormChartHReport.QRChart1.Chart.BottomAxis.Labels := False;
2952
    for i := 0 to ChartFeed2.SeriesCount - 1 do
2953
      CloneChartSeries(ChartFeed2[i]).ParentChart := FormChartHReport.QRChart1.Chart;
2954
    FormChartHReport.QuickRepChart.PrinterSetup;
2955
    if FormChartHReport.QuickRepChart.Tag = 0
2956
    then
2957
      FormChartHReport.QuickRepChart.Print;
2958
  finally
2959
    FormChartHReport.Release;
2960
    Screen.Cursor := crDefault;
2961
  end;
2962
end;
2963
2964
procedure TFormFeedsCharts.SpeedButtonPrint3Click(Sender: TObject);
2965
var
2966
  i: Integer;
2967
begin
2968
  FormChartHReport := TFormChartHReport.Create(nil);
2969
  try
2970
    FormChartHReport.QRChart1.Chart.View3D := ChartFeed3.View3D;
2971
    FormChartHReport.QRChart1.Chart.Title.Assign(ChartFeed3.Title);
2972
    FormChartHReport.QRChart1.Chart.SubTitle.Assign(ChartFeed3.SubTitle);
2973
    FormChartHReport.QRChart1.Chart.BottomAxis.Labels := False;
2974
    for i := 0 to ChartFeed3.SeriesCount - 1 do
2975
      CloneChartSeries(ChartFeed3[i]).ParentChart := FormChartHReport.QRChart1.Chart;
2976
    FormChartHReport.QuickRepChart.PrinterSetup;
2977
    if FormChartHReport.QuickRepChart.Tag = 0
2978
    then
2979
      FormChartHReport.QuickRepChart.Print;
2980
  finally
2981
    FormChartHReport.Release;
2982
    Screen.Cursor := crDefault;
2983
  end;
2984
end;
2985
2986
procedure TFormFeedsCharts.SpeedButtonPrint4Click(Sender: TObject);
2987
var
2988
  i: Integer;
2989
begin
2990
  FormChartHReport := TFormChartHReport.Create(nil);
2991
  try
2992
    FormChartHReport.QRChart1.Chart.View3D := ChartFeed4.View3D;
2993
    FormChartHReport.QRChart1.Chart.Title.Assign(ChartFeed4.Title);
2994
    FormChartHReport.QRChart1.Chart.SubTitle.Assign(ChartFeed4.SubTitle);
2995
    FormChartHReport.QRChart1.Chart.BottomAxis.Labels := False;
2996
    for i := 0 to ChartFeed4.SeriesCount - 1 do
2997
      CloneChartSeries(ChartFeed4[i]).ParentChart := FormChartHReport.QRChart1.Chart;
2998
    FormChartHReport.QuickRepChart.PrinterSetup;
2999
    if FormChartHReport.QuickRepChart.Tag = 0
3000
    then
3001
      FormChartHReport.QuickRepChart.Print;
3002
  finally
3003
    FormChartHReport.Release;
3004
  end;
3005
end;
3006
3007
procedure TFormFeedsCharts.WMSysCommand(var Message: TWMSysCommand);
3008
begin
3009
  if Message.CmdType = SC_MINIMIZE
3010
  then
3011
    Application.Minimize
3012
  else
3013
    inherited;
3014
end;
3015
3016
end.