Révision 3 InraAfz/UnitMain.pas
UnitMain.pas | ||
---|---|---|
8 | 8 |
Buttons, ExtCtrls, StdCtrls, DBCtrls, JvCsvData, DBTables, xmldom, XMLIntf, |
9 | 9 |
msxmldom, XMLDoc, JvSimpleXml; |
10 | 10 |
|
11 |
const |
|
12 |
CALORIE = 4.184; // Conversion J -> cal |
|
13 |
|
|
11 | 14 |
type |
12 | 15 |
TFormMain = class(TForm) |
13 | 16 |
DataSourceInraAfz: TDataSource; |
... | ... | |
98 | 101 |
ClientDataSetInraAfzComment: TStringField; |
99 | 102 |
OpenDialogCSV: TOpenDialog; |
100 | 103 |
JvCsvDataSetInput: TJvCsvDataSet; |
104 |
ClientDataSetInraAfzNa: TFloatField; |
|
105 |
ClientDataSetInraAfzK: TFloatField; |
|
106 |
ClientDataSetInraAfzCl: TFloatField; |
|
101 | 107 |
procedure FormShow(Sender: TObject); |
102 | 108 |
procedure FormClose(Sender: TObject; var Action: TCloseAction); |
103 | 109 |
procedure SpeedButtonExitClick(Sender: TObject); |
... | ... | |
211 | 217 |
JvCsvDataSetInput.FileName := OpenDialogCSV.FileName; |
212 | 218 |
JvCsvDataSetInput.Active := True; |
213 | 219 |
JvCsvDataSetInput.First; |
214 |
JvCsvDataSetInput.Next; // Ignorer la seconde ligne de titre (unit?s de mesure) |
|
220 |
(* |
|
221 |
// Ignorer la seconde ligne de titre (unit?s de mesure) |
|
222 |
JvCsvDataSetInput.Next; |
|
223 |
*) |
|
215 | 224 |
while not JvCsvDataSetInput.Eof do |
216 | 225 |
begin |
217 | 226 |
ClientDataSetInraAfz.Append; |
218 | 227 |
for i := 0 to ClientDataSetInraAfz.Fields.Count - 1 do |
228 |
(* |
|
219 | 229 |
case i of |
220 | 230 |
0: // Id (AutoInc) |
221 | 231 |
; |
... | ... | |
251 | 261 |
72..73: // dP (%) |
252 | 262 |
ClientDataSetInraAfz.Fields[i].AsFloat := JvCsvDataSetInput.Fields[i+1].AsFloat / 100; |
253 | 263 |
end; |
264 |
*) |
|
265 |
case i of |
|
266 |
0: // Nom (ENG) |
|
267 |
if (Length(JvCsvDataSetInput.Fields[i].AsString) > 0) then |
|
268 |
ClientDataSetInraAfz.Fields[i+1].AsString := JvCsvDataSetInput.Fields[i].AsString; |
|
269 |
1: ; // Nom (FRA) ignor? |
|
270 |
2: // Origine |
|
271 |
if (Length(JvCsvDataSetInput.Fields[i].AsString) > 0) then |
|
272 |
ClientDataSetInraAfz.Fields[i+1].AsString := JvCsvDataSetInput.Fields[i].AsString; |
|
273 |
3: ; // Classe (fkLookup) |
|
274 |
4: // ClassId |
|
275 |
ClientDataSetInraAfz.Fields[i].AsInteger := JvCsvDataSetInput.Fields[i].AsInteger; |
|
276 |
5..9, 11, 13, 15..17: // % |
|
277 |
ClientDataSetInraAfz.Fields[i+1].AsFloat := JvCsvDataSetInput.Fields[i].AsFloat / 100; |
|
278 |
10, 12, 14: // Coef |
|
279 |
ClientDataSetInraAfz.Fields[i+1].AsFloat := JvCsvDataSetInput.Fields[i].AsFloat; |
|
280 |
18: // EB kcal |
|
281 |
ClientDataSetInraAfz.Fields[i+1].AsFloat := JvCsvDataSetInput.Fields[i].AsFloat * CALORIE / 1000; |
|
282 |
19..24: // % |
|
283 |
ClientDataSetInraAfz.Fields[i+1].AsFloat := JvCsvDataSetInput.Fields[i].AsFloat / 100; |
|
284 |
25, 26: // Coef |
|
285 |
ClientDataSetInraAfz.Fields[i+1].AsFloat := JvCsvDataSetInput.Fields[i].AsFloat; |
|
286 |
27..28: // % |
|
287 |
ClientDataSetInraAfz.Fields[i+1].AsFloat := JvCsvDataSetInput.Fields[i].AsFloat / 100; |
|
288 |
29..48: // AA (g/kg MS) -> fraction de MAT |
|
289 |
if JvCsvDataSetInput.Fields[i].AsFloat = 0 |
|
290 |
then |
|
291 |
ClientDataSetInraAfz.Fields[i+1].AsFloat := 0 |
|
292 |
else |
|
293 |
ClientDataSetInraAfz.Fields[i+1].AsFloat := JvCsvDataSetInput.Fields[i].AsFloat / ClientDataSetInraAfzMAT.Value / 1000; |
|
294 |
49..68: // dAA (%) |
|
295 |
ClientDataSetInraAfz.Fields[i+1].AsFloat := JvCsvDataSetInput.Fields[i].AsFloat / 100; |
|
296 |
69..70: // Min (g/kg MS) |
|
297 |
ClientDataSetInraAfz.Fields[i+1].AsFloat := JvCsvDataSetInput.Fields[i].AsFloat / 1000; |
|
298 |
71..72: // dP (%) |
|
299 |
ClientDataSetInraAfz.Fields[i+1].AsFloat := JvCsvDataSetInput.Fields[i].AsFloat / 100; |
|
300 |
73..75: // Min (g/kg MS) |
|
301 |
ClientDataSetInraAfz.Fields[i+1].AsFloat := JvCsvDataSetInput.Fields[i].AsFloat / 1000; |
|
302 |
end; |
|
254 | 303 |
JvCsvDataSetInput.Next; |
255 | 304 |
end; |
256 | 305 |
ClientDataSetInraAfz.First; |
Formats disponibles : Unified diff