1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| procedure Tfm_Add.cxButton_SaveClick(Sender: TObject);
const
sql_chaine : string = 'insert into TB_NUTRITION (CODE_ENFANT, CODE_ALIMENT, HEURE_ENR, PERIODE)' +
' Values (:c_enfant, :c_aliment, :h_heure, :p_periode)';
var
i: Integer;
ch : string;
begin
FDQuery_Nutrition.Active := False;
FDQuery_Nutrition.SQL.Clear;
FDQuery_Nutrition.SQL.Add(sql_chaine);
for i := 0 to cxListView1.Items.Count - 1 do
begin
ch := TRIM(cxListView1.Items[i].SubItems.Text);
// Paramètres
try
FDQuery_Nutrition.ParamByName('c_enfant').AsString :=
FDQuery_Enfant.FieldByName('CODE_ENFANT').AsString;
FDQuery_Nutrition.ParamByName('c_aliment').AsString := ch;
FDQuery_Nutrition.ParamByName('h_heure').AsDateTime := now;
FDQuery_Nutrition.ParamByName('p_periode').AsString :=
RzLEDDisplay1.Caption;
// Exécution
FDQuery_Nutrition.ExecSQL;
except
on E: EFDDBEngineException do
case E.Kind of
ekUKViolated : Format('L''aliment %s a déjà été ajouté pour la période %s',
[cxListView1.Items[i].Caption,
RzLEDDisplay1.Caption]);
end;
end;
end;
end; |