Statistiques
| Révision:

root / UFRapCompSimulP.pas @ 5

Historique | Voir | Annoter | Télécharger (14,571 ko)

1 3 avalancogn
unit UFRapCompSimulP ;
2
3
interface
4
5
uses
6
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7
  Dialogs, OleCtrls, StdCtrls, ComCtrls, DB, DBClient, ExtCtrls, QRCtrls,
8
  QuickRpt, QRPrntr, MidasLib, UVariables, gnugettext;
9
10
type
11
  TFRapCompSimulP = class(TForm)
12
    QRRapport: TQuickRep;
13
    PHBRapport: TQRBand;
14
    DBRapport: TQRBand;
15
    QRLTitre: TQRLabel;
16
    QRLCaract: TQRLabel;
17
    QRLPerf: TQRLabel;
18
    QRLProfil: TQRLabel;
19
    QRLSeqAli: TQRLabel;
20
    QRLRation: TQRLabel;
21
    QRLPoidsDeb: TQRLabel;
22
    QRLPoidsFin: TQRLabel;
23
    QRDBTProfil: TQRDBText;
24
    QRDBTSeqAli: TQRDBText;
25
    QRDBTRation: TQRDBText;
26
    QRDBTPoidsDeb_1: TQRDBText;
27
    QRDBTPoidsFin_1: TQRDBText;
28
    QRLAgeDeb: TQRLabel;
29
    QRLAgeFin: TQRLabel;
30
    QRDBTAgeDeb_1: TQRDBText;
31
    QRDBTAgeFin_1: TQRDBText;
32
    QRLDuree: TQRLabel;
33
    QRLGMQ: TQRLabel;
34
    QREDuree_1: TQRExpr;
35
    QREGMQ_1: TQRExpr;
36
    QRLPD: TQRLabel;
37
    QRLLD: TQRLabel;
38
    QRLAliTot: TQRLabel;
39
    QRLAliMoy: TQRLabel;
40
    QRDBTAliTot_1: TQRDBText;
41
    QREAliMoy_1: TQRExpr;
42
    QREPD_1: TQRExpr;
43
    QRELD_1: TQRExpr;
44
    QRLWastage: TQRLabel;
45
    QREWastage_1: TQRExpr;
46
    QRLFeed: TQRLabel;
47
    QRLTMP: TQRLabel;
48
    QRDBTTMP_1: TQRDBText;
49
    QRLP2: TQRLabel;
50
    QRDBTP2_1: TQRDBText;
51
    CDSRapport: TClientDataSet;
52
    IFAgeDeb_1: TIntegerField;
53
    IFAgeFin_1: TIntegerField;
54
    FFPoidsDeb_1: TFloatField;
55
    FFPoidsFin_1: TFloatField;
56
    FFpDeb_1: TFloatField;
57
    FFlDeb_1: TFloatField;
58
    FFConso_1: TFloatField;
59
    FFTMP_1: TFloatField;
60
    FFP2_1: TFloatField;
61
    PFBRapport: TQRBand;
62
    QRLUser: TQRLabel;
63
    QRLWarning: TQRLabel;
64
    QRSDDate: TQRSysData;
65
    QRSEntete: TQRShape;
66
    QRLRC: TQRLabel;
67
    QRDBTRC_1: TQRDBText;
68
    FFRC_2: TFloatField;
69
    QRSDRapport: TQRSubDetail;
70
    CDSSimul: TClientDataSet;
71
    SFProfil: TStringField;
72
    SFSeqAli: TStringField;
73
    SFRation: TStringField;
74
    IFAgeDeb_2: TIntegerField;
75
    IFAgeFin_2: TIntegerField;
76
    FFPoidsDeb_2: TFloatField;
77
    FFPoidsFin_2: TFloatField;
78
    FFpDeb_2: TFloatField;
79
    FFlDeb_2: TFloatField;
80
    FFConso_2: TFloatField;
81
    FFTMP_2: TFloatField;
82
    FFP2_2: TFloatField;
83
    IFAgeDeb_3: TIntegerField;
84
    IFAgeFin_3: TIntegerField;
85
    FFPoidsDeb_3: TFloatField;
86
    FFPoidsFin_3: TFloatField;
87
    FFpDeb_3: TFloatField;
88
    FFlDeb_3: TFloatField;
89
    FFConso_3: TFloatField;
90
    FFTMP_3: TFloatField;
91
    FFP2_3: TFloatField;
92
    FFRC_3: TFloatField;
93
    IFAgeDeb_4: TIntegerField;
94
    IFAgeFin_4: TIntegerField;
95
    FFPoidsDeb_4: TFloatField;
96
    FFPoidsFin_4: TFloatField;
97
    FFpDeb_4: TFloatField;
98
    FFlDeb_4: TFloatField;
99
    FFConso_4: TFloatField;
100
    FFTMP_4: TFloatField;
101
    FFP2_4: TFloatField;
102
    FFRC_4: TFloatField;
103
    IFAgeDeb_5: TIntegerField;
104
    IFAgeFin_5: TIntegerField;
105
    FFPoidsDeb_5: TFloatField;
106
    FFPoidsFin_5: TFloatField;
107
    FFpDeb_5: TFloatField;
108
    FFlDeb_5: TFloatField;
109
    FFConso_5: TFloatField;
110
    FFTMP_5: TFloatField;
111
    FFP2_5: TFloatField;
112
    FFRC_5: TFloatField;
113
    FFRC_1: TFloatField;
114
    QREWastage_2: TQRExpr;
115
    QRELD_2: TQRExpr;
116
    QREPD_2: TQRExpr;
117
    QREAliMoy_2: TQRExpr;
118
    QREGMQ_2: TQRExpr;
119
    QREDuree_2: TQRExpr;
120
    QRDBTPoidsDeb_2: TQRDBText;
121
    QRDBTPoidsFin_2: TQRDBText;
122
    QRDBTAgeDeb_2: TQRDBText;
123
    QRDBTAgeFin_2: TQRDBText;
124
    QRDBTAliTot_2: TQRDBText;
125
    QRDBTTMP_2: TQRDBText;
126
    QRDBTP2_2: TQRDBText;
127
    QRDBTRC_2: TQRDBText;
128
    QREWastage_3: TQRExpr;
129
    QRELD_3: TQRExpr;
130
    QREPD_3: TQRExpr;
131
    QREAliMoy_3: TQRExpr;
132
    QREGMQ_3: TQRExpr;
133
    QREDuree_3: TQRExpr;
134
    QRDBTPoidsDeb_3: TQRDBText;
135
    QRDBTPoidsFin_3: TQRDBText;
136
    QRDBTAgeDeb_3: TQRDBText;
137
    QRDBTAgeFin_3: TQRDBText;
138
    QRDBTAliTot_3: TQRDBText;
139
    QRDBTTMP_3: TQRDBText;
140
    QRDBTP2_3: TQRDBText;
141
    QRDBTRC_3: TQRDBText;
142
    QREWastage_4: TQRExpr;
143
    QRELD_4: TQRExpr;
144
    QREPD_4: TQRExpr;
145
    QREAliMoy_4: TQRExpr;
146
    QREGMQ_4: TQRExpr;
147
    QREDuree_4: TQRExpr;
148
    QRDBTPoidsDeb_4: TQRDBText;
149
    QRDBTPoidsFin_4: TQRDBText;
150
    QRDBTAgeDeb_4: TQRDBText;
151
    QRDBTAgeFin_4: TQRDBText;
152
    QRDBTAliTot_4: TQRDBText;
153
    QRDBTTMP_4: TQRDBText;
154
    QRDBTP2_4: TQRDBText;
155
    QRDBTRC_4: TQRDBText;
156
    QREWastage_5: TQRExpr;
157
    QRELD_5: TQRExpr;
158
    QREPD_5: TQRExpr;
159
    QREAliMoy_5: TQRExpr;
160
    QREGMQ_5: TQRExpr;
161
    QREDuree_5: TQRExpr;
162
    QRDBTPoidsDeb_5: TQRDBText;
163
    QRDBTPoidsFin_5: TQRDBText;
164
    QRDBTAgeDeb_5: TQRDBText;
165
    QRDBTAgeFin_5: TQRDBText;
166
    QRDBTAliTot_5: TQRDBText;
167
    QRDBTTMP_5: TQRDBText;
168
    QRDBTP2_5: TQRDBText;
169
    QRDBTRC_5: TQRDBText;
170
    SFSimul: TStringField;
171
    QRDBTSimul: TQRDBText;
172
    QRLSimulNo: TQRLabel;
173
    QRLNo1: TQRLabel;
174
    QRLabel1: TQRLabel;
175
    QRLabel2: TQRLabel;
176
    QRLabel3: TQRLabel;
177
    QRLabel4: TQRLabel;
178
    QRIInraPorc: TQRImage;
179
    QRLInraPorc: TQRLabel;
180
    FFpFin_1: TFloatField;
181
    FFlFin_1: TFloatField;
182
    FFpFin_2: TFloatField;
183
    FFlFin_2: TFloatField;
184
    FFpFin_3: TFloatField;
185
    FFlFin_3: TFloatField;
186
    FFpFin_4: TFloatField;
187
    FFlFin_4: TFloatField;
188
    FFpFin_5: TFloatField;
189
    FFlFin_5: TFloatField;
190
    FFIngere_1: TFloatField;
191
    FFIngere_2: TFloatField;
192
    FFIngere_3: TFloatField;
193
    FFIngere_4: TFloatField;
194
    FFIngere_5: TFloatField;
195
    QREFeed_5: TQRExpr;
196
    QREFeed_4: TQRExpr;
197
    QREFeed_3: TQRExpr;
198
    QREFeed_2: TQRExpr;
199
    QREFeed_1: TQRExpr;
200
    procedure FormCreate(Sender: TObject);
201
  private
202
    { D?clarations priv?es }
203
  public
204
    { D?clarations publiques }
205
  end;
206
207
var
208
  FRapCompSimulP: TFRapCompSimulP;
209
210
implementation
211
212
uses
213
  UStrings, UFindRec, UCalcul, UUtil, UFSimulP, UFPrevRap ;
214
215
{$R *.dfm}
216
217
{ TFRapSimulP }
218
219
procedure TFRapCompSimulP.FormCreate(Sender: TObject);
220
var
221
  i, k, t : integer ;
222
  c : double ;
223
begin
224
  if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1
225
  then
226
    Font.Name := 'Arial Unicode MS';
227
  TranslateComponent(Self);
228
  // Licence
229
  if IsEducation and (Length (Course) > 0)
230
  then
231
    QRLUSer.Caption := Format('%s (%s)', [Course, Company])
232
  else
233
  if IsComplete or IsEducation
234
  then
235
    QRLUSer.Caption := Format('%s %s (%s)', [FirstName, LastName, Company])
236
  else
237
  if IsEvaluation
238
  then
239
    QRLUSer.Caption := StrEvaluation
240
  else
241
  begin
242
    QRLUSer.Caption := StrReadOnly;
243
    QRLUser.Font.Color := clRed;
244
  end;
245
  with CDSSimul do
246
  begin
247
    CreateDataSet;
248
    for k := 1 to 5 do
249
      if TabSimulP[k].Ok
250
      then
251
      begin
252
        Append;
253
        FieldValues['_Simul_'] := Format (StrSimulNo, [k]) ;
254
        PSimulP := ListSimulP[FindIdxSimulP (FindNomSimulP (TabSimulP[k].Simul))] ;
255
        if TabSimulP[k].Profil = -1
256
        then // Profil de la simulation
257
          FieldValues['_Profil_'] := FindNomProfilP (PSimulP.Profil)
258
        else
259
          FieldValues['_Profil_'] := FindNomProfilP (TabSimulP[k].Profil) ;
260
        if TabSimulP[k].SeqAli = -1
261
        then // S?quence alimentaire de la simulation
262
          FieldValues['_SeqAli_'] := FindNomSeqAliP (PSimulP.SeqAli)
263
        else
264
          FieldValues['_SeqAli_'] := FindNomSeqAliP (TabSimulP[k].SeqAli) ;
265
        if TabSimulP[k].Ration = -1
266
        then // plan de rationnement de la simulation
267
          FieldValues['_Ration_'] := FindNomRationP (PSimulP.Ration)
268
        else
269
          FieldValues['_Ration_'] := FindNomRationP (TabSimulP[k].Ration) ;
270
        Post;
271
      end ;
272
  end ;
273
  with CDSRapport do
274
  begin
275
    CreateDataSet;
276
    Append;
277
    for k := 1 to 5 do
278
      if TabSimulP[k].Ok
279
      then
280
      begin
281
        if TabSimulP[k].Profil = -1
282
        then // Profil de la simulation
283
          PProfilP := ListProfilP[FindIdxProfilP (FindNomProfilP (PSimulP.Profil))]
284
        else
285
          PProfilP := ListProfilP[FindIdxProfilP (FindNomProfilP (TabSimulP[k].Profil))] ;
286
        t := TabSimulP[k].Result.NbJSim;
287
        FieldValues[Format('_AgeDeb_%d_', [k])] := TabSimulP[k].Result.TabResult[1, 1];
288
        FieldValues[Format('_AgeFin_%d_', [k])] := TabSimulP[k].Result.TabResult[1, t] + 1;
289
        FieldValues[Format('_PoidsDeb_%d_', [k])] := TabSimulP[k].Result.TabResult[2, 1];
290
        FieldValues[Format('_PoidsFin_%d_', [k])] := TabSimulP[k].Result.TabResult[2, t] + TabSimulP[k].Result.TabResult[84, t];
291
        FieldValues[Format('_pDeb_%d_', [k])] := TabSimulP[k].Result.TabResult[49, 1];
292
        FieldValues[Format('_pFin_%d_', [k])] := TabSimulP[k].Result.TabResult[49, t] + TabSimulP[k].Result.TabResult[79, t] / 1000;
293
        FieldValues[Format('_lDeb_%d_', [k])] := TabSimulP[k].Result.TabResult[50, 1];
294
        FieldValues[Format('_lFin_%d_', [k])] := TabSimulP[k].Result.TabResult[50, t] + TabSimulP[k].Result.TabResult[80, t] / 1000;
295
        c := 0;
296
        for i := 1 to t do
297
          c := c + TabSimulP[k].Result.TabResult[113, i];
298
        FieldValues[Format('_Conso_%d_', [k])] := c;
299
        c := 0;
300
        for i := 1 to t do
301
          c := c + TabSimulP[k].Result.TabResult[11, i];
302
        FieldValues[Format('_Ingere_%d_', [k])] := c;
303
        if FatInfo = 0
304
        then // P2
305
          FieldValues[Format('_P2_%d_', [k])] := CalcP2(FieldValues[Format('_lFin_%d_', [k])])
306
        else // User defined
307
          FieldValues[Format('_P2_%d_', [k])] := CalcUserFat(CalcPVV(FieldValues[Format('_PoidsFin_%d_', [k])]), FieldValues[Format('_pFin_%d_', [k])], FieldValues[Format('_lFin_%d_', [k])]);
308
        if LeanInfo = 0
309
        then // TMP
310
          FieldValues[Format('_TMP_%d_', [k])] := CalcTMP(CalcPVV(FieldValues[Format('_PoidsFin_%d_', [k])]), FieldValues[Format('_pFin_%d_', [k])], FieldValues[Format('_lFin_%d_', [k])])
311
        else // User defined
312
          FieldValues[Format('_TMP_%d_', [k])] := CalcUserLean(CalcPVV(FieldValues[Format('_PoidsFin_%d_', [k])]), FieldValues[Format('_pFin_%d_', [k])], FieldValues[Format('_lFin_%d_', [k])]);
313
        FieldValues[Format('_RC_%d_', [k])] := CalcRC(FieldValues[Format('_PoidsFin_%d_', [k])], CalcRCStd(PProfilP.PVFin, PProfilP.Carcasse), FieldValues[Format('_PoidsFin_%d_', [k])]) * 100;
314
      end
315
      else
316
      begin
317
        FieldValues[Format('_AgeDeb_%d_', [k])] := 0;
318
        FieldValues[Format('_AgeFin_%d_', [k])] := 0;
319
        FieldValues[Format('_PoidsDeb_%d_', [k])] := 0;
320
        FieldValues[Format('_PoidsFin_%d_', [k])] := 0;
321
        FieldValues[Format('_pDeb_%d_', [k])] := 0;
322
        FieldValues[Format('_pFin_%d_', [k])] := 0;
323
        FieldValues[Format('_lDeb_%d_', [k])] := 0;
324
        FieldValues[Format('_lFin_%d_', [k])] := 0;
325
        FieldValues[Format('_Conso_%d_', [k])] := 0;
326
        FieldValues[Format('_Ingere_%d_', [k])] := 0;
327
        FieldValues[Format('_P2_%d_', [k])] := 0;
328
        FieldValues[Format('_TMP_%d_', [k])] := 0;
329
        FieldValues[Format('_RC_%d_', [k])] := 0;
330
      end ;
331
    Post;
332
  end ;
333
  if FeedInfo = 0
334
  then // Indice de consommation
335
    QREFeed_1.Expression := 'IF(CDSRapport._PoidsDeb_1_ = CDSRapport._PoidsFin_1_, 0, CDSRapport._Conso_1_ / (CDSRapport._PoidsFin_1_ - CDSRapport._PoidsDeb_1_))'
336
  else // Efficacit? alimentaire
337
    QREFeed_1.Expression := 'IF(CDSRapport._Conso_1_ = 0, 0, (CDSRapport._PoidsFin_1_ - CDSRapport._PoidsDeb_1_) / CDSRapport._Conso_1_)';
338
  if FeedInfo = 0
339
  then // Indice de consommation
340
    QREFeed_2.Expression := 'IF(CDSRapport._PoidsDeb_2_ = CDSRapport._PoidsFin_2_, 0, CDSRapport._Conso_2_ / (CDSRapport._PoidsFin_2_ - CDSRapport._PoidsDeb_2_))'
341
  else // Efficacit? alimentaire
342
    QREFeed_2.Expression := 'IF(CDSRapport._Conso_2_ = 0, 0, (CDSRapport._PoidsFin_2_ - CDSRapport._PoidsDeb_2_) / CDSRapport._Conso_2_)';
343
  if FeedInfo = 0
344
  then // Indice de consommation
345
    QREFeed_3.Expression := 'IF(CDSRapport._PoidsDeb_3_ = CDSRapport._PoidsFin_3_, 0, CDSRapport._Conso_3_ / (CDSRapport._PoidsFin_3_ - CDSRapport._PoidsDeb_3_))'
346
  else // Efficacit? alimentaire
347
    QREFeed_3.Expression := 'IF(CDSRapport._Conso_3_ = 0, 0, (CDSRapport._PoidsFin_3_ - CDSRapport._PoidsDeb_3_) / CDSRapport._Conso_3_)';
348
  if FeedInfo = 0
349
  then // Indice de consommation
350
    QREFeed_4.Expression := 'IF(CDSRapport._PoidsDeb_4_ = CDSRapport._PoidsFin_4_, 0, CDSRapport._Conso_4_ / (CDSRapport._PoidsFin_4_ - CDSRapport._PoidsDeb_4_))'
351
  else // Efficacit? alimentaire
352
    QREFeed_4.Expression := 'IF(CDSRapport._Conso_4_ = 0, 0, (CDSRapport._PoidsFin_4_ - CDSRapport._PoidsDeb_4_) / CDSRapport._Conso_4_)';
353
  if FeedInfo = 0
354
  then // Indice de consommation
355
    QREFeed_5.Expression := 'IF(CDSRapport._PoidsDeb_5_ = CDSRapport._PoidsFin_5_, 0, CDSRapport._Conso_5_ / (CDSRapport._PoidsFin_5_ - CDSRapport._PoidsDeb_5_))'
356
  else // Efficacit? alimentaire
357
    QREFeed_5.Expression := 'IF(CDSRapport._Conso_5_ = 0, 0, (CDSRapport._PoidsFin_5_ - CDSRapport._PoidsDeb_5_) / CDSRapport._Conso_5_)';
358
  QRLAgeDeb.Caption := Format('%s (%s)', [QRLAgeDeb.Caption, _('d')]);
359
  QRLAgeFin.Caption := Format('%s (%s)', [QRLAgeFin.Caption, _('d')]);
360
  QRLDuree.Caption := Format('%s (%s)', [QRLDuree.Caption, _('d')]);
361
  QRLPoidsDeb.Caption := Format('%s (%s)', [QRLPoidsDeb.Caption, _('kg')]);
362
  QRLPoidsFin.Caption := Format('%s (%s)', [QRLPoidsFin.Caption, _('kg')]);
363
  QRLGMQ.Caption := Format('%s (%s/%s)', [QRLGMQ.Caption, _('g'), _('d')]);
364
  QRLPD.Caption := Format('%s (%s/%s)', [QRLPD.Caption, _('g'), _('d')]);
365
  QRLLD.Caption := Format('%s (%s/%s)', [QRLLD.Caption, _('g'), _('d')]);
366
  QRLAliTot.Caption := Format('%s (%s)', [QRLAliTot.Caption, _('kg')]);
367
  QRLAliMoy.Caption := Format('%s (%s/%s)', [QRLAliMoy.Caption, _('g'), _('d')]);
368
  QRLWastage.Caption := Format('%s (%%)', [QRLWastage.Caption]);
369
  if FeedInfo = 0
370
  then // Indice de consommation
371
    QRLFeed.Caption := Format('%s (%s/%s)', [_('Average feed-to-gain ratio'), _('kg feed'), _('kg gain')])
372
  else // Efficacit? alimentaire
373
    QRLFeed.Caption := Format('%s (%s/%s)', [_('Average gain-to-feed ratio'), _('kg gain'), _('kg feed')]);
374
  if FatInfo = 0
375
  then // P2
376
    QRLP2.Caption := Format('%s (%s)', [_('Backfat thickness at slaughter'), _('mm')])
377
  else // User defined
378
    if Length(UserFatLongName) = 0
379
    then
380
      QRLP2.Caption := Format('%s (%s)', [_('User-defined backfat thickness'), _('mm')])
381
    else
382
      QRLP2.Caption := Format('%s (%s)', [UserFatLongName, _('mm')]);
383
  if LeanInfo = 0
384
  then // TMP
385
    QRLTMP.Caption := Format('%s (%%)', [_('Lean meat at slaughter')])
386
  else // User defined
387
    if Length(UserLeanLongName) = 0
388
    then
389
      QRLTMP.Caption := Format('%s (%%)', [_('User-defined lean meat')])
390
    else
391
      QRLTMP.Caption := Format('%s (%%)', [UserLeanLongName]);
392
  QRLRC.Caption := Format('%s (%%)', [QRLRC.Caption]);
393
  RegisterPreviewClass(TQRPrevRapInterface);
394
//  QRRapport.PreviewModal;
395
//  RegisterPreviewClass(TQRStandardPreviewInterface);
396
end;
397
398
end.