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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
procedure TForm1.DupliquerFiche;
var
i, Numfiche : integer;
ListeChamps, NomColonne : string;
begin
ListeChamps :='';
NomColonne :='';
For i:=1 to DM1.QFicheInter.FieldCount -1 do
// je ne le fais pas commencer à 0 pour ne pas prendre le champ autoincrémenté (clé primaire)
if (DM1.QFicheInter.Fields[i].Value <> null) then
if DM1.QFicheInter.Fields[i].DataType = ftDate then
begin
ListeChamps := ListeChamps + ','+ DateToStr(DM1.QFicheInter.Fields[i].Value);
NomColonne := NomColonne + ','+ DM1.QFicheInter.Fields[i].FieldName;
end
else if DM1.QFicheInter.Fields[i].DataType = ftTime then
begin
ListeChamps := ListeChamps + ','+ TimeToStr(DM1.QFicheInter.Fields[i].Value);
NomColonne := NomColonne + ','+ DM1.QFicheInter.Fields[i].FieldName;
end
else if DM1.QFicheInter.Fields[i].DataType = ftCurrency then
begin
ListeChamps := ListeChamps + ','+ FloatToStr(DM1.QFicheInter.Fields[i].Value);
NomColonne := NomColonne + ','+ DM1.QFicheInter.Fields[i].FieldName;
end
else if DM1.QFicheInter.Fields[i].DataType = ftFloat then
begin
ListeChamps := ListeChamps + ','+ FloatToStr(DM1.QFicheInter.Fields[i].Value);
NomColonne := NomColonne + ','+ DM1.QFicheInter.Fields[i].FieldName;
end
else if DM1.QFicheInter.Fields[i].DataType = ftBoolean then
begin
ListeChamps := ListeChamps + ','+ BoolToStr(DM1.QFicheInter.Fields[i].Value);
NomColonne := NomColonne + ','+ DM1.QFicheInter.Fields[i].FieldName;
end
else if DM1.QFicheInter.Fields[i].DataType = ftSmallint then
begin
ListeChamps := ListeChamps + ','+ IntToStr(DM1.QFicheInter.Fields[i].Value);
NomColonne := NomColonne + ','+ DM1.QFicheInter.Fields[i].FieldName;
end
else if (DM1.QFicheInter.Fields[i].Value <> '') then
begin
ListeChamps := ListeChamps + ','+ DM1.QFicheInter.Fields[i].Value;
NomColonne := NomColonne + ','+ DM1.QFicheInter.Fields[i].FieldName;
end;
Delete(Nomcolonne,1,1);
Delete(ListeChamps,1,1);
DM1.QFicheInter.SQL.Clear;
DM1.QFicheInter.SQL.Add('INSERT INTO TFichesInter.DB ('+ NomColonne +')');
DM1.QFicheInter.SQL.Add('VALUES ('+ ListeChamps +')');
DM1.QFicheInter.ExecSQL; |
Partager