root / UFImpExp.pas
Historique | Voir | Annoter | Télécharger (45,36 ko)
1 |
unit UFImpExp ;
|
---|---|
2 |
|
3 |
interface
|
4 |
|
5 |
uses
|
6 |
Windows, Forms, Classes, Controls, Dialogs, StdCtrls, Buttons, UVariables; |
7 |
|
8 |
type
|
9 |
TFImpExp = class(TForm)
|
10 |
LBMatiere: TListBox; |
11 |
GBMatiere: TGroupBox; |
12 |
GBAliment: TGroupBox; |
13 |
LBAliment: TListBox; |
14 |
GBFichier: TGroupBox; |
15 |
LBFichier: TListBox; |
16 |
SBExpMat: TSpeedButton; |
17 |
SBImpMat: TSpeedButton; |
18 |
SBExpAli: TSpeedButton; |
19 |
SBImpAli: TSpeedButton; |
20 |
EFichier: TEdit; |
21 |
SBFichier: TSpeedButton; |
22 |
SDFichier: TSaveDialog; |
23 |
LTypeMat: TLabel; |
24 |
CBTypeMat: TComboBox; |
25 |
LTypeAli: TLabel; |
26 |
CBTypeAli: TComboBox; |
27 |
GBExpr: TGroupBox; |
28 |
LFibres: TLabel; |
29 |
LGal: TLabel; |
30 |
LCompo: TLabel; |
31 |
LAA: TLabel; |
32 |
LAG: TLabel; |
33 |
LMacro: TLabel; |
34 |
LOligo: TLabel; |
35 |
LTFibres: TLabel; |
36 |
LTOligo: TLabel; |
37 |
LTMacro: TLabel; |
38 |
LTAG: TLabel; |
39 |
LTAA: TLabel; |
40 |
LdAA: TLabel; |
41 |
LTCompo: TLabel; |
42 |
LdCompo: TLabel; |
43 |
LRap: TLabel; |
44 |
LDig: TLabel; |
45 |
procedure FormShow(Sender: TObject);
|
46 |
procedure FormClose(Sender: TObject; var Action: TCloseAction); |
47 |
procedure FormActivate(Sender: TObject);
|
48 |
procedure FormDeactivate(Sender: TObject);
|
49 |
procedure SBFichierClick(Sender: TObject);
|
50 |
procedure SBExpMatClick(Sender: TObject);
|
51 |
procedure SBImpMatClick(Sender: TObject);
|
52 |
procedure SBExpAliClick(Sender: TObject);
|
53 |
procedure SBImpAliClick(Sender: TObject);
|
54 |
procedure CBTypeMatChange(Sender: TObject);
|
55 |
procedure CBTypeAliChange(Sender: TObject);
|
56 |
procedure FormCreate(Sender: TObject);
|
57 |
private
|
58 |
{ D?clarations priv?es }
|
59 |
ModifMat, ModifAli: Boolean; |
60 |
F: TextFile; |
61 |
ListCSV: TList; |
62 |
Separator: String;
|
63 |
procedure SaveMat;
|
64 |
procedure SaveAli;
|
65 |
function GetInteger(var I: Integer; var Ch: Char): Boolean; |
66 |
function GetDouble(var D: Double; var Ch: Char): Boolean; |
67 |
function GetString(var S: string; var Ch: Char): Boolean; |
68 |
procedure FormatInToOut(const recIn: PRecCSV; var recOut: PRecCSV); |
69 |
procedure FormatOutToIn(const recOut: PRecCSV; var recIn: PRecCSV); |
70 |
procedure PutCSV(recIn: PRecCSV);
|
71 |
public
|
72 |
{ D?clarations publiques }
|
73 |
procedure DisplayConfig;
|
74 |
end;
|
75 |
|
76 |
var
|
77 |
FImpExp: TFImpExp; |
78 |
|
79 |
implementation
|
80 |
|
81 |
uses
|
82 |
SysUtils, gnugettext, UStrings, UInit, UUtil, UFindRec, UFConfig; |
83 |
|
84 |
{$R *.dfm}
|
85 |
|
86 |
{ TFImpExp }
|
87 |
|
88 |
procedure TFImpExp.FormCreate(Sender: TObject);
|
89 |
begin
|
90 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
91 |
then
|
92 |
Font.Name := 'Arial Unicode MS';
|
93 |
TranslateComponent(Self); |
94 |
Constraints.MinWidth := 792 + (Width - ClientWidth);
|
95 |
Width := Constraints.MinWidth; |
96 |
Constraints.MinHeight := 416 + (Height - ClientHeight);
|
97 |
Height := Constraints.MinHeight; |
98 |
CBTypeMat.ItemIndex := 0;
|
99 |
CBTypeAli.ItemIndex := 0;
|
100 |
end;
|
101 |
|
102 |
procedure TFImpExp.FormShow (Sender : TObject) ;
|
103 |
begin
|
104 |
ModifMat := FALSE ; |
105 |
ModifAli := FALSE ; |
106 |
ListCSV := TList.Create ; |
107 |
Separator := ListSeparator; |
108 |
// Ajustement du mode d'expression
|
109 |
FConfig := TFConfig.Create(Self); // Cr?ation de la configuration
|
110 |
DisplayConfig; // Affichage des libell?s
|
111 |
FConfig.Release; // Lib?ration de la configuration
|
112 |
end ;
|
113 |
|
114 |
procedure TFImpExp.FormClose (Sender : TObject ; var Action : TCloseAction) ; |
115 |
var
|
116 |
i: Integer; |
117 |
recIn: PRecCSV; |
118 |
begin
|
119 |
if ModifMat then SaveMat ; |
120 |
if ModifAli then SaveAli ; |
121 |
if ListCSV.Count > 0 |
122 |
then
|
123 |
for i := 0 to ListCSV.Count - 1 do |
124 |
begin
|
125 |
recIn := ListCSV[i]; |
126 |
Dispose(recIn); |
127 |
end;
|
128 |
ListCSV.Free; |
129 |
Action := caFree ; |
130 |
NumWinImpExp := -1 ;
|
131 |
end ;
|
132 |
|
133 |
procedure TFImpExp.FormActivate (Sender : TObject) ;
|
134 |
begin
|
135 |
CBTypeMatChange (nil) ;
|
136 |
CBTypeAliChange (nil) ;
|
137 |
end ;
|
138 |
|
139 |
procedure TFImpExp.FormDeactivate (Sender : TObject) ;
|
140 |
begin
|
141 |
if ModifMat then SaveMat ; |
142 |
if ModifAli then SaveAli ; |
143 |
end ;
|
144 |
|
145 |
procedure TFImpExp.SaveMat ;
|
146 |
begin
|
147 |
ModifMat := FALSE ; |
148 |
if MessageDlg (MsgSaveMat, mtConfirmation, [mbYes, mbNo], 0) = mrYes |
149 |
then
|
150 |
SaveMatiere |
151 |
else
|
152 |
LoadMatiere ; |
153 |
end ;
|
154 |
|
155 |
procedure TFImpExp.SaveAli ;
|
156 |
begin
|
157 |
ModifAli := FALSE ; |
158 |
if MessageDlg (MsgSaveAli, mtConfirmation, [mbYes, mbNo], 0) = mrYes |
159 |
then
|
160 |
SaveAliment |
161 |
else
|
162 |
LoadAliment ; |
163 |
end ;
|
164 |
|
165 |
function TFImpExp.GetInteger (var I : Integer ; var Ch : Char) : Boolean ; |
166 |
var
|
167 |
S : string ;
|
168 |
Fin : boolean ; |
169 |
begin
|
170 |
S := '' ;
|
171 |
Read (F, Ch) ;
|
172 |
Fin := (Ch = Separator) or (Ch = Chr (13)) or (Ch = Chr (26)) ; |
173 |
while not Fin do |
174 |
begin
|
175 |
S := S + Ch ; |
176 |
Read (F, Ch) ;
|
177 |
Fin := (Ch = Separator) or (Ch = Chr (13)) or (Ch = Chr (26)) ; |
178 |
end ;
|
179 |
S := Trim (S) ; |
180 |
result := TRUE ; |
181 |
if Length (S) = 0 |
182 |
then
|
183 |
I := 0
|
184 |
else
|
185 |
try
|
186 |
I := StrToInt (S) ; |
187 |
except
|
188 |
result := FALSE ; |
189 |
end ;
|
190 |
end ;
|
191 |
|
192 |
function TFImpExp.GetDouble (var D : Double ; var Ch : Char) : Boolean ; |
193 |
var
|
194 |
S : string ;
|
195 |
Fin : boolean ; |
196 |
begin
|
197 |
S := '' ;
|
198 |
Read (F, Ch) ;
|
199 |
Fin := (Ch = Separator) or (Ch = Chr (13)) or (Ch = Chr (26)) ; |
200 |
while not Fin do |
201 |
begin
|
202 |
S := S + Ch ; |
203 |
Read (F, Ch) ;
|
204 |
Fin := (Ch = Separator) or (Ch = Chr (13)) or (Ch = Chr (26)) ; |
205 |
end ;
|
206 |
S := Trim (S) ; |
207 |
result := TRUE ; |
208 |
if Length (S) = 0 |
209 |
then
|
210 |
D := 0
|
211 |
else
|
212 |
try
|
213 |
D := StrToFloat (S) ; |
214 |
except
|
215 |
result := FALSE ; |
216 |
end ;
|
217 |
end ;
|
218 |
|
219 |
function TFImpExp.GetString (var S : string ; var Ch : Char) : Boolean ; |
220 |
var
|
221 |
Fin, Quoted : boolean ; |
222 |
begin
|
223 |
S := '' ;
|
224 |
Read (F, Ch) ;
|
225 |
Fin := (Ch = Separator) or (Ch = Chr (13)) or (Ch = Chr (26)) ; |
226 |
Quoted := (Ch = '"') ;
|
227 |
if Quoted
|
228 |
then
|
229 |
begin
|
230 |
Read (F, Ch) ;
|
231 |
Fin := (Ch = Chr (26)) ;
|
232 |
while not Fin do |
233 |
begin
|
234 |
if (Ch = '"') |
235 |
then
|
236 |
begin
|
237 |
Read (F, Ch) ;
|
238 |
Fin := (Ch <> '"') ;
|
239 |
Quoted := not ((Ch = Separator) or (Ch = Chr (13)) or (Ch = Chr (26))) ; |
240 |
end ;
|
241 |
if not Fin |
242 |
then
|
243 |
begin
|
244 |
S := S + Ch ; |
245 |
Read (F, Ch) ;
|
246 |
Fin := (Ch = Chr (26)) ;
|
247 |
end ;
|
248 |
end ;
|
249 |
end
|
250 |
else
|
251 |
while not Fin do |
252 |
begin
|
253 |
S := S + Ch ; |
254 |
Read (F, Ch) ;
|
255 |
Fin := (Ch = Separator) or (Ch = Chr (13)) or (Ch = Chr (26)) ; |
256 |
end ;
|
257 |
result := not Quoted ;
|
258 |
end ;
|
259 |
|
260 |
procedure TFImpExp.FormatInToOut(const recIn: PRecCSV; var recOut: PRecCSV); |
261 |
var
|
262 |
i: Integer; |
263 |
RapMS, RapTcompo, RapTAA, RapTAG, RapTMacro, RapTOligo, RapTFibres, RapDCompo, RapDAA: Double; |
264 |
begin
|
265 |
recOut.Nom := recIn.Nom; |
266 |
recOut.Memo := recIn.Memo; |
267 |
recOut.Typ := recIn.Typ; |
268 |
if ConfTCompo = 0 |
269 |
then // g/kg |
270 |
recOut.CC.MS := recIn.CC.MS |
271 |
else // % |
272 |
recOut.CC.MS := recIn.CC.MS / 1000 * 100; |
273 |
if ConfRap = 0 |
274 |
then // sur frais |
275 |
RapMS := recIn.CC.MS / 1000
|
276 |
else // sur mati?re s?che |
277 |
RapMS := 1;
|
278 |
if ConfTCompo = 0 |
279 |
then // g/kg |
280 |
RapTCompo := RapMS |
281 |
else // % |
282 |
RapTCompo := 100 / 1000 * RapMS; |
283 |
recOut.CC.MM := recIn.CC.MM * RapTCompo; |
284 |
recOut.CC.MO := recIn.CC.MO * RapTCompo; |
285 |
recOut.CC.Lip := recIn.CC.Lip * RapTCompo; |
286 |
recOut.CC.MAT := recIn.CC.MAT * RapTCompo; |
287 |
recOut.CC.Amidon := recIn.CC.Amidon * RapTCompo; |
288 |
recOut.CC.Sucres := recIn.CC.Sucres * RapTCompo; |
289 |
if ConfDig = 0 |
290 |
then // CUD |
291 |
RapDCompo := 1
|
292 |
else // Teneur digestible |
293 |
if ConfdCompo = 0 |
294 |
then // g/kg |
295 |
RapDCompo := 1 / 100 * RapMS |
296 |
else // % |
297 |
RapDCompo := 1 / 1000 * RapMS; |
298 |
if ConfDig = 0 |
299 |
then // CUD |
300 |
begin
|
301 |
recOut.CC.dMO_T := recIn.CC.dMO_T * RapDCompo; |
302 |
recOut.CC.dMO_C := recIn.CC.dMO_C * RapDCompo; |
303 |
recOut.CC.dLip_T := recIn.CC.dLip_T * RapDCompo; |
304 |
recOut.CC.dLip_C := recIn.CC.dLip_C * RapDCompo; |
305 |
recOut.CC.dMAT_T := recIn.CC.dMAT_T * RapDCompo; |
306 |
recOut.CC.dMAT_C := recIn.CC.dMAT_C * RapDCompo; |
307 |
end
|
308 |
else // Teneur digestible |
309 |
begin
|
310 |
recOut.CC.dMO_T := recIn.CC.dMO_T * recIn.CC.MO * RapDCompo; |
311 |
recOut.CC.dMO_C := recIn.CC.dMO_C * recIn.CC.MO * RapDCompo; |
312 |
recOut.CC.dLip_T := recIn.CC.dLip_T * recIn.CC.Lip * RapDCompo; |
313 |
recOut.CC.dLip_C := recIn.CC.dLip_C * recIn.CC.Lip * RapDCompo; |
314 |
recOut.CC.dMAT_T := recIn.CC.dMAT_T * recIn.CC.MAT * RapDCompo; |
315 |
recOut.CC.dMAT_C := recIn.CC.dMAT_C * recIn.CC.MAT * RapDCompo; |
316 |
end;
|
317 |
recOut.CC.EB := recIn.CC.EB * RapMS; |
318 |
recOut.CC.ED_T := recIn.CC.ED_T * RapMS; |
319 |
recOut.CC.ED_C := recIn.CC.ED_C * RapMS; |
320 |
recOut.CC.EM_T := recIn.CC.EM_T * RapMS; |
321 |
recOut.CC.EM_C := recIn.CC.EM_C * RapMS; |
322 |
recOut.CC.EN_T := recIn.CC.EN_T * RapMS; |
323 |
recOut.CC.EN_C := recIn.CC.EN_C * RapMS; |
324 |
if ConfTMacro = 0 |
325 |
then // g/kg |
326 |
RapTMacro := RapMS |
327 |
else // % |
328 |
RapTMacro := 100 / 1000 * RapMS; |
329 |
recOut.CC.Ca := recIn.CC.Ca * RapTMacro; |
330 |
recOut.CC.P := recIn.CC.P * RapTMacro; |
331 |
recOut.CC.Na := recIn.CC.Na * RapTMacro; |
332 |
recOut.CC.K := recIn.CC.K * RapTMacro; |
333 |
recOut.CC.Mg := recIn.CC.Mg * RapTMacro; |
334 |
recOut.CC.Cl := recIn.CC.Cl * RapTMacro; |
335 |
recOut.CC.S := recIn.CC.S * RapTMacro; |
336 |
if ConfTOligo = 0 |
337 |
then // mg/kg |
338 |
RapTOligo := RapMS |
339 |
else // % |
340 |
RapTOligo := 100 / 1000000 * RapMS; |
341 |
recOut.CC.Cu := recIn.CC.Cu * RapTOligo; |
342 |
recOut.CC.Zn := recIn.CC.Zn * RapTOligo; |
343 |
recOut.CC.Mn := recIn.CC.Mn * RapTOligo; |
344 |
recOut.CC.Fe := recIn.CC.Fe * RapTOligo; |
345 |
recOut.CC.Se := recIn.CC.Se * RapTOligo; |
346 |
recOut.CC.Co := recIn.CC.Co * RapTOligo; |
347 |
recOut.CC.Mb := recIn.CC.Mb * RapTOligo; |
348 |
recOut.CC.I := recIn.CC.I * RapTOligo; |
349 |
recOut.CC.PdigG := recIn.CC.PdigG * RapMS; |
350 |
recOut.CC.PdigF := recIn.CC.PdigF * RapMS; |
351 |
recOut.CC.Phytase := recIn.CC.Phytase; |
352 |
recOut.CC.ActPhytE := recIn.CC.ActPhytE * RapMS; |
353 |
recOut.CC.ActPhytM := recIn.CC.ActPhytM * RapMS; |
354 |
recOut.CC.AGsLip := recIn.CC.AGsLip; |
355 |
case ConfTAG of |
356 |
0 : // g/kg |
357 |
RapTAG := 1000 / 100 * recIn.CC.AGsLip / 100 * recIn.CC.Lip / 1000 * RapMS; |
358 |
1 : // % |
359 |
RapTAG := recIn.CC.AGsLip / 100 * recIn.CC.Lip / 1000 * RapMS; |
360 |
else // % acides gras |
361 |
RapTAG := 1;
|
362 |
end;
|
363 |
recOut.CC.C6C8C10 := recIn.CC.C6C8C10 * RapTAG; |
364 |
recOut.CC.C12_0 := recIn.CC.C12_0 * RapTAG; |
365 |
recOut.CC.C14_0 := recIn.CC.C14_0 * RapTAG; |
366 |
recOut.CC.C16_0 := recIn.CC.C16_0 * RapTAG; |
367 |
recOut.CC.C16_1 := recIn.CC.C16_1 * RapTAG; |
368 |
recOut.CC.C18_0 := recIn.CC.C18_0 * RapTAG; |
369 |
recOut.CC.C18_1 := recIn.CC.C18_1 * RapTAG; |
370 |
recOut.CC.C18_2 := recIn.CC.C18_2 * RapTAG; |
371 |
recOut.CC.C18_3 := recIn.CC.C18_3 * RapTAG; |
372 |
recOut.CC.C18_4 := recIn.CC.C18_4 * RapTAG; |
373 |
recOut.CC.C20_0 := recIn.CC.C20_0 * RapTAG; |
374 |
recOut.CC.C20_1 := recIn.CC.C20_1 * RapTAG; |
375 |
recOut.CC.C20_4 := recIn.CC.C20_4 * RapTAG; |
376 |
recOut.CC.C20_5 := recIn.CC.C20_5 * RapTAG; |
377 |
recOut.CC.C22_0 := recIn.CC.C22_0 * RapTAG; |
378 |
recOut.CC.C22_1 := recIn.CC.C22_1 * RapTAG; |
379 |
recOut.CC.C22_5 := recIn.CC.C22_5 * RapTAG; |
380 |
recOut.CC.C22_6 := recIn.CC.C22_6 * RapTAG; |
381 |
recOut.CC.C24_0 := recIn.CC.C24_0 * RapTAG; |
382 |
if ConfTFibres = 0 |
383 |
then // g/kg |
384 |
RapTFibres := RapMS |
385 |
else // % |
386 |
RapTFibres := 100 / 1000 * RapMS; |
387 |
recOut.CC.CB := recIn.CC.CB * RapTFibres; |
388 |
if ConfDig = 0 |
389 |
then // CUD |
390 |
begin
|
391 |
recOut.CC.dCB_T := recIn.CC.dCB_T * RapDCompo; |
392 |
recOut.CC.dCB_C := recIn.CC.dCB_C * RapDCompo; |
393 |
end
|
394 |
else // Teneur digestible |
395 |
begin
|
396 |
recOut.CC.dCB_T := recIn.CC.dCB_T * recIn.CC.CB * RapDCompo; |
397 |
recOut.CC.dCB_C := recIn.CC.dCB_C * recIn.CC.CB * RapDCompo; |
398 |
end;
|
399 |
recOut.CC.Residu := recIn.CC.Residu * RapTCompo; |
400 |
if ConfDig = 0 |
401 |
then // CUD |
402 |
begin
|
403 |
recOut.CC.dResidu_T := recIn.CC.dResidu_T * RapDCompo; |
404 |
recOut.CC.dResidu_C := recIn.CC.dResidu_C * RapDCompo; |
405 |
end
|
406 |
else // Teneur digestible |
407 |
begin
|
408 |
recOut.CC.dResidu_T := recIn.CC.dResidu_T * recIn.CC.Residu * RapDCompo; |
409 |
recOut.CC.dResidu_C := recIn.CC.dResidu_C * recIn.CC.Residu * RapDCompo; |
410 |
end;
|
411 |
recOut.CC.NDF := recIn.CC.NDF * RapTFibres; |
412 |
recOut.CC.ADF := recIn.CC.ADF * RapTFibres; |
413 |
recOut.CC.ADL := recIn.CC.ADL * RapTFibres; |
414 |
recOut.CC.Parois := recIn.CC.Parois * RapTFibres; |
415 |
case ConfTAA of |
416 |
1 : // % |
417 |
RapTAA := 100 / 1000 * RapMS; |
418 |
2 : // % MAT |
419 |
if recIn.CC.MAT = 0 |
420 |
then
|
421 |
RapTAA := 0
|
422 |
else
|
423 |
RapTAA := 100 / recIn.CC.MAT;
|
424 |
else // g/kg |
425 |
RapTAA := RapMS; |
426 |
end;
|
427 |
for i := 1 to 12 do |
428 |
recOut.AAtotal[i] := recIn.AAtotal[i] * RapTAA; |
429 |
if ConfDig = 0 |
430 |
then // CUD |
431 |
RapDAA := 1
|
432 |
else // Teneur digestible |
433 |
if ConfdAA = 0 |
434 |
then // g/kg |
435 |
RapDAA := 1 / 100 * RapMS |
436 |
else // % |
437 |
RapDAA := 1 / 1000 * RapMS; |
438 |
for i := 0 to 12 do |
439 |
if ConfDig = 0 |
440 |
then // CUD |
441 |
recOut.CUDAA[i] := recIn.CUDAA[i] * RapDAA |
442 |
else // Teneur digestible |
443 |
recOut.CUDAA[i] := recIn.CUDAA[i] * recIn.AAtotal[i] * RapDAA; |
444 |
end;
|
445 |
|
446 |
procedure TFImpExp.FormatOutToIn(const recOut: PRecCSV; var recIn: PRecCSV); |
447 |
var
|
448 |
i: Integer; |
449 |
RapMS, RapTcompo, RapTAA, RapTAG, RapTMacro, RapTOligo, RapTFibres, RapDCompo, RapDAA: Double; |
450 |
begin
|
451 |
recIn.Nom := recOut.Nom; |
452 |
recIn.Memo := recOut.Memo; |
453 |
recIn.Typ := recOut.Typ; |
454 |
if ConfTCompo = 0 |
455 |
then // g/kg |
456 |
recIn.CC.MS := recOut.CC.MS |
457 |
else // % |
458 |
recIn.CC.MS := recOut.CC.MS / 100 * 1000; |
459 |
if ConfRap = 0 |
460 |
then // sur frais |
461 |
if recIn.CC.MS = 0 |
462 |
then
|
463 |
RapMS := 0
|
464 |
else
|
465 |
RapMS := 1000 / recIn.CC.MS
|
466 |
else // sur mati?re s?che |
467 |
RapMS := 1;
|
468 |
if ConfTCompo = 0 |
469 |
then // g/kg |
470 |
RapTCompo := RapMS |
471 |
else // % |
472 |
RapTCompo := 1000 / 100 * RapMS; |
473 |
recIn.CC.MM := recOut.CC.MM * RapTCompo; |
474 |
recIn.CC.MO := recOut.CC.MO * RapTCompo; |
475 |
recIn.CC.Lip := recOut.CC.Lip * RapTCompo; |
476 |
recIn.CC.MAT := recOut.CC.MAT * RapTCompo; |
477 |
recIn.CC.Amidon := recOut.CC.Amidon * RapTCompo; |
478 |
recIn.CC.Sucres := recOut.CC.Sucres * RapTCompo; |
479 |
if ConfDig = 0 |
480 |
then // CUD |
481 |
RapDCompo := 1
|
482 |
else // Teneur digestible |
483 |
if ConfdCompo = 0 |
484 |
then // g/kg |
485 |
RapDCompo := 100 * RapMS
|
486 |
else // % |
487 |
RapDCompo := 1000 * RapMS;
|
488 |
if ConfDig = 0 |
489 |
then // CUD |
490 |
begin
|
491 |
recIn.CC.dMO_T := recOut.CC.dMO_T * RapDCompo; |
492 |
recIn.CC.dMO_C := recOut.CC.dMO_C * RapDCompo; |
493 |
recIn.CC.dLip_T := recOut.CC.dLip_T * RapDCompo; |
494 |
recIn.CC.dLip_C := recOut.CC.dLip_C * RapDCompo; |
495 |
recIn.CC.dMAT_T := recOut.CC.dMAT_T * RapDCompo; |
496 |
recIn.CC.dMAT_C := recOut.CC.dMAT_C * RapDCompo; |
497 |
end
|
498 |
else // Teneur digestible |
499 |
begin
|
500 |
if recIn.CC.MO = 0 |
501 |
then
|
502 |
begin
|
503 |
recIn.CC.dMO_T := 0;
|
504 |
recIn.CC.dMO_C := 0;
|
505 |
end
|
506 |
else
|
507 |
begin
|
508 |
recIn.CC.dMO_T := recOut.CC.dMO_T / recIn.CC.MO * RapDCompo; |
509 |
recIn.CC.dMO_C := recOut.CC.dMO_C / recIn.CC.MO * RapDCompo; |
510 |
end;
|
511 |
if recIn.CC.Lip = 0 |
512 |
then
|
513 |
begin
|
514 |
recIn.CC.dLip_T := 0;
|
515 |
recIn.CC.dLip_C := 0;
|
516 |
end
|
517 |
else
|
518 |
begin
|
519 |
recIn.CC.dLip_T := recOut.CC.dLip_T / recIn.CC.Lip * RapDCompo; |
520 |
recIn.CC.dLip_C := recOut.CC.dLip_C / recIn.CC.Lip * RapDCompo; |
521 |
end;
|
522 |
if recIn.CC.MAT = 0 |
523 |
then
|
524 |
begin
|
525 |
recIn.CC.dMAT_T := 0;
|
526 |
recIn.CC.dMAT_C := 0;
|
527 |
end
|
528 |
else
|
529 |
begin
|
530 |
recIn.CC.dMAT_T := recOut.CC.dMAT_T / recIn.CC.MAT * RapDCompo; |
531 |
recIn.CC.dMAT_C := recOut.CC.dMAT_C / recIn.CC.MAT * RapDCompo; |
532 |
end;
|
533 |
end;
|
534 |
recIn.CC.EB := recOut.CC.EB * RapMS; |
535 |
recIn.CC.ED_T := recOut.CC.ED_T * RapMS; |
536 |
recIn.CC.ED_C := recOut.CC.ED_C * RapMS; |
537 |
recIn.CC.EM_T := recOut.CC.EM_T * RapMS; |
538 |
recIn.CC.EM_C := recOut.CC.EM_C * RapMS; |
539 |
recIn.CC.EN_T := recOut.CC.EN_T * RapMS; |
540 |
recIn.CC.EN_C := recOut.CC.EN_C * RapMS; |
541 |
if ConfTMacro = 0 |
542 |
then // g/kg |
543 |
RapTMacro := RapMS |
544 |
else // % |
545 |
RapTMacro := 1000 / 100 * RapMS; |
546 |
recIn.CC.Ca := recOut.CC.Ca * RapTMacro; |
547 |
recIn.CC.P := recOut.CC.P * RapTMacro; |
548 |
recIn.CC.Na := recOut.CC.Na * RapTMacro; |
549 |
recIn.CC.K := recOut.CC.K * RapTMacro; |
550 |
recIn.CC.Mg := recOut.CC.Mg * RapTMacro; |
551 |
recIn.CC.Cl := recOut.CC.Cl * RapTMacro; |
552 |
recIn.CC.S := recOut.CC.S * RapTMacro; |
553 |
if ConfTOligo = 0 |
554 |
then // mg/kg |
555 |
RapTOligo := RapMS |
556 |
else // % |
557 |
RapTOligo := 1000000 / 100 * RapMS; |
558 |
recIn.CC.Cu := recOut.CC.Cu * RapTOligo; |
559 |
recIn.CC.Zn := recOut.CC.Zn * RapTOligo; |
560 |
recIn.CC.Mn := recOut.CC.Mn * RapTOligo; |
561 |
recIn.CC.Fe := recOut.CC.Fe * RapTOligo; |
562 |
recIn.CC.Se := recOut.CC.Se * RapTOligo; |
563 |
recIn.CC.Co := recOut.CC.Co * RapTOligo; |
564 |
recIn.CC.Mb := recOut.CC.Mb * RapTOligo; |
565 |
recIn.CC.I := recOut.CC.I * RapTOligo; |
566 |
recIn.CC.PdigG := recOut.CC.PdigG * RapMS; |
567 |
recIn.CC.PdigF := recOut.CC.PdigF * RapMS; |
568 |
recIn.CC.Phytase := recOut.CC.Phytase; |
569 |
recIn.CC.ActPhytE := recOut.CC.ActPhytE * RapMS; |
570 |
recIn.CC.ActPhytM := recOut.CC.ActPhytM * RapMS; |
571 |
recIn.CC.AGsLip := recOut.CC.AGsLip; |
572 |
case ConfTAG of |
573 |
0 : // g/kg |
574 |
if (recIn.CC.AGsLip = 0) or (recIn.CC.Lip = 0) |
575 |
then
|
576 |
RapTAG := 0
|
577 |
else
|
578 |
RapTAG := 100 / 1000 / recIn.CC.AGsLip * 100 / recIn.CC.Lip * 1000 * RapMS; |
579 |
1 : // % |
580 |
if (recIn.CC.AGsLip = 0) or (recIn.CC.Lip = 0) |
581 |
then
|
582 |
RapTAG := 0
|
583 |
else
|
584 |
RapTAG := 1 / recIn.CC.AGsLip * 100 / recIn.CC.Lip * 1000 * RapMS; |
585 |
else // % acides gras |
586 |
RapTAG := 1;
|
587 |
end;
|
588 |
recIn.CC.C6C8C10 := recOut.CC.C6C8C10 * RapTAG; |
589 |
recIn.CC.C12_0 := recOut.CC.C12_0 * RapTAG; |
590 |
recIn.CC.C14_0 := recOut.CC.C14_0 * RapTAG; |
591 |
recIn.CC.C16_0 := recOut.CC.C16_0 * RapTAG; |
592 |
recIn.CC.C16_1 := recOut.CC.C16_1 * RapTAG; |
593 |
recIn.CC.C18_0 := recOut.CC.C18_0 * RapTAG; |
594 |
recIn.CC.C18_1 := recOut.CC.C18_1 * RapTAG; |
595 |
recIn.CC.C18_2 := recOut.CC.C18_2 * RapTAG; |
596 |
recIn.CC.C18_3 := recOut.CC.C18_3 * RapTAG; |
597 |
recIn.CC.C18_4 := recOut.CC.C18_4 * RapTAG; |
598 |
recIn.CC.C20_0 := recOut.CC.C20_0 * RapTAG; |
599 |
recIn.CC.C20_1 := recOut.CC.C20_1 * RapTAG; |
600 |
recIn.CC.C20_4 := recOut.CC.C20_4 * RapTAG; |
601 |
recIn.CC.C20_5 := recOut.CC.C20_5 * RapTAG; |
602 |
recIn.CC.C22_0 := recOut.CC.C22_0 * RapTAG; |
603 |
recIn.CC.C22_1 := recOut.CC.C22_1 * RapTAG; |
604 |
recIn.CC.C22_5 := recOut.CC.C22_5 * RapTAG; |
605 |
recIn.CC.C22_6 := recOut.CC.C22_6 * RapTAG; |
606 |
recIn.CC.C24_0 := recOut.CC.C24_0 * RapTAG; |
607 |
if ConfTFibres = 0 |
608 |
then // g/kg |
609 |
RapTFibres := RapMS |
610 |
else // % |
611 |
RapTFibres := 1000 / 100 * RapMS; |
612 |
recIn.CC.CB := recOut.CC.CB * RapTFibres; |
613 |
if ConfDig = 0 |
614 |
then // CUD |
615 |
begin
|
616 |
recIn.CC.dCB_T := recOut.CC.dCB_T * RapDCompo; |
617 |
recIn.CC.dCB_C := recOut.CC.dCB_C * RapDCompo; |
618 |
end
|
619 |
else // Teneur digestible |
620 |
if recIn.CC.CB = 0 |
621 |
then
|
622 |
begin
|
623 |
recIn.CC.dCB_T := 0;
|
624 |
recIn.CC.dCB_C := 0;
|
625 |
end
|
626 |
else
|
627 |
begin
|
628 |
recIn.CC.dCB_T := recOut.CC.dCB_T / recIn.CC.CB * RapDCompo; |
629 |
recIn.CC.dCB_C := recOut.CC.dCB_C / recIn.CC.CB * RapDCompo; |
630 |
end;
|
631 |
recIn.CC.Residu := recOut.CC.Residu * RapTCompo; |
632 |
if ConfDig = 0 |
633 |
then // CUD |
634 |
begin
|
635 |
recIn.CC.dResidu_T := recOut.CC.dResidu_T * RapDCompo; |
636 |
recIn.CC.dResidu_C := recOut.CC.dResidu_C * RapDCompo; |
637 |
end
|
638 |
else // Teneur digestible |
639 |
if recIn.CC.Residu = 0 |
640 |
then
|
641 |
begin
|
642 |
recIn.CC.dResidu_T := 0;
|
643 |
recIn.CC.dResidu_C := 0;
|
644 |
end
|
645 |
else
|
646 |
begin
|
647 |
recIn.CC.dResidu_T := recOut.CC.dResidu_T / recIn.CC.Residu * RapDCompo; |
648 |
recIn.CC.dResidu_C := recOut.CC.dResidu_C / recIn.CC.Residu * RapDCompo; |
649 |
end;
|
650 |
recIn.CC.NDF := recOut.CC.NDF * RapTFibres; |
651 |
recIn.CC.ADF := recOut.CC.ADF * RapTFibres; |
652 |
recIn.CC.ADL := recOut.CC.ADL * RapTFibres; |
653 |
recIn.CC.Parois := recOut.CC.Parois * RapTFibres; |
654 |
case ConfTAA of |
655 |
1 : // % |
656 |
RapTAA := 1000 / 100 * RapMS; |
657 |
2 : // % MAT |
658 |
RapTAA := recIn.CC.MAT / 100;
|
659 |
else // g/kg |
660 |
RapTAA := RapMS; |
661 |
end;
|
662 |
recIn.AAtotal[0] := recIn.CC.MAT;
|
663 |
for i := 1 to 12 do |
664 |
recIn.AAtotal[i] := recOut.AAtotal[i] * RapTAA; |
665 |
if ConfDig = 0 |
666 |
then // CUD |
667 |
RapDAA := 1
|
668 |
else // Teneur digestible |
669 |
if ConfdAA = 0 |
670 |
then // g/kg |
671 |
RapDAA := 100 * RapMS
|
672 |
else // % |
673 |
RapDAA := 1000 * RapMS;
|
674 |
for i := 0 to 12 do |
675 |
if ConfDig = 0 |
676 |
then // CUD |
677 |
recIn.CUDAA[i] := recOut.CUDAA[i] * RapDAA |
678 |
else // Teneur digestible |
679 |
if recIn.AAtotal[i] = 0 |
680 |
then
|
681 |
recIn.CUDAA[i] := 0
|
682 |
else
|
683 |
recIn.CUDAA[i] := recOut.CUDAA[i] / recIn.AAtotal[i] * RapDAA; |
684 |
end;
|
685 |
|
686 |
procedure TFImpExp.PutCSV(recIn: PRecCSV);
|
687 |
var
|
688 |
i: Integer; |
689 |
recOut: PRecCSV; |
690 |
begin
|
691 |
New(recOut); |
692 |
FormatInToOut(recIn, recOut); |
693 |
Append(f); |
694 |
with recOut^ do |
695 |
begin
|
696 |
Write(f, AnsiQuotedStr(Nom, '"')); |
697 |
Write(f, Separator, AnsiQuotedStr(Memo, '"')); |
698 |
Write(f, Separator, Format('%d', [Typ])); |
699 |
// Composition ?l?mentaire
|
700 |
if ConfTCompo = 0 |
701 |
then // g/kg |
702 |
begin
|
703 |
Write(f, Separator, Format('%1.1f', [CC.MS])); |
704 |
Write(f, Separator, Format('%1.1f', [CC.MM])); |
705 |
Write(f, Separator, Format('%1.1f', [CC.MO])); |
706 |
Write(f, Separator, Format('%1.1f', [CC.Lip])); |
707 |
Write(f, Separator, Format('%1.1f', [CC.MAT])); |
708 |
Write(f, Separator, Format('%1.1f', [CC.Amidon])); |
709 |
Write(f, Separator, Format('%1.1f', [CC.Sucres])); |
710 |
end
|
711 |
else // % |
712 |
begin
|
713 |
Write(f, Separator, Format('%1.2f', [CC.MS])); |
714 |
Write(f, Separator, Format('%1.2f', [CC.MM])); |
715 |
Write(f, Separator, Format('%1.2f', [CC.MO])); |
716 |
Write(f, Separator, Format('%1.2f', [CC.Lip])); |
717 |
Write(f, Separator, Format('%1.2f', [CC.MAT])); |
718 |
Write(f, Separator, Format('%1.2f', [CC.Amidon])); |
719 |
Write(f, Separator, Format('%1.2f', [CC.Sucres])); |
720 |
end;
|
721 |
if (ConfDig = 0) |
722 |
then // CUD |
723 |
begin
|
724 |
Write(f, Separator, Format('%1.1f', [CC.dMO_T])); |
725 |
Write(f, Separator, Format('%1.1f', [CC.dMO_C])); |
726 |
Write(f, Separator, Format('%1.1f', [CC.dLip_T])); |
727 |
Write(f, Separator, Format('%1.1f', [CC.dLip_C])); |
728 |
Write(f, Separator, Format('%1.1f', [CC.dMAT_T])); |
729 |
Write(f, Separator, Format('%1.1f', [CC.dMAT_C])); |
730 |
end
|
731 |
else // Teneur digestible |
732 |
if ConfdCompo = 0 |
733 |
then // g/kg |
734 |
begin
|
735 |
Write(f, Separator, Format('%1.1f', [CC.dMO_T])); |
736 |
Write(f, Separator, Format('%1.1f', [CC.dMO_C])); |
737 |
Write(f, Separator, Format('%1.1f', [CC.dLip_T])); |
738 |
Write(f, Separator, Format('%1.1f', [CC.dLip_C])); |
739 |
Write(f, Separator, Format('%1.1f', [CC.dMAT_T])); |
740 |
Write(f, Separator, Format('%1.1f', [CC.dMAT_C])); |
741 |
end
|
742 |
else // % |
743 |
begin
|
744 |
Write(f, Separator, Format('%1.2f', [CC.dMO_T])); |
745 |
Write(f, Separator, Format('%1.2f', [CC.dMO_C])); |
746 |
Write(f, Separator, Format('%1.2f', [CC.dLip_T])); |
747 |
Write(f, Separator, Format('%1.2f', [CC.dLip_C])); |
748 |
Write(f, Separator, Format('%1.2f', [CC.dMAT_T])); |
749 |
Write(f, Separator, Format('%1.2f', [CC.dMAT_C])); |
750 |
end;
|
751 |
Write(f, Separator, Format('%1.2f', [CC.EB])); |
752 |
Write(f, Separator, Format('%1.2f', [CC.ED_T])); |
753 |
Write(f, Separator, Format('%1.2f', [CC.ED_C])); |
754 |
Write(f, Separator, Format('%1.2f', [CC.EM_T])); |
755 |
Write(f, Separator, Format('%1.2f', [CC.EM_C])); |
756 |
Write(f, Separator, Format('%1.2f', [CC.EN_T])); |
757 |
Write(f, Separator, Format('%1.2f', [CC.EN_C])); |
758 |
// Min?raux
|
759 |
if ConfTMacro = 0 |
760 |
then // g/kg |
761 |
begin
|
762 |
Write(f, Separator, Format('%1.2f', [CC.Ca])); |
763 |
Write(f, Separator, Format('%1.2f', [CC.P])); |
764 |
Write(f, Separator, Format('%1.2f', [CC.Na])); |
765 |
Write(f, Separator, Format('%1.2f', [CC.K])); |
766 |
Write(f, Separator, Format('%1.2f', [CC.Mg])); |
767 |
Write(f, Separator, Format('%1.2f', [CC.Cl])); |
768 |
Write(f, Separator, Format('%1.2f', [CC.S])); |
769 |
end
|
770 |
else // % |
771 |
begin
|
772 |
Write(f, Separator, Format('%1.3f', [CC.Ca])); |
773 |
Write(f, Separator, Format('%1.3f', [CC.P])); |
774 |
Write(f, Separator, Format('%1.3f', [CC.Na])); |
775 |
Write(f, Separator, Format('%1.3f', [CC.K])); |
776 |
Write(f, Separator, Format('%1.3f', [CC.Mg])); |
777 |
Write(f, Separator, Format('%1.3f', [CC.Cl])); |
778 |
Write(f, Separator, Format('%1.3f', [CC.S])); |
779 |
end;
|
780 |
if ConfTOligo = 0 |
781 |
then // mg/kg |
782 |
begin
|
783 |
Write(f, Separator, Format('%1.2f', [CC.Cu])); |
784 |
Write(f, Separator, Format('%1.2f', [CC.Zn])); |
785 |
Write(f, Separator, Format('%1.2f', [CC.Mn])); |
786 |
Write(f, Separator, Format('%1.2f', [CC.Fe])); |
787 |
Write(f, Separator, Format('%1.2f', [CC.Se])); |
788 |
Write(f, Separator, Format('%1.2f', [CC.Co])); |
789 |
Write(f, Separator, Format('%1.2f', [CC.Mb])); |
790 |
Write(f, Separator, Format('%1.2f', [CC.I])); |
791 |
end
|
792 |
else // % |
793 |
begin
|
794 |
Write(f, Separator, Format('%1.6f', [CC.Cu])); |
795 |
Write(f, Separator, Format('%1.6f', [CC.Zn])); |
796 |
Write(f, Separator, Format('%1.6f', [CC.Mn])); |
797 |
Write(f, Separator, Format('%1.6f', [CC.Fe])); |
798 |
Write(f, Separator, Format('%1.6f', [CC.Se])); |
799 |
Write(f, Separator, Format('%1.6f', [CC.Co])); |
800 |
Write(f, Separator, Format('%1.6f', [CC.Mb])); |
801 |
Write(f, Separator, Format('%1.6f', [CC.I])); |
802 |
end;
|
803 |
Write(f, Separator, Format('%1.2f', [CC.PdigG])); |
804 |
Write(f, Separator, Format('%1.2f', [CC.PdigF])); |
805 |
Write(f, Separator, Format('%1.1f', [CC.Phytase])); |
806 |
Write(f, Separator, Format('%1.0f', [CC.ActPhytE])); |
807 |
Write(f, Separator, Format('%1.0f', [CC.ActPhytM])); |
808 |
// Acides gras
|
809 |
case ConfTAG of |
810 |
0 : // g/kg |
811 |
begin
|
812 |
Write(f, Separator, Format('%1.2f', [CC.C6C8C10])); |
813 |
Write(f, Separator, Format('%1.2f', [CC.C12_0])); |
814 |
Write(f, Separator, Format('%1.2f', [CC.C14_0])); |
815 |
Write(f, Separator, Format('%1.2f', [CC.C16_0])); |
816 |
Write(f, Separator, Format('%1.2f', [CC.C16_1])); |
817 |
Write(f, Separator, Format('%1.2f', [CC.C18_0])); |
818 |
Write(f, Separator, Format('%1.2f', [CC.C18_1])); |
819 |
Write(f, Separator, Format('%1.2f', [CC.C18_2])); |
820 |
Write(f, Separator, Format('%1.2f', [CC.C18_3])); |
821 |
Write(f, Separator, Format('%1.2f', [CC.C18_4])); |
822 |
Write(f, Separator, Format('%1.2f', [CC.C20_0])); |
823 |
Write(f, Separator, Format('%1.2f', [CC.C20_1])); |
824 |
Write(f, Separator, Format('%1.2f', [CC.C20_4])); |
825 |
Write(f, Separator, Format('%1.2f', [CC.C20_5])); |
826 |
Write(f, Separator, Format('%1.2f', [CC.C22_0])); |
827 |
Write(f, Separator, Format('%1.2f', [CC.C22_1])); |
828 |
Write(f, Separator, Format('%1.2f', [CC.C22_5])); |
829 |
Write(f, Separator, Format('%1.2f', [CC.C22_6])); |
830 |
Write(f, Separator, Format('%1.2f', [CC.C24_0])); |
831 |
end;
|
832 |
1 : // % |
833 |
begin
|
834 |
Write(f, Separator, Format('%1.3f', [CC.C6C8C10])); |
835 |
Write(f, Separator, Format('%1.3f', [CC.C12_0])); |
836 |
Write(f, Separator, Format('%1.3f', [CC.C14_0])); |
837 |
Write(f, Separator, Format('%1.3f', [CC.C16_0])); |
838 |
Write(f, Separator, Format('%1.3f', [CC.C16_1])); |
839 |
Write(f, Separator, Format('%1.3f', [CC.C18_0])); |
840 |
Write(f, Separator, Format('%1.3f', [CC.C18_1])); |
841 |
Write(f, Separator, Format('%1.3f', [CC.C18_2])); |
842 |
Write(f, Separator, Format('%1.3f', [CC.C18_3])); |
843 |
Write(f, Separator, Format('%1.3f', [CC.C18_4])); |
844 |
Write(f, Separator, Format('%1.3f', [CC.C20_0])); |
845 |
Write(f, Separator, Format('%1.3f', [CC.C20_1])); |
846 |
Write(f, Separator, Format('%1.3f', [CC.C20_4])); |
847 |
Write(f, Separator, Format('%1.3f', [CC.C20_5])); |
848 |
Write(f, Separator, Format('%1.3f', [CC.C22_0])); |
849 |
Write(f, Separator, Format('%1.3f', [CC.C22_1])); |
850 |
Write(f, Separator, Format('%1.3f', [CC.C22_5])); |
851 |
Write(f, Separator, Format('%1.3f', [CC.C22_6])); |
852 |
Write(f, Separator, Format('%1.3f', [CC.C24_0])); |
853 |
end
|
854 |
else // % acides gras |
855 |
begin
|
856 |
Write(f, Separator, Format('%1.1f', [CC.C6C8C10])); |
857 |
Write(f, Separator, Format('%1.1f', [CC.C12_0])); |
858 |
Write(f, Separator, Format('%1.1f', [CC.C14_0])); |
859 |
Write(f, Separator, Format('%1.1f', [CC.C16_0])); |
860 |
Write(f, Separator, Format('%1.1f', [CC.C16_1])); |
861 |
Write(f, Separator, Format('%1.1f', [CC.C18_0])); |
862 |
Write(f, Separator, Format('%1.1f', [CC.C18_1])); |
863 |
Write(f, Separator, Format('%1.1f', [CC.C18_2])); |
864 |
Write(f, Separator, Format('%1.1f', [CC.C18_3])); |
865 |
Write(f, Separator, Format('%1.1f', [CC.C18_4])); |
866 |
Write(f, Separator, Format('%1.1f', [CC.C20_0])); |
867 |
Write(f, Separator, Format('%1.1f', [CC.C20_1])); |
868 |
Write(f, Separator, Format('%1.1f', [CC.C20_4])); |
869 |
Write(f, Separator, Format('%1.1f', [CC.C20_5])); |
870 |
Write(f, Separator, Format('%1.1f', [CC.C22_0])); |
871 |
Write(f, Separator, Format('%1.1f', [CC.C22_1])); |
872 |
Write(f, Separator, Format('%1.1f', [CC.C22_5])); |
873 |
Write(f, Separator, Format('%1.1f', [CC.C22_6])); |
874 |
Write(f, Separator, Format('%1.1f', [CC.C24_0])); |
875 |
end;
|
876 |
end ;
|
877 |
Write(f, Separator, Format('%1.1f', [CC.AGsLip])) ; |
878 |
// Fibres
|
879 |
if ConfTFibres = 0 |
880 |
then // g/kg |
881 |
Write(f, Separator, Format('%1.1f', [CC.CB])) |
882 |
else // % |
883 |
Write(f, Separator, Format('%1.2f', [CC.CB])); |
884 |
if (ConfDig = 0) |
885 |
then // CUD |
886 |
begin
|
887 |
Write(f, Separator, Format('%1.1f', [CC.dCB_T])); |
888 |
Write(f, Separator, Format('%1.1f', [CC.dCB_C])); |
889 |
end
|
890 |
else // Teneur digestible |
891 |
if ConfdCompo = 0 |
892 |
then // g/kg |
893 |
begin
|
894 |
Write(f, Separator, Format('%1.1f', [CC.dCB_T])); |
895 |
Write(f, Separator, Format('%1.1f', [CC.dCB_C])); |
896 |
end
|
897 |
else // % |
898 |
begin
|
899 |
Write(f, Separator, Format('%1.2f', [CC.dCB_T])); |
900 |
Write(f, Separator, Format('%1.2f', [CC.dCB_C])); |
901 |
end;
|
902 |
if ConfTCompo = 0 |
903 |
then // g/kg |
904 |
Write(f, Separator, Format('%1.1f', [CC.Residu])) |
905 |
else // % |
906 |
Write(f, Separator, Format('%1.2f', [CC.Residu])); |
907 |
if (ConfDig = 0) |
908 |
then // CUD |
909 |
begin
|
910 |
Write(f, Separator, Format('%1.1f', [CC.dResidu_T])); |
911 |
Write(f, Separator, Format('%1.1f', [CC.dResidu_C])); |
912 |
end
|
913 |
else // Teneur digestible |
914 |
if ConfdCompo = 0 |
915 |
then // g/kg |
916 |
begin
|
917 |
Write(f, Separator, Format('%1.1f', [CC.dResidu_T])); |
918 |
Write(f, Separator, Format('%1.1f', [CC.dResidu_C])); |
919 |
end
|
920 |
else // % |
921 |
begin
|
922 |
Write(f, Separator, Format('%1.2f', [CC.dResidu_T])); |
923 |
Write(f, Separator, Format('%1.2f', [CC.dResidu_C])); |
924 |
end;
|
925 |
if ConfTFibres = 0 |
926 |
then // g/kg |
927 |
begin
|
928 |
Write(f, Separator, Format('%1.1f', [CC.NDF])); |
929 |
Write(f, Separator, Format('%1.1f', [CC.ADF])); |
930 |
Write(f, Separator, Format('%1.1f', [CC.ADL])); |
931 |
Write(f, Separator, Format('%1.1f', [CC.Parois])); |
932 |
end
|
933 |
else // % |
934 |
begin
|
935 |
Write(f, Separator, Format('%1.2f', [CC.NDF])); |
936 |
Write(f, Separator, Format('%1.2f', [CC.ADF])); |
937 |
Write(f, Separator, Format('%1.2f', [CC.ADL])); |
938 |
Write(f, Separator, Format('%1.2f', [CC.Parois])); |
939 |
end;
|
940 |
// Acides amin?s
|
941 |
if ConfTAA = 1 |
942 |
then // % |
943 |
for i := 1 to 12 do |
944 |
Write(f, Separator, Format('%1.3f', [AAtotal[i]])) |
945 |
else // %MAT ou g/kg |
946 |
for i := 1 to 12 do |
947 |
Write(f, Separator, Format('%1.2f', [AAtotal[i]])); |
948 |
if ConfDig = 0 |
949 |
then // CUD |
950 |
for i := 0 to 12 do |
951 |
Write(f, Separator, Format('%1.1f', [CUDAA[i]])) |
952 |
else // Teneur digestible |
953 |
if ConfdAA = 0 |
954 |
then // g/kg |
955 |
for i := 0 to 12 do |
956 |
Write(f, Separator, Format('%1.2f', [CUDAA[i]])) |
957 |
else // % |
958 |
for i := 0 to 12 do |
959 |
Write(f, Separator, Format('%1.3f', [CUDAA[i]])); |
960 |
WriteLn(f); |
961 |
end;
|
962 |
CloseFile(f); |
963 |
Dispose(recOut); |
964 |
end;
|
965 |
|
966 |
procedure TFImpExp.DisplayConfig;
|
967 |
begin
|
968 |
LRap.Caption := FConfig.CBRap.Items[ConfRap]; |
969 |
LDig.Caption := FConfig.CBDig.Items[ConfDig]; |
970 |
LTCompo.Caption := FConfig.CBTCompo.Items[ConfTCompo]; |
971 |
LdCompo.Caption := FConfig.CBdCompo.Items[ConfDCompo]; |
972 |
LTAA.Caption := FConfig.CBTAA.Items[ConfTAA]; |
973 |
LdAA.Caption := FConfig.CBdAA.Items[ConfDAA]; |
974 |
LTAG.Caption := FConfig.CBTAG.Items[ConfTAG]; |
975 |
LTMacro.Caption := FConfig.CBTMacro.Items[ConfTMacro]; |
976 |
LTOligo.Caption := FConfig.CBTOligo.Items[ConfTOligo]; |
977 |
LTFibres.Caption := FConfig.CBTFibres.Items[ConfTFibres]; |
978 |
end;
|
979 |
|
980 |
procedure TFImpExp.CBTypeMatChange (Sender : TObject) ;
|
981 |
begin
|
982 |
StringsMatiere (LBMatiere.Items, CBTypeMat.ItemIndex, FALSE, FALSE) ; |
983 |
end ;
|
984 |
|
985 |
procedure TFImpExp.CBTypeAliChange (Sender : TObject) ;
|
986 |
begin
|
987 |
StringsAliment (LBAliment.Items, CBTypeAli.ItemIndex, FALSE) ; |
988 |
end ;
|
989 |
|
990 |
procedure TFImpExp.SBFichierClick (Sender : TObject) ;
|
991 |
var
|
992 |
i, lig, col: Integer; |
993 |
recOut, recIn: PRecCSV; |
994 |
Titre: String;
|
995 |
ok: Boolean; |
996 |
s: string;
|
997 |
v: Double; |
998 |
sep: Char; |
999 |
begin
|
1000 |
SDFichier.InitialDir := GetCurrentDir; |
1001 |
if not SDFichier.Execute |
1002 |
then // Annulation |
1003 |
Exit; |
1004 |
// effacement de la liste avant chargement
|
1005 |
LBFichier.Clear; |
1006 |
if ListCSV.Count > 0 |
1007 |
then
|
1008 |
for i := 0 to ListCSV.Count - 1 do |
1009 |
begin
|
1010 |
recIn := ListCSV[i]; |
1011 |
Dispose(recIn); |
1012 |
end;
|
1013 |
ListCSV.Clear; |
1014 |
EFichier.Text := SDFichier.FileName; |
1015 |
AssignFile(F, SDFichier.FileName); |
1016 |
LBFichier.Clear; |
1017 |
// Composition du titre (avec remplacement du ';' par ListSeparator)
|
1018 |
Titre := StringReplace(StrTitreCSV1, ';', Separator, [rfReplaceAll])
|
1019 |
+ StringReplace(StrTitreCSV2, ';', Separator, [rfReplaceAll])
|
1020 |
+ StringReplace(StrTitreCSV3, ';', Separator, [rfReplaceAll])
|
1021 |
+ StringReplace(StrTitreCSV4, ';', Separator, [rfReplaceAll])
|
1022 |
+ StringReplace(StrTitreCSV5, ';', Separator, [rfReplaceAll])
|
1023 |
+ StringReplace(StrTitreCSV6, ';', Separator, [rfReplaceAll])
|
1024 |
+ StringReplace(StrTitreCSV7, ';', Separator, [rfReplaceAll]);
|
1025 |
if not FileExists(SDFichier.FileName) |
1026 |
then // Le fichier n'existe pas : cr?ation avec titre |
1027 |
begin
|
1028 |
Rewrite(F); |
1029 |
Writeln(F, Titre); |
1030 |
CloseFile(F); |
1031 |
Exit; |
1032 |
end;
|
1033 |
Reset(F); |
1034 |
if Eof(F)
|
1035 |
then // Le fichier est vide : insertion du titre |
1036 |
begin
|
1037 |
Writeln(F, Titre); |
1038 |
CloseFile(F); |
1039 |
Exit; |
1040 |
end;
|
1041 |
Readln(F, s); // Lecture de la ligne de titre
|
1042 |
if Eof(F)
|
1043 |
then // Il n'y a pas d'enregistrement |
1044 |
begin
|
1045 |
CloseFile(F); |
1046 |
Exit; |
1047 |
end;
|
1048 |
lig := 1;
|
1049 |
col := 1;
|
1050 |
New(recOut); |
1051 |
with recOut^ do |
1052 |
repeat
|
1053 |
ok := TRUE; |
1054 |
case col of |
1055 |
1: // Nom |
1056 |
begin
|
1057 |
ok := GetString(s, sep); |
1058 |
if ok then Nom := Trim(s); |
1059 |
end;
|
1060 |
2: // Commentaire |
1061 |
begin
|
1062 |
ok := GetString(s, sep); |
1063 |
if ok then Memo := s; |
1064 |
end;
|
1065 |
3: // Type |
1066 |
ok := GetInteger(Typ, sep); |
1067 |
4..98: // Valeurs |
1068 |
begin
|
1069 |
ok := GetDouble(v, sep); |
1070 |
if ok
|
1071 |
then
|
1072 |
case col of |
1073 |
4: CC.MS := v;
|
1074 |
5: CC.MM := v;
|
1075 |
6: CC.MO := v;
|
1076 |
7: CC.Lip := v;
|
1077 |
8: CC.MAT := v;
|
1078 |
9: CC.Amidon := v;
|
1079 |
10: CC.Sucres := v;
|
1080 |
11: CC.dMO_T := v;
|
1081 |
12: CC.dMO_C := v;
|
1082 |
13: CC.dLip_T := v;
|
1083 |
14: CC.dLip_C := v;
|
1084 |
15: CC.dMAT_T := v;
|
1085 |
16: CC.dMAT_C := v;
|
1086 |
17: CC.EB := v;
|
1087 |
18: CC.ED_T := v;
|
1088 |
19: CC.ED_C := v;
|
1089 |
20: CC.EM_T := v;
|
1090 |
21: CC.EM_C := v;
|
1091 |
22: CC.EN_T := v;
|
1092 |
23: CC.EN_C := v;
|
1093 |
24: CC.Ca := v;
|
1094 |
25: CC.P := v;
|
1095 |
26: CC.Na := v;
|
1096 |
27: CC.K := v;
|
1097 |
28: CC.Mg := v;
|
1098 |
29: CC.Cl := v;
|
1099 |
30: CC.S := v;
|
1100 |
31: CC.Cu := v;
|
1101 |
32: CC.Zn := v;
|
1102 |
33: CC.Mn := v;
|
1103 |
34: CC.Fe := v;
|
1104 |
35: CC.Se := v;
|
1105 |
36: CC.Co := v;
|
1106 |
37: CC.Mb := v;
|
1107 |
38: CC.I := v;
|
1108 |
39: CC.PdigG := v;
|
1109 |
40: CC.PdigF := v;
|
1110 |
41: CC.Phytase := v;
|
1111 |
42: CC.ActPhytE := v;
|
1112 |
43: CC.ActPhytM := v;
|
1113 |
44: CC.C6C8C10 := v;
|
1114 |
45: CC.C12_0 := v;
|
1115 |
46: CC.C14_0 := v;
|
1116 |
47: CC.C16_0 := v;
|
1117 |
48: CC.C16_1 := v;
|
1118 |
49: CC.C18_0 := v;
|
1119 |
50: CC.C18_1 := v;
|
1120 |
51: CC.C18_2 := v;
|
1121 |
52: CC.C18_3 := v;
|
1122 |
53: CC.C18_4 := v;
|
1123 |
54: CC.C20_0 := v;
|
1124 |
55: CC.C20_1 := v;
|
1125 |
56: CC.C20_4 := v;
|
1126 |
57: CC.C20_5 := v;
|
1127 |
58: CC.C22_0 := v;
|
1128 |
59: CC.C22_1 := v;
|
1129 |
60: CC.C22_5 := v;
|
1130 |
61: CC.C22_6 := v;
|
1131 |
62: CC.C24_0 := v;
|
1132 |
63: CC.AGsLip := v;
|
1133 |
64: CC.CB := v;
|
1134 |
65: CC.dCB_T := v;
|
1135 |
66: CC.dCB_C := v;
|
1136 |
67: CC.Residu := v;
|
1137 |
68: CC.dResidu_T := v;
|
1138 |
69: CC.dResidu_C := v;
|
1139 |
70: CC.NDF := v;
|
1140 |
71: CC.ADF := v;
|
1141 |
72: CC.ADL := v;
|
1142 |
73: CC.Parois := v;
|
1143 |
74..85: AAtotal[col - 73] := v; |
1144 |
86..98: CUDAA[col - 86] := v; |
1145 |
end;
|
1146 |
end;
|
1147 |
end ;
|
1148 |
if not ok then Break; |
1149 |
if (col = 98) or ((col = 1) and (Length(Nom) = 0)) |
1150 |
then // Dernier champs ou ligne vide |
1151 |
ok := (sep = Chr(13)) or (sep = Chr(26)) |
1152 |
else
|
1153 |
ok := (sep = Separator); |
1154 |
if not ok then Break; |
1155 |
if sep = Chr(13) then Read(F, sep); // Chr(10) |
1156 |
if col = 98 |
1157 |
then // Passage ? la ligne suivante |
1158 |
begin
|
1159 |
New(recIn); |
1160 |
FormatOutToIn(recOut, recIn); |
1161 |
recIn.AAtotal[0] := recIn.CC.MAT;
|
1162 |
ListCSV.Add(recIn); |
1163 |
LBFichier.Items.Add(Nom); |
1164 |
Dispose(recOut); |
1165 |
Inc(lig); |
1166 |
col := 1;
|
1167 |
New(recOut); |
1168 |
end
|
1169 |
else
|
1170 |
if (col > 1) or (Length(Nom) > 0) |
1171 |
then // Passage au champs suivant |
1172 |
Inc(col); |
1173 |
until sep = Chr(26); // Eof(f) |
1174 |
Dispose(recOut); |
1175 |
CloseFile(F); |
1176 |
if not ok |
1177 |
then // erreur de lecture |
1178 |
begin
|
1179 |
MessageDlg(Format(MsgCSVError, [lig, col]), mtError, [mbOk], 0);
|
1180 |
// effacement de la liste suite ? une erreur de lecture
|
1181 |
LBFichier.Clear; |
1182 |
if ListCSV.Count > 0 |
1183 |
then
|
1184 |
for i := 0 to ListCSV.Count - 1 do |
1185 |
begin
|
1186 |
recIn := ListCSV[i]; |
1187 |
Dispose(recIn); |
1188 |
end;
|
1189 |
ListCSV.Clear; |
1190 |
EFichier.Text := '';
|
1191 |
end;
|
1192 |
end;
|
1193 |
|
1194 |
procedure TFImpExp.SBExpMatClick (Sender : TObject) ;
|
1195 |
var
|
1196 |
i, j : integer ; |
1197 |
rec : PRecCSV ; |
1198 |
begin
|
1199 |
if EFichier.Text = '' |
1200 |
then
|
1201 |
begin
|
1202 |
MessageDlg (MsgNoCSV, mtError, [mbOk], 0) ;
|
1203 |
Exit ; |
1204 |
end ;
|
1205 |
if LBMatiere.Count = 0 |
1206 |
then
|
1207 |
begin
|
1208 |
MessageDlg (MsgNoMat, mtError, [mbOk], 0) ;
|
1209 |
Exit ; |
1210 |
end ;
|
1211 |
if LBMatiere.SelCount = 0 |
1212 |
then
|
1213 |
begin
|
1214 |
MessageDlg (MsgNoMatSel, mtError, [mbOk], 0) ;
|
1215 |
Exit ; |
1216 |
end ;
|
1217 |
for i := 0 to LBMatiere.Count - 1 do |
1218 |
if LBMatiere.Selected[i]
|
1219 |
then
|
1220 |
begin
|
1221 |
PMatiere := ListMatiere[FindIdxMatiere (LBMatiere.Items[i])] ; |
1222 |
with PMatiere^ do |
1223 |
begin
|
1224 |
New (rec) ; |
1225 |
rec.Nom := Nom ; |
1226 |
rec.Memo := Memo ; |
1227 |
rec.Typ := Typ ; |
1228 |
rec.CC := CC ; |
1229 |
for j := 0 to 12 do |
1230 |
rec.AAtotal[j] := AAtotal[j] ; |
1231 |
for j := 0 to 12 do |
1232 |
rec.CUDAA[j] := CUDAA[j] ; |
1233 |
ListCSV.Add (rec) ; |
1234 |
PutCSV (rec) ; |
1235 |
LBFichier.Items.Add (Nom) ; |
1236 |
end ;
|
1237 |
end ;
|
1238 |
end ;
|
1239 |
|
1240 |
procedure TFImpExp.SBImpMatClick (Sender : TObject) ;
|
1241 |
var
|
1242 |
i, j, n : integer ; |
1243 |
ok : Boolean ; |
1244 |
rec : PRecCSV ; |
1245 |
begin
|
1246 |
if EFichier.Text = '' |
1247 |
then
|
1248 |
begin
|
1249 |
MessageDlg (MsgNoCSV, mtError, [mbOk], 0) ;
|
1250 |
Exit ; |
1251 |
end ;
|
1252 |
if LBFichier.Count = 0 |
1253 |
then
|
1254 |
begin
|
1255 |
MessageDlg (MsgNoImp, mtError, [mbOk], 0) ;
|
1256 |
Exit ; |
1257 |
end ;
|
1258 |
if LBFichier.SelCount = 0 |
1259 |
then
|
1260 |
begin
|
1261 |
MessageDlg (MsgNoImpSel, mtError, [mbOk], 0) ;
|
1262 |
Exit ; |
1263 |
end ;
|
1264 |
n := 0 ;
|
1265 |
for i := 0 to LBFichier.Count - 1 do |
1266 |
if LBFichier.Selected[i]
|
1267 |
then
|
1268 |
begin
|
1269 |
rec := ListCSV[i] ; |
1270 |
repeat // V?rification du nom |
1271 |
if Length (rec.Nom) > 35 |
1272 |
then // Nom trop long |
1273 |
begin
|
1274 |
ok := FALSE ; |
1275 |
MessageDlg (Format (MsgNameTooLarge, [35]), mtWarning, [mbOk], 0) ; |
1276 |
rec.Nom := Copy (rec.Nom, 1, 35) ; |
1277 |
end
|
1278 |
else
|
1279 |
begin
|
1280 |
ok := TRUE ; |
1281 |
j := 0 ;
|
1282 |
while ok and (j < ListMatiere.Count) do |
1283 |
begin
|
1284 |
PMatiere := ListMatiere[j] ; |
1285 |
if PMatiere.Nom = rec.Nom
|
1286 |
then // Nom d?j? utilis? |
1287 |
begin
|
1288 |
ok := FALSE ; |
1289 |
MessageDlg (MsgNameExists, mtWarning, [mbOk], 0) ;
|
1290 |
end
|
1291 |
else
|
1292 |
Inc (j) ; |
1293 |
end ;
|
1294 |
end ;
|
1295 |
if not ok |
1296 |
then // Saisie du nom |
1297 |
if not InputQuery (FImpExp.Caption, MsgName, rec.Nom) |
1298 |
then // Annulation |
1299 |
begin
|
1300 |
ok := TRUE ; |
1301 |
LBFichier.Selected[i] := FALSE ; |
1302 |
end ;
|
1303 |
until ok ;
|
1304 |
if LBFichier.Selected[i]
|
1305 |
then
|
1306 |
begin
|
1307 |
repeat // Recherche du premier num?ro libre |
1308 |
Inc (n) ; |
1309 |
ok := TRUE ; |
1310 |
j := 0 ;
|
1311 |
while ok and (j < ListMatiere.Count) do |
1312 |
begin
|
1313 |
PMatiere := ListMatiere[j] ; |
1314 |
if PMatiere.Num = n
|
1315 |
then
|
1316 |
ok := FALSE |
1317 |
else
|
1318 |
Inc (j) ; |
1319 |
end ;
|
1320 |
until ok ;
|
1321 |
ModifMat := TRUE ; |
1322 |
New (PMatiere) ; |
1323 |
with PMatiere^ do |
1324 |
begin
|
1325 |
Num := n ; |
1326 |
Nom := rec.Nom ; |
1327 |
Memo := rec.Memo ; |
1328 |
if rec.Typ < 10 |
1329 |
then // Mati?re premi?re |
1330 |
Typ := rec.Typ |
1331 |
else // Aliment |
1332 |
begin
|
1333 |
MessageDlg (Format (MsgAli2Mat, [Nom]), mtWarning, [mbOk], 0) ;
|
1334 |
Typ := 0 ;
|
1335 |
end ;
|
1336 |
CC := rec.CC ; |
1337 |
for j := 0 to 12 do |
1338 |
AAtotal[j] := rec.AAtotal[j] ; |
1339 |
for j := 0 to 12 do |
1340 |
CUDAA[j] := rec.CUDAA[j] ; |
1341 |
end ;
|
1342 |
ListMatiere.Add (PMatiere) ; |
1343 |
if (CBTypeMat.ItemIndex = 0) or (PMatiere.Typ = CBTypeMat.ItemIndex) |
1344 |
then
|
1345 |
LBMatiere.Items.Add (PMatiere.Nom) ; |
1346 |
end ;
|
1347 |
end ;
|
1348 |
end ;
|
1349 |
|
1350 |
procedure TFImpExp.SBExpAliClick (Sender : TObject) ;
|
1351 |
var
|
1352 |
i, j : integer ; |
1353 |
rec : PRecCSV ; |
1354 |
begin
|
1355 |
if EFichier.Text = '' |
1356 |
then
|
1357 |
begin
|
1358 |
MessageDlg (MsgNoCSV, mtError, [mbOk], 0) ;
|
1359 |
Exit ; |
1360 |
end ;
|
1361 |
if LBAliment.Count = 0 |
1362 |
then
|
1363 |
begin
|
1364 |
MessageDlg (MsgNoAli, mtError, [mbOk], 0) ;
|
1365 |
Exit ; |
1366 |
end ;
|
1367 |
if LBAliment.SelCount = 0 |
1368 |
then
|
1369 |
begin
|
1370 |
MessageDlg (MsgNoAliSel, mtError, [mbOk], 0) ;
|
1371 |
Exit ; |
1372 |
end ;
|
1373 |
for i := 0 to LBAliment.Count - 1 do |
1374 |
if LBAliment.Selected[i]
|
1375 |
then
|
1376 |
begin
|
1377 |
PAliment := ListAliment[FindIdxAliment (LBAliment.Items[i])] ; |
1378 |
with PAliment^ do |
1379 |
begin
|
1380 |
New (rec) ; |
1381 |
rec.Nom := Nom ; |
1382 |
rec.Memo := Memo ; |
1383 |
rec.Typ := Typ * (Presentation + 1) + 10 ; |
1384 |
rec.CC := CC ; |
1385 |
for j := 0 to 12 do |
1386 |
rec.AAtotal[j] := AAtotal[j] ; |
1387 |
for j := 0 to 12 do |
1388 |
rec.CUDAA[j] := CUDAA[j] ; |
1389 |
ListCSV.Add (rec) ; |
1390 |
PutCSV (rec) ; |
1391 |
LBFichier.Items.Add (Nom) ; |
1392 |
end ;
|
1393 |
end ;
|
1394 |
end ;
|
1395 |
|
1396 |
procedure TFImpExp.SBImpAliClick (Sender : TObject) ;
|
1397 |
var
|
1398 |
i, j, k, n : integer ; |
1399 |
ok : Boolean ; |
1400 |
rec : PRecCSV ; |
1401 |
begin
|
1402 |
if EFichier.Text = '' |
1403 |
then
|
1404 |
begin
|
1405 |
MessageDlg (MsgNoCSV, mtError, [mbOk], 0) ;
|
1406 |
Exit ; |
1407 |
end ;
|
1408 |
if LBFichier.Count = 0 |
1409 |
then
|
1410 |
begin
|
1411 |
MessageDlg (MsgNoImp, mtError, [mbOk], 0) ;
|
1412 |
Exit ; |
1413 |
end ;
|
1414 |
if LBFichier.SelCount = 0 |
1415 |
then
|
1416 |
begin
|
1417 |
MessageDlg (MsgNoImpSel, mtError, [mbOk], 0) ;
|
1418 |
Exit ; |
1419 |
end ;
|
1420 |
n := 0 ;
|
1421 |
for i := 0 to LBFichier.Count - 1 do |
1422 |
if LBFichier.Selected[i]
|
1423 |
then
|
1424 |
begin
|
1425 |
rec := ListCSV[i] ; |
1426 |
repeat // V?rification du nom |
1427 |
if Length (rec.Nom) > 35 |
1428 |
then // Nom trop long |
1429 |
begin
|
1430 |
ok := FALSE ; |
1431 |
MessageDlg (Format (MsgNameTooLarge, [35]), mtWarning, [mbOk], 0) ; |
1432 |
rec.Nom := Copy (rec.Nom, 1, 35) ; |
1433 |
end
|
1434 |
else
|
1435 |
begin
|
1436 |
ok := TRUE ; |
1437 |
j := 0 ;
|
1438 |
while ok and (j < ListAliment.Count) do |
1439 |
begin
|
1440 |
PAliment := ListAliment[j] ; |
1441 |
if PAliment.Nom = rec.Nom
|
1442 |
then // Nom d?j? utilis? |
1443 |
begin
|
1444 |
ok := FALSE ; |
1445 |
MessageDlg (MsgNameExists, mtWarning, [mbOk], 0) ;
|
1446 |
end
|
1447 |
else
|
1448 |
Inc (j) ; |
1449 |
end ;
|
1450 |
end ;
|
1451 |
if not ok |
1452 |
then // Saisie du nom |
1453 |
if not InputQuery (FImpExp.Caption, MsgName, rec.Nom) |
1454 |
then // Annulation |
1455 |
begin
|
1456 |
ok := TRUE ; |
1457 |
LBFichier.Selected[i] := FALSE ; |
1458 |
end ;
|
1459 |
until ok ;
|
1460 |
if LBFichier.Selected[i]
|
1461 |
then
|
1462 |
begin
|
1463 |
repeat // Recherche du premier num?ro libre |
1464 |
Inc (n) ; |
1465 |
ok := TRUE ; |
1466 |
j := 0 ;
|
1467 |
while ok and (j < ListAliment.Count) do |
1468 |
begin
|
1469 |
PAliment := ListAliment[j] ; |
1470 |
if PAliment.Num = n
|
1471 |
then
|
1472 |
ok := FALSE |
1473 |
else
|
1474 |
Inc (j) ; |
1475 |
end ;
|
1476 |
until ok ;
|
1477 |
ModifAli := TRUE ; |
1478 |
New (PAliment) ; |
1479 |
with PAliment^ do |
1480 |
begin
|
1481 |
Num := n ; |
1482 |
Nom := rec.Nom ; |
1483 |
Memo := rec.Memo ; |
1484 |
if rec.Typ < 10 |
1485 |
then // Mati?re premi?re |
1486 |
begin
|
1487 |
MessageDlg (Format (MsgMat2Ali, [Nom]), mtWarning, [mbOk], 0) ;
|
1488 |
Typ := 0 ;
|
1489 |
Presentation := 0 ;
|
1490 |
end
|
1491 |
else // Aliment |
1492 |
begin
|
1493 |
Typ := (rec.Typ - 10) mod 3 ; |
1494 |
Presentation := (rec.Typ - 10) div 3 ; |
1495 |
end ;
|
1496 |
Prix := 0 ;
|
1497 |
MP.NbMat := 0 ;
|
1498 |
for k := 0 to MAX_MP do |
1499 |
begin
|
1500 |
MP.NumMat[k] := 0 ;
|
1501 |
MP.MS[k] := 0 ;
|
1502 |
MP.Qte[k] := 0 ;
|
1503 |
end ;
|
1504 |
CC := rec.CC ; |
1505 |
for j := 0 to 12 do |
1506 |
AAtotal[j] := rec.AAtotal[j] ; |
1507 |
for j := 0 to 12 do |
1508 |
CUDAA[j] := rec.CUDAA[j] ; |
1509 |
end ;
|
1510 |
ListAliment.Add (PAliment) ; |
1511 |
if (CBTypeAli.ItemIndex = 0) or (PAliment.Typ = CBTypeAli.ItemIndex) |
1512 |
then
|
1513 |
LBAliment.Items.Add (PAliment.Nom) ; |
1514 |
end ;
|
1515 |
end ;
|
1516 |
end ;
|
1517 |
|
1518 |
end.
|